From patchwork Tue Oct 15 15:50:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 11190849 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 470161390 for ; Tue, 15 Oct 2019 15:51:50 +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 E8AA320854 for ; Tue, 15 Oct 2019 15:51:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SlaDMoaQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8AA320854 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rp0fY18/xtVcxQdAUxGQZMrACSD1JYDx5aC8RvHRNTs=; b=SlaDMoaQnBLPjO svskcFHn6q86lKYwN2bDZXGbAqinxeEaLzx+CUxV+HqZZF6omtUcP8Z1OSLA1AanCifL5WhDRlNU0 FKwdaYJH4cuIPCfSWpswaACuiJG7InplqlP5Xzq/E9FgCv+0wB1FNeMEOiqH6TG8RlWNuijaMVuUs rYIcOphFeA2S3LLtglsWgXQskkb93iMxa3bPkWCaRdFTEzMEmrxXtbCAdLDdnf0XEUbh9ePK3LOnP /tGJZiUsVZAOoBJd44UPCoh/KnK0yZ1d1g3jBwIqc7X1C01zTmHF8/uoHIN3imlbeaLdICf4BY4OX U8rvPQ6ab3k8xOUdy2xg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iKP6z-000429-4y; Tue, 15 Oct 2019 15:51:49 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iKP5b-0002pl-23 for linux-arm-kernel@lists.infradead.org; Tue, 15 Oct 2019 15:50:26 +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 231B21650; Tue, 15 Oct 2019 08:50:22 -0700 (PDT) Received: from e110467-lin.cambridge.arm.com (e110467-lin.cambridge.arm.com [10.1.197.57]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 71C953F68E; Tue, 15 Oct 2019 08:50:21 -0700 (PDT) From: Robin Murphy To: will@kernel.org, catalin.marinas@arm.com Subject: [PATCH 8/8] arm64: Tidy up _asm_extable_faultaddr usage Date: Tue, 15 Oct 2019 16:50:03 +0100 Message-Id: X-Mailer: git-send-email 2.21.0.dirty In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191015_085023_250000_714EE5FC X-CRM114-Status: GOOD ( 11.93 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sam.tebbs@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org To match the way the USER() shorthand wraps _asm_extable entries, introduce USER_F() to wrap _asm_extable_faultaddr and clean up a bit. Signed-off-by: Robin Murphy --- arch/arm64/include/asm/assembler.h | 4 ++ arch/arm64/lib/copy_from_user.S | 36 +++++---------- arch/arm64/lib/copy_in_user.S | 72 ++++++++++-------------------- arch/arm64/lib/copy_to_user.S | 33 +++++--------- 4 files changed, 51 insertions(+), 94 deletions(-) diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index 02bb156cbf0e..959f6fa493ef 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -155,6 +155,10 @@ alternative_endif 9999: x; \ _asm_extable 9999b, l +#define USER_F(l, x...) \ +9999: x; \ + _asm_extable_faultaddr 9999b, l + /* * Register aliases. */ diff --git a/arch/arm64/lib/copy_from_user.S b/arch/arm64/lib/copy_from_user.S index 8928c38d8c76..d0bcfad5dafd 100644 --- a/arch/arm64/lib/copy_from_user.S +++ b/arch/arm64/lib/copy_from_user.S @@ -21,8 +21,7 @@ */ .macro ldrb1 reg, ptr, offset=0 - 8888: ldtrb \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, ldtrb \reg, [\ptr, \offset]) .endm .macro strb1 reg, ptr, offset=0 @@ -31,9 +30,8 @@ .macro ldrb1_reg reg, ptr, offset add \ptr, \ptr, \offset - 8888: ldtrb \reg, [\ptr] + USER_F(9998f, ldtrb \reg, [\ptr]) sub \ptr, \ptr, \offset - _asm_extable_faultaddr 8888b,9998f; .endm .macro strb1_reg reg, ptr, offset @@ -41,8 +39,7 @@ .endm .macro ldr1 reg, ptr, offset=0 - 8888: ldtr \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, ldtr \reg, [\ptr, \offset]) .endm .macro str1 reg, ptr, offset=0 @@ -50,10 +47,8 @@ .endm .macro ldp1 regA, regB, ptr, offset=0 - 8888: ldtr \regA, [\ptr, \offset] - 8889: ldtr \regB, [\ptr, \offset + 8] - _asm_extable_faultaddr 8888b,9998f; - _asm_extable_faultaddr 8889b,9998f; + USER_F(9998f, ldtr \regA, [\ptr, \offset]) + USER_F(9998f, ldtr \regB, [\ptr, \offset + 8]) .endm .macro stp1 regA, regB, ptr, offset=0 @@ -61,11 +56,9 @@ .endm .macro ldp1_pre regA, regB, ptr, offset - 8888: ldtr \regA, [\ptr, \offset] - 8889: ldtr \regB, [\ptr, \offset + 8] + USER_F(9998f, ldtr \regA, [\ptr, \offset]) + USER_F(9998f, ldtr \regB, [\ptr, \offset + 8]) add \ptr, \ptr, \offset - _asm_extable_faultaddr 8888b,9998f; - _asm_extable_faultaddr 8889b,9998f; .endm .macro stp1_pre regA, regB, ptr, offset @@ -73,8 +66,7 @@ .endm .macro ldrb1_nuao reg, ptr, offset=0 - 8888: ldrb \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, ldrb \reg, [\ptr, \offset]) .endm .macro strb1_nuao reg, ptr, offset=0 @@ -82,8 +74,7 @@ .endm .macro ldrb1_nuao_reg reg, ptr, offset=0 - 8888: ldrb \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, ldrb \reg, [\ptr, \offset]) .endm .macro strb1_nuao_reg reg, ptr, offset=0 @@ -91,8 +82,7 @@ .endm .macro ldr1_nuao reg, ptr, offset=0 - 8888: ldr \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, ldr \reg, [\ptr, \offset]) .endm .macro str1_nuao reg, ptr, offset=0 @@ -100,8 +90,7 @@ .endm .macro ldp1_nuao regA, regB, ptr, offset=0 - 8888: ldp \regA, \regB, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, ldp \regA, \regB, [\ptr, \offset]) .endm .macro stp1_nuao regA, regB, ptr, offset=0 @@ -109,8 +98,7 @@ .endm .macro ldp1_pre_nuao regA, regB, ptr, offset - 8888: ldp \regA, \regB, [\ptr, \offset]! - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, ldp \regA, \regB, [\ptr, \offset]!) .endm .macro stp1_pre_nuao regA, regB, ptr, offset diff --git a/arch/arm64/lib/copy_in_user.S b/arch/arm64/lib/copy_in_user.S index 2aecdc300c8d..25fdedc6eed8 100644 --- a/arch/arm64/lib/copy_in_user.S +++ b/arch/arm64/lib/copy_in_user.S @@ -23,117 +23,93 @@ */ .macro ldrb1 reg, ptr, offset=0 - 8888: ldtrb \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, ldtrb \reg, [\ptr, \offset]) .endm .macro strb1 reg, ptr, offset=0 - 8888: sttrb \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, sttrb \reg, [\ptr, \offset]) .endm .macro ldrb1_reg reg, ptr, offset add \ptr, \ptr, \offset - 8888: ldtrb \reg, [\ptr] + USER_F(9998f, ldtrb \reg, [\ptr]) sub \ptr, \ptr, \offset - _asm_extable_faultaddr 8888b,9998f; .endm .macro strb1_reg reg, ptr, offset add \ptr, \ptr, \offset - 8888: sttrb \reg, [\ptr] + USER_F(9998f, sttrb \reg, [\ptr]) sub \ptr, \ptr, \offset - _asm_extable_faultaddr 8888b,9998f; .endm .macro ldr1 reg, ptr, offset=0 - 8888: ldtr \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, ldtr \reg, [\ptr, \offset]) .endm .macro str1 reg, ptr, offset=0 - 8888: sttr \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, sttr \reg, [\ptr, \offset]) .endm .macro ldp1 regA, regB, ptr, offset=0 - 8888: ldtr \regA, [\ptr, \offset] - 8889: ldtr \regB, [\ptr, \offset + 8] - _asm_extable_faultaddr 8888b,9998f; - _asm_extable_faultaddr 8889b,9998f; + USER_F(9998f, ldtr \regA, [\ptr, \offset]) + USER_F(9998f, ldtr \regB, [\ptr, \offset + 8]) .endm .macro stp1 regA, regB, ptr, offset=0 - 8888: sttr \regA, [\ptr, \offset] - 8889: sttr \regB, [\ptr, \offset + 8] - _asm_extable_faultaddr 8888b,9998f; - _asm_extable_faultaddr 8889b,9998f; + USER_F(9998f, sttr \regA, [\ptr, \offset]) + USER_F(9998f, sttr \regB, [\ptr, \offset + 8]) .endm .macro ldp1_pre regA, regB, ptr, offset - 8888: ldtr \regA, [\ptr, \offset] - 8889: ldtr \regB, [\ptr, \offset + 8] + USER_F(9998f, ldtr \regA, [\ptr, \offset]) + USER_F(9998f, ldtr \regB, [\ptr, \offset + 8]) add \ptr, \ptr, \offset - _asm_extable_faultaddr 8888b,9998f; - _asm_extable_faultaddr 8889b,9998f; .endm .macro stp1_pre regA, regB, ptr, offset - 8888: sttr \regA, [\ptr, \offset] - 8889: sttr \regB, [\ptr, \offset + 8] + USER_F(9998f, sttr \regA, [\ptr, \offset]) + USER_F(9998f, sttr \regB, [\ptr, \offset + 8]) add \ptr, \ptr, \offset - _asm_extable_faultaddr 8888b,9998f; - _asm_extable_faultaddr 8889b,9998f; .endm .macro ldrb1_nuao reg, ptr, offset=0 - 8888: ldrb \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, ldrb \reg, [\ptr, \offset]) .endm .macro strb1_nuao reg, ptr, offset=0 - 8888: strb \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, strb \reg, [\ptr, \offset]) .endm .macro ldrb1_nuao_reg reg, ptr, offset=0 - 8888: ldrb \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, ldrb \reg, [\ptr, \offset]) .endm .macro strb1_nuao_reg reg, ptr, offset=0 - 8888: strb \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, strb \reg, [\ptr, \offset]) .endm .macro ldr1_nuao reg, ptr, offset=0 - 8888: ldr \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, ldr \reg, [\ptr, \offset]) .endm .macro str1_nuao reg, ptr, offset=0 - 8888: str \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, str \reg, [\ptr, \offset]) .endm .macro ldp1_nuao regA, regB, ptr, offset=0 - 8888: ldp \regA, \regB, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, ldp \regA, \regB, [\ptr, \offset]) .endm .macro stp1_nuao regA, regB, ptr, offset=0 - 8888: stp \regA, \regB, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, stp \regA, \regB, [\ptr, \offset]) .endm .macro ldp1_pre_nuao regA, regB, ptr, offset - 8888: ldp \regA, \regB, [\ptr, \offset]! - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, ldp \regA, \regB, [\ptr, \offset]!) .endm .macro stp1_pre_nuao regA, regB, ptr, offset - 8888: stp \regA, \regB, [\ptr, \offset]! - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, stp \regA, \regB, [\ptr, \offset]!) .endm .macro copy_exit diff --git a/arch/arm64/lib/copy_to_user.S b/arch/arm64/lib/copy_to_user.S index d49db097bc31..744c57460619 100644 --- a/arch/arm64/lib/copy_to_user.S +++ b/arch/arm64/lib/copy_to_user.S @@ -25,8 +25,7 @@ .endm .macro strb1 reg, ptr, offset=0 - 8888: sttrb \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, sttrb \reg, [\ptr, \offset]) .endm .macro ldrb1_reg reg, ptr, offset @@ -35,9 +34,8 @@ .macro strb1_reg reg, ptr, offset add \ptr, \ptr, \offset - 8888: sttrb \reg, [\ptr] + USER_F(9998f, sttrb \reg, [\ptr]) sub \ptr, \ptr, \offset - _asm_extable_faultaddr 8888b,9998f; .endm .macro ldr1 reg, ptr, offset=0 @@ -45,8 +43,7 @@ .endm .macro str1 reg, ptr, offset=0 - 8888: sttr \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, sttr \reg, [\ptr, \offset]) .endm .macro ldp1 regA, regB, ptr, offset=0 @@ -54,10 +51,8 @@ .endm .macro stp1 regA, regB, ptr, offset=0 - 8888: sttr \regA, [\ptr, \offset] - 8889: sttr \regB, [\ptr, \offset + 8] - _asm_extable_faultaddr 8888b,9998f; - _asm_extable_faultaddr 8889b,9998f; + USER_F(9998f, sttr \regA, [\ptr, \offset]) + USER_F(9998f, sttr \regB, [\ptr, \offset + 8]) .endm .macro ldp1_pre regA, regB, ptr, offset @@ -65,11 +60,9 @@ .endm .macro stp1_pre regA, regB, ptr, offset - 8888: sttr \regA, [\ptr, \offset] - 8889: sttr \regB, [\ptr, \offset + 8] + USER_F(9998f, sttr \regA, [\ptr, \offset]) + USER_F(9998f, sttr \regB, [\ptr, \offset + 8]) add \ptr, \ptr, \offset - _asm_extable_faultaddr 8888b,9998f; - _asm_extable_faultaddr 8889b,9998f; .endm .macro ldrb1_nuao reg, ptr, offset=0 @@ -77,8 +70,7 @@ .endm .macro strb1_nuao reg, ptr, offset=0 - 8888: strb \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, strb \reg, [\ptr, \offset]) .endm .macro ldrb1_nuao_reg reg, ptr, offset=0 @@ -94,8 +86,7 @@ .endm .macro str1_nuao reg, ptr, offset=0 - 8888: str \reg, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, str \reg, [\ptr, \offset]) .endm .macro ldp1_nuao regA, regB, ptr, offset=0 @@ -107,13 +98,11 @@ .endm .macro stp1_nuao regA, regB, ptr, offset=0 - 8888: stp \regA, \regB, [\ptr, \offset] - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, stp \regA, \regB, [\ptr, \offset]) .endm .macro stp1_pre_nuao regA, regB, ptr, offset - 8888: stp \regA, \regB, [\ptr, \offset]! - _asm_extable_faultaddr 8888b,9998f; + USER_F(9998f, stp \regA, \regB, [\ptr, \offset]!) .endm .macro copy_exit