[PATCH] powerpc/kvm: Handle the boundary condition correctly

Alexander Graf agraf at suse.de
Mon Aug 26 04:16:09 EST 2013


On 23.08.2013, at 04:31, Aneesh Kumar K.V wrote:

> Alexander Graf <agraf at suse.de> writes:
> 
>> On 22.08.2013, at 12:37, Aneesh Kumar K.V wrote:
>> 
>>> From: "Aneesh Kumar K.V" <aneesh.kumar at linux.vnet.ibm.com>
>> 
>> Isn't this you?
> 
> Yes. The patches are generated using git format-patch and sent by
> git send-email. That's how it always created patches for me. I am not sure if
> there is a config I can change to avoid having From:
> 
>> 
>>> 
>>> We should be able to copy upto count bytes
>> 
>> Why?
>> 
> 
> Without this we end up doing
> 
> +    struct kvm_get_htab_buf {
> +        struct kvm_get_htab_header header;
> +        /*
> +         * Older kernel required one extra byte.
> +         */
> +        unsigned long hpte[3];
> +    } hpte_buf;
> 
> 
> even though we are only looking for one hpte entry.

Ok, please give me an example with real numbers and why it breaks.


Alex

> 
> http://mid.gmane.org/1376995766-16526-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com
> 
>> 
>> Alex
>> 
>>> 
>>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
>>> ---
>>> arch/powerpc/kvm/book3s_64_mmu_hv.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>> 
>>> diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
>>> index 710d313..0ae6bb6 100644
>>> --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
>>> +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
>>> @@ -1362,7 +1362,7 @@ static ssize_t kvm_htab_read(struct file *file, char __user *buf,
>>> 	lbuf = (unsigned long __user *)buf;
>>> 
>>> 	nb = 0;
>>> -	while (nb + sizeof(hdr) + HPTE_SIZE < count) {
>>> +	while (nb + sizeof(hdr) + HPTE_SIZE <= count) {
>>> 		/* Initialize header */
>>> 		hptr = (struct kvm_get_htab_header __user *)buf;
>>> 		hdr.n_valid = 0;
>>> @@ -1385,7 +1385,7 @@ static ssize_t kvm_htab_read(struct file *file, char __user *buf,
>>> 		/* Grab a series of valid entries */
>>> 		while (i < kvm->arch.hpt_npte &&
>>> 		       hdr.n_valid < 0xffff &&
>>> -		       nb + HPTE_SIZE < count &&
>>> +		       nb + HPTE_SIZE <= count &&
>>> 		       record_hpte(flags, hptp, hpte, revp, 1, first_pass)) {
>>> 			/* valid entry, write it out */
>>> 			++hdr.n_valid;
>>> -- 
>>> 1.8.1.2
>>> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the Linuxppc-dev mailing list