Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <natechancellor@gmail.com>
To: Will Deacon <will@kernel.org>
Cc: mark.rutland@arm.com, tstellar@redhat.com,
	android-kvm@google.com, catalin.marinas@arm.com,
	ndesaulniers@google.com, clang-built-linux@googlegroups.com,
	Mark Brown <broonie@kernel.org>,
	linux-arm-kernel@lists.infradead.org, daniel.kiss@arm.com
Subject: Re: Clang miscompiling arm64 kernel with BTI and PAC?
Date: Tue, 16 Jun 2020 10:49:04 -0700	[thread overview]
Message-ID: <20200616174904.GA3403100@ubuntu-n2-xlarge-x86> (raw)
In-Reply-To: <20200616173728.GC2129@willie-the-truck>

On Tue, Jun 16, 2020 at 06:37:28PM +0100, Will Deacon wrote:
> On Mon, Jun 15, 2020 at 07:31:05AM -0700, Nathan Chancellor wrote:
> > [+ Tom, the clang 10 release manager]
> > 
> > On Mon, Jun 15, 2020 at 01:02:23PM +0100, Will Deacon wrote:
> > > On Mon, Jun 15, 2020 at 12:53:37PM +0100, Mark Brown wrote:
> > > > On Mon, Jun 15, 2020 at 11:55:24AM +0100, Will Deacon wrote:
> > > > 
> > > > > Here, the switch statement has been replaced by a jump table which we *tail
> > > > > call* into. The register dump shows we're going to 0xffffd68929392e14:
> > > > 
> > > > > ffff800010032e14:       d503233f        paciasp
> > > > > ffff800010032e18:       a9bf7bfd        stp     x29, x30, [sp, #-16]!
> > > > > ffff800010032e1c:       910003fd        mov     x29, sp
> > > > > ffff800010032e20:       aa0803e0        mov     x0, x8
> > > > > ffff800010032e24:       940017c0        bl      ffff800010038d24 <kvm_vm_ioctl_check_extension>
> > > > > ffff800010032e28:       93407c00        sxtw    x0, w0
> > > > > ffff800010032e2c:       a8c17bfd        ldp     x29, x30, [sp], #16
> > > > > ffff800010032e30:       d50323bf        autiasp
> > > > > ffff800010032e34:       d65f03c0        ret
> > > > 
> > > > > The problem is that the paciasp instruction is not BTYPE-compatible with BR;
> > > > > it expects to be called with a branch-and-link, and so we panic. I think you
> > > > > need to emit a 'bti j' here prior to the paciasp.
> > > > 
> > > > I checked with our internal teams and they actually ran into this
> > > > recently with some other code, the patch:
> > > > 
> > > >    https://reviews.llvm.org/D81746
> > > > 
> > > > ([AArch64] Fix BTI instruction emission) should fix this, it's been
> > > > reviewed so should be merged shortly.
> > > 
> > > Cheers, that's good to hear. Shall we have a guess at the clang release
> > > that will get the fix, or just disable in-kernel BTI with clang for now?
> > > 
> > > Will
> > > 
> > 
> > This will be in clang 11 for sure. Tom, would it be too late to get this
> > in to clang 10.0.1? If it is not, I can open a PR.
> 
> Any update on this, please? I'd like to get the kernel fixed this week.
> 
> Cheers,
> 
> Will

The AArch64 backend owner said it should be okay to add to 10.0.1:
https://llvm.org/pr46327

Tom just needs to pick it, I see no reason to believe that won't happen
this week.

Cheers,
Nathan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-06-16 17:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-15 10:55 Clang miscompiling arm64 kernel with BTI and PAC? Will Deacon
2020-06-15 11:37 ` Mark Brown
2020-06-15 11:53 ` Mark Brown
2020-06-15 12:02   ` Will Deacon
2020-06-15 14:31     ` Nathan Chancellor
2020-06-15 15:00       ` Daniel Kiss
2020-06-16 17:37       ` Will Deacon
2020-06-16 17:49         ` Nathan Chancellor [this message]
2020-06-16 17:55           ` Will Deacon
2020-06-16 18:35             ` Nick Desaulniers
2020-06-17  6:36               ` Fangrui Song
2020-06-18 11:22                 ` Daniel Kiss
2020-06-16 18:09           ` Tom Stellard

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=20200616174904.GA3403100@ubuntu-n2-xlarge-x86 \
    --to=natechancellor@gmail.com \
    --cc=android-kvm@google.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=daniel.kiss@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=ndesaulniers@google.com \
    --cc=tstellar@redhat.com \
    --cc=will@kernel.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