From patchwork Fri Jul 15 06:10:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 12918782 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 162D5C43334 for ; Fri, 15 Jul 2022 06:20:18 +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:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=kV2H/8BH2W/QoRm5x4boAKB7fJirf8f/iIVXwl4hxHc=; b=sc2uvGBvv/gI6OCg/1ZHJoFDVW omJDaDE9Cgv0H+BNYjaai76cJKeRrBmxEhfLtNk9sbUBZJ7eqGy4Hylw4YBWD8dfCxmL10L0y3ikw pqQJsqVFdhTO6QMOGN/kdkvSL6RxU3V9dG889byvCIY9G89sIk261WIWcbmtPv/zqpZZ3MD1KpXcn 8xyPtoXUyvQ/TIMpRzYwQdqOBkhEQptbPxOGNQPuHFon1kgm4oBwDIi9B/pHr9njAwP2hcdPqw/Ph LdWoBjWWITsoXCovwjCUA+WI2NvIagIW3YneQv8k6LAfvYbiM0a5HvEtqP2D6qoxjOdezvZ3yDa04 x9PrjsPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCEfE-004ZUd-Q6; Fri, 15 Jul 2022 06:19:01 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCEYJ-004WZv-2n for linux-arm-kernel@lists.infradead.org; Fri, 15 Jul 2022 06:11:52 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-31c9a49a1a8so33281317b3.9 for ; Thu, 14 Jul 2022 23:11:50 -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=C+9RN60EOV8842FFgmBAy6PrpfwWqW7C+czhzeS/rR4=; b=YBfbYLBhEFURhCK4QKUC8bI/R6G7EXpPYpXv8EgvXFE5JI8iCfdDD/zhxXUPJ1FCj2 HobAgwdJcz8iCJZ3Nf6qUn5/JFvFqTXwTbxs1Vp8JQ5DiIGMNOmoxWd8ZFtzh4zWdbW2 UXXqKfjRvUH0FaeGEFgQrLpiSfFzw/8JrEAdOPLimA7QNNMLXVfCXV7aWgjExnRC71PE st+L76+Nt2+hlQM0Y7sQ2cwdVY2C1xVk2yx3eg9khBifSFQMmA4ZOR9Djwd7LeLopeWE xiMe9XRODecY4NQkbUkZ8/WtMreqsn6dA6vGRjB7aYLob2bWXnsgyxD5ML6TZoiDhcWj CuIQ== 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=C+9RN60EOV8842FFgmBAy6PrpfwWqW7C+czhzeS/rR4=; b=kIq2W9xNRdN8uZJ51LN5BOoLdwhRQSMh6mtTryZmOP8EEV2yjpMenltF5No/T0bh4Y E2ayjT4W/M3ZtrWIVNscgeu7kvhRjlLooNyIgC0LEojU6QysG2tgljim86eeT+9fR9Rb NLHDOQHLzImUkvyVlvNlm2sOjavuH13qnJ0xL/CgR7RzTAfi2X76xma18AzB1F8KWm6K ZkXLfA07/j9WgDiGqYftVJC8av8FYMipZ4AtfunOmGKMYlgV8XHLMfQ27WZezEUVcOHh 1WEqmES2t0kIgLZ5zYygPElKq1b2H6K7oTOVCH6EsOGfwUfmRbyAwNx3b/znxYdub2sW YYdw== X-Gm-Message-State: AJIora/cK3CtwiohFuYsgbHRi1o5J9YVazGQDyADHyyxwHi0OLhxl7wj 5DLh+sEibO5QahhgvSEI04TTyCTOGFFQy8am7w== X-Google-Smtp-Source: AGRyM1vmpZrg9C65GGAVW8i3cJzkzgqCICriOC0RsFfWEe5JJODK8w4KS6U/1MhBLlAvC1UTH/ak2+fLI6MXcu3Qzw== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:f010:455b:62ce:19e]) (user=kaleshsingh job=sendgmr) by 2002:a5b:44d:0:b0:66f:ad5a:9d0b with SMTP id s13-20020a5b044d000000b0066fad5a9d0bmr10986561ybp.79.1657865509675; Thu, 14 Jul 2022 23:11:49 -0700 (PDT) Date: Thu, 14 Jul 2022 23:10:27 -0700 In-Reply-To: <20220715061027.1612149-1-kaleshsingh@google.com> Message-Id: <20220715061027.1612149-19-kaleshsingh@google.com> Mime-Version: 1.0 References: <20220715061027.1612149-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog Subject: [PATCH v4 18/18] KVM: arm64: Dump nVHE hypervisor stack on panic From: Kalesh Singh To: maz@kernel.org, mark.rutland@arm.com, broonie@kernel.org, madvenka@linux.microsoft.com Cc: will@kernel.org, qperret@google.com, tabba@google.com, kaleshsingh@google.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, andreyknvl@gmail.com, russell.king@oracle.com, vincenzo.frascino@arm.com, mhiramat@kernel.org, ast@kernel.org, drjones@redhat.com, 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220714_231151_179920_2471A780 X-CRM114-Status: GOOD ( 11.35 ) 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 On hyp_panic(), unwind and dump the nVHE hypervisor stack trace. In protected nVHE mode, hypervisor stacktraces are only produced if CONFIG_PROTECTED_NVHE_STACKTRACE is enabled. Example backtrace: [ 126.862960] kvm [371]: nVHE hyp panic at: [] __kvm_nvhe_recursive_death+0x10/0x34! [ 126.869920] kvm [371]: Protected nVHE HYP call trace: [ 126.870528] kvm [371]: [] __kvm_nvhe_hyp_panic+0xac/0xf8 [ 126.871342] kvm [371]: [] __kvm_nvhe_hyp_panic_bad_stack+0x10/0x10 [ 126.872174] kvm [371]: [] __kvm_nvhe_recursive_death+0x24/0x34 [ 126.872971] kvm [371]: [] __kvm_nvhe_recursive_death+0x24/0x34 . . . [ 126.927314] kvm [371]: [] __kvm_nvhe_recursive_death+0x24/0x34 [ 126.927727] kvm [371]: [] __kvm_nvhe_recursive_death+0x24/0x34 [ 126.928137] kvm [371]: [] __kvm_nvhe___kvm_vcpu_run+0x30/0x40c [ 126.928561] kvm [371]: [] __kvm_nvhe_handle___kvm_vcpu_run+0x30/0x48 [ 126.928984] kvm [371]: [] __kvm_nvhe_handle_trap+0xc4/0x128 [ 126.929385] kvm [371]: [] __kvm_nvhe___host_exit+0x64/0x64 [ 126.929804] kvm [371]: ---- End of Protected nVHE HYP call trace ---- Signed-off-by: Kalesh Singh --- arch/arm64/kvm/handle_exit.c | 4 ++++ arch/arm64/kvm/hyp/nvhe/switch.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index f66c0142b335..ef8b57953aa2 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -353,6 +354,9 @@ void __noreturn __cold nvhe_hyp_panic_handler(u64 esr, u64 spsr, (void *)panic_addr); } + /* Dump the nVHE hypervisor backtrace */ + kvm_nvhe_dump_backtrace(hyp_offset); + /* * Hyp has panicked and we're going to handle that by panicking the * kernel. The kernel offset will be revealed in the panic so we're diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c index 6db801db8f27..a50cfd39dedb 100644 --- a/arch/arm64/kvm/hyp/nvhe/switch.c +++ b/arch/arm64/kvm/hyp/nvhe/switch.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -375,6 +376,10 @@ asmlinkage void __noreturn hyp_panic(void) __sysreg_restore_state_nvhe(host_ctxt); } + /* Prepare to dump kvm nvhe hyp stacktrace */ + kvm_nvhe_prepare_backtrace((unsigned long)__builtin_frame_address(0), + _THIS_IP_); + __hyp_do_panic(host_ctxt, spsr, elr, par); unreachable(); }