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 94D81F3D31A for ; Thu, 5 Mar 2026 16:22:12 +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=JngvlC5my5lcycQIGdOLFfQM9Uh8ziNkiH4Le/NRxpA=; b=NSmLOJFC6kbEPNXh5pSSk18JqB HeAN4XNgbhhkbcjsI0y2wZpvf+Rr/p558VwX8fgdR0qvIm+X0/DXfrxAoHNN5t7ETCTrK3wn1s/2f BuHAxYIqurq4Cob254fL7qPIYTuWvGCxZoSz+KF7SKcFnGYbFGIKV8coZhxSwcnncM/jXC+aVJLI7 vqHCo4BHsICuaECNKNj8L3H3FiWq1HUFtStXamLhMXVTH/8n1O9+GWC/rsboGlYeIK6tm20tLGbuV uKW/PQLp/zQAWYxXFTDuQuhx/0sDC4nRETZqjx1sy79J1ceoB/GiX6PDGy8K621RwRa+j9WM1c6Cj yqobO/eQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vyBSh-00000002CZG-0Njz; Thu, 05 Mar 2026 16:22:07 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vyBSf-00000002CZ7-2lUG for linux-arm-kernel@lists.infradead.org; Thu, 05 Mar 2026 16:22:05 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 64E4260053; Thu, 5 Mar 2026 16:22:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12DE0C116C6; Thu, 5 Mar 2026 16:22:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772727724; bh=hPWaiZQkURcBYGdXokPMW62Jof8BcCJ3U+PevWfi8YI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=lD47VTeb7TSWq2q5RNFtPI6pyRXzBVaysvoruNmv/SpVgCv/AGontBHZzPEMOvXcW 6ER/u+nCtsmjHkIMLIuOuonom9ZYkIeKw3tBQ1EcM+s92RdieejufkVLnJGTpiuW0i CH7uB7fhI66QHkHdeOPU6xZJbYjcVBe/E4NiSwfPGBsCYc/xeS0Gnj/uWClkbDwsrT pVosvYPHLOy5CSBT69VvItUQSIuMrhVM+8/IysadP2GszaudA5xRx5lYHg4rSyPIr7 z65HpRlPOOr0Iln3j3Q6Qutd1O/oZalVeRflsNkwaywlYz5eoAapKKfdTS9MxBFF6Z LcTiK5tdno7jg== 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 1vyBSb-0000000GWk5-3BHT; Thu, 05 Mar 2026 16:22:01 +0000 Date: Thu, 05 Mar 2026 16:22:01 +0000 Message-ID: <86ldg66yc6.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, yangyicong@hisilicon.com, wangzhou1@hisilicon.com Subject: Re: [PATCH v1 2/2] KVM: arm64: Fix vma_shift staleness on nested hwpoison path In-Reply-To: References: <20260304162222.836152-1-tabba@google.com> <20260304162222.836152-3-tabba@google.com> <86ms0m6yzk.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/30.1 (aarch64-unknown-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: tabba@google.com, kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, yangyicong@hisilicon.com, wangzhou1@hisilicon.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false 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 Thu, 05 Mar 2026 16:13:43 +0000, Fuad Tabba wrote: > > On Thu, 5 Mar 2026 at 16:08, Marc Zyngier wrote: > > > > Hi Fuad, > > > > On Wed, 04 Mar 2026 16:22:22 +0000, > > Fuad Tabba wrote: > > > > > > When user_mem_abort() handles a nested stage-2 fault, it truncates > > > vma_pagesize to respect the guest's mapping size. However, the local > > > variable vma_shift is never updated to match this new size. > > > > > > If the underlying host page turns out to be hardware poisoned, > > > kvm_send_hwpoison_signal() is called with the original, larger > > > vma_shift instead of the actual mapping size. This signals incorrect > > > poison boundaries to userspace and breaks hugepage memory poison > > > containment for nested VMs. > > > > > > Update vma_shift to match the truncated vma_pagesize when operating > > > on behalf of a nested hypervisor. > > > > > > Fixes: fd276e71d1e7 ("KVM: arm64: nv: Handle shadow stage 2 page faults") > > > Signed-off-by: Fuad Tabba > > > --- > > > arch/arm64/kvm/mmu.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c > > > index e1d6a4f591a9..b08240e0cab1 100644 > > > --- a/arch/arm64/kvm/mmu.c > > > +++ b/arch/arm64/kvm/mmu.c > > > @@ -1751,6 +1751,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa, > > > > > > force_pte = (max_map_size == PAGE_SIZE); > > > vma_pagesize = min_t(long, vma_pagesize, max_map_size); > > > + vma_shift = force_pte ? PAGE_SHIFT : __ffs(vma_pagesize); > > > > If force_pte is set, then we know that max_map_size == PAGE_SIZE. From > > there, vma_pagesize == PAGE_SIZE, since nothing can be smaller. > > > > Is there anything preventing us from having: > > > > vma_shift = __ffs(vma_pagesize); > > > > and be done with it? > > Nope, nothing prevents that. Even simpler and better. > > Would you like me to respin it? Nah, I'll fix that locally. Thanks for having given it a look. M. -- Without deviation from the norm, progress is not possible.