Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp485260imn; Tue, 26 Jul 2022 00:46:33 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vZbrOqQrbExqEQlBDvZlQ11Rr5c241F2tAYOdrxDhYFMzbFZpVg4WEmp21Es6VjOc24U89 X-Received: by 2002:a05:6402:5388:b0:435:71b:5d44 with SMTP id ew8-20020a056402538800b00435071b5d44mr16691004edb.364.1658821593382; Tue, 26 Jul 2022 00:46:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658821593; cv=none; d=google.com; s=arc-20160816; b=P+aKjHXgCVdiClidZm/lit61w2VRUThVyyrS3KqawHUfFecowZvd+fbOvVLBvvgnBM m52510iHi/bt2p9XNYuDAuA51SrFRdnXZZzOctb8XwZ1dHViO+e17eNI+IMTl1MUXRKa nP3hkr4vNkXVenu9SzzRCrrJCY+44mTOOi6dRxJ08JU7YKuloFV+Dy/q0zJLIGEihrVi hCBRnBiY14iJhFInEZs296/UCOwb1DlRVjl/YwdeehIvXa4fSnf/K5LczlaCBo1hxgn+ OAPFLrpWZOgOtUXWF0NWcpgXWC012tZXobNBkUomeeIwbX2W3sILfr342WAkQEqokueL uVKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=jVgz/szeSDEehPkBGFOtiG6TH4cWoSnAE1JEiuFeF4M=; b=LZLfSLX2VKUzIc2NTmRIGe+cww3eOhMtqhUdT0Lfbu7eiVdgn1IQ8lJ0/JreO/sg+u xc2AD6D4vPGH6lQ3xktfHCoUqeu33tVCZ3QMxq8dl+4EusAQD2t0QtF6SyUhDIGiiTTF 3aQFHSelG5i6Ze4IkJH+yrYSXLBrbfuazFy2KZudaPoV63dYGUkDueTL786zBAnSP1M/ gxZ0rgtshp4bpaYpdeIQQnK5BCMicIIfU1IHbQr5lWCJVBFfFQqVA0/VygTWzayGNVcD mYZ5NYHu7HyE9hRX+iZAJSogFb3rTX66n6VulOBfcHSGakQDu/WUMUp3nH2AhiW6EsJT 0Frg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="C8Yf1l5/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w15-20020a1709061f0f00b0072b3338c3absi14632502ejj.878.2022.07.26.00.46.08; Tue, 26 Jul 2022 00:46:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="C8Yf1l5/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238109AbiGZHjs (ORCPT + 99 others); Tue, 26 Jul 2022 03:39:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238423AbiGZHin (ORCPT ); Tue, 26 Jul 2022 03:38:43 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB5F41FE for ; Tue, 26 Jul 2022 00:38:12 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id b129-20020a25e487000000b0066e1c52ac55so10471327ybh.11 for ; Tue, 26 Jul 2022 00:38:12 -0700 (PDT) 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:to :cc; bh=jVgz/szeSDEehPkBGFOtiG6TH4cWoSnAE1JEiuFeF4M=; b=C8Yf1l5/uTkII4CdB1cNpCvsxEc+28PsYTXUIba+64kfS7ozSMTCfLNCiyBvwQNoYx v4tLxHFGn1NugmrjBRhPGqOdAZyJXo6plyN8kY2kxqrqmVq3LsXugD6jJievh78HX1KU 8SV94Q4buvRguuD8HdNpI5/LLT4QrCi5nivUYVxFdpMWinuWqv8Wjo2CCaEzyts5qj2l xJc8atY4LJrRDy1iJjqOnQ7dmFBLYGMRuagGcaTc0e7clYvr/Z70nvyA4TtGSrPQOrH8 Y5fQN/ePeHrKVVNVIg/c62DaamTj1boYjZ/CNnJsQw/brcmyDLOOKu7s7UrMm8NQL9ED RE3A== 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:to:cc; bh=jVgz/szeSDEehPkBGFOtiG6TH4cWoSnAE1JEiuFeF4M=; b=W6nX1aoPvnYa+bXVErtL49UShvknb/Hou7Yd2xcygoO1HB1XxidJFEkWQldbURoIBM qQEEbnYWHUPu6hg1vhFuiCZEuECf1TRlY9/u8ool25QJwPW3hBIeic/XLVpUfo74u1Mz E1RrYbJRgfjXdkwndk/a9wdBKcUegf5+jrgyPXEQJB/2Ye1VhgiXePyYbzuiQ4eK50Dc IhbJHdmWVApc3d7BEaCQGMbpSoXx1ZrnCOxc5uOPHJzWLMBMvyxMOQ9dishS6v/DHPt6 K5n1Ms+2ZSL28+5UbYDqQCnHgZEw1OV3TDXNtV3k1zFg8OXA4s6UJ0KAp4aLbQZlXM0a P1vQ== X-Gm-Message-State: AJIora9SB0aIOImFbwiQ/p4mAPd9EWkfn4QmEW1QUKnqgG6g8fDgt1t4 0HbM7aLItGC34X/VTYjC18XNtzM5HHx5VUeUlw== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:4f77:3b64:736a:394e]) (user=kaleshsingh job=sendgmr) by 2002:a05:6902:1613:b0:671:2e0c:dda1 with SMTP id bw19-20020a056902161300b006712e0cdda1mr7585688ybb.514.1658821092633; Tue, 26 Jul 2022 00:38:12 -0700 (PDT) Date: Tue, 26 Jul 2022 00:37:40 -0700 In-Reply-To: <20220726073750.3219117-1-kaleshsingh@google.com> Message-Id: <20220726073750.3219117-8-kaleshsingh@google.com> Mime-Version: 1.0 References: <20220726073750.3219117-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.37.1.359.gd136c6c3e2-goog Subject: [PATCH v6 07/17] KVM: arm64: On stack overflow switch to hyp overflow_stack From: Kalesh Singh To: maz@kernel.org, mark.rutland@arm.com, broonie@kernel.org, madvenka@linux.microsoft.com, tabba@google.com, oliver.upton@linux.dev Cc: will@kernel.org, qperret@google.com, kaleshsingh@google.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, andreyknvl@gmail.com, vincenzo.frascino@arm.com, mhiramat@kernel.org, ast@kernel.org, wangkefeng.wang@huawei.com, elver@google.com, keirf@google.com, yuzenghui@huawei.com, ardb@kernel.org, oupton@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, android-mm@google.com, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham 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 hyp stack overflow switch to 16-byte aligned secondary stack. 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 Reviewed-by: Fuad Tabba Tested-by: Fuad Tabba --- Changes in v6: - Add Fuad's Tested-by tag Changes in v5: - Add Reviewed-by tag from Fuad arch/arm64/kvm/hyp/nvhe/Makefile | 2 +- arch/arm64/kvm/hyp/nvhe/host.S | 9 ++------- arch/arm64/kvm/hyp/nvhe/stacktrace.c | 11 +++++++++++ 3 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 arch/arm64/kvm/hyp/nvhe/stacktrace.c diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Makefile index f9fe4dc21b1f..524e7dad5739 100644 --- a/arch/arm64/kvm/hyp/nvhe/Makefile +++ b/arch/arm64/kvm/hyp/nvhe/Makefile @@ -14,7 +14,7 @@ lib-objs := $(addprefix ../../../lib/, $(lib-objs)) obj-y := timer-sr.o sysreg-sr.o debug-sr.o switch.o tlb.o hyp-init.o host.o \ hyp-main.o hyp-smp.o psci-relay.o early_alloc.o page_alloc.o \ - cache.o setup.o mm.o mem_protect.o sys_regs.o pkvm.o + cache.o setup.o mm.o mem_protect.o sys_regs.o pkvm.o stacktrace.o obj-y += ../vgic-v3-sr.o ../aarch32.o ../vgic-v2-cpuif-proxy.o ../entry.o \ ../fpsimd.o ../hyp-entry.o ../exception.o ../pgtable.o obj-$(CONFIG_DEBUG_LIST) += list_debug.o diff --git a/arch/arm64/kvm/hyp/nvhe/host.S b/arch/arm64/kvm/hyp/nvhe/host.S index ea6a397b64a6..b6c0188c4b35 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 + OVERFLOW_STACK_SIZE, x0 b hyp_panic_bad_stack ASM_BUG() diff --git a/arch/arm64/kvm/hyp/nvhe/stacktrace.c b/arch/arm64/kvm/hyp/nvhe/stacktrace.c new file mode 100644 index 000000000000..a3d5b34e1249 --- /dev/null +++ b/arch/arm64/kvm/hyp/nvhe/stacktrace.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * KVM nVHE hypervisor stack tracing support. + * + * Copyright (C) 2022 Google LLC + */ +#include +#include + +DEFINE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack) + __aligned(16); -- 2.37.1.359.gd136c6c3e2-goog