Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796295499; b=tns+pwxSrfC1VlSLiXz6XarD21Nvq8pynwxihbhfEzRa6M4CQbEkuat74El+05tj9NVl pL9BXzxhdHjo/JU8r/8I77Zj6lWsXH+Mw7MT3YkcquQpOUYeyFeDerD2Y1AoyA7u8Xr+9 qJhvu9pFmLvYebGli5l9nEfIaBksxUlafvbLTk0hjQy/YRAKMecMHT0YUqgqKWdUBgrnz j01cvk+kIY8A5SngRtv6xfvOXHM1hwiaDVLQBROgoUREA79y3PCfMlNMJK+8D0yDZ8R7S PVEYKuPAknBHr0vhirxmUKhnhf0w4e6SZ2DaZCNO7x8Tr68o5ob1YKVPzck/sjns6aA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796295499; h=DMARC-Filter:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-Id:X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=A+vbO49cI1QwV5SU0U1H8NH+hH1HsvYW9696t/sdnsM=; b=g8UDd7JM9P5cSkEnUJP6ylJ9b3ifCZyEKNdxuCU7DN3mSSYY5SFMJjcFYJ/1u45KT3KQ WYKS+pCUE73VySSUvv5+1E/qGW7X5yewWiCr+rBEVCLCj32UW5PkUztHf/g1Nd7DEOtui n9IV1veURcAdKdIlyYB9OFbeU3vDSM4iMxuuuHEK7aQd8Q6C7RVQeWfSd7Rx/fFoKi8J5 RQK3TEG4cIxLWOxSdz9kKirxLnoqD7mqRmHomwFR+3hmEy/G7RZ7tPjXkyiIyfXv7oPZl N6nGjtdRwti5E/J4Y0D32UDiasmPNEpQ2lmQEgDnrYUnQfBKGtv/C6nCSMBiDAg/fKg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=HiEHLHd4; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6A4F606A32F; Thu, 3 Dec 2026 10:58:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D6A4F606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=HiEHLHd4 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E94761477; Thu, 3 Dec 2026 02:58:14 -0800 (PST) Received: from entos-yitian-01.Arm.com (unknown [10.168.196.233]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4D0943F86F; Thu, 3 Dec 2026 02:58:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796295497; bh=+k279guhtZaHIYzLH8TONk9dBIwltmIfZB5m2o9L4Tg=; h=From:To:Cc:Subject:Date:From; b=HiEHLHd4wG3nENycRiDonhqutOk9x3++H+gvHiEwo0QZEXpn4+Te3U250ayQyKLC0 lhW+5mMoeak37eZP+1cwBT9yPy3J1lJX5P3B0BehTLYtO9Jf1lhgxJuoEVQk/hw0SB e6kCmwc+8avXjAA5W54h3Ou/6ya03xfgAUefgs7Y= From: Jia He To: Marc Zyngier , Oliver Upton Cc: Jia He , Fuad Tabba , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Mark Rutland , Paolo Bonzini , Sean Christopherson , Shuah Khan , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 0/4] KVM: arm64: nv: VNCR page mapping fixes Date: Thu, 3 Dec 2026 10:58:01 +0000 Message-Id: <20261203105805.165749-1-justin.he@arm.com> X-Mailer: git-send-email 2.34.1 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Fix the VNCR fixmap offset on hosts with 16K or 64K pages and inject the fault recorded by the stage-1 walker when an AF update fails. Add a selftest for both fixes. The last patch allows cacheable PFNMAP memory to back the VNCR page. Testing for patch 4: On an FGT-capable host with L1's RAM backed by cacheable PFNMAP, the L2 hypervisor repeatedly took an SEA before the patch and booted with it. On Neoverse-N2, an NV2 VTTBR_EL2 read from a cacheable PFNMAP VNCR page in a read-only memslot took an SEA with gfn_to_hva_memslot() and read the expected value with gfn_to_hva_memslot_prot(). On a Neoverse-N2 host with 4K pages, both writable and read-only memslots passed the cacheable PFNMAP read, non-cacheable PFNMAP and PROT_NONE rejection, and concurrent PFNMAP/shmem replacement tests. Both 5-second remap runs completed without a spurious SEA or bad read; an instrumented run confirmed that both the fault-in error and cacheability failure paths hit concurrent invalidations and retried. nv_vncr_abort passed 3/3. Changes since v3: - Rebase onto v7.4-rc4. - Patch 1: use the cached HPA in __compute_hcr(), align the address passed to __set_fixmap(), and clarify the granule requirements (Marc). - Patch 3: document the 16K and 64K test results and that the test runs with nested stage-2 disabled (Marc). - Patch 4: shorten the cacheability helper comment (Marc), move the test descriptions to the cover letter (Marc), and defer the SEA injection for PFN fault-in errors and non-cacheable results until after the existing mmu_invalidate_retry() check under mmu_lock. Changes since v2: - New patch 1 (Sashiko). - Patch 3: size the read-only memslot to whole host pages, and map the VNCR page at a VA whose bits [15:12] differ from those of its PA (Sashiko). Changes since v1: - New patches 2 and 3 (Sashiko). - Patch 4: get the HVA with gfn_to_hva_memslot_prot() so that a VNCR page in a read-only memslot is not rejected (Sashiko). - Patch 4: limit the stage-2 comparison in the commit message to VM_PFNMAP and VM_MIXEDMAP VMAs. v3: https://lore.kernel.org/r/20261128011447.3588988-1-justin.he@arm.com v2: https://lore.kernel.org/r/20261125024426.3464050-1-justin.he@arm.com v1: https://lore.kernel.org/r/20261124025336.4107575-1-justin.he@arm.com Jia He (4): KVM: arm64: nv: Locate the VNCR page in the host page from its PA KVM: arm64: nv: Inject an SEA when the VNCR walk cannot set the AF KVM: arm64: selftests: Add a test for VNCR_EL2 translation faults KVM: arm64: nv: Allow the L1 VNCR page in cacheable PFNMAP memory arch/arm64/include/asm/kvm_mmu.h | 2 + arch/arm64/include/asm/kvm_nested.h | 20 ++ arch/arm64/kvm/hyp/vhe/switch.c | 7 +- arch/arm64/kvm/mmu.c | 2 +- arch/arm64/kvm/nested.c | 82 ++++--- tools/testing/selftests/kvm/Makefile.kvm | 1 + .../selftests/kvm/arm64/nv_vncr_abort.c | 221 ++++++++++++++++++ 7 files changed, 296 insertions(+), 39 deletions(-) create mode 100644 tools/testing/selftests/kvm/arm64/nv_vncr_abort.c base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f -- 2.34.1