* [PATCH] Revert "hw/char/pl011: Warn when using disabled receiver"
@ 2025-03-11 15:37 Paolo Bonzini
2025-03-12 13:36 ` Peter Maydell
0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2025-03-11 15:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Peter Maydell
The guest does not control whether characters are sent on the UART.
Sending them before the guest happens to boot will now result in a
"guest error" log entry that is only because of timing, even if the
guest _would_ later setup the receiver correctly.
This reverts commit abf2b6a028670bd2890bb3aee7e103fe53e4b0df, apart
from adding the comment.
Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/char/pl011.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/hw/char/pl011.c b/hw/char/pl011.c
index 23a9db8c57c..efca8baecd7 100644
--- a/hw/char/pl011.c
+++ b/hw/char/pl011.c
@@ -85,7 +85,6 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr)
#define CR_OUT1 (1 << 12)
#define CR_RTS (1 << 11)
#define CR_DTR (1 << 10)
-#define CR_RXE (1 << 9)
#define CR_TXE (1 << 8)
#define CR_LBE (1 << 7)
#define CR_UARTEN (1 << 0)
@@ -490,16 +489,9 @@ static int pl011_can_receive(void *opaque)
unsigned fifo_depth = pl011_get_fifo_depth(s);
unsigned fifo_available = fifo_depth - s->read_count;
- if (!(s->cr & CR_UARTEN)) {
- qemu_log_mask(LOG_GUEST_ERROR,
- "PL011 receiving data on disabled UART\n");
- }
- if (!(s->cr & CR_RXE)) {
- qemu_log_mask(LOG_GUEST_ERROR,
- "PL011 receiving data on disabled RX UART\n");
- }
+ /* Should check enable and return 0? */
+
trace_pl011_can_receive(s->lcr, s->read_count, fifo_depth, fifo_available);
-
return fifo_available;
}
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Revert "hw/char/pl011: Warn when using disabled receiver"
2025-03-11 15:37 [PATCH] Revert "hw/char/pl011: Warn when using disabled receiver" Paolo Bonzini
@ 2025-03-12 13:36 ` Peter Maydell
2025-03-12 13:43 ` Peter Maydell
2025-03-12 14:22 ` Peter Maydell
0 siblings, 2 replies; 5+ messages in thread
From: Peter Maydell @ 2025-03-12 13:36 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, Philippe Mathieu-Daudé
On Tue, 11 Mar 2025 at 15:37, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> The guest does not control whether characters are sent on the UART.
> Sending them before the guest happens to boot will now result in a
> "guest error" log entry that is only because of timing, even if the
> guest _would_ later setup the receiver correctly.
>
> This reverts commit abf2b6a028670bd2890bb3aee7e103fe53e4b0df, apart
> from adding the comment.
>
> Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
> Cc: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/char/pl011.c | 12 ++----------
> 1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/hw/char/pl011.c b/hw/char/pl011.c
> index 23a9db8c57c..efca8baecd7 100644
> --- a/hw/char/pl011.c
> +++ b/hw/char/pl011.c
> @@ -85,7 +85,6 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr)
> #define CR_OUT1 (1 << 12)
> #define CR_RTS (1 << 11)
> #define CR_DTR (1 << 10)
> -#define CR_RXE (1 << 9)
> #define CR_TXE (1 << 8)
> #define CR_LBE (1 << 7)
> #define CR_UARTEN (1 << 0)
> @@ -490,16 +489,9 @@ static int pl011_can_receive(void *opaque)
> unsigned fifo_depth = pl011_get_fifo_depth(s);
> unsigned fifo_available = fifo_depth - s->read_count;
>
> - if (!(s->cr & CR_UARTEN)) {
> - qemu_log_mask(LOG_GUEST_ERROR,
> - "PL011 receiving data on disabled UART\n");
> - }
> - if (!(s->cr & CR_RXE)) {
> - qemu_log_mask(LOG_GUEST_ERROR,
> - "PL011 receiving data on disabled RX UART\n");
> - }
> + /* Should check enable and return 0? */
We decided deliberately not to check the enable and return 0
here, as described in the commit message of abf2b6a028670bd:
we think there's too likely to be existing works-on-QEMU code
out there that doesn't ever set the enable bits.
Otherwise, yes, agreed with the revert.
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Revert "hw/char/pl011: Warn when using disabled receiver"
2025-03-12 13:36 ` Peter Maydell
@ 2025-03-12 13:43 ` Peter Maydell
2025-03-12 14:28 ` Philippe Mathieu-Daudé
2025-03-12 14:22 ` Peter Maydell
1 sibling, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2025-03-12 13:43 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, Philippe Mathieu-Daudé
On Wed, 12 Mar 2025 at 13:36, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Tue, 11 Mar 2025 at 15:37, Paolo Bonzini <pbonzini@redhat.com> wrote:
> >
> > The guest does not control whether characters are sent on the UART.
> > Sending them before the guest happens to boot will now result in a
> > "guest error" log entry that is only because of timing, even if the
> > guest _would_ later setup the receiver correctly.
> >
> > This reverts commit abf2b6a028670bd2890bb3aee7e103fe53e4b0df, apart
> > from adding the comment.
> >
> > Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
> > Cc: Peter Maydell <peter.maydell@linaro.org>
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > ---
> > hw/char/pl011.c | 12 ++----------
> > 1 file changed, 2 insertions(+), 10 deletions(-)
> >
> > diff --git a/hw/char/pl011.c b/hw/char/pl011.c
> > index 23a9db8c57c..efca8baecd7 100644
> > --- a/hw/char/pl011.c
> > +++ b/hw/char/pl011.c
> > @@ -85,7 +85,6 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr)
> > #define CR_OUT1 (1 << 12)
> > #define CR_RTS (1 << 11)
> > #define CR_DTR (1 << 10)
> > -#define CR_RXE (1 << 9)
> > #define CR_TXE (1 << 8)
> > #define CR_LBE (1 << 7)
> > #define CR_UARTEN (1 << 0)
> > @@ -490,16 +489,9 @@ static int pl011_can_receive(void *opaque)
> > unsigned fifo_depth = pl011_get_fifo_depth(s);
> > unsigned fifo_available = fifo_depth - s->read_count;
> >
> > - if (!(s->cr & CR_UARTEN)) {
> > - qemu_log_mask(LOG_GUEST_ERROR,
> > - "PL011 receiving data on disabled UART\n");
> > - }
> > - if (!(s->cr & CR_RXE)) {
> > - qemu_log_mask(LOG_GUEST_ERROR,
> > - "PL011 receiving data on disabled RX UART\n");
> > - }
> > + /* Should check enable and return 0? */
>
> We decided deliberately not to check the enable and return 0
> here, as described in the commit message of abf2b6a028670bd:
> we think there's too likely to be existing works-on-QEMU code
> out there that doesn't ever set the enable bits.
>
> Otherwise, yes, agreed with the revert.
Oh, and I just realized that the right place to diagnose
"guest didn't enable the UART" would be when it reads/writes
the data register while the enable bits are clear.
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Revert "hw/char/pl011: Warn when using disabled receiver"
2025-03-12 13:36 ` Peter Maydell
2025-03-12 13:43 ` Peter Maydell
@ 2025-03-12 14:22 ` Peter Maydell
1 sibling, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2025-03-12 14:22 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, Philippe Mathieu-Daudé
On Wed, 12 Mar 2025 at 13:36, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Tue, 11 Mar 2025 at 15:37, Paolo Bonzini <pbonzini@redhat.com> wrote:
> >
> > The guest does not control whether characters are sent on the UART.
> > Sending them before the guest happens to boot will now result in a
> > "guest error" log entry that is only because of timing, even if the
> > guest _would_ later setup the receiver correctly.
> >
> > This reverts commit abf2b6a028670bd2890bb3aee7e103fe53e4b0df, apart
> > from adding the comment.
> >
> > Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
> > Cc: Peter Maydell <peter.maydell@linaro.org>
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > ---
> > hw/char/pl011.c | 12 ++----------
> > 1 file changed, 2 insertions(+), 10 deletions(-)
> >
> > diff --git a/hw/char/pl011.c b/hw/char/pl011.c
> > index 23a9db8c57c..efca8baecd7 100644
> > --- a/hw/char/pl011.c
> > +++ b/hw/char/pl011.c
> > @@ -85,7 +85,6 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr)
> > #define CR_OUT1 (1 << 12)
> > #define CR_RTS (1 << 11)
> > #define CR_DTR (1 << 10)
> > -#define CR_RXE (1 << 9)
> > #define CR_TXE (1 << 8)
> > #define CR_LBE (1 << 7)
> > #define CR_UARTEN (1 << 0)
> > @@ -490,16 +489,9 @@ static int pl011_can_receive(void *opaque)
> > unsigned fifo_depth = pl011_get_fifo_depth(s);
> > unsigned fifo_available = fifo_depth - s->read_count;
> >
> > - if (!(s->cr & CR_UARTEN)) {
> > - qemu_log_mask(LOG_GUEST_ERROR,
> > - "PL011 receiving data on disabled UART\n");
> > - }
> > - if (!(s->cr & CR_RXE)) {
> > - qemu_log_mask(LOG_GUEST_ERROR,
> > - "PL011 receiving data on disabled RX UART\n");
> > - }
> > + /* Should check enable and return 0? */
>
> We decided deliberately not to check the enable and return 0
> here, as described in the commit message of abf2b6a028670bd:
> we think there's too likely to be existing works-on-QEMU code
> out there that doesn't ever set the enable bits.
>
> Otherwise, yes, agreed with the revert.
I've applied this to target-arm.next with the comment expanded
(and I left the define of CR_RXE in too):
+ /*
+ * In theory we should check the UART and RX enable bits here and
+ * return 0 if they are not set (so the guest can't receive data
+ * until you have enabled the UART). In practice we suspect there
+ * is at least some guest code out there which has been tested only
+ * on QEMU and which never bothers to enable the UART because we
+ * historically never enforced that. So we effectively keep the
+ * UART continuously enabled regardless of the enable bits.
+ */
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Revert "hw/char/pl011: Warn when using disabled receiver"
2025-03-12 13:43 ` Peter Maydell
@ 2025-03-12 14:28 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-03-12 14:28 UTC (permalink / raw)
To: Peter Maydell, Paolo Bonzini; +Cc: qemu-devel
On 12/3/25 14:43, Peter Maydell wrote:
> On Wed, 12 Mar 2025 at 13:36, Peter Maydell <peter.maydell@linaro.org> wrote:
>>
>> On Tue, 11 Mar 2025 at 15:37, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>>
>>> The guest does not control whether characters are sent on the UART.
>>> Sending them before the guest happens to boot will now result in a
>>> "guest error" log entry that is only because of timing, even if the
>>> guest _would_ later setup the receiver correctly.
>>>
>>> This reverts commit abf2b6a028670bd2890bb3aee7e103fe53e4b0df, apart
>>> from adding the comment.
>>>
>>> Cc: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> Cc: Peter Maydell <peter.maydell@linaro.org>
>>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>>> ---
>>> hw/char/pl011.c | 12 ++----------
>>> 1 file changed, 2 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/hw/char/pl011.c b/hw/char/pl011.c
>>> index 23a9db8c57c..efca8baecd7 100644
>>> --- a/hw/char/pl011.c
>>> +++ b/hw/char/pl011.c
>>> @@ -85,7 +85,6 @@ DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr)
>>> #define CR_OUT1 (1 << 12)
>>> #define CR_RTS (1 << 11)
>>> #define CR_DTR (1 << 10)
>>> -#define CR_RXE (1 << 9)
>>> #define CR_TXE (1 << 8)
>>> #define CR_LBE (1 << 7)
>>> #define CR_UARTEN (1 << 0)
>>> @@ -490,16 +489,9 @@ static int pl011_can_receive(void *opaque)
>>> unsigned fifo_depth = pl011_get_fifo_depth(s);
>>> unsigned fifo_available = fifo_depth - s->read_count;
>>>
>>> - if (!(s->cr & CR_UARTEN)) {
>>> - qemu_log_mask(LOG_GUEST_ERROR,
>>> - "PL011 receiving data on disabled UART\n");
>>> - }
>>> - if (!(s->cr & CR_RXE)) {
>>> - qemu_log_mask(LOG_GUEST_ERROR,
>>> - "PL011 receiving data on disabled RX UART\n");
>>> - }
>>> + /* Should check enable and return 0? */
>>
>> We decided deliberately not to check the enable and return 0
>> here, as described in the commit message of abf2b6a028670bd:
>> we think there's too likely to be existing works-on-QEMU code
>> out there that doesn't ever set the enable bits.
>>
>> Otherwise, yes, agreed with the revert.
>
> Oh, and I just realized that the right place to diagnose
> "guest didn't enable the UART" would be when it reads/writes
> the data register while the enable bits are clear.
Doh, sorry. I wonder how I ended putting this code here... Since I
rebased this a lot, maybe something went wrong. Anyway, I'll post
a fix.
Regards,
Phil.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-03-12 14:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-11 15:37 [PATCH] Revert "hw/char/pl011: Warn when using disabled receiver" Paolo Bonzini
2025-03-12 13:36 ` Peter Maydell
2025-03-12 13:43 ` Peter Maydell
2025-03-12 14:28 ` Philippe Mathieu-Daudé
2025-03-12 14:22 ` Peter Maydell
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).