Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3045527imw; Mon, 18 Jul 2022 00:32:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uyuqKksEdbtjBkEjWx+8rbAzs9gfNslosrks9EPAUX/qeD9/YujeuOpOOkjbxLqen2Nelz X-Received: by 2002:a05:6402:f08:b0:43a:b202:1f63 with SMTP id i8-20020a0564020f0800b0043ab2021f63mr35606060eda.207.1658129569437; Mon, 18 Jul 2022 00:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658129569; cv=none; d=google.com; s=arc-20160816; b=neOiZysundz2RQlwqpxCGs2LPWflSdaZCZvc4J3bmDbZbxjB9ffIq15HVEW1HAfmBL mnZjYJsa1oZtISrdnkVNhdaJ4iHrBWNH328fpCSliTSly0vUuDKd7c+taYS+Bvww5RuA 4KePKiN9spUCnH8BseoU2SpFfgvihxBFatI5BtgSLGKMaTzH+ricP0oJVVzCElcl7nyA GjMRdLgBTbTkoHTMv83jUdHeR46hBpb3StfWs+Uhc+BsJnWcUKi2q03XjOzDMOz9XC9M pgSTM3JKpubjJkOxPA1jJUUVMZ4DN6Z9SaJpTee+IGE7sm8N27FzgqglC+atjKULwfSv iqlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=PzKXH9g/absUXn1I5rYsnxMkzSXnVorVekO+HJGGr5M=; b=RR0r/c+fCTDNqzus0aDtmj6+kYX4wF4Y/U1mklyOb87Nmth9EZTSj9rss8Kl6sK72V fYRusmNewIABbJw8gCsL6tdt8NbvGzvX69MXGrRZCLilEXh27NuubLaE0qggoPvM/sHq 7JMpPX5t348vuZQMxK/7njp5GDjRerrT7jzYgg19uMO4F00p7a6OykNLpUYXI0363xHa o4d79BhEVp8PqnxqptboqnKj2nAxaIr09v9Ihjno7CQNjOaffz/RseO09YV1lu+sejOs yRjq63YQev+2mOwpclqy8Ok6LlBrLPtguXXiMGVTFCDmTgAFnd2oqbruZ5jahyquoexn SsMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XXjAueoj; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w20-20020a170906131400b0072edc3ce5a8si8341281ejb.301.2022.07.18.00.32.24; Mon, 18 Jul 2022 00:32:49 -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=@kernel.org header.s=k20201202 header.b=XXjAueoj; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233758AbiGRHNQ (ORCPT + 99 others); Mon, 18 Jul 2022 03:13:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231689AbiGRHNO (ORCPT ); Mon, 18 Jul 2022 03:13:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7D2517A86 for ; Mon, 18 Jul 2022 00:13:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 845A461319 for ; Mon, 18 Jul 2022 07:13:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBAF3C341C0; Mon, 18 Jul 2022 07:13:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658128392; bh=51swZxaHJh3GKTY5TD3dhPc0ycstZoPXVjupMS9JkwQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=XXjAueojpHAo+0wnGZa7OPm63c4moRcpozBTtgkbHmnr3e/NLNI3XjD2dma7lRViM ERotw0AL0sBjZokWNZT6AETiiVnRXuxHendgkysRZz5QugwCQtaKbyhVeNXBX618Eg iQmyAgu45qZk5MVMpNDowMS5DconlmISNh0bIIMAL6FMmLJL2J504QunH0ftuSAsTo iz6iR+XuzONiCKAnScyjy815y7n/27b3bU2NokneKx5SciSrUXj0z5IVEIuJs3Judg hIwN8+Eb12/m/N5oTvgqHYXK38v1nxmFMzs7FofdfCmbQZKxsQ98CVFS5BuE+/a/VI j+9VtH1ZDofJA== Received: from 82-132-227-210.dab.02.net ([82.132.227.210] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oDKwI-0088Nz-IW; Mon, 18 Jul 2022 08:13:10 +0100 Date: Mon, 18 Jul 2022 08:13:00 +0100 Message-ID: <87bktm51xf.wl-maz@kernel.org> From: Marc Zyngier To: Kalesh Singh Cc: mark.rutland@arm.com, broonie@kernel.org, madvenka@linux.microsoft.com, will@kernel.org, qperret@google.com, tabba@google.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, andreyknvl@gmail.com, russell.king@oracle.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 Subject: Re: [PATCH v4 09/18] KVM: arm64: Allocate shared pKVM hyp stacktrace buffers In-Reply-To: <20220715061027.1612149-10-kaleshsingh@google.com> References: <20220715061027.1612149-1-kaleshsingh@google.com> <20220715061027.1612149-10-kaleshsingh@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 82.132.227.210 X-SA-Exim-Rcpt-To: kaleshsingh@google.com, mark.rutland@arm.com, broonie@kernel.org, madvenka@linux.microsoft.com, will@kernel.org, qperret@google.com, tabba@google.com, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, andreyknvl@gmail.com, russell.king@oracle.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 X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Fri, 15 Jul 2022 07:10:18 +0100, 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 do the buffer required, assuming the min frame s/do/for/ ? > 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. Let me see if I understand this: the maximum stack size is the combination of the HYP and overflow stacks, and the smallest possible stack frame is 128bit (only FP+LR). The buffer thus needs to provide one 64bit entry per stack frame that fits in the combined stack, plus one entry as an end marker. So the resulting size is half of the combined stack size, plus a single 64bit word. Is this correct? > > The stacktrace buffers are used later in the seried to dump the > nVHE hypervisor stacktrace when using protected-mode. > > Signed-off-by: Kalesh Singh > --- > arch/arm64/include/asm/memory.h | 7 +++++++ > arch/arm64/kvm/hyp/nvhe/stacktrace.c | 4 ++++ > 2 files changed, 11 insertions(+) > > diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h > index 0af70d9abede..28a4893d4b84 100644 > --- a/arch/arm64/include/asm/memory.h > +++ b/arch/arm64/include/asm/memory.h > @@ -113,6 +113,13 @@ > > #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 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 */ OK, so the allocation exists even if KVM is not running in protected mode. I guess this is OK for now, but definitely reinforces my request that this is only there when compiled for debug mode. Thanks, M. -- Without deviation from the norm, progress is not possible.