Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp180088iob; Mon, 2 May 2022 16:26:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHZKwcandqXFgy60mePznzpHfPadBHfLCqo4vnpPeL/KTez81+SCDIzmgb+K6uNLnxf6KF X-Received: by 2002:a65:4c8e:0:b0:3aa:24bf:9e63 with SMTP id m14-20020a654c8e000000b003aa24bf9e63mr11600198pgt.592.1651533976651; Mon, 02 May 2022 16:26:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651533976; cv=none; d=google.com; s=arc-20160816; b=A1QmDmc6Zqy85Ue25KHtklcxasL0aqonN2w3w37/Runc+hq8IroxL/dLNTTHnggRGO +3U8HriPlLSMBI8tVAUUO2kis1B6j726wVwaX3VdyO8zmEhm75auAq7QwQzTwuWBuB7Q X8Cl8XxkvIAwuqXcMbM87uQx0J5Xax+hwq6cNQLfcd6wCC/LsJwecMYthgGoSW4BOq/q u2JBDw09jqCi5yG+13uDqXgRq/d2mEDwVOWDvwYayhclh20S0VAG9ejeJz0k66pZgAOE udHu976CWPSaDXkLtUUnSdrFi8zc2s1KHW5U8zUKLXAlcylCwgZRuTWdOKRuAI/e0WSl c7gw== 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=NecAjaKo6a145Hd4bQjyaTWZfIjyHs70zkocfLAKQSs=; b=T+gmtVBowbBxh20hkyuQRmxJJwiL+YOdWRElfZ3KlydYLcxr3Auf1+0k7NlwTD9fsB o6sVP6JVIvEDqzvUtZWAuS1NISVg3oDJrzFkoaecjlJ/mxkP5deM11Kc44CRIeiM9Fdm b0SxzpvysKhujbzeChLvH0oAfccBH8HvihTjF1TypuusmtfJS/9HWlrABndZjbmNcx0M 4Q6XL+M1qPrW5gPMpYgUXoljYZ6Ufk90Bj7vPoZmFDLjnDpESEgA8OuPmIbITWWyvtk8 QyViE1leZ52WVoUshpAu0/uNf+BQl2cnWPtQy155mZYEoN0RG54uXEoYx04chs+jogje PMHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=QVB6MW5t; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id p31-20020a056a000a1f00b0050832077ba7si16270297pfh.273.2022.05.02.16.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 16:26:16 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=QVB6MW5t; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 49E8F63FE; Mon, 2 May 2022 16:25:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387057AbiEBTRU (ORCPT + 99 others); Mon, 2 May 2022 15:17:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1387044AbiEBTRS (ORCPT ); Mon, 2 May 2022 15:17:18 -0400 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 02F48E1E for ; Mon, 2 May 2022 12:13:49 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-2f7ee6bc6ddso143183837b3.1 for ; Mon, 02 May 2022 12:13:48 -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=NecAjaKo6a145Hd4bQjyaTWZfIjyHs70zkocfLAKQSs=; b=QVB6MW5tJEeXEtBnaqj+68WPwqmSC0IDheiS7ttyTWBXJheFxYJ7C/cvodMmjalP5S vgZ+25BOK1Vt3B+UC80FJgGZdJxmILirm2qIWWMzqQF9btkic9cKsZ4U90LlRJKgOIQb OrTHHTjrX2SGtENn6w3FoHexOsjv2+FfLK1KiMDV/DFHYvlaEcbXAMk9Uha4wZsMlT57 r3Qm38iqI4B/e8OLYePe0sEmEzTlEV4o1W4+PTuBcWIQ9QCFi9NQMtRyR9gXalxyZAsd L8fbI+dfQxvDWPmAQbezRSSCqwvyOACkyZSwVL6lKIEY19fxQPrqDUQjvTJeSh4cKII1 /WCg== 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=NecAjaKo6a145Hd4bQjyaTWZfIjyHs70zkocfLAKQSs=; b=PEUOph0hD3lsNS+JZd38RRnVN8qEGZdcnCD2j1OadUJEp3glL/eONqzDvFtlswBxkH JavdpfJrq/qAYIVNYwJ2FIgiNn4z8gHdbWElRHtNjOAms2jBrCDXJFEWcu9IRIeue+R0 nFlxeTTkZdIvhv+7TZ9Zk57TrAoRhKmZADFr0vPsGrPqBp8x3sirpFZdJFDxqwR40mKZ BXRrQHzo8d+rcfwOjJr6avsxmYFPKzyasLz2L46mGD7Qdv5ykacNpQwY7ohH0q+XEPQ0 ErBCMK5/iwcB0v15VxfEmDRXuIWvJXzpOR87jY2EeN0dhxQWboFtHRuSib2iKC0uxOM/ 8VwQ== X-Gm-Message-State: AOAM530I4wQy+GnGK/6IiqVcgMvWz5SJKvop8Rkb6dVu/ddfH68pXy5q kR/Ihr5bb+7hftpiKbj3IYwPzjEYT3xPMDgcmA== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:55c:7548:7073:c14f]) (user=kaleshsingh job=sendgmr) by 2002:a25:7243:0:b0:649:1be0:5061 with SMTP id n64-20020a257243000000b006491be05061mr11146766ybc.597.1651518828253; Mon, 02 May 2022 12:13:48 -0700 (PDT) Date: Mon, 2 May 2022 12:12:03 -0700 In-Reply-To: <20220502191222.4192768-1-kaleshsingh@google.com> Message-Id: <20220502191222.4192768-4-kaleshsingh@google.com> Mime-Version: 1.0 References: <20220502191222.4192768-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v2 3/5] KVM: arm64: Add hypervisor overflow stack 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 , Peter Collingbourne , Alexei Starovoitov , "Madhavan T. Venkataraman" , Andrew Jones , Marco Elver , Kefeng Wang , Keir Fraser , Zenghui Yu , 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=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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. 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.464.gb9c8b46e94-goog