Xen-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [Xen-devel] [PATCH] xen/console: Fix build when CONFIG_DEBUG_TRACE=y
@ 2019-08-19 18:01 Julien Grall
  2019-08-19 18:04 ` Andrew Cooper
  0 siblings, 1 reply; 5+ messages in thread
From: Julien Grall @ 2019-08-19 18:01 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Julien Grall, Jan Beulich

Commit b5e6e1ee8da "xen/console: Don't treat NUL character as the end
of the buffer" extended sercon_puts to take the number of character
to print in argument.

Sadly, a couple of couple of the callers in debugtrace_dump_worker()
were not converted. This result to a build failure when enabling
CONFIG_DEBUG_TRACE.

Spotted by Travis using randconfig
Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 xen/drivers/char/console.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 2c14c2ca73..924d4971ca 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -1185,11 +1185,12 @@ static void debugtrace_dump_worker(void)
 
     /* Print oldest portion of the ring. */
     ASSERT(debugtrace_buf[debugtrace_bytes - 1] == 0);
-    sercon_puts(&debugtrace_buf[debugtrace_prd]);
+    sercon_puts(&debugtrace_buf[debugtrace_prd],
+                strlen(&debugtrace_buf[debugtrace_prd]));
 
     /* Print youngest portion of the ring. */
     debugtrace_buf[debugtrace_prd] = '\0';
-    sercon_puts(&debugtrace_buf[0]);
+    sercon_puts(&debugtrace_buf[0], debugtrace_prd);
 
     memset(debugtrace_buf, '\0', debugtrace_bytes);
 
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] xen/console: Fix build when CONFIG_DEBUG_TRACE=y
  2019-08-19 18:01 [Xen-devel] [PATCH] xen/console: Fix build when CONFIG_DEBUG_TRACE=y Julien Grall
@ 2019-08-19 18:04 ` Andrew Cooper
  2019-08-19 18:37   ` Julien Grall
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2019-08-19 18:04 UTC (permalink / raw)
  To: Julien Grall, xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Ian Jackson, Tim Deegan, Jan Beulich

On 19/08/2019 19:01, Julien Grall wrote:
> Commit b5e6e1ee8da "xen/console: Don't treat NUL character as the end
> of the buffer" extended sercon_puts to take the number of character
> to print in argument.
>
> Sadly, a couple of couple of the callers in debugtrace_dump_worker()
> were not converted. This result to a build failure when enabling
> CONFIG_DEBUG_TRACE.
>
> Spotted by Travis using randconfig
> Signed-off-by: Julien Grall <julien.grall@arm.com>
> ---
>  xen/drivers/char/console.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
> index 2c14c2ca73..924d4971ca 100644
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -1185,11 +1185,12 @@ static void debugtrace_dump_worker(void)
>  
>      /* Print oldest portion of the ring. */
>      ASSERT(debugtrace_buf[debugtrace_bytes - 1] == 0);
> -    sercon_puts(&debugtrace_buf[debugtrace_prd]);
> +    sercon_puts(&debugtrace_buf[debugtrace_prd],
> +                strlen(&debugtrace_buf[debugtrace_prd]));

Isn't this just debugtrace_bytes - debugtrace_prd - 1 ?

~Andrew

>  
>      /* Print youngest portion of the ring. */
>      debugtrace_buf[debugtrace_prd] = '\0';
> -    sercon_puts(&debugtrace_buf[0]);
> +    sercon_puts(&debugtrace_buf[0], debugtrace_prd);
>  
>      memset(debugtrace_buf, '\0', debugtrace_bytes);
>  


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] xen/console: Fix build when CONFIG_DEBUG_TRACE=y
  2019-08-19 18:04 ` Andrew Cooper
@ 2019-08-19 18:37   ` Julien Grall
  2019-08-20 13:12     ` Andrew Cooper
  0 siblings, 1 reply; 5+ messages in thread
From: Julien Grall @ 2019-08-19 18:37 UTC (permalink / raw)
  To: Andrew Cooper, xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Ian Jackson, Tim Deegan, Jan Beulich

Hi Andrew,

On 8/19/19 7:04 PM, Andrew Cooper wrote:
> On 19/08/2019 19:01, Julien Grall wrote:
>> Commit b5e6e1ee8da "xen/console: Don't treat NUL character as the end
>> of the buffer" extended sercon_puts to take the number of character
>> to print in argument.
>>
>> Sadly, a couple of couple of the callers in debugtrace_dump_worker()
>> were not converted. This result to a build failure when enabling
>> CONFIG_DEBUG_TRACE.
>>
>> Spotted by Travis using randconfig
>> Signed-off-by: Julien Grall <julien.grall@arm.com>
>> ---
>>   xen/drivers/char/console.c | 5 +++--
>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
>> index 2c14c2ca73..924d4971ca 100644
>> --- a/xen/drivers/char/console.c
>> +++ b/xen/drivers/char/console.c
>> @@ -1185,11 +1185,12 @@ static void debugtrace_dump_worker(void)
>>   
>>       /* Print oldest portion of the ring. */
>>       ASSERT(debugtrace_buf[debugtrace_bytes - 1] == 0);
>> -    sercon_puts(&debugtrace_buf[debugtrace_prd]);
>> +    sercon_puts(&debugtrace_buf[debugtrace_prd],
>> +                strlen(&debugtrace_buf[debugtrace_prd]));
> 
> Isn't this just debugtrace_bytes - debugtrace_prd - 1 ?

I tried and it resulted to print a lot of @^ on the console. This is 
because the ring may not be full.

So the portion between debugtrace_prd and debugtrace_bytes will be full 
of zero.

Looking at the code again, I think this portion and either be full of 
zero character or full of non-zero character. In other word, a mix would 
not be possible. So how about:

if ( debugtrace_buf[debugtrace_prd] != '\0' )
   sercon_puts(&debugtrace_buf[debugtrace_prd],
               debugtrace_bytes - debugtrace_prd - 1);


Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] xen/console: Fix build when CONFIG_DEBUG_TRACE=y
  2019-08-19 18:37   ` Julien Grall
@ 2019-08-20 13:12     ` Andrew Cooper
  2019-08-21 17:30       ` Julien Grall
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2019-08-20 13:12 UTC (permalink / raw)
  To: Julien Grall, xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Ian Jackson, Tim Deegan, Jan Beulich

On 19/08/2019 19:37, Julien Grall wrote:
> Hi Andrew,
>
> On 8/19/19 7:04 PM, Andrew Cooper wrote:
>> On 19/08/2019 19:01, Julien Grall wrote:
>>> Commit b5e6e1ee8da "xen/console: Don't treat NUL character as the end
>>> of the buffer" extended sercon_puts to take the number of character
>>> to print in argument.
>>>
>>> Sadly, a couple of couple of the callers in debugtrace_dump_worker()
>>> were not converted. This result to a build failure when enabling
>>> CONFIG_DEBUG_TRACE.
>>>
>>> Spotted by Travis using randconfig
>>> Signed-off-by: Julien Grall <julien.grall@arm.com>
>>> ---
>>>   xen/drivers/char/console.c | 5 +++--
>>>   1 file changed, 3 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
>>> index 2c14c2ca73..924d4971ca 100644
>>> --- a/xen/drivers/char/console.c
>>> +++ b/xen/drivers/char/console.c
>>> @@ -1185,11 +1185,12 @@ static void debugtrace_dump_worker(void)
>>>         /* Print oldest portion of the ring. */
>>>       ASSERT(debugtrace_buf[debugtrace_bytes - 1] == 0);
>>> -    sercon_puts(&debugtrace_buf[debugtrace_prd]);
>>> +    sercon_puts(&debugtrace_buf[debugtrace_prd],
>>> +                strlen(&debugtrace_buf[debugtrace_prd]));
>>
>> Isn't this just debugtrace_bytes - debugtrace_prd - 1 ?
>
> I tried and it resulted to print a lot of @^ on the console. This is
> because the ring may not be full.
>
> So the portion between debugtrace_prd and debugtrace_bytes will be
> full of zero.
>
> Looking at the code again, I think this portion and either be full of
> zero character or full of non-zero character. In other word, a mix
> would not be possible. So how about:
>
> if ( debugtrace_buf[debugtrace_prd] != '\0' )
>   sercon_puts(&debugtrace_buf[debugtrace_prd],
>               debugtrace_bytes - debugtrace_prd - 1);

LGTM.  Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] xen/console: Fix build when CONFIG_DEBUG_TRACE=y
  2019-08-20 13:12     ` Andrew Cooper
@ 2019-08-21 17:30       ` Julien Grall
  0 siblings, 0 replies; 5+ messages in thread
From: Julien Grall @ 2019-08-21 17:30 UTC (permalink / raw)
  To: Andrew Cooper, xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Ian Jackson, Tim Deegan, Jan Beulich

Hi,

On 20/08/2019 14:12, Andrew Cooper wrote:
> On 19/08/2019 19:37, Julien Grall wrote:
>> Hi Andrew,
>>
>> On 8/19/19 7:04 PM, Andrew Cooper wrote:
>>> On 19/08/2019 19:01, Julien Grall wrote:
>>>> Commit b5e6e1ee8da "xen/console: Don't treat NUL character as the end
>>>> of the buffer" extended sercon_puts to take the number of character
>>>> to print in argument.
>>>>
>>>> Sadly, a couple of couple of the callers in debugtrace_dump_worker()
>>>> were not converted. This result to a build failure when enabling
>>>> CONFIG_DEBUG_TRACE.
>>>>
>>>> Spotted by Travis using randconfig
>>>> Signed-off-by: Julien Grall <julien.grall@arm.com>
>>>> ---
>>>>    xen/drivers/char/console.c | 5 +++--
>>>>    1 file changed, 3 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
>>>> index 2c14c2ca73..924d4971ca 100644
>>>> --- a/xen/drivers/char/console.c
>>>> +++ b/xen/drivers/char/console.c
>>>> @@ -1185,11 +1185,12 @@ static void debugtrace_dump_worker(void)
>>>>          /* Print oldest portion of the ring. */
>>>>        ASSERT(debugtrace_buf[debugtrace_bytes - 1] == 0);
>>>> -    sercon_puts(&debugtrace_buf[debugtrace_prd]);
>>>> +    sercon_puts(&debugtrace_buf[debugtrace_prd],
>>>> +                strlen(&debugtrace_buf[debugtrace_prd]));
>>>
>>> Isn't this just debugtrace_bytes - debugtrace_prd - 1 ?
>>
>> I tried and it resulted to print a lot of @^ on the console. This is
>> because the ring may not be full.
>>
>> So the portion between debugtrace_prd and debugtrace_bytes will be
>> full of zero.
>>
>> Looking at the code again, I think this portion and either be full of
>> zero character or full of non-zero character. In other word, a mix
>> would not be possible. So how about:
>>
>> if ( debugtrace_buf[debugtrace_prd] != '\0' )
>>    sercon_puts(&debugtrace_buf[debugtrace_prd],
>>                debugtrace_bytes - debugtrace_prd - 1);
> 
> LGTM.  Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>

Thank you! I will update the patch and commit it.

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-19 18:01 [Xen-devel] [PATCH] xen/console: Fix build when CONFIG_DEBUG_TRACE=y Julien Grall
2019-08-19 18:04 ` Andrew Cooper
2019-08-19 18:37   ` Julien Grall
2019-08-20 13:12     ` Andrew Cooper
2019-08-21 17:30       ` Julien Grall

Xen-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/xen-devel/0 xen-devel/git/0.git
	git clone --mirror https://lore.kernel.org/xen-devel/1 xen-devel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 xen-devel xen-devel/ https://lore.kernel.org/xen-devel \
		xen-devel@lists.xenproject.org xen-devel@archiver.kernel.org
	public-inbox-index xen-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.xenproject.lists.xen-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox