Why does the kernel still boot normally even though the identity mapping is not set up?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm currently reading the code of identity mapping and have found a
strange problem.

In head64.c, kernel sets up identity mapping[1] for the switchover, or
more precisely, this temporary mapping is used by the following two
instructions in head_64.S[2]:

    /* Ensure I am executing from virtual addresses */
    movq $1f, %rax
    jmp *%rax

I delete all the code of identity mapping[1] and recompile my kernel
and then test it in Bochs. To my surprise, this kernel can still boot
normally. I also test it in VMware(with Fedora 25) and QEMU. Vmware
can boot without any problem but QEMU can't. However, others have
reported[3] that QEMU can boot normally too if kvm is enabled with
--enable-kvm. Then I want to find out what happened, so I debug these
code in Bochs line by line. When the above two instructions are being
executed, Bochs prints warnings:

??? (physical address not available)
??? (physical address not available)

I ignore these warnings and make the kernel continue running. I find
the kernel can reach the next instruction (movl $0x80000001, %eax)
successfully and the RIP register is set to the correct virtual
address as if the identity mapping code was not deleted.

My question is why the kernel can still boot normally even though the
identity mapping is not set up. This question is first raised in a
GitHub issue: https://github.com/0xAX/linux-insides/issues/544

Could someone give us some hints? Many Thanks!

[1] https://github.com/torvalds/linux/blob/0c86a6bd85ff0629cd2c5141027fc1c8bb6cde9c/arch/x86/kernel/head64.c#L98-L138
[2] https://github.com/torvalds/linux/blob/0c86a6bd85ff0629cd2c5141027fc1c8bb6cde9c/arch/x86/kernel/head_64.S#L135-L137
[3] https://www.spinics.net/lists/kvm/msg159168.html

Regards,
Hao Lee

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]
  Powered by Linux