Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2302213iof; Wed, 8 Jun 2022 01:55:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcubcbhd+FOsnq6KFeo7g9/tdUJCmn2z8+Gyk+CAZkcYfhztUTYRvnkB8o0MEaD38s3EtK X-Received: by 2002:a17:90b:4b48:b0:1e8:7df8:1e25 with SMTP id mi8-20020a17090b4b4800b001e87df81e25mr16521773pjb.186.1654678547357; Wed, 08 Jun 2022 01:55:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654678547; cv=none; d=google.com; s=arc-20160816; b=Qe6axnUWI8MNFl+Us6cK50v24+yXT0RFXOQA9Sl8A8YY4EtiX8y86jcY0k/qdVBVWP wYaI/Nmx0jaAb2mCEk98zmkxC6fJx9ronjBPVoHwerJ2oN2UtgJaEgWhb7JTpMI1YUWc vO5mcmuBeVIGTNi2TBljLt1oeOD20cCSxjXG84IOH9Q4LKo9B+j/yylHCiPOzLbN4RB6 og/Mnu03I7G84ZP5wNxm5J9Et8FDKC3NEHyw0R+n5f/9oxaDFfrd6XkbUJCc+tCaRllG q27gPF8voX6KI/8s0ZaBPFkSLzjaCwnBU8q+ZvnMngkUEdPZ78ZVrGiHFGoddvTHk3cJ eRKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=T+91DYFNFX2HEef3iVKp7J+dZiUxvoyQpyNf8jgYTFk=; b=YKGWkjOcvxOOoSJDXHf8Hh0GHjNSZyWMGGG52Vne9ouOKsFzrmWrRCigXLUTzxrmBz ZDrIQZGyDyZxkPpnIJ945NQYxD37sxcF+R90mNHwNULKtEblkYBaL7zZI/OqAXxP6frs UUHIWYPwiNmq0y8HhCBoWwZn6Pl80hHDlLOBEUbTbAzjbMkuQWIEQVAMV+X3W6bWindr OnB2lm/0+yiHDThUR14J8kGP0XGs6+0qMyB2JVBwnYpeAVIstZTKhgO1uwmjxuRMQU8w 0PdaZVDuJYyk8tI6WtuKNhsZ75HaJkMW+WbCj57YJD84zC6AtghmmkfMcdluhNcD7cDS e7Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qEaE9E6N; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id jc18-20020a17090325d200b00163ed1aff09si25086375plb.337.2022.06.08.01.55.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:55:47 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qEaE9E6N; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E6DEB3A79C7; Wed, 8 Jun 2022 01:18:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231773AbiFHIBp (ORCPT + 99 others); Wed, 8 Jun 2022 04:01:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230012AbiFHIBb (ORCPT ); Wed, 8 Jun 2022 04:01:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEB1623B949 for ; Wed, 8 Jun 2022 00:34:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B992E614FC for ; Wed, 8 Jun 2022 07:34:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22DD2C34116; Wed, 8 Jun 2022 07:34:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654673645; bh=zUAriSoqt7X75BSYiptDA8HT+jFpatA1VwWFOOuCHJU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qEaE9E6N5v30L8JQ3VERoWqoGcxl8hjBVPm9K5ojoQJfgnnWatnqWxG4DP8/xS08Y owgC1hj6TgQHhVZmWYY07U4Hr4n7znTtDHnqs84R3TKN5D6JAaOti4R2JeDo4yPd86 LGx2N9NpwuDbOuk+nao/8IwB8iIyRqwtRG1NSmDkbd7OU9NHPkZV+kM/RMaGs7GksU o5Nvb/O3ljrUr4Y+aY6Z2Ub4n7QZPPuwSFhI+7WsT+gkooyreYBFNJwr9iysfWhfIw lIcr5/Utb29CLYN2QUa/09Zn+YLbk6pfaNGBlRvSY2C1yAReeyCxIEnhV1qnGHK51b pSCFuLuNYzfuQ== Received: from ip-185-104-136-29.ptr.icomera.net ([185.104.136.29] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nyqCY-00GWcs-UT; Wed, 08 Jun 2022 08:34:03 +0100 Date: Wed, 08 Jun 2022 08:33:59 +0100 Message-ID: <87k09rzk0o.wl-maz@kernel.org> From: Marc Zyngier To: Kalesh Singh Cc: mark.rutland@arm.com, broonie@kernel.org, will@kernel.org, qperret@google.com, tabba@google.com, surenb@google.com, tjmercier@google.com, kernel-team@android.com, James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Masami Hiramatsu , Alexei Starovoitov , "Madhavan T. Venkataraman" , Peter Zijlstra , Andrew Jones , Zenghui Yu , Kefeng Wang , Keir Fraser , Ard Biesheuvel , Oliver Upton , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/5] KVM: arm64: Add hypervisor overflow stack In-Reply-To: <20220607165105.639716-4-kaleshsingh@google.com> References: <20220607165105.639716-1-kaleshsingh@google.com> <20220607165105.639716-4-kaleshsingh@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.104.136.29 X-SA-Exim-Rcpt-To: kaleshsingh@google.com, mark.rutland@arm.com, broonie@kernel.org, will@kernel.org, qperret@google.com, tabba@google.com, surenb@google.com, tjmercier@google.com, kernel-team@android.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, mhiramat@kernel.org, ast@kernel.org, madvenka@linux.microsoft.com, peterz@infradead.org, drjones@redhat.com, yuzenghui@huawei.com, wangkefeng.wang@huawei.com, keirf@google.com, ardb@kernel.org, oupton@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 07 Jun 2022 17:50:45 +0100, Kalesh Singh wrote: > > Allocate and switch to 16-byte aligned secondary stack on overflow. This > provides us stack space to better handle overflows; and is used in > a subsequent patch to dump the hypervisor stacktrace. > > Signed-off-by: Kalesh Singh > --- > arch/arm64/kernel/stacktrace.c | 3 +++ > arch/arm64/kvm/hyp/nvhe/host.S | 9 ++------- > 2 files changed, 5 insertions(+), 7 deletions(-) > > diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c > index a84e38d41d38..f346b4c66f1c 100644 > --- a/arch/arm64/kernel/stacktrace.c > +++ b/arch/arm64/kernel/stacktrace.c > @@ -242,4 +242,7 @@ noinline notrace void arch_stack_walk(stack_trace_consume_fn consume_entry, > > unwind(task, &state, consume_entry, cookie); > } > +#else /* __KVM_NVHE_HYPERVISOR__ */ > +DEFINE_PER_CPU(unsigned long [PAGE_SIZE/sizeof(long)], overflow_stack) > + __aligned(16); Does this need to be a whole page? With 64kB pages, this is potentially a lot of memory for something that will hardly ever be used. The rest of the kernel limits this to 4kB, which seems more reasonable. There is no guard page anyway, so PAGE_SIZE doesn't provide any extra protection. > #endif /* !__KVM_NVHE_HYPERVISOR__ */ > diff --git a/arch/arm64/kvm/hyp/nvhe/host.S b/arch/arm64/kvm/hyp/nvhe/host.S > index ea6a397b64a6..4e3032a244e1 100644 > --- a/arch/arm64/kvm/hyp/nvhe/host.S > +++ b/arch/arm64/kvm/hyp/nvhe/host.S > @@ -177,13 +177,8 @@ SYM_FUNC_END(__host_hvc) > b hyp_panic > > .L__hyp_sp_overflow\@: > - /* > - * Reset SP to the top of the stack, to allow handling the hyp_panic. > - * This corrupts the stack but is ok, since we won't be attempting > - * any unwinding here. > - */ > - ldr_this_cpu x0, kvm_init_params + NVHE_INIT_STACK_HYP_VA, x1 > - mov sp, x0 > + /* Switch to the overflow stack */ > + adr_this_cpu sp, overflow_stack + PAGE_SIZE, x0 > > b hyp_panic_bad_stack > ASM_BUG() > -- > 2.36.1.255.ge46751e96f-goog > > Thanks, M. -- Without deviation from the norm, progress is not possible.