linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: Assign correct value to array.maxnent
@ 2020-06-04  2:43 Xiaoyao Li
  2020-06-04  3:55 ` Xiaoyao Li
  0 siblings, 1 reply; 2+ messages in thread
From: Xiaoyao Li @ 2020-06-04  2:43 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel, Xiaoyao Li

Delay the assignment of array.maxnent to use correct value for the case
cpuid->nent > KVM_MAX_CPUID_ENTRIES.

Fixes: e53c95e8d41e ("KVM: x86: Encapsulate CPUID entries and metadata in struct")
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
 arch/x86/kvm/cpuid.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 253b8e875ccd..befff01d100c 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -870,7 +870,6 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid,
 
 	struct kvm_cpuid_array array = {
 		.nent = 0,
-		.maxnent = cpuid->nent,
 	};
 	int r, i;
 
@@ -887,6 +886,8 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid,
 	if (!array.entries)
 		return -ENOMEM;
 
+	array.maxnent = cpuid->nent;
+
 	for (i = 0; i < ARRAY_SIZE(funcs); i++) {
 		r = get_cpuid_func(&array, funcs[i], type);
 		if (r)
-- 
2.18.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: x86: Assign correct value to array.maxnent
  2020-06-04  2:43 [PATCH] KVM: x86: Assign correct value to array.maxnent Xiaoyao Li
@ 2020-06-04  3:55 ` Xiaoyao Li
  0 siblings, 0 replies; 2+ messages in thread
From: Xiaoyao Li @ 2020-06-04  3:55 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel

On 6/4/2020 10:43 AM, Xiaoyao Li wrote:
> Delay the assignment of array.maxnent to use correct value for the case
> cpuid->nent > KVM_MAX_CPUID_ENTRIES.
> 
> Fixes: e53c95e8d41e ("KVM: x86: Encapsulate CPUID entries and metadata in struct")
> Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
> ---
>   arch/x86/kvm/cpuid.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 253b8e875ccd..befff01d100c 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -870,7 +870,6 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid,
>   
>   	struct kvm_cpuid_array array = {
>   		.nent = 0,
> -		.maxnent = cpuid->nent,
>   	};
>   	int r, i;
>   
> @@ -887,6 +886,8 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid,
>   	if (!array.entries)
>   		return -ENOMEM;
>   
> +	array.maxnent = cpuid->nent;

Miss the fact that maxnent is const, V2 is coming.

> +
>   	for (i = 0; i < ARRAY_SIZE(funcs); i++) {
>   		r = get_cpuid_func(&array, funcs[i], type);
>   		if (r)
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-04  3:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-04  2:43 [PATCH] KVM: x86: Assign correct value to array.maxnent Xiaoyao Li
2020-06-04  3:55 ` Xiaoyao Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).