Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796309253; b=AXsrUU5FNZ3BA9K4EyK2WQQWbehh41p4teCTaxrdTFqiSB+hWXFTlCKCY2NT8Ntixj3m cL7VID6JzULrB9rnqIMQFJpxv/UfqoSlYvg7t6hmTAXgRTUf2gTSRHOSTd07ZNgMCBEmk v3PDn0/ki+kXQTrlQHAtdQlsTtPiNtV8pgoCN7IluehIyL+bpviHPBCABYwKeV/7ve77H 53/ASc1XeljU4S9CTSO3+ATVXOdmHimCGWaB+sVEYE93a96SQpBqEgakWwPRaor+s93vA slLrq/zdOSb4iNFRhe/W/QiFT+1OI5KWDB8MKg5sP+pCsGe5u80lRaqaXSJE3Yz68DQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796309253; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=xv8fJ5M+PYv0iD4EuAmkrNPspYJrMIPISpbney82xws=; b=FigaTcKSh51NdonCn4VMRPz+mv4sR96zVOYQAp+3oyxDaIGjhcExN+tdVarA8xiy39Yw dsHNgzVmmqA9Xs5So6vK7WiPCvLcI6ITqxVrdP8gtWMs9FZE5YXQoU7XjeIu3fYE6HkUQ BVKKP6yhTKdSBRNQJguZ9BYwUmD/yVgMX/7Kt6s/m/p4ELEL6SDDMhN0VQpVUC7ARYiPv iuX/jajXzzk9mwoMm6w+RX3Lwe4T5RzLb9ceyTbnitzyk9366Ln0oq57/HvDzQhhfM37l dpaOqetxtcGrpa3JQANZ8LBkI3PeFxXGtOTKzxSpzfPcCSmmFYqBbH7nVczTegyiaZg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=imXyPN4n; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D47C606A32D for ; Thu, 3 Dec 2026 14:47:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=imXyPN4n Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1F181F000C1; Thu, 3 Dec 2026 14:47:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796309253; bh=xv8fJ5M+PYv0iD4EuAmkrNPspYJrMIPISpbney82xws=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=imXyPN4nXZThddSYtdQo6tv0JGEvchmjrX3mkde6v1Ml+trm4tcq3MeQ5w+EYxSmT 13Q09R+gbjfetVbbF+ykqIDnOhCzeZqN/AJp/IxvihhMl1w6fOq7iXxzFRg22xcGXr BST6FyN/CIsmCtt9RCHPft0BPJ8XgHfPbmj2TPZrMhH5tEYuF36ixwnA8zN9IBSrTl rk1v5aHH6wPcFJlfkkGmIEZfiasyiAc02houbAXdbWlBUO10b3BXtRguAxB9vsUdKd Asjfu4x1ttjSFxussYMVk1qwoGYnJL5HOs5NGAlbTgIF4Lp575LeAUUZbwn+MfGfT7 nM/aPDe/2zwvA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v6 10/24] KVM: arm64: Add a range to __pkvm_host_reclaim_guest() Reply-To: sashiko-reviews@lists.linux.dev To: "Vincent Donnefort" , kvmarm@lists.linux.dev Cc: "Oliver Upton" , "Marc Zyngier" In-Reply-To: <20261203115209.1690207-11-vdonnefort@google.com> References: <20261203115209.1690207-1-vdonnefort@google.com> <20261203115209.1690207-11-vdonnefort@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 14:47:32 +0000 X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] KVM: arm64: PMD_SIZE reclaim in __pkvm_host_reclaim_guest() stalls EL2 - [Low] KVM: arm64: commit message misnames __pkvm_reclaim_dying_guest() HVC -- commit 09b9348d8f7f8f99dfcf78626a4ea1cc2e74c269 Author: Vincent Donnefort KVM: arm64: Add a range to __pkvm_host_reclaim_guest() This commit extends dying-guest reclaim to accept a nr_pages argument of either 1 or PMD_SIZE / PAGE_SIZE, and renames the helper and hypercall accordingly. > In preparation for supporting stage-2 huge mappings for protected VMs, > add a nr_pages argument to the __pkvm_host_reclaim_guest() hypercall. > This range supports only two values: 1 or PMD_SIZE / PAGE_SIZE (that is > 512 on a 4K-pages system). > > Also, rename both the mem_protect function and the HVC to > __pkvm_host_reclaim_guest() as it can now operate on a range. [Severity: Low] This isn't a bug, but the hypercall is renamed to __pkvm_reclaim_dying_guest(), while only the mem_protect.c helper is named __pkvm_host_reclaim_guest(). Should the commit message reflect that? [ ... ] > diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/n= vhe/mem_protect.c > index 555566bbb9c2b..12bec74eeade2 100644 > --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c > +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c [ ... ] > @@ -1397,35 +1410,40 @@ int __pkvm_host_force_reclaim_page_guest(phys_add= r_t phys) > return ret; > } > =20 > -int __pkvm_host_reclaim_page_guest(u64 gfn, struct pkvm_hyp_vm *vm) > +int __pkvm_host_reclaim_guest(u64 gfn, u64 nr_pages, struct pkvm_hyp_vm = *vm) > { > u64 ipa =3D hyp_pfn_to_phys(gfn); > kvm_pte_t pte; > u64 phys; > + u64 size; > int ret; > =20 > + ret =3D __guest_check_transition_size(0, ipa, nr_pages, &size); > + if (ret) > + return ret; > + > host_lock_component(); > guest_lock_component(vm); > =20 > - ret =3D get_valid_guest_pte(vm, ipa, &pte, &phys); > + ret =3D get_valid_guest_pte(vm, ipa, size, &pte, &phys); > if (ret) > goto unlock; > =20 > switch (guest_get_page_state(pte, ipa)) { > case PKVM_PAGE_OWNED: > - WARN_ON(__host_check_page_state_range(phys, PAGE_SIZE, PKVM_NOPAGE)); > - hyp_poison_range(phys, PAGE_SIZE); > + WARN_ON(__host_check_page_state_range(phys, size, PKVM_NOPAGE)); > + hyp_poison_range(phys, size); > break; [Severity: Medium] Can hyp_poison_range() over a PMD_SIZE block stall EL2 and hold host_mmu.lock for too long? When tearing down a dying protected VM with PMD mappings, this zeroes and flushes up to 2 MiB (4K pages), 32 MiB (16K pages), or 512 MiB (64K pages) to PoC inside a single non-preemptible, IRQ-masked EL2 hypercall while holding host_mmu.lock and vm->lock. On 4K and 16K kernels, hyp_fixblock_map() also holds hyp_fixblock_lock across the whole block. On 64K kernels, HAS_FIXBLOCK is undefined, so __apply_guest_page() loops 8,192 times with per-page fixmaps, issuing a synchronous broadcast vale2is TLBI in fixmap_clear_slot() each iteration. Commit 0bf5f4d400cd ("KVM: arm64: Introduce __pkvm_reclaim_dying_guest_page()") reclaimed one page per HVC so EL1 could reschedule. Poisoning a full PMD under host_mmu.lock risks long IRQ-off stalls and lockups while blocking other CPUs on host_mmu.lock. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203115209.1690= 207-1-vdonnefort@google.com?part=3D10