Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4841139ioa; Wed, 27 Apr 2022 12:18:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDCfRO2yAvyLpQgYoFrfHrYgNA82OZiwsw+OfsP5tVqbNYKQbkozIKky22KlLq9n29QfDW X-Received: by 2002:aa7:d651:0:b0:425:c3a4:2291 with SMTP id v17-20020aa7d651000000b00425c3a42291mr28806530edr.54.1651087086680; Wed, 27 Apr 2022 12:18:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651087086; cv=none; d=google.com; s=arc-20160816; b=sSSm+uuRBcrUpowrfGeOPlvZE1z5zWXec87/oNy3sLtZs5hW4vSeEmDY7DrljO3Nju pq24GhXEQlMEeGWsw49ICHCoM2Ss4BynaNifx4mEjCu9A9Fj8JaeD/Iiky7J9FlRwaC9 BuQ4i4ZN3KpwbEimtncpiKTiScOYV4QhvKdhzKPfrFLCO++AYZ6ePmMX9PzJNC9Hn4/D Us866gyrGhogfbNyDuDxHGiyBFPBWSoOiTYRzuLZSddGQA4oFXG++i/gnxUF6/dZ/R19 KybM/+ywhvaYePQuROU9Ce+kWGZBU6MjD91qEXIM63jvuqSTh533SapYcCi53VUtUF16 xcIw== 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=Ukl4ZPUY8nPN3AM2d1WxIlfrlMTerAUV8TUpQy4uNBg=; b=nPJAtq653xTIEtbacroYTmyImH5O++jt9odE9CTHF6/i+CgwADE9kSvyi5saqaJJW8 qSqWjNnG0fugr/Ng6XH2evvcMVbWiOkLC0fysPr0sJHg1meA5zXEw3GwW48XXQZJ6Owb f7q/8HaAVCkcYku65AnlPm1pqykmM2kGd8frXEBE0mKHGgznHDhaNBpbvjbk0W/fGd/0 eqUquMYt4POKLyau6twYKRhXEYyKBMjJBmlQvfFETka8+OzwyEjTQNq+s7VqZUkD2U3n pzRxWAPGURhb3ClM2o9ErtEKeUbUULZlDHCai1f3Z2/q728xCAMNNWabFcoj2hiWiYOs G2iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=MwumuTMc; 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 js21-20020a17090797d500b006e8d683e525si2083209ejc.404.2022.04.27.12.17.40; Wed, 27 Apr 2022 12:18:06 -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=MwumuTMc; 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 S229726AbiD0TCX (ORCPT + 99 others); Wed, 27 Apr 2022 15:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbiD0TCE (ORCPT ); Wed, 27 Apr 2022 15:02:04 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1D7DC400A for ; Wed, 27 Apr 2022 11:48:32 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 7-20020a250c07000000b0064137917a4eso2448835ybm.12 for ; Wed, 27 Apr 2022 11:48:32 -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:cc; bh=Ukl4ZPUY8nPN3AM2d1WxIlfrlMTerAUV8TUpQy4uNBg=; b=MwumuTMcrRhIVZ9j7swb6gFPtCMubn8HLn1QrjGmsWx6TDamUjamppzeC7+Fpo2zsC Hn4bx3jBlAkmNArZrSe6MdpVTjEJg354zjO4FkLXTKbIoUVQPlCUBjO2SZCJxc5IkFM8 cDuvx4Cjo2Ct4xWbHuhsaSXdjyU9NRnacoQoThUDFhnn0R1qKldXoHqIdeFSuyIQg2pC chNYgFV6zRM7TOLluFi18wIvk6VKlbVk1NgR+RDLPm9CxC6YqCUydpbanBRewfexSaQv 7fpo7I+PJ8U4nSeyCdXBluXkIB1PCAe1DvM/MnApanh4SLKGov6OQPuc3nE3UJpm+UME sagA== 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=Ukl4ZPUY8nPN3AM2d1WxIlfrlMTerAUV8TUpQy4uNBg=; b=Mp1LLRevZL0zL1y94i4gOb9+dB5t1n4pSvJPT4sN3p6X+xMSoY6j+OQXx9F6IV0KJl Alz5Av/pJRu9cgiPG/z82G+OnSoukLuDwCC3e7T8WrnCT0QY67wayFwgbC2cV59G/n6g KmtJXm0DGJKW2vmjaK1OpqSwBr1ZXxkMnXeE7TyyIe90xIWU2l9I7RQdJKF1WmjfVZe9 1eO7txnSjqa7fS4tu7l5yUNkom3jUb2VOBYiVhMnzs9+4EpGuTUvm/kgEwVbWnjOTxos JpnjGTEpejs8eyS8dejgwVArbUeN9fCFl8Us4axEZf2XXimRy4aEmFyr8pUTP3pCfLYu 93Ow== X-Gm-Message-State: AOAM533P8ZOZqvTYQDBimH4JrVbCT0UpbBFgB0ajW6y1T29UU8eLzxmp /eOyWduAPtEwnzVO7es+1rap5gQmUlhcQnK67A== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:16ec:6da0:8cc5:5f24]) (user=kaleshsingh job=sendgmr) by 2002:a5b:44:0:b0:645:d798:590f with SMTP id e4-20020a5b0044000000b00645d798590fmr23864940ybp.228.1651085311643; Wed, 27 Apr 2022 11:48:31 -0700 (PDT) Date: Wed, 27 Apr 2022 11:46:57 -0700 In-Reply-To: <20220427184716.1949239-1-kaleshsingh@google.com> Message-Id: <20220427184716.1949239-3-kaleshsingh@google.com> Mime-Version: 1.0 References: <20220427184716.1949239-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog Subject: [PATCH 2/4] KVM: arm64: Add hypervisor overflow stack From: Kalesh Singh Cc: mark.rutland@arm.com, 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 , Peter Collingbourne , Alexei Starovoitov , Mark Brown , "Madhavan T. Venkataraman" , Andrew Jones , Zenghui Yu , Keir Fraser , Kefeng Wang , 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,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. Signed-off-by: Kalesh Singh --- arch/arm64/kernel/stacktrace.c | 3 +++ arch/arm64/kvm/hyp/nvhe/host.S | 9 ++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index a84e38d41d38..f346b4c66f1c 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -242,4 +242,7 @@ noinline notrace void arch_stack_walk(stack_trace_consume_fn consume_entry, unwind(task, &state, consume_entry, cookie); } +#else /* __KVM_NVHE_HYPERVISOR__ */ +DEFINE_PER_CPU(unsigned long [PAGE_SIZE/sizeof(long)], overflow_stack) + __aligned(16); #endif /* !__KVM_NVHE_HYPERVISOR__ */ diff --git a/arch/arm64/kvm/hyp/nvhe/host.S b/arch/arm64/kvm/hyp/nvhe/host.S index 09b5254fb497..1cd2de4f039e 100644 --- a/arch/arm64/kvm/hyp/nvhe/host.S +++ b/arch/arm64/kvm/hyp/nvhe/host.S @@ -179,13 +179,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 + PAGE_SIZE, x0 b hyp_panic_bad_stack ASM_BUG() -- 2.36.0.rc2.479.g8af0fa9b8e-goog