restore the fake x2apic value for cpuid
Subsystems (2)
PATCH 1/1 restore the fake x2apic value for cpuid
From: Talons Lee <[email protected]>
Commit e657fcc clears cpu x2apic capability bit instead of using fake cpuid value. However, with cpuid x2apic bit on, xen_read_msr_safe() will not clear the EXTD bit, which leads to uncessary msr write trying to disable x2apic in __x2apic_disable(). So restore the fake x2apic value.
---
CC: Igor Druzhinin <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Juergen Gross <[email protected]>
--- arch/x86/xen/enlighten_pv.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/x86/xen/enlighten_pv.c +6 -0
@@ -165,12 +165,17 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx, unsigned int *cx, unsigned int *dx) { unsigned maskebx = ~0; +unsigned maskecx = ~0 ;/* * Mask out inconvenient features, to try and disable as many * unsupported kernel subsystems as possible. */ switch (*ax) { +case 1 : + maskecx &= ~(1 << (X86_FEATURE_X2APIC %32 )); +break ; +case CPUID_MWAIT_LEAF :/* Synthesize the values.. */ *ax =0 ;
@@ -193,6 +198,7 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx, : "0" (*ax), "2" (*cx)); *bx &= maskebx; + *cx &= maskecx; }STACK_FRAME_NON_STANDARD (xen_cpuid);/* XEN_EMULATE_PREFIX */
Signature · 7 lines
1.8.3.1 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Juergen Gross
maintainerQuoted 8 lines · Xin Li
From: Talons Lee <[email protected]>
Commit e657fcc clears cpu x2apic capability bit instead of using fake cpuid value. However, with cpuid x2apic bit on,
xen_read_msr_safe()will not clear the EXTD bit, which leads to uncessary msr write trying to disable x2apic in__x2apic_disable(). So restore the fake x2apic value.Signed-off-by Talons Lee <[email protected]>
Wouldn't it be easier to use just rdmsr_safe() in __x2apic_disable() instead?
Juergen
Quoted 35 lines
---
CC: Igor Druzhinin <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Juergen Gross <[email protected]>--- arch/x86/xen/enlighten_pv.c | 6 ++++++ 1 file changed, 6 insertions(+)arch/x86/xen/enlighten_pv.c +5
-0@@ -165,12 +165,17 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx, unsigned int *cx, unsigned int *dx) { unsigned maskebx = ~0; +unsigned maskecx = ~0 ;/* * Mask out inconvenient features, to try and disable as many * unsupported kernel subsystems as possible. */ switch (*ax) { +case 1 : + maskecx &= ~(1 << (X86_FEATURE_X2APIC %32 )); +break ; +case CPUID_MWAIT_LEAF :/* Synthesize the values.. */ *ax =0 ;
arch/x86/xen/enlighten_pv.c static void xen_cpuid(unsigned int *ax, unsigned int *bx, · line 204
Quoted 7 lines
arch/x86/xen/enlighten_pv.c +1
-0@@ -193,6 +198,7 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx, : "0" (*ax), "2" (*cx)); *bx &= maskebx; + *cx &= maskecx; }STACK_FRAME_NON_STANDARD (xen_cpuid);/* XEN_EMULATE_PREFIX */
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Juergen Gross
maintainerQuoted 8 lines · Juergen Gross
Quoted 7 lines · Xin Li
From: Talons Lee <[email protected]>
Commit e657fcc clears cpu x2apic capability bit instead of using fake cpuid value. However, with cpuid x2apic bit on,
xen_read_msr_safe()will not clear the EXTD bit, which leads to uncessary msr write trying to disable x2apic in__x2apic_disable(). So restore the fake x2apic value.
Quoted 4 lines
Quoted 1 line
Signed-off-by Talons Lee <[email protected]>Wouldn't it be easier to use just
rdmsr_safe()in__x2apic_disable()instead?
Sorry, just seeing it now: using apic_is_x2apic_enabled() might be even better. Same in __x2apic_enable().
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Hi Juergen,
thanks for your comments.
Are you suggesting to call apic_is_x2apic_enabled() in __x2apic_disable()? but I think that's exact what changed due to the fake xen_cpuid value. Doing so will probably still see the EXTD bit on, and call wrmsrl to disable x2apic.
log for linux4.4:check_x2apic()
[ 0.000000] xen_read_msr_safe native read: fee00d00 [ 0.000000] clear X2APIC_ENABLE [ 0.000000] xen_read_msr_safe cpuid: fee00900 [ 0.000000] x2apic_enabled cpu_has_x2apic: 0 apic_is_x2apic_enabled: 0
log for linux4.19:
[ 0.000817] xen_read_msr_safe native read: fee00d00 [ 0.000819] xen_read_msr_safe cpuid: *fee00d00 * //X2APIC_ENABLE not cleared [ 0.000820] x2apic_enabled X86_FEATURE_X2APIC: 0 apic_is_x2apic_enabled: 1
________________________________________
From: Juergen Gross <[email protected]>
Sent: Monday, December 3, 2018 3:03 PM
To: Xin Li; [email protected]
Cc: Xin Li (Talons); Sergey Dyasli; Andrew Cooper; Igor Druzhinin
Subject: Re: [Xen-devel] [PATCH v1] restore the fake x2apic value for cpuid
Quoted 8 lines · Juergen Gross
Quoted 7 lines · Xin Li
From: Talons Lee <[email protected]>
Commit e657fcc clears cpu x2apic capability bit instead of using fake cpuid value. However, with cpuid x2apic bit on,
xen_read_msr_safe()will not clear the EXTD bit, which leads to uncessary msr write trying to disable x2apic in__x2apic_disable(). So restore the fake x2apic value.
Quoted 4 lines
Quoted 1 line
Signed-off-by Talons Lee <[email protected]>Wouldn't it be easier to use just
rdmsr_safe()in__x2apic_disable()instead?
Sorry, just seeing it now: using apic_is_x2apic_enabled() might be even better. Same in __x2apic_enable().
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Juergen Gross
maintainerQuoted 14 lines · Xin Li (Talons)
Hi Juergen,
thanks for your comments.Are you suggesting to call
apic_is_x2apic_enabled()in__x2apic_disable()? but I think that's exact what changed due to the fakexen_cpuidvalue. Doing so will probably still see the EXTD bit on, and call wrmsrl to disable x2apic.log for linux4.4:
check_x2apic()[ 0.000000] xen_read_msr_safe native read: fee00d00 [ 0.000000] clear X2APIC_ENABLE [ 0.000000] xen_read_msr_safe cpuid: fee00900 [ 0.000000] x2apic_enabled cpu_has_x2apic: 0 apic_is_x2apic_enabled: 0
Quoted 4 lines
log for linux4.19:
[ 0.000817] xen_read_msr_safe native read: fee00d00 [ 0.000819] xen_read_msr_safe cpuid: *fee00d00 * //X2APIC_ENABLE not cleared [ 0.000820] x2apic_enabled X86_FEATURE_X2APIC: 0 apic_is_x2apic_enabled: 1
Oh, you are right, sorry.
I overlooked rdmsr() is already using xen_read_msr_safe().
OTOH looking into xen_read_msr_safe() I can't see why the X2APIC_ENABLE bit should be cleared depending on the cpuid value returned. We always do setup_clear_cpu_cap(X86_FEATURE_X2APIC) for PV domains, so there is no reason to check the cpuid return data for deciding whether to clear X2APIC_ENABLE or not. I think we can do that always.
So why don't we remove the #ifdef CONFIG_X86_X2APIC block from xen_read_msr_safe() ?
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel