A physical memory data management method and system for a trusted operating system

By allocating physical memory and generating system calls in the trusted operating system, accurate monitoring and management of physical memory can be achieved, solving the problem that traditional virtual memory management cannot meet the needs of the trusted operating system and improving the security and stability of the system.

CN119166544BActive Publication Date: 2025-09-26SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411277533.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-12
Publication Date
2025-09-26
Estimated Expiration
2044-09-12

AI Technical Summary

Technical Problem

Traditional virtual memory management methods cannot meet the precise monitoring and management requirements of physical memory by trusted operating systems, and cannot detect and handle potential threats in a timely manner, resulting in insufficient security and stability.

Method used

By allocating physical memory from the kernel space in the trusted operating system, generating virtual addresses and mapping memory pages, creating user virtual space, and generating system calls based on operation information, responding to user editing operations, and executing corresponding physical memory editing functions, accurate monitoring and management of physical memory can be achieved.

Benefits of technology

It improves the stability and data security of the trusted operating system, reduces the risk of attacks and data leakage, and improves overall security and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166544B_ABST
    Figure CN119166544B_ABST
Patent Text Reader

Abstract

The present application provides a physical memory data management method and system for a trusted operating system, which is applicable to a trusted operating system. The trusted operating system includes a kernel space and a user space. A section of physical memory is allocated from the kernel space to obtain a virtual address of the physical memory, and the virtual address of the physical memory is mapped to the memory page of the obtained physical memory to determine the physical address of the physical memory; a user virtual space is created in the user space, and the physical memory is mapped to the user virtual space according to the page frame number corresponding to the memory page and the physical address of the physical memory; a system call for the physical memory is generated according to the operation information of the physical memory, the physical address of the physical memory, the memory size of the physical memory and a pre-set file path; in response to the user's physical memory editing operation on the physical memory, the physical memory editing function corresponding to the physical memory editing operation is executed through the system call to complete the corresponding physical memory editing operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and more specifically, to a physical memory data management method and system for an information-based operating system. Background Art

[0002] Operating systems focused on supporting trusted computing applications, known as trusted computing operating systems, have extremely high security requirements. In trusted computing operating systems, dangerous data often runs in memory, so robust physical memory data detection and management capabilities are essential to ensure the stability of the trusted computing operating system and the security of the data stored therein.

[0003] Traditional operating systems typically rely on virtual memory management to process memory data, but trusted operating systems have more stringent requirements and need to be able to scan physical memory in real time to identify and process any potentially dangerous data. This not only protects against malware or data leaks, but also prevents possible hardware failures or other runtime errors in memory.

[0004] However, the traditional virtual memory management method cannot adapt to the needs of the trusted operating system. Therefore, how to provide a physical memory data management method to achieve accurate monitoring and management of the content data of the physical memory, and timely discover and handle abnormal situations that may threaten the operation of the trusted operating system, is a problem that this application urgently needs to solve. Summary of the Invention

[0005] In view of this, the present application provides a physical memory data management method and system for a trusted operating system, with the purpose of accurately monitoring and managing the content data of the physical memory, and timely discovering and handling abnormal situations that may threaten the operation of the trusted operating system.

[0006] A first aspect of the present application provides a physical memory data management method for an ICT operating system, which is applicable to the ICT operating system, wherein the ICT operating system includes a kernel space and a user space, and the method includes:

[0007] Allocate a section of physical memory from the kernel space, obtain a virtual address of the physical memory, and map the virtual address of the physical memory to a memory page of the physical memory to determine a physical address of the physical memory;

[0008] Creating a user virtual space in the user space, and mapping the physical memory to the user virtual space according to the page frame number corresponding to the memory page and the physical address of the physical memory;

[0009] Generate a system call of the physical memory according to the operation information of the physical memory, the physical address of the physical memory, the memory size of the physical memory and a preset file path;

[0010] In response to a user's physical memory editing operation on the physical memory, a physical memory editing function corresponding to the physical memory editing operation is executed through the system call to complete the corresponding physical memory editing operation.

[0011] Optionally, if the physical memory editing operation is a memory allocation operation, responding to the user's physical memory editing operation on the physical memory, executing a physical memory editing function corresponding to the physical memory editing operation through the system call to complete the corresponding physical memory editing operation, includes:

[0012] In response to a memory allocation operation of the user on the physical memory, determining a memory allocation function corresponding to the memory allocation operation according to an operation name of the memory allocation operation in the system call;

[0013] The memory allocation function is executed through the operation command in the system call, so that when the memory size of the requested memory indicated by the memory allocation operation is smaller than the memory size of the physical memory, the virtual address of the requested memory is mapped to the memory page of the requested memory; the memory page of the requested memory is converted into the physical address of the requested memory, and a memory management object of the requested memory is generated according to the virtual address of the requested memory, the physical address of the requested memory and the memory information structure generated based on the information of the requested memory, so as to complete the corresponding memory allocation operation.

[0014] Optionally, if the physical memory editing operation is a memory release operation, responding to the user's physical memory editing operation on the physical memory by executing a physical memory editing function corresponding to the physical memory editing operation through the system call to complete the corresponding physical memory editing operation includes:

[0015] In response to a memory release operation of the user on the physical memory, determining a memory release function corresponding to the memory release operation according to an operation name of the memory release operation in the system call;

[0016] Executing the memory release function through the operation command in the system call to obtain a memory management object and a virtual address of the physical memory according to the physical address of the physical memory; releasing the physical memory, the virtual address of the physical memory, and the memory management object of the physical memory, and deleting the memory management object to complete the corresponding memory release operation;

[0017] The memory management object of the physical memory is obtained by generating a memory information structure of the physical memory according to the physical address of the physical memory, the virtual address of the physical memory and the information of the physical memory, and initializing the memory information structure of the physical memory.

[0018] Optionally, if the physical memory editing operation is a memory initialization operation, in response to the user's physical memory editing operation on the physical memory, executing a physical memory editing function corresponding to the physical memory editing operation through the system call to complete the corresponding physical memory editing operation includes:

[0019] In response to a memory initialization operation of the user on the physical memory, determining a memory initialization function corresponding to the memory initialization operation according to an operation name corresponding to the memory initialization operation in the system call;

[0020] The memory initialization function is executed through the operation command in the system call to detect the file path input by the user based on the memory initialization operation, and the file content obtained according to the file path is filled into the physical memory; when the file path input by the user based on the memory initialization operation is not detected, the filling content of the physical memory is determined to be 0 to complete the corresponding memory initialization operation.

[0021] Optionally, if the physical memory editing operation is a memory display operation, the responding to the user's physical memory editing operation on the physical memory, executing a physical memory editing function corresponding to the physical memory editing operation through the system call to complete the corresponding physical memory editing operation, includes:

[0022] In response to a memory display operation of the user on the physical memory, determining a memory display function corresponding to the memory display operation according to an operation name of the memory display operation in the system call;

[0023] The memory display function is executed through the operation command in the system call to detect that the user has passed in the physical address of the physical memory based on the memory display operation, and the memory management object of the physical memory is obtained and displayed according to the physical address of the physical memory; if it is not detected that the user has input the physical address of the physical memory based on the memory display operation, the memory management object of the physical memory is obtained and displayed according to the process ID of the physical memory; the memory management object of the physical memory is displayed to complete the corresponding memory display operation.

[0024] Optionally, if the physical memory editing operation is a memory reduction operation, responding to the user's physical memory editing operation on the physical memory, executing a physical memory editing function corresponding to the physical memory editing operation through the system call to complete the corresponding physical memory editing operation, includes:

[0025] In response to a memory reduction operation of the user on the physical memory, determining a memory reduction function corresponding to the memory reduction operation according to an operation name of the memory reduction operation in the system call;

[0026] The memory reduction function is executed through the operation command in the system call to detect that the user has passed in the physical address of the physical memory based on the memory reduction operation, and the available capacity of the physical memory is obtained according to the physical address of the physical memory; if the user has not passed in the physical address of the physical memory based on the memory reduction operation, the physical address is obtained according to the process ID of the physical memory to obtain the available capacity of the physical memory; if the available capacity of the physical memory is not less than the reduced capacity indicated by the memory reduction operation, the available capacity of the physical memory is reduced according to the reduced capacity to complete the corresponding memory reduction operation.

[0027] Optionally, if the physical memory editing operation is a memory detailed information operation, the responding to the user's physical memory editing operation on the physical memory, executing a physical memory editing function corresponding to the physical memory editing operation by the system call to complete the corresponding physical memory editing operation, includes:

[0028] In response to a user's memory detailed information operation on the physical memory, determining a memory detailed information function corresponding to the memory detailed information operation according to an operation name of the memory detailed information operation in the system call;

[0029] The memory detailed information function is executed through the operation command in the system call to detect that the user has passed in the physical address of the physical memory based on the memory detailed information operation, and obtain the available capacity of the physical memory according to the physical address of the physical memory; if the user has not passed in the physical address of the physical memory based on the memory detailed information operation, obtain the physical address according to the process ID of the physical memory to obtain the available capacity of the physical memory; obtain a predefined temporary variable of the physical memory, and store the physical address and the available capacity of the physical memory in the temporary variable to obtain a target variable; pass the target variable into a corresponding parameter pointer to release the target variable, and complete the corresponding memory detailed information operation.

[0030] Optionally, if the physical memory editing operation is a memory data insertion operation, the responding to the user's physical memory editing operation on the physical memory, executing a physical memory editing function corresponding to the physical memory editing operation through the system call to complete the corresponding physical memory editing operation, includes:

[0031] In response to a memory data insertion operation of the user on the physical memory, determining a memory data insertion function corresponding to the memory data insertion operation according to an operation name of the memory data insertion operation in the system call;

[0032] The memory data insertion function is executed through the operation command in the system call to detect that the user has passed the physical address of the physical memory based on the memory data insertion operation, and the available capacity of the physical memory is obtained according to the physical address of the physical memory; if the user has not passed the physical address of the physical memory based on the memory data insertion operation, the physical address is obtained according to the process number of the physical memory to obtain the available capacity of the physical memory; if the available capacity of the physical memory is not less than the data amount of the memory data indicated to be inserted by the memory data insertion operation; the memory data is inserted into the physical memory to complete the corresponding memory data insertion operation.

[0033] A second aspect of the present application provides a physical memory data management system for an ICT operating system, which is applicable to the ICT operating system. The ICT operating system includes a kernel space and a user space, and the system includes:

[0034] a physical memory allocation unit, configured to allocate a section of physical memory from the kernel space, obtain a virtual address of the physical memory, and map the virtual address of the physical memory to a memory page of the physical memory to determine a physical address of the physical memory;

[0035] a mapping unit, configured to create a user virtual space in the user space, and map the physical memory to the user virtual space according to a page frame number corresponding to the memory page and a physical address of the physical memory;

[0036] a system call generating unit, configured to generate a system call of the physical memory according to the operation information of the physical memory, the physical address of the physical memory, the memory size of the physical memory, and a preset file path;

[0037] The physical memory editing unit is used to respond to the user's physical memory editing operation on the physical memory, and execute the physical memory editing function corresponding to the physical memory editing operation through the system call to complete the corresponding physical memory editing operation.

[0038] Optionally, if the physical memory editing operation is a memory allocation operation, in response to the user's physical memory editing operation on the physical memory, the physical memory editing unit executes a physical memory editing function corresponding to the physical memory editing operation through the system call to complete the corresponding physical memory editing operation, specifically for:

[0039] In response to a memory allocation operation of the user on the physical memory, determining a memory allocation function corresponding to the memory allocation operation according to an operation name of the memory allocation operation in the system call;

[0040] The memory allocation function is executed through the operation command in the system call, so that when the memory size of the requested memory indicated by the memory allocation operation is smaller than the memory size of the physical memory, the virtual address of the requested memory is mapped to the memory page of the requested memory; the memory page of the requested memory is converted into the physical address of the requested memory, and a memory management object of the requested memory is generated according to the virtual address of the requested memory, the physical address of the requested memory and the memory information structure generated based on the information of the requested memory, so as to complete the corresponding memory allocation operation.

[0041] The present application provides a physical memory data management method and system for a trusted operating system, which is applicable to a trusted operating system, wherein the trusted operating system includes a kernel space; a virtual address of the physical memory is obtained by allocating a section of physical memory from the kernel space; the virtual address of the physical memory is mapped to a memory page of the physical memory, and the memory page of the physical memory is converted to a physical address of the physical memory; a user virtual space is created in the user space, and the physical memory is mapped to the user virtual space according to the page frame number corresponding to the memory page and the physical address of the physical memory; a system call of the physical memory is generated according to the operation information of the physical memory, the physical address of the physical memory, the memory size of the physical memory and a pre-set file path; in response to the user's physical memory editing operation on the physical memory, the physical memory editing function corresponding to the physical memory editing operation is executed through the system call to complete the corresponding physical memory editing operation. The technical solution provided by the present application allocates a section of physical memory from the kernel space and creates a user virtual space in the user space, so that the physical memory can be mapped to the user virtual space according to the page frame number and physical address corresponding to the physical memory, thereby better protecting the physical memory and ensuring the stability of the trusted operating system and the security of the data; and, the present solution can also generate a system call for the physical memory based on the operation information of the physical memory, the physical address of the physical memory, the memory size of the physical memory and the pre-set file path, and support the user to perform corresponding physical memory editing operations on the physical memory through the system call, thereby realizing accurate monitoring and management of the memory data of the physical memory, reducing the risk of the trusted operating system being attacked or data leaked, and thereby improving the overall security and reliability of the trusted operating system. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.

[0043] Figure 1 A flow chart of a method for managing physical memory data of a trusted operating system provided in an embodiment of the present application;

[0044] Figure 2 A schematic diagram of the structure of a physical memory data management system of a trusted operating system provided in an embodiment of the present application;

[0045] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0046] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0047] In this application, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.

[0048] See also Figure 1 , shows a flow chart of a physical memory data management method provided by an embodiment of the present application, which is applicable to a trusted operating system, which includes a kernel space and a user space. The physical memory data management method specifically includes the following steps:

[0049] S101: Allocate a section of physical memory from the kernel space, obtain a virtual address of the physical memory, and map the virtual address of the physical memory to a memory page of the obtained physical memory to determine a physical address of the physical memory.

[0050] In the specific execution of step S101, a section of physical memory of size PAGE_SIZE is allocated from the kernel space using the slab allocator through kmalloc, and the PID of the process in the physical memory, the memory size of the physical memory, and the actual available length are recorded. At the same time, the process in the physical memory will feedback the virtual address corresponding to the physical memory, where the memory size of the physical memory is PAGE_SIZE, and PAGE_SIZE is the size of a memory page; the virtual address of the physical memory is mapped to the memory page of the physical memory through a pre-set memory page mapping function, and finally the memory page of the physical memory is converted to the physical address of the physical memory through a physical address conversion function. Among them, the code example for determining the physical address of the physical memory is as follows:

[0051] if (size < PAGE_SIZE){

[0052] kvaddr = kmalloc(PAGE_SIZE, GFP_KERNEL); / / Allocate physical memory of size PAGE_SIZE

[0053] page = virt_to_page(kvaddr); / / Get memory page

[0054] paddr = page_to_phys(page); / / Convert memory page to physical address

[0055] }else{

[0056] return -2;

[0057] }.

[0058] It should be noted that virt_to_page is a preset memory page mapping function, and page_to_phys is a preset physical address translation function.

[0059] Furthermore, in an embodiment of the present application, information of the physical memory is obtained; a memory information structure of the physical memory is generated according to the physical address of the physical memory, the virtual address of the physical memory and the information of the physical memory, and the memory information structure is initialized to obtain a memory management object of the physical memory.

[0060] It should be noted that the physical memory information includes at least the process ID (PID) of the physical memory process, the starting physical address of the available capacity of the physical memory, the memory size of the physical memory, the number of memory pages of the physical memory, etc. Among them, the PID is a unique identifier assigned by the operating system to each running process to identify the process.

[0061] In some embodiments, a memory information structure of the physical memory can be generated based on the process ID (PID) of the physical memory, the physical address of the physical memory, the virtual address of the physical memory, the starting physical address of the available capacity of the physical memory, the memory size of the physical memory, and the number of memory pages of the physical memory, as shown in Table 1, and the memory information structure of the physical memory is initialized to generate a memory management object of the physical memory.

[0062] Table 1:

[0063]

[0064] S102: Create a user virtual space in the user space, and map the physical memory to the user virtual space according to the page frame number corresponding to the memory page and the physical address of the physical memory.

[0065] In the specific process of executing step S102, after obtaining the physical address of the physical memory, the page frame number (PEN number) of the memory page of the physical memory can be further obtained, and at the same time, a new memory area is created in the user space of the trusted operating system through mmap, that is, a new user virtual space is created in the user space, and the physical memory is mapped to the user virtual space according to the PEN number of the memory page and the physical address of the physical memory through the remap_pfn_ranges method. Among them, the remap_pfn_ranges method indicates that the physical memory is mapped to the specified virtual address space. Therefore, the corresponding physical memory can be mapped to the user virtual space according to the PEN number of the memory page and the physical address of the physical memory through the remap_pfn_ranges method.

[0066] S103: Generate a system call of the physical memory according to the operation information of the physical memory, the physical address of the physical memory, the memory size of the physical memory and the preset file path.

[0067] In an embodiment of the present application, operation information related to the physical memory that needs to be allocated can be pre-set, wherein the operation information includes operands, operation names and physical memory editing functions corresponding to multiple physical memory editing operations; corresponding system call parameters are generated according to the physical address of the physical memory, the physical size of the physical memory, the pre-set file path and the operation name corresponding to each physical memory editing operation, as shown in Table 2, so as to generate a system call corresponding to the physical memory according to the system call parameters, so as to respond to the user's physical memory editing operation on the physical memory when detecting the user's physical memory editing operation, and execute the physical memory editing function corresponding to the physical memory editing operation through the system call to complete the corresponding physical memory editing operation.

[0068] Table 2:

[0069]

[0070] It should be noted that the pre-set physical memory editing operations may include memory allocation operations, memory release operations, memory initialization operations, memory display operations, memory reduction operations, memory detailed information operations, memory data insertion operations, and the like. Furthermore, a correspondence between the operation name and the operation value of each physical memory editing operation, as well as a correspondence between the operation name and the physical memory editing function of each physical memory editing operation, may be established. The correspondence between the operation name and the operation value of each operation may be as shown in Table 3 below:

[0071] Table 3:

[0072]

[0073] In actual application, after obtaining the physical memory information, the system call corresponding to the physical memory can be generated according to the physical memory operation command, physical address, physical size of the physical memory, pre-set file path, and operation name corresponding to each physical memory editing operation. The code example corresponding to the generation process of the physical memory system call can be as follows:

[0074] asmlinkage long kmem_map(conststructpt_regs *regs){

[0075] intcmd = (int)PT_REGS_PARM1(regs); / / Physical memory operation command

[0076] int size = (int)PT_REGS_PARM2(regs); / / physical memory size

[0077] unsigned long paddr = (unsigned long)PT_REGS_PARM3(regs); / / Physical address of physical memory

[0078] char *buff = (char *)PT_REGS_PARM4(regs); / / Pre-set file path

[0079] intbuff_len = 0;

[0080] char *k_buff;

[0081] / / Get the file path

[0082] k_buff = kmalloc(PATH_MAX, GFP_KERNEL);

[0083] if (buff){

[0084] buff_len = strncpy_from_user(k_buff, buff, PATH_MAX);

[0085] }

[0086] / / Call the physical memory editing function of different physical memory editing operations according to the operation command

[0087] if (cmd == KMEM_ALLOC){

[0088] return kmem_alloc(size);

[0089] }else if (cmd == KMEM_FREE){

[0090] return kmem_free(paddr);

[0091] }else if (cmd == KMEM_INIT){

[0092] return kmem_init(paddr, k_buff);

[0093] }else if (cmd == KMEM_INFO){

[0094] / / copy to user:

[0095] return kmem_info(paddr, k_buff);

[0096] }else if (cmd == KMEM_DEC){

[0097] return kmem_dec(paddr);

[0098] }else if (cmd == KMEM_SHOW){

[0099] return kmem_show(paddr, k_buff);

[0100] }else if (cmd == KMEM_INSERT){

[0101] return kmem_insert(paddr, k_buff);

[0102] }else{

[0103] / / cmd not found

[0104] return -404;

[0105] }

[0106] }。

[0107] S104: In response to the user's physical memory editing operation on the physical memory, a physical memory editing function corresponding to the physical memory editing operation is executed through a system call to complete the corresponding physical memory editing operation.

[0108] During the specific execution of step S104, after the system call for physical memory is generated, it can be detected in real time whether there is a user's physical memory editing operation on the physical memory; when the user's physical memory editing operation is detected, the user's physical memory editing operation can be responded to, and the physical memory editing function corresponding to the physical memory editing operation can be determined according to the operation name corresponding to the physical memory editing operation in the system call of physical memory; the physical memory editing function is executed through the operation command in the system call to complete the corresponding physical memory editing operation.

[0109] As an implementation method of an embodiment of the present application, if the physical memory editing operation is a memory allocation operation, in response to the user's physical memory editing operation on the physical memory, the physical memory editing function corresponding to the physical memory editing operation is executed through a system call to complete the corresponding physical memory editing operation. The specific process can be: in response to the user's memory allocation operation on the physical memory, the memory allocation function corresponding to the memory allocation operation is determined according to the operation name of the memory allocation operation in the system call; the memory allocation function is executed through the operation command in the system call, so that when the memory size of the requested memory indicated by the memory allocation operation is smaller than the memory size of the physical memory, the virtual address of the requested memory is mapped to the memory page of the requested memory; the memory page of the requested memory is converted into the physical address of the requested memory, and a memory management object of the requested memory is generated based on the virtual address of the requested memory, the physical address of the requested memory and the memory information structure generated by the information of the requested memory to complete the corresponding memory allocation operation.

[0110] It should be noted that the information of the memory application includes at least: the information of the memory application includes at least the PID of the memory application, the starting physical address of the available capacity of the memory application, the memory size of the memory application, the number of memory pages of the memory application, etc.

[0111] In actual application, it is possible to detect in real time whether there is an operand input by the user. When the operand input by the user is detected, it can be determined that the user is currently performing a physical memory editing operation; if the operand input by the user is 0, it can be determined that the physical memory editing operation performed by the user is a memory allocation operation, and then the user's memory allocation operation can be responded to, and the memory allocation operation function corresponding to the memory allocation operation can be determined according to the operation name of the memory allocation operation in the system call.

[0112] A memory allocation function is executed through the operation command in the system call to allocate a section of requested memory and obtain the virtual address fed back by the process of the requested memory; corresponding memory data is set for the requested memory; it is determined whether the memory size of the requested memory indicated by the memory allocation operation is smaller than the memory size of the physical memory; if the memory size of the requested memory is smaller than the memory size of the physical memory, a corresponding virtual address is allocated for the requested memory according to the process of the requested memory, and the virtual address of the requested memory is mapped to the memory page of the requested memory, and the memory page of the requested memory is converted to the physical address of the requested memory, and finally, a memory information structure of the requested memory is generated according to the virtual address of the requested memory, the physical address of the requested memory, the PID of the requested memory, the starting physical address of the available capacity of the requested memory, the memory size of the requested memory and the number of memory pages of the memory, and the memory information structure of the requested memory is initialized to generate a memory management object of the requested memory.

[0113] It should be noted that the code example corresponding to the memory allocation operation function corresponding to the memory allocation operation can be as follows:

[0114] intkmem_alloc(int size){

[0115] void *kvaddr;

[0116] unsigned long paddr;

[0117] struct page *page;

[0118] structkmem_map_struct *new;

[0119] if (size <= 0){

[0120] return -1;

[0121] }

[0122] if (size < PAGE_SIZE){

[0123] / / page = (struct page *)__get_free_pages(GFP_KERNEL, 0);

[0124] kvaddr = kmalloc(PAGE_SIZE, GFP_KERNEL); / / Allocate virtual memory for memory request

[0125] pr_info("kmem_mapallocsuccessed at vaddr=%p\n", kvaddr);

[0126] memset(kvaddr, 'c', PAGE_SIZE); / / Set memory data

[0127] page = virt_to_page(kvaddr); / / Map the virtual address of the memory request to the memory page of the memory request

[0128] paddr = page_to_phys(page); / / Map the memory page of the requested memory to the physical address of the requested memory

[0129] pr_info("kmem_mapallocsuccessed at paddr=%lx\n", paddr);

[0130] }else{

[0131] return -2;

[0132] }

[0133] / / Initialize the memory management object

[0134] new = kmalloc(sizeof(structkmem_map_struct), GFP_KERNEL);

[0135] new->phys_addr = paddr;

[0136] new->virt_addr = kvaddr;

[0137] new->pid = current->pid;

[0138] new->allocated_size = size;

[0139] new->nr_pages = 1;

[0140] new->offset = 0;

[0141] list_add(&new->list, &kmem_map_list);

[0142] return paddr;

[0143] }.

[0144] As an implementation method of an embodiment of the present application, if the physical memory editing operation is a memory release operation, in response to the user's physical memory editing operation on the physical memory, the physical memory editing function corresponding to the physical memory editing operation is executed through a system call to complete the corresponding physical memory editing operation. The specific process can be: in response to the user's memory release operation on the physical memory, the memory release function corresponding to the memory release operation is determined according to the operation name of the memory release operation in the system call; the memory release function is executed through the operation command in the system call to obtain the memory management object and virtual address of the physical memory according to the physical address of the physical memory; the physical memory, the virtual address of the physical memory and the memory management object of the physical memory are released, and the memory management object is deleted to complete the corresponding memory release operation.

[0145] In actual application, it is possible to detect in real time whether there is an operand input by the user for the physical memory. When the operand input by the user is detected, it can be determined that the user has performed a physical memory editing operation on the physical memory; if the operand input by the user is 1, it can be determined that the physical memory editing operation performed by the user on the physical memory is a memory release operation, and then the user's memory release operation can be responded to, and the memory release operation function corresponding to the memory release operation can be determined according to the operation name of the memory release operation in the system call. The memory release function is executed through the operation command in the system call to obtain the physical address (physical address of the physical memory) passed in when the user performs the memory release operation, and the memory management object and virtual address of the physical memory are obtained according to the physical address of the physical memory; the physical memory, the memory management object of the physical memory and the virtual address of the physical memory are released, and finally the memory management object of the physical memory is deleted to complete the corresponding memory release operation. Among them, the user can also pass in the physical address of other physical memories, which is not limited in this embodiment of the present application.

[0146] It should be noted that the code example corresponding to the memory release operation function corresponding to the memory release operation can be as follows:

[0147] intkmem_free(unsigned long paddr){

[0148] structkmem_map_struct *allocated_info = get_by_paddr(paddr);

[0149] if (!allocated_info){

[0150] return -1;

[0151] }

[0152] / / Release physical memory, memory management objects and virtual addresses

[0153] kfree(allocated_info->virt_addr);

[0154] list_del(&allocated_info->list);

[0155] kfree(allocated_info);

[0156] return 0;

[0157] }.

[0158] As an implementation method of an embodiment of the present application, if the physical memory editing operation is a memory initialization operation, in response to the user's physical memory editing operation on the physical memory, the physical memory editing function corresponding to the physical memory editing operation is executed through a system call to complete the corresponding physical memory editing operation. The specific process can be: in response to the user's memory initialization operation on the physical memory, the memory initialization function corresponding to the memory initialization operation is determined according to the operation name corresponding to the memory initialization operation in the system call; the memory initialization function is executed through the operation command in the system call, and when the file path input by the user based on the memory initialization operation is detected, the file content obtained according to the file path is filled into the physical memory; when the file path input by the user based on the memory initialization operation is not detected, the fill content of the physical memory is determined to be 0 to complete the corresponding memory initialization operation.

[0159] In actual applications, it is possible to detect in real time whether a user has currently input an operand for physical memory. When the user-input operand is detected, it can be determined that the user has performed a physical memory editing operation on the physical memory. If the user-input operand is 2, it can be determined that the physical memory editing operation performed by the user on the physical memory is a memory initialization operation. The user's memory initialization operation can then be responded to and a memory initialization operation function corresponding to the memory initialization operation can be determined based on the operation name of the memory initialization operation in the system call. The memory initialization function is executed using the operation command in the system call to obtain the physical address (physical address of the physical memory) input by the user when performing the memory initialization operation. If the user does not input a corresponding file path when performing the memory initialization operation, it can be determined that the fill content of the physical memory corresponding to the physical address is 0. If the user inputs a corresponding file path when performing the memory initialization operation, it can be determined whether the content size of the file content corresponding to the file path is greater than the available capacity of the physical memory. If not, the file content obtained according to the file path is filled into the physical memory. If it is, the file content corresponding to the file path can be written starting from the starting physical address of the available capacity of the physical memory until the physical memory is full, thereby completing the corresponding memory initialization operation.

[0160] It should be noted that the code example corresponding to the memory initialization operation function corresponding to the memory initialization operation can be as follows:

[0161] intkmem_init(unsigned long paddr, char* path_name){

[0162] structkmem_map_struct *allocated_info = get_by_paddr(paddr);

[0163] struct file *file;

[0164] int ret;

[0165] if (!allocated_info){

[0166] return -1;

[0167] }

[0168] if (!path_name){

[0169] memset(allocated_info->virt_addr, 0, allocated_info->allocated_size);

[0170] return 0;

[0171] }

[0172] / / Open the corresponding file from kernel space according to the file path

[0173] file = filp_open(path_name, O_RDONLY, 0);

[0174] if (IS_ERR(file)) {

[0175] pr_err("Failed to open file: %s\n", path_name);

[0176] return -2;

[0177] }

[0178] ret = kernel_read(file, allocated_info->virt_addr, allocated_info->allocated_size, 0);

[0179] filp_close(file, NULL);

[0180] return 0;

[0181] }.

[0182] It should be noted that in the above code example, the Init operation specifies that the physical memory at the corresponding physical address is filled with 0 or a specified file (the file corresponding to the file path entered by the user); if path_name (file path) is NULL, the physical memory is determined to be filled with 0; otherwise, the file content corresponding to path_name is filled into the physical memory; and. If the size of the file content exceeds the available capacity of the physical memory, the file content corresponding to the file path is written starting from the physical address of the available capacity of the physical memory until the physical memory is full. If the filling is successful, 0 is returned. If it fails, the return value is defined as follows: -1: paddr not allocated; -2: file open failure. It can be defined according to actual application and is not limited in this embodiment of the application.

[0183] As an implementation method of an embodiment of the present application, if the physical memory editing operation is a memory display operation, in response to the user's physical memory editing operation on the physical memory, the physical memory editing function corresponding to the physical memory editing operation is executed through a system call to complete the corresponding physical memory editing operation. The specific process can be: in response to the user's memory display operation on the physical memory, the memory display function corresponding to the memory display operation is determined according to the operation name of the memory display operation in the system call; the memory display function is executed through the operation command in the system call, and when it is detected that the user passes in the physical address of the physical memory based on the memory display operation, the memory management object of the physical memory is obtained and displayed according to the physical address of the physical memory, and the memory management object is displayed; if the user is not detected to input the physical address of the physical memory based on the memory display operation, the memory management object of the physical memory is obtained and displayed according to the process number of the physical memory.

[0184] In actual application, it is possible to detect in real time whether there is an operand input by the user for physical memory. When the operand input by the user is detected, it can be determined that the user is currently performing a physical memory editing operation on the physical memory. If the operand input by the user is 3, it can be determined that the physical memory editing operation performed by the user on the physical memory is a memory display operation. Then, the user's memory display operation can be responded to and the memory display operation function corresponding to the memory display operation can be determined according to the operation name of the memory display operation in the system call. The memory display function is executed through the operation command in the system call to detect whether the user has passed in the corresponding physical address (the physical address of the physical memory) when performing the memory display operation. If it is detected that the user has passed in the corresponding physical address when performing the memory display operation, the memory management object of the corresponding physical memory can be obtained according to the physical address, and the memory management object of the physical memory can be printed (displayed). If the physical address passed in by the user when performing the memory operation is not detected, the memory management object of the physical memory can be obtained according to the PID of the process of the physical memory, and the memory management object of the physical memory can be printed to complete the corresponding memory display operation.

[0185] It should be noted that the code example corresponding to the memory display operation function corresponding to the memory display operation can be as follows:

[0186] intkmem_info(unsigned long paddr, char* ret_msg){

[0187] structkmem_map_struct *allocated_info;

[0188] if (paddr)

[0189] allocated_info = get_by_paddr(paddr);

[0190] else

[0191] allocated_info = get_by_pid();

[0192] if (!allocated_info){

[0193] do_log("Operation: Info; result: failed.");

[0194] return -400;

[0195] }.

[0196] It should be noted that, in the above code example, the Info operation indicates the return of the real-time available capacity, available ratio, starting physical address, starting physical address of available capacity and memory management object of the physical memory allocated by the process; if the user passes in the physical address paddr when performing the memory display operation, the real-time available capacity, available ratio, starting physical address, starting physical address of available capacity and memory management object of the physical memory corresponding to the physical address are returned according to the physical address; if the user does not pass in the physical address paddr when performing the memory display operation, the real-time available capacity, available ratio, starting physical address, starting physical address of available capacity and memory management object of the physical memory are returned according to the PID of the process of the physical memory; 0 is returned when the memory display is successful; -1 is returned when the memory display fails.

[0197] As an implementation method of an embodiment of the present application, if the physical memory editing operation is a memory reduction operation, in response to the user's physical memory editing operation on the physical memory, the physical memory editing function corresponding to the physical memory editing operation is executed through a system call to complete the corresponding physical memory editing operation. The specific process can be: in response to the user's memory reduction operation on the physical memory, the memory reduction function corresponding to the memory reduction operation is determined according to the operation name of the memory reduction operation in the system call; the memory reduction function is executed through the operation command in the system call to detect the physical address of the physical memory passed in by the user based on the memory reduction operation, and the available capacity of the physical memory is obtained according to the physical address of the physical memory; if the physical address of the physical memory passed in by the user based on the memory reduction operation is not detected, the physical address is obtained according to the process number of the physical memory to obtain the available capacity of the physical memory; if the available capacity of the physical memory is greater than the reduced capacity indicated by the memory reduction operation, the available capacity of the physical memory is reduced according to the reduced capacity to complete the corresponding memory reduction operation.

[0198] In actual application, it is possible to detect in real time whether there is an operand input by the user for physical memory. When the operand input by the user is detected, it can be determined that the user is currently performing a physical memory editing operation on the physical memory; if the operand input by the user is 4, it can be determined that the physical memory editing operation performed by the user on the physical memory is a memory reduction operation, and then the user's memory reduction operation can be responded to, and the memory reduction operation function corresponding to the memory reduction operation can be determined according to the operation name of the memory reduction operation in the system call. A memory reduction function is executed through an operation command in a system call to detect whether a corresponding physical address (the physical address of the physical memory) is passed in when the user performs a memory display operation; if it is detected that the user passes in a corresponding physical address when performing a memory display operation, the available capacity of the corresponding physical memory can be obtained according to the physical address; if the physical address of the physical memory passed in by the user based on the memory reduction operation is not detected, the available capacity of the physical memory is obtained according to the process ID (PID) of the physical memory; it is determined whether the available capacity of the physical memory is less than the reduced capacity indicated by the memory reduction operation; if the available capacity of the physical memory is not less than the reduced capacity indicated by the memory reduction operation, the available capacity of the physical memory is reduced according to the reduced capacity; if the available capacity of the physical memory is less than the reduced capacity indicated by the memory reduction operation, a prompt message indicating that the capacity reduction of the physical memory has failed can be fed back.

[0199] It should be noted that the code example corresponding to the memory reduction operation function corresponding to the memory reduction operation can be as follows:

[0200] intkmem_dec(unsigned long paddr, int size){

[0201] structkmem_map_struct *allocated_info;

[0202] if (paddr)

[0203] allocated_info = get_by_paddr(paddr);

[0204] else

[0205] allocated_info = get_by_pid();

[0206] if (!allocated_info){

[0207] do_log("Operation: Dec; result: failed.");

[0208] return -400;

[0209] }

[0210] if (allocated_info->allocated_size - allocated_info->offset <size){

[0211] pr_info("kmem_mapdec failed at paddr=0x%lx. Only have %lx spaceleft.\n", paddr,

[0212] allocated_info->allocated_size - allocated_info->offset);

[0213] do_log("Operation: Dec; result: failed.");

[0214] return -1;

[0215] }

[0216] / / Reduce the specified memory size

[0217] allocated_info->allocated_size -= size;

[0218] memset(allocated_info->virt_addr + allocated_info->allocated_size, 1,size);

[0219] do_log("Operation: Dec; result: success.");

[0220] return 0;

[0221] }.

[0222] It should be noted that, in the above code example, the Dec operation indicates to reduce the available capacity of the physical memory, and writes 1 to the content of the physical memory after the available capacity is reduced; 0 is returned when the available capacity of the physical memory is successfully reduced; the return value in case of failure is defined as follows: -1: the reduced capacity exceeds the available capacity.

[0223] As an implementation method of an embodiment of the present application, if the physical memory editing operation is a memory detailed information operation, in response to the user's physical memory editing operation on the physical memory, the physical memory editing function corresponding to the physical memory editing operation is executed through a system call to complete the corresponding physical memory editing operation. The specific process can be: in response to the user's memory detailed information operation on the physical memory, the memory detailed information function corresponding to the memory detailed information operation is determined according to the operation name of the memory detailed information operation in the system call; the memory detailed information function is executed through the operation command in the system call, and when the physical address of the physical memory passed in by the user based on the memory detailed information operation is detected, the available capacity of the physical memory is obtained according to the physical address of the physical memory; if the physical address of the physical memory passed in by the user based on the memory detailed information operation is not detected, the physical address is obtained according to the process number of the physical memory to obtain the available capacity of the physical memory; a pre-defined temporary variable of the physical memory is obtained, and the physical address and available capacity of the physical memory are stored in the temporary variable to obtain a target variable; the target variable is passed into the corresponding parameter pointer to release the target variable to complete the corresponding memory detailed information operation.

[0224] In actual application, it is possible to detect in real time whether there is an operand input by the user for physical memory. When the operand input by the user is detected, it can be determined that the user is currently performing a physical memory editing operation on the physical memory; if the operand input by the user is 5, it can be determined that the physical memory editing operation performed by the user on the physical memory is a memory detailed information operation, and then the user's memory detailed information operation can be responded to, and the memory detailed information operation function corresponding to the memory detailed information operation can be determined according to the operation name of the memory detailed information operation in the system call. The memory detailed information function is executed through the operation command in the system call to detect whether the user passes in the corresponding physical address (the physical address of the physical memory) when performing the memory display operation; if it is detected that the user passes in the corresponding physical address when performing the memory display operation, the available capacity of the corresponding physical memory can be obtained according to the physical address; if the physical address of the physical memory passed in by the user based on the memory detailed information operation is not detected, the physical address is obtained according to the process ID (PID) of the physical memory to obtain the available capacity of the physical memory; a pre-defined temporary variable of the physical memory is obtained, and the physical address and available capacity of the physical memory are copied to the temporary variable to convert the contents of the physical address and available capacity of the physical memory into readable information, and finally the target variable storing the physical address and available capacity is passed to the parameter pointer to achieve the purpose of displaying the memory detailed information of the physical memory and complete the corresponding memory detailed information operation.

[0225] It should be noted that the code example corresponding to the memory detailed information operation function can be as follows:

[0226] int kmem_show(unsigned long paddr, char* ret_msg) {

[0227] struct kmem_map_struct *allocated_info;

[0228] if (paddr)

[0229] allocated_info = get_by_paddr(paddr);

[0230] else

[0231] allocated_info = get_by_pid();

[0232] if (!allocated_info) {

[0233] do_log("Operation: Show; result: failed.");

[0234] return -400;

[0235] }

[0236] char * buff = vmalloc(allocated_info->allocated_size + 1);

[0237] buff[allocated_info->allocated_size] = '\0';

[0238] memcpy(buff, allocated_info->virt_addr, allocated_info->allocated_size);

[0239] Display memory details

[0240] sprintf(ret_msg, "Physaddr 0x%lx, Content: \n%s\n", allocated_info->phys_addr, buff);

[0241] printk("Show: result %s\n", ret_msg);

[0242] vfree(buff);

[0243] do_log("Operation: Show; result: success.");

[0244] return 0;

[0245] }.

[0246] It should be noted that in the above code example, the Show operation indicates that the contents of the physical address and available capacity of the physical memory are converted into readable information and printed to the pointer parameter to complete the corresponding memory detailed information; return value: 0 is fed back when the memory detailed information is successfully displayed, and -1 is returned when the memory detailed information is successfully displayed.

[0247] As an implementation method of an embodiment of the present application, if the physical memory editing operation is a memory data insertion operation, in response to the user's physical memory editing operation on the physical memory, the physical memory editing function corresponding to the physical memory editing operation is executed through a system call to complete the corresponding physical memory editing operation. The specific process can be: in response to the user's memory data insertion operation on the physical memory, the memory data insertion function corresponding to the memory data insertion operation is determined according to the operation name of the memory data insertion operation in the system call; the memory data insertion function is executed through the operation command in the system call to detect the physical address of the physical memory passed in by the user based on the memory data insertion operation, and the available capacity of the physical memory is obtained according to the physical address of the physical memory; if the physical address of the physical memory passed in by the user based on the memory data insertion operation is not detected, the physical address is obtained according to the process number of the physical memory to obtain the available capacity of the physical memory; if the available capacity of the physical memory is greater than the amount of memory data indicated to be inserted by the memory data insertion operation; the memory data is inserted into the physical memory to complete the corresponding memory data insertion operation.

[0248] In actual application, it is possible to detect in real time whether there is an operand input by the user for the physical memory. When the operand input by the user is detected, it can be determined that the user is currently performing a physical memory editing operation on the physical memory; if the operand input by the user is 5, it can be determined that the physical memory editing operation performed by the user on the physical memory is a memory data insertion operation, and then the user's memory data insertion operation can be responded to, and the memory data insertion function corresponding to the memory data insertion operation can be determined according to the operation name of the memory data insertion operation in the system call. A memory data insertion function is executed through an operation command in a system call to detect whether a corresponding physical address (physical address of physical memory) is passed in when a user performs a memory display operation; if it is detected that a corresponding physical address is passed in when a user performs a memory display operation, the available capacity of the corresponding physical memory can be obtained according to the physical address; if the physical address of the physical memory passed in by the user based on the memory detailed information operation is not detected, the available capacity of the physical memory is obtained according to the process ID (PID) of the physical memory; it is determined whether the available capacity of the physical memory is less than the amount of memory data inserted as indicated by the memory data insertion operation; if the available capacity of the physical memory is not less than the amount of memory data inserted as indicated by the memory data insertion operation; the memory data is inserted into the physical memory to complete the corresponding memory data insertion operation; if the available capacity of the physical memory is less than the amount of memory data, a prompt message indicating that the memory data insertion failed can be output.

[0249] It should be noted that the code example corresponding to the memory data insertion operation function corresponding to the memory data insertion operation can be as follows:

[0250] intkmem_insert(unsigned long paddr, char* buff){

[0251] structkmem_map_struct *allocated_info;

[0252] if (paddr)

[0253] allocated_info = get_by_paddr(paddr);

[0254] else

[0255] allocated_info = get_by_pid();

[0256] if (!allocated_info){

[0257] do_log("Operation: Insert; result: failed.");

[0258] return -400;

[0259] }

[0260] if (strlen(buff) >allocated_info->allocated_size - allocated_info->offset){

[0261] pr_info("kmem_map insert failed at paddr=0x%lx. Only have %lx spaceleft.\n", paddr,

[0262] allocated_info->allocated_size - allocated_info->offset);

[0263] do_log("Operation: Insert; result: failed.");

[0264] return -1;

[0265] }

[0266] / / Insert data[[ID=2�]]

[0267] memcpy(allocated_info->virt_addr + allocated_info->offset, buff,strlen(buff));

[0268] allocated_info->offset += strlen(buff);

[0269] do_log("Operation: Insert; result: success.");

[0270] return 0;

[0271] }。

[0272] It should be noted that in the above code example, the Insert operation indicates that the passed string (memory data) is inserted into the requested physical memory; return value: the corresponding content is returned when the memory data is successfully inserted, and the return value when the memory data insertion fails is defined as follows: -1: the string is too long (the amount of memory data is too large).

[0273] The present application provides a physical memory data management method, which allocates a section of physical memory from the kernel space of the trusted operating system and creates a user virtual space in the user space, so that the physical memory can be mapped to the user virtual space according to the page frame number and physical address corresponding to the physical memory, which can better protect the physical memory and ensure the stability of the trusted operating system and the security of the data; and, this solution can also generate a system call for the physical memory based on the operation information of the physical memory, the physical address of the physical memory, the memory size of the physical memory and the pre-set file path; through this system call, the user is supported to perform physical memory editing operations such as memory allocation operation, memory release operation, memory initialization operation, memory display operation, memory reduction operation, memory detailed information operation, memory data insertion operation on the physical memory, so as to achieve accurate monitoring and management of the memory data of the physical memory, reduce the risk of the trusted operating system being attacked or data leaked, and thus improve the overall security and reliability of the trusted operating system. In addition, the system administrator can scan the allocated physical memory regularly or in real time to detect and clear any potential abnormal data, thereby further reducing the risk of the system being attacked or data leaked.

[0274] Based on the physical memory data management method of the trust-based operating system provided in the embodiment of the present application, the embodiment of the present application also provides a physical memory data management system of the trust-based operating system, such as Figure 2 As shown, the physical memory data management system of the trusted operating system is applicable to the trusted operating system, which includes kernel space and user space. The physical memory data management system of the trusted operating system includes:

[0275] A physical memory allocation unit 21 is configured to allocate a segment of physical memory from the kernel space, obtain a virtual address of the physical memory, and map the virtual address of the physical memory to a memory page of the obtained physical memory to determine a physical address of the physical memory;

[0276] A mapping unit 22 is configured to create a user virtual space in the user space and map the physical memory to the user virtual space based on the page frame number corresponding to the memory page and the physical address of the physical memory;

[0277] The system call generating unit 23 is used to generate a system call of the physical memory according to the operation information of the physical memory, the physical address of the physical memory, the memory size of the physical memory and the preset file path;

[0278] The physical memory editing unit 24 is used to respond to the user's physical memory editing operation on the physical memory, and execute the physical memory editing function corresponding to the physical memory editing operation through system call to complete the corresponding physical memory editing operation.

[0279] The specific principles and execution processes of each unit in the physical memory data management system of the trusted operating system disclosed in the above-mentioned embodiment of the present application are the same as the physical memory data management method of the trusted operating system disclosed in the above-mentioned embodiment of the present application. Please refer to the corresponding parts of the physical memory data management method of the trusted operating system disclosed in the above-mentioned embodiment of the present application, and no further details will be given here.

[0280] The present application provides a physical memory data management system for a trusted operating system, which is applicable to the trusted operating system, and the trusted operating system includes a kernel space; a virtual address of the physical memory is obtained by allocating a section of physical memory from the kernel space; the virtual address of the physical memory is mapped to a memory page of the physical memory, and the memory page of the physical memory is converted into a physical address of the physical memory; a user virtual space is created in the user space, and the physical memory is mapped to the user virtual space according to the page frame number corresponding to the memory page and the physical address of the physical memory; a system call for the physical memory is generated according to the operation information of the physical memory, the physical address of the physical memory, the memory size of the physical memory and a pre-set file path; in response to the user's physical memory editing operation on the physical memory, the physical memory editing function corresponding to the physical memory editing operation is executed through the system call to complete the corresponding physical memory editing operation. The technical solution provided by the present application allocates a section of physical memory from the kernel space and creates a user virtual space in the user space, so that the physical memory can be mapped to the user virtual space according to the page frame number and physical address corresponding to the physical memory, thereby better protecting the physical memory and ensuring the stability of the trusted operating system and the security of the data; and, the present solution can also generate a system call for the physical memory based on the operation information of the physical memory, the physical address of the physical memory, the memory size of the physical memory and the pre-set file path, and support the user to perform corresponding physical memory editing operations on the physical memory through the system call, thereby realizing accurate monitoring and management of the memory data of the physical memory, reducing the risk of the trusted operating system being attacked or data leaked, and thereby improving the overall security and reliability of the trusted operating system.

[0281] Optionally, if the physical memory editing operation is a memory allocation operation, in response to the user's physical memory editing operation on the physical memory, a physical memory editing unit is configured to execute a physical memory editing function corresponding to the physical memory editing operation through a system call to complete the corresponding physical memory editing operation, specifically for:

[0282] In response to a user's memory allocation operation on physical memory, a memory allocation function corresponding to the memory allocation operation is determined according to an operation name of the memory allocation operation in a system call;

[0283] The memory allocation function is executed through the operation command in the system call, so that when the memory size of the requested memory indicated by the memory allocation operation is smaller than the memory size of the physical memory, the virtual address of the requested memory is mapped to the memory page of the requested memory; the memory page of the requested memory is converted into the physical address of the requested memory, and a memory management object of the requested memory is generated based on the virtual address of the requested memory, the physical address of the requested memory and the memory information structure generated by the requested memory information to complete the corresponding memory allocation operation.

[0284] Optionally, if the physical memory editing operation is a memory release operation, in response to the user's physical memory editing operation on the physical memory, a physical memory editing unit is configured to execute a physical memory editing function corresponding to the physical memory editing operation through a system call to complete the corresponding physical memory editing operation, specifically for:

[0285] In response to a user's memory release operation on physical memory, a memory release function corresponding to the memory release operation is determined according to an operation name of the memory release operation in a system call;

[0286] Executing a memory release function through an operation command in a system call to obtain a memory management object and a virtual address of the physical memory according to a physical address of the physical memory; releasing the physical memory, the virtual address of the physical memory, and the memory management object of the physical memory, and deleting the memory management object to complete a corresponding memory release operation;

[0287] The memory management object of the physical memory is obtained by generating a memory information structure of the physical memory according to the physical address of the physical memory, the virtual address of the physical memory and the information of the physical memory, and initializing the memory information structure of the physical memory.

[0288] Optionally, if the physical memory editing operation is a memory initialization operation, in response to the user's physical memory editing operation on the physical memory, a physical memory editing unit that executes a physical memory editing function corresponding to the physical memory editing operation through a system call to complete the corresponding physical memory editing operation is specifically configured to:

[0289] In response to a user's memory initialization operation on physical memory, determining a memory initialization function corresponding to the memory initialization operation according to an operation name corresponding to the memory initialization operation in a system call;

[0290] The memory initialization function is executed through the operation command in the system call. When the file path input by the user based on the memory initialization operation is detected, the file content obtained according to the file path is filled into the physical memory; when the file path input by the user based on the memory initialization operation is not detected, the filling content of the physical memory is determined to be 0 to complete the corresponding memory initialization operation.

[0291] Optionally, if the physical memory editing operation is a memory display operation, in response to the user's physical memory editing operation on the physical memory, a physical memory editing unit that executes a physical memory editing function corresponding to the physical memory editing operation through a system call to complete the corresponding physical memory editing operation is specifically configured to:

[0292] In response to a user's memory display operation on physical memory, determining a memory display function corresponding to the memory display operation according to an operation name of the memory display operation in a system call;

[0293] The memory display function is executed through the operation command in the system call to detect that the user passes in the physical address of the physical memory based on the memory display operation, and then obtain and display the memory management object of the physical memory according to the physical address of the physical memory; if the user is not detected to input the physical address of the physical memory based on the memory display operation, the memory management object of the physical memory is obtained and displayed according to the process ID of the physical memory; the memory management object of the physical memory is displayed to complete the corresponding memory display operation.

[0294] Optionally, if the physical memory editing operation is a memory reduction operation, in response to the user's physical memory editing operation on the physical memory, a physical memory editing unit is configured to execute a physical memory editing function corresponding to the physical memory editing operation through a system call to complete the corresponding physical memory editing operation, specifically for:

[0295] In response to a memory reduction operation of the user on the physical memory, determining a memory reduction function corresponding to the memory reduction operation according to an operation name of the memory reduction operation in a system call;

[0296] The memory reduction function is executed through the operation command in the system call to detect the physical address of the physical memory passed in by the user based on the memory reduction operation, and the available capacity of the physical memory is obtained according to the physical address of the physical memory; if the physical address of the physical memory passed in by the user based on the memory reduction operation is not detected, the physical address is obtained according to the process number of the physical memory to obtain the available capacity of the physical memory; if the available capacity of the physical memory is not less than the reduced capacity indicated by the memory reduction operation, the available capacity of the physical memory is reduced according to the reduced capacity to complete the corresponding memory reduction operation.

[0297] Optionally, if the physical memory editing operation is a memory detailed information operation, in response to the user's physical memory editing operation on the physical memory, a physical memory editing unit executes a physical memory editing function corresponding to the physical memory editing operation through a system call to complete the corresponding physical memory editing operation, specifically for:

[0298] In response to a user's memory detailed information operation on physical memory, determining a memory detailed information function corresponding to the memory detailed information operation according to an operation name of the memory detailed information operation in a system call;

[0299] The memory detailed information function is executed through the operation command in the system call to detect that the physical address of the physical memory passed in by the user based on the memory detailed information operation, and the available capacity of the physical memory is obtained according to the physical address of the physical memory; if the physical address of the physical memory passed in by the user based on the memory detailed information operation is not detected, the physical address is obtained according to the process ID of the physical memory to obtain the available capacity of the physical memory; a pre-defined temporary variable of the physical memory is obtained, and the physical address and available capacity of the physical memory are stored in the temporary variable to obtain a target variable; the target variable is passed into a corresponding parameter pointer to release the target variable, and the corresponding memory detailed information operation is completed.

[0300] Optionally, if the physical memory editing operation is a memory data insertion operation, in response to the user's physical memory editing operation on the physical memory, a physical memory editing unit that executes a physical memory editing function corresponding to the physical memory editing operation through a system call to complete the corresponding physical memory editing operation is specifically configured to:

[0301] In response to a user's memory data insertion operation on a physical memory, determining a memory data insertion function corresponding to the memory data insertion operation according to an operation name of the memory data insertion operation in a system call;

[0302] The memory data insertion function is executed through the operation command in the system call to detect the physical address of the physical memory passed in by the user based on the memory data insertion operation, and the available capacity of the physical memory is obtained according to the physical address of the physical memory; if the physical address of the physical memory passed in by the user based on the memory data insertion operation is not detected, the physical address is obtained according to the process number of the physical memory to obtain the available capacity of the physical memory; if the available capacity of the physical memory is not less than the amount of memory data inserted as indicated by the memory data insertion operation; the memory data is inserted into the physical memory to complete the corresponding memory data insertion operation.

[0303] The present application embodiment provides an electronic device, such as Figure 3 As shown, the electronic device includes a processor 301 and a memory 302, the memory 302 is used to store program codes and data for physical memory data management of the trusted operating system, and the processor 301 is used to call program instructions in the memory to execute the steps shown in the physical memory data management method of the trusted operating system in the above embodiment.

[0304] An embodiment of the present application provides a storage medium, which includes a storage program, wherein when the program is running, the device where the storage medium is located is controlled to execute the physical memory data management method of the trusted operating system shown in the above embodiment.

[0305] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system or system embodiments, since they are basically similar to method embodiments, the description is relatively simple. For relevant parts, refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic. The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without making any creative efforts.

[0306] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0307] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

[0308] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A physical memory data management method for an information-based operating system, characterized in that: Applicable to a trusted operating system, the trusted operating system includes a kernel space and a user space, and the method includes: Allocate a section of physical memory from the kernel space, obtain a virtual address of the physical memory, and map the virtual address of the physical memory to a memory page of the physical memory to determine a physical address of the physical memory; Creating a user virtual space in the user space, and mapping the physical memory to the user virtual space according to the page frame number corresponding to the memory page and the physical address of the physical memory; Generate a system call for the physical memory based on operation information of the physical memory, a physical address of the physical memory, a memory size of the physical memory, and a preset file path; wherein operation information related to the physical memory to be allocated is preset, and the operation information includes operands, operation names, and physical memory editing functions corresponding to a plurality of physical memory editing operations; generate corresponding system call parameters based on the physical address of the physical memory, the memory size of the physical memory, the preset file path, and the operation names corresponding to the respective physical memory editing operations, so as to generate a system call corresponding to the physical memory based on the system call parameters; In response to a user's physical memory editing operation on the physical memory, a physical memory editing function corresponding to the physical memory editing operation is executed through the system call to complete the corresponding physical memory editing operation.

2. The method according to claim 1, characterized in that If the physical memory editing operation is a memory allocation operation, the responding to the user's physical memory editing operation on the physical memory, executing a physical memory editing function corresponding to the physical memory editing operation by the system call to complete the corresponding physical memory editing operation, includes: In response to a memory allocation operation of the user on the physical memory, determining a memory allocation function corresponding to the memory allocation operation according to an operation name of the memory allocation operation in the system call; The memory allocation function is executed through the operation command in the system call, so that when the memory size of the requested memory indicated by the memory allocation operation is smaller than the memory size of the physical memory, the virtual address of the requested memory is mapped to the memory page of the requested memory; the memory page of the requested memory is converted into the physical address of the requested memory, and a memory management object of the requested memory is generated according to the virtual address of the requested memory, the physical address of the requested memory and the memory information structure generated based on the information of the requested memory, so as to complete the corresponding memory allocation operation.

3. The method according to claim 1, characterized in that If the physical memory editing operation is a memory release operation, the responding to the user's physical memory editing operation on the physical memory, executing a physical memory editing function corresponding to the physical memory editing operation by the system call to complete the corresponding physical memory editing operation, includes: In response to a memory release operation of the user on the physical memory, determining a memory release function corresponding to the memory release operation according to an operation name of the memory release operation in the system call; Executing the memory release function through the operation command in the system call to obtain a memory management object and a virtual address of the physical memory according to the physical address of the physical memory; releasing the physical memory, the virtual address of the physical memory, and the memory management object of the physical memory, and deleting the memory management object to complete the corresponding memory release operation; The memory management object of the physical memory is obtained by generating a memory information structure of the physical memory according to the physical address of the physical memory, the virtual address of the physical memory and the information of the physical memory, and initializing the memory information structure of the physical memory.

4. The method according to claim 1, wherein If the physical memory editing operation is a memory initialization operation, in response to the user's physical memory editing operation on the physical memory, executing a physical memory editing function corresponding to the physical memory editing operation through the system call to complete the corresponding physical memory editing operation, including: In response to a memory initialization operation of the user on the physical memory, determining a memory initialization function corresponding to the memory initialization operation according to an operation name corresponding to the memory initialization operation in the system call; The memory initialization function is executed through the operation command in the system call to detect the file path input by the user based on the memory initialization operation, and the file content obtained according to the file path is filled into the physical memory; when the file path input by the user based on the memory initialization operation is not detected, the filling content of the physical memory is determined to be 0 to complete the corresponding memory initialization operation.

5. The method according to claim 1, wherein If the physical memory editing operation is a memory display operation, the responding to the user's physical memory editing operation on the physical memory, executing a physical memory editing function corresponding to the physical memory editing operation through the system call to complete the corresponding physical memory editing operation, includes: In response to a memory display operation of the user on the physical memory, determining a memory display function corresponding to the memory display operation according to an operation name of the memory display operation in the system call; The memory display function is executed through the operation command in the system call to detect that the user has passed in the physical address of the physical memory based on the memory display operation, and the memory management object of the physical memory is obtained and displayed according to the physical address of the physical memory; if it is not detected that the user has input the physical address of the physical memory based on the memory display operation, the memory management object of the physical memory is obtained and displayed according to the process ID of the physical memory; the memory management object of the physical memory is displayed to complete the corresponding memory display operation.

6. The method according to claim 1, characterized in that If the physical memory editing operation is a memory reduction operation, the responding to the user's physical memory editing operation on the physical memory, executing a physical memory editing function corresponding to the physical memory editing operation by the system call to complete the corresponding physical memory editing operation, includes: In response to a memory reduction operation of the user on the physical memory, determining a memory reduction function corresponding to the memory reduction operation according to an operation name of the memory reduction operation in the system call; The memory reduction function is executed through the operation command in the system call to detect that the user has passed in the physical address of the physical memory based on the memory reduction operation, and the available capacity of the physical memory is obtained according to the physical address of the physical memory; if the user has not passed in the physical address of the physical memory based on the memory reduction operation, the physical address is obtained according to the process ID of the physical memory to obtain the available capacity of the physical memory; if the available capacity of the physical memory is not less than the reduced capacity indicated by the memory reduction operation, the available capacity of the physical memory is reduced according to the reduced capacity to complete the corresponding memory reduction operation.

7. The method according to claim 1, characterized in that If the physical memory editing operation is a memory detailed information operation, the responding to the user's physical memory editing operation on the physical memory, executing a physical memory editing function corresponding to the physical memory editing operation by the system call to complete the corresponding physical memory editing operation, includes: In response to a user's memory detailed information operation on the physical memory, determining a memory detailed information function corresponding to the memory detailed information operation according to an operation name of the memory detailed information operation in the system call; The memory detailed information function is executed through the operation command in the system call to detect that the user has passed in the physical address of the physical memory based on the memory detailed information operation, and obtain the available capacity of the physical memory according to the physical address of the physical memory; if the user has not passed in the physical address of the physical memory based on the memory detailed information operation, obtain the physical address according to the process ID of the physical memory to obtain the available capacity of the physical memory; obtain a predefined temporary variable of the physical memory, and store the physical address and the available capacity of the physical memory in the temporary variable to obtain a target variable; pass the target variable into a corresponding parameter pointer to release the target variable, and complete the corresponding memory detailed information operation.

8. The method according to claim 1, characterized in that If the physical memory editing operation is a memory data insertion operation, the responding to the user's physical memory editing operation on the physical memory, executing a physical memory editing function corresponding to the physical memory editing operation by the system call to complete the corresponding physical memory editing operation, includes: In response to a memory data insertion operation of the user on the physical memory, determining a memory data insertion function corresponding to the memory data insertion operation according to an operation name of the memory data insertion operation in the system call; The memory data insertion function is executed through the operation command in the system call to detect that the user has passed the physical address of the physical memory based on the memory data insertion operation, and the available capacity of the physical memory is obtained according to the physical address of the physical memory; if the user has not passed the physical address of the physical memory based on the memory data insertion operation, the physical address is obtained according to the process number of the physical memory to obtain the available capacity of the physical memory; if the available capacity of the physical memory is not less than the data amount of the memory data indicated to be inserted by the memory data insertion operation; the memory data is inserted into the physical memory to complete the corresponding memory data insertion operation.

9. A physical memory data management system for a trusted operating system, characterized in that: Applicable to the trusted operating system, the trusted operating system includes kernel space and user space, and the system includes: a physical memory allocation unit, configured to allocate a section of physical memory from the kernel space, obtain a virtual address of the physical memory, and map the virtual address of the physical memory to a memory page of the physical memory to determine a physical address of the physical memory; a mapping unit, configured to create a user virtual space in the user space, and map the physical memory to the user virtual space according to a page frame number corresponding to the memory page and a physical address of the physical memory; a system call generating unit, configured to generate a system call for the physical memory based on operation information of the physical memory, a physical address of the physical memory, a memory size of the physical memory, and a preset file path; wherein the operation information related to the physical memory to be allocated is preset, and the operation information includes operands, operation names, and physical memory editing functions corresponding to a plurality of physical memory editing operations; and generating corresponding system call parameters based on the physical address of the physical memory, the memory size of the physical memory, the preset file path, and the operation names corresponding to the respective physical memory editing operations, so as to generate a system call corresponding to the physical memory based on the system call parameters; The physical memory editing unit is used to respond to the user's physical memory editing operation on the physical memory, and execute the physical memory editing function corresponding to the physical memory editing operation through the system call to complete the corresponding physical memory editing operation.

10. The system according to claim 9, characterized in that If the physical memory editing operation is a memory allocation operation, in response to the user's physical memory editing operation on the physical memory, the physical memory editing unit executes a physical memory editing function corresponding to the physical memory editing operation through the system call to complete the corresponding physical memory editing operation, specifically for: In response to a memory allocation operation of the user on the physical memory, determining a memory allocation function corresponding to the memory allocation operation according to an operation name of the memory allocation operation in the system call; The memory allocation function is executed through the operation command in the system call, so that when the memory size of the requested memory indicated by the memory allocation operation is smaller than the memory size of the physical memory, the virtual address of the requested memory is mapped to the memory page of the requested memory; the memory page of the requested memory is converted into the physical address of the requested memory, and a memory management object of the requested memory is generated according to the virtual address of the requested memory, the physical address of the requested memory and the memory information structure generated based on the information of the requested memory, so as to complete the corresponding memory allocation operation.

Citation Information

Patent Citations

  • Memory control method and memory control device

    CN105335306A

  • VMI-based file system fine-grained monitoring method

    CN107391234A