Skip to contentSkip to conversation

powerpc/kvm: Handle the boundary condition correctly

PATCH In review Aneesh Kumar K.V 3 participants 11 messages Aug 22, 2013 – Sep 25, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/kvm: Handle the boundary condition correctly

From: "Aneesh Kumar K.V" <[email protected]>

We should be able to copy upto count bytes

---
 arch/powerpc/kvm/book3s_64_mmu_hv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +2 -2
index 710d313..0ae6bb6 100644
@@ -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;
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 1 line · Aneesh Kumar K.V

From: "Aneesh Kumar K.V" <[email protected]>

Isn't this you?

Quoted 2 lines

We should be able to copy upto count bytes

Why?

Alex

Quoted 31 lines

---
arch/powerpc/kvm/book3s_64_mmu_hv.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +2 -2
index 710d313..0ae6bb6 100644
@@ -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;
Signature · 1 line
1.8.1.2
#2 lore raw
Quoted 5 lines · Alexander Graf
Quoted 1 line · Aneesh Kumar K.V

From: "Aneesh Kumar K.V" <[email protected]>

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:

Quoted 6 lines
Quoted 3 lines

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.

http://mid.gmane.org/1376995766-16526-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com

Quoted 34 lines

Alex

Quoted 31 lines

---
arch/powerpc/kvm/book3s_64_mmu_hv.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +2 -2
index 710d313..0ae6bb6 100644
@@ -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;
Signature · 1 line
1.8.1.2
#3 lore raw
Quoted 11 lines · Aneesh Kumar K.V
Quoted 5 lines · Alexander Graf
Quoted 1 line · Aneesh Kumar K.V

From: "Aneesh Kumar K.V" <[email protected]>

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:

Don't bother, that's perfectly fine, and git am will do the right thing.

Cheers,
Ben.

Quoted 56 lines
Quoted 6 lines
Quoted 3 lines

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.

http://mid.gmane.org/1376995766-16526-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com

Quoted 34 lines

Alex

Quoted 31 lines

---
arch/powerpc/kvm/book3s_64_mmu_hv.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +2 -2
index 710d313..0ae6bb6 100644
@@ -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;
Signature · 1 line
1.8.1.2
#4 lore raw
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 6 lines · Aneesh Kumar K.V
Quoted 4 lines · Alexander Graf
Quoted 1 line · Aneesh Kumar K.V

From: "Aneesh Kumar K.V" <[email protected]>

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

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:

Don't bother, that's perfectly fine, and git am will do the right thing.

It will, but it's an indicator that something in his git config is misconfigured. Usually when git sees "Author = Sender" it will omit the From: line.

Alex

#5 lore raw
In reply to Aneesh Kumar K.V
Quoted 30 lines · Aneesh Kumar K.V
Quoted 5 lines · Alexander Graf
Quoted 1 line · Aneesh Kumar K.V

From: "Aneesh Kumar K.V" <[email protected]>

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:

Quoted 6 lines
Quoted 3 lines

We should be able to copy upto count bytes

Why?

Without this we end up doing

(quoted diff) +7 -0
+    struct kvm_get_htab_buf {
+        struct kvm_get_htab_header header;
+        /*
+         * Older kernel required one extra byte.
+         */
+        unsigned long hpte[3];
+    } hpte_buf;
Quoted 1 line

even though we are only looking for one hpte entry.

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

Alex

Quoted 42 lines

http://mid.gmane.org/1376995766-16526-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com

Quoted 26 lines

Alex

Quoted 23 lines

---
arch/powerpc/kvm/book3s_64_mmu_hv.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +1 -1
index 710d313..0ae6bb6 100644
@@ -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 &&
Quoted 8 lines
Quoted 8 lines
arch/powerpc/kvm/book3s_64_mmu_hv.c +1 -1
-		       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;
Signature · 1 line
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#6 lore raw
Quoted 32 lines · Alexander Graf
Quoted 30 lines · Aneesh Kumar K.V
Quoted 5 lines · Alexander Graf
Quoted 1 line · Aneesh Kumar K.V

From: "Aneesh Kumar K.V" <[email protected]>

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:

Quoted 6 lines
Quoted 3 lines

We should be able to copy upto count bytes

Why?

Without this we end up doing

(quoted diff) +7 -0
+    struct kvm_get_htab_buf {
+        struct kvm_get_htab_header header;
+        /*
+         * Older kernel required one extra byte.
+         */
+        unsigned long hpte[3];
+    } hpte_buf;
Quoted 7 lines
Quoted 1 line

even though we are only looking for one hpte entry.

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

Quoted 3 lines

http://mid.gmane.org/1376995766-16526-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com

Didn't quiet get what you are looking for. As explained before, we now need to pass an array with array size 3 even though we know we need to read only 2 entries because kernel doesn't loop correctly.

-aneesh

#7 lore raw
Quoted 39 lines · Aneesh Kumar K.V
Quoted 37 lines · Alexander Graf
Quoted 30 lines · Aneesh Kumar K.V
Quoted 5 lines · Alexander Graf
Quoted 1 line · Aneesh Kumar K.V

From: "Aneesh Kumar K.V" <[email protected]>

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:

Quoted 6 lines
Quoted 3 lines

We should be able to copy upto count bytes

Why?

Without this we end up doing

(quoted diff) +7 -0
+    struct kvm_get_htab_buf {
+        struct kvm_get_htab_header header;
+        /*
+         * Older kernel required one extra byte.
+         */
+        unsigned long hpte[3];
+    } hpte_buf;
Quoted 1 line

even though we are only looking for one hpte entry.

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

Quoted 1 line
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

http://mid.gmane.org/1376995766-16526-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com

Didn't quiet get what you are looking for. As explained before, we now need to pass an array with array size 3 even though we know we need to read only 2 entries because kernel doesn't loop correctly.

But we need to do that regardless, because newer QEMU needs to be able to run on older kernels, no?

Alex

#8 lore raw
Quoted 41 lines · Alexander Graf
Quoted 39 lines · Aneesh Kumar K.V
Quoted 37 lines · Alexander Graf
Quoted 30 lines · Aneesh Kumar K.V
Quoted 5 lines · Alexander Graf
Quoted 1 line · Aneesh Kumar K.V

From: "Aneesh Kumar K.V" <[email protected]>

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:

Quoted 6 lines
Quoted 3 lines

We should be able to copy upto count bytes

Why?

Without this we end up doing

(quoted diff) +7 -0
+    struct kvm_get_htab_buf {
+        struct kvm_get_htab_header header;
+        /*
+         * Older kernel required one extra byte.
+         */
+        unsigned long hpte[3];
+    } hpte_buf;
Quoted 1 line

even though we are only looking for one hpte entry.

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

Quoted 1 line
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

http://mid.gmane.org/1376995766-16526-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com

Didn't quiet get what you are looking for. As explained before, we now need to pass an array with array size 3 even though we know we need to read only 2 entries because kernel doesn't loop correctly.

But we need to do that regardless, because newer QEMU needs to be able to run on older kernels, no?

yes. So use space will have to pass an array of size 3. But that should not prevent us from fixing this right ?

-aneesh

#9 lore raw

Hi Alex,

Quoted 10 lines · Aneesh Kumar K.V
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

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

Quoted 3 lines

http://mid.gmane.org/1376995766-16526-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com

Didn't quiet get what you are looking for. As explained before, we now need to pass an array with array size 3 even though we know we need to read only 2 entries because kernel doesn't loop correctly.

Quoted 6 lines
Quoted 2 lines

But we need to do that regardless, because newer QEMU needs to be able to run on older kernels, no?

yes. So use space will have to pass an array of size 3. But that should not prevent us from fixing this right ?

Do we still want this patch or should I drop this ?

-aneesh

#10 lore raw
Quoted 14 lines · Aneesh Kumar K.V

Hi Alex,

Quoted 10 lines · Aneesh Kumar K.V
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

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

Quoted 3 lines

http://mid.gmane.org/1376995766-16526-4-git-send-email-aneesh.kumar@linux.vnet.ibm.com

Didn't quiet get what you are looking for. As explained before, we now need to pass an array with array size 3 even though we know we need to read only 2 entries because kernel doesn't loop correctly.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

But we need to do that regardless, because newer QEMU needs to be able to run on older kernels, no?

yes. So use space will have to pass an array of size 3. But that should not prevent us from fixing this right ?

Do we still want this patch or should I drop this ?

If we really want it we need to be able to tell user space that we support this feature through a CAP, so that it can act accordingly. Given the additional complexity of this and the fact that we do want to support older KVM versions regardless, I don't think it's worth the hassle.

Alex