Linux kernel cross-partition service access method, device, medium and program product

By using a two-level page table switching mechanism between the EL1 kernel layer and the EL2 isolation layer in the Linux system, the problem of low-security-level component failures spreading to high-security-level components is solved, achieving efficient isolation and reliability between Linux kernel-mode components and meeting the isolation requirements of security-critical scenarios.

CN123138148APending Publication Date: 2026-11-20ZEBRED NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611066602.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-16
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

Existing technologies cannot effectively prevent memory failures in low-security-level components from spreading to high-security-level components, causing the system security isolation mechanism to fail in the Linux monolithic kernel environment.

Method used

By introducing the EL1 kernel layer and EL2 isolation layer into the Linux system and utilizing the second-level page table switching mechanism, the target memory partition is determined when a cross-partition service request is made, and the system switches to the second-level page table of the target memory partition. The service is executed in the address space of the target memory partition to complete the target service call, and then switches back to the second-level page table of the source memory partition to return the target service result.

Benefits of technology

It improves the fine-grainedness and reliability of spatial isolation between Linux kernel-mode components, ensuring that collaborative calls between components of different security levels do not affect system security isolation, and meets the requirement of preventing the propagation of faults in security-critical scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123138148A_ABST
    Figure CN123138148A_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a Linux kernel cross-partition service access method, device, medium and program product. When a source kernel component in a source memory partition initiates a cross-partition service request, the target memory partition is first identified, and then the secondary page table used by the current address conversion is switched, the target service execution is completed in the address space corresponding to the target memory partition, and after completion, the source partition page table is restored and the result is returned. The method dynamically switches and restores the secondary page table according to the service access process, directly switches the secondary page table corresponding to the target memory partition to realize the Linux kernel cross-partition service access, and improves the isolation reliability of the access between the kernel components.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, device, medium, and program product for accessing cross-partition services in Linux kernel mode. Background Technology

[0002] Safety-critical industries such as autonomous driving and aerospace generally use monolithic kernel architecture operating systems, which require strict isolation and non-interference between components of different security levels. Because all kernel modules of the system share the address space, memory errors can easily cross-spread between components of different security levels.

[0003] Currently, the industry mostly uses dynamic software testing and static source code analysis techniques to detect code vulnerabilities such as memory out-of-bounds access and wild pointer access in third-party driver modules, thereby avoiding program anomalies at the coding level.

[0004] However, existing technologies cannot prevent faults from propagating across security domains. Memory faults in low-security-level components can directly spread to high-security-level core modules, causing the system's security isolation mechanism to fail. Summary of the Invention

[0005] This application provides a method, device, medium, and program product for accessing cross-partition services in the Linux kernel state to solve the aforementioned technical problems. This method targets different memory partitions in a Linux system. While maintaining the isolation between memory partitions, it identifies and processes cross-partition service requests initiated by the source memory partition, determines the target memory partition corresponding to the service request, and adapts the processing context to the address space of the target memory partition during service execution to complete the target service call and return the result. This approach balances the cross-partition collaboration requirements of kernel-state components and the partition isolation requirements in a Linux monolithic kernel environment.

[0006] In a first aspect, embodiments of this application provide a method for accessing cross-partition services in Linux kernel mode, applied to a Linux system. The Linux system includes an EL1 kernel layer and an EL2 isolation layer. The EL1 kernel layer includes multiple memory partitions, each memory partition being configured with a corresponding second-level page table. The method includes:

[0007] Receive cross-partition service requests initiated by source kernel components in the source memory partition;

[0008] The target memory partition is determined based on the cross-partition service request;

[0009] Obtain the second-level page table corresponding to the target memory partition, and switch the second-level page table corresponding to the current address translation to the second-level page table corresponding to the target memory partition;

[0010] Establish the address translation relationship corresponding to the target memory partition based on the second-level page table corresponding to the target memory partition, and execute the target service in the address space corresponding to the target memory partition.

[0011] After the target service is executed, the second-level page table corresponding to the current address translation is switched back to the second-level page table corresponding to the source memory partition, and the execution result corresponding to the target service is returned to the source kernel component.

[0012] Optionally, obtaining the second-level page table corresponding to the target memory partition and switching the second-level page table corresponding to the current address translation to the second-level page table corresponding to the target memory partition includes:

[0013] Obtain the target memory partition identifier corresponding to the cross-partition service request;

[0014] Find the second-level page table corresponding to the target memory partition based on the target memory partition identifier;

[0015] Switch the second-level page table corresponding to the current address translation to the second-level page table corresponding to the target memory partition.

[0016] Optionally, the step of establishing the address translation relationship corresponding to the target memory partition based on the second-level page table corresponding to the target memory partition, and executing the target service in the address space corresponding to the target memory partition, includes:

[0017] Address translation is performed based on the second-level page table corresponding to the target memory partition to obtain the physical address after address translation;

[0018] The physical memory region corresponding to the target memory partition is accessed using the physical address after address translation, and the target service is executed in the address space corresponding to the target memory partition.

[0019] Optionally, the step of switching the second-level page table corresponding to the current address translation back to the second-level page table corresponding to the source memory partition, and returning the execution result corresponding to the target service to the source kernel component, includes:

[0020] Obtain the second-level page table corresponding to the source memory partition;

[0021] Switch the second-level page table corresponding to the current address translation back to the second-level page table corresponding to the source memory partition;

[0022] The address translation relationship is reconstructed based on the second-level page table corresponding to the source memory partition, and the address space of the source memory partition is restored.

[0023] Based on the restored source memory partition address space, the execution result corresponding to the target service is returned to the source kernel component.

[0024] Optional, also includes:

[0025] An interruption request was received during the execution of the target service;

[0026] The corresponding interrupt handling memory partition is determined based on the interrupt request;

[0027] Switch the second-level page table corresponding to the current address translation to the second-level page table corresponding to the interrupt handling memory partition;

[0028] The interrupt service routine corresponding to the interrupt request is executed in the address space corresponding to the interrupt handling memory partition.

[0029] After the interrupt service routine is completed, the second-level page table corresponding to the current address translation is switched back to the second-level page table corresponding to the memory partition before the interrupt occurred.

[0030] Optional, also includes:

[0031] An address translation anomaly was detected during the address translation process of the second-level page table.

[0032] Obtain the fault address information and access type information corresponding to the address translation anomaly;

[0033] Based on the fault address information and the access type information, the corresponding abnormal access behavior is determined;

[0034] Based on the abnormal access behavior, the exception handling mechanism is triggered.

[0035] Optionally, the exception handling mechanism includes at least one of the following:

[0036] Log exceptions;

[0037] Generate alarm information;

[0038] Block the abnormal access behavior;

[0039] Isolate the memory partition corresponding to the abnormal access behavior.

[0040] Secondly, embodiments of this application provide a Linux kernel-mode cross-partition service access device, applied to a Linux system. The Linux system includes an EL1 kernel layer and an EL2 isolation layer. The EL1 kernel layer includes multiple memory partitions, each memory partition being configured with a corresponding second-level page table. The device includes:

[0041] The receiving module is used to receive cross-partition service requests initiated by the source kernel components in the source memory partition;

[0042] The determination module is used to determine the target memory partition based on the cross-partition service request;

[0043] The switching module is used to obtain the second-level page table corresponding to the target memory partition and switch the second-level page table corresponding to the current address translation to the second-level page table corresponding to the target memory partition.

[0044] The execution module is used to establish the address translation relationship corresponding to the target memory partition based on the second-level page table corresponding to the target memory partition, and to execute the target service in the address space corresponding to the target memory partition;

[0045] The return module is used to switch the second-level page table corresponding to the current address translation back to the second-level page table corresponding to the source memory partition after the target service is executed, and return the execution result corresponding to the target service to the source kernel component.

[0046] Thirdly, embodiments of this application provide an electronic device, including: a processor, and a memory communicatively connected to the processor;

[0047] The memory stores computer-executed instructions;

[0048] The processor executes the computer execution instructions stored in the memory to implement the Linux kernel-mode cross-partition service access method described in the first aspect and various possible designs of the first aspect.

[0049] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions. When a processor executes the computer-executable instructions, it implements the Linux kernel-mode cross-partition service access method described in the first aspect and various possible designs of the first aspect.

[0050] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the Linux kernel-mode cross-partition service access method as described in the first aspect and various possible designs of the first aspect.

[0051] This application provides a method, device, medium, and program product for cross-partition service access in Linux kernel mode. It receives a cross-partition service request initiated by a source kernel component in a source memory partition, determines the target memory partition based on the request, obtains the second-level page table corresponding to the target memory partition, switches the current address translation-based second-level page table to the target memory partition's second-level page table, establishes an address translation relationship for the target memory partition based on the target memory partition's second-level page table, executes the target service in the address space corresponding to the target memory partition, and after the target service execution is complete, switches the current address translation-based second-level page table back to the source memory partition's second-level page table and returns the execution result. This ensures that the service execution process is always constrained by the target memory partition's address translation relationship and access permissions in Linux kernel mode cross-partition service access scenarios. This improves the fine-grainedness, reliability, and protection capabilities of spatial isolation between kernel components in the Linux monolithic kernel environment while meeting the collaborative calling requirements of kernel components with different security levels. Attached Figure Description

[0052] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0053] Figure 1 A schematic diagram of a partitioned memory isolation architecture for cross-partition service access in Linux kernel mode provided in this application embodiment;

[0054] Figure 2 A flowchart illustrating the Linux kernel-mode cross-partition service access method provided in this application embodiment;

[0055] Figure 3 This is a flowchart illustrating the cross-partition synchronous page table switching execution process provided in an embodiment of this application.

[0056] Figure 4 This is a flowchart illustrating the cross-partition synchronous callback page table switching execution process provided in an embodiment of this application.

[0057] Figure 5 A flowchart of the partition page table switching interrupt handling provided in this application embodiment;

[0058] Figure 6 This application provides a diagram illustrating the architecture of a partner system partition migration type.

[0059] Figure 7 A three-layer stack protection security detection link diagram provided for embodiments of this application;

[0060] Figure 8 A schematic diagram of the structure of the Linux kernel-mode cross-partition service access device provided in the embodiments of this application;

[0061] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0062] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0063] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can also include other sequential examples besides those illustrated or described. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0064] Linux monolithic kernel isolation technology is widely used in safety-critical computing scenarios such as intelligent driving, industrial control, and rail transportation. These systems typically need to simultaneously host safety-critical and non-safety components in the same kernel environment, while meeting the comprehensive requirements of high reliability, low latency, and verifiable isolation.

[0065] In such scenarios, the system typically relies on the processor, kernel, and memory management mechanisms to work together to support the coexistence and interaction of drivers, kernel services, and security-related tasks in a unified operating environment.

[0066] Existing solutions typically enhance system isolation capabilities through virtualization, microkernel modifications, or access control mechanisms. This involves imposing permission constraints on operating system instances, user-mode processes, or peripheral access paths, thereby reducing mutual interference between different software modules. In a Linux environment, kernel policy checks or peripheral-side address mapping can also restrict some illegal accesses.

[0067] However, the above solutions mainly target operating system-level, process-level, or DMA (Direct Memory Access) level isolation, and are insufficiently constrained by the issue of multiple kernel-mode components sharing the address space within the Linux monolithic kernel. If a low-security-level component experiences pointer out-of-bounds errors, abnormal writes, or erroneous calls, it may still directly affect the memory region where a high-security-level component resides, making it difficult to achieve hardware-enforced, fine-grained, and verifiable space isolation.

[0068] Meanwhile, existing technologies often lack a unified mechanism for partition-level switching based on the current address translation relationship during cross-component service access. The isolation guarantee in dynamic memory allocation and kernel service call chain is discontinuous, which limits the isolation granularity, reliability and consistency throughout the life cycle, making it difficult to meet the requirements of non-propagation of faults in safety-critical scenarios.

[0069] To address the aforementioned issues, this application proposes a Linux kernel-mode cross-partition service access method. When a source kernel component in a source memory partition initiates a cross-partition service request, the target memory partition is first determined, then the second-level page table corresponding to the target memory partition is obtained and switched to. The target service is executed in the address space corresponding to the target memory partition. After the target service is completed, the process switches back to the second-level page table corresponding to the source memory partition and returns the execution result, thereby improving the isolation reliability and controllability of service access between kernel-mode components.

[0070] The technical solutions of this application will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0071] Figure 1 This is a schematic diagram of a partitioned memory isolation architecture for cross-partition service access in Linux kernel mode, provided in an embodiment of this application. Figure 1 As shown, it includes:

[0072] The partitioned memory isolation system consists of four layers: the compilation and build layer, the EL1 kernel layer, the EL2 isolation layer, and the hardware layer. These four layers are sequentially connected and work together to complete the entire process of partition isolation and cross-partition service access in the Linux kernel mode. The compilation and build layer includes linker scripts (implementing section partitioning) and compiler plugins (implementing partition marking and boundary instrumentation). The compiled output kernel image adapted to the partition constraints is input down to the EL1 kernel layer. The EL1 kernel layer runs Linux kernel-mode components and internally divides into three major memory partitions: SAFETY partition (security partition), CORE partition (kernel partition), and QM partition (quality management partition). Interaction between partitions is achieved by switching across partition call boundaries. The CORE partition outputs the IPA (Intermediate Physical Address) space, managed by the memory management subsystem, down to the EL2 isolation layer. The EL2 isolation layer uses a hypervisor to manage page table contexts and maintains SAFETY, CORE, and QM second-level page tables. Each of the three types of second-level page tables executes an IPA→PA (Physical Address) translation path to connect to the underlying hardware layer. The hardware layer relies on the MMU (Memory Management Unit) to complete two-level address translation, ultimately mapping to physical memory PA. Physical memory is statically divided into three independent memory regions: the SAFETY pool, the CORE pool, and the QM pool.

[0073] The compilation and build layer is divided into two main functional modules: the linker script is responsible for section partitioning, and the compiler plugin is responsible for partition marking and boundary instrumentation. These two tools work together to constrain the partition ownership of kernel code and data segments during the compilation phase. The processed kernel image is then loaded into the EL1 kernel layer for execution. The EL1 kernel layer contains three independent partitions: the SAFETY partition carries security drivers / kernel threads, the QM partition carries third-party drivers / kernel threads, and both the SAFETY and QM partitions access the CORE partition through cross-partition call boundary switching paths. The CORE partition has built-in kernel infrastructure, covering basic scheduling, interrupt, and memory management capabilities. A memory management subsystem is mounted below the CORE partition. This subsystem integrates memblock (memory block manager), buddy system, slab (memory allocator), vmalloc (virtual memory allocation), percpu (memory), and DMA (direct memory access) – a complete set of memory management functions. It is responsible for managing the IPA space and passing it down to the EL2 isolation layer. The EL1 kernel layer only operates on intermediate IPA addresses and cannot directly access the underlying real physical memory.

[0074] The core of the EL2 isolation layer is the Hypervisor, which is responsible for unified page table context management. The Hypervisor maintains three independent page tables: SAFETY second-level page table, CORE second-level page table, and QM second-level page table. Each of the three second-level page tables generates an independent IPA→PA translation channel, which is connected to the MMU unit in the hardware layer. The hardware layer consists of two parts: the MMU and the physical memory PA. The MMU provides two-level address translation hardware capabilities, receiving IPA addresses from the EL2 isolation layer to complete the final address resolution. The underlying physical memory PA is statically divided into non-overlapping SAFETY pools, CORE pools, and QM pools, respectively matching the resource requirements of the three types of memory partitions in the upper layer. Relying on two-level address translation and independent second-level page tables, strong physical memory isolation of SAFETY, CORE, and QM partitions is achieved at the hardware level.

[0075] Figure 2 This is a flowchart illustrating a Linux kernel-mode cross-partition service access method provided in an embodiment of this application. The method in this embodiment can be executed by a Linux system. Figure 2 As shown, the method in this embodiment may include:

[0076] S101: Receive cross-partition service requests initiated by the source kernel component in the source memory partition.

[0077] Cross-partition service requests refer to the request information generated when a source kernel component calls a target service within another memory partition. Cross-partition service requests can include call origination information, target service identification information, call parameters, and execution return information.

[0078] Source memory partitions refer to kernel memory partitions that are statically divided by the kernel according to the functional safety integrity level. Source memory partitions include SAFETY partitions, CORE partitions, and QM partitions.

[0079] The source kernel component refers to the kernel-mode execution entity deployed and running inside the source memory partition. Specifically, it includes the partition driver, kernel threads, and kernel underlying infrastructure code, and is the initiator of cross-partition calls.

[0080] Optionally, memory partitioning follows the core principle that higher security integrity levels correspond to stricter memory write protection control, and faults in low-level partitions cannot propagate to high-level partitions. The SAFETY partition carries security-related drivers and security kernel threads, possessing high functional security integrity and using a dedicated security physical memory pool. The CORE partition carries Linux kernel infrastructure such as task scheduling, interrupts, and memory management, possessing medium functional security integrity and using a dedicated kernel physical memory pool. The QM partition carries third-party drivers and kernel threads without quality assurance, possessing low functional security integrity and using a dedicated quality control physical memory pool. Each partition statically declares its own physical memory range through the Device Tree Source (DTS) file. During the device power-on and startup phase, the ARM64 architecture virtualization exception level (EL2) uniformly completes the memory page table permissions and mapping configuration. The partition ownership of a component does not support dynamic adjustment or change during kernel runtime. The layered memory isolation mechanism is used to achieve fault isolation and differentiated memory write protection control for components with different security levels.

[0081] For example, source kernel components uniformly submit cross-partition service requests via the boundary switching layer. Before submission, input parameters are standardized, and the service identifier, call parameters, return address, and register context are written into a request description structure in a permission-controlled shared control area. The Linux system employs two request reception paths: First, during kernel image compilation at the build layer, cross-partition call wrapper code is generated, replacing the component's native call logic. At runtime, the wrapper code assembles the request and reports it to the EL1 kernel layer. Second, at runtime, registered cross-partition calls are directly identified, and the source kernel component is located to receive the request. Upon receiving the request, the EL1 kernel layer performs a validity check. If the check passes, the call is bound to the page table context information, and the call is transferred to a controlled execution flow. Simultaneously, it supports both synchronous blocking and asynchronous registration call modes to adapt to different kernel operating scenarios.

[0082] Cross-partition service request reception is subject to several boundary constraints: all cross-partition calls must be submitted through the unified entry point of the boundary switching layer, and bypassing control is prohibited; call reception is not limited to specific partitions and component types, and any compliant kernel component within the three types of memory partitions can initiate the call; the request reception phase does not rely on the kernel's global shared address space for addressing, and all requests are handled by the EL2 isolation layer; the overall process must strictly adhere to layered responsibilities, with each layer performing its own duties, and no layer may be skipped to directly execute cross-partition calls, ensuring memory partition isolation and call security.

[0083] S102: Determine the target memory partition based on the cross-partition service request.

[0084] The target memory partition is the memory partition that carries the target service to be called in the cross-partition service request. The EL1 kernel layer divides the memory partitions into three types: SAFETY partition, CORE partition, and QM partition. Each partition is configured with an independent second-level page table in the EL2 isolation layer. The second-level page table stores the IPA to PA address mapping and physical memory access permissions. The identification result of the target memory partition directly determines the second-level page table object that needs to be switched later. The service routing table and service mapping relationship are used to establish the association mapping between cross-partition service requests and target memory partitions. The routing table can be statically generated by the compilation and build layer or dynamically generated by kernel initialization. Before the target memory partition is determined, the system will not perform page table replacement.

[0085] Optionally, the EL2 layer hypervisor maintains a separate set of independent Stage-2 page tables (IPA to PA) for each business partition within the system. Each time a context switch operation is performed between different partitions, the hypervisor synchronously loads and replaces the target partition's dedicated Stage-2 page table, thereby isolating the address translation views of each partition. The overall memory permission matrix follows the integrity level isolation design principle, stipulating that low-integrity-level partitions can only perform read-only access to the memory occupied by high-integrity-level partitions. This blocks the risk of code vulnerabilities in low-integrity partitions and abnormal operations tampering with memory data in high-integrity partitions from the hardware address translation level. The permission rules for each partition to access the SAFETY, CORE, and QM memory regions are as follows: The SAFETY partition has read and write permissions for all three types of memory. The CORE partition can only access SAFETY memory in read-only mode, and supports read and write access to CORE and QM memory. The QM partition can only access SAFETY and CORE memory in read-only mode, and only has read and write permissions for its own QM memory. This permission constraint is implemented based on the access attribute configuration of page table entries corresponding to different physical memory ranges in the independent second-level page table of each partition. Taking the second-level page table of the QM partition as an example, the page table entries pointing to the SAFETY physical memory range are uniformly configured as read-only. Once the QM partition's running code initiates a write operation request for SAFETY memory, the MMU will directly trigger a storage abort exception in the Stage-2 address translation process. The exception is captured and handled by the EL2 Hypervisor. During the entire process, the original memory data of the SAFETY partition will not be modified or destroyed.

[0086] For example, the EL1 kernel layer pre-maintains service mapping relationships. Upon receiving a cross-partition service request, it determines the target partition using two paths: if the cross-partition service request carries a target memory partition identifier, the EL1 kernel layer locks the candidate partition based on the identifier and verifies the service-partition ownership matching relationship; if the cross-partition service request only carries service interface and service identifier information, it queries the pre-stored service mapping relationship to retrieve the target partition and reads the partition's runtime information. This process includes two implementation schemes: in the static compilation scheme, the compilation build layer generates a partition identifier for the cross-partition service, and the source kernel component writes the identifier into the request by calling the wrapper code; in the dynamic registration scheme, the target service completes registration with the EL1 kernel layer during initialization, and the registration information is stored in the service mapping relationship for runtime matching. Simultaneously, the EL2 isolation layer can participate in the determination, first verifying that the service identifier exists in the service routing table, then parsing the corresponding target partition and service entry point. For scenarios where the QM partition calls the SAFETY partition, it additionally verifies the call permissions in conjunction with the access policy. After identifying the partition, the EL1 kernel layer performs a legality check. If the check fails, the cross-partition access is terminated; if the check passes, the target partition and execution-related context information are retained.

[0087] The EL1 kernel layer divides the system into three functional security partitions and maintains service mapping relationships. The EL2 isolation layer configures independent second-level page tables for each partition. Traditional kernel calls directly pass memory addresses, posing a risk of unauthorized cross-partition access. This solution resolves partition ownership through service identifiers, transforming direct address calls into a controlled partition access mode. It pre-locks a unique target partition and its corresponding second-level page table switching object, ensuring a clear context for subsequent page table switching and guaranteeing consistency between the execution subject and address space switching object of cross-partition calls. Simultaneously, relying on partition description information and access permission policies, it implements permission control for calls between partitions of different security levels, performing partition legality verification before page table switching, and logically preventing unauthorized cross-partition memory access.

[0088] S103: Obtain the second-level page table corresponding to the target memory partition, and switch the second-level page table corresponding to the current address translation to the second-level page table corresponding to the target memory partition.

[0089] In the ARM64 two-level address translation architecture, the second-level page table specifically refers to the Stage-2 page table maintained by the EL2 isolation layer, which is responsible for completing the address mapping from IPA to PA and restricting the read, write and execution permissions of each physical memory pool through page entry attributes. The system generates independent second-level page tables for the three types of memory partitions: SAFETY, CORE and QM, and only opens access permissions to the corresponding physical memory area to this partition. In other hierarchical address translation architectures, it can also refer to the set of lower-level page tables bound to the execution context.

[0090] For example, the second-level page table corresponding to the current address translation is switched to the second-level page table corresponding to the target memory partition. This is the Stage-2 page table currently in effect on the EL2 side during the CPU's execution of the source kernel component, i.e., the second-level page table associated with the source memory partition, which determines the physical memory range and access permissions visible to the current hardware context. The EL2 page table base address control register is updated, and in conjunction with memory synchronization barriers and Stage-2 TLB invalidation operations, the Stage-2 mapping rules used by the CPU hardware address translation are replaced. Only the IPA-PA mapping relationship on the EL2 side is changed; the EL1 layer virtual address layout remains unchanged. This is used to save the base address of the source partition's second-level page table, the exception return address, and the register context before the switch.

[0091] During the Linux system initialization phase, the Hypervisor in EL2 reads the physical memory ranges of the SAFETY pool, CORE pool, and QM pool, pre-creates independent second-level page tables for each partition, and configures access permissions for each physical memory region according to security policies. After determining the target memory partition, the EL2 isolation layer first completes two pre-operations: first, it reads the target memory partition's dedicated second-level page table; second, it reads the source partition's second-level page table information currently active on the CPU, writing the source partition's page table base address, register context, and return address into the cross-partition switching record. Then, it executes the complete page table switching process: writing the target partition's second-level page table base address into the EL2 control register, sequentially executing the data synchronization barrier, instruction synchronization barrier, and Stage-2 TLB invalidation instruction, and clearing the old address translation cache; if the CPU is not in an interrupt-masked region, the boundary switching layer enhances the atomicity of the switching process, preventing the insertion of other partition contexts during the switch. Different logic is adapted for different hardware scheduling granularities: in multi-core scenarios, the switching operation only applies to the currently executing processor core; in task scheduling scenarios, the page table context can be written into the task structure. After the switch is completed, the hardware MMU only follows the permission constraints of the target partition's second-level page table when performing address translation. Memory addresses that are accessible to the source partition but not authorized by the target partition will be directly intercepted during the Stage-2 translation phase. The service follows the hardware access control rules of the target partition throughout the entire process.

[0092] By replacing the independent second-level page table, hardware-enforced access control is implemented. Illegal access behaviors such as wild pointers and out-of-bounds writes generated by low-integrity partitions are directly intercepted by the MMU during the Stage-2 address translation stage, without relying on software active verification. This meets the strong isolation requirements for functional safety. At the same time, the source partition's page table, registers, and other context information are completely saved before the switch. After the target service is completed, the source partition's operating environment can be completely restored based on the retained records. Furthermore, the second-level page tables of each partition are statically created by the EL2 Hypervisor based on the device tree during system startup. During runtime, only the page table base address register is modified and the switch is completed in conjunction with TLB refresh, without the need for dynamic reconstruction of the page table. This balances the execution continuity and operating performance of cross-partition calls.

[0093] S104: Establish the address translation relationship corresponding to the target memory partition based on the second-level page table corresponding to the target memory partition, and execute the target service in the address space corresponding to the target memory partition.

[0094] The address translation relationship is a two-level address mapping system under the ARM64 architecture. First, EL1 completes the first-level translation from virtual address VA to intermediate address IPA. Then, relying on the loaded and effective second-level page table of the target partition, the Stage-2 mapping from IPA to the real physical address PA is completed.

[0095] The address space corresponding to the target memory partition refers to the entire range of IPA virtual addresses belonging to that partition within the EL1 kernel layer.

[0096] The target service is a variety of kernel function code deployed in the target partition, covering device control interface, security policy calculation interface, status query interface, scheduling and driver processing logic. Its runtime instruction fetching, data reading and writing, and return value writing are all constrained by the mapping range and permission bits of the current second-level page table.

[0097] For example, after loading the target partition's second-level page table, there's no need to regenerate the entire address mapping. The hardware layer will apply the address translation relationship to all subsequent instruction values, data reads and writes, and parameter interactions in real time, based on the currently effective second-level page table. After the page table switch is completed, the CPU maintains the EL1 runtime level and resolves the target service entry address through the service routing table or the target partition's exported symbol table. The boundary switching layer, using a controlled shared area or dedicated parameter buffer, passes the parameters carried in the cross-partition request to the target service according to the kernel calling convention. The target service runs entirely in the target partition's dedicated IPA address space. Access to its own private data structures, buffers, and function tables will all undergo address translation and permission verification through the target's second-level page table. If it needs to read cross-partition public data, it can access the globally shared bridging metadata area. During execution, if the code attempts to access a memory page beyond the permissions mapped by the second-level page table, the MMU will trigger a Stage-2Abort exception during the Stage-2 address translation phase, which will be handled by the EL2 isolation layer. If the business completes normally, the target service will write the result code, output parameters, and running status into the return structure agreed upon by the boundary switching layer. The entire execution process reuses the same processor hardware execution flow, but the underlying address translation context has been switched to the target partition context. The physical memory range that the hardware is allowed to access and the read and write execution permissions are updated synchronously, realizing a controlled service execution closed loop that is separated from the source partition address space and is in the independent address space of the target partition.

[0098] Traditional monolithic kernels use a unified shared address space, and cross-partition calls lack hardware isolation. Relying on software verification makes them prone to memory out-of-bounds errors and fault propagation across partitions. In contrast, this solution uses a hardware MMU to intercept illegal access in real time based on the target partition's second-level page table. It completes permission adjudication during the address translation hardware stage, without relying on software active checks. It relies on hardware to achieve the strong partition isolation required for functional safety. The second-level page tables of each partition are statically created during system startup. During runtime, access constraints can be switched by modifying the EL2 page table base address register. At the same time, a shared bridging metadata area is set up. Based on strict isolation of the private memory of each partition, it fully supports the entire process of cross-partition parameter passing and result writing back.

[0099] S105: After the target service is executed, switch the second-level page table corresponding to the current address translation back to the second-level page table corresponding to the source memory partition, and return the execution result corresponding to the target service to the source kernel component.

[0100] Among them, the second-level page table corresponding to the source memory partition is the Stage-2 page table that is effective on the EL2 side before the cross-partition call is initiated, which is used to restore the hardware address translation context at the beginning of the call.

[0101] The execution result includes the target service's normal output data, running status code, output buffer address, and exception information. If an illegal memory access occurs during execution, the exception information is generated by EL2 after capturing the Stage-2 Abort exception and handed over to the security monitoring component in the SAFETY partition for processing. Synchronization barrier instructions and TLB failure operations are used to clear the old address translation cache to ensure that the hardware mapping takes effect immediately after the page table is switched back. The security monitoring component is deployed in the SAFETY partition and executes security handling strategies such as fault isolation, service degradation, or system reset after receiving fault notifications.

[0102] For example, after the target service completes its execution and returns to the boundary switching layer, the program re-enters the EL2 isolation layer. In EL2, the Hypervisor reads the source partition identifier and source second-level page table information pre-saved in the cross-partition switching record, and executes the context recovery process in reverse of the page table switching: the source partition second-level page table base address is rewritten into the EL2 control register, data synchronization barrier, instruction synchronization barrier and Stage-2 TLB invalidation operations are performed, and the hardware address translation relationship is switched back to the source partition; after the page table recovery is completed, the currently effective page table is verified to be consistent with the source second-level page table in the record, and the execution flow is confirmed to return to the source partition address space.

[0103] After the page table rollback is completed, the EL1 kernel layer reads the execution result generated by the target service and encapsulates the returned content according to the data format agreed upon by the source kernel component. In normal execution scenarios, the result code and output parameters are copied to the source partition's accessible buffer, the call point register and program counter are restored, and the execution result is delivered to the source kernel component. If a Stage-2 Abort exception is triggered during service execution, EL2 parses the fault IPA, access type, and current partition information and pushes a fault notification to the security monitoring component. Simultaneously, it generates an exception result carrying the exception code, fault address, and service identifier and returns it to the source kernel component. Regardless of whether a runtime exception occurs, the page table rollback is prioritized to prevent the fault handling process from continuously occupying the target partition's address space. If the result is written to the shared control page, the source partition is still subject to the permission constraints of its own second-level page table when reading the result. After delivering the result to the source kernel component, the EL1 kernel layer clears the marker in the switch record, completing a single Linux kernel-mode cross-partition service access loop.

[0104] This application provides a method for accessing cross-partition services in Linux kernel mode, including: receiving a cross-partition service request initiated by a source kernel component in a source memory partition; determining the target memory partition based on the cross-partition service request; obtaining the second-level page table corresponding to the target memory partition and switching the second-level page table corresponding to the current address translation to the second-level page table corresponding to the target memory partition; establishing an address translation relationship corresponding to the target memory partition based on the second-level page table corresponding to the target memory partition, and executing the target service in the address space corresponding to the target memory partition; after the target service is executed, switching the second-level page table corresponding to the current address translation back to the second-level page table corresponding to the source memory partition, and returning the execution result corresponding to the target service to the source kernel component. The compilation and build layer generates a kernel image that satisfies partition ownership constraints; the EL1 kernel layer statically divides Linux kernel-mode components into SAFETY, CORE, and QM partitions; the EL2 isolation layer maintains independent second-level page tables for each partition and performs page table switching before and after cross-partition calls; the hardware layer relies on the ARM64 MMU to complete the two-level translation from VA to IPA and from IPA to PA, and performs mandatory checks on page table entry permissions. Therefore, cross-partition service calls no longer rely on software constraints under the shared address space within the monolithic kernel. Instead, partition-level switching is completed around the current address translation relationship before and after the target service is executed, so that the target service can only run in the address space corresponding to the target partition. Illegal writes are caught during the Stage-2 address translation stage.

[0105] In one possible implementation, the second-level page table corresponding to the target memory partition is obtained, and the second-level page table corresponding to the current address translation is switched to the second-level page table corresponding to the target memory partition. Specific implementation methods include: obtaining the target memory partition identifier corresponding to the cross-partition service request; searching for the second-level page table corresponding to the target memory partition based on the target memory partition identifier; and switching the second-level page table corresponding to the current address translation to the second-level page table corresponding to the target memory partition.

[0106] For example, the system obtains the target memory partition identifier corresponding to a cross-partition service request: After the cross-partition service request enters the boundary switching layer instrumentation code, the system parses the request payload, service identifier, or context flag to extract the target memory partition identifier. Based on the target memory partition identifier, the system searches for the corresponding second-level page table: The kernel reads the partition page table mapping table within the partition control block, matches the index entry based on the extracted target memory partition identifier, and directly retrieves the base address of the second-level page table corresponding to that partition. The partition identifiers and second-level page table pointers in the mapping table correspond one-to-one, allowing for rapid location of page table information. The system switches the second-level page table corresponding to the current address translation to the second-level page table corresponding to the target memory partition: The processor page table base address register is updated through a kernel-mode write operation, and a TLB cache refresh operation is performed synchronously to complete the hardware address translation context switch. After the switch is completed, all subsequent instruction addressing and data reading / writing by the processor follow the permission mapping rules of the target partition's second-level page table. The entire switching logic is encapsulated in the cross-partition call entry instrumentation code, and the upper-layer kernel components are unaware of it; simultaneously, it works with memblock to complete early memory pool partition marking, ensuring that the second-level page table mapping relationship and physical memory partition ownership match.

[0107] The target partition resolution, page table retrieval, and page table switching are consolidated into a unified cross-partition call boundary, ensuring consistency between partition context switching and function call boundaries. The partition page table mapping table adopts a one-to-one index structure, enabling fast retrieval of the second-level page table based on the partition identifier without global traversal. Switching can be completed with lightweight modification of the page table base address register, eliminating the need to rebuild address mapping and reducing runtime performance overhead. The switching logic is encapsulated by instrumentation code automatically generated during the compilation phase, shielding the underlying hardware operation details and making it completely transparent to business components within the SAFETY, CORE, and QM partitions. By linking with memblock, the two mechanisms of early-stage memory allocation partition constraints and runtime EL2 second-level page table address translation are unified, synchronously implementing partition isolation from both memory allocation and hardware access translation dimensions. All cross-partition access boundaries can be directly verified and confirmed through the current effective page table status, achieving verifiable and strongly constrained partition isolation effects based on hardware page tables.

[0108] Optionally, the Linux memory management subsystem consists of multiple layers of memory allocators, and there are dependencies between the allocators at each layer. Therefore, this solution performs bottom-up full-stack adaptation of the memory management subsystem to ensure that all memory allocation operations of each memory partition strictly originate from its respective physical memory pool throughout its entire lifecycle from early kernel startup to runtime, thus avoiding cross-partition memory sharing. In this system, memblock acts as the boot allocator in the early stages of kernel startup, undertaking all memory allocation work before the buddy system is initialized. This scheme declares the physical memory range corresponding to each memory partition through the Extended Device Tree (DTS) attribute. For example, it configures the corresponding memory nodes and partition attributes for the SAFETY physical memory pool and the QM physical memory pool respectively. During the initialization process, memblock parses the DTS declaration, establishes an independent memory region label for each partition, and performs targeted allocation according to the partition to which the memory allocation request belongs. That is, memory allocation requests belonging to the SAFETY partition are only satisfied from the SAFETY physical memory region, memory allocation requests belonging to the QM partition are only satisfied from the QM physical memory region, and memory allocation requests without a labeled partition are satisfied from the CORE physical memory region by default. This allows the kernel to strictly follow the partition ownership constraints in the early stages of startup, achieving physical memory isolation during the startup phase.

[0109] In one possible implementation, Figure 3 The flowchart for cross-partition synchronous page table switching execution provided in this application embodiment is as follows: Figure 3 As shown, the cross-partition synchronous call page table switching method includes: performing address translation based on the second-level page table corresponding to the target memory partition to obtain the physical address after address translation; using the physical address after address translation to access the physical memory region corresponding to the target memory partition, and executing the target service in the address space corresponding to the target memory partition.

[0110] The physical memory area is a pre-divided and isolated block of hardware memory, divided into the SAFETY pool, QM pool, and CORE pool, each corresponding to dedicated hardware storage resources for its respective partition.

[0111] For example, when a SAFETY partition or QM partition initiates a cross-partition synchronization call to a CORE partition, it enters the boundary switching layer. The boundary switching layer first saves the current source partition identifier to the call stack frame, and then switches from the EL2 isolation layer to the CORE second-level page table to establish the address translation relationship corresponding to the target memory partition CORE. After the system receives the target service call request, it parses the page directory entries and page table entries layer by layer based on the CORE second-level page table to complete the address translation and obtain the physical address belonging to the CORE pool. Then, it uses the physical address to access the physical memory area corresponding to the CORE, jumps to the CORE partition and executes the CORE partition logic. The entire process is completed within the address space corresponding to the CORE partition, including memory allocation, locking operations and other target services. All instruction fetching and data reading and writing are constrained by the CORE second-level page table mapping rules and can only access the CORE physical memory pool.

[0112] After the CORE partition target service completes its execution, it returns the processing result to the boundary switching layer. The boundary switching layer restores the previously stored source partition identifier from the call stack frame. The EL2 isolation layer performs the operation of switching back to the source partition's second-level page table, destroys the CORE partition address translation relationship, rebuilds the SAFETY / QM partition's dedicated address translation mapping, restores hardware memory access permissions to the source partition's isolation range, and finally returns the final call result to the SAFETY / QM partition that initiated the call, completing a complete cross-partition synchronous call. Throughout the process, the boundary switching layer relies on the stack frame to save the partition identifier and dynamically switches the second-level page table to achieve hardware memory isolation and controllable calls between partitions.

[0113] In one possible implementation, Figure 4 The flowchart for cross-partition synchronous callback page table switching execution provided in the embodiments of this application is as follows: Figure 4 As shown, the cross-partition synchronous callback page table switching method includes: obtaining the second-level page table corresponding to the source memory partition; switching the second-level page table corresponding to the current address translation back to the second-level page table corresponding to the source memory partition; reconstructing the address translation relationship based on the second-level page table corresponding to the source memory partition to restore the address space of the source memory partition; and returning the execution result corresponding to the target service to the source kernel component based on the restored address space of the source memory partition.

[0114] For example, after the CORE partition initiates a callback call to the boundary switching layer, the boundary switching layer first saves the CORE partition identifier to the call stack frame, then switches to the SAFETY / QM target partition's second-level page table, and then enters the SAFETY / QM partition to execute the target partition logic. After the target partition logic is completed and returns to the boundary switching layer, the boundary switching layer restores the CORE partition identifier from the call stack frame, retrieves the second-level page table corresponding to the source CORE memory partition based on the identifier, and the kernel-mode page table management module switches the second-level page table currently being used by the MMU address translation unit back to the CORE partition's second-level page table. The MMU then reconstructs the address translation mapping relationship from IPA to PA based on the source partition's second-level page table, restoring the independent address space of the CORE partition.

[0115] After completing the page table switching and address translation relationship reconstruction, and restoring the CORE partition address space to an accessible state, the boundary switching layer relies on the currently effective CORE partition addressing context to encapsulate the return data, status codes, or exception information generated by the SAFETY / QM partition target service into standard execution results. Following the return protocol recognizable by the CORE kernel components, the layer returns the callback results to the CORE partition through the return link.

[0116] In one possible implementation, Figure 5 The flowchart of the partition page table switching interrupt handling provided in the embodiments of this application is as follows: Figure 5 As shown, the partitioned page table switching interrupt handling method further includes: receiving an interrupt request during the execution of the target service; determining the corresponding interrupt handling memory partition based on the interrupt request; switching the second-level page table corresponding to the current address translation to the second-level page table corresponding to the interrupt handling memory partition; executing the interrupt service routine corresponding to the interrupt request in the address space corresponding to the interrupt handling memory partition; and switching the second-level page table corresponding to the current address translation back to the second-level page table corresponding to the memory partition before the interrupt occurred after the interrupt service routine is executed.

[0117] Interrupt requests are interrupt / exception signals sent out by hardware interrupts. They interrupt the normal operation of the target service within the interrupted partition, causing the program to jump to the exception entry point of the EL1 exception vector table. They are the asynchronous trigger source that triggers cross-partition secondary page table switching and enters the CORE interrupt handler.

[0118] The interrupt handling memory partition is a dedicated isolated memory partition with an independent CORE level 2 page table. After an interrupt is triggered, the boundary switching layer will switch to the page table of this partition. Interrupt service routines (including nested interrupts) are executed in the address space of this partition, thereby isolating the interrupt from the original service partition's memory access permissions.

[0119] For example, the target service executes normally within the address space of the second-level page table corresponding to the interrupted partition. When a hardware interrupt triggers an interrupt / exception request, the program jumps to the exception entry point of the EL1 exception vector table. First, the interrupted partition identifier is saved to the current thread stack. Then, the boundary switching layer logic is called to switch to the CORE interrupt handling second-level page table and enter the interrupt handler for execution. If an interrupt re-entry occurs during the execution of the interrupt handler and the interrupt is triggered again, the current partition identifier is saved to the interrupt stack. Relying on the page table already in the CORE context, there is no need to switch repeatedly. The CORE second-level page table is directly reused to execute the nested interrupt handler. After the nested interrupt handling is completed, the upper-level partition identifier is restored from the interrupt stack, and the original top-level interrupt handling flow is returned. Throughout the process, interrupt-related code and peripheral access are restricted to the address space corresponding to the interrupt handling memory partition. Only the code segment, data segment, and peripheral area mapped by this partition can be accessed. All memory accesses follow the IPA to PA address translation constraints of the interrupt partition.

[0120] After the entire interrupt handling process is completed, the system reads the pre-saved partition identifier before the interrupt from the current thread stack, switches the secondary page table corresponding to the processor address translation back to the secondary page table corresponding to the interrupted partition before the interrupt occurred through the boundary switching layer, rebuilds the original address translation mapping relationship of the target service, and switches back to the address space of the interrupted partition after the page table switch is completed, and restores the target service to continue normal execution. This page table restoration action is automatically completed by the interrupt exit path, which can ensure the continuity and consistency of the address translation state before and after the interrupt handling. The basic management relationship of the original business memory partition is not changed throughout the process. Only the dedicated interrupt partition address space is temporarily switched to respond to the interrupt event. The memory isolation constraints and the hardware MMU address translation behavior are kept consistent.

[0121] In one possible implementation, the method for detecting and handling address translation anomalies in a second-level page table includes: detecting address translation anomalies during the address translation process of the second-level page table; obtaining fault address information and access type information corresponding to the address translation anomaly; determining the corresponding abnormal access behavior based on the fault address information and access type information; and triggering an anomaly handling mechanism based on the abnormal access behavior.

[0122] For example, the system uses the EL2-side Hypervisor to uniformly maintain the secondary page table corresponding to the memory partition. During the MMU's Stage-2 hardware address translation, it synchronously traverses the secondary page table, verifies the page table access permission bits, matches memory access attributes, and detects address translation anomalies in real time. If a valid physical address cannot be generated, or if the access permission and memory attributes corresponding to the generated physical address do not match the current access operation, the hardware immediately triggers an address translation anomaly and jumps to a preset anomaly entry point. The anomaly handling process reads the fault record register, the anomaly context, and the duty status register, and parses and extracts two core fault information types: the fault address and the read / write execution type of the anomaly.

[0123] The exception handling module retrieves the global memory partition permission matrix and, based on whether the fault address belongs to a restricted memory partition of the system and whether the extracted access type is illegal read, write out of bounds, or execution of unauthorized instructions, comprehensively determines the specific abnormal access behavior. After classifying the abnormal behavior, it triggers the entire exception handling mechanism in conjunction with the pre-set handling strategy. It relies on the log recording unit to retain the original fault information, the alarm reporting unit to push the abnormal event, and the access blocking unit to terminate illegal access. For cross-partition access anomalies, it simultaneously links the secondary page table repair and memory partition isolation operations to complete the closed-loop exception control.

[0124] In one possible implementation, the exception handling mechanism includes at least one of the following: recording exception logs; generating alarm information; blocking abnormal access behavior; and performing isolation processing on the memory partition corresponding to the abnormal access behavior.

[0125] For example, after capturing abnormal memory access behavior, the system can combine multi-dimensional information such as the type of abnormal fault, the attribute of the memory access target, and the virtual / physical address of the fault to execute differentiated handling strategies: it can either execute single actions such as writing abnormal logs to disk and reporting security alarms, or it can execute dual operations of logging and alarm reporting, while simultaneously intercepting the illegal memory access request. If the abnormal behavior indicates that the memory partition has high-risk risks such as persistent memory corruption, out-of-bounds overflow, or illegal tampering, the system further switches the risky memory partition to a forced isolation state and restricts the partition's interaction permissions in both directions: on the one hand, it prohibits the faulty partition from actively initiating cross-partition memory access and cross-partition business calls; on the other hand, it blocks other normal partitions from initiating access requests to the faulty partition, cutting off the risk propagation link.

[0126] The four functional modules for anomaly handling—logging, alarm push, access blocking, and partition isolation—have flexible deployment options: they can be uniformly encapsulated as kernel-built-in anomaly handling submodules to centrally receive memory anomaly detection results and handle them in a closed loop; or they can be decoupled and deployed between the EL2 isolation layer and the EL1 kernel layer to receive anomaly reporting signals in layers and execute control logic step by step.

[0127] When an MMU level 2 page table address translation failure is captured and the hardware fault information is standardized and mapped to normalized abnormal access behavior, the entire anomaly handling mechanism relies on pre-configured security response strategies to implement hierarchical closed-loop processing: firstly, all fault context logs are retained, traceable security alarms are generated, and abnormal behavior auditing is completed; then, the anomaly severity level is matched, and single access blocking and global partition isolation control are selectively executed to cut off the abnormal address translation link and prevent illegal memory access behavior from spreading upward and downward.

[0128] With this hierarchical anomaly response mechanism, complete fault tracing data can be retained to accurately locate the source of illegal memory access, fault address, and trigger timing. It can also rely on the memory partition boundary isolation capability to constrain the scope of fault propagation, strictly limit abnormal disturbances within the partition's preset safety boundary, and ensure the stable operation of the remaining normal memory partitions such as CORE, SAFETY, and QM.

[0129] In one possible implementation, the code and data in the kernel image are organized by Section. The standard Linux kernel linker script lays out the code uniformly according to Section type, merging all Sections of the same type without distinguishing their memory partitions. This can lead to code or data from different partitions being mixed and stored in the same physical page. To address this issue, this solution modifies the kernel linker script, reorganizing each Section according to memory partitions and splitting it at the page level with forced page alignment. This results in a partitioned layout for the kernel image: [CORE.text] → page alignment → [SAFETY.text] → page alignment → [QM.text] → page alignment → [CORE.data] → page alignment → [SAFETY.data] → page alignment → [QM.data]... Functions marked with __safe_text and __qm_text are compiled into the code segment of their respective partitions, variables marked with __safe_data and __qm_data are compiled into the data segment of their respective partitions, and all other unmarked content belongs to the CORE partition by default. Page alignment is employed because the EL2 second-level page table uses physical pages (e.g., 4KB) as the minimum permission configuration granularity. When code or data belonging to different partitions exist within the same physical page, it is impossible to configure access permissions separately for different objects within the page, rendering partition isolation ineffective. By forcing page alignment, it is ensured that any physical page belongs to only one partition, allowing the EL2 second-level page table to precisely map access permissions to each physical page, thus achieving page-level access control. Furthermore, for the special percpu segment in the Linux kernel, this solution organizes the percpu units of each partition independently. Since the percpu units of each partition do not need to be stored contiguously in physical memory, a page-by-page mapping method is used to establish virtual address mapping relationships, ensuring that the percpu units corresponding to the same CPU are arranged contiguously in the virtual address space. This achieves transparent compatibility with existing software without modifying the existing percpu access model.

[0130] In one possible implementation, Figure 6 The accompanying diagram shows the partition migration type architecture of the partner system provided in this application embodiment, such as... Figure 6As shown, the buddy system internally includes a global free page list (Free List) and three partition-specific migration types: MIGRATE_CORE, MIGRATE_SAFETY, and MIGRATE_QM. Externally, three independent physical memory pools—CORE, SAFETY, and QM—provide unidirectional supply to the corresponding migration types. During kernel startup, each partition's dedicated physical memory area is pre-divided using memblock and the device tree. Upper-layer allocators such as slab, vmalloc, percpu, and DMA, after carrying the GFP_SAFETY and GFP_QM identifiers, will precisely route allocation requests to the corresponding migration type. Requests without partition identifiers will default to MIGRATE_CORE, thus distinguishing the memory sources of different partitions from the root.

[0131] Cross-partition page borrowing is prohibited between MIGRATE_SAFETY, MIGRATE_QM, and MIGRATE_CORE. SAFETY and QM dedicated migration type pages do not participate in cross-partition memory consolidation, page reclamation, and OOM preemption. During runtime, the physical memory pool boundaries of each partition always remain independent and stable, completely avoiding dynamic memory sharing between different partitions. Combined with the kernel image page alignment and splitting scheme, it achieves full-dimensional partition isolation between static images and runtime dynamic memory.

[0132] In one possible implementation, Figure 7 The three-layer stack protection security detection link diagram provided in the embodiments of this application is as follows: Figure 7 As shown, the physical memory allocation of the kernel stack must simultaneously satisfy the access permission requirements of all potential writeers. Since the kernel stack, in addition to its own thread's stack operations, is also pushed onto call frames during function calls and onto interrupt contexts during interrupt handling, its physical memory allocation must be determined based on the permission matrix to ensure that all legitimate writeers have write permissions. Based on this principle, the CORE thread stack, QM thread stack, and interrupt stack are uniformly allocated in QM physical memory, while the SAFETY thread stack is allocated in CORE physical memory. Building upon this, to further enhance kernel stack security, this solution constructs a multi-layered stack protection mechanism: Guard Pages are used to set inaccessible guard pages at the bottom of the stack to achieve real-time stack overflow detection; stack canary inserts random checksums into stack frames and performs integrity checks upon function return to detect stack frame data overwriting; and the ARM64 PAC (Pointer Authentication) hardware mechanism is used to sign and authenticate the return address, effectively preventing attackers from exploiting stack overflows to tamper with the return address and implement control flow hijacking, thus forming a multi-layered security protection system covering stack overflow detection, stack integrity protection, and control flow integrity protection.

[0133] The three-layer complementary kernel stack protection mechanism—Guard Page, Stack Canary, and ARM64 PAC—protects against three types of stack security threats: stack overflow exceeding the boundary, data tampering within the stack frame, and return address hijacking. The three mechanisms detect each other independently and in parallel. Specifically, Guard Page triggers Page Fault when accessing outside the boundary, Stack Canary returns verification failure when the verification is inconsistent, and PAC triggers authentication failure when verifying an illegal pointer. The three types of exceptions have their own independent triggering paths.

[0134] The abnormal signals generated by the three types of protection mechanisms will be uniformly aggregated to the kernel exception handling module. After the kernel exception handling program completes the fault context capture and exception type determination, it will actively send a notification signal to the security monitoring component, thus realizing the unified collection, reporting and tracing of attack behaviors such as stack overflow, stack tampering and return address hijacking. Combined with the kernel stack partition ownership policy, a complete stack security defense closed loop combining software and hardware is constructed on the basis of meeting the write permission requirements of multi-partition code stack.

[0135] One possible implementation describes the Linux kernel compilation and build process. While maintaining the existing development workflow largely unchanged, memory partitioning is integrated into the compilation chain. This enables automatic transfer of partition information, automatic section splitting, and automatic instrumentation of cross-partition calls, allowing partition isolation capabilities to be deployed during the compilation phase and providing a foundation for runtime page-level isolation. The entire compilation and build process includes four stages: source code layer, compilation layer, linking layer, and runtime initialization. These stages work together to build the memory partition isolation environment.

[0136] The source code layer is primarily responsible for declaring partition ownership information. Developers use predefined partition annotation macros to assign partition ownership to objects such as kernel code, global variables, and static data, and simultaneously declare the physical memory range corresponding to each partition through the Device Tree System (DTS) configuration file. The compilation system assigns code and data to the corresponding partitions based on the above annotation information; for objects that are not explicitly labeled, they are assigned to the CORE partition by default, thus ensuring that the migration of existing Linux kernel code can be completed without large-scale modifications, improving the compatibility of the solution with the original code.

[0137] The compiler layer is primarily responsible for handling cross-partition calls. Since different memory partitions correspond to independent second-level page tables, cross-partition function calls require execution context switching. Therefore, developers only need to identify cross-partition call boundaries and explicitly declare them using cross-partition call annotation macros. The compiler plugin automatically scans all call annotations during the compilation phase and automatically generates instrumentation code at the corresponding locations, including partition context saving, second-level page table switching, target partition entry jump, and context restoration after return. Compared to manually writing page table switching logic at every call point, this approach reduces development workload to only boundary identification and annotation. All instrumentation code is generated uniformly by the compiler, which not only improves development efficiency but also ensures the consistency of all cross-partition call switching logic, reducing security risks caused by human error or implementation omissions.

[0138] The linker layer is primarily responsible for image layout optimization. It modifies the kernel linker script to organize sections belonging to different partitions based on the partition information generated during the source code phase. This is done by splitting sections at the page level and forcing page alignment, ensuring that each physical page contains only code or data from the same partition. This prevents objects with different security levels from being mixed on the same page, thus meeting the requirement of EL2 second-level page tables to configure access permissions at the page level, and providing a correct image layout foundation for runtime page-level access control.

[0139] The runtime initialization phase is responsible for establishing the partition runtime environment. Before the kernel starts, the EL2 Hypervisor builds independent second-level page tables for each memory partition based on a preset permission matrix and configures the corresponding access permissions. Subsequently, in the early stages of kernel startup, memblock parses the partition physical memory configuration in the device tree, establishes the physical memory region corresponding to each partition, and completes the partition mapping correction of the per-CPU data region. During the buddy system initialization process, independent page migration types and physical page management mechanisms are established for the SAFETY partition and QM partition, respectively, so that all subsequent dynamic memory allocations for each partition come from their own independent physical memory pools, ultimately achieving full lifecycle partition isolation from the kernel image, static data to runtime dynamic memory.

[0140] Based on the same idea, this specification also provides an apparatus corresponding to the above method. Figure 8 This is a schematic diagram of the structure of the Linux kernel-mode cross-partition service access device provided in the embodiments of this application, as shown below. Figure 8 As shown, the device provided in this embodiment is applied to a Linux system. The Linux system includes an EL1 kernel layer and an EL2 isolation layer. The EL1 kernel layer includes multiple memory partitions, and each memory partition is configured with a corresponding second-level page table, which may include:

[0141] The receiving module 201 is used to receive cross-partition service requests initiated by the source kernel component in the source memory partition;

[0142] Module 202 is used to determine the target memory partition based on the cross-partition service request;

[0143] The switching module 203 is used to obtain the second-level page table corresponding to the target memory partition and switch the second-level page table corresponding to the current address translation to the second-level page table corresponding to the target memory partition.

[0144] Execution module 204 is used to establish the address translation relationship corresponding to the target memory partition based on the second-level page table corresponding to the target memory partition, and execute the target service in the address space corresponding to the target memory partition;

[0145] The return module 205 is used to switch the second-level page table corresponding to the current address translation back to the second-level page table corresponding to the source memory partition after the target service is executed, and to return the execution result corresponding to the target service to the source kernel component.

[0146] In one possible implementation, the Linux kernel-mode cross-partition service access device 200 includes: an acquisition module 205 and a lookup module 206;

[0147] Module 205 is used to obtain the target memory partition identifier corresponding to the cross-partition service request;

[0148] The lookup module 206 is used to look up the second-level page table corresponding to the target memory partition based on the target memory partition identifier;

[0149] The switching module 203 is also used to switch the second-level page table corresponding to the current address translation to the second-level page table corresponding to the target memory partition.

[0150] In one possible implementation, the switching module 203 is also used to perform address translation based on the second-level page table corresponding to the target memory partition to obtain the physical address after address translation;

[0151] The execution module 204 is also used to access the physical memory region corresponding to the target memory partition using the physical address after address translation, and to execute the target service in the address space corresponding to the target memory partition.

[0152] In one possible implementation, the Linux kernel-mode cross-partition service access device 200 includes: a reconstruction module 207 and a return module 208;

[0153] The acquisition module 205 is also used to acquire the second-level page table corresponding to the source memory partition;

[0154] The switching module 203 is also used to switch the second-level page table corresponding to the current address translation back to the second-level page table corresponding to the source memory partition;

[0155] The reconstruction module 207 is used to reconstruct the address translation relationship based on the second-level page table corresponding to the source memory partition and restore the address space of the source memory partition.

[0156] Return module 208 is used to return the execution result corresponding to the target service to the source kernel component based on the restored source memory partition address space.

[0157] In one possible implementation, the receiving module 201 is configured to receive an interruption request during the execution of the target service;

[0158] The determination module 202 is also used to determine the corresponding interrupt handling memory partition based on the interrupt request;

[0159] The switching module 203 is also used to switch the second-level page table corresponding to the current address translation to the second-level page table corresponding to the interrupt handling memory partition;

[0160] Execution module 204 is also used to execute the interrupt service routine corresponding to the interrupt request in the address space corresponding to the interrupt handling memory partition;

[0161] The switching module 203 is also used to switch the second-level page table corresponding to the current address translation back to the second-level page table corresponding to the memory partition before the interrupt occurred after the interrupt service routine has been executed.

[0162] In one possible implementation, the Linux kernel-mode cross-partition service access device 200 includes: a detection module 209 and a triggering module 210;

[0163] Detection module 209 is used to detect address translation anomalies during the address translation process of the second-level page table;

[0164] The acquisition module 205 is also used to acquire fault address information and access type information corresponding to address translation anomalies;

[0165] The determination module 202 is also used to determine the corresponding abnormal access behavior based on the fault address information and access type information;

[0166] Trigger module 210 is used to trigger the exception handling mechanism based on abnormal access behavior.

[0167] In one possible implementation, the determination module 202, for the exception handling mechanism, includes at least one of the following:

[0168] Log exceptions;

[0169] Generate alarm information;

[0170] Block abnormal access behavior;

[0171] Isolate the memory partition corresponding to the abnormal access behavior.

[0172] Figure 9 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application, such as... Figure 9 As shown, the device 300 provided in this embodiment includes a processor 301 and a memory communicatively connected to the processor. The processor 301 and the memory 302 are connected via a bus 303.

[0173] In the specific implementation process, the processor 301 executes the computer execution instructions stored in the memory 302, causing the processor 301 to execute the method in the above method embodiment.

[0174] The specific implementation process of processor 301 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0175] In the above Figure 9 In the illustrated embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.

[0176] The memory may include high-speed RAM, and may also include non-volatile storage (NVM), such as at least one disk storage.

[0177] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0178] This application also provides a computer-readable storage medium storing computer-executable instructions. When the processor executes the computer-executable instructions, it implements the Linux kernel-mode cross-partition service access method described in the above method embodiments.

[0179] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described Linux kernel-mode cross-partition service access method.

[0180] The aforementioned computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.

[0181] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.

[0182] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0183] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A method for accessing cross-partition services in Linux kernel mode, characterized in that, Applied to a Linux system, the Linux system includes an EL1 kernel layer and an EL2 isolation layer, the EL1 kernel layer includes multiple memory partitions, each memory partition is configured with a corresponding second-level page table, the method includes: Receive cross-partition service requests initiated by source kernel components in the source memory partition; The target memory partition is determined based on the cross-partition service request; Obtain the second-level page table corresponding to the target memory partition, and switch the second-level page table corresponding to the current address translation to the second-level page table corresponding to the target memory partition; Establish the address translation relationship corresponding to the target memory partition based on the second-level page table corresponding to the target memory partition, and execute the target service in the address space corresponding to the target memory partition. After the target service is executed, the second-level page table corresponding to the current address translation is switched back to the second-level page table corresponding to the source memory partition, and the execution result corresponding to the target service is returned to the source kernel component.

2. The method according to claim 1, characterized in that, The step of obtaining the second-level page table corresponding to the target memory partition and switching the second-level page table corresponding to the current address translation to the second-level page table corresponding to the target memory partition includes: Obtain the target memory partition identifier corresponding to the cross-partition service request; Find the second-level page table corresponding to the target memory partition based on the target memory partition identifier; Switch the second-level page table corresponding to the current address translation to the second-level page table corresponding to the target memory partition.

3. The method according to claim 1, characterized in that, The step of establishing the address translation relationship corresponding to the target memory partition based on the second-level page table corresponding to the target memory partition, and executing the target service in the address space corresponding to the target memory partition, includes: Address translation is performed based on the second-level page table corresponding to the target memory partition to obtain the physical address after address translation; The physical memory region corresponding to the target memory partition is accessed using the physical address after address translation, and the target service is executed in the address space corresponding to the target memory partition.

4. The method according to claim 1, characterized in that, The step of switching the second-level page table corresponding to the current address translation back to the second-level page table corresponding to the source memory partition, and returning the execution result corresponding to the target service to the source kernel component, includes: Obtain the second-level page table corresponding to the source memory partition; Switch the second-level page table corresponding to the current address translation back to the second-level page table corresponding to the source memory partition; The address translation relationship is reconstructed based on the second-level page table corresponding to the source memory partition, and the address space of the source memory partition is restored. Based on the restored source memory partition address space, the execution result corresponding to the target service is returned to the source kernel component.

5. The method according to claim 1, characterized in that, Also includes: An interruption request was received during the execution of the target service; The corresponding interrupt handling memory partition is determined based on the interrupt request; Switch the second-level page table corresponding to the current address translation to the second-level page table corresponding to the interrupt handling memory partition; The interrupt service routine corresponding to the interrupt request is executed in the address space corresponding to the interrupt handling memory partition. After the interrupt service routine is completed, the second-level page table corresponding to the current address translation is switched back to the second-level page table corresponding to the memory partition before the interrupt occurred.

6. The method according to any one of claims 1 to 5, characterized in that, Also includes: An address translation anomaly was detected during the address translation process of the second-level page table. Obtain the fault address information and access type information corresponding to the address translation anomaly; Based on the fault address information and the access type information, the corresponding abnormal access behavior is determined; Based on the abnormal access behavior, the exception handling mechanism is triggered.

7. The method according to claim 6, characterized in that, The exception handling mechanism includes at least one of the following: Log exceptions; Generate alarm information; Block the abnormal access behavior; Isolate the memory partition corresponding to the abnormal access behavior.

8. A Linux kernel-mode cross-partition service access device, characterized in that, Applied to a Linux system, the Linux system including an EL1 kernel layer and an EL2 isolation layer, the EL1 kernel layer including multiple memory partitions, each memory partition configured with a corresponding second-level page table, the device includes: The receiving module is used to receive cross-partition service requests initiated by the source kernel components in the source memory partition; The determination module is used to determine the target memory partition based on the cross-partition service request; The switching module is used to obtain the second-level page table corresponding to the target memory partition and switch the second-level page table corresponding to the current address translation to the second-level page table corresponding to the target memory partition. The execution module is used to establish the address translation relationship corresponding to the target memory partition based on the second-level page table corresponding to the target memory partition, and to execute the target service in the address space corresponding to the target memory partition; The return module is used to switch the second-level page table corresponding to the current address translation back to the second-level page table corresponding to the source memory partition after the target service is executed, and return the execution result corresponding to the target service to the source kernel component.

9. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the Linux kernel-mode cross-partition service access method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by the processor, implement the Linux kernel-mode cross-partition service access method as described in any one of claims 1 to 7.

11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the Linux kernel-mode cross-partition service access method as described in any one of claims 1 to 7.