From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D5A7FC433FE for ; Tue, 15 Nov 2022 13:26:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=v3R+F8SN1tEDrsStx68r8kJGxC2X+bKF2ZZ1Vaa+3JM=; b=z9FWeUTs30Euie cq+BIHxpG0eJRDRBHd79Mn8jzSj5T+awwoYn5+s6z/E9BiA9GA5HV+cwG+urIX2F8cIlUHvP9nGik 73YfXCFOrWQBnONckr6oYRxcEheaTKxpqJ7dvcLU4Z3f+N9qchbeiGr8zzQRN7BV7u1hzvUHsV1HA k1bkD0f9ZRYcAYMkabXXTPkn9G1bQZTqQOtApw7BXfL/MwqMJCCAezTiw662uBmXCWb102Z3hYETi C9/qjacHeAgBlO4FnFs1uT7FBiYgpPGAqMtGQ4xrcpxBn/DjTZc0P9hRqDiccwj7KGUSFQOiEzkPl n9Y/uvD4WJuBAsxXNB1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouvwd-00BQx7-KU; Tue, 15 Nov 2022 13:25:43 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouvwb-00BQwO-Cn for linux-arm-kernel@lists.infradead.org; Tue, 15 Nov 2022 13:25:42 +0000 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 69FC06175C; Tue, 15 Nov 2022 13:25:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAE73C433C1; Tue, 15 Nov 2022 13:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668518739; bh=UM+NUCSnWPwBJSvEkj5YDlxzvPW4Tgd7hH1Drivd2Zs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RqZ9uF5m3XKPVewGy4ALND0OQ3MGnKSHjy6twsxd/uCbC94LRX+4P51B1H4QaTxRD I0Yy/vswyh50t4VuZYD3hnnTuBbwyd9XFlu5LQWYWY6iS80PIzaXUij+A35UJcrEiX aXt8nrrXToBs78xY5yW0ngDQDtSEWbkMBKGpeTs4P8num13y4kByCOzf8c7Lcxb6RS YLaeuzgyKOo/3hSbvu/kps+pUtZyMu45nNRH4G5UBCYrbTrFI3F5mWR5nTzMfImfGw JQrrE0Z15YULA9373JtK5yDZxF583FEM8EGEUErB24fKur2C12EhbLj+CNG5/SGOr8 vRjFt987RBnYQ== Date: Tue, 15 Nov 2022 13:25:34 +0000 From: Will Deacon To: Oliver Upton Cc: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] KVM: arm64: Use a separate function for hyp stage-1 walks Message-ID: <20221115132532.GA524@willie-the-truck> References: <20221114201127.1814794-1-oliver.upton@linux.dev> <20221114201127.1814794-2-oliver.upton@linux.dev> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221114201127.1814794-2-oliver.upton@linux.dev> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221115_052541_551316_C53E5A93 X-CRM114-Status: GOOD ( 24.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Nov 14, 2022 at 08:11:27PM +0000, Oliver Upton wrote: > A subsequent change to the page table walkers adds RCU protection for > walking stage-2 page tables. KVM uses a global lock to serialize hyp > stage-1 walks, meaning RCU protection is quite meaningless for > protecting hyp stage-1 walkers. > > Add a new helper, kvm_pgtable_hyp_walk(), for use when walking hyp > stage-1 tables. Call directly into __kvm_pgtable_walk() as table > concatenation is not a supported feature at stage-1. > > No functional change intended. > > Signed-off-by: Oliver Upton > --- > arch/arm64/include/asm/kvm_pgtable.h | 24 ++++++++++++++++++++++++ > arch/arm64/kvm/hyp/nvhe/setup.c | 2 +- > arch/arm64/kvm/hyp/pgtable.c | 18 +++++++++++++++--- > 3 files changed, 40 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h > index a874ce0ce7b5..43b2f1882e11 100644 > --- a/arch/arm64/include/asm/kvm_pgtable.h > +++ b/arch/arm64/include/asm/kvm_pgtable.h > @@ -596,6 +596,30 @@ int kvm_pgtable_stage2_flush(struct kvm_pgtable *pgt, u64 addr, u64 size); > int kvm_pgtable_walk(struct kvm_pgtable *pgt, u64 addr, u64 size, > struct kvm_pgtable_walker *walker); > > +/** > + * kvm_pgtable_hyp_walk() - Walk a hyp stage-1 page-table. > + * @pgt: Page-table structure initialized by kvm_pgtable_hyp_init(). > + * @addr: Input address for the start of the walk. > + * @size: Size of the range to walk. > + * @walker: Walker callback description. > + * > + * The offset of @addr within a page is ignored and @size is rounded-up to > + * the next page boundary. > + * > + * The walker will walk the page-table entries corresponding to the input > + * address range specified, visiting entries according to the walker flags. > + * Invalid entries are treated as leaf entries. Leaf entries are reloaded > + * after invoking the walker callback, allowing the walker to descend into > + * a newly installed table. > + * > + * Returning a negative error code from the walker callback function will > + * terminate the walk immediately with the same error code. > + * > + * Return: 0 on success, negative error code on failure. > + */ > +int kvm_pgtable_hyp_walk(struct kvm_pgtable *pgt, u64 addr, u64 size, > + struct kvm_pgtable_walker *walker); Hmm, this feels like slightly the wrong abstraction to me -- there's nothing hyp-specific about the problem being solved, it's just that the only user is for hyp walks. Could we instead rework 'struct kvm_pgtable' slightly so that the existing 'flags' field is no-longer stage-2 specific and includes a KVM_PGTABLE_LOCKED flag which could be set by kvm_pgtable_hyp_init()? That way the top-level API remains unchanged and the existing callers will continue to work. Cheers, Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel