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 5825B79C9 for ; Thu, 12 Jan 2023 15:44:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 013D9C433D2; Thu, 12 Jan 2023 15:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673538293; bh=/PZ5vXzNnZEX5lWeDeEnqyVs/kvjGL1YUm9pnpiT5hg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=EuTukSA4kvNgD5mRnsEVW8yskuoL06z/Te5dbT2u10lEhHqcjd3QqSJMdRGllHBuF SRsRXGrroX2M6FsRy+NXgBd2hXTHTWzZi/4AJx/OflLX1GvF8q3rq7CW7wG0bRpxGn Tb8j7lrG2qlMzpPl6j+jjRRrBqrXH9hlFkXWtRY0xW761ffNM51QIDime/Fs8y6mPm OUzeau9rxYoyd9au5XNURvad18UyWAFIJJhCBOn3IAh4z2YF9dVHNQbKbggutCmeD7 F1oQg12x0+Ewj7+Ah4WO5356NRbeofvXnM6b0GXW8IeY/6xTCSbEcc7/YE3QCt1Sil P6CRD1jasoPPw== 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.95) (envelope-from ) id 1pFzl4-001EZU-Eh; Thu, 12 Jan 2023 15:44:50 +0000 Date: Thu, 12 Jan 2023 15:44:50 +0000 Message-ID: <86bkn3oiz1.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: James Morse , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Quentin Perret , Will Deacon , Reiji Watanabe Subject: Re: [PATCH 4/5] KVM: arm64: Correctly handle page aging notifiers for unaligned memlsot In-Reply-To: <20230111000300.2034799-5-oliver.upton@linux.dev> References: <20230111000300.2034799-1-oliver.upton@linux.dev> <20230111000300.2034799-5-oliver.upton@linux.dev> 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/28.2 (aarch64-unknown-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: oliver.upton@linux.dev, james.morse@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, qperret@google.com, will@kernel.org, reijiw@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Wed, 11 Jan 2023 00:02:59 +0000, Oliver Upton wrote: > > Userspace is allowed to select any PAGE_SIZE aligned hva to back guest > memory. This is even the case with hugepages, although it is a rather > suboptimal configuration as PTE level mappings are used at stage-2. > > The page aging notifiers have an assumption that the spefified range > is exactly one page/block of memory, which in the aforementioned case is > not necessarily true. All together this leads to a rather obvious kernel > WARN when using an unaligned memslot: > > However, the WARN is only part of the issue as the table walkers visit > at most a single leaf PTE. For hugepage-backed memory that is at a > suboptimal alignment in the memslot, page aging entirely misses accesses > to the hugepage at an offset greater than PAGE_SIZE. > > Pass through the size of the notifier range to the table walkers and > traverse the full range of memory requested. While at it, drop the WARN > from before as it is clearly a valid condition. Rather than changing the low-level walker, with the oddity that it generates (patch #3), couldn't we instead just iterate over the range and only process one entry at a time? All we need to know is the level of the last processed entry to progress to the following block... Thoughts? M. -- Without deviation from the norm, progress is not possible.