From patchwork Thu Feb 24 05:13:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 12757846 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E8EC9C433FE for ; Thu, 24 Feb 2022 05:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:From:Subject:References:Mime-Version :Message-Id:In-Reply-To:Date:Reply-To:To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uXNl7XyZZDmRGVwwvcu4cO+STqdo780dy02jkOKf1Dw=; b=vA9bXEuNbvXMT3 irvkee1sBlfkkPbdw4+tbSsC76FH09QMAuYkj/qFeANVNc45+FCuov42dMcC+cMJjcrzAMvzMOzc3 HDV6F0A2X4RrQN2pw5PZetQtcUocLVYZGyRMI1WSGCwwQpSQboW5ADrKngewvBo6NCohAO68ev/7i FB9H0dnD+JT+451++6GD27ootloNxqo6jriDfFi6ehzhhPQ5nAJIc6UuFduIPryvy+OSOjO89LHht WWePh4TrDGYCMEJ+bYKMV+KqOH4G7b+RrJQ7ZxWvlgTCEtvEmCFgTleKWsHpROQ8he3ao7ll5/+zi ZMXAxWWhfEQBmHwuuItA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nN6ZC-00Gr54-HQ; Thu, 24 Feb 2022 05:21:26 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nN6Z8-00Gr3J-Dx for linux-arm-kernel@lists.infradead.org; Thu, 24 Feb 2022 05:21:23 +0000 Received: by mail-yb1-xb49.google.com with SMTP id i6-20020a255406000000b006241e97e420so940840ybb.5 for ; Wed, 23 Feb 2022 21:21:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:cc; bh=v7H+YHEXea4IIqGySI7aLREzIvLtpBuCKjmvH1cIeXQ=; b=NulZA7w/XH6Ovox3Z8EPA5m/C/4Cu5qNglcuNmoAQGiwk4ZsQUEDaqrrza3kj0/rO1 4AIBYeKLpSv0/Y0kyPuD0iIaYP+rfQjHEEPqR6hATVEXSiEGw1puhIgCf0xl4KrRv9Ze bf3X6bGXRtPd3AVhIvpnfTipQKZ7kaRoy2V22FK420mGJNxu4NBXNZkGrPE31FXO18uL p5giufi9NXloDjTBFhB+FZiUOIrIvZ5VdVoH+krscvWKPlnWpw3VycB1f6vXmcZ/3Bcy kQgU10gE8FIBPttAIaRsih5zbrOFWZVcM3EhGsNnh5UyKz3q6san4735fgWDpsuyGnfD vTQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:cc; bh=v7H+YHEXea4IIqGySI7aLREzIvLtpBuCKjmvH1cIeXQ=; b=4jW5BKhfVp6pscaPCwC4N8tAf22gexkHhdeyYDcJox8GtUllcrBbj/EMNq/5ea/kGy Q/alC5z/ObGtpkiZrsi0Z1jlkn0OsJ1dSHwjMabUFGtTmvS56nmKMTxg15AhLVoBNC1r J8L3aSqhk1kRcgwsdqVpwCm0BMIOU0ztAHKVc4unJpwkMSVMVNdpnB2VvIkU6lFaLGoy +AWLs/j/VOQPQ20yIZqgOfnWgkhOvR2vvfT6uSNvWFy/bEIwqu0kr3hztZHYhoNiNVKR Xyg+A7D7xhyeY5APcMva4DaKxABd+dWQquYk/OE4A7ua3AgrsYN5YR0YC+MdM28KUyIR orFA== X-Gm-Message-State: AOAM531LMxhCSA7KL8BV7WF4C0R/kLq9EuRZFAzoA8ShOny6YJs/uypc FTNJ+ax3f5Ap0XckCLa/ZmVKdhM842bUk+Nc2A== X-Google-Smtp-Source: ABdhPJyGTlGm+C/X/WYwJEpFuocVcINp/xR0sgVssDAtD0IXfiwn+elCX3UtU0cHn8Y6Lskq6uXxQyXVu8faJREUXQ== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:415c:9be0:c461:440a]) (user=kaleshsingh job=sendgmr) by 2002:a25:9108:0:b0:61e:329:700 with SMTP id v8-20020a259108000000b0061e03290700mr976530ybl.369.1645680080321; Wed, 23 Feb 2022 21:21:20 -0800 (PST) Date: Wed, 23 Feb 2022 21:13:41 -0800 In-Reply-To: <20220224051439.640768-1-kaleshsingh@google.com> Message-Id: <20220224051439.640768-7-kaleshsingh@google.com> Mime-Version: 1.0 References: <20220224051439.640768-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.35.1.473.g83b2b277ed-goog Subject: [PATCH v3 6/8] KVM: arm64: Add hypervisor overflow stack From: Kalesh Singh Cc: will@kernel.org, maz@kernel.org, qperret@google.com, tabba@google.com, surenb@google.com, kernel-team@android.com, Kalesh Singh , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Mark Rutland , Mark Brown , Masami Hiramatsu , Peter Collingbourne , "Madhavan T. Venkataraman" , Andrew Walbran , Andrew Scull , Zenghui Yu , Ard Biesheuvel , Paolo Bonzini , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220223_212122_510740_F7E30BC6 X-CRM114-Status: GOOD ( 13.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. The overflow stack is only allocated if CONFIG_NVHE_EL2_DEBUG is enabled, as hypervisor stacktraces is a debug feature dependent on CONFIG_NVHE_EL2_DEBUG. Signed-off-by: Kalesh Singh --- arch/arm64/kvm/hyp/nvhe/host.S | 5 +++++ arch/arm64/kvm/hyp/nvhe/switch.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/host.S b/arch/arm64/kvm/hyp/nvhe/host.S index 749961bfa5ba..367a01e8abed 100644 --- a/arch/arm64/kvm/hyp/nvhe/host.S +++ b/arch/arm64/kvm/hyp/nvhe/host.S @@ -179,6 +179,10 @@ SYM_FUNC_END(__host_hvc) b hyp_panic .L__hyp_sp_overflow\@: +#ifdef CONFIG_NVHE_EL2_DEBUG + /* Switch to the overflow stack */ + adr_this_cpu sp, hyp_overflow_stack + PAGE_SIZE, x0 +#else /* * 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 @@ -186,6 +190,7 @@ SYM_FUNC_END(__host_hvc) */ ldr_this_cpu x0, kvm_init_params + NVHE_INIT_STACK_HYP_VA, x1 mov sp, x0 +#endif bl hyp_panic_bad_stack ASM_BUG() diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c index 703a5d3f611b..efc20273a352 100644 --- a/arch/arm64/kvm/hyp/nvhe/switch.c +++ b/arch/arm64/kvm/hyp/nvhe/switch.c @@ -34,6 +34,11 @@ DEFINE_PER_CPU(struct kvm_host_data, kvm_host_data); DEFINE_PER_CPU(struct kvm_cpu_context, kvm_hyp_ctxt); DEFINE_PER_CPU(unsigned long, kvm_hyp_vector); +#ifdef CONFIG_NVHE_EL2_DEBUG +DEFINE_PER_CPU(unsigned long [PAGE_SIZE/sizeof(long)], hyp_overflow_stack) + __aligned(16); +#endif + static void __activate_traps(struct kvm_vcpu *vcpu) { u64 val;