[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240529104257.GIZlcGsTkJHVBblkrY@fat_crate.local>
Date: Wed, 29 May 2024 12:42:57 +0200
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,
"Rafael J. Wysocki" <rafael@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@...ux.intel.com>,
Elena Reshetova <elena.reshetova@...el.com>,
Jun Nakajima <jun.nakajima@...el.com>,
Rick Edgecombe <rick.p.edgecombe@...el.com>,
Tom Lendacky <thomas.lendacky@....com>,
"Kalra, Ashish" <ashish.kalra@....com>,
Sean Christopherson <seanjc@...gle.com>,
"Huang, Kai" <kai.huang@...el.com>,
Ard Biesheuvel <ardb@...nel.org>, Baoquan He <bhe@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>,
"K. Y. Srinivasan" <kys@...rosoft.com>,
Haiyang Zhang <haiyangz@...rosoft.com>, kexec@...ts.infradead.org,
linux-hyperv@...r.kernel.org, linux-acpi@...r.kernel.org,
linux-coco@...ts.linux.dev, linux-kernel@...r.kernel.org,
Nikolay Borisov <nik.borisov@...e.com>, Tao Liu <ltao@...hat.com>
Subject: Re: [PATCHv11 10/19] x86/mm: Add callbacks to prepare encrypted
memory for kexec
On Tue, May 28, 2024 at 12:55:13PM +0300, Kirill A. Shutemov wrote:
> diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
> index 28ac3cb9b987..6cade48811cc 100644
> --- a/arch/x86/include/asm/x86_init.h
> +++ b/arch/x86/include/asm/x86_init.h
> @@ -149,12 +149,21 @@ struct x86_init_acpi {
> * @enc_status_change_finish Notify HV after the encryption status of a range is changed
> * @enc_tlb_flush_required Returns true if a TLB flush is needed before changing page encryption status
> * @enc_cache_flush_required Returns true if a cache flush is needed before changing page encryption status
> + * @enc_kexec_begin Begin the two-step process of conversion shared memory back
s/conversion/converting/
> + * to private. It stops the new conversions from being started
> + * and waits in-flight conversions to finish, if possible.
Good.
Now add "The @crash parameter denotes whether the function is being
called in the crash shutdown path."
> + * @enc_kexec_finish Finish the two-step process of conversion shared memory to
s/conversion/converting/
> + * private. All memory is private after the call.
"... when the function returns."
> + * It called with all CPUs but one shutdown and interrupts
> + * disabled.
"It is called on only one CPU while the others are shut down and with
interrupts disabled."
> */
> struct x86_guest {
> int (*enc_status_change_prepare)(unsigned long vaddr, int npages, bool enc);
> int (*enc_status_change_finish)(unsigned long vaddr, int npages, bool enc);
> bool (*enc_tlb_flush_required)(bool enc);
> bool (*enc_cache_flush_required)(void);
> + void (*enc_kexec_begin)(bool crash);
> + void (*enc_kexec_finish)(void);
> };
>
> /**
> diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
> index f06501445cd9..74f6305eb9ec 100644
> --- a/arch/x86/kernel/crash.c
> +++ b/arch/x86/kernel/crash.c
> @@ -128,6 +128,18 @@ void native_machine_crash_shutdown(struct pt_regs *regs)
> #ifdef CONFIG_HPET_TIMER
> hpet_disable();
> #endif
> +
> + /*
> + * Non-crash kexec calls enc_kexec_begin() while scheduling is still
> + * active. This allows the callback to wait until all in-flight
> + * shared<->private conversions are complete. In a crash scenario,
> + * enc_kexec_begin() get call after all but one CPU has been shut down
"gets called" ... "have been shut down"
> + * and interrupts have been disabled. This only allows the callback to
only?
> + * detect a race with the conversion and report it.
> + */
> + x86_platform.guest.enc_kexec_begin(true);
> + x86_platform.guest.enc_kexec_finish();
> +
..
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists