Skip to contentSkip to conversation

viridian: fix cpuid leaf 0x40000003

PATCH In review Paul Durrant 3 participants 3 messages May 11, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 viridian: fix cpuid leaf 0x40000003

The response to viridian leaf 3 needs to split a 64-bit mask across EAX and EBX, with the low order 32 bits in EAX and the high order 32 bits in EBX. To facilitate this a union of two uint32_t values and the mask (type HV_PARTITION_PRIVILEGE_MASK) is allocated on stack as follows:

union {
    HV_PARTITION_PRIVILEGE_MASK mask;
    uint32_t lo, hi;
} u;

This, of course, is incorrect as both lo and hi will alias the low order 32 bits of the mask.

This patch wraps lo and hi in an anonmymous struct to achieve the desired effect.

NOTE: Fixing this also stops Windows making the HvGetPartitionId hypercall
which was previously considered erroneous behaviour. Thus the hypercall handler is also modified to stop squashing the 'unimplemented' warning for this hypercall.

---
Cc: Jan Beulich <[email protected]>
Cc: Andrew Cooper <[email protected]>

---
 xen/arch/x86/hvm/viridian.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
xen/arch/x86/hvm/viridian.c +3 -5
index d6aa89d..694eae6 100644
@@ -245,7 +245,7 @@ void cpuid_viridian_leaves(const struct vcpu *v, uint32_t leaf,
         };
         union {
             HV_PARTITION_PRIVILEGE_MASK mask;
-            uint32_t lo, hi;
+            struct { uint32_t lo, hi; };
         } u;
 
         if ( !(viridian_feature_mask(d) & HVMPV_no_freq) )
@@ -964,12 +964,10 @@ int viridian_hypercall(struct cpu_user_regs *regs)
         gprintk(XENLOG_WARNING, "unimplemented hypercall %04x\n",
                 input.call_code);
         /* Fallthrough. */
-    case HvGetPartitionId:
     case HvExtCallQueryCapabilities:
         /*
-         * These hypercalls seem to be erroneously issued by Windows
-         * despite neither AccessPartitionId nor EnableExtendedHypercalls
-         * being set in CPUID leaf 2.
+         * This hypercall seems to be erroneously issued by Windows
+         * despite EnableExtendedHypercalls not being set in CPUID leaf 2.
          * Given that return a status of 'invalid code' has not so far
          * caused any problems it's not worth logging.
          */
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines · Paul Durrant

The response to viridian leaf 3 needs to split a 64-bit mask across EAX and EBX, with the low order 32 bits in EAX and the high order 32 bits in EBX. To facilitate this a union of two uint32_t values and the mask (type HV_PARTITION_PRIVILEGE_MASK) is allocated on stack as follows:

union {
    HV_PARTITION_PRIVILEGE_MASK mask;
    uint32_t lo, hi;
} u;

This, of course, is incorrect as both lo and hi will alias the low order 32 bits of the mask.

This patch wraps lo and hi in an anonmymous struct to achieve the desired effect.

Quoted 6 lines

NOTE: Fixing this also stops Windows making the HvGetPartitionId hypercall
which was previously considered erroneous behaviour. Thus the hypercall handler is also modified to stop squashing the 'unimplemented' warning for this hypercall.

CC Juergen.  This wants backporting, and taking into 4.11

~Andrew

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

#2 lore raw
Quoted 22 lines · Andrew Cooper
Quoted 21 lines · Paul Durrant

The response to viridian leaf 3 needs to split a 64-bit mask across EAX and EBX, with the low order 32 bits in EAX and the high order 32 bits in EBX. To facilitate this a union of two uint32_t values and the mask (type HV_PARTITION_PRIVILEGE_MASK) is allocated on stack as follows:

union {
    HV_PARTITION_PRIVILEGE_MASK mask;
    uint32_t lo, hi;
} u;

This, of course, is incorrect as both lo and hi will alias the low order 32 bits of the mask.

This patch wraps lo and hi in an anonmymous struct to achieve the desired effect.

NOTE: Fixing this also stops Windows making the HvGetPartitionId hypercall
which was previously considered erroneous behaviour. Thus the hypercall handler is also modified to stop squashing the 'unimplemented' warning for this hypercall.

Quoted 5 lines
Quoted 1 line

CC Juergen.  This wants backporting, and taking into 4.11

Juergen

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