A Linux kernel decoupling method, device and readable storage medium

By introducing the decoupling layer and structure size table into the Linux kernel, the problem of loading failure and crash caused by implicit restrictions of the kernel module is solved, and the stability and compatibility of the kernel module are improved.

CN115113916BActive Publication Date: 2024-10-11GUANGZHOU ANYKA MICROELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210710794.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-22
Publication Date
2024-10-11
Estimated Expiration
2042-06-22

AI Technical Summary

Technical Problem

The changes in structure size and members caused by implicit restrictions in the Linux kernel and kernel modules lead to module loading failures, kernel crashes and other problems, which are difficult to effectively solve with existing technology.

Method used

The decoupling layer is used to encapsulate the kernel structure, and the kernel module can dynamically read and access the structure size through the structure size table and interface to ensure that the kernel module can be loaded and initialized correctly when the kernel configuration items change.

Benefits of technology

It effectively decouples the dependence between the kernel and the kernel module, improves the compatibility and stability of the kernel module, and avoids module loading failures and kernel crashes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115113916B_ABST
    Figure CN115113916B_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of embedded systems, and discloses a Linux kernel decoupling method, device and readable storage medium. The method comprises: encapsulating the structure of the kernel with a decoupling layer, wherein the decoupling layer comprises a structure size table and an interface for reading the structure size table for the kernel module, and the code of the decoupling layer is written in the kernel; when the kernel modifies a configuration item, the kernel and the decoupling layer are recompiled; the kernel module reads the structure size in the structure size table through the interface to achieve decoupling, thereby achieving the effect of solving the technical problem of decoupling of the existing kernel and the kernel module due to implicit restrictions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of embedded technology, and in particular to a Linux kernel decoupling method, device and readable storage medium. Background Art

[0002] Kernel modules are an effective way to add device drivers, file devices, and other components to the Linux kernel without recompiling the kernel or restarting the device. In the manufacturer's PDK release, drivers are often released in the form of kernel modules. Kernel modules are cross-compiled on the development host and then loaded and used on the product. In current use, it is found that when customers modify the kernel configuration and recompile the kernel, the loading module will fail to load the module, the kernel crashes after loading, and the module fails to initialize after loading. These problems are referred to as "Linux kernel and kernel module coupling problems" below.

[0003] After analysis, the main reasons for the Linux kernel-kernel coupling problem are as follows:

[0004] 1. Explicit restrictions on the kernel's module mechanism:

[0005] When the kernel module is compiled, it saves the kernel version number, SMP and PREEMPT information. During the loading process, the kernel module mechanism will check the module's struct module structure CRC check, kernel version number matching and license copyright, so there will be explicit restrictions on loading modules.

[0006] 2. Implicit restrictions: When modifying the kernel configuration, the size and members of the structure may change.

[0007] When the kernel configuration is modified, the size, number of members, and member offsets of certain structures (for example, various structures including the struct module structure) of the kernel and kernel modules change, resulting in the above-mentioned module loading failure, kernel crash OOPS after loading, module initialization failure after loading, and other problems.

[0008] For explicit standards, it is a design necessity; while implicit restrictions are existing problems that need to be solved urgently. Summary of the invention

[0009] To this end, the embodiments of the present application provide a Linux kernel decoupling method and device and a readable storage medium, which can solve the technical problem of decoupling the existing kernel and kernel module due to implicit restrictions. The specific technical solution is as follows:

[0010] In a first aspect, an embodiment of the present application provides a Linux kernel decoupling method, the method comprising:

[0011] The structure of the kernel is encapsulated by using a decoupling layer, wherein the decoupling layer includes a structure size table and an interface for reading the structure size table to the kernel module, and the code of the decoupling layer is written in the kernel;

[0012] When the kernel modifies the configuration item, recompile the kernel and the decoupling layer;

[0013] The kernel module reads the structure size in the structure size table through an interface to achieve decoupling.

[0014] Optionally, the encapsulating the structure of the kernel by using a decoupling layer includes:

[0015] The decoupling layer provides macros that define the interface;

[0016] The interface function of the interface is defined in the kernel through corresponding macros and the interface function is declared. When the kernel is recompiled, the interface function dynamically links the structure size table and the structure members.

[0017] Optionally, the encapsulating the structure of the kernel by using a decoupling layer further includes:

[0018] The decoupling layer provides macros for declaring structures in the structure size table;

[0019] The decoupling layer creates a structure size table in the kernel, declares the structure in the structure size table, and defines a global structure.

[0020] Optionally, the structure size table includes several structure instances;

[0021] The kernel module reads the structure size in the structure size table through an interface, including:

[0022] The kernel module accesses the corresponding table entry in the structure size table through an interface; the table entry records the size of the corresponding structure.

[0023] Optionally, the kernel module reads the structure size in the structure size table through an interface to achieve decoupling, including:

[0024] The kernel module dynamically allocates the memory of the structure through the return value of the interface.

[0025] Optionally, when the kernel modifies the configuration item, recompiling the kernel and the decoupling layer includes:

[0026] When the kernel modifies the configuration item, the kernel and the decoupling layer are recompiled, and the structure size is re-recorded into the structure size table.

[0027] Optionally, the method further includes:

[0028] After the kernel adjusts the position of the structure, if the structure is affected by the kernel configuration item, the kernel module uses the structure member access function provided by the decoupling layer to access the structure members.

[0029] In a second aspect, an embodiment of the present application provides a Linux kernel decoupling device, the device comprising:

[0030] An encapsulation module, used for encapsulating the structure of the kernel by using a decoupling layer, wherein the decoupling layer includes a structure size table and an interface for reading the structure size table to the kernel module, and the code of the decoupling layer is written in the kernel;

[0031] A compiling module, used for recompiling the kernel and the decoupling layer when the kernel modifies the configuration item;

[0032] The decoupling module is used for the kernel module to read the structure size in the structure size table through an interface to achieve decoupling.

[0033] Optionally, the encapsulation module includes:

[0034] A macro definition module, used to implement the decoupling layer to provide macros defining the interface;

[0035] The access module is used to define the interface function of the interface in the kernel through corresponding macros and declare the interface function. When the kernel is recompiled, the interface function dynamically links the structure size table and the structure members.

[0036] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any one of the aforementioned Linux kernel decoupling methods are implemented.

[0037] In summary, compared with the prior art, the technical solution provided in the embodiment of the present application has at least the following beneficial effects:

[0038] The kernel structure is encapsulated with a decoupling layer, which includes a structure size table and an interface. The code of the decoupling layer is written in the kernel. When the kernel configuration items are modified, the kernel will be recompiled and the decoupling layer will be recompiled to update the structure size and the structure size table, thereby realizing the decoupling of the kernel and the kernel module. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 It is a flowchart of a Linux kernel decoupling method provided in one embodiment of the present application. DETAILED DESCRIPTION

[0040] This specific embodiment is merely an explanation of the present application and is not a limitation of the present application. After reading this specification, those skilled in the art may make modifications to the present embodiment without any creative contribution as needed. However, as long as it is within the scope of the claims of the present application, it shall be protected by the patent law.

[0041] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0042] In addition, the term "and / or" in this application is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this application, unless otherwise specified, generally indicates that the associated objects before and after are in an "or" relationship.

[0043] In this application, the terms "first", "second", etc. are used to distinguish identical or similar items with basically the same effects and functions. It should be understood that there is no logical or temporal dependency between "first", "second", and "nth", nor is there any limitation on quantity and execution order.

[0044] In the present application, the term "at least one" means one or more, and the meaning of "plurality" means three or more, for example, a plurality of first positions means three or more first positions.

[0045] The embodiments of the present application are further described in detail below in conjunction with the drawings in the specification.

[0046] An operating system is a program that manages computer hardware and software resources. It is responsible for managing and configuring memory, determining the priority of device resource supply and demand, controlling input and output devices, operating networks, and managing file devices. A kernel is the core of an operating system, which refers to a device software that provides hardware abstraction layer, disk and file device control, multitasking and other functions. The kernel is generally a compressed file. Before using the kernel, it must be decompressed and loaded into memory. In order to cope with the ever-changing hardware, current kernels have the function of reading modular drivers, which is the so-called modularization function. The so-called modularization can be thought of as a plug-in. The plug-in may be provided by the hardware developer, or it may be supported by the kernel. Newer hardware usually requires the hardware developer to provide a driver module.

[0047] Reference Figure 1 In one embodiment of the present application, a Linux kernel decoupling method is provided, and the main steps of the method are described as follows:

[0048] S1: encapsulating the structure of the kernel with a decoupling layer, wherein the decoupling layer includes a structure size table and an interface for reading the structure size table for the kernel module, and the code of the decoupling layer is written in the kernel;

[0049] The decoupling layer provides the kernel module with an interface for accessing structure members. When the offset of a structure member changes due to a kernel configuration item change, the decoupling layer can access the member normally through the structure member access interface. The decoupling layer provides the kernel module with an interface for accessing the structure size. When the size of a structure changes due to a kernel configuration item change, the decoupling layer can obtain the structure size normally through the structure size interface.

[0050] S2: When the kernel modifies the configuration item, recompile the kernel and the decoupling layer;

[0051] Specifically, in this embodiment, the structure of the kernel is encapsulated using a decoupling layer, the decoupling layer includes a structure size table and an interface, and the code of the decoupling layer is written in the kernel. When the configuration items of the kernel are modified, the kernel will be recompiled, and the decoupling layer will be recompiled to update the structure size and the structure size table, which includes several structure instances.

[0052] A decoupling layer is set up so that the kernel module can dynamically obtain the size of the structure in the kernel, dynamically access the structure members, etc., thereby solving the coupling problem between the Linux kernel and the kernel and improving the compatibility of the kernel module.

[0053] S3: The kernel module reads the structure size in the structure size table through an interface to achieve decoupling.

[0054] Specifically, when the kernel configuration items are modified, the kernel is recompiled and the decoupling layer is also recompiled. The entries in the structure size table are structure size instances of some structures affected by the kernel configuration items. When the kernel configuration items are modified and the kernel is recompiled, the structure size table will be updated and initialized to the structure size table.

[0055] The solution of this application proposes a structure size table. Using the structure size table, the correct structure size can be obtained after the kernel configuration is changed. The kernel module can dynamically allocate memory according to the value of the structure size.

[0056] Further, when the kernel modifies the configuration item, recompiling the kernel and the decoupling layer includes:

[0057] When the kernel modifies the configuration item, the kernel and the decoupling layer are recompiled, and the structure size is re-recorded into the structure size table.

[0058] Furthermore, the method further comprises:

[0059] After the kernel adjusts the position of the structure, if the structure is affected by the kernel configuration item, the kernel module uses the structure member access function provided by the decoupling layer to access the structure members.

[0060] Specifically, in an example of the present application, the decoupling layer is an AKMI decoupling layer, and the AKMI decoupling layer provides the kernel module with an interface AKMI_SIZEOF for obtaining the size of a certain structure. The size information of the structure obtained by AKMI_SIZEOF is not affected by the kernel configuration items, that is, the AKMI_SIZEOF decoupling layer implements a series of access functions for structure members. When the kernel configuration items are modified and the kernel is recompiled, the kernel module can still accurately access these structure members. Specifically, when the offset of a member of a structure is affected by a kernel configuration item, modifying the kernel configuration item, recompiling the kernel, and then loading the kernel module will cause a series of coupling problems between the Linux kernel and the kernel module. For this type of situation, the AKMI decoupling layer provides access interfaces to these members affected by the kernel configuration items, such as the ak_mi_xxx_get_of_yyy and ak_mi_xxx_set_of_yyy interfaces.

[0061] Further, the structure size table includes a number of structure instances;

[0062] The kernel module reads the structure size in the structure size table through an interface, including:

[0063] The kernel module accesses the corresponding table entry in the structure size table through an interface; the table entry records the size of the corresponding structure.

[0064] Furthermore, the encapsulation of the kernel structure using a decoupling layer includes: the decoupling layer provides a macro for defining the interface; the interface function of the interface is defined in the kernel through the corresponding macro, and the interface function is declared, and when the kernel is recompiled, the interface function dynamically links the structure size table and the members used to access the structure.

[0065] Furthermore, the decoupling layer provides a macro for declaring a structure in the structure size table; the decoupling layer creates a structure size table in the kernel, declares the structure in the structure size table, and defines a global structure.

[0066] An example of this application is as follows:

[0067] If you need to use the AKMI_SIZEOF interface to obtain the size of a structure, you need to follow the steps below to add the relevant content of the structure. The following takes struct xxx as an example.

[0068] (1) The AKMI decoupling layer creates a structure size table.

[0069] The table entries of the structure size table are the structure sizes of some structures affected by kernel configuration items. When the kernel configuration items are modified and the kernel is recompiled, these table entries will be updated and initialized to the structure size table.

[0070] The structure size table is described using the struct_size_table structure g_struct_size_table, and its initialization process is as follows:

[0071] A. Declare the struct_size_table structure

[0072] 1. The AKMI decoupling module provides the AKMI_SIZE_DEFINE macro, which is used to declare the struct_size_table structure, as follows:

[0073]

[0074]

[0075] B. Define the global struct_size_table structure g_struct_size_table.

[0076]

[0077] (2) AKMI_SIZEOF is used in the kernel to dynamically obtain the size of the structure. The size information of the structure obtained is not affected by the kernel configuration items.

[0078] #define AKMI_SIZEOF(str) (struct_size_table.str)

[0079] In the kernel module, the places where sizeof was used to obtain the size of the structure should be changed to use the AKMI_SIZEOF interface. For example, sizeof(struct xxx) should be changed to AKMI_SIZEOF(xxx).

[0080] 2. The AKMI decoupling layer implements a series of access functions for structure members. When the kernel configuration items are modified and the kernel is recompiled, the kernel module can still accurately access these structure members.

[0081] When the offset of the structure's members is affected by kernel configuration items, modifying the kernel configuration items, recompiling the kernel, and then loading the kernel module will lead to a series of Linux kernel and kernel module coupling problems.

[0082] For this type of situation, the AKMI decoupling layer provides access interfaces to these members affected by kernel configuration items, such as ak_mi_xxx_get_of_yyy and ak_mi_xxx_set_of_yyy interfaces. These interfaces can be used when the position of a structure member is adjusted but the member is still affected by the kernel configuration item.

[0083] ak_mi_xxx_get_of_yyy is the interface for obtaining the yyy member of the structure xxx.

[0084] ak_mi_xxx_set_of_yyy is the interface for assigning the value of the yyy member of the structure xxx (note that if the member is an array, ak_mi_xxx_set_of_yyy cannot be used to assign a value to it, and ak_mi_xxx_get_of_yyy needs to be used in conjunction with interfaces such as memcpy).

[0085] ak_mi_xxx_get_of_yyy and ak_mi_xxx_set_of_yyy interfaces of the AKMI decoupling layer. These interfaces will be recompiled when the kernel configuration items are modified and the kernel is recompiled.

[0086] The ak_mi_xxx_get_of_yyy and ak_mi_xxx_set_of_yyy interfaces provided by the AKMI decoupling layer to the kernel module are dynamically linked when the kernel module is loaded, so that the kernel module can accurately access these members.

[0087] The following takes accessing the int yyy member of struct xxx as an example:

[0088] (1) AKMI decoupling layer implements ak_mi_xxx_get_of_yyy and ak_mi_xxx_set_of_yyy interfaces

[0089] Some macros are provided to facilitate the definition and declaration of interfaces.

[0090] A. Define ak_mi_xxx_get_of_yyy and ak_mi_xxx_set_of_yyy functions

[0091]

[0092] B. Declare ak_mi_xxx_get_of_yyy and ak_mi_xxx_set_of_yyy functions

[0093]

[0094] (2) In the kernel module, use interfaces such as ak_mi_xxx_get_of_yyy and ak_mi_xxx_set_of_yyy to access structure members.

[0095] Note that the places in the driver that previously used "->" to access structure members need to be modified.

[0096] struct xxx*xxx_ptr; int y;

[0097] y = xxx_ptr->yyy;

[0098] Modified to:

[0099] struct xxx*xxx_ptr; int y;

[0100] y=ak_mi_xxx_get_yyy(dev);

[0101] 3. Kernel module structure definition method

[0102] The general structure definition has the following situations:

[0103] (1) Structures dynamically defined in kernel modules;

[0104] (2) A structure defined in the Linux kernel, whose pointer is passed to the kernel module;

[0105] (3) Structures statically defined in kernel modules.

[0106] If the structure is affected by kernel configuration items, it cannot be statically defined in the kernel module (i.e. the third point), because the size and members of the statically defined variables are already determined during the compilation phase. The AKMI decoupling layer cannot dynamically obtain the size of the structure, nor can it dynamically access the structure members. Therefore, the AKMI decoupling layer only supports the decoupling of the first and second defined variables.

[0107] When the size of the structure and the offset of its members are affected by kernel configuration items, the kernel module can achieve decoupling by defining the structure as follows:

[0108] (1) Use the AKMI_SIZEOF interface to obtain the structure size. Do not use sizeof.

[0109] (2) Dynamically allocate the memory of the structure based on the return value of AKMI_SIZEOF.

[0110] (3) When the kernel module defines a structure according to the above method and accesses the structure members through the member access interface of the structure provided by the decoupling layer, the kernel module can be decoupled from the Linux kernel without the need for special processing of the kernel module.

[0111] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0112] In one embodiment of the present application, a Linux kernel decoupling device is provided, and the Linux kernel decoupling device corresponds one-to-one to the Linux kernel decoupling method in the above embodiment. The Linux kernel decoupling device includes:

[0113] An encapsulation module, used for encapsulating the structure of the kernel by using a decoupling layer, wherein the decoupling layer includes a structure size table and an interface for reading the structure size table to the kernel module, and the code of the decoupling layer is written in the kernel;

[0114] A compiling module, used for recompiling the kernel and the decoupling layer when the kernel modifies the configuration item;

[0115] The decoupling module is used for the kernel module to read the structure size in the structure size table through an interface to achieve decoupling.

[0116] Optionally, the encapsulation module includes:

[0117] A macro definition module, used to implement the decoupling layer to provide macros defining the interface;

[0118] The access module is used to define the interface function of the interface in the kernel through corresponding macros and declare the interface function. When the kernel is recompiled, the interface function dynamically links the structure size table and the structure members.

[0119] Optionally, the encapsulating the structure of the kernel by using a decoupling layer further includes:

[0120] The decoupling layer provides macros for declaring structures in the structure size table;

[0121] The decoupling layer creates a structure size table in the kernel, declares the structure in the structure size table, and defines a global structure.

[0122] Optionally, the structure size table includes several structure instances;

[0123] The kernel module reads the structure size in the structure size table through an interface, including:

[0124] The kernel module accesses the corresponding table entry in the structure size table through an interface; the table entry records the size of the corresponding structure.

[0125] Optionally, the kernel module reads the structure size in the structure size table through an interface to achieve decoupling, including:

[0126] The kernel module dynamically allocates the memory of the structure through the return value of the interface.

[0127] Optionally, when the kernel modifies the configuration item, recompiling the kernel and the decoupling layer includes:

[0128] When the kernel modifies the configuration item, the kernel and the decoupling layer are recompiled, and the structure size is re-recorded into the structure size table.

[0129] Optionally, the method further includes:

[0130] After the kernel adjusts the position of the structure, if the structure is affected by the kernel configuration item, the kernel module uses the structure member access function provided by the decoupling layer to access the structure members.

[0131] Each module of the above-mentioned Linux kernel decoupling device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0132] In one embodiment of the present application, a computer device is provided, which may be a server. The computer device includes a processor, a memory and a network interface connected by a device bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device can be implemented by any type of volatile or non-volatile storage device or a combination thereof, and the volatile or non-volatile storage device includes but is not limited to: a disk, an optical disk, an EEPROM (Electrically-Erasable Programmable Read Only Memory), an EPROM (Erasable Programmable Read Only Memory), an SRAM (Static Random Access Memory), a ROM (Read-Only Memory), a magnetic memory, a flash memory, and a PROM (Programmable Read-Only Memory). The memory of the computer device provides an environment for the operation of the operating device and the computer program stored therein. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by a processor, the steps of the Linux kernel decoupling method described in the above embodiment are implemented.

[0133] In one embodiment of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the Linux kernel decoupling method described in the above embodiment are implemented. The computer-readable storage medium includes a ROM (Read-Only Memory), a RAM (Random-Access Memory), a CD-ROM (Compact Disc Read-Only Memory), a magnetic disk, a floppy disk, etc.

[0134] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device described in the present application is divided into different functional units or modules to complete all or part of the functions described above.

Claims

1. A Linux kernel decoupling method, characterized in that: The method comprises: The structure of the kernel is encapsulated by using a decoupling layer, the decoupling layer includes a structure size table and an interface for the kernel module to read the structure size table, and the code of the decoupling layer is written in the kernel; specifically, the decoupling layer provides a macro for defining the interface; an interface function of the interface is defined in the kernel through a corresponding macro, and the interface function is declared, and when the kernel is recompiled, the interface function dynamically links the structure size table and the structure member; When the kernel modifies the configuration item, recompile the kernel and the decoupling layer; The kernel module reads the structure size in the structure size table through an interface to achieve decoupling.

2. The Linux kernel decoupling method according to claim 1, characterized in that: The structure of the core is encapsulated by using a decoupling layer, and further comprises: The decoupling layer provides macros for declaring structures in the structure size table; The decoupling layer creates a structure size table in the kernel, declares the structure in the structure size table, and defines a global structure.

3. The Linux kernel decoupling method according to claim 1, characterized in that: The structure size table includes several structure instances; The kernel module reads the structure size in the structure size table through an interface, including: The kernel module accesses the corresponding table entry in the structure size table through an interface; The table entry records the size of the corresponding structure.

4. The Linux kernel decoupling method according to claim 1, characterized in that: The kernel module reads the structure size in the structure size table through an interface to achieve decoupling, including: The kernel module dynamically allocates the memory of the structure through the return value of the interface.

5. The Linux kernel decoupling method according to claim 1, characterized in that: When the kernel modifies the configuration item, the kernel and the decoupling layer are recompiled as follows: When the kernel modifies the configuration item, the kernel and the decoupling layer are recompiled, and the structure size is re-recorded into the structure size table.

6. The Linux kernel decoupling method according to claim 1, characterized in that: The method further comprises: After the kernel adjusts the position of the structure, if the structure is affected by the kernel configuration item, the kernel module uses the structure member access function provided by the decoupling layer to access the structure members.

7. A Linux kernel decoupling device, characterized in that: The device comprises: An encapsulation module, used for encapsulating the structure of the kernel by using a decoupling layer, wherein the decoupling layer includes a structure size table and an interface for reading the structure size table to the kernel module, and the code of the decoupling layer is written in the kernel; Specifically, the decoupling layer provides a macro for defining the interface; the encapsulation module is used to define the interface function of the interface in the kernel through the corresponding macro and declare the interface function, and when the kernel is recompiled, the interface function dynamically links the structure size table and the structure member; A compiling module, used for recompiling the kernel and the decoupling layer when the kernel modifies the configuration item; The decoupling module is used for the kernel module to read the structure size in the structure size table through an interface to achieve decoupling.

8. The Linux kernel decoupling device according to claim 7, characterized in that: The packaging module comprises: A macro definition module, used to implement the decoupling layer to provide macros defining the interface; The access module is used to define the interface function of the interface in the kernel through corresponding macros and declare the interface function. When the kernel is recompiled, the interface function dynamically links the structure size table and the structure members.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the Linux kernel decoupling method according to any one of claims 1 to 6 are implemented.