Skip to contentSkip to conversation

xenfb bug fixes and cleanup

PATCH In review Wei Liu 5 participants 22 messages Apr 12, 2016 – Apr 22, 2016

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

v2 cover xenfb bug fixes and cleanup

Wei Liu (3):
xenfb: use the correct condition to avoid excessive looping
xenfb: move xen_rmb to the correct location
xenfb: remove out_cons in xenfb_handle_events

 hw/display/xenfb.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
author
#1 lore raw

PATCH v2 1/3 xenfb: use the correct condition to avoid excessive looping

In commit ac0487e1 ("xenfb.c: avoid expensive loops when prod <= out_cons"), ">=" was used. In fact, a full ring is a legit state. Correct the test to use ">".

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

Backport candidate to our own tree.

---
 hw/display/xenfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/xenfb.c +1 -1
index 40b096a..9866dfd 100644
@@ -775,7 +775,7 @@ static void xenfb_handle_events(struct XenFB *xenfb)
 
     prod = page->out_prod;
     out_cons = page->out_cons;
-    if (prod - out_cons >= XENFB_OUT_RING_LEN) {
+    if (prod - out_cons > XENFB_OUT_RING_LEN) {
         return;
     }
     xen_rmb();		/* ensure we see ring contents up to prod */
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
author
#2 lore raw

PATCH v2 1/3 xenfb: use the correct condition to avoid excessive looping

In reply to Wei Liu

In commit ac0487e1 ("xenfb.c: avoid expensive loops when prod <= out_cons"), ">=" was used. In fact, a full ring is a legit state. Correct the test to use ">".

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

Backport candidate to our own tree.

---
 hw/display/xenfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/xenfb.c +1 -1
index 40b096a..9866dfd 100644
@@ -775,7 +775,7 @@ static void xenfb_handle_events(struct XenFB *xenfb)
 
     prod = page->out_prod;
     out_cons = page->out_cons;
-    if (prod - out_cons >= XENFB_OUT_RING_LEN) {
+    if (prod - out_cons > XENFB_OUT_RING_LEN) {
         return;
     }
     xen_rmb();		/* ensure we see ring contents up to prod */
Signature · 1 line
2.1.4
Acked-by on v2 1/3
#3 lore raw

Re: [PATCH v2 1/3] xenfb: use the correct condition to avoid excessive looping

Quoted 8 lines · Wei Liu

In commit ac0487e1 ("xenfb.c: avoid expensive loops when prod <= out_cons"), ">=" was used. In fact, a full ring is a legit state. Correct the test to use ">".

I'll add it to my queue

Quoted 24 lines
Cc Stefano Stabellini <[email protected]>
Cc Anthony Perard <[email protected]>

Backport candidate to our own tree.

---
 hw/display/xenfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/xenfb.c +1 -1
index 40b096a..9866dfd 100644
@@ -775,7 +775,7 @@ static void xenfb_handle_events(struct XenFB *xenfb)
 
     prod = page->out_prod;
     out_cons = page->out_cons;
-    if (prod - out_cons >= XENFB_OUT_RING_LEN) {
+    if (prod - out_cons > XENFB_OUT_RING_LEN) {
         return;
     }
     xen_rmb();		/* ensure we see ring contents up to prod */
Signature · 1 line
2.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v2 1/3
#4 lore raw

Re: [Qemu-devel] [PATCH v2 1/3] xenfb: use the correct condition to avoid excessive looping

In reply to Wei Liu
Quoted 8 lines · Wei Liu

In commit ac0487e1 ("xenfb.c: avoid expensive loops when prod <= out_cons"), ">=" was used. In fact, a full ring is a legit state. Correct the test to use ">".

I'll add it to my queue

Quoted 24 lines
Cc Stefano Stabellini <[email protected]>
Cc Anthony Perard <[email protected]>

Backport candidate to our own tree.

---
 hw/display/xenfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/xenfb.c +1 -1
index 40b096a..9866dfd 100644
@@ -775,7 +775,7 @@ static void xenfb_handle_events(struct XenFB *xenfb)
 
     prod = page->out_prod;
     out_cons = page->out_cons;
-    if (prod - out_cons >= XENFB_OUT_RING_LEN) {
+    if (prod - out_cons > XENFB_OUT_RING_LEN) {
         return;
     }
     xen_rmb();		/* ensure we see ring contents up to prod */
Signature · 1 line
2.1.4
#5 lore raw

Re: [PATCH v2 1/3] xenfb: use the correct condition to avoid excessive looping

Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Wei Liu

In commit ac0487e1 ("xenfb.c: avoid expensive loops when prod <= out_cons"), ">=" was used. In fact, a full ring is a legit state. Correct the test to use ">".

Quoted 14 lines
Quoted 4 lines

I'll add it to my queue

Quoted 4 lines
Cc Stefano Stabellini <[email protected]>
Cc Anthony Perard <[email protected]>

Backport candidate to our own tree.

Patch backported to qemu-xen.git:master.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#6 lore raw

Re: [Qemu-devel] [PATCH v2 1/3] xenfb: use the correct condition to avoid excessive looping

In reply to Stefano Stabellini
Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Wei Liu

In commit ac0487e1 ("xenfb.c: avoid expensive loops when prod <= out_cons"), ">=" was used. In fact, a full ring is a legit state. Correct the test to use ">".

Quoted 14 lines
Quoted 4 lines

I'll add it to my queue

Quoted 4 lines
Cc Stefano Stabellini <[email protected]>
Cc Anthony Perard <[email protected]>

Backport candidate to our own tree.

Patch backported to qemu-xen.git:master.

Signature · 1 line
Anthony PERARD
author
#7 lore raw

Re: [PATCH v2 1/3] xenfb: use the correct condition to avoid excessive looping

Quoted 16 lines · Anthony PERARD
Quoted 15 lines · Stefano Stabellini
Quoted 8 lines · Wei Liu

In commit ac0487e1 ("xenfb.c: avoid expensive loops when prod <= out_cons"), ">=" was used. In fact, a full ring is a legit state. Correct the test to use ">".

I'll add it to my queue

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Cc Stefano Stabellini <[email protected]>
Cc Anthony Perard <[email protected]>

Backport candidate to our own tree.

Patch backported to qemu-xen.git:master.

I think you mean staging. :-)

Wei.

Quoted 2 lines
Signature · 1 line
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#8 lore raw

Re: [Qemu-devel] [PATCH v2 1/3] xenfb: use the correct condition to avoid excessive looping

In reply to Anthony PERARD
Quoted 16 lines · Anthony PERARD
Quoted 15 lines · Stefano Stabellini
Quoted 8 lines · Wei Liu

In commit ac0487e1 ("xenfb.c: avoid expensive loops when prod <= out_cons"), ">=" was used. In fact, a full ring is a legit state. Correct the test to use ">".

I'll add it to my queue

Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Cc Stefano Stabellini <[email protected]>
Cc Anthony Perard <[email protected]>

Backport candidate to our own tree.

Patch backported to qemu-xen.git:master.

I think you mean staging. :-)

Wei.

Quoted 2 lines
Signature · 1 line
Anthony PERARD
author
#9 lore raw

PATCH v2 2/3 xenfb: move xen_rmb to the correct location

In reply to Wei Liu

It should be placed before first time producer and consumer are used.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

Backport candidate to our own tree.

---
 hw/display/xenfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/xenfb.c +1 -1
index 9866dfd..7f4fad7 100644
@@ -775,10 +775,10 @@ static void xenfb_handle_events(struct XenFB *xenfb)
 
     prod = page->out_prod;
     out_cons = page->out_cons;
+    xen_rmb();
     if (prod - out_cons > XENFB_OUT_RING_LEN) {
         return;
     }
-    xen_rmb();		/* ensure we see ring contents up to prod */
     for (cons = out_cons; cons != prod; cons++) {
 	union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
         uint8_t type = event->type;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#10 lore raw

Re: [PATCH v2 2/3] xenfb: move xen_rmb to the correct location

Quoted 1 line · Wei Liu

It should be placed before first time producer and consumer are used.

This change isn't necessary and is confusing as this is not what this barrier is for.

The barrier needs to be between the load of prod and the load of the ring contents (there's even a comment that says this). This pairs with the corresponding write barrier between the store of the ring contents and the store of prod (in the other end).

David

Quoted 18 lines

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

Backport candidate to our own tree.

---
 hw/display/xenfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/xenfb.c +0 -0
index 9866dfd..7f4fad7 100644
@@ -775,10 +775,10 @@ static void xenfb_handle_events(struct XenFB *xenfb)
 

hw/display/xenfb.c static void xenfb_handle_events(struct XenFB *xenfb) · line 784

Quoted 10 lines
hw/display/xenfb.c +1 -1
     prod = page->out_prod;
     out_cons = page->out_cons;
+    xen_rmb();
     if (prod - out_cons > XENFB_OUT_RING_LEN) {
         return;
     }
-    xen_rmb();		/* ensure we see ring contents up to prod */
     for (cons = out_cons; cons != prod; cons++) {
 	union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
         uint8_t type = event->type;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#11 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH v2 2/3] xenfb: move xen_rmb to the correct location

In reply to Wei Liu
Quoted 1 line · Wei Liu

It should be placed before first time producer and consumer are used.

This change isn't necessary and is confusing as this is not what this barrier is for.

The barrier needs to be between the load of prod and the load of the ring contents (there's even a comment that says this). This pairs with the corresponding write barrier between the store of the ring contents and the store of prod (in the other end).

David

Quoted 28 lines

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

Backport candidate to our own tree.

---
 hw/display/xenfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/xenfb.c +1 -1
index 9866dfd..7f4fad7 100644
@@ -775,10 +775,10 @@ static void xenfb_handle_events(struct XenFB *xenfb)
 
     prod = page->out_prod;
     out_cons = page->out_cons;
+    xen_rmb();
     if (prod - out_cons > XENFB_OUT_RING_LEN) {
         return;
     }
-    xen_rmb();		/* ensure we see ring contents up to prod */
     for (cons = out_cons; cons != prod; cons++) {
 	union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
         uint8_t type = event->type;
#12 lore raw

Re: [PATCH v2 2/3] xenfb: move xen_rmb to the correct location

Quoted 9 lines · David Vrabel
Quoted 1 line · Wei Liu

It should be placed before first time producer and consumer are used.

This change isn't necessary and is confusing as this is not what this barrier is for.

The barrier needs to be between the load of prod and the load of the ring contents (there's even a comment that says this). This pairs with the corresponding write barrier between the store of the ring contents and the store of prod (in the other end).

Looking further, this code will compile to multiple reads of the page, because there is no ACCESS_ONCE(). This code is still vulnerable to XSA-155.

~Andrew

Quoted 19 lines

David

Quoted 16 lines

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

Backport candidate to our own tree.

---
 hw/display/xenfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/xenfb.c +0 -0
index 9866dfd..7f4fad7 100644
@@ -775,10 +775,10 @@ static void xenfb_handle_events(struct XenFB *xenfb)
 
Quoted 16 lines

hw/display/xenfb.c static void xenfb_handle_events(struct XenFB *xenfb) · line 784

Quoted 11 lines
hw/display/xenfb.c +1 -1
     prod = page->out_prod;
     out_cons = page->out_cons;
+    xen_rmb();
     if (prod - out_cons > XENFB_OUT_RING_LEN) {
         return;
     }
-    xen_rmb();		/* ensure we see ring contents up to prod */
     for (cons = out_cons; cons != prod; cons++) {
 	union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
         uint8_t type = event->type;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#13 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH v2 2/3] xenfb: move xen_rmb to the correct location

In reply to David Vrabel
Quoted 9 lines · David Vrabel
Quoted 1 line · Wei Liu

It should be placed before first time producer and consumer are used.

This change isn't necessary and is confusing as this is not what this barrier is for.

The barrier needs to be between the load of prod and the load of the ring contents (there's even a comment that says this). This pairs with the corresponding write barrier between the store of the ring contents and the store of prod (in the other end).

Looking further, this code will compile to multiple reads of the page, because there is no ACCESS_ONCE(). This code is still vulnerable to XSA-155.

~Andrew

Quoted 35 lines

David

Quoted 17 lines

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

Backport candidate to our own tree.

---
 hw/display/xenfb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/xenfb.c +0 -0
index 9866dfd..7f4fad7 100644
@@ -775,10 +775,10 @@ static void xenfb_handle_events(struct XenFB *xenfb)
 

hw/display/xenfb.c static void xenfb_handle_events(struct XenFB *xenfb) · line 784

Quoted 10 lines
hw/display/xenfb.c +1 -1
     prod = page->out_prod;
     out_cons = page->out_cons;
+    xen_rmb();
     if (prod - out_cons > XENFB_OUT_RING_LEN) {
         return;
     }
-    xen_rmb();		/* ensure we see ring contents up to prod */
     for (cons = out_cons; cons != prod; cons++) {
 	union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
         uint8_t type = event->type;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#14 lore raw

Re: [PATCH v2 2/3] xenfb: move xen_rmb to the correct location

Quoted 6 lines · Andrew Cooper
Quoted 5 lines · David Vrabel
Quoted 1 line · Wei Liu

It should be placed before first time producer and consumer are used.

This change isn't necessary and is confusing as this is not what this barrier is for.

Quoted 9 lines
Quoted 4 lines

The barrier needs to be between the load of prod and the load of the ring contents (there's even a comment that says this). This pairs with the corresponding write barrier between the store of the ring contents and the store of prod (in the other end).

Looking further, this code will compile to multiple reads of the page, because there is no ACCESS_ONCE(). This code is still vulnerable to XSA-155.

Oops, accidentally kicked over a can of worms. Should have just sent patch 1. :-)

Jokes aside, more time is needed to fix this properly. So maybe we should just upstream patch #1 first. Stefano? Anthony?

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#15 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH v2 2/3] xenfb: move xen_rmb to the correct location

In reply to Andrew Cooper
Quoted 6 lines · Andrew Cooper
Quoted 5 lines · David Vrabel
Quoted 1 line · Wei Liu

It should be placed before first time producer and consumer are used.

This change isn't necessary and is confusing as this is not what this barrier is for.

Quoted 9 lines
Quoted 4 lines

The barrier needs to be between the load of prod and the load of the ring contents (there's even a comment that says this). This pairs with the corresponding write barrier between the store of the ring contents and the store of prod (in the other end).

Looking further, this code will compile to multiple reads of the page, because there is no ACCESS_ONCE(). This code is still vulnerable to XSA-155.

Oops, accidentally kicked over a can of worms. Should have just sent patch 1. :-)

Jokes aside, more time is needed to fix this properly. So maybe we should just upstream patch #1 first. Stefano? Anthony?

Wei.

#16 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH v2 2/3] xenfb: move xen_rmb to the correct location

Quoted 7 lines · Wei Liu
Quoted 6 lines · Andrew Cooper
Quoted 5 lines · David Vrabel
Quoted 1 line · Wei Liu

It should be placed before first time producer and consumer are used.

This change isn't necessary and is confusing as this is not what this barrier is for.

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

The barrier needs to be between the load of prod and the load of the ring contents (there's even a comment that says this). This pairs with the corresponding write barrier between the store of the ring contents and the store of prod (in the other end).

Looking further, this code will compile to multiple reads of the page, because there is no ACCESS_ONCE(). This code is still vulnerable to XSA-155.

There is no ACCESS_ONCE in QEMU, the closest thing to it is atomic_read.

Quoted 5 lines

Oops, accidentally kicked over a can of worms. Should have just sent patch 1. :-)

Jokes aside, more time is needed to fix this properly. So maybe we should just upstream patch #1 first. Stefano? Anthony?

Sure

#17 lore raw

Re: [PATCH v2 2/3] xenfb: move xen_rmb to the correct location

In reply to Wei Liu
Quoted 7 lines · Wei Liu
Quoted 6 lines · Andrew Cooper
Quoted 5 lines · David Vrabel
Quoted 1 line · Wei Liu

It should be placed before first time producer and consumer are used.

This change isn't necessary and is confusing as this is not what this barrier is for.

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

The barrier needs to be between the load of prod and the load of the ring contents (there's even a comment that says this). This pairs with the corresponding write barrier between the store of the ring contents and the store of prod (in the other end).

Looking further, this code will compile to multiple reads of the page, because there is no ACCESS_ONCE(). This code is still vulnerable to XSA-155.

There is no ACCESS_ONCE in QEMU, the closest thing to it is atomic_read.

Quoted 5 lines

Oops, accidentally kicked over a can of worms. Should have just sent patch 1. :-)

Jokes aside, more time is needed to fix this properly. So maybe we should just upstream patch #1 first. Stefano? Anthony?

Sure

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

author
#18 lore raw

PATCH v2 3/3 xenfb: remove out_cons in xenfb_handle_events

In reply to Wei Liu

The variable out_cons was only used to temporarily hold the consumer index. Use cons directly to simplify code a bit.

No functional change introduced.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

---
 hw/display/xenfb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/display/xenfb.c +4 -4
index 7f4fad7..7d50efb 100644
@@ -770,16 +770,16 @@ static void xenfb_invalidate(void *opaque)
 
 static void xenfb_handle_events(struct XenFB *xenfb)
 {
-    uint32_t prod, cons, out_cons;
+    uint32_t prod, cons;
     struct xenfb_page *page = xenfb->c.page;
 
     prod = page->out_prod;
-    out_cons = page->out_cons;
+    cons = page->out_cons;
     xen_rmb();
-    if (prod - out_cons > XENFB_OUT_RING_LEN) {
+    if (prod - cons > XENFB_OUT_RING_LEN) {
         return;
     }
-    for (cons = out_cons; cons != prod; cons++) {
+    for ( ; cons != prod; cons++) {
 	union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
         uint8_t type = event->type;
 	int x, y, w, h;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
author
#19 lore raw

PATCH v2 3/3 xenfb: remove out_cons in xenfb_handle_events

In reply to Wei Liu

The variable out_cons was only used to temporarily hold the consumer index. Use cons directly to simplify code a bit.

No functional change introduced.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Anthony Perard <[email protected]>

---
 hw/display/xenfb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/display/xenfb.c +4 -4
index 7f4fad7..7d50efb 100644
@@ -770,16 +770,16 @@ static void xenfb_invalidate(void *opaque)
 
 static void xenfb_handle_events(struct XenFB *xenfb)
 {
-    uint32_t prod, cons, out_cons;
+    uint32_t prod, cons;
     struct xenfb_page *page = xenfb->c.page;
 
     prod = page->out_prod;
-    out_cons = page->out_cons;
+    cons = page->out_cons;
     xen_rmb();
-    if (prod - out_cons > XENFB_OUT_RING_LEN) {
+    if (prod - cons > XENFB_OUT_RING_LEN) {
         return;
     }
-    for (cons = out_cons; cons != prod; cons++) {
+    for ( ; cons != prod; cons++) {
 	union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
         uint8_t type = event->type;
 	int x, y, w, h;
Signature · 1 line
2.1.4
Acked-by on v2 3/3
#20 lore raw

Re: [PATCH v2 3/3] xenfb: remove out_cons in xenfb_handle_events

Quoted 6 lines · Wei Liu

The variable out_cons was only used to temporarily hold the consumer index. Use cons directly to simplify code a bit.

No functional change introduced.

Except for the fact that it is based on patch #2, which is wrong, this looks OK.

Quoted 34 lines
Cc Stefano Stabellini <[email protected]>
Cc Anthony Perard <[email protected]>
---
 hw/display/xenfb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/display/xenfb.c +4 -4
index 7f4fad7..7d50efb 100644
@@ -770,16 +770,16 @@ static void xenfb_invalidate(void *opaque)
 
 static void xenfb_handle_events(struct XenFB *xenfb)
 {
-    uint32_t prod, cons, out_cons;
+    uint32_t prod, cons;
     struct xenfb_page *page = xenfb->c.page;
 
     prod = page->out_prod;
-    out_cons = page->out_cons;
+    cons = page->out_cons;
     xen_rmb();
-    if (prod - out_cons > XENFB_OUT_RING_LEN) {
+    if (prod - cons > XENFB_OUT_RING_LEN) {
         return;
     }
-    for (cons = out_cons; cons != prod; cons++) {
+    for ( ; cons != prod; cons++) {
 	union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
         uint8_t type = event->type;
 	int x, y, w, h;
Signature · 1 line
2.1.4

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v2 3/3
#21 lore raw

Re: [Qemu-devel] [PATCH v2 3/3] xenfb: remove out_cons in xenfb_handle_events

In reply to Wei Liu
Quoted 6 lines · Wei Liu

The variable out_cons was only used to temporarily hold the consumer index. Use cons directly to simplify code a bit.

No functional change introduced.

Except for the fact that it is based on patch #2, which is wrong, this looks OK.

Quoted 34 lines
Cc Stefano Stabellini <[email protected]>
Cc Anthony Perard <[email protected]>
---
 hw/display/xenfb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/display/xenfb.c +4 -4
index 7f4fad7..7d50efb 100644
@@ -770,16 +770,16 @@ static void xenfb_invalidate(void *opaque)
 
 static void xenfb_handle_events(struct XenFB *xenfb)
 {
-    uint32_t prod, cons, out_cons;
+    uint32_t prod, cons;
     struct xenfb_page *page = xenfb->c.page;
 
     prod = page->out_prod;
-    out_cons = page->out_cons;
+    cons = page->out_cons;
     xen_rmb();
-    if (prod - out_cons > XENFB_OUT_RING_LEN) {
+    if (prod - cons > XENFB_OUT_RING_LEN) {
         return;
     }
-    for (cons = out_cons; cons != prod; cons++) {
+    for ( ; cons != prod; cons++) {
 	union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
         uint8_t type = event->type;
 	int x, y, w, h;
Signature · 1 line
2.1.4