Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3311770pxb; Thu, 10 Feb 2022 18:14:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzgjh/K28BX9nv5Hi2eo1poJJPXFEUUvwtAsjRl7aGbLUyGgMp5UxtuZTtoCz5QZmx5v9Va X-Received: by 2002:a50:e616:: with SMTP id y22mr11282543edm.277.1644545687980; Thu, 10 Feb 2022 18:14:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644545687; cv=none; d=google.com; s=arc-20160816; b=rnm8XjOCwTElPsL5liu41qxxn1RBsXrjwvpO7LOA7nmM5eJa0SLPANDk1Pr64xmDaf PhJ6YwfmTAFsNH5Uh7LGpCDmJF405h4H5XQSpi1NbmWP+U+STdSvK9LBjCOJBB/9TEiO MOohPxys964QDd9sCU8iULOVxvjLzzDPvUROQePApCGGq4Vrc9uSWvwOHjaDnCbRNtMG G/3Z/X930VaFUH5zZGJecm4x2lggBOD7fIw6PIC8WuoDe5o7bHho7QiIM/HkNriN6p1K ruW5TXTfF7Gv7GiAJUdlCbIcz/uaxzI40Nn1VoRLcc8rn7Yq7VKq0+Ival0Hr1H5PlfP tfkg== 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=/IZyRrpjogHkvvKAbn/wuM+XhkmHZlGRNHWt0e5zr8A=; b=JadldjmDFHd8hp/EG/v7PyEV0YMv9U8rL6YuD63VNQPHhWppj8pa+nKNBm4VS2J8va oxWDL+oFejyO6i6aC96is68KKHQq2VHIjziSz8IlbJCyBs4B10pFveGDDJwE7MROHcxC a8sN7vv0SoEVflMA4OGmdoatvPV3tJmC3hIluimV5dh/fRJJ1xV7KY5HLOgp0koedf8z Ej8n+sWRXPkDebW7uF4zvoFs9p9xJfqj22roGQgIbMimk0eXt7c2TtzaAxPDzIUVH0BX tlut8pKLaEX5eL8p0Ya2lep7CYThFK4hSlWoOg4mlDbuyv6fhTekejyD/umeGbHIzUdo E53g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=PBkmRwuF; 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 w23si9778645edi.27.2022.02.10.18.14.23; Thu, 10 Feb 2022 18:14:47 -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=PBkmRwuF; 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 S245145AbiBJWqC (ORCPT + 99 others); Thu, 10 Feb 2022 17:46:02 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:35048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241709AbiBJWqB (ORCPT ); Thu, 10 Feb 2022 17:46:01 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD9D45589 for ; Thu, 10 Feb 2022 14:46:01 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id j17-20020a25ec11000000b0061dabf74012so15055269ybh.15 for ; Thu, 10 Feb 2022 14:46: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=/IZyRrpjogHkvvKAbn/wuM+XhkmHZlGRNHWt0e5zr8A=; b=PBkmRwuFiGGrv5iRHo7tLluafzQlZXF9AN4cUQvrlWacXQcrnAlFwCuc/zOtvTnj3A eyIK8Dr7DfK8BlaH06yRYxaDcs2bvmYni1BgVFeXEqyLnH4uCPmVWvtXo1p/9EFiq8OK yozHbjdo5J8wCe1HRkEpfHLkD8SJn8NzBv9iKIQrno5l1WcFw65NEM8NvqQ6xCxV2EW5 EPhU/2linown0tcJ3M3OITrVQ+B7l8BdSNdus0cc0Zg5pAix41rloxydzHuthJS8zX7p ctJ0Xrcr/w2hgACd8f01767tNpufMelYYz/KRWp+lszWzveeyi2sIdj7lorWwXkseetK RatA== 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=/IZyRrpjogHkvvKAbn/wuM+XhkmHZlGRNHWt0e5zr8A=; b=HNokUAgE3UguDutcWSrsSOKsBZFjBtO96XHT9BMJGfkH0QuWP5cuJLF/UN1tki1OzI 6IdB9koxpRLjP9gAsSvh3do8TW4u2aBLmQF5PRu/6izPi+cKCbs4041jlpxPlw+Z7BxH J1A9G9Twpekf6BQBE2oWpyGrxiVkzPdbcRDNl7VsgAisrfXlkbZ18NzutTFiIbZ7ASnX 3KPD5A71H7wkVkcYECqA3rFwn3sH8dav1qTQyGJTe6sgwTQ1CVPIFtqRbHyiW6cNSoED r6pJMI8Vxlx+0bquI0DLtm4fHBtkH2fBKSGkKVjDXIqo/tKJTqghq0K1krLLMTGS+hZW a4eA== X-Gm-Message-State: AOAM532AEJJLM+xo5hZC+t0CBqinoLuIHVmhtgB8QVgLBTuKtCfWYT8B 4Sp8umVVK1bYYR8wIe5MB7yf8r2hfpm2EPFdrA== X-Received: from kaleshsingh.mtv.corp.google.com ([2620:15c:211:200:8f02:232:ad86:2ab2]) (user=kaleshsingh job=sendgmr) by 2002:a81:3494:: with SMTP id b142mr9302016ywa.246.1644533161146; Thu, 10 Feb 2022 14:46:01 -0800 (PST) Date: Thu, 10 Feb 2022 14:41:46 -0800 In-Reply-To: <20220210224220.4076151-1-kaleshsingh@google.com> Message-Id: <20220210224220.4076151-6-kaleshsingh@google.com> Mime-Version: 1.0 References: <20220210224220.4076151-1-kaleshsingh@google.com> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog Subject: [PATCH 5/7] KVM: arm64: Add Hyp 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 , Catalin Marinas , James Morse , Alexandru Elisei , Suzuki K Poulose , Ard Biesheuvel , Mark Rutland , Pasha Tatashin , Joey Gouly , Peter Collingbourne , Andrew Scull , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu 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 --- arch/arm64/kvm/hyp/nvhe/host.S | 5 +++++ arch/arm64/kvm/hyp/nvhe/setup.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/host.S b/arch/arm64/kvm/hyp/nvhe/host.S index 78e4b612ac06..751a4b9e429f 100644 --- a/arch/arm64/kvm/hyp/nvhe/host.S +++ b/arch/arm64/kvm/hyp/nvhe/host.S @@ -171,6 +171,10 @@ 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 @@ -178,6 +182,7 @@ SYM_FUNC_END(__host_hvc) */ 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/setup.c b/arch/arm64/kvm/hyp/nvhe/setup.c index 114053dff228..39937fa6a1b2 100644 --- a/arch/arm64/kvm/hyp/nvhe/setup.c +++ b/arch/arm64/kvm/hyp/nvhe/setup.c @@ -20,6 +20,11 @@ unsigned long hyp_nr_cpus; +#ifdef CONFIG_NVHE_EL2_DEBUG +DEFINE_PER_CPU(unsigned long [PAGE_SIZE/sizeof(long)], hyp_overflow_stack) + __aligned(16); +#endif + #define hyp_percpu_size ((unsigned long)__per_cpu_end - \ (unsigned long)__per_cpu_start) -- 2.35.1.265.g69c8d7142f-goog