All of lore.kernel.org
 help / color / mirror / Atom feed
* Problems with arm64 compat vdso
@ 2019-09-20 14:27 Will Deacon
  2019-09-20 16:33 ` Vincenzo Frascino
                   ` (3 more replies)
  0 siblings, 4 replies; 127+ messages in thread
From: Will Deacon @ 2019-09-20 14:27 UTC (permalink / raw)
  To: vincenzo.frascino
  Cc: linux-kernel, linux-kernel, tglx, linux, ard.biesheuvel, catalin.marinas

Hi Vincenzo,

I've been running into a few issues with the COMPAT vDSO. Please could
you have a look?

If I do the following:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
[...]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
[set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

Then I see the following warning:

arch/arm64/Makefile:62: CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built

even though the compat vDSO *has* been built:

$ file arch/arm64/kernel/vdso32/vdso.so
arch/arm64/kernel/vdso32/vdso.so: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=c67f6c786f2d2d6f86c71f708595594aa25247f6, stripped

However, I also get some warnings because arm64 headers are being included
in the compat vDSO build:

In file included from ./arch/arm64/include/asm/thread_info.h:17:0,
                 from ./include/linux/thread_info.h:38,
                 from ./arch/arm64/include/asm/preempt.h:5,
                 from ./include/linux/preempt.h:78,
                 from ./include/linux/spinlock.h:51,
                 from ./include/linux/seqlock.h:36,
                 from ./include/linux/time.h:6,
                 from /usr/local/google/home/willdeacon/work/linux/lib/vdso/gettimeofday.c:7,
                 from <command-line>:0:
./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  u64 __addr = (u64)addr & ~__tag_shifted(0xff);
               ^
In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0,
                 from ./arch/arm64/include/asm/processor.h:34,
                 from ./arch/arm64/include/asm/elf.h:118,
                 from ./include/linux/elf.h:5,
                 from ./include/linux/elfnote.h:62,
                 from arch/arm64/kernel/vdso32/note.c:11:
./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  u64 __addr = (u64)addr & ~__tag_shifted(0xff);
               ^
Worse, if your compat binutils isn't up-to-date, you'll actually run into
a build failure:

/tmp/ccFCrjUg.s:80: Error: invalid barrier type -- `dmb ishld'
/tmp/ccFCrjUg.s:124: Error: invalid barrier type -- `dmb ishld'

There also appears to be a problem getting the toolchain prefix from Kconfig.
If, for example, I do:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
[...]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
[set CONFIG_CROSS_COMPILE_COMPAT_VDSO="vincenzo"]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
arch/arm64/Makefile:64: *** vincenzogcc not found, check CROSS_COMPILE_COMPAT.  Stop.
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
[set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
arch/arm64/Makefile:64: *** vincenzogcc not found, check CROSS_COMPILE_COMPAT.  Stop.
$ grep CONFIG_CROSS_COMPILE_COMPAT_VDSO .config
CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"

which is irritating, because it seems to force a 'mrproper' if you don't
get the prefix right first time.

Cheers,

Will

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: Problems with arm64 compat vdso
  2019-09-20 14:27 Problems with arm64 compat vdso Will Deacon
@ 2019-09-20 16:33 ` Vincenzo Frascino
  2019-09-23 16:41   ` Ard Biesheuvel
  2019-09-26  6:03   ` Vincenzo Frascino
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-20 16:33 UTC (permalink / raw)
  To: Will Deacon
  Cc: linux-kernel, linux-kernel, tglx, linux, ard.biesheuvel, catalin.marinas

[-- Attachment #1: Type: text/plain, Size: 3814 bytes --]

Hi Will,

thank you for reporting this.

On 20/09/2019 15:27, Will Deacon wrote:
> Hi Vincenzo,
> 
> I've been running into a few issues with the COMPAT vDSO. Please could
> you have a look?
> 

I will be at Linux Recipes next week. I will look at this with priority when I
come back.

> If I do the following:
> 
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
> [...]
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
> [set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
> 
> Then I see the following warning:
> 
> arch/arm64/Makefile:62: CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built
> 
> even though the compat vDSO *has* been built:
> 
> $ file arch/arm64/kernel/vdso32/vdso.so
> arch/arm64/kernel/vdso32/vdso.so: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=c67f6c786f2d2d6f86c71f708595594aa25247f6, stripped
> 
> However, I also get some warnings because arm64 headers are being included
> in the compat vDSO build:
> 
> In file included from ./arch/arm64/include/asm/thread_info.h:17:0,
>                  from ./include/linux/thread_info.h:38,
>                  from ./arch/arm64/include/asm/preempt.h:5,
>                  from ./include/linux/preempt.h:78,
>                  from ./include/linux/spinlock.h:51,
>                  from ./include/linux/seqlock.h:36,
>                  from ./include/linux/time.h:6,
>                  from /usr/local/google/home/willdeacon/work/linux/lib/vdso/gettimeofday.c:7,
>                  from <command-line>:0:
> ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
> ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>   u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>                ^
> In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0,
>                  from ./arch/arm64/include/asm/processor.h:34,
>                  from ./arch/arm64/include/asm/elf.h:118,
>                  from ./include/linux/elf.h:5,
>                  from ./include/linux/elfnote.h:62,
>                  from arch/arm64/kernel/vdso32/note.c:11:
> ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
> ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>   u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>                ^
> Worse, if your compat binutils isn't up-to-date, you'll actually run into
> a build failure:
> 
> /tmp/ccFCrjUg.s:80: Error: invalid barrier type -- `dmb ishld'
> /tmp/ccFCrjUg.s:124: Error: invalid barrier type -- `dmb ishld'
> 
> There also appears to be a problem getting the toolchain prefix from Kconfig.
> If, for example, I do:
> 
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
> [...]
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
> [set CONFIG_CROSS_COMPILE_COMPAT_VDSO="vincenzo"]
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
> arch/arm64/Makefile:64: *** vincenzogcc not found, check CROSS_COMPILE_COMPAT.  Stop.
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
> [set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
> arch/arm64/Makefile:64: *** vincenzogcc not found, check CROSS_COMPILE_COMPAT.  Stop.
> $ grep CONFIG_CROSS_COMPILE_COMPAT_VDSO .config
> CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"
> 
> which is irritating, because it seems to force a 'mrproper' if you don't
> get the prefix right first time.
> 
> Cheers,
> 
> Will
> 

-- 
Regards,
Vincenzo

[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 14291 bytes --]

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: Problems with arm64 compat vdso
  2019-09-20 16:33 ` Vincenzo Frascino
@ 2019-09-23 16:41   ` Ard Biesheuvel
  2019-09-24 12:11     ` Vincenzo Frascino
  2019-09-25 15:58     ` Ard Biesheuvel
  0 siblings, 2 replies; 127+ messages in thread
From: Ard Biesheuvel @ 2019-09-23 16:41 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: Will Deacon, linux-kernel, Linux Kernel Mailing List,
	Thomas Gleixner, Russell King, Catalin Marinas

On Fri, 20 Sep 2019 at 18:33, Vincenzo Frascino
<vincenzo.frascino@arm.com> wrote:
>
> Hi Will,
>
> thank you for reporting this.
>
> On 20/09/2019 15:27, Will Deacon wrote:
> > Hi Vincenzo,
> >
> > I've been running into a few issues with the COMPAT vDSO. Please could
> > you have a look?
> >
>
> I will be at Linux Recipes next week. I will look at this with priority when I
> come back.
>

Hi all,

I noticed another issue: I build out of tree, and the VDSO gets
rebuilt every time I build the kernel, even if I haven't made any
changes to the source tree at all.

Could you please look into that as well? (once you get around to it)

Thanks,
Ard.


> > If I do the following:
> >
> > $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
> > [...]
> > $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
> > [set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
> > $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
> >
> > Then I see the following warning:
> >
> > arch/arm64/Makefile:62: CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built
> >
> > even though the compat vDSO *has* been built:
> >
> > $ file arch/arm64/kernel/vdso32/vdso.so
> > arch/arm64/kernel/vdso32/vdso.so: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=c67f6c786f2d2d6f86c71f708595594aa25247f6, stripped
> >
> > However, I also get some warnings because arm64 headers are being included
> > in the compat vDSO build:
> >
> > In file included from ./arch/arm64/include/asm/thread_info.h:17:0,
> >                  from ./include/linux/thread_info.h:38,
> >                  from ./arch/arm64/include/asm/preempt.h:5,
> >                  from ./include/linux/preempt.h:78,
> >                  from ./include/linux/spinlock.h:51,
> >                  from ./include/linux/seqlock.h:36,
> >                  from ./include/linux/time.h:6,
> >                  from /usr/local/google/home/willdeacon/work/linux/lib/vdso/gettimeofday.c:7,
> >                  from <command-line>:0:
> > ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
> > ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
> >   u64 __addr = (u64)addr & ~__tag_shifted(0xff);
> >                ^
> > In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0,
> >                  from ./arch/arm64/include/asm/processor.h:34,
> >                  from ./arch/arm64/include/asm/elf.h:118,
> >                  from ./include/linux/elf.h:5,
> >                  from ./include/linux/elfnote.h:62,
> >                  from arch/arm64/kernel/vdso32/note.c:11:
> > ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
> > ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
> >   u64 __addr = (u64)addr & ~__tag_shifted(0xff);
> >                ^
> > Worse, if your compat binutils isn't up-to-date, you'll actually run into
> > a build failure:
> >
> > /tmp/ccFCrjUg.s:80: Error: invalid barrier type -- `dmb ishld'
> > /tmp/ccFCrjUg.s:124: Error: invalid barrier type -- `dmb ishld'
> >
> > There also appears to be a problem getting the toolchain prefix from Kconfig.
> > If, for example, I do:
> >
> > $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
> > [...]
> > $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
> > [set CONFIG_CROSS_COMPILE_COMPAT_VDSO="vincenzo"]
> > $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
> > arch/arm64/Makefile:64: *** vincenzogcc not found, check CROSS_COMPILE_COMPAT.  Stop.
> > $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
> > [set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
> > $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
> > arch/arm64/Makefile:64: *** vincenzogcc not found, check CROSS_COMPILE_COMPAT.  Stop.
> > $ grep CONFIG_CROSS_COMPILE_COMPAT_VDSO .config
> > CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"
> >
> > which is irritating, because it seems to force a 'mrproper' if you don't
> > get the prefix right first time.
> >
> > Cheers,
> >
> > Will
> >
>
> --
> Regards,
> Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: Problems with arm64 compat vdso
  2019-09-23 16:41   ` Ard Biesheuvel
@ 2019-09-24 12:11     ` Vincenzo Frascino
  2019-09-24 18:06       ` Nick Desaulniers
  2019-09-25 15:58     ` Ard Biesheuvel
  1 sibling, 1 reply; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-24 12:11 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Will Deacon, linux-kernel, Linux Kernel Mailing List,
	Thomas Gleixner, Russell King, Catalin Marinas

Hi Ard,

On 9/23/19 5:41 PM, Ard Biesheuvel wrote:
> On Fri, 20 Sep 2019 at 18:33, Vincenzo Frascino
> <vincenzo.frascino@arm.com> wrote:
>>
>> Hi Will,
>>
>> thank you for reporting this.
>>
>> On 20/09/2019 15:27, Will Deacon wrote:
>>> Hi Vincenzo,
>>>
>>> I've been running into a few issues with the COMPAT vDSO. Please could
>>> you have a look?
>>>
>>
>> I will be at Linux Recipes next week. I will look at this with priority when I
>> come back.
>>
> 
> Hi all,
> 
> I noticed another issue: I build out of tree, and the VDSO gets
> rebuilt every time I build the kernel, even if I haven't made any
> changes to the source tree at all.
> 
> Could you please look into that as well? (once you get around to it)
> 

I am happy to have a look at this once back from Kernel Recipes next week.
In the meantime may I ask for some more details?

Could be useful to have a set of commands and a log that shows the problem, in
this way I will be sure to be looking at the same issue.

> Thanks,
> Ard.
> 
> 
>>> If I do the following:
>>>
>>> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
>>> [...]
>>> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
>>> [set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
>>> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
>>>
>>> Then I see the following warning:
>>>
>>> arch/arm64/Makefile:62: CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built
>>>
>>> even though the compat vDSO *has* been built:
>>>
>>> $ file arch/arm64/kernel/vdso32/vdso.so
>>> arch/arm64/kernel/vdso32/vdso.so: ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=c67f6c786f2d2d6f86c71f708595594aa25247f6, stripped
>>>
>>> However, I also get some warnings because arm64 headers are being included
>>> in the compat vDSO build:
>>>
>>> In file included from ./arch/arm64/include/asm/thread_info.h:17:0,
>>>                  from ./include/linux/thread_info.h:38,
>>>                  from ./arch/arm64/include/asm/preempt.h:5,
>>>                  from ./include/linux/preempt.h:78,
>>>                  from ./include/linux/spinlock.h:51,
>>>                  from ./include/linux/seqlock.h:36,
>>>                  from ./include/linux/time.h:6,
>>>                  from /usr/local/google/home/willdeacon/work/linux/lib/vdso/gettimeofday.c:7,
>>>                  from <command-line>:0:
>>> ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
>>> ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>>>   u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>>>                ^
>>> In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0,
>>>                  from ./arch/arm64/include/asm/processor.h:34,
>>>                  from ./arch/arm64/include/asm/elf.h:118,
>>>                  from ./include/linux/elf.h:5,
>>>                  from ./include/linux/elfnote.h:62,
>>>                  from arch/arm64/kernel/vdso32/note.c:11:
>>> ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
>>> ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
>>>   u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>>>                ^
>>> Worse, if your compat binutils isn't up-to-date, you'll actually run into
>>> a build failure:
>>>
>>> /tmp/ccFCrjUg.s:80: Error: invalid barrier type -- `dmb ishld'
>>> /tmp/ccFCrjUg.s:124: Error: invalid barrier type -- `dmb ishld'
>>>
>>> There also appears to be a problem getting the toolchain prefix from Kconfig.
>>> If, for example, I do:
>>>
>>> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
>>> [...]
>>> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
>>> [set CONFIG_CROSS_COMPILE_COMPAT_VDSO="vincenzo"]
>>> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
>>> arch/arm64/Makefile:64: *** vincenzogcc not found, check CROSS_COMPILE_COMPAT.  Stop.
>>> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
>>> [set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
>>> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
>>> arch/arm64/Makefile:64: *** vincenzogcc not found, check CROSS_COMPILE_COMPAT.  Stop.
>>> $ grep CONFIG_CROSS_COMPILE_COMPAT_VDSO .config
>>> CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"
>>>
>>> which is irritating, because it seems to force a 'mrproper' if you don't
>>> get the prefix right first time.
>>>
>>> Cheers,
>>>
>>> Will
>>>
>>
>> --
>> Regards,
>> Vincenzo

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: Problems with arm64 compat vdso
  2019-09-24 12:11     ` Vincenzo Frascino
@ 2019-09-24 18:06       ` Nick Desaulniers
  2019-09-24 20:42         ` Vincenzo Frascino
  0 siblings, 1 reply; 127+ messages in thread
From: Nick Desaulniers @ 2019-09-24 18:06 UTC (permalink / raw)
  To: vincenzo.frascino
  Cc: ard.biesheuvel, catalin.marinas, linux-kernel, linux-kernel,
	linux, tglx, will, natechancellor

Hi Vincenzo,
We also are having issues building the cross vDSO with Clang:
https://github.com/ClangBuiltLinux/linux/issues/595

It seems that `LINUXINCLUDE` in arch/arm64/kernel/vdso32/Makefile is including
arm64 headers in the arm part of the vdso32 build, which causes Clang to error
on the arm64 inline asm constraints being used in arm64.

I think if the issue Will described is fixed, it will be simpler for us to fix
the rest to get it to build w/ Clang.

https://github.com/ClangBuiltLinux/linux/issues/595#issuecomment-509874891
is the basis of such a patch.

Clang ships with all backends on by default, and uses a `-target <triple>` to
cross compile; so the idea of passing two cross compiler binaries for a compat
vDSO build doesn't really apply to Clang.

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: Problems with arm64 compat vdso
  2019-09-24 18:06       ` Nick Desaulniers
@ 2019-09-24 20:42         ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-24 20:42 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: ard.biesheuvel, catalin.marinas, linux-kernel, linux-kernel,
	linux, tglx, will, natechancellor

Hi Nick,

thanks for reporting this.

On 9/24/19 7:06 PM, Nick Desaulniers wrote:
> Hi Vincenzo,
> We also are having issues building the cross vDSO with Clang:
> https://github.com/ClangBuiltLinux/linux/issues/595
> 

The initial implementation of vdso32 does not have support for Clang. I was
planning to add it with a second patch set but it seems requiring more work.

> It seems that `LINUXINCLUDE` in arch/arm64/kernel/vdso32/Makefile is including
> arm64 headers in the arm part of the vdso32 build, which causes Clang to error
> on the arm64 inline asm constraints being used in arm64.
> 
> I think if the issue Will described is fixed, it will be simpler for us to fix
> the rest to get it to build w/ Clang.
> 
> https://github.com/ClangBuiltLinux/linux/issues/595#issuecomment-509874891
> is the basis of such a patch.
> 

I agree with you this issue needs to be solved once and for all, but I feel that
the solution is not straight forward. Next week I will post a fix to the problem
Will raised and then will start investigating a more long term solution.

> Clang ships with all backends on by default, and uses a `-target <triple>` to
> cross compile; so the idea of passing two cross compiler binaries for a compat
> vDSO build doesn't really apply to Clang.
> 

My idea was to derivate the triple for clang from the compat cross compiler name
removing the final dash.

I have in my Makefile something on the lines:

CLANG_TRIPLE ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%-"=%)
...
COMPATCC := $(CC) --target=$(notdir $CLANG_TRIPLE)


-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: Problems with arm64 compat vdso
  2019-09-23 16:41   ` Ard Biesheuvel
  2019-09-24 12:11     ` Vincenzo Frascino
@ 2019-09-25 15:58     ` Ard Biesheuvel
  1 sibling, 0 replies; 127+ messages in thread
From: Ard Biesheuvel @ 2019-09-25 15:58 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: Will Deacon, linux-kernel, Linux Kernel Mailing List,
	Thomas Gleixner, Russell King, Catalin Marinas

On Mon, 23 Sep 2019 at 18:41, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
> On Fri, 20 Sep 2019 at 18:33, Vincenzo Frascino
> <vincenzo.frascino@arm.com> wrote:
> >
> > Hi Will,
> >
> > thank you for reporting this.
> >
> > On 20/09/2019 15:27, Will Deacon wrote:
> > > Hi Vincenzo,
> > >
> > > I've been running into a few issues with the COMPAT vDSO. Please could
> > > you have a look?
> > >
> >
> > I will be at Linux Recipes next week. I will look at this with priority when I
> > come back.
> >
>
> Hi all,
>
> I noticed another issue: I build out of tree, and the VDSO gets
> rebuilt every time I build the kernel, even if I haven't made any
> changes to the source tree at all.
>
> Could you please look into that as well? (once you get around to it)
>

I haven't managed to reproduce this on a fresh checkout, so it looks
like this is a transient thing.

^ permalink raw reply	[flat|nested] 127+ messages in thread

* [PATCH 0/4] arm64: vdso32: Address various issues
  2019-09-20 14:27 Problems with arm64 compat vdso Will Deacon
@ 2019-09-26  6:03   ` Vincenzo Frascino
  2019-09-26  6:03   ` Vincenzo Frascino
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26  6:03 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

Hi Will,

this patch series is meant to address the various compilation issues you
reported about arm64 vdso32.

Please let me know if there is still something missing.

Thanks,
Vincenzo

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>

Vincenzo Frascino (4):
  arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  arm64: vdso32: Detect binutils support for dmb ishld
  arm64: vdso32: Fix compilation warning
  arm64: Remove gettimeofday.S

 arch/arm64/Kconfig                           |  5 ++++-
 arch/arm64/Makefile                          | 15 ++-------------
 arch/arm64/include/asm/memory.h              |  5 +++++
 arch/arm64/include/asm/vdso/compat_barrier.h |  2 +-
 arch/arm64/kernel/vdso/gettimeofday.S        |  0
 arch/arm64/kernel/vdso32/Makefile            |  5 ++++-
 6 files changed, 16 insertions(+), 16 deletions(-)
 delete mode 100644 arch/arm64/kernel/vdso/gettimeofday.S

-- 
2.23.0


^ permalink raw reply	[flat|nested] 127+ messages in thread

* [PATCH 0/4] arm64: vdso32: Address various issues
@ 2019-09-26  6:03   ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26  6:03 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

Hi Will,

this patch series is meant to address the various compilation issues you
reported about arm64 vdso32.

Please let me know if there is still something missing.

Thanks,
Vincenzo

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>

Vincenzo Frascino (4):
  arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  arm64: vdso32: Detect binutils support for dmb ishld
  arm64: vdso32: Fix compilation warning
  arm64: Remove gettimeofday.S

 arch/arm64/Kconfig                           |  5 ++++-
 arch/arm64/Makefile                          | 15 ++-------------
 arch/arm64/include/asm/memory.h              |  5 +++++
 arch/arm64/include/asm/vdso/compat_barrier.h |  2 +-
 arch/arm64/kernel/vdso/gettimeofday.S        |  0
 arch/arm64/kernel/vdso32/Makefile            |  5 ++++-
 6 files changed, 16 insertions(+), 16 deletions(-)
 delete mode 100644 arch/arm64/kernel/vdso/gettimeofday.S

-- 
2.23.0


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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-09-26  6:03   ` Vincenzo Frascino
@ 2019-09-26  6:03     ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26  6:03 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

As reported by Will Deacon the .config file and the generated
include/config/auto.conf can end up out of sync after a set of
commands since CONFIG_CROSS_COMPILE_COMPAT_VDSO is not updated
correctly.

The sequence can be reproduced as follows:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
[...]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
[set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

Which results in:

arch/arm64/Makefile:62: CROSS_COMPILE_COMPAT not defined or empty,
the compat vDSO will not be built

even though the compat vDSO has been built:

$ file arch/arm64/kernel/vdso32/vdso.so
arch/arm64/kernel/vdso32/vdso.so: ELF 32-bit LSB pie executable, ARM,
EABI5 version 1 (SYSV), dynamically linked,
BuildID[sha1]=c67f6c786f2d2d6f86c71f708595594aa25247f6, stripped

A similar case that involves changing the configuration parameter multiple
times can be reconducted to the same family of problems.

The reason behind it comes from the fact that the master Makefile includes
that architecture Makefile twice, once before the syncconfig and one after.
Since the synchronization of the files happens only upon syncconfig, the
architecture Makefile included before this event does not see the change in
configuration.

As a consequence of this it is not possible to handle the cross compiler
definitions inside the architecture Makefile.

Address the problem removing CONFIG_CROSS_COMPILE_COMPAT_VDSO and moving
the detection of the correct compiler into Kconfig via COMPAT_CC_IS_GCC.

As a consequence of this it is not possible anymore to set the compat
cross compiler from menuconfig but it requires to be exported via
command line.

E.g.:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
CROSS_COMPILE_COMPAT=arm-linux-gnueabihf

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/Kconfig  |  5 ++++-
 arch/arm64/Makefile | 15 ++-------------
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 37c610963eee..afe8c948b493 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -110,7 +110,7 @@ config ARM64
 	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
-	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
+	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPAT_CC_IS_GCC)
 	select HANDLE_DOMAIN_IRQ
 	select HARDIRQS_SW_RESEND
 	select HAVE_PCI
@@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
 	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
 	default 0xffffffffffffffff
 
+config COMPAT_CC_IS_GCC
+	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)
+
 source "arch/arm64/Kconfig.platforms"
 
 menu "Kernel Features"
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 84a3d502c5a5..34f53eb11878 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -54,19 +54,8 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
 endif
 
 ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
-  CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%)
-
-  ifeq ($(CONFIG_CC_IS_CLANG), y)
-    $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built)
-  else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),)
-    $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
-  else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),)
-    $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT)
-  else
-    export CROSS_COMPILE_COMPAT
-    export CONFIG_COMPAT_VDSO := y
-    compat_vdso := -DCONFIG_COMPAT_VDSO=1
-  endif
+  export CONFIG_COMPAT_VDSO := y
+  compat_vdso := -DCONFIG_COMPAT_VDSO=1
 endif
 
 KBUILD_CFLAGS	+= -mgeneral-regs-only $(lseinstr) $(brokengasinst)	\
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-09-26  6:03     ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26  6:03 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

As reported by Will Deacon the .config file and the generated
include/config/auto.conf can end up out of sync after a set of
commands since CONFIG_CROSS_COMPILE_COMPAT_VDSO is not updated
correctly.

The sequence can be reproduced as follows:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
[...]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
[set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

Which results in:

arch/arm64/Makefile:62: CROSS_COMPILE_COMPAT not defined or empty,
the compat vDSO will not be built

even though the compat vDSO has been built:

$ file arch/arm64/kernel/vdso32/vdso.so
arch/arm64/kernel/vdso32/vdso.so: ELF 32-bit LSB pie executable, ARM,
EABI5 version 1 (SYSV), dynamically linked,
BuildID[sha1]=c67f6c786f2d2d6f86c71f708595594aa25247f6, stripped

A similar case that involves changing the configuration parameter multiple
times can be reconducted to the same family of problems.

The reason behind it comes from the fact that the master Makefile includes
that architecture Makefile twice, once before the syncconfig and one after.
Since the synchronization of the files happens only upon syncconfig, the
architecture Makefile included before this event does not see the change in
configuration.

As a consequence of this it is not possible to handle the cross compiler
definitions inside the architecture Makefile.

Address the problem removing CONFIG_CROSS_COMPILE_COMPAT_VDSO and moving
the detection of the correct compiler into Kconfig via COMPAT_CC_IS_GCC.

As a consequence of this it is not possible anymore to set the compat
cross compiler from menuconfig but it requires to be exported via
command line.

E.g.:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
CROSS_COMPILE_COMPAT=arm-linux-gnueabihf

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/Kconfig  |  5 ++++-
 arch/arm64/Makefile | 15 ++-------------
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 37c610963eee..afe8c948b493 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -110,7 +110,7 @@ config ARM64
 	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
-	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
+	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPAT_CC_IS_GCC)
 	select HANDLE_DOMAIN_IRQ
 	select HARDIRQS_SW_RESEND
 	select HAVE_PCI
@@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
 	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
 	default 0xffffffffffffffff
 
+config COMPAT_CC_IS_GCC
+	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)
+
 source "arch/arm64/Kconfig.platforms"
 
 menu "Kernel Features"
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 84a3d502c5a5..34f53eb11878 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -54,19 +54,8 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
 endif
 
 ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
-  CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%)
-
-  ifeq ($(CONFIG_CC_IS_CLANG), y)
-    $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built)
-  else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),)
-    $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
-  else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),)
-    $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT)
-  else
-    export CROSS_COMPILE_COMPAT
-    export CONFIG_COMPAT_VDSO := y
-    compat_vdso := -DCONFIG_COMPAT_VDSO=1
-  endif
+  export CONFIG_COMPAT_VDSO := y
+  compat_vdso := -DCONFIG_COMPAT_VDSO=1
 endif
 
 KBUILD_CFLAGS	+= -mgeneral-regs-only $(lseinstr) $(brokengasinst)	\
-- 
2.23.0


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

^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH 2/4] arm64: vdso32: Detect binutils support for dmb ishld
  2019-09-26  6:03   ` Vincenzo Frascino
@ 2019-09-26  6:03     ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26  6:03 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

As reported by Will Deacon, older versions of binutils that do not
support certain types of memory barriers can cause build failure of the
vdso32 library.

Add a compilation time mechanism that detects if binutils supports those
instructions and configure the kernel accordingly.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/include/asm/vdso/compat_barrier.h | 2 +-
 arch/arm64/kernel/vdso32/Makefile            | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
index fb60a88b5ed4..3fd8fd6d8fc2 100644
--- a/arch/arm64/include/asm/vdso/compat_barrier.h
+++ b/arch/arm64/include/asm/vdso/compat_barrier.h
@@ -20,7 +20,7 @@
 
 #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
 
-#if __LINUX_ARM_ARCH__ >= 8
+#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
 #define aarch32_smp_mb()	dmb(ish)
 #define aarch32_smp_rmb()	dmb(ishld)
 #define aarch32_smp_wmb()	dmb(ishst)
diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 1fba0776ed40..1a3299d901b1 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -55,6 +55,9 @@ endif
 VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
 VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
 
+# Check for binutils support for dmb ishld
+dmbinstr := $(call as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1)
+
 # Try to compile for ARMv8. If the compiler is too old and doesn't support it,
 # fall back to v7. There is no easy way to check for what architecture the code
 # is being compiled, so define a macro specifying that (see arch/arm/Makefile).
@@ -62,7 +65,7 @@ VDSO_CAFLAGS += $(call cc32-option,-march=armv8-a -D__LINUX_ARM_ARCH__=8,\
                                    -march=armv7-a -D__LINUX_ARM_ARCH__=7)
 
 VDSO_CFLAGS := $(VDSO_CAFLAGS)
-VDSO_CFLAGS += -DENABLE_COMPAT_VDSO=1
+VDSO_CFLAGS += -DENABLE_COMPAT_VDSO=1 $(dmbinstr)
 # KBUILD_CFLAGS from top-level Makefile
 VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
                -fno-strict-aliasing -fno-common \
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH 2/4] arm64: vdso32: Detect binutils support for dmb ishld
@ 2019-09-26  6:03     ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26  6:03 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

As reported by Will Deacon, older versions of binutils that do not
support certain types of memory barriers can cause build failure of the
vdso32 library.

Add a compilation time mechanism that detects if binutils supports those
instructions and configure the kernel accordingly.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/include/asm/vdso/compat_barrier.h | 2 +-
 arch/arm64/kernel/vdso32/Makefile            | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
index fb60a88b5ed4..3fd8fd6d8fc2 100644
--- a/arch/arm64/include/asm/vdso/compat_barrier.h
+++ b/arch/arm64/include/asm/vdso/compat_barrier.h
@@ -20,7 +20,7 @@
 
 #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
 
-#if __LINUX_ARM_ARCH__ >= 8
+#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
 #define aarch32_smp_mb()	dmb(ish)
 #define aarch32_smp_rmb()	dmb(ishld)
 #define aarch32_smp_wmb()	dmb(ishst)
diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 1fba0776ed40..1a3299d901b1 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -55,6 +55,9 @@ endif
 VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
 VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
 
+# Check for binutils support for dmb ishld
+dmbinstr := $(call as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1)
+
 # Try to compile for ARMv8. If the compiler is too old and doesn't support it,
 # fall back to v7. There is no easy way to check for what architecture the code
 # is being compiled, so define a macro specifying that (see arch/arm/Makefile).
@@ -62,7 +65,7 @@ VDSO_CAFLAGS += $(call cc32-option,-march=armv8-a -D__LINUX_ARM_ARCH__=8,\
                                    -march=armv7-a -D__LINUX_ARM_ARCH__=7)
 
 VDSO_CFLAGS := $(VDSO_CAFLAGS)
-VDSO_CFLAGS += -DENABLE_COMPAT_VDSO=1
+VDSO_CFLAGS += -DENABLE_COMPAT_VDSO=1 $(dmbinstr)
 # KBUILD_CFLAGS from top-level Makefile
 VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
                -fno-strict-aliasing -fno-common \
-- 
2.23.0


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

^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH 3/4] arm64: vdso32: Fix compilation warning
  2019-09-26  6:03   ` Vincenzo Frascino
@ 2019-09-26  6:03     ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26  6:03 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

As reported by Will Deacon the following compilation warning appears
during the compilation of the vdso32:

In file included from ./arch/arm64/include/asm/thread_info.h:17:0,
                 from ./include/linux/thread_info.h:38,
                 from ./arch/arm64/include/asm/preempt.h:5,
                 from ./include/linux/preempt.h:78,
                 from ./include/linux/spinlock.h:51,
                 from ./include/linux/seqlock.h:36,
                 from ./include/linux/time.h:6,
                 from .../work/linux/lib/vdso/gettimeofday.c:7,
                 from <command-line>:0:
./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
  u64 __addr = (u64)addr & ~__tag_shifted(0xff);
               ^
In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0,
                 from ./arch/arm64/include/asm/processor.h:34,
                 from ./arch/arm64/include/asm/elf.h:118,
                 from ./include/linux/elf.h:5,
                 from ./include/linux/elfnote.h:62,
                 from arch/arm64/kernel/vdso32/note.c:11:
./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
  u64 __addr = (u64)addr & ~__tag_shifted(0xff);
               ^

This happens because few 64 bit compilation headers are included during
the generation of vdso32.

Fix the issue redefining the __tag_set function.

Note: This fix is meant to be temporary, a more comprehensive solution
based on the refactoring of the generic headers will be provided with a
future patch set. At that point it will be possible to revert this patch.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/include/asm/memory.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index b61b50bf68b1..b1c8c43234c5 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -228,11 +228,16 @@ static inline unsigned long kaslr_offset(void)
 #define __tag_get(addr)		0
 #endif /* CONFIG_KASAN_SW_TAGS */
 
+#ifdef __aarch64__
 static inline const void *__tag_set(const void *addr, u8 tag)
 {
 	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
 	return (const void *)(__addr | __tag_shifted(tag));
 }
+#else
+/* Unused in 32 bit mode */
+#define __tag_set(addr, tag) 0
+#endif
 
 /*
  * Physical vs virtual RAM address space conversion.  These are
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH 3/4] arm64: vdso32: Fix compilation warning
@ 2019-09-26  6:03     ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26  6:03 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

As reported by Will Deacon the following compilation warning appears
during the compilation of the vdso32:

In file included from ./arch/arm64/include/asm/thread_info.h:17:0,
                 from ./include/linux/thread_info.h:38,
                 from ./arch/arm64/include/asm/preempt.h:5,
                 from ./include/linux/preempt.h:78,
                 from ./include/linux/spinlock.h:51,
                 from ./include/linux/seqlock.h:36,
                 from ./include/linux/time.h:6,
                 from .../work/linux/lib/vdso/gettimeofday.c:7,
                 from <command-line>:0:
./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
  u64 __addr = (u64)addr & ~__tag_shifted(0xff);
               ^
In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0,
                 from ./arch/arm64/include/asm/processor.h:34,
                 from ./arch/arm64/include/asm/elf.h:118,
                 from ./include/linux/elf.h:5,
                 from ./include/linux/elfnote.h:62,
                 from arch/arm64/kernel/vdso32/note.c:11:
./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
  u64 __addr = (u64)addr & ~__tag_shifted(0xff);
               ^

This happens because few 64 bit compilation headers are included during
the generation of vdso32.

Fix the issue redefining the __tag_set function.

Note: This fix is meant to be temporary, a more comprehensive solution
based on the refactoring of the generic headers will be provided with a
future patch set. At that point it will be possible to revert this patch.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/include/asm/memory.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index b61b50bf68b1..b1c8c43234c5 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -228,11 +228,16 @@ static inline unsigned long kaslr_offset(void)
 #define __tag_get(addr)		0
 #endif /* CONFIG_KASAN_SW_TAGS */
 
+#ifdef __aarch64__
 static inline const void *__tag_set(const void *addr, u8 tag)
 {
 	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
 	return (const void *)(__addr | __tag_shifted(tag));
 }
+#else
+/* Unused in 32 bit mode */
+#define __tag_set(addr, tag) 0
+#endif
 
 /*
  * Physical vs virtual RAM address space conversion.  These are
-- 
2.23.0


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

^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH 4/4] arm64: Remove gettimeofday.S
  2019-09-26  6:03   ` Vincenzo Frascino
@ 2019-09-26  6:03     ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26  6:03 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

gettimeofday.S was originally removed with the introduction of the
support for Unified vDSOs in arm64 and replaced with the C
implementation.

The file seems again present in the repository due to a side effect of
rebase.

Remove the file again.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/kernel/vdso/gettimeofday.S | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 arch/arm64/kernel/vdso/gettimeofday.S

diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S
deleted file mode 100644
index e69de29bb2d1..000000000000
-- 
2.23.0


^ permalink raw reply	[flat|nested] 127+ messages in thread

* [PATCH 4/4] arm64: Remove gettimeofday.S
@ 2019-09-26  6:03     ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26  6:03 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

gettimeofday.S was originally removed with the introduction of the
support for Unified vDSOs in arm64 and replaced with the C
implementation.

The file seems again present in the repository due to a side effect of
rebase.

Remove the file again.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/kernel/vdso/gettimeofday.S | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 arch/arm64/kernel/vdso/gettimeofday.S

diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S
deleted file mode 100644
index e69de29bb2d1..000000000000
-- 
2.23.0


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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-09-26  6:03     ` Vincenzo Frascino
@ 2019-09-26  8:06       ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26  8:06 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On Thu, Sep 26, 2019 at 07:03:50AM +0100, Vincenzo Frascino wrote:
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 37c610963eee..afe8c948b493 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -110,7 +110,7 @@ config ARM64
>  	select GENERIC_STRNLEN_USER
>  	select GENERIC_TIME_VSYSCALL
>  	select GENERIC_GETTIMEOFDAY
> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPAT_CC_IS_GCC)
>  	select HANDLE_DOMAIN_IRQ
>  	select HARDIRQS_SW_RESEND
>  	select HAVE_PCI
> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>  	default 0xffffffffffffffff
>  
> +config COMPAT_CC_IS_GCC
> +	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)

Nitpick: I prefer COMPATCC instead of COMPAT_CC for consistency with
HOSTCC.

Now, could we not generate a COMPATCC in the Makefile and use
$(COMPATCC) here instead of $(CROSS_COMPILE_COMPAT)gcc? It really
doesn't make sense to check that gcc is gcc.

A next step would be to check that COMPATCC can actually generate 32-bit
objects. But it's not essential at this stage.

> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index 84a3d502c5a5..34f53eb11878 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -54,19 +54,8 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
>  endif
>  
>  ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
> -  CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%)
> -
> -  ifeq ($(CONFIG_CC_IS_CLANG), y)
> -    $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built)
> -  else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),)
> -    $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
> -  else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),)
> -    $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT)
> -  else
> -    export CROSS_COMPILE_COMPAT
> -    export CONFIG_COMPAT_VDSO := y
> -    compat_vdso := -DCONFIG_COMPAT_VDSO=1
> -  endif
> +  export CONFIG_COMPAT_VDSO := y
> +  compat_vdso := -DCONFIG_COMPAT_VDSO=1
>  endif

Has CONFIG_CROSS_COMPILE_COMPAT_VDSO actually been removed from
lib/vdso/Kconfig? (I haven't checked the subsequent patches).

-- 
Catalin

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-09-26  8:06       ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26  8:06 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 07:03:50AM +0100, Vincenzo Frascino wrote:
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 37c610963eee..afe8c948b493 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -110,7 +110,7 @@ config ARM64
>  	select GENERIC_STRNLEN_USER
>  	select GENERIC_TIME_VSYSCALL
>  	select GENERIC_GETTIMEOFDAY
> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPAT_CC_IS_GCC)
>  	select HANDLE_DOMAIN_IRQ
>  	select HARDIRQS_SW_RESEND
>  	select HAVE_PCI
> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>  	default 0xffffffffffffffff
>  
> +config COMPAT_CC_IS_GCC
> +	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)

Nitpick: I prefer COMPATCC instead of COMPAT_CC for consistency with
HOSTCC.

Now, could we not generate a COMPATCC in the Makefile and use
$(COMPATCC) here instead of $(CROSS_COMPILE_COMPAT)gcc? It really
doesn't make sense to check that gcc is gcc.

A next step would be to check that COMPATCC can actually generate 32-bit
objects. But it's not essential at this stage.

> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
> index 84a3d502c5a5..34f53eb11878 100644
> --- a/arch/arm64/Makefile
> +++ b/arch/arm64/Makefile
> @@ -54,19 +54,8 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
>  endif
>  
>  ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
> -  CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%)
> -
> -  ifeq ($(CONFIG_CC_IS_CLANG), y)
> -    $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built)
> -  else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),)
> -    $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
> -  else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),)
> -    $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT)
> -  else
> -    export CROSS_COMPILE_COMPAT
> -    export CONFIG_COMPAT_VDSO := y
> -    compat_vdso := -DCONFIG_COMPAT_VDSO=1
> -  endif
> +  export CONFIG_COMPAT_VDSO := y
> +  compat_vdso := -DCONFIG_COMPAT_VDSO=1
>  endif

Has CONFIG_CROSS_COMPILE_COMPAT_VDSO actually been removed from
lib/vdso/Kconfig? (I haven't checked the subsequent patches).

-- 
Catalin

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 2/4] arm64: vdso32: Detect binutils support for dmb ishld
  2019-09-26  6:03     ` Vincenzo Frascino
@ 2019-09-26  8:30       ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26  8:30 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On Thu, Sep 26, 2019 at 07:03:51AM +0100, Vincenzo Frascino wrote:
> diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
> index fb60a88b5ed4..3fd8fd6d8fc2 100644
> --- a/arch/arm64/include/asm/vdso/compat_barrier.h
> +++ b/arch/arm64/include/asm/vdso/compat_barrier.h
> @@ -20,7 +20,7 @@
>  
>  #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
>  
> -#if __LINUX_ARM_ARCH__ >= 8
> +#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
>  #define aarch32_smp_mb()	dmb(ish)
>  #define aarch32_smp_rmb()	dmb(ishld)
>  #define aarch32_smp_wmb()	dmb(ishst)
> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
> index 1fba0776ed40..1a3299d901b1 100644
> --- a/arch/arm64/kernel/vdso32/Makefile
> +++ b/arch/arm64/kernel/vdso32/Makefile
> @@ -55,6 +55,9 @@ endif
>  VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
>  VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
>  
> +# Check for binutils support for dmb ishld
> +dmbinstr := $(call as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1)

Is this check for the compat gas or the native one? Looking at
scripts/Kbuild.include, as-instr uses CC but you'd need a COMPATCC here
instead.

I may have missed something but I don't think this fixes the issue
Will's issue since he reported the problem with an old compat binutils.

-- 
Catalin

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 2/4] arm64: vdso32: Detect binutils support for dmb ishld
@ 2019-09-26  8:30       ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26  8:30 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 07:03:51AM +0100, Vincenzo Frascino wrote:
> diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
> index fb60a88b5ed4..3fd8fd6d8fc2 100644
> --- a/arch/arm64/include/asm/vdso/compat_barrier.h
> +++ b/arch/arm64/include/asm/vdso/compat_barrier.h
> @@ -20,7 +20,7 @@
>  
>  #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
>  
> -#if __LINUX_ARM_ARCH__ >= 8
> +#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
>  #define aarch32_smp_mb()	dmb(ish)
>  #define aarch32_smp_rmb()	dmb(ishld)
>  #define aarch32_smp_wmb()	dmb(ishst)
> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
> index 1fba0776ed40..1a3299d901b1 100644
> --- a/arch/arm64/kernel/vdso32/Makefile
> +++ b/arch/arm64/kernel/vdso32/Makefile
> @@ -55,6 +55,9 @@ endif
>  VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
>  VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
>  
> +# Check for binutils support for dmb ishld
> +dmbinstr := $(call as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1)

Is this check for the compat gas or the native one? Looking at
scripts/Kbuild.include, as-instr uses CC but you'd need a COMPATCC here
instead.

I may have missed something but I don't think this fixes the issue
Will's issue since he reported the problem with an old compat binutils.

-- 
Catalin

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 3/4] arm64: vdso32: Fix compilation warning
  2019-09-26  6:03     ` Vincenzo Frascino
@ 2019-09-26  8:32       ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26  8:32 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On Thu, Sep 26, 2019 at 07:03:52AM +0100, Vincenzo Frascino wrote:
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index b61b50bf68b1..b1c8c43234c5 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -228,11 +228,16 @@ static inline unsigned long kaslr_offset(void)
>  #define __tag_get(addr)		0
>  #endif /* CONFIG_KASAN_SW_TAGS */
>  
> +#ifdef __aarch64__
>  static inline const void *__tag_set(const void *addr, u8 tag)
>  {
>  	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>  	return (const void *)(__addr | __tag_shifted(tag));
>  }
> +#else
> +/* Unused in 32 bit mode */
> +#define __tag_set(addr, tag) 0
> +#endif

I'm fine with this as a temporary workaround (or hack). But please add a
better comment on what the 32-bit mode is about - the compat vDSO.

-- 
Catalin

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 3/4] arm64: vdso32: Fix compilation warning
@ 2019-09-26  8:32       ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26  8:32 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 07:03:52AM +0100, Vincenzo Frascino wrote:
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index b61b50bf68b1..b1c8c43234c5 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -228,11 +228,16 @@ static inline unsigned long kaslr_offset(void)
>  #define __tag_get(addr)		0
>  #endif /* CONFIG_KASAN_SW_TAGS */
>  
> +#ifdef __aarch64__
>  static inline const void *__tag_set(const void *addr, u8 tag)
>  {
>  	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>  	return (const void *)(__addr | __tag_shifted(tag));
>  }
> +#else
> +/* Unused in 32 bit mode */
> +#define __tag_set(addr, tag) 0
> +#endif

I'm fine with this as a temporary workaround (or hack). But please add a
better comment on what the 32-bit mode is about - the compat vDSO.

-- 
Catalin

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 4/4] arm64: Remove gettimeofday.S
  2019-09-26  6:03     ` Vincenzo Frascino
@ 2019-09-26  8:34       ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26  8:34 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On Thu, Sep 26, 2019 at 07:03:53AM +0100, Vincenzo Frascino wrote:
> gettimeofday.S was originally removed with the introduction of the
> support for Unified vDSOs in arm64 and replaced with the C
> implementation.
> 
> The file seems again present in the repository due to a side effect of
> rebase.
> 
> Remove the file again.
> 
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> 
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

Nitpick: don't leave a space between the Cc and the Sob lines, it all
comes as a single block.

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 4/4] arm64: Remove gettimeofday.S
@ 2019-09-26  8:34       ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26  8:34 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 07:03:53AM +0100, Vincenzo Frascino wrote:
> gettimeofday.S was originally removed with the introduction of the
> support for Unified vDSOs in arm64 and replaced with the C
> implementation.
> 
> The file seems again present in the repository due to a side effect of
> rebase.
> 
> Remove the file again.
> 
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> 
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

Nitpick: don't leave a space between the Cc and the Sob lines, it all
comes as a single block.

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-09-26  8:06       ` Catalin Marinas
@ 2019-09-26 10:56         ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 10:56 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On 9/26/19 9:06 AM, Catalin Marinas wrote:
> On Thu, Sep 26, 2019 at 07:03:50AM +0100, Vincenzo Frascino wrote:
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index 37c610963eee..afe8c948b493 100644
>> --- a/arch/arm64/Kconfig
>> +++ b/arch/arm64/Kconfig
>> @@ -110,7 +110,7 @@ config ARM64
>>  	select GENERIC_STRNLEN_USER
>>  	select GENERIC_TIME_VSYSCALL
>>  	select GENERIC_GETTIMEOFDAY
>> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
>> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPAT_CC_IS_GCC)
>>  	select HANDLE_DOMAIN_IRQ
>>  	select HARDIRQS_SW_RESEND
>>  	select HAVE_PCI
>> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>>  	default 0xffffffffffffffff
>>  
>> +config COMPAT_CC_IS_GCC
>> +	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)
> 
> Nitpick: I prefer COMPATCC instead of COMPAT_CC for consistency with
> HOSTCC.
>

Ok, will change this in v2.

> Now, could we not generate a COMPATCC in the Makefile and use
> $(COMPATCC) here instead of $(CROSS_COMPILE_COMPAT)gcc? It really
> doesn't make sense to check that gcc is gcc.
> 

All right, COMPATCC is already in the makefile, I will use it in here.

> A next step would be to check that COMPATCC can actually generate 32-bit
> objects. But it's not essential at this stage.
> 

We are already checking this making sure that arm is present in the triple (grep
-q arm).

>> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
>> index 84a3d502c5a5..34f53eb11878 100644
>> --- a/arch/arm64/Makefile
>> +++ b/arch/arm64/Makefile
>> @@ -54,19 +54,8 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
>>  endif
>>  
>>  ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
>> -  CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%)
>> -
>> -  ifeq ($(CONFIG_CC_IS_CLANG), y)
>> -    $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built)
>> -  else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),)
>> -    $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
>> -  else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),)
>> -    $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT)
>> -  else
>> -    export CROSS_COMPILE_COMPAT
>> -    export CONFIG_COMPAT_VDSO := y
>> -    compat_vdso := -DCONFIG_COMPAT_VDSO=1
>> -  endif
>> +  export CONFIG_COMPAT_VDSO := y
>> +  compat_vdso := -DCONFIG_COMPAT_VDSO=1
>>  endif
> 
> Has CONFIG_CROSS_COMPILE_COMPAT_VDSO actually been removed from
> lib/vdso/Kconfig? (I haven't checked the subsequent patches).
> 

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-09-26 10:56         ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 10:56 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On 9/26/19 9:06 AM, Catalin Marinas wrote:
> On Thu, Sep 26, 2019 at 07:03:50AM +0100, Vincenzo Frascino wrote:
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index 37c610963eee..afe8c948b493 100644
>> --- a/arch/arm64/Kconfig
>> +++ b/arch/arm64/Kconfig
>> @@ -110,7 +110,7 @@ config ARM64
>>  	select GENERIC_STRNLEN_USER
>>  	select GENERIC_TIME_VSYSCALL
>>  	select GENERIC_GETTIMEOFDAY
>> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
>> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPAT_CC_IS_GCC)
>>  	select HANDLE_DOMAIN_IRQ
>>  	select HARDIRQS_SW_RESEND
>>  	select HAVE_PCI
>> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>>  	default 0xffffffffffffffff
>>  
>> +config COMPAT_CC_IS_GCC
>> +	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)
> 
> Nitpick: I prefer COMPATCC instead of COMPAT_CC for consistency with
> HOSTCC.
>

Ok, will change this in v2.

> Now, could we not generate a COMPATCC in the Makefile and use
> $(COMPATCC) here instead of $(CROSS_COMPILE_COMPAT)gcc? It really
> doesn't make sense to check that gcc is gcc.
> 

All right, COMPATCC is already in the makefile, I will use it in here.

> A next step would be to check that COMPATCC can actually generate 32-bit
> objects. But it's not essential at this stage.
> 

We are already checking this making sure that arm is present in the triple (grep
-q arm).

>> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
>> index 84a3d502c5a5..34f53eb11878 100644
>> --- a/arch/arm64/Makefile
>> +++ b/arch/arm64/Makefile
>> @@ -54,19 +54,8 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
>>  endif
>>  
>>  ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
>> -  CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%)
>> -
>> -  ifeq ($(CONFIG_CC_IS_CLANG), y)
>> -    $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built)
>> -  else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),)
>> -    $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
>> -  else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),)
>> -    $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT)
>> -  else
>> -    export CROSS_COMPILE_COMPAT
>> -    export CONFIG_COMPAT_VDSO := y
>> -    compat_vdso := -DCONFIG_COMPAT_VDSO=1
>> -  endif
>> +  export CONFIG_COMPAT_VDSO := y
>> +  compat_vdso := -DCONFIG_COMPAT_VDSO=1
>>  endif
> 
> Has CONFIG_CROSS_COMPILE_COMPAT_VDSO actually been removed from
> lib/vdso/Kconfig? (I haven't checked the subsequent patches).
> 

-- 
Regards,
Vincenzo

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 2/4] arm64: vdso32: Detect binutils support for dmb ishld
  2019-09-26  8:30       ` Catalin Marinas
@ 2019-09-26 10:59         ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 10:59 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On 9/26/19 9:30 AM, Catalin Marinas wrote:
> On Thu, Sep 26, 2019 at 07:03:51AM +0100, Vincenzo Frascino wrote:
>> diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
>> index fb60a88b5ed4..3fd8fd6d8fc2 100644
>> --- a/arch/arm64/include/asm/vdso/compat_barrier.h
>> +++ b/arch/arm64/include/asm/vdso/compat_barrier.h
>> @@ -20,7 +20,7 @@
>>  
>>  #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
>>  
>> -#if __LINUX_ARM_ARCH__ >= 8
>> +#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
>>  #define aarch32_smp_mb()	dmb(ish)
>>  #define aarch32_smp_rmb()	dmb(ishld)
>>  #define aarch32_smp_wmb()	dmb(ishst)
>> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
>> index 1fba0776ed40..1a3299d901b1 100644
>> --- a/arch/arm64/kernel/vdso32/Makefile
>> +++ b/arch/arm64/kernel/vdso32/Makefile
>> @@ -55,6 +55,9 @@ endif
>>  VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
>>  VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
>>  
>> +# Check for binutils support for dmb ishld
>> +dmbinstr := $(call as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1)
> 
> Is this check for the compat gas or the native one? Looking at
> scripts/Kbuild.include, as-instr uses CC but you'd need a COMPATCC here
> instead.
> 
> I may have missed something but I don't think this fixes the issue
> Will's issue since he reported the problem with an old compat binutils.
> 

Good catch I thought that it was sufficient to put it in the correct makefile,
but I missed that COMPATCC != CC. This selects the wrong binutils.

Need to add something in Kbuild for that.

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 2/4] arm64: vdso32: Detect binutils support for dmb ishld
@ 2019-09-26 10:59         ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 10:59 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On 9/26/19 9:30 AM, Catalin Marinas wrote:
> On Thu, Sep 26, 2019 at 07:03:51AM +0100, Vincenzo Frascino wrote:
>> diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
>> index fb60a88b5ed4..3fd8fd6d8fc2 100644
>> --- a/arch/arm64/include/asm/vdso/compat_barrier.h
>> +++ b/arch/arm64/include/asm/vdso/compat_barrier.h
>> @@ -20,7 +20,7 @@
>>  
>>  #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
>>  
>> -#if __LINUX_ARM_ARCH__ >= 8
>> +#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
>>  #define aarch32_smp_mb()	dmb(ish)
>>  #define aarch32_smp_rmb()	dmb(ishld)
>>  #define aarch32_smp_wmb()	dmb(ishst)
>> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
>> index 1fba0776ed40..1a3299d901b1 100644
>> --- a/arch/arm64/kernel/vdso32/Makefile
>> +++ b/arch/arm64/kernel/vdso32/Makefile
>> @@ -55,6 +55,9 @@ endif
>>  VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
>>  VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
>>  
>> +# Check for binutils support for dmb ishld
>> +dmbinstr := $(call as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1)
> 
> Is this check for the compat gas or the native one? Looking at
> scripts/Kbuild.include, as-instr uses CC but you'd need a COMPATCC here
> instead.
> 
> I may have missed something but I don't think this fixes the issue
> Will's issue since he reported the problem with an old compat binutils.
> 

Good catch I thought that it was sufficient to put it in the correct makefile,
but I missed that COMPATCC != CC. This selects the wrong binutils.

Need to add something in Kbuild for that.

-- 
Regards,
Vincenzo

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-09-26 10:56         ` Vincenzo Frascino
@ 2019-09-26 11:02           ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 11:02 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel


On 9/26/19 11:56 AM, Vincenzo Frascino wrote:
> On 9/26/19 9:06 AM, Catalin Marinas wrote:
>> On Thu, Sep 26, 2019 at 07:03:50AM +0100, Vincenzo Frascino wrote:
>>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>>> index 37c610963eee..afe8c948b493 100644
>>> --- a/arch/arm64/Kconfig
>>> +++ b/arch/arm64/Kconfig
>>> @@ -110,7 +110,7 @@ config ARM64
>>>  	select GENERIC_STRNLEN_USER
>>>  	select GENERIC_TIME_VSYSCALL
>>>  	select GENERIC_GETTIMEOFDAY
>>> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
>>> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPAT_CC_IS_GCC)
>>>  	select HANDLE_DOMAIN_IRQ
>>>  	select HARDIRQS_SW_RESEND
>>>  	select HAVE_PCI
>>> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>>>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>>>  	default 0xffffffffffffffff
>>>  
>>> +config COMPAT_CC_IS_GCC
>>> +	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)
>>
>> Nitpick: I prefer COMPATCC instead of COMPAT_CC for consistency with
>> HOSTCC.
>>
> 
> Ok, will change this in v2.
> 
>> Now, could we not generate a COMPATCC in the Makefile and use
>> $(COMPATCC) here instead of $(CROSS_COMPILE_COMPAT)gcc? It really
>> doesn't make sense to check that gcc is gcc.
>>
> 
> All right, COMPATCC is already in the makefile, I will use it in here.
> 
>> A next step would be to check that COMPATCC can actually generate 32-bit
>> objects. But it's not essential at this stage.
>>
> 
> We are already checking this making sure that arm is present in the triple (grep
> -q arm).
> 
>>> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
>>> index 84a3d502c5a5..34f53eb11878 100644
>>> --- a/arch/arm64/Makefile
>>> +++ b/arch/arm64/Makefile
>>> @@ -54,19 +54,8 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
>>>  endif
>>>  
>>>  ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
>>> -  CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%)
>>> -
>>> -  ifeq ($(CONFIG_CC_IS_CLANG), y)
>>> -    $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built)
>>> -  else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),)
>>> -    $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
>>> -  else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),)
>>> -    $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT)
>>> -  else
>>> -    export CROSS_COMPILE_COMPAT
>>> -    export CONFIG_COMPAT_VDSO := y
>>> -    compat_vdso := -DCONFIG_COMPAT_VDSO=1
>>> -  endif
>>> +  export CONFIG_COMPAT_VDSO := y
>>> +  compat_vdso := -DCONFIG_COMPAT_VDSO=1
>>>  endif
>>
>> Has CONFIG_CROSS_COMPILE_COMPAT_VDSO actually been removed from
>> lib/vdso/Kconfig? (I haven't checked the subsequent patches).
>>
> 

Missed this, I have the patch ready for that. When this series will be merged,
no more architectures will use the macro hence I will send a separate patch to
remove it from the common code.

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-09-26 11:02           ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 11:02 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel


On 9/26/19 11:56 AM, Vincenzo Frascino wrote:
> On 9/26/19 9:06 AM, Catalin Marinas wrote:
>> On Thu, Sep 26, 2019 at 07:03:50AM +0100, Vincenzo Frascino wrote:
>>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>>> index 37c610963eee..afe8c948b493 100644
>>> --- a/arch/arm64/Kconfig
>>> +++ b/arch/arm64/Kconfig
>>> @@ -110,7 +110,7 @@ config ARM64
>>>  	select GENERIC_STRNLEN_USER
>>>  	select GENERIC_TIME_VSYSCALL
>>>  	select GENERIC_GETTIMEOFDAY
>>> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
>>> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPAT_CC_IS_GCC)
>>>  	select HANDLE_DOMAIN_IRQ
>>>  	select HARDIRQS_SW_RESEND
>>>  	select HAVE_PCI
>>> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>>>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>>>  	default 0xffffffffffffffff
>>>  
>>> +config COMPAT_CC_IS_GCC
>>> +	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)
>>
>> Nitpick: I prefer COMPATCC instead of COMPAT_CC for consistency with
>> HOSTCC.
>>
> 
> Ok, will change this in v2.
> 
>> Now, could we not generate a COMPATCC in the Makefile and use
>> $(COMPATCC) here instead of $(CROSS_COMPILE_COMPAT)gcc? It really
>> doesn't make sense to check that gcc is gcc.
>>
> 
> All right, COMPATCC is already in the makefile, I will use it in here.
> 
>> A next step would be to check that COMPATCC can actually generate 32-bit
>> objects. But it's not essential at this stage.
>>
> 
> We are already checking this making sure that arm is present in the triple (grep
> -q arm).
> 
>>> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
>>> index 84a3d502c5a5..34f53eb11878 100644
>>> --- a/arch/arm64/Makefile
>>> +++ b/arch/arm64/Makefile
>>> @@ -54,19 +54,8 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
>>>  endif
>>>  
>>>  ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
>>> -  CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%)
>>> -
>>> -  ifeq ($(CONFIG_CC_IS_CLANG), y)
>>> -    $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built)
>>> -  else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),)
>>> -    $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
>>> -  else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),)
>>> -    $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT)
>>> -  else
>>> -    export CROSS_COMPILE_COMPAT
>>> -    export CONFIG_COMPAT_VDSO := y
>>> -    compat_vdso := -DCONFIG_COMPAT_VDSO=1
>>> -  endif
>>> +  export CONFIG_COMPAT_VDSO := y
>>> +  compat_vdso := -DCONFIG_COMPAT_VDSO=1
>>>  endif
>>
>> Has CONFIG_CROSS_COMPILE_COMPAT_VDSO actually been removed from
>> lib/vdso/Kconfig? (I haven't checked the subsequent patches).
>>
> 

Missed this, I have the patch ready for that. When this series will be merged,
no more architectures will use the macro hence I will send a separate patch to
remove it from the common code.

-- 
Regards,
Vincenzo

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 3/4] arm64: vdso32: Fix compilation warning
  2019-09-26  8:32       ` Catalin Marinas
@ 2019-09-26 11:03         ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 11:03 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On 9/26/19 9:32 AM, Catalin Marinas wrote:
> On Thu, Sep 26, 2019 at 07:03:52AM +0100, Vincenzo Frascino wrote:
>> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
>> index b61b50bf68b1..b1c8c43234c5 100644
>> --- a/arch/arm64/include/asm/memory.h
>> +++ b/arch/arm64/include/asm/memory.h
>> @@ -228,11 +228,16 @@ static inline unsigned long kaslr_offset(void)
>>  #define __tag_get(addr)		0
>>  #endif /* CONFIG_KASAN_SW_TAGS */
>>  
>> +#ifdef __aarch64__
>>  static inline const void *__tag_set(const void *addr, u8 tag)
>>  {
>>  	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>>  	return (const void *)(__addr | __tag_shifted(tag));
>>  }
>> +#else
>> +/* Unused in 32 bit mode */
>> +#define __tag_set(addr, tag) 0
>> +#endif
> 
> I'm fine with this as a temporary workaround (or hack). But please add a
> better comment on what the 32-bit mode is about - the compat vDSO.
> 

Ok, I will do in v2, to avoid confusion.

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 3/4] arm64: vdso32: Fix compilation warning
@ 2019-09-26 11:03         ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 11:03 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On 9/26/19 9:32 AM, Catalin Marinas wrote:
> On Thu, Sep 26, 2019 at 07:03:52AM +0100, Vincenzo Frascino wrote:
>> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
>> index b61b50bf68b1..b1c8c43234c5 100644
>> --- a/arch/arm64/include/asm/memory.h
>> +++ b/arch/arm64/include/asm/memory.h
>> @@ -228,11 +228,16 @@ static inline unsigned long kaslr_offset(void)
>>  #define __tag_get(addr)		0
>>  #endif /* CONFIG_KASAN_SW_TAGS */
>>  
>> +#ifdef __aarch64__
>>  static inline const void *__tag_set(const void *addr, u8 tag)
>>  {
>>  	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>>  	return (const void *)(__addr | __tag_shifted(tag));
>>  }
>> +#else
>> +/* Unused in 32 bit mode */
>> +#define __tag_set(addr, tag) 0
>> +#endif
> 
> I'm fine with this as a temporary workaround (or hack). But please add a
> better comment on what the 32-bit mode is about - the compat vDSO.
> 

Ok, I will do in v2, to avoid confusion.

-- 
Regards,
Vincenzo

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-09-26 10:56         ` Vincenzo Frascino
@ 2019-09-26 12:22           ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 12:22 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On 9/26/19 11:56 AM, Vincenzo Frascino wrote:
> On 9/26/19 9:06 AM, Catalin Marinas wrote:
>> On Thu, Sep 26, 2019 at 07:03:50AM +0100, Vincenzo Frascino wrote:
>>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>>> index 37c610963eee..afe8c948b493 100644
>>> --- a/arch/arm64/Kconfig
>>> +++ b/arch/arm64/Kconfig
>>> @@ -110,7 +110,7 @@ config ARM64
>>>  	select GENERIC_STRNLEN_USER
>>>  	select GENERIC_TIME_VSYSCALL
>>>  	select GENERIC_GETTIMEOFDAY
>>> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
>>> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPAT_CC_IS_GCC)
>>>  	select HANDLE_DOMAIN_IRQ
>>>  	select HARDIRQS_SW_RESEND
>>>  	select HAVE_PCI
>>> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>>>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>>>  	default 0xffffffffffffffff
>>>  
>>> +config COMPAT_CC_IS_GCC
>>> +	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)
>>
>> Nitpick: I prefer COMPATCC instead of COMPAT_CC for consistency with
>> HOSTCC.
>>
> 
> Ok, will change this in v2.
> 
>> Now, could we not generate a COMPATCC in the Makefile and use
>> $(COMPATCC) here instead of $(CROSS_COMPILE_COMPAT)gcc? It really
>> doesn't make sense to check that gcc is gcc.
>>
> 
> All right, COMPATCC is already in the makefile, I will use it in here.
>

What you are proposing seems not possible because Kconfig runs first and then
the arch Makefile, hence compatcc does not take effect on the Kconfig. I will
post v2 with what I proposed, please feel free to comment if you have a better idea.

arch/arm64/configs/defconfig:726:warning: symbol value 'm' invalid for
REMOTEPROC
#

# configuration written to .config

#

make[1]: Leaving directory '/data1/Projects/LinuxKernel/linux-out'

make[1]: Entering directory '/data1/Projects/LinuxKernel/linux-out'

$COMPATCC is [arm-linux-gnueabihf-gcc]

  GEN     Makefile

>> A next step would be to check that COMPATCC can actually generate 32-bit
>> objects. But it's not essential at this stage.
>>
> 
> We are already checking this making sure that arm is present in the triple (grep
> -q arm).
> 
>>> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
>>> index 84a3d502c5a5..34f53eb11878 100644
>>> --- a/arch/arm64/Makefile
>>> +++ b/arch/arm64/Makefile
>>> @@ -54,19 +54,8 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
>>>  endif
>>>  
>>>  ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
>>> -  CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%)
>>> -
>>> -  ifeq ($(CONFIG_CC_IS_CLANG), y)
>>> -    $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built)
>>> -  else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),)
>>> -    $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
>>> -  else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),)
>>> -    $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT)
>>> -  else
>>> -    export CROSS_COMPILE_COMPAT
>>> -    export CONFIG_COMPAT_VDSO := y
>>> -    compat_vdso := -DCONFIG_COMPAT_VDSO=1
>>> -  endif
>>> +  export CONFIG_COMPAT_VDSO := y
>>> +  compat_vdso := -DCONFIG_COMPAT_VDSO=1
>>>  endif
>>
>> Has CONFIG_CROSS_COMPILE_COMPAT_VDSO actually been removed from
>> lib/vdso/Kconfig? (I haven't checked the subsequent patches).
>>
> 

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-09-26 12:22           ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 12:22 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On 9/26/19 11:56 AM, Vincenzo Frascino wrote:
> On 9/26/19 9:06 AM, Catalin Marinas wrote:
>> On Thu, Sep 26, 2019 at 07:03:50AM +0100, Vincenzo Frascino wrote:
>>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>>> index 37c610963eee..afe8c948b493 100644
>>> --- a/arch/arm64/Kconfig
>>> +++ b/arch/arm64/Kconfig
>>> @@ -110,7 +110,7 @@ config ARM64
>>>  	select GENERIC_STRNLEN_USER
>>>  	select GENERIC_TIME_VSYSCALL
>>>  	select GENERIC_GETTIMEOFDAY
>>> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
>>> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPAT_CC_IS_GCC)
>>>  	select HANDLE_DOMAIN_IRQ
>>>  	select HARDIRQS_SW_RESEND
>>>  	select HAVE_PCI
>>> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>>>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>>>  	default 0xffffffffffffffff
>>>  
>>> +config COMPAT_CC_IS_GCC
>>> +	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)
>>
>> Nitpick: I prefer COMPATCC instead of COMPAT_CC for consistency with
>> HOSTCC.
>>
> 
> Ok, will change this in v2.
> 
>> Now, could we not generate a COMPATCC in the Makefile and use
>> $(COMPATCC) here instead of $(CROSS_COMPILE_COMPAT)gcc? It really
>> doesn't make sense to check that gcc is gcc.
>>
> 
> All right, COMPATCC is already in the makefile, I will use it in here.
>

What you are proposing seems not possible because Kconfig runs first and then
the arch Makefile, hence compatcc does not take effect on the Kconfig. I will
post v2 with what I proposed, please feel free to comment if you have a better idea.

arch/arm64/configs/defconfig:726:warning: symbol value 'm' invalid for
REMOTEPROC
#

# configuration written to .config

#

make[1]: Leaving directory '/data1/Projects/LinuxKernel/linux-out'

make[1]: Entering directory '/data1/Projects/LinuxKernel/linux-out'

$COMPATCC is [arm-linux-gnueabihf-gcc]

  GEN     Makefile

>> A next step would be to check that COMPATCC can actually generate 32-bit
>> objects. But it's not essential at this stage.
>>
> 
> We are already checking this making sure that arm is present in the triple (grep
> -q arm).
> 
>>> diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
>>> index 84a3d502c5a5..34f53eb11878 100644
>>> --- a/arch/arm64/Makefile
>>> +++ b/arch/arm64/Makefile
>>> @@ -54,19 +54,8 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
>>>  endif
>>>  
>>>  ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
>>> -  CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%)
>>> -
>>> -  ifeq ($(CONFIG_CC_IS_CLANG), y)
>>> -    $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built)
>>> -  else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),)
>>> -    $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
>>> -  else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),)
>>> -    $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT)
>>> -  else
>>> -    export CROSS_COMPILE_COMPAT
>>> -    export CONFIG_COMPAT_VDSO := y
>>> -    compat_vdso := -DCONFIG_COMPAT_VDSO=1
>>> -  endif
>>> +  export CONFIG_COMPAT_VDSO := y
>>> +  compat_vdso := -DCONFIG_COMPAT_VDSO=1
>>>  endif
>>
>> Has CONFIG_CROSS_COMPILE_COMPAT_VDSO actually been removed from
>> lib/vdso/Kconfig? (I haven't checked the subsequent patches).
>>
> 

-- 
Regards,
Vincenzo

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* [PATCH v2 0/4] arm64: vdso32: Address various issues
  2019-09-20 14:27 Problems with arm64 compat vdso Will Deacon
@ 2019-09-26 13:38   ` Vincenzo Frascino
  2019-09-26  6:03   ` Vincenzo Frascino
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 13:38 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

Hi Will,

this patch series is meant to address the various compilation issues you
reported about arm64 vdso32. (This time for real I hope ;))

Please let me know if there is still something missing.

Thanks,
Vincenzo

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>

---

v2:
   - Fixed binutils detection
   - Addressed review comments

Vincenzo Frascino (4):
  arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  arm64: vdso32: Detect binutils support for dmb ishld
  arm64: vdso32: Fix compilation warning
  arm64: Remove gettimeofday.S

 arch/arm64/Kbuild                            |  6 ++++++
 arch/arm64/Kconfig                           |  5 ++++-
 arch/arm64/Makefile                          | 15 ++-------------
 arch/arm64/include/asm/memory.h              |  5 +++++
 arch/arm64/include/asm/vdso/compat_barrier.h |  2 +-
 arch/arm64/kernel/vdso/gettimeofday.S        |  0
 arch/arm64/kernel/vdso32/Makefile            |  9 +++++++++
 7 files changed, 27 insertions(+), 15 deletions(-)
 delete mode 100644 arch/arm64/kernel/vdso/gettimeofday.S

-- 
2.23.0


^ permalink raw reply	[flat|nested] 127+ messages in thread

* [PATCH v2 0/4] arm64: vdso32: Address various issues
@ 2019-09-26 13:38   ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 13:38 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

Hi Will,

this patch series is meant to address the various compilation issues you
reported about arm64 vdso32. (This time for real I hope ;))

Please let me know if there is still something missing.

Thanks,
Vincenzo

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>

---

v2:
   - Fixed binutils detection
   - Addressed review comments

Vincenzo Frascino (4):
  arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  arm64: vdso32: Detect binutils support for dmb ishld
  arm64: vdso32: Fix compilation warning
  arm64: Remove gettimeofday.S

 arch/arm64/Kbuild                            |  6 ++++++
 arch/arm64/Kconfig                           |  5 ++++-
 arch/arm64/Makefile                          | 15 ++-------------
 arch/arm64/include/asm/memory.h              |  5 +++++
 arch/arm64/include/asm/vdso/compat_barrier.h |  2 +-
 arch/arm64/kernel/vdso/gettimeofday.S        |  0
 arch/arm64/kernel/vdso32/Makefile            |  9 +++++++++
 7 files changed, 27 insertions(+), 15 deletions(-)
 delete mode 100644 arch/arm64/kernel/vdso/gettimeofday.S

-- 
2.23.0


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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* [PATCH v2 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-09-26 13:38   ` Vincenzo Frascino
@ 2019-09-26 13:38     ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 13:38 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

As reported by Will Deacon the .config file and the generated
include/config/auto.conf can end up out of sync after a set of
commands since CONFIG_CROSS_COMPILE_COMPAT_VDSO is not updated
correctly.

The sequence can be reproduced as follows:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
[...]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
[set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

Which results in:

arch/arm64/Makefile:62: CROSS_COMPILE_COMPAT not defined or empty,
the compat vDSO will not be built

even though the compat vDSO has been built:

$ file arch/arm64/kernel/vdso32/vdso.so
arch/arm64/kernel/vdso32/vdso.so: ELF 32-bit LSB pie executable, ARM,
EABI5 version 1 (SYSV), dynamically linked,
BuildID[sha1]=c67f6c786f2d2d6f86c71f708595594aa25247f6, stripped

A similar case that involves changing the configuration parameter multiple
times can be reconducted to the same family of problems.

The reason behind it comes from the fact that the master Makefile includes
that architecture Makefile twice, once before the syncconfig and one after.
Since the synchronization of the files happens only upon syncconfig, the
architecture Makefile included before this event does not see the change in
configuration.

As a consequence of this it is not possible to handle the cross compiler
definitions inside the architecture Makefile.

Address the problem removing CONFIG_CROSS_COMPILE_COMPAT_VDSO and moving
the detection of the correct compiler into Kconfig via COMPAT_CC_IS_GCC.

As a consequence of this it is not possible anymore to set the compat
cross compiler from menuconfig but it requires to be exported via
command line.

E.g.:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
CROSS_COMPILE_COMPAT=arm-linux-gnueabihf

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/Kconfig  |  5 ++++-
 arch/arm64/Makefile | 15 ++-------------
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 37c610963eee..13e2d2e16af7 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -110,7 +110,7 @@ config ARM64
 	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
-	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
+	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_GCC)
 	select HANDLE_DOMAIN_IRQ
 	select HARDIRQS_SW_RESEND
 	select HAVE_PCI
@@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
 	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
 	default 0xffffffffffffffff
 
+config COMPATCC_IS_GCC
+	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)
+
 source "arch/arm64/Kconfig.platforms"
 
 menu "Kernel Features"
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 84a3d502c5a5..34f53eb11878 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -54,19 +54,8 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
 endif
 
 ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
-  CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%)
-
-  ifeq ($(CONFIG_CC_IS_CLANG), y)
-    $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built)
-  else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),)
-    $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
-  else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),)
-    $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT)
-  else
-    export CROSS_COMPILE_COMPAT
-    export CONFIG_COMPAT_VDSO := y
-    compat_vdso := -DCONFIG_COMPAT_VDSO=1
-  endif
+  export CONFIG_COMPAT_VDSO := y
+  compat_vdso := -DCONFIG_COMPAT_VDSO=1
 endif
 
 KBUILD_CFLAGS	+= -mgeneral-regs-only $(lseinstr) $(brokengasinst)	\
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH v2 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-09-26 13:38     ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 13:38 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

As reported by Will Deacon the .config file and the generated
include/config/auto.conf can end up out of sync after a set of
commands since CONFIG_CROSS_COMPILE_COMPAT_VDSO is not updated
correctly.

The sequence can be reproduced as follows:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
[...]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
[set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

Which results in:

arch/arm64/Makefile:62: CROSS_COMPILE_COMPAT not defined or empty,
the compat vDSO will not be built

even though the compat vDSO has been built:

$ file arch/arm64/kernel/vdso32/vdso.so
arch/arm64/kernel/vdso32/vdso.so: ELF 32-bit LSB pie executable, ARM,
EABI5 version 1 (SYSV), dynamically linked,
BuildID[sha1]=c67f6c786f2d2d6f86c71f708595594aa25247f6, stripped

A similar case that involves changing the configuration parameter multiple
times can be reconducted to the same family of problems.

The reason behind it comes from the fact that the master Makefile includes
that architecture Makefile twice, once before the syncconfig and one after.
Since the synchronization of the files happens only upon syncconfig, the
architecture Makefile included before this event does not see the change in
configuration.

As a consequence of this it is not possible to handle the cross compiler
definitions inside the architecture Makefile.

Address the problem removing CONFIG_CROSS_COMPILE_COMPAT_VDSO and moving
the detection of the correct compiler into Kconfig via COMPAT_CC_IS_GCC.

As a consequence of this it is not possible anymore to set the compat
cross compiler from menuconfig but it requires to be exported via
command line.

E.g.:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
CROSS_COMPILE_COMPAT=arm-linux-gnueabihf

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/Kconfig  |  5 ++++-
 arch/arm64/Makefile | 15 ++-------------
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 37c610963eee..13e2d2e16af7 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -110,7 +110,7 @@ config ARM64
 	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
-	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
+	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_GCC)
 	select HANDLE_DOMAIN_IRQ
 	select HARDIRQS_SW_RESEND
 	select HAVE_PCI
@@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
 	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
 	default 0xffffffffffffffff
 
+config COMPATCC_IS_GCC
+	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)
+
 source "arch/arm64/Kconfig.platforms"
 
 menu "Kernel Features"
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 84a3d502c5a5..34f53eb11878 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -54,19 +54,8 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
 endif
 
 ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
-  CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%)
-
-  ifeq ($(CONFIG_CC_IS_CLANG), y)
-    $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built)
-  else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),)
-    $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
-  else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),)
-    $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT)
-  else
-    export CROSS_COMPILE_COMPAT
-    export CONFIG_COMPAT_VDSO := y
-    compat_vdso := -DCONFIG_COMPAT_VDSO=1
-  endif
+  export CONFIG_COMPAT_VDSO := y
+  compat_vdso := -DCONFIG_COMPAT_VDSO=1
 endif
 
 KBUILD_CFLAGS	+= -mgeneral-regs-only $(lseinstr) $(brokengasinst)	\
-- 
2.23.0


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

^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH v2 2/4] arm64: vdso32: Detect binutils support for dmb ishld
  2019-09-26 13:38   ` Vincenzo Frascino
@ 2019-09-26 13:38     ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 13:38 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

As reported by Will Deacon, older versions of binutils that do not
support certain types of memory barriers can cause build failure of the
vdso32 library.

Add a compilation time mechanism that detects if binutils supports those
instructions and configure the kernel accordingly.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/Kbuild                            | 6 ++++++
 arch/arm64/include/asm/vdso/compat_barrier.h | 2 +-
 arch/arm64/kernel/vdso32/Makefile            | 9 +++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild
index d6465823b281..75cf8c796d0e 100644
--- a/arch/arm64/Kbuild
+++ b/arch/arm64/Kbuild
@@ -4,3 +4,9 @@ obj-$(CONFIG_NET)	+= net/
 obj-$(CONFIG_KVM)	+= kvm/
 obj-$(CONFIG_XEN)	+= xen/
 obj-$(CONFIG_CRYPTO)	+= crypto/
+
+# as-instr-compat
+# Usage: cflags-y += $(call as-instr-compat,instr,option1,option2)
+
+as-instr-compat = $(call try-run,\
+	printf "%b\n" "$(1)" | $(COMPATCC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
index fb60a88b5ed4..3fd8fd6d8fc2 100644
--- a/arch/arm64/include/asm/vdso/compat_barrier.h
+++ b/arch/arm64/include/asm/vdso/compat_barrier.h
@@ -20,7 +20,7 @@
 
 #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
 
-#if __LINUX_ARM_ARCH__ >= 8
+#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
 #define aarch32_smp_mb()	dmb(ish)
 #define aarch32_smp_rmb()	dmb(ishld)
 #define aarch32_smp_wmb()	dmb(ishst)
diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 1fba0776ed40..22f0d31ea528 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -17,6 +17,8 @@ cc32-disable-warning = $(call try-run,\
 	$(COMPATCC) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
 cc32-ldoption = $(call try-run,\
         $(COMPATCC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
+cc32-as-instr = $(call try-run,\
+	printf "%b\n" "$(1)" | $(COMPATCC) $(VDSO_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
 
 # We cannot use the global flags to compile the vDSO files, the main reason
 # being that the 32-bit compiler may be older than the main (64-bit) compiler
@@ -55,6 +57,7 @@ endif
 VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
 VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
 
+
 # Try to compile for ARMv8. If the compiler is too old and doesn't support it,
 # fall back to v7. There is no easy way to check for what architecture the code
 # is being compiled, so define a macro specifying that (see arch/arm/Makefile).
@@ -91,6 +94,12 @@ VDSO_CFLAGS += -Wno-int-to-pointer-cast
 VDSO_AFLAGS := $(VDSO_CAFLAGS)
 VDSO_AFLAGS += -D__ASSEMBLY__
 
+# Check for binutils support for dmb ishld
+dmbinstr := $(call cc32-as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1)
+
+VDSO_CFLAGS += $(dmbinstr)
+VDSO_AFLAGS += $(dmbinstr)
+
 VDSO_LDFLAGS := $(VDSO_CPPFLAGS)
 # From arm vDSO Makefile
 VDSO_LDFLAGS += -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH v2 2/4] arm64: vdso32: Detect binutils support for dmb ishld
@ 2019-09-26 13:38     ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 13:38 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

As reported by Will Deacon, older versions of binutils that do not
support certain types of memory barriers can cause build failure of the
vdso32 library.

Add a compilation time mechanism that detects if binutils supports those
instructions and configure the kernel accordingly.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/Kbuild                            | 6 ++++++
 arch/arm64/include/asm/vdso/compat_barrier.h | 2 +-
 arch/arm64/kernel/vdso32/Makefile            | 9 +++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild
index d6465823b281..75cf8c796d0e 100644
--- a/arch/arm64/Kbuild
+++ b/arch/arm64/Kbuild
@@ -4,3 +4,9 @@ obj-$(CONFIG_NET)	+= net/
 obj-$(CONFIG_KVM)	+= kvm/
 obj-$(CONFIG_XEN)	+= xen/
 obj-$(CONFIG_CRYPTO)	+= crypto/
+
+# as-instr-compat
+# Usage: cflags-y += $(call as-instr-compat,instr,option1,option2)
+
+as-instr-compat = $(call try-run,\
+	printf "%b\n" "$(1)" | $(COMPATCC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
index fb60a88b5ed4..3fd8fd6d8fc2 100644
--- a/arch/arm64/include/asm/vdso/compat_barrier.h
+++ b/arch/arm64/include/asm/vdso/compat_barrier.h
@@ -20,7 +20,7 @@
 
 #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
 
-#if __LINUX_ARM_ARCH__ >= 8
+#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
 #define aarch32_smp_mb()	dmb(ish)
 #define aarch32_smp_rmb()	dmb(ishld)
 #define aarch32_smp_wmb()	dmb(ishst)
diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 1fba0776ed40..22f0d31ea528 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -17,6 +17,8 @@ cc32-disable-warning = $(call try-run,\
 	$(COMPATCC) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
 cc32-ldoption = $(call try-run,\
         $(COMPATCC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
+cc32-as-instr = $(call try-run,\
+	printf "%b\n" "$(1)" | $(COMPATCC) $(VDSO_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
 
 # We cannot use the global flags to compile the vDSO files, the main reason
 # being that the 32-bit compiler may be older than the main (64-bit) compiler
@@ -55,6 +57,7 @@ endif
 VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
 VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
 
+
 # Try to compile for ARMv8. If the compiler is too old and doesn't support it,
 # fall back to v7. There is no easy way to check for what architecture the code
 # is being compiled, so define a macro specifying that (see arch/arm/Makefile).
@@ -91,6 +94,12 @@ VDSO_CFLAGS += -Wno-int-to-pointer-cast
 VDSO_AFLAGS := $(VDSO_CAFLAGS)
 VDSO_AFLAGS += -D__ASSEMBLY__
 
+# Check for binutils support for dmb ishld
+dmbinstr := $(call cc32-as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1)
+
+VDSO_CFLAGS += $(dmbinstr)
+VDSO_AFLAGS += $(dmbinstr)
+
 VDSO_LDFLAGS := $(VDSO_CPPFLAGS)
 # From arm vDSO Makefile
 VDSO_LDFLAGS += -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1
-- 
2.23.0


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

^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH v2 3/4] arm64: vdso32: Fix compilation warning
  2019-09-26 13:38   ` Vincenzo Frascino
@ 2019-09-26 13:38     ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 13:38 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

As reported by Will Deacon the following compilation warning appears
during the compilation of the vdso32:

In file included from ./arch/arm64/include/asm/thread_info.h:17:0,
                 from ./include/linux/thread_info.h:38,
                 from ./arch/arm64/include/asm/preempt.h:5,
                 from ./include/linux/preempt.h:78,
                 from ./include/linux/spinlock.h:51,
                 from ./include/linux/seqlock.h:36,
                 from ./include/linux/time.h:6,
                 from .../work/linux/lib/vdso/gettimeofday.c:7,
                 from <command-line>:0:
./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
  u64 __addr = (u64)addr & ~__tag_shifted(0xff);
               ^
In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0,
                 from ./arch/arm64/include/asm/processor.h:34,
                 from ./arch/arm64/include/asm/elf.h:118,
                 from ./include/linux/elf.h:5,
                 from ./include/linux/elfnote.h:62,
                 from arch/arm64/kernel/vdso32/note.c:11:
./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
  u64 __addr = (u64)addr & ~__tag_shifted(0xff);
               ^

This happens because few 64 bit compilation headers are included during
the generation of vdso32.

Fix the issue redefining the __tag_set function.

Note: This fix is meant to be temporary, a more comprehensive solution
based on the refactoring of the generic headers will be provided with a
future patch set. At that point it will be possible to revert this patch.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/include/asm/memory.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index b61b50bf68b1..cfa9cd87af14 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -228,11 +228,16 @@ static inline unsigned long kaslr_offset(void)
 #define __tag_get(addr)		0
 #endif /* CONFIG_KASAN_SW_TAGS */
 
+#ifdef __aarch64__
 static inline const void *__tag_set(const void *addr, u8 tag)
 {
 	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
 	return (const void *)(__addr | __tag_shifted(tag));
 }
+#else
+/* Unused in compat vdso */
+#define __tag_set(addr, tag) 0
+#endif
 
 /*
  * Physical vs virtual RAM address space conversion.  These are
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH v2 3/4] arm64: vdso32: Fix compilation warning
@ 2019-09-26 13:38     ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 13:38 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

As reported by Will Deacon the following compilation warning appears
during the compilation of the vdso32:

In file included from ./arch/arm64/include/asm/thread_info.h:17:0,
                 from ./include/linux/thread_info.h:38,
                 from ./arch/arm64/include/asm/preempt.h:5,
                 from ./include/linux/preempt.h:78,
                 from ./include/linux/spinlock.h:51,
                 from ./include/linux/seqlock.h:36,
                 from ./include/linux/time.h:6,
                 from .../work/linux/lib/vdso/gettimeofday.c:7,
                 from <command-line>:0:
./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
  u64 __addr = (u64)addr & ~__tag_shifted(0xff);
               ^
In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0,
                 from ./arch/arm64/include/asm/processor.h:34,
                 from ./arch/arm64/include/asm/elf.h:118,
                 from ./include/linux/elf.h:5,
                 from ./include/linux/elfnote.h:62,
                 from arch/arm64/kernel/vdso32/note.c:11:
./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
  u64 __addr = (u64)addr & ~__tag_shifted(0xff);
               ^

This happens because few 64 bit compilation headers are included during
the generation of vdso32.

Fix the issue redefining the __tag_set function.

Note: This fix is meant to be temporary, a more comprehensive solution
based on the refactoring of the generic headers will be provided with a
future patch set. At that point it will be possible to revert this patch.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/include/asm/memory.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index b61b50bf68b1..cfa9cd87af14 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -228,11 +228,16 @@ static inline unsigned long kaslr_offset(void)
 #define __tag_get(addr)		0
 #endif /* CONFIG_KASAN_SW_TAGS */
 
+#ifdef __aarch64__
 static inline const void *__tag_set(const void *addr, u8 tag)
 {
 	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
 	return (const void *)(__addr | __tag_shifted(tag));
 }
+#else
+/* Unused in compat vdso */
+#define __tag_set(addr, tag) 0
+#endif
 
 /*
  * Physical vs virtual RAM address space conversion.  These are
-- 
2.23.0


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

^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH v2 4/4] arm64: Remove gettimeofday.S
  2019-09-26 13:38   ` Vincenzo Frascino
@ 2019-09-26 13:38     ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 13:38 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

gettimeofday.S was originally removed with the introduction of the
support for Unified vDSOs in arm64 and replaced with the C
implementation.

The file seems again present in the repository due to a side effect of
rebase.

Remove the file again.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
---
 arch/arm64/kernel/vdso/gettimeofday.S | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 arch/arm64/kernel/vdso/gettimeofday.S

diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S
deleted file mode 100644
index e69de29bb2d1..000000000000
-- 
2.23.0


^ permalink raw reply	[flat|nested] 127+ messages in thread

* [PATCH v2 4/4] arm64: Remove gettimeofday.S
@ 2019-09-26 13:38     ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 13:38 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

gettimeofday.S was originally removed with the introduction of the
support for Unified vDSOs in arm64 and replaced with the C
implementation.

The file seems again present in the repository due to a side effect of
rebase.

Remove the file again.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
---
 arch/arm64/kernel/vdso/gettimeofday.S | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 arch/arm64/kernel/vdso/gettimeofday.S

diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S
deleted file mode 100644
index e69de29bb2d1..000000000000
-- 
2.23.0


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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 2/4] arm64: vdso32: Detect binutils support for dmb ishld
  2019-09-26 13:38     ` Vincenzo Frascino
@ 2019-09-26 14:26       ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26 14:26 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On Thu, Sep 26, 2019 at 02:38:03PM +0100, Vincenzo Frascino wrote:
> diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild
> index d6465823b281..75cf8c796d0e 100644
> --- a/arch/arm64/Kbuild
> +++ b/arch/arm64/Kbuild
> @@ -4,3 +4,9 @@ obj-$(CONFIG_NET)	+= net/
>  obj-$(CONFIG_KVM)	+= kvm/
>  obj-$(CONFIG_XEN)	+= xen/
>  obj-$(CONFIG_CRYPTO)	+= crypto/
> +
> +# as-instr-compat
> +# Usage: cflags-y += $(call as-instr-compat,instr,option1,option2)
> +
> +as-instr-compat = $(call try-run,\
> +	printf "%b\n" "$(1)" | $(COMPATCC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))

This doesn't seem to be used anywhere. Was it meant to be replaced by
cc32-as-instr?

-- 
Catalin

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 2/4] arm64: vdso32: Detect binutils support for dmb ishld
@ 2019-09-26 14:26       ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26 14:26 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 02:38:03PM +0100, Vincenzo Frascino wrote:
> diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild
> index d6465823b281..75cf8c796d0e 100644
> --- a/arch/arm64/Kbuild
> +++ b/arch/arm64/Kbuild
> @@ -4,3 +4,9 @@ obj-$(CONFIG_NET)	+= net/
>  obj-$(CONFIG_KVM)	+= kvm/
>  obj-$(CONFIG_XEN)	+= xen/
>  obj-$(CONFIG_CRYPTO)	+= crypto/
> +
> +# as-instr-compat
> +# Usage: cflags-y += $(call as-instr-compat,instr,option1,option2)
> +
> +as-instr-compat = $(call try-run,\
> +	printf "%b\n" "$(1)" | $(COMPATCC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))

This doesn't seem to be used anywhere. Was it meant to be replaced by
cc32-as-instr?

-- 
Catalin

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-09-26 13:38     ` Vincenzo Frascino
@ 2019-09-26 15:13       ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26 15:13 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On Thu, Sep 26, 2019 at 02:38:02PM +0100, Vincenzo Frascino wrote:
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 37c610963eee..13e2d2e16af7 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -110,7 +110,7 @@ config ARM64
>  	select GENERIC_STRNLEN_USER
>  	select GENERIC_TIME_VSYSCALL
>  	select GENERIC_GETTIMEOFDAY
> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_GCC)
>  	select HANDLE_DOMAIN_IRQ
>  	select HARDIRQS_SW_RESEND
>  	select HAVE_PCI
> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>  	default 0xffffffffffffffff
>  
> +config COMPATCC_IS_GCC
> +	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)

Nitpick: COMPAT_CC_IS_ARM_GCC together with 'grep -q "arm-.*-gcc"'

The patch below allows me to use $(COMPATCC) directly here and also set
either CROSS_COMPILE_COMPAT or COMPATCC on the command line:

----------8<----------------------------------
diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild
index 75cf8c796d0e..d6465823b281 100644
--- a/arch/arm64/Kbuild
+++ b/arch/arm64/Kbuild
@@ -4,9 +4,3 @@ obj-$(CONFIG_NET)	+= net/
 obj-$(CONFIG_KVM)	+= kvm/
 obj-$(CONFIG_XEN)	+= xen/
 obj-$(CONFIG_CRYPTO)	+= crypto/
-
-# as-instr-compat
-# Usage: cflags-y += $(call as-instr-compat,instr,option1,option2)
-
-as-instr-compat = $(call try-run,\
-	printf "%b\n" "$(1)" | $(COMPATCC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 5d4be0b4f980..811c89fa2b71 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -110,7 +110,7 @@ config ARM64
 	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
-	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_GCC)
+	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_ARM_GCC)
 	select HANDLE_DOMAIN_IRQ
 	select HARDIRQS_SW_RESEND
 	select HAVE_PCI
@@ -313,8 +313,8 @@ config KASAN_SHADOW_OFFSET
 	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
 	default 0xffffffffffffffff
 
-config COMPATCC_IS_GCC
-	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)
+config COMPATCC_IS_ARM_GCC
+	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
 
 source "arch/arm64/Kconfig.platforms"
 
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 34f53eb11878..6b4eb5c444c5 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -53,6 +53,9 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
   endif
 endif
 
+COMPATCC	?= $(CROSS_COMPILE_COMPAT)gcc
+export		COMPATCC
+
 ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
   export CONFIG_COMPAT_VDSO := y
   compat_vdso := -DCONFIG_COMPAT_VDSO=1
diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 22f0d31ea528..77aa61340374 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -8,8 +8,6 @@
 ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
 include $(srctree)/lib/vdso/Makefile
 
-COMPATCC := $(CROSS_COMPILE_COMPAT)gcc
-
 # Same as cc-*option, but using COMPATCC instead of CC
 cc32-option = $(call try-run,\
         $(COMPATCC) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))

^ permalink raw reply related	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-09-26 15:13       ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26 15:13 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 02:38:02PM +0100, Vincenzo Frascino wrote:
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 37c610963eee..13e2d2e16af7 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -110,7 +110,7 @@ config ARM64
>  	select GENERIC_STRNLEN_USER
>  	select GENERIC_TIME_VSYSCALL
>  	select GENERIC_GETTIMEOFDAY
> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_GCC)
>  	select HANDLE_DOMAIN_IRQ
>  	select HARDIRQS_SW_RESEND
>  	select HAVE_PCI
> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>  	default 0xffffffffffffffff
>  
> +config COMPATCC_IS_GCC
> +	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)

Nitpick: COMPAT_CC_IS_ARM_GCC together with 'grep -q "arm-.*-gcc"'

The patch below allows me to use $(COMPATCC) directly here and also set
either CROSS_COMPILE_COMPAT or COMPATCC on the command line:

----------8<----------------------------------
diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild
index 75cf8c796d0e..d6465823b281 100644
--- a/arch/arm64/Kbuild
+++ b/arch/arm64/Kbuild
@@ -4,9 +4,3 @@ obj-$(CONFIG_NET)	+= net/
 obj-$(CONFIG_KVM)	+= kvm/
 obj-$(CONFIG_XEN)	+= xen/
 obj-$(CONFIG_CRYPTO)	+= crypto/
-
-# as-instr-compat
-# Usage: cflags-y += $(call as-instr-compat,instr,option1,option2)
-
-as-instr-compat = $(call try-run,\
-	printf "%b\n" "$(1)" | $(COMPATCC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 5d4be0b4f980..811c89fa2b71 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -110,7 +110,7 @@ config ARM64
 	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
-	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_GCC)
+	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_ARM_GCC)
 	select HANDLE_DOMAIN_IRQ
 	select HARDIRQS_SW_RESEND
 	select HAVE_PCI
@@ -313,8 +313,8 @@ config KASAN_SHADOW_OFFSET
 	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
 	default 0xffffffffffffffff
 
-config COMPATCC_IS_GCC
-	def_bool $(success,$(CROSS_COMPILE_COMPAT)gcc --version | head -n 1 | grep -q arm)
+config COMPATCC_IS_ARM_GCC
+	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
 
 source "arch/arm64/Kconfig.platforms"
 
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 34f53eb11878..6b4eb5c444c5 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -53,6 +53,9 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
   endif
 endif
 
+COMPATCC	?= $(CROSS_COMPILE_COMPAT)gcc
+export		COMPATCC
+
 ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
   export CONFIG_COMPAT_VDSO := y
   compat_vdso := -DCONFIG_COMPAT_VDSO=1
diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 22f0d31ea528..77aa61340374 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -8,8 +8,6 @@
 ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
 include $(srctree)/lib/vdso/Makefile
 
-COMPATCC := $(CROSS_COMPILE_COMPAT)gcc
-
 # Same as cc-*option, but using COMPATCC instead of CC
 cc32-option = $(call try-run,\
         $(COMPATCC) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))

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

^ permalink raw reply related	[flat|nested] 127+ messages in thread

* Re: [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-09-26 12:22           ` Vincenzo Frascino
@ 2019-09-26 15:17             ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26 15:17 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 01:22:01PM +0100, Vincenzo Frascino wrote:
> On 9/26/19 11:56 AM, Vincenzo Frascino wrote:
> > On 9/26/19 9:06 AM, Catalin Marinas wrote:
> >> Now, could we not generate a COMPATCC in the Makefile and use
> >> $(COMPATCC) here instead of $(CROSS_COMPILE_COMPAT)gcc? It really
> >> doesn't make sense to check that gcc is gcc.
> >>
> > 
> > All right, COMPATCC is already in the makefile, I will use it in here.
> 
> What you are proposing seems not possible because Kconfig runs first and then
> the arch Makefile, hence compatcc does not take effect on the Kconfig. I will
> post v2 with what I proposed, please feel free to comment if you have a better idea.

I think it works as long as you export COMPATCC from the
arch/arm64/Makefile. The arch Makefile is used in the config step
AFAICT. See the diff I posted in my reply to your v2.

-- 
Catalin

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-09-26 15:17             ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26 15:17 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 01:22:01PM +0100, Vincenzo Frascino wrote:
> On 9/26/19 11:56 AM, Vincenzo Frascino wrote:
> > On 9/26/19 9:06 AM, Catalin Marinas wrote:
> >> Now, could we not generate a COMPATCC in the Makefile and use
> >> $(COMPATCC) here instead of $(CROSS_COMPILE_COMPAT)gcc? It really
> >> doesn't make sense to check that gcc is gcc.
> >>
> > 
> > All right, COMPATCC is already in the makefile, I will use it in here.
> 
> What you are proposing seems not possible because Kconfig runs first and then
> the arch Makefile, hence compatcc does not take effect on the Kconfig. I will
> post v2 with what I proposed, please feel free to comment if you have a better idea.

I think it works as long as you export COMPATCC from the
arch/arm64/Makefile. The arch Makefile is used in the config step
AFAICT. See the diff I posted in my reply to your v2.

-- 
Catalin

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 3/4] arm64: vdso32: Fix compilation warning
  2019-09-26 13:38     ` Vincenzo Frascino
@ 2019-09-26 15:22       ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26 15:22 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On Thu, Sep 26, 2019 at 02:38:04PM +0100, Vincenzo Frascino wrote:
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index b61b50bf68b1..cfa9cd87af14 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -228,11 +228,16 @@ static inline unsigned long kaslr_offset(void)
>  #define __tag_get(addr)		0
>  #endif /* CONFIG_KASAN_SW_TAGS */
>  
> +#ifdef __aarch64__
>  static inline const void *__tag_set(const void *addr, u8 tag)
>  {
>  	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>  	return (const void *)(__addr | __tag_shifted(tag));
>  }
> +#else
> +/* Unused in compat vdso */
> +#define __tag_set(addr, tag) 0
> +#endif

Do we actually need an #else block here? I think the #ifdef is
sufficient, with a comment along the lines of "Do not attempt to compile
when included in the compat vdso" (or pick some better wording).

-- 
Catalin

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 3/4] arm64: vdso32: Fix compilation warning
@ 2019-09-26 15:22       ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26 15:22 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 02:38:04PM +0100, Vincenzo Frascino wrote:
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index b61b50bf68b1..cfa9cd87af14 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -228,11 +228,16 @@ static inline unsigned long kaslr_offset(void)
>  #define __tag_get(addr)		0
>  #endif /* CONFIG_KASAN_SW_TAGS */
>  
> +#ifdef __aarch64__
>  static inline const void *__tag_set(const void *addr, u8 tag)
>  {
>  	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>  	return (const void *)(__addr | __tag_shifted(tag));
>  }
> +#else
> +/* Unused in compat vdso */
> +#define __tag_set(addr, tag) 0
> +#endif

Do we actually need an #else block here? I think the #ifdef is
sufficient, with a comment along the lines of "Do not attempt to compile
when included in the compat vdso" (or pick some better wording).

-- 
Catalin

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-09-26 11:02           ` Vincenzo Frascino
@ 2019-09-26 15:23             ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26 15:23 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 12:02:38PM +0100, Vincenzo Frascino wrote:
> On 9/26/19 11:56 AM, Vincenzo Frascino wrote:
> > On 9/26/19 9:06 AM, Catalin Marinas wrote:
> >> Has CONFIG_CROSS_COMPILE_COMPAT_VDSO actually been removed from
> >> lib/vdso/Kconfig? (I haven't checked the subsequent patches).
> 
> Missed this, I have the patch ready for that. When this series will be merged,
> no more architectures will use the macro hence I will send a separate patch to
> remove it from the common code.

Since arm64 was the only user, can you send it together with this
series? I find it strange that Kbuild prompts me to enter this option
when it wouldn't have any effect.

-- 
Catalin

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-09-26 15:23             ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26 15:23 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 12:02:38PM +0100, Vincenzo Frascino wrote:
> On 9/26/19 11:56 AM, Vincenzo Frascino wrote:
> > On 9/26/19 9:06 AM, Catalin Marinas wrote:
> >> Has CONFIG_CROSS_COMPILE_COMPAT_VDSO actually been removed from
> >> lib/vdso/Kconfig? (I haven't checked the subsequent patches).
> 
> Missed this, I have the patch ready for that. When this series will be merged,
> no more architectures will use the macro hence I will send a separate patch to
> remove it from the common code.

Since arm64 was the only user, can you send it together with this
series? I find it strange that Kbuild prompts me to enter this option
when it wouldn't have any effect.

-- 
Catalin

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 0/4] arm64: vdso32: Address various issues
  2019-09-26 13:38   ` Vincenzo Frascino
@ 2019-09-26 15:31     ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26 15:31 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On Thu, Sep 26, 2019 at 02:38:01PM +0100, Vincenzo Frascino wrote:
> this patch series is meant to address the various compilation issues you
> reported about arm64 vdso32. (This time for real I hope ;))
> 
> Please let me know if there is still something missing.

Apart from the diff I posted and some nitpicks, the series looks fine to
me. If you post an update, I'll ack it (and a tested-by).

In addition to this series I'd still prefer to have my Kconfig option to
disable the compat vDSO if something else fails in the future (at least
until we complete the headers clean-up). But I'm fine with a default y
and removing EXPERT.

Thanks for the quick turnaround.

-- 
Catalin

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 0/4] arm64: vdso32: Address various issues
@ 2019-09-26 15:31     ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26 15:31 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 02:38:01PM +0100, Vincenzo Frascino wrote:
> this patch series is meant to address the various compilation issues you
> reported about arm64 vdso32. (This time for real I hope ;))
> 
> Please let me know if there is still something missing.

Apart from the diff I posted and some nitpicks, the series looks fine to
me. If you post an update, I'll ack it (and a tested-by).

In addition to this series I'd still prefer to have my Kconfig option to
disable the compat vDSO if something else fails in the future (at least
until we complete the headers clean-up). But I'm fine with a default y
and removing EXPERT.

Thanks for the quick turnaround.

-- 
Catalin

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 2/4] arm64: vdso32: Detect binutils support for dmb ishld
  2019-09-26 13:38     ` Vincenzo Frascino
@ 2019-09-26 15:59       ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26 15:59 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On Thu, Sep 26, 2019 at 02:38:03PM +0100, Vincenzo Frascino wrote:
>  arch/arm64/kernel/vdso32/Makefile            | 9 +++++++++

Could you please also remove the unnecessary gcc-goto.sh check in this
file? We don't use jump labels in the vdso (can't run-time patch them).
I found it while forcing COMPATCC=clang with my additional diff and I
get the warning on 'make clean'.

diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 22f0d31ea528..038357a1e835 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -40,9 +38,6 @@ VDSO_CAFLAGS += $(call cc32-option,-fno-PIE)
 ifdef CONFIG_DEBUG_INFO
 VDSO_CAFLAGS += -g
 endif
-ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(COMPATCC)), y)
-VDSO_CAFLAGS += -DCC_HAVE_ASM_GOTO
-endif
 
 # From arm Makefile
 VDSO_CAFLAGS += $(call cc32-option,-fno-dwarf2-cfi-asm)

-- 
Catalin

^ permalink raw reply related	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 2/4] arm64: vdso32: Detect binutils support for dmb ishld
@ 2019-09-26 15:59       ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-26 15:59 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 02:38:03PM +0100, Vincenzo Frascino wrote:
>  arch/arm64/kernel/vdso32/Makefile            | 9 +++++++++

Could you please also remove the unnecessary gcc-goto.sh check in this
file? We don't use jump labels in the vdso (can't run-time patch them).
I found it while forcing COMPATCC=clang with my additional diff and I
get the warning on 'make clean'.

diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 22f0d31ea528..038357a1e835 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -40,9 +38,6 @@ VDSO_CAFLAGS += $(call cc32-option,-fno-PIE)
 ifdef CONFIG_DEBUG_INFO
 VDSO_CAFLAGS += -g
 endif
-ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(COMPATCC)), y)
-VDSO_CAFLAGS += -DCC_HAVE_ASM_GOTO
-endif
 
 # From arm Makefile
 VDSO_CAFLAGS += $(call cc32-option,-fno-dwarf2-cfi-asm)

-- 
Catalin

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

^ permalink raw reply related	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 2/4] arm64: vdso32: Detect binutils support for dmb ishld
  2019-09-26 13:38     ` Vincenzo Frascino
@ 2019-09-26 16:23       ` Nick Desaulniers
  -1 siblings, 0 replies; 127+ messages in thread
From: Nick Desaulniers @ 2019-09-26 16:23 UTC (permalink / raw)
  To: Vincenzo Frascino, Will Deacon
  Cc: Linux ARM, LKML, Ard Biesheuvel, Catalin Marinas, Thomas Gleixner

On Thu, Sep 26, 2019 at 6:38 AM Vincenzo Frascino
<vincenzo.frascino@arm.com> wrote:
>
> As reported by Will Deacon, older versions of binutils that do not
> support certain types of memory barriers can cause build failure of the
> vdso32 library.

Do we know which specific version of binutils has this problem?
Documentation/process/changes.rst lists 2.21+ as the supported
versions.  If it's older than that, it's unsupported.

I triple checked android's 2.27 seems ok.

$ cat bar.s
.text
.globl foo
  dmb ish
  dmb ishld
  dmb ishst
$ aarch64-linux-gnu-as bar.s
$ echo $?
0
$ llvm-objdump -d a.out

a.out: file format ELF64-aarch64-little


Disassembly of section .text:

0000000000000000 $x:
       0: bf 3b 03 d5                  dmb ish
       4: bf 39 03 d5                  dmb ishld
       8: bf 3a 03 d5                  dmb ishst

>
> Add a compilation time mechanism that detects if binutils supports those
> instructions and configure the kernel accordingly.
>
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>  arch/arm64/Kbuild                            | 6 ++++++
>  arch/arm64/include/asm/vdso/compat_barrier.h | 2 +-
>  arch/arm64/kernel/vdso32/Makefile            | 9 +++++++++
>  3 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild
> index d6465823b281..75cf8c796d0e 100644
> --- a/arch/arm64/Kbuild
> +++ b/arch/arm64/Kbuild
> @@ -4,3 +4,9 @@ obj-$(CONFIG_NET)       += net/
>  obj-$(CONFIG_KVM)      += kvm/
>  obj-$(CONFIG_XEN)      += xen/
>  obj-$(CONFIG_CRYPTO)   += crypto/
> +
> +# as-instr-compat
> +# Usage: cflags-y += $(call as-instr-compat,instr,option1,option2)
> +
> +as-instr-compat = $(call try-run,\
> +       printf "%b\n" "$(1)" | $(COMPATCC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
> diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
> index fb60a88b5ed4..3fd8fd6d8fc2 100644
> --- a/arch/arm64/include/asm/vdso/compat_barrier.h
> +++ b/arch/arm64/include/asm/vdso/compat_barrier.h
> @@ -20,7 +20,7 @@
>
>  #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
>
> -#if __LINUX_ARM_ARCH__ >= 8
> +#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
>  #define aarch32_smp_mb()       dmb(ish)
>  #define aarch32_smp_rmb()      dmb(ishld)
>  #define aarch32_smp_wmb()      dmb(ishst)
> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
> index 1fba0776ed40..22f0d31ea528 100644
> --- a/arch/arm64/kernel/vdso32/Makefile
> +++ b/arch/arm64/kernel/vdso32/Makefile
> @@ -17,6 +17,8 @@ cc32-disable-warning = $(call try-run,\
>         $(COMPATCC) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
>  cc32-ldoption = $(call try-run,\
>          $(COMPATCC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
> +cc32-as-instr = $(call try-run,\
> +       printf "%b\n" "$(1)" | $(COMPATCC) $(VDSO_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
>
>  # We cannot use the global flags to compile the vDSO files, the main reason
>  # being that the 32-bit compiler may be older than the main (64-bit) compiler
> @@ -55,6 +57,7 @@ endif
>  VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
>  VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
>
> +
>  # Try to compile for ARMv8. If the compiler is too old and doesn't support it,
>  # fall back to v7. There is no easy way to check for what architecture the code
>  # is being compiled, so define a macro specifying that (see arch/arm/Makefile).
> @@ -91,6 +94,12 @@ VDSO_CFLAGS += -Wno-int-to-pointer-cast
>  VDSO_AFLAGS := $(VDSO_CAFLAGS)
>  VDSO_AFLAGS += -D__ASSEMBLY__
>
> +# Check for binutils support for dmb ishld
> +dmbinstr := $(call cc32-as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1)
> +
> +VDSO_CFLAGS += $(dmbinstr)
> +VDSO_AFLAGS += $(dmbinstr)
> +
>  VDSO_LDFLAGS := $(VDSO_CPPFLAGS)
>  # From arm vDSO Makefile
>  VDSO_LDFLAGS += -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1
> --
> 2.23.0
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 2/4] arm64: vdso32: Detect binutils support for dmb ishld
@ 2019-09-26 16:23       ` Nick Desaulniers
  0 siblings, 0 replies; 127+ messages in thread
From: Nick Desaulniers @ 2019-09-26 16:23 UTC (permalink / raw)
  To: Vincenzo Frascino, Will Deacon
  Cc: Catalin Marinas, Thomas Gleixner, LKML, Linux ARM, Ard Biesheuvel

On Thu, Sep 26, 2019 at 6:38 AM Vincenzo Frascino
<vincenzo.frascino@arm.com> wrote:
>
> As reported by Will Deacon, older versions of binutils that do not
> support certain types of memory barriers can cause build failure of the
> vdso32 library.

Do we know which specific version of binutils has this problem?
Documentation/process/changes.rst lists 2.21+ as the supported
versions.  If it's older than that, it's unsupported.

I triple checked android's 2.27 seems ok.

$ cat bar.s
.text
.globl foo
  dmb ish
  dmb ishld
  dmb ishst
$ aarch64-linux-gnu-as bar.s
$ echo $?
0
$ llvm-objdump -d a.out

a.out: file format ELF64-aarch64-little


Disassembly of section .text:

0000000000000000 $x:
       0: bf 3b 03 d5                  dmb ish
       4: bf 39 03 d5                  dmb ishld
       8: bf 3a 03 d5                  dmb ishst

>
> Add a compilation time mechanism that detects if binutils supports those
> instructions and configure the kernel accordingly.
>
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>  arch/arm64/Kbuild                            | 6 ++++++
>  arch/arm64/include/asm/vdso/compat_barrier.h | 2 +-
>  arch/arm64/kernel/vdso32/Makefile            | 9 +++++++++
>  3 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild
> index d6465823b281..75cf8c796d0e 100644
> --- a/arch/arm64/Kbuild
> +++ b/arch/arm64/Kbuild
> @@ -4,3 +4,9 @@ obj-$(CONFIG_NET)       += net/
>  obj-$(CONFIG_KVM)      += kvm/
>  obj-$(CONFIG_XEN)      += xen/
>  obj-$(CONFIG_CRYPTO)   += crypto/
> +
> +# as-instr-compat
> +# Usage: cflags-y += $(call as-instr-compat,instr,option1,option2)
> +
> +as-instr-compat = $(call try-run,\
> +       printf "%b\n" "$(1)" | $(COMPATCC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
> diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
> index fb60a88b5ed4..3fd8fd6d8fc2 100644
> --- a/arch/arm64/include/asm/vdso/compat_barrier.h
> +++ b/arch/arm64/include/asm/vdso/compat_barrier.h
> @@ -20,7 +20,7 @@
>
>  #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
>
> -#if __LINUX_ARM_ARCH__ >= 8
> +#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
>  #define aarch32_smp_mb()       dmb(ish)
>  #define aarch32_smp_rmb()      dmb(ishld)
>  #define aarch32_smp_wmb()      dmb(ishst)
> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
> index 1fba0776ed40..22f0d31ea528 100644
> --- a/arch/arm64/kernel/vdso32/Makefile
> +++ b/arch/arm64/kernel/vdso32/Makefile
> @@ -17,6 +17,8 @@ cc32-disable-warning = $(call try-run,\
>         $(COMPATCC) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
>  cc32-ldoption = $(call try-run,\
>          $(COMPATCC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
> +cc32-as-instr = $(call try-run,\
> +       printf "%b\n" "$(1)" | $(COMPATCC) $(VDSO_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
>
>  # We cannot use the global flags to compile the vDSO files, the main reason
>  # being that the 32-bit compiler may be older than the main (64-bit) compiler
> @@ -55,6 +57,7 @@ endif
>  VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
>  VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
>
> +
>  # Try to compile for ARMv8. If the compiler is too old and doesn't support it,
>  # fall back to v7. There is no easy way to check for what architecture the code
>  # is being compiled, so define a macro specifying that (see arch/arm/Makefile).
> @@ -91,6 +94,12 @@ VDSO_CFLAGS += -Wno-int-to-pointer-cast
>  VDSO_AFLAGS := $(VDSO_CAFLAGS)
>  VDSO_AFLAGS += -D__ASSEMBLY__
>
> +# Check for binutils support for dmb ishld
> +dmbinstr := $(call cc32-as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1)
> +
> +VDSO_CFLAGS += $(dmbinstr)
> +VDSO_AFLAGS += $(dmbinstr)
> +
>  VDSO_LDFLAGS := $(VDSO_CPPFLAGS)
>  # From arm vDSO Makefile
>  VDSO_LDFLAGS += -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1
> --
> 2.23.0
>


-- 
Thanks,
~Nick Desaulniers

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-09-26 15:17             ` Catalin Marinas
@ 2019-09-26 20:17               ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 20:17 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On 9/26/19 4:17 PM, Catalin Marinas wrote:
> On Thu, Sep 26, 2019 at 01:22:01PM +0100, Vincenzo Frascino wrote:
>> On 9/26/19 11:56 AM, Vincenzo Frascino wrote:
>>> On 9/26/19 9:06 AM, Catalin Marinas wrote:
>>>> Now, could we not generate a COMPATCC in the Makefile and use
>>>> $(COMPATCC) here instead of $(CROSS_COMPILE_COMPAT)gcc? It really
>>>> doesn't make sense to check that gcc is gcc.
>>>>
>>>
>>> All right, COMPATCC is already in the makefile, I will use it in here.
>>
>> What you are proposing seems not possible because Kconfig runs first and then
>> the arch Makefile, hence compatcc does not take effect on the Kconfig. I will
>> post v2 with what I proposed, please feel free to comment if you have a better idea.
> 
> I think it works as long as you export COMPATCC from the
> arch/arm64/Makefile. The arch Makefile is used in the config step
> AFAICT. See the diff I posted in my reply to your v2.
> 

All right I will retry and repost v3 if I can get it working.

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-09-26 20:17               ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 20:17 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On 9/26/19 4:17 PM, Catalin Marinas wrote:
> On Thu, Sep 26, 2019 at 01:22:01PM +0100, Vincenzo Frascino wrote:
>> On 9/26/19 11:56 AM, Vincenzo Frascino wrote:
>>> On 9/26/19 9:06 AM, Catalin Marinas wrote:
>>>> Now, could we not generate a COMPATCC in the Makefile and use
>>>> $(COMPATCC) here instead of $(CROSS_COMPILE_COMPAT)gcc? It really
>>>> doesn't make sense to check that gcc is gcc.
>>>>
>>>
>>> All right, COMPATCC is already in the makefile, I will use it in here.
>>
>> What you are proposing seems not possible because Kconfig runs first and then
>> the arch Makefile, hence compatcc does not take effect on the Kconfig. I will
>> post v2 with what I proposed, please feel free to comment if you have a better idea.
> 
> I think it works as long as you export COMPATCC from the
> arch/arm64/Makefile. The arch Makefile is used in the config step
> AFAICT. See the diff I posted in my reply to your v2.
> 

All right I will retry and repost v3 if I can get it working.

-- 
Regards,
Vincenzo

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 2/4] arm64: vdso32: Detect binutils support for dmb ishld
  2019-09-26 14:26       ` Catalin Marinas
@ 2019-09-26 20:19         ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 20:19 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On 9/26/19 3:26 PM, Catalin Marinas wrote:
> On Thu, Sep 26, 2019 at 02:38:03PM +0100, Vincenzo Frascino wrote:
>> diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild
>> index d6465823b281..75cf8c796d0e 100644
>> --- a/arch/arm64/Kbuild
>> +++ b/arch/arm64/Kbuild
>> @@ -4,3 +4,9 @@ obj-$(CONFIG_NET)	+= net/
>>  obj-$(CONFIG_KVM)	+= kvm/
>>  obj-$(CONFIG_XEN)	+= xen/
>>  obj-$(CONFIG_CRYPTO)	+= crypto/
>> +
>> +# as-instr-compat
>> +# Usage: cflags-y += $(call as-instr-compat,instr,option1,option2)
>> +
>> +as-instr-compat = $(call try-run,\
>> +	printf "%b\n" "$(1)" | $(COMPATCC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
> 
> This doesn't seem to be used anywhere. Was it meant to be replaced by
> cc32-as-instr?
> 

Forgot to squash a stash here. Will fix in v3. This is not used anymore was just
an experiment.

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 2/4] arm64: vdso32: Detect binutils support for dmb ishld
@ 2019-09-26 20:19         ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 20:19 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On 9/26/19 3:26 PM, Catalin Marinas wrote:
> On Thu, Sep 26, 2019 at 02:38:03PM +0100, Vincenzo Frascino wrote:
>> diff --git a/arch/arm64/Kbuild b/arch/arm64/Kbuild
>> index d6465823b281..75cf8c796d0e 100644
>> --- a/arch/arm64/Kbuild
>> +++ b/arch/arm64/Kbuild
>> @@ -4,3 +4,9 @@ obj-$(CONFIG_NET)	+= net/
>>  obj-$(CONFIG_KVM)	+= kvm/
>>  obj-$(CONFIG_XEN)	+= xen/
>>  obj-$(CONFIG_CRYPTO)	+= crypto/
>> +
>> +# as-instr-compat
>> +# Usage: cflags-y += $(call as-instr-compat,instr,option1,option2)
>> +
>> +as-instr-compat = $(call try-run,\
>> +	printf "%b\n" "$(1)" | $(COMPATCC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
> 
> This doesn't seem to be used anywhere. Was it meant to be replaced by
> cc32-as-instr?
> 

Forgot to squash a stash here. Will fix in v3. This is not used anymore was just
an experiment.

-- 
Regards,
Vincenzo

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 0/4] arm64: vdso32: Address various issues
  2019-09-26 15:31     ` Catalin Marinas
@ 2019-09-26 20:29       ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 20:29 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On 9/26/19 4:31 PM, Catalin Marinas wrote:
> On Thu, Sep 26, 2019 at 02:38:01PM +0100, Vincenzo Frascino wrote:
>> this patch series is meant to address the various compilation issues you
>> reported about arm64 vdso32. (This time for real I hope ;))
>>
>> Please let me know if there is still something missing.
> 
> Apart from the diff I posted and some nitpicks, the series looks fine to
> me. If you post an update, I'll ack it (and a tested-by).
> 
> In addition to this series I'd still prefer to have my Kconfig option to
> disable the compat vDSO if something else fails in the future (at least
> until we complete the headers clean-up). But I'm fine with a default y
> and removing EXPERT.
>

It is fine by me, but may I ask to state in the commit message that the patch
can be reverted once the we fix the headers issue? I would like to have symmetry
in enabling vDSOs in between arm64 and compat once everything is fixed.

> Thanks for the quick turnaround.
> 

No problem, it is my responsibility to fix the vDSOs on arm64 and compat if
something breaks ;)

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 0/4] arm64: vdso32: Address various issues
@ 2019-09-26 20:29       ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 20:29 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On 9/26/19 4:31 PM, Catalin Marinas wrote:
> On Thu, Sep 26, 2019 at 02:38:01PM +0100, Vincenzo Frascino wrote:
>> this patch series is meant to address the various compilation issues you
>> reported about arm64 vdso32. (This time for real I hope ;))
>>
>> Please let me know if there is still something missing.
> 
> Apart from the diff I posted and some nitpicks, the series looks fine to
> me. If you post an update, I'll ack it (and a tested-by).
> 
> In addition to this series I'd still prefer to have my Kconfig option to
> disable the compat vDSO if something else fails in the future (at least
> until we complete the headers clean-up). But I'm fine with a default y
> and removing EXPERT.
>

It is fine by me, but may I ask to state in the commit message that the patch
can be reverted once the we fix the headers issue? I would like to have symmetry
in enabling vDSOs in between arm64 and compat once everything is fixed.

> Thanks for the quick turnaround.
> 

No problem, it is my responsibility to fix the vDSOs on arm64 and compat if
something breaks ;)

-- 
Regards,
Vincenzo

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 2/4] arm64: vdso32: Detect binutils support for dmb ishld
  2019-09-26 15:59       ` Catalin Marinas
@ 2019-09-26 21:17         ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 21:17 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx



On 9/26/19 4:59 PM, Catalin Marinas wrote:
> On Thu, Sep 26, 2019 at 02:38:03PM +0100, Vincenzo Frascino wrote:
>>  arch/arm64/kernel/vdso32/Makefile            | 9 +++++++++
> 
> Could you please also remove the unnecessary gcc-goto.sh check in this
> file? We don't use jump labels in the vdso (can't run-time patch them).
> I found it while forcing COMPATCC=clang with my additional diff and I
> get the warning on 'make clean'.
>

I will do it in a separate cleanup patch, I want to keep this only for the error
reported by Will.

> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
> index 22f0d31ea528..038357a1e835 100644
> --- a/arch/arm64/kernel/vdso32/Makefile
> +++ b/arch/arm64/kernel/vdso32/Makefile
> @@ -40,9 +38,6 @@ VDSO_CAFLAGS += $(call cc32-option,-fno-PIE)
>  ifdef CONFIG_DEBUG_INFO
>  VDSO_CAFLAGS += -g
>  endif
> -ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(COMPATCC)), y)
> -VDSO_CAFLAGS += -DCC_HAVE_ASM_GOTO
> -endif
>  
>  # From arm Makefile
>  VDSO_CAFLAGS += $(call cc32-option,-fno-dwarf2-cfi-asm)
> 

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v2 2/4] arm64: vdso32: Detect binutils support for dmb ishld
@ 2019-09-26 21:17         ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 21:17 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel



On 9/26/19 4:59 PM, Catalin Marinas wrote:
> On Thu, Sep 26, 2019 at 02:38:03PM +0100, Vincenzo Frascino wrote:
>>  arch/arm64/kernel/vdso32/Makefile            | 9 +++++++++
> 
> Could you please also remove the unnecessary gcc-goto.sh check in this
> file? We don't use jump labels in the vdso (can't run-time patch them).
> I found it while forcing COMPATCC=clang with my additional diff and I
> get the warning on 'make clean'.
>

I will do it in a separate cleanup patch, I want to keep this only for the error
reported by Will.

> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
> index 22f0d31ea528..038357a1e835 100644
> --- a/arch/arm64/kernel/vdso32/Makefile
> +++ b/arch/arm64/kernel/vdso32/Makefile
> @@ -40,9 +38,6 @@ VDSO_CAFLAGS += $(call cc32-option,-fno-PIE)
>  ifdef CONFIG_DEBUG_INFO
>  VDSO_CAFLAGS += -g
>  endif
> -ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(COMPATCC)), y)
> -VDSO_CAFLAGS += -DCC_HAVE_ASM_GOTO
> -endif
>  
>  # From arm Makefile
>  VDSO_CAFLAGS += $(call cc32-option,-fno-dwarf2-cfi-asm)
> 

-- 
Regards,
Vincenzo

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* [PATCH v3 0/5]arm64: vdso32: Address various issues
  2019-09-20 14:27 Problems with arm64 compat vdso Will Deacon
@ 2019-09-26 21:43   ` Vincenzo Frascino
  2019-09-26  6:03   ` Vincenzo Frascino
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 21:43 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

Hi Will,

this patch series is meant to address the various compilation issues you
reported about arm64 vdso32.

Please let me know if there is still something missing.

Thanks,
Vincenzo

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>

---

v3:
   - Exposed COMPATCC
   - Addressed Review Comments

v2:
   - Fixed binutils detection
   - Addressed review comments

Vincenzo Frascino (5):
  arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  arm64: vdso32: Detect binutils support for dmb ishld
  arm64: vdso32: Fix compilation warning
  arm64: Remove gettimeofday.S
  arm64: vdso32: Remove jump label config option in Makefile

 arch/arm64/Kconfig                           |  5 ++++-
 arch/arm64/Makefile                          | 18 +++++-------------
 arch/arm64/include/asm/memory.h              |  3 +++
 arch/arm64/include/asm/vdso/compat_barrier.h |  2 +-
 arch/arm64/kernel/vdso/gettimeofday.S        |  0
 arch/arm64/kernel/vdso32/Makefile            | 14 +++++++++-----
 6 files changed, 22 insertions(+), 20 deletions(-)
 delete mode 100644 arch/arm64/kernel/vdso/gettimeofday.S

-- 
2.23.0


^ permalink raw reply	[flat|nested] 127+ messages in thread

* [PATCH v3 0/5]arm64: vdso32: Address various issues
@ 2019-09-26 21:43   ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 21:43 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

Hi Will,

this patch series is meant to address the various compilation issues you
reported about arm64 vdso32.

Please let me know if there is still something missing.

Thanks,
Vincenzo

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>

---

v3:
   - Exposed COMPATCC
   - Addressed Review Comments

v2:
   - Fixed binutils detection
   - Addressed review comments

Vincenzo Frascino (5):
  arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  arm64: vdso32: Detect binutils support for dmb ishld
  arm64: vdso32: Fix compilation warning
  arm64: Remove gettimeofday.S
  arm64: vdso32: Remove jump label config option in Makefile

 arch/arm64/Kconfig                           |  5 ++++-
 arch/arm64/Makefile                          | 18 +++++-------------
 arch/arm64/include/asm/memory.h              |  3 +++
 arch/arm64/include/asm/vdso/compat_barrier.h |  2 +-
 arch/arm64/kernel/vdso/gettimeofday.S        |  0
 arch/arm64/kernel/vdso32/Makefile            | 14 +++++++++-----
 6 files changed, 22 insertions(+), 20 deletions(-)
 delete mode 100644 arch/arm64/kernel/vdso/gettimeofday.S

-- 
2.23.0


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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-09-26 21:43   ` Vincenzo Frascino
@ 2019-09-26 21:43     ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 21:43 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

As reported by Will Deacon the .config file and the generated
include/config/auto.conf can end up out of sync after a set of
commands since CONFIG_CROSS_COMPILE_COMPAT_VDSO is not updated
correctly.

The sequence can be reproduced as follows:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
[...]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
[set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

Which results in:

arch/arm64/Makefile:62: CROSS_COMPILE_COMPAT not defined or empty,
the compat vDSO will not be built

even though the compat vDSO has been built:

$ file arch/arm64/kernel/vdso32/vdso.so
arch/arm64/kernel/vdso32/vdso.so: ELF 32-bit LSB pie executable, ARM,
EABI5 version 1 (SYSV), dynamically linked,
BuildID[sha1]=c67f6c786f2d2d6f86c71f708595594aa25247f6, stripped

A similar case that involves changing the configuration parameter multiple
times can be reconducted to the same family of problems.

The reason behind it comes from the fact that the master Makefile includes
that architecture Makefile twice, once before the syncconfig and one after.
Since the synchronization of the files happens only upon syncconfig, the
architecture Makefile included before this event does not see the change in
configuration.

As a consequence of this it is not possible to handle the cross compiler
definitions inside the architecture Makefile.

Address the problem removing CONFIG_CROSS_COMPILE_COMPAT_VDSO and moving
the detection of the correct compiler into Kconfig via COMPAT_CC_IS_GCC.

As a consequence of this it is not possible anymore to set the compat
cross compiler from menuconfig but it requires to be exported via
command line.

E.g.:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
CROSS_COMPILE_COMPAT=arm-linux-gnueabihf

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/Kconfig                |  5 ++++-
 arch/arm64/Makefile               | 18 +++++-------------
 arch/arm64/kernel/vdso32/Makefile |  2 --
 3 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 37c610963eee..0e5beb928af5 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -110,7 +110,7 @@ config ARM64
 	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
-	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
+	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_ARM_GCC)
 	select HANDLE_DOMAIN_IRQ
 	select HARDIRQS_SW_RESEND
 	select HAVE_PCI
@@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
 	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
 	default 0xffffffffffffffff
 
+config COMPATCC_IS_ARM_GCC
+	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
+
 source "arch/arm64/Kconfig.platforms"
 
 menu "Kernel Features"
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 84a3d502c5a5..dfa6a5cb99e4 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -53,20 +53,12 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
   endif
 endif
 
+COMPATCC ?= $(CROSS_COMPILE_COMPAT)gcc
+export COMPATCC
+
 ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
-  CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%)
-
-  ifeq ($(CONFIG_CC_IS_CLANG), y)
-    $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built)
-  else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),)
-    $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
-  else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),)
-    $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT)
-  else
-    export CROSS_COMPILE_COMPAT
-    export CONFIG_COMPAT_VDSO := y
-    compat_vdso := -DCONFIG_COMPAT_VDSO=1
-  endif
+  export CONFIG_COMPAT_VDSO := y
+  compat_vdso := -DCONFIG_COMPAT_VDSO=1
 endif
 
 KBUILD_CFLAGS	+= -mgeneral-regs-only $(lseinstr) $(brokengasinst)	\
diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 1fba0776ed40..19e0d3115ffe 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -8,8 +8,6 @@
 ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
 include $(srctree)/lib/vdso/Makefile
 
-COMPATCC := $(CROSS_COMPILE_COMPAT)gcc
-
 # Same as cc-*option, but using COMPATCC instead of CC
 cc32-option = $(call try-run,\
         $(COMPATCC) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-09-26 21:43     ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 21:43 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

As reported by Will Deacon the .config file and the generated
include/config/auto.conf can end up out of sync after a set of
commands since CONFIG_CROSS_COMPILE_COMPAT_VDSO is not updated
correctly.

The sequence can be reproduced as follows:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
[...]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
[set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

Which results in:

arch/arm64/Makefile:62: CROSS_COMPILE_COMPAT not defined or empty,
the compat vDSO will not be built

even though the compat vDSO has been built:

$ file arch/arm64/kernel/vdso32/vdso.so
arch/arm64/kernel/vdso32/vdso.so: ELF 32-bit LSB pie executable, ARM,
EABI5 version 1 (SYSV), dynamically linked,
BuildID[sha1]=c67f6c786f2d2d6f86c71f708595594aa25247f6, stripped

A similar case that involves changing the configuration parameter multiple
times can be reconducted to the same family of problems.

The reason behind it comes from the fact that the master Makefile includes
that architecture Makefile twice, once before the syncconfig and one after.
Since the synchronization of the files happens only upon syncconfig, the
architecture Makefile included before this event does not see the change in
configuration.

As a consequence of this it is not possible to handle the cross compiler
definitions inside the architecture Makefile.

Address the problem removing CONFIG_CROSS_COMPILE_COMPAT_VDSO and moving
the detection of the correct compiler into Kconfig via COMPAT_CC_IS_GCC.

As a consequence of this it is not possible anymore to set the compat
cross compiler from menuconfig but it requires to be exported via
command line.

E.g.:

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
CROSS_COMPILE_COMPAT=arm-linux-gnueabihf

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/Kconfig                |  5 ++++-
 arch/arm64/Makefile               | 18 +++++-------------
 arch/arm64/kernel/vdso32/Makefile |  2 --
 3 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 37c610963eee..0e5beb928af5 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -110,7 +110,7 @@ config ARM64
 	select GENERIC_STRNLEN_USER
 	select GENERIC_TIME_VSYSCALL
 	select GENERIC_GETTIMEOFDAY
-	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
+	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_ARM_GCC)
 	select HANDLE_DOMAIN_IRQ
 	select HARDIRQS_SW_RESEND
 	select HAVE_PCI
@@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
 	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
 	default 0xffffffffffffffff
 
+config COMPATCC_IS_ARM_GCC
+	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
+
 source "arch/arm64/Kconfig.platforms"
 
 menu "Kernel Features"
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 84a3d502c5a5..dfa6a5cb99e4 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -53,20 +53,12 @@ $(warning Detected assembler with broken .inst; disassembly will be unreliable)
   endif
 endif
 
+COMPATCC ?= $(CROSS_COMPILE_COMPAT)gcc
+export COMPATCC
+
 ifeq ($(CONFIG_GENERIC_COMPAT_VDSO), y)
-  CROSS_COMPILE_COMPAT ?= $(CONFIG_CROSS_COMPILE_COMPAT_VDSO:"%"=%)
-
-  ifeq ($(CONFIG_CC_IS_CLANG), y)
-    $(warning CROSS_COMPILE_COMPAT is clang, the compat vDSO will not be built)
-  else ifeq ($(strip $(CROSS_COMPILE_COMPAT)),)
-    $(warning CROSS_COMPILE_COMPAT not defined or empty, the compat vDSO will not be built)
-  else ifeq ($(shell which $(CROSS_COMPILE_COMPAT)gcc 2> /dev/null),)
-    $(error $(CROSS_COMPILE_COMPAT)gcc not found, check CROSS_COMPILE_COMPAT)
-  else
-    export CROSS_COMPILE_COMPAT
-    export CONFIG_COMPAT_VDSO := y
-    compat_vdso := -DCONFIG_COMPAT_VDSO=1
-  endif
+  export CONFIG_COMPAT_VDSO := y
+  compat_vdso := -DCONFIG_COMPAT_VDSO=1
 endif
 
 KBUILD_CFLAGS	+= -mgeneral-regs-only $(lseinstr) $(brokengasinst)	\
diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 1fba0776ed40..19e0d3115ffe 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -8,8 +8,6 @@
 ARCH_REL_TYPE_ABS := R_ARM_JUMP_SLOT|R_ARM_GLOB_DAT|R_ARM_ABS32
 include $(srctree)/lib/vdso/Makefile
 
-COMPATCC := $(CROSS_COMPILE_COMPAT)gcc
-
 # Same as cc-*option, but using COMPATCC instead of CC
 cc32-option = $(call try-run,\
         $(COMPATCC) $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
-- 
2.23.0


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

^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH v3 2/5] arm64: vdso32: Detect binutils support for dmb ishld
  2019-09-26 21:43   ` Vincenzo Frascino
@ 2019-09-26 21:43     ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 21:43 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

As reported by Will Deacon, older versions of binutils that do not
support certain types of memory barriers can cause build failure of the
vdso32 library.

Add a compilation time mechanism that detects if binutils supports those
instructions and configure the kernel accordingly.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/include/asm/vdso/compat_barrier.h | 2 +-
 arch/arm64/kernel/vdso32/Makefile            | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
index fb60a88b5ed4..3fd8fd6d8fc2 100644
--- a/arch/arm64/include/asm/vdso/compat_barrier.h
+++ b/arch/arm64/include/asm/vdso/compat_barrier.h
@@ -20,7 +20,7 @@
 
 #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
 
-#if __LINUX_ARM_ARCH__ >= 8
+#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
 #define aarch32_smp_mb()	dmb(ish)
 #define aarch32_smp_rmb()	dmb(ishld)
 #define aarch32_smp_wmb()	dmb(ishst)
diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 19e0d3115ffe..77aa61340374 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -15,6 +15,8 @@ cc32-disable-warning = $(call try-run,\
 	$(COMPATCC) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
 cc32-ldoption = $(call try-run,\
         $(COMPATCC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
+cc32-as-instr = $(call try-run,\
+	printf "%b\n" "$(1)" | $(COMPATCC) $(VDSO_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
 
 # We cannot use the global flags to compile the vDSO files, the main reason
 # being that the 32-bit compiler may be older than the main (64-bit) compiler
@@ -53,6 +55,7 @@ endif
 VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
 VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
 
+
 # Try to compile for ARMv8. If the compiler is too old and doesn't support it,
 # fall back to v7. There is no easy way to check for what architecture the code
 # is being compiled, so define a macro specifying that (see arch/arm/Makefile).
@@ -89,6 +92,12 @@ VDSO_CFLAGS += -Wno-int-to-pointer-cast
 VDSO_AFLAGS := $(VDSO_CAFLAGS)
 VDSO_AFLAGS += -D__ASSEMBLY__
 
+# Check for binutils support for dmb ishld
+dmbinstr := $(call cc32-as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1)
+
+VDSO_CFLAGS += $(dmbinstr)
+VDSO_AFLAGS += $(dmbinstr)
+
 VDSO_LDFLAGS := $(VDSO_CPPFLAGS)
 # From arm vDSO Makefile
 VDSO_LDFLAGS += -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH v3 2/5] arm64: vdso32: Detect binutils support for dmb ishld
@ 2019-09-26 21:43     ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 21:43 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

As reported by Will Deacon, older versions of binutils that do not
support certain types of memory barriers can cause build failure of the
vdso32 library.

Add a compilation time mechanism that detects if binutils supports those
instructions and configure the kernel accordingly.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/include/asm/vdso/compat_barrier.h | 2 +-
 arch/arm64/kernel/vdso32/Makefile            | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
index fb60a88b5ed4..3fd8fd6d8fc2 100644
--- a/arch/arm64/include/asm/vdso/compat_barrier.h
+++ b/arch/arm64/include/asm/vdso/compat_barrier.h
@@ -20,7 +20,7 @@
 
 #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
 
-#if __LINUX_ARM_ARCH__ >= 8
+#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
 #define aarch32_smp_mb()	dmb(ish)
 #define aarch32_smp_rmb()	dmb(ishld)
 #define aarch32_smp_wmb()	dmb(ishst)
diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 19e0d3115ffe..77aa61340374 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -15,6 +15,8 @@ cc32-disable-warning = $(call try-run,\
 	$(COMPATCC) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
 cc32-ldoption = $(call try-run,\
         $(COMPATCC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
+cc32-as-instr = $(call try-run,\
+	printf "%b\n" "$(1)" | $(COMPATCC) $(VDSO_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
 
 # We cannot use the global flags to compile the vDSO files, the main reason
 # being that the 32-bit compiler may be older than the main (64-bit) compiler
@@ -53,6 +55,7 @@ endif
 VDSO_CAFLAGS += -fPIC -fno-builtin -fno-stack-protector
 VDSO_CAFLAGS += -DDISABLE_BRANCH_PROFILING
 
+
 # Try to compile for ARMv8. If the compiler is too old and doesn't support it,
 # fall back to v7. There is no easy way to check for what architecture the code
 # is being compiled, so define a macro specifying that (see arch/arm/Makefile).
@@ -89,6 +92,12 @@ VDSO_CFLAGS += -Wno-int-to-pointer-cast
 VDSO_AFLAGS := $(VDSO_CAFLAGS)
 VDSO_AFLAGS += -D__ASSEMBLY__
 
+# Check for binutils support for dmb ishld
+dmbinstr := $(call cc32-as-instr,dmb ishld,-DCONFIG_AS_DMB_ISHLD=1)
+
+VDSO_CFLAGS += $(dmbinstr)
+VDSO_AFLAGS += $(dmbinstr)
+
 VDSO_LDFLAGS := $(VDSO_CPPFLAGS)
 # From arm vDSO Makefile
 VDSO_LDFLAGS += -Wl,-Bsymbolic -Wl,--no-undefined -Wl,-soname=linux-vdso.so.1
-- 
2.23.0


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

^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH v3 3/5] arm64: vdso32: Fix compilation warning
  2019-09-26 21:43   ` Vincenzo Frascino
@ 2019-09-26 21:43     ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 21:43 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

As reported by Will Deacon the following compilation warning appears
during the compilation of the vdso32:

In file included from ./arch/arm64/include/asm/thread_info.h:17:0,
                 from ./include/linux/thread_info.h:38,
                 from ./arch/arm64/include/asm/preempt.h:5,
                 from ./include/linux/preempt.h:78,
                 from ./include/linux/spinlock.h:51,
                 from ./include/linux/seqlock.h:36,
                 from ./include/linux/time.h:6,
                 from .../work/linux/lib/vdso/gettimeofday.c:7,
                 from <command-line>:0:
./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
  u64 __addr = (u64)addr & ~__tag_shifted(0xff);
               ^
In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0,
                 from ./arch/arm64/include/asm/processor.h:34,
                 from ./arch/arm64/include/asm/elf.h:118,
                 from ./include/linux/elf.h:5,
                 from ./include/linux/elfnote.h:62,
                 from arch/arm64/kernel/vdso32/note.c:11:
./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
  u64 __addr = (u64)addr & ~__tag_shifted(0xff);
               ^

This happens because few 64 bit compilation headers are included during
the generation of vdso32.

Fix the issue redefining the __tag_set function.

Note: This fix is meant to be temporary, a more comprehensive solution
based on the refactoring of the generic headers will be provided with a
future patch set. At that point it will be possible to revert this patch.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/include/asm/memory.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index b61b50bf68b1..c61b2eb50a3b 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -228,11 +228,14 @@ static inline unsigned long kaslr_offset(void)
 #define __tag_get(addr)		0
 #endif /* CONFIG_KASAN_SW_TAGS */
 
+#ifdef __aarch64__
+/* Do not attempt to compile this code with compat vdso */
 static inline const void *__tag_set(const void *addr, u8 tag)
 {
 	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
 	return (const void *)(__addr | __tag_shifted(tag));
 }
+#endif
 
 /*
  * Physical vs virtual RAM address space conversion.  These are
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH v3 3/5] arm64: vdso32: Fix compilation warning
@ 2019-09-26 21:43     ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 21:43 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

As reported by Will Deacon the following compilation warning appears
during the compilation of the vdso32:

In file included from ./arch/arm64/include/asm/thread_info.h:17:0,
                 from ./include/linux/thread_info.h:38,
                 from ./arch/arm64/include/asm/preempt.h:5,
                 from ./include/linux/preempt.h:78,
                 from ./include/linux/spinlock.h:51,
                 from ./include/linux/seqlock.h:36,
                 from ./include/linux/time.h:6,
                 from .../work/linux/lib/vdso/gettimeofday.c:7,
                 from <command-line>:0:
./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
  u64 __addr = (u64)addr & ~__tag_shifted(0xff);
               ^
In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0,
                 from ./arch/arm64/include/asm/processor.h:34,
                 from ./arch/arm64/include/asm/elf.h:118,
                 from ./include/linux/elf.h:5,
                 from ./include/linux/elfnote.h:62,
                 from arch/arm64/kernel/vdso32/note.c:11:
./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
  u64 __addr = (u64)addr & ~__tag_shifted(0xff);
               ^

This happens because few 64 bit compilation headers are included during
the generation of vdso32.

Fix the issue redefining the __tag_set function.

Note: This fix is meant to be temporary, a more comprehensive solution
based on the refactoring of the generic headers will be provided with a
future patch set. At that point it will be possible to revert this patch.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/include/asm/memory.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index b61b50bf68b1..c61b2eb50a3b 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -228,11 +228,14 @@ static inline unsigned long kaslr_offset(void)
 #define __tag_get(addr)		0
 #endif /* CONFIG_KASAN_SW_TAGS */
 
+#ifdef __aarch64__
+/* Do not attempt to compile this code with compat vdso */
 static inline const void *__tag_set(const void *addr, u8 tag)
 {
 	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
 	return (const void *)(__addr | __tag_shifted(tag));
 }
+#endif
 
 /*
  * Physical vs virtual RAM address space conversion.  These are
-- 
2.23.0


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

^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH v3 4/5] arm64: Remove gettimeofday.S
  2019-09-26 21:43   ` Vincenzo Frascino
@ 2019-09-26 21:43     ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 21:43 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

gettimeofday.S was originally removed with the introduction of the
support for Unified vDSOs in arm64 and replaced with the C
implementation.

The file seems again present in the repository due to a side effect of
rebase.

Remove the file again.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
---
 arch/arm64/kernel/vdso/gettimeofday.S | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 arch/arm64/kernel/vdso/gettimeofday.S

diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S
deleted file mode 100644
index e69de29bb2d1..000000000000
-- 
2.23.0


^ permalink raw reply	[flat|nested] 127+ messages in thread

* [PATCH v3 4/5] arm64: Remove gettimeofday.S
@ 2019-09-26 21:43     ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 21:43 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

gettimeofday.S was originally removed with the introduction of the
support for Unified vDSOs in arm64 and replaced with the C
implementation.

The file seems again present in the repository due to a side effect of
rebase.

Remove the file again.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
---
 arch/arm64/kernel/vdso/gettimeofday.S | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 arch/arm64/kernel/vdso/gettimeofday.S

diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S
deleted file mode 100644
index e69de29bb2d1..000000000000
-- 
2.23.0


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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* [PATCH v3 5/5] arm64: vdso32: Remove jump label config option in Makefile
  2019-09-26 21:43   ` Vincenzo Frascino
@ 2019-09-26 21:43     ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 21:43 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: vincenzo.frascino, ard.biesheuvel, ndesaulniers, catalin.marinas,
	will, tglx

The jump labels are not used in vdso32 since it is not possible to run
runtime patching on them.

Remove the configuration option from the Makefile.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/kernel/vdso32/Makefile | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 77aa61340374..038357a1e835 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -38,9 +38,6 @@ VDSO_CAFLAGS += $(call cc32-option,-fno-PIE)
 ifdef CONFIG_DEBUG_INFO
 VDSO_CAFLAGS += -g
 endif
-ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(COMPATCC)), y)
-VDSO_CAFLAGS += -DCC_HAVE_ASM_GOTO
-endif
 
 # From arm Makefile
 VDSO_CAFLAGS += $(call cc32-option,-fno-dwarf2-cfi-asm)
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 127+ messages in thread

* [PATCH v3 5/5] arm64: vdso32: Remove jump label config option in Makefile
@ 2019-09-26 21:43     ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-09-26 21:43 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, tglx,
	vincenzo.frascino, will

The jump labels are not used in vdso32 since it is not possible to run
runtime patching on them.

Remove the configuration option from the Makefile.

Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/arm64/kernel/vdso32/Makefile | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
index 77aa61340374..038357a1e835 100644
--- a/arch/arm64/kernel/vdso32/Makefile
+++ b/arch/arm64/kernel/vdso32/Makefile
@@ -38,9 +38,6 @@ VDSO_CAFLAGS += $(call cc32-option,-fno-PIE)
 ifdef CONFIG_DEBUG_INFO
 VDSO_CAFLAGS += -g
 endif
-ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(COMPATCC)), y)
-VDSO_CAFLAGS += -DCC_HAVE_ASM_GOTO
-endif
 
 # From arm Makefile
 VDSO_CAFLAGS += $(call cc32-option,-fno-dwarf2-cfi-asm)
-- 
2.23.0


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

^ permalink raw reply related	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-09-26 21:43     ` Vincenzo Frascino
@ 2019-09-27  9:24       ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-27  9:24 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
> Address the problem removing CONFIG_CROSS_COMPILE_COMPAT_VDSO and moving

And this config does need to go in a subsequent patch.

> the detection of the correct compiler into Kconfig via COMPAT_CC_IS_GCC.

Nitpick: it's COMPATCC_IS_ARM_GCC now.

> As a consequence of this it is not possible anymore to set the compat
> cross compiler from menuconfig but it requires to be exported via
> command line.
> 
> E.g.:
> 
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
> CROSS_COMPILE_COMPAT=arm-linux-gnueabihf

Another nitpick, add a '-' at the end of 'gnueabihf'.

Otherwise:

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-09-27  9:24       ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-27  9:24 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
> Address the problem removing CONFIG_CROSS_COMPILE_COMPAT_VDSO and moving

And this config does need to go in a subsequent patch.

> the detection of the correct compiler into Kconfig via COMPAT_CC_IS_GCC.

Nitpick: it's COMPATCC_IS_ARM_GCC now.

> As a consequence of this it is not possible anymore to set the compat
> cross compiler from menuconfig but it requires to be exported via
> command line.
> 
> E.g.:
> 
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
> CROSS_COMPILE_COMPAT=arm-linux-gnueabihf

Another nitpick, add a '-' at the end of 'gnueabihf'.

Otherwise:

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 2/5] arm64: vdso32: Detect binutils support for dmb ishld
  2019-09-26 21:43     ` Vincenzo Frascino
@ 2019-09-27  9:25       ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-27  9:25 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On Thu, Sep 26, 2019 at 10:43:39PM +0100, Vincenzo Frascino wrote:
> As reported by Will Deacon, older versions of binutils that do not
> support certain types of memory barriers can cause build failure of the
> vdso32 library.
> 
> Add a compilation time mechanism that detects if binutils supports those
> instructions and configure the kernel accordingly.
> 
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 2/5] arm64: vdso32: Detect binutils support for dmb ishld
@ 2019-09-27  9:25       ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-27  9:25 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 10:43:39PM +0100, Vincenzo Frascino wrote:
> As reported by Will Deacon, older versions of binutils that do not
> support certain types of memory barriers can cause build failure of the
> vdso32 library.
> 
> Add a compilation time mechanism that detects if binutils supports those
> instructions and configure the kernel accordingly.
> 
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 3/5] arm64: vdso32: Fix compilation warning
  2019-09-26 21:43     ` Vincenzo Frascino
@ 2019-09-27  9:26       ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-27  9:26 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On Thu, Sep 26, 2019 at 10:43:40PM +0100, Vincenzo Frascino wrote:
> Note: This fix is meant to be temporary, a more comprehensive solution
> based on the refactoring of the generic headers will be provided with a
> future patch set. At that point it will be possible to revert this patch.

With this note, I'm fine with the patch.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 3/5] arm64: vdso32: Fix compilation warning
@ 2019-09-27  9:26       ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-27  9:26 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 10:43:40PM +0100, Vincenzo Frascino wrote:
> Note: This fix is meant to be temporary, a more comprehensive solution
> based on the refactoring of the generic headers will be provided with a
> future patch set. At that point it will be possible to revert this patch.

With this note, I'm fine with the patch.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 5/5] arm64: vdso32: Remove jump label config option in Makefile
  2019-09-26 21:43     ` Vincenzo Frascino
@ 2019-09-27  9:27       ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-27  9:27 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On Thu, Sep 26, 2019 at 10:43:42PM +0100, Vincenzo Frascino wrote:
> The jump labels are not used in vdso32 since it is not possible to run
> runtime patching on them.
> 
> Remove the configuration option from the Makefile.
> 
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 5/5] arm64: vdso32: Remove jump label config option in Makefile
@ 2019-09-27  9:27       ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-27  9:27 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 10:43:42PM +0100, Vincenzo Frascino wrote:
> The jump labels are not used in vdso32 since it is not possible to run
> runtime patching on them.
> 
> Remove the configuration option from the Makefile.
> 
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 0/5]arm64: vdso32: Address various issues
  2019-09-26 21:43   ` Vincenzo Frascino
@ 2019-09-27 10:46     ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-27 10:46 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, will, tglx

On Thu, Sep 26, 2019 at 10:43:37PM +0100, Vincenzo Frascino wrote:
> Vincenzo Frascino (5):
>   arm64: vdso32: Introduce COMPAT_CC_IS_GCC
>   arm64: vdso32: Detect binutils support for dmb ishld
>   arm64: vdso32: Fix compilation warning
>   arm64: Remove gettimeofday.S
>   arm64: vdso32: Remove jump label config option in Makefile

You can add this as well:

Tested-by: Catalin Marinas <catalin.marinas@arm.com>

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 0/5]arm64: vdso32: Address various issues
@ 2019-09-27 10:46     ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-09-27 10:46 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx, will, linux-arm-kernel

On Thu, Sep 26, 2019 at 10:43:37PM +0100, Vincenzo Frascino wrote:
> Vincenzo Frascino (5):
>   arm64: vdso32: Introduce COMPAT_CC_IS_GCC
>   arm64: vdso32: Detect binutils support for dmb ishld
>   arm64: vdso32: Fix compilation warning
>   arm64: Remove gettimeofday.S
>   arm64: vdso32: Remove jump label config option in Makefile

You can add this as well:

Tested-by: Catalin Marinas <catalin.marinas@arm.com>

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-09-26 21:43     ` Vincenzo Frascino
@ 2019-10-01 13:14       ` Will Deacon
  -1 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 13:14 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers,
	catalin.marinas, tglx

On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
> As reported by Will Deacon the .config file and the generated
> include/config/auto.conf can end up out of sync after a set of
> commands since CONFIG_CROSS_COMPILE_COMPAT_VDSO is not updated
> correctly.
> 
> The sequence can be reproduced as follows:
> 
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
> [...]
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
> [set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
> 
> Which results in:
> 
> arch/arm64/Makefile:62: CROSS_COMPILE_COMPAT not defined or empty,
> the compat vDSO will not be built
> 
> even though the compat vDSO has been built:
> 
> $ file arch/arm64/kernel/vdso32/vdso.so
> arch/arm64/kernel/vdso32/vdso.so: ELF 32-bit LSB pie executable, ARM,
> EABI5 version 1 (SYSV), dynamically linked,
> BuildID[sha1]=c67f6c786f2d2d6f86c71f708595594aa25247f6, stripped
> 
> A similar case that involves changing the configuration parameter multiple
> times can be reconducted to the same family of problems.
> 
> The reason behind it comes from the fact that the master Makefile includes
> that architecture Makefile twice, once before the syncconfig and one after.
> Since the synchronization of the files happens only upon syncconfig, the
> architecture Makefile included before this event does not see the change in
> configuration.
> 
> As a consequence of this it is not possible to handle the cross compiler
> definitions inside the architecture Makefile.
> 
> Address the problem removing CONFIG_CROSS_COMPILE_COMPAT_VDSO and moving
> the detection of the correct compiler into Kconfig via COMPAT_CC_IS_GCC.
> 
> As a consequence of this it is not possible anymore to set the compat
> cross compiler from menuconfig but it requires to be exported via
> command line.
> 
> E.g.:
> 
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
> CROSS_COMPILE_COMPAT=arm-linux-gnueabihf
> 
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>  arch/arm64/Kconfig                |  5 ++++-
>  arch/arm64/Makefile               | 18 +++++-------------
>  arch/arm64/kernel/vdso32/Makefile |  2 --
>  3 files changed, 9 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 37c610963eee..0e5beb928af5 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -110,7 +110,7 @@ config ARM64
>  	select GENERIC_STRNLEN_USER
>  	select GENERIC_TIME_VSYSCALL
>  	select GENERIC_GETTIMEOFDAY
> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_ARM_GCC)
>  	select HANDLE_DOMAIN_IRQ
>  	select HARDIRQS_SW_RESEND
>  	select HAVE_PCI
> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>  	default 0xffffffffffffffff
>  
> +config COMPATCC_IS_ARM_GCC
> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")

I've seen toolchains where the first part of the tuple is "armv7-", so they
won't get detected here. However, do we really need to detect this? If
somebody passes a duff compiler, then the build will fail in the same way as
if they passed it to CROSS_COMPILE=.

I'd prefer to drop this check altogether.

Will

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-10-01 13:14       ` Will Deacon
  0 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 13:14 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, linux-kernel,
	tglx, linux-arm-kernel

On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
> As reported by Will Deacon the .config file and the generated
> include/config/auto.conf can end up out of sync after a set of
> commands since CONFIG_CROSS_COMPILE_COMPAT_VDSO is not updated
> correctly.
> 
> The sequence can be reproduced as follows:
> 
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- defconfig
> [...]
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig
> [set CONFIG_CROSS_COMPILE_COMPAT_VDSO="arm-linux-gnueabihf-"]
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
> 
> Which results in:
> 
> arch/arm64/Makefile:62: CROSS_COMPILE_COMPAT not defined or empty,
> the compat vDSO will not be built
> 
> even though the compat vDSO has been built:
> 
> $ file arch/arm64/kernel/vdso32/vdso.so
> arch/arm64/kernel/vdso32/vdso.so: ELF 32-bit LSB pie executable, ARM,
> EABI5 version 1 (SYSV), dynamically linked,
> BuildID[sha1]=c67f6c786f2d2d6f86c71f708595594aa25247f6, stripped
> 
> A similar case that involves changing the configuration parameter multiple
> times can be reconducted to the same family of problems.
> 
> The reason behind it comes from the fact that the master Makefile includes
> that architecture Makefile twice, once before the syncconfig and one after.
> Since the synchronization of the files happens only upon syncconfig, the
> architecture Makefile included before this event does not see the change in
> configuration.
> 
> As a consequence of this it is not possible to handle the cross compiler
> definitions inside the architecture Makefile.
> 
> Address the problem removing CONFIG_CROSS_COMPILE_COMPAT_VDSO and moving
> the detection of the correct compiler into Kconfig via COMPAT_CC_IS_GCC.
> 
> As a consequence of this it is not possible anymore to set the compat
> cross compiler from menuconfig but it requires to be exported via
> command line.
> 
> E.g.:
> 
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
> CROSS_COMPILE_COMPAT=arm-linux-gnueabihf
> 
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>  arch/arm64/Kconfig                |  5 ++++-
>  arch/arm64/Makefile               | 18 +++++-------------
>  arch/arm64/kernel/vdso32/Makefile |  2 --
>  3 files changed, 9 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 37c610963eee..0e5beb928af5 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -110,7 +110,7 @@ config ARM64
>  	select GENERIC_STRNLEN_USER
>  	select GENERIC_TIME_VSYSCALL
>  	select GENERIC_GETTIMEOFDAY
> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_ARM_GCC)
>  	select HANDLE_DOMAIN_IRQ
>  	select HARDIRQS_SW_RESEND
>  	select HAVE_PCI
> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>  	default 0xffffffffffffffff
>  
> +config COMPATCC_IS_ARM_GCC
> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")

I've seen toolchains where the first part of the tuple is "armv7-", so they
won't get detected here. However, do we really need to detect this? If
somebody passes a duff compiler, then the build will fail in the same way as
if they passed it to CROSS_COMPILE=.

I'd prefer to drop this check altogether.

Will

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 3/5] arm64: vdso32: Fix compilation warning
  2019-09-26 21:43     ` Vincenzo Frascino
@ 2019-10-01 13:21       ` Will Deacon
  -1 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 13:21 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers,
	catalin.marinas, tglx

On Thu, Sep 26, 2019 at 10:43:40PM +0100, Vincenzo Frascino wrote:
> As reported by Will Deacon the following compilation warning appears
> during the compilation of the vdso32:
> 
> In file included from ./arch/arm64/include/asm/thread_info.h:17:0,
>                  from ./include/linux/thread_info.h:38,
>                  from ./arch/arm64/include/asm/preempt.h:5,
>                  from ./include/linux/preempt.h:78,
>                  from ./include/linux/spinlock.h:51,
>                  from ./include/linux/seqlock.h:36,
>                  from ./include/linux/time.h:6,
>                  from .../work/linux/lib/vdso/gettimeofday.c:7,
>                  from <command-line>:0:
> ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
> ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
> integer of different size [-Wpointer-to-int-cast]
>   u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>                ^
> In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0,
>                  from ./arch/arm64/include/asm/processor.h:34,
>                  from ./arch/arm64/include/asm/elf.h:118,
>                  from ./include/linux/elf.h:5,
>                  from ./include/linux/elfnote.h:62,
>                  from arch/arm64/kernel/vdso32/note.c:11:
> ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
> ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
> integer of different size [-Wpointer-to-int-cast]
>   u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>                ^
> 
> This happens because few 64 bit compilation headers are included during
> the generation of vdso32.
> 
> Fix the issue redefining the __tag_set function.
> 
> Note: This fix is meant to be temporary, a more comprehensive solution
> based on the refactoring of the generic headers will be provided with a
> future patch set. At that point it will be possible to revert this patch.
> 
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>  arch/arm64/include/asm/memory.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index b61b50bf68b1..c61b2eb50a3b 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -228,11 +228,14 @@ static inline unsigned long kaslr_offset(void)
>  #define __tag_get(addr)		0
>  #endif /* CONFIG_KASAN_SW_TAGS */
>  
> +#ifdef __aarch64__
> +/* Do not attempt to compile this code with compat vdso */
>  static inline const void *__tag_set(const void *addr, u8 tag)
>  {
>  	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>  	return (const void *)(__addr | __tag_shifted(tag));
>  }
> +#endif

Sorry, but I'm not taking this.

I know you're trying to fix the issues I reported as quickly as you can (and
thank you for that), but I'm sure that you agree this needs more thought to
develop a proper solution to what is a much bigger issue than can be solved
by sprinkling #ifdefs. I can live with the warning on the basis that a
proper fix is in the pipeline, but in the meantime it can serve as a
reminder that we're not done here.

Will

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 3/5] arm64: vdso32: Fix compilation warning
@ 2019-10-01 13:21       ` Will Deacon
  0 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 13:21 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, linux-kernel,
	tglx, linux-arm-kernel

On Thu, Sep 26, 2019 at 10:43:40PM +0100, Vincenzo Frascino wrote:
> As reported by Will Deacon the following compilation warning appears
> during the compilation of the vdso32:
> 
> In file included from ./arch/arm64/include/asm/thread_info.h:17:0,
>                  from ./include/linux/thread_info.h:38,
>                  from ./arch/arm64/include/asm/preempt.h:5,
>                  from ./include/linux/preempt.h:78,
>                  from ./include/linux/spinlock.h:51,
>                  from ./include/linux/seqlock.h:36,
>                  from ./include/linux/time.h:6,
>                  from .../work/linux/lib/vdso/gettimeofday.c:7,
>                  from <command-line>:0:
> ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
> ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
> integer of different size [-Wpointer-to-int-cast]
>   u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>                ^
> In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0,
>                  from ./arch/arm64/include/asm/processor.h:34,
>                  from ./arch/arm64/include/asm/elf.h:118,
>                  from ./include/linux/elf.h:5,
>                  from ./include/linux/elfnote.h:62,
>                  from arch/arm64/kernel/vdso32/note.c:11:
> ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
> ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
> integer of different size [-Wpointer-to-int-cast]
>   u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>                ^
> 
> This happens because few 64 bit compilation headers are included during
> the generation of vdso32.
> 
> Fix the issue redefining the __tag_set function.
> 
> Note: This fix is meant to be temporary, a more comprehensive solution
> based on the refactoring of the generic headers will be provided with a
> future patch set. At that point it will be possible to revert this patch.
> 
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>  arch/arm64/include/asm/memory.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
> index b61b50bf68b1..c61b2eb50a3b 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -228,11 +228,14 @@ static inline unsigned long kaslr_offset(void)
>  #define __tag_get(addr)		0
>  #endif /* CONFIG_KASAN_SW_TAGS */
>  
> +#ifdef __aarch64__
> +/* Do not attempt to compile this code with compat vdso */
>  static inline const void *__tag_set(const void *addr, u8 tag)
>  {
>  	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>  	return (const void *)(__addr | __tag_shifted(tag));
>  }
> +#endif

Sorry, but I'm not taking this.

I know you're trying to fix the issues I reported as quickly as you can (and
thank you for that), but I'm sure that you agree this needs more thought to
develop a proper solution to what is a much bigger issue than can be solved
by sprinkling #ifdefs. I can live with the warning on the basis that a
proper fix is in the pipeline, but in the meantime it can serve as a
reminder that we're not done here.

Will

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 2/5] arm64: vdso32: Detect binutils support for dmb ishld
  2019-09-26 21:43     ` Vincenzo Frascino
@ 2019-10-01 13:26       ` Will Deacon
  -1 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 13:26 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers,
	catalin.marinas, tglx

On Thu, Sep 26, 2019 at 10:43:39PM +0100, Vincenzo Frascino wrote:
> As reported by Will Deacon, older versions of binutils that do not
> support certain types of memory barriers can cause build failure of the
> vdso32 library.
> 
> Add a compilation time mechanism that detects if binutils supports those
> instructions and configure the kernel accordingly.
> 
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>  arch/arm64/include/asm/vdso/compat_barrier.h | 2 +-
>  arch/arm64/kernel/vdso32/Makefile            | 9 +++++++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
> index fb60a88b5ed4..3fd8fd6d8fc2 100644
> --- a/arch/arm64/include/asm/vdso/compat_barrier.h
> +++ b/arch/arm64/include/asm/vdso/compat_barrier.h
> @@ -20,7 +20,7 @@
>  
>  #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
>  
> -#if __LINUX_ARM_ARCH__ >= 8
> +#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
>  #define aarch32_smp_mb()	dmb(ish)
>  #define aarch32_smp_rmb()	dmb(ishld)
>  #define aarch32_smp_wmb()	dmb(ishst)
> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
> index 19e0d3115ffe..77aa61340374 100644
> --- a/arch/arm64/kernel/vdso32/Makefile
> +++ b/arch/arm64/kernel/vdso32/Makefile
> @@ -15,6 +15,8 @@ cc32-disable-warning = $(call try-run,\
>  	$(COMPATCC) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
>  cc32-ldoption = $(call try-run,\
>          $(COMPATCC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
> +cc32-as-instr = $(call try-run,\
> +	printf "%b\n" "$(1)" | $(COMPATCC) $(VDSO_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))

It's a shame that we have to duplicate the logic from scripts/Kbuild.include
here. Is there a way to reuse those helpers by temporarily overriding things
like CC and KBUILD_AFLAGS? If not, no bother, but thought I'd better ask.

Will

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 2/5] arm64: vdso32: Detect binutils support for dmb ishld
@ 2019-10-01 13:26       ` Will Deacon
  0 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 13:26 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, linux-kernel,
	tglx, linux-arm-kernel

On Thu, Sep 26, 2019 at 10:43:39PM +0100, Vincenzo Frascino wrote:
> As reported by Will Deacon, older versions of binutils that do not
> support certain types of memory barriers can cause build failure of the
> vdso32 library.
> 
> Add a compilation time mechanism that detects if binutils supports those
> instructions and configure the kernel accordingly.
> 
> Cc: Will Deacon <will@kernel.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>  arch/arm64/include/asm/vdso/compat_barrier.h | 2 +-
>  arch/arm64/kernel/vdso32/Makefile            | 9 +++++++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
> index fb60a88b5ed4..3fd8fd6d8fc2 100644
> --- a/arch/arm64/include/asm/vdso/compat_barrier.h
> +++ b/arch/arm64/include/asm/vdso/compat_barrier.h
> @@ -20,7 +20,7 @@
>  
>  #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
>  
> -#if __LINUX_ARM_ARCH__ >= 8
> +#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
>  #define aarch32_smp_mb()	dmb(ish)
>  #define aarch32_smp_rmb()	dmb(ishld)
>  #define aarch32_smp_wmb()	dmb(ishst)
> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
> index 19e0d3115ffe..77aa61340374 100644
> --- a/arch/arm64/kernel/vdso32/Makefile
> +++ b/arch/arm64/kernel/vdso32/Makefile
> @@ -15,6 +15,8 @@ cc32-disable-warning = $(call try-run,\
>  	$(COMPATCC) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
>  cc32-ldoption = $(call try-run,\
>          $(COMPATCC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
> +cc32-as-instr = $(call try-run,\
> +	printf "%b\n" "$(1)" | $(COMPATCC) $(VDSO_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))

It's a shame that we have to duplicate the logic from scripts/Kbuild.include
here. Is there a way to reuse those helpers by temporarily overriding things
like CC and KBUILD_AFLAGS? If not, no bother, but thought I'd better ask.

Will

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 0/5]arm64: vdso32: Address various issues
  2019-09-26 21:43   ` Vincenzo Frascino
@ 2019-10-01 13:27     ` Will Deacon
  -1 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 13:27 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers,
	catalin.marinas, tglx

On Thu, Sep 26, 2019 at 10:43:37PM +0100, Vincenzo Frascino wrote:
> this patch series is meant to address the various compilation issues you
> reported about arm64 vdso32.

Thanks, I've commented on the patches. Also, when you respin, please can
you drop the "As reported by Will Deacon ..." lines from the commit messages
and just add a Reported-by tag instead?

Thanks,

Will

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 0/5]arm64: vdso32: Address various issues
@ 2019-10-01 13:27     ` Will Deacon
  0 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 13:27 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, linux-kernel,
	tglx, linux-arm-kernel

On Thu, Sep 26, 2019 at 10:43:37PM +0100, Vincenzo Frascino wrote:
> this patch series is meant to address the various compilation issues you
> reported about arm64 vdso32.

Thanks, I've commented on the patches. Also, when you respin, please can
you drop the "As reported by Will Deacon ..." lines from the commit messages
and just add a Reported-by tag instead?

Thanks,

Will

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-10-01 13:14       ` Will Deacon
@ 2019-10-01 13:27         ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-10-01 13:27 UTC (permalink / raw)
  To: Will Deacon
  Cc: Vincenzo Frascino, linux-arm-kernel, linux-kernel,
	ard.biesheuvel, ndesaulniers, tglx

On Tue, Oct 01, 2019 at 02:14:23PM +0100, Will Deacon wrote:
> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
> > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> > index 37c610963eee..0e5beb928af5 100644
> > --- a/arch/arm64/Kconfig
> > +++ b/arch/arm64/Kconfig
> > @@ -110,7 +110,7 @@ config ARM64
> >  	select GENERIC_STRNLEN_USER
> >  	select GENERIC_TIME_VSYSCALL
> >  	select GENERIC_GETTIMEOFDAY
> > -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
> > +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_ARM_GCC)
> >  	select HANDLE_DOMAIN_IRQ
> >  	select HARDIRQS_SW_RESEND
> >  	select HAVE_PCI
> > @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
> >  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
> >  	default 0xffffffffffffffff
> >  
> > +config COMPATCC_IS_ARM_GCC
> > +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
> 
> I've seen toolchains where the first part of the tuple is "armv7-", so they
> won't get detected here. However, do we really need to detect this? If
> somebody passes a duff compiler, then the build will fail in the same way as
> if they passed it to CROSS_COMPILE=.

Not sure what happens if we pass an aarch64 compiler. Can we end up with
a 64-bit compat vDSO?

-- 
Catalin

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-10-01 13:27         ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-10-01 13:27 UTC (permalink / raw)
  To: Will Deacon
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx,
	Vincenzo Frascino, linux-arm-kernel

On Tue, Oct 01, 2019 at 02:14:23PM +0100, Will Deacon wrote:
> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
> > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> > index 37c610963eee..0e5beb928af5 100644
> > --- a/arch/arm64/Kconfig
> > +++ b/arch/arm64/Kconfig
> > @@ -110,7 +110,7 @@ config ARM64
> >  	select GENERIC_STRNLEN_USER
> >  	select GENERIC_TIME_VSYSCALL
> >  	select GENERIC_GETTIMEOFDAY
> > -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
> > +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_ARM_GCC)
> >  	select HANDLE_DOMAIN_IRQ
> >  	select HARDIRQS_SW_RESEND
> >  	select HAVE_PCI
> > @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
> >  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
> >  	default 0xffffffffffffffff
> >  
> > +config COMPATCC_IS_ARM_GCC
> > +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
> 
> I've seen toolchains where the first part of the tuple is "armv7-", so they
> won't get detected here. However, do we really need to detect this? If
> somebody passes a duff compiler, then the build will fail in the same way as
> if they passed it to CROSS_COMPILE=.

Not sure what happens if we pass an aarch64 compiler. Can we end up with
a 64-bit compat vDSO?

-- 
Catalin

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-10-01 13:27         ` Catalin Marinas
@ 2019-10-01 14:20           ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-10-01 14:20 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers, tglx

On 10/1/19 2:27 PM, Catalin Marinas wrote:
> On Tue, Oct 01, 2019 at 02:14:23PM +0100, Will Deacon wrote:
>> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
>>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>>> index 37c610963eee..0e5beb928af5 100644
>>> --- a/arch/arm64/Kconfig
>>> +++ b/arch/arm64/Kconfig
>>> @@ -110,7 +110,7 @@ config ARM64
>>>  	select GENERIC_STRNLEN_USER
>>>  	select GENERIC_TIME_VSYSCALL
>>>  	select GENERIC_GETTIMEOFDAY
>>> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
>>> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_ARM_GCC)
>>>  	select HANDLE_DOMAIN_IRQ
>>>  	select HARDIRQS_SW_RESEND
>>>  	select HAVE_PCI
>>> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>>>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>>>  	default 0xffffffffffffffff
>>>  
>>> +config COMPATCC_IS_ARM_GCC
>>> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
>>
>> I've seen toolchains where the first part of the tuple is "armv7-", so they
>> won't get detected here. However, do we really need to detect this? If
>> somebody passes a duff compiler, then the build will fail in the same way as
>> if they passed it to CROSS_COMPILE=.
> 
> Not sure what happens if we pass an aarch64 compiler. Can we end up with
> a 64-bit compat vDSO?
> 

I agree with Catalin here. The problem is not only when you pass and aarch64
toolchain but even an x86 and so on.

If the problem is related to armv7- we can change the rule as "arm.*-gcc" which
should detect them as well. Do you know what is the triple that an armv7-
toolchain prints?

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-10-01 14:20           ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-10-01 14:20 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: tglx, ndesaulniers, linux-kernel, linux-arm-kernel, ard.biesheuvel

On 10/1/19 2:27 PM, Catalin Marinas wrote:
> On Tue, Oct 01, 2019 at 02:14:23PM +0100, Will Deacon wrote:
>> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
>>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>>> index 37c610963eee..0e5beb928af5 100644
>>> --- a/arch/arm64/Kconfig
>>> +++ b/arch/arm64/Kconfig
>>> @@ -110,7 +110,7 @@ config ARM64
>>>  	select GENERIC_STRNLEN_USER
>>>  	select GENERIC_TIME_VSYSCALL
>>>  	select GENERIC_GETTIMEOFDAY
>>> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
>>> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_ARM_GCC)
>>>  	select HANDLE_DOMAIN_IRQ
>>>  	select HARDIRQS_SW_RESEND
>>>  	select HAVE_PCI
>>> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>>>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>>>  	default 0xffffffffffffffff
>>>  
>>> +config COMPATCC_IS_ARM_GCC
>>> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
>>
>> I've seen toolchains where the first part of the tuple is "armv7-", so they
>> won't get detected here. However, do we really need to detect this? If
>> somebody passes a duff compiler, then the build will fail in the same way as
>> if they passed it to CROSS_COMPILE=.
> 
> Not sure what happens if we pass an aarch64 compiler. Can we end up with
> a 64-bit compat vDSO?
> 

I agree with Catalin here. The problem is not only when you pass and aarch64
toolchain but even an x86 and so on.

If the problem is related to armv7- we can change the rule as "arm.*-gcc" which
should detect them as well. Do you know what is the triple that an armv7-
toolchain prints?

-- 
Regards,
Vincenzo

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-10-01 14:20           ` Vincenzo Frascino
@ 2019-10-01 14:20             ` Will Deacon
  -1 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 14:20 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: Catalin Marinas, linux-arm-kernel, linux-kernel, ard.biesheuvel,
	ndesaulniers, tglx

On Tue, Oct 01, 2019 at 03:20:35PM +0100, Vincenzo Frascino wrote:
> On 10/1/19 2:27 PM, Catalin Marinas wrote:
> > On Tue, Oct 01, 2019 at 02:14:23PM +0100, Will Deacon wrote:
> >> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
> >>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> >>> index 37c610963eee..0e5beb928af5 100644
> >>> --- a/arch/arm64/Kconfig
> >>> +++ b/arch/arm64/Kconfig
> >>> @@ -110,7 +110,7 @@ config ARM64
> >>>  	select GENERIC_STRNLEN_USER
> >>>  	select GENERIC_TIME_VSYSCALL
> >>>  	select GENERIC_GETTIMEOFDAY
> >>> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
> >>> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_ARM_GCC)
> >>>  	select HANDLE_DOMAIN_IRQ
> >>>  	select HARDIRQS_SW_RESEND
> >>>  	select HAVE_PCI
> >>> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
> >>>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
> >>>  	default 0xffffffffffffffff
> >>>  
> >>> +config COMPATCC_IS_ARM_GCC
> >>> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
> >>
> >> I've seen toolchains where the first part of the tuple is "armv7-", so they
> >> won't get detected here. However, do we really need to detect this? If
> >> somebody passes a duff compiler, then the build will fail in the same way as
> >> if they passed it to CROSS_COMPILE=.
> > 
> > Not sure what happens if we pass an aarch64 compiler. Can we end up with
> > a 64-bit compat vDSO?
> > 
> 
> I agree with Catalin here. The problem is not only when you pass and aarch64
> toolchain but even an x86 and so on.

I disagree. What happens if you do:

$ make ARCH=arm64 CROSS_COMPILE=x86_64-linux-gnu-

on your x86 box?

> If the problem is related to armv7- we can change the rule as "arm.*-gcc" which
> should detect them as well. Do you know what is the triple that an armv7-
> toolchain prints?

'fraid not, since I don't have one to hand. I think you'd end up matching
arm*-gcc, which is pretty broad.

Will

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-10-01 14:20             ` Will Deacon
  0 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 14:20 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, Catalin Marinas, ndesaulniers, linux-kernel,
	tglx, linux-arm-kernel

On Tue, Oct 01, 2019 at 03:20:35PM +0100, Vincenzo Frascino wrote:
> On 10/1/19 2:27 PM, Catalin Marinas wrote:
> > On Tue, Oct 01, 2019 at 02:14:23PM +0100, Will Deacon wrote:
> >> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
> >>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> >>> index 37c610963eee..0e5beb928af5 100644
> >>> --- a/arch/arm64/Kconfig
> >>> +++ b/arch/arm64/Kconfig
> >>> @@ -110,7 +110,7 @@ config ARM64
> >>>  	select GENERIC_STRNLEN_USER
> >>>  	select GENERIC_TIME_VSYSCALL
> >>>  	select GENERIC_GETTIMEOFDAY
> >>> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
> >>> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_ARM_GCC)
> >>>  	select HANDLE_DOMAIN_IRQ
> >>>  	select HARDIRQS_SW_RESEND
> >>>  	select HAVE_PCI
> >>> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
> >>>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
> >>>  	default 0xffffffffffffffff
> >>>  
> >>> +config COMPATCC_IS_ARM_GCC
> >>> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
> >>
> >> I've seen toolchains where the first part of the tuple is "armv7-", so they
> >> won't get detected here. However, do we really need to detect this? If
> >> somebody passes a duff compiler, then the build will fail in the same way as
> >> if they passed it to CROSS_COMPILE=.
> > 
> > Not sure what happens if we pass an aarch64 compiler. Can we end up with
> > a 64-bit compat vDSO?
> > 
> 
> I agree with Catalin here. The problem is not only when you pass and aarch64
> toolchain but even an x86 and so on.

I disagree. What happens if you do:

$ make ARCH=arm64 CROSS_COMPILE=x86_64-linux-gnu-

on your x86 box?

> If the problem is related to armv7- we can change the rule as "arm.*-gcc" which
> should detect them as well. Do you know what is the triple that an armv7-
> toolchain prints?

'fraid not, since I don't have one to hand. I think you'd end up matching
arm*-gcc, which is pretty broad.

Will

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 2/5] arm64: vdso32: Detect binutils support for dmb ishld
  2019-10-01 13:26       ` Will Deacon
@ 2019-10-01 14:23         ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-10-01 14:23 UTC (permalink / raw)
  To: Will Deacon
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers,
	catalin.marinas, tglx

On 10/1/19 2:26 PM, Will Deacon wrote:
> On Thu, Sep 26, 2019 at 10:43:39PM +0100, Vincenzo Frascino wrote:
>> As reported by Will Deacon, older versions of binutils that do not
>> support certain types of memory barriers can cause build failure of the
>> vdso32 library.
>>
>> Add a compilation time mechanism that detects if binutils supports those
>> instructions and configure the kernel accordingly.
>>
>> Cc: Will Deacon <will@kernel.org>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>> ---
>>  arch/arm64/include/asm/vdso/compat_barrier.h | 2 +-
>>  arch/arm64/kernel/vdso32/Makefile            | 9 +++++++++
>>  2 files changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
>> index fb60a88b5ed4..3fd8fd6d8fc2 100644
>> --- a/arch/arm64/include/asm/vdso/compat_barrier.h
>> +++ b/arch/arm64/include/asm/vdso/compat_barrier.h
>> @@ -20,7 +20,7 @@
>>  
>>  #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
>>  
>> -#if __LINUX_ARM_ARCH__ >= 8
>> +#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
>>  #define aarch32_smp_mb()	dmb(ish)
>>  #define aarch32_smp_rmb()	dmb(ishld)
>>  #define aarch32_smp_wmb()	dmb(ishst)
>> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
>> index 19e0d3115ffe..77aa61340374 100644
>> --- a/arch/arm64/kernel/vdso32/Makefile
>> +++ b/arch/arm64/kernel/vdso32/Makefile
>> @@ -15,6 +15,8 @@ cc32-disable-warning = $(call try-run,\
>>  	$(COMPATCC) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
>>  cc32-ldoption = $(call try-run,\
>>          $(COMPATCC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
>> +cc32-as-instr = $(call try-run,\
>> +	printf "%b\n" "$(1)" | $(COMPATCC) $(VDSO_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
> 
> It's a shame that we have to duplicate the logic from scripts/Kbuild.include
> here. Is there a way to reuse those helpers by temporarily overriding things
> like CC and KBUILD_AFLAGS? If not, no bother, but thought I'd better ask.
> 

I tried to define a rule in scripts/Kbuild.include at the beginning doing what
you are saying but I could not end up with a working solution, hence I ended up
with a dedicated one.

> Will
> 

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 2/5] arm64: vdso32: Detect binutils support for dmb ishld
@ 2019-10-01 14:23         ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-10-01 14:23 UTC (permalink / raw)
  To: Will Deacon
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, linux-kernel,
	tglx, linux-arm-kernel

On 10/1/19 2:26 PM, Will Deacon wrote:
> On Thu, Sep 26, 2019 at 10:43:39PM +0100, Vincenzo Frascino wrote:
>> As reported by Will Deacon, older versions of binutils that do not
>> support certain types of memory barriers can cause build failure of the
>> vdso32 library.
>>
>> Add a compilation time mechanism that detects if binutils supports those
>> instructions and configure the kernel accordingly.
>>
>> Cc: Will Deacon <will@kernel.org>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>> ---
>>  arch/arm64/include/asm/vdso/compat_barrier.h | 2 +-
>>  arch/arm64/kernel/vdso32/Makefile            | 9 +++++++++
>>  2 files changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/include/asm/vdso/compat_barrier.h b/arch/arm64/include/asm/vdso/compat_barrier.h
>> index fb60a88b5ed4..3fd8fd6d8fc2 100644
>> --- a/arch/arm64/include/asm/vdso/compat_barrier.h
>> +++ b/arch/arm64/include/asm/vdso/compat_barrier.h
>> @@ -20,7 +20,7 @@
>>  
>>  #define dmb(option) __asm__ __volatile__ ("dmb " #option : : : "memory")
>>  
>> -#if __LINUX_ARM_ARCH__ >= 8
>> +#if __LINUX_ARM_ARCH__ >= 8 && defined(CONFIG_AS_DMB_ISHLD)
>>  #define aarch32_smp_mb()	dmb(ish)
>>  #define aarch32_smp_rmb()	dmb(ishld)
>>  #define aarch32_smp_wmb()	dmb(ishst)
>> diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile
>> index 19e0d3115ffe..77aa61340374 100644
>> --- a/arch/arm64/kernel/vdso32/Makefile
>> +++ b/arch/arm64/kernel/vdso32/Makefile
>> @@ -15,6 +15,8 @@ cc32-disable-warning = $(call try-run,\
>>  	$(COMPATCC) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
>>  cc32-ldoption = $(call try-run,\
>>          $(COMPATCC) $(1) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
>> +cc32-as-instr = $(call try-run,\
>> +	printf "%b\n" "$(1)" | $(COMPATCC) $(VDSO_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3))
> 
> It's a shame that we have to duplicate the logic from scripts/Kbuild.include
> here. Is there a way to reuse those helpers by temporarily overriding things
> like CC and KBUILD_AFLAGS? If not, no bother, but thought I'd better ask.
> 

I tried to define a rule in scripts/Kbuild.include at the beginning doing what
you are saying but I could not end up with a working solution, hence I ended up
with a dedicated one.

> Will
> 

-- 
Regards,
Vincenzo

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-10-01 14:20             ` Will Deacon
@ 2019-10-01 14:37               ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-10-01 14:37 UTC (permalink / raw)
  To: Will Deacon
  Cc: Catalin Marinas, linux-arm-kernel, linux-kernel, ard.biesheuvel,
	ndesaulniers, tglx



On 10/1/19 3:20 PM, Will Deacon wrote:
> On Tue, Oct 01, 2019 at 03:20:35PM +0100, Vincenzo Frascino wrote:
>> On 10/1/19 2:27 PM, Catalin Marinas wrote:
>>> On Tue, Oct 01, 2019 at 02:14:23PM +0100, Will Deacon wrote:
>>>> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
>>>>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>>>>> index 37c610963eee..0e5beb928af5 100644
>>>>> --- a/arch/arm64/Kconfig
>>>>> +++ b/arch/arm64/Kconfig
>>>>> @@ -110,7 +110,7 @@ config ARM64
>>>>>  	select GENERIC_STRNLEN_USER
>>>>>  	select GENERIC_TIME_VSYSCALL
>>>>>  	select GENERIC_GETTIMEOFDAY
>>>>> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
>>>>> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_ARM_GCC)
>>>>>  	select HANDLE_DOMAIN_IRQ
>>>>>  	select HARDIRQS_SW_RESEND
>>>>>  	select HAVE_PCI
>>>>> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>>>>>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>>>>>  	default 0xffffffffffffffff
>>>>>  
>>>>> +config COMPATCC_IS_ARM_GCC
>>>>> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
>>>>
>>>> I've seen toolchains where the first part of the tuple is "armv7-", so they
>>>> won't get detected here. However, do we really need to detect this? If
>>>> somebody passes a duff compiler, then the build will fail in the same way as
>>>> if they passed it to CROSS_COMPILE=.
>>>
>>> Not sure what happens if we pass an aarch64 compiler. Can we end up with
>>> a 64-bit compat vDSO?
>>>
>>
>> I agree with Catalin here. The problem is not only when you pass and aarch64
>> toolchain but even an x86 and so on.
> 
> I disagree. What happens if you do:
> 
> $ make ARCH=arm64 CROSS_COMPILE=x86_64-linux-gnu-
> 
> on your x86 box?
>

The kernel compilation breaks as follows:

x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-mlittle-endian’;
did you mean ‘-fconvert=little-endian’?
/data1/Projects/LinuxKernel/linux/scripts/Makefile.build:265: recipe for target
'scripts/mod/empty.o' failed
make[2]: *** [scripts/mod/empty.o] Error 1
/data1/Projects/LinuxKernel/linux/Makefile:1128: recipe for target 'prepare0' failed
make[1]: *** [prepare0] Error 2
make[1]: Leaving directory '/data1/Projects/LinuxKernel/linux-out'
Makefile:179: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2

Similar issue in the compat vdso library compilation if I do (without the check):

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
CROSS_COMPILE_COMPAT=x86_64-linux-gnu-

With this check the compilation completes correctly but the compat vdso does not
get built (unless my environment is playing me tricks ;) ).

>> If the problem is related to armv7- we can change the rule as "arm.*-gcc" which
>> should detect them as well. Do you know what is the triple that an armv7-
>> toolchain prints?
> 
> 'fraid not, since I don't have one to hand. I think you'd end up matching
> arm*-gcc, which is pretty broad.
> 

If we all agree I can extend this rule then.

> Will
> 

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-10-01 14:37               ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-10-01 14:37 UTC (permalink / raw)
  To: Will Deacon
  Cc: ard.biesheuvel, Catalin Marinas, ndesaulniers, linux-kernel,
	tglx, linux-arm-kernel



On 10/1/19 3:20 PM, Will Deacon wrote:
> On Tue, Oct 01, 2019 at 03:20:35PM +0100, Vincenzo Frascino wrote:
>> On 10/1/19 2:27 PM, Catalin Marinas wrote:
>>> On Tue, Oct 01, 2019 at 02:14:23PM +0100, Will Deacon wrote:
>>>> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
>>>>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>>>>> index 37c610963eee..0e5beb928af5 100644
>>>>> --- a/arch/arm64/Kconfig
>>>>> +++ b/arch/arm64/Kconfig
>>>>> @@ -110,7 +110,7 @@ config ARM64
>>>>>  	select GENERIC_STRNLEN_USER
>>>>>  	select GENERIC_TIME_VSYSCALL
>>>>>  	select GENERIC_GETTIMEOFDAY
>>>>> -	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT)
>>>>> +	select GENERIC_COMPAT_VDSO if (!CPU_BIG_ENDIAN && COMPAT && COMPATCC_IS_ARM_GCC)
>>>>>  	select HANDLE_DOMAIN_IRQ
>>>>>  	select HARDIRQS_SW_RESEND
>>>>>  	select HAVE_PCI
>>>>> @@ -313,6 +313,9 @@ config KASAN_SHADOW_OFFSET
>>>>>  	default 0xeffffff900000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS
>>>>>  	default 0xffffffffffffffff
>>>>>  
>>>>> +config COMPATCC_IS_ARM_GCC
>>>>> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
>>>>
>>>> I've seen toolchains where the first part of the tuple is "armv7-", so they
>>>> won't get detected here. However, do we really need to detect this? If
>>>> somebody passes a duff compiler, then the build will fail in the same way as
>>>> if they passed it to CROSS_COMPILE=.
>>>
>>> Not sure what happens if we pass an aarch64 compiler. Can we end up with
>>> a 64-bit compat vDSO?
>>>
>>
>> I agree with Catalin here. The problem is not only when you pass and aarch64
>> toolchain but even an x86 and so on.
> 
> I disagree. What happens if you do:
> 
> $ make ARCH=arm64 CROSS_COMPILE=x86_64-linux-gnu-
> 
> on your x86 box?
>

The kernel compilation breaks as follows:

x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-mlittle-endian’;
did you mean ‘-fconvert=little-endian’?
/data1/Projects/LinuxKernel/linux/scripts/Makefile.build:265: recipe for target
'scripts/mod/empty.o' failed
make[2]: *** [scripts/mod/empty.o] Error 1
/data1/Projects/LinuxKernel/linux/Makefile:1128: recipe for target 'prepare0' failed
make[1]: *** [prepare0] Error 2
make[1]: Leaving directory '/data1/Projects/LinuxKernel/linux-out'
Makefile:179: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2

Similar issue in the compat vdso library compilation if I do (without the check):

$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
CROSS_COMPILE_COMPAT=x86_64-linux-gnu-

With this check the compilation completes correctly but the compat vdso does not
get built (unless my environment is playing me tricks ;) ).

>> If the problem is related to armv7- we can change the rule as "arm.*-gcc" which
>> should detect them as well. Do you know what is the triple that an armv7-
>> toolchain prints?
> 
> 'fraid not, since I don't have one to hand. I think you'd end up matching
> arm*-gcc, which is pretty broad.
> 

If we all agree I can extend this rule then.

> Will
> 

-- 
Regards,
Vincenzo

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 3/5] arm64: vdso32: Fix compilation warning
  2019-10-01 13:21       ` Will Deacon
@ 2019-10-01 14:41         ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-10-01 14:41 UTC (permalink / raw)
  To: Will Deacon
  Cc: linux-arm-kernel, linux-kernel, ard.biesheuvel, ndesaulniers,
	catalin.marinas, tglx

On 10/1/19 2:21 PM, Will Deacon wrote:
> On Thu, Sep 26, 2019 at 10:43:40PM +0100, Vincenzo Frascino wrote:
>> As reported by Will Deacon the following compilation warning appears
>> during the compilation of the vdso32:
>>
>> In file included from ./arch/arm64/include/asm/thread_info.h:17:0,
>>                  from ./include/linux/thread_info.h:38,
>>                  from ./arch/arm64/include/asm/preempt.h:5,
>>                  from ./include/linux/preempt.h:78,
>>                  from ./include/linux/spinlock.h:51,
>>                  from ./include/linux/seqlock.h:36,
>>                  from ./include/linux/time.h:6,
>>                  from .../work/linux/lib/vdso/gettimeofday.c:7,
>>                  from <command-line>:0:
>> ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
>> ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
>> integer of different size [-Wpointer-to-int-cast]
>>   u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>>                ^
>> In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0,
>>                  from ./arch/arm64/include/asm/processor.h:34,
>>                  from ./arch/arm64/include/asm/elf.h:118,
>>                  from ./include/linux/elf.h:5,
>>                  from ./include/linux/elfnote.h:62,
>>                  from arch/arm64/kernel/vdso32/note.c:11:
>> ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
>> ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
>> integer of different size [-Wpointer-to-int-cast]
>>   u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>>                ^
>>
>> This happens because few 64 bit compilation headers are included during
>> the generation of vdso32.
>>
>> Fix the issue redefining the __tag_set function.
>>
>> Note: This fix is meant to be temporary, a more comprehensive solution
>> based on the refactoring of the generic headers will be provided with a
>> future patch set. At that point it will be possible to revert this patch.
>>
>> Cc: Will Deacon <will@kernel.org>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>> ---
>>  arch/arm64/include/asm/memory.h | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
>> index b61b50bf68b1..c61b2eb50a3b 100644
>> --- a/arch/arm64/include/asm/memory.h
>> +++ b/arch/arm64/include/asm/memory.h
>> @@ -228,11 +228,14 @@ static inline unsigned long kaslr_offset(void)
>>  #define __tag_get(addr)		0
>>  #endif /* CONFIG_KASAN_SW_TAGS */
>>  
>> +#ifdef __aarch64__
>> +/* Do not attempt to compile this code with compat vdso */
>>  static inline const void *__tag_set(const void *addr, u8 tag)
>>  {
>>  	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>>  	return (const void *)(__addr | __tag_shifted(tag));
>>  }
>> +#endif
> 
> Sorry, but I'm not taking this.
> 
> I know you're trying to fix the issues I reported as quickly as you can (and
> thank you for that), but I'm sure that you agree this needs more thought to
> develop a proper solution to what is a much bigger issue than can be solved
> by sprinkling #ifdefs. I can live with the warning on the basis that a
> proper fix is in the pipeline, but in the meantime it can serve as a
> reminder that we're not done here.
>

This was my original preference as well, if we silence the warnings we tend to
forget about them. Since you reported the issue as urgent, I reacted with
something that fixes it temporarily, but I have not objections if you want to
wait for a more comprehensive solution.

> Will
> 

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 3/5] arm64: vdso32: Fix compilation warning
@ 2019-10-01 14:41         ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-10-01 14:41 UTC (permalink / raw)
  To: Will Deacon
  Cc: ard.biesheuvel, catalin.marinas, ndesaulniers, linux-kernel,
	tglx, linux-arm-kernel

On 10/1/19 2:21 PM, Will Deacon wrote:
> On Thu, Sep 26, 2019 at 10:43:40PM +0100, Vincenzo Frascino wrote:
>> As reported by Will Deacon the following compilation warning appears
>> during the compilation of the vdso32:
>>
>> In file included from ./arch/arm64/include/asm/thread_info.h:17:0,
>>                  from ./include/linux/thread_info.h:38,
>>                  from ./arch/arm64/include/asm/preempt.h:5,
>>                  from ./include/linux/preempt.h:78,
>>                  from ./include/linux/spinlock.h:51,
>>                  from ./include/linux/seqlock.h:36,
>>                  from ./include/linux/time.h:6,
>>                  from .../work/linux/lib/vdso/gettimeofday.c:7,
>>                  from <command-line>:0:
>> ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
>> ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
>> integer of different size [-Wpointer-to-int-cast]
>>   u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>>                ^
>> In file included from ./arch/arm64/include/asm/pgtable-hwdef.h:8:0,
>>                  from ./arch/arm64/include/asm/processor.h:34,
>>                  from ./arch/arm64/include/asm/elf.h:118,
>>                  from ./include/linux/elf.h:5,
>>                  from ./include/linux/elfnote.h:62,
>>                  from arch/arm64/kernel/vdso32/note.c:11:
>> ./arch/arm64/include/asm/memory.h: In function ‘__tag_set’:
>> ./arch/arm64/include/asm/memory.h:233:15: warning: cast from pointer to
>> integer of different size [-Wpointer-to-int-cast]
>>   u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>>                ^
>>
>> This happens because few 64 bit compilation headers are included during
>> the generation of vdso32.
>>
>> Fix the issue redefining the __tag_set function.
>>
>> Note: This fix is meant to be temporary, a more comprehensive solution
>> based on the refactoring of the generic headers will be provided with a
>> future patch set. At that point it will be possible to revert this patch.
>>
>> Cc: Will Deacon <will@kernel.org>
>> Cc: Catalin Marinas <catalin.marinas@arm.com>
>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>> ---
>>  arch/arm64/include/asm/memory.h | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
>> index b61b50bf68b1..c61b2eb50a3b 100644
>> --- a/arch/arm64/include/asm/memory.h
>> +++ b/arch/arm64/include/asm/memory.h
>> @@ -228,11 +228,14 @@ static inline unsigned long kaslr_offset(void)
>>  #define __tag_get(addr)		0
>>  #endif /* CONFIG_KASAN_SW_TAGS */
>>  
>> +#ifdef __aarch64__
>> +/* Do not attempt to compile this code with compat vdso */
>>  static inline const void *__tag_set(const void *addr, u8 tag)
>>  {
>>  	u64 __addr = (u64)addr & ~__tag_shifted(0xff);
>>  	return (const void *)(__addr | __tag_shifted(tag));
>>  }
>> +#endif
> 
> Sorry, but I'm not taking this.
> 
> I know you're trying to fix the issues I reported as quickly as you can (and
> thank you for that), but I'm sure that you agree this needs more thought to
> develop a proper solution to what is a much bigger issue than can be solved
> by sprinkling #ifdefs. I can live with the warning on the basis that a
> proper fix is in the pipeline, but in the meantime it can serve as a
> reminder that we're not done here.
>

This was my original preference as well, if we silence the warnings we tend to
forget about them. Since you reported the issue as urgent, I reacted with
something that fixes it temporarily, but I have not objections if you want to
wait for a more comprehensive solution.

> Will
> 

-- 
Regards,
Vincenzo

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-10-01 14:37               ` Vincenzo Frascino
@ 2019-10-01 14:43                 ` Will Deacon
  -1 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 14:43 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: Catalin Marinas, linux-arm-kernel, linux-kernel, ard.biesheuvel,
	ndesaulniers, tglx

On Tue, Oct 01, 2019 at 03:37:49PM +0100, Vincenzo Frascino wrote:
> On 10/1/19 3:20 PM, Will Deacon wrote:
> > On Tue, Oct 01, 2019 at 03:20:35PM +0100, Vincenzo Frascino wrote:
> >> On 10/1/19 2:27 PM, Catalin Marinas wrote:
> >>> On Tue, Oct 01, 2019 at 02:14:23PM +0100, Will Deacon wrote:
> >>>> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
> >>>>> +config COMPATCC_IS_ARM_GCC
> >>>>> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
> >>>>
> >>>> I've seen toolchains where the first part of the tuple is "armv7-", so they
> >>>> won't get detected here. However, do we really need to detect this? If
> >>>> somebody passes a duff compiler, then the build will fail in the same way as
> >>>> if they passed it to CROSS_COMPILE=.
> >>>
> >>> Not sure what happens if we pass an aarch64 compiler. Can we end up with
> >>> a 64-bit compat vDSO?
> >>>
> >>
> >> I agree with Catalin here. The problem is not only when you pass and aarch64
> >> toolchain but even an x86 and so on.
> > 
> > I disagree. What happens if you do:
> > 
> > $ make ARCH=arm64 CROSS_COMPILE=x86_64-linux-gnu-
> > 
> > on your x86 box?
> >
> 
> The kernel compilation breaks as follows:
> 
> x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-mlittle-endian’;
> did you mean ‘-fconvert=little-endian’?
> /data1/Projects/LinuxKernel/linux/scripts/Makefile.build:265: recipe for target
> 'scripts/mod/empty.o' failed
> make[2]: *** [scripts/mod/empty.o] Error 1
> /data1/Projects/LinuxKernel/linux/Makefile:1128: recipe for target 'prepare0' failed
> make[1]: *** [prepare0] Error 2
> make[1]: Leaving directory '/data1/Projects/LinuxKernel/linux-out'
> Makefile:179: recipe for target 'sub-make' failed
> make: *** [sub-make] Error 2
> 
> Similar issue in the compat vdso library compilation if I do (without the check):
> 
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
> CROSS_COMPILE_COMPAT=x86_64-linux-gnu-
> 
> With this check the compilation completes correctly but the compat vdso does not
> get built (unless my environment is playing me tricks ;) ).

My point was that we don't attempt to sanitise the compiler passed via
CROSS_COMPILE, so I don't think we should do anything special for COMPATCC
either.

Will

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-10-01 14:43                 ` Will Deacon
  0 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 14:43 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: ard.biesheuvel, Catalin Marinas, ndesaulniers, linux-kernel,
	tglx, linux-arm-kernel

On Tue, Oct 01, 2019 at 03:37:49PM +0100, Vincenzo Frascino wrote:
> On 10/1/19 3:20 PM, Will Deacon wrote:
> > On Tue, Oct 01, 2019 at 03:20:35PM +0100, Vincenzo Frascino wrote:
> >> On 10/1/19 2:27 PM, Catalin Marinas wrote:
> >>> On Tue, Oct 01, 2019 at 02:14:23PM +0100, Will Deacon wrote:
> >>>> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
> >>>>> +config COMPATCC_IS_ARM_GCC
> >>>>> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
> >>>>
> >>>> I've seen toolchains where the first part of the tuple is "armv7-", so they
> >>>> won't get detected here. However, do we really need to detect this? If
> >>>> somebody passes a duff compiler, then the build will fail in the same way as
> >>>> if they passed it to CROSS_COMPILE=.
> >>>
> >>> Not sure what happens if we pass an aarch64 compiler. Can we end up with
> >>> a 64-bit compat vDSO?
> >>>
> >>
> >> I agree with Catalin here. The problem is not only when you pass and aarch64
> >> toolchain but even an x86 and so on.
> > 
> > I disagree. What happens if you do:
> > 
> > $ make ARCH=arm64 CROSS_COMPILE=x86_64-linux-gnu-
> > 
> > on your x86 box?
> >
> 
> The kernel compilation breaks as follows:
> 
> x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-mlittle-endian’;
> did you mean ‘-fconvert=little-endian’?
> /data1/Projects/LinuxKernel/linux/scripts/Makefile.build:265: recipe for target
> 'scripts/mod/empty.o' failed
> make[2]: *** [scripts/mod/empty.o] Error 1
> /data1/Projects/LinuxKernel/linux/Makefile:1128: recipe for target 'prepare0' failed
> make[1]: *** [prepare0] Error 2
> make[1]: Leaving directory '/data1/Projects/LinuxKernel/linux-out'
> Makefile:179: recipe for target 'sub-make' failed
> make: *** [sub-make] Error 2
> 
> Similar issue in the compat vdso library compilation if I do (without the check):
> 
> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
> CROSS_COMPILE_COMPAT=x86_64-linux-gnu-
> 
> With this check the compilation completes correctly but the compat vdso does not
> get built (unless my environment is playing me tricks ;) ).

My point was that we don't attempt to sanitise the compiler passed via
CROSS_COMPILE, so I don't think we should do anything special for COMPATCC
either.

Will

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-10-01 14:43                 ` Will Deacon
@ 2019-10-01 14:59                   ` Vincenzo Frascino
  -1 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-10-01 14:59 UTC (permalink / raw)
  To: Will Deacon
  Cc: Catalin Marinas, linux-arm-kernel, linux-kernel, ard.biesheuvel,
	ndesaulniers, tglx

On 10/1/19 3:43 PM, Will Deacon wrote:
> On Tue, Oct 01, 2019 at 03:37:49PM +0100, Vincenzo Frascino wrote:
>> On 10/1/19 3:20 PM, Will Deacon wrote:
>>> On Tue, Oct 01, 2019 at 03:20:35PM +0100, Vincenzo Frascino wrote:
>>>> On 10/1/19 2:27 PM, Catalin Marinas wrote:
>>>>> On Tue, Oct 01, 2019 at 02:14:23PM +0100, Will Deacon wrote:
>>>>>> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
>>>>>>> +config COMPATCC_IS_ARM_GCC
>>>>>>> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
>>>>>>
>>>>>> I've seen toolchains where the first part of the tuple is "armv7-", so they
>>>>>> won't get detected here. However, do we really need to detect this? If
>>>>>> somebody passes a duff compiler, then the build will fail in the same way as
>>>>>> if they passed it to CROSS_COMPILE=.
>>>>>
>>>>> Not sure what happens if we pass an aarch64 compiler. Can we end up with
>>>>> a 64-bit compat vDSO?
>>>>>
>>>>
>>>> I agree with Catalin here. The problem is not only when you pass and aarch64
>>>> toolchain but even an x86 and so on.
>>>
>>> I disagree. What happens if you do:
>>>
>>> $ make ARCH=arm64 CROSS_COMPILE=x86_64-linux-gnu-
>>>
>>> on your x86 box?
>>>
>>
>> The kernel compilation breaks as follows:
>>
>> x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-mlittle-endian’;
>> did you mean ‘-fconvert=little-endian’?
>> /data1/Projects/LinuxKernel/linux/scripts/Makefile.build:265: recipe for target
>> 'scripts/mod/empty.o' failed
>> make[2]: *** [scripts/mod/empty.o] Error 1
>> /data1/Projects/LinuxKernel/linux/Makefile:1128: recipe for target 'prepare0' failed
>> make[1]: *** [prepare0] Error 2
>> make[1]: Leaving directory '/data1/Projects/LinuxKernel/linux-out'
>> Makefile:179: recipe for target 'sub-make' failed
>> make: *** [sub-make] Error 2
>>
>> Similar issue in the compat vdso library compilation if I do (without the check):
>>
>> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
>> CROSS_COMPILE_COMPAT=x86_64-linux-gnu-
>>
>> With this check the compilation completes correctly but the compat vdso does not
>> get built (unless my environment is playing me tricks ;) ).
> 
> My point was that we don't attempt to sanitise the compiler passed via
> CROSS_COMPILE, so I don't think we should do anything special for COMPATCC
> either.
>

I agree on this, but the point I was trying to make is that the kernel should
still be able to build even if the compiler for compat vdso is not correct.

I do not have a strong opinion though.

> Will
> 

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-10-01 14:59                   ` Vincenzo Frascino
  0 siblings, 0 replies; 127+ messages in thread
From: Vincenzo Frascino @ 2019-10-01 14:59 UTC (permalink / raw)
  To: Will Deacon
  Cc: ard.biesheuvel, Catalin Marinas, ndesaulniers, linux-kernel,
	tglx, linux-arm-kernel

On 10/1/19 3:43 PM, Will Deacon wrote:
> On Tue, Oct 01, 2019 at 03:37:49PM +0100, Vincenzo Frascino wrote:
>> On 10/1/19 3:20 PM, Will Deacon wrote:
>>> On Tue, Oct 01, 2019 at 03:20:35PM +0100, Vincenzo Frascino wrote:
>>>> On 10/1/19 2:27 PM, Catalin Marinas wrote:
>>>>> On Tue, Oct 01, 2019 at 02:14:23PM +0100, Will Deacon wrote:
>>>>>> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
>>>>>>> +config COMPATCC_IS_ARM_GCC
>>>>>>> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
>>>>>>
>>>>>> I've seen toolchains where the first part of the tuple is "armv7-", so they
>>>>>> won't get detected here. However, do we really need to detect this? If
>>>>>> somebody passes a duff compiler, then the build will fail in the same way as
>>>>>> if they passed it to CROSS_COMPILE=.
>>>>>
>>>>> Not sure what happens if we pass an aarch64 compiler. Can we end up with
>>>>> a 64-bit compat vDSO?
>>>>>
>>>>
>>>> I agree with Catalin here. The problem is not only when you pass and aarch64
>>>> toolchain but even an x86 and so on.
>>>
>>> I disagree. What happens if you do:
>>>
>>> $ make ARCH=arm64 CROSS_COMPILE=x86_64-linux-gnu-
>>>
>>> on your x86 box?
>>>
>>
>> The kernel compilation breaks as follows:
>>
>> x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-mlittle-endian’;
>> did you mean ‘-fconvert=little-endian’?
>> /data1/Projects/LinuxKernel/linux/scripts/Makefile.build:265: recipe for target
>> 'scripts/mod/empty.o' failed
>> make[2]: *** [scripts/mod/empty.o] Error 1
>> /data1/Projects/LinuxKernel/linux/Makefile:1128: recipe for target 'prepare0' failed
>> make[1]: *** [prepare0] Error 2
>> make[1]: Leaving directory '/data1/Projects/LinuxKernel/linux-out'
>> Makefile:179: recipe for target 'sub-make' failed
>> make: *** [sub-make] Error 2
>>
>> Similar issue in the compat vdso library compilation if I do (without the check):
>>
>> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
>> CROSS_COMPILE_COMPAT=x86_64-linux-gnu-
>>
>> With this check the compilation completes correctly but the compat vdso does not
>> get built (unless my environment is playing me tricks ;) ).
> 
> My point was that we don't attempt to sanitise the compiler passed via
> CROSS_COMPILE, so I don't think we should do anything special for COMPATCC
> either.
>

I agree on this, but the point I was trying to make is that the kernel should
still be able to build even if the compiler for compat vdso is not correct.

I do not have a strong opinion though.

> Will
> 

-- 
Regards,
Vincenzo

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-10-01 14:43                 ` Will Deacon
@ 2019-10-01 15:30                   ` Catalin Marinas
  -1 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-10-01 15:30 UTC (permalink / raw)
  To: Will Deacon
  Cc: Vincenzo Frascino, linux-arm-kernel, linux-kernel,
	ard.biesheuvel, ndesaulniers, tglx

On Tue, Oct 01, 2019 at 03:43:54PM +0100, Will Deacon wrote:
> > >>>> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
> > >>>>> +config COMPATCC_IS_ARM_GCC
> > >>>>> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
[...]
> My point was that we don't attempt to sanitise the compiler passed via
> CROSS_COMPILE, so I don't think we should do anything special for COMPATCC
> either.

What I really want from kbuild with this patch is:

1. Not to warn me that I don't have a CROSS_COMPILE_COMPAT set

2. Not to give me a compilation error if the makefile made up a COMPATCC
   that doesn't work

Since we dropped the Kconfig option for the compat gcc prefix (which I
didn't like anyway), COMPATCC is now initialised to
(CROSS_COMPILE_COMPAT)gcc. This means that it is valid compiler (and
it's an aarch64 compiler on my machine). The COMPATCC_IS_ARM_GCC
silently disables the compat vDSO for this case rather than giving me a
build error if we don't have such checks.

In the long run, I wouldn't mandate CROSS_COMPILE_COMPAT to always be
set for the compat vDSO since with clang we could use the same compiler
binary for both native and compat (with different flags). That's once we
cleaned up the headers.

So, I think the best option for the time being is to check that the
compat compiler is an "arm*-gcc", otherwise disable the compat vDSO.

-- 
Catalin

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-10-01 15:30                   ` Catalin Marinas
  0 siblings, 0 replies; 127+ messages in thread
From: Catalin Marinas @ 2019-10-01 15:30 UTC (permalink / raw)
  To: Will Deacon
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx,
	Vincenzo Frascino, linux-arm-kernel

On Tue, Oct 01, 2019 at 03:43:54PM +0100, Will Deacon wrote:
> > >>>> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
> > >>>>> +config COMPATCC_IS_ARM_GCC
> > >>>>> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
[...]
> My point was that we don't attempt to sanitise the compiler passed via
> CROSS_COMPILE, so I don't think we should do anything special for COMPATCC
> either.

What I really want from kbuild with this patch is:

1. Not to warn me that I don't have a CROSS_COMPILE_COMPAT set

2. Not to give me a compilation error if the makefile made up a COMPATCC
   that doesn't work

Since we dropped the Kconfig option for the compat gcc prefix (which I
didn't like anyway), COMPATCC is now initialised to
(CROSS_COMPILE_COMPAT)gcc. This means that it is valid compiler (and
it's an aarch64 compiler on my machine). The COMPATCC_IS_ARM_GCC
silently disables the compat vDSO for this case rather than giving me a
build error if we don't have such checks.

In the long run, I wouldn't mandate CROSS_COMPILE_COMPAT to always be
set for the compat vDSO since with clang we could use the same compiler
binary for both native and compat (with different flags). That's once we
cleaned up the headers.

So, I think the best option for the time being is to check that the
compat compiler is an "arm*-gcc", otherwise disable the compat vDSO.

-- 
Catalin

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-10-01 15:30                   ` Catalin Marinas
@ 2019-10-01 16:46                     ` Will Deacon
  -1 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 16:46 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Vincenzo Frascino, linux-arm-kernel, linux-kernel,
	ard.biesheuvel, ndesaulniers, tglx

On Tue, Oct 01, 2019 at 04:30:56PM +0100, Catalin Marinas wrote:
> On Tue, Oct 01, 2019 at 03:43:54PM +0100, Will Deacon wrote:
> > > >>>> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
> > > >>>>> +config COMPATCC_IS_ARM_GCC
> > > >>>>> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
> [...]
> > My point was that we don't attempt to sanitise the compiler passed via
> > CROSS_COMPILE, so I don't think we should do anything special for COMPATCC
> > either.
> 
> What I really want from kbuild with this patch is:
> 
> 1. Not to warn me that I don't have a CROSS_COMPILE_COMPAT set
> 
> 2. Not to give me a compilation error if the makefile made up a COMPATCC
>    that doesn't work
> 
> Since we dropped the Kconfig option for the compat gcc prefix (which I
> didn't like anyway), COMPATCC is now initialised to
> (CROSS_COMPILE_COMPAT)gcc. This means that it is valid compiler (and
> it's an aarch64 compiler on my machine). The COMPATCC_IS_ARM_GCC
> silently disables the compat vDSO for this case rather than giving me a
> build error if we don't have such checks.
> 
> In the long run, I wouldn't mandate CROSS_COMPILE_COMPAT to always be
> set for the compat vDSO since with clang we could use the same compiler
> binary for both native and compat (with different flags). That's once we
> cleaned up the headers.

But we'll still need it even with clang so that the relevant triple can be
passed to the --target option. The top-level Makefile already does this:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile#n544

so I think we should do the same thing for the compat vdso as well, which
would allow us to remove this complexity by requiring that
CROSS_COMPILE_COMPAT identifies the cross-compiler to use in exactly the
same way as CROSS_COMPILE does.

Am I missing something here?

Will

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-10-01 16:46                     ` Will Deacon
  0 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 16:46 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: ard.biesheuvel, ndesaulniers, linux-kernel, tglx,
	Vincenzo Frascino, linux-arm-kernel

On Tue, Oct 01, 2019 at 04:30:56PM +0100, Catalin Marinas wrote:
> On Tue, Oct 01, 2019 at 03:43:54PM +0100, Will Deacon wrote:
> > > >>>> On Thu, Sep 26, 2019 at 10:43:38PM +0100, Vincenzo Frascino wrote:
> > > >>>>> +config COMPATCC_IS_ARM_GCC
> > > >>>>> +	def_bool $(success,$(COMPATCC) --version | head -n 1 | grep -q "arm-.*-gcc")
> [...]
> > My point was that we don't attempt to sanitise the compiler passed via
> > CROSS_COMPILE, so I don't think we should do anything special for COMPATCC
> > either.
> 
> What I really want from kbuild with this patch is:
> 
> 1. Not to warn me that I don't have a CROSS_COMPILE_COMPAT set
> 
> 2. Not to give me a compilation error if the makefile made up a COMPATCC
>    that doesn't work
> 
> Since we dropped the Kconfig option for the compat gcc prefix (which I
> didn't like anyway), COMPATCC is now initialised to
> (CROSS_COMPILE_COMPAT)gcc. This means that it is valid compiler (and
> it's an aarch64 compiler on my machine). The COMPATCC_IS_ARM_GCC
> silently disables the compat vDSO for this case rather than giving me a
> build error if we don't have such checks.
> 
> In the long run, I wouldn't mandate CROSS_COMPILE_COMPAT to always be
> set for the compat vDSO since with clang we could use the same compiler
> binary for both native and compat (with different flags). That's once we
> cleaned up the headers.

But we'll still need it even with clang so that the relevant triple can be
passed to the --target option. The top-level Makefile already does this:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile#n544

so I think we should do the same thing for the compat vdso as well, which
would allow us to remove this complexity by requiring that
CROSS_COMPILE_COMPAT identifies the cross-compiler to use in exactly the
same way as CROSS_COMPILE does.

Am I missing something here?

Will

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-10-01 16:46                     ` Will Deacon
@ 2019-10-01 16:59                       ` Nick Desaulniers
  -1 siblings, 0 replies; 127+ messages in thread
From: Nick Desaulniers @ 2019-10-01 16:59 UTC (permalink / raw)
  To: Will Deacon
  Cc: Catalin Marinas, Vincenzo Frascino, Linux ARM, LKML,
	Ard Biesheuvel, Thomas Gleixner

On Tue, Oct 1, 2019 at 9:47 AM Will Deacon <will@kernel.org> wrote:
>
> On Tue, Oct 01, 2019 at 04:30:56PM +0100, Catalin Marinas wrote:
> > In the long run, I wouldn't mandate CROSS_COMPILE_COMPAT to always be
> > set for the compat vDSO since with clang we could use the same compiler
> > binary for both native and compat (with different flags). That's once we
> > cleaned up the headers.
>
> But we'll still need it even with clang so that the relevant triple can be
> passed to the --target option. The top-level Makefile already does this:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile#n544

That's not pulling the cross compiler out of a *config* (as this patch
is proposing); rather from an env var.

>
> so I think we should do the same thing for the compat vdso as well, which
> would allow us to remove this complexity by requiring that
> CROSS_COMPILE_COMPAT identifies the cross-compiler to use in exactly the
> same way as CROSS_COMPILE does.
>
> Am I missing something here?

I think the second paragraph you wrote shows we're all in agreement,
but I suspect you may be conflating *how* the toplevel Makefile knows
we're doing a cross compile.  It doesn't read a config, this patch
would make it so a cross compiler is specified via config, Catalin
asked "please no," I agree with Catalin (and I suspect you do too).
-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-10-01 16:59                       ` Nick Desaulniers
  0 siblings, 0 replies; 127+ messages in thread
From: Nick Desaulniers @ 2019-10-01 16:59 UTC (permalink / raw)
  To: Will Deacon
  Cc: Ard Biesheuvel, Catalin Marinas, LKML, Thomas Gleixner,
	Vincenzo Frascino, Linux ARM

On Tue, Oct 1, 2019 at 9:47 AM Will Deacon <will@kernel.org> wrote:
>
> On Tue, Oct 01, 2019 at 04:30:56PM +0100, Catalin Marinas wrote:
> > In the long run, I wouldn't mandate CROSS_COMPILE_COMPAT to always be
> > set for the compat vDSO since with clang we could use the same compiler
> > binary for both native and compat (with different flags). That's once we
> > cleaned up the headers.
>
> But we'll still need it even with clang so that the relevant triple can be
> passed to the --target option. The top-level Makefile already does this:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile#n544

That's not pulling the cross compiler out of a *config* (as this patch
is proposing); rather from an env var.

>
> so I think we should do the same thing for the compat vdso as well, which
> would allow us to remove this complexity by requiring that
> CROSS_COMPILE_COMPAT identifies the cross-compiler to use in exactly the
> same way as CROSS_COMPILE does.
>
> Am I missing something here?

I think the second paragraph you wrote shows we're all in agreement,
but I suspect you may be conflating *how* the toplevel Makefile knows
we're doing a cross compile.  It doesn't read a config, this patch
would make it so a cross compiler is specified via config, Catalin
asked "please no," I agree with Catalin (and I suspect you do too).
-- 
Thanks,
~Nick Desaulniers

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-10-01 16:59                       ` Nick Desaulniers
@ 2019-10-01 17:07                         ` Will Deacon
  -1 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 17:07 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Catalin Marinas, Vincenzo Frascino, Linux ARM, LKML,
	Ard Biesheuvel, Thomas Gleixner

On Tue, Oct 01, 2019 at 09:59:43AM -0700, Nick Desaulniers wrote:
> On Tue, Oct 1, 2019 at 9:47 AM Will Deacon <will@kernel.org> wrote:
> >
> > On Tue, Oct 01, 2019 at 04:30:56PM +0100, Catalin Marinas wrote:
> > > In the long run, I wouldn't mandate CROSS_COMPILE_COMPAT to always be
> > > set for the compat vDSO since with clang we could use the same compiler
> > > binary for both native and compat (with different flags). That's once we
> > > cleaned up the headers.
> >
> > But we'll still need it even with clang so that the relevant triple can be
> > passed to the --target option. The top-level Makefile already does this:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile#n544
> 
> That's not pulling the cross compiler out of a *config* (as this patch
> is proposing); rather from an env var.

CROSS_COMPILE_COMPAT is the environment variable, right? If not, then I have
my terminology mixed up.

> > so I think we should do the same thing for the compat vdso as well, which
> > would allow us to remove this complexity by requiring that
> > CROSS_COMPILE_COMPAT identifies the cross-compiler to use in exactly the
> > same way as CROSS_COMPILE does.
> >
> > Am I missing something here?
> 
> I think the second paragraph you wrote shows we're all in agreement,
> but I suspect you may be conflating *how* the toplevel Makefile knows
> we're doing a cross compile.  It doesn't read a config, this patch
> would make it so a cross compiler is specified via config, Catalin
> asked "please no," I agree with Catalin (and I suspect you do too).

Yes, I'm saying let's have an environment variable only and drop the
CONFIG stuff completely. I think this means that the environment variable
must always be specified if you want the compat vDSO, but I don't see that
as a problem.

Will

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-10-01 17:07                         ` Will Deacon
  0 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 17:07 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Ard Biesheuvel, Catalin Marinas, LKML, Thomas Gleixner,
	Vincenzo Frascino, Linux ARM

On Tue, Oct 01, 2019 at 09:59:43AM -0700, Nick Desaulniers wrote:
> On Tue, Oct 1, 2019 at 9:47 AM Will Deacon <will@kernel.org> wrote:
> >
> > On Tue, Oct 01, 2019 at 04:30:56PM +0100, Catalin Marinas wrote:
> > > In the long run, I wouldn't mandate CROSS_COMPILE_COMPAT to always be
> > > set for the compat vDSO since with clang we could use the same compiler
> > > binary for both native and compat (with different flags). That's once we
> > > cleaned up the headers.
> >
> > But we'll still need it even with clang so that the relevant triple can be
> > passed to the --target option. The top-level Makefile already does this:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile#n544
> 
> That's not pulling the cross compiler out of a *config* (as this patch
> is proposing); rather from an env var.

CROSS_COMPILE_COMPAT is the environment variable, right? If not, then I have
my terminology mixed up.

> > so I think we should do the same thing for the compat vdso as well, which
> > would allow us to remove this complexity by requiring that
> > CROSS_COMPILE_COMPAT identifies the cross-compiler to use in exactly the
> > same way as CROSS_COMPILE does.
> >
> > Am I missing something here?
> 
> I think the second paragraph you wrote shows we're all in agreement,
> but I suspect you may be conflating *how* the toplevel Makefile knows
> we're doing a cross compile.  It doesn't read a config, this patch
> would make it so a cross compiler is specified via config, Catalin
> asked "please no," I agree with Catalin (and I suspect you do too).

Yes, I'm saying let's have an environment variable only and drop the
CONFIG stuff completely. I think this means that the environment variable
must always be specified if you want the compat vDSO, but I don't see that
as a problem.

Will

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-10-01 17:07                         ` Will Deacon
@ 2019-10-01 17:12                           ` Nick Desaulniers
  -1 siblings, 0 replies; 127+ messages in thread
From: Nick Desaulniers @ 2019-10-01 17:12 UTC (permalink / raw)
  To: Will Deacon
  Cc: Catalin Marinas, Vincenzo Frascino, Linux ARM, LKML,
	Ard Biesheuvel, Thomas Gleixner

On Tue, Oct 1, 2019 at 10:08 AM Will Deacon <will@kernel.org> wrote:
>
> On Tue, Oct 01, 2019 at 09:59:43AM -0700, Nick Desaulniers wrote:
> > On Tue, Oct 1, 2019 at 9:47 AM Will Deacon <will@kernel.org> wrote:
> > >
> > > On Tue, Oct 01, 2019 at 04:30:56PM +0100, Catalin Marinas wrote:
> > > > In the long run, I wouldn't mandate CROSS_COMPILE_COMPAT to always be
> > > > set for the compat vDSO since with clang we could use the same compiler
> > > > binary for both native and compat (with different flags). That's once we
> > > > cleaned up the headers.
> > >
> > > But we'll still need it even with clang so that the relevant triple can be
> > > passed to the --target option. The top-level Makefile already does this:
> > >
> > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile#n544
> >
> > That's not pulling the cross compiler out of a *config* (as this patch
> > is proposing); rather from an env var.
>
> CROSS_COMPILE_COMPAT is the environment variable, right? If not, then I have
> my terminology mixed up.

Ah, sorry, I'm the one misreading the patch.  I thought the commit
message was showing what the new process would be. I see now that it's
describing the issue pre-patch.  My mistake.

>
> > > so I think we should do the same thing for the compat vdso as well, which
> > > would allow us to remove this complexity by requiring that
> > > CROSS_COMPILE_COMPAT identifies the cross-compiler to use in exactly the
> > > same way as CROSS_COMPILE does.
> > >
> > > Am I missing something here?
> >
> > I think the second paragraph you wrote shows we're all in agreement,
> > but I suspect you may be conflating *how* the toplevel Makefile knows
> > we're doing a cross compile.  It doesn't read a config, this patch
> > would make it so a cross compiler is specified via config, Catalin
> > asked "please no," I agree with Catalin (and I suspect you do too).
>
> Yes, I'm saying let's have an environment variable only and drop the
> CONFIG stuff completely. I think this means that the environment variable
> must always be specified if you want the compat vDSO, but I don't see that
> as a problem.
>
> Will



-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-10-01 17:12                           ` Nick Desaulniers
  0 siblings, 0 replies; 127+ messages in thread
From: Nick Desaulniers @ 2019-10-01 17:12 UTC (permalink / raw)
  To: Will Deacon
  Cc: Ard Biesheuvel, Catalin Marinas, LKML, Thomas Gleixner,
	Vincenzo Frascino, Linux ARM

On Tue, Oct 1, 2019 at 10:08 AM Will Deacon <will@kernel.org> wrote:
>
> On Tue, Oct 01, 2019 at 09:59:43AM -0700, Nick Desaulniers wrote:
> > On Tue, Oct 1, 2019 at 9:47 AM Will Deacon <will@kernel.org> wrote:
> > >
> > > On Tue, Oct 01, 2019 at 04:30:56PM +0100, Catalin Marinas wrote:
> > > > In the long run, I wouldn't mandate CROSS_COMPILE_COMPAT to always be
> > > > set for the compat vDSO since with clang we could use the same compiler
> > > > binary for both native and compat (with different flags). That's once we
> > > > cleaned up the headers.
> > >
> > > But we'll still need it even with clang so that the relevant triple can be
> > > passed to the --target option. The top-level Makefile already does this:
> > >
> > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile#n544
> >
> > That's not pulling the cross compiler out of a *config* (as this patch
> > is proposing); rather from an env var.
>
> CROSS_COMPILE_COMPAT is the environment variable, right? If not, then I have
> my terminology mixed up.

Ah, sorry, I'm the one misreading the patch.  I thought the commit
message was showing what the new process would be. I see now that it's
describing the issue pre-patch.  My mistake.

>
> > > so I think we should do the same thing for the compat vdso as well, which
> > > would allow us to remove this complexity by requiring that
> > > CROSS_COMPILE_COMPAT identifies the cross-compiler to use in exactly the
> > > same way as CROSS_COMPILE does.
> > >
> > > Am I missing something here?
> >
> > I think the second paragraph you wrote shows we're all in agreement,
> > but I suspect you may be conflating *how* the toplevel Makefile knows
> > we're doing a cross compile.  It doesn't read a config, this patch
> > would make it so a cross compiler is specified via config, Catalin
> > asked "please no," I agree with Catalin (and I suspect you do too).
>
> Yes, I'm saying let's have an environment variable only and drop the
> CONFIG stuff completely. I think this means that the environment variable
> must always be specified if you want the compat vDSO, but I don't see that
> as a problem.
>
> Will



-- 
Thanks,
~Nick Desaulniers

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
  2019-10-01 17:12                           ` Nick Desaulniers
@ 2019-10-01 17:14                             ` Will Deacon
  -1 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 17:14 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Catalin Marinas, Vincenzo Frascino, Linux ARM, LKML,
	Ard Biesheuvel, Thomas Gleixner

On Tue, Oct 01, 2019 at 10:12:59AM -0700, Nick Desaulniers wrote:
> On Tue, Oct 1, 2019 at 10:08 AM Will Deacon <will@kernel.org> wrote:
> >
> > On Tue, Oct 01, 2019 at 09:59:43AM -0700, Nick Desaulniers wrote:
> > > On Tue, Oct 1, 2019 at 9:47 AM Will Deacon <will@kernel.org> wrote:
> > > >
> > > > On Tue, Oct 01, 2019 at 04:30:56PM +0100, Catalin Marinas wrote:
> > > > > In the long run, I wouldn't mandate CROSS_COMPILE_COMPAT to always be
> > > > > set for the compat vDSO since with clang we could use the same compiler
> > > > > binary for both native and compat (with different flags). That's once we
> > > > > cleaned up the headers.
> > > >
> > > > But we'll still need it even with clang so that the relevant triple can be
> > > > passed to the --target option. The top-level Makefile already does this:
> > > >
> > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile#n544
> > >
> > > That's not pulling the cross compiler out of a *config* (as this patch
> > > is proposing); rather from an env var.
> >
> > CROSS_COMPILE_COMPAT is the environment variable, right? If not, then I have
> > my terminology mixed up.
> 
> Ah, sorry, I'm the one misreading the patch.  I thought the commit
> message was showing what the new process would be. I see now that it's
> describing the issue pre-patch.  My mistake.

Thanks. Thought I was losing the plot for a moment there!

Will

^ permalink raw reply	[flat|nested] 127+ messages in thread

* Re: [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC
@ 2019-10-01 17:14                             ` Will Deacon
  0 siblings, 0 replies; 127+ messages in thread
From: Will Deacon @ 2019-10-01 17:14 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Ard Biesheuvel, Catalin Marinas, LKML, Thomas Gleixner,
	Vincenzo Frascino, Linux ARM

On Tue, Oct 01, 2019 at 10:12:59AM -0700, Nick Desaulniers wrote:
> On Tue, Oct 1, 2019 at 10:08 AM Will Deacon <will@kernel.org> wrote:
> >
> > On Tue, Oct 01, 2019 at 09:59:43AM -0700, Nick Desaulniers wrote:
> > > On Tue, Oct 1, 2019 at 9:47 AM Will Deacon <will@kernel.org> wrote:
> > > >
> > > > On Tue, Oct 01, 2019 at 04:30:56PM +0100, Catalin Marinas wrote:
> > > > > In the long run, I wouldn't mandate CROSS_COMPILE_COMPAT to always be
> > > > > set for the compat vDSO since with clang we could use the same compiler
> > > > > binary for both native and compat (with different flags). That's once we
> > > > > cleaned up the headers.
> > > >
> > > > But we'll still need it even with clang so that the relevant triple can be
> > > > passed to the --target option. The top-level Makefile already does this:
> > > >
> > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile#n544
> > >
> > > That's not pulling the cross compiler out of a *config* (as this patch
> > > is proposing); rather from an env var.
> >
> > CROSS_COMPILE_COMPAT is the environment variable, right? If not, then I have
> > my terminology mixed up.
> 
> Ah, sorry, I'm the one misreading the patch.  I thought the commit
> message was showing what the new process would be. I see now that it's
> describing the issue pre-patch.  My mistake.

Thanks. Thought I was losing the plot for a moment there!

Will

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

^ permalink raw reply	[flat|nested] 127+ messages in thread

end of thread, other threads:[~2019-10-01 17:14 UTC | newest]

Thread overview: 127+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-20 14:27 Problems with arm64 compat vdso Will Deacon
2019-09-20 16:33 ` Vincenzo Frascino
2019-09-23 16:41   ` Ard Biesheuvel
2019-09-24 12:11     ` Vincenzo Frascino
2019-09-24 18:06       ` Nick Desaulniers
2019-09-24 20:42         ` Vincenzo Frascino
2019-09-25 15:58     ` Ard Biesheuvel
2019-09-26  6:03 ` [PATCH 0/4] arm64: vdso32: Address various issues Vincenzo Frascino
2019-09-26  6:03   ` Vincenzo Frascino
2019-09-26  6:03   ` [PATCH 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC Vincenzo Frascino
2019-09-26  6:03     ` Vincenzo Frascino
2019-09-26  8:06     ` Catalin Marinas
2019-09-26  8:06       ` Catalin Marinas
2019-09-26 10:56       ` Vincenzo Frascino
2019-09-26 10:56         ` Vincenzo Frascino
2019-09-26 11:02         ` Vincenzo Frascino
2019-09-26 11:02           ` Vincenzo Frascino
2019-09-26 15:23           ` Catalin Marinas
2019-09-26 15:23             ` Catalin Marinas
2019-09-26 12:22         ` Vincenzo Frascino
2019-09-26 12:22           ` Vincenzo Frascino
2019-09-26 15:17           ` Catalin Marinas
2019-09-26 15:17             ` Catalin Marinas
2019-09-26 20:17             ` Vincenzo Frascino
2019-09-26 20:17               ` Vincenzo Frascino
2019-09-26  6:03   ` [PATCH 2/4] arm64: vdso32: Detect binutils support for dmb ishld Vincenzo Frascino
2019-09-26  6:03     ` Vincenzo Frascino
2019-09-26  8:30     ` Catalin Marinas
2019-09-26  8:30       ` Catalin Marinas
2019-09-26 10:59       ` Vincenzo Frascino
2019-09-26 10:59         ` Vincenzo Frascino
2019-09-26  6:03   ` [PATCH 3/4] arm64: vdso32: Fix compilation warning Vincenzo Frascino
2019-09-26  6:03     ` Vincenzo Frascino
2019-09-26  8:32     ` Catalin Marinas
2019-09-26  8:32       ` Catalin Marinas
2019-09-26 11:03       ` Vincenzo Frascino
2019-09-26 11:03         ` Vincenzo Frascino
2019-09-26  6:03   ` [PATCH 4/4] arm64: Remove gettimeofday.S Vincenzo Frascino
2019-09-26  6:03     ` Vincenzo Frascino
2019-09-26  8:34     ` Catalin Marinas
2019-09-26  8:34       ` Catalin Marinas
2019-09-26 13:38 ` [PATCH v2 0/4] arm64: vdso32: Address various issues Vincenzo Frascino
2019-09-26 13:38   ` Vincenzo Frascino
2019-09-26 13:38   ` [PATCH v2 1/4] arm64: vdso32: Introduce COMPAT_CC_IS_GCC Vincenzo Frascino
2019-09-26 13:38     ` Vincenzo Frascino
2019-09-26 15:13     ` Catalin Marinas
2019-09-26 15:13       ` Catalin Marinas
2019-09-26 13:38   ` [PATCH v2 2/4] arm64: vdso32: Detect binutils support for dmb ishld Vincenzo Frascino
2019-09-26 13:38     ` Vincenzo Frascino
2019-09-26 14:26     ` Catalin Marinas
2019-09-26 14:26       ` Catalin Marinas
2019-09-26 20:19       ` Vincenzo Frascino
2019-09-26 20:19         ` Vincenzo Frascino
2019-09-26 15:59     ` Catalin Marinas
2019-09-26 15:59       ` Catalin Marinas
2019-09-26 21:17       ` Vincenzo Frascino
2019-09-26 21:17         ` Vincenzo Frascino
2019-09-26 16:23     ` Nick Desaulniers
2019-09-26 16:23       ` Nick Desaulniers
2019-09-26 13:38   ` [PATCH v2 3/4] arm64: vdso32: Fix compilation warning Vincenzo Frascino
2019-09-26 13:38     ` Vincenzo Frascino
2019-09-26 15:22     ` Catalin Marinas
2019-09-26 15:22       ` Catalin Marinas
2019-09-26 13:38   ` [PATCH v2 4/4] arm64: Remove gettimeofday.S Vincenzo Frascino
2019-09-26 13:38     ` Vincenzo Frascino
2019-09-26 15:31   ` [PATCH v2 0/4] arm64: vdso32: Address various issues Catalin Marinas
2019-09-26 15:31     ` Catalin Marinas
2019-09-26 20:29     ` Vincenzo Frascino
2019-09-26 20:29       ` Vincenzo Frascino
2019-09-26 21:43 ` [PATCH v3 0/5]arm64: " Vincenzo Frascino
2019-09-26 21:43   ` Vincenzo Frascino
2019-09-26 21:43   ` [PATCH v3 1/5] arm64: vdso32: Introduce COMPAT_CC_IS_GCC Vincenzo Frascino
2019-09-26 21:43     ` Vincenzo Frascino
2019-09-27  9:24     ` Catalin Marinas
2019-09-27  9:24       ` Catalin Marinas
2019-10-01 13:14     ` Will Deacon
2019-10-01 13:14       ` Will Deacon
2019-10-01 13:27       ` Catalin Marinas
2019-10-01 13:27         ` Catalin Marinas
2019-10-01 14:20         ` Vincenzo Frascino
2019-10-01 14:20           ` Vincenzo Frascino
2019-10-01 14:20           ` Will Deacon
2019-10-01 14:20             ` Will Deacon
2019-10-01 14:37             ` Vincenzo Frascino
2019-10-01 14:37               ` Vincenzo Frascino
2019-10-01 14:43               ` Will Deacon
2019-10-01 14:43                 ` Will Deacon
2019-10-01 14:59                 ` Vincenzo Frascino
2019-10-01 14:59                   ` Vincenzo Frascino
2019-10-01 15:30                 ` Catalin Marinas
2019-10-01 15:30                   ` Catalin Marinas
2019-10-01 16:46                   ` Will Deacon
2019-10-01 16:46                     ` Will Deacon
2019-10-01 16:59                     ` Nick Desaulniers
2019-10-01 16:59                       ` Nick Desaulniers
2019-10-01 17:07                       ` Will Deacon
2019-10-01 17:07                         ` Will Deacon
2019-10-01 17:12                         ` Nick Desaulniers
2019-10-01 17:12                           ` Nick Desaulniers
2019-10-01 17:14                           ` Will Deacon
2019-10-01 17:14                             ` Will Deacon
2019-09-26 21:43   ` [PATCH v3 2/5] arm64: vdso32: Detect binutils support for dmb ishld Vincenzo Frascino
2019-09-26 21:43     ` Vincenzo Frascino
2019-09-27  9:25     ` Catalin Marinas
2019-09-27  9:25       ` Catalin Marinas
2019-10-01 13:26     ` Will Deacon
2019-10-01 13:26       ` Will Deacon
2019-10-01 14:23       ` Vincenzo Frascino
2019-10-01 14:23         ` Vincenzo Frascino
2019-09-26 21:43   ` [PATCH v3 3/5] arm64: vdso32: Fix compilation warning Vincenzo Frascino
2019-09-26 21:43     ` Vincenzo Frascino
2019-09-27  9:26     ` Catalin Marinas
2019-09-27  9:26       ` Catalin Marinas
2019-10-01 13:21     ` Will Deacon
2019-10-01 13:21       ` Will Deacon
2019-10-01 14:41       ` Vincenzo Frascino
2019-10-01 14:41         ` Vincenzo Frascino
2019-09-26 21:43   ` [PATCH v3 4/5] arm64: Remove gettimeofday.S Vincenzo Frascino
2019-09-26 21:43     ` Vincenzo Frascino
2019-09-26 21:43   ` [PATCH v3 5/5] arm64: vdso32: Remove jump label config option in Makefile Vincenzo Frascino
2019-09-26 21:43     ` Vincenzo Frascino
2019-09-27  9:27     ` Catalin Marinas
2019-09-27  9:27       ` Catalin Marinas
2019-09-27 10:46   ` [PATCH v3 0/5]arm64: vdso32: Address various issues Catalin Marinas
2019-09-27 10:46     ` Catalin Marinas
2019-10-01 13:27   ` Will Deacon
2019-10-01 13:27     ` Will Deacon

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.