Skip to contentSkip to conversation

always clear the X2APIC_ENABLE bit for PV guest

PATCH Superseded Xin Li 3 participants 3 messages Dec 4, 2018

Subsystems (2)
lore
Share & tools
lore

Xin Li

author
#0 lore raw

PATCH v2 1/1 always clear the X2APIC_ENABLE bit for PV guest

From: Talons Lee <[email protected]>

Commit e657fcc clears cpu capability bit instead of using fake cpuid value, the EXID should always be off for PV guest without depending on cpuid value. So remove the cpuid check in xen_read_msr_safe() to always clear the X2APIC_ENABLE bit.

---
CC: Igor Druzhinin <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Juergen Gross <[email protected]>

v2:
don't use fake cpuid to cheat xen_read_msr_safe(), just always clear the EXIT bit.

---
 arch/x86/xen/enlighten_pv.c | 3 ---
 1 file changed, 3 deletions(-)
arch/x86/xen/enlighten_pv.c +0 -3
index 4b20082..6ad312d 100644
@@ -900,9 +900,6 @@ static u64 xen_read_msr_safe(unsigned int msr, int *err)
 	val = native_read_msr_safe(msr, err);
 	switch (msr) {
 	case MSR_IA32_APICBASE:
-#ifdef CONFIG_X86_X2APIC
-		if (!(cpuid_ecx(1) & (1 << (X86_FEATURE_X2APIC & 31))))
-#endif
 			val &= ~X2APIC_ENABLE;
 		break;
 	}
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 27 lines · Xin Li

From: Talons Lee <[email protected]>

Commit e657fcc clears cpu capability bit instead of using fake cpuid value, the EXID should always be off for PV guest without depending on cpuid value. So remove the cpuid check in xen_read_msr_safe() to always clear the X2APIC_ENABLE bit.

---
CC: Igor Druzhinin <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Juergen Gross <[email protected]>

v2:
don't use fake cpuid to cheat xen_read_msr_safe(), just always clear the EXIT bit.

---
 arch/x86/xen/enlighten_pv.c | 3 ---
 1 file changed, 3 deletions(-)
arch/x86/xen/enlighten_pv.c +0 -0
index 4b20082..6ad312d 100644

arch/x86/xen/enlighten_pv.c static u64 xen_read_msr_safe(unsigned int msr, int *err) · line 903

Quoted 7 lines
arch/x86/xen/enlighten_pv.c +0 -3
@@ -900,9 +900,6 @@ static u64 xen_read_msr_safe(unsigned int msr, int *err)
 	val = native_read_msr_safe(msr, err);
 	switch (msr) {
 	case MSR_IA32_APICBASE:
-#ifdef CONFIG_X86_X2APIC
-		if (!(cpuid_ecx(1) & (1 << (X86_FEATURE_X2APIC & 31))))
-#endif
 			val &= ~X2APIC_ENABLE;

Could you please correct indentation?

With that addressed you can have my

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
In reply to Xin Li
Quoted 4 lines · Xin Li

From: Talons Lee <[email protected]>

Commit e657fcc clears cpu capability bit instead of using fake cpuid value, the EXID should always be off for PV guest without depending

EXTD

Quoted 23 lines

on cpuid value. So remove the cpuid check in xen_read_msr_safe() to always clear the X2APIC_ENABLE bit.

---
CC: Igor Druzhinin <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Juergen Gross <[email protected]>

v2:
don't use fake cpuid to cheat xen_read_msr_safe(), just always clear the EXIT bit.

---
 arch/x86/xen/enlighten_pv.c | 3 ---
 1 file changed, 3 deletions(-)
arch/x86/xen/enlighten_pv.c +0 -0
index 4b20082..6ad312d 100644

arch/x86/xen/enlighten_pv.c static u64 xen_read_msr_safe(unsigned int msr, int *err) · line 903

Quoted 7 lines
arch/x86/xen/enlighten_pv.c +0 -3
@@ -900,9 +900,6 @@ static u64 xen_read_msr_safe(unsigned int msr, int *err)
 	val = native_read_msr_safe(msr, err);
 	switch (msr) {
 	case MSR_IA32_APICBASE:
-#ifdef CONFIG_X86_X2APIC
-		if (!(cpuid_ecx(1) & (1 << (X86_FEATURE_X2APIC & 31))))
-#endif
 			val &= ~X2APIC_ENABLE;

While this probably does bodge the issue for now, I can't help but think its going to cause problems for larger PV guests.

The problem isn't the visibility (or not) of x2APIC per say - it's that Linux goes and tries to use the APIC.  Ideally, PV guests should never have been able to see the APIC at all, and should be safe in the knowledge that, because its virtualised, it has sane capabilities.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel