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,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 3D02ECA9EB5 for ; Mon, 4 Nov 2019 13:21:14 +0000 (UTC) Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.kernel.org (Postfix) with SMTP id 9523421D7D for ; Mon, 4 Nov 2019 13:21:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9523421D7D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernel-hardening-return-17259-kernel-hardening=archiver.kernel.org@lists.openwall.com Received: (qmail 3134 invoked by uid 550); 4 Nov 2019 13:21:07 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Received: (qmail 3114 invoked from network); 4 Nov 2019 13:21:07 -0000 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 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...