From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 37197466B79; Tue, 21 Jul 2026 10:10:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784628616; cv=none; b=RkMGDbPAZEQRvTjpHQ34bh27HrNDkgdcRrxmX4pZDPIeLnTeysJi1kFuBLl8owrkK+vua3siTIX4Q8auUTXChmoVg+jQmpHsNxRfnFVrenkD2oxrtggZn0hqDmwH931RSwTWSaa4KgfuQVdrQac0IJgNi3l1UHms8dturua+Y9Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784628616; c=relaxed/simple; bh=9af8pJkZLGkqL5vZ9I9/VgZYqEsM1wFe5SSVOddR4Y0=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=V0dfYdPh9MdptseZ+3FgPmUm5mhKch7e4duNgg5rrmIjW2Qvgu7MuH7frTSK7kRrTJas4/ciLjq8/Lvy7zD1LXmRfzn9A/mJEyyIle/4tI/bLDY6zFDSVQaxgO465ysl4/Iir1H39jq4/gHqHJdUT3dwwXiJFS2iVeZuvECaMQM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FaEL8nWE; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FaEL8nWE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3CCC1F00A3D; Tue, 21 Jul 2026 10:10:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784628609; bh=hahn6XSzy902fKG1P4kmxqNqlV/jNKxzeedAcmrHaus=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=FaEL8nWEGrFzE/bQMIY6hJDYdPut/3vfz+09zNAOZ4L1XhUeUkJJ1QInnnmZ6/JDp Hc3amOmBPptQCiocf3b/vpFMtsxT14ygjw4XnhtxiRmHm5GCFV6VBxoXyBbpKzq/sL qK+51dNhTar0XsFyNWJHlCuAN/t0wC75VjI2eqP8sWR6JwuwfWq5CwHJKBW2J96MUp IQF4d55ep5AGw5XOn3dOW4szm1DWhN7IYX9UAsO59waDFjgYrqQd/vWqpSAkv1r3Pk RtAhh+zT8pgZZZAS/hvV7ChjnPPE5Gr80cxnRTz4L24mFNpx73QvySB57IU3819Xvl MlLRqzwi6KBqg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wm7QN-00000007AKu-33ds; Tue, 21 Jul 2026 10:10:07 +0000 Date: Tue, 21 Jul 2026 11:10:07 +0100 Message-ID: <86y0f4ejr4.wl-maz@kernel.org> From: Marc Zyngier To: Mostafa Saleh Cc: linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oupton@kernel.org, seiden@linux.ibm.com, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, vdonnefort@google.com, tabba@google.com, sebastianene@google.com, keirf@google.com, Fuad Tabba Subject: Re: [PATCH v2] KVM: arm64: Optimize protected mode and FWB In-Reply-To: <20260721085646.1660673-1-smostafa@google.com> References: <20260721085646.1660673-1-smostafa@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/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: smostafa@google.com, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oupton@kernel.org, seiden@linux.ibm.com, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, vdonnefort@google.com, tabba@google.com, sebastianene@google.com, keirf@google.com, fuad.tabba@linux.dev X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Tue, 21 Jul 2026 09:56:45 +0100, Mostafa Saleh wrote: > > KVM opportunistically enables FWB if supported by the system for guest > VMs, which allows it to elude cache maintenance for data as they are > forced to be cacheable from stage-2. > In that case, __clean_dcache_guest_page() will immediately return. > However in protected mode, before calling __clean_dcache_guest_page() > it loops over the range and fix_map/unmap it, issuing TLB > invalidations, dsb() and isb() unnecessarily. > > This can be optimized by returning early if FWB is supported, > kvm_pgtable_stage2_map() already issues dsb() and tlb invalidation > functions issue dsb() for the unmap path. > > Signed-off-by: Mostafa Saleh > Reviewed-by: Fuad Tabba > --- > arch/arm64/kvm/hyp/nvhe/mem_protect.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > index 4e329e39a695..049a09be2bbf 100644 > --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c > +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > @@ -261,6 +261,13 @@ static void __apply_guest_page(void *va, size_t size, > > static void clean_dcache_guest_page(void *va, size_t size) > { > + /* > + * Guest stage-2 uses FWB if available, making it safe to elide CMOs. > + * In contrast, the host stage-2 never has FWB enabled. Beeeeeeep!!! Since a373930ec9406 ("KVM: arm64: Switch pKVM host S2 over to KVM_PGTABLE_S2_AS_S1"), FWB is enabled everywhere when available. Not sure that changes anything, but the comment is factually wrong. Thanks, M. -- Without deviation from the norm, progress is not possible.