Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads

2022-09-06 Thread Catalin Marinas
On Fri, 1 Jul 2022 15:53:22 +0200, Ard Biesheuvel wrote:
> The 32-bit ARM kernel implements fixups on behalf of user space when
> using LDM/STM or LDRD/STRD instructions on addresses that are not 32-bit
> aligned. This is not something that is supported by the architecture,
> but was done anyway to increase compatibility with user space software,
> which mostly targeted x86 at the time and did not care about aligned
> accesses.
> 
> [...]

Applied to arm64 (for-next/misc), thanks!

[1/1] arm64: compat: Implement misalignment fixups for multiword loads
  https://git.kernel.org/arm64/c/3fc24ef32d3b

-- 
Catalin



Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads

2022-09-05 Thread Catalin Marinas
On Mon, Sep 05, 2022 at 12:04:47PM +0200, Ard Biesheuvel wrote:
> On Wed, 31 Aug 2022 at 19:07, Catalin Marinas  wrote:
> > On Fri, Jul 01, 2022 at 03:53:22PM +0200, Ard Biesheuvel wrote:
> > > +config COMPAT_ALIGNMENT_FIXUPS
> > > + bool "Fix up misaligned multi-word loads and stores in user space"
> > > + default y
> >
> > For consistency with ARMV8_DEPRECATED, I think we should keep this as
> > default n.
> 
> Fair enough. I take it you can fix this up while applying?

Yes.

-- 
Catalin



Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads

2022-09-05 Thread Ard Biesheuvel
On Wed, 31 Aug 2022 at 19:07, Catalin Marinas  wrote:
>
> On Fri, Jul 01, 2022 at 03:53:22PM +0200, Ard Biesheuvel wrote:
> > The 32-bit ARM kernel implements fixups on behalf of user space when
> > using LDM/STM or LDRD/STRD instructions on addresses that are not 32-bit
> > aligned. This is not something that is supported by the architecture,
> > but was done anyway to increase compatibility with user space software,
> > which mostly targeted x86 at the time and did not care about aligned
> > accesses.
> >
> > This feature is one of the remaining impediments to being able to switch
> > to 64-bit kernels on 64-bit capable hardware running 32-bit user space,
> > soDocumentation/x86/boot.rst let's implement it for the arm64 compat layer 
> > as well.
> >
> > Note that the intent is to implement the exact same handling of
> > misaligned multi-word loads and stores as the 32-bit kernel does,
> > including what appears to be missing support for user space programs
> > that rely on SETEND to switch to a different byte order and back. Also,
> > like the 32-bit ARM version, we rely on the faulting address reported by
> > the CPU to infer the memory address, instead of decoding the instruction
> > fully to obtain this information.
> >
> > This implementation is taken from the 32-bit ARM tree, with all pieces
> > removed that deal with instructions other than LDRD/STRD and LDM/STM, or
> > that deal with alignment exceptions taken in kernel mode.
> >
> > Cc: debian-arm@lists.debian.org
> > Cc: Vagrant Cascadian 
> > Cc: Riku Voipio 
> > Cc: Steve McIntyre 
> > Signed-off-by: Ard Biesheuvel 
> > ---
> > Note to cc'ees: if this is something you would like to see merged,
> > please indicate so. This stuff is unlikely to get in if there are no
> > users.
> >
> > v2: - drop some obsolete comments
> > - emit a perf alignment-fault event for every handled instruction
> > - use arm64_skip_faulting_instruction() to get the correct behavior
> >   wrt IT state and single step
> > - use types with correct endianness annotation (instructions are
> >   always little endian on v7/v8+)
>
> It looks like that's a fairly popular request from people running 32-bit
> user on AArch64 kernels, so happy to queue it for 6.1 (if it still
> applies cleanly). I'm not too keen on code duplication but it's a lot
> more hassle to create a common decoding/emulation library to share with
> arch/arm, especially as such code is not going to change in the future.
>
> > +config COMPAT_ALIGNMENT_FIXUPS
> > + bool "Fix up misaligned multi-word loads and stores in user space"
> > + default y
>
> For consistency with ARMV8_DEPRECATED, I think we should keep this as
> default n.
>

Fair enough. I take it you can fix this up while applying?



Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads

2022-08-31 Thread Catalin Marinas
On Fri, Jul 01, 2022 at 03:53:22PM +0200, Ard Biesheuvel wrote:
> The 32-bit ARM kernel implements fixups on behalf of user space when
> using LDM/STM or LDRD/STRD instructions on addresses that are not 32-bit
> aligned. This is not something that is supported by the architecture,
> but was done anyway to increase compatibility with user space software,
> which mostly targeted x86 at the time and did not care about aligned
> accesses.
> 
> This feature is one of the remaining impediments to being able to switch
> to 64-bit kernels on 64-bit capable hardware running 32-bit user space,
> so let's implement it for the arm64 compat layer as well.
> 
> Note that the intent is to implement the exact same handling of
> misaligned multi-word loads and stores as the 32-bit kernel does,
> including what appears to be missing support for user space programs
> that rely on SETEND to switch to a different byte order and back. Also,
> like the 32-bit ARM version, we rely on the faulting address reported by
> the CPU to infer the memory address, instead of decoding the instruction
> fully to obtain this information.
> 
> This implementation is taken from the 32-bit ARM tree, with all pieces
> removed that deal with instructions other than LDRD/STRD and LDM/STM, or
> that deal with alignment exceptions taken in kernel mode.
> 
> Cc: debian-arm@lists.debian.org
> Cc: Vagrant Cascadian 
> Cc: Riku Voipio 
> Cc: Steve McIntyre 
> Signed-off-by: Ard Biesheuvel 
> ---
> Note to cc'ees: if this is something you would like to see merged,
> please indicate so. This stuff is unlikely to get in if there are no
> users.
> 
> v2: - drop some obsolete comments
> - emit a perf alignment-fault event for every handled instruction
> - use arm64_skip_faulting_instruction() to get the correct behavior
>   wrt IT state and single step
> - use types with correct endianness annotation (instructions are
>   always little endian on v7/v8+)

It looks like that's a fairly popular request from people running 32-bit
user on AArch64 kernels, so happy to queue it for 6.1 (if it still
applies cleanly). I'm not too keen on code duplication but it's a lot
more hassle to create a common decoding/emulation library to share with
arch/arm, especially as such code is not going to change in the future.

> +config COMPAT_ALIGNMENT_FIXUPS
> + bool "Fix up misaligned multi-word loads and stores in user space"
> + default y

For consistency with ARMV8_DEPRECATED, I think we should keep this as
default n.

Thanks.

-- 
Catalin



Clarification [WAS Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads]

2022-08-19 Thread Andrew M.A. Cater
On Fri, Aug 19, 2022 at 03:19:23PM +0200, LinAdmin wrote:
> Good night Andy
> 
> Is it possible you never have heard of the Streisand effect?
> 
> Regards
> LinAdmin
> 

Hi LinAdmin,

As one of the people who wrote the FAQ for the debian-user mailing list,
not only have I heard of it, I specifically referenced it. If you are trying
to get some random posting removed from a Debian mailing list, this is 
difficult becasue it may be archived anywhere in the world. Complaining
too much about it risks the Streisand effect. See, for example, the latest
https://lists.debian.org/debian-user/2022/08/msg4.html

My reply to you yesterday was to ask you to be considerate, think of
others on the mailing list and to specifically consider how your words
may come across. Working constructively with people, adding to what
they are doing, offering help is more useful than offering criticism
in general.

This is a community: you are working with / being read by people you may
never meet and it helps to work out who you are dealing with and what
ability they may have to help you.

In an earlier message in the thread:
 
you suggested that you didn't care about Debian because Ubuntu
worked well.

We do care about what you've said, some of the people following
the list are people who might be able to help evaluate what we can do to
improve Debian but the way that you are making your point is not the most
helpful to what you are trying to say. There may be better ways to explain as
you wish to without putting down other people's work.

The Code of Conduct (https://www.debian.org/code_of_conduct) and Debian
Community Team notes (https://www.debian.org/code_of_conduct_interpretation)
refer.

I'd suggest particularly that section 2 - Assume good faith is very relevant in 
this situation.

> On 18.08.22 18:58, Andrew M.A. Cater wrote:
> > On Thu, Aug 18, 2022 at 05:21:19PM +0200, LinAdmin wrote:
> >> I do know that you do not like my comment that 32bit on Pi4
> >> is much more efficient than 64 Bit ...
> >> Linadmin
> >>
> >>
> > Good afternoon, LinAdmin
> >
> > It does appear to me that this comment is not directly relevant to this
> > message and might not be helpful. Nobody mentioned this in this thread
> > today apart from you
> >
>

With every good wish, as ever,

Andy Cater

[For the Debian Community Team]. 



Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads

2022-08-19 Thread LinAdmin
Good night Andy

Is it possible you never have heard of the Streisand effect?

Regards
LinAdmin

On 18.08.22 18:58, Andrew M.A. Cater wrote:
> On Thu, Aug 18, 2022 at 05:21:19PM +0200, LinAdmin wrote:
>> I do know that you do not like my comment that 32bit on Pi4
>> is much more efficient than 64 Bit ...
>> Linadmin
>>
>>
> Good afternoon, LinAdmin
>
> It does appear to me that this comment is not directly relevant to this
> message and might not be helpful. Nobody mentioned this in this thread
> today apart from you
>
> It might be worth looking at the Debian Code of Conduct: please be 
> considerate,
> think about how you come across and be constructive. Working with people is
> more useful than provoking them.
>
> This list - as all Debian lists - is subject to the Debian Code of Conduct to
> allow us to work better together. This is a reminder rather than a warning.
>
> With every good wish, as ever,
>
> Andy Cater
>
> [For the Debian Community Team.]
>  
>



Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads

2022-08-18 Thread Andrew M.A. Cater
On Thu, Aug 18, 2022 at 05:21:19PM +0200, LinAdmin wrote:
> I do know that you do not like my comment that 32bit on Pi4
> is much more efficient than 64 Bit ...
> Linadmin
> 
>

Good afternoon, LinAdmin

It does appear to me that this comment is not directly relevant to this
message and might not be helpful. Nobody mentioned this in this thread
today apart from you

It might be worth looking at the Debian Code of Conduct: please be considerate,
think about how you come across and be constructive. Working with people is
more useful than provoking them.

This list - as all Debian lists - is subject to the Debian Code of Conduct to
allow us to work better together. This is a reminder rather than a warning.

With every good wish, as ever,

Andy Cater

[For the Debian Community Team.]
 



Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads

2022-08-18 Thread LinAdmin
I do know that you do not like my comment that 32bit on Pi4
is much more efficient than 64 Bit ...
Linadmin

On 17.08.22 11:47, Arnd Bergmann wrote:
> On Tue, Aug 16, 2022 at 10:29 PM Ard Biesheuvel  wrote:
>> Thanks for chiming in.
>>
>> At this point, it is really up to the maintainers to decide whether
>> the maintenance burden is worth it. The code itself seems pretty
>> uncontroversial afaict.
>>
>> Might other distros be in a similar situation? Or is this specific to Debian?
> My guess is that this is the most prominent on Debian: Many others including
> have discontinued or reduced support for 32-bit builds across architectures:
> Ubuntu only supports "Core" with fewer packages on Raspberry Pi 2 but
> not desktop or server, Opensuse Leap and Tumbleweed both distributes a
> lot of board specific images but you have to know where to look as the main
> page only advertises amd64/i686/arm64/ppc64le/s390x, Fedora stopped
> entirely.
>
> Android may be an interesting distro here: there are still a lot of phones
> running a pure 32-bit userland on Cortex-A53/A55 CPUs, and there are a
> large number of applications built for this. As far as I can tell, they tend 
> to
> run 32-bit kernels as well, but that is not going to work on newer processors
> starting with Cortex-A76 big cores or Cortex-A510 little cores.
>
> archlinuxarm supports 32-bit and 64-bit machines equally, but they
> apparently avoid the build service problem by using distcc with
> x86-to-arm cross compilers, and they don't seem to support
> their 32-bit images on 64-bit hardware/kernel.
>
> https://hub.docker.com/search?q==verified=image=arm_filter=official
> lists 98 "official" arm32 images plus countless ones in other categories.
> I think these are popular in memory-constrained cloud hosting
> setups on arm64, so the Alpine based images are probably the most
> interesting ones because of their size, but they would run under
> someone else's kernel.
>
> Arnd
>



Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads

2022-08-17 Thread Arnd Bergmann
On Tue, Aug 16, 2022 at 10:29 PM Ard Biesheuvel  wrote:
>
> Thanks for chiming in.
>
> At this point, it is really up to the maintainers to decide whether
> the maintenance burden is worth it. The code itself seems pretty
> uncontroversial afaict.
>
> Might other distros be in a similar situation? Or is this specific to Debian?

My guess is that this is the most prominent on Debian: Many others including
have discontinued or reduced support for 32-bit builds across architectures:
Ubuntu only supports "Core" with fewer packages on Raspberry Pi 2 but
not desktop or server, Opensuse Leap and Tumbleweed both distributes a
lot of board specific images but you have to know where to look as the main
page only advertises amd64/i686/arm64/ppc64le/s390x, Fedora stopped
entirely.

Android may be an interesting distro here: there are still a lot of phones
running a pure 32-bit userland on Cortex-A53/A55 CPUs, and there are a
large number of applications built for this. As far as I can tell, they tend to
run 32-bit kernels as well, but that is not going to work on newer processors
starting with Cortex-A76 big cores or Cortex-A510 little cores.

archlinuxarm supports 32-bit and 64-bit machines equally, but they
apparently avoid the build service problem by using distcc with
x86-to-arm cross compilers, and they don't seem to support
their 32-bit images on 64-bit hardware/kernel.

https://hub.docker.com/search?q==verified=image=arm_filter=official
lists 98 "official" arm32 images plus countless ones in other categories.
I think these are popular in memory-constrained cloud hosting
setups on arm64, so the Alpine based images are probably the most
interesting ones because of their size, but they would run under
someone else's kernel.

Arnd



Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads

2022-08-16 Thread Ard Biesheuvel
On Tue, 16 Aug 2022 at 21:29, Aurelien Jarno  wrote:
>
> Hi,
>
> On 2022-07-14 02:52, Wookey wrote:
> > On 2022-07-01 15:53 +0200, Ard Biesheuvel wrote:
> > > The 32-bit ARM kernel implements fixups on behalf of user space when
> > > using LDM/STM or LDRD/STRD instructions on addresses that are not 32-bit
> > > aligned.
> >
> > > This feature is one of the remaining impediments to being able to switch
> > > to 64-bit kernels on 64-bit capable hardware running 32-bit user space,
> > > so let's implement it for the arm64 compat layer as well.
> >
> > > Note to cc'ees: if this is something you would like to see merged,
> > > please indicate so. This stuff is unlikely to get in if there are no
> > > users.
> >
> > Decent 32-bit arm hardware is thin on the ground these days. Debian
> > still has some but it's getting old and flaky. Being able to build
> > reliably on 64-bit hardware is important and useful. Unaligned
> > accesses are much less of a problem than they used to be, but they can
> > still happen, so having these fixups available is definitely a good
> > thing.
> >
> > Debian runs its 32-bit buildds with alignment fixups turned on. It
> > looks like the boxes still hit about 1 per day.
> >
> > We also do 32 bit builds on 64-bit kernels (in 32-bit userspaces) and
> > it mostly works. We do have packages that fail on 64-bit kernels and
> > have to be built on real 32-bit hardware, but I don't know how much of
> > that would be fixed by this patch. Some, presumably.
> >
> > So yes, cheers for this. It is helpful in the real world (or at least
> > it should be).
>
> I confirm that this would be very helpful to Debian, so that 32-bit
> binaries behaves the same with a 32-bit or a 64-bit kernel. Otherwise we
> need to keep running (old) 32-bit hardware.
>
> What's the status of those patches?
>

Thanks for chiming in.

At this point, it is really up to the maintainers to decide whether
the maintenance burden is worth it. The code itself seems pretty
uncontroversial afaict.

Might other distros be in a similar situation? Or is this specific to Debian?



Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads

2022-08-16 Thread Aurelien Jarno
Hi,

On 2022-07-14 02:52, Wookey wrote:
> On 2022-07-01 15:53 +0200, Ard Biesheuvel wrote:
> > The 32-bit ARM kernel implements fixups on behalf of user space when
> > using LDM/STM or LDRD/STRD instructions on addresses that are not 32-bit
> > aligned.
> 
> > This feature is one of the remaining impediments to being able to switch
> > to 64-bit kernels on 64-bit capable hardware running 32-bit user space,
> > so let's implement it for the arm64 compat layer as well.
>  
> > Note to cc'ees: if this is something you would like to see merged,
> > please indicate so. This stuff is unlikely to get in if there are no
> > users.
> 
> Decent 32-bit arm hardware is thin on the ground these days. Debian
> still has some but it's getting old and flaky. Being able to build
> reliably on 64-bit hardware is important and useful. Unaligned
> accesses are much less of a problem than they used to be, but they can
> still happen, so having these fixups available is definitely a good
> thing.
> 
> Debian runs its 32-bit buildds with alignment fixups turned on. It
> looks like the boxes still hit about 1 per day.
> 
> We also do 32 bit builds on 64-bit kernels (in 32-bit userspaces) and
> it mostly works. We do have packages that fail on 64-bit kernels and
> have to be built on real 32-bit hardware, but I don't know how much of
> that would be fixed by this patch. Some, presumably.
> 
> So yes, cheers for this. It is helpful in the real world (or at least
> it should be).

I confirm that this would be very helpful to Debian, so that 32-bit
binaries behaves the same with a 32-bit or a 64-bit kernel. Otherwise we
need to keep running (old) 32-bit hardware.

What's the status of those patches?

Thanks
Aurelien

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net


signature.asc
Description: PGP signature


Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads

2022-07-15 Thread LinAdmin
Pi 4 has much more throughput in 32-bit modes but the so
called experts of Debian decided to abandon it :-(


On 14.07.22 03:52, Wookey wrote:
> On 2022-07-01 15:53 +0200, Ard Biesheuvel wrote:
>> The 32-bit ARM kernel implements fixups on behalf of user space when
>> using LDM/STM or LDRD/STRD instructions on addresses that are not 32-bit
>> aligned.
>> This feature is one of the remaining impediments to being able to switch
>> to 64-bit kernels on 64-bit capable hardware running 32-bit user space,
>> so let's implement it for the arm64 compat layer as well.
>  
>> Note to cc'ees: if this is something you would like to see merged,
>> please indicate so. This stuff is unlikely to get in if there are no
>> users.
> Decent 32-bit arm hardware is thin on the ground these days. Debian
> still has some but it's getting old and flaky. Being able to build
> reliably on 64-bit hardware is important and useful. Unaligned
> accesses are much less of a problem than they used to be, but they can
> still happen, so having these fixups available is definitely a good
> thing.
>
> Debian runs its 32-bit buildds with alignment fixups turned on. It
> looks like the boxes still hit about 1 per day.
>
> We also do 32 bit builds on 64-bit kernels (in 32-bit userspaces) and
> it mostly works. We do have packages that fail on 64-bit kernels and
> have to be built on real 32-bit hardware, but I don't know how much of
> that would be fixed by this patch. Some, presumably.
>
> So yes, cheers for this. It is helpful in the real world (or at least
> it should be).
>
> Wookey




Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads

2022-07-13 Thread Wookey
On 2022-07-01 15:53 +0200, Ard Biesheuvel wrote:
> The 32-bit ARM kernel implements fixups on behalf of user space when
> using LDM/STM or LDRD/STRD instructions on addresses that are not 32-bit
> aligned.

> This feature is one of the remaining impediments to being able to switch
> to 64-bit kernels on 64-bit capable hardware running 32-bit user space,
> so let's implement it for the arm64 compat layer as well.
 
> Note to cc'ees: if this is something you would like to see merged,
> please indicate so. This stuff is unlikely to get in if there are no
> users.

Decent 32-bit arm hardware is thin on the ground these days. Debian
still has some but it's getting old and flaky. Being able to build
reliably on 64-bit hardware is important and useful. Unaligned
accesses are much less of a problem than they used to be, but they can
still happen, so having these fixups available is definitely a good
thing.

Debian runs its 32-bit buildds with alignment fixups turned on. It
looks like the boxes still hit about 1 per day.

We also do 32 bit builds on 64-bit kernels (in 32-bit userspaces) and
it mostly works. We do have packages that fail on 64-bit kernels and
have to be built on real 32-bit hardware, but I don't know how much of
that would be fixed by this patch. Some, presumably.

So yes, cheers for this. It is helpful in the real world (or at least
it should be).

Wookey
-- 
Principal hats:  Debian, Wookware, ARM
http://wookware.org/


signature.asc
Description: PGP signature


Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads

2022-07-01 Thread gene heskett

On 7/1/22 10:14, Ard Biesheuvel wrote:

The 32-bit ARM kernel implements fixups on behalf of user space when
using LDM/STM or LDRD/STRD instructions on addresses that are not 32-bit
aligned. This is not something that is supported by the architecture,
but was done anyway to increase compatibility with user space software,
which mostly targeted x86 at the time and did not care about aligned
accesses.

This is a jolly good idea. Linuxcnc is one app that would benefit
from this if it doesn't have a huge effect on latency when we
build a preempt-rt kernel. I built this one on a pi for the pi, several
years ago now, and its worked so well I've not diligently searched
for newer.

4.19.71-rt24-v7l+ #1 SMP PREEMPT RT Thu Feb 6 07:09:18 EST 2020 armv7l
Installed on top of the armhf raspios buster, it Just Works.

This feature is one of the remaining impediments to being able to switch
to 64-bit kernels on 64-bit capable hardware running 32-bit user space,
so let's implement it for the arm64 compat layer as well.

Note that the intent is to implement the exact same handling of
misaligned multi-word loads and stores as the 32-bit kernel does,
including what appears to be missing support for user space programs
that rely on SETEND to switch to a different byte order and back. Also,
like the 32-bit ARM version, we rely on the faulting address reported by
the CPU to infer the memory address, instead of decoding the instruction
fully to obtain this information.

This implementation is taken from the 32-bit ARM tree, with all pieces
removed that deal with instructions other than LDRD/STRD and LDM/STM, or
that deal with alignment exceptions taken in kernel mode.

Cc: debian-arm@lists.debian.org
Cc: Vagrant Cascadian 
Cc: Riku Voipio 
Cc: Steve McIntyre 
Signed-off-by: Ard Biesheuvel 
---
Note to cc'ees: if this is something you would like to see merged,
please indicate so. This stuff is unlikely to get in if there are no
users.

v2: - drop some obsolete comments
 - emit a perf alignment-fault event for every handled instruction
 - use arm64_skip_faulting_instruction() to get the correct behavior
   wrt IT state and single step
 - use types with correct endianness annotation (instructions are
   always little endian on v7/v8+)

  arch/arm64/Kconfig   |   4 +
  arch/arm64/include/asm/exception.h   |   1 +
  arch/arm64/kernel/Makefile   |   1 +
  arch/arm64/kernel/compat_alignment.c | 389 
  arch/arm64/mm/fault.c|   3 +
  5 files changed, 398 insertions(+)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 1652a9800ebe..401e4f8fa149 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1508,6 +1508,10 @@ config THUMB2_COMPAT_VDSO
  Compile the compat vDSO with '-mthumb -fomit-frame-pointer' if y,
  otherwise with '-marm'.
  
+config COMPAT_ALIGNMENT_FIXUPS

+   bool "Fix up misaligned multi-word loads and stores in user space"
+   default y
+
  menuconfig ARMV8_DEPRECATED
bool "Emulate deprecated/obsolete ARMv8 instructions"
depends on SYSCTL
diff --git a/arch/arm64/include/asm/exception.h 
b/arch/arm64/include/asm/exception.h
index d94aecff9690..e92ca08f754c 100644
--- a/arch/arm64/include/asm/exception.h
+++ b/arch/arm64/include/asm/exception.h
@@ -70,6 +70,7 @@ void do_sysinstr(unsigned long esr, struct pt_regs *regs);
  void do_sp_pc_abort(unsigned long addr, unsigned long esr, struct pt_regs 
*regs);
  void bad_el0_sync(struct pt_regs *regs, int reason, unsigned long esr);
  void do_cp15instr(unsigned long esr, struct pt_regs *regs);
+int do_compat_alignment_fixup(unsigned long addr, struct pt_regs *regs);
  void do_el0_svc(struct pt_regs *regs);
  void do_el0_svc_compat(struct pt_regs *regs);
  void do_ptrauth_fault(struct pt_regs *regs, unsigned long esr);
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index fa7981d0d917..58b472fa34fe 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -40,6 +40,7 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE
  obj-$(CONFIG_COMPAT)  += sys32.o signal32.o   
\
   sys_compat.o
  obj-$(CONFIG_COMPAT)  += sigreturn32.o
+obj-$(CONFIG_COMPAT_ALIGNMENT_FIXUPS)  += compat_alignment.o
  obj-$(CONFIG_KUSER_HELPERS)   += kuser32.o
  obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o
  obj-$(CONFIG_MODULES) += module.o
diff --git a/arch/arm64/kernel/compat_alignment.c 
b/arch/arm64/kernel/compat_alignment.c
new file mode 100644
index ..3b41557803a3
--- /dev/null
+++ b/arch/arm64/kernel/compat_alignment.c
@@ -0,0 +1,387 @@
+// SPDX-License-Identifier: GPL-2.0-only
+// based on arch/arm/mm/alignment.c
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+/*
+ * 32-bit misaligned trap handler (c) 1998 San Mehat (CCC) -July 1998
+ *
+ * Speed 

Re: [PATCH v2] arm64: compat: Implement misalignment fixups for multiword loads

2022-07-01 Thread Arnd Bergmann
On Fri, Jul 1, 2022 at 3:53 PM Ard Biesheuvel  wrote:
>
> v2: - drop some obsolete comments
> - emit a perf alignment-fault event for every handled instruction
> - use arm64_skip_faulting_instruction() to get the correct behavior
>   wrt IT state and single step
> - use types with correct endianness annotation (instructions are
>   always little endian on v7/v8+)

Reviewed-by: Arnd Bergmann