A method for inter-process function call and related device
By introducing a first function in user space and directly remotely calling a second function in the physical memory address space of the system service process, the performance overhead caused by IPC in the microkernel architecture is solved, and efficient inter-process function calls and secure isolation are achieved.
Patent Information
- Application Number
- CN202111266347.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-28
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2041-10-28
AI Technical Summary
In microkernel architectures, existing technologies use inter-process communication (IPC) to perform inter-process function calls, which results in data copying and process switching, increasing device performance overhead.
By introducing a first function in user space, a second function in the physical memory address space of the system service process can be directly and remotely called, avoiding process switching and data copying, and using kernel configuration access permissions to ensure security.
It improves the performance of inter-process function calls, reduces security risks, and increases the execution efficiency of the device.
Smart Images

Figure CN116048827B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of computer security isolation, and in particular, to a function calling method between processes and related equipment. BACKGROUND
[0002] The microkernel-based operating system architecture (referred to as microkernel architecture) is widely used in cloud platforms, embedded devices, mobile devices, unmanned vehicles, and the like. The microkernel architecture reduces its true core functions to a very small number, and places many components in the traditional operating system kernel (such as the macrokernel architecture Linux), such as system programs, in user-mode processes to run.
[0003] Currently, the operating system architecture in the industry is mainly divided into microkernel architecture and macrokernel architecture. The microkernel architecture (QNX, seL4, fuchsia, etc.) has the characteristic that the kernel itself is very small, and many system service functions (such as file systems, memory management, networks, drivers, etc.) are placed as separate service processes (referred to as system service processes) in the user mode to run, and the kernel mode only retains critical functions (such as interrupt handling, timer functions, inter-process communication (IPC), memory mapping, etc.). In the microkernel architecture, user processes and system service processes mainly communicate through the IPC mode, thereby achieving the security isolation between processes. For scenarios in which a user process needs to call a function in a system service process, the user process sends the function argument data to the system service process through the IPC mode. In this process, argument data copying is performed, usually twice, the first time being to copy the argument data from the user process to the kernel data segment, and the second time being to copy the argument data from the kernel data segment to the system service process data segment, and then the system service process runs the function according to the argument data.
[0004] However, the above function calling mode based on IPC will increase the overhead with the increase of the amount of incoming data, thereby affecting the device performance. SUMMARY
[0005] Embodiments of the present application provide a function calling method between processes and related equipment, which can improve the efficiency of the first process in executing a function in the system service process.
[0006] The first aspect of the embodiment of the present application provides a function calling method between processes, which can be applied to low-power embedded devices or Internet of Things (IOT) devices, and the like. The method comprises the following steps: a first process triggers a first system call based on a first function, the first function being a function readable and executable by all processes in a user mode, the first function being used to trigger the first system call and call a second function in a first system service process, the first system call being used to instruct a kernel to configure a first access permission of the first process to a physical memory address space of the first system service process, the physical memory address space storing the second function, the second function being a function for implementing a function of the first system service process; the first process receives indication information sent by the kernel in response to the first system call, the indication information being used to indicate whether the first access permission has been enabled; and when it is determined that the indication information is used to indicate that the first access permission has been enabled, the first process executes the second function in the physical memory address space based on the first function.
[0007] In the embodiment of the present application, the first function readable and executable by all processes in the user mode can be used to remotely call the second function stored in the physical memory address space of the first system service process by the first function, so as to execute the second function by the first process. Compared with the process switching and data copying required by the function calling method based on the IPC in the prior art, the second function of the first system service process is called by the first process without process switching and data copying, so that the calling performance of the second function in the first system service process is improved from the mechanism logic level. In addition, the first process is limited to execute the second function by the first function, the scenario in which the first process executes the second function is limited, or it can be understood that the first process must execute the second function in the public area (i.e., the first function readable and executable by all processes). The security risks caused by the unconditional execution of the second function by the user are reduced.
[0008] Optionally, in a possible implementation manner of the first aspect, the first function is further used to trigger a second system call, the second system call being used to instruct the kernel to cancel the first access permission; and after the first process executes the second function, the method further comprises the following steps: the first process triggers the second system call based on the first function, the second system call being used to instruct the kernel to cancel the first access permission.
[0009] In this possible implementation manner, the first access permission can be cancelled after the thread (or task) ends, so as to prevent other threads of the first process from randomly accessing the physical memory address space, and thus the calling safety of the second function is ensured.
[0010] Optionally, in a possible implementation manner of the first aspect, the first access right comprises: read and execute access rights of a code segment in the first system service process and read and write access rights of a data segment in the first system service process; and the first system call is further configured to trigger the kernel to configure the first process with the read and execute access rights of the code segment and the read and write access rights of the data segment. In other words, the first system call is configured to trigger the kernel to set the code segment of the first system service process as readable and executable and set the data segment of the first system service process as readable and writable (or understood as that the physical memory address space of the first system service process is readable and executable for the first process). In addition, in order to ensure the safety of the call of the second function, the code segment of the first process can be configured as non-readable and non-executable.
[0011] In the possible implementation manner, the first process obtains the first access right through the first system call, so as to subsequently call and execute the second function of the first system service process based on the first function.
[0012] Optionally, in a possible implementation manner of the first aspect, before the first process triggers the first system call based on the first function, the method further comprises: the first process obtains a first task, and the first task comprises executing the second function by the first process. The first task can be understood as a thread. The first task can also be understood as a first task determined based on a user operation.
[0013] In the possible implementation manner, the first task is determined based on a user operation, and the second function of the physical memory address space of the first system service process is called and executed based on the first function. In the process of executing the second function, data copying and process switching are avoided, and thus the efficiency of executing the second function is improved.
[0014] Optionally, in a possible implementation manner of the first aspect, the first process is a user process or a second system service process. That is, the first process can be a process corresponding to a user state application program, or the first process is a process corresponding to a second system service program running in a user state, and the first system service process is a process corresponding to a first system service program running in a user state. The first system service process and the second system service process can be system service processes of the same type or system service processes of different types, and the specific types are not limited here.
[0015] In the possible implementation manner, the method can be applied to a scenario in which a process in a user state calls a system service function of a system service process.
[0016] Optionally, in a possible implementation manner of the first aspect, the first system service process integrates at least two subsystem service processes in the user mode, the subsystem service processes are a driver process, a network management process, or a file system management process; the second function is a function in one of the at least two subsystem service processes, the third function is a function readable and executable by all processes in the user mode, and the third function is used to call a function in another of the at least two subsystem service processes; and the first process executes the second function in the physical memory address space based on the first function, including: the first process invokes and executes the third function through the second function, and the first access permission does not change before the first process returns to the first function.
[0017] In the possible implementation manner, for a nested scenario, the first function and the third function are of the same attribute, in the scenario, after the third function is executed, the first function is returned to, and in order to avoid multiple system calls (opening, closing, re-opening, and re-closing of the first access permission), the access permission does not need to be changed in the case that the execution domain (that is, a physical memory address space used by an execution task) does not change in one thread task.
[0018] Optionally, in a possible implementation manner of the first aspect, the method is applied to a microkernel architecture, and the first system service process is a driver process, a network management process, or a file system management process.
[0019] In the possible implementation manner, the method can be applied to a microkernel architecture, and the first process can complete a driver task, a network management task, and / or a file system management task through the first function call.
[0020] Optionally, in a possible implementation manner of the first aspect, the physical memory address space is an address space managed by a memory management unit (MMU), a memory protection unit (MPU), or physical memory protection (PMP) hardware.
[0021] In the possible implementation manner, the method can be applied to a small embedded device based on an MPU / PMP, and because the process and data copying do not need to be switched in the execution of a thread task, the performance of the small embedded device is improved.
[0022] Optionally, in a possible implementation manner of the first aspect, the computer device is an Internet of Things (IOT) device.
[0023] In the possible implementation, the method can be applied to an IOT device, and since process switching and data copying are not needed in executing a thread task, the performance of the IOT device is improved.
[0024] The second aspect of the embodiments of the present application provides a function calling method between processes. The method can be applied to low-power embedded devices or IOT devices, and the method comprises the following steps: a kernel configures, in response to a first system call triggered by a first process, a first access permission of the first process to a physical memory address space of a first system service process, the physical memory address space storing a second function, the second function being a function for implementing a function of the first system service process, and the first system call being used to instruct the kernel to configure the first access permission; and the kernel sends, to the first process, indication information, the indication information being used to indicate whether the first access permission has been enabled, and the first access permission being used for the first process to execute the second function in the physical memory address space.
[0025] In the embodiments of the present application, the kernel can configure the first access permission in response to the system call triggered by the first process, and indicate that the first access permission has been enabled by sending the indication information, so that the first process can call and execute the second function stored in the physical memory address space of the first system service process through the first access permission. Compared with the prior art, the first process in the embodiments of the present application does not need to perform process switching and data copying when calling the second function of the first system service process, and the calling performance of the second function in the first system service process is improved from the mechanism logic level.
[0026] Optionally, in a possible implementation of the second aspect, the step of configuring the first access permission of the first process to the physical memory address space of the first system service process comprises the following steps: when it is determined that the first process has a second access permission and the first access permission is not enabled, the kernel configures the first access permission, and the indication information is specifically used to indicate that the first access permission has been enabled, and the second access permission is a permission for calling the second function.
[0027] In the possible implementation, the kernel judges whether the first process has the permission for calling the second function (i.e., the second access permission) before configuring the first access permission of the first process, and only when the first process has the second access permission, the kernel configures the first access permission, so that the process without the second access permission cannot call the second function, and the security of the system or the first system service process is ensured.
[0028] Optionally, in a possible implementation of the second aspect, the method further comprises the following steps: the kernel cancels the first access permission in response to a second system call triggered by the first process, and the second system call is used to instruct the kernel to cancel the first access permission.
[0029] In a possible implementation manner of the method, the first access permission can be canceled after the thread (or task) ends, so as to prevent other threads of the first process from randomly accessing the physical memory address space, and thus the safety of the calling of the second function is ensured.
[0030] Optionally, in a possible implementation manner of the second aspect, the first access permission includes: read and execution permissions of a code segment in the first system service process and read and write permissions of a data segment in the first system service process; and the first system call is further used to trigger the kernel to configure the read and execution permissions of the code segment in the first process and the read and write permissions of the data segment in the first process.
[0031] In a possible implementation manner, the first process obtains the first access permission through the first system call, so as to facilitate the subsequent calling and execution of the second function by the first process.
[0032] Optionally, in a possible implementation manner of the second aspect, the first process is a user process or a second system service process.
[0033] In a possible implementation manner, the method can be applied to a scenario in which a process in a user state calls a system service function in a system service process.
[0034] Optionally, in a possible implementation manner of the second aspect, the first system service process integrates at least two subsystem service processes in the user state, and the subsystem service process is a driver process, a network management process or a file system management process; when it is determined that the first process has the second access permission and the first access permission is enabled, the indication information is used to indicate that the first access permission is enabled, and the first function is instructed not to enable the second system call, the first function is a function that can be read and executed by all processes in the user state, and the first function is used to trigger the first system call, call the second function and trigger the second system call, and the second system call is used to instruct the kernel to cancel the first access permission.
[0035] In a possible implementation manner, for a nested scenario, the first function and the third function are of the same attribute, and in this scenario, the indication information sent by the kernel to the first process can also be used to instruct the first function not to enable the second system call, that is, in a thread task, in order to avoid multiple system calls (opening, closing, re-opening and re-closing of the first access permission), the access permission can not be changed in the case that the execution domain (that is, the physical memory address space used by the execution task) does not change.
[0036] Optionally, in a possible implementation manner of the second aspect, the method is applied to a microkernel architecture, and the first system service process is a driver process, a network management process or a file system management process.
[0037] In a possible implementation of the method, the method can be applied to a microkernel architecture, and the first process can complete a driver task, a network management task, and / or a file system management task through the first function call.
[0038] Optionally, in a possible implementation of the second aspect, the physical memory address space is an address space managed by a memory management unit (MMU), a memory protection unit (MPU), or a physical address protection (PMP) hardware.
[0039] In a possible implementation of the method, the method can be applied to a small embedded device based on MPU / PMP, and because the process switching and data copying are not needed in the execution of the thread task, the performance of the small embedded device is improved.
[0040] Optionally, in a possible implementation of the second aspect, the computer device is an Internet of Things (IOT) device.
[0041] In a possible implementation of the method, the method can be applied to an IOT device, and because the process switching and data copying are not needed in the execution of the thread task, the performance of the IOT device is improved.
[0042] The third aspect of the present application provides a computer device, which comprises: a triggering unit configured to trigger a first system call based on a first function, the first function being a function readable and executable by all processes in a user mode, the first function being configured to trigger the first system call and a second function in a first system service process, the first system call being configured to instruct a kernel to configure a first process with a first access permission to a physical memory address space of the first system service process, the physical memory address space storing the second function, the second function being a function for implementing a function of the first system service process; a receiving unit configured to receive indication information sent by the kernel in response to the first system call, the indication information being configured to indicate whether the first access permission has been enabled; and an execution unit configured to, when it is determined that the indication information indicates that the first access permission has been enabled, execute the second function in the physical memory address space based on the first function.
[0043] Optionally, in a possible implementation of the third aspect, the first function is further configured to trigger a second system call, the second system call being configured to instruct the kernel to cancel the first access permission; and the triggering unit is further configured to trigger the second system call based on the first function, the second system call being configured to instruct the kernel to cancel the first access permission.
[0044] Optionally, in a possible implementation manner of the third aspect, the first access permission comprises: read and execute permissions of a code segment in the first system service process and read and write permissions of a data segment in the first system service process; and the first system call is further used to trigger the kernel to configure the first process with the read and execute permissions of the code segment and the read and write permissions of the data segment.
[0045] Optionally, in a possible implementation manner of the third aspect, the computer device further comprises an obtaining unit, configured to obtain the first task, the first task comprising execution of the second function by the first process.
[0046] Optionally, in a possible implementation manner of the third aspect, the first process is a user process or a second system service process.
[0047] Optionally, in a possible implementation manner of the third aspect, the first system service process integrates at least two subsystem service processes in a user mode, the subsystem service processes being a driver process, a network management process or a file system management process; the second function is a function in one of the at least two subsystem service processes, the third function is a function readable and executable by all processes in the user mode, the third function being used to call a function in another of the at least two subsystem service processes; and the execution unit is specifically configured to call and execute the third function through the second function, and the first access permission is unchanged before the first process returns the first function.
[0048] Optionally, in a possible implementation manner of the third aspect, the computer device adopts a micro-kernel architecture, and the first system service process is a driver process, a network management process or a file system management process.
[0049] Optionally, in a possible implementation manner of the third aspect, the physical memory address space is an address space managed by a memory management unit (MMU), a memory protection unit (MPU) or a physical address protection (PMP) hardware.
[0050] Optionally, in a possible implementation manner of the third aspect, the computer device is an Internet of Things (IOT) device.
[0051] The fourth aspect of the present application provides a computer device, comprising: a configuration unit, configured to configure, in response to a first system call triggered by a first process, a first access right of the first process to a physical memory address space of a first system service process, the physical memory address space storing a second function, the second function being a function for implementing a function of the first system service process, the first system call being used to instruct a kernel to configure the first access right; and a sending unit, configured to send, to the first process, indication information used to indicate whether the first access right has been enabled, the first access right being used by the first process to execute the second function in the physical memory address space.
[0052] Optionally, in a possible implementation manner of the fourth aspect, the configuration unit is specifically configured to configure the first access right when it is determined that the first process has a second access right and the first access right is not enabled, and the indication information is specifically used to indicate that the first access right has been enabled, the second access right being a right for calling the second function.
[0053] Optionally, in a possible implementation manner of the fourth aspect, the configuration unit is further configured to cancel the first access right in response to a second system call triggered by the first process, the second system call being used to instruct the kernel to cancel the first access right.
[0054] Optionally, in a possible implementation manner of the fourth aspect, the access right comprises a read and execute right of a code segment in the first system service process and a read and write right of a data segment in the first system service process, and the first system call is further used to trigger the kernel to configure a read and execute right of the code segment in the first process and a read and write right of the data segment in the first process.
[0055] Optionally, in a possible implementation manner of the fourth aspect, the process is a user process or a second system service process.
[0056] Optionally, in a possible implementation manner of the fourth aspect, the system service process integrates at least two subsystem service processes in a user mode, the subsystem service process being a driver process, a network management process or a file system management process; when it is determined that the first process has the second access right and the first access right has been enabled, the indication information is used to indicate that the first access right has been enabled, and the first function is instructed not to enable the second system call, the first function being a function that can be read and executed by all processes in the user mode, the first function being used to trigger the first system call, call the second function and trigger the second system call, the second system call being used to instruct the kernel to cancel the first access right.
[0057] Optionally, in a possible implementation manner of the fourth aspect, the computer device adopts a microkernel architecture, and the first system service process is a driver process, a network management process or a file system management process.
[0058] Optionally, in a possible implementation manner of the fourth aspect, the physical memory address space is an address space managed by a memory management unit (MMU), a memory protection unit (MPU), or a physical address protection (PMP) hardware.
[0059] Optionally, in a possible implementation manner of the fourth aspect, the computer device is an Internet of Things (IOT) device.
[0060] The fifth aspect of the present application provides a computer device, which executes the method in the first aspect or any possible implementation manner of the first aspect, or executes the method in the second aspect or any possible implementation manner of the second aspect.
[0061] The sixth aspect of the present application provides a computer device, comprising: a processor coupled with a memory, the memory being configured to store programs or instructions, when the programs or instructions are executed by the processor, the computer device is caused to implement the method in the first aspect or any possible implementation manner of the first aspect, or the computer device is caused to implement the method in the second aspect or any possible implementation manner of the second aspect.
[0062] The seventh aspect of the present application provides a communication system architecture, comprising the first process in the first aspect or any possible implementation manner of the first aspect, and / or the kernel in the second aspect or any possible implementation manner of the second aspect.
[0063] The eighth aspect of the present application provides a computer readable medium, which stores computer programs or instructions, when the computer programs or instructions are executed on a computer, the computer is caused to execute the method in the first aspect or any possible implementation manner of the first aspect, or the computer is caused to execute the method in the second aspect or any possible implementation manner of the second aspect.
[0064] The ninth aspect of the present application provides a computer program product, when the computer program product is executed on a computer, the computer is caused to execute the method in the first aspect or any possible implementation manner of the first aspect, the second aspect or any possible implementation manner of the second aspect.
[0065] The technical effects brought by the third, fifth, sixth, seventh, eighth aspects or any possible implementation manner thereof can be referred to the technical effects brought by the first aspect or different possible implementation manners of the first aspect, which will not be repeated here.
[0066] The technical effects brought by the fourth, fifth, sixth, seventh, eighth aspects or any possible implementation manner thereof can be referred to the technical effects brought by the second aspect or different possible implementation manners of the second aspect, which will not be repeated here.
[0067] From the above technical solutions, the embodiments of the present application have the following advantages: through the first function readable and executable by all processes in the user mode, the first process can remotely call the second function stored in the physical memory address space of the first system service process through the first function, and then the first process executes the second function. Compared with the prior art based on the IPC function calling mode, the first process calling the second function of the first system service process in the embodiments of the present application does not need to perform context switching and data copying, which improves the calling performance of the second function in the first system service process from the mechanism logic level. In addition, the first process is limited to execute the second function through the first function, which limits the scenario of the first process executing the second function, or is understood as limiting the first process to execute the second function in the public area (i.e., storing the first function readable and executable by all processes). This reduces the security risks caused by the unconditional execution of the second function by the user. BRIEF DESCRIPTION OF DRAWINGS
[0068] Figure 1 A structural schematic diagram of a microkernel architecture provided for the embodiments of the present application;
[0069] Figure 2 A structural schematic diagram of a system architecture provided for the embodiments of the present application;
[0070] Figure 3 A flowchart of a function calling method between processes provided for the embodiments of the present application;
[0071] Figure 4 Various situation diagrams of indication information provided for the embodiments of the present application;
[0072] Figure 5 A flowchart of a design stage provided for the embodiments of the present application;
[0073] Figure 6 Another flowchart of a design stage provided for the embodiments of the present application;
[0074] Figures 7 to 9 Several structural schematic diagrams of computer devices provided for the embodiments of the present application. DETAILED DESCRIPTION
[0075] The embodiments of the present application provide a function calling method between processes and related devices, which can improve the efficiency of the first process executing the function in the system service process.
[0076] The embodiments of the present application are described below with reference to the drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments. Those skilled in the art can know that with the development of technology and the emergence of new scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems. In the description of the embodiments of the present application, unless otherwise specified, " / " represents the meaning of or, for example, A / B can represent A or B; "and / or" in this paper is only a description of the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which means that there are three cases of A alone, A and B together, and B alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0077] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with "first" and "second" can explicitly or implicitly include one or more features. In the description of the embodiments, unless otherwise specified, the meaning of "multiple" is two or more than two.
[0078] In order to facilitate understanding of the technical solutions provided by the present application, some concepts are introduced as follows.
[0079] 1. Microkernel and macrokernel
[0080] Microkernel: A kind of operating system kernel architecture, represented by QNX, seL4, fuchsia, etc., by running most system services in the form of independent processes in user mode, realizing the "minimization" of the kernel itself.
[0081] Macrokernel: A kind of operating system kernel architecture, represented by Linux, Unix, etc., by concentrating all system service functions in the kernel, realizing a large and complete "macro" kernel.
[0082] 2. Program and process
[0083] Program is a collection of instructions and data, which can be saved as a target file on a disk or stored as a segment in a memory address space. Process is the running entity of the program. Or, program is the description of instructions, data and their organization form, and process is the running entity of the program. Multiple threads can be concurrent in a process, and each thread executes different tasks in parallel. Thread can be the actual operating unit of process, and different threads in a process are distinguished in switching state. For example, thread X of process A is in "switched" state, and thread Y under the same process can be in "non-switched" state or "switched" state. Or, it can be understood that the embodiments of the present application describe the first task from the perspective of process.
[0084] System programs refer to a collection of various programs that control and coordinate computer devices and external devices, support application software development and operation, and do not require user intervention.
[0085] Application programs are the counterpart of system software and are a collection of various programming languages that users can use and programs written in various programming languages. They are divided into application software packages and user programs.
[0086] 3、Memory protection unit (MPU) and physical memory protection (PMP)
[0087] MPU is a kind of effective protection system resource hardware equipped in ARM, which provides memory area protection function. MPU allows privileged software (such as operating system) to define regions in memory and assign access permissions and attributes to these regions. MPU monitors transactions between central processing unit (CPU) and memory, and issues an alert (trigger fault exception) when it detects access violations. The main purpose of MPU is to prevent programs from accessing memory that has not been allocated to it. This can prevent innocent errors in ordinary programs or malicious software programs from affecting other processes or the operating system itself.
[0088] The functions of PMP and MPU are the same, and MPU is called ARM architecture, and PMP is called risc-V architecture.
[0089] 4、Memory management unit (MMU)
[0090] MMU is mainly used to manage virtual memory and physical memory control lines, and is also responsible for virtual address mapping to physical address, as well as providing hardware mechanism for memory access authorization and multi-task multi-process operating system.
[0091] MMU is a more powerful memory protection mechanism than MPU, which only provides memory region protection. MMU provides virtual address mapping technology on this basis, and in operation, MMU is more complex than MPU.
[0092] 5、System call
[0093] The collection of all system calls provided by the operating system implementation is called program interface or application programming interface (API). It is the interface between application programs and the system, and can also be understood as the interface provided by the kernel to user processes.
[0094] 6. Kernel mode and user mode
[0095] Kernel mode and user mode are two operating states of the central processing unit (CPU). If a process executes a system call and thus kernel code, it is said to be in kernel mode; if a process executes user code, it is said to be in user mode. Kernel mode can also be called privileged mode, and user mode can also be called non-privileged mode. The following text will use the terms kernel mode and user mode consistently.
[0096] Specifically, in the ARM architecture, EL0 represents user mode and EL1 represents kernel mode; while in the x86 architecture, ring3 represents user mode and ring0 represents kernel mode.
[0097] like Figure 1 As shown, in existing microkernel architectures, applications and system programs run as independent processes in user mode, while the kernel runs in kernel mode. Applications need to access system programs through the kernel. Because applications and system programs are isolated from each other, system programs cannot access the physical memory address space of applications, resulting in lower performance of microkernel architectures.
[0098] In a microkernel architecture, user processes and system service processes primarily communicate via Inter-Process Communication (IPC) to achieve secure isolation between processes. When a user process needs to call a function in a system service process, the user process sends the function's input parameters to the system service process via IPC. This process involves copying the input parameters, typically twice: first, from the user process to the kernel data segment, and second, from the kernel data segment to the system service process's data segment. The system service process then executes the function based on this input parameter data.
[0099] However, the above-mentioned method of calling functions based on IPC will increase the overhead as the amount of incoming data increases, thereby affecting device performance.
[0100] To address the aforementioned issues, this application provides an inter-process function call method. Through a first function readable and executable by all processes in user space, a first process can remotely call a second function stored in the physical memory address space of a first system service process, thereby enabling the first process to execute the second function. Compared to the context switching and data copying involved in prior art based on IPC function calls, the embodiments of this application eliminate the need for process switching, context switching, and data copying when calling the second function of the first system service process, thus improving the function call performance of the first system service process from a logical mechanism perspective.
[0101] Firstly, the system architecture provided by the embodiment of the present application is described as shown in the following table. Figure 2 The system architecture provided by the embodiment of the present application includes a first process, a first system service process, a user space public area, a kernel and hardware.
[0102] The first process includes a code segment and a data segment, and the first system service process includes a code segment and a data segment. The data segment can be understood as a concept corresponding to the code segment. The data segment is usually a data segment, a data read-only segment and a block started by symbol (BSS) segment. The data read-only segment is used to store initialized (non-0) global variables and static local variables in the program (the first program or the first system service program). The starting position of the data segment is confirmed by a link positioning file, and the size is automatically allocated during compilation and linking. The BSS segment usually refers to a block of memory regions used to store uninitialized global variables and static variables in the program. The code segment is mapped as read-only and executable in the memory. It is automatically calculated by the compiler during compilation and linking. It is usually used to store instructions for executing the program (the first program or the first system service program).
[0103] The first process in the embodiment of the present application can be a user process or a second system service process. The first system service process and the second system process can include a driver process, a network management process, a file system management process or a memory management process, etc., and the specific types are not limited here. Further, the types (for example: driver, network management and file system management) of the first system service process and the second system service process can be the same or different. For example, the first system service process and the second system service process can both be driver processes. For another example, the first system service process is a network management process, and the second system service process is a driver process.
[0104] The user space public area refers to a region that can be read and executed by all processes in the user space. The user space public area includes a first system service process call entry function module, a system call entry function module and a public function library module. The first system service process call entry function module is used to store the call entry function corresponding to the first system service process. The call entry function is used to call the system to indicate the kernel to configure or cancel the access permission of the first process to the physical memory address space of the first system service process, and is also used to call the system service function stored in the physical memory address space in the first system service process. The public function library module is used to provide common functions to the user space process. For example, the public function library includes at least one of the libc library (such as glibc, musl libc library) or the posix library.
[0105] The kernel refers to the core of the operating system, which is used to manage system resources. The user state system service management module in the kernel is mainly used to configure the access permission of the physical memory address space of the first system service process based on the current state of the first system service process. The permission of the physical memory address space of the first system service process is switched (i.e., switched between opening the access permission and closing the access permission) based on the permission of the first process.
[0106] The hardware includes a CPU and a memory protection unit (MPU / PMP). The memory protection unit is mainly used to set the ability of the physical memory to be read and written. Alternatively, it can be understood as setting the access permission of the physical memory address space. The memory protection unit can also be a reduced-function MMU, which is not limited here. In addition, if the first system service process is a driver process, the hardware can also include an input / output (I / O) memory area, which refers to the memory area corresponding to the input / output device.
[0107] Optionally, a type of system service is located in one system service process. Taking the case that the first system service process is a driver process as an example, the driver process can include one or more drivers, or can include the code of all user state drivers. For the case where the driver process includes one driver, it can be understood that the system architecture is a microkernel system architecture. In addition, part of the driver system service can be in the user state driver process, and another part of the driver system service can be in the kernel. In this case, it can be understood as a hybrid kernel system architecture. For example, the driver system service includes a USB driver, a serial port driver, and a network driver. The USB driver and the serial port driver can be embodied in the form of a process in the user state, and the network driver can be placed in the system management of the kernel. It can be understood that the exemplary description here takes three drivers included in the driver system service as an example. Of course, in this case, when the first process is the second system service process, since a type of system service is located in one system service process, the second system service process and the first system service process belong to different types of system service processes.
[0108] Because of the protection and limitation of the memory protection unit on the first system service process, the first process cannot directly call the functions in the first system service process and access the data in the first system service process. The system call entry function is introduced in the embodiment of the application. After the user state system service management module in the kernel performs the permission switching, the first process can remotely call the system service function in the first system service process and execute it.
[0109] In the communication architecture provided by the embodiments of the present application, the communication architecture can be applied to platforms of Intel architecture, ARM architecture, AARCH64 architecture, Risc-V architecture, and the like. For a chip supporting a memory protection unit (MPU / PMP) and supporting a user mode and a kernel mode in the architecture, the advantages described below are more obvious. In addition, the architecture is also applicable to small operating systems running based on a real address.
[0110] In one aspect, the first process can execute a system service function in the first system service process by remotely calling an entry function, thereby reducing the additional overhead caused by process switching or data copying in the prior art. In another aspect, since the entry function for remote calling is located in the user mode common area and can be read and executed by all processes in the user mode, it is ensured that when the entry function is called, the processing exception caused by the code segment in the user process being unreadable due to the system call is avoided. In another aspect, the system management module in the kernel can configure the access permission of the physical memory address space of the first system service process, thereby ensuring the security isolation of the first process and the first system service process.
[0111] The function calling method between processes provided by the embodiments of the present application will be described in detail below in combination with the system architecture and the accompanying drawings. Figure 2
[0112] Please refer to Figure 3 In one embodiment of the function calling method between processes provided by the embodiments of the present application, the method can be applied to a computer device, and can also be applied to a component (such as a processor, a chip, or a chip system, etc.) of the computer device. The embodiment includes steps 301 to 306.
[0113] In this embodiment, the computer device can be a terminal device for serving users or a cloud device. The terminal device can be an Internet of Things (IoT) device, such as a head-mounted display (HMD), which can be a combination of a virtual reality (VR) box and a terminal, a VR all-in-one machine, a personal computer (PC), an augmented reality (AR) device, a mixed reality (MR) device, etc. The terminal device can also include a smartphone, a personal digital assistant (PDA), a tablet computer, a laptop computer, a personal computer (PC), an in-vehicle terminal, headphones, a smartwatch, instruments, a camera, etc., and the specifics are not limited here.
[0114] Step 301: The first process triggers the first system call based on the first function.
[0115] In this embodiment, the first process can be either a user process or a second system service process; no specific limitation is made here. The relationship between the first system service process and the second system service process can be referred to the foregoing. Figure 2 The description of the architecture shown will not be repeated here.
[0116] The first function in this embodiment can be stored in... Figure 2 The user-space system service process in the illustrated architecture can call the entry function module, or it can be stored in a readable and executable area of all processes in user space. Alternatively, it can be understood as a function that is readable and executable by all processes in user space. This first function is used to trigger a first system call and call a second function in the first system service process. The first system call instructs the kernel to configure the first process to access the first system service process's physical memory address space, which stores the second function. This second function is the function that implements the functionality of the first system service process.
[0117] Optionally, the first system call instructs the kernel to configure the code and data segments of the first system process as readable, writable, and executable (i.e., first access permissions). Additionally, to ensure the security of subsequent calls to the second function, the data segment of the first process is configured as readable and writable, while the code segment is configured as neither readable nor executable.
[0118] Optionally, the first function is written by a developer of the first system service process. Further, the developer of the first process has read and executable permissions on the first function, but not development permissions. In other words, only the developer of the first system service process in which the system service function is located has development permissions on the first function.
[0119] Since the first process cannot directly modify the first access permissions of the physical memory address space by modifying the registers of the memory protection unit, but the kernel can modify the first access permissions of the physical memory address space by the memory protection unit, the first process can complete the configuration of the first access permissions through the first system call of the first function.
[0120] Optionally, if the first process is a user process, the first function can also be understood as a function called by an application function in the first process. The first process triggers the first system call based on the first function, which can be understood as the first process executing an application function in the first process, which calls the first function to trigger the first system call.
[0121] Optionally, the first process obtains a first task input by a user, and the first task is to execute the second function by the first process. After the first process obtains the first task, the application function corresponding to the first task in the first process calls the first function, and after entering the first function, the first system call is called first.
[0122] Step 302, the kernel configures the first access permissions of the first process to the physical memory address space of the first system service process in response to the first system call.
[0123] After the user process triggers the first system call, since the first system call is used to instruct the kernel to configure the first access permissions of the first process to access the physical memory address space of the first system service process, the kernel configures the first access permissions in response to the first system call. The first access permissions can include: the code segment and the data segment in the first system process are configured as read-write-executable permissions.
[0124] Optionally, the kernel configuring the first access permissions can include: the kernel can set the code segment of the first system service process as readable and executable, and set the data segment of the first system service process as readable and writable. In addition, in order to ensure the safety of the call of the second function, the code segment of the first process can be configured as non-readable and non-executable.
[0125] Optionally, if the first system service process is a driver process, the kernel can also configure the I / O memory area corresponding to the driver process in the memory protection unit as a read-write state, thereby facilitating the access of the external device. Figure 2
[0126] Optionally, in order to ensure the security of the system, after the user process triggers the first system call, the kernel can authenticate the first process (i.e., determine whether the second access right exists). If the first process has the second access right and the first access right is not enabled, the kernel configures the first access right. The second access right can be understood as the calling right of the second function set by the developer of the first system service process in the design stage.
[0127] Optionally, the authentication basis can be 32-bit information set by the third developer, each bit of the information indicating whether different processes have the second access right, 1 indicating that the second access right exists and 0 indicating that the second access right does not exist.
[0128] In step 303, the kernel sends the indication information to the first process. Correspondingly, the first process receives the indication information sent by the kernel.
[0129] After the kernel configures the first access right of the first process to the physical memory address space of the first system service process, the kernel can send the indication information to the first process. The indication information can be in various forms, which are described as follows.
[0130] The first kind: the indication information is used to indicate that the first access right is enabled.
[0131] This mode can be understood as that the kernel has configured the first access right. The timing of the configuration can be after the first system call is received or before the first system call is received, which is not limited here. If the indication information is used to indicate that the first access right is enabled, step 304 is performed.
[0132] Optionally, this mode can also be understood as that the first process has the second access right and the kernel has enabled the first access right. In this case, the indication information is used to indicate that the first access right is enabled.
[0133] In addition, if the timing of configuring the first access permission is before the first process triggers the first system call, the indication information can be used to indicate that the first function does not enable the second system call in addition to indicating that the first access permission has been enabled. This mode is applied to the case where the first system service process integrates at least two subsystem service processes (driver process, network management process, or file system management process, etc.), that is, the second function has a third function nested therein, the third function has the same attribute as the first function (for example, the third function is also a function that can be read and executed by all processes in the user mode, and the third function is used to trigger the first system call and the second system call), and before returning to the first function after the execution of the third function ends, the first access permission does not need to be cancelled because the execution of the second function still needs the first access permission. By using the indication information to indicate that the first function does not enable the second system call, repeated enabling and disabling of the first access permission is avoided. It can also be understood that the first access permission does not change before the first process returns to the first function.
[0134] The above can also be understood as follows: in the nested scenario, after the execution of the third function, since it is necessary to return to the first function, in order to avoid multiple system calls (opening, closing, re-opening, and re-closing of the first access permission), in the case where the execution domain (i.e., the physical memory address space used for execution tasks) does not change in one thread task, the first access permission can not need to be changed.
[0135] Or it can be understood that in the scenario where there are nested functions (i.e., one function includes another function) and the nested functions are in the same physical memory address space, the calling of the system call twice (once to enable the access permission and once to cancel the access permission) before and after the execution of one function is avoided, which saves the energy consumption caused by multiple system calls on the one hand. On the other hand, the execution efficiency of the nested function is improved.
[0136] The second mode is that the indication information is used to indicate that the first access permission has not been enabled.
[0137] In this mode, it can be understood that the kernel does not configure the first access permission. If the indication information is used to indicate that the first access permission has not been enabled, the first function is returned.
[0138] Alternatively, this mode can also be understood as follows: if the first process does not have the second access permission (which can be referred to in the foregoing description and will not be described herein), the indication information is used to indicate that the first access permission has not been enabled, or the first process does not have the second access permission.
[0139] Alternatively, the indication information in this step can be in multiple cases, which can be referred to in the foregoing description. Figure 4The instruction information includes the first and second scenarios mentioned above. The second scenario can be further divided into two sub-scenarios: one sub-scenarios is that the first access permission has been enabled and a first function call followed by a second system call is required (or, in other words, permissions need to be disabled). The other sub-scenarios is that permissions have been enabled and a first function call followed by a second system call is not required (or, in other words, the nested functions mentioned earlier, where permissions do not need to be disabled).
[0140] Step 304: When it is determined that the indication information is used to indicate that the first access permission has been enabled, the first process executes the second function in the physical memory address space based on the first function.
[0141] When the indication information is determined to indicate that the first access permission has been enabled, that is, the first process has the permission to access the physical memory address space of the first system service process, the first process can execute the second function stored in the physical memory address space of the first system service process based on the first function. The second function is a function that implements the functions of the first system service process.
[0142] This step can also be understood as follows: after the first system call ends, it returns to the first function. And since the first process has the first access permission, it jumps to the second function and executes.
[0143] Optionally, the execution of the second function by the first process can be understood as the execution of the first task by the first process, which includes the execution of the second function by the first process, or the first task needs to be completed by executing the second function.
[0144] Optionally, if the first process is a user process and the first system service process is a network management process, then the second function is used to receive / send network data. If the first process is a user process and the first system service process is a file system management process, then the second function is used to read and write files. If the first process is a user process and the first system service process is a driver process, then the second function is used to support I / O devices.
[0145] Step 305: The first process triggers a second system call based on the first function. This step is optional.
[0146] Optionally, after the first process executes the second function, it can trigger a second system call based on the first function. This second system call is used to instruct the kernel to revoke the first access permission.
[0147] This step can also be understood as the second function returning to the first function after execution, and then triggering the second system call.
[0148] Step 306: The kernel responds to the second system call and revokes the first access permission. This step is optional.
[0149] After the first process triggers the second system call, the kernel responds to the second system call and cancels the first access permission.
[0150] Optionally, if the first system call triggers the kernel to configure the first access permission specifically comprises: the kernel can set the code segment and the data segment of the first system service process as readable and writable and executable, set the data segment of the first process as readable and writable, and set the code segment of the first process as readable and non-executable. The second system call is used to cancel the first access permission. Alternatively, it is understood as setting the code segment and the data segment in the first system process as non-readable, non-writable and non-executable. Further, the data segment in the first process can be set as readable and writable, and the code segment in the first process can be set as readable and executable.
[0151] Optionally, after the second system call is completed, the first function is returned. Further, if the first process is a user process, the application function for calling the first function is returned.
[0152] In a possible implementation manner, the function calling method between processes provided by the embodiment of the present application can comprise steps 301 to 304. In another possible implementation manner, the function calling method between processes provided by the embodiment of the present application can comprise steps 301 to 306.
[0153] Optionally, before the embodiment shown in Figure 3 is executed, it can be determined whether the first task acquired by the user process satisfies a first condition. If the first condition is satisfied, the embodiment shown in Figure 3 is executed. The first condition can be understood as whether the first task is in the first process. If yes, the embodiment shown in Figure 3 is executed. If the first task is in a system service process in the kernel mode or the user mode, the kernel sends the indication information to the first process as in the first case in step 303. The indication information is used to indicate that the access permission has been started, and is also used to indicate that the first function does not enable the second system call. In other words, the process in which the task is located itself has the access permission to the physical memory address space, and it is not necessary to waste the overhead caused by the system call.
[0154] In this embodiment, a first function, readable and executable by all processes in user space, enables the first process to remotely call a second function stored in the physical memory address space of the first system service process, thereby allowing the first process to execute the second function. Compared to existing technologies that require context switching and data copying when calling functions via IPC, this embodiment eliminates the need for context switching and data copying when calling the second function of the first system service process, thus improving the performance of function calls from the mechanism logic level. Furthermore, in scenarios with nested functions (i.e., one function containing another) within the same physical memory address space, this avoids the need for two system calls (one to enable access and one to disable access) before and after each function execution, saving energy consumption caused by multiple system calls and improving the execution efficiency of nested functions. Additionally, it restricts the execution of the second function to the first process through the first function, limiting the scenario in which the first process executes the second function, or in other words, restricting the execution of the second function to the public area (i.e., storing the first function, readable and executable by all processes). This reduces the security risks associated with users unconditionally executing the second function.
[0155] In addition, during the design phase, it can be done through Figure 5 The following steps enable the first process to remotely call the second function stored in the physical memory address space of the system service process via the first function.
[0156] Step 501: Compile the code for the operating system, the first process, the public function library, and the first system service process.
[0157] The description of the first process in this embodiment can be found in the foregoing. Figure 3 The descriptions in the illustrated embodiments will not be repeated here. This embodiment is only used as an example where the first process is a user process.
[0158] The process involves the first developer compiling the operating system code, the second developer compiling the first process code, the third developer compiling the first system service process code, and the fourth developer compiling the common function library code. Furthermore, the remote call entry point function library within the common function library is designed by the third developer corresponding to the first system service process; or it can be understood as the entry point provided by the third developer to the first process for calling second functions.
[0159] Optionally, a third developer develops the code for the remote call entry function and compiles and links the first function into the system's public function library. Furthermore, to ensure security isolation, each process is developed by its own developer, but a unified code template is used to facilitate standardized function calling across processes.
[0160] The compiling in the embodiments of the present application refers to converting a file into a binary file. The linking refers to putting various code segments together, putting various data segments together, or being understood as the integration process of the code segments or the data segments. The compiling and linking can isolate the first process, the first system service process and the kernel from each other. If a type of system service is embodied in the form of a process, for example, all drivers are embodied in the form of a driver process, the various drivers in the driver process are not isolated from each other.
[0161] In step 502, the code segments and the data segments of the operating system are linked to the first address space of the memory.
[0162] The first developer links the code segments and the data segments of the operating system to the first address space of the memory.
[0163] Further, the address spaces (the first address space, the second address space, the third address space and the fourth address space) in the embodiments of the present application include a code area and a data area, wherein the code area is used for storing the code segments, and the data area is used for storing the data segments. Or it can be understood that the code segments and the data segments are separated in the address spaces.
[0164] In step 503, the code segments and the data segments of the first process are linked to the second address space of the memory.
[0165] The second developer links the code segments and the data segments of the first process to the second address space of the memory.
[0166] In step 504, the code of the public function library is linked to the third address space of the memory.
[0167] The fourth developer links the code of the public function library to the third address space of the memory. The third developer compiles and links the remote call entry function corresponding to the first system service process to the public function library.
[0168] In step 505, the code segments and the data segments of the first system service process are linked to the fourth address space of the memory.
[0169] The third developer links the code segments and the data segments of the first system service process to the fourth address space of the memory.
[0170] Optionally, the third developer can specify which processes have the permission to call the remote call entry function (i.e., the second access permission) when developing the first system service process, and the permission cannot be modified in the process of running the first system service process. Further, it is ensured that the processes with the second access permission can be authenticated successfully in the embodiments shown in the drawings. Figure 3 Figure 3
[0171] Optionally, the third developer may use 32 bits of information to indicate whether each process has second access rights, with 1 indicating accessibility and 0 indicating inaccessibility.
[0172] In this embodiment, the developers may be the same or different. For example, an application (APP) and its driver produced by a single manufacturer may be developed and designed by a single developer. Of course, to ensure isolation between the processes and the kernel, as well as isolation between the processes themselves, the first developer, the second developer, the third developer, and the fourth developer in this application may be different developers.
[0173] For example, please refer to Figure 6 ,yes Figure 5 Another schematic diagram of the illustrated embodiment. In this diagram, the operating system's code segment is a machine-mode readable executable (MRX), and the operating system's data segment is a machine-mode readable writable (MRW). The first process's code segment is a user-mode readable executable (URX), and the first process's data segment is a user-mode readable writable (URW). The first system service process's code segment consists of URX and MRX. The first system service process's data segment consists of URW and MRW. The remote call interface (i.e., the remote call entry function) code segment is URX.
[0174] In this embodiment, a remote call entry function designed by a third developer for other processes to call the second function (which can be understood as...) is used. Figure 3 The first function in this embodiment allows the first process to call the second function stored in the physical memory address space of the first system service process via a remote call entry function, thereby enabling the first process to execute the second function. Compared to existing technologies that require context switching and data copying based on IPC function calls, this embodiment eliminates the need for context switching and data copying when calling the second function of the first system service process, thus improving the performance of function calls by the first system service process from a logical mechanism perspective. Furthermore, it restricts the execution of the second function by requiring the first process to use the first function, limiting the scenario in which the first process executes the second function. This can be understood as requiring the first process to execute the second function within a public area (i.e., where the first function is stored and can be read and executed by all processes). This reduces the security risks associated with users unconditionally executing the second function.
[0175] The system configuration processing method in the embodiments of the present application is described above, and the computer device in the embodiments of the present application is described below. Please refer to Figure 7 One of the embodiments of the computer device in the embodiments of the present application includes
[0176] The triggering unit 701 is configured to trigger a first system call based on a first function, the first function being a function readable and executable by all processes in a user mode, the first function being used to trigger the first system call and call a second function in a first system service process, the first system call being used to instruct the kernel to configure a first access right of the first process to a physical memory address space of the first system service process, the physical memory address space storing the second function, the second function being a function for implementing a function of the first system service process;
[0177] The receiving unit 702 is configured to receive indication information sent by the kernel in response to the first system call, the indication information being used to indicate whether the first access right has been opened.
[0178] The execution unit 703 is configured to, when it is determined that the indication information is used to indicate that the first access right has been opened, execute the second function in the physical memory address space based on the first function.
[0179] Optionally, the computer device can further include an obtaining unit 704 configured to obtain a first task, the first task including execution of the second function by the first process.
[0180] In the embodiment, the operations performed by each unit in the computer device are similar to those described in the foregoing Figures 2 to 6 embodiment, and thus will not be described here.
[0181] In the embodiment, through the first function readable and executable by all processes in the user mode, the execution unit 703 can implement remote calling of the second function stored in the physical memory address space of the first system service process by the first function by the first process, and further implement execution of the second function by the first process. Compared with the process switching and data copying required by the function calling mode based on the IPC in the prior art, the calling of the second function of the first system service process by the first process in the embodiment of the present application does not require process switching and data copying, thereby improving the calling performance of the second function in the first system service process from the mechanism logic level.
[0182] Please refer to Figure 8 Another embodiment of the computer device in the embodiments of the present application includes
[0183] The configuration unit 801 is configured to, in response to a first system call triggered by a first process, configure a first access permission of the first process to a physical memory address space of a first system service process, the physical memory address space storing a second function, the second function being a function for implementing a function of the first system service process, the first system call being used to instruct the kernel to configure the first access permission.
[0184] The sending unit 802 is configured to send indication information to the first process, the indication information being used to indicate whether the first access permission has been started, the first access permission being used for the first process to execute the second function in the physical memory address space based on the first function.
[0185] In the embodiment, the operations performed by the units in the computer device are similar to those of the foregoing Figures 2 to 6 embodiment, which will not be described here again.
[0186] In the embodiment, the configuration unit 801 can configure the first access permission in response to the system call triggered by the first process, and the sending unit 802 sends the indication information to indicate that the first access permission has been started, so that the first process can call and execute the second function stored in the physical memory address space of the first system service process through the first access permission. Compared with the prior art, the first process needs to perform process switching and data copying to call the function based on the IPC, and in the embodiment, the first process does not need to perform process switching and data copying to call the second function of the first system service process, thereby improving the calling performance of the second function in the first system service process from the mechanism logic level.
[0187] Referring to Figure 9 , the present application provides another structural diagram of a computer device. The computer device can include a processor 901, a memory 902 and a communication interface 903. The processor 901, the memory 902 and the communication interface 903 are interconnected by lines. Among them, the memory 902 stores program instructions and data.
[0188] The memory 902 stores the corresponding program instructions and data of the steps performed by the computer device in the foregoing Figures 2 to 6 corresponding embodiments. For the Figures 2 to 4 embodiment, the memory 902 includes a physical memory address space corresponding to the first system service process. For the Figure 5 embodiment, the memory 902 includes a first address space, a second address space, a third address space and a fourth address space, and the description of the address space can refer to the description of the foregoing Figure 5 embodiment, which will not be described here again.
[0189] The processor 901 is configured to execute the foregoingFigures 2 to 6 the steps performed by the computer device in any of the embodiments shown.
[0190] The communication interface 903 can be configured to receive and send data, and be configured to perform the foregoing Figures 2 to 6 the steps related to obtaining, sending, receiving in any of the embodiments shown.
[0191] In an implementation manner, the computer device can include the components relative to Figure 9 More or less components can be included, and the present application is merely illustrative and is not limited.
[0192] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other manners. For example, the described device embodiments are merely illustrative, and the division of units is merely a logical function division, and there can be another division manner in actual implementation, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection between units can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or other forms.
[0193] The units described as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, that is, can be located in one place, or can be distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the present embodiment.
[0194] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be implemented by software, hardware, firmware or any combination thereof, in whole or in part.
[0195] When the units are implemented by using software, the units can be wholly or partially implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are wholly or partially generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable apparatus. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transferred from one website, computer, server or data center to another website, computer, server or data center through a wired (for example, coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (for example, infrared, wireless, microwave, etc.) manner. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that includes one or more available media sets. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)), etc.
[0196] The terms "first", "second", and the like in the description and claims of the present application and the above drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged under appropriate circumstances, and this is only a way of distinguishing the objects with the same attributes in the description of the embodiments of the present application. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, so that the processes, methods, systems, products or devices containing a series of units do not have to be limited to those units, but can include other units not clearly listed or inherent to these processes, methods, products or devices.
Claims
1. A method of inter-process function calling, characterized by, The method is applied to a computer device, and the method comprises: A first process triggers a first system call based on a first function, the first function being a function readable and executable by all processes in a user space, the first function being used to trigger the first system call and call a second function in a first system service process, the first system call being used to instruct a kernel to configure a first access right of the first process to a physical memory address space of the first system service process, the physical memory address space storing the second function, the second function being a function for implementing a function of the first system service process; The first process receives indication information sent by the kernel in response to the first system call, the indication information being used to indicate whether the first access right has been enabled; When it is determined that the indication information is used to indicate that the first access right has been enabled, the first process executes the second function based on the first function.
2. The method of claim 1, wherein, The first function is also used to trigger a second system call, the second system call being used for the kernel to cancel the first access right; After the first process executes the second function, the method further comprises: The first process triggers a second system call based on the first function, the second system call being used to instruct the kernel to cancel the first access right.
3. The method of claim 1, wherein, The first access right comprises read and execute rights of a code segment in the first system service process and read and write rights of a data segment in the first system service process; and the first system call is also used to trigger the kernel to configure read and execute rights of a code segment in the first process and read and write rights of a data segment in the first process.
4. The method of claim 1, wherein, Before the first process triggers the first system call based on the first function, the method further comprises: The first process acquires a first task, the first task comprising execution of the second function by the first process.
5. The method according to any one of claims 1 to 4, characterized in that, The first process is a user process or a second system service process.
6. The method according to any one of claims 1 to 4, characterized in that, The first system service process integrates at least two subsystem service processes in the user space, the subsystem service processes being a driver process, a network management process or a file system management process; and the second function is a function in one of the at least two subsystem service processes. The first process executes the second function in the physical memory address space based on the first function, comprising: The first process calls and executes a third function through the second function, the first access right being unchanged before the first process returns the first function, the third function being a function readable and executable by all processes in the user space, the third function being used to call a function in another of the at least two subsystem service processes.
7. The method according to any one of claims 1 to 4, characterized in that, The method is applied to a microkernel architecture, and the first system service process is a driver process, a network management process or a file system management process.
8. The method according to any one of claims 1 to 4, characterized in that, The physical memory address space is an address space managed by a memory management unit (MMU), a memory protection unit (MPU) or a physical address protection (PMP) hardware.
9. The method according to any one of claims 1 to 4, characterized in that, The computer device is an Internet of Things (IOT) device.
10. A method of inter-process function calling, characterized by, The method is applied to a computer device, and the method comprises: The kernel configures, in response to a first system call triggered by a first process, a first access right of the first process to a physical memory address space of a first system service process, the physical memory address space storing a second function, the second function being a function for implementing a function of the first system service process, the first system call being used to instruct the kernel to configure the first access right; The kernel sends, to the first process, indication information used to indicate whether the first access right has been enabled, the first access right being used by the first process to execute the second function.
11. The method of claim 10, wherein, The configuring of the first access right of the first process to the physical memory address space of the first system service process comprises: When it is determined that the first process has a second access right and the first access right has not been enabled, the kernel configures the first access right, and the indication information is specifically used to indicate that the first access right has been enabled, the second access right being a right to call the second function.
12. The method of claim 10, wherein, The method further comprises: The kernel cancels the first access right in response to a second system call triggered by the first process, the second system call being used to instruct the kernel to cancel the first access right.
13. The method of claim 10, wherein, The first access right comprises read and execute rights of a code segment in the first system service process and read and write rights of a data segment in the first system service process, and the first system call is further used to trigger the kernel to configure read and execute rights of a code segment in the first process and read and write rights of a data segment in the first process.
14. The method according to any one of claims 10 to 13, characterized in that, The first process is a user process or a second system service process.
15. The method according to any one of claims 10 to 13, characterized in that, The first system service process integrates at least two subsystem service processes in a user mode, the subsystem service processes being a driver process, a network management process, or a file system management process. When it is determined that the first process has a second access right and the first access right has been enabled, the indication information is used to indicate that the first access right has been enabled and that a first function does not enable a second system call, the second access right being a right to call the second function, the first function being a function readable and executable by all processes in the user mode, the first function being used to trigger the first system call, call the second function, and trigger the second system call, the second system call being used to instruct the kernel to cancel the first access right.
16. The method of any one of claims 10 to 13, wherein, The method is applied to a microkernel architecture, and the first system service process is a driver process, a network management process, or a file system management process.
17. The method of any one of claims 10-13, wherein, The physical memory address space is an address space managed by a memory management unit (MMU), a memory protection unit (MPU), or a physical address protection (PMP) hardware.
18. The method of any one of claims 10-13, wherein, The computer device is an Internet of Things (IOT) device.
19. A computer device, comprising: The computer device comprises: triggering, based on a first function, a first system call, the first function being a function readable and executable by all processes in a user space, the first function being used to trigger the first system call and to call a second function in a first system service process, the first system call being used to instruct a kernel to configure a first process with a first access right to a physical memory address space of the first system service process, the physical memory address space storing the second function, the second function being a function implementing a function of the first system service process; receiving, from the kernel, indication information sent in response to the first system call, the indication information being used to indicate whether the first access right has been enabled; executing, based on the first function, the second function when it is determined that the indication information indicates that the first access right has been enabled.
20. The apparatus of claim 19, wherein, The first function is further used to trigger a second system call, the second system call being used to instruct the kernel to cancel the first access right. The triggering unit is further configured to trigger, based on the first function, a second system call, the second system call being used to instruct the kernel to cancel the first access right.
21. The apparatus of claim 19, wherein, The first access right includes a read and execute right of a code segment in the first system service process and a read and write right of a data segment in the first system service process, and the first system call is further used to instruct the kernel to configure a read and execute right of a code segment in the first process and a read and write right of a data segment in the first process.
22. The apparatus of claim 19, wherein, The computer device further includes: an obtaining unit configured to obtain a first task, the first task including execution of the second function by the first process.
23. The apparatus of any one of claims 19-22, wherein, The first process is a user process or a second system service process.
24. The apparatus of any one of claims 19-22, wherein, The first system service process integrates at least two subsystem service processes in the user space, the subsystem service processes being a driver process, a network management process, or a file system management process, and the second function is a function in one of the at least two subsystem service processes. The execution unit is specifically configured to call and execute a third function through the second function, the first access right being unchanged before the first process returns the first function, the third function being a function readable and executable by all processes in the user space, the third function being used to call a function in another of the at least two subsystem service processes.
25. The apparatus of any one of claims 19-22, wherein, The computer device adopts a microkernel architecture, and the first system service process is a driver process, a network management process, or a file system management process.
26. The apparatus of any one of claims 19-22, wherein, The physical memory address space is an address space managed by a memory management unit (MMU), a memory protection unit (MPU), or a physical address protection (PMP) hardware.
27. The apparatus of any one of claims 19-22, wherein, The computer device is an Internet of Things (IOT) device.
28. A computer device, comprising: The computer device includes: The configuration unit is configured to configure, in response to a first system call triggered by a first process, a first access permission of the first process to a physical memory address space of a first system service process, the physical memory address space storing a second function, the second function being a function for implementing a function of the first system service process, the first system call being used to instruct a kernel to configure the first access permission. The sending unit is configured to send, to the first process, indication information used to indicate whether the first access permission has been enabled, the first access permission being used for the first process to execute the second function.
29. The apparatus of claim 28, wherein, The configuration unit is specifically configured to configure the first access permission when it is determined that the first process has a second access permission and the first access permission is not enabled, the indication information being specifically used to indicate that the first access permission has been enabled, the second access permission being a permission for calling the second function.
30. The apparatus of claim 28, wherein, The configuration unit is further configured to cancel the first access permission in response to a second system call triggered by the first process, the second system call being used to instruct the kernel to cancel the first access permission.
31. The apparatus of claim 28, wherein, The first access permission includes read and execution permissions of a code segment in the first system service process and read and write permissions of a data segment in the first system service process, and the first system call is further used to trigger the kernel to configure read and execution permissions of a code segment in the first process and read and write permissions of a data segment in the first process.
32. The apparatus of any one of claims 28-31, wherein, The first process is a user process or a second system service process.
33. The apparatus of any one of claims 28-31, wherein, The first system service process integrates at least two subsystem service processes in a user mode, the subsystem service processes being a driver process, a network management process, or a file system management process. When it is determined that the first process has a second access permission and the first access permission has been enabled, the indication information is used to indicate that the first access permission has been enabled and a first function does not enable a second system call, the second access permission being a permission for calling the second function, the first function being a function that can be read and executed by all processes in the user mode, and the first function being used to trigger the first system call, call the second function, and trigger the second system call, the second system call being used to instruct the kernel to cancel the first access permission.
34. The apparatus of any one of claims 28-31, wherein, The computer device adopts a micro-kernel architecture, and the first system service process is a driver process, a network management process, or a file system management process.
35. The apparatus of any one of claims 28-31, wherein, The physical memory address space is an address space managed by a memory management unit (MMU), a memory protection unit (MPU), or a physical address protection (PMP) hardware.
36. The apparatus of any one of claims 28-31, wherein, The computer device is an Internet of Things (IOT) device.
37. A computer device, comprising: The computer device includes a memory and a processor, the memory stores code, and the processor is configured to execute the code, when the code is executed, the computer device performs the method in any one of claims 1 to 9 and / or the method in any one of claims 10 to 18.
38. A communication system architecture, characterized by The communication system architecture includes the first process in any one of the preceding claims 1 to 9 and / or the kernel in any one of the preceding claims 10 to 18.
39. A computer-readable storage medium, characterized in that, computer readable instructions, which, when run on a computer, cause the computer to perform the method of any one of claims 1 to 9, and / or the method of any one of claims 10 to 18.
40. A computer program product, characterised in that, computer readable instructions, which, when run on a computer, cause the computer to perform the method of any one of claims 1 to 9, and / or the method of any one of claims 10 to 18.
Citation Information
Patent Citations
Interprocess function invocation method and device based on shared memory
CN107491355A
MPK technology-based inter-microkernel-module communication method and system, and medium
CN111949596A