xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libvchan: Make raw_get_{data_ready, buffer_space} match
@ 2014-05-16 20:48 Jason Andryuk
  2014-05-19 11:31 ` Ian Jackson
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Andryuk @ 2014-05-16 20:48 UTC (permalink / raw)
  To: xen-devel; +Cc: Jason Andryuk, Ian Jackson, Ian Campbell, Stefano Stabellini

For writing into a vchan, raw_get_buffer_space used >, allowing the full
ring size to be written.  On the read side, raw_get_data_ready compared
the ring size with >=.  This mismatch means a completely filled buffer
cannot be read.  Fix this by making the size checks identical.

Signed-off-by: Jason Andryuk <andryuk@aero.org>
---
 tools/libvchan/io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libvchan/io.c b/tools/libvchan/io.c
index 804c63c..6e6e239 100644
--- a/tools/libvchan/io.c
+++ b/tools/libvchan/io.c
@@ -118,7 +118,7 @@ static inline int send_notify(struct libxenvchan *ctrl, uint8_t bit)
 static inline int raw_get_data_ready(struct libxenvchan *ctrl)
 {
 	uint32_t ready = rd_prod(ctrl) - rd_cons(ctrl);
-	if (ready >= rd_ring_size(ctrl))
+	if (ready > rd_ring_size(ctrl))
 		/* We have no way to return errors.  Locking up the ring is
 		 * better than the alternatives. */
 		return 0;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] libvchan: Make raw_get_{data_ready, buffer_space} match
  2014-05-16 20:48 [PATCH] libvchan: Make raw_get_{data_ready, buffer_space} match Jason Andryuk
@ 2014-05-19 11:31 ` Ian Jackson
  2014-05-19 20:21   ` Daniel De Graaf
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Jackson @ 2014-05-19 11:31 UTC (permalink / raw)
  To: Jason Andryuk
  Cc: Daniel De Graaf, Stefano Stabellini, Ian Campbell, Rafal Wojtczuk,
	xen-devel

Jason Andryuk writes ("[PATCH] libvchan: Make raw_get_{data_ready,buffer_space} match"):
> For writing into a vchan, raw_get_buffer_space used >, allowing the full
> ring size to be written.  On the read side, raw_get_data_ready compared
> the ring size with >=.  This mismatch means a completely filled buffer
> cannot be read.  Fix this by making the size checks identical.

This seems right to me, but I have CC'd the authors of this area of
code to give them a chance to comment.

Thanks,
Ian.

> Signed-off-by: Jason Andryuk <andryuk@aero.org>
> ---
>  tools/libvchan/io.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/libvchan/io.c b/tools/libvchan/io.c
> index 804c63c..6e6e239 100644
> --- a/tools/libvchan/io.c
> +++ b/tools/libvchan/io.c
> @@ -118,7 +118,7 @@ static inline int send_notify(struct libxenvchan *ctrl, uint8_t bit)
>  static inline int raw_get_data_ready(struct libxenvchan *ctrl)
>  {
>  	uint32_t ready = rd_prod(ctrl) - rd_cons(ctrl);
> -	if (ready >= rd_ring_size(ctrl))
> +	if (ready > rd_ring_size(ctrl))
>  		/* We have no way to return errors.  Locking up the ring is
>  		 * better than the alternatives. */
>  		return 0;
> -- 
> 1.8.3.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libvchan: Make raw_get_{data_ready, buffer_space} match
  2014-05-19 11:31 ` Ian Jackson
@ 2014-05-19 20:21   ` Daniel De Graaf
  2014-05-21 12:01     ` Ian Campbell
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel De Graaf @ 2014-05-19 20:21 UTC (permalink / raw)
  To: Ian Jackson, Jason Andryuk
  Cc: Stefano Stabellini, Ian Campbell, Rafal Wojtczuk, xen-devel

On 05/19/2014 07:31 AM, Ian Jackson wrote:
> Jason Andryuk writes ("[PATCH] libvchan: Make raw_get_{data_ready,buffer_space} match"):
>> For writing into a vchan, raw_get_buffer_space used >, allowing the full
>> ring size to be written.  On the read side, raw_get_data_ready compared
>> the ring size with >=.  This mismatch means a completely filled buffer
>> cannot be read.  Fix this by making the size checks identical.
>
> This seems right to me, but I have CC'd the authors of this area of
> code to give them a chance to comment.
>
> Thanks,
> Ian.

This also looks correct to me.

>> Signed-off-by: Jason Andryuk <andryuk@aero.org>
>> ---
>>   tools/libvchan/io.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/libvchan/io.c b/tools/libvchan/io.c
>> index 804c63c..6e6e239 100644
>> --- a/tools/libvchan/io.c
>> +++ b/tools/libvchan/io.c
>> @@ -118,7 +118,7 @@ static inline int send_notify(struct libxenvchan *ctrl, uint8_t bit)
>>   static inline int raw_get_data_ready(struct libxenvchan *ctrl)
>>   {
>>   	uint32_t ready = rd_prod(ctrl) - rd_cons(ctrl);
>> -	if (ready >= rd_ring_size(ctrl))
>> +	if (ready > rd_ring_size(ctrl))
>>   		/* We have no way to return errors.  Locking up the ring is
>>   		 * better than the alternatives. */
>>   		return 0;
>> --
>> 1.8.3.1
>>
>
>


-- 
Daniel De Graaf
National Security Agency

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libvchan: Make raw_get_{data_ready, buffer_space} match
  2014-05-19 20:21   ` Daniel De Graaf
@ 2014-05-21 12:01     ` Ian Campbell
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Campbell @ 2014-05-21 12:01 UTC (permalink / raw)
  To: Daniel De Graaf
  Cc: Jason Andryuk, Ian Jackson, Rafal Wojtczuk, Stefano Stabellini,
	xen-devel

On Mon, 2014-05-19 at 16:21 -0400, Daniel De Graaf wrote:
> On 05/19/2014 07:31 AM, Ian Jackson wrote:
> > Jason Andryuk writes ("[PATCH] libvchan: Make raw_get_{data_ready,buffer_space} match"):
> >> For writing into a vchan, raw_get_buffer_space used >, allowing the full
> >> ring size to be written.  On the read side, raw_get_data_ready compared
> >> the ring size with >=.  This mismatch means a completely filled buffer
> >> cannot be read.  Fix this by making the size checks identical.
> >
> > This seems right to me, but I have CC'd the authors of this area of
> > code to give them a chance to comment.
> >
> > Thanks,
> > Ian.
> 
> This also looks correct to me.

Can I take that as an Acked-by frm the both of you?

Acked-by: Ian Campbell <ian.campbell@citrix.com>

Ian.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-05-21 12:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-16 20:48 [PATCH] libvchan: Make raw_get_{data_ready, buffer_space} match Jason Andryuk
2014-05-19 11:31 ` Ian Jackson
2014-05-19 20:21   ` Daniel De Graaf
2014-05-21 12:01     ` Ian Campbell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).