xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: Andre Przywara <andre.przywara@arm.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	 Michal Orzel <michal.orzel@amd.com>,
	Jiamei Xie <Jiamei.Xie@arm.com>,
	 "xen-devel@lists.xenproject.org"
	<xen-devel@lists.xenproject.org>,  Wei Chen <Wei.Chen@arm.com>,
	Bertrand Marquis <Bertrand.Marquis@arm.com>,
	 "julien@xen.org" <julien@xen.org>
Subject: Re: Xen Arm vpl011 UART will cause segmentation fault in Linux guest
Date: Wed, 16 Nov 2022 15:54:24 -0800 (PST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2211161552420.4020@ubuntu-linux-20-04-desktop> (raw)
In-Reply-To: <20221116110942.3faf952f@donnerap.cambridge.arm.com>

[-- Attachment #1: Type: text/plain, Size: 2488 bytes --]

On Wed, 16 Nov 2022, Andre Przywara wrote:
> On Thu, 10 Nov 2022 12:32:49 -0800 (PST)
> Stefano Stabellini <sstabellini@kernel.org> wrote:
> > On Wed, 9 Nov 2022, Michal Orzel wrote:
> > > Hi Jiamei,
> > > 
> > > On 09/11/2022 09:25, Jiamei Xie wrote:  
> > > > 
> > > > 
> > > > Hi Michal,
> > > > 
> > > > Below log can be got when stating the linux guest. It says 9c09 is sbsa. And 9c09 is also output
> > > >  in bootlogd error message:
> > > > Serial: AMBA PL011 UART driver
> > > > 9c0b0000.uart: ttyAMA0 at MMIO 0x9c0b0000 (irq = 12, base_baud = 0) is a PL011 rev2
> > > > printk: console [ttyAMA0] enabled
> > > > 9c090000.sbsa-uart: ttyAMA1 at MMIO 0x9c090000 (irq = 15, base_baud = 0) is a SBSA
> > > >   
> > > 
> > > Xen behavior is correct and this would be Linux fault to try to write to DMACR for SBSA UART device.
> > > DMACR is just an example. If you try to program e.g. the baudrate (through LCR) for VPL011 it will
> > > also result in injecting abort into the guest. Should Xen support it? No. The reason why is that
> > > it is not spec compliant operation. SBSA specification directly specifies what registers are exposed.
> > > If Linux tries to write to some of the none-spec compliant registers - it is its fault.  
> > 
> > Yeah, we need to fix Linux.
> 
> Yes, it's a bug in Linux, and nobody noticed because most SBSA UARTs are
> actual PL011s, just not with everything wired up and the clocks fixed.
> 
> But while you can take pride all day in Xen having a perfect
> spec-compliant implementation - and you would be right - you have to face
> the reality that existing Linux kernels will crash.
> So we will add the one-liner in Linux that fixes that issue, and this will
> probably be backported to stable kernels, but you will still encounter
> kernels without the fix in the wild.
> So I wonder if you should consider to just implement the other PL011
> registers as RAZ/WI? That would be spec compliant as well (since an actual
> PL011 is also a spec-compliant SBSA-UART), but would work either way. Of
> course you don't need to implement the DMA or baudrate functionality, but
> at least not be nasty and trap on those register accesses.

I think this is one of those cases where we should do both:
- we should fix Linux, because that is a bug in Linux
- we should improve Xen to make this class of issues less likely to show
  up in the future

So I think implementing the other PL011 registers as RAZ/WI is a good
improvement we could have in Xen.

      reply	other threads:[~2022-11-16 23:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09  7:20 Xen Arm vpl011 UART will cause segmentation fault in Linux guest Jiamei Xie
2022-11-09  7:39 ` Michal Orzel
2022-11-09  8:25   ` Jiamei Xie
2022-11-09  9:25     ` Michal Orzel
2022-11-10 20:32       ` Stefano Stabellini
2022-11-11  4:31         ` Jiamei Xie
2022-11-16 12:46           ` Jiamei Xie
2022-11-16 12:51             ` Jiamei Xie
2022-11-16 11:09         ` Andre Przywara
2022-11-16 23:54           ` Stefano Stabellini [this message]

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=alpine.DEB.2.22.394.2211161552420.4020@ubuntu-linux-20-04-desktop \
    --to=sstabellini@kernel.org \
    --cc=Bertrand.Marquis@arm.com \
    --cc=Jiamei.Xie@arm.com \
    --cc=Wei.Chen@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --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).