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 CF701C2D0CD for ; Sat, 17 May 2025 08:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OtqRKkSu9HLEoV4pzidESjOkH5HnwMBH+pZ+cUvcqrc=; b=xP83adyobmcSPzqGl5dxBxvW+u Bitk7MWB1+bYuSAAHSIP3xd9R1D6ccskO1BLcVicbngroL2UDMK14SAcOa8YHw28RxP+kZncU6uoc GNcRZbtRo/PDsV2vjbkyfa9SANmjzBWq22J1QdXxI7f+ofExi/QulNwJ/IrYji/r78XZpoVtgssPo phX4hTpAmtcPAM+BSJ1SfHuBMd5rHk+QT8nPwXLKXL63j1dEUOrnms15t0YhsUnH3WVL/wuf3p2YE V69hXOOIIQ4ZiVPvWsVyIfBCd4tDGxiSoOdRP6NNHShGWMK6O8lkboR74UYAu7VouoQ7iDvUwFrma raH8Nj0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uGDKJ-00000005Qro-2iGd; Sat, 17 May 2025 08:55:27 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uGDHl-00000005QXd-2Sfg for linux-arm-kernel@lists.infradead.org; Sat, 17 May 2025 08:52:50 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 51A3E40BE7; Sat, 17 May 2025 08:52:49 +0000 (UTC) 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) 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250517_015249_666714_F65162B2 X-CRM114-Status: GOOD ( 19.70 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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.