All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <natechancellor@gmail.com>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: mark.rutland@arm.com, keescook@chromium.org,
	suzuki.poulose@arm.com, catalin.marinas@arm.com,
	kristina.martsenko@arm.com, ardb@kernel.org,
	yamada.masahiro@socionext.com, broonie@kernel.org,
	james.morse@arm.com, clang-built-linux@googlegroups.com,
	ramana.radhakrishnan@arm.com, amit.kachhap@arm.com,
	vincenzo.frascino@arm.com, will@kernel.org, Dave.Martin@arm.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm64: Kconfig: verify binutils support for ARM64_PTR_AUTH
Date: Thu, 19 Mar 2020 11:35:38 -0700	[thread overview]
Message-ID: <20200319183538.GA33965@ubuntu-m2-xlarge-x86> (raw)
In-Reply-To: <20200319181951.102662-1-ndesaulniers@google.com>

On Thu, Mar 19, 2020 at 11:19:51AM -0700, 'Nick Desaulniers' via Clang Built Linux wrote:
> Clang relies on GNU as from binutils to assemble the Linux kernel,
> currently. A recent patch to enable the armv8.3-a extension for pointer
> authentication checked for compiler support of the relevant flags.
> Everything works with binutils 2.34+, but for older versions we observe
> assembler errors:
> 
> /tmp/vgettimeofday-36a54b.s: Assembler messages:
> /tmp/vgettimeofday-36a54b.s:40: Error: unknown pseudo-op: `.cfi_negate_ra_state'
> 
> When compiling with Clang, require the assembler to support
> .cfi_negate_ra_state directives, in order to support CONFIG_ARM64_PTR_AUTH.
> 
> Link: https://github.com/ClangBuiltLinux/linux/issues/938
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> Tested with binutils 2.33.1 and ToT. Boot tested in QEMU.
> I added this requirement only for Clang.
> 
> GCC maybe doesn't produce these assembler directives, or looks like GCC
> 8.2 produces .cfi_window_save (https://godbolt.org/z/awZWZ5, godbolt
> doesn't have a newer aarch64-linux-gnu-gcc...) instead of
> .cfi_negate_ra_state. Maybe ARM can sort out the inconsistency between
> compilers?
> 
> If we plan to add .cfi_negate_ra_state to out of
> line assembly, we may want to make AS_HAS_CFI_NEGATE_RA_STATE a hard
> requirement, regardless of compiler.
> 
> Also, rather than CC_IS_GCC, we could do !CC_IS_CLANG || ...
> 
> 
>  arch/arm64/Kconfig | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index b889d7956abf..1ee1d8fab218 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -1506,6 +1506,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 (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_REGS)
>  	help
>  	  Pointer authentication (part of the ARMv8.3 Extensions) provides
> @@ -1550,6 +1551,9 @@ config CC_HAS_SIGN_RETURN_ADDRESS
>  config AS_HAS_PAC
>  	def_bool $(as-option,-Wa$(comma)-march=armv8.3-a)
>  
> +config AS_HAS_CFI_NEGATE_RA_STATE
> +	def_bool $(as-instr,.cfi_startproc\n.cfi_negate_ra_state\n.cfi_endproc\n)
> +
>  endmenu
>  
>  menu "ARMv8.4 architectural features"
> -- 
> 2.25.1.696.g5e7596f4ac-goog
> 

It would be nice to make this kind of check work for both GCC and Clang
but like you noted, there appears to be inconsistencies between them so
something for another day. CONFIG_ARM64_PTR_AUTH is getting a little
gnarly in terms of dependencies but I suppose that makes sense given its
nature. I verified that AS_HAS_CFI_NEGATE_RA_STATE gets set with ToT
binutils and that it does not with an older version.

Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>

This unlocks our CI so hopefully it can get picked up quickly.

https://travis-ci.com/github/ClangBuiltLinux/continuous-integration/jobs/299816618

Cheers,
Nathan

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

  reply	other threads:[~2020-03-19 18:35 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-13  9:04 [PATCH v7 00/17] arm64: return address signing Amit Daniel Kachhap
2020-03-13  9:04 ` [PATCH v7 01/17] arm64: cpufeature: Fix meta-capability cpufeature check Amit Daniel Kachhap
2020-03-13  9:04 ` [PATCH v7 02/17] arm64: cpufeature: add pointer auth meta-capabilities Amit Daniel Kachhap
2020-03-13  9:04 ` [PATCH v7 03/17] arm64: rename ptrauth key structures to be user-specific Amit Daniel Kachhap
2020-03-13  9:04 ` [PATCH v7 04/17] arm64: install user ptrauth keys at kernel exit time Amit Daniel Kachhap
2020-03-13  9:04 ` [PATCH v7 05/17] arm64: ptrauth: Add bootup/runtime flags for __cpu_setup Amit Daniel Kachhap
2020-03-13  9:04 ` [PATCH v7 06/17] arm64: cpufeature: Move cpu capability helpers inside C file Amit Daniel Kachhap
2020-03-13  9:04 ` [PATCH v7 07/17] arm64: cpufeature: handle conflicts based on capability Amit Daniel Kachhap
2020-03-13  9:04 ` [PATCH v7 08/17] arm64: enable ptrauth earlier Amit Daniel Kachhap
2020-03-13  9:04 ` [PATCH v7 09/17] arm64: initialize and switch ptrauth kernel keys Amit Daniel Kachhap
2020-03-13  9:04 ` [PATCH v7 10/17] arm64: initialize ptrauth keys for kernel booting task Amit Daniel Kachhap
2020-03-13  9:04 ` [PATCH v7 11/17] arm64: mask PAC bits of __builtin_return_address Amit Daniel Kachhap
2020-03-13  9:04 ` [PATCH v7 12/17] arm64: unwind: strip PAC from kernel addresses Amit Daniel Kachhap
2020-03-13  9:05 ` [PATCH v7 13/17] arm64: __show_regs: strip PAC from lr in printk Amit Daniel Kachhap
2020-03-13  9:05 ` [PATCH v7 14/17] arm64: suspend: restore the kernel ptrauth keys Amit Daniel Kachhap
2020-03-13  9:05 ` [PATCH v7 15/17] kconfig: Add support for 'as-option' Amit Daniel Kachhap
2020-03-13  9:05   ` Amit Daniel Kachhap
2020-03-13  9:10   ` Masahiro Yamada
2020-03-13  9:10     ` Masahiro Yamada
2020-03-13  9:14     ` Amit Kachhap
2020-03-13  9:14       ` Amit Kachhap
2020-03-13  9:05 ` [PATCH v7 16/17] arm64: compile the kernel with ptrauth return address signing Amit Daniel Kachhap
2020-03-19 18:19   ` [PATCH] arm64: Kconfig: verify binutils support for ARM64_PTR_AUTH Nick Desaulniers
2020-03-19 18:35     ` Nathan Chancellor [this message]
2020-03-20 15:09     ` Catalin Marinas
2020-03-13  9:05 ` [PATCH v7 17/17] lkdtm: arm64: test kernel pointer authentication Amit Daniel Kachhap
2020-03-18 14:32 ` [PATCH v7 00/17] arm64: return address signing Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200319183538.GA33965@ubuntu-m2-xlarge-x86 \
    --to=natechancellor@gmail.com \
    --cc=Dave.Martin@arm.com \
    --cc=amit.kachhap@arm.com \
    --cc=ardb@kernel.org \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=james.morse@arm.com \
    --cc=keescook@chromium.org \
    --cc=kristina.martsenko@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=ndesaulniers@google.com \
    --cc=ramana.radhakrishnan@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=vincenzo.frascino@arm.com \
    --cc=will@kernel.org \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.