From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from esa3.hc1455-7.c3s2.iphmx.com (esa3.hc1455-7.c3s2.iphmx.com [207.54.90.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4367438BF9C for ; Sun, 16 Aug 2026 22:03:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.54.90.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786917782; cv=none; b=mfV2l8f0H+LujMGFlt28sO4WwF5YfIJ3fNTIDFloycd3VP6NJaVNk+p155C1+aXq0WUoyLRHumWumC4k6K7CLe1bAlDfqBxgKUcY3B53zJ0KCLcTPdKMbNTQjLmzqS3nsNKf+4gErD4L/mAUJ5HdP8VPQsN5Y0Mqj8NFe8mwo1E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786917782; c=relaxed/simple; bh=pVjiwzYXzj3mUBgzqtSSepmjg4P1MZh72aHgeka8p1w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cGMpVHptdQ5CtCg3t5wlpamufh9eYiCG1pavjErYXkvvoTMJWPZVUC600GH0VNN5Dn2+jPVLSG3pUC7NoGEuqAc+Y4OKlOE3yMCn79jeE0XGxCfVmXXxzZvT/BKVnnXNTZsLFtm3bOPr2jeRN5Kg0asZA6iZMWg8YmVDxsu+//I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fujitsu.com; spf=pass smtp.mailfrom=fujitsu.com; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b=EpmUjtqF; arc=none smtp.client-ip=207.54.90.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fujitsu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fujitsu.com header.i=@fujitsu.com header.b="EpmUjtqF" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=fujitsu.com; i=@fujitsu.com; q=dns/txt; s=fj2; t=1786917782; x=1818453782; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=pVjiwzYXzj3mUBgzqtSSepmjg4P1MZh72aHgeka8p1w=; b=EpmUjtqFxbaoBWUc0cmFgO9BGs8rH5Qpv/V0uB1qrXaMbirts/sJQ9zF uCalAOKMDUztvyn6CT7N0b3rw7tr/Exq+n0XQwfUgchRu252LIDpjoADf yvtN5hoG+C7oSbULf1vsl0/8ltFkASm9ZPMxDMRd6mByntsjEUvak+xXV nA076arzatepFRp1GDJzD4cOfUSeKeqyoGXWVLxLId0t9ghbi8rgtzOuX X1KFj4mNy7kUKoXX8ICMEGUvoV5QT0jjG+O+XZrWuZpZy6pIUZFglepgp ohlMLEUSTq334eqTmLpG/8/+UPljv1Qb6OnhQkNmfZQVBNT0azeY9vCSM A==; X-CSE-ConnectionGUID: FhfcQMsESj6D0KZcN49ETw== X-CSE-MsgGUID: I9Pk5H6FTGKxhPr+PtGt+A== X-IronPort-AV: E=McAfee;i="6800,10657,11877"; a="251254357" X-IronPort-AV: E=Sophos;i="6.25,227,1779116400"; d="scan'208";a="251254357" Received: from gmgwnl01.global.fujitsu.com (HELO mgmgwnl01.global.fujitsu.com) ([52.143.17.124]) by esa3.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Aug 2026 07:01:50 +0900 Received: from az2nlsmgm1.o.css.fujitsu.com (unknown [10.150.26.203]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mgmgwnl01.global.fujitsu.com (Postfix) with ESMTPS id 4C69A550A for ; Sun, 16 Aug 2026 22:01:50 +0000 (UTC) Received: from az2uksmom3.o.css.fujitsu.com (unknown [10.151.22.205]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by az2nlsmgm1.o.css.fujitsu.com (Postfix) with ESMTPS id E7458C012B0 for ; Sun, 16 Aug 2026 22:01:49 +0000 (UTC) Received: from sm-arm-grace07 (unknown [10.124.178.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by az2uksmom3.o.css.fujitsu.com (Postfix) with ESMTPS id 46B28100008B; Sun, 16 Aug 2026 22:01:45 +0000 (UTC) Date: Mon, 17 Aug 2026 07:01:42 +0900 From: Itaru Kitayama To: Wei-Lin Chang Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Marc Zyngier , Oliver Upton , Fuad Tabba , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Lorenzo Stoakes Subject: Re: [PATCH v5 2/6] KVM: arm64: nv: Introduce guest stage-2 tracking structures Message-ID: References: <20260810205038.118843-1-weilin.chang@arm.com> <20260810205038.118843-3-weilin.chang@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Aug 14, 2026 at 11:42:24AM +0100, Wei-Lin Chang wrote: > Hi, > > On Fri, Aug 14, 2026 at 10:04:57AM +0900, Itaru Kitayama wrote: > > On Mon, Aug 10, 2026 at 09:50:34PM +0100, Wei-Lin Chang wrote: > > > In order to avoid unmapping all shadow stage-2 mappings when KVM > > > receives a MMU notifier unmap call, we have to keep track of the > > > canonical IPA -> nested IPA relationship of the shadow mappings > > > created. This essentially means tracking the guest's stage-2. > > > > > > To do this, represent each mapping by struct kvm_guest_s2_mapping. It > > > stores the mapping's canonical IPA range and the nested IPA range using > > > two interval tree nodes. Both nodes will be inserted into their > > > respective interval trees called guest_s2_mappings. The canonical IPA > > > ranges will be stored in the tree within the canonical MMU, and the > > > nested IPA ranges will be stored in the corresponding nested MMU's tree. > > > > > > For example: > > > > > > struct kvm_guest_s2_mapping mapping1, mapping2; > > > > > > ---------------------> mapping2.canonical > > > | mapping1.canonical > > > | ^ (both stored in canonical mmu's tree) > > > | | > > > --*****-----------------------*****----------- CIPA > > > \\\\\ ||||| mapping1.nested_mmu > > > \\\\\ \\\\\ | > > > \\\\\ \\\\\ v > > > ------\\\\\---------------------*****--------- NIPA #1 (nested mmu #1) > > > \\\\\ | > > > \\\\\ -> mapping1.nested > > > \\\\\ (stored in nested mmu #1's tree) > > > \\\\\ > > > -----------*****------------------------------ NIPA #2 (nested mmu #2) > > > | ^ > > > -> mapping2.nested | > > > (stored in nested mmu #2's tree) mapping2.nested_mmu > > > > > > Using the trees we can look up nodes in either of the IPA spaces, and > > > for each node, find the corresponding range in the other IPA space from > > > the other node in the enclosing kvm_guest_s2_mapping. > > > > > > Define kvm_guest_s2_mapping and the interval tree here. Guest stage-2 > > > mapping tracking will come in subsequent patches. > > > > > > Signed-off-by: Wei-Lin Chang > > > --- > > [...] > > > > > > > +/* > > > + * Record of a guest stage-2 mapping, storing canonical and nested IPA > > > + * ranges. Both ranges have the same size. > > > + */ > > > +struct kvm_guest_s2_mapping { > > > + struct interval_tree_node canonical; > > > + struct interval_tree_node nested; > > > + struct kvm_s2_mmu *nested_mmu; > > > +}; > > > > Is this to be used for normal (L1) guests? I guess this series is for > > shadow stage 2 unmapping optimization, so not sure. > > Sorry I don't totally understand your question. Yes this series is > optimizing cases where a GPA (L1's PA) range have to be unmapped, from > an MMU notifier unmap call. > > When we want to unmap a GPA range, the corresponding L2PAs must also be > unmapped from the shadow page tables. Before this series there is no way > of knowing what L2PAs are affected, so the code just calls > kvm_nested_s2_unmap() to unmap all shadow mappings. > > Each struct kvm_guest_s2_mapping instance keeps one L1PA <-> L2PA > mapping record. For example: > > canonical (L1PA space): [x, x+4K) <- node stored in canonical MMU tree > nested (L2PA space): [y, y+4K) <- node stored in nested MMU tree > > Does this make sense? Yes, makes sense. I was mostly wondering about the sturct name, kvm_guest_s2_mapping you introduced, since this is only needed for a guest acting as a hypervisor. No strong opinion. Thanks, Itaru. > > Thanks, > Wei-Lin Chang > > > > > Thanks, > > Itaru. > > > > [...]