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 B57991DE8A0; Sat, 17 May 2025 08:52:49 +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=1747471969; cv=none; b=Co8J/5E2x1kRYSQ5U8a1nTBVLtScMSowIWC+gfsZ+vDVcoRvlMy6NowDE+3m0pnysvEOVrAn/2p8H/OeM27CFkv2RJkplthkyZBV174FgFLwI6K90mWkvhTMqh2ZCHIXQSwdZBpfHZQ3doryvFBGFDskK4xs5WfKrzWUyYKBRYU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747471969; c=relaxed/simple; bh=qcZhH/eXIxJWC3CJPIuxmlJlmaJ5e1iSxpa3ehv9pgY=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=hLr2pO83F28tEelnjOLjzbcP2TVWS/ziLY0Sov6wj+BLRz0+K0xyLp6lOS0BlrAGye3HV4ThnRnwUAEpzXurLlhbnM+GNZOqdYgQSeoMYMbwZ5edc+MHkCBHSG87UNOCzfc1duhOJ+DsECV7SgmF5LdsqQMS/x6BcHX0/Pcy6So= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O9VvIyw2; 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="O9VvIyw2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2938EC4CEE3; Sat, 17 May 2025 08:52:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1747471969; bh=qcZhH/eXIxJWC3CJPIuxmlJlmaJ5e1iSxpa3ehv9pgY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=O9VvIyw2Z8yRTfvujjSYRKh2ZNhXdFvtVk5KowlsjCkC3MjVjDeLQ4oVyjy13Iog2 4hb8ofmIXLAUZ3CHuDlH2WwaHEcitEdQ1ru29xiZIefJ+t18P5yul3jBCP6O4jM6gL ueUYvR/BlTTB+VYhOX0hOAmwQT5srl2JFZmTEdq2FVgvVE0j7LCTztBHidLbWBDmBW m0XyxfIh6Xh4gB9SPG3YGuZ/sZHOnaOdHPTYCBP4EhMItaC3WOExtTYHSYpZ/0pQzW 4+OqBG0/yz6xck+XdYETwZB6VW8ShZWVL7+tOutamvCM7iPjVmwJQ0SbhSFtX35N+3 /ZSRlV9Obon7g== 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 1uGDHi-00Fm0h-F3; Sat, 17 May 2025 09:52:46 +0100 Date: Sat, 17 May 2025 09:53:24 +0100 Message-ID: <877c2fr52z.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 10/10] KVM: arm64: np-guest CMOs with PMD_SIZE fixmap In-Reply-To: References: <20250509131706.2336138-1-vdonnefort@google.com> <20250509131706.2336138-11-vdonnefort@google.com> <864ixkfynk.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: 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: 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 19:03:14 +0100, Vincent Donnefort wrote: > > > > +} > > > + > > > static void clean_dcache_guest_page(void *va, size_t size) > > > { > > > WARN_ON(!PAGE_ALIGNED(size)); > > > > > > while (size) { > > > - __clean_dcache_guest_page(hyp_fixmap_map(__hyp_pa(va)), > > > - PAGE_SIZE); > > > - hyp_fixmap_unmap(); > > > - va += PAGE_SIZE; > > > - size -= PAGE_SIZE; > > > + size_t fixmap_size = size == PMD_SIZE ? size : PAGE_SIZE; > > > + void *addr = __fixmap_guest_page(va, &fixmap_size); > > > + > > > + __clean_dcache_guest_page(addr, fixmap_size); > > > + __fixunmap_guest_page(fixmap_size); > > > + > > > + size -= fixmap_size; > > > + va += fixmap_size; > > > > Can this ever be called with a *multiple* of PMD_SIZE? In this case > > you'd still end-up doing PAGE_SIZEd-bite CMOs until there is only > > PMD_SIZE left, ruining the optimisation. > > > > I think this needs fixing. > > So this can be only called with size either equal to PAGE_SIZE or PMD_SIZE. I > wasn't sure if it was worth to make it more generic than it needs. > > But like for the first patch, I can make it more future-proof by handling size > > PMD_SIZE. Yup. These things are hard enough to debug that we should try and make it fool-proof, even if that's not immediately used (and fixing that is pretty easy). Thanks, M. -- Without deviation from the norm, progress is not possible.