A method for calling user mode functions from kernel mode

A technology for calling functions and kernel mode, applied in the field of Linux kernel, to achieve the effect of satisfying special operations, flexible development, and unified deployment

Active Publication Date: 2022-07-08
FENGHUO COMM SCI & TECH CO LTD +1
View PDF6 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

[0003] Aiming at the limitations existing in the prior art, the present invention proposes a method for calling user-mode functions by kernel-mode functions to solve the problem that kernel-mode functions need to be called by user-mode functions in some cases

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • A method for calling user mode functions from kernel mode
  • A method for calling user mode functions from kernel mode
  • A method for calling user mode functions from kernel mode

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0027] The invention provides a method for invoking user mode functions in kernel mode, which converts the invocation of user mode functions in kernel mode into blocking and waking up of kernel mode threads: realizing parameter encapsulation of called user mode functions in kernel mode, The kernel mode thread is blocked and ioctl message communication is used to complete the user mode function call. When the user mode function returns the call result, the user mode function return result is sent to the kernel mode through ioctl message communication, and then the blocked kernel mode thread is woken up to complete the function. the entire process of calling.

[0028] figure 1 It is a schematic diagram of the method for calling a user mode function in the kernel mode in the embodiment of the present invention, including two parts of the design of the user mode and the kernel mode. The function of the kernel mode is the main part, and the user mode part completes the function by ...

Embodiment 2

[0032] figure 2 is a schematic flowchart of a method for calling a user-mode function in the kernel mode in the embodiment of the present invention, as shown in figure 2 As shown, the method for calling a user mode function in the kernel mode of the present invention includes the following steps:

[0033] S1. Implement the encapsulation function of the original user mode function in the kernel mode. For each user mode function that needs to be called, it is first necessary to implement an encapsulation function with the same prototype as the user mode function in the kernel mode. The name of the state function is used as a parameter, and the parameters of the encapsulation function should also include the parameters passed by the upper-level calling function. In order for user-mode threads to distinguish calls from different kernel-mode threads, the parameters of the encapsulation function should also include the id of the kernel-mode thread. information, and save the param...

Embodiment 3

[0043] The following demonstrates the implementation process of the solution of the present invention with a specific example, such as image 3 and Figure 4 As shown, in this example: the kernel mode thread kprocB calls the user mode function funA, the user mode function funA is implemented in the user mode thread procA, and the prototype of the procA function in the user mode thread is int procA(int arg). The implementation process includes:

[0044] S11. Implement the encapsulation function kfunA of the user mode function funA in the kernel mode (this function is an encapsulation function, and the prototype is the same as the user mode thread procA). The internal implementation of the encapsulation function kfunA is to put the parameters arg and the function name of procA and the thread id of kprocB. into a data structure;

[0045] S12. The kernel state thread kprocB calls the kernel state encapsulation function kfunA to complete the parameter encapsulation in step 1. Afte...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

PUM

No PUM Login to view more

Abstract

The invention discloses a method for invoking a user mode function in a kernel mode, comprising: converting the invocation of the user mode function in the kernel mode into blocking and waking up the kernel mode thread; realizing the parameters of the invoked user mode function in the kernel mode Encapsulation, kernel mode thread blocking, ioctl message communication to complete the user mode function call, when the called user mode function returns the call result, the user mode function return result is sent to the kernel mode through ioctl message communication, and then the blocked kernel mode is woken up The thread, completes the entire process of the function call. The invention realizes the calling of the user state function from the kernel state, and uses the blocking wake-up mode to complete the transparent call from the kernel state to the user state without modifying the logic of the original function without modifying the logic of the original function.

Description

technical field [0001] The invention belongs to the technical field of Linux kernel, and more particularly, relates to a method for calling user mode functions in kernel mode. Background technique [0002] In modern operating systems, for the stability of the system, two execution environments, kernel mode and user mode, are implemented. The two environments have different execution permissions and different address spaces. The core part of the operating system generally runs in the kernel mode, which is used for It completes core functions such as task scheduling, memory management, and hardware management. Most of the application layer functions run in user mode. User mode threads can fall into kernel mode through special system calls to execute kernel functions. The kernel-mode function cannot call the user-mode function interface in turn. For some separately designed systems, such as modules running in kernel mode and user mode at the same time, there is a need to call ...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to view more

Application Information

Patent Timeline
no application Login to view more
Patent Type & Authority Patents(China)
IPC IPC(8): G06F9/48G06F9/54
CPCG06F9/485G06F9/4881G06F9/546G06F2209/548
Inventor 王永强
Owner FENGHUO COMM SCI & TECH CO LTD
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products