[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4EC62D58.103@linux.vnet.ibm.com>
Date: Fri, 18 Nov 2011 18:03:04 +0800
From: Xiao Guangrong <xiaoguangrong@...ux.vnet.ibm.com>
To: Sasha Levin <levinsasha928@...il.com>
CC: Avi Kivity <avi@...hat.com>, Marcelo Tosatti <mtosatti@...hat.com>,
LKML <linux-kernel@...r.kernel.org>, KVM <kvm@...r.kernel.org>
Subject: Re: [PATCH v2 6/6] KVM: introduce a table to map slot id to index
in memslots arry
On 11/18/2011 05:45 PM, Sasha Levin wrote:
>> struct kvm {
>> @@ -340,14 +342,13 @@ static inline struct kvm_memslots *kvm_memslots(struct kvm *kvm)
>> static inline struct kvm_memory_slot *
>> id_to_memslot(struct kvm_memslots *slots, int id)
>> {
>> - int i;
>> + int index = slots->id_to_index[id];
>> + struct kvm_memory_slot *slot;
>>
>> - for (i = 0; i < KVM_MEM_SLOTS_NUM; i++)
>> - if (slots->memslots[i].id == id)
>> - return &slots->memslots[i];
>> + slot = &slots->memslots[index];
>>
>> - WARN_ON(1);
>> - return NULL;
>> + WARN_ON(slot->id != id);
>> + return slot;
>> }
>
> If we didn't find the right memslot we shouldn't be returning a wrong
> one, we should be failing.
>
Um, in the current code, the "id" has already been checked by the caller,
that means "id" should be < KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS, so,
if we can not find the memslot for this slot, it must be a bug.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists