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.4 required=3.0 tests=BUG6152_INVALID_DATE_TZ_ABSURD,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,INCLUDES_PATCH,INVALID_DATE_TZ_ABSURD,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 89CACCA9EB5 for ; Mon, 4 Nov 2019 13:21:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BD8721E6F for ; Mon, 4 Nov 2019 13:21:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572873670; bh=+ur3cFsLEdysaNjIddhbzZq/BZI5gTX9BdFCF2OwS7M=; h=To:Subject:Date:From:Cc:In-Reply-To:References:List-ID:From; b=qQkF3XG81njEVMNqfDlEJH5tQGXgibam5fEUtpE2vthsd+ltX4nFbR+E8NLvEjsPZ zuAmKQb43N4f/Uc72Khembkk1FHGs+g4FqwQ35/i42SC1FTK0MI5LtNb8VY+ZwQG1E tmzcie6uwJuNJLBu9u5yyXEzk/Wno83HEB9hHtag= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729300AbfKDNVJ (ORCPT ); Mon, 4 Nov 2019 08:21:09 -0500 Received: from inca-roads.misterjones.org ([213.251.177.50]:45446 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727454AbfKDNVI (ORCPT ); Mon, 4 Nov 2019 08:21:08 -0500 Received: from www-data by cheepnis.misterjones.org with local (Exim 4.80) (envelope-from ) id 1iRcHe-00058k-W2; Mon, 04 Nov 2019 14:20:39 +0100 To: Sami Tolvanen Subject: Re: [PATCH v4 13/17] arm64: preserve x18 when CPU is suspended X-PHP-Originating-Script: 0:main.inc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 04 Nov 2019 14:29:59 +0109 From: Marc Zyngier Cc: Will Deacon , Catalin Marinas , Steven Rostedt , Masami Hiramatsu , Ard Biesheuvel , Dave Martin , Kees Cook , Laura Abbott , Mark Rutland , Nick Desaulniers , Jann Horn , Miguel Ojeda , Masahiro Yamada , , , , In-Reply-To: <20191101221150.116536-14-samitolvanen@google.com> References: <20191018161033.261971-1-samitolvanen@google.com> <20191101221150.116536-1-samitolvanen@google.com> <20191101221150.116536-14-samitolvanen@google.com> Message-ID: <02c56a5273f94e9d832182f1b3cb5097@www.loen.fr> X-Sender: maz@kernel.org User-Agent: Roundcube Webmail/0.7.2 X-SA-Exim-Connect-IP: X-SA-Exim-Rcpt-To: samitolvanen@google.com, will@kernel.org, catalin.marinas@arm.com, rostedt@goodmis.org, mhiramat@kernel.org, ard.biesheuvel@linaro.org, dave.martin@arm.com, keescook@chromium.org, labbott@redhat.com, mark.rutland@arm.com, ndesaulniers@google.com, jannh@google.com, miguel.ojeda.sandonis@gmail.com, yamada.masahiro@socionext.com, clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-11-01 23:21, Sami Tolvanen wrote: > Don't lose the current task's shadow stack when the CPU is suspended. > > Signed-off-by: Sami Tolvanen > Reviewed-by: Nick Desaulniers > Reviewed-by: Kees Cook > --- > arch/arm64/include/asm/suspend.h | 2 +- > arch/arm64/mm/proc.S | 10 ++++++++++ > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/include/asm/suspend.h > b/arch/arm64/include/asm/suspend.h > index 8939c87c4dce..0cde2f473971 100644 > --- a/arch/arm64/include/asm/suspend.h > +++ b/arch/arm64/include/asm/suspend.h > @@ -2,7 +2,7 @@ > #ifndef __ASM_SUSPEND_H > #define __ASM_SUSPEND_H > > -#define NR_CTX_REGS 12 > +#define NR_CTX_REGS 13 > #define NR_CALLEE_SAVED_REGS 12 > > /* > diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S > index fdabf40a83c8..5616dc52a033 100644 > --- a/arch/arm64/mm/proc.S > +++ b/arch/arm64/mm/proc.S > @@ -49,6 +49,8 @@ > * cpu_do_suspend - save CPU registers context > * > * x0: virtual address of context pointer > + * > + * This must be kept in sync with struct cpu_suspend_ctx in > . > */ > ENTRY(cpu_do_suspend) > mrs x2, tpidr_el0 > @@ -73,6 +75,9 @@ alternative_endif > stp x8, x9, [x0, #48] > stp x10, x11, [x0, #64] > stp x12, x13, [x0, #80] > +#ifdef CONFIG_SHADOW_CALL_STACK > + str x18, [x0, #96] > +#endif Do we need the #ifdefery here? We didn't add that to the KVM path, and I'd feel better having a single behaviour, specially when NR_CTX_REGS is unconditionally sized to hold 13 regs. > ret > ENDPROC(cpu_do_suspend) > > @@ -89,6 +94,11 @@ ENTRY(cpu_do_resume) > ldp x9, x10, [x0, #48] > ldp x11, x12, [x0, #64] > ldp x13, x14, [x0, #80] > +#ifdef CONFIG_SHADOW_CALL_STACK > + ldr x18, [x0, #96] > + /* Clear the SCS pointer from the state buffer */ > + str xzr, [x0, #96] > +#endif > msr tpidr_el0, x2 > msr tpidrro_el0, x3 > msr contextidr_el1, x4 Thanks, M. -- Jazz is not dead. It just smells funny... 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.3 required=3.0 tests=BUG6152_INVALID_DATE_TZ_ABSURD,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID, INCLUDES_PATCH,INVALID_DATE_TZ_ABSURD,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 2F0EBCA9ED3 for ; Mon, 4 Nov 2019 13:21:11 +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 042D121D7D for ; Mon, 4 Nov 2019 13:21:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="GDNlgvnJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 042D121D7D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:From:Date: MIME-Version:Subject:To:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gLbKOS/mAmOLH7LZkpjHxX7k9I0ppXpqdj4xoKgSkg4=; b=GDNlgvnJ2xaFsTr3AEyTYWRHE IhhmIlj4GiCLedKyjNZo2a2gaphmiSc5JxNYh6VppD3YO4Y62adoXt3EM5tT5kzzavgUSxevW1mC7 7sUevwTYznj7ZgtKl64bf26Vo0pqS/t/mpSBW4PWE2Xd5h0Oia01VHam0TE/W5mVv54KU4dlMm0Cs NwxZEv0uw/QFIfCK9wM0s8fPQ4Q2kSNRGau7sBCCzMnajZ7im+uLkFyGhFhvR6JWlk7e8r6M/i+LS 5ahEGXRmBKsfkCyrlh2vDbQNVJDaBfgc4B8Z1NbJVUb6HT/pctwSh0t0P08ROLPUR3vF6rqOg0wlY H8eEU6DhQ==; 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 1iRcIA-0002Dt-0Q; Mon, 04 Nov 2019 13:21:10 +0000 Received: from inca-roads.misterjones.org ([213.251.177.50]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iRcI7-0002DW-Ba for linux-arm-kernel@lists.infradead.org; Mon, 04 Nov 2019 13:21:08 +0000 Received: from www-data by cheepnis.misterjones.org with local (Exim 4.80) (envelope-from ) id 1iRcHe-00058k-W2; Mon, 04 Nov 2019 14:20:39 +0100 To: Sami Tolvanen Subject: Re: [PATCH v4 13/17] arm64: preserve x18 when CPU is suspended X-PHP-Originating-Script: 0:main.inc MIME-Version: 1.0 Date: Mon, 04 Nov 2019 14:29:59 +0109 From: Marc Zyngier In-Reply-To: <20191101221150.116536-14-samitolvanen@google.com> References: <20191018161033.261971-1-samitolvanen@google.com> <20191101221150.116536-1-samitolvanen@google.com> <20191101221150.116536-14-samitolvanen@google.com> Message-ID: <02c56a5273f94e9d832182f1b3cb5097@www.loen.fr> X-Sender: maz@kernel.org User-Agent: Roundcube Webmail/0.7.2 X-SA-Exim-Connect-IP: X-SA-Exim-Rcpt-To: samitolvanen@google.com, will@kernel.org, catalin.marinas@arm.com, rostedt@goodmis.org, mhiramat@kernel.org, ard.biesheuvel@linaro.org, dave.martin@arm.com, keescook@chromium.org, labbott@redhat.com, mark.rutland@arm.com, ndesaulniers@google.com, jannh@google.com, miguel.ojeda.sandonis@gmail.com, yamada.masahiro@socionext.com, clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191104_052107_549722_0E01706D X-CRM114-Status: GOOD ( 15.17 ) 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: Mark Rutland , Kees Cook , Ard Biesheuvel , Masahiro Yamada , Catalin Marinas , Jann Horn , Nick Desaulniers , linux-kernel@vger.kernel.org, Steven Rostedt , Miguel Ojeda , Masami Hiramatsu , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, Laura Abbott , Will Deacon , Dave Martin , linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2019-11-01 23:21, Sami Tolvanen wrote: > Don't lose the current task's shadow stack when the CPU is suspended. > > Signed-off-by: Sami Tolvanen > Reviewed-by: Nick Desaulniers > Reviewed-by: Kees Cook > --- > arch/arm64/include/asm/suspend.h | 2 +- > arch/arm64/mm/proc.S | 10 ++++++++++ > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/include/asm/suspend.h > b/arch/arm64/include/asm/suspend.h > index 8939c87c4dce..0cde2f473971 100644 > --- a/arch/arm64/include/asm/suspend.h > +++ b/arch/arm64/include/asm/suspend.h > @@ -2,7 +2,7 @@ > #ifndef __ASM_SUSPEND_H > #define __ASM_SUSPEND_H > > -#define NR_CTX_REGS 12 > +#define NR_CTX_REGS 13 > #define NR_CALLEE_SAVED_REGS 12 > > /* > diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S > index fdabf40a83c8..5616dc52a033 100644 > --- a/arch/arm64/mm/proc.S > +++ b/arch/arm64/mm/proc.S > @@ -49,6 +49,8 @@ > * cpu_do_suspend - save CPU registers context > * > * x0: virtual address of context pointer > + * > + * This must be kept in sync with struct cpu_suspend_ctx in > . > */ > ENTRY(cpu_do_suspend) > mrs x2, tpidr_el0 > @@ -73,6 +75,9 @@ alternative_endif > stp x8, x9, [x0, #48] > stp x10, x11, [x0, #64] > stp x12, x13, [x0, #80] > +#ifdef CONFIG_SHADOW_CALL_STACK > + str x18, [x0, #96] > +#endif Do we need the #ifdefery here? We didn't add that to the KVM path, and I'd feel better having a single behaviour, specially when NR_CTX_REGS is unconditionally sized to hold 13 regs. > ret > ENDPROC(cpu_do_suspend) > > @@ -89,6 +94,11 @@ ENTRY(cpu_do_resume) > ldp x9, x10, [x0, #48] > ldp x11, x12, [x0, #64] > ldp x13, x14, [x0, #80] > +#ifdef CONFIG_SHADOW_CALL_STACK > + ldr x18, [x0, #96] > + /* Clear the SCS pointer from the state buffer */ > + str xzr, [x0, #96] > +#endif > msr tpidr_el0, x2 > msr tpidrro_el0, x3 > msr contextidr_el1, x4 Thanks, M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel