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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38888C433EF for ; Tue, 19 Oct 2021 11:51:51 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 00E85610C7 for ; Tue, 19 Oct 2021 11:51:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 00E85610C7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=cFcj5/aQ/a+n1U1LPDt08wtOrgCFvVUPeNUnJfvoVQU=; b=da6oPWbZj2ijwj MV7Mb/fbDSaobYPcW2kRUGLbcNpvXVmmShkhRsCvtivfKBkXQQOGRnLxU7sG2eAYGPWL6Voxx+YI/ WzZFXTZ41OJM+/emzLO9EGcl2AFpvhE9mdfqJv2fYme3qiEriMwjFpiBfymBWJa693pXVFxPLKmOS sojrFfo2YfcP4WpH376zopfHzut3l4tN3Ag6PWoQt7wdrKTz5+B3nrq1fmbHE+RpKLqyJXeRoR+E2 cm7+mSh5TqBd83lFejWHLrtpldAjZiIWvjGsAPa/pM4+UIsUjMnkJasZ5enC22tXXbciE7gbb2gLB UYd0l7sa2wjJY2qteHVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcndb-0010YV-8A; Tue, 19 Oct 2021 11:50:35 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcndX-0010Xp-JH for linux-arm-kernel@lists.infradead.org; Tue, 19 Oct 2021 11:50:33 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 08975D6E; Tue, 19 Oct 2021 04:50:27 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E65503F70D; Tue, 19 Oct 2021 04:50:24 -0700 (PDT) Date: Tue, 19 Oct 2021 12:50:22 +0100 From: Mark Rutland To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, alexandru.elisei@arm.com, andrii@kernel.org, ardb@kernel.org, ast@kernel.org, broonie@kernel.org, catalin.marinas@arm.com, daniel@iogearbox.net, dvyukov@google.com, james.morse@arm.com, jean-philippe@linaro.org, jpoimboe@redhat.com, maz@kernel.org, peterz@infradead.org, robin.murphy@arm.com, suzuki.poulose@arm.com Subject: Re: [PATCH 10/13] arm64: extable: add `type` and `data` fields Message-ID: <20211019115022.GB941@lakrids.cambridge.arm.com> References: <20211013110059.10324-1-mark.rutland@arm.com> <20211013110059.10324-11-mark.rutland@arm.com> <20211019112954.GG13251@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211019112954.GG13251@willie-the-truck> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211019_045031_801727_4E1DACCB X-CRM114-Status: GOOD ( 35.90 ) 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 Tue, Oct 19, 2021 at 12:29:55PM +0100, Will Deacon wrote: > On Wed, Oct 13, 2021 at 12:00:56PM +0100, Mark Rutland wrote: > > Subsequent patches will add specialized handlers for fixups, in addition > > to the simple PC fixup and BPF handlers we have today. In preparation, > > this patch adds a new `type` field to struct exception_table_entry, and > > uses this to distinguish the fixup and BPF cases. A `data` field is also > > added so that subsequent patches can associate data specific to each > > exception site (e.g. register numbers). > > > > Handlers are named ex_handler_*() for consistency, following the exmaple > > of x86. At the same time, get_ex_fixup() is split out into a helper so > > that it can be used by other ex_handler_*() functions ins subsequent > > patches. > > > > This patch will increase the size of the exception tables, which will be > > remedied by subsequent patches removing redundant fixup code. There > > should be no functional change as a result of this patch. > > > > Signed-off-by: Mark Rutland > > Cc: Alexei Starovoitov > > Cc: Andrii Nakryiko > > Cc: Ard Biesheuvel > > Cc: Catalin Marinas > > Cc: Daniel Borkmann > > Cc: James Morse > > Cc: Jean-Philippe Brucker > > Cc: Robin Murphy > > Cc: Will Deacon > > --- > > arch/arm64/include/asm/asm-extable.h | 32 ++++++++++++++++++++------------ > > arch/arm64/include/asm/extable.h | 19 +++++++++++++++---- > > arch/arm64/mm/extable.c | 29 +++++++++++++++++++++++++---- > > arch/arm64/net/bpf_jit_comp.c | 7 +++++-- > > scripts/sorttable.c | 30 ++++++++++++++++++++++++++++++ > > 5 files changed, 95 insertions(+), 22 deletions(-) > > > > diff --git a/arch/arm64/include/asm/asm-extable.h b/arch/arm64/include/asm/asm-extable.h > > index 986b4c0d4792..5ee748edaef1 100644 > > --- a/arch/arm64/include/asm/asm-extable.h > > +++ b/arch/arm64/include/asm/asm-extable.h > > @@ -2,13 +2,19 @@ > > #ifndef __ASM_ASM_EXTABLE_H > > #define __ASM_ASM_EXTABLE_H > > > > +#define EX_TYPE_NONE 0 > > +#define EX_TYPE_FIXUP 1 > > +#define EX_TYPE_BPF 2 > > + > > #ifdef __ASSEMBLY__ > > > > -#define __ASM_EXTABLE_RAW(insn, fixup) \ > > - .pushsection __ex_table, "a"; \ > > - .align 3; \ > > - .long ((insn) - .); \ > > - .long ((fixup) - .); \ > > +#define __ASM_EXTABLE_RAW(insn, fixup, type, data) \ > > + .pushsection __ex_table, "a"; \ > > + .align 2; \ > > + .long ((insn) - .); \ > > + .long ((fixup) - .); \ > > + .short (type); \ > > + .short (data); \ > > Why are you reducing the alignment here? That's because the size of each entry is now 12 bytes, and `.align 3` aligns to 8 bytes, which would leave a gap between entries. We only require the fields are naturally aligned, so `.align 2` is sufficient, and doesn't waste space. I'll update the commit message to call that out. > > diff --git a/scripts/sorttable.c b/scripts/sorttable.c > > index 6ee4fa882919..ee95bb47a50d 100644 > > --- a/scripts/sorttable.c > > +++ b/scripts/sorttable.c > > @@ -231,6 +231,34 @@ static void sort_relative_table(char *extab_image, int image_size) > > } > > } > > > > +static void arm64_sort_relative_table(char *extab_image, int image_size) > > +{ > > + int i = 0; > > + > > + while (i < image_size) { > > + uint32_t *loc = (uint32_t *)(extab_image + i); > > + > > + w(r(loc) + i, loc); > > + w(r(loc + 1) + i + 4, loc + 1); > > + /* Don't touch the fixup type or data */ > > + > > + i += sizeof(uint32_t) * 3; > > + } > > + > > + qsort(extab_image, image_size / 12, 12, compare_relative_table); > > + > > + i = 0; > > + while (i < image_size) { > > + uint32_t *loc = (uint32_t *)(extab_image + i); > > + > > + w(r(loc) - i, loc); > > + w(r(loc + 1) - (i + 4), loc + 1); > > + /* Don't touch the fixup type or data */ > > + > > + i += sizeof(uint32_t) * 3; > > + } > > +} > > This is very nearly a direct copy of x86_sort_relative_table() (magic > numbers and all). It would be nice to tidy that up, but I couldn't > immediately see a good way to do it :( Beware that's true in linux-next, but not mainline, as that changes in commit: 46d28947d9876fc0 ("x86/extable: Rework the exception table mechanics") A patch to unify the two is trivial, but will cause a cross-tree dependency, so I'd suggest having this separate for now and sending a unification patch come -rc1. I can note something to that effect in the commit message, if that helps? Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel