[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <521b5214803d404766cb576af2b90fe3ec8326f2.camel@gmail.com>
Date: Fri, 11 Apr 2025 19:01:44 +0200
From: Francesco Lavra <francescolavra.fl@...il.com>
To: Neeraj Upadhyay <Neeraj.Upadhyay@....com>, linux-kernel@...r.kernel.org
Cc: bp@...en8.de, tglx@...utronix.de, mingo@...hat.com,
dave.hansen@...ux.intel.com, Thomas.Lendacky@....com, nikunj@....com,
Santosh.Shukla@....com, Vasant.Hegde@....com,
Suravee.Suthikulpanit@....com, David.Kaplan@....com, x86@...nel.org,
hpa@...or.com, peterz@...radead.org, seanjc@...gle.com,
pbonzini@...hat.com, kvm@...r.kernel.org, kirill.shutemov@...ux.intel.com,
huibo.wang@....com, naveen.rao@....com
Subject: Re: [PATCH v3 14/17] x86/apic: Add kexec support for Secure AVIC
On Tue, 2025-04-01 at 17:06 +0530, Neeraj Upadhyay wrote:
> Add a apic->teardown() callback to disable Secure AVIC before
> rebooting into the new kernel. This ensures that the new
> kernel does not access the old APIC backing page which was
> allocated by the previous kernel. Such accesses can happen
> if there are any APIC accesses done during guest boot before
> Secure AVIC driver probe is done by the new kernel (as Secure
> AVIC would have remained enabled in the Secure AVIC control
> msr).
>
> Signed-off-by: Neeraj Upadhyay <Neeraj.Upadhyay@....com>
> ---
> Changes since v2:
> - Change savic_unregister_gpa() interface to allow GPA
> unregistration
> only for local CPU.
>
> arch/x86/coco/sev/core.c | 25 +++++++++++++++++++++++++
> arch/x86/include/asm/apic.h | 1 +
> arch/x86/include/asm/sev.h | 2 ++
> arch/x86/kernel/apic/apic.c | 3 +++
> arch/x86/kernel/apic/x2apic_savic.c | 8 ++++++++
> 5 files changed, 39 insertions(+)
>
> diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
> index 9ade2b1993ad..2381859491db 100644
> --- a/arch/x86/coco/sev/core.c
> +++ b/arch/x86/coco/sev/core.c
> @@ -1588,6 +1588,31 @@ enum es_result savic_register_gpa(u64 gpa)
> return res;
> }
>
> +enum es_result savic_unregister_gpa(u64 *gpa)
> +{
> + struct ghcb_state state;
> + struct es_em_ctxt ctxt;
> + unsigned long flags;
> + struct ghcb *ghcb;
> + int ret = 0;
This should be an enum es_result, and there is no need to zero-
initialize it.
> +
> + local_irq_save(flags);
guard(irqsave)();
> +
> + ghcb = __sev_get_ghcb(&state);
> +
> + vc_ghcb_invalidate(ghcb);
> +
> + ghcb_set_rax(ghcb, -1ULL);
> + ret = sev_es_ghcb_hv_call(ghcb, &ctxt,
> SVM_VMGEXIT_SECURE_AVIC,
> + SVM_VMGEXIT_SECURE_AVIC_UNREGISTER_GPA, 0);
> + if (gpa && ret == ES_OK)
> + *gpa = ghcb->save.rbx;
> + __sev_put_ghcb(&state);
> +
> + local_irq_restore(flags);
> + return ret;
> +}
Powered by blists - more mailing lists