2020-03-26 15:32:51

by Amit Kachhap

[permalink] [raw]
Subject: [PATCH 1/2] init/kconfig: Add LD_VERSION Kconfig

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 <[email protected]>
---

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


2020-03-26 15:35:27

by Amit Kachhap

[permalink] [raw]
Subject: [PATCH 2/2] arm64: Kconfig: ptrauth: Add binutils version check to fix mismatch

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 <[email protected]>
Suggested-by: Vincenzo Frascino <[email protected]>
Signed-off-by: Amit Daniel Kachhap <[email protected]>
---
arch/arm64/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index e6712b6..73135da 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1503,7 +1503,7 @@ 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)
+ depends on (CC_IS_GCC && (GCC_VERSION < 90100 || LD_VERSION >= 233010000)) || (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

2020-03-27 12:56:01

by Catalin Marinas

[permalink] [raw]
Subject: Re: [PATCH 2/2] arm64: Kconfig: ptrauth: Add binutils version check to fix mismatch

On Thu, Mar 26, 2020 at 09:02:00PM +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
>
> 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 <[email protected]>
> Suggested-by: Vincenzo Frascino <[email protected]>
> Signed-off-by: Amit Daniel Kachhap <[email protected]>
> ---
> arch/arm64/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index e6712b6..73135da 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -1503,7 +1503,7 @@ 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)
> + depends on (CC_IS_GCC && (GCC_VERSION < 90100 || LD_VERSION >= 233010000)) || (CC_IS_CLANG && AS_HAS_CFI_NEGATE_RA_STATE)

We should add some of the comments in the commit log to the Kconfig
entry. I would also split this in two (equivalent to CC_IS_ implies):

depends on !CC_IS_GCC || GCC_VERSION < 90100 || LD_VERSION >= 233010000
depends on !CC_IS_CLANG || AS_HAS_CFI_NEGATE_RA_STATE

and add a comment above the gcc/ld version checking.

(not entirely identical to the original if CC is neither of them but I
don't think we have this problem)

--
Catalin

2020-03-30 11:44:41

by Amit Kachhap

[permalink] [raw]
Subject: Re: [PATCH 2/2] arm64: Kconfig: ptrauth: Add binutils version check to fix mismatch



On 3/27/20 6:25 PM, Catalin Marinas wrote:
> On Thu, Mar 26, 2020 at 09:02:00PM +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
>>
>> 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 <[email protected]>
>> Suggested-by: Vincenzo Frascino <[email protected]>
>> Signed-off-by: Amit Daniel Kachhap <[email protected]>
>> ---
>> arch/arm64/Kconfig | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
>> index e6712b6..73135da 100644
>> --- a/arch/arm64/Kconfig
>> +++ b/arch/arm64/Kconfig
>> @@ -1503,7 +1503,7 @@ 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)
>> + depends on (CC_IS_GCC && (GCC_VERSION < 90100 || LD_VERSION >= 233010000)) || (CC_IS_CLANG && AS_HAS_CFI_NEGATE_RA_STATE)
>
> We should add some of the comments in the commit log to the Kconfig
> entry. I would also split this in two (equivalent to CC_IS_ implies):
>
> depends on !CC_IS_GCC || GCC_VERSION < 90100 || LD_VERSION >= 233010000
> depends on !CC_IS_CLANG || AS_HAS_CFI_NEGATE_RA_STATE
>
> and add a comment above the gcc/ld version checking.
>
> (not entirely identical to the original if CC is neither of them but I
> don't think we have this problem)

Re-posted v2 as per the suggestions.

Thanks,
Amit
>