From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2101FC2BA83 for ; Wed, 12 Feb 2020 11:09:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E891A2073C for ; Wed, 12 Feb 2020 11:09:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PKzxkHFO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E891A2073C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iHwUM6Ln3uGQSmbNcDQOFvN2Jzy6VXd20Yz4Jvusw24=; b=PKzxkHFOreugl4 JatZ7iDyN7ol0E8Pjr0XjsPBbN1uSrVRpRIM7GRap6lnXEH4ruMkXNH394LZ+LtSWUrLOHsrMkh4s Jf6HGuFC5n8y2PzwCq92miOVTHPMVBDFcrc14chAS9IwMHEsrFuIE8xj33HHuIf4gh036uGyDhfUX NT7Ic4vALNb5GP5Xda3wWUXqBjkMPAMukUTmMBLzjzsk3qPnK5U/ifNITIKJ5Ax3WI+lusD+CB502 RH0AabMQVEq/+vYjoXxnrWLbNKt4dEDNMI7uWrXzfjumSraYQI+MEMpNZUSI5haipGd3rqMDJhB53 pZczI2yvPn5Cpz0nLkEQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1ptH-0000w7-PW; Wed, 12 Feb 2020 11:09:11 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j1ptE-0000vZ-I4 for linux-arm-kernel@lists.infradead.org; Wed, 12 Feb 2020 11:09:10 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4489030E; Wed, 12 Feb 2020 03:09:07 -0800 (PST) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.196.71]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9602E3F68F; Wed, 12 Feb 2020 03:09:05 -0800 (PST) Date: Wed, 12 Feb 2020 11:09:03 +0000 From: Catalin Marinas To: Peter Collingbourne Subject: Re: [PATCH] arm64: mte: Do not service syscalls after async tag fault Message-ID: <20200212110903.GE488264@arrakis.emea.arm.com> References: <20191217180152.GO5624@arrakis.emea.arm.com> <20191220013639.212396-1-pcc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20191220013639.212396-1-pcc@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200212_030908_688535_A0F0A24F X-CRM114-Status: GOOD ( 21.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Richard Earnshaw , linux-mm@kvack.org, Szabolcs Nagy , Marc Zyngier , Kevin Brodsky , Kostya Serebryany , Evgenii Stepanov , Andrey Konovalov , Vincenzo Frascino , Will Deacon , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Dec 19, 2019 at 05:36:39PM -0800, Peter Collingbourne wrote: > When entering the kernel after an async tag fault due to a syscall, rather > than for another reason (e.g. preemption), we don't want to service the > syscall as it may mask the tag fault. Rewind the PC to the svc instruction > in order to give a userspace signal handler an opportunity to handle the > fault and resume, and skip all other syscall processing. > > Signed-off-by: Peter Collingbourne > --- [...] > arch/arm64/kernel/syscall.c | 22 +++++++++++++++++++--- > 1 file changed, 19 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c > index 9a9d98a443fc..49ea9bb47190 100644 > --- a/arch/arm64/kernel/syscall.c > +++ b/arch/arm64/kernel/syscall.c > @@ -95,13 +95,29 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, > { > unsigned long flags = current_thread_info()->flags; > > - regs->orig_x0 = regs->regs[0]; > - regs->syscallno = scno; > - > cortex_a76_erratum_1463225_svc_handler(); > local_daif_restore(DAIF_PROCCTX); > user_exit(); > > +#ifdef CONFIG_ARM64_MTE > + if (flags & _TIF_MTE_ASYNC_FAULT) { > + /* > + * We entered the kernel after an async tag fault due to a > + * syscall, rather than for another reason (e.g. preemption). > + * In this case, we don't want to service the syscall as it may > + * mask the tag fault. Rewind the PC to the svc instruction in > + * order to give a userspace signal handler an opportunity to > + * handle the fault and resume, and skip all other syscall > + * processing. > + */ > + regs->pc -= 4; > + return; > + } > +#endif > + > + regs->orig_x0 = regs->regs[0]; > + regs->syscallno = scno; I'm slightly worried about the interaction with single-step, other signals. It might be better if we just use the existing syscall restarting mechanism. Untested diff below: -------------------8<------------------------------- diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index a12c0c88d345..db25f5d6a07c 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -102,6 +102,16 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, local_daif_restore(DAIF_PROCCTX); user_exit(); + if (system_supports_mte() && (flags & _TIF_MTE_ASYNC_FAULT)) { + /* + * Process the asynchronous tag check fault before the actual + * syscall. do_notify_resume() will send a signal to userspace + * before the syscall is restarted. + */ + regs->regs[0] = -ERESTARTNOINTR; + return; + } + if (has_syscall_work(flags)) { /* set default errno for user-issued syscall(-1) */ if (scno == NO_SYSCALL) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel