From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CA67DB676; Sat, 17 May 2025 08:51:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747471863; cv=none; b=em5ipowB4H4OYr/6za06BolxEkF9IgbeyPwxA40dIC/WEvgtzq3GdINZGAN8nohxp9WLD1Doqi7oJMe8IK+RjqRQdi/oysQHAwpBGn21pLxJPgKLfrHTZsmhqugG9f494ufGklc4GPJHktnVLoC4pHf6Zs93bkm9x2ccyK5PBc4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747471863; c=relaxed/simple; bh=dDQtD4ccdQG3UJa8qk1S/jtk3uLsTxKgzWBbQ6o6fdI=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=kV1Vyow7phCbeSSo5/ml/VbPYmWtu3ySkx2rKxp9L/IF7gTJimncppSbZN5UEgF9h3Dk6k60sWxC5ma8+loCf0aiEvhgDw1RyHiuJmqS9ZgdHcJmZvKU2OiNSc2lLzpfAS0kkkjuP17PkiQaAmc0YKeSDgm4vxnzAU7PS1zEqEI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cVyTSYLw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cVyTSYLw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30D7FC4CEE3; Sat, 17 May 2025 08:51:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1747471863; bh=dDQtD4ccdQG3UJa8qk1S/jtk3uLsTxKgzWBbQ6o6fdI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cVyTSYLwsGN96CR4uED4vSOD9avoVXlg309uHrcqPr1euk0/Zm0lnHavfYrikseMY ft+N/Mim4XEOxbycMS91qF2LYiHWeGbwFnzXkiMeRXYF1S1l7lcOHyWfdlYpOVAiA+ cS19ZxHEqtHRmlGCdFEJRSG50tri7jfQg7IHuL+EHB3Pp78hrIgBa1IMdXdoa8GKBC Iqaugk9tI/h4rLE657RdnwG/kkdmVcVE0+yRqng5sqNOnQ5px7ELEfImjW3uTsMjSV QhxF8l359kle+Mnhy4lfnNY2tI3pBhM5udaOKYhEyBR5CSeBHXwhE2MwiHvUFLmypJ kzWCkzECP5pqA== Received: from sofa.misterjones.org ([185.219.108.64] 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 1uGDG0-00Flz2-OG; Sat, 17 May 2025 09:51:00 +0100 Date: Sat, 17 May 2025 09:51:39 +0100 Message-ID: <878qmvr55w.wl-maz@kernel.org> From: Marc Zyngier To: Vincent Donnefort Cc: oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, qperret@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH v4 01/10] KVM: arm64: Handle huge mappings for np-guest CMOs In-Reply-To: References: <20250509131706.2336138-1-vdonnefort@google.com> <20250509131706.2336138-2-vdonnefort@google.com> <86bjrsg3az.wl-maz@kernel.org> 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/29.4 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev 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: vdonnefort@google.com, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, qperret@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, 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 On Fri, 16 May 2025 18:53:27 +0100, Vincent Donnefort wrote: > > Hi, > > Thanks for having a look at the series. > > On Fri, May 16, 2025 at 01:15:00PM +0100, Marc Zyngier wrote: > > On Fri, 09 May 2025 14:16:57 +0100, > > Vincent Donnefort wrote: > > > > > > clean_dcache_guest_page() and invalidate_icache_guest_page() accept a > > > size as an argument. But they also rely on fixmap, which can only map a > > > single PAGE_SIZE page. > > > > > > With the upcoming stage-2 huge mappings for pKVM np-guests, those > > > callbacks will get size > PAGE_SIZE. Loop the CMOs on a PAGE_SIZE basis > > > until the whole range is done. > > > > > > Signed-off-by: Vincent Donnefort > > > > > > diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > > > index 31173c694695..23544928a637 100644 > > > --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c > > > +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c > > > @@ -219,14 +219,28 @@ static void guest_s2_put_page(void *addr) > > > > > > static void clean_dcache_guest_page(void *va, size_t size) > > > { > > > - __clean_dcache_guest_page(hyp_fixmap_map(__hyp_pa(va)), size); > > > - hyp_fixmap_unmap(); > > > + WARN_ON(!PAGE_ALIGNED(size)); > > > > What if "va" isn't aligned? > > So the only callers are either for PAGE_SIZE or PMD_SIZE with the right > alignment addr alignment. > > But happy to make this more future-proof, after all an ALIGN() is quite cheap. Exactly. I'd rather have too many of those instead of something that may not terminate. If anything, it makes it easy to reason about it. Thanks, M. -- Without deviation from the norm, progress is not possible.