All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Desaulniers <ndesaulniers@google.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Russell King <linux@armlinux.org.uk>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Ard Biesheuvel <ardb@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Nathan Chancellor <nathan@kernel.org>,
	llvm@lists.linux.dev, David Spickett <david.spickett@linaro.org>
Subject: Re: [PATCH 06/14] ARM: disallow CONFIG_THUMB with ARMv4
Date: Wed, 29 Sep 2021 11:52:11 -0700	[thread overview]
Message-ID: <CAKwvOdngJj-b=MJ2-Bik6dQGoambMZxGdZyVeO0O5KkaMhhU3Q@mail.gmail.com> (raw)
In-Reply-To: <20210928154143.2106903-7-arnd@kernel.org>

On Tue, Sep 28, 2021 at 8:42 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> We can currently build a multi-cpu enabled kernel that allows both ARMv4
> and ARMv5 CPUs, and also supports THUMB mode in user space.
>
> However, returning to user space in this configuration with the usr_ret
> macro requires the use of the 'bx' instruction, which is refused by
> the assembler:
>
> arch/arm/kernel/entry-armv.S: Assembler messages:
> arch/arm/kernel/entry-armv.S:937: Error: selected processor does not support `bx lr' in ARM mode
> arch/arm/kernel/entry-armv.S:960: Error: selected processor does not support `bx lr' in ARM mode
> arch/arm/kernel/entry-armv.S:1003: Error: selected processor does not support `bx lr' in ARM mode
> <instantiation>:2:2: note: instruction requires: armv4t
>  bx lr
>
> While it would be possible to handle this correctly in principle, doing so
> seems to not be worth it, if we can simply avoid the problem by enforcing

does `mov pc, lr` work here, with a preprocessor guard on CPU_32v4? Or
better yet...

If `ret` is just an assembler macro
(arch/arm/include/asm/assembler.h#L449), then perhaps always just
using `ret` would be preferable here? In that case, it looks like
`usr_ret` could be outright replaced with just expansions of `ret`?

Just spitballing ideas; like you said, maybe not worth fixing.

> that a kernel supporting both ARMv4 and a later CPU architecture cannot
> run THUMB binaries.
>
> This turned up while build-testing with clang; for some reason,
> gcc never triggered the problem.

I suspect this is a Clang's integrated assembler vs GAS difference
(compiler irrelevant); clang's assembler is more strict that `bx lr`
requires armvt (CPU_32v4T).  Though I can reproduce that exact message
in local testing with GAS:

$ cat foo.s
bx lr
$ arm-linux-gnueabi-as -march=armv4 -c foo.s
foo.s: Assembler messages:
foo.s:1: Error: selected processor does not support `bx lr' in ARM mode
$ arm-linux-gnueabi-as -march=armv4t -c foo.s
$ arm-linux-gnueabi-objdump -dr a.out
...
00000000 <.text>:
   0:   e12fff1e        bx      lr
                        0: R_ARM_V4BX   *ABS*

The `<instantiation>:2:2` makes me think of inline asm.

>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  arch/arm/mm/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
> index 82aa990c4180..58afba346729 100644
> --- a/arch/arm/mm/Kconfig
> +++ b/arch/arm/mm/Kconfig
> @@ -675,7 +675,7 @@ config ARM_PV_FIXUP
>
>  config ARM_THUMB
>         bool "Support Thumb user binaries" if !CPU_THUMBONLY && EXPERT
> -       depends on CPU_THUMB_CAPABLE
> +       depends on CPU_THUMB_CAPABLE && !CPU_32v4
>         default y
>         help
>           Say Y if you want to include kernel support for running user space
> --
> 2.29.2
>


-- 
Thanks,
~Nick Desaulniers

WARNING: multiple messages have this Message-ID (diff)
From: Nick Desaulniers <ndesaulniers@google.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Russell King <linux@armlinux.org.uk>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	 Ard Biesheuvel <ardb@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	 Nathan Chancellor <nathan@kernel.org>,
	llvm@lists.linux.dev,  David Spickett <david.spickett@linaro.org>
Subject: Re: [PATCH 06/14] ARM: disallow CONFIG_THUMB with ARMv4
Date: Wed, 29 Sep 2021 11:52:11 -0700	[thread overview]
Message-ID: <CAKwvOdngJj-b=MJ2-Bik6dQGoambMZxGdZyVeO0O5KkaMhhU3Q@mail.gmail.com> (raw)
In-Reply-To: <20210928154143.2106903-7-arnd@kernel.org>

On Tue, Sep 28, 2021 at 8:42 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> We can currently build a multi-cpu enabled kernel that allows both ARMv4
> and ARMv5 CPUs, and also supports THUMB mode in user space.
>
> However, returning to user space in this configuration with the usr_ret
> macro requires the use of the 'bx' instruction, which is refused by
> the assembler:
>
> arch/arm/kernel/entry-armv.S: Assembler messages:
> arch/arm/kernel/entry-armv.S:937: Error: selected processor does not support `bx lr' in ARM mode
> arch/arm/kernel/entry-armv.S:960: Error: selected processor does not support `bx lr' in ARM mode
> arch/arm/kernel/entry-armv.S:1003: Error: selected processor does not support `bx lr' in ARM mode
> <instantiation>:2:2: note: instruction requires: armv4t
>  bx lr
>
> While it would be possible to handle this correctly in principle, doing so
> seems to not be worth it, if we can simply avoid the problem by enforcing

does `mov pc, lr` work here, with a preprocessor guard on CPU_32v4? Or
better yet...

If `ret` is just an assembler macro
(arch/arm/include/asm/assembler.h#L449), then perhaps always just
using `ret` would be preferable here? In that case, it looks like
`usr_ret` could be outright replaced with just expansions of `ret`?

Just spitballing ideas; like you said, maybe not worth fixing.

> that a kernel supporting both ARMv4 and a later CPU architecture cannot
> run THUMB binaries.
>
> This turned up while build-testing with clang; for some reason,
> gcc never triggered the problem.

I suspect this is a Clang's integrated assembler vs GAS difference
(compiler irrelevant); clang's assembler is more strict that `bx lr`
requires armvt (CPU_32v4T).  Though I can reproduce that exact message
in local testing with GAS:

$ cat foo.s
bx lr
$ arm-linux-gnueabi-as -march=armv4 -c foo.s
foo.s: Assembler messages:
foo.s:1: Error: selected processor does not support `bx lr' in ARM mode
$ arm-linux-gnueabi-as -march=armv4t -c foo.s
$ arm-linux-gnueabi-objdump -dr a.out
...
00000000 <.text>:
   0:   e12fff1e        bx      lr
                        0: R_ARM_V4BX   *ABS*

The `<instantiation>:2:2` makes me think of inline asm.

>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  arch/arm/mm/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
> index 82aa990c4180..58afba346729 100644
> --- a/arch/arm/mm/Kconfig
> +++ b/arch/arm/mm/Kconfig
> @@ -675,7 +675,7 @@ config ARM_PV_FIXUP
>
>  config ARM_THUMB
>         bool "Support Thumb user binaries" if !CPU_THUMBONLY && EXPERT
> -       depends on CPU_THUMB_CAPABLE
> +       depends on CPU_THUMB_CAPABLE && !CPU_32v4
>         default y
>         help
>           Say Y if you want to include kernel support for running user space
> --
> 2.29.2
>


-- 
Thanks,
~Nick Desaulniers

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

  reply	other threads:[~2021-09-29 18:52 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28 15:41 [PATCH 00/14] ARM: randconfig build fixes Arnd Bergmann
2021-09-28 15:41 ` Arnd Bergmann
2021-09-28 15:41 ` [PATCH 01/14] ARM: RiscPC needs older gcc version Arnd Bergmann
2021-09-28 15:41   ` Arnd Bergmann
2021-09-28 16:03   ` Arnd Bergmann
2021-09-28 16:03     ` Arnd Bergmann
2021-09-28 16:03     ` Arnd Bergmann
2021-09-29  8:45     ` Arnd Bergmann
2021-09-29  8:45       ` Arnd Bergmann
2021-09-29  8:45       ` Arnd Bergmann
2021-09-28 15:41 ` [PATCH 02/14] ARM: patch: fix BE32 compilation Arnd Bergmann
2021-09-28 15:41   ` Arnd Bergmann
2021-09-28 21:33   ` Linus Walleij
2021-09-28 21:33     ` Linus Walleij
2021-09-28 21:33     ` Linus Walleij
2021-09-28 15:41 ` [PATCH 03/14] ARM: remove duplicate memcpy() definition Arnd Bergmann
2021-09-28 15:41   ` Arnd Bergmann
2021-09-28 21:39   ` Linus Walleij
2021-09-28 21:39     ` Linus Walleij
2021-09-28 21:39     ` Linus Walleij
2021-09-28 15:41 ` [PATCH 04/14] ARM: kprobes: address gcc -Wempty-body warning Arnd Bergmann
2021-09-28 15:41   ` Arnd Bergmann
2021-09-28 15:41 ` [PATCH 05/14] ARM: ARMv7-M uses BE-8, not BE-32 Arnd Bergmann
2021-09-28 15:41   ` Arnd Bergmann
2021-09-28 15:41 ` [PATCH 06/14] ARM: disallow CONFIG_THUMB with ARMv4 Arnd Bergmann
2021-09-28 15:41   ` Arnd Bergmann
2021-09-29 18:52   ` Nick Desaulniers [this message]
2021-09-29 18:52     ` Nick Desaulniers
2021-09-29 18:52     ` Nick Desaulniers
2021-10-06 16:01   ` Ard Biesheuvel
2021-10-06 16:01     ` Ard Biesheuvel
2021-09-28 15:41 ` [PATCH 07/14] ARM: fix link warning with XIP + frame-pointer Arnd Bergmann
2021-09-28 15:41   ` Arnd Bergmann
2021-09-28 15:41 ` [PATCH 08/14] ARM: kprobes: fix arch_init_kprobes() prototype Arnd Bergmann
2021-09-28 15:41   ` Arnd Bergmann
2021-09-28 15:41 ` [PATCH 09/14] ARM: allow compile-testing without machine record Arnd Bergmann
2021-09-28 15:41   ` Arnd Bergmann
2021-09-28 15:41 ` [PATCH 10/14] ARM: only warn about XIP address when not compile testing Arnd Bergmann
2021-09-28 15:41   ` Arnd Bergmann
2021-09-28 15:41 ` [PATCH 11/14] ARM: kasan: work around LPAE build warning Arnd Bergmann
2021-09-28 15:41   ` Arnd Bergmann
2021-09-28 15:41 ` [PATCH 12/14] ARM: add CONFIG_PHYS_OFFSET default values Arnd Bergmann
2021-09-28 15:41   ` Arnd Bergmann
2021-09-28 16:02   ` Nicolas Pitre
2021-09-28 16:02     ` Nicolas Pitre
2021-09-28 16:02     ` Nicolas Pitre
2021-09-28 21:44   ` Linus Walleij
2021-09-28 21:44     ` Linus Walleij
2021-09-28 21:44     ` Linus Walleij
2021-09-28 15:41 ` [PATCH 13/14] ARM: use .arch directives instead of assembler command line flags Arnd Bergmann
2021-09-28 15:41   ` Arnd Bergmann
2021-09-28 17:10   ` Nick Desaulniers
2021-09-28 17:10     ` Nick Desaulniers
2021-09-28 17:10     ` Nick Desaulniers
2021-09-28 18:32     ` Arnd Bergmann
2021-09-28 18:32       ` Arnd Bergmann
2021-09-28 18:32       ` Arnd Bergmann
2021-09-29 18:11       ` Nick Desaulniers
2021-09-29 18:11         ` Nick Desaulniers
2021-09-29 18:11         ` Nick Desaulniers
2022-01-21 22:17   ` Nathan Chancellor
2022-01-21 22:17     ` Nathan Chancellor
2021-09-28 15:41 ` [PATCH 14/14] [RFC] ARM: forbid ftrace with clang and thumb2_kernel Arnd Bergmann
2021-09-28 15:41   ` Arnd Bergmann
2021-09-28 17:20   ` Nick Desaulniers
2021-09-28 17:20     ` Nick Desaulniers
2021-09-28 17:20     ` Nick Desaulniers

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='CAKwvOdngJj-b=MJ2-Bik6dQGoambMZxGdZyVeO0O5KkaMhhU3Q@mail.gmail.com' \
    --to=ndesaulniers@google.com \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=david.spickett@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@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 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.