From patchwork Mon May 2 19:12:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Singh X-Patchwork-Id: 12834637 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 B435CC433FE for ; Mon, 2 May 2022 19:13:58 +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:Mime-Version:Message-Id :Date:Reply-To:To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=LypBZUF6d5bXxgqqvjjpLSg1Jt7WXWUSlvtWb+3fpYo=; b=OF6oZhLSozTK45 dKVNSnw3UvqqqhK7rTA/HclqaCAgwaTaLb0IkRaTh0on1DPvEzHaiOEfxtXFTFa0Q8r+cbQbAAS7i HkPc1Y1z5jVWYXz/eXMXUYpX/ELW9qEJXVRA78cjGLaGEuzn0KfYnA+xS3pJA50Cy2mMZKB1apvTl l+ZWhdRcXm2YfyBQ/fnXYiS5tYPfwnm+VH9yJr5Me3sayAGzDJL3fDGT1J7tXYkpVG2iz9b7NCNsT NZS7DItCdoD7cNq7oaw+IbTQXX+Dc/UvNRvQmbsIBJ4bmNx0SjEH8JH8FIS6icMnggqAlDXZpRtpr 6df2+NPzWY4+J6MPmUUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nlbTH-002Jq5-Iy; Mon, 02 May 2022 19:12:35 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nlbTE-002JpT-7M for linux-arm-kernel@lists.infradead.org; Mon, 02 May 2022 19:12:33 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2f4e758e54bso143460677b3.3 for ; Mon, 02 May 2022 12:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:cc; bh=uV3AMgXfaKdpLzrKDgt2Pftc7Y3s541BqTPcU4XvOsc=; b=f/f3SDrAnawn000xkOkHhrYZWDBT/8Cfw436AFLd7ZGxWqX2AndGj6iIOi9pFxg9Lu c33w4E0W3pJafd0pLQ7kM+38rflKqPdINJwxPvlkEcM9yPSifoU2cXy2eZQgwskzblUc ZHWFN5SCm40eX/3Ntni/B2HAKTUKBbTBwHvSx3ykdEb1t9AbkLnxKyabLTk4rSAUbfFz GpCR3RXHSIMIryrvEiju/VgLVKQQkM61eujNeTaggZt7ybDKDRRkndV5NPsx3+Cair4K fPXJuHxCkPpbMqLH8CProCushBiyS/Ic8u4Kne6k3YlaVo4L97+BQUR11iFgCmGvubgH je1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:cc; bh=uV3AMgXfaKdpLzrKDgt2Pftc7Y3s541BqTPcU4XvOsc=; b=j/Cng0su1NDD8FPhHJD2mcjZXGphXZ9m129inOvx4NdFUAL8pM70LnXKYNyvhon6mM GSZSWecRszgce24kBhR4ATbwIwXN7GfLJk30tJzJ/JQX3ZWmq5f2rd4JOJs1zq/rgbAC 7suD0BTdBlwwOrd2D8sT4dqWD9ucr9DNac0PrpgenUiT6bVdBP6UHpVQXz01szWfyIqV ruJRApZKEXnqnzc2CRjNvzELXWKjUkGTfAzDKYHh4rxe999HkTd5EzVzHwDH7wmpyZ9I +0Z5pGRQ7jH7Cyt1JsS1fi//3Azu+hJS4T5T6n3K3TziK6y86HQxVFYNmJAWaWgN4p3H UtuQ== X-Gm-Message-State: AOAM530sYiSu++zFoWP+YnjhR5J9na8go153toc6uWFnoXknmIStf+oJ PQLtlBu3V4pLMN498oQE8S+nl9ewPYvEsoU7Tw== X-Google-Smtp-Source: ABdhPJw3anR5PV2AbjH4cWd8FKWezlG379Lha/KDbqGyzNif8TIgOLLb8qPZNat5PHuda44OzO6PJQ55Yf4E13DL8Q== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:55c:7548:7073:c14f]) (user=kaleshsingh job=sendgmr) by 2002:a5b:b4a:0:b0:649:15ed:1b87 with SMTP id b10-20020a5b0b4a000000b0064915ed1b87mr10856706ybr.374.1651518750235; Mon, 02 May 2022 12:12:30 -0700 (PDT) Date: Mon, 2 May 2022 12:12:00 -0700 Message-Id: <20220502191222.4192768-1-kaleshsingh@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v2 0/5] KVM nVHE Hypervisor stack unwinder From: Kalesh Singh Cc: mark.rutland@arm.com, broonie@kernel.org, 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 , Masami Hiramatsu , Alexei Starovoitov , Peter Collingbourne , "Madhavan T. Venkataraman" , Andrew Jones , Zenghui Yu , Keir Fraser , Kefeng Wang , 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-20220502_121232_306843_1ED8CAE3 X-CRM114-Status: GOOD ( 14.82 ) 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 Hi all, This v2 of the nVHE hypervisor stack unwinder. The previous version was posted at: v1: https://lore.kernel.org/lkml/20220427184716.1949239-1-kaleshsingh@google.com/ The series is based on arm64 for-next/core and is also dependent on kvm-arm64/hyp-stack-guard [1]. The main changes in this version is splitting some patches into more incremental changes, per Mark Brown The relevant parts of the previous cover letter are copied below for convenience. [1] https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms.git/log/?h=kvm-arm64/hyp-stack-guard Thanks, Kalesh ------- This new version of the unwinder splits the unwinding and dumping of the stack between the hypervisor and host: - The hypervisor unwinds its stack and dumps the address entries into a page shared with the host. - The host then symnolizes and prints the hyp stacktrace from the shared page. The new approach doesn't depend on CONFIG_NVHE_EL2_DEBUG, and allows dumping hyp stacktraces in prodcution environments (!CONFIG_NVHE_EL2_DEBUG). arm64/kernel/stacktrace.c is compiled twice: stacktrace.o for the host kernel and stacktrace.nvhe.o for the hypervisor. This allows reusing most of the host unwinding logic in the nVHE hypervisor. Kalesh Singh (5): KVM: arm64: Factor out common stack unwinding logic KVM: arm64: Compile stacktrace.nvhe.o KVM: arm64: Add hypervisor overflow stack KVM: arm64: Allocate shared stacktrace pages KVM: arm64: Unwind and dump nVHE hypervisor stacktrace arch/arm64/include/asm/kvm_asm.h | 1 + arch/arm64/include/asm/stacktrace.h | 58 +++++++++-- arch/arm64/kernel/stacktrace.c | 151 +++++++++++++++++++++++----- arch/arm64/kvm/arm.c | 34 +++++++ arch/arm64/kvm/handle_exit.c | 4 + arch/arm64/kvm/hyp/nvhe/Makefile | 3 +- arch/arm64/kvm/hyp/nvhe/host.S | 9 +- arch/arm64/kvm/hyp/nvhe/setup.c | 11 ++ arch/arm64/kvm/hyp/nvhe/switch.c | 4 + 9 files changed, 231 insertions(+), 44 deletions(-)