From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8AD15C43334 for ; Wed, 15 Jun 2022 16:51:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uIaXfmTn5U+/NbAJ452OWi7XR4Ik+kbVvDX43eJRwrg=; b=ItzE+ht2NkCljl 9PQVVnMfVTRge59LkJdHDfPN+iC5UfNZmr5Jk6eKGlU7lVZYbh60+eDGBP27Cryd8KKsppxVRSNud fiBqHExBZWj/dILuV+M4h8V2l+u/xUJJoWBv+swgl5YfD90b9mleWfZoBTyw22AiObiBB6xtr6Nn8 wsdgNz33afo2S5g6r6eGH3NYttKl4SQNTw1XiC+nfpg1ih41xl0Ia6yG+jFnlGvsDSarEvPjT7oQb lMYzvYPysYKYrWGSOCFY1fZdqS8vYpBHymEBVod2D3aaIuHJSYd/7CVWijVFxLFGFRZgjZqDlB40q VZB5xR5PMz2KHWbRA6xQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1WEF-00FV2G-8g; Wed, 15 Jun 2022 16:50:51 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1WEC-00FV0z-UZ for linux-arm-kernel@lists.infradead.org; Wed, 15 Jun 2022 16:50:50 +0000 Received: by mail-pf1-x42a.google.com with SMTP id u2so11970355pfc.2 for ; Wed, 15 Jun 2022 09:50:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=l2m/p73ZOkmp2a0YRPGNyi0Tat7B8/y1fh71Z6pBMwY=; b=YBWUvDApGb3GYnHlIiCV4O1q440hLN8wqIqgUuSo5ef5MmW5hjWkqWj8bYXlj2rEgj UgFqBOGCMGAlIjWigVNrs0SBsxQS3huTo+lxR638XpsoQLuzcoJcyeP3D8D5+dqm1UNP QiyYXt2aZ7ntYCEfQI0q3a+Jx3vZhAR7iNMQYaoJIOraDhxYbkMZtmpaArUJ6BZbEn0c 0jKMe6OCq00Foby+aMbwJkR3H8aFjRALp9ghu0SrOATI1Jxo0KNp6P5LgrUgLrzXwjNb 0HpROOfbnlqRDrF+bzVKydyrtgKzEVNniGK+7qeN5btcYTli7sK+756TjuQ6UrPWDxYW uX8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=l2m/p73ZOkmp2a0YRPGNyi0Tat7B8/y1fh71Z6pBMwY=; b=eDaK7IRIDqiCRS0mhYTMPpB58hActL9obi3ep/A5yj4hrjhLNK2B+AxBwzODl/2fwy 38/LQXKpGJIi2A3ZY9Quw0sbnDTTke6vo/5+JhngUBksNIOcReE+ECbEq2KyTDReyQfn B4tvIp1+Z0oaHu1fVr/s5y6rHLL7VlV8swaBP/T/cNdTsWyZVGm1eAYVkhLdRp9KHtnJ rknI2/O03+C2kYgknbBmbTpQenIwRYgaNMu2DdgVIrpMYXbrt5jIQUOkBpQg4pNwsK9Y UW7gKmGNKeSPfURC7uB/kPgEw7SWTiyENCwHmidHzkLg38gFEAvOwvcv7L12CenUo4/2 wkqg== X-Gm-Message-State: AJIora+cYruQZE3pq6ieQNAGBqtvQcsDjv59te0OHTU4/7h38W6Js3Wp /XKCUHMB+ZJKQzKw74TIS0JXIg== X-Google-Smtp-Source: AGRyM1uoSjlVr9r3uO9BNvQ5R9nzewnVd1E0rD6Im8y+8Q8eBfT5Er5Uf5pMlAuOEc7xBMyqG+f8cw== X-Received: by 2002:a05:6a00:244a:b0:4fa:ebf9:75de with SMTP id d10-20020a056a00244a00b004faebf975demr359273pfj.73.1655311843886; Wed, 15 Jun 2022 09:50:43 -0700 (PDT) Received: from google.com ([2620:15c:201:2:eaa0:bc6e:4256:1385]) by smtp.gmail.com with ESMTPSA id l1-20020a17090a72c100b001e834d799casm2039748pjk.55.2022.06.15.09.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 09:50:43 -0700 (PDT) Date: Wed, 15 Jun 2022 09:50:36 -0700 From: Sami Tolvanen To: Ard Biesheuvel Cc: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, maz@kernel.org, Kees Cook , Fangrui Song , Nick Desaulniers , Dan Li Subject: Re: [PATCH v3 1/3] arm64: unwind: add asynchronous unwind tables to kernel and modules Message-ID: References: <20220613134008.3760481-1-ardb@kernel.org> <20220613134008.3760481-2-ardb@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220613134008.3760481-2-ardb@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220615_095049_028220_3CDCB13E X-CRM114-Status: GOOD ( 24.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 13, 2022 at 03:40:06PM +0200, Ard Biesheuvel wrote: > Enable asynchronous unwind table generation for both the core kernel as > well as modules, and emit the resulting .eh_frame sections as init code > so we can use the unwind directives for code patching at boot or module > load time. > > This will be used by dynamic shadow call stack support, which will rely > on code patching rather than compiler codegen to emit the shadow call > stack push and pop instructions. > > Signed-off-by: Ard Biesheuvel > Reviewed-by: Nick Desaulniers > --- > arch/arm64/Kconfig | 3 +++ > arch/arm64/Makefile | 5 +++++ > arch/arm64/include/asm/module.lds.h | 8 ++++++++ > arch/arm64/kernel/vmlinux.lds.S | 13 +++++++++++++ > arch/arm64/kvm/hyp/nvhe/Makefile | 1 + > drivers/firmware/efi/libstub/Makefile | 1 + > 6 files changed, 31 insertions(+) > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index 1652a9800ebe..5f92344edff5 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -366,6 +366,9 @@ config KASAN_SHADOW_OFFSET > default 0xeffffff800000000 if ARM64_VA_BITS_36 && KASAN_SW_TAGS > default 0xffffffffffffffff > > +config UNWIND_TABLES > + bool > + > source "arch/arm64/Kconfig.platforms" > > menu "Kernel Features" > diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile > index 6d9d4a58b898..4fbca56fa602 100644 > --- a/arch/arm64/Makefile > +++ b/arch/arm64/Makefile > @@ -45,8 +45,13 @@ KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) > KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) > > # Avoid generating .eh_frame* sections. > +ifneq ($(CONFIG_UNWIND_TABLES),y) > KBUILD_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables > KBUILD_AFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables > +else > +KBUILD_CFLAGS += -fasynchronous-unwind-tables > +KBUILD_AFLAGS += -fasynchronous-unwind-tables > +endif > > ifeq ($(CONFIG_STACKPROTECTOR_PER_TASK),y) > prepare: stack_protector_prepare > diff --git a/arch/arm64/include/asm/module.lds.h b/arch/arm64/include/asm/module.lds.h > index 094701ec5500..dbba4b7559aa 100644 > --- a/arch/arm64/include/asm/module.lds.h > +++ b/arch/arm64/include/asm/module.lds.h > @@ -17,4 +17,12 @@ SECTIONS { > */ > .text.hot : { *(.text.hot) } > #endif > + > +#ifdef CONFIG_UNWIND_TABLES > + /* > + * Currently, we only use unwind info at module load time, so we can > + * put it into the .init allocation. > + */ > + .init.eh_frame : { *(.eh_frame) } > +#endif > } > diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S > index 2d4a8f995175..7bf4809f523d 100644 > --- a/arch/arm64/kernel/vmlinux.lds.S > +++ b/arch/arm64/kernel/vmlinux.lds.S > @@ -120,6 +120,17 @@ jiffies = jiffies_64; > #define TRAMP_TEXT > #endif > > +#ifdef CONFIG_UNWIND_TABLES > +#define UNWIND_DATA_SECTIONS \ > + .eh_frame : { \ > + __eh_frame_start = .; \ > + *(.eh_frame) \ > + __eh_frame_end = .; \ > + } > +#else > +#define UNWIND_DATA_SECTIONS > +#endif How does this work with SANITIZER_DISCARDS dropping .eh_frame in include/asm-generic/vmlinux.lds.h and scripts/module.lds.S? We would definitely want to enable this together with CONFIG_CFI_CLANG, so it seems like we'd have to drop the discard rules as well. Sami _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel