Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp409213imi; Thu, 21 Jul 2022 03:36:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vZofZpsUfC5bvQBodXXMSxVEM38NYuHxvklXFoQajYJCO7YKVYF64LK82IyiT28Zo9ERdP X-Received: by 2002:a05:6a00:2446:b0:528:5f22:5b6f with SMTP id d6-20020a056a00244600b005285f225b6fmr43774124pfj.73.1658399818065; Thu, 21 Jul 2022 03:36:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658399818; cv=none; d=google.com; s=arc-20160816; b=mswCRGD5DR3l58mthRm7Yg2xBsoUvDPSrRGEF7iOxx0F882wBgesrK33tQhwGSaZkN gGX48EBpxyzxtxmzFlg7pCNM28tjL2b09M5Ayi0Lk+LLgyjeZr9OAFlJB22Ma6wZfq6D HLdwwbR6fLyk1HLx5cl9+hwFhTiaQ52QMOv9CgSLjGUqKwsUqzZZU6QeNwdAHfmLBija 8Njqalpwtao4MeDeMZEQ3k7ouNJFHfXy26TnPMILOVCFLSeJWDVmc4/kbRN0IutLB1de 6un75KDQ+WkTLQHm5V9Z1PWIz03uBtehFX3iyA2myFyqtf3l6snMZ1pn5TIqKkwA2rFL cMIw== 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=cke61x1VyLaOYMRXa+KSlFmuqpeiXyYoEp5L0oHK1QY=; b=0HYm9et0603PGKXKr9xMlcXI2tc8rfOdV4tIIqWYGX4SjyfoBC6gLOmK8C3hMzTgpw p9YlcnimUwTWK6Kygd+2LqXg/j0o+VmXSSrHx8XD3SCeNnp3L70l5WHQ02G1a2z4GCai hVQ+SndVJoCIx/i+iQkfXf6xQNco77Roh8LDD8grmYFSbwSiIi/kLuTXsmdmDKLAHGNP TbscwIIzBNdXE0GLrx/OZXbWjzvBgBrzT0rARSBDTtL5AEf05p4OE/b5SKvMxxpxy2T6 /lHj2H1lG9+LWlWxu9KqOB7/ZzxJrMeVLJ6OGtfuj483B7lXWMGUrcIrOpmnUxLe+2ga mkaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Tv95sC0R; 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 w7-20020a63af07000000b0041a6f5c4922si1912310pge.407.2022.07.21.03.36.43; Thu, 21 Jul 2022 03:36:58 -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=Tv95sC0R; 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 S232927AbiGUJ6n (ORCPT + 99 others); Thu, 21 Jul 2022 05:58:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232936AbiGUJ6h (ORCPT ); Thu, 21 Jul 2022 05:58:37 -0400 Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12FDB820D6 for ; Thu, 21 Jul 2022 02:58:33 -0700 (PDT) Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-10d9137bd2eso1708187fac.3 for ; Thu, 21 Jul 2022 02:58:33 -0700 (PDT) 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=cke61x1VyLaOYMRXa+KSlFmuqpeiXyYoEp5L0oHK1QY=; b=Tv95sC0RqA3YKlr8Mh8ehqDQQXV9jQB2dagD6vtqdXmVNw98AKjRH+UwEbuwL2OHbz KAAkhFIW3FZwlIYmgkwTCOJgSBItuMIrzMHPGXkY7LvyHwdFnRrGX0LevGgQFkGpNRpE J9wqLlYi4/pflPV5HBV4XXjyVO6b+I8QstZAqTw65q71c3h/PMs622hA5yg4rCgfSeJ5 2g5Di77DrhkMVDgr+gOZbpQD3/hK1YSEfxYJGaey4k6XC/JL0gnm47mrlpXpzdxznlaL oGUh9EqkT5n2W2VMQjS6SQd/55HLeg9DGahze8oyN1mdYMq19MZHbB0woZe+TGiOkWwU JilQ== 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=cke61x1VyLaOYMRXa+KSlFmuqpeiXyYoEp5L0oHK1QY=; b=FrcUXRjVj5VGoOgWtN4P3iblv1SHgY680BNZP7HeeOeLuYZJJZlq5Qx/K1UIJEuq8K eVok2G2Ti/FLkgvs2eFneFI9nt6p0i++YITMOhyXWI/JIyfheHhk/8hLBu/M3tTPKXsM pZGm9u25TxDWlbo6DWL8M5OmAxp7x4guU2WU4/Fuw1tueEWf2sqv3NAQE3sa0LTgMopd xPl56Wl2DRDOVyhuuFmzTTJTQHrYUBlVoqnPkUbEbLHo0VGiZ4zZWP/H585jh3Q9GxIC zgZEICNtS16Lj93pW/QxzCZLGqgUscr7jisi2t6Rp/lx8z6JnasMkWqlTNYReKqBO8vA Q3+Q== X-Gm-Message-State: AJIora8d7DB0OWtXU9tdBs2vSVBWa070v2SiAIE2XMeIIsN+oT4+he7c 7LUwfVusycJBzOyxyGpaObXWp0SWTyTxa4E525tAag== X-Received: by 2002:a05:6871:890:b0:10b:f3eb:b45d with SMTP id r16-20020a056871089000b0010bf3ebb45dmr4955346oaq.294.1658397512248; Thu, 21 Jul 2022 02:58:32 -0700 (PDT) MIME-Version: 1.0 References: <20220721055728.718573-1-kaleshsingh@google.com> <20220721055728.718573-10-kaleshsingh@google.com> In-Reply-To: <20220721055728.718573-10-kaleshsingh@google.com> From: Fuad Tabba Date: Thu, 21 Jul 2022 10:57:56 +0100 Message-ID: Subject: Re: [PATCH v5 09/17] KVM: arm64: Allocate shared pKVM hyp stacktrace buffers To: Kalesh Singh Cc: maz@kernel.org, mark.rutland@arm.com, broonie@kernel.org, madvenka@linux.microsoft.com, will@kernel.org, qperret@google.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, andreyknvl@gmail.com, vincenzo.frascino@arm.com, mhiramat@kernel.org, ast@kernel.org, wangkefeng.wang@huawei.com, elver@google.com, keirf@google.com, yuzenghui@huawei.com, ardb@kernel.org, oupton@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kernel-team@android.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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, Jul 21, 2022 at 6:57 AM Kalesh Singh wrote: > > In protected nVHE mode the host cannot directly access > hypervisor memory, so we will dump the hypervisor stacktrace > to a shared buffer with the host. > > The minimum size for the buffer required, assuming the min frame > size of [x29, x30] (2 * sizeof(long)), is half the combined size of > the hypervisor and overflow stacks plus an additional entry to > delimit the end of the stacktrace. > > The stacktrace buffers are used later in the seried to dump the nit: seried/series > nVHE hypervisor stacktrace when using protected-mode. > > Signed-off-by: Kalesh Singh > --- Reviewed-by: Fuad Tabba Cheers, /fuad > Changes in v5: > - Fix typo in commit text, per Marc > > arch/arm64/include/asm/memory.h | 8 ++++++++ > arch/arm64/kvm/hyp/nvhe/stacktrace.c | 4 ++++ > 2 files changed, 12 insertions(+) > > diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h > index 0af70d9abede..cab80a9a4086 100644 > --- a/arch/arm64/include/asm/memory.h > +++ b/arch/arm64/include/asm/memory.h > @@ -113,6 +113,14 @@ > > #define OVERFLOW_STACK_SIZE SZ_4K > > +/* > + * With the minimum frame size of [x29, x30], exactly half the combined > + * sizes of the hyp and overflow stacks is the maximum size needed to > + * save the unwinded stacktrace; plus an additional entry to delimit the > + * end. > + */ > +#define NVHE_STACKTRACE_SIZE ((OVERFLOW_STACK_SIZE + PAGE_SIZE) / 2 + sizeof(long)) > + > /* > * Alignment of kernel segments (e.g. .text, .data). > * > diff --git a/arch/arm64/kvm/hyp/nvhe/stacktrace.c b/arch/arm64/kvm/hyp/nvhe/stacktrace.c > index a3d5b34e1249..69e65b457f1c 100644 > --- a/arch/arm64/kvm/hyp/nvhe/stacktrace.c > +++ b/arch/arm64/kvm/hyp/nvhe/stacktrace.c > @@ -9,3 +9,7 @@ > > DEFINE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack) > __aligned(16); > + > +#ifdef CONFIG_PROTECTED_NVHE_STACKTRACE > +DEFINE_PER_CPU(unsigned long [NVHE_STACKTRACE_SIZE/sizeof(long)], pkvm_stacktrace); > +#endif /* CONFIG_PROTECTED_NVHE_STACKTRACE */ > -- > 2.37.0.170.g444d1eabd0-goog >