[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241031142324.GJZyOS3G62E3pn9ZJ-@fat_crate.local>
Date: Thu, 31 Oct 2024 15:23:24 +0100
From: Borislav Petkov <bp@...en8.de>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H. Peter Anvin" <hpa@...or.com>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>, Baoquan He <bhe@...hat.com>,
Ard Biesheuvel <ardb@...nel.org>,
Tom Lendacky <thomas.lendacky@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
Sean Christopherson <seanjc@...gle.com>,
linux-kernel@...r.kernel.org, linux-acpi@...r.kernel.org,
Kai Huang <kai.huang@...el.com>
Subject: Re: [PATCHv4, REBASED 3/4] x86/64/kexec: Map original
relocate_kernel() in init_transition_pgtable()
On Wed, Oct 16, 2024 at 02:14:57PM +0300, Kirill A. Shutemov wrote:
> The init_transition_pgtable() function sets up transitional page tables.
> It ensures that the relocate_kernel() function is present in the
> identity mapping at the same location as in the kernel page tables.
> relocate_kernel() switches to the identity mapping, and the function
> must be present at the same location in the virtual address space before
> and after switching page tables.
>
> init_transition_pgtable() maps a copy of relocate_kernel() in
> image->control_code_page at the relocate_kernel() virtual address, but
> the original physical address of relocate_kernel() would also work.
>
> It is safe to use original relocate_kernel() physical address cannot be
^^^^^^^^^^^^^^^
something went missing here in that sentence. Reads weird.
> overwritten until swap_pages() is called, and the relocate_kernel()
> virtual address will not be used by then.
...
> diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
> index 9c9ac606893e..645690e81c2d 100644
> --- a/arch/x86/kernel/machine_kexec_64.c
> +++ b/arch/x86/kernel/machine_kexec_64.c
> @@ -157,7 +157,7 @@ static int init_transition_pgtable(struct kimage *image, pgd_t *pgd)
> pte_t *pte;
>
> vaddr = (unsigned long)relocate_kernel;
> - paddr = __pa(page_address(image->control_code_page)+PAGE_SIZE);
> + paddr = __pa(relocate_kernel);
> pgd += pgd_index(vaddr);
> if (!pgd_present(*pgd)) {
> p4d = (p4d_t *)get_zeroed_page(GFP_KERNEL);
Such changes always make me nervous so I'd queue them only after this merge
window is over so that they can get maximal testing in next. Unless someone
objects...
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists