[RFC PATCH 6/6] x86/x2apic-savic: Not set APIC backing page if Secure AVIC is not enabled.

Tianyu Lan posted 6 patches 7 months, 2 weeks ago
There is a newer version of this series
[RFC PATCH 6/6] x86/x2apic-savic: Not set APIC backing page if Secure AVIC is not enabled.
Posted by Tianyu Lan 7 months, 2 weeks ago
From: Tianyu Lan <tiala@microsoft.com>

When Secure AVIC is not enabled, init_apic_page()
should return directly.

Signed-off-by: Tianyu Lan <tiala@microsoft.com>
---
 arch/x86/kernel/apic/x2apic_savic.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/apic/x2apic_savic.c b/arch/x86/kernel/apic/x2apic_savic.c
index 0dd7e39931b0..fb09c0f9e276 100644
--- a/arch/x86/kernel/apic/x2apic_savic.c
+++ b/arch/x86/kernel/apic/x2apic_savic.c
@@ -333,6 +333,9 @@ static void init_apic_page(void)
 {
 	u32 apic_id;
 
+	if (!cc_platform_has(CC_ATTR_SNP_SECURE_AVIC))
+		return;
+
 	/*
 	 * Before Secure AVIC is enabled, APIC msr reads are intercepted.
 	 * APIC_ID msr read returns the value from the Hypervisor.
-- 
2.25.1
Re: [RFC PATCH 6/6] x86/x2apic-savic: Not set APIC backing page if Secure AVIC is not enabled.
Posted by Neeraj Upadhyay 7 months, 1 week ago

On 5/6/2025 6:37 PM, Tianyu Lan wrote:
> From: Tianyu Lan <tiala@microsoft.com>
> 
> When Secure AVIC is not enabled, init_apic_page()
> should return directly.
> 
> Signed-off-by: Tianyu Lan <tiala@microsoft.com>
> ---
>  arch/x86/kernel/apic/x2apic_savic.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/x86/kernel/apic/x2apic_savic.c b/arch/x86/kernel/apic/x2apic_savic.c
> index 0dd7e39931b0..fb09c0f9e276 100644
> --- a/arch/x86/kernel/apic/x2apic_savic.c
> +++ b/arch/x86/kernel/apic/x2apic_savic.c
> @@ -333,6 +333,9 @@ static void init_apic_page(void)
>  {
>  	u32 apic_id;
>  
> +	if (!cc_platform_has(CC_ATTR_SNP_SECURE_AVIC))
> +		return;
> +
>  	/*

Why is this change needed? init_apic_page() is only called from Secure AVIC driver's
setup() callback. savic_probe() already does this check. So, if this check fails during
savic_probe(), Secure AVIC apic driver won't be selected as apic driver and it's setup
callback will never get invoked.


- Neeraj



>  	 * Before Secure AVIC is enabled, APIC msr reads are intercepted.
>  	 * APIC_ID msr read returns the value from the Hypervisor.
Re: [RFC PATCH 6/6] x86/x2apic-savic: Not set APIC backing page if Secure AVIC is not enabled.
Posted by Tianyu Lan 7 months ago
On Wed, May 7, 2025 at 12:03 PM Neeraj Upadhyay <Neeraj.Upadhyay@amd.com> wrote:
>
>
>
> On 5/6/2025 6:37 PM, Tianyu Lan wrote:
> > From: Tianyu Lan <tiala@microsoft.com>
> >
> > When Secure AVIC is not enabled, init_apic_page()
> > should return directly.
> >
> > Signed-off-by: Tianyu Lan <tiala@microsoft.com>
> > ---
> >  arch/x86/kernel/apic/x2apic_savic.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/arch/x86/kernel/apic/x2apic_savic.c b/arch/x86/kernel/apic/x2apic_savic.c
> > index 0dd7e39931b0..fb09c0f9e276 100644
> > --- a/arch/x86/kernel/apic/x2apic_savic.c
> > +++ b/arch/x86/kernel/apic/x2apic_savic.c
> > @@ -333,6 +333,9 @@ static void init_apic_page(void)
> >  {
> >       u32 apic_id;
> >
> > +     if (!cc_platform_has(CC_ATTR_SNP_SECURE_AVIC))
> > +             return;
> > +
> >       /*
>
> Why is this change needed? init_apic_page() is only called from Secure AVIC driver's
> setup() callback. savic_probe() already does this check. So, if this check fails during
> savic_probe(), Secure AVIC apic driver won't be selected as apic driver and it's setup
> callback will never get invoked.
>
>
Hi Neeraj:
       Thanks for your review. Agree. Will remove it.


--
Thanks
Tianyu Lan