From what I found, there are basically two modes of kernel and users If the memory segment is a kernel or user space segment, there should be some bits in the memory segment. But where do those bits originate? Are there some “switches” in the compiler that mark the program as a kernel program? For example, if the driver is in kernel mode, how does the operating system manage its integration with the system so that no malware is added as a driver?
If anyone can enlighten me on this issue, I would be very grateful, thank you
The way this piece of hardware works is that it saves a list of memory fragments in the cache. And their corresponding address list. When the program tries to read some memory that does not exist in the cache, the MMU does not just get the memory from the main ram, because the address in the cacher is just a “logical” address. Instead, it calls another The program interprets the address and obtains the memory from anywhere.
The program is called a pager, provided by the kernel, and a special flag in the MMU prevents the program from being overwritten.
If the program is Determine that the address corresponds to the memory that the process should use, then it provides the physical address in the main memory to the MMU, which corresponds to the logical address required by the user program, the MMU extracts it into its cache, and resumes running the user program .
If the address is a “special” address, just like a memory-mapped file, the kernel will extract the corresponding part of the file into the cache and let the program run with it.
< p>If the address is in the range belonging to the kernel, or the program has not assigned the address to itself, the pager will trigger SEGFAULT, thereby terminating the program.
Because the address is a logical address and not a physical address, so Different user programs can use the same logical address to represent different physical addresses. The kernel pager program and MMU make this all transparent and automatic.
Old CPU (such as 80286 cpu) and some ultra-low Power-consuming devices (such as ARM CortexM3 or Attiny CPU) do not provide this level of protection, because there is no MMU, all addresses on these systems are physical addresses, and there is a 1-to-1 correspondence between ram and address space
My question is how does the operating system protect its kernel part.
From what I found, there are basically two modes of kernel and users If the memory segment is a kernel or user space segment, there should be some bits in the memory segment. But where do those bits originate? Are there some “switches” in the compiler that mark the program as a kernel program? For example, if the driver is in kernel mode, how does the operating system manage its integration with the system so that no malware is added as a driver?
If anyone can enlighten me on this issue, I would be very grateful, thank you
The usual technique is to use most modern The function of the virtual memory manager that exists in the cpu.
The way this piece of hardware works is that it saves a list of memory fragments in the cache and a list of their corresponding addresses. When the program tries to read When some memory does not exist in the cache, the MMU does not just get the memory from the main ram, because the address in the cacher is just a “logical” address. Instead, it calls another program to interpret the address and get the memory from anywhere.
This program is called a pager and is provided by the kernel. A special flag in the MMU prevents the program from being overwritten.
If the program determines that the address corresponds to the memory that the process should use, Then it provides the physical address in the main memory to the MMU. The physical address corresponds to the logical address required by the user program. The MMU extracts it into its cache and resumes running the user program.
If the address is A “special” address, just like a memory-mapped file, the kernel will extract the corresponding part of the file into the cache and let the program run with it.
If the address is within the scope of the kernel, or The program has not assigned the address to itself, the pager will trigger SEGFAULT, thereby terminating the program.
Because the address is a logical address instead of a physical address, different user programs can use the same logical address to represent Different physical addresses, kernel pager programs and MMU make this all transparent and automatic.
Old CPUs (such as 80286 cpu) and some ultra-low power devices (such as ARM CortexM3 or Attiny CPU) do not This level of protection is provided, because there is no MMU, all addresses on these systems are physical addresses, with a one-to-one correspondence between ram and address space