From patchwork Thu Feb 10 22:41:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 12742499 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 C3A64C433EF for ; Thu, 10 Feb 2022 22:47:24 +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=NWx7Yv3oPfgJ3pnKIMqLGd5Eq9hC+I/ba9Zc7R8gIlo=; b=RYZgStIKv2IkJ/ glYS3qBF0Rg5gsHpTmnKI8OBFMcS5gQ+vGZ0wRwvZ5+S+xXCGOpNP+XS830O4mgl/1N213DydPx+/ pupWsLvRXAZMfDW01Uz1fmgDj2uOV7mC6o2jZwEU4utKMN6E7A0nqrLm+02D6uTlJESWVk4fSRAvK fHP4m2gFCipV64INSfLHe6P+BFvlwky37FiBwJEMyPJ94OeBUd6jJ7pIjqRIBMDqM6p2/1B3amDkO nooz1qi9D/UsRRrwxDQ0DAr3vayOo+gLQmAhSCmosPggPagOFoQI2qtX8xyJSAuL6ha5tR4Vd3cHI vNRRtVWobGgbB76w0o/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIICW-0054VZ-3f; Thu, 10 Feb 2022 22:46:08 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIICQ-0054So-NB for linux-arm-kernel@lists.infradead.org; Thu, 10 Feb 2022 22:46:05 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id b64-20020a256743000000b0061e169a5f19so14658968ybc.11 for ; Thu, 10 Feb 2022 14:46:01 -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=/IZyRrpjogHkvvKAbn/wuM+XhkmHZlGRNHWt0e5zr8A=; b=PBkmRwuFiGGrv5iRHo7tLluafzQlZXF9AN4cUQvrlWacXQcrnAlFwCuc/zOtvTnj3A eyIK8Dr7DfK8BlaH06yRYxaDcs2bvmYni1BgVFeXEqyLnH4uCPmVWvtXo1p/9EFiq8OK yozHbjdo5J8wCe1HRkEpfHLkD8SJn8NzBv9iKIQrno5l1WcFw65NEM8NvqQ6xCxV2EW5 EPhU/2linown0tcJ3M3OITrVQ+B7l8BdSNdus0cc0Zg5pAix41rloxydzHuthJS8zX7p ctJ0Xrcr/w2hgACd8f01767tNpufMelYYz/KRWp+lszWzveeyi2sIdj7lorWwXkseetK RatA== 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=/IZyRrpjogHkvvKAbn/wuM+XhkmHZlGRNHWt0e5zr8A=; b=PcLMv8Em3lunsfc2TNt+AHAp9a4NQ6vJ74lFIuj0Vc5xNZxsovy/4a42dQqtw5kGTm jw0R3mCMiLuuFKYgkA6IK9ZYogMU7jF5QN6mAYPJUtkxCI1xNWEkVqECH317AcEocjBL 8At770+8W9cbOoGs2JWebgjy4xJOJi4Sd3+dQs+GgNNgvHt6wmjN6amSJteZu3QJtZ/o UzuWJwCPWFy3AsFyzUOx6rcqzWgDgGbdhqch67BNJgQk9mvWf3PNtB7T9oYC6hsipLSy 8+vs8RmEJoeUZG8be+4sxHgxb3BZrbBGt48lWiqehs9fk7Gaep+lwdHSWbL9OK5ZgpJb 7xIQ== X-Gm-Message-State: AOAM531k8pSAGddLju/qHYzAwDUw8YRckYCHf9eM5cZrDRBrfpUdYODD CbrpawzQgAYCLeiq6GeMiIlZyMQdXonGrPFrqQ== X-Google-Smtp-Source: ABdhPJxltTVLo3VOurL3QnroR1cp79bh23NqnvdKXTYN3qVmilP7Lx3u//hZdXpNdmMvGA/0NZZ08lArO17mKqkodg== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:8f02:232:ad86:2ab2]) (user=kaleshsingh job=sendgmr) by 2002:a81:3494:: with SMTP id b142mr9302016ywa.246.1644533161146; Thu, 10 Feb 2022 14:46:01 -0800 (PST) Date: Thu, 10 Feb 2022 14:41:46 -0800 In-Reply-To: <20220210224220.4076151-1-kaleshsingh@google.com> Message-Id: <20220210224220.4076151-6-kaleshsingh@google.com> Mime-Version: 1.0 References: <20220210224220.4076151-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog Subject: [PATCH 5/7] KVM: arm64: Add Hyp 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 , Catalin Marinas , James Morse , Alexandru Elisei , Suzuki K Poulose , Ard Biesheuvel , Mark Rutland , Pasha Tatashin , Joey Gouly , Peter Collingbourne , Andrew Scull , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220210_144602_782161_A3BD3406 X-CRM114-Status: GOOD ( 12.84 ) 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/setup.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 78e4b612ac06..751a4b9e429f 100644 --- a/arch/arm64/kvm/hyp/nvhe/host.S +++ b/arch/arm64/kvm/hyp/nvhe/host.S @@ -171,6 +171,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 @@ -178,6 +182,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/setup.c b/arch/arm64/kvm/hyp/nvhe/setup.c index 114053dff228..39937fa6a1b2 100644 --- a/arch/arm64/kvm/hyp/nvhe/setup.c +++ b/arch/arm64/kvm/hyp/nvhe/setup.c @@ -20,6 +20,11 @@ unsigned long hyp_nr_cpus; +#ifdef CONFIG_NVHE_EL2_DEBUG +DEFINE_PER_CPU(unsigned long [PAGE_SIZE/sizeof(long)], hyp_overflow_stack) + __aligned(16); +#endif + #define hyp_percpu_size ((unsigned long)__per_cpu_end - \ (unsigned long)__per_cpu_start)