Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.72 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796298786; b=IChWtuv+nkaFEzVctzT/4qOGSuFARoCT/jYT9qxm43T41+gL789Hn/HT7x/NlqThMjl1 q1924ZsPQpu/8kVtl7R4P8hwFk/acyDZYK+XbhJX1UZJlgZSStUd0UFaLZTUXEuMmX6F8 dOIGe/cE7albHw4LrXXeWiakEuwhG76E3LCZ8os8YDerjI/UzthFExFz7fZONBYuYZ7qg WVImBsxho/ISLyvOj3mbXDH69oN+2H2uhzCDQLlApUeJxjRJzb77HjVSkX4Tz1buGbIX7 r9xD8X9PXHKLxU7HQIfi2SdbPOVdF+uyXpLJuSBw7gnrnHOfjkB8jjwxrN3vwxdMo7g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796298786; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=UhGFaTtJXzsUCJmAnqWD2Z72DdNyiQAP/uQ5Y+Xo+18=; b=bOQChODv8hqylFe1G1IkTGr599eqEHrIfjSWcd7EaQyvYy3O9msNQDqqE+tn3lEASmj4 klqvUFY3umHhnduXFw2u7ypd5GC4ZUMdfoUsgJq+jFHdEcR3v+oHZaPLg3dUAYZgj8nJ8 0AUNkzNG7SHWHyqXp4iVXgFb4b7h+LcXnFIOWKVQs5RUWl51TUX10hd0kOuvuiK4qLgJ8 BSi3AI7abPXpH89WkU91TkhlHLOv0PEeF3l45L/DF6liSvu9WSuOqIOEnCP/4rMKR6vlg BYjE+Y6kbB/+aGI3R4GazHq7SjWWCthRfTMFi0e62Z78iJ9xrki2Vb0qUxb4+nndJDA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--vdonnefort.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=hAWdG0b1; arc=none smtp.remote-ip=209.85.221.72 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5429F606A333 for ; Thu, 3 Dec 2026 11:53:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5429F606A333 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--vdonnefort.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=hAWdG0b1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4a589b28bddso4409309f8f.0 for ; Thu, 03 Dec 2026 03:53:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796298785; x=1796903585; darn=lists.linux.dev; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=UhGFaTtJXzsUCJmAnqWD2Z72DdNyiQAP/uQ5Y+Xo+18=; b=hAWdG0b16gRKZ1tVoYL8CCtE4nXh39kjsVSzfI87dpzp6ofnvMinuegKdulfHnqDQk c1RI3qJe+Zpyyduwn2CK68QC+LJ1saeXmaZQRHJGQxfS2c0vQDoMXN11Nw63n7yw0iCc zxLCM7364+mKbx81AYG2RETBYlHjQ/p3NXm29di/OKv6oDzdXBOoheTJoRggafcfu/gC kp2oz0g3aVd1pr0COb07/tx8sfQH0Tyo2HFPW5bwOQlF6jmVSxaoM8dm5/2zMdKZnA6Z zPAXBt5Rci8kehv8tPCM86wc87JZkPmd7VCJMQYGBM+6YTFPris9MM6JjfudwPGM8szf 0gFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796298785; x=1796903585; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=UhGFaTtJXzsUCJmAnqWD2Z72DdNyiQAP/uQ5Y+Xo+18=; b=PLD4ZWhkD+8W1BP75TOPu3yUp2KrXWpFBQmNEwJPS91eNh+Bcp+4gCAszvpGUWNMX4 dfI7nDkq2J4qHPAqivmrNxeXdeTjkFg0RFMTOsT1Wcing1XqC9v0uDaIA+wuONO+Ggsy NUUEInEhZKPMX4tFhJ48fEapKi+DGo3eDMUcMwToNBzFMvX2zRt9ckthxOm/KOEGyNU/ M4miNtmdLwz1r+pxIbfUrThgDVbilO3qtIttszCAGTiMbODLHCrSG6UAlErK3aUw0ZBR nuM2DcW2DsqY7siU33U0bfLUwMLF3W6WqFe0prBfFWTIb1xHV3p78YBRIYRXgSfl6+cg mCew== X-Forwarded-Encrypted: i=1; AL+hErGKcgkftx7jM0T2RH+w28R43uVyM3F7lr0c4kkFfMCL6lBrTtgLxYBDqDry1SeuvAEYfxgFY0g=@lists.linux.dev X-Gm-Message-State: APuU4Z/W1Ft5e4ocyYXiuFNXzAzToUeXQAwzUycggxk+8d+KJm6cyvIR xPP40xXUNNTltoR9pQ/C5d/CV43zC492020RqBT724o9qMKDfIFX/ON7tThbiX8DvLQzw4mo9It bW+WqRPLQk9D5LF/q7PPOiQ== X-Received: from wrbdj8.prod.google.com ([2002:a05:6000:b08:b0:4a7:4b90:c045]) (user=vdonnefort job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:4381:b0:4a6:5a2a:f5a3 with SMTP id ffacd0b85a97d-4abaa9773abmr93255150f8f.3.1796298784571; Thu, 03 Dec 2026 03:53:04 -0800 (PST) Date: Thu, 3 Dec 2026 11:52:06 +0000 In-Reply-To: <20261203115209.1690207-1-vdonnefort@google.com> X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261203115209.1690207-1-vdonnefort@google.com> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261203115209.1690207-22-vdonnefort@google.com> Subject: [PATCH v6 21/24] KVM: arm64: Extend pKVM page ownership selftests to cover guest block split From: Vincent Donnefort To: maz@kernel.org, oupton@kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org Cc: joey.gouly@arm.com, seiden@linux.ibm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, kernel-team@android.com, fuad.tabba@linux.dev, qperret@google.com, weilin.chang@arm.com, Vincent Donnefort Content-Type: text/plain; charset="UTF-8" Extend the pKVM page ownership selftests to test the split of a guest stage-2 block and the per-page reclaim of that same block. Signed-off-by: Vincent Donnefort --- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c index 118f92472299..c2635d8c4131 100644 --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c @@ -2129,6 +2129,47 @@ int __pkvm_ownership_selftest(u64 pfn, u64 nr_pages, u64 pgtable_pfn, assert_transition_res(-EPERM, __pkvm_host_donate_guest, pfn, gfn, nr_pages, vcpu); assert_transition_res(-EPERM, __pkvm_host_share_guest, pfn, gfn, nr_pages, vcpu, prot); + if (size == PMD_SIZE) { + /* [gfn, gfn + nr_pages) was poisoned. Skip it */ + gfn += nr_pages; + + selftest_state.host = PKVM_NOPAGE; + selftest_state.guest[1] = PKVM_PAGE_OWNED; + assert_transition_res(0, __pkvm_host_donate_guest, pfn, gfn, nr_pages, vcpu); + assert_transition_res(-E2BIG, __pkvm_host_reclaim_guest, gfn, 1, vm); + assert_transition_res(-E2BIG, __pkvm_guest_share_host, vcpu, gfn, 1); + assert_transition_res(0, __pkvm_host_split_guest, gfn, nr_pages, vcpu); + + assert_transition_res(-E2BIG, __pkvm_host_split_guest, gfn, nr_pages, vcpu); + assert_transition_res(-E2BIG, __pkvm_host_reclaim_guest, gfn, nr_pages, vm); + assert_transition_res(-E2BIG, __pkvm_guest_share_host, vcpu, gfn, nr_pages); + + for (int i = 0; i < nr_pages; i++) { + WARN_ON(__pkvm_guest_share_host(vcpu, gfn + i, 1)); + WARN_ON(__pkvm_guest_unshare_host(vcpu, gfn + i, 1)); + } + assert_page_state(); + + for (int i = 0; i < nr_pages; i++) + WARN_ON(__pkvm_host_reclaim_guest(gfn + i, 1, vm)); + + selftest_state.host = PKVM_PAGE_OWNED; + selftest_state.guest[1] = PKVM_NOPAGE; + assert_page_state(); + + selftest_state.host = PKVM_NOPAGE; + selftest_state.guest[1] = PKVM_PAGE_OWNED; + assert_transition_res(0, __pkvm_host_donate_guest, pfn, gfn, nr_pages, vcpu); + assert_transition_res(0, __pkvm_host_split_guest, gfn, nr_pages, vcpu); + + for (int i = 0; i < nr_pages; i++) + WARN_ON(__pkvm_host_force_reclaim_page_guest(phys + i * PAGE_SIZE)); + + selftest_state.host = PKVM_PAGE_OWNED; + selftest_state.guest[1] = PKVM_POISON; + assert_page_state(); + } + selftest_state.host = PKVM_NOPAGE; selftest_state.hyp = PKVM_PAGE_OWNED; assert_transition_res(0, __pkvm_host_donate_hyp, pfn, nr_pages); -- 2.56.1.911.g883d8bcb20-goog