System call processing method, device, system, equipment, medium and program product
By receiving and converting operation requests in user space into kernel space, and using the syscall_stub kernel module to handle system calls, the problem of completing application updates without interrupting user services is solved, achieving efficient execution of system call operations and improving the stability and reliability of the operating system.
Patent Information
- Application Number
- CN202411337715.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-01-07
AI Technical Summary
How can we update the original application within the server operating system without interrupting user services, especially for the introduction of new system call interfaces, to avoid system downtime?
By receiving system calls in user space and converting them into kernel-mode operation requests, carrying the call number, and calling back the corresponding kernel-mode application, the system call forwarding and routing are implemented using the syscall_stub kernel module, and online addition of system calls is supported.
It effectively reduces system downtime, improves the stability and reliability of the operating system, and ensures that application updates and system call operations can be completed without interrupting user services.
Smart Images

Figure CN119271432A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of operating systems, and in particular to a system call processing method, device, system, equipment, medium and program product. Background Art
[0002] Linux (an operating system) is a widely used operating system in the server field. The server operating system faces the need to fix known problems and upgrade. For example, to improve security, fix CVE (Common Vulnerabilities & Exposures) vulnerabilities, upgrade product versions, etc. However, the server system reliability requirements are high, and the downtime allowed for a server in normal use is very short within the set time. For example: for a server with 4 9 requirements, the maximum downtime in a year is (1-99.99%)*365*24*40=52.6 minutes, and for a server with 5 9 requirements, the maximum downtime in a year is 5.26 minutes. In this way, the server operating system needs to be updated online without affecting the business.
[0003] In the related art, user-mode applications can complete the update of the original application without interrupting user services through appropriate strategy designs such as kernel module technology or hot patch technology. However, no matter which technology is used, its usage scenarios are greatly limited. In the scenario of more application upgrades, the demand for new system calls is increased. For example: for io_uring (a new asynchronous I / O model provided by Linux), for the newly introduced features, backporting (applying a software patch to an older version than the version corresponding to this patch) is implemented in the form of a kernel module. If the new feature of io_uring is to add three system call interfaces, io_uring_setup, io_uring_register, and io_uring_enter, to the Linux kernel, then due to the kernel's restrictions on system calls, it is impossible to complete the update of the original application through kernel module technology or hot patch technology without interrupting user services. Therefore, how to complete the update of the original application without interrupting user services for most application scenarios has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] In view of this, the present invention provides a system call processing method, apparatus, system, device, medium and program product to solve the problem of how to complete the update of the original application without interrupting user services for most application scenarios.
[0005] In a first aspect, the present invention provides a system call processing method, which is applied to an operating system, where the operating system has a user state and a kernel state, and the method comprises:
[0006] Receive user-mode system calls in user mode;
[0007] Convert the system call to an operation request in kernel mode, where the operation request carries the call number of the operation request;
[0008] Based on the call number, call back the kernel-mode application corresponding to the system call.
[0009] The system call processing method of the present invention converts the system call to an operation request in the kernel state when receiving a system call in the user state. The operation request carries the call number of the operation request, and based on the call number, calls back the kernel state application corresponding to the system call. Thus, by converting the system call in the user state into the operation request in the kernel state, the system call is realized, avoiding the problem of downtime required for executing the user state system call directly through the user interface, thereby effectively reducing the downtime, completing the operation that requires executing the system call, such as application update, without interrupting the user service, and significantly improving the stability of the operating system.
[0010] In an optional implementation, converting a system call to an operation request in a kernel state includes:
[0011] Based on a pre-configured system call list received from kernel mode by user mode, system calls are converted to operation requests in kernel mode.
[0012] The system call processing method of the present invention converts the system call to the operation request of the kernel state based on the pre-configured system call list received by the user state from the kernel state, and further implements the system call by executing the operation request by the kernel state, thereby effectively avoiding the problem of needing to shut down the computer when executing the user state system call directly through the user interface.
[0013] In an optional implementation, calling back a kernel-mode application corresponding to a system call based on a call number includes:
[0014] Find the kernel-mode application corresponding to the call number from the pre-configured system call list;
[0015] Callback to kernel-mode application.
[0016] The system call processing method of the present invention pre-configures multiple system calls in the kernel state to form a system call list, which contains the corresponding relationship between the call number and the kernel state application. After the kernel state receives the system call with the call number sent by the user state, the kernel state application corresponding to the call number can be quickly found based on the call number to implement the call to the kernel state application. Without adding a system call interface, the system call is implemented, the system availability is effectively improved, thereby effectively reducing the downtime problem caused by system call operations such as application updates, improving the stability and reliability of the system, and significantly improving the user experience.
[0017] In an optional implementation, calling back a kernel-mode application includes:
[0018] The kernel interface calling module forwards the operation request to the operating system to implement the call to the kernel state application.
[0019] The system call processing method of the present invention forwards the operation request to the operating system by the kernel interface calling module, effectively realizes the call to the kernel state application, and avoids the interface quantity limitation problem existing in performing system calls through multiple calling interfaces.
[0020] In an optional implementation, before receiving the system call in user mode, the method further includes:
[0021] Receive registration request for new system calls in kernel mode;
[0022] Configure the newly added system call in the system call list.
[0023] In an optional implementation, configuring the newly added system call in the system call list includes:
[0024] Configure the newly added system call in the kernel state system call list;
[0025] Distribute the system call list to user mode.
[0026] The system call processing method of the present invention configures the newly added system call in the system call list of the kernel state, and distributes the system call list to the user state. The kernel state system call list and the user state system call list are synchronized, so that when a system call sent by the user state is received, the kernel state operation request is quickly determined by the call number in the user state list, and the callback of the system call is realized.
[0027] In an optional implementation, distributing the system call list to the user state includes:
[0028] The calling device is registered with the virtual file system of the operating system, and the calling device is used to receive the system call in the user mode.
[0029] The system call processing method of the present invention receives the registration request of the newly added system call in advance in the kernel state, configures the newly added system call, and configures the newly added system call in the system call list. Thus, when the system call sent by the user state is received, the callback of the system call is quickly realized, thereby improving the execution efficiency of the system call.
[0030] In an optional implementation, configuring the newly added system call in the system call list further includes:
[0031] Assign call numbers to new system calls;
[0032] Bind call numbers to newly added system calls.
[0033] The system call processing method of the present invention allocates a call number to a newly added system call and binds the call number to the newly added system call. Thus, when a system call is made, the system call from user state to kernel state and then to kernel state system application can be realized by the call number, effectively improving the availability of the operating system.
[0034] In an optional implementation, configuring the newly added system call in the system call list further includes:
[0035] After distributing the system call list to the user state, the system call list is compiled into a newly added system application based on the user state.
[0036] The system call processing method of the present invention compiles the system call list into the newly added system application based on the user state after distributing the system call list to the user state. Thus, the compilation of the newly added system application can be realized in the user state without stopping the system, effectively avoiding the frequent shutdown operations caused by system call operations such as adding new applications and application updates, and significantly improving the stability and reliability of the operating system.
[0037] In a second aspect, an embodiment of the present invention provides a system call processing device, which is applied to an operating system, where the operating system has a user state and a kernel state, and the device includes:
[0038] A receiving module, used for receiving a system call in a user state in a user state;
[0039] A conversion module, used for converting a system call into an operation request in a kernel state, where the operation request carries a call number of the operation request;
[0040] The callback module is used to call back the kernel-mode application corresponding to the system call based on the call number.
[0041] In a third aspect, an embodiment of the present invention provides an operating system, the operating system having a user state and a kernel state;
[0042] In user mode, receiving user mode system calls;
[0043] In kernel mode, the system call is converted into an operation request in kernel mode, the operation request carries a call number of the operation request; and based on the call number, the kernel mode application corresponding to the system call is called back.
[0044] In an optional implementation, the kernel state is configured with a function kernel module, and the function kernel module is configured with a system call list;
[0045] The function kernel module is used to receive a registration request for a new system call in kernel mode, and configure the new system call in a system call list.
[0046] In an optional implementation, the function kernel module is also used to distribute the system call list to the user mode.
[0047] In an optional implementation, the function kernel module is further used to assign a call number to the newly added system call and bind the call number to the newly added system call.
[0048] In an optional implementation, the kernel state is also used to configure the new system call in the form of a kernel module when the operating system adds a new system call, and send a registration request for the new system call to the function kernel module.
[0049] In an optional implementation, the user state is configured with a system call registration library, and the system call registration library is used to receive the system call list distributed by the function kernel module to the user state.
[0050] In an optional implementation, the user state is configured with a system call registry, and the system call registry is used to receive a pre-configured system call list from the kernel state, and an operation request to convert the system call to the kernel state.
[0051] In a fourth aspect, an embodiment of the present invention provides a computer device, including:
[0052] The memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the system call processing method of the first aspect or any corresponding implementation method thereof by executing the computer instructions.
[0053] In a fifth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to enable a computer to execute the system call processing method of the above-mentioned first aspect or any corresponding implementation method thereof.
[0054] In a sixth aspect, an embodiment of the present invention provides a computer program product, including computer instructions, which are used to enable a computer to execute the system call processing method of the above-mentioned first aspect or any corresponding implementation method.
[0055] In the system call processing method, device, system, equipment, medium and program product of the present invention, when a user state system call is received in the user state, the system call is converted to an operation request in the kernel state, the operation request carries the call number of the operation request, and based on the call number, the kernel state application corresponding to the system call is called back. Thus, by converting the user state system call into the kernel state operation request, the system call is realized, avoiding the problem of downtime required for executing the user state system call directly through the user interface, thereby effectively reducing the downtime, completing the operation that requires executing the system call, such as application update, without interrupting the user service, and significantly improving the stability of the operating system. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0057] Figure 1 It is a schematic diagram of the working principle of an operating system to which the system call processing method according to an embodiment of the present invention is applied;
[0058] Figure 2 is a flowchart of a system call processing method according to an embodiment of the present invention;
[0059] Figure 3 is a flow chart of another system call processing method according to an embodiment of the present invention;
[0060] Figure 4 is a flowchart of another system call processing method according to an embodiment of the present invention;
[0061] Figure 5 is a structural block diagram of a system call processing device according to an embodiment of the present invention;
[0062] Figure 6 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0063] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0064] The user state of the operating system cannot directly use system resources, nor can it change the working state of the CPU (Central Processing Unit), and can only access the storage space of the user program itself. However, user-state applications can be designed with appropriate strategies, such as building application copies, to complete the update of the original application without interrupting user services. For example, in the field of server virtualization, the qemu-kvm virtual machine can implement an uninterrupted application switching strategy through online migration. In addition, as a macro-kernel operating system, Linux can also support the "kernel module" mechanism, which can replace and update kernel-state components or drivers online without restarting the operating system. Linux also supports the "kernel hot patch" technology livepatch, which supports online repair of kernel functions based on function granularity.
[0065] However, both kernel module technology and hot patch technology have very limited usage scenarios. In the upgrade scenarios of some applications, there is a need to add new system calls. Taking the io_uring feature as an example, the high-performance asynchronous IO framework io_uring was first introduced in the Linux 5.1 kernel in 2019, which can be used to accelerate the performance of IO-intensive applications. However, the update iteration of server operating systems is slow, and they are usually built on the Linux 3.x and 4.x kernels. For newly introduced features, the new features are backported to the old version in the form of kernel modules. When the io_uring feature is introduced, three system call interfaces need to be added to the Linux kernel, namely io_uring_setup, io_uring_register, and io_uring_enter. However, due to the kernel's restrictions on system calls, we cannot introduce it online through internal hot patches or kernel modules, but must introduce it offline by recompiling the kernel mode. Recompiling the kernel module will inevitably require a global restart of the system, and will destroy the Linux ABI compatibility, which obviously does not meet the requirements of the upgrade scenario.
[0066] Based on the above problems, the following characteristics of the kernel state of the operating system are fully considered: During the design of the operating system, based on the characteristics of the operating system that "the operating system has both operating system programs and ordinary user programs", for the sake of security and stability, a kernel state that the operating system programs cannot access at will is set. However, only the programs that execute the operating system must be converted to the kernel state for execution.
[0067] Based on this, we fully analyzed the existing infrastructure of Linux and the design and implementation principles of the Linux kernel interface, proposed a design scheme that supports adding system calls to Linux online, and completed the final implementation of the design. This scheme was applied to server virtualization products and solved the technical problem of adding system calls online.
[0068] In order to solve or partially solve the above technical problems, the present invention provides a system call processing method, device, system, equipment, medium and program product, which supports the design and implementation of the scheme of adding system calls to the Linux kernel online. First, the syscall_stub kernel module is designed and implemented. The main function of the kernel module is to receive the registration of the newly added system call interface group, and to forward and route the system call. Secondly, the newly added system call function is implemented in the form of a kernel module, and the newly added system call interface is registered to the kernel module syscall_stub. Finally, a system call registration library is provided in the user state, and the system call registration library can be presented in the form of a static library. The function of the system call registration library is mainly to convert the system call into the interaction with the syscall_stub module by the user state program, that is, to convert the system call into the interaction with the syscall_stub file handle, and then the syscall_stub kernel module forwards the system call to the underlying system call implementation module. Since both the syscall_stub_lib and the newly added system call kernel module support online loading, it is possible to add system calls to the Linux kernel online. Specifically, the method is applied to an operating system, and the operating system has a user state and a kernel state. The method includes: receiving a user-state system call in user state; converting the system call to a kernel-state operation request, the operation request carrying the call number of the operation request; and calling back the kernel-state application corresponding to the system call based on the call number. Thus, by converting the user-state system call to the kernel-state operation request, the system call is implemented, avoiding the problem of downtime required for executing the user-state system call directly through the user interface, thereby effectively reducing downtime, completing operations such as application updates that require execution of system calls without interrupting user services, and significantly improving the stability of the operating system.
[0069] According to an embodiment of the present invention, a system call processing method embodiment is provided, which is applied to an operating system. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0070] In order to better describe the technical solution, the operating system in the embodiment of the present invention is first described here.
[0071] Figure 1 The schematic diagram of the operating system implementation principle is shown in FIG. Figure 1 As shown, the operating system has a user state and a kernel state. Applications are configured in the user state. By making system calls to the kernel state, new applications are added, changed, and updated. In an embodiment of the present invention, a kernel module syscall_stub capable of performing operations such as application registration, calling, and management is configured in the kernel state. After the kernel module syscall_stub receives a registration request for a new system call newsyscall module, it registers the system call, generates a call number for the new system call, and adds the new system call to the system call list syscall_stub_lib. The system call list syscall_stub_lib is in Figure 1 It is shown in the figure with multiple rectangular boxes in the kernel module syscall_stub. And the kernel module syscall_stub in the kernel state can synchronize the system call list to the system call registry configured in the user state. The system call registry can be a static library, but the system call registry can be updated based on the system call list sent by the kernel state. Other detailed working principles of the operating system and operations represented by sequence numbers such as ①, ② and ③ will be described in detail below in conjunction with other specific embodiments, and will not be repeated here.
[0072] In this embodiment, a system call processing method is provided, which can be applied to an operating system. The operating system has a user state and a kernel state. Figure 2 is a flow chart of a system call processing method according to an embodiment of the present invention, such as Figure 2 As shown, the process includes the following steps:
[0073] Step S201, receiving a user-mode system call in user mode.
[0074] In some optional embodiments of the present invention, the user issues a system call such as application update based on an application configured in user mode.
[0075] Step S202: convert the system call to an operation request in kernel mode, where the operation request carries a call number of the operation request.
[0076] In some optional embodiments of the present invention, the system call list in the system call registration library can be used to characterize the correspondence between user-mode system calls and kernel-mode applications. The correspondence can be directly shown as a mapping between system calls and kernel-mode operation requests. The mapping relationship can also show other information such as the system call call number according to actual needs.
[0077] The system call registration library configured in the user state of the operating system can determine the kernel state application corresponding to the received system call based on the system call list received in advance from the kernel state. For example, the system call sent by the application carries a call number, and the system call has a unique call number. Therefore, based on the call number, the system call can be converted into an operation request in the kernel state.
[0078] In some optional embodiments of the present invention, the system call can be converted to an operation request of the kernel state based on the pre-configured system call list received by the user state from the kernel state. Thus, based on the pre-configured system call list received by the user state from the kernel state, the system call is converted to an operation request of the kernel state, and the system call is further implemented by executing the operation request through the kernel state, effectively avoiding the problem of needing to shut down the system when executing the user state system call directly through the user interface.
[0079] Step S203: based on the call number, calling back the kernel-mode application corresponding to the system call.
[0080] The kernel state is also configured with a system call list. Based on the call number of this system call and the system call list, the kernel state application corresponding to the system call can be determined. Therefore, the kernel state application corresponding to the system call can be quickly determined based on the call number, and the kernel state application can be called back to achieve fast and accurate response processing to the system call.
[0081] In some optional implementations of the present invention, the kernel-state application corresponding to the call number can be first searched from a pre-configured system call list. Then the kernel-state application corresponding to the call number is called back. Therefore, in the system call processing method of the present invention, the kernel state pre-configures multiple system calls to form a system call list, and the list contains the correspondence between the call number and the kernel-state application. After the kernel state receives the system call with the call number sent by the user state, the kernel-state application corresponding to the call number can be quickly searched based on the call number to implement the call to the kernel-state application. Without adding a system call interface, the system call is implemented, which effectively improves the system availability, thereby effectively reducing the downtime problem caused by system call operations such as application updates, improving the stability and reliability of the system, and significantly improving the user experience.
[0082] The system call processing method of the present invention converts the system call to an operation request in the kernel state when receiving a system call in the user state. The operation request carries the call number of the operation request, and based on the call number, calls back the kernel state application corresponding to the system call. Thus, by converting the system call in the user state into the operation request in the kernel state, the system call is realized, avoiding the problem of downtime required for executing the user state system call directly through the user interface, thereby effectively reducing the downtime, completing the operation that requires executing the system call, such as application update, without interrupting the user service, and significantly improving the stability of the operating system.
[0083] In another embodiment of the present invention, a system call processing method is provided, which can be applied to an operating system, wherein the operating system has a user state and a kernel state. Figure 3 is a flow chart of a system call processing method according to an embodiment of the present invention, such as Figure 3 As shown, the process includes the following steps:
[0084] Step S301, receiving a registration request for a new system call in kernel mode.
[0085] In one embodiment of the present invention, the operating system is running, the kernel state newly added system call implementation module newsyscallmodule is loaded, and the following is presented in the VFS (Virutal File System) Figure 1 The / dev / syscall_stub virtual device is shown in the triangle. User state can call ioctl (a system call dedicated to device input and output operations) through this virtual device to interact with kernel state. System calls are essentially a set of kernel export functions that perform specific functions. Here, through the registration interface provided by the new system call implementation module newsyscall module, a registration request is sent to the kernel module syscall_stub in kernel state. As a result, the kernel module syscall_stub can receive the registration request for the new system call in kernel state.
[0086] Step S302, configuring the newly added system call in the system call list.
[0087] In an optional implementation, after the kernel module syscall_stub receives the registration request for the newly added system call in the kernel state, the newly added system call to be provided by the operating system can be registered in the system call list of syscall_stub. The system call list can include only the newly added system call function or all kernel state system calls. The system call list can refer to Figure 1 Multiple rectangular boxes inside the kernel module syscall_stub.
[0088] In an optional implementation, the above step S302 includes:
[0089] Step S3021, configure the newly added system call in the system call list of the kernel state.
[0090] In an optional implementation, after the kernel module syscall_stub receives the registration request for the newly added system call in the kernel state, the newly added system call to be provided by the operating system can be registered in the system call list of syscall_stub. The system call list can include only the newly added system call function or all kernel state system calls. The system call list can refer to Figure 1 Multiple rectangular boxes inside the kernel module syscall_stub.
[0091] Step S3022, distribute the system call list to the user state.
[0092] In an optional implementation, in order to keep the system call lists in kernel mode and user mode consistent, thereby ensuring fast and efficient implementation of system calls, the kernel module syscall_stub distributes the system call list to the user mode in a timely manner when the system call list is updated.
[0093] Specifically, it can be sent to the system call registration library configured in the user state to update the system call list syscall_stub_lib in the user state.
[0094] In an optional implementation, a calling device may be registered with a virtual file system of the operating system, and the calling device is used to receive system calls in the user state, so as to distribute the system call list to the user state in step S3022.
[0095] For example, in user mode, a supporting system call registration library syscall_stub_lib that interacts with syscall_stub can be provided. The system call registration library can be a set of static link libraries. Before calling a new system call, the application can call the interface provided by the system call registration library to establish an association between the new system call and the underlying registered kernel-mode application. Syscall_stub_lib can be linked with the user-mode application to form an executable file. When the application calls the new system call, the system call is converted into an operation request to the kernel mode. For example, the system call received from the user mode can be converted into an access to / dev / syscall_stub.
[0096] The system call processing method of the present invention receives the registration request of the newly added system call in advance in the kernel state, configures the newly added system call, and configures the newly added system call in the system call list. Thus, when the system call sent by the user state is received, the callback of the system call is quickly realized, thereby improving the execution efficiency of the system call.
[0097] In an optional implementation, the above step S302 further includes:
[0098] Step S3023, assigning a call number to the newly added system call.
[0099] Specifically, in order to ensure the uniqueness of the system call, when registering the newly added system call, a call number is assigned to the newly added system call. The generation rule of the call number can be set according to actual needs, which can characterize the uniqueness of the newly added system call and effectively achieve a fast and accurate response to the system call through the call registration library configured by the user state system and the kernel module configured by the kernel state without adding system calls. For example, ioctlcmd can be used as the call code.
[0100] Step S3024, bind the call number to the newly added system call.
[0101] Specifically, the call number can be transmitted as the information of the system call during the interaction between the kernel state and the user state. The ioctl cmd is a necessary parameter for the user state to interact with the kernel state through ioctl, and the ioctl cmd can be used as the call code.
[0102] The system call processing method of the present invention allocates a call number to a newly added system call and binds the call number to the newly added system call. Thus, when a system call is made, the system call from user state to kernel state and then to kernel state system application can be realized by the call number, effectively improving the availability of the operating system.
[0103] In an optional implementation, the above step S302 further includes:
[0104] Step S3025, after distributing the system call list to the user state, compile the system call list into a newly added system application based on the user state.
[0105] In an optional implementation, the application can be recompiled and linked based on the user state, and syscall_stub_lib can be compiled into the application. At the same time, the system call macro provided by syscall_stub_lib can be used to associate the newly added system calls used by the application with the bottom layer. This process is essentially to convert the system call function into an ioctl request for the / dev / syscall_stub device.
[0106] The system call processing method of the present invention compiles the system call list into the newly added system application based on the user state after distributing the system call list to the user state. Thus, the compilation of the newly added system application can be realized in the user state without stopping the system, effectively avoiding the frequent shutdown operations caused by system call operations such as adding new applications and application updates, and significantly improving the stability and reliability of the operating system.
[0107] According to an embodiment of the present invention, a system call processing method embodiment is provided, which is applied to an operating system. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here. The system call processing method of the present invention configures the newly added system call in the system call list of the kernel state, and distributes the system call list to the user state. The kernel state system call list and the user state system call list are synchronized, so that when a system call sent by the user state is received, the kernel state operation request is quickly determined by the call number in the user state list, and the system call callback is realized.
[0108] Step S303: receiving a user-mode system call in the user mode.
[0109] For details, please see Figure 1 Step S201 of the illustrated embodiment will not be described in detail here.
[0110] Step S304: convert the system call to an operation request in kernel mode, where the operation request carries a call number of the operation request.
[0111] In an optional implementation, the above step S304 may include:
[0112] Step S3041: based on the pre-configured system call list received by the user state from the kernel state, convert the system call to an operation request of the kernel state.
[0113] In some optional implementations of the present invention, the application executes a system call, and the system call is converted into an ioctl request to the / dev / syscall_stub device through syscall_stub_lib.
[0114] The system call processing method of the present invention converts the system call to the operation request of the kernel state based on the pre-configured system call list received by the user state from the kernel state, and further implements the system call by executing the operation request by the kernel state, thereby effectively avoiding the problem of needing to shut down the computer when executing the user state system call directly through the user interface.
[0115] Step S305: based on the call number, calling back the kernel-mode application corresponding to the system call.
[0116] In an optional implementation, the above step S305 may include:
[0117] Step S3051, searching a pre-configured system call list for a kernel-mode application corresponding to the call number.
[0118] In an optional implementation, after the system call is converted to an ioctl request to the device / dev / syscall_stub, the kernel module syscall_stub module in the kernel state responds to the ioctl request. Specifically, according to the call number ioctl_cmd carried in the ioctl request, the syscall_stub list can be searched to determine the pre-registered system call with the call number ioctl_cmd.
[0119] Step S3052: Call back the kernel-mode application.
[0120] In some optional implementations of the present invention, the kernel module Syscall_stub in the kernel state executes the system call with the call number ioctl_cmd in the form of a callback function, thereby implementing the execution of the user state application system call.
[0121] The system call processing method of the present invention pre-configures multiple system calls in the kernel state to form a system call list, which contains the corresponding relationship between the call number and the kernel state application. After the kernel state receives the system call with the call number sent by the user state, the kernel state application corresponding to the call number can be quickly found based on the call number to implement the call to the kernel state application. Without adding a system call interface, the system call is implemented, the system availability is effectively improved, thereby effectively reducing the downtime problem caused by system call operations such as application updates, improving the stability and reliability of the system, and significantly improving the user experience.
[0122] In an optional implementation, the kernel interface calling module may forward the operation request to the operating system to implement the call to the kernel state application, thereby implementing the above step S3052.
[0123] The system call processing method of the present invention forwards the operation request to the operating system by the kernel interface calling module, effectively realizes the call to the kernel state application, and avoids the interface quantity limitation problem existing in performing system calls through multiple calling interfaces.
[0124] According to an embodiment of the present invention, a system call processing method embodiment is provided, which is applied to an operating system. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that here. In this embodiment, a system call processing method is provided, which can be applied to an operating system, which has a user state and a kernel state. Figure 4 is a flow chart of a system call processing method according to an embodiment of the present invention, such as Figure 4 As shown, the process includes the following steps:
[0125] Step S401, registering a new system call.
[0126] Specifically, step S401 may include:
[0127] Step S4011, receiving a new system call registration request sent by the new system call implementation module, and adding the new system call to the system call list syscall_stub_lib of the kernel module syscall_stub.
[0128] Step S4012: assign a call number ioctl cmd to the newly added system call, and bind the call number ioctl cmd to the newly added system call.
[0129] Step S4013, registering the / dev / syscall_stub device with the VFS to accept system call requests from the user state.
[0130] Step S4014: distribute the system call request to the user state.
[0131] Step S4015, complete backporting (updating or repairing the application) of the newly added system call function, and update the newly added system call to the kernel module syscall_stub in the kernel state.
[0132] Backporting is the process of applying updates or fixes from upstream versions of software to downstream versions of software. This process is often used to apply fixes for security vulnerabilities to already released software versions to provide security updates.
[0133] In some optional implementations of the present invention, the newly added system call can be compiled into a kernel module and loaded into the operating system online. When backporting the newly added system call function, in the __init function of the kernel module syscall_stub, the syscall_stub_register() interface provided by the kernel module syscall_stub is called to register the newly added system call to the kernel module syscall_stub.
[0134] Step S4016, in user mode, complete the compilation of the newly added system call.
[0135] In some optional embodiments of the present invention, in user mode, the application can be recompiled and linked, and syscall_stub_lib can be compiled into a new application. At the same time, the system call macro provided by the system call registration library syscall_stub_lib needs to be used by the application. The newly added system call to be used by the application is associated with the kernel state application. This process is essentially to convert the calling function of the system call into an ioctl request for the kernel state virtual device / dev / syscall_stub.
[0136] Step S402, execution of the system call.
[0137] Specifically, the above step S402 may include:
[0138] Step S4021, the application sends a system call to the system call registration library.
[0139] In some optional implementations of the present invention, the application executes a system call, and the system call is converted into an ioctl request to the / dev / syscall_stub device through syscall_stub_lib. Figure 1 The operation flow is shown in ①.
[0140] Step S4022: searching a pre-configured system call list for a kernel-mode application corresponding to the call number.
[0141] In an optional implementation, after the system call is converted to an ioctl request to the device / dev / syscall_stub, the kernel module syscall_stub module in the kernel state responds to the ioctl request. Specifically, according to the call number ioctl_cmd carried by the ioctl request, the syscall_stub list can be searched to determine the pre-registered system call with the call number ioctl_cmd. For details, please refer to Figure 1 The operation flow is shown in ②.
[0142] Step S4023, calling back the kernel-mode application.
[0143] In some optional embodiments of the present invention, the kernel module Syscall_stub in the kernel state executes the system call with the call number ioctl_cmd in the form of a callback function. This implements the execution of the user state application system call. For details, please refer to Figure 1 The operation flow is shown in ③.
[0144] In the processing method of the system call of the present invention, by configuring the kernel module in the kernel state, adding the system call registration library in the user state, realizing the process of converting the user state system call to the kernel state operation request, and further realizing the execution of the system call. In essence, it converts the fixed and dedicated system call in the user state into the general and dynamic ioctl request in the kernel state. In the whole process of the system call, the largest operating system CPU (Central Processing Unit, central processing unit) overhead is the system call distribution process of the kernel module syscall_stub, but this process only involves one traversal search, and the system call in the related art needs to call the interface between the user state and the kernel state multiple times, and the overhead of the distribution process can be ignored. Therefore, the CPU performance overhead of the operating system in the processing method of the system call of the present invention is very small. And the processing method of the system call of the present invention effectively avoids the problems of multiple interface calls of the kernel state from the user state, can support the online upgrade of the server operating system, ensure the reliability and availability of the system, and can be applied to application scenarios with strict requirements on the high availability of the system. In addition, this solution is also applicable to adding system calls to the kernel, while maintaining the compatibility of Linux (operating system) in related technologies, and supports adding new system calls without recompiling the kernel. It makes up for the defects of adding new system calls in system online upgrade scenarios and other compatible scenarios in related technologies, improves the availability of the system, and can effectively improve product competitiveness.
[0145] Therefore, in the system call processing method, device, system, equipment, medium and program product of the present invention, when receiving a system call in user state in user state, the system call is converted to an operation request in kernel state, the operation request carries the call number of the operation request, and based on the call number, the kernel state application corresponding to the system call is called back. Therefore, by converting the system call in user state into an operation request in kernel state, the system call is implemented, avoiding the problem of downtime required for executing the user state system call directly through the user interface, thereby effectively reducing downtime, completing the operation that requires executing the system call, such as application update, without interrupting user services, and significantly improving the stability of the operating system.
[0146] In this embodiment, a system call processing device is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0147] This embodiment provides a system call processing device, which is applied to an operating system. The operating system has a user state and a kernel state, such as Figure 5 As shown, including:
[0148] A receiving module 501 is used to receive a system call in a user state in a user state;
[0149] A conversion module 502, used for converting a system call into an operation request in kernel mode, where the operation request carries a call number of the operation request;
[0150] The callback module 503 is used to call back the kernel-mode application corresponding to the system call based on the call number.
[0151] In an optional implementation, the conversion module 502 includes:
[0152] The first conversion unit is used to convert the system call into an operation request of the kernel state based on a pre-configured system call list received by the user state from the kernel state.
[0153] In an optional implementation, the callback module 503 includes:
[0154] A number search unit, used to search for a kernel-mode application corresponding to a call number from a pre-configured system call list;
[0155] The callback unit is used to call back kernel-mode applications.
[0156] In an optional implementation, the callback unit includes:
[0157] The request forwarding subunit is used to forward the operation request from the kernel interface calling module to the operating system to implement the call to the kernel state application.
[0158] The system call processing method of the present invention forwards the operation request to the operating system by the kernel interface calling module, effectively realizes the call to the kernel state application, and avoids the interface quantity limitation problem existing in performing system calls through multiple calling interfaces.
[0159] In an optional implementation, the system call processing device further includes:
[0160] A registration request module, used for receiving a registration request for a newly added system call in kernel mode before receiving a system call in user mode;
[0161] Call the configuration module to configure the newly added system call in the system call list.
[0162] In an optional implementation, calling the configuration module includes:
[0163] A configuration unit, used for configuring a newly added system call in a system call list in a kernel state;
[0164] The distribution unit is used to distribute the system call list to the user mode.
[0165] In an optional implementation, the distribution unit includes:
[0166] The device registration subunit is used to register the calling device with the virtual file system of the operating system, and the calling device is used to receive the system call in the user state.
[0167] In an optional implementation, the configuration unit further includes:
[0168] A number allocation subunit is used to allocate call numbers to newly added system calls;
[0169] The number binding subunit is used to bind the call number to the newly added system call.
[0170] In an optional implementation, the configuration unit further includes:
[0171] The compiling subunit is used to compile the system call list into a newly added system application based on the user state after distributing the system call list to the user state.
[0172] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0173] The processing device for the system call in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0174] Based on the above system call processing method, the embodiment of the present invention provides an operating system, and the operating principle diagram of the operating system can be returned to reference Figure 1The operating system has user state and kernel state. In user state, a system call in user state is received. In kernel state, the system call is converted into an operation request in kernel state, the operation request carries the call number of the operation request, and based on the call number, the kernel state application corresponding to the system call is called back.
[0175] In the embodiment of the present invention, a kernel module syscall_stub capable of registering, calling and managing applications is configured in the kernel state. After the kernel module syscall_stub receives the registration request of the new system call newsyscall module, it registers the system call, generates the call number of the new system call, and adds the new system call to the system call list syscall_stub_lib. The system call list syscall_stub_lib is in Figure 1 In the figure, it is shown by multiple rectangular boxes in the kernel module syscall_stub. And the kernel module syscall_stub in the kernel state can synchronize the system call list to the system call registry configured in the user state. The system call registry can be a static library, but the system call registry can be updated based on the system call list sent by the kernel state.
[0176] In an optional implementation, the kernel state is configured with a function kernel module, the function kernel module is configured with a system call list, the function kernel module is used to receive a registration request for a new system call in the kernel state, and configure the new system call in the system call list.
[0177] The function kernel module may refer to the kernel module syscall_stub shown above.
[0178] In an optional implementation, the function kernel module is also used to distribute the system call list to the user mode.
[0179] In an optional implementation, the function kernel module is further used to assign a call number to the newly added system call and bind the call number to the newly added system call.
[0180] In an optional implementation, the kernel state is also used to configure the new system call in the form of a kernel module when the operating system adds a new system call, and send a registration request for the new system call to the function kernel module.
[0181] Among them, the kernel module can refer to the kernel module syscall_stub mentioned above.
[0182] In an optional implementation, the user state is configured with a system call registration library, and the system call registration library is used to receive the system call list distributed by the function kernel module to the user state.
[0183] In an optional implementation, the user state is configured with a system call registry, and the system call registry is used to receive a pre-configured system call list from the kernel state, and an operation request to convert the system call to the kernel state.
[0184] The embodiment of the present invention also provides a computer device having the above Figure 5 The system call processing device is shown.
[0185] See also Figure 6 , Figure 6 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 6 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 10 is taken as an example.
[0186] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0187] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0188] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0189] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0190] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0191] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0192] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0193] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A system call processing method, characterized in that: Applied to an operating system, the operating system having a user state and a kernel state, the method comprising: Receive user-mode system calls in user mode; Convert the system call to an operation request in kernel mode, wherein the operation request carries a call number of the operation request; Based on the call number, a kernel-mode application corresponding to the system call is called back.
2. The method according to claim 1, characterized in that The operation request for converting the system call to the kernel state includes: Based on a pre-configured system call list received by the user state from the kernel state, the system call is converted into an operation request of the kernel state.
3. The method according to claim 1, characterized in that The calling back the kernel-mode application corresponding to the system call based on the call number includes: Searching for a kernel-mode application corresponding to the call number from a preconfigured system call list; Calling back the kernel-mode application.
4. The method according to claim 1, characterized in that: The calling back of the kernel state application includes: The kernel interface calling module forwards the operation request to the operating system to implement the calling of the kernel state application.
5. The method according to claim 1, characterized in that: Before receiving the system call in user mode, the method further includes: Receive registration request for new system calls in kernel mode; The newly added system call is configured in the system call list.
6. The method according to claim 5, characterized in that The configuring the newly added system call in the system call list includes: Configuring the newly added system call in the system call list of kernel state; Distribute the system call list to the user mode.
7. The method according to claim 6, characterized in that The distributing the system call list to the user state includes: A calling device is registered with the virtual file system of the operating system, and the calling device is used to receive the system call in the user mode.
8. The method according to claim 7, characterized in that The configuring the newly added system call in the system call list further includes: Assigning a call number to the newly added system call; The call number is bound to the newly added system call.
9. The method according to claim 6, characterized in that The configuring the newly added system call in the system call list further includes: After distributing the system call list to the user state, the system call list is compiled into the newly added system application based on the user state.
10. A system call processing device, characterized in that: Applied to an operating system, the operating system has a user state and a kernel state, and the device comprises: A receiving module, used for receiving a system call in a user state in a user state; A conversion module, used for converting the system call into an operation request in kernel mode, wherein the operation request carries a call number of the operation request; The callback module is used to call back the kernel-mode application corresponding to the system call based on the call number.
11. An operating system, characterized in that: The operating system has a user state and a kernel state; In the user state, receiving a system call in the user state; In the kernel state, the system call is converted into an operation request in the kernel state, the operation request carries a call number of the operation request; and based on the call number, a kernel state application corresponding to the system call is called back.
12. The operating system according to claim 11, characterized in that: The kernel state is configured with a function kernel module, and the function kernel module is configured with a system call list; The function kernel module is used for receiving a registration request of a newly added system call in kernel mode, and configuring the newly added system call in a system call list.
13. The operating system according to claim 12, characterized in that: The function kernel module is also used to distribute the system call list to the user state.
14. The operating system according to claim 12, characterized in that: The function kernel module is also used to assign a call number to the newly added system call and bind the call number to the newly added system call.
15. The operating system according to claim 12, characterized in that: The kernel state is also used to configure the newly added system call in the form of a kernel module when the operating system adds a new system call, and send a registration request for the newly added system call to the function kernel module.
16. The operating system according to claim 12, characterized in that: The user state is configured with a system call registration library, and the system call registration library is used to receive the system call list distributed by the function kernel module to the user state.
17. The operating system according to claim 11, characterized in that: The user state is configured with a system call registration library, and the system call registration library is used for receiving a pre-configured system call list from the kernel state and an operation request for converting the system call to the kernel state.
18. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the system call processing method according to any one of claims 1 to 9 by executing the computer instructions.
19. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the system call processing method according to any one of claims 1 to 9.
20. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the system call processing method according to any one of claims 1 to 9.
Citation Information
Cited By
Customized calling method and device for credential operation system
CN119473307A