Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2794309pxp; Tue, 8 Mar 2022 01:50:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4gkjftUDhqnucY+c+xo7QrFciMnL07QEh8ZGSM0cl7OxU4YtyRXM+J1tHxMzEL80uET1k X-Received: by 2002:a17:90b:1e0a:b0:1bf:4d44:ce17 with SMTP id pg10-20020a17090b1e0a00b001bf4d44ce17mr3788394pjb.140.1646733038290; Tue, 08 Mar 2022 01:50:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646733038; cv=none; d=google.com; s=arc-20160816; b=oD+DX3M/5eLzAfCOBEOztyJE4lRU5Ot/tPyRwim8rl10ACACYgy9KAGlyW/EFot95j wATlATyWqrHAurRdETJZn/rsQKwK/Uug9GB6pguYPktxuvsysDH7orNmifJvwFMxuEQu EH/vuWc/oeqNKI28zgjKBC1Kw9a6vXK/o7RQauCYzdJ0V+CUyBn8xaxTGQ3ZNwbz2k4N grvWlbXqxHbMZOStTPCe72EwDs5iuK73aFv0wpFUwa0HpOtiA34qBLHVT+5SurEB93y4 5hgnhgj9xH27isZszjW2GoL4tgEAHS0mmuSFCk62DbJomUiJOMKdFgOmXr3xyTMq0DUJ 8j3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:cc:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=UdruCL33ZZYFGiCR380CmESQcj657VbKKdTgZ1Wg8kc=; b=wl2YY9NhQsXkEKhBXJH9iXgy3/UgEnFB7DRJPbiBevxb5A3kx20cJe47Au2AQuJknv 3jl9N8dhQYLujfHZBOjpCZzJMdICYKik6aja4KHfYNUcB6Nc8ir+DAdvYIPUEJZvUlxP V8eJQKZ9bml5yh821fLZcbS8Qfy7SDLNq7o5j5uAK3E6iayuNbt9c2p4KEmC2NDWQ958 TNN+UtmdLHzyJhgtzWj6v1u5bLZB1PhGhjxnh/Da3ampPUinObfSCF+v22/yFuY0quDj s2n4/vlm26xroq8NzzTTagBRIZ4bxXkwtYdpTQSDi3BOApvMiGZPPWeyn9RYfzlDNrSj mduw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=bTmhJBEG; 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 gq24-20020a17090b105800b001bd14e01fb8si1672288pjb.166.2022.03.08.01.50.23; Tue, 08 Mar 2022 01:50:38 -0800 (PST) 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=bTmhJBEG; 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 S243469AbiCGSx7 (ORCPT + 99 others); Mon, 7 Mar 2022 13:53:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237160AbiCGSx5 (ORCPT ); Mon, 7 Mar 2022 13:53:57 -0500 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4D6B6A059 for ; Mon, 7 Mar 2022 10:53:01 -0800 (PST) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2dc7bdd666fso69561857b3.7 for ; Mon, 07 Mar 2022 10:53: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=UdruCL33ZZYFGiCR380CmESQcj657VbKKdTgZ1Wg8kc=; b=bTmhJBEGbQH5zpBf4K3Tji6NNSug2HBwU66gLQY4V5NmqKRyZhideePdARpKiCOF1c OOXrO4Me1fvF4pmpx411lsWI36L53KeZD78//0S7lZr7sWRneIo6LIZnHduanDKHirrp cW/4+mBILBdF49NaYQQ0ozFhlZCcywn/DUEVKJhd4GnfmL1mzgkqZ3czm1wYzJZkNXS4 qW0Xc4qp7wwzIJVMA4t3smwcBSiVYJXN3TcTP/hWgqOHXc334UibH9+IWo75N0qlPwVC YmStcjlKcadCn3EjrZpBFiXMXsvKRboTwre/t2KGu5JqT/eDWY7BZogvQhmzrK9+elF8 Tk5Q== 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=UdruCL33ZZYFGiCR380CmESQcj657VbKKdTgZ1Wg8kc=; b=n03wZtcGVvyJTC1ZXUXwMpeMLaBdj5/2GPJRx0VK2VWRMVLVVve8zk1cHWUiSTXbQi kCWpOrq3mVoupR2uBGgZX2/hY599r2vivIEwhGo0q/QQFTIXcDMm9wW8nPaCq0Z4NPgD 4/e7pJ0E6jBEUufjYScxuoCCUVvBfjaIhXMBv/9semTDWNcgdhhMumtc6OPCMBAXgIpN Iv0q3cpa40PEDJNlzOleFy3vJzdfV5hPX20R+PgseBrEZfolJb100DyQG7TJIcLXFanl xLI7IGUDD/2wupx5cWKOuGdFDaI/jIzyNMzrt9OL9Sz6zVxY+gpqmJ0vQ3u8RDOU9vBb JZWw== X-Gm-Message-State: AOAM530ObqlEj4OH01/R4tv5Mt2BQA+U7cuT7GgQAgyNlLh7DXQxfd1r UkH6Nh6QfMkQXBzN2VyDL+MevAiJVBOZxjs0qQ== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:dd66:1e7d:1858:4587]) (user=kaleshsingh job=sendgmr) by 2002:a25:be85:0:b0:61d:7838:c9a2 with SMTP id i5-20020a25be85000000b0061d7838c9a2mr9060538ybk.364.1646679180921; Mon, 07 Mar 2022 10:53:00 -0800 (PST) Date: Mon, 7 Mar 2022 10:49:04 -0800 In-Reply-To: <20220307184935.1704614-1-kaleshsingh@google.com> Message-Id: <20220307184935.1704614-7-kaleshsingh@google.com> Mime-Version: 1.0 References: <20220307184935.1704614-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog Subject: [PATCH v5 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" , Stephen Boyd , Andrew Walbran , Andrew Scull , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MISSING_HEADERS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- Changes in v4: - Update comment to clarify resetting the SP to the top of the stack only happens if CONFIG_NVHE_EL2_DEBUG is disabled, per Fuad arch/arm64/kvm/hyp/nvhe/host.S | 11 ++++++++--- arch/arm64/kvm/hyp/nvhe/switch.c | 5 +++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/host.S b/arch/arm64/kvm/hyp/nvhe/host.S index be6d844279b1..a0c4b4f1549f 100644 --- a/arch/arm64/kvm/hyp/nvhe/host.S +++ b/arch/arm64/kvm/hyp/nvhe/host.S @@ -179,13 +179,18 @@ 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 - * any unwinding here. + * If !CONFIG_NVHE_EL2_DEBUG, 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 +#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; -- 2.35.1.616.g0bdcbb4464-goog