All of lore.kernel.org
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: Android and compatibility with deprecated armv7 instructions
Date: Wed, 2 Jul 2014 17:16:49 +0100	[thread overview]
Message-ID: <20140702161649.GF24879@arm.com> (raw)
In-Reply-To: <CAMbhsRSm_o78X-+2mfgUfR7pwgaDob75Lcvjfck50kHcagX=cQ@mail.gmail.com>

Hi Colin,

On Wed, Jul 02, 2014 at 04:48:07PM +0100, Colin Cross wrote:
> On Wed, Jul 2, 2014 at 3:01 AM, Will Deacon <will.deacon@arm.com> wrote:
> > On Wed, Jul 02, 2014 at 12:48:00AM +0100, Mark Brown wrote:
> > > On Tue, Jul 01, 2014 at 04:42:01PM -0700, Olof Johansson wrote:
> > > > On Tue, Jul 1, 2014 at 4:06 PM, Colin Cross <ccross@google.com> wrote:
> > > > > Would you consider taking support for SWP emulation, enabling CP15
> > > > > barriers (CP15BEN bit only until there's a real device that needs
> > > > > emulation, also requires clearing COMPAT_PSR_E_BIT in
> > > > > compat_setup_return) and enabling SETEND, all behind a default-off
> > > > > CONFIG_DEPRECATED_ARMV7_COMPAT?
> > >
> > > > It sounds really silly to push back against this, since it's actually
> > > > needed by so many platforms out there.
> >
> > The big problem with emulating instructions that don't even appear in the
> > hardware anymore is that we end up creating baggage which we can *never*
> > remove.
> >
> > I'm against SWP emulation in the kernel for a number of reasons:
> >
> >   (1) The hardware doesn't have the instruction at all. If we start
> >       emulating it, then we'll always have to emulate it and it doesn't
> >       encourage software migration.
> >
> >   (2) I'm not convinced that it can't be handled in userspace by trapping
> >       the SIGILL and emulating there (admittedly, this sounds difficult).
> >
> >   (3) The usual uses of SWP are in homebrew locking implementations and
> >       are almost certainly a _bug_. For those v7 CPUs that could do SWP,
> >       it's not even guaranteed to be atomic iirc. Trapping and emulating
> >       is also bad for performance (although I note that Colin made an
> >       argument that it was acceptable).
> >
> >   (4) This only affects legacy binaries. Should we also try to support OABI?
> >       How about misaligned ldm/stm? We have to draw the line somewhere.
> 
> The problem is that we (Android) have to draw the line somewhere else
> - there are too many highly visible apps in the app store that still
> use these instructions.  When we add them back to our kernels, then we
> are no longer ABI compatible with an upstream kernel.

For an ARMv7 kernel, this is still controlled by CONFIG_SWP_EMULATE, so
you would have the exact same issues with kernels where that has been turned
off. You assumedly have a bunch of patches on top of mainline for Android; I
don't understand why this one is any different.

> > The CP15 barriers are a more interesting case, as the CPUs can *currently*
> > support those if we flip a bit in the SCTLR. However, I see that as a
> > slippery slope to emulation if CPUs stop supporting those instructions in
> > the future (they almost certainly will).
> 
> I agree that this will likely lead to emulation when a CPU
> manufacturer eventually decides to leave out hardware support,
> although hopefully they won't if they see that the bit is set in SCTLR
> on all Android devices.

... and what if/when people start building AArch64-only CPUs? Are we going to
emulate the entire AArch32 instruction set in the kernel? Or just the
deprecated/obsolete subset of that ;)

> > Whilst I appreciate that people are being bitten by this lack of emulation
> > support, the vast majority of AArch32 code out there is working fine with
> > the existing compat layer. I think the right way to solve this problem is
> > to fix the code making use of the missing instructions.
> 
> A not-insignificant number of apps use these instructions - these
> issues have been found by people taking the top 100 or so Android
> apps, trying them out, and finding they crash.  Asking them all to
> recompile is not feasible.  I view this issue as similar to Linus'
> view on kernel ABIs - if somebody uses it, you have to keep it.  As
> far as I know, nobody is generating new code with SWP and CP15 barrier
> instructions, although ffmpeg is probably still using SETEND.

I don't actually know *how* you would emulate SETEND. Have you tried? Also,
we haven't ever supported SWP on arm64 compat, so I don't agree with your
comparison to Linus's argument.

Will

  reply	other threads:[~2014-07-02 16:16 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-01 23:06 Android and compatibility with deprecated armv7 instructions Colin Cross
2014-07-01 23:42 ` Olof Johansson
2014-07-01 23:48   ` Mark Brown
2014-07-02 10:01     ` Will Deacon
2014-07-02 15:48       ` Colin Cross
2014-07-02 16:16         ` Will Deacon [this message]
2014-07-02 18:03           ` Christopher Covington
2014-07-02 18:25             ` Will Deacon
2014-07-02 19:47               ` Mark Brown
2014-07-05 21:26           ` Rob Herring
2014-07-02 16:39       ` Mark Brown
2014-07-02 17:01         ` Will Deacon
2014-07-02 17:33           ` Mark Brown
2014-07-02 22:14           ` Grant Likely
2014-07-03 10:41             ` Catalin Marinas
2014-07-03 14:28               ` Arnd Bergmann
2014-07-03 15:00                 ` Russell King - ARM Linux
2014-07-03 15:40                   ` Grant Likely
2014-07-03 17:13                   ` Catalin Marinas
2014-07-03 17:48                     ` Russell King - ARM Linux
2014-07-03 18:15                     ` Arnd Bergmann
2014-07-03 18:30                       ` Russell King - ARM Linux
2014-07-03 18:37                         ` Will Deacon
2014-07-03 18:52                           ` Russell King - ARM Linux
2014-07-03 19:00                             ` Will Deacon
2014-07-04  8:57                         ` Catalin Marinas
2014-07-04  9:25                           ` Russell King - ARM Linux
2014-07-04 10:12                             ` Arnd Bergmann
2014-07-04 14:09                               ` Dr. David Alan Gilbert
2014-07-04 12:56                             ` Grant Likely
2014-07-04 13:31                               ` Russell King - ARM Linux
2014-07-03 18:46                       ` Will Deacon
2014-07-03 18:53                         ` Arnd Bergmann
2014-07-03 19:07                           ` Russell King - ARM Linux
2014-07-03 19:40                             ` Arnd Bergmann
2014-07-04 13:25                     ` Grant Likely
2014-07-03 16:22               ` Grant Likely
2014-07-03 17:05                 ` Russell King - ARM Linux
2014-07-03 17:32                   ` Will Deacon
2014-07-03 18:23                     ` Arnd Bergmann
2014-07-03 18:38                       ` Peter Maydell
2014-07-03 18:40                       ` Will Deacon
2014-07-03 18:32                     ` Mark Brown
2014-07-03 22:16                     ` Måns Rullgård
2014-07-03 22:47                       ` Russell King - ARM Linux
2014-07-04  7:08                         ` Ard Biesheuvel
2014-07-04  8:24                           ` Catalin Marinas
2014-07-04  8:33                             ` Ard Biesheuvel
2014-07-04  9:21                               ` Måns Rullgård
2014-07-04  9:34                                 ` Russell King - ARM Linux
2014-07-04 10:21                                   ` Måns Rullgård
2014-07-04 10:33                                     ` Russell King - ARM Linux
2014-07-04 11:00                                       ` Ard Biesheuvel
2014-07-04 17:28                                         ` Nicolas Pitre
2014-07-03 17:43                 ` Catalin Marinas
2014-07-04 13:22                   ` Grant Likely
2014-07-04 19:24                     ` Mark Brown
2014-07-04 19:33                       ` Arnd Bergmann
2014-07-04 22:06                         ` Måns Rullgård
2014-07-04 22:08                         ` Mark Brown
2014-07-05 11:14                     ` Catalin Marinas
2014-07-05 11:25                       ` Russell King - ARM Linux
2014-07-05 16:43                       ` Mark Brown
2014-07-05 17:06                         ` Catalin Marinas
2014-07-05 18:43                           ` Arnd Bergmann
2014-07-05 21:19                             ` Catalin Marinas
2014-07-06 15:39                               ` Arnd Bergmann
2014-07-07 13:59                                 ` Janne Grunau
2014-07-07 14:52                                   ` Catalin Marinas
2014-07-07 17:52                                     ` Janne Grunau
2014-07-07 15:43                                   ` Peter Maydell
2014-07-08  5:28                                   ` Måns Rullgård
2014-07-07 14:35                                 ` Catalin Marinas
2014-07-07 21:26                                   ` Arnd Bergmann
2014-07-07 12:28                       ` Grant Likely
2014-07-07 18:35                         ` Colin Cross

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=20140702161649.GF24879@arm.com \
    --to=will.deacon@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.