WO2017028309A1 - 文件数据访问方法和计算机系统 - Google Patents

文件数据访问方法和计算机系统 Download PDF

Info

Publication number
WO2017028309A1
WO2017028309A1 PCT/CN2015/087667 CN2015087667W WO2017028309A1 WO 2017028309 A1 WO2017028309 A1 WO 2017028309A1 CN 2015087667 W CN2015087667 W CN 2015087667W WO 2017028309 A1 WO2017028309 A1 WO 2017028309A1
Authority
WO
WIPO (PCT)
Prior art keywords
page
global directory
file
space
address
Prior art date
Application number
PCT/CN2015/087667
Other languages
English (en)
French (fr)
Inventor
于群
徐君
王元钢
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN201580001269.4A priority Critical patent/CN107209715B/zh
Priority to PCT/CN2015/087667 priority patent/WO2017028309A1/zh
Priority to EP15901513.0A priority patent/EP3324296B1/en
Publication of WO2017028309A1 publication Critical patent/WO2017028309A1/zh
Priority to US15/895,615 priority patent/US10606769B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/14Protection against unauthorised use of memory or access to memory
    • G06F12/1416Protection against unauthorised use of memory or access to memory by checking the object accessibility, e.g. type of access defined by the memory independently of subject rights
    • G06F12/145Protection against unauthorised use of memory or access to memory by checking the object accessibility, e.g. type of access defined by the memory independently of subject rights the protection being virtual, e.g. for virtual blocks or segments before a translation mechanism
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/10Address translation
    • G06F12/1027Address translation using associative or pseudo-associative address translation means, e.g. translation look-aside buffer [TLB]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/14Protection against unauthorised use of memory or access to memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/062Securing storage systems
    • G06F3/0622Securing storage systems in relation to access
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/545Interprogram communication where tasks reside in different layers, e.g. user- and kernel-space
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/0292User address space allocation, e.g. contiguous or non contiguous base addressing using tables or multilevel address translation means
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1032Reliability improvement, data loss prevention, degraded operation etc
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1052Security improvement
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/46Caching storage objects of specific type in disk cache
    • G06F2212/463File
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/65Details of virtual memory and virtual address translation
    • G06F2212/656Address space sharing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/68Details of translation look-aside buffer [TLB]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/68Details of translation look-aside buffer [TLB]
    • G06F2212/681Multi-level TLB, e.g. microTLB and main TLB
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/68Details of translation look-aside buffer [TLB]
    • G06F2212/683Invalidation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/72Details relating to flash memory management
    • G06F2212/7201Logical to physical mapping or translation of blocks or pages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/72Details relating to flash memory management
    • G06F2212/7207Details relating to flash memory management management of metadata or control data

Definitions

  • Embodiments of the present invention relate to the field of computer systems, and in particular, to a file data access method and a computer system.
  • a file system is a method of storing and organizing computer data. It uses a file format to organize data stored in a memory and defines a file access policy. Strictly speaking, a file system is a set of data storage, hierarchical organization, Data management software for operations such as access.
  • the traditional file system works in the kernel mode, and the user process runs in the user mode. If the user-run process needs to access files in the memory, such as reading/writing files, it needs to execute the file system interface function and execute the file system interface.
  • the function belongs to the system call, it will switch from the user mode to the kernel state, and then execute the file system interface function in the kernel state to realize the access to the file in the memory. After the file access is completed, the kernel state is switched back to the user state, and the process continues; The switch between the secondary user state and the kernel state occupies resources and takes up time.
  • an embodiment of the present invention provides a file data access method and a computer system; and securely accessing file data in a user state.
  • an embodiment of the present invention provides a file data access method, where the method is applied to a computer system, the computer system includes a processor and a memory, and the memory is a non-volatile memory, and the processor is Running an operating system, the operating system adopting a file system to manage file data in the memory;
  • the process running on the operating system is allocated with user space and kernel space at the time of initialization, and the user space of the process includes a file system space and a page global directory space, and the page global directory space is a virtual address space of the page global directory.
  • the page global directory space is a virtual address space of the page global directory.
  • the method includes:
  • the method further includes:
  • the page global directory page table is also recorded in the memory, the page global directory page The table points to the base address of the global directory of the page;
  • the accessing the page global directory by using the page global directory space includes:
  • the method further includes:
  • the second virtual address is operated to link the base address of the file page table of the process to the first page global directory entry.
  • the method further includes:
  • the method further includes:
  • an embodiment of the present invention provides a computer system including a processor and a memory, the memory is a non-volatile memory, an operating system is run on the processor, and the operating system uses a file system to manage the File data in memory;
  • the process running on the operating system is allocated with user space and kernel space at the time of initialization, and the user space of the process includes a file system space and a page global directory space, and the page global directory space is a virtual address space of the page global directory. a physical address space for mapping to the page global directory in the memory, the file system space being a virtual address space of the file data, for mapping to a physicality of the file data in the memory space;
  • the operating system includes an access unit and a link unit
  • the access unit is configured to access the page global directory by using the page global directory space when acquiring the access information that the process accesses the first file data;
  • the linking unit configured to determine, according to the access to the page global directory, the first page in the page global directory according to the first virtual address in the file system space according to the first file data a global directory entry, and linking a base address of the file page table of the process to the first page global directory entry, the file page table pointing to a physical address of the file data, so that the processor is configured according to the a virtual address and obtaining, by the page global directory and the file page table index, a first physical address of the first file data in the memory, and the first file data according to the first physical address Make an access.
  • the linking unit when the access to the first file data ends, is configured to: disconnect the base of the file page table The link between the address and the first page global catalog item in the page global directory.
  • a page global directory page table is also recorded in the memory, where the page global directory page The table points to the base address of the global directory of the page;
  • the access unit is configured to access the page global directory by using the page global directory space, specifically:
  • the access unit is configured to obtain a preset address in the global directory space of the page, and index the second global directory entry in the global directory of the page according to the preset address, according to the second global directory.
  • the entry queries the page global catalog page table and accesses the page global catalog based on the base address of the page global catalog page indicated by the page global catalog page table.
  • the operating system includes Interrupt processing unit;
  • the interrupt processing unit is configured to acquire a second virtual address of the first page global directory entry in the kernel space when a process interrupt occurs in the process of accessing the first file data by the process, and the operation is performed.
  • the second virtual address is used to disconnect a link between a base address of the file page table and the first page global directory entry;
  • the interrupt processing unit is configured to operate the second virtual address to link a base address of a file page table of the process to the first page global directory entry.
  • the operating system includes a thread scheduler
  • the thread scheduler is configured to acquire a second virtual address of the first page global directory item in the kernel space, Operating the second virtual address to disconnect a link between a base address of the file page table and the first page global directory entry;
  • the thread scheduler When scheduling other threads to access the thread of the first file data in the process, the thread scheduler is configured to operate the second virtual address to link a base address of a file page table of the process to The first page global directory entry.
  • the operating system further includes a cache clearing unit
  • the cache clearing unit is configured to clear the translation of the bypass buffer TLB table The TLB entry corresponding to the file page table.
  • an embodiment of the present invention provides a computer system, where the computer system includes a processor and a memory, the processor and the memory are connected by a memory bus, and the memory is a non-volatile memory, Running an operating system on the processor, the operating system adopting a file system to manage file data in the memory;
  • the process running on the operating system is allocated with user space and kernel space at the time of initialization, and the user space of the process includes a file system space and a page global directory space, and the page global directory space is a virtual address space of the page global directory. a physical address space for mapping to the page global directory in the memory, the file system space being a virtual address space of the file data, for mapping to a physicality of the file data in the memory space;
  • the non-volatile memory is configured to store computer execution instructions
  • the processor reads the computer execution instructions stored by the non-volatile memory to cause the computer system to execute when the computer system is running A file data access method according to any one of claims 1 to 6.
  • the base address of the file page table is linked to the first page global directory item, so that the first file data in the NVM is accessed in the user state, and the user is implemented. Secure access to the first file data.
  • FIG. 1 is a schematic diagram of a system hardware structure of an application scenario of a file data access method
  • FIG. 2 is a schematic diagram of a user space of a process and its corresponding page table
  • FIG. 3 is an exemplary basic flowchart of a file data access method
  • step S301 in FIG. 3 is an optional refinement flowchart of step S301 in FIG. 3;
  • FIG. 5 is an optional refinement flowchart of the file data access method provided in FIG. 3;
  • FIG. 7 is a schematic diagram of the logic implementation of the operating system 600.
  • the system scenario of the embodiment of the present invention is as shown in FIG. 1.
  • the computer system 100 includes a processor 101, a non-volatile memory (Non Volatile Memory, NVM) 102, and a memory bus 103.
  • the processor 101 can be accessed through the memory bus 103.
  • the nonvolatile memory 102, the nonvolatile memory 102 may be a phase change memory (PCM), a resistive random access memory (RRAM), a magnetic random access memory (MRAM), or a ferroelectric
  • PCM phase change memory
  • RRAM resistive random access memory
  • MRAM magnetic random access memory
  • ferroelectric ferroelectric
  • the storage medium of the nonvolatile memory 102 is not limited.
  • the nonvolatile memory 102 is used as a memory, and includes temporary data for implementing the save processor 101, operation data (including computer instructions) for storing and storing the processor 101, and temporary storage and external memory ( Memory functions such as data exchanged such as hard disks, disks, etc.
  • temporary storage and external memory Memory functions such as data exchanged such as hard disks, disks, etc.
  • DRAM Dynamic Random Access Memory
  • the advantage of the non-volatile memory 102 as memory usage is that the non-volatile memory 102 has data when power is off. Lost features, after power failure recovery, use is not easy
  • the data in the lost memory 102 can restore the running scene before power down in time, and continue the task before power down.
  • the processor 101 may be a central processing unit (CPU), which serves as a control core of the computer device, interprets and executes computer instructions, and processes data of data and/or hardware of software in the computer;
  • CPU central processing unit
  • the processor 101 can also be other programmable logic units.
  • An operating system is run on the processor 101, and other software programs can be run under the scheduling of the operating system.
  • the operating system can use virtual memory to run the software program, and in general, the virtual memory virtual address range is larger than the physical address range of the memory, which is convenient for using a virtual memory to implement a completed program.
  • the operating system can operate the virtual address to select which program segments to cache in 4M memory and exchange between the memory and the external disk when needed. The program fragment, so that you can run 16M programs on a computer with only 4M memory.
  • the processor 101 has a Memory Management Unit (MMU) for converting a virtual address of an operating system into a physical address of physical memory.
  • MMU Memory Management Unit
  • the MMU is responsible for mapping the virtual address of the virtual memory to the physical address of the non-volatile memory 102 (memory), and providing the memory access authorization of the hardware mechanism. If the MMU uses a multi-level page table to implement the address translation of the virtual address to the physical address of the memory, the MMU needs to access the memory N+1 times (N is the page table level) every time the virtual address is converted to the physical address. The cost of each address translation is not small.
  • the Translation Lookaside Buffer (TLB) table is used as the cache of the MMU, and the address mapping relationship recently found by the MMU is cached in the TLB table, specifically in the TLB table. Recording the TLB entry that reflects the address mapping relationship is usually based on each page entry (English name: page table entry, PTE for short) that the MMU recently accesses to generate a TLB entry and update the TLB table with the newly generated TLB entry.
  • the subsequent processor 101 accesses the memory, it first searches whether the TLB entry cached by the TLB table records the virtual address used for accessing the memory.
  • TLB entry If it finds, it directly reads from the cache or the memory according to the physical address recorded by the found TLB entry. Data, if not found, use the MMU to perform virtual address to physical address conversion according to the above multi-level page table, and usually will convert this time
  • the used TLB entries are cached in the TLB table.
  • the operating system divides the virtual address space that virtual memory it uses into user space and kernel space.
  • kernel of the operating system initializes the process, each process is allocated its own dedicated user space and the page directory for addressing.
  • page global directory is used (English full name: page global directory) , abbreviated as: PGD) is described as a page directory addressed for process allocation.
  • kernel space is shared by all processes in the operating system. Each process can enter the kernel through system calls, triggering the kernel to execute kernel code using kernel space.
  • the kernel state also known as the privileged state
  • the kernel refers to the mode in which the kernel of the operating system uses kernel space to execute kernel code.
  • the kernel runs kernel code in kernel mode, and can use kernel space to access system storage and external devices without restriction, and the processing resources occupied are not allowed to be preempted.
  • the user mode also called the non-privileged state, can only use the user space to restrict access to the system storage and external devices, and the processing resources occupied by the user can be preempted; usually, the process is in the user state. Execute the user code.
  • a process running in the user state is executed in the kernel code by means of system calls, interrupts, and exception handling, and the process is switched from the user state to the kernel state; relatively, after executing the kernel code in the kernel state, The process can be switched from kernel mode to user mode.
  • the operating system can use the file system to manage data in the nonvolatile memory; specifically, the file system will use data in the nonvolatile memory. It is organized into file data in the form of a file, corresponding to metadata that generates attributes describing the file data, and stores the metadata in a non-volatile memory.
  • the file system space is divided from the virtual address space of the virtual memory; and the file page table is stored in the non-volatile memory, the file page table records the file system space
  • the mapping between the virtual address in the virtual address and the physical address in the non-volatile memory, the file page table may be a one-level or multi-level page table, usually according to the size of the virtual memory. If the non-volatile memory (memory) is accessed, the MMU of the processor uses the file page table to perform virtual address-to-physical address conversion, and uses the converted physical address to implement access to the file data in the non-volatile memory.
  • the file system space is divided from the kernel space of the virtual memory; the process
  • the file data managed by the file system is a system call.
  • the process of accessing the file data through the system call requires two switching between the user state and the kernel state, which will undoubtedly cause system resource loss and time loss.
  • the embodiment of the present invention selects a part of the virtual address range to be used as the file system space in the user space used by the process alone; therefore, the A file system space, which is a virtual address space of file data in a user space of a process, for mapping to a physical space of the file data in the memory. Recording an address mapping relationship between the file system space and the physical address space of the NVM in the file page table; and, the file page table recording the address mapping relationship may be one or more, correspondingly determined in the global page directory of the process.
  • each first page global directory item is used to correspondingly link a file page table, and the correspondence of the links is determined according to the address mapping relationship or the virtual address of the file system space.
  • the process uses the user space to execute the user code, the base address of the file page table is copied to the corresponding global page directory entry, that is, the link between the first global directory entry and the base address of the file page table is established, and the The first page global directory entry is indexed to the corresponding file page table.
  • the process can operate the file system space at any time and directly access the file data in the NVM, thereby reducing the system call. System resource loss and time loss; but during the entire process, other illegal pointers of the process can also manipulate the file system space and access the file data. The access of the illegal pointer will undoubtedly bring security risks to the file data in the NVM.
  • the first embodiment of the present invention is implemented to securely access file data in the NVM in the user mode.
  • the first improvement accesses the file data in the NVM, and establishes a link between the first global directory entry and the base address of the file page table, and does not need to access the file data in the NVM, and disconnects the first global directory entry and the file. A link to the base address of the page table.
  • the first implementation is integrated into the entire process of accessing file data. If the process recognizes an instruction to access file data on the non-volatile memory or the process performs other access to the file data.
  • the operation corresponds to determining the access information of the process for accessing the file data; if the operating system obtains the access information, the base address of the file page table is linked to the first page global directory entry, so that the MMU can perform address translation.
  • the file system interface function belongs to the interface of the file system, and the execution file system interface function can complete the entire access to the file data in the NVM; in this implementation manner, if the process executes the file system interface function, The operating system will obtain access information to the process to access the file data. Therefore, the implementation mode modifies the file system interface function, and the modification includes: 1. Adding code at the beginning of the file system interface function, the code is used to write the file page table to the first page global directory entry.
  • Base address; 2 also added code at the end of the file system interface function, the code is used to clear the base address of the file page table stored in the first page global directory entry, including modification or deletion, For example, executing the code to write other data (which is different from the base address of the file page table) to the first page global directory entry to implement the clearing, and then executing the code to delete the data in the first page global directory entry, for example. operating.
  • the process when the process does not execute the file system interface function, the first page global directory entry does not store the base address of the file page table, and the MMU cannot index the file page table on the first page global directory entry, and then processes The device cannot access the file data; the process executes to the file system interface function, first writes the base address of the file page table to the first page global directory entry, and the MMU can index the file page table on the first page global directory entry. Therefore, the processor can operate the file system space to access the file data, and finally, when the file data access is ended, the base address of the file page table stored in the first page global directory entry is cleared, and the MMU cannot be on the first page global directory entry. Indexing to the file page table, the processor cannot access the file data.
  • the functions used by the file system to manage files in the memory belong to the file system library functions.
  • the functions in the file system library function are system calls, and then the file data management needs to be implemented in the kernel state.
  • This implementation modifies the execution permission of the file system library function. After modifying the permission, the function in the file system library function (including the file system interface function) can be executed in the user state, and the file data in the NVM can be managed in the user state. .
  • An optional optimization implementation is provided for the first implementation of the first improvement.
  • the file system interface function not only is the addition of a file page table for clearing the first page global directory entry.
  • the base address code also adds code for implementing the TLB entry in the TLB table that corresponds to the file page table.
  • the process executes the file system interface function to access the file data end, not only clears the base address of the file page table recorded in the first page global directory entry, but also clears the TLB entry corresponding to the file page table in the TLB table.
  • the TLB entry cached in the TLB table cannot find the TLB entry corresponding to the file system space for address translation, and the MMU cannot index to the file page table on the first page global directory entry. Address translation is performed, and illegal pointers cannot access file data in the NVM.
  • a second improvement is made in the embodiment of the present invention if it is desired to implement the first improvement in the user mode.
  • the second improvement is to divide a page global directory space different from the file system space from the user space; the page global directory space is a virtual address space of the page global directory, and is used to map to the page global directory in the memory
  • the physical address space in the page; in the page global catalog page table, the mapping between the physical address occupied by the page global directory of the process and the virtual address in the page global directory space is recorded, and the page global directory page table is stored.
  • the second page global directory entry is different from the first page global directory entry used to link the file page table.
  • the MMU can index from the second page global directory entry to the page global directory page table, using the global directory page table for the virtual address. Conversion to physical address. In this way, when the process operates the page global directory space in the user mode, data can be modified for each page global directory entry in the page global directory of the process, for example, copying the base address of the file page table to the first page global directory entry. .
  • the page global directory (English full name: page global directory, PGD for short) page is the page directory of the process; the second PGD item is used for the link page.
  • the second page global directory entry of the global catalog page table; the first PGD item is the first page global catalog item for linking the file page table, and the first PGD item may be one or more, different first PGD
  • the item links different file page tables, and FIG. 2 only schematically provides a link relationship between a first PGD item and a file page table file page table.
  • the page global directory page table is a three-level page table, including the page upper directory (English full name: Page Upper Directory, referred to as: PUD) page, page intermediate directory (English full name: Page Middle Directory, referred to as: PMD) page and Page table entry (English full name: page table entry, referred to as: PTE) page, PUD page, PMD page and PTE page link in turn.
  • PUD Page Upper Directory
  • PMD Page Middle Directory
  • Page table entry English full name: page table entry, referred to as: PTE page
  • PUD page Page
  • PMD page and PTE page link in turn.
  • three spaces are defined from the user space of the process, including a process private space, a PGD mapping space, and a file system space.
  • the implementation uses a process private space to run the process, where the PGD mapping space is used.
  • the virtual address in the PGD mapping space it can be determined which PGD item in the PGD page is the second PGD item corresponding to the PGD mapping space.
  • the second PGD item of the PGD page stores the page global directory page table.
  • Base address the base address of the page global catalog page table is the base address of the PUD page in the page global catalog page table, according to the PGD mapping space and the address mapping relationship of the PGD page in the PTE page of the page global catalog page table A PTE entry is determined, which is used to store the first physical address of the PGD page.
  • the virtual address in the PGD mapping space can be converted to the physical address of the PGD page according to the page global directory page table linked by the second PGD item.
  • the process operates the virtual address of the first PGD item in the PGD mapping space in the user state, and the data recorded in the first PGD item can be changed, for example, the virtual address of the first PGD item is operated to write the base address of the file page table.
  • the first PGD item is entered, and the virtual address of the first PGD item is operated, for example, to delete or change the data recorded in the first PGD item.
  • a process interrupt may occur.
  • the type of the interrupt may be a hardware interrupt or a software interrupt, which is not limited herein; the trigger condition for triggering the process interrupt may be various. It can also be a condition for an existing trigger interrupt, and is not limited herein.
  • the third embodiment of the present invention provides a third improvement, and the third improvement is mainly for modifying the interrupt function for processing interrupts.
  • the third embodiment of the present invention modifies the interrupt function that interrupts the processing process as follows:
  • a code is added at the beginning of the interrupt function, and the code is executed to operate the part of the virtual address to clear the base address of the file page table recorded in the first page global directory entry, and disconnect the first page global directory entry and a link to the base address of the file page table;
  • the code can be executed to operate the part of the virtual address, to achieve the base address of the file page table is written to the first page global directory entry, on the first page global directory entry The base address of the linked file page table.
  • the kernel executes the interrupt function in the kernel state, first operating the part of the virtual address to disconnect the process file page table from the first page global directory entry; then interrupt processing, interrupt The processing may be an existing processing method such as executing an interrupt program; after the interrupt processing is completed, the virtual address is operated to re-link the base address of the file page table to the first page global directory entry.
  • interrupt processing may be an existing processing method such as executing an interrupt program; after the interrupt processing is completed, the virtual address is operated to re-link the base address of the file page table to the first page global directory entry.
  • the embodiment of the present invention can further modify the interrupt function to improve the security factor of the file data that cannot be accessed during the interrupt processing.
  • Further modification of the interrupt function is that the code added at the beginning of the interrupt function can also implement the following functions: A TLB entry corresponding to the file page table in the TLB table; wherein, the TLB entry corresponding to the file page table records an address translation relationship of converting the virtual address of the file system space into the physical address of the file data.
  • the code added at the beginning of the kernel execution interrupt function not only disconnects the file page table from the first page global directory entry, but also clears the TLB entry corresponding to the file page table in the TLB table, during the interrupt processing period. Avoid illegal pointers to the file system space, access file data through the file page table, or access file data in the NVM through the TLB entry in the TLB table, causing system risks and even causing abnormal crashes.
  • a process can have one or more threads at the same time, but for one processor core, only one machine instruction can be executed at any time, and each thread can only execute the instruction by obtaining the right to use the processor core.
  • the so-called multi-threaded concurrent operation means that each thread takes the right to use the processor core in turn, and performs their respective tasks.
  • the kernel needs to run a piece of code to implement the thread scheduler.
  • the thread scheduler is responsible for thread scheduling.
  • the thread scheduling refers to multiple mechanisms according to specific mechanisms. The threads allocate the right to use the processor core.
  • each thread in the process shares the user space of the process; therefore, for the file system space partitioned from the user space of the process, each thread in the process is also shared.
  • each thread performs different tasks, and multiple threads in parallel do not necessarily need to access file data.
  • the fourth embodiment of the present invention provides a fourth improvement.
  • the fourth improvement is to modify the thread scheduling policy.
  • the modified thread scheduling policy can implement the following two processes: the first processing, if the currently running thread in the processor is accessing the file data, but the thread scheduler allocates time for the thread. After the slice has run out, the thread scheduler disconnects the base address of the file page table from the first page global directory entry during the scheduling of the thread to other threads, and preferably also clears the TLB table corresponding to the file page table.
  • the TLB entry thus, even if other threads illegally manipulate the file system space, can avoid using the file page table to access the file data in the NVM, and can not find the TLB entry used to access the file data in the NVM; the second processing
  • the thread scheduler links the base address of the file page table to the first page global directory item during scheduling from other threads to the thread accessing the file data, ensuring that the scheduled thread can continue to access the file data in the NVM.
  • the TLB entry corresponding to the file page table in the TLB table is cleared in the user state, and the TLB entry in the TLB table may be replaced.
  • Alternative method provides three different structures for the TLB table.
  • the TLB table is implemented by using the TLB fully associative structure. If the TLB entry corresponding to the file page table in the TLB table is to be cleared, only part of the TLB entries in the TLB table belong to the file page. The corresponding TLB entry of the table still needs to access the virtual address that is not in the file system space to generate a new TLB entry, and use the new TLB entry to completely replace all TLB entries in the TLB table;
  • the TLB table is implemented by using the TLB group associative structure. If the TLB entry corresponding to the file page table in the TLB table is to be cleared, first determine which TLB groups in the TLB table contain the file. A TLB entry corresponding to the page table, accessing a virtual address that is not in the file system space to generate a new TLB entry, and using the new TLB entry to perform all TLB entries in the determined TLB group (including the TLB entry corresponding to the file page table) Replace all
  • the TLB table is implemented by using a TLB direct associative structure. If the TLB entry corresponding to the file page table in the TLB table is to be cleared, the access is not virtual to the file system space. The address is used to generate a new TLB entry, and the TLB entry corresponding to the file page table in the TLB table is replaced with the new TLB entry.
  • the file data access method provided by the method embodiment of the present invention is applied to a computer system.
  • the computer system includes a processor and a memory, the memory is a non-volatile memory; an operating system is run on the processor, and the operating system uses a file system to manage file data in the memory.
  • the following improvements have been made to the computer system in relation to the prior art:
  • the process running on the operating system is allocated with user space and kernel space at the time of initialization, and the user space of the process includes a file system space and a page global directory space, and the page global directory space is a virtual address space of the page global directory. a physical address space for mapping to the page global directory in the memory, the file system space being a virtual address space of the file data, for mapping to a physicality of the file data in the memory space.
  • the basic flow of the file data access method includes step S301 and step S302.
  • Step S301 When obtaining the access information that the process accesses the first file data, accessing the page global directory through the page global directory space.
  • the first file data belongs to some or all of the data in the file data stored in the NVM, and the first file data may be stored separately in one file or may be stored in multiple files in a distributed manner.
  • the user uses the process running in the operating system to access the first file data in the NVM, or operate
  • the process running in the system executes the code to access the first file data in the NVM, and the access information of the first file data is recorded in the computer system, and the access information indicates the access status of the first file data, so The access information can determine whether the current process accesses the first file data.
  • the access information is usually recorded in a register or in the NVM, but the present invention does not limit the manner in which the record access information is recorded.
  • the access information is recorded in the computer system when the first file data is accessed. If the first file data is not accessed, the access information of the first file data is not recorded in the computer system, so that the first file data is The generation time of the access information determines the event that the current process starts accessing the first file data.
  • the computer system records the access information of the first file data in real time; but when the first file data is accessed, the content of the access information record is different from the content of the access information record when the first file data is not accessed; For example, an event that the current process starts to access the first file data may be determined according to the content recorded by the access information of the first file data.
  • the step S301 is performed to access the page global directory by using the page global directory space.
  • the page global directory space is the virtual address space of the page global directory; in the case that the MMU can know the address translation relationship between the page global directory space and the page global directory in the in-memory physical address space, the operation page globally The virtual address of the directory space enables access to the corresponding page global directory entry in the page global directory.
  • Step S302 Determine, according to the access to the global directory of the page, a first global directory entry in the page global directory according to the first virtual address in the file system space according to the first file data, and a base address of a file page table of the process is linked to the first page global directory entry, the file page table pointing to a physical address of file data of the process, so that the processor passes the first virtual address and passes
  • the page global directory and the file page table index obtain a first physical address of the first file data in the memory, and access the first file data according to the first physical address.
  • the file page table records the address mapping relationship between the file system space and the physical address space of the NVM, and the PTE item in the PTE page in the file page table points to the physical address of the file data. Used to record the article
  • the file page table of the address mapping relationship between the system space and the physical address space of the NVM may be one or more, and one file page table corresponds to a page global directory item to be linked, and the correspondence of the links may be converted according to the file page table. The address is determined.
  • step S302 can determine, according to the first virtual address of the first file data, a first page global directory item, where the first page global directory item is used to link a file page table capable of converting the address to the first virtual address, specifically, There is a PTE entry pointing to the physical address of the first file data in the PTE page of the file page table.
  • the processor converts the first virtual address to the first physical address, it first searches whether the TLB entry that matches the first virtual address is cached in the TLB table, and if found, records the location of the TLB entry.
  • the physical address of the first virtual address mapping is determined as the first physical address, and then the first physical data is directly used to access the first file data in the NVM; in this embodiment, the first virtual address is used.
  • the first file data is accessed once, and the TLB entry that the first virtual address matches cannot be found in the TLB table.
  • the MMU performs address translation on the first virtual address. Specifically, the MMU firstly globalizes according to the address size of the first virtual address. The directory matches the corresponding first page global directory entry, and indexes to the file page table on the first page global directory entry, and further indexes to the PTE page according to the first virtual address in the file page table according to the upper and lower levels of the page. Looking up a PTE entry for converting the first virtual address in the PTE page, the PTE entry pointing to the first physical address.
  • FIG. 2 illustrates an example of an address translation process in which the MMU converts the first virtual address into the first physical address.
  • the corresponding first PGD item is determined in the PGD page according to the address size of the first virtual address, and then according to the first The address size of the virtual address is found in the PUD page of the first PGD item link, and the corresponding PMD item is found in the PMD page of the PUG item according to the address size of the first virtual address, and finally according to the first The address size of the virtual address finds a corresponding PTE item in the PTE page of the PMG item, and the PTE item points to the first physical address.
  • the processor After converting the first virtual address to the first physical address, the processor accesses the first file data in the NVM through the memory bus using the first physical address.
  • step S301 and step S302 are performed to link the file page table to the corresponding first page directory item when accessing the file data in the NVM; and accessing the file data in the NVM.
  • the file page table was not linked to the corresponding first page directory entry, thus avoiding unauthorized access to the file data in the NVM before operating the file system space without accessing the file data in the NVM.
  • a page global directory page table is also recorded in the memory, and the page global directory page table points to a base address of the page global directory.
  • the address mapping relationship recorded in the global directory page table of the page refers specifically to the address translation relationship of the virtual address in the global directory space of the page to the physical address occupied by the page global directory.
  • the PTE item determined in the PTE page of the page global directory page table according to the address mapping relationship is directed to a base address of the page global directory, and the base address of the page global directory page table is linked to the page
  • the MMU can index the base address of the page global catalog page table in the second page global catalog item, and use the page global catalog page table for address translation.
  • the page global directory space is large enough, and only a part of the virtual address in the page global directory space has an address mapping relationship with the physical address of the page global directory page table, and this refinement implementation will A virtual address having an address mapping relationship with a physical address of the global directory page table of the page is referred to as a preset address; a remaining virtual address in the page global directory space (a virtual address other than the preset address in the page global directory space) and the The physical address of the page global catalog page table does not have an address mapping relationship, and the MMU does not convert the remaining portion of the virtual address address to the physical address of the page global catalog page table.
  • step S301 a specific refinement is performed in step S301.
  • the accessing the page global directory through the page global directory space includes steps S401 and S402.
  • Step S401 Acquire a preset address in the global directory space of the page, and index the second global directory entry in the global directory of the page according to the preset address.
  • Step S402 querying the page global directory page table according to the second page global directory entry, and accessing the page global directory according to the base address of the page global directory page indicated by the page global directory page table.
  • the page global directory entry for indexing the preset address in the page global directory can be determined, and the determined page global directory entry is the second page global directory entry.
  • the second page global directory item can be indexed to the page global directory page table, and according to the preset address, the PTE page of the page global directory page table can be found to point to the page global directory.
  • the PTE entry of the base address (the first physical address of the page global directory); when the preset address of the global directory space of the page is manipulated, the page global directory can be accessed.
  • the process can access the global directory space of the page in the user state, so that the process can access the page global directory in the user state, and modify the page in the user state.
  • the data in a global catalog item such as the first page global catalog item.
  • the method further includes step S501.
  • Step S501 when the access to the first file data ends, disconnect the link between the base address of the file page table and the first page global directory entry in the page global directory.
  • the process operates the file system space in the user state to end the access to the first file data, and the process operates the page global directory space to access the page global directory again, specifically accessing the first page in the global directory of the page.
  • the page global directory entry clears the base address of the file page table recorded in the first page global directory entry, and the base address of the file page table is cleared by deleting the base address of the file page table recorded in the first page global directory entry.
  • the way to clear the base address of the file page table may also be to write other data to the first page global directory entry, so that the MMU cannot index to the file page table in the first page global directory entry; therefore, by clearing the first
  • the base address of the file page table recorded in the page global directory entry can be used to disconnect the base address of the file page table from the first page global directory entry.
  • step S302 the base address of the file page table of the process is linked to the first page global directory entry, and step S501 is in the file.
  • step S501 is in the file.
  • the system interface function is executed to access the first file data in the NVM
  • the base address of the file page table of the process is first linked to the first page global directory entry, and then the first virtual address is operated to implement the The access of the first file data, the end of the access, and the disconnection between the base address of the file page table and the first page global directory entry in the page global directory, complete the execution of the file system interface function.
  • the execution file system interface function can realize the access to the file data in the NVM, and the other time when the file system interface function does not execute the file data access, the first page global directory item cannot be indexed to the file page table, even if the operation text is The system space also cannot access the file data in the NVM, which improves the security factor of accessing the file data.
  • the method further includes step S601 and step S602.
  • Step S601 when a process interruption occurs in the process of accessing the first file data by the process, acquiring a second virtual address of the first page global directory entry in the kernel space, and operating the second virtual address Commuting a link between the base address of the file page table and the first page global directory entry;
  • Step S602 when the process interruption ends, operating the second virtual address to link the base address of the file page table of the process to the first page global directory entry.
  • the virtual address of the page global directory is allocated in the kernel space.
  • a page table that records the address translation relationship between the virtual address of the global directory of the page and the physical address of the global directory of the page, linked in the page directory of the kernel; the kernel operates the virtual address of the global directory of the page in the kernel space,
  • the MMU can index the page table in the kernel's page directory (recording the address translation relationship between the virtual address of the page global directory in the kernel space to the physical address of the page global directory) for address translation. Therefore, the kernel can operate the virtual address of the page global directory in the kernel space to access the entire page global directory, including operating the second virtual address access to the first page global directory entry.
  • the kernel space is shared for each process established by the operating system.
  • the process interrupt it is predetermined which software interrupts the process interrupt can include, and which hardware interrupts can be included.
  • the kernel state is trapped, and the kernel executes the interrupt function corresponding to the process interrupt.
  • the present implementation adopts a third improvement as described above, modifying the interrupt function; thereby obtaining the second virtual of the first page global directory entry in the kernel space at the beginning of executing the modified interrupt function Addressing, and operating the second virtual address to disconnect the base address of the file page table from the first page global directory entry; then performing interrupt processing; and executing the modified interrupt function
  • the second virtual address is operated to link the base address of the file page table of the process to the first page global directory entry; the interrupt is executed when the execution of the modified interrupt function is ended. return.
  • the method further includes:
  • the thread scheduler runs in the kernel and allocates time slices for each thread in the process; therefore, the current thread's time slice runs out, and scheduling between threads is performed.
  • This embodiment adopts the fourth improvement described above and modifies the thread scheduling policy.
  • the following describes the thread scheduling process provided by this embodiment in combination with the modified thread scheduling policy:
  • the scheduling policy performs thread scheduling, specifically, acquiring a second virtual of the first page global directory item in the kernel space during scheduling of the currently executing thread that is accessing the first file data to other threads Addressing, and operating the second virtual address to disconnect a link between a base address of the file page table and the first page global directory entry;
  • the time slice of executing other threads is used up, and the thread scheduler uses the modified thread scheduling policy to perform thread scheduling, specifically, during scheduling of other threads currently executing to the thread accessing the first file data, the operation is performed.
  • Two virtual addresses to link the base address of the file page table of the process to the first page global directory entry.
  • the thread scheduler disconnects the base address of the file page table and the first page global directory item before scheduling to other threads that do not need to access the file data.
  • the link between them ensures that other threads cannot illegally access file data in the NVM.
  • the file data to be accessed by the two threads may be the same or different, and when scheduling between the two threads, the second need not be operated.
  • the method further includes:
  • the foregoing method embodiment or the refinement implementation breaks the link between the base address of the file page table and the first page global directory item to prevent unauthorized access to the first file in the NVM.
  • Data but the TLB entry may be cached in the TLB table to record the address mapping relationship between the first virtual address and the first physical address. If the TLB table caches the TLB entry, the embodiment further clears the data.
  • the TLB entry in the TLB table When the first virtual address is illegally operated, the address conversion of the first virtual address to the first physical address is implemented according to the TLB entry, and the first file data is illegally accessed. For example, when the process executes the file system interface function to disconnect the first page global directory entry from the base address of the file page table, the present embodiment clears the TLB entry corresponding to the file page table in the TLB table.
  • the present embodiment clears the TLB entry corresponding to the file page table in the TLB table.
  • the present embodiment clears the TLB entry corresponding to the file page table in the TLB table.
  • the TLB entry in the TLB table is cleared in the user state, and a new virtual address that does not belong to the file system space is operated, and the TLB entry of the virtual address is used to replace the file page table corresponding to the TLB table cache.
  • TLB item the different structures of the TLB table are implemented by using different alternative manners.
  • the foregoing first alternative manner is adopted for the TLB fully associative structure
  • the second alternative manner is adopted for the TLB group associative structure, for example.
  • the third alternative is adopted for the TLB direct associative structure.
  • the first system embodiment the computer system provided by the embodiment of the system includes a processor and a memory, the memory is a non-volatile memory, an operating system is run on the processor, and the operating system adopts a file system management office.
  • File data in memory characterized in that
  • the process running on the operating system is allocated with user space and kernel space at the time of initialization, and the user space of the process includes a file system space and a page global directory space, and the page global directory space is a virtual address space of the page global directory. a physical address space for mapping to the page global directory in the memory, the file system space being a virtual address space of the file data, for mapping to a physicality of the file data in the memory space;
  • the operating system of the embodiment of the present invention is schematically provided from the implementation of the software device.
  • the operating system 700 includes an access unit 701 and a linking unit 702.
  • the access unit 701 is configured to access the page global directory by using the page global directory space when acquiring the access information that the process accesses the first file data.
  • the linking unit 702 is configured to determine, according to the access to the page global directory, the first page global directory in the page global directory according to the first virtual address in the file system space according to the first file data. And linking a base address of the file page table of the process to the first page global directory entry, the file page table pointing to a physical address of the file data, so that the processor is based on the first virtual And obtaining, by the page global directory and the file page table index, a first physical address of the first file data in the memory, and accessing the first file data according to the first physical address .
  • the linking unit 702 is configured to: disconnect the base address of the file page table from the page A link between the first page global catalog items in the global catalog.
  • a page global directory page table is further recorded in the memory, where the page global directory page table points to a base address of the page global directory;
  • the access unit 701 is configured to access the page global directory by using the page global directory space, specifically:
  • the access unit 701 is configured to acquire a preset address in the global directory space of the page, according to the location Decoding a preset address to a second page global directory entry in the page global directory, querying the page global directory page table according to the second page global directory entry, and indicating according to the page global directory page table The base address of the page global directory page accesses the page global directory.
  • the operating system 700 further includes an interrupt processing unit 703;
  • the interrupt processing unit 703 is configured to acquire a second virtual address of the first page global directory item in the kernel space, when a process interruption occurs in the process of accessing the first file data by the process, Operating the second virtual address to disconnect a link between a base address of the file page table and the first page global directory entry;
  • the interrupt processing unit 703 is configured to operate the second virtual address to link the base address of the file page table of the process to the first page global directory entry.
  • the operating system 700 further includes a thread scheduler 704;
  • the thread scheduler 704 is configured to acquire a second virtual address of the first page global directory item in the kernel space.
  • the second virtual address is operated to disconnect a link between the base address of the file page table and the first page global directory entry;
  • the thread scheduler 704 is configured to operate the second virtual address to link a base address of a file page table of the process Go to the first page global catalog item.
  • the operating system 700 further includes a cache clearing unit 705;
  • the cache clearing unit 705 is configured to clear the translation bypass buffer TLB table. A TLB entry corresponding to the file page table.
  • the computer system 100 provided by the system embodiment includes a processor 101 and a memory, and the processor 101 and The memory is connected through the memory bus 103, and the memory is not easy.
  • the operating system runs on the processor 101, and the operating system uses a file system to manage file data in the memory;
  • the process running on the operating system is allocated with user space and kernel space at the time of initialization, and the user space of the process includes a file system space and a page global directory space, and the page global directory space is a virtual address space of the page global directory. a physical address space for mapping to the page global directory in the memory, the file system space being a virtual address space of the file data, for mapping to a physicality of the file data in the memory space;
  • the non-volatile memory 102 is configured to store computer execution instructions, and when the computer system 100 is running, the processor 101 reads the computer execution instructions stored by the non-volatile memory 102 to make The computer system 100 performs the file data access method provided by the foregoing method embodiments or the optional refinement implementations of the foregoing method embodiments.
  • the non-volatile memory 102 may store a complete computer execution instruction for implementing a file data access method; or the computer execution instruction for implementing the file data access method is stored in an external memory, and is not easy to use.
  • the cryptographic memory 102 caches the computer-executable instructions that the processor 101 reads from the external memory, i.e., the non-volatile memory 102 stores only a portion of the computer-executed instructions required for current execution.
  • the disclosed processor, computer system and method may be implemented in other manners.
  • the computer system embodiments described above are merely illustrative.
  • the unit division of the operating system is only a logical function division, and may be implemented in another manner, for example, multiple modules or units or components may be Combined or can be integrated into another system or device, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be electrical, mechanical or otherwise.
  • the units described as separate components may or may not be physically separate, and the components as units may or may not be physical modules, that is, may be located in one place, or may be distributed to multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in various embodiments of the present invention may be integrated in one processing module. It is also possible that each unit physically exists alone, or two or more units may be integrated in one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
  • the above-described units that implement integration in the form of software functional units may be stored in a computer readable storage medium, such as in an NVM, or in an external memory.
  • the software functional units described above are stored in a storage medium and include instructions for causing a computer device (which may be a personal computer, server, or network device, etc.) to perform portions of the steps of the methods described in various embodiments of the present invention.
  • the foregoing memory includes: a mobile hard disk, a read-only memory (English: Read-Only Memory, ROM for short), a random access memory (English: Random Access Memory, RAM for short), a magnetic disk or an optical disk, and the like, which can store program codes. Medium.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Human Computer Interaction (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

本发明实施例公开了一种文件数据访问方法和计算机系统。在获取到进程对第一文件数据进行访问的访问信息时,通过页全局目录空间访问进程的页全局目录;基于对所述页全局目录的访问,根据所述第一文件数据在所述文件系统空间中的第一虚拟地址确定所述页全局目录中的第一页全局目录项,并将所述进程的文件页表的基地址链接到所述第一页全局目录项,所述文件页表指向所述文件数据的物理地址,以便所述处理器根据所述第一虚拟地址并通过所述页全局目录和所述文件页表索引得到所述第一文件数据在所述内存中的第一物理地址,以及根据所述第一物理地址对所述第一文件数据进行访问,实现在用户态下对第一文件数据的安全访问。

Description

文件数据访问方法和计算机系统 技术领域
本发明实施例涉及计算机系统领域,尤其涉及文件数据访问方法和计算机系统。
背景技术
文件系统,是一种存储和组织计算机数据的方法,采用文件形式来组织存储器中存储的数据,并定义文件的访问策略;严格地说,文件系统是一套实现了数据的存储、分级组织、存取等操作的数据管理软件。
传统的文件系统工作在内核态,而用户进程运行在用户态,若用户态运行的进程需要访问存储器中的文件,如对文件进行读/写操作,需要执行文件系统接口函数,执行文件系统接口函数属于系统调用,会从用户态切换到内核态,再在内核态下执行文件系统接口函数实现对存储器中文件的访问,完成文件访问后再从内核态切换回用户态,继续运行进程;两次用户态与内核态之间的切换占用资源,占用时间。
发明内容
有鉴于此,本发明实施例提供了一种文件数据访问方法和计算机系统;实现在用户态安全访问文件数据。
第一方面,本发明实施例提供了一种文件数据访问方法,所述方法应用于计算机系统,所述计算机系统包括处理器和内存,所述内存为非易失性存储器,所述处理器上运行操作系统,所述操作系统采用文件系统管理所述内存中的文件数据;
所述操作系统上运行的进程在初始化时被分配有用户空间和内核空间,所述进程的用户空间包括文件系统空间和页全局目录空间,所述页全局目录空间为页全局目录的虚拟地址空间,用于映射到所述页全局目录在所述内存 中的物理地址空间,所述文件系统空间为所述文件数据的虚拟地址空间,用于映射到所述文件数据在所述内存中的物理空间;
所述方法包括:
在获取到所述进程对第一文件数据进行访问的访问信息时,通过所述页全局目录空间访问所述页全局目录;
基于对所述页全局目录的访问,根据所述第一文件数据在所述文件系统空间中的第一虚拟地址确定所述页全局目录中的第一页全局目录项,并将所述进程的文件页表的基地址链接到所述第一页全局目录项,所述文件页表指向所述文件数据的物理地址,以便所述处理器根据所述第一虚拟地址并通过所述页全局目录和所述文件页表索引得到所述第一文件数据在所述内存中的第一物理地址,以及根据所述第一物理地址对所述第一文件数据进行访问。
结合第一方面,在第一方面的第一种可能的实现方式中,所述方法还包括:
在对所述第一文件数据的访问结束时,断开所述所述文件页表的基地址与所述页全局目录中的第一页全局目录项之间的链接。
结合第一方面或者第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,所述内存中还记录有页全局目录页表,所述页全局目录页表指向所述页全局目录的基地址;
所述通过所述页全局目录空间访问所述页全局目录,包括:
获取所述页全局目录空间中的预设地址,根据所述预设地址索引到所述页全局目录中的第二页全局目录项;
根据所述第二页全局目录项查询所述页全局目录页表,并根据所述页全局目录页表指示的所述页全局目录页的基地址访问所述页全局目录。
结合第一方面或者第一方面的第一种可能的实现方式或者第一方面的第二种可能的实现方式,在第一方面的第三种可能的实现方式中,所述方法还包括:
在所述进程访问所述第一文件数据的过程中发生进程中断时,获取所述第一页全局目录项在所述内核空间中的第二虚拟地址,操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接;
在所述进程中断结束时,操作所述第二虚拟地址来将所述进程的文件页表的基地址链接到所述第一页全局目录项。
结合第一方面或者第一方面的第一种可能的实现方式或者第一方面的第二种可能的实现方式或者第一方面的第三种可能的实现方式,在第一方面的第四种可能的实现方式中,所述方法还包括:
在线程调度器将所述进程中访问所述第一文件数据的线程调度至其他线程时,获取所述第一页全局目录项在所述内核空间中的第二虚拟地址,操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接;
在所述线程调度器将其他线程调度至所述进程中访问所述第一文件数据的线程时,操作所述第二虚拟地址来将所述进程的文件页表的基地址链接到所述第一页全局目录项。
结合第一方面或者第一方面的第一种可能的实现方式或者第一方面的第二种可能的实现方式或者第一方面的第四种可能的实现方式,在第一方面的第五种可能的实现方式中,所述方法还包括:
在断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接时,清除转译旁观缓冲器TLB表中与所述文件页表对应的TLB项。
第二方面,本发明实施例提供了一种计算机系统,包括处理器和内存,所述内存为非易失性存储器,所述处理器上运行操作系统,所述操作系统采用文件系统管理所述内存中的文件数据;
所述操作系统上运行的进程在初始化时被分配有用户空间和内核空间,所述进程的用户空间包括文件系统空间和页全局目录空间,所述页全局目录空间为页全局目录的虚拟地址空间,用于映射到所述页全局目录在所述内存中的物理地址空间,所述文件系统空间为所述文件数据的虚拟地址空间,用于映射到所述文件数据在所述内存中的物理空间;
所述操作系统包括访问单元和链接单元;
所述访问单元,用于在获取到所述进程对第一文件数据进行访问的访问信息时,通过所述页全局目录空间访问所述页全局目录;
所述链接单元,用于基于对所述页全局目录的访问,根据所述第一文件数据在所述文件系统空间中的第一虚拟地址确定所述页全局目录中的第一页 全局目录项,并将所述进程的文件页表的基地址链接到所述第一页全局目录项,所述文件页表指向所述文件数据的物理地址,以便所述处理器根据所述第一虚拟地址并通过所述页全局目录和所述文件页表索引得到所述第一文件数据在所述内存中的第一物理地址,以及根据所述第一物理地址对所述第一文件数据进行访问。
结合第二方面,在第二方面的第一种可能的实现方式中,在对所述第一文件数据的访问结束时,所述链接单元用于:断开所述所述文件页表的基地址与所述页全局目录中的第一页全局目录项之间的链接。
结合第二方面或者第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述内存中还记录有页全局目录页表,所述页全局目录页表指向所述页全局目录的基地址;
所述访问单元,用于通过所述页全局目录空间访问所述页全局目录,具体为:
所述访问单元,用于获取所述页全局目录空间中的预设地址,根据所述预设地址索引到所述页全局目录中的第二页全局目录项,根据所述第二页全局目录项查询所述页全局目录页表,并根据所述页全局目录页表指示的所述页全局目录页的基地址访问所述页全局目录。
结合第二方面或者第二方面的第一种可能的实现方式或者第二方面的第二种可能的实现方式,在第二方面的第三种可能的实现方式中,所述操作系统包括还包括中断处理单元;
在在所述进程访问所述第一文件数据的过程中发生进程中断时,所述中断处理单元,用于获取所述第一页全局目录项在所述内核空间中的第二虚拟地址,操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接;
在所述进程中断结束时,所述中断处理单元,用于操作所述第二虚拟地址来将所述进程的文件页表的基地址链接到所述第一页全局目录项。
结合第一方面或者第一方面的第一种可能的实现方式或者第一方面的第二种可能的实现方式或者第一方面的第三种可能的实现方式,在第一方面的第四种可能的实现方式中,所述操作系统包括还包括线程调度器;
在将所述进程中访问所述第一文件数据的线程调度至其他线程时,所述线程调度器,用于获取所述第一页全局目录项在所述内核空间中的第二虚拟地址,操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接;
在将其他线程调度至所述进程中访问所述第一文件数据的线程时,所述线程调度器,用于操作所述第二虚拟地址来将所述进程的文件页表的基地址链接到所述第一页全局目录项。
结合第一方面或者第一方面的第一种可能的实现方式或者第一方面的第二种可能的实现方式或者第一方面的第三种可能的实现方式或者第四种可能的实现方式,在第一方面的第五种可能的实现方式中,所述操作系统包括还包括缓存清除单元;
在所述链接单元断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接时,所述缓存清除单元,用于清除转译旁观缓冲器TLB表中与所述文件页表对应的TLB项。
第三方面,本发明实施例提供了一种计算机系统,所述计算机系统包括处理器和内存,所述处理器和所述内存通过内存总线连接,所述内存为非易失性存储器,所述处理器上运行操作系统,所述操作系统采用文件系统管理所述内存中的文件数据;
所述操作系统上运行的进程在初始化时被分配有用户空间和内核空间,所述进程的用户空间包括文件系统空间和页全局目录空间,所述页全局目录空间为页全局目录的虚拟地址空间,用于映射到所述页全局目录在所述内存中的物理地址空间,所述文件系统空间为所述文件数据的虚拟地址空间,用于映射到所述文件数据在所述内存中的物理空间;
所述非易失性存储器用于存储计算机执行指令,当所述计算机系统运行时,所述处理器读取所述非易失性存储器存储的所述计算机执行指令,以使所述计算机系统执行权利要求1至6任一项所述的文件数据访问方法。
通过上述方案,在需要访问第一文件数据时,才将文件页表的基地址链接到所述第一页全局目录项上,以便在用户态下访问NVM中的第一文件数据,实现在用户态下对第一文件数据的安全访问。
附图说明
图1为文件数据访问方法的应用场景的系统硬件结构示意图;
图2为进程的用户空间及其对应页表的一种示意图;
图3为文件数据访问方法的一种示范性基本流程图;
图4为对图3中步骤S301的一种可选细化流程图;
图5为对图3提供的文件数据访问方法的一种可选细化流程图;
图6为文件数据访问方法针对中断处理提供的一种可选示范性流程图;
图7为操作系统600的逻辑实现示意图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
本发明实施例适用的系统场景,如图1所示,计算机系统100包括处理器101、非易失存储器(Non Volatile Memory,简称NVM)102和内存总线103,处理器101可通过内存总线103访问非易失存储器102,非易失存储器102可以是相变存储器(Phase Change Memory,PCM)、阻变存储器(Resistive Random Access Memory,RRAM)、磁性随机存储器(Magnetic Random Access Memory,MRAM)或者铁电式随机存储器(Ferroelectric Random Access Memory,FRAM)等,本发明实施例对非易失存储器102具体为哪种存储介质构成不做限定。
本发明实施例中,非易失存储器102作为内存使用,包括用于实现保存处理器101的临时数据、保存存放处理器101运行时的运算数据(包括计算机指令)、以及暂存与外部存储器(如硬盘、磁盘等)等交换的数据等内存功能。相对于传统内存,例如动态随机存储器(Dynamic Random Access Memory,DRAM),在掉电时会丢失数据,非易失存储器102当做内存使用的优点是:非易失存储器102具有在掉电时数据不丢失的特性,掉电恢复后,使用非易 失存储器102中的数据能够及时恢复掉电前的运行场景,继续掉电前的任务。
本发明实施例中,处理器101可以是中央处理器(CPU,Central Processing Unit),该CPU作为计算机设备的控制核心,解释并执行计算机指令,处理计算机中软件的数据和/或硬件的数据;当然,处理器101也可以是其他可编程逻辑单元。
处理器101上运行操作系统,可在该操作系统的调度下运行其他软件程序。本领域人员应知,操作系统可采用虚拟内存(Virtual Memory)来运行软件程序,并且在通常情况下,虚拟内存的虚拟地址范围大于内存的物理地址范围,便于使用虚拟内存实现一个完成程序的运行。例如,若一个计算机只有4M内存,当该计算机需要运行一个16MB的程序时,操作系统可以操作虚拟地址选择将哪些程序片段缓存在4M内存中运行,并在需要时在内存和外部磁盘之间交换程序片段,这样就可以在一个只具有4M内存的计算机上运行16M的程序了。
处理器101具有内存管理单元(Memory Management Unit,简称MMU),MMU用于将操作系统的虚拟地址转换为物理内存的物理地址。本发明实施例中,MMU负责将虚拟内存的虚拟地址映射为非易失存储器102(内存)的物理地址,以及提供硬件机制的内存访问授权。MMU如果是采用多级页表实现虚拟地址到内存的物理地址的地址转换,MMU每完成一次虚拟地址到物理地址的转换,都需要访问内存N+1次(N为页表级数),可见,每次地址转换的开销均不小。为提高MMU将虚拟地址转换为物理地址的转换速度,使用(Translation Lookaside Buffer,简称TLB)表作为MMU的缓存,在TLB表中缓存MMU近期查找出的地址映射关系,具体是在该TLB表中记录反应该地址映射关系的TLB项,通常是依据MMU近期访问的每个页表项(英文全称:page table entry,简称:PTE)项生成TLB项并使用新生成的TLB项更新TLB表。后续处理器101访问内存时,先查找TLB表缓存的TLB项是否记录本次访问内存所使用的虚拟地址,如果查找到,直接根据查找到的TLB项所记录的物理地址从缓存或者内存读取数据,如果没有查找到,才使用MMU根据上述的多级页表进行虚拟地址到物理地址的转换,并通常会将本次转换所 使用的TLB项缓存在TLB表中。
操作系统将其使用的虚拟内存所具有的虚拟地址空间划分为用户空间和内核空间。操作系统的内核初始化进程时,为每个进程分配其各自专用的用户空间以及用于寻址的页目录,为便于与其他页目录区分和理解,下面采用页全局目录(英文全称:page global directory,简称:PGD)作为为进程分配来寻址的页目录进行描述。另外,内核空间对操作系统内的所有进程是共享的,每个进程都可以通过系统调用进入内核,触发内核使用内核空间执行内核代码。
本领域人员知道,内核态,也称作特权态,是指操作系统的内核使用内核空间执行内核代码的模式。内核在内核态下运行内核代码,可以使用内核空间无限制地对系统存储、外部设备进行访问,并且所占有的处理资源是不允许被抢占的。相对应地,用户态,也称作非特权态,只能使用用户空间有限制地对系统存储、外部设备进行访问,其所占有的处理资源是可被抢占的;通常,进程在用户态下执行用户代码。另外,一个处于用户态下运行的进程,通过系统调用、中断和异常处理等方式而陷入内核代码中执行,称进程从用户态切换到内核态;相对地,完成在内核态执行内核代码后,可以将进程从内核态切换回用户态。
在本发明实施例中,由于非易失存储器具有掉电不丢失数据的特性,操作系统可使用文件系统管理非易失存储器中的数据;具体地,该文件系统将非易失存储器中的数据以文件形式组织成文件数据,对应生成描述文件数据的属性的元数据,并将该元数据存储至非易失存储器中。
为实现操作系统对非易失存储器中的文件数据的访问,从虚拟内存的虚拟地址空间中划分了文件系统空间;并在非易失存储器中存储文件页表,该文件页表记录文件系统空间中的虚拟地址与非易失存储器中的物理地址的映射关系,该文件页表可以是一级或多级页表,通常根据根据虚拟内存的大小而定。若访问非易失存储器(内存),处理器的MMU使用该文件页表进行虚拟地址到物理地址的转换,并使用转换得到的物理地址实现对非易失存储器中文件数据的访问。
现有技术中,文件系统空间是从虚拟内存的内核空间划分出来的;进程 访问文件系统管理的文件数据属于系统调用,进程通过系统调用访问文件数据需要两次在用户态与内核态之间的切换,无疑会造成系统资源损耗以及时间损耗。
鉴于现有技术在用户态与内核态之间的切换所带来的资源损耗,本发明实施例选择在进程独自使用的用户空间中划分出一部分虚拟地址范围作为文件系统空间使用;因此,所述文件系统空间,为在进程的用户空间中文件数据的虚拟地址空间,用于映射到所述文件数据在所述内存中的物理空间。在文件页表中记录该文件系统空间与NVM的物理地址空间的地址映射关系;并且,记录该地址映射关系的文件页表可以是一个或多个,对应地需要在进程的全局页目录中确定一个或多个第一页全局目录项,每个第一页全局目录项用于对应链接一个文件页表,链接的对应关系根据该地址映射关系或者文件系统空间的虚拟地址而定。进程使用用户空间执行用户代码的期间,将文件页表的基地址拷贝到对应第一页全局目录项上,即建立起该第一全局目录项与文件页表的基地址的链接,便可通过该第一页全局目录项索引到对应的文件页表。假如在进程的整个运行期间,文件页表一直链接在该第一页全局目录项上,进程在任何时间都可以操作文件系统空间,直接访问到NVM中的文件数据,减少了系统调用所带来的系统资源损耗和时间损耗;但是在整个进程运行期间,本进程的其他非法指针也可以操作文件系统空间并访问到文件数据,非法指针的访问无疑会给NVM中的文件数据带来安全隐患。
鉴于上述的安全隐患,由于在整个进程运行期间中不一定都需要访问非易失存储器上的文件数据,为实现在用户态下安全访问NVM中的文件数据,本发明实施例做了第一个改进。
第一个改进,进程访问NVM中的文件数据,才建立第一全局目录项与文件页表的基地址的链接,不需访问NVM中的文件数据,断开该第一全局目录项与该文件页表的基地址的链接。
第一个改进结合到访问文件数据的整个过程的具体实现是,若进程识别到访问非易失存储器上的文件数据的指令或者进程执行其它访问文件数据的 操作,便对应确定进程对文件数据进行访问的访问信息;操作系统获取到所述访问信息,才将文件页表的基地址链接到第一页全局目录项上,使得MMU在进行地址转换时能够从该第一页全局目录项索引到文件页表;待完成对非易失存储器上的文件数据访问,删除第一页全局目录项上记录的文件页表的基地址,断开第一页全局目录项与文件页表的链接关系,使得MMU不能够从该第一页全局目录项索引到文件页表。因此第一个改进可避免:在不需要访问文件系统的其他时间段内,MMU非法在第一页全局目录项上索引到文件页表来进行地址转换。
作为第一个改进的一种实现方式,文件系统接口函数属于文件系统的接口,执行文件系统接口函数可完成对NVM中文件数据的整个访问;本实现方式中,若进程执行文件系统接口函数,操作系统便会获取到所述进程对文件数据进行访问的访问信息。因此,本实现方式对文件系统接口函数进行修改,修改包括:1,在文件系统接口函数中的起始处添加了代码,该代码用于向第一页全局目录项写入所述文件页表的基地址;2,还在文件系统接口函数中的末尾处添加了代码,该代码用于清除在第一页全局目录项中存储的所述文件页表的基地址,清除包括修改或删除,例如执行该代码来向第一页全局目录项写入其他数据(与所述文件页表的基地址不同)来实现清除,再例如执行该代码来对第一页全局目录项中的数据进行删除操作。本实现方式中,进程未执行文件系统接口函数的其它时间,第一页全局目录项中没有存储文件页表的基地址,MMU无法在第一页全局目录项上索引到文件页表,进而处理器无法实现对文件数据的访问;进程执行到文件系统接口函数,首先向第一页全局目录项中写入文件页表的基地址,MMU能够在第一页全局目录项上索引到文件页表,从而处理器可操作文件系统空间来访问文件数据,最后在结束文件数据访问时,清除在第一页全局目录项中存储的文件页表的基地址,MMU无法在第一页全局目录项上索引到文件页表,处理器无法实现对文件数据的访问。
本领域人员应知,文件系统管理存储器中的文件所使用的函数(例如文件系统接口函数),统属于文件系统库函数。现有技术中,执行文件系统库函数中的函数属于系统调用,继而需要在内核态下实现文件数据的管理。本实施 例修改了文件系统库函数的执行权限,修改权限后在用户态下即可执行文件系统库函数中的函数(包括文件系统接口函数),在用户态下便可对NVM中的文件数据进行管理。
对第一个改进的上述实现方式提供一个可选的优化实现方式,在文件系统接口函数中的末尾处,不但添加了用于实现清除在第一页全局目录项中清除所述文件页表的基地址的代码,还添加了用于实现清除TLB表中与文件页表对应的TLB项的代码。进程执行该文件系统接口函数访问文件数据结束,不但清除在第一页全局目录项中记录的所述文件页表的基地址,还清除TLB表中与文件页表对应的TLB项。这样,即使非法指针操作文件系统空间,在TLB表中缓存的TLB项找不到与文件系统空间对应的TLB项来进行地址转换,MMU不能在第一页全局目录项上索引到文件页表来进行地址转换,非法指针无法访问NVM中的文件数据。
如果期望在用户态下实现第一个改进,本发明实施例做了第二个改进。
第二个改进,从用户空间划分出不同于文件系统空间的页全局目录空间;所述页全局目录空间,为页全局目录的虚拟地址空间,用于映射到所述页全局目录在所述内存中的物理地址空间;本发明实施例在该页全局目录页表中记录进程的页全局目录所占用的物理地址与页全局目录空间中的虚拟地址的映射关系,并将页全局目录页表存储在内存中。因页全局目录空间与文件系统空间不同,相应地,第二页全局目录项与用于链接文件页表的第一页全局目录项也不同。若将该页全局目录页表链接到进程的页全局目录的第二页全局目录项上,MMU便可从第二页全局目录项索引到页全局目录页表,使用全局目录页表进行虚拟地址到物理地址的转换。这样,进程在用户态下操作页全局目录空间时,即可对进程的页全局目录中每个页全局目录项进行数据修改,例如将文件页表的基地址拷贝到第一页全局目录项上。
作为第二个改进的一种实现方式,参见图2,图2中的页全局目录(英文全称:page global directory,简称:PGD)页为进程的页目录;第二PGD项为用于链接页全局目录页表的第二页全局目录项;第一PGD项为用于链接文件页表的第一页全局目录项,第一PGD项可以是一个或多个,不同第一PGD 项链接不同的文件页表,图2仅示意性地提供了一个第一PGD项与一个文件页表文件页表的链接关系。图2中,页全局目录页表为三级页表,包括页上级目录(英文全称:Page Upper Directory,简称:PUD)页、页中级目录(英文全称:Page Middle Directory,简称:PMD)页和页表项(英文全称:page table entry,简称:PTE)页,PUD页、PMD页以及PTE页依次链接。如图2所示,从进程的用户空间中划分出三个空间,包括进程私有空间、PGD映射空间和文件系统空间,其中,本实现方式使用程私有空间来运行进程,其中,将PGD映射空间作为页全局目录空间。根据该PGD映射空间中的虚拟地址即可确定PGD页中哪个PGD项为与PGD映射空间对应的第二PGD项,本实现方式中,该PGD页的第二PGD项存储页全局目录页表的基地址,该页全局目录页表的基地址即为页全局目录页表中的PUD页的基地址,根据该PGD映射空间与该PGD页的地址映射关系在页全局目录页表的PTE页中确定一个PTE项,该个PTE项用于存储PGD页的首个物理地址。这样,根据第二PGD项链接的页全局目录页表,可将PGD映射空间中的虚拟地址转换为PGD页的物理地址。进而,进程在用户态下操作PGD映射空间中第一PGD项的虚拟地址,即可更改第一PGD项中记录的数据,例如操作第一PGD项的虚拟地址来将文件页表的基地址写入第一PGD项,再例如操作第一PGD项的虚拟地址来删除或者更改第一PGD项中记录的数据。
进程在用户态下访问NVM中的文件数据的过程中,可能会发生进程中断,该进程中断的类型可以是硬件中断和软件中断,此处不做限定;触发进程中断的触发条件可以多种多样,也可以是现有触发中断的条件,在此也不做限定。为避免在进程中断期间,非法指针操作文件系统空间来访问文件数据,本发明实施例做了第三个改进,在第三个改进主要是针对处理中断的中断函数进行了修改。
本领域人员应知,在操作系统的内核空间中已确定了部分虚拟地址,这部分虚拟地址与进程的页全局目录的物理地址映射;即这部分虚拟地址为进程的页全局目录在内核空间中的虚拟地址,供内核操作进程的页全局目录使用。基于此部分虚拟地址,本发明实施例在第三个改进中对处理进程中断的中断函数做了如下修改:
一,在该中断函数的起始处添加了代码,执行该代码可操作这部分虚拟地址来清除第一页全局目录项中记录的文件页表的基地址,断开第一页全局目录项与文件页表的基地址的链接;
二,在该中断函数的末尾处也添加了代码,执行该代码可操作这部分虚拟地址,来实现将文件页表的基地址写入第一页全局目录项,在第一页全局目录项上链接文件页表的基地址。
基于第三个改进,进程陷入进程中断之后,内核在内核态下执行中断函数,首先操作这部分虚拟地址断开该进程文件页表与第一页全局目录项的链接;继而进行中断处理,中断处理可以是执行中断程序等现有处理方式;完成中断处理后,操作这部分虚拟地址重新将该文件页表的基地址链接到与第一页全局目录项。这样,中断处理的时间段内,非法指针即使操作文件系统空间,也无法使用文件页表访问到文件数据,保证了中断处理对NVM中文件数据的保护。
本发明实施例可对中断函数作进一步修改来提高中断处理期间不能访问文件数据的安全系数,对中断函数的进一步修改是,在该中断函数的起始处添加的代码还能实现以下功能:清除TLB表中与文件页表对应的TLB项;其中,与文件页表对应的TLB项,记录有将文件系统空间的虚拟地址转换为文件数据的物理地址的地址转换关系。这样,内核执行中断函数的起始处添加的代码,不但会断开文件页表与第一页全局目录项的链接,还会清除TLB表中与文件页表对应的TLB项,中断处理期间,避免指向文件系统空间的非法指针,能够通过文件页表访问到文件数据,或者通过TLB表中的TLB项访问NVM中的文件数据,引发系统风险,甚至导致异常死机。
本领域人员应知,进程可以同时具有一个或多个线程,但对于一个处理器核而言,在任意时刻都只能执行一条机器指令,每个线程只有获得处理器核的使用权才能执行指令。所谓多线程的并发运行,从宏观上看,是指各个线程轮流获得处理器核的使用权,分别执行各自的任务。在运行的线程池中会有多个处于就绪状态的线程在等待处理器核,需要内核运行一段代码来实现线程调度器,该线程调度器负责线程调度,该线程调度是指按照特定机制为多个线程分配处理器核的使用权。
进程中各个线程是共享所述进程的用户空间的;因此对于从该进程的用户空间划分出的文件系统空间,该进程中每个线程也是共享的。通常,各个线程执行不同任务,并行的多个线程不一定都需要访问文件数据,为避免并行线程中的非法指针修改文件数据,本发明实施例做了第四个改进。
第四个改进是修改线程调度策略,修改的线程调度策略可实现以下两个处理:第一个处理,若处理器中当前运行的线程正在访问文件数据,但线程调度器为本线程分配的时间片已用完,线程调度器在将本线程调度至其它线程的期间,断开文件页表的基地址与第一页全局目录项的链接,优选地,还清除TLB表中与文件页表对应的TLB项,从而,即使其它线程非法操作文件系统空间,也能避免使用文件页表访问到NVM中的文件数据,也查找不到用来访问NVM中的文件数据的TLB项;第二个处理,线程调度器从其它线程调度至访问文件数据的线程的期间,将文件页表的基地址链接到第一页全局目录项,保证调度后的线程能够继续访问NVM中的文件数据。采用改进的线程调度策略,能够避免其他线程的非法指针,在执行该其他线程的时间片非法访问NVM中的文件数据。
本发明实施例中可选地,为实现在用户态下清除TLB表中与文件页表对应的TLB项,可采用替换TLB表中TLB项的方式实现,下面针对TLB表的不同结构提供三种替换方式:
第一种替换方式,TLB表采用TLB全相联结构实现,如果要实现对TLB表中与所述文件页表对应的TLB项的清除,即使TLB表中仅部分TLB项属于与所述文件页表对应的TLB项,仍需访问不属于文件系统空间的虚拟地址来生成新TLB项,利用新TLB项对TLB表中所有TLB项进行全部替换;
第二种替换方式,TLB表采用TLB组相联结构实现,如果要实现对TLB表中与所述文件页表对应的TLB项的清除,首先确定TLB表中哪些TLB组包含有与所述文件页表对应的TLB项,访问不属于文件系统空间的虚拟地址来生成新TLB项,利用新TLB项对确定的TLB组(包含有与所述文件页表对应的TLB项)中所有TLB项进行全部替换;
第三种替换方式,TLB表采用TLB直接相联结构实现,如果要实现对TLB表中与所述文件页表对应的TLB项的清除,访问不属于文件系统空间的虚拟 地址来生成新TLB项,利用新TLB项一一替换TLB表中与所述文件页表对应的TLB项。
本发明的方法实施例
基于上述计算机系统提供的硬件环境,结合上述改进,提供了文件数据访问方法的基本实现流程及其可选优化的细化实现流程;该文件数据访问方法的基本实现流程如图3所示,但为便于说明,仅在图3示出与本实施例相关的部分。
首先重申下,本发明的方法实施例所提供的文件数据访问方法,应用于计算机系统。所述计算机系统包括处理器和内存,所述内存为非易失性存储器;所述处理器上运行操作系统,所述操作系统采用文件系统管理所述内存中的文件数据。相对于现有技术,为实现本发明,对该计算机系统做了以下改进:
所述操作系统上运行的进程在初始化时被分配有用户空间和内核空间,所述进程的用户空间包括文件系统空间和页全局目录空间,所述页全局目录空间为页全局目录的虚拟地址空间,用于映射到所述页全局目录在所述内存中的物理地址空间,所述文件系统空间为所述文件数据的虚拟地址空间,用于映射到所述文件数据在所述内存中的物理空间。
基于上述改进后的计算机系统,下面对文件数据访问方法的方法实施例进行适应性详述,为便于描述,以下文件数据访问方法的基本流程或基本流程的可选细化流程均是从单个进程提供的,应知,这些方法流程对于计算机系统中运行的每个进程均是适用的,并在在本发明的精神下,可对流程中的部分步骤或技术特征作删减、等同替换、增加等操作。
参见图3,文件数据访问方法的基本流程包括步骤S301和步骤S302。
步骤S301、在获取到所述进程对第一文件数据进行访问的访问信息时,通过所述页全局目录空间访问所述页全局目录。
须知,第一文件数据属于NVM中存储的文件数据中的部分或全部数据,第一文件数据可能是单独存储在一个文件里,也可能是分散存储在多个文件中。
用户使用操作系统中运行的进程来访问NVM中的第一文件数据,或者操作 系统中运行的进程自己执行代码来访问NVM中的第一文件数据,都会在计算机系统中记录下该第一文件数据的访问信息,该访问信息表示对第一文件数据的访问状态,因此通过该访问信息能够确定当前进程是否访问第一文件数据。通常是将访问信息记录在寄存器中或者NVM中,但本发明对记录访问信息的记录方式不做限定。
可选地,访问第一文件数据时才在计算机系统中记录访问信息,若没有访问第一文件数据,在计算机系统中不会记录有第一文件数据的访问信息,这样可根据第一文件数据的访问信息的生成时间确定当前进程开始访问第一文件数据这一事件。
可选地,计算机系统实时记录第一文件数据的访问信息;但访问第一文件数据时该访问信息记录的内容,与没有访问第一文件数据时该访问信息记录的内容,存在不同;本实施例可根据第一文件数据的访问信息所记录的内容,确定当前进程开始访问第一文件数据这一事件。
本实施例中,处理器若根据第一文件数据的访问信息确定发生当前进程开始访问第一文件数据这一事件,执行步骤S301通过所述页全局目录空间访问所述页全局目录。
须知,页全局目录空间为页全局目录的虚拟地址空间;在MMU能够获知该页全局目录空间与页全局目录在所述内存中的物理地址空间之间的地址转换关系的情况下,操作页全局目录空间的虚拟地址,可实现对页全局目录中对应的页全局目录项进行访问。
步骤S302、基于对所述页全局目录的访问,根据所述第一文件数据在所述文件系统空间中的第一虚拟地址确定所述页全局目录中的第一页全局目录项,并将所述进程的文件页表的基地址链接到所述第一页全局目录项,所述文件页表指向所述进程的文件数据的物理地址,以便所述处理器根据所述第一虚拟地址并通过所述页全局目录和所述文件页表索引得到所述第一文件数据在所述内存中的第一物理地址,以及根据所述第一物理地址对所述第一文件数据进行访问。
具体地,文件页表记录文件系统空间与NVM的物理地址空间的地址映射关系,文件页表中的PTE页中的PTE项指向文件数据的物理地址。用于记录该文 件系统空间与NVM的物理地址空间的地址映射关系的文件页表可能是一个或多个,一个文件页表对应需一个页全局目录项来链接,链接的对应关系根据文件页表可转换的虚拟地址确定。
因此,步骤S302根据第一文件数据的第一虚拟地址,能够确定第一页全局目录项,该第一页全局目录项用于链接能够对第一虚拟地址转换地址的文件页表,具体是,在该文件页表的PTE页中存在指向第一文件数据的物理地址的PTE项。
处理器在实现对第一虚拟地址转换为第一物理地址时,首先查找TLB表中是否缓存有与所述第一虚拟地址匹配的TLB项,如果查找到,将该TLB项中记录的与所述第一虚拟地址映射的物理地址确定为所述第一物理地址,继而可直接使用该第一物理地址访问到NVM中的所述第一文件数据;本实施例中,使用第一虚拟地址第一次访问第一文件数据,在TLB表中是查找不到该第一虚拟地址匹配的TLB项的。
如果处理器在TLB表中没有查找到与所述第一虚拟地址匹配的TLB项,MMU对第一虚拟地址进行地址转换,具体是,MMU首先根据第一虚拟地址的地址大小在所述页全局目录中匹配到对应的第一页全局目录项,并在该第一页全局目录项上索引到文件页表,进一步根据第一虚拟地址在文件页表中按照页的上下级依次索引到PTE页,在该PTE页中查找用于转换第一虚拟地址的PTE项,该PTE项指向第一物理地址。
以图2为例举例说明MMU将第一虚拟地址转换为第一物理地址的地址转换过程,首先,根据第一虚拟地址的地址大小在PGD页中确定对应的第一PGD项,再根据第一虚拟地址的地址大小在第一PGD项链接的PUD页中查找到对应的PUD项,再根据第一虚拟地址的地址大小在该PUG项的PMD页中查找到对应的PMD项,最后根据第一虚拟地址的地址大小在该PMG项的PTE页中查找到对应的PTE项,该PTE项指向第一物理地址。
处理器在将第一虚拟地址转换为第一物理地址之后,通过内存总线,使用第一物理地址访问到NVM中的第一文件数据。
本实施例执行步骤S301和步骤S302,实现在需要访问NVM中的文件数据时,才将文件页表链接到对应第一页目录项上;在访问NVM中的文件数据 之前,该文件页表是没有链接到对应第一页目录项上的,这样可避免没访问NVM中的文件数据之前操作文件系统空间非法访问到NVM中的文件数据。
作为本方法实施例的一可选细化实现方式,在所述内存中还记录有页全局目录页表,所述页全局目录页表指向所述页全局目录的基地址。参见上述第二个改进中的描述,在该页全局目录页表记录的地址映射关系,具体是指页全局目录空间中的虚拟地址到页全局目录所占用的物理地址的地址转换关系。并且,根据该地址映射关系在所述页全局目录页表的PTE页中确定的PTE项是指向所述页全局目录的基地址的,将所述页全局目录页表的基地址链接到该页全局目录页表中的第二页全局目录项,MMU便可在第二页全局目录项索引到所述页全局目录页表的基地址,使用所述页全局目录页表进行地址转换。
为了提高访问页全局目录的安全系数,页全局目录空间足够大,页全局目录空间中仅一部分虚拟地址与该页全局目录页表的物理地址具有一一地址映射关系,本细化实现方式将这部分与该页全局目录页表的物理地址具有地址映射关系的虚拟地址称作预设地址;页全局目录空间中剩余部分虚拟地址(页全局目录空间中除了预设地址以外的虚拟地址)与该页全局目录页表的物理地址不具有地址映射关系,MMU不会将剩余部分虚拟地址地址转换为该页全局目录页表的物理地址。
相应地,对步骤S301作一具体细化,参见图4,所述通过所述页全局目录空间访问所述页全局目录,包括步骤S401和步骤S402。
步骤S401,获取所述页全局目录空间中的预设地址,根据所述预设地址索引到所述页全局目录中的第二页全局目录项。
步骤S402,根据所述第二页全局目录项查询所述页全局目录页表,并根据所述页全局目录页表指示的所述页全局目录页的基地址访问所述页全局目录。
本细化实现方式中,根据预设地址的地址大小,能够确定页全局目录中用于索引该预设地址的页全局目录项,确定的页全局目录项即是第二页全局目录项。进一步地,从第二页全局目录项可索引到页全局目录页表,并根据该预设地址能够在页全局目录页表的PTE页中查找到指向所述页全局目录的 基地址(所述页全局目录的首个物理地址)的PTE项;在操作页全局目录空间的预设地址时,能够访问到所述页全局目录的。
因页全局目录空间是从进程的用户空间中划分出来的,进程在用户态下可访问该页全局目录空间,这样,该进程能够在用户态下访问到页全局目录,在用户态下修改页全局目录项(例如第一页全局目录项)中的数据。
作为本方法实施例的一可选细化实现方式,参见图5,所述方法还包括步骤S501。
步骤S501,在对所述第一文件数据的访问结束时,断开所述所述文件页表的基地址与所述页全局目录中的第一页全局目录项之间的链接。
具体地,进程在用户态下操作文件系统空间对所述第一文件数据的访问结束,进程会操作页全局目录空间再次访问所述页全局目录,具体是访问所述页全局目录中的第一页全局目录项,清除第一页全局目录项中记录的文件页表的基地址,清除该文件页表的基地址的方式可以是删除第一页全局目录项中记录的文件页表的基地址,清除该文件页表的基地址的方式还可以是向第一页全局目录项写入其他数据,这样,MMU无法在第一页全局目录项中索引到文件页表;因此,通过清除第一页全局目录项中记录的文件页表的基地址,便可实现断开所述文件页表的基地址与所述第一页全局目录项之间的链接。
本方法是实施例中可采用上述第一个改进的一种实现方式,步骤S302中将所述进程的文件页表的基地址链接到所述第一页全局目录项,和步骤S501,在文件系统接口函数中实现。这样,在执行文件系统接口函数访问NVM中的第一文件数据时,首先将所述进程的文件页表的基地址链接到所述第一页全局目录项,继而操作第一虚拟地址可实现对第一文件数据的访问,访问结束,再断开所述所述文件页表的基地址与所述页全局目录中的第一页全局目录项之间的链接,完成文件系统接口函数的执行。可见,执行文件系统接口函数可实现对NVM中的文件数据的访问,未执行文件系统接口函数访问文件数据的其他时间,无法在第一页全局目录项索引到文件页表,即使操作文 件系统空间也无法访问到NVM中的文件数据,提高了访问文件数据的安全系数。
作为本方法实施例的一可选细化实现方式,参见图6,所述方法还包括步骤S601和步骤S602。
步骤S601,在所述进程访问所述第一文件数据的过程中发生进程中断时,获取所述第一页全局目录项在所述内核空间中的第二虚拟地址,操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接;
步骤S602,在所述进程中断结束时,操作所述第二虚拟地址来将所述进程的文件页表的基地址链接到所述第一页全局目录项。
本领域人员应知,操作系统初始化进程时,在内核空间分配有页全局目录的虚拟地址。记录该页全局目录在内核空间的虚拟地址到该页全局目录的物理地址之间的地址转换关系的页表,链接在内核的页目录中;内核操作该页全局目录在内核空间的虚拟地址,MMU能够在内核的页目录中索引到该页表(记录该页全局目录在内核空间的虚拟地址到该页全局目录的物理地址之间的地址转换关系)来进行地址转换。因此,内核可操作内核空间中该页全局目录的虚拟地址访问整个页全局目录,包括操作第二虚拟地址访问到第一页全局目录项。本实施方式中可选地,内核空间对于操作系统建立的每个进程是共享的。
在本实现方式中,预先设定进程中断可以包括哪些软件中断,以及可以包括哪些硬件中断。所述进程访问所述第一文件数据的过程中,如果发生任一种进程中断,均会陷入到内核态,内核执行该进程中断对应的中断函数。本实现方式采用如上所述的第三个改进,对中断函数做了修改;从而在执行修改的中断函数的开始处,获取所述第一页全局目录项在所述内核空间中的第二虚拟地址,并操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接;然后进行中断处理;再在执行修改的中断函数的结束处,操作所述第二虚拟地址来将所述进程的文件页表的基地址链接到所述第一页全局目录项;最后结束执行修改的中断函数时执行中断 返回。
可见,在进行中断处理的期间,不能在所述第一页全局目录项索引到文件页表,即使操作文件系统空间也不能非法访问到NVM中的文件数据。
作为本方法实施例的一可选细化实现方式,所述方法还包括:
在线程调度器将所述进程中访问所述第一文件数据的线程调度至其他线程时,获取所述第一页全局目录项在所述内核空间中的第二虚拟地址,操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接;
对应地,在所述线程调度器将其他线程调度至所述进程中访问所述第一文件数据的线程时,操作所述第二虚拟地址来将所述进程的文件页表的基地址链接到所述第一页全局目录项。
本领域人员应知,线程调度器运行在内核中,为进程中每个线程分配的时间片;因此,当前线程的时间片用完,会进行线程之间的调度。
本实施方式采用上述第四个改进,对用于线程调度策略做了修改。下面结合修改的线程调度策略解释下本实施方式提供的线程调度过程:
为便于理解,假设除了访问所述第一文件数据的线程以外的其他线程,均不需要访问文件数据;当前访问所述第一文件数据的线程的时间片用完,线程调度器采用修改的线程调度策略进行线程调度,具体是在将当前执行的正在访问所述第一文件数据的线程调度至其他线程的调度期间,获取所述第一页全局目录项在所述内核空间中的第二虚拟地址,并操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接;
执行其他线程的时间片用完,线程调度器采用修改的线程调度策略进行线程调度,具体是在将当前执行的其他线程调度至访问所述第一文件数据的线程的调度期间,操作所述第二虚拟地址来将所述进程的文件页表的基地址链接到所述第一页全局目录项。
可见,在并行运行的多个线程中调度时,线程调度器在调度至不需要访问文件数据的其他线程之前,断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接,确保了其他线程不能非法访问NVM中的文件数据。
当然,如果线程调度的前后两个线程都需要访问NVM中的文件数据,两个线程各需访问的文件数据可能相同或者不同,在这两个线程之间调度时,不需要操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接。
作为结合本方法实施例或者结合上述实施方式的一可选细化实现方式,所述方法还包括:
在断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接时,清除转译旁观缓冲器TLB表中与所述文件页表对应的TLB项。
具体地,上述方法实施例或者细化实现方式断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接的目的是为了防止非法访问NVM中的第一文件数据,但在断开之前访问文件数据时可能在TLB表中缓存有记录第一虚拟地址与第一物理地址的地址映射关系的TLB项,如果TLB表缓存有该TLB项,本实施方式进一步清除TLB表中的该TLB项;避免非法操作第一虚拟地址时,根据该TLB项实现第一虚拟地址到第一物理地址的地址转换,非法访问到第一文件数据。例如,进程执行文件系统接口函数来断开在第一页全局目录项与文件页表的基地址的链接时,本实施方式清除TLB表中与所述文件页表对应的TLB项。
例如,进程执行中断函数来断开在第一页全局目录项与文件页表的基地址的链接时,本实施方式清除TLB表中与所述文件页表对应的TLB项。
例如,线程调度器断开在第一页全局目录项与文件页表的基地址的链接时,本实施方式清除TLB表中与所述文件页表对应的TLB项。
本实施方式可选地,为在用户态下实现TLB表中TLB项的清除,操作新的不属于文件系统空间的虚拟地址,使用该虚拟地址的TLB项替换掉TLB表缓存的文件页表对应的TLB项。在具体实现时,针对TLB表的不同结构,采用不同替换方式实现,例如上述针对TLB全相联结构采用第一种替换方式,再例如上述针对TLB组相联结构采用第二种替换方式,再例如上述针对TLB直接相联结构采用第三种替换方式。
本发明的系统实施例
下面系统实施例及其细化实施方式提供的计算机系统均是针对单个进程进行处理的,当然也同样适用于对操作系统中其他各个进程的分别处理。
第一个系统实施例,本系统实施例提供的计算机系统,包括处理器和内存,所述内存为非易失性存储器,所述处理器上运行操作系统,所述操作系统采用文件系统管理所述内存中的文件数据;其特征在于,
所述操作系统上运行的进程在初始化时被分配有用户空间和内核空间,所述进程的用户空间包括文件系统空间和页全局目录空间,所述页全局目录空间为页全局目录的虚拟地址空间,用于映射到所述页全局目录在所述内存中的物理地址空间,所述文件系统空间为所述文件数据的虚拟地址空间,用于映射到所述文件数据在所述内存中的物理空间;
下面示意性地从软件装置的实现方式提供本系统实施例的操作系统,参见图7,所述操作系统700包括访问单元701和链接单元702;
所述访问单元701,用于在获取到所述进程对第一文件数据进行访问的访问信息时,通过所述页全局目录空间访问所述页全局目录;
所述链接单元702,用于基于对所述页全局目录的访问,根据所述第一文件数据在所述文件系统空间中的第一虚拟地址确定所述页全局目录中的第一页全局目录项,并将所述进程的文件页表的基地址链接到所述第一页全局目录项,所述文件页表指向所述文件数据的物理地址,以便所述处理器根据所述第一虚拟地址并通过所述页全局目录和所述文件页表索引得到所述第一文件数据在所述内存中的第一物理地址,以及根据所述第一物理地址对所述第一文件数据进行访问。
作为系统实施例的一可选细化实施方式,在对所述第一文件数据的访问结束时,所述链接单元702用于:断开所述所述文件页表的基地址与所述页全局目录中的第一页全局目录项之间的链接。
作为系统实施例的一可选细化实施方式,所述内存中还记录有页全局目录页表,所述页全局目录页表指向所述页全局目录的基地址;
所述访问单元701,用于通过所述页全局目录空间访问所述页全局目录,具体为:
所述访问单元701,用于获取所述页全局目录空间中的预设地址,根据所 述预设地址索引到所述页全局目录中的第二页全局目录项,根据所述第二页全局目录项查询所述页全局目录页表,并根据所述页全局目录页表指示的所述页全局目录页的基地址访问所述页全局目录。
作为系统实施例的一可选细化实施方式,所述操作系统700包括还包括中断处理单元703;
在在所述进程访问所述第一文件数据的过程中发生进程中断时,所述中断处理单元703,用于获取所述第一页全局目录项在所述内核空间中的第二虚拟地址,操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接;
在所述进程中断结束时,所述中断处理单元703,用于操作所述第二虚拟地址来将所述进程的文件页表的基地址链接到所述第一页全局目录项。
作为系统实施例的一可选细化实施方式,所述操作系统700包括还包括线程调度器704;
在将所述进程中访问所述第一文件数据的线程调度至其他线程时,所述线程调度器704,用于获取所述第一页全局目录项在所述内核空间中的第二虚拟地址,操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接;
在将其他线程调度至所述进程中访问所述第一文件数据的线程时,所述线程调度器704,用于操作所述第二虚拟地址来将所述进程的文件页表的基地址链接到所述第一页全局目录项。
作为结合上述系统实施例或者上述可选细化实现方式的一可选细化实施方式,所述操作系统700包括还包括缓存清除单元705;
在所述链接单元702断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接时,所述缓存清除单元705,用于清除转译旁观缓冲器TLB表中与所述文件页表对应的TLB项。
第二个系统实施例,下面示意性地从硬件装置的实现方式提供了本系统实施例,参见图1,本系统实施例提供的计算机系统100包括处理器101和内存,所述处理器101和所述内存通过内存总线103连接,所述内存为非易 失性存储器102,所述处理器101上运行操作系统,所述操作系统采用文件系统管理所述内存中的文件数据;
所述操作系统上运行的进程在初始化时被分配有用户空间和内核空间,所述进程的用户空间包括文件系统空间和页全局目录空间,所述页全局目录空间为页全局目录的虚拟地址空间,用于映射到所述页全局目录在所述内存中的物理地址空间,所述文件系统空间为所述文件数据的虚拟地址空间,用于映射到所述文件数据在所述内存中的物理空间;
所述非易失性存储器102用于存储计算机执行指令,当所述计算机系统100运行时,所述处理器101读取所述非易失性存储器102存储的所述计算机执行指令,以使所述计算机系统100执行上述方法实施例或者上述方法实施例的各可选细化实现方式提供的文件数据访问方法。
其中,所述非易失性存储器102可能存储有完整的用于实现文件数据访问方法的计算机执行指令;或者,用于实现文件数据访问方法的计算机执行指令是存储在外部存储器中,使用非易失性存储器102缓存处理器101从外部存储器读取的计算机执行指令,即非易失性存储器102仅存储有当前执行所需的部分计算机执行指令。
在本申请所提供的几个实施例中,应该理解到,所揭露的处理器,计算机系统和方法,可以通过其它的方式实现。例如,以上所描述的计算机系统实施例仅仅是示意性的,例如,操作系统的单元划分,仅仅为一种逻辑功能划分,实现时可以有另外的划分方式,例如多个模块或单元或组件可以结合或者可以集成到另一个系统或设备,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,设备或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络模块上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。
另外,在本发明各个实施例中的各功能单元可以集成在一个处理模块中, 也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。
上述以软件功能单元的形式实现集成的单元,可以存储在一个计算机可读取存储介质中,例如存储在NVM中,或者存储在外部存储器中。上述软件功能单元存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的部分步骤。而前述的存储器包括:移动硬盘、只读存储器(英文:Read-Only Memory,简称ROM)、随机存取存储器(英文:Random Access Memory,简称RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的保护范围。

Claims (13)

  1. 一种文件数据访问方法,所述方法应用于计算机系统,所述计算机系统包括处理器和内存,所述内存为非易失性存储器,所述处理器上运行操作系统,所述操作系统采用文件系统管理所述内存中的文件数据;其特征在于,
    所述操作系统上运行的进程在初始化时被分配有用户空间和内核空间,所述进程的用户空间包括文件系统空间和页全局目录空间,所述页全局目录空间为页全局目录的虚拟地址空间,用于映射到所述页全局目录在所述内存中的物理地址空间,所述文件系统空间为所述文件数据的虚拟地址空间,用于映射到所述文件数据在所述内存中的物理空间;
    所述方法包括:
    在获取到所述进程对第一文件数据进行访问的访问信息时,通过所述页全局目录空间访问所述页全局目录;
    基于对所述页全局目录的访问,根据所述第一文件数据在所述文件系统空间中的第一虚拟地址确定所述页全局目录中的第一页全局目录项,并将所述进程的文件页表的基地址链接到所述第一页全局目录项,所述文件页表指向所述文件数据的物理地址,以便所述处理器根据所述第一虚拟地址并通过所述页全局目录和所述文件页表索引得到所述第一文件数据在所述内存中的第一物理地址,以及根据所述第一物理地址对所述第一文件数据进行访问。
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    在对所述第一文件数据的访问结束时,断开所述所述文件页表的基地址与所述页全局目录中的第一页全局目录项之间的链接。
  3. 根据权利要求1或2所述的方法,其特征在于,所述内存中还记录有页全局目录页表,所述页全局目录页表指向所述页全局目录的基地址;
    所述通过所述页全局目录空间访问所述页全局目录,包括:
    获取所述页全局目录空间中的预设地址,根据所述预设地址索引到所述页全局目录中的第二页全局目录项;
    根据所述第二页全局目录项查询所述页全局目录页表,并根据所述页全 局目录页表指示的所述页全局目录页的基地址访问所述页全局目录。
  4. 根据权利要求1至3任一项所述的方法,其特征在于,所述方法还包括:
    在所述进程访问所述第一文件数据的过程中发生进程中断时,获取所述第一页全局目录项在所述内核空间中的第二虚拟地址,操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接;
    在所述进程中断结束时,操作所述第二虚拟地址来将所述进程的文件页表的基地址链接到所述第一页全局目录项。
  5. 根据权利要求1至4任一项所述的方法,其特征在于,所述方法还包括:
    在线程调度器将所述进程中访问所述第一文件数据的线程调度至其他线程时,获取所述第一页全局目录项在所述内核空间中的第二虚拟地址,操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接;
    在所述线程调度器将其他线程调度至所述进程中访问所述第一文件数据的线程时,操作所述第二虚拟地址来将所述进程的文件页表的基地址链接到所述第一页全局目录项。
  6. 根据权利要求1至5任一项所述的方法,其特征在于,所述方法还包括:
    在断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接时,清除转译旁观缓冲器TLB表中与所述文件页表对应的TLB项。
  7. 一种计算机系统,包括处理器和内存,所述内存为非易失性存储器,所述处理器上运行操作系统,所述操作系统采用文件系统管理所述内存中的文件数据;其特征在于,
    所述操作系统上运行的进程在初始化时被分配有用户空间和内核空间,所述进程的用户空间包括文件系统空间和页全局目录空间,所述页全局目录空间为页全局目录的虚拟地址空间,用于映射到所述页全局目录在所述内存中的物理地址空间,所述文件系统空间为所述文件数据的虚拟地址空间,用于映射到所述文件数据在所述内存中的物理空间;
    所述操作系统包括访问单元和链接单元;
    所述访问单元,用于在获取到所述进程对第一文件数据进行访问的访问信息时,通过所述页全局目录空间访问所述页全局目录;
    所述链接单元,用于基于对所述页全局目录的访问,根据所述第一文件数据在所述文件系统空间中的第一虚拟地址确定所述页全局目录中的第一页全局目录项,并将所述进程的文件页表的基地址链接到所述第一页全局目录项,所述文件页表指向所述文件数据的物理地址,以便所述处理器根据所述第一虚拟地址并通过所述页全局目录和所述文件页表索引得到所述第一文件数据在所述内存中的第一物理地址,以及根据所述第一物理地址对所述第一文件数据进行访问。
  8. 根据权利要求7所述的计算机系统,其特征在于,
    在对所述第一文件数据的访问结束时,所述链接单元用于:断开所述所述文件页表的基地址与所述页全局目录中的第一页全局目录项之间的链接。
  9. 根据权利要求7或8所述的计算机系统,其特征在于,所述内存中还记录有页全局目录页表,所述页全局目录页表指向所述页全局目录的基地址;
    所述访问单元,用于通过所述页全局目录空间访问所述页全局目录,具体为:
    所述访问单元,用于获取所述页全局目录空间中的预设地址,根据所述预设地址索引到所述页全局目录中的第二页全局目录项,根据所述第二页全局目录项查询所述页全局目录页表,并根据所述页全局目录页表指示的所述页全局目录页的基地址访问所述页全局目录。
  10. 根据权利要求7至9任一项所述的计算机系统,其特征在于,所述操作系统包括还包括中断处理单元;
    在在所述进程访问所述第一文件数据的过程中发生进程中断时,所述中断处理单元,用于获取所述第一页全局目录项在所述内核空间中的第二虚拟地址,操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接;
    在所述进程中断结束时,所述中断处理单元,用于操作所述第二虚拟地址来将所述进程的文件页表的基地址链接到所述第一页全局目录项。
  11. 根据权利要求7至10任一项所述的计算机系统,其特征在于,所述操作系统包括还包括线程调度器;
    在将所述进程中访问所述第一文件数据的线程调度至其他线程时,所述线程调度器,用于获取所述第一页全局目录项在所述内核空间中的第二虚拟地址,操作所述第二虚拟地址来断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接;
    在将其他线程调度至所述进程中访问所述第一文件数据的线程时,所述线程调度器,用于操作所述第二虚拟地址来将所述进程的文件页表的基地址链接到所述第一页全局目录项。
  12. 根据权利要求7至11任一项所述的计算机系统,其特征在于,所述操作系统包括还包括缓存清除单元;
    在所述链接单元断开所述所述文件页表的基地址与所述第一页全局目录项之间的链接时,所述缓存清除单元,用于清除转译旁观缓冲器TLB表中与所述文件页表对应的TLB项。
  13. 一种计算机系统,所述计算机系统包括处理器和内存,所述处理器和所述内存通过内存总线连接,所述内存为非易失性存储器,所述处理器上运行操作系统,所述操作系统采用文件系统管理所述内存中的文件数据;其特征在于,
    所述操作系统上运行的进程在初始化时被分配有用户空间和内核空间,所述进程的用户空间包括文件系统空间和页全局目录空间,所述页全局目录空间为页全局目录的虚拟地址空间,用于映射到所述页全局目录在所述内存中的物理地址空间,所述文件系统空间为所述文件数据的虚拟地址空间,用于映射到所述文件数据在所述内存中的物理空间;
    所述非易失性存储器用于存储计算机执行指令,当所述计算机系统运行时,所述处理器读取所述非易失性存储器存储的所述计算机执行指令,以使所述计算机系统执行权利要求1至6任一项所述的文件数据访问方法。
PCT/CN2015/087667 2015-08-20 2015-08-20 文件数据访问方法和计算机系统 WO2017028309A1 (zh)

Priority Applications (4)

Application Number Priority Date Filing Date Title
CN201580001269.4A CN107209715B (zh) 2015-08-20 2015-08-20 文件数据访问方法和计算机系统
PCT/CN2015/087667 WO2017028309A1 (zh) 2015-08-20 2015-08-20 文件数据访问方法和计算机系统
EP15901513.0A EP3324296B1 (en) 2015-08-20 2015-08-20 File data access method and computer system
US15/895,615 US10606769B2 (en) 2015-08-20 2018-02-13 Time-restricted access to file data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2015/087667 WO2017028309A1 (zh) 2015-08-20 2015-08-20 文件数据访问方法和计算机系统

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US15/895,615 Continuation US10606769B2 (en) 2015-08-20 2018-02-13 Time-restricted access to file data

Publications (1)

Publication Number Publication Date
WO2017028309A1 true WO2017028309A1 (zh) 2017-02-23

Family

ID=58050973

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/087667 WO2017028309A1 (zh) 2015-08-20 2015-08-20 文件数据访问方法和计算机系统

Country Status (4)

Country Link
US (1) US10606769B2 (zh)
EP (1) EP3324296B1 (zh)
CN (1) CN107209715B (zh)
WO (1) WO2017028309A1 (zh)

Families Citing this family (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9971397B2 (en) 2014-10-08 2018-05-15 Apple Inc. Methods and apparatus for managing power with an inter-processor communication link between independently operable processors
US10146696B1 (en) * 2016-09-30 2018-12-04 EMC IP Holding Company LLC Data storage system with cluster virtual memory on non-cache-coherent cluster interconnect
CN111512290B (zh) * 2017-12-27 2023-09-22 华为技术有限公司 文件页表管理技术
US11792307B2 (en) 2018-03-28 2023-10-17 Apple Inc. Methods and apparatus for single entity buffer pool management
US10846224B2 (en) 2018-08-24 2020-11-24 Apple Inc. Methods and apparatus for control of a jointly shared memory-mapped region
CN109918355B (zh) * 2019-03-05 2020-12-15 杭州前云数据技术有限公司 实现基于对象存储服务的nas的虚拟元数据映射系统和方法
US11558348B2 (en) 2019-09-26 2023-01-17 Apple Inc. Methods and apparatus for emerging use case support in user space networking
US11829303B2 (en) 2019-09-26 2023-11-28 Apple Inc. Methods and apparatus for device driver operation in non-kernel space
US11477123B2 (en) 2019-09-26 2022-10-18 Apple Inc. Methods and apparatus for low latency operation in user space networking
CN114610232A (zh) * 2020-04-28 2022-06-10 华为技术有限公司 一种存储系统、内存管理方法和管理节点
CN111666230B (zh) * 2020-05-27 2023-08-01 江苏华创微系统有限公司 在组相联tlb中支持巨页的方法
US11606302B2 (en) 2020-06-12 2023-03-14 Apple Inc. Methods and apparatus for flow-based batching and processing
CN114090273A (zh) * 2020-07-30 2022-02-25 华为技术有限公司 一种进程间通信的方法、装置及计算机存储介质
US11775359B2 (en) 2020-09-11 2023-10-03 Apple Inc. Methods and apparatuses for cross-layer processing
US11954540B2 (en) 2020-09-14 2024-04-09 Apple Inc. Methods and apparatus for thread-level execution in non-kernel space
US11799986B2 (en) 2020-09-22 2023-10-24 Apple Inc. Methods and apparatus for thread level execution in non-kernel space
US11876719B2 (en) 2021-07-26 2024-01-16 Apple Inc. Systems and methods for managing transmission control protocol (TCP) acknowledgements
US11882051B2 (en) 2021-07-26 2024-01-23 Apple Inc. Systems and methods for managing transmission control protocol (TCP) acknowledgements
CN116662224A (zh) * 2022-02-17 2023-08-29 华为技术有限公司 内存访问的方法、装置、存储介质及计算机程序产品

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014138005A1 (en) * 2013-03-05 2014-09-12 Qualcomm Incorporated Method and apparatus for preventing unauthorized access to contents of a register under certain conditions when performing a hardware table walk (hwtw)
CN104123229A (zh) * 2014-07-21 2014-10-29 上海斐讯数据通信技术有限公司 能使报文高效地从内核态提交到用户态的方法及系统
CN104732164A (zh) * 2013-12-18 2015-06-24 国家计算机网络与信息安全管理中心 一种提高ssl数据处理速度的装置及其方法

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6804766B1 (en) * 1997-11-12 2004-10-12 Hewlett-Packard Development Company, L.P. Method for managing pages of a designated memory object according to selected memory management policies
US7383584B2 (en) 2002-03-27 2008-06-03 Advanced Micro Devices, Inc. System and method for controlling device-to-device accesses within a computer system
US9218135B2 (en) 2010-06-16 2015-12-22 Microsoft Technology Licensing, Llc Hierarchical allocation for file system storage device
CN102541984B (zh) * 2011-10-25 2013-08-28 曙光信息产业(北京)有限公司 一种分布式文件系统客户端的文件系统的实现方法
CN103095758B (zh) * 2011-11-01 2016-09-21 北大方正集团有限公司 一种分布式文件系统及该系统中处理文件数据的方法
US9575690B2 (en) * 2011-12-23 2017-02-21 Oracle International Corporation Sub-lun auto-tiering
US9135183B2 (en) * 2013-03-13 2015-09-15 Samsung Electronics Co., Ltd. Multi-threaded memory management
KR20150082010A (ko) * 2014-01-07 2015-07-15 삼성전자주식회사 불휘발성 메모리 파일 시스템에서의 마이크로 저널링 방법
CN104077084B (zh) * 2014-07-22 2017-07-21 中国科学院上海微系统与信息技术研究所 分布式随机访问文件系统及其访问控制方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014138005A1 (en) * 2013-03-05 2014-09-12 Qualcomm Incorporated Method and apparatus for preventing unauthorized access to contents of a register under certain conditions when performing a hardware table walk (hwtw)
CN104732164A (zh) * 2013-12-18 2015-06-24 国家计算机网络与信息安全管理中心 一种提高ssl数据处理速度的装置及其方法
CN104123229A (zh) * 2014-07-21 2014-10-29 上海斐讯数据通信技术有限公司 能使报文高效地从内核态提交到用户态的方法及系统

Also Published As

Publication number Publication date
US20180173643A1 (en) 2018-06-21
EP3324296A4 (en) 2018-08-08
US10606769B2 (en) 2020-03-31
EP3324296B1 (en) 2019-12-04
CN107209715A (zh) 2017-09-26
CN107209715B (zh) 2019-09-27
EP3324296A1 (en) 2018-05-23

Similar Documents

Publication Publication Date Title
WO2017028309A1 (zh) 文件数据访问方法和计算机系统
US10552337B2 (en) Memory management and device
US10061711B2 (en) File access method and apparatus, and storage system
WO2016082196A1 (zh) 文件访问方法、装置及存储设备
JP2018125025A (ja) 適応持続性システム、方法、インタフェース
US9535628B2 (en) Memory system with shared file system
US20120159103A1 (en) System and method for providing stealth memory
KR20160022248A (ko) 데이터 액세스 장치 및 그것의 동작 방법
US20180349409A1 (en) Intelligent file system with transparent storage tiering
CN101645045A (zh) 使用透明页变换的存储器管理
US8892810B2 (en) Semiconductor device and memory protection method
WO2020057394A1 (zh) 监控样本进程的内存访问行为的方法和装置
US9304946B2 (en) Hardware-base accelerator for managing copy-on-write of multi-level caches utilizing block copy-on-write differential update table
CN110659248B (zh) 基于非易失性内存的用户态文件系统设计方法及系统
US9772776B2 (en) Per-memory group swap device
JP2006294028A (ja) 直接実行機能を提供するためのシステム、コンピュータシステム、方法およびプログラム
Chen et al. A unified framework for designing high performance in-memory and hybrid memory file systems
Venkatesan et al. Ex-tmem: Extending transcendent memory with non-volatile memory for virtual machines
US20150356108A1 (en) Storage system and storage system control method
US20160170659A1 (en) Method and apparatus for adaptively managing data in a memory based file system
JP4792065B2 (ja) データ記憶方法
WO2024099448A1 (zh) 内存释放、内存恢复方法、装置、计算机设备及存储介质
Zhao et al. Efficient inline deduplication on VM images in desktop virtualization environment
TW201342061A (zh) 用於增加虛擬記憶體效能之電腦可讀儲存媒體、設備及電腦實施方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15901513

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 2015901513

Country of ref document: EP