From patchwork Mon May 14 09:46:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135702 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1531174lji; Mon, 14 May 2018 02:47:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqmtTiLaeqqx2TdvsYNgytuywyr3k17/LLHqPQE8WAYKrse1EZfy30Ont+IVZmtFaWaphnr X-Received: by 2002:a63:63c5:: with SMTP id x188-v6mr7625995pgb.302.1526291227301; Mon, 14 May 2018 02:47:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291227; cv=none; d=google.com; s=arc-20160816; b=AN5y8Jy5ppaE/poTyFlLnmw5xijd50u0SPgnrs+FKDEQMr+fSLhCYADvUYgebDgm8n S3hYoqirIegi9wUgo7uG5t7corA0lnDcBM5TyOy4qsdQQt4DWS4ciSdv/ZmKadHHpOa8 I8ejPQEMOZlRjLzZsH/6/demkDfa9ek1zwOTopEDU+Zu9fw5Ev6wfHA3DC/4mh4X7cIq idcr2+Z7m8FIak6qcF9mz0jiwSy7RpKLjxoQrSBE3bpFcBeljLv5PvydSABLrGfSbhBs vzjL+qqLE9H1iC8vRGnY2FAq4f4tyQ4XsBEQ450b6a4FK48PgtVtRto6/BSMUdtlLjsr NXSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=YYF9jMCAkVuL6dk/nVVwbR6X2N/SqfZb6VgRkE5GRgo=; b=Fn71y4pbCowu5bOSDOcP0OjCyENH7l5PTMT/9bKKCfGnEWLl8NRPfEn6HwgSLL3u5X dPrfvrlaKtMufgxY68XQglSwOZfakSfKEu8f2zXDehJMqOA2E6rfUczVDaq1NnOHL77S FdpC7++EmfoTOMPGR3DFY+2e7JLI3T+R99vvhrizSbFNM4WTn0GfoyKysnQ8G6J2fmI1 GFVDZBX+dmqyTrYrClB5IfwfHQQzcAMy1Ob3Y+dORXn116I3ONqGxcrmx+5kxJr9cuFS D80Gc8+fOEXfi+7NvJTaJuQUz3yxIIU3S0gh2ipxb9nrroMvzy0uDn34IDb9QeD+2fyA Y67w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ba9-v6si9346936plb.110.2018.05.14.02.47.06; Mon, 14 May 2018 02:47:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752178AbeENJrF (ORCPT + 29 others); Mon, 14 May 2018 05:47:05 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38186 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752021AbeENJrC (ORCPT ); Mon, 14 May 2018 05:47:02 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 20D7915AB; Mon, 14 May 2018 02:47:02 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2AF973F25D; Mon, 14 May 2018 02:47:00 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 01/18] arm64: consistently use unsigned long for thread flags Date: Mon, 14 May 2018 10:46:23 +0100 Message-Id: <20180514094640.27569-2-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In do_notify_resume, we manipulate thread_flags as a 32-bit unsigned int, whereas thread_info::flags is a 64-bit unsigned long, and elsewhere (e.g. in the entry assembly) we manipulate the flags as a 64-bit quantity. For consistency, and to avoid problems if we end up with more than 32 flags, let's make do_notify_resume take the flags as a 64-bit unsigned long. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 Reviewed-by: Dave Martin diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 154b7d30145d..8e624fec4707 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -896,7 +896,7 @@ static void do_signal(struct pt_regs *regs) } asmlinkage void do_notify_resume(struct pt_regs *regs, - unsigned int thread_flags) + unsigned long thread_flags) { /* * The assembly code enters us with IRQs off, but it hasn't From patchwork Mon May 14 09:46:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135703 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1531352lji; Mon, 14 May 2018 02:47:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrnhM7VCec53VlzTqOH8Cs6cZJ8xaDRf79OnDFXXHJEpfgLHq7NwvOHLSzuDATWGp1hll4O X-Received: by 2002:a17:902:14cb:: with SMTP id y11-v6mr8948858plg.229.1526291238768; Mon, 14 May 2018 02:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291238; cv=none; d=google.com; s=arc-20160816; b=jn0leCQAK2sgPkUJJbbJeuEz4lAfbVZpgxm2fj1oMjqt2CGmAzC0SNwOCzaK7ay3YZ fA3R+bcOETQxh2HyhiN1V5ytho/uTDsX/HBcdqFYYWBW191ivG8NeMAFKzWWAFe0Vphr prQTWGmLOzN6LlDrF5i4aNuJAzFQj1P+3pCk86j47GvjYeKxrN3+hDFT+fQDwdXIi0p/ i/3j2r5sLw1LUVHluEgBDplTEkxRX6JHwcte+SOxY8WnVRS3tbkA64NUGK+GCzjvAPiS LWBr2mr+AMfM/3ciXtX353CqWnsQdRw3TJ9e7Q55wbuhoslWOHG8NgNIu8D2LXBd2Mth z8HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=S/BtI+vFnbNkUeV2dn+BUNh+xhM1JE/AKSCA9TJ8X+o=; b=U7Tf736gJkXMkmO6kwq5iDUsFa9n0NAhzUbU66goAT3mahAqRclzB59b4QuMhLi7Ag X5uAcVBI6/Jl5aMUpwwqfrdjeil6SWzFBdtKmYRti0JyLIoCE3EiuuhatrbsWIgYecOs oRfqIzeih0Ultcf8ScG7O0BEPAgrg5AQuiM0+gSD/WEk87ymFyXSnIbMulPw8T2GDZwU UJ7j8ZSlHRoqZ0oA6vb3tO/4R77p86LMtZT5cNd/uWej1yzzgHci/+fzyca8Jaw41PgZ MCH8gHhZDYJfX1H0getfEG9jumGTDht81r3Ge5xjDrF3igoCvsPEBfJzuU6+HIjPCAHD gVPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g34-v6si9002906pld.411.2018.05.14.02.47.18; Mon, 14 May 2018 02:47:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752228AbeENJrQ (ORCPT + 29 others); Mon, 14 May 2018 05:47:16 -0400 Received: from foss.arm.com ([217.140.101.70]:38192 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752021AbeENJrO (ORCPT ); Mon, 14 May 2018 05:47:14 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 04A9715AD; Mon, 14 May 2018 02:47:14 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1770F3F25D; Mon, 14 May 2018 02:47:11 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 02/18] arm64: move SCTLR_EL{1, 2} assertions to Date: Mon, 14 May 2018 10:46:24 +0100 Message-Id: <20180514094640.27569-3-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently we assert that the SCTLR_EL{1,2}_{SET,CLEAR} bits are self-consistent with an assertion in config_sctlr_el1(). This is a bit unusual, since config_sctlr_el1() doesn't make use of these definitions, and is far away from the definitions themselves. We can use the CPP #error directive to have equivalent assertions in , next to the definitions of the set/clear bits, which is a bit clearer and simpler. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: James Morse Cc: Will Deacon --- arch/arm64/include/asm/sysreg.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) -- 2.11.0 Reviewed-by: Dave Martin diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index 6171178075dc..bd1d1194a5e7 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -452,9 +452,9 @@ SCTLR_ELx_SA | SCTLR_ELx_I | SCTLR_ELx_WXN | \ ENDIAN_CLEAR_EL2 | SCTLR_EL2_RES0) -/* Check all the bits are accounted for */ -#define SCTLR_EL2_BUILD_BUG_ON_MISSING_BITS BUILD_BUG_ON((SCTLR_EL2_SET ^ SCTLR_EL2_CLEAR) != ~0) - +#if (SCTLR_EL2_SET ^ SCTLR_EL2_CLEAR) != 0xffffffff +#error "Inconsistent SCTLR_EL2 set/clear bits" +#endif /* SCTLR_EL1 specific flags. */ #define SCTLR_EL1_UCI (1 << 26) @@ -492,8 +492,9 @@ SCTLR_EL1_UMA | SCTLR_ELx_WXN | ENDIAN_CLEAR_EL1 |\ SCTLR_EL1_RES0) -/* Check all the bits are accounted for */ -#define SCTLR_EL1_BUILD_BUG_ON_MISSING_BITS BUILD_BUG_ON((SCTLR_EL1_SET ^ SCTLR_EL1_CLEAR) != ~0) +#if (SCTLR_EL1_SET ^ SCTLR_EL1_CLEAR) != 0xffffffff +#error "Inconsistent SCTLR_EL1 set/clear bits" +#endif /* id_aa64isar0 */ #define ID_AA64ISAR0_TS_SHIFT 52 @@ -732,9 +733,6 @@ static inline void config_sctlr_el1(u32 clear, u32 set) { u32 val; - SCTLR_EL2_BUILD_BUG_ON_MISSING_BITS; - SCTLR_EL1_BUILD_BUG_ON_MISSING_BITS; - val = read_sysreg(sctlr_el1); val &= ~clear; val |= set; From patchwork Mon May 14 09:46:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135704 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1531593lji; Mon, 14 May 2018 02:47:33 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoMMWROCi9wtM4b4jslmv+2gu+VUZ3o/TCSvEuxla7m0NZ+8kCQxmlBFq6fyRFuq0v6uRK8 X-Received: by 2002:a62:5c06:: with SMTP id q6-v6mr9768691pfb.118.1526291253386; Mon, 14 May 2018 02:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291253; cv=none; d=google.com; s=arc-20160816; b=ztma2A1ZL2oLNHyp+JopxRqVKSyNIffcNnFQGVZy4NaZk8lFdY5jrDCZTdLlrcERZT JZy1xYi0J1PLMUzR9ilJPRzv/O7r7E0TJamk9X+dClcFNzgMHmjvzJBL6jI44GA4k1PV hxBTJMKH597oSeiAaTZU2DR0H+QVTvOb66BaH0T5Av5qc/cZn81j2ywRK2zTFcatdaTk MXGIKX0ZofZlvIy5CmPDQk/9id3jIlCV4bNvEmpqTivmsUiRxmCE8cwKk4AJg6WtnvOk a5dMdUw77qKSuiQsLxPul0L7NTVC3I44jjKtk+8truJWuGusHr7tqfjndM7gDPXoaAxs RwGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=uUL9hPQnpzX+XoPRbc6B0UKrDi6Pa+rhnQYp0fEF+wE=; b=kg/Bh2DgxDpjLAHknghZzzVKuZftDU3CabyRB3VIscHN2iNzbHMh4JHuxCvdHTJwmt bMSxWEuGBzznr01+FgY3xfbfB/h357ACjGk04hEOK0MB+/AXyrPhKeCEGTvVJk9y+OMn X195lWYm/7Yfe7PVmJJgrjMiMlQ1c77k1aFIrdWuCmRVq2no+337MDLMhzd4gQSknz8r 9ImPyhCVo3Sqy0+UWk1/f1avJ4apmEMoDmFoRamagaYzkh1x7C7toCJAJ+ILzx6Peuza N4PF+EoLHCeKPSG6YfJYyaU3IOJ6Nx+PlIEcht5MO/niQTYKr1A6dI/wwhA/AcnrO7ci OvWw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g34-v6si9002906pld.411.2018.05.14.02.47.33; Mon, 14 May 2018 02:47:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752384AbeENJra (ORCPT + 29 others); Mon, 14 May 2018 05:47:30 -0400 Received: from foss.arm.com ([217.140.101.70]:38208 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752292AbeENJr3 (ORCPT ); Mon, 14 May 2018 05:47:29 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3E43E1435; Mon, 14 May 2018 02:47:29 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 500953F25D; Mon, 14 May 2018 02:47:27 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 03/18] arm64: introduce sysreg_clear_set() Date: Mon, 14 May 2018 10:46:25 +0100 Message-Id: <20180514094640.27569-4-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently we have a couple of helpers to manipulate bits in particular sysregs: * config_sctlr_el1(u32 clear, u32 set) * change_cpacr(u64 val, u64 mask) The parameters of these differ in naming convention, order, and size, which is unfortunate. They also differ slightly in behaviour, as change_cpacr() skips the sysreg write if the bits are unchanged, which is a useful optimization when sysreg writes are expensive. Before we gain more yet another sysreg manipulation function, let's unify these with a common helper, providing a consistent order for clear/set operands, and the write skipping behaviour from change_cpacr(). Code will be migrated to the new helper in subsequent patches. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Dave Martin Cc: Marc Zyngier --- arch/arm64/include/asm/sysreg.h | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.11.0 Reviewed-by: Dave Martin diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index bd1d1194a5e7..b52762769329 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -729,6 +729,17 @@ asm( asm volatile("msr_s " __stringify(r) ", %x0" : : "rZ" (__val)); \ } while (0) +/* + * Modify bits in a sysreg. Bits in the clear mask are zeroed, then bits in the + * set mask are set. Other bits are left as-is. + */ +#define sysreg_clear_set(sysreg, clear, set) do { \ + u64 __scs_val = read_sysreg(sysreg); \ + u64 __scs_new = (__scs_val & ~(u64)(clear)) | (set); \ + if (__scs_new != __scs_val) \ + write_sysreg(__scs_new, sysreg); \ +} while (0) + static inline void config_sctlr_el1(u32 clear, u32 set) { u32 val; From patchwork Mon May 14 09:46:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135705 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1531690lji; Mon, 14 May 2018 02:47:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrzDslk7erSqpMpUSatqWNepJleSHMxA7JfymVIaif5rQw8n8OnyyPPwJvzJGvyi6EL+uz1 X-Received: by 2002:a65:4c8d:: with SMTP id m13-v6mr2634964pgt.310.1526291259249; Mon, 14 May 2018 02:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291259; cv=none; d=google.com; s=arc-20160816; b=jmKrBcB/Hjl07kThgsj74mwplgQDkCPCp+Px+tL6Tt5o/97kDLiX+o/OP8Gsw69PUT OXPFaaKs4Hk9aYRDXTRGAxAXN5rrdEVnYbp5KFP0Ui+UE+XMgDO4SAqIbT0ngsNqjV+S y4LmaRksjtZYLbbDIXF5N0h36HyF9FzV2vYfQidyovMvAe658HXDcRdHuTtHWnxdfD5q CUNSOFdG70UHHP9fJ7wfPkBd+PM9pvuLUVdzKkbEebRY9PCpyhUrxGPINHQly5NICA4b OrQyjQDmja+NELRyJxaV2a0zVFlcBwAjHbx7bZQmxNrIWgB3QvRbI9gPAwyFy8LUDhof sYPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=2sWG/TkZ+46qU5IjnUoaBwSi+QzqSY7Tn1bQsQIsXb8=; b=GQ+HHLlXaco2aB6LbA7MNx6QEIvvndbvlLwbLb8HxCoXLjZNbRewSpI1BOReMrc7Jf zzJsNaBK2cvGRj5uqDI0wr1PjvZhU5rsJGxkLYysvzLmRPJdcVGc972E2MHYd+4cw6gT bj+sP3OwCiWJw7gOkcOvvgFzHfUkVV19E8QJRV7fRFO7YjYnOtk73wJvbnSSwWhZUG3W akUK5YrB24j0Gqn5ede8UCacVduT+9PiLkg7c7EHwvsDYn8EFDD53BZE1ol46eEWn9I2 qeb3pRXazjVSjFiYRw5LWzlqC+fiS4/ebhfKL0ds+xGx1+hbwN4i87m/UAQ3PfudoCN8 LC/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c21-v6si8853617plo.51.2018.05.14.02.47.38; Mon, 14 May 2018 02:47:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752446AbeENJrf (ORCPT + 29 others); Mon, 14 May 2018 05:47:35 -0400 Received: from foss.arm.com ([217.140.101.70]:38228 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752292AbeENJrc (ORCPT ); Mon, 14 May 2018 05:47:32 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 620CB1650; Mon, 14 May 2018 02:47:32 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 752E33F25D; Mon, 14 May 2018 02:47:30 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 04/18] arm64: kill config_sctlr_el1() Date: Mon, 14 May 2018 10:46:26 +0100 Message-Id: <20180514094640.27569-5-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we have sysreg_clear_set(), we can consistently use this instead of config_sctlr_el1(). Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: James Morse Cc: Will Deacon --- arch/arm64/include/asm/sysreg.h | 10 ---------- arch/arm64/kernel/armv8_deprecated.c | 8 ++++---- arch/arm64/kernel/cpu_errata.c | 3 +-- arch/arm64/kernel/traps.c | 2 +- arch/arm64/mm/fault.c | 2 +- 5 files changed, 7 insertions(+), 18 deletions(-) -- 2.11.0 Reviewed-by: Dave Martin diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index b52762769329..3493c7048994 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -740,16 +740,6 @@ asm( write_sysreg(__scs_new, sysreg); \ } while (0) -static inline void config_sctlr_el1(u32 clear, u32 set) -{ - u32 val; - - val = read_sysreg(sctlr_el1); - val &= ~clear; - val |= set; - write_sysreg(val, sctlr_el1); -} - #endif #endif /* __ASM_SYSREG_H */ diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c index 6e47fc3ab549..778cf810f0d8 100644 --- a/arch/arm64/kernel/armv8_deprecated.c +++ b/arch/arm64/kernel/armv8_deprecated.c @@ -512,9 +512,9 @@ static int cp15barrier_handler(struct pt_regs *regs, u32 instr) static int cp15_barrier_set_hw_mode(bool enable) { if (enable) - config_sctlr_el1(0, SCTLR_EL1_CP15BEN); + sysreg_clear_set(sctlr_el1, 0, SCTLR_EL1_CP15BEN); else - config_sctlr_el1(SCTLR_EL1_CP15BEN, 0); + sysreg_clear_set(sctlr_el1, SCTLR_EL1_CP15BEN, 0); return 0; } @@ -549,9 +549,9 @@ static int setend_set_hw_mode(bool enable) return -EINVAL; if (enable) - config_sctlr_el1(SCTLR_EL1_SED, 0); + sysreg_clear_set(sctlr_el1, SCTLR_EL1_SED, 0); else - config_sctlr_el1(0, SCTLR_EL1_SED); + sysreg_clear_set(sctlr_el1, 0, SCTLR_EL1_SED); return 0; } diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index a900befadfe8..879daf8ea0f8 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -74,8 +74,7 @@ has_mismatched_cache_line_size(const struct arm64_cpu_capabilities *entry, static void cpu_enable_trap_ctr_access(const struct arm64_cpu_capabilities *__unused) { - /* Clear SCTLR_EL1.UCT */ - config_sctlr_el1(SCTLR_EL1_UCT, 0); + sysreg_clear_set(sctlr_el1, SCTLR_EL1_UCT, 0); } atomic_t arm64_el2_vector_last_slot = ATOMIC_INIT(-1); diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 8bbdc17e49df..b8d3e0d8c616 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -411,7 +411,7 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs) void cpu_enable_cache_maint_trap(const struct arm64_cpu_capabilities *__unused) { - config_sctlr_el1(SCTLR_EL1_UCI, 0); + sysreg_clear_set(sctlr_el1, SCTLR_EL1_UCI, 0); } #define __user_cache_maint(insn, address, res) \ diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 4165485e8b6e..e7977d932038 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -812,7 +812,7 @@ void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused) */ WARN_ON_ONCE(in_interrupt()); - config_sctlr_el1(SCTLR_EL1_SPAN, 0); + sysreg_clear_set(sctlr_el1, SCTLR_EL1_SPAN, 0); asm(SET_PSTATE_PAN(1)); } #endif /* CONFIG_ARM64_PAN */ From patchwork Mon May 14 09:46:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135719 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1535893lji; Mon, 14 May 2018 02:52:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpQ+MHfzM3gCuEETt//p5/EUU0R7bCRN2ccVBdsUgYHBAV72L1hQH6kelmmX3P5m4NzGw0x X-Received: by 2002:a62:d717:: with SMTP id b23-v6mr9668601pfh.5.1526291522992; Mon, 14 May 2018 02:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291522; cv=none; d=google.com; s=arc-20160816; b=c0+Qd+TP67JQ8AyyQ5RtXRmXNZgzTOSKHH3Lu6iCIsdOrPGLAeLNzoyMixn+ZmokJf LTw4ThKKjEK9t9XOAwQvCPIRh74qVQY9gJkWIiT/vGHKXBf4JPiDPZ3rOWTT8vFmsaEE 66rIXaC3BXgU6JUXF8Rvo+CSrWcJVXkQPNSoDrIIlAEVBOxSKsLzV3Ko/KYrOYJcE2RC c2DjtGbO/I3WK4SuOzrowaRMKkJwRzVQHfgTRWJb/EPj+ne0ktuk1FkJLYEvDkWWzoi/ t1VXwQQoyTTgL6DyRrsc5R2BS4ySv8GUc2J2r0/7Jx0Q8qOU2JWCxzDIPI71H0dsamZr zVPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=RUreloWr4aBLuOGap5agex0r819D384koFElTjTf+vU=; b=h+87+Gbi8DZcZE9FtK0vqKrcajj8JOCZ/IYwGdx3HEWlq9c/b4+HFmiKE7bkFPLXsv ciAOP9MWXLXHCkuWtH3I8Ajo8R7FAqNLL0VXwf3UkvNW2KRvXYbSijyS5BgFT5XMxKZU x2OYdgClGK93Vw8vCMoYrY0ilBKPkyeaiV7Wi+kuU/VJNtqpkYcmG/tTHVe+HsHC4aWb k+l4+HEXuAKRKLnzWQ8QTDxml4c3Q01HYqZP3VdA2isEyCmAl9oZDZXJTdJ4w/0+bfFp cxf9PQ6rOM2prvGoLkl4N7bJ4vJz+Niul5Os/4aBgv1QDWcZQnOf+76Qabcsoq6Em5ro uALw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34-v6si9076344plp.409.2018.05.14.02.52.02; Mon, 14 May 2018 02:52:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752728AbeENJwA (ORCPT + 29 others); Mon, 14 May 2018 05:52:00 -0400 Received: from foss.arm.com ([217.140.101.70]:38240 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752411AbeENJrf (ORCPT ); Mon, 14 May 2018 05:47:35 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1201F15AB; Mon, 14 May 2018 02:47:35 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 251703F25D; Mon, 14 May 2018 02:47:33 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 05/18] arm64: kill change_cpacr() Date: Mon, 14 May 2018 10:46:27 +0100 Message-Id: <20180514094640.27569-6-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we have sysreg_clear_set(), we can use this instead of change_cpacr(). Note that the order of the set and clear arguments differs between change_cpacr() and sysreg_clear_set(), so these are flipped as part of the conversion. Also, sve_user_enable() redundantly clears CPACR_EL1_ZEN_EL0EN before setting it; this is removed for clarity. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Dave Martin Cc: James Morse Cc: Will Deacon --- arch/arm64/kernel/fpsimd.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) -- 2.11.0 Reviewed-by: Dave Martin diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index 87a35364e750..088940387a4d 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -172,23 +172,14 @@ static void *sve_pffr(struct task_struct *task) sve_ffr_offset(task->thread.sve_vl); } -static void change_cpacr(u64 val, u64 mask) -{ - u64 cpacr = read_sysreg(CPACR_EL1); - u64 new = (cpacr & ~mask) | val; - - if (new != cpacr) - write_sysreg(new, CPACR_EL1); -} - static void sve_user_disable(void) { - change_cpacr(0, CPACR_EL1_ZEN_EL0EN); + sysreg_clear_set(cpacr_el1, CPACR_EL1_ZEN_EL0EN, 0); } static void sve_user_enable(void) { - change_cpacr(CPACR_EL1_ZEN_EL0EN, CPACR_EL1_ZEN_EL0EN); + sysreg_clear_set(cpacr_el1, 0, CPACR_EL1_ZEN_EL0EN); } /* From patchwork Mon May 14 09:46:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135706 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1531766lji; Mon, 14 May 2018 02:47:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrXkGsYh1vZmevBZcsU9J3hdEso9t35lyZj8fZdKZromeuwqXo2irRtasEsrhtCiB+6o664 X-Received: by 2002:a63:735c:: with SMTP id d28-v6mr7748737pgn.436.1526291263485; Mon, 14 May 2018 02:47:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291263; cv=none; d=google.com; s=arc-20160816; b=GNQVSk23UB8d01mhjhCQAYy+czDZnftKyaC/5jOj/F3kd4I+KBIZWJZnHCZj0fNZgE VFJM7iyWv/wHhARgKQcA9auTpheao3Y4kKs1ETxFBH8PaVT3b7SUOGSgqd+InEjl7V/n 0/ZPUUq45wC3uEIaLE15TL9GGyUSza8mOsksOk1pMH2km/OCYdEg3lGPngn2qEIdmhT9 X0DSXNB3Et1/GMEK96iMD2aTgB2HRzV6hDny91wj20o1Muv4BJdEmRZSdFgtcZlgjT+A PC0K2jf5oLCSIRhdHNdUTlw/vjhycLMpLEpNTr4cMhnBRYf6fL4c+BMGCksyIBrZBYS6 wwOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=DXIOJ8agrKiQcaGEMTPiCAVxjhWTylKsW0oiOKdLXRQ=; b=01epeCKawzWxe7s+UP5AhGRC7E7Uy4ygG3GL1A/8luc7gXikvDSRWDNA81bGT/GToV SNGwCOBmeipON0bdkmR2duRdewNF1pIcT1StR6nkXBWMbhDZpML1sA3ECrJlvNbiOaHh d1JoJ9tQNT4vtMr8kDWMVnO4INc1QvnPepz9icwg96WgIhkH8jJ1h8aYg6mhZ8xj8kbd aNCOY03OzzfhYBHizFg/HaJZVydFI5XkQQkJn1zHeC1cYEKaGRiGLrfTHPsXcf5O3JZb SIM1a/ChP+JL3LHFSQ3kzIgqZH8QoP6JzJSe4/Gk3kf5GHHqXRbKfkC5LAWXCtc+ZFTa J+BQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c21-v6si8853617plo.51.2018.05.14.02.47.43; Mon, 14 May 2018 02:47:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752488AbeENJrk (ORCPT + 29 others); Mon, 14 May 2018 05:47:40 -0400 Received: from foss.arm.com ([217.140.101.70]:38254 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751219AbeENJrh (ORCPT ); Mon, 14 May 2018 05:47:37 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A68CD1684; Mon, 14 May 2018 02:47:37 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B98963F25D; Mon, 14 May 2018 02:47:35 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 06/18] arm64: move sve_user_{enable, disable} to Date: Mon, 14 May 2018 10:46:28 +0100 Message-Id: <20180514094640.27569-7-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In subsequent patches, we'll want to make use of sve_user_enable() and sve_user_disable() outside of kernel/fpsimd.c. Let's move these to where we can make use of them. To avoid ifdeffery in sequences like: if (system_supports_sve() && some_condition sve_user_disable(); ... empty stubs are provided when support for SVE is not enabled. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Dave Martin Cc: Will Deacon --- arch/arm64/include/asm/fpsimd.h | 17 ++++++++++++++++- arch/arm64/kernel/fpsimd.c | 11 ----------- 2 files changed, 16 insertions(+), 12 deletions(-) -- 2.11.0 diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h index aa7162ae93e3..7377d7593c06 100644 --- a/arch/arm64/include/asm/fpsimd.h +++ b/arch/arm64/include/asm/fpsimd.h @@ -16,11 +16,13 @@ #ifndef __ASM_FP_H #define __ASM_FP_H -#include #include +#include +#include #ifndef __ASSEMBLY__ +#include #include #include #include @@ -81,6 +83,16 @@ extern int sve_set_vector_length(struct task_struct *task, extern int sve_set_current_vl(unsigned long arg); extern int sve_get_current_vl(void); +static inline void sve_user_disable(void) +{ + sysreg_clear_set(cpacr_el1, CPACR_EL1_ZEN_EL0EN, 0); +} + +static inline void sve_user_enable(void) +{ + sysreg_clear_set(cpacr_el1, 0, CPACR_EL1_ZEN_EL0EN); +} + /* * Probing and setup functions. * Calls to these functions must be serialised with one another. @@ -107,6 +119,9 @@ static inline int sve_get_current_vl(void) return -EINVAL; } +static inline void sve_user_disable(void) { } +static inline void sve_user_enable(void) { } + static inline void sve_init_vq_map(void) { } static inline void sve_update_vq_map(void) { } static inline int sve_verify_vq_map(void) { return 0; } diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index 088940387a4d..79a81c7d85c6 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -159,7 +159,6 @@ static void sve_free(struct task_struct *task) __sve_free(task); } - /* Offset of FFR in the SVE register dump */ static size_t sve_ffr_offset(int vl) { @@ -172,16 +171,6 @@ static void *sve_pffr(struct task_struct *task) sve_ffr_offset(task->thread.sve_vl); } -static void sve_user_disable(void) -{ - sysreg_clear_set(cpacr_el1, CPACR_EL1_ZEN_EL0EN, 0); -} - -static void sve_user_enable(void) -{ - sysreg_clear_set(cpacr_el1, 0, CPACR_EL1_ZEN_EL0EN); -} - /* * TIF_SVE controls whether a task can use SVE without trapping while * in userspace, and also the way a task's FPSIMD/SVE state is stored From patchwork Mon May 14 09:46:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135707 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1531840lji; Mon, 14 May 2018 02:47:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrf0dCPvWmSup+q3/2Hg60+49v8exBbcaodnCYcD5PQQMJ+ro+169KdqwBn/gyRw4srGThm X-Received: by 2002:a17:902:145:: with SMTP id 63-v6mr9235310plb.332.1526291268317; Mon, 14 May 2018 02:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291268; cv=none; d=google.com; s=arc-20160816; b=yAsmniGVO0g4JRzYDxcQe68pqASMIvWQ5NHzh8TvUkAuaOivXyKoLQs0jbk4c3jJ48 irH/n386I40gxmFE5rmoKHA6fugUNKcmQ5NYqlJYE0mJEegJ+xMgrpy2cCZALihK8Z+l To2QKx3kmBvTkI5U91dr4DmnuSJC3lt5As3mKT8++oo2Fp/wFO4Bfo3JW0OYG5mRDcrb X/DojMEjghs7oG7VkV66YsOuRDW/3ujwAn8CB7Lz8RnB3SwSUWAkvl1x55yQQ3WboUbY JODiVRYdBVQ3Rk0l25OZPyb/DGYLMCFbfz9jxQIiFU15DFZ3PTynPnV5r1ZtyYZg0nPy NPQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=wA9AO/3Aa5kSlfWEzZWGCD3vEn+qGJNbv1Kix1Xqug0=; b=ealij9oVIHrKynGaw+sVLSxHZsLFLVuA81VnsvwwIyDyBt+PzwN4i46WRuZC2F/pnb Tol6uFMHvyAJ+PlxRjZ5dIFn32I30ZRV3Z9hhf+d8jppsJB8PuIvPU4rTAjA2dIH3V0C VL6cdhoYVbb709TJF9qppqhI90iAqkwl3p1pcTJyPOpAqXrXQmY/F2bGI1OTexj4bKqD BQ7/T7c6h05vSV6EukSm0yqBY4efcUpfhO+ZH3Gg1p7YdqhsReGsvF77yPmRjHv6R5et lKSQwDXKr57CoMPZLut/s+S4UrA1+OVxyzd0ZJvSG+zmFs1ZN1chucHU0TRP/4bIaBut 3tfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8-v6si2141964pgs.441.2018.05.14.02.47.47; Mon, 14 May 2018 02:47:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751498AbeENJrm (ORCPT + 29 others); Mon, 14 May 2018 05:47:42 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38264 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752497AbeENJrk (ORCPT ); Mon, 14 May 2018 05:47:40 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4B56F169F; Mon, 14 May 2018 02:47:40 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5DAB93F25D; Mon, 14 May 2018 02:47:38 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 07/18] arm64: remove sigreturn wrappers Date: Mon, 14 May 2018 10:46:29 +0100 Message-Id: <20180514094640.27569-8-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The arm64 sigreturn* syscall handlers are non-standard. Rather than taking a number of user parameters in registers as per the AAPCS, they expect the pt_regs as their sole argument. To make this work, we override the syscall definitions to invoke wrappers written in assembly, which mov the SP into x0, and branch to their respective C functions. On other architectures (such as x86), the sigreturn* functions take no argument and instead use current_pt_regs() to acquire the user registers. This requires less boilerplate code, and allows for other features such as interposing C code in this path. This patch takes the same approach for arm64. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/include/asm/unistd32.h | 4 ++-- arch/arm64/kernel/entry.S | 8 -------- arch/arm64/kernel/entry32.S | 10 ---------- arch/arm64/kernel/signal.c | 3 ++- arch/arm64/kernel/signal32.c | 6 ++++-- arch/arm64/kernel/sys.c | 3 +-- arch/arm64/kernel/sys32.c | 4 ++-- 7 files changed, 11 insertions(+), 27 deletions(-) -- 2.11.0 diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h index ef292160748c..ab95554b1734 100644 --- a/arch/arm64/include/asm/unistd32.h +++ b/arch/arm64/include/asm/unistd32.h @@ -260,7 +260,7 @@ __SYSCALL(117, sys_ni_syscall) #define __NR_fsync 118 __SYSCALL(__NR_fsync, sys_fsync) #define __NR_sigreturn 119 -__SYSCALL(__NR_sigreturn, compat_sys_sigreturn_wrapper) +__SYSCALL(__NR_sigreturn, compat_sys_sigreturn) #define __NR_clone 120 __SYSCALL(__NR_clone, sys_clone) #define __NR_setdomainname 121 @@ -368,7 +368,7 @@ __SYSCALL(__NR_getresgid, sys_getresgid16) #define __NR_prctl 172 __SYSCALL(__NR_prctl, sys_prctl) #define __NR_rt_sigreturn 173 -__SYSCALL(__NR_rt_sigreturn, compat_sys_rt_sigreturn_wrapper) +__SYSCALL(__NR_rt_sigreturn, compat_sys_rt_sigreturn) #define __NR_rt_sigaction 174 __SYSCALL(__NR_rt_sigaction, compat_sys_rt_sigaction) #define __NR_rt_sigprocmask 175 diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index ec2ee720e33e..08ea3cbfb08f 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -1108,14 +1108,6 @@ __entry_tramp_data_start: #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ /* - * Special system call wrappers. - */ -ENTRY(sys_rt_sigreturn_wrapper) - mov x0, sp - b sys_rt_sigreturn -ENDPROC(sys_rt_sigreturn_wrapper) - -/* * Register switch for AArch64. The callee-saved registers need to be saved * and restored. On entry: * x0 = previous task_struct (must be preserved across the switch) diff --git a/arch/arm64/kernel/entry32.S b/arch/arm64/kernel/entry32.S index f332d5d1f6b4..f9461696dde4 100644 --- a/arch/arm64/kernel/entry32.S +++ b/arch/arm64/kernel/entry32.S @@ -30,16 +30,6 @@ * System call wrappers for the AArch32 compatibility layer. */ -ENTRY(compat_sys_sigreturn_wrapper) - mov x0, sp - b compat_sys_sigreturn -ENDPROC(compat_sys_sigreturn_wrapper) - -ENTRY(compat_sys_rt_sigreturn_wrapper) - mov x0, sp - b compat_sys_rt_sigreturn -ENDPROC(compat_sys_rt_sigreturn_wrapper) - ENTRY(compat_sys_statfs64_wrapper) mov w3, #84 cmp w1, #88 diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 8e624fec4707..caa7a68cf2d2 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -538,8 +538,9 @@ static int restore_sigframe(struct pt_regs *regs, return err; } -asmlinkage long sys_rt_sigreturn(struct pt_regs *regs) +asmlinkage long sys_rt_sigreturn(void) { + struct pt_regs *regs = current_pt_regs(); struct rt_sigframe __user *frame; /* Always make any pending restarted system calls return -EINTR */ diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c index 77b91f478995..cb10588a7cb2 100644 --- a/arch/arm64/kernel/signal32.c +++ b/arch/arm64/kernel/signal32.c @@ -282,8 +282,9 @@ static int compat_restore_sigframe(struct pt_regs *regs, return err; } -asmlinkage int compat_sys_sigreturn(struct pt_regs *regs) +asmlinkage int compat_sys_sigreturn(void) { + struct pt_regs *regs = current_pt_regs(); struct compat_sigframe __user *frame; /* Always make any pending restarted system calls return -EINTR */ @@ -312,8 +313,9 @@ asmlinkage int compat_sys_sigreturn(struct pt_regs *regs) return 0; } -asmlinkage int compat_sys_rt_sigreturn(struct pt_regs *regs) +asmlinkage int compat_sys_rt_sigreturn(void) { + struct pt_regs *regs = current_pt_regs(); struct compat_rt_sigframe __user *frame; /* Always make any pending restarted system calls return -EINTR */ diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c index 72981bae10eb..31045f3fed92 100644 --- a/arch/arm64/kernel/sys.c +++ b/arch/arm64/kernel/sys.c @@ -48,8 +48,7 @@ SYSCALL_DEFINE1(arm64_personality, unsigned int, personality) /* * Wrappers to pass the pt_regs argument. */ -asmlinkage long sys_rt_sigreturn_wrapper(void); -#define sys_rt_sigreturn sys_rt_sigreturn_wrapper +asmlinkage long sys_rt_sigreturn(void); #define sys_personality sys_arm64_personality #undef __SYSCALL diff --git a/arch/arm64/kernel/sys32.c b/arch/arm64/kernel/sys32.c index a40b1343b819..1ef103c95410 100644 --- a/arch/arm64/kernel/sys32.c +++ b/arch/arm64/kernel/sys32.c @@ -25,8 +25,8 @@ #include #include -asmlinkage long compat_sys_sigreturn_wrapper(void); -asmlinkage long compat_sys_rt_sigreturn_wrapper(void); +asmlinkage long compat_sys_sigreturn(void); +asmlinkage long compat_sys_rt_sigreturn(void); asmlinkage long compat_sys_statfs64_wrapper(void); asmlinkage long compat_sys_fstatfs64_wrapper(void); asmlinkage long compat_sys_pread64_wrapper(void); From patchwork Mon May 14 09:46:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135709 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1531943lji; Mon, 14 May 2018 02:47:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpbXJSXh9X1eYerp+awuRmOHfe10Hx0YTVaIHFoj/Dm48QipfaSe6VnA7wL3lKU35AFMk9G X-Received: by 2002:a63:31d8:: with SMTP id x207-v6mr7880575pgx.411.1526291274817; Mon, 14 May 2018 02:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291274; cv=none; d=google.com; s=arc-20160816; b=AbDtOyFxGDguUVTfSQXhqpMZ2jYQ+dCziMGdMSFtsCJmuip4zYFMY/BTqzgY2qJreW dhBYlkYSJzfDMCKs8xuRWxyokMrrDQ3awvE1i9Zp8bEq2YyPniuaI60beGEjr7D3Zl/Y Yg0KZ+zB938T//yke6pe7lFCVl5rMXLpYEHHLHtEyt2cXzSf8Nvz5uTw72opszBeMglQ /Vi6+ccqOekPmvv76pojdgDX9ijk2T858GGXxi/s0uzbhpg1HhpUml9YRsDbQjiNLg3x Fh/tLpZaColMerJCAQcEZ84PsSBdAL4eXdOYdyJZMn7nfzrOKA+jI/akcxQ1mC7JYj/6 IYmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=QCov34juBddASdErHCCaxzhnxHe5fa0+h2vSPlFhJEQ=; b=h0gynG5+/NT56JRLIvFGe9jg7BsqCo92RKFDJ2GRTtoy4//V9bEGW0qUeyTFZ+AfWS zMF6S0FMIdPgFkVkjfpE/rq9BsHgYxjc5OgCdvSVAA1C6ngIAtNCk1vqK1NfAbRbdj5f BA5uqjI+3UEHZkQAzwzwHvJO1LmsHj8bQLICu+MXmpZ3HbRtSc53w2hFGYOQgekOs2Py 9r2thrucRY/sSMHG2c2q2oJOSUV6kk4mwxTvGSOlxCpo5BOVFZwyECkv5GwXOV+QQEAf 2wihx3qBN1ORV7SeZjRYI4u5jt2SdGtHgMsArvbCA2L3ELebT819g1Vk3ZJ+fIK8GhB/ PpoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9-v6si7498080pgw.394.2018.05.14.02.47.54; Mon, 14 May 2018 02:47:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752579AbeENJrs (ORCPT + 29 others); Mon, 14 May 2018 05:47:48 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38276 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752497AbeENJrn (ORCPT ); Mon, 14 May 2018 05:47:43 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DB4E0168F; Mon, 14 May 2018 02:47:42 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EE3463F25D; Mon, 14 May 2018 02:47:40 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 08/18] arm64: convert raw syscall invocation to C Date: Mon, 14 May 2018 10:46:30 +0100 Message-Id: <20180514094640.27569-9-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As a first step towards invoking syscalls with a pt_regs argument, convert the raw syscall invocation logic to C. We end up with a bit more register shuffling, but the unified invocation logic means we can unify the tracing paths, too. This only converts the invocation of the syscall. The rest of the syscall triage and tracing is left in assembly for now, and will be converted in subsequent patches. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/Makefile | 3 ++- arch/arm64/kernel/entry.S | 36 ++++++++++-------------------------- arch/arm64/kernel/syscall.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 27 deletions(-) create mode 100644 arch/arm64/kernel/syscall.c -- 2.11.0 diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index bf825f38d206..c22e8ace5ea3 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -18,7 +18,8 @@ arm64-obj-y := debug-monitors.o entry.o irq.o fpsimd.o \ hyp-stub.o psci.o cpu_ops.o insn.o \ return_address.o cpuinfo.o cpu_errata.o \ cpufeature.o alternative.o cacheinfo.o \ - smp.o smp_spin_table.o topology.o smccc-call.o + smp.o smp_spin_table.o topology.o smccc-call.o \ + syscall.o extra-$(CONFIG_EFI) := efi-entry.o diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 08ea3cbfb08f..d6e057500eaf 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -873,7 +873,6 @@ ENDPROC(el0_error) */ ret_fast_syscall: disable_daif - str x0, [sp, #S_X0] // returned x0 ldr x1, [tsk, #TSK_TI_FLAGS] // re-check for syscall tracing and x2, x1, #_TIF_SYSCALL_WORK cbnz x2, ret_fast_syscall_trace @@ -946,15 +945,11 @@ el0_svc_naked: // compat entry point tst x16, #_TIF_SYSCALL_WORK // check for syscall hooks b.ne __sys_trace - cmp wscno, wsc_nr // check upper syscall limit - b.hs ni_sys - mask_nospec64 xscno, xsc_nr, x19 // enforce bounds for syscall number - ldr x16, [stbl, xscno, lsl #3] // address in the syscall table - blr x16 // call sys_* routine - b ret_fast_syscall -ni_sys: mov x0, sp - bl do_ni_syscall + mov w1, wscno + mov w2, wsc_nr + mov x3, stbl + bl invoke_syscall b ret_fast_syscall ENDPROC(el0_svc) @@ -971,29 +966,18 @@ __sys_trace: bl syscall_trace_enter cmp w0, #NO_SYSCALL // skip the syscall? b.eq __sys_trace_return_skipped - mov wscno, w0 // syscall number (possibly new) - mov x1, sp // pointer to regs - cmp wscno, wsc_nr // check upper syscall limit - b.hs __ni_sys_trace - ldp x0, x1, [sp] // restore the syscall args - ldp x2, x3, [sp, #S_X2] - ldp x4, x5, [sp, #S_X4] - ldp x6, x7, [sp, #S_X6] - ldr x16, [stbl, xscno, lsl #3] // address in the syscall table - blr x16 // call sys_* routine -__sys_trace_return: - str x0, [sp, #S_X0] // save returned x0 + mov x0, sp + mov w1, wscno + mov w2, wsc_nr + mov x3, stbl + bl invoke_syscall + __sys_trace_return_skipped: mov x0, sp bl syscall_trace_exit b ret_to_user -__ni_sys_trace: - mov x0, sp - bl do_ni_syscall - b __sys_trace_return - .popsection // .entry.text #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c new file mode 100644 index 000000000000..58d7569f47df --- /dev/null +++ b/arch/arm64/kernel/syscall.c @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include + +long do_ni_syscall(struct pt_regs *regs); + +typedef long (*syscall_fn_t)(unsigned long, unsigned long, + unsigned long, unsigned long, + unsigned long, unsigned long); + +static void __invoke_syscall(struct pt_regs *regs, syscall_fn_t syscall_fn) +{ + regs->regs[0] = syscall_fn(regs->regs[0], regs->regs[1], + regs->regs[2], regs->regs[3], + regs->regs[4], regs->regs[5]); +} + +asmlinkage void invoke_syscall(struct pt_regs *regs, int scno, int sc_nr, + syscall_fn_t syscall_table[]) +{ + if (scno < sc_nr) { + syscall_fn_t syscall_fn; + syscall_fn = syscall_table[array_index_nospec(scno, sc_nr)]; + __invoke_syscall(regs, syscall_fn); + } else { + regs->regs[0] = do_ni_syscall(regs); + } +} From patchwork Mon May 14 09:46:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135718 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1535233lji; Mon, 14 May 2018 02:51:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpttLWMMK9EO0DZibWVFffB+ecEDMmEKR73vHcfb1h/ARly3Rte5YD4Zxx4BnC7SG1pLOnG X-Received: by 2002:a17:902:8308:: with SMTP id bd8-v6mr4530139plb.195.1526291483774; Mon, 14 May 2018 02:51:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291483; cv=none; d=google.com; s=arc-20160816; b=YrayNa8cOJKAiy2vjaGlyHEUpT/HowaWkRyi3LEdgx1sbma4IgqwYhBo/qoMpmoDxH yKSd5uBDBOFffQiEXsGTXrdT+qXgw28QXq2ti8LO2p5EwKrw+d4HbOP5zsTynS4dhBaG HgQdBZBtBnLqIZk/HdXzNnsScA8er6j3ONz9OUHdGY01AMiCzLkiLpXRm4iMZiVS8EfG MWBtLbi8GHX5NPWMlYB/iiV2VT8eVg3QjNnUxoWK9jtSwysb9JUz6kUvnOZyX9nlmV1l I1ygYszSCTRi7P4Ht0QLIe7tG1JszExyf/7G8ilGnId6MU3Rbk/O1Blkvu/KQ4GXAxxQ o7Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=CKEP7v0rtC9Bph/8/ynLmj/1DNV2upqBtveLaiCC7Es=; b=UtPKTMVwvTV6mL6z3zl+EiObIVYNL/GpaHQQDGklZYCes5qGurrphJqbEOL5OWArj3 RcUICPd9BOmeWxVxoVDBuUXr7zcS7vbSc9c5YZuGcM3H1CrzvOPxIv827JulgQg+2Okg gwizR6Ksz5Vig1Sz7Bs/aSRHDJyBl8daYdQi9qAMFB0QTstNv2ckxImKQ2HXmB3NsGgY 3qKNsPkOrndifhBqf2WZoF+HX8FxyFrwjYGcnucGWyhMebWKYsUOKs1jJI+jtR4tBIoE mx3Fx79HUSjUuh39VfO4qg0HlrA6aOfbVBLfkI95UUG2I9vQjEqLWU118fAEwQq20Ceg zH8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34-v6si9076344plp.409.2018.05.14.02.51.23; Mon, 14 May 2018 02:51:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752291AbeENJvU (ORCPT + 29 others); Mon, 14 May 2018 05:51:20 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38286 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752556AbeENJrq (ORCPT ); Mon, 14 May 2018 05:47:46 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7759D16A0; Mon, 14 May 2018 02:47:45 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8A96E3F25D; Mon, 14 May 2018 02:47:43 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 09/18] arm64: convert syscall trace logic to C Date: Mon, 14 May 2018 10:46:31 +0100 Message-Id: <20180514094640.27569-10-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently syscall tracing is a tricky assembly state machine, which can be rather difficult to follow, and even harder to modify. Before we start fiddling with it for pt_regs syscalls, let's convert it to C. This is not intended to have any functional change. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/entry.S | 53 ++---------------------------------------- arch/arm64/kernel/syscall.c | 56 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 53 deletions(-) -- 2.11.0 diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index d6e057500eaf..5c60369b52fc 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -866,24 +866,6 @@ el0_error_naked: b ret_to_user ENDPROC(el0_error) - -/* - * This is the fast syscall return path. We do as little as possible here, - * and this includes saving x0 back into the kernel stack. - */ -ret_fast_syscall: - disable_daif - ldr x1, [tsk, #TSK_TI_FLAGS] // re-check for syscall tracing - and x2, x1, #_TIF_SYSCALL_WORK - cbnz x2, ret_fast_syscall_trace - and x2, x1, #_TIF_WORK_MASK - cbnz x2, work_pending - enable_step_tsk x1, x2 - kernel_exit 0 -ret_fast_syscall_trace: - enable_daif - b __sys_trace_return_skipped // we already saved x0 - /* * Ok, we need to do extra processing, enter the slow path. */ @@ -939,44 +921,13 @@ alternative_else_nop_endif #endif el0_svc_naked: // compat entry point - stp x0, xscno, [sp, #S_ORIG_X0] // save the original x0 and syscall number - enable_daif - ct_user_exit 1 - - tst x16, #_TIF_SYSCALL_WORK // check for syscall hooks - b.ne __sys_trace mov x0, sp mov w1, wscno mov w2, wsc_nr mov x3, stbl - bl invoke_syscall - b ret_fast_syscall -ENDPROC(el0_svc) - - /* - * This is the really slow path. We're going to be doing context - * switches, and waiting for our parent to respond. - */ -__sys_trace: - cmp wscno, #NO_SYSCALL // user-issued syscall(-1)? - b.ne 1f - mov x0, #-ENOSYS // set default errno if so - str x0, [sp, #S_X0] -1: mov x0, sp - bl syscall_trace_enter - cmp w0, #NO_SYSCALL // skip the syscall? - b.eq __sys_trace_return_skipped - - mov x0, sp - mov w1, wscno - mov w2, wsc_nr - mov x3, stbl - bl invoke_syscall - -__sys_trace_return_skipped: - mov x0, sp - bl syscall_trace_exit + bl el0_svc_common b ret_to_user +ENDPROC(el0_svc) .popsection // .entry.text diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 58d7569f47df..5df857e32b48 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -1,8 +1,13 @@ // SPDX-License-Identifier: GPL-2.0 +#include +#include #include #include +#include +#include + long do_ni_syscall(struct pt_regs *regs); typedef long (*syscall_fn_t)(unsigned long, unsigned long, @@ -16,8 +21,8 @@ static void __invoke_syscall(struct pt_regs *regs, syscall_fn_t syscall_fn) regs->regs[4], regs->regs[5]); } -asmlinkage void invoke_syscall(struct pt_regs *regs, int scno, int sc_nr, - syscall_fn_t syscall_table[]) +static void invoke_syscall(struct pt_regs *regs, int scno, int sc_nr, + syscall_fn_t syscall_table[]) { if (scno < sc_nr) { syscall_fn_t syscall_fn; @@ -27,3 +32,50 @@ asmlinkage void invoke_syscall(struct pt_regs *regs, int scno, int sc_nr, regs->regs[0] = do_ni_syscall(regs); } } + +static inline bool has_syscall_work(unsigned long flags) +{ + return unlikely(flags & _TIF_SYSCALL_WORK); +} + +int syscall_trace_enter(struct pt_regs *regs); +void syscall_trace_exit(struct pt_regs *regs); + +asmlinkage void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, + syscall_fn_t syscall_table[]) +{ + unsigned long flags = current_thread_info()->flags; + + regs->orig_x0 = regs->regs[0]; + regs->syscallno = scno; + + local_daif_restore(DAIF_PROCCTX); + user_exit(); + + if (has_syscall_work(flags)) { + /* set default errno for user-issued syscall(-1) */ + if (scno == NO_SYSCALL) + regs->regs[0] = -ENOSYS; + scno = syscall_trace_enter(regs); + if (scno == NO_SYSCALL) + goto trace_exit; + } + + invoke_syscall(regs, scno, sc_nr, syscall_table); + + /* + * The tracing status may have changed under our feet, so we have to + * check again. However, if we were tracing entry, then we always trace + * exit regardless, as the old entry assembly did. + */ + if (!has_syscall_work(flags)) { + local_daif_mask(); + flags = current_thread_info()->flags; + if (!has_syscall_work(flags)) + return; + local_daif_restore(DAIF_PROCCTX); + } + +trace_exit: + syscall_trace_exit(regs); +} From patchwork Mon May 14 09:46:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135708 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1531918lji; Mon, 14 May 2018 02:47:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpFXTja+dEc0tSvgspeNvd+k6f1TSo9oUaGEUE/j9C3EzgHw+DGgJIkkObeVG4W8qupdIzM X-Received: by 2002:a65:438b:: with SMTP id m11-v6mr7583800pgp.99.1526291273210; Mon, 14 May 2018 02:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291273; cv=none; d=google.com; s=arc-20160816; b=TVzjmKPc18dktbYXaDIYT+/018VfmKex2PYDsm7Cn4FEFZpcmhiRkljW78Bnt3Pcv5 sNcoUDc+tu85LweU7PBOgky6xQxLzPlD5mXpdrJ6teXbJAZpP3pn3r9lfIF0MGMEThSr QW5EFHX9LlDLK9honL8/Q3J4au9+Fu/1V+8Ek38xzVszOKxT9EuYAInU65sQqacdC3a0 q/1XlASelKeCjXWHGvMtRUD3QREi6MU678fMQS981k9xvDBivAicoB7xKNaYYiQC9o7Q FpkKaXruOJctJFgXoDdnlXqlIV635n+SN0JUl6UsFlltJpssyYqLgyzLDGrmfsKgLmvc ZbSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=uOto9tvpn4iD/ZGE6/JioOBSIBTMt5hjG4S8GYduPwg=; b=fAUiU+mTcQ8xZIpUEoRNJob35Y5F3EE1ef5Tc9T4pODSzYAxqiI+wtQX6vegTD7OKu FRPk2co5TMRQWzvMvQ8o09+fxG+1AV2SbWHZz9CUEhFVgcVU8LbCJWpRPkFwHg2pVjYV AYMMgdOs+h+N9svqANwwbNt6hrEU1sAa6dnfFOcvTXXiNKyio2EZ4zyE5hc8BraR1nJn Wna9FN5ifefO5s6MM1Tzd74yja4dqC4ijHerMH3c9/CGDnFHOSdC55u1ooePiBy0riXh CeOEUmPuekVA7NYDkYNr3UpLl/D3yv+0Ne5lJmJTRXcIWoc2eZdJbARmb4okhz3yoS6E xZJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8-v6si2141964pgs.441.2018.05.14.02.47.52; Mon, 14 May 2018 02:47:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752615AbeENJru (ORCPT + 29 others); Mon, 14 May 2018 05:47:50 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38294 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752576AbeENJrs (ORCPT ); Mon, 14 May 2018 05:47:48 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0BF0B16BA; Mon, 14 May 2018 02:47:48 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1F2AF3F25D; Mon, 14 May 2018 02:47:45 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 10/18] arm64: convert native/compat syscall entry to C Date: Mon, 14 May 2018 10:46:32 +0100 Message-Id: <20180514094640.27569-11-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that the syscall invocation logic is in C, we can migrate the rest of the syscall entry logic over, so that the entry assembly needn't look at the register values at all. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/entry.S | 42 ++++-------------------------------------- arch/arm64/kernel/syscall.c | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 40 deletions(-) -- 2.11.0 diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 5c60369b52fc..13afefbf608f 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -690,14 +690,9 @@ el0_sync_compat: b.ge el0_dbg b el0_inv el0_svc_compat: - /* - * AArch32 syscall handling - */ - ldr x16, [tsk, #TSK_TI_FLAGS] // load thread flags - adrp stbl, compat_sys_call_table // load compat syscall table pointer - mov wscno, w7 // syscall number in w7 (r7) - mov wsc_nr, #__NR_compat_syscalls - b el0_svc_naked + mov x0, sp + bl el0_svc_compat_handler + b ret_to_user .align 6 el0_irq_compat: @@ -895,37 +890,8 @@ ENDPROC(ret_to_user) */ .align 6 el0_svc: - ldr x16, [tsk, #TSK_TI_FLAGS] // load thread flags - adrp stbl, sys_call_table // load syscall table pointer - mov wscno, w8 // syscall number in w8 - mov wsc_nr, #__NR_syscalls - -#ifdef CONFIG_ARM64_SVE -alternative_if_not ARM64_SVE - b el0_svc_naked -alternative_else_nop_endif - tbz x16, #TIF_SVE, el0_svc_naked // Skip unless TIF_SVE set: - bic x16, x16, #_TIF_SVE // discard SVE state - str x16, [tsk, #TSK_TI_FLAGS] - - /* - * task_fpsimd_load() won't be called to update CPACR_EL1 in - * ret_to_user unless TIF_FOREIGN_FPSTATE is still set, which only - * happens if a context switch or kernel_neon_begin() or context - * modification (sigreturn, ptrace) intervenes. - * So, ensure that CPACR_EL1 is already correct for the fast-path case: - */ - mrs x9, cpacr_el1 - bic x9, x9, #CPACR_EL1_ZEN_EL0EN // disable SVE for el0 - msr cpacr_el1, x9 // synchronised by eret to el0 -#endif - -el0_svc_naked: // compat entry point mov x0, sp - mov w1, wscno - mov w2, wsc_nr - mov x3, stbl - bl el0_svc_common + bl el0_svc_handler b ret_to_user ENDPROC(el0_svc) diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 5df857e32b48..4706f841e758 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -6,7 +6,9 @@ #include #include +#include #include +#include long do_ni_syscall(struct pt_regs *regs); @@ -41,8 +43,8 @@ static inline bool has_syscall_work(unsigned long flags) int syscall_trace_enter(struct pt_regs *regs); void syscall_trace_exit(struct pt_regs *regs); -asmlinkage void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, - syscall_fn_t syscall_table[]) +static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, + syscall_fn_t syscall_table[]) { unsigned long flags = current_thread_info()->flags; @@ -79,3 +81,37 @@ asmlinkage void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, trace_exit: syscall_trace_exit(regs); } + +static inline void sve_user_reset(void) +{ + if (!system_supports_sve()) + return; + + /* + * task_fpsimd_load() won't be called to update CPACR_EL1 in + * ret_to_user unless TIF_FOREIGN_FPSTATE is still set, which only + * happens if a context switch or kernel_neon_begin() or context + * modification (sigreturn, ptrace) intervenes. + * So, ensure that CPACR_EL1 is already correct for the fast-path case. + */ + if (test_and_clear_thread_flag(TIF_SVE)) + sve_user_disable(); +} + +extern syscall_fn_t sys_call_table[]; + +asmlinkage void el0_svc_handler(struct pt_regs *regs) +{ + sve_user_disable(); + el0_svc_common(regs, regs->regs[8], __NR_syscalls, sys_call_table); +} + +#ifdef CONFIG_COMPAT +extern syscall_fn_t compat_sys_call_table[]; + +asmlinkage void el0_svc_compat_handler(struct pt_regs *regs) +{ + el0_svc_common(regs, regs->regs[7], __NR_compat_syscalls, + compat_sys_call_table); +} +#endif From patchwork Mon May 14 09:46:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135710 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1532032lji; Mon, 14 May 2018 02:47:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqlYOWuQ/wlYUZ3cU7HIIW8AsJAwYBegn53druJhF09gt3/5j96pFHznIcAYPIfciwbRT75 X-Received: by 2002:a65:5bcc:: with SMTP id o12-v6mr7863670pgr.449.1526291278752; Mon, 14 May 2018 02:47:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291278; cv=none; d=google.com; s=arc-20160816; b=eENaKx0SWhA4Qgi0wnkvp1mfVEc04dkSDntm4AvqHh/ySQ9RjJIFcxAhfpSiJlyh5S RlUvQ4LUta1L4KJP3m4DDP/ownxQF58zc54sluFTiCUuKV6JDRMg4DpWEuNCJXA0buDQ AF/cjErpc23l2LudyCwPI03X+wa8JaXGKrhYiry79UxtEGZrGcCWPhRW2l6Hx5HQYsA8 Bm8OT49SoPI0k+SnHsXXmmZUVFKuzM9haO7lgPbflV41e6k7dh6lFOZnFSqFdp1qilJS wZUlsejMNMJb64VIhkNY5N8LOBkGMXcYv3N6nIjW2T9QJaZbXa2OO0HIEFg9DXFGsKpQ nTNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=W7XMg/lwEEiIDgDtBiAUyCkD5MyaIOw3SqRSipqzz6c=; b=zc9/PwPfyME+IoU8XCnrVeoe3CLxFLOJe+frK+rBvNOSUE/ofIHJhfPDapFUkkag/W V5dWVGzmWn5JSg7cuRv7m2+lnTBDb06BrR65/AUJzDKn7gGbQRqnPaL49HN+E8lmU+pJ KqAD7ZWJ+b5gxCUd/cgdPFpARPZOjxgmW4n8GWFdrrbl5VctRG2SyDLgw7Mkm3Z1leFr x8czt/mSGo6gKi1xZ/GXResUi6iF5UNxNwV4EeCO2RpJv5OJpfP5omDFgpNsK/PHRSlZ I/2l8v2kUBndEzmoki3Zq1adEd0ebSK2nisqLPHHe+u7a5KrH50ZOXw8cIGicOxa4PUs oVdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9-v6si7498080pgw.394.2018.05.14.02.47.58; Mon, 14 May 2018 02:47:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752640AbeENJry (ORCPT + 29 others); Mon, 14 May 2018 05:47:54 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38300 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752611AbeENJru (ORCPT ); Mon, 14 May 2018 05:47:50 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A1B2E174E; Mon, 14 May 2018 02:47:50 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id ABC383F25D; Mon, 14 May 2018 02:47:48 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 11/18] arm64: zero GPRs upon entry from EL0 Date: Mon, 14 May 2018 10:46:33 +0100 Message-Id: <20180514094640.27569-12-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We can zero GPRs x0 - x29 upon entry from EL0 to make it harder for userspace to control values consumed by speculative gadgets. We don't blat x30, since this is stashed much later, and we'll blat it before invoking C code. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/entry.S | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) -- 2.11.0 diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 13afefbf608f..4dd529fd03fd 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -62,6 +62,12 @@ #endif .endm + .macro clear_gp_regs + .irp n,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29 + mov x\n, xzr + .endr + .endm + /* * Bad Abort numbers *----------------- @@ -158,12 +164,11 @@ alternative_else_nop_endif stp x28, x29, [sp, #16 * 14] .if \el == 0 + clear_gp_regs mrs x21, sp_el0 ldr_this_cpu tsk, __entry_task, x20 // Ensure MDSCR_EL1.SS is clear, ldr x19, [tsk, #TSK_TI_FLAGS] // since we can unmask debug disable_step_tsk x19, x20 // exceptions when scheduling. - - mov x29, xzr // fp pointed to user-space .else add x21, sp, #S_FRAME_SIZE get_thread_info tsk From patchwork Mon May 14 09:46:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135717 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1534650lji; Mon, 14 May 2018 02:50:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpG64Oswri5TFlq8F1145uGKNBExpvoW6cEHwA2oVfV7LsbczTtDvIIM0x/s7NZjs45Wxj3 X-Received: by 2002:a17:902:6bc7:: with SMTP id m7-v6mr8924736plt.162.1526291448312; Mon, 14 May 2018 02:50:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291448; cv=none; d=google.com; s=arc-20160816; b=j+szHq5lvr/nR30G5Uw3a1W4RCRyrLBC8CzsljWZKnzjPONyW5/hvpznopjdnfgK+U Rw1XjLRPf4grAsueCzwVxSTwxlEEbfT6vUMe65LKdBbPXjNz2lw+kJXguy3OEXIza/op Y50CObjvj5ni7QYBJLwaidSWq100LRO0QzpSW9d1KlUpl3uEZwiYJGePMY8ZjHIDU+6P zwVVYVgK9dF3NQsJ2VO/t9F6RYI/4MC7IHeCl9++WG1IG/CjFZZcfVd8zwkP4SMnlI44 4E4Y8oLW9syd46isO8T4sIjyIBR5FNBiyLOPr9CTYFblB2FBydkiuCf7TPiZSAIYVy2l Oggg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=erxRZcdY1UuR+r6SNI72qvmIfM8ccVC8jD32eLJticU=; b=Wgpk3IdiUC++NawHjMZAAsVWwokwa8vOYu1Wyv6ABGLo8P33jcKh0DDIYF0W2dAzno aIxxXDcmXGmrhcP8lwPx5h2g/Px7OwI72rrxKKDKmidX9kAyhjFuR8BFVwrMhdJ7ovfE zQ+JMT6zAG6Rwxx8DzDqF4QcFx6EqGZWTdaEjJazykSden6E4uKVMaRV6XPgNzsqwV7X lJCfSNQJOQhjpoCZYuUMYWgMp2xJFXAsCQ/slTI4VSake+JvYTxZwcqO/IJ8qajFTRhV AVpDmDbD+dbbbi0VjhCOu4tKifJtPbES3uLH+/B86kohrHdqr0KgbbMWyTlk8ucjeTEx bu7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g72-v6si10161501pfb.280.2018.05.14.02.50.48; Mon, 14 May 2018 02:50:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752706AbeENJuo (ORCPT + 29 others); Mon, 14 May 2018 05:50:44 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38320 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752576AbeENJrx (ORCPT ); Mon, 14 May 2018 05:47:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 40DB21991; Mon, 14 May 2018 02:47:53 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 53E6E3F25D; Mon, 14 May 2018 02:47:51 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 12/18] kernel: add ksys_personality() Date: Mon, 14 May 2018 10:46:34 +0100 Message-Id: <20180514094640.27569-13-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using this helper allows us to avoid the in-kernel call to the sys_personality() syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_personality(). This is necessary to enable conversion of arm64's syscall handling to use pt_regs wrappers. Signed-off-by: Mark Rutland Cc: Al Viro Cc: Dominik Brodowski --- include/linux/syscalls.h | 1 + kernel/exec_domain.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) -- 2.11.0 Reviewed-by: Dave Martin diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 70fcda1a9049..6723ea51ec99 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -1148,6 +1148,7 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long pgoff); ssize_t ksys_readahead(int fd, loff_t offset, size_t count); +unsigned int ksys_personality(unsigned int personality); /* * The following kernel syscall equivalents are just wrappers to fs-internal diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c index a5697119290e..4ba2b404cba2 100644 --- a/kernel/exec_domain.c +++ b/kernel/exec_domain.c @@ -47,7 +47,7 @@ static int __init proc_execdomains_init(void) module_init(proc_execdomains_init); #endif -SYSCALL_DEFINE1(personality, unsigned int, personality) +unsigned int ksys_personality(unsigned int personality) { unsigned int old = current->personality; @@ -56,3 +56,8 @@ SYSCALL_DEFINE1(personality, unsigned int, personality) return old; } + +SYSCALL_DEFINE1(personality, unsigned int, personality) +{ + return ksys_personality(personality); +} From patchwork Mon May 14 09:46:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135711 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1532116lji; Mon, 14 May 2018 02:48:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrmCCLeC83c2oK+0CTR50CC/5imJJAlalRXGCwSbskfv0nvLSVJA9Hm0oF4h2rH0xbG5vhJ X-Received: by 2002:a17:902:6687:: with SMTP id e7-v6mr3181818plk.242.1526291283336; Mon, 14 May 2018 02:48:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291283; cv=none; d=google.com; s=arc-20160816; b=IUaf6T5CAursZDBwxqXkrOf4GJL8jT6F3iTgJcVj2/pUqxrklRdbcV5JJJPQzsGeQw C5NZPtFo10DFEGDrKcHMVBznSAiw2lWNqdnkW2M6j9f7pAlD0J0R4CGmm5YoxEhgdk0u JwMe93LOYPfJBN97WSx82may8Rfwr9G7DvgXW0vAGUtKFfNeaINpZNikeiEzO9vSX66F qRQ3XNO6Ljea95s8ovwupRhw2Yd+i5X/k7H/NcVUhtfQvERgTOjtBMD9nf7v/kWpU5D7 ig81hgwpI/tl9opbEeV+cQBBW9TQSDPVUh4Cyg2INQ2FrU1mqIrZMtERzTecwSnaIrG5 Gozg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=fs+Hj3uvr4RgvwVOQbd8T6mzw798/4Adh2Ecs6hvvWg=; b=C9VwmdpfapjXbR99wTBwasahOZgq/iq+pMkLlsW06rFf4jwA8Jy6U1FH03Fo99cP/W FkVK6g9puEa8bwIGFJDbXdrkG1su6Aph3qYv6fgHM+C1aWcearFvR0pR3tY++votcEKC lZ9Qr7HYJ9fd08DA492PG4RgoFW1hOK9Sut78WenijWcngJDzeAgz9tYyhxYAjtX7Rtl ameJ5CYzsIiZEQuGXKBsSVLCMPYKsNWpFPAnfHpezHKFroWo9q7GItRABiBRUWsgHf/H Vndz4O/6T/n5dw2DoLB0YE5hlGHooeBbTA3nQkHNV+cHLWklyVZFM44/tMB2AToM0eQ4 7x+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t8-v6si3367871pgc.142.2018.05.14.02.48.03; Mon, 14 May 2018 02:48:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752671AbeENJsA (ORCPT + 29 others); Mon, 14 May 2018 05:48:00 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38330 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752611AbeENJr4 (ORCPT ); Mon, 14 May 2018 05:47:56 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D9367199B; Mon, 14 May 2018 02:47:55 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EC3873F25D; Mon, 14 May 2018 02:47:53 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 13/18] kernel: add kcompat_sys_{f,}statfs64() Date: Mon, 14 May 2018 10:46:35 +0100 Message-Id: <20180514094640.27569-14-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Using this helper allows us to avoid the in-kernel calls to the compat_sys_{f,}statfs64() sycalls, as are necessary for parameter mangling in arm64's compat handling. Following the example of ksys_* functions, kcompat_sys_* functions are intended to be a drop-in replacement for their compat_sys_* counterparts, with the same calling convention. This is necessary to enable conversion of arm64's syscall handling to use pt_regs wrappers. Signed-off-by: Mark Rutland Cc: Al Viro Cc: Dominik Brodowski Cc: linux-fsdevel@vger.kernel.org --- fs/statfs.c | 14 ++++++++++++-- include/linux/syscalls.h | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) -- 2.11.0 diff --git a/fs/statfs.c b/fs/statfs.c index 5b2a24f0f263..f0216629621d 100644 --- a/fs/statfs.c +++ b/fs/statfs.c @@ -335,7 +335,7 @@ static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstat return 0; } -COMPAT_SYSCALL_DEFINE3(statfs64, const char __user *, pathname, compat_size_t, sz, struct compat_statfs64 __user *, buf) +int kcompat_sys_statfs64(const char __user * pathname, compat_size_t sz, struct compat_statfs64 __user * buf) { struct kstatfs tmp; int error; @@ -349,7 +349,12 @@ COMPAT_SYSCALL_DEFINE3(statfs64, const char __user *, pathname, compat_size_t, s return error; } -COMPAT_SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, compat_size_t, sz, struct compat_statfs64 __user *, buf) +COMPAT_SYSCALL_DEFINE3(statfs64, const char __user *, pathname, compat_size_t, sz, struct compat_statfs64 __user *, buf) +{ + return kcompat_sys_statfs64(pathname, sz, buf); +} + +int kcompat_sys_fstatfs64(unsigned int fd, compat_size_t sz, struct compat_statfs64 __user * buf) { struct kstatfs tmp; int error; @@ -363,6 +368,11 @@ COMPAT_SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, compat_size_t, sz, struct co return error; } +COMPAT_SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, compat_size_t, sz, struct compat_statfs64 __user *, buf) +{ + return kcompat_sys_fstatfs64(fd, sz, buf); +} + /* * This is a copy of sys_ustat, just dealing with a structure layout. * Given how simple this syscall is that apporach is more maintainable diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index 6723ea51ec99..e0bf3e4bb897 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h @@ -59,6 +59,7 @@ struct tms; struct utimbuf; struct mq_attr; struct compat_stat; +struct compat_statfs64; struct compat_timeval; struct robust_list_head; struct getcpu_cache; @@ -1150,6 +1151,13 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len, ssize_t ksys_readahead(int fd, loff_t offset, size_t count); unsigned int ksys_personality(unsigned int personality); +#ifdef CONFIG_COMPAT +int kcompat_sys_statfs64(const char __user * pathname, compat_size_t sz, + struct compat_statfs64 __user * buf); +int kcompat_sys_fstatfs64(unsigned int fd, compat_size_t sz, + struct compat_statfs64 __user * buf); +#endif + /* * The following kernel syscall equivalents are just wrappers to fs-internal * functions. Therefore, provide stubs to be inlined at the callsites. From patchwork Mon May 14 09:46:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135716 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1533781lji; Mon, 14 May 2018 02:49:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoO8q4QE2kxXzn2npzanSTr4jk0HOQXhDo/mpwRPEZA76bgFiqqK7DgVsKCgQEXM/+N7m9Q X-Received: by 2002:a63:774f:: with SMTP id s76-v6mr7668252pgc.403.1526291388925; Mon, 14 May 2018 02:49:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291388; cv=none; d=google.com; s=arc-20160816; b=wKJGL9/Kg7P2l/zqaHH2bhVm8rJwbqFtk6UFtjB7SS3uSCa31E3JarUKbmHXQNTBzB M0K4xGza+rK49E+IQ+6Cg60U2meqQFqvB3VOykxloZHUtxq5LDEf3b3pJxAHXGBSmaNK v2WGVKia0fbRn7ICy/EJO5UJcMc4XI68PwdXue8n0xcSynlgqb4q28UqiPC7sMMzkqoU SAqqTswt/qXsrEh9f3YiUsOuQE/fTZ8JMT5FxuxYQ3db8uk3JRX4yjVh46K6C8RpJbKw cUn4GCivhTUy4cTk1hHAgw4gcB6SDhVGsf9K4Ya3z4l5jtCuF+wAXUx3gmRo3lClOPjl EjUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=iemocDnVJQ7xzC5SIlxQ40unDLGqIdXL/TCmoRVQiao=; b=GM7q+9MKjtfeRlP7pgyGkLo44/9DDA5VHZQYCf4HH2Yrm5D5GG4Q30q9cTOZ73Z8z2 RQK9xt5ufcOavwW63El8DzwCad0Am89vwoln98QudJhV3DE7sL9hD54s7iyFFCuPnL+P 646CCSVYgbP/nxNU3dH5vSVwAhqz2qqmYoie1A+SefYkMpgqNHrpcnie6NyzUMahx2Sf 83/hcku22m9b5TYRbv57jKbtM8n1w8SCJIRXrwNx71bibnbI/KAFyw2aQQrvaCskZNwX vTgJ0k5w/KcNCFuvWloQSyF8tSKpttyoQG0j2t1c3UgndtBo9txt+iwIHms6lMaTUNN8 xwsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w68-v6si9412345pfb.325.2018.05.14.02.49.48; Mon, 14 May 2018 02:49:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752767AbeENJtq (ORCPT + 29 others); Mon, 14 May 2018 05:49:46 -0400 Received: from foss.arm.com ([217.140.101.70]:38342 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752633AbeENJr6 (ORCPT ); Mon, 14 May 2018 05:47:58 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7A9A019BF; Mon, 14 May 2018 02:47:58 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 84B1E3F25D; Mon, 14 May 2018 02:47:56 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 14/18] arm64: remove in-kernel call to sys_personality() Date: Mon, 14 May 2018 10:46:36 +0100 Message-Id: <20180514094640.27569-15-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With pt_regs syscall wrappers, the calling convention for sys_personality() will change. Use ksys_personality(), which is functionally equivalent. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c index 31045f3fed92..a82c3f7a9a90 100644 --- a/arch/arm64/kernel/sys.c +++ b/arch/arm64/kernel/sys.c @@ -42,7 +42,7 @@ SYSCALL_DEFINE1(arm64_personality, unsigned int, personality) if (personality(personality) == PER_LINUX32 && !system_supports_32bit_el0()) return -EINVAL; - return sys_personality(personality); + return ksys_personality(personality); } /* From patchwork Mon May 14 09:46:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135715 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1532864lji; Mon, 14 May 2018 02:48:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrx1+fC+auI1hBF++H279+gnM6pfhLb4cmYV9uC+kiE/C1fte2QMGR4s2IgHwW49oVOf4KV X-Received: by 2002:a65:4502:: with SMTP id n2-v6mr7685178pgq.95.1526291330620; Mon, 14 May 2018 02:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291330; cv=none; d=google.com; s=arc-20160816; b=HLlxrru0KjOGvcS5PJzhyDspcAXtIFDU3iKsn4qw3uDLLLdeGP7JpXsCOSJyDCBidk S7XtNjPK2Q0q9nY4C8srY748l5RwnVsdzytjI5RwAZVeQcRML8J1XXvcadhdsuSj/l1M uGpWh76LxbvoSTlOA2tBqHqGIKC7zLVtHEh5jAAXkVzsqdpC5a2TampDQuB3SkRjIs9t 22cagQpfOo1gCpgG0bMlyU0jGWbkSI49FuMyyiNz8yX1fxDpR6TgfrGmIbIjf7cSxnEW 9Xi5yVNqt9Xxcs6xpf94h63imeZMWgGrtIRWJ1TW1huIBTM9Q8P0Ou/pu+VOVhKwdrdG Ncvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=hBjJuyDd1pK2W0iK9C6UkQAUr59FhFQAPEcgIlSDjfo=; b=A6ko3l4Du7TuwpYardRYzIXMWZ9FzcdlSYgI0k5php5Ud3/2idEQvvm+QKOOiVkxKn r+7D4mpWvTLbgj3r2IyvuT3VIaF4sTGuFRNXsVpCuxwodANOTuQsm8/UT6y3j9Tgs133 mOBuCQqQVk9oAXpeFS06DdAP7oKSW4yCvCqxHRTE4ECe5EpnIyYlWlbdQb9xeS6Knmjy 3nHP/+ebi3WQT8J8wAI2gffsU9LCifltAKc9+cD8xwQAoC4bdvjK9sPhdXKm8ChwTlAt umAWtfWRbLxQjpCevHcwStUe6bGLYOMuF/ThMetkwTtWovrgBjgx0HCpVOq0YLmWTaLA Bvgw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x33-v6si8809804plb.512.2018.05.14.02.48.50; Mon, 14 May 2018 02:48:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752695AbeENJsF (ORCPT + 29 others); Mon, 14 May 2018 05:48:05 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38348 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752611AbeENJsB (ORCPT ); Mon, 14 May 2018 05:48:01 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 19E1D19E8; Mon, 14 May 2018 02:48:01 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2CD423F25D; Mon, 14 May 2018 02:47:59 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 15/18] arm64: use {COMPAT,}SYSCALL_DEFINE0 for sigreturn Date: Mon, 14 May 2018 10:46:37 +0100 Message-Id: <20180514094640.27569-16-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We don't currently annotate our various sigreturn functions as syscalls, as we need to do to use pt_regs syscall wrappers. Let's mark them as real syscalls. For compat_sys_sigreturn and compat_sys_rt_sigreturn, this changes the return type from int to long, matching the prototypes in sys32.c. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/signal.c | 2 +- arch/arm64/kernel/signal32.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) -- 2.11.0 diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index caa7a68cf2d2..04a26dcbea32 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -538,7 +538,7 @@ static int restore_sigframe(struct pt_regs *regs, return err; } -asmlinkage long sys_rt_sigreturn(void) +SYSCALL_DEFINE0(rt_sigreturn) { struct pt_regs *regs = current_pt_regs(); struct rt_sigframe __user *frame; diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c index cb10588a7cb2..1948566dcccf 100644 --- a/arch/arm64/kernel/signal32.c +++ b/arch/arm64/kernel/signal32.c @@ -282,7 +282,7 @@ static int compat_restore_sigframe(struct pt_regs *regs, return err; } -asmlinkage int compat_sys_sigreturn(void) +COMPAT_SYSCALL_DEFINE0(sigreturn) { struct pt_regs *regs = current_pt_regs(); struct compat_sigframe __user *frame; @@ -313,7 +313,7 @@ asmlinkage int compat_sys_sigreturn(void) return 0; } -asmlinkage int compat_sys_rt_sigreturn(void) +COMPAT_SYSCALL_DEFINE0(rt_sigreturn) { struct pt_regs *regs = current_pt_regs(); struct compat_rt_sigframe __user *frame; From patchwork Mon May 14 09:46:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135712 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1532239lji; Mon, 14 May 2018 02:48:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrNmzTEf/jFuS/C+ZwDTXDzJPkVDFpb/tqayQn2g4JNEokPaUzFfgeW0/GzkATUiNxqcjfY X-Received: by 2002:a17:902:6687:: with SMTP id e7-v6mr3182170plk.242.1526291289672; Mon, 14 May 2018 02:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291289; cv=none; d=google.com; s=arc-20160816; b=NSpp7M+633dC3u27xhCil9uy/ajHFSjh4qJO6/KlOXbV/tCU0YL3Fs/psPDj2+hrW0 c6Ot78/23qKUzn1i9d9h5Edjy8i2qI9A1axQLKOcUAlH2ODZXoOT6xn/rmq3EU5kIfz8 +XfTMXL5v4lWJC3IsV0QZOonJwbrCWRIcRXLrD8cb0eP04oyJd14T2GAnhRH+xsjJZtb hfa69TD2GFiuWu6QvfrgkHltk/N9yCFNhmFed3sahVWpSM9zU28DsUdjJLNgoAJ1kYpM xhgoKlhVvVC3ICaDF/5FypMiA+qwbyf66xYwZy8TnJHoFEnkLhPiOCKToJApuHGjzVTg kxYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=tpwknUO5hW4xd9o9VI1aWSsObL7O/6tJQbYg+VGdd9Q=; b=tkrwPcfoYHayfWqQKdOnlMkdnkExGzaG665O9T6ZpkRXAKRftvWdoOqjEqaVLUHvhO wRs9ypovLJNyahrM8xI52d28OITmipAYAwrep/MmZxxFTBHRhTbKyjTbHiepdvntv/QO 5wj/YrRuQlf0ux4jaZwLArNFH0YIJtv2+PUltwP025/P27Zb07sMiX6QRMLSt1wpeA9C g+N1CcylVehoTVJTDLfnotH0FyHGmQk6wS51yUehkbLqMd2IlRgwg9AzGiJz9/AGz40o aYBji1nesqr+u4RYuA6d1mEY02WGp/MKh7AHPHaJxWCjVJJHtR06F8diCdNVjC9dgslC agMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t8-v6si3367871pgc.142.2018.05.14.02.48.09; Mon, 14 May 2018 02:48:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752715AbeENJsH (ORCPT + 29 others); Mon, 14 May 2018 05:48:07 -0400 Received: from foss.arm.com ([217.140.101.70]:38356 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752222AbeENJsE (ORCPT ); Mon, 14 May 2018 05:48:04 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BB05A1AD7; Mon, 14 May 2018 02:48:03 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C533C3F25D; Mon, 14 May 2018 02:48:01 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 16/18] arm64: use SYSCALL_DEFINE6() for mmap Date: Mon, 14 May 2018 10:46:38 +0100 Message-Id: <20180514094640.27569-17-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We don't currently annotate our mmap implementation as a syscall, as we need to do to use pt_regs syscall wrappers. Let's mark it as a real syscall. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/sys.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.11.0 diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c index a82c3f7a9a90..2ad1497a184e 100644 --- a/arch/arm64/kernel/sys.c +++ b/arch/arm64/kernel/sys.c @@ -27,9 +27,9 @@ #include #include -asmlinkage long sys_mmap(unsigned long addr, unsigned long len, - unsigned long prot, unsigned long flags, - unsigned long fd, off_t off) +SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, + unsigned long, prot, unsigned long, flags, + unsigned long, fd, off_t, off) { if (offset_in_page(off) != 0) return -EINVAL; From patchwork Mon May 14 09:46:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135713 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1532354lji; Mon, 14 May 2018 02:48:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqJc/L9nu39HR/Vo5erjR2dz0iNyQ6xYrej5lP8wHObiSfiRx4CP5ZKa0FQFWBnCvHnq902 X-Received: by 2002:a65:534b:: with SMTP id w11-v6mr7814139pgr.79.1526291296589; Mon, 14 May 2018 02:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291296; cv=none; d=google.com; s=arc-20160816; b=yI6ZexdhWYg/H5Cjc80oAKjhEr/PfjKahZDOwW64um1wt6KgqxLqV4tAUwkVA5FBOA iDgfdt6tRgNk1g3f6ayDg9YsyzNsYichM7upmkDx2O3TmrUCtmhvBpmcIwQZypP4Dbas gaNvPrjlWwZF7oFZB+2NjVDBulou8py79g+HIVbGPJ9EPivRjyiEXGC468cW4dEof5zZ dN4+I/CkvmwyWXlh6mt5bpIZZMpUIVh7+jXl1aKxNB34B2z/3YKKlDH4FQ42XSlVCAkZ uNQkH1T0k4uaSiKDxJ6a+7iJsg1leQFCPgE6MBpsO0ALJpOLpnfh7iUThT++TCSJ/rUb 1/lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=XpK5mFPH1PWS3iS12NUzRaOY4qftxJBzZnx9w+QywTI=; b=diwtbO6tozAwScDLx8pX4KeJ9Vn4oDFH8xWLPp7SJsl/UftzfzsLsyCDqotxMBwbbU vi3ffoSa0utV9dUn/KtAS0dJS7/jpR30xeP9kF5LsjBv31i3ylCtnzqbhAtiKzKqeSl0 uyPrZ4Z0jsucNN7BkqZBb5HEAPpBVUYG/qfWyHk3IXf8JGHw3bCSknaRKkvZB9s0Nezc tJZF2vG9KlQSy2oPzmM8HXXiQQrQsnu/BKEXrtg6F4tm7sadFDqhiVyj9cfTpEaaytVY 1xoj0Esu+6+mmsnYU9cUH0RiTxlHC01R0Z0XgfQetN0PlF3N38ZhyNc9nYiTIaePD7gB G6nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l16-v6si7049535pgc.177.2018.05.14.02.48.16; Mon, 14 May 2018 02:48:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752735AbeENJsN (ORCPT + 29 others); Mon, 14 May 2018 05:48:13 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:38366 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752013AbeENJsJ (ORCPT ); Mon, 14 May 2018 05:48:09 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 676521AED; Mon, 14 May 2018 02:48:09 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7A8863F25D; Mon, 14 May 2018 02:48:07 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 17/18] arm64: convert compat wrappers to C Date: Mon, 14 May 2018 10:46:39 +0100 Message-Id: <20180514094640.27569-18-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for converting to pt_regs syscall wrappers, convert our existing compat wrappers to C. This will allow the pt_regs wrappers to be automatically generated, and will allow for the compat register manipulation to be folded in with the pt_regs accesses. To avoid confusion with the upcoming pt_regs wrappers and existing compat wrappers provided by core code, the C wrappers are renamed to compat_sys_aarch32_. With the assembly wrappers gone, we can get rid of entry32.S and the associated boilerplate. Note that these must call the ksys_* syscall entry points, as the usual sys_* entry points will be modified to take a single pt_regs pointer argument. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/include/asm/unistd32.h | 22 ++++---- arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/entry32.S | 111 -------------------------------------- arch/arm64/kernel/sys32.c | 103 +++++++++++++++++++++++++++++++---- 4 files changed, 104 insertions(+), 134 deletions(-) delete mode 100644 arch/arm64/kernel/entry32.S -- 2.11.0 diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h index ab95554b1734..0e3dd3265993 100644 --- a/arch/arm64/include/asm/unistd32.h +++ b/arch/arm64/include/asm/unistd32.h @@ -382,9 +382,9 @@ __SYSCALL(__NR_rt_sigqueueinfo, compat_sys_rt_sigqueueinfo) #define __NR_rt_sigsuspend 179 __SYSCALL(__NR_rt_sigsuspend, compat_sys_rt_sigsuspend) #define __NR_pread64 180 -__SYSCALL(__NR_pread64, compat_sys_pread64_wrapper) +__SYSCALL(__NR_pread64, compat_sys_aarch32_pread64) #define __NR_pwrite64 181 -__SYSCALL(__NR_pwrite64, compat_sys_pwrite64_wrapper) +__SYSCALL(__NR_pwrite64, compat_sys_aarch32_pwrite64) #define __NR_chown 182 __SYSCALL(__NR_chown, sys_chown16) #define __NR_getcwd 183 @@ -406,11 +406,11 @@ __SYSCALL(__NR_vfork, sys_vfork) #define __NR_ugetrlimit 191 /* SuS compliant getrlimit */ __SYSCALL(__NR_ugetrlimit, compat_sys_getrlimit) /* SuS compliant getrlimit */ #define __NR_mmap2 192 -__SYSCALL(__NR_mmap2, compat_sys_mmap2_wrapper) +__SYSCALL(__NR_mmap2, compat_sys_aarch32_mmap2) #define __NR_truncate64 193 -__SYSCALL(__NR_truncate64, compat_sys_truncate64_wrapper) +__SYSCALL(__NR_truncate64, compat_sys_aarch32_truncate64) #define __NR_ftruncate64 194 -__SYSCALL(__NR_ftruncate64, compat_sys_ftruncate64_wrapper) +__SYSCALL(__NR_ftruncate64, compat_sys_aarch32_ftruncate64) #define __NR_stat64 195 __SYSCALL(__NR_stat64, sys_stat64) #define __NR_lstat64 196 @@ -472,7 +472,7 @@ __SYSCALL(223, sys_ni_syscall) #define __NR_gettid 224 __SYSCALL(__NR_gettid, sys_gettid) #define __NR_readahead 225 -__SYSCALL(__NR_readahead, compat_sys_readahead_wrapper) +__SYSCALL(__NR_readahead, compat_sys_aarch32_readahead) #define __NR_setxattr 226 __SYSCALL(__NR_setxattr, sys_setxattr) #define __NR_lsetxattr 227 @@ -554,15 +554,15 @@ __SYSCALL(__NR_clock_getres, compat_sys_clock_getres) #define __NR_clock_nanosleep 265 __SYSCALL(__NR_clock_nanosleep, compat_sys_clock_nanosleep) #define __NR_statfs64 266 -__SYSCALL(__NR_statfs64, compat_sys_statfs64_wrapper) +__SYSCALL(__NR_statfs64, compat_sys_aarch32_statfs64) #define __NR_fstatfs64 267 -__SYSCALL(__NR_fstatfs64, compat_sys_fstatfs64_wrapper) +__SYSCALL(__NR_fstatfs64, compat_sys_aarch32_fstatfs64) #define __NR_tgkill 268 __SYSCALL(__NR_tgkill, sys_tgkill) #define __NR_utimes 269 __SYSCALL(__NR_utimes, compat_sys_utimes) #define __NR_arm_fadvise64_64 270 -__SYSCALL(__NR_arm_fadvise64_64, compat_sys_fadvise64_64_wrapper) +__SYSCALL(__NR_arm_fadvise64_64, compat_sys_aarch32_fadvise64_64) #define __NR_pciconfig_iobase 271 __SYSCALL(__NR_pciconfig_iobase, sys_pciconfig_iobase) #define __NR_pciconfig_read 272 @@ -704,7 +704,7 @@ __SYSCALL(__NR_get_robust_list, compat_sys_get_robust_list) #define __NR_splice 340 __SYSCALL(__NR_splice, sys_splice) #define __NR_sync_file_range2 341 -__SYSCALL(__NR_sync_file_range2, compat_sys_sync_file_range2_wrapper) +__SYSCALL(__NR_sync_file_range2, compat_sys_aarch32_sync_file_range2) #define __NR_tee 342 __SYSCALL(__NR_tee, sys_tee) #define __NR_vmsplice 343 @@ -726,7 +726,7 @@ __SYSCALL(__NR_timerfd_create, sys_timerfd_create) #define __NR_eventfd 351 __SYSCALL(__NR_eventfd, sys_eventfd) #define __NR_fallocate 352 -__SYSCALL(__NR_fallocate, compat_sys_fallocate_wrapper) +__SYSCALL(__NR_fallocate, compat_sys_aarch32_fallocate) #define __NR_timerfd_settime 353 __SYSCALL(__NR_timerfd_settime, compat_sys_timerfd_settime) #define __NR_timerfd_gettime 354 diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index c22e8ace5ea3..5886bc53fc9f 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -28,7 +28,7 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE $(call if_changed,objcopy) arm64-obj-$(CONFIG_COMPAT) += sys32.o kuser32.o signal32.o \ - sys_compat.o entry32.o + sys_compat.o arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o arm64-obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o diff --git a/arch/arm64/kernel/entry32.S b/arch/arm64/kernel/entry32.S deleted file mode 100644 index f9461696dde4..000000000000 --- a/arch/arm64/kernel/entry32.S +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Compat system call wrappers - * - * Copyright (C) 2012 ARM Ltd. - * Authors: Will Deacon - * Catalin Marinas - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include - -#include -#include -#include -#include - -/* - * System call wrappers for the AArch32 compatibility layer. - */ - -ENTRY(compat_sys_statfs64_wrapper) - mov w3, #84 - cmp w1, #88 - csel w1, w3, w1, eq - b compat_sys_statfs64 -ENDPROC(compat_sys_statfs64_wrapper) - -ENTRY(compat_sys_fstatfs64_wrapper) - mov w3, #84 - cmp w1, #88 - csel w1, w3, w1, eq - b compat_sys_fstatfs64 -ENDPROC(compat_sys_fstatfs64_wrapper) - -/* - * Note: off_4k (w5) is always in units of 4K. If we can't do the - * requested offset because it is not page-aligned, we return -EINVAL. - */ -ENTRY(compat_sys_mmap2_wrapper) -#if PAGE_SHIFT > 12 - tst w5, #~PAGE_MASK >> 12 - b.ne 1f - lsr w5, w5, #PAGE_SHIFT - 12 -#endif - b sys_mmap_pgoff -1: mov x0, #-EINVAL - ret -ENDPROC(compat_sys_mmap2_wrapper) - -/* - * Wrappers for AArch32 syscalls that either take 64-bit parameters - * in registers or that take 32-bit parameters which require sign - * extension. - */ -ENTRY(compat_sys_pread64_wrapper) - regs_to_64 x3, x4, x5 - b sys_pread64 -ENDPROC(compat_sys_pread64_wrapper) - -ENTRY(compat_sys_pwrite64_wrapper) - regs_to_64 x3, x4, x5 - b sys_pwrite64 -ENDPROC(compat_sys_pwrite64_wrapper) - -ENTRY(compat_sys_truncate64_wrapper) - regs_to_64 x1, x2, x3 - b sys_truncate -ENDPROC(compat_sys_truncate64_wrapper) - -ENTRY(compat_sys_ftruncate64_wrapper) - regs_to_64 x1, x2, x3 - b sys_ftruncate -ENDPROC(compat_sys_ftruncate64_wrapper) - -ENTRY(compat_sys_readahead_wrapper) - regs_to_64 x1, x2, x3 - mov w2, w4 - b sys_readahead -ENDPROC(compat_sys_readahead_wrapper) - -ENTRY(compat_sys_fadvise64_64_wrapper) - mov w6, w1 - regs_to_64 x1, x2, x3 - regs_to_64 x2, x4, x5 - mov w3, w6 - b sys_fadvise64_64 -ENDPROC(compat_sys_fadvise64_64_wrapper) - -ENTRY(compat_sys_sync_file_range2_wrapper) - regs_to_64 x2, x2, x3 - regs_to_64 x3, x4, x5 - b sys_sync_file_range2 -ENDPROC(compat_sys_sync_file_range2_wrapper) - -ENTRY(compat_sys_fallocate_wrapper) - regs_to_64 x2, x2, x3 - regs_to_64 x3, x4, x5 - b sys_fallocate -ENDPROC(compat_sys_fallocate_wrapper) diff --git a/arch/arm64/kernel/sys32.c b/arch/arm64/kernel/sys32.c index 1ef103c95410..1a84e79c47f3 100644 --- a/arch/arm64/kernel/sys32.c +++ b/arch/arm64/kernel/sys32.c @@ -27,17 +27,98 @@ asmlinkage long compat_sys_sigreturn(void); asmlinkage long compat_sys_rt_sigreturn(void); -asmlinkage long compat_sys_statfs64_wrapper(void); -asmlinkage long compat_sys_fstatfs64_wrapper(void); -asmlinkage long compat_sys_pread64_wrapper(void); -asmlinkage long compat_sys_pwrite64_wrapper(void); -asmlinkage long compat_sys_truncate64_wrapper(void); -asmlinkage long compat_sys_ftruncate64_wrapper(void); -asmlinkage long compat_sys_readahead_wrapper(void); -asmlinkage long compat_sys_fadvise64_64_wrapper(void); -asmlinkage long compat_sys_sync_file_range2_wrapper(void); -asmlinkage long compat_sys_fallocate_wrapper(void); -asmlinkage long compat_sys_mmap2_wrapper(void); + +COMPAT_SYSCALL_DEFINE3(aarch32_statfs64, const char __user *, pathname, + compat_size_t, sz, struct compat_statfs64 __user *, buf) +{ + if (sz == 88) + sz = 84; + + return kcompat_sys_statfs64(pathname, sz, buf); +} + +COMPAT_SYSCALL_DEFINE3(aarch32_fstatfs64, unsigned int, fd, compat_size_t, sz, + struct compat_statfs64 __user *, buf) +{ + if (sz == 88) + sz = 84; + + return kcompat_sys_fstatfs64(fd, sz, buf); +} + +/* + * Note: off_4k is always in units of 4K. If we can't do the + * requested offset because it is not page-aligned, we return -EINVAL. + */ +COMPAT_SYSCALL_DEFINE6(aarch32_mmap2, unsigned long, addr, unsigned long, len, + unsigned long, prot, unsigned long, flags, + unsigned long, fd, unsigned long, off_4k) +{ + if (off_4k & (~PAGE_MASK >> 12)) + return -EINVAL; + + off_4k >>= (PAGE_SHIFT - 12); + + return ksys_mmap_pgoff(addr, len, prot, flags, fd, off_4k); +} + +#ifdef CONFIG_CPU_BIG_ENDIAN +#define arg_u32p(name) u32, name##_hi, u32, name##_lo +#else +#define arg_u32p(name) u32, name##_lo, u32, name##_hi +#endif + +#define arg_u64(name) (((u64)name##_hi << 32) | name##_lo) + +COMPAT_SYSCALL_DEFINE6(aarch32_pread64, unsigned int, fd, char __user *, buf, + size_t, count, u32, __pad, arg_u32p(pos)) +{ + return ksys_pread64(fd, buf, count, arg_u64(pos)); +} + +COMPAT_SYSCALL_DEFINE6(aarch32_pwrite64, unsigned int, fd, + const char __user *, buf, size_t, count, u32, __pad, + arg_u32p(pos)) +{ + return ksys_pwrite64(fd, buf, count, arg_u64(pos)); +} + +COMPAT_SYSCALL_DEFINE4(aarch32_truncate64, const char __user *, pathname, + u32, __pad, arg_u32p(length)) +{ + return ksys_truncate(pathname, arg_u64(length)); +} + +COMPAT_SYSCALL_DEFINE4(aarch32_ftruncate64, unsigned int, fd, u32, __pad, + arg_u32p(length)) +{ + return ksys_ftruncate(fd, arg_u64(length)); +} + +COMPAT_SYSCALL_DEFINE5(aarch32_readahead, int, fd, u32, __pad, + arg_u32p(offset), size_t, count) +{ + return ksys_readahead(fd, arg_u64(offset), count); +} + +COMPAT_SYSCALL_DEFINE6(aarch32_fadvise64_64, int, fd, int, advice, + arg_u32p(offset), arg_u32p(len)) +{ + return ksys_fadvise64_64(fd, arg_u64(offset), arg_u64(len), advice); +} + +COMPAT_SYSCALL_DEFINE6(aarch32_sync_file_range2, int, fd, unsigned int, flags, + arg_u32p(offset), arg_u32p(nbytes)) +{ + return ksys_sync_file_range(fd, arg_u64(offset), arg_u64(nbytes), + flags); +} + +COMPAT_SYSCALL_DEFINE6(aarch32_fallocate, int, fd, int, mode, + arg_u32p(offset), arg_u32p(len)) +{ + return ksys_fallocate(fd, mode, arg_u64(offset), arg_u64(len)); +} #undef __SYSCALL #define __SYSCALL(nr, sym) [nr] = sym, From patchwork Mon May 14 09:46:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 135714 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1532434lji; Mon, 14 May 2018 02:48:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqkEEG/NEYQh9TPSuvsRG39gHpd2op6ixe6yvOvnfgH+vFON25ZWMxoZFQbOcAD61jxm8SA X-Received: by 2002:a17:902:d24:: with SMTP id 33-v6mr9099794plu.22.1526291303644; Mon, 14 May 2018 02:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526291303; cv=none; d=google.com; s=arc-20160816; b=tMqjI399dVZEGUbnDnLr/hTIPQQdCMgvQCSyaA3iDhiQplejoIIN61iu44xleVPBre jQRCw9Ym8D23u83zqvJJjuvefX1FtwtEXEOGvMZe/0pd/jZcZbbaptuTif96c3n/rfEd ted2lm+k5fAS2WNRP5tqqHD14KcF4Stmq8WATYqcelM2SwGRymRenCNIgrbjfZtkNXn8 QNRRnDmXj1K0lxUFoSXkYeAXMOYRlRlCd4IlRKAifk6NDU/VBAh7fpe2kYBTzSuhD3Rw Wp7M9RCNCvRAomuSdRKH2vQHQ4i29N02YHTvdsyDnsjdtOUmwOrTm3MBtECtCPfyCFTI UejQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=g+dtht4icgDDcz9FUh3jb9VIV7+XP4OOpAC5n6kKiKo=; b=CKbSKEMINMDyHKL8kqbwGmQ20W5FXOJq0juPjqq/6cYEDQ7lsuhFHuRLDE20lLHI3K xnj4JtW8AtFjU/Jg2LmUEH4izLmAj/dYFyKtsRM6vos0qmawacgEQUPUl0nCXO/6NRjX f/uD5xt28l7wGUl+eqIl9oRwEK0Luq4rrOMte4YahPO8nzR0g1XZMnaE8sCX/it7/yHt 2ADFiJS/IPEiTGXxU4wegtMo90MYJwmIQlZ3diUW3n1uWNkc5xCCMySzw917kzwDJJBk fyBhNXmRTChtRJxk7LLDlhmnmU0eZSmSzD6U7UBLQWP9+6CqgUju7zerXMEShr8FBwZb 9jmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l16-v6si7049535pgc.177.2018.05.14.02.48.23; Mon, 14 May 2018 02:48:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752751AbeENJsV (ORCPT + 29 others); Mon, 14 May 2018 05:48:21 -0400 Received: from foss.arm.com ([217.140.101.70]:38372 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752090AbeENJsM (ORCPT ); Mon, 14 May 2018 05:48:12 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 177F21B55; Mon, 14 May 2018 02:48:12 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 2AD1E3F25D; Mon, 14 May 2018 02:48:10 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk, will.deacon@arm.com Subject: [PATCH 18/18] arm64: implement syscall wrappers Date: Mon, 14 May 2018 10:46:40 +0100 Message-Id: <20180514094640.27569-19-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180514094640.27569-1-mark.rutland@arm.com> References: <20180514094640.27569-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To minimize the risk of userspace-controlled values being used under speculation, this patch adds pt_regs based syscall wrappers for arm64, which pass the minimum set of required userspace values to syscall implementations. For each syscall, a wrapper which takes a pt_regs argument is automatically generated, and this extracts the arguments before calling the "real" syscall implementation. Each syscall has three functions generated: * __do_sys_ is the "real" syscall implementation, with the expected prototype. * __se_sys_ is the sign-extension/narrowing wrapper, inherited from common code. This takes a series of long parameters, casting each to the requisite types required by the "real" syscall implementation in __do_sys_. This wrapper *may* not be necessary on arm64 given the AAPCS rules on unused register bits, but it seemed safer to keep the wrapper for now. * __arm64__sys_ takes a struct pt_regs pointer, and extracts *only* the relevant register values, passing these on to the __se_sys_ wrapper. The syscall invocation code is updated to handle the calling convention required by __arm64__sys_, and passes a single struct pt_regs pointer. The compiler can fold the syscall implementation and its wrappers, such that the overhead of this approach is minimized. Note that we play games with sys_ni_syscall(). It can't be defined with SYSCALL_DEFINE0() because we must avoid the possibility of error injection. Additionally, there are a couple of locations where we need to call it from C code, and we don't (currently) have a ksys_ni_syscall(). While it has no wrapper, passing in a redundant pt_regs pointer is benign per the AAPCS. When ARCH_HAS_SYSCALL_WRAPPER is selected, no prototype is define for sys_ni_syscall(). Since we need to treat it differently for in-kernel calls and the syscall tables, the prototype is defined as-required. Largely the wrappers are largely the same as their x86 counterparts, but simplified as we don't have a variety of compat calling conventions that require separate stubs. Unlike x86, we have some zero-argument compat syscalls, and must define COMPAT_SYSCALL_DEFINE0(). Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Will Deacon --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/syscall_wrapper.h | 80 ++++++++++++++++++++++++++++++++ arch/arm64/kernel/sys.c | 10 +++- arch/arm64/kernel/sys32.c | 9 +++- arch/arm64/kernel/syscall.c | 8 +--- arch/arm64/kernel/traps.c | 2 + 6 files changed, 101 insertions(+), 9 deletions(-) create mode 100644 arch/arm64/include/asm/syscall_wrapper.h -- 2.11.0 diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index eb2cf4938f6d..8e559b1fc555 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -21,6 +21,7 @@ config ARM64 select ARCH_HAS_SG_CHAIN select ARCH_HAS_STRICT_KERNEL_RWX select ARCH_HAS_STRICT_MODULE_RWX + select ARCH_HAS_SYSCALL_WRAPPER select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST select ARCH_HAVE_NMI_SAFE_CMPXCHG select ARCH_INLINE_READ_LOCK if !PREEMPT diff --git a/arch/arm64/include/asm/syscall_wrapper.h b/arch/arm64/include/asm/syscall_wrapper.h new file mode 100644 index 000000000000..a4477e515b79 --- /dev/null +++ b/arch/arm64/include/asm/syscall_wrapper.h @@ -0,0 +1,80 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * syscall_wrapper.h - arm64 specific wrappers to syscall definitions + * + * Based on arch/x86/include/asm_syscall_wrapper.h + */ + +#ifndef __ASM_SYSCALL_WRAPPER_H +#define __ASM_SYSCALL_WRAPPER_H + +#define SC_ARM64_REGS_TO_ARGS(x, ...) \ + __MAP(x,__SC_ARGS \ + ,,regs->regs[0],,regs->regs[1],,regs->regs[2] \ + ,,regs->regs[3],,regs->regs[4],,regs->regs[5]) + +#ifdef CONFIG_COMPAT + +#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ + asmlinkage long __arm64_compat_sys##name(const struct pt_regs *regs); \ + ALLOW_ERROR_INJECTION(__arm64_compat_sys##name, ERRNO); \ + static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ + static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ + asmlinkage long __arm64_compat_sys##name(const struct pt_regs *regs) \ + { \ + return __se_compat_sys##name(SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \ + } \ + static long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ + { \ + return __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \ + } \ + static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) + +#define COMPAT_SYSCALL_DEFINE0(sname) \ + asmlinkage long __arm64_compat_sys_##sname(void); \ + ALLOW_ERROR_INJECTION(__arm64_compat_sys_##sname, ERRNO); \ + asmlinkage long __arm64_compat_sys_##sname(void) + +#define COND_SYSCALL_COMPAT(name) \ + cond_syscall(__arm64_compat_sys_##name); + +#define COMPAT_SYS_NI(name) \ + SYSCALL_ALIAS(__arm64_compat_sys_##name, sys_ni_posix_timers); + +#endif /* CONFIG_COMPAT */ + +#define __SYSCALL_DEFINEx(x, name, ...) \ + asmlinkage long __arm64_sys##name(const struct pt_regs *regs); \ + ALLOW_ERROR_INJECTION(__arm64_sys##name, ERRNO); \ + static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ + static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ + asmlinkage long __arm64_sys##name(const struct pt_regs *regs) \ + { \ + return __se_sys##name(SC_ARM64_REGS_TO_ARGS(x,__VA_ARGS__)); \ + } \ + static long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ + { \ + long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \ + __MAP(x,__SC_TEST,__VA_ARGS__); \ + __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \ + return ret; \ + } \ + static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) + +#ifndef SYSCALL_DEFINE0 +#define SYSCALL_DEFINE0(sname) \ + SYSCALL_METADATA(_##sname, 0); \ + asmlinkage long __arm64_sys_##sname(void); \ + ALLOW_ERROR_INJECTION(__arm64_sys_##sname, ERRNO); \ + asmlinkage long __arm64_sys_##sname(void) +#endif + +#ifndef COND_SYSCALL +#define COND_SYSCALL(name) cond_syscall(__arm64_sys_##name) +#endif + +#ifndef SYS_NI +#define SYS_NI(name) SYSCALL_ALIAS(__arm64_sys_##name, sys_ni_posix_timers); +#endif + +#endif /* __ASM_SYSCALL_WRAPPER_H */ diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c index 2ad1497a184e..ee93bf789f0a 100644 --- a/arch/arm64/kernel/sys.c +++ b/arch/arm64/kernel/sys.c @@ -48,11 +48,17 @@ SYSCALL_DEFINE1(arm64_personality, unsigned int, personality) /* * Wrappers to pass the pt_regs argument. */ -asmlinkage long sys_rt_sigreturn(void); #define sys_personality sys_arm64_personality +asmlinkage long sys_ni_syscall(const struct pt_regs *); +#define __arm64_sys_ni_syscall sys_ni_syscall + +#undef __SYSCALL +#define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *); +#include + #undef __SYSCALL -#define __SYSCALL(nr, sym) [nr] = sym, +#define __SYSCALL(nr, sym) [nr] = __arm64_##sym, /* * The sys_call_table array must be 4K aligned to be accessible from diff --git a/arch/arm64/kernel/sys32.c b/arch/arm64/kernel/sys32.c index 1a84e79c47f3..8359b54a9c97 100644 --- a/arch/arm64/kernel/sys32.c +++ b/arch/arm64/kernel/sys32.c @@ -120,8 +120,15 @@ COMPAT_SYSCALL_DEFINE6(aarch32_fallocate, int, fd, int, mode, return ksys_fallocate(fd, mode, arg_u64(offset), arg_u64(len)); } +asmlinkage long sys_ni_syscall(const struct pt_regs *); +#define __arm64_sys_ni_syscall sys_ni_syscall + +#undef __SYSCALL +#define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *); +#include + #undef __SYSCALL -#define __SYSCALL(nr, sym) [nr] = sym, +#define __SYSCALL(nr, sym) [nr] = __arm64_##sym, /* * The sys_call_table array must be 4K aligned to be accessible from diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 4706f841e758..15b5d18f6104 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -12,15 +12,11 @@ long do_ni_syscall(struct pt_regs *regs); -typedef long (*syscall_fn_t)(unsigned long, unsigned long, - unsigned long, unsigned long, - unsigned long, unsigned long); +typedef long (*syscall_fn_t)(struct pt_regs *regs); static void __invoke_syscall(struct pt_regs *regs, syscall_fn_t syscall_fn) { - regs->regs[0] = syscall_fn(regs->regs[0], regs->regs[1], - regs->regs[2], regs->regs[3], - regs->regs[4], regs->regs[5]); + regs->regs[0] = syscall_fn(regs); } static void invoke_syscall(struct pt_regs *regs, int scno, int sc_nr, diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index b8d3e0d8c616..8bfcc37cbc65 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -549,6 +549,8 @@ asmlinkage void __exception do_sysinstr(unsigned int esr, struct pt_regs *regs) long compat_arm_syscall(struct pt_regs *regs); +long sys_ni_syscall(void); + asmlinkage long do_ni_syscall(struct pt_regs *regs) { #ifdef CONFIG_COMPAT