Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1742380pxm; Thu, 24 Feb 2022 08:32:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxEaqBydjSqllXa0IqvSSw2k7jGBfkizpQex0OhdpI7rHuDiVmtFh8zH0h0WElPWpFB35l X-Received: by 2002:a17:903:244d:b0:150:18f3:8e98 with SMTP id l13-20020a170903244d00b0015018f38e98mr2517599pls.28.1645720353207; Thu, 24 Feb 2022 08:32:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645720353; cv=none; d=google.com; s=arc-20160816; b=EjQVyBbWQ/n0AivEIm0FTH8IujqTL7D3qEui/yOGSfYyP5sxRZsd0m9waBoZHljJMv tAVIqN03QnjM3Oyt2HWIDbfB2Kt9aqt/6BaWIRMzoIAoWWHGhOnk3+VLI+x8LflcTXGm t5pkRotLnV9ABBhRAz6jXW/QlJB0DKf7b9aP1b+EesGZH7VBuai7iiywTA0Zpq6Hb2Nt SdIgjsC5Q5mNy0XVZ8WXTqgxv9+i0m/6BuYaIoQZ2epoThL9/CZBNXKIcAVCyY6uBjyP J6NdWIVfaFLWHGl+x0rbv+UrAB6V2k2WdR+4lC+kOyfwoCOu1wvC8QvAoT43ScRg8c3K JuyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=nwPQWibcxWFMgXyN9ojVzSP3LzP6lHj2lJ3iUxgMjZo=; b=zGoxCDgKjeG63AQ5za8pVBmt6r6g3K54cxw3m2qQubxXy0xS7NHghNQQWuDwv0fLQh Ev8WvKXS8xhvIwnYBZPDH3/xJCOzE7BNLVdRXH9BIR6mTQaRtjAFqSHTdenwnCODtDal okF/aidP3JWFqgZmCNgrxZTjrtHEV8BE4TJjJtNl+oqg10TyRT3PMozgYY3O679cEuVc u0T2yikZcQyxXBfV05gfA61s32CQGrHfWXU1+vi2TBkBXHJV2yaBXvGWXSP+jlMG0c4p U036WWB/JFLpB5SnKpfluOXFCtnW3THfxUCQ//39rV37fwnn0OEZwPOD0bhjRygrNWzH hDmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=UBXR2MWY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a15si2839983pgp.549.2022.02.24.08.32.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 08:32:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=UBXR2MWY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8288211B5E5; Thu, 24 Feb 2022 08:17:02 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234290AbiBXM1l (ORCPT + 99 others); Thu, 24 Feb 2022 07:27:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232673AbiBXM1k (ORCPT ); Thu, 24 Feb 2022 07:27:40 -0500 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C6EDBBE10 for ; Thu, 24 Feb 2022 04:27:10 -0800 (PST) Received: by mail-oi1-x233.google.com with SMTP id j2so2258088oie.7 for ; Thu, 24 Feb 2022 04:27:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nwPQWibcxWFMgXyN9ojVzSP3LzP6lHj2lJ3iUxgMjZo=; b=UBXR2MWYL/s+kIoqgRGAYAptEH4Pc/nZimkfWIwawk2UW5OrLBRBIriDI+z5GgP8K2 oN5Rh18Lml+7Bn+qfKh11yqwH8Xr6ium0CITxUAYF/VtkBUn9F9Naa3DN24atWoDEirn Iw6npN0oSb16EtzPL1tg8TP9yNcT4GoI3MkBnWQIXGsXW/fTT92AKS/5+ewrtpAjJyKv YtouZoIqplRqkGT7FlRhU5i+rEslOCdT5HNqp3Np7DGOoy+X0sKaBN7fUyyYNOSwLw12 Jfcr/RVp8xnyU7eAq6n92RFOWtamJgnHZTa9bsP/dNcGunwXcAF2ZN/cUb44hwFZREoz hbBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nwPQWibcxWFMgXyN9ojVzSP3LzP6lHj2lJ3iUxgMjZo=; b=velMIMxpH0hRpiaD87oqLSm4kGKjylPFcRXvRSovBN7yYzab3pETNecHHUb7Mw/Qzr 1DyK/InedgO5L1j01L+L/YWiisk5sD1/GukJM42U3QPmjKiu6RmJr3P5OBHjcKAfEq56 HNMnDh4cZEVpX171P9OeZECtEdWVjeSyxXbOvdd6uI7b1MvDEqQ0bY8d8IR/VfBGibH/ nqmid5RnP8uTAwUQl5n+UaAeOWXG5kmwSdy9L5QTVB2x5dTiOPjQHy+rYLlnWDdGw/Y9 8i10eqNUeRDSTsQ+JMA8nlNK+pOsYgSBy0RlyYKvQbReUvPFPo5jBXC8S17A29DfamW5 OaOQ== X-Gm-Message-State: AOAM531U/ZOWjZteNiyj6dSpOmj1ukDJIw5LSI5BeLThnLIP9Rad93X/ BGADoZwOCgV3q2mZ0o5onyJdTiVB92N5uK/iP1/aZw== X-Received: by 2002:a05:6808:ec1:b0:2d6:52f:6405 with SMTP id q1-20020a0568080ec100b002d6052f6405mr5741674oiv.124.1645705629835; Thu, 24 Feb 2022 04:27:09 -0800 (PST) MIME-Version: 1.0 References: <20220224051439.640768-1-kaleshsingh@google.com> <20220224051439.640768-7-kaleshsingh@google.com> In-Reply-To: <20220224051439.640768-7-kaleshsingh@google.com> From: Fuad Tabba Date: Thu, 24 Feb 2022 12:26:33 +0000 Message-ID: Subject: Re: [PATCH v3 6/8] KVM: arm64: Add hypervisor overflow stack To: Kalesh Singh Cc: will@kernel.org, maz@kernel.org, qperret@google.com, surenb@google.com, kernel-team@android.com, James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Mark Rutland , Mark Brown , Masami Hiramatsu , Peter Collingbourne , "Madhavan T. Venkataraman" , Andrew Walbran , Andrew Scull , Zenghui Yu , Ard Biesheuvel , Paolo Bonzini , 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kalesh, On Thu, Feb 24, 2022 at 5:21 AM Kalesh Singh wrote: > > 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/switch.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 749961bfa5ba..367a01e8abed 100644 > --- a/arch/arm64/kvm/hyp/nvhe/host.S > +++ b/arch/arm64/kvm/hyp/nvhe/host.S > @@ -179,6 +179,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 > @@ -186,6 +190,7 @@ SYM_FUNC_END(__host_hvc) > */ Nit: Maybe you should update this comment as well, since whether it corrupts the stack or not depends on what happens above with CONFIG_NVHE_EL2_DEBUG. Thanks, /fuad > 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.473.g83b2b277ed-goog >