linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] init/kconfig: Add LD_VERSION Kconfig
@ 2020-03-30 11:41 Amit Daniel Kachhap
  2020-03-30 11:41 ` [PATCH v2 2/2] arm64: Kconfig: ptrauth: Add binutils version check to fix mismatch Amit Daniel Kachhap
  2020-05-04  7:11 ` [PATCH v2 1/2] init/kconfig: Add LD_VERSION Kconfig Geert Uytterhoeven
  0 siblings, 2 replies; 6+ messages in thread
From: Amit Daniel Kachhap @ 2020-03-30 11:41 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Catalin Marinas, Will Deacon, Vincenzo Frascino, linux-kernel,
	Amit Daniel Kachhap

This option can be used in Kconfig files to compare the ld version
and enable/disable incompatible config options if required.

This option is used in the subsequent patch along with GCC_VERSION to
filter out an incompatible feature.

Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
---
Changes since v1:
* None.

This patch series is based on Linux arm64 for-next tree [1]. More details
of this work can be found in the thread [2].

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
[2]: http://lists.infradead.org/pipermail/linux-arm-kernel/2020-March/720257.html

 init/Kconfig | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/init/Kconfig b/init/Kconfig
index 452bc18..68ddbcd 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -17,6 +17,10 @@ config GCC_VERSION
 	default $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) if CC_IS_GCC
 	default 0
 
+config LD_VERSION
+	int
+	default $(shell,$(LD) --version | $(srctree)/scripts/ld-version.sh)
+
 config CC_IS_CLANG
 	def_bool $(success,$(CC) --version | head -n 1 | grep -q clang)
 
-- 
2.7.4


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

* [PATCH v2 2/2] arm64: Kconfig: ptrauth: Add binutils version check to fix mismatch
  2020-03-30 11:41 [PATCH v2 1/2] init/kconfig: Add LD_VERSION Kconfig Amit Daniel Kachhap
@ 2020-03-30 11:41 ` Amit Daniel Kachhap
  2020-04-01 12:28   ` Catalin Marinas
  2020-05-04  7:11 ` [PATCH v2 1/2] init/kconfig: Add LD_VERSION Kconfig Geert Uytterhoeven
  1 sibling, 1 reply; 6+ messages in thread
From: Amit Daniel Kachhap @ 2020-03-30 11:41 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Catalin Marinas, Will Deacon, Vincenzo Frascino, linux-kernel,
	Amit Daniel Kachhap

Recent addition of ARM64_PTR_AUTH exposed a mismatch issue with binutils.
9.1+ versions of gcc inserts a section note .note.gnu.property but this
can be used properly by binutils version greater than 2.33.1. If older
binutils are used then the following warnings are generated,

aarch64-linux-ld: warning: arch/arm64/kernel/vdso/vgettimeofday.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0000000
aarch64-linux-objdump: warning: arch/arm64/lib/csum.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0000000
aarch64-linux-nm: warning: .tmp_vmlinux1: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0000000

This patch enables ARM64_PTR_AUTH when gcc and binutils versions are
compatible with each other. Older gcc which do not insert such section
continue to work as before.

This scenario may not occur with clang as a recent commit 3b446c7d27ddd06
("arm64: Kconfig: verify binutils support for ARM64_PTR_AUTH") masks
binutils version lesser then 2.34.

Reported-by: kbuild test robot <lkp@intel.com>
Suggested-by: Vincenzo Frascino <Vincenzo.Frascino@arm.com>
Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
---
Changes since v1[1]:
 * Separated GCC and CLANG checks as suggested by Catalin.
 * Added comments in Kconfig entry.

[1]: https://lkml.org/lkml/2020/3/26/626 

 arch/arm64/Kconfig | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index e6712b6..4391a4f 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1503,7 +1503,10 @@ config ARM64_PTR_AUTH
 	default y
 	depends on !KVM || ARM64_VHE
 	depends on (CC_HAS_SIGN_RETURN_ADDRESS || CC_HAS_BRANCH_PROT_PAC_RET) && AS_HAS_PAC
-	depends on CC_IS_GCC || (CC_IS_CLANG && AS_HAS_CFI_NEGATE_RA_STATE)
+	# GCC 9.1 version inserts a section note .note.gnu.property for PAC
+	# which can be used properly by binutils version 2.33.1 and higher.
+	depends on !CC_IS_GCC || GCC_VERSION < 90100 || LD_VERSION >= 233010000
+	depends on !CC_IS_CLANG || AS_HAS_CFI_NEGATE_RA_STATE
 	depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_REGS)
 	help
 	  Pointer authentication (part of the ARMv8.3 Extensions) provides
-- 
2.7.4


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

* Re: [PATCH v2 2/2] arm64: Kconfig: ptrauth: Add binutils version check to fix mismatch
  2020-03-30 11:41 ` [PATCH v2 2/2] arm64: Kconfig: ptrauth: Add binutils version check to fix mismatch Amit Daniel Kachhap
@ 2020-04-01 12:28   ` Catalin Marinas
  0 siblings, 0 replies; 6+ messages in thread
From: Catalin Marinas @ 2020-04-01 12:28 UTC (permalink / raw)
  To: Amit Daniel Kachhap
  Cc: linux-arm-kernel, Vincenzo Frascino, Will Deacon, linux-kernel

On Mon, Mar 30, 2020 at 05:11:39PM +0530, Amit Daniel Kachhap wrote:
> Recent addition of ARM64_PTR_AUTH exposed a mismatch issue with binutils.
> 9.1+ versions of gcc inserts a section note .note.gnu.property but this
> can be used properly by binutils version greater than 2.33.1. If older
> binutils are used then the following warnings are generated,
> 
> aarch64-linux-ld: warning: arch/arm64/kernel/vdso/vgettimeofday.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0000000
> aarch64-linux-objdump: warning: arch/arm64/lib/csum.o: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0000000
> aarch64-linux-nm: warning: .tmp_vmlinux1: unsupported GNU_PROPERTY_TYPE (5) type: 0xc0000000

I queued both patches for 5.7. Thanks.

-- 
Catalin

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

* Re: [PATCH v2 1/2] init/kconfig: Add LD_VERSION Kconfig
  2020-03-30 11:41 [PATCH v2 1/2] init/kconfig: Add LD_VERSION Kconfig Amit Daniel Kachhap
  2020-03-30 11:41 ` [PATCH v2 2/2] arm64: Kconfig: ptrauth: Add binutils version check to fix mismatch Amit Daniel Kachhap
@ 2020-05-04  7:11 ` Geert Uytterhoeven
  2020-05-04  8:06   ` Will Deacon
  1 sibling, 1 reply; 6+ messages in thread
From: Geert Uytterhoeven @ 2020-05-04  7:11 UTC (permalink / raw)
  To: Amit Daniel Kachhap
  Cc: Linux ARM, Catalin Marinas, Vincenzo Frascino, Will Deacon,
	Linux Kernel Mailing List, Michael Ellerman

Hi Amit,

On Mon, Mar 30, 2020 at 1:42 PM Amit Daniel Kachhap
<amit.kachhap@arm.com> wrote:
> This option can be used in Kconfig files to compare the ld version
> and enable/disable incompatible config options if required.
>
> This option is used in the subsequent patch along with GCC_VERSION to
> filter out an incompatible feature.
>
> Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>

> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -17,6 +17,10 @@ config GCC_VERSION
>         default $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) if CC_IS_GCC
>         default 0
>
> +config LD_VERSION
> +       int
> +       default $(shell,$(LD) --version | $(srctree)/scripts/ld-version.sh)
> +
>  config CC_IS_CLANG
>         def_bool $(success,$(CC) --version | head -n 1 | grep -q clang)

.config: warning: symbol value '2.01827e+11' invalid for LD_VERSION

Seen with the or32 compiler on kisskb, e.g.
http://kisskb.ellerman.id.au/kisskb/buildresult/14226173/

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 1/2] init/kconfig: Add LD_VERSION Kconfig
  2020-05-04  7:11 ` [PATCH v2 1/2] init/kconfig: Add LD_VERSION Kconfig Geert Uytterhoeven
@ 2020-05-04  8:06   ` Will Deacon
  2020-05-05 13:51     ` Michael Ellerman
  0 siblings, 1 reply; 6+ messages in thread
From: Will Deacon @ 2020-05-04  8:06 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Amit Daniel Kachhap, Linux ARM, Catalin Marinas,
	Vincenzo Frascino, Linux Kernel Mailing List, Michael Ellerman

On Mon, May 04, 2020 at 09:11:12AM +0200, Geert Uytterhoeven wrote:
> On Mon, Mar 30, 2020 at 1:42 PM Amit Daniel Kachhap
> <amit.kachhap@arm.com> wrote:
> > This option can be used in Kconfig files to compare the ld version
> > and enable/disable incompatible config options if required.
> >
> > This option is used in the subsequent patch along with GCC_VERSION to
> > filter out an incompatible feature.
> >
> > Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
> 
> > --- a/init/Kconfig
> > +++ b/init/Kconfig
> > @@ -17,6 +17,10 @@ config GCC_VERSION
> >         default $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) if CC_IS_GCC
> >         default 0
> >
> > +config LD_VERSION
> > +       int
> > +       default $(shell,$(LD) --version | $(srctree)/scripts/ld-version.sh)
> > +
> >  config CC_IS_CLANG
> >         def_bool $(success,$(CC) --version | head -n 1 | grep -q clang)
> 
> .config: warning: symbol value '2.01827e+11' invalid for LD_VERSION
> 
> Seen with the or32 compiler on kisskb, e.g.
> http://kisskb.ellerman.id.au/kisskb/buildresult/14226173/

Hmm. The binutils version there is '2.26.20160125', but I think
scripts/ld-version.sh is expecting that to be '2.26.0.20160125' as it would
then ignore the date suffix as of commit 0d61ed17dd30 ("ld-version: Drop
the 4th and 5th version components"). On a 32-bit host architecture, the
awk expression ends up printing the version using exponential notation,
but even on a 64-bit arch the number would still be bogus.

Will

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

* Re: [PATCH v2 1/2] init/kconfig: Add LD_VERSION Kconfig
  2020-05-04  8:06   ` Will Deacon
@ 2020-05-05 13:51     ` Michael Ellerman
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2020-05-05 13:51 UTC (permalink / raw)
  To: Will Deacon, Geert Uytterhoeven
  Cc: Amit Daniel Kachhap, Linux ARM, Catalin Marinas,
	Vincenzo Frascino, Linux Kernel Mailing List

Will Deacon <will@kernel.org> writes:
> On Mon, May 04, 2020 at 09:11:12AM +0200, Geert Uytterhoeven wrote:
>> On Mon, Mar 30, 2020 at 1:42 PM Amit Daniel Kachhap
>> <amit.kachhap@arm.com> wrote:
>> > This option can be used in Kconfig files to compare the ld version
>> > and enable/disable incompatible config options if required.
>> >
>> > This option is used in the subsequent patch along with GCC_VERSION to
>> > filter out an incompatible feature.
>> >
>> > Signed-off-by: Amit Daniel Kachhap <amit.kachhap@arm.com>
>> 
>> > --- a/init/Kconfig
>> > +++ b/init/Kconfig
>> > @@ -17,6 +17,10 @@ config GCC_VERSION
>> >         default $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) if CC_IS_GCC
>> >         default 0
>> >
>> > +config LD_VERSION
>> > +       int
>> > +       default $(shell,$(LD) --version | $(srctree)/scripts/ld-version.sh)
>> > +
>> >  config CC_IS_CLANG
>> >         def_bool $(success,$(CC) --version | head -n 1 | grep -q clang)
>> 
>> .config: warning: symbol value '2.01827e+11' invalid for LD_VERSION
>> 
>> Seen with the or32 compiler on kisskb, e.g.
>> http://kisskb.ellerman.id.au/kisskb/buildresult/14226173/
>
> Hmm. The binutils version there is '2.26.20160125', but I think
> scripts/ld-version.sh is expecting that to be '2.26.0.20160125' as it would
> then ignore the date suffix as of commit 0d61ed17dd30 ("ld-version: Drop
> the 4th and 5th version components").

I updated the or32 compiler on kisskb to gcc 9.3.0, thanks to Arnd for
building it.

It has binutils 2.34.

cheers

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

end of thread, other threads:[~2020-05-05 13:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30 11:41 [PATCH v2 1/2] init/kconfig: Add LD_VERSION Kconfig Amit Daniel Kachhap
2020-03-30 11:41 ` [PATCH v2 2/2] arm64: Kconfig: ptrauth: Add binutils version check to fix mismatch Amit Daniel Kachhap
2020-04-01 12:28   ` Catalin Marinas
2020-05-04  7:11 ` [PATCH v2 1/2] init/kconfig: Add LD_VERSION Kconfig Geert Uytterhoeven
2020-05-04  8:06   ` Will Deacon
2020-05-05 13:51     ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).