From: Julien Grall <julien.grall@arm.com>
To: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Cc: xen-devel@lists.xenproject.org, nd@arm.com,
Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [PATCH 01/11] xen/arm: vpl011: Add pl011 uart emulation in Xen
Date: Tue, 21 Mar 2017 19:38:11 +0000 [thread overview]
Message-ID: <c546963e-ea9b-feda-12ae-588ff77a9142@arm.com> (raw)
In-Reply-To: <CACtJ1JQqELQvv=12kzaG7u5BOX32TXgNOuP3GnbOD9ym__bfpA@mail.gmail.com>
On 03/21/2017 01:27 PM, Bhupinder Thakur wrote:
> Hi Julien,
Hi Bhupinder,
> On 26 February 2017 at 22:37, Julien Grall <julien.grall@arm.com> wrote:
>>> + break;
>>> + case VPL011_UARTDR_OFFSET:
>>> + vpl011_read_data(v->domain, &ch);
>>
>>
>> Should not you check the return value of vpl011_read_data? Also, what if
>> there is no data?
> This condition should not happen because the RX FIFO empty bit would
> be set in the UARTFR register when the last data is read from the ring
> buffer and the the guest is not supposed to issue next read until the
> RX FIFO empty bit is cleared indicating there is more data now.
What you describe is how a well-behave guest will interact with the
pl011 emulation. It does not describe what would happen if a misbehaved
guest will read continuously the register.
I cannot find any things in the spec about what should be the state of
the register if no data is available. So I guess we just need to ensure
that we don't leak in information from the stack. This seems to be
addressed by *data = 0 in "vpl011_read_data".
Please document it to avoid removing it by mistake in the future.
>
>>
>>> + *r = ch;
>>> + break;
>>> + case VPL011_UARTFR_OFFSET:
>>> + *r = v->domain->arch.vpl011.flag;
>>
>>
>> I am fairly surprised that none of this code is actually protected by lock.
>> For instance the update of flag is not atomic. So is it safe?
> For reading, I thought no locking was required, as I believe a 32-bit
> value read/write on ARM should be atomic. So if the value is modified
> in some other context while it is being read in another context, the
> reader should see either the old value or the new value.
> For register writes, yes I need to take a lock where I am updating
> certain bits in the register. I will add the locking there.
Fair point. I was more worry about ordering between read/write between
multiple vCPU. But I guess we don't care if the read does not return an
update to date value.
>
>>
>>> + break;
>>> + case VPL011_UARTIMSC_OFFSET:
>>> + *r = v->domain->arch.vpl011.intr_mask;
>>> + break;
>>> + case VPL011_UARTICR_OFFSET:
>>> + *r = 0;
>>
>>
>> Looking at the spec, this register is write-only. So why do you implement
>> RAZ?
> In such cases, where the guest tries to write to RO register or tries
> to read a WO register, should I send a abort to the guest?
I don't see any behavior requirement in the spec. So I would send an
abort to the guest (e.g return 0 in the function).
>>
>>> + break;
>>> + case VPL011_UARTRIS_OFFSET:
>>> + *r = v->domain->arch.vpl011.raw_intr_status;
>>> + break;
>>> + case VPL011_UARTMIS_OFFSET:
>>> + *r = v->domain->arch.vpl011.raw_intr_status &
>>> + v->domain->arch.vpl011.intr_mask;
>>> + break;
>>> + case VPL011_UARTDMACR_OFFSET:
>>> + *r = 0; /* uart DMA is not supported. Here it always returns
>>> 0 */
>>
>>
>> My understanding of the spec is DMA is not optional. So what would happen if
>> the guest tries to enable it?
>>
>>> + break;
>>> + case VPL011_UARTRSR_OFFSET:
>>> + *r = 0; /* it always returns 0 as there are no physical
>>> errors */
>>
>>
>> This register contains contains the bit OE that tells whether the FIFO is
>> full or not. The FIFO here is the PV ring, so maybe we should set this bit
>> if the ring is full.
> The OE condition will not happen in this case since xenconsole will
> not write more data to the guest if the ring buffer is full. There is
> a separate UARTFR status bit which indicates whether the ring buffer
> is full.
Sorry I still don't get it. Xenconsole will likely have to hold
characters that are not written in the PV console. I would have expected
that this would be used to set the OE bit. Did I miss anything?
>>
>>> + break;
>>> + default:
>>> + printk ("vpl011_mmio_read: invalid switch case %d\n",
>>> (int)(info->gpa - GUEST_PL011_BASE));
>>
>>
>> Coding style: printk(...).
>>
>> Also, printk is not ratelimited by default. Please use gprintk(...) which
>> will be ratelimited and print the domain information. This is useful when
>> you have multiple guest.
>>
> Replaced printk with gprintk.
>
>>> + break;
>>> + }
>>> +
>>> + return VPL011_EMUL_OK;
>>
>>
>> Please use plain value as the return is not pl011 specific. Also, I am a bit
>> surprised that you return "ok" even when a register as not been emulated.
>> IHMO, a data abort should be sent to the guest.
>
> Corrected this. Now it returns an error incase the register is not
> emulated . For the return values, I see that typically values 1/0 are
> returned like in vgic-v2/3.c. Are there some common macros which I can
> use?
No. I want to replace 0/1 by false/true but I never had the time to do
the work.
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-03-22 8:27 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-21 11:25 [PATCH 00/11] pl011 emulation support in Xen Bhupinder Thakur
2017-02-21 11:25 ` [PATCH 01/11] xen/arm: vpl011: Add pl011 uart emulation " Bhupinder Thakur
2017-02-26 21:37 ` Julien Grall
2017-03-03 19:19 ` Julien Grall
2017-03-21 13:27 ` Bhupinder Thakur
2017-03-21 19:38 ` Julien Grall [this message]
2017-03-23 9:44 ` Bhupinder Thakur
2017-03-23 13:51 ` Julien Grall
2017-03-03 19:59 ` Konrad Rzeszutek Wilk
2017-03-05 1:04 ` Julien Grall
2017-03-06 14:22 ` Konrad Rzeszutek Wilk
2017-03-05 1:15 ` Julien Grall
2017-03-05 11:59 ` Julien Grall
2017-03-22 5:50 ` Bhupinder Thakur
2017-03-05 12:12 ` Julien Grall
2017-03-23 9:14 ` Bhupinder Thakur
2017-03-23 14:16 ` Julien Grall
2017-03-24 10:39 ` Bhupinder Thakur
2017-02-21 11:25 ` [PATCH 02/11] xen/arm: vpl011: Add new hvm params in Xen for ring buffer/event setup Bhupinder Thakur
2017-03-03 20:02 ` Konrad Rzeszutek Wilk
2017-03-24 6:58 ` Bhupinder Thakur
2017-03-05 12:35 ` Julien Grall
2017-03-06 8:06 ` Jan Beulich
2017-03-06 11:42 ` Julien Grall
2017-03-06 12:41 ` Jan Beulich
2017-03-06 13:21 ` Julien Grall
2017-03-06 13:48 ` Jan Beulich
2017-03-08 14:45 ` Julien Grall
2017-03-08 15:21 ` Jan Beulich
2017-03-08 18:22 ` Stefano Stabellini
2017-04-11 14:38 ` Bhupinder Thakur
2017-04-11 22:07 ` Stefano Stabellini
2017-04-14 7:12 ` Bhupinder Thakur
2017-04-19 18:43 ` Stefano Stabellini
2017-03-06 14:48 ` George Dunlap
2017-03-08 13:52 ` Julien Grall
2017-03-24 7:31 ` Bhupinder Thakur
2017-02-21 11:26 ` [PATCH 03/11] xen/arm: vpl011: Refactor evtchn_send in Xen to allow sending events from a xen bound channel Bhupinder Thakur
2017-03-03 21:13 ` Konrad Rzeszutek Wilk
2017-03-06 10:16 ` Bhupinder Thakur
2017-03-06 10:35 ` Jan Beulich
2017-03-05 12:39 ` Julien Grall
2017-03-06 8:15 ` Jan Beulich
2017-03-06 10:44 ` Bhupinder Thakur
2017-03-06 10:54 ` Jan Beulich
2017-03-06 11:12 ` Bhupinder Thakur
2017-03-28 9:43 ` Bhupinder Thakur
2017-02-21 11:26 ` [PATCH 04/11] xen/arm: vpl011: Enable vpl011 emulation for a domain in Xen Bhupinder Thakur
2017-03-03 21:47 ` Konrad Rzeszutek Wilk
2017-03-05 12:46 ` Julien Grall
2017-03-06 8:27 ` Jan Beulich
2017-02-21 11:26 ` [PATCH 05/11] xen/arm: vpl011: Initialize nr_spis in vgic_init in Xen to atleast 1 Bhupinder Thakur
2017-03-03 20:49 ` Konrad Rzeszutek Wilk
2017-03-05 12:51 ` Julien Grall
2017-03-16 6:50 ` Bhupinder Thakur
2017-03-16 8:24 ` Julien Grall
2017-03-16 10:31 ` Bhupinder Thakur
2017-03-16 13:24 ` Julien Grall
2017-03-20 16:29 ` Bhupinder Thakur
2017-02-21 11:26 ` [PATCH 06/11] xen/arm: vpl011: Add a new pl011 uart node in the guest DT in the toolstack Bhupinder Thakur
2017-03-03 20:15 ` Konrad Rzeszutek Wilk
2017-03-03 21:03 ` Konrad Rzeszutek Wilk
2017-03-05 12:59 ` Julien Grall
2017-03-05 13:04 ` Julien Grall
2017-03-14 13:00 ` Wei Liu
2017-02-21 11:26 ` [PATCH 07/11] xen/arm: vpl011: Add two new vpl011 parameters to xenstore Bhupinder Thakur
2017-03-03 20:58 ` Konrad Rzeszutek Wilk
2017-03-28 7:49 ` Bhupinder Thakur
2017-02-21 11:26 ` [PATCH 08/11] xen/arm: vpl011: Allocate a new PFN in the toolstack and pass to Xen using a hvm call Bhupinder Thakur
2017-03-03 20:51 ` Konrad Rzeszutek Wilk
2017-03-05 13:07 ` Julien Grall
2017-02-21 11:26 ` [PATCH 09/11] xen/arm: vpl011: Modify domain_create_ring in xenconsole to map the ring buffer and event channel Bhupinder Thakur
2017-03-03 21:46 ` Konrad Rzeszutek Wilk
2017-02-21 11:26 ` [PATCH 10/11] xen/arm: vpl011: Modify handle_ring_read and buffer_append to read/append vpl011 data Bhupinder Thakur
2017-03-03 21:06 ` Konrad Rzeszutek Wilk
2017-02-21 11:26 ` [PATCH 11/11] xen/arm: vpl011: Modify handle_tty_read in xenconsole to redirect user data to vpl011 IN ring buffer Bhupinder Thakur
2017-03-03 21:17 ` Konrad Rzeszutek Wilk
2017-03-03 20:23 ` [PATCH 00/11] pl011 emulation support in Xen Konrad Rzeszutek Wilk
2017-03-03 21:15 ` Konrad Rzeszutek Wilk
2017-03-14 7:44 ` Bhupinder Thakur
2017-03-05 11:46 ` Julien Grall
2017-03-14 7:47 ` Bhupinder Thakur
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c546963e-ea9b-feda-12ae-588ff77a9142@arm.com \
--to=julien.grall@arm.com \
--cc=bhupinder.thakur@linaro.org \
--cc=nd@arm.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).