[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c1be65e5-fbcb-246d-03a2-c7de44e4fad9@amd.com>
Date: Tue, 20 Sep 2016 09:50:45 +0700
From: Suravee Suthikulpanit <Suravee.Suthikulpanit@....com>
To: Colin King <colin.king@...onical.com>,
Joerg Roedel <joro@...tes.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Radim Krčmář <rkrcmar@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H . Peter Anvin" <hpa@...or.com>, <x86@...nel.org>,
<kvm@...r.kernel.org>
CC: <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kvm: svm: fix unsigned compare less than zero comparison
Hi,
On 9/19/16 13:11, Colin King wrote:
> From: Colin Ian King <colin.king@...onical.com>
>
> vm_data->avic_vm_id is a u32, so the check for a error
> return (less than zero) such as -EAGAIN from
> avic_get_next_vm_id currently has no effect whatsoever.
> Fix this by using a temporary int for the comparison
> and assign vm_data->avic_vm_id to this. I used an explicit
> u32 cast in the assignment to show why vm_data->avic_vm_id
> cannot be used in the assign/compare steps.
>
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
> ---
> arch/x86/kvm/svm.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 1b66c5a..2ca66aa 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -1419,7 +1419,7 @@ static void avic_vm_destroy(struct kvm *kvm)
> static int avic_vm_init(struct kvm *kvm)
> {
> unsigned long flags;
> - int err = -ENOMEM;
> + int vm_id, err = -ENOMEM;
> struct kvm_arch *vm_data = &kvm->arch;
> struct page *p_page;
> struct page *l_page;
> @@ -1427,9 +1427,10 @@ static int avic_vm_init(struct kvm *kvm)
> if (!avic)
> return 0;
>
> - vm_data->avic_vm_id = avic_get_next_vm_id();
> - if (vm_data->avic_vm_id < 0)
> - return vm_data->avic_vm_id;
> + vm_id = avic_get_next_vm_id();
> + if (vm_id < 0)
> + return vm_id;
> + vm_data->avic_vm_id = (u32)vm_id;
>
> /* Allocating physical APIC ID table (4KB) */
> p_page = alloc_page(GFP_KERNEL);
>
Thanks for catching this.
Suravee
Powered by blists - more mailing lists