On 5/13/19 6:47 PM, Alexandre Chartre wrote:
On 5/13/19 5:50 PM, Dave Hansen wrote:
+ /*
+ * Copy the mapping for all the kernel text. We copy at the PMD
+ * level since the PUD is shared with the module mapping space.
+ */
+ rv = kvm_copy_mapping((void *)__START_KERNEL_map, KERNEL_IMAGE_SIZE,
+ PGT_LEVEL_PMD);
+ if (rv)
+ goto out_uninit_page_table;
Could you double-check this? We (I) have had some repeated confusion
with the PTI code and kernel text vs. kernel data vs. __init.
KERNEL_IMAGE_SIZE looks to be 512MB which is quite a bit bigger than
kernel text.
I probably have the same confusion :-) but I will try to check again.
mm.txt says that kernel text is 512MB, and that's probably why I used
KERNEL_IMAGE_SIZE.
https://www.kernel.org/doc/Documentation/x86/x86_64/mm.txt
========================================================================================================================
Start addr | Offset | End addr | Size | VM area description
========================================================================================================================
[...]
ffffffff80000000 | -2 GB | ffffffff9fffffff | 512 MB | kernel text mapping, mapped to physical address 0
[...]
However, vmlinux.lds.S does:
. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
"kernel image bigger than KERNEL_IMAGE_SIZE");
So this covers everything between _text and _end, which includes text, data,
init and other stuff
The end of the text section is tagged with _etext. So the text section is
effectively (_etext - _text). This matches with what efi_setup_page_tables()
used to copy kernel text:
int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)
{
[...]
npages = (_etext - _text) >> PAGE_SHIFT;
text = __pa(_text);
pfn = text >> PAGE_SHIFT;
pf = _PAGE_RW | _PAGE_ENC;
if (kernel_map_pages_in_pgd(pgd, pfn, text, npages, pf)) {
pr_err("Failed to map kernel text 1:1\n");
return 1;
}
[...]
}
alex.