From patchwork Fri Mar 24 15:55:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 9643161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B29ED602C9 for ; Fri, 24 Mar 2017 15:56:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A43B4205F7 for ; Fri, 24 Mar 2017 15:56:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98F6A26E56; Fri, 24 Mar 2017 15:56:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 166A825404 for ; Fri, 24 Mar 2017 15:56:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=kXpTa8pFEwia+cZpm233y0UvPbjWddQfLuoQnlpoFbo=; b=aSW zQlBxD1vZzaTntwBbpFJX+EtI6f7k0pxKUnjfjs4NWSbQmLr6xyvLywvo/ibemiltjuML0G8idY4o RGHJhq0w+smwpVi1kdwkeONJO2yIga7i8IkcCP1sGIGrPWqZE+qo8sXdDEkZUQ1tj3AEsq2W1MfvO YumT9Mv3odaLNJL7cf/19pcKdGgIM2V2Ql23Hhaz9lgMeYBYxW/zeF+UFdWMQ9jdZ0fZEGPuqNU1u m4JjE/YSowE16RwJ3W0ARJNYHawK8ZdYLIGRQQeSlkf1MSYHDcW1//kt+iT1CdWMipTSIFMd9s93Q W0TdUe+gxBKVKqni4IlRtQ2zgbA6abA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1crRZi-0004Mk-Hb; Fri, 24 Mar 2017 15:56:26 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1crRZH-0003qF-2d for linux-arm-kernel@lists.infradead.org; Fri, 24 Mar 2017 15:56:04 +0000 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 B56E42B; Fri, 24 Mar 2017 08:55:38 -0700 (PDT) Received: from e103592.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 0046D3F3E1; Fri, 24 Mar 2017 08:55:37 -0700 (PDT) From: Dave Martin To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64: ptrace: Crystallise the pt_regs->syscallno = ~0UL idiom Date: Fri, 24 Mar 2017 15:55:33 +0000 Message-Id: <1490370933-24057-1-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170324_085559_977990_0A629875 X-CRM114-Status: UNSURE ( 9.19 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Catalin Marinas , Will Deacon MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Assigning ~0UL to pt_regs->syscallno to indicate that a task is not executing a syscall is a little obscure. This patch defines a helper zap_syscall() to make users of this idiom and its intent a bit more readable. This concept allows relaxations to the system call ABI whereby not all userspace state need be preserved by the kernel around an explicit syscall. The Scalable Vector Extension ABI will make use of this with regard to the extra register state added by SVE. No relaxation of the _existing_ system call ABI is implied here. Signed-off-by: Dave Martin --- arch/arm64/include/asm/processor.h | 7 ++++++- arch/arm64/kernel/ptrace.c | 3 ++- arch/arm64/kernel/signal.c | 4 ++-- arch/arm64/kernel/signal32.c | 3 ++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index c97b8bd..0502007 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -104,10 +104,15 @@ struct thread_struct { #define INIT_THREAD { } +static inline void zap_syscall(struct pt_regs *regs) +{ + regs->syscallno = ~0UL; +} + static inline void start_thread_common(struct pt_regs *regs, unsigned long pc) { memset(regs, 0, sizeof(*regs)); - regs->syscallno = ~0UL; + zap_syscall(regs); regs->pc = pc; } diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index c142459..d92b422 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -1348,7 +1349,7 @@ static void tracehook_report_syscall(struct pt_regs *regs, if (dir == PTRACE_SYSCALL_EXIT) tracehook_report_syscall_exit(regs, 0); else if (tracehook_report_syscall_entry(regs)) - regs->syscallno = ~0UL; + zap_syscall(regs); regs->regs[regno] = saved_reg; } diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 49c30df..1aef3d7 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -351,7 +351,7 @@ static int restore_sigframe(struct pt_regs *regs, /* * Avoid sys_rt_sigreturn() restarting. */ - regs->syscallno = ~0UL; + zap_syscall(regs); err |= !valid_user_regs(®s->user_regs, current); if (err == 0) @@ -634,7 +634,7 @@ static void do_signal(struct pt_regs *regs) /* * Avoid additional syscall restarting via ret_to_user. */ - regs->syscallno = ~0UL; + zap_syscall(regs); /* * Prepare for system call restart. We do this here so that a diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c index c747a0f..53f1cc0 100644 --- a/arch/arm64/kernel/signal32.c +++ b/arch/arm64/kernel/signal32.c @@ -27,6 +27,7 @@ #include #include #include +#include #include struct compat_sigcontext { @@ -354,7 +355,7 @@ static int compat_restore_sigframe(struct pt_regs *regs, /* * Avoid compat_sys_sigreturn() restarting. */ - regs->syscallno = ~0UL; + zap_syscall(regs); err |= !valid_user_regs(®s->user_regs, current);