Skip to contentSkip to conversation

x86/CPUID: fill all fields in x86_cpuid_policy_fill_native()

PATCH In review Jan Beulich 3 participants 7 messages Jun 22, 2020 – Jun 25, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/CPUID: fill all fields in x86_cpuid_policy_fill_native()

Coverity validly complains that the new call from tools/tests/cpu-policy/test-cpu-policy.c:test_cpuid_current() leaves two fields uninitialized, yet they get then consumed by x86_cpuid_copy_to_buffer(). (All other present callers of the function pass a pointer to a static - and hence initialized - buffer.)

Coverity-ID: 1464809

Fixes c22ced93e167 ("tests/cpu-policy: Confirm that CPUID serialisation is sorted")
xen/lib/x86/cpuid.c +4 -0
@@ -176,6 +176,10 @@ void x86_cpuid_policy_fill_native(struct
                           ARRAY_SIZE(p->extd.raw) - 1); ++i )
         cpuid_leaf(0x80000000 + i, &p->extd.raw[i]);
 
+    /* Don't report leaves from possible lower level hypervisor. */
+    p->hv_limit = 0;
+    p->hv2_limit = 0;
+
     x86_cpuid_policy_recalc_synth(p);
 }
 
#1 lore raw
Quoted 13 lines · Jan Beulich

Coverity validly complains that the new call from tools/tests/cpu-policy/test-cpu-policy.c:test_cpuid_current() leaves two fields uninitialized, yet they get then consumed by x86_cpuid_copy_to_buffer(). (All other present callers of the function pass a pointer to a static - and hence initialized - buffer.)

Coverity-ID: 1464809

Fixes c22ced93e167 ("tests/cpu-policy: Confirm that CPUID serialisation is sorted")

xen/lib/x86/cpuid.c void x86_cpuid_policy_fill_native(struct · line 179

Quoted 4 lines
xen/lib/x86/cpuid.c +1 -0
@@ -176,6 +176,10 @@ void x86_cpuid_policy_fill_native(struct
                           ARRAY_SIZE(p->extd.raw) - 1); ++i )
         cpuid_leaf(0x80000000 + i, &p->extd.raw[i]);
 
+    /* Don't report leaves from possible lower level hypervisor. */

", for now."

This will change in the future.

With this, Reviewed-by: Andrew Cooper <[email protected]>

Quoted 6 lines
xen/lib/x86/cpuid.c +3 -0
+    p->hv_limit = 0;
+    p->hv2_limit = 0;
+
     x86_cpuid_policy_recalc_synth(p);
 }
 
#2 lore raw
Quoted 17 lines · Andrew Cooper
Quoted 16 lines · Jan Beulich

Coverity validly complains that the new call from tools/tests/cpu-policy/test-cpu-policy.c:test_cpuid_current() leaves two fields uninitialized, yet they get then consumed by x86_cpuid_copy_to_buffer(). (All other present callers of the function pass a pointer to a static - and hence initialized - buffer.)

Coverity-ID: 1464809

Fixes c22ced93e167 ("tests/cpu-policy: Confirm that CPUID serialisation is sorted")
xen/lib/x86/cpuid.c +0 -0
@@ -176,6 +176,10 @@ void x86_cpuid_policy_fill_native(struct
                           ARRAY_SIZE(p->extd.raw) - 1); ++i )
         cpuid_leaf(0x80000000 + i, &p->extd.raw[i]);
 
Quoted 5 lines

xen/lib/x86/cpuid.c void x86_cpuid_policy_fill_native(struct · line 179

Quoted 1 line
xen/lib/x86/cpuid.c +1 -0
+    /* Don't report leaves from possible lower level hypervisor. */

", for now."

This will change in the future.

I was pondering at that moment whether to add it, but then I didn't think we'd want to let shine through lower level hypervisor info. But yes, I've added it, because it won't be wrong to say "for now", even if it end up being for much longer.

Quoted 1 line

With this, Reviewed-by: Andrew Cooper <[email protected]>

Thanks, Jan

#3 lore raw
Quoted 18 lines · Jan Beulich
Quoted 17 lines · Andrew Cooper
Quoted 16 lines · Jan Beulich

Coverity validly complains that the new call from tools/tests/cpu-policy/test-cpu-policy.c:test_cpuid_current() leaves two fields uninitialized, yet they get then consumed by x86_cpuid_copy_to_buffer(). (All other present callers of the function pass a pointer to a static - and hence initialized - buffer.)

Coverity-ID: 1464809

Fixes c22ced93e167 ("tests/cpu-policy: Confirm that CPUID serialisation is sorted")
xen/lib/x86/cpuid.c +0 -0
@@ -176,6 +176,10 @@ void x86_cpuid_policy_fill_native(struct
                           ARRAY_SIZE(p->extd.raw) - 1); ++i )
         cpuid_leaf(0x80000000 + i, &p->extd.raw[i]);
 
Quoted 8 lines
Quoted 4 lines

xen/lib/x86/cpuid.c void x86_cpuid_policy_fill_native(struct · line 179

Quoted 1 line
xen/lib/x86/cpuid.c +1 -0
+    /* Don't report leaves from possible lower level hypervisor. */

", for now."

This will change in the future.

I was pondering at that moment whether to add it, but then I didn't think we'd want to let shine through lower level hypervisor info. But yes, I've added it, because it won't be wrong to say "for now", even if it end up being for much longer.

It won't be very much longer.

I don't intend to let it "shine though", but the outer hypervisors data should be in the raw/host policy, just as the Xen Xen/Viridian leaves need to be in the guest policies.

This is the longterm plan to handle Viridian features, because the existing HVMPARAM simply isn't expressive enough.

~Andrew

#4 lore raw

Ping: [PATCH] x86/CPUID: fill all fields in x86_cpuid_policy_fill_native()

In reply to Andrew Cooper
Quoted 17 lines · Andrew Cooper
Quoted 16 lines · Jan Beulich

Coverity validly complains that the new call from tools/tests/cpu-policy/test-cpu-policy.c:test_cpuid_current() leaves two fields uninitialized, yet they get then consumed by x86_cpuid_copy_to_buffer(). (All other present callers of the function pass a pointer to a static - and hence initialized - buffer.)

Coverity-ID: 1464809

Fixes c22ced93e167 ("tests/cpu-policy: Confirm that CPUID serialisation is sorted")
xen/lib/x86/cpuid.c +0 -0
@@ -176,6 +176,10 @@ void x86_cpuid_policy_fill_native(struct
                           ARRAY_SIZE(p->extd.raw) - 1); ++i )
         cpuid_leaf(0x80000000 + i, &p->extd.raw[i]);
 
Quoted 7 lines

xen/lib/x86/cpuid.c void x86_cpuid_policy_fill_native(struct · line 179

Quoted 1 line
xen/lib/x86/cpuid.c +1 -0
+    /* Don't report leaves from possible lower level hypervisor. */

", for now."

This will change in the future.

With this, Reviewed-by: Andrew Cooper <[email protected]>

Paul?

Thanks, Jan

#5 lore raw

Ping: [PATCH] x86/CPUID: fill all fields in x86_cpuid_policy_fill_native()

In reply to Andrew Cooper

(sorry, re-sending with To and Cc corrected)

Quoted 17 lines · Andrew Cooper
Quoted 16 lines · Jan Beulich

Coverity validly complains that the new call from tools/tests/cpu-policy/test-cpu-policy.c:test_cpuid_current() leaves two fields uninitialized, yet they get then consumed by x86_cpuid_copy_to_buffer(). (All other present callers of the function pass a pointer to a static - and hence initialized - buffer.)

Coverity-ID: 1464809

Fixes c22ced93e167 ("tests/cpu-policy: Confirm that CPUID serialisation is sorted")
xen/lib/x86/cpuid.c +0 -0
@@ -176,6 +176,10 @@ void x86_cpuid_policy_fill_native(struct
                           ARRAY_SIZE(p->extd.raw) - 1); ++i )
         cpuid_leaf(0x80000000 + i, &p->extd.raw[i]);
 
Quoted 7 lines

xen/lib/x86/cpuid.c void x86_cpuid_policy_fill_native(struct · line 179

Quoted 1 line
xen/lib/x86/cpuid.c +1 -0
+    /* Don't report leaves from possible lower level hypervisor. */

", for now."

This will change in the future.

With this, Reviewed-by: Andrew Cooper <[email protected]>

Paul?

Thanks, Jan

#6 lore raw

RE: Ping: [PATCH] x86/CPUID: fill all fields in x86_cpuid_policy_fill_native()

Quoted 32 lines

-----Original Message-----
From: Jan Beulich <[email protected]>
Sent: 24 June 2020 16:36
To: Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; [email protected]; Wei Liu <[email protected]>; Roger Pau Monné <[email protected]>
Subject: Ping: [PATCH] x86/CPUID: fill all fields in x86_cpuid_policy_fill_native()

(sorry, re-sending with To and Cc corrected)

Quoted 21 lines · Andrew Cooper
Quoted 13 lines · Jan Beulich

Coverity validly complains that the new call from tools/tests/cpu-policy/test-cpu-policy.c:test_cpuid_current() leaves two fields uninitialized, yet they get then consumed by x86_cpuid_copy_to_buffer(). (All other present callers of the function pass a pointer to a static - and hence initialized - buffer.)

Coverity-ID: 1464809

Fixes c22ced93e167 ("tests/cpu-policy: Confirm that CPUID serialisation is sorted")

xen/lib/x86/cpuid.c void x86_cpuid_policy_fill_native(struct · line 179

Quoted 4 lines
xen/lib/x86/cpuid.c +1 -0
@@ -176,6 +176,10 @@ void x86_cpuid_policy_fill_native(struct
                           ARRAY_SIZE(p->extd.raw) - 1); ++i )
         cpuid_leaf(0x80000000 + i, &p->extd.raw[i]);
 
+    /* Don't report leaves from possible lower level hypervisor. */

", for now."

Quoted 5 lines
Quoted 3 lines

This will change in the future.

With this, Reviewed-by: Andrew Cooper <[email protected]>

Paul?

Quoted 2 lines

Thanks, Jan