"Answer" about the virtual address translation problem before the MMU in the kernel is not opened

Source: Internet
Author: User

1. Does the kernel have a virtual address before opening the MMU? Where's the virtual address without the MMU?

A: Yes, due to the loading of the address and the execution of the different address caused by not opening the MMU before there will be a virtual address problem.

2. What is the difference between the on-load address and the execution address. Why is there such a difference?

Answer: Load-on address: Put the executable file into the memory address of physical memory, such as put the image to the 0x80000000 address, then load the address =0x80000000

Execution-time Address: The virtual address after the image is generated, as determined by the compiler and connection scripts.

When the kernel image is put into memory, the address placed is arbitrary, so consider the fact that the offset is calculated using the in-memory data before the MMU is opened.


The following code is an excerpt from the Armv8linux kernel Head.s. Can be very good to explain the actual address conversion problem before opening the MMU:

ENTRY (Lookup_processor_type)
ADR x1, __lookup_processor_type_data //x1= The offset between the current PC's Value + and the label __lookup_processor_type_data. That is, X1 stores the __lookup_processor_type_data address value relative to the current PC, where the PC is the physical address. After the MMU was opened, all the PCs were virtual addresses.



LDP x2, X3, [X1] Put the following __lookup_processor_type_data in the label "." Save to X2. Cpu_table stored in X3,X2,X3 is a virtual address.

Sub x1, x1, x2//Get offset between VA and PA. There is ambiguity here, X1 is the physical address, X2 is the virtual address. So this is Pa-va, not va-pa.
Add x3, x3, x1//Convert VA to PA. Here x3 is VA, plus pa-va to draw x3 pa
1:

LDP W5, W6, [x3]//load Cpu_id_val and Cpu_id_mask

CBZ W5, 2f//end of list?
And W6, W6, W0
CMP W5, W6
B.eq 3f
Add x3, x3, #CPU_INFO_SZ
B 1b
2:
MOV x3, #0//Unknown processor
3:
mov x0, x3
Ret
Endproc (Lookup_processor_type)


. Align 4
. Type __lookup_processor_type_data,%object
__lookup_processor_type_data:
. Quad. //"." Represents the current virtual address, the above ADR that command calculates the X1 is the physical address of the current instruction, the LDP that directive X2 is a virtual address, so the sub is calculated Pa-va

. Quad Cpu_table

"Answer" about the virtual address translation problem before the MMU in the kernel is not opened

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.