Skip to contentSkip to conversation

x86/levelling: Fix breakage on older Intel boxes from c/s 08e7738

PATCH In review Andrew Cooper 2 participants 2 messages Sep 1, 2016 – Sep 2, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/levelling: Fix breakage on older Intel boxes from c/s 08e7738

cpufeat_mask() yields an unsigned integer constant. As a result, taking its complement causes zero extention rather than sign extention.

The result is that, when a guest OS has OXSAVE disabled, all features in 1d are hidden from native CPUID. Amongst other things, this causes the early code in Linux to find no LAPIC, but for everything to appear fine later when userspace is up and running.

---
CC: Jan Beulich <[email protected]>

I wonder whether a better fix might be to put an explicit (int) cast in cpufeat_mask() to yield an signed constant?

---
 xen/arch/x86/cpu/intel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/cpu/intel.c +1 -1
index a9355cbf..7b60aaa 100644
@@ -192,7 +192,7 @@ static void intel_ctxt_switch_levelling(const struct vcpu *next)
 		 */
 		if (next && is_pv_vcpu(next) && !is_idle_vcpu(next) &&
 		    !(next->arch.pv_vcpu.ctrlreg[4] & X86_CR4_OSXSAVE))
-			val &= ~cpufeat_mask(X86_FEATURE_OSXSAVE);
+			val &= ~(uint64_t)cpufeat_mask(X86_FEATURE_OSXSAVE);
 
 		if (unlikely(these_masks->_1cd != val)) {
 			wrmsrl(msr_basic, val);
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 01.09.16 at 20:26, <[email protected]> wrote:

I wonder whether a better fix might be to put an explicit (int) cast in cpufeat_mask() to yield an signed constant?

That's an option, but will make us use implementation defined behavior (due to the unsigned -> signed conversion of a non- representable type when the bit in question is bit 31).

Jan

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