x86/CPUID: fill all fields in x86_cpuid_policy_fill_native()
diff mbox series

Message ID 41177396-9944-0bbd-66d2-8b4f2bd063f0@suse.com
State New
Headers show
Series
  • x86/CPUID: fill all fields in x86_cpuid_policy_fill_native()
Related show

Commit Message

Jan Beulich June 22, 2020, 12:09 p.m. UTC
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")
Signed-off-by: Jan Beulich <jbeulich@suse.com>

Comments

Andrew Cooper June 22, 2020, 12:39 p.m. UTC | #1
On 22/06/2020 13:09, Jan Beulich wrote:
> 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")
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> --- a/xen/lib/x86/cpuid.c
> +++ b/xen/lib/x86/cpuid.c
> @@ -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 <andrew.cooper3@citrix.com>

> +    p->hv_limit = 0;
> +    p->hv2_limit = 0;
> +
>      x86_cpuid_policy_recalc_synth(p);
>  }
>
Jan Beulich June 22, 2020, 1:37 p.m. UTC | #2
On 22.06.2020 14:39, Andrew Cooper wrote:
> On 22/06/2020 13:09, Jan Beulich wrote:
>> 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")
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>
>> --- a/xen/lib/x86/cpuid.c
>> +++ b/xen/lib/x86/cpuid.c
>> @@ -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.

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.

> With this, Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

Thanks, Jan
Andrew Cooper June 22, 2020, 1:59 p.m. UTC | #3
On 22/06/2020 14:37, Jan Beulich wrote:
> On 22.06.2020 14:39, Andrew Cooper wrote:
>> On 22/06/2020 13:09, Jan Beulich wrote:
>>> 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")
>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>>
>>> --- a/xen/lib/x86/cpuid.c
>>> +++ b/xen/lib/x86/cpuid.c
>>> @@ -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.
> 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
Jan Beulich June 24, 2020, 3:32 p.m. UTC | #4
On 22.06.2020 14:39, Andrew Cooper wrote:
> On 22/06/2020 13:09, Jan Beulich wrote:
>> 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")
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>
>> --- a/xen/lib/x86/cpuid.c
>> +++ b/xen/lib/x86/cpuid.c
>> @@ -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 <andrew.cooper3@citrix.com>

Paul?

Thanks, Jan
Jan Beulich June 24, 2020, 3:35 p.m. UTC | #5
(sorry, re-sending with To and Cc corrected)

On 22.06.2020 14:39, Andrew Cooper wrote:
> On 22/06/2020 13:09, Jan Beulich wrote:
>> 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")
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>
>> --- a/xen/lib/x86/cpuid.c
>> +++ b/xen/lib/x86/cpuid.c
>> @@ -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 <andrew.cooper3@citrix.com>

Paul?

Thanks, Jan
Paul Durrant June 25, 2020, 6:57 a.m. UTC | #6
> -----Original Message-----
> From: Jan Beulich <jbeulich@suse.com>
> Sent: 24 June 2020 16:36
> To: Paul Durrant <paul@xen.org>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>; xen-devel@lists.xenproject.org; Wei Liu <wl@xen.org>;
> Roger Pau Monné <roger.pau@citrix.com>
> Subject: Ping: [PATCH] x86/CPUID: fill all fields in x86_cpuid_policy_fill_native()
> 
> (sorry, re-sending with To and Cc corrected)
> 
> On 22.06.2020 14:39, Andrew Cooper wrote:
> > On 22/06/2020 13:09, Jan Beulich wrote:
> >> 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")
> >> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> >>
> >> --- a/xen/lib/x86/cpuid.c
> >> +++ b/xen/lib/x86/cpuid.c
> >> @@ -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 <andrew.cooper3@citrix.com>
> 
> Paul?

Release-acked-by: Paul Durrant <paul@xen.org>

> 
> Thanks, Jan

Patch
diff mbox series

--- a/xen/lib/x86/cpuid.c
+++ b/xen/lib/x86/cpuid.c
@@ -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);
 }