2019-03-05 22:20:00

by Stefan Agner

[permalink] [raw]
Subject: [PATCH 1/2] ARM: drop unnecessary WASM

The W macro for generating wide instructions when targeting Thumb-2
is not required for the preload data instructions (pld, pldw) since
they are only available as wide instructions. The GNU assembler seems
to work with or without the .w appended when compiling an Thumb-2
kernel. However, Clang's integrated assembler does not consider the
.w variants as valid instructions:

./arch/arm/include/asm/processor.h:133:5: error: invalid instruction
"pldw.w\t%a0 \n"
^
<inline asm>:2:1: note: instantiated into assembly here
pldw.w [r0]
^
1 error generated.

Drop the macro to make sure non-wide variants of pld and pldw are
emitted in all cases.

Signed-off-by: Stefan Agner <[email protected]>
---
arch/arm/include/asm/processor.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
index 120f4c9bbfde..042d77cf686d 100644
--- a/arch/arm/include/asm/processor.h
+++ b/arch/arm/include/asm/processor.h
@@ -131,8 +131,8 @@ static inline void prefetchw(const void *ptr)
__asm__ __volatile__(
".arch_extension mp\n"
__ALT_SMP_ASM(
- WASM(pldw) "\t%a0",
- WASM(pld) "\t%a0"
+ "pldw\t%a0",
+ "pld\t%a0"
)
:: "p" (ptr));
}
--
2.20.1



2019-03-05 22:22:19

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH 2/2] ARM: drop -mauto-it

On Tue, Mar 5, 2019 at 2:17 PM Stefan Agner <[email protected]> wrote:
>
> The assembler option -mauto-it is no longer a valid option. It has
> been removed from the documentation in July 2009, which is well
> before the release date of the currently supported binutils version
> 2.20.

Do you by chance have a link to the relevant commit?

>
> Signed-off-by: Stefan Agner <[email protected]>
> ---
> arch/arm/Makefile | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> index 9561325c5201..ebf67bebe73d 100644
> --- a/arch/arm/Makefile
> +++ b/arch/arm/Makefile
> @@ -113,8 +113,7 @@ CFLAGS_ABI +=-funwind-tables
> endif
>
> ifeq ($(CONFIG_THUMB2_KERNEL),y)
> -AFLAGS_AUTOIT :=$(call as-option,-Wa$(comma)-mimplicit-it=always,-Wa$(comma)-mauto-it)
> -CFLAGS_ISA :=-mthumb $(AFLAGS_AUTOIT)
> +CFLAGS_ISA :=-mthumb -Wa$(comma)-mimplicit-it=always

Is $(comma) still needed? I thought it was only needed when a flag
that would contain commas would be in another set of parens (thus
making an ambiguity), like cc-ldoption or such? Can you replace
`$(comma)` here with `,`? I suspect it should work.

--
Thanks,
~Nick Desaulniers

2019-03-05 22:23:15

by Stefan Agner

[permalink] [raw]
Subject: [PATCH 2/2] ARM: drop -mauto-it

The assembler option -mauto-it is no longer a valid option. It has
been removed from the documentation in July 2009, which is well
before the release date of the currently supported binutils version
2.20.

Signed-off-by: Stefan Agner <[email protected]>
---
arch/arm/Makefile | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 9561325c5201..ebf67bebe73d 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -113,8 +113,7 @@ CFLAGS_ABI +=-funwind-tables
endif

ifeq ($(CONFIG_THUMB2_KERNEL),y)
-AFLAGS_AUTOIT :=$(call as-option,-Wa$(comma)-mimplicit-it=always,-Wa$(comma)-mauto-it)
-CFLAGS_ISA :=-mthumb $(AFLAGS_AUTOIT)
+CFLAGS_ISA :=-mthumb -Wa$(comma)-mimplicit-it=always
AFLAGS_ISA :=$(CFLAGS_ISA) -Wa$(comma)-mthumb
# Work around buggy relocation from gas if requested:
ifeq ($(CONFIG_THUMB2_AVOID_R_ARM_THM_JUMP11),y)
--
2.20.1


2019-03-05 22:41:52

by Stefan Agner

[permalink] [raw]
Subject: Re: [PATCH 2/2] ARM: drop -mauto-it

On 05.03.2019 23:21, Nick Desaulniers wrote:
> On Tue, Mar 5, 2019 at 2:17 PM Stefan Agner <[email protected]> wrote:
>>
>> The assembler option -mauto-it is no longer a valid option. It has
>> been removed from the documentation in July 2009, which is well
>> before the release date of the currently supported binutils version
>> 2.20.
>
> Do you by chance have a link to the relevant commit?
>

Documentation got removed in
https://github.com/bminor/binutils-gdb/commit/529707530657a333a304c651c808ea630c955223

I think -mauto-it never really made it upstream. Documentation has been
introduced here, but it seems that the option already has been renamed:
https://github.com/bminor/binutils-gdb/commit/e07e6e58be1c5273ed79a25c80ba831e71ac86b1

>>
>> Signed-off-by: Stefan Agner <[email protected]>
>> ---
>> arch/arm/Makefile | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
>> index 9561325c5201..ebf67bebe73d 100644
>> --- a/arch/arm/Makefile
>> +++ b/arch/arm/Makefile
>> @@ -113,8 +113,7 @@ CFLAGS_ABI +=-funwind-tables
>> endif
>>
>> ifeq ($(CONFIG_THUMB2_KERNEL),y)
>> -AFLAGS_AUTOIT :=$(call as-option,-Wa$(comma)-mimplicit-it=always,-Wa$(comma)-mauto-it)
>> -CFLAGS_ISA :=-mthumb $(AFLAGS_AUTOIT)
>> +CFLAGS_ISA :=-mthumb -Wa$(comma)-mimplicit-it=always
>
> Is $(comma) still needed? I thought it was only needed when a flag
> that would contain commas would be in another set of parens (thus
> making an ambiguity), like cc-ldoption or such? Can you replace
> `$(comma)` here with `,`? I suspect it should work.

Could catch, yes comma should work here.

--
Stefan

2019-03-05 23:23:17

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH 2/2] ARM: drop -mauto-it

On Tue, Mar 5, 2019 at 2:40 PM Stefan Agner <[email protected]> wrote:
>
> On 05.03.2019 23:21, Nick Desaulniers wrote:
> > On Tue, Mar 5, 2019 at 2:17 PM Stefan Agner <[email protected]> wrote:
> >>
> >> The assembler option -mauto-it is no longer a valid option. It has
> >> been removed from the documentation in July 2009, which is well
> >> before the release date of the currently supported binutils version
> >> 2.20.
> >
> > Do you by chance have a link to the relevant commit?
> >
>
> Documentation got removed in
> https://github.com/bminor/binutils-gdb/commit/529707530657a333a304c651c808ea630c955223

The minimum version of binutils as per
Documentation/process/changes.rst is 2.20. Looks like 2.20 was
released around 2009-09-04:
https://github.com/bminor/binutils-gdb/commit/81c23f829ee829524ac3bf0b9422f8950306d1d6#diff-2bb5799f8d22903a285e71e925800c08

>
> I think -mauto-it never really made it upstream. Documentation has been
> introduced here, but it seems that the option already has been renamed:
> https://github.com/bminor/binutils-gdb/commit/e07e6e58be1c5273ed79a25c80ba831e71ac86b1
>
> >>
> >> Signed-off-by: Stefan Agner <[email protected]>
> >> ---
> >> arch/arm/Makefile | 3 +--
> >> 1 file changed, 1 insertion(+), 2 deletions(-)
> >>
> >> diff --git a/arch/arm/Makefile b/arch/arm/Makefile
> >> index 9561325c5201..ebf67bebe73d 100644
> >> --- a/arch/arm/Makefile
> >> +++ b/arch/arm/Makefile
> >> @@ -113,8 +113,7 @@ CFLAGS_ABI +=-funwind-tables
> >> endif
> >>
> >> ifeq ($(CONFIG_THUMB2_KERNEL),y)
> >> -AFLAGS_AUTOIT :=$(call as-option,-Wa$(comma)-mimplicit-it=always,-Wa$(comma)-mauto-it)
> >> -CFLAGS_ISA :=-mthumb $(AFLAGS_AUTOIT)
> >> +CFLAGS_ISA :=-mthumb -Wa$(comma)-mimplicit-it=always
> >
> > Is $(comma) still needed? I thought it was only needed when a flag
> > that would contain commas would be in another set of parens (thus
> > making an ambiguity), like cc-ldoption or such? Can you replace
> > `$(comma)` here with `,`? I suspect it should work.
>
> Could catch, yes comma should work here.

Cool, if you wouldn't mind sending a v2 with that change, feel free to
add my reviewed by tag.
--
Thanks,
~Nick Desaulniers

2019-03-06 00:31:12

by Robin Murphy

[permalink] [raw]
Subject: Re: [PATCH 1/2] ARM: drop unnecessary WASM

Hi Stefan,

On 2019-03-05 10:18 pm, Stefan Agner wrote:
> The W macro for generating wide instructions when targeting Thumb-2
> is not required for the preload data instructions (pld, pldw) since
> they are only available as wide instructions. The GNU assembler seems
> to work with or without the .w appended when compiling an Thumb-2
> kernel. However, Clang's integrated assembler does not consider the
> .w variants as valid instructions:
>
> ./arch/arm/include/asm/processor.h:133:5: error: invalid instruction
> "pldw.w\t%a0 \n"
> ^
> <inline asm>:2:1: note: instantiated into assembly here
> pldw.w [r0]
> ^
> 1 error generated.

Have you filed a bug against Clang for that? Something like "pldwal.w"
may be super-redundant, but it's still perfectly valid syntax. The
"Standard assembler syntax fields" section of the Arm ARM even calls out
that "...the .W qualifier has no effect" on ARM/A32 instructions since
they are inherently 32-bit; that should equally apply for 32-bit only
Thumb/T32 instructions. There are certainly a few instructions which
don't allow a condition code (even "AL"), but off-hand I don't remember
any not having the optional {<q>} field in their syntax.

That said, obviously the patch itself is no problem since the syntax
*is* redundant here, but it really is just a workaround for an assembler
bug.

Robin.

> Drop the macro to make sure non-wide variants of pld and pldw are
> emitted in all cases.
>
> Signed-off-by: Stefan Agner <[email protected]>
> ---
> arch/arm/include/asm/processor.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
> index 120f4c9bbfde..042d77cf686d 100644
> --- a/arch/arm/include/asm/processor.h
> +++ b/arch/arm/include/asm/processor.h
> @@ -131,8 +131,8 @@ static inline void prefetchw(const void *ptr)
> __asm__ __volatile__(
> ".arch_extension mp\n"
> __ALT_SMP_ASM(
> - WASM(pldw) "\t%a0",
> - WASM(pld) "\t%a0"
> + "pldw\t%a0",
> + "pld\t%a0"
> )
> :: "p" (ptr));
> }
>

2019-03-06 00:55:03

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH 1/2] ARM: drop unnecessary WASM

On Tue, Mar 5, 2019 at 3:39 PM Robin Murphy <[email protected]> wrote:
>
> Hi Stefan,
>
> On 2019-03-05 10:18 pm, Stefan Agner wrote:
> > The W macro for generating wide instructions when targeting Thumb-2
> > is not required for the preload data instructions (pld, pldw) since
> > they are only available as wide instructions. The GNU assembler seems
> > to work with or without the .w appended when compiling an Thumb-2
> > kernel. However, Clang's integrated assembler does not consider the
> > .w variants as valid instructions:
> >
> > ./arch/arm/include/asm/processor.h:133:5: error: invalid instruction
> > "pldw.w\t%a0 \n"
> > ^
> > <inline asm>:2:1: note: instantiated into assembly here
> > pldw.w [r0]
> > ^
> > 1 error generated.
>
> Have you filed a bug against Clang for that? Something like "pldwal.w"

Yes; please. For each deficiency you find, please file a bug. We're
working on identifying what's missing from Clang's integrated
assembler support. Given the list of issues, it's easier to estimate
how much effort is needed, which helps us allocate resources towards
fixing those issues better.

It would be good to know if pldw.w is valid under UAL or not.

Hopefully, the ARM kernel team can stress the importance of assembler
support for their ISA to their LLVM team.
--
Thanks,
~Nick Desaulniers

2019-03-06 09:24:20

by Stefan Agner

[permalink] [raw]
Subject: Re: [PATCH 1/2] ARM: drop unnecessary WASM

On 06.03.2019 00:39, Robin Murphy wrote:
> Hi Stefan,
>
> On 2019-03-05 10:18 pm, Stefan Agner wrote:
>> The W macro for generating wide instructions when targeting Thumb-2
>> is not required for the preload data instructions (pld, pldw) since
>> they are only available as wide instructions. The GNU assembler seems
>> to work with or without the .w appended when compiling an Thumb-2
>> kernel. However, Clang's integrated assembler does not consider the
>> .w variants as valid instructions:
>>
>> ./arch/arm/include/asm/processor.h:133:5: error: invalid instruction
>> "pldw.w\t%a0 \n"
>> ^
>> <inline asm>:2:1: note: instantiated into assembly here
>> pldw.w [r0]
>> ^
>> 1 error generated.
>
> Have you filed a bug against Clang for that? Something like "pldwal.w"
> may be super-redundant, but it's still perfectly valid syntax. The
> "Standard assembler syntax fields" section of the Arm ARM even calls
> out that "...the .W qualifier has no effect" on ARM/A32 instructions
> since they are inherently 32-bit; that should equally apply for 32-bit
> only Thumb/T32 instructions. There are certainly a few instructions
> which don't allow a condition code (even "AL"), but off-hand I don't
> remember any not having the optional {<q>} field in their syntax.

Good point, bug filed:
https://bugs.llvm.org/show_bug.cgi?id=40972

Will send a v2 and note that this is a work around for Clang and
reference the bug.

--
Stefan

>
> That said, obviously the patch itself is no problem since the syntax
> *is* redundant here, but it really is just a workaround for an
> assembler bug.
>
> Robin.
>
>> Drop the macro to make sure non-wide variants of pld and pldw are
>> emitted in all cases.
>>
>> Signed-off-by: Stefan Agner <[email protected]>
>> ---
>> arch/arm/include/asm/processor.h | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
>> index 120f4c9bbfde..042d77cf686d 100644
>> --- a/arch/arm/include/asm/processor.h
>> +++ b/arch/arm/include/asm/processor.h
>> @@ -131,8 +131,8 @@ static inline void prefetchw(const void *ptr)
>> __asm__ __volatile__(
>> ".arch_extension mp\n"
>> __ALT_SMP_ASM(
>> - WASM(pldw) "\t%a0",
>> - WASM(pld) "\t%a0"
>> + "pldw\t%a0",
>> + "pld\t%a0"
>> )
>> :: "p" (ptr));
>> }
>>

2019-03-17 15:47:28

by Stefan Agner

[permalink] [raw]
Subject: Re: [PATCH 1/2] ARM: drop unnecessary WASM

On 06.03.2019 01:47, Nick Desaulniers wrote:
> On Tue, Mar 5, 2019 at 3:39 PM Robin Murphy <[email protected]> wrote:
>>
>> Hi Stefan,
>>
>> On 2019-03-05 10:18 pm, Stefan Agner wrote:
>> > The W macro for generating wide instructions when targeting Thumb-2
>> > is not required for the preload data instructions (pld, pldw) since
>> > they are only available as wide instructions. The GNU assembler seems
>> > to work with or without the .w appended when compiling an Thumb-2
>> > kernel. However, Clang's integrated assembler does not consider the
>> > .w variants as valid instructions:
>> >
>> > ./arch/arm/include/asm/processor.h:133:5: error: invalid instruction
>> > "pldw.w\t%a0 \n"
>> > ^
>> > <inline asm>:2:1: note: instantiated into assembly here
>> > pldw.w [r0]
>> > ^
>> > 1 error generated.
>>
>> Have you filed a bug against Clang for that? Something like "pldwal.w"
>
> Yes; please. For each deficiency you find, please file a bug. We're
> working on identifying what's missing from Clang's integrated
> assembler support. Given the list of issues, it's easier to estimate
> how much effort is needed, which helps us allocate resources towards
> fixing those issues better.
>
> It would be good to know if pldw.w is valid under UAL or not.

As far as I understand the Arm ARM it is valid under UAL.

Reported a bug in LLVM's bug tracker:
https://bugs.llvm.org/show_bug.cgi?id=40972

Will send a v2 patch mentioning this is really a work around for LLVM
and link to the bug report.

>
> Hopefully, the ARM kernel team can stress the importance of assembler
> support for their ISA to their LLVM team.

--
Stefan