From nobody Tue Apr 7 14:25:05 2026 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67C21378811 for ; Fri, 13 Mar 2026 06:13:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773382408; cv=none; b=hb8BERLJ3xdsZ/13J6X9R45lG3I4dpY2C8WObYo0qebBRpv9ibu39dXZUaEY+tkiINgHylza+QOQGsTVdl5tvN79hdj1yUOBbE25CZnHjO2sEg0HWwZKDuk3X/QfRvsLNhlYNWJLncaMvvJPpCi3HBAiTmsdO62QKrzuyzYZhTI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773382408; c=relaxed/simple; bh=efC+TzVwwA+lCFeRajm2dnq2MqPAbO6F5f4+fKbrYw4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pfTrmFTlKBSx+FtcyhBiU7zq+Z8DlCRQPyxggAFpjKSg84x4zkGCDm4lhHvvHOMkYws8wPMQ1rpYinVYL3EPNPNZxtzm3eXUsdWySwPBDL9WeosZGqFK+h3REK4sTtOf3h2oX5VGyk0AmPhXDdPkkZ3OdlJwGkZvtlhNHaD7mfs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=HN0YAtv9; arc=none smtp.client-ip=209.85.215.201 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--ackerleytng.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="HN0YAtv9" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b62da7602a0so1327483a12.2 for ; Thu, 12 Mar 2026 23:13:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1773382407; x=1773987207; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=SKsDiBkOMuSiXMAD20hKx6nWgAocdhX8X7LRy61gCzM=; b=HN0YAtv9b/GcBALegpZP+cvZMrB9a8Ql4i9AZ7cPdzRvHSC/8Uh5Zi0iUIA2OBWggb j1cG+89Mc3Ccrhf1GOxAWK3nF46U/5XcIcgnaooCLRkOJ030XDOPMb8Pwmv6i9/ZrBNL ndEXC8uFasURBp90S1vd6F7PEPla0EkxjcaU9L0xtYHyLHaOC60Lcy3Ba+/EhpjO2QsJ CBo4BMOX+VM4EvwdxzYOw2H+/y66PeLT/deCVbr1plyE4Pn+2/iqs6uhAa7Orz59KChs kf42r/VSx0LBHjJi+5ItkuHqMyk4jpdp8z+/vpHlOLMkdrtvuD7Z28k9jGl2aTeWjxyo ZBdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773382407; x=1773987207; h=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; bh=SKsDiBkOMuSiXMAD20hKx6nWgAocdhX8X7LRy61gCzM=; b=ESF+gldJTSZkBNwrbQ5cHh4GEWkgzQhM3YgPUE5eYDVGpMLEiwaD2wK1CGCSkL0k9D U+tfvvHlcI80oEGjBEA6T8NJDJ8/M/cceawC/+uUXP0FGdAjNX8v321O/6DlgpRJfGhX qBoP5K9MsV5F/NMVj2T3lkxO3jlCQhs2i2/80jkT3mr/mkHzhsJQ5FZTfuTOZrF6vkDS Vh+ivRFybuRGpuWh9/0hGaqXQ3g+Ko2qO2MlQAxNQ+ovG1rcg9grFAxJed0C/ePN3f+5 skQmMQ8MAyUlyfGF/wC+vZbu5VdYkNFK5ouWLB5Qq9/5iBbVqfSFFr/RDx90Hb7mJQHj uQug== X-Forwarded-Encrypted: i=1; AJvYcCUzwKxHogrqRdEQEJbTdIlO5+ZFsvjyFSSS2wTFPtRX9Hpo7N+kbfA434uQocvrUbVkX3Ip2Fv7ayuBLdk=@vger.kernel.org X-Gm-Message-State: AOJu0YwfEMGRYCJ5iMlQEXvhLJULQe13b38dLt1kyI2pjFj+Xl7LEwgt dXRttX0ttFxsMAQhhVJvQSpIR/8h01ACbz6rO4XMdwieY0QwTChLT6pb7KVoiuQfWOzaOPBRZWR z5A0EWsBjK1MLbxMAUtrJkxIemg== X-Received: from pgbcr10.prod.google.com ([2002:a05:6a02:410a:b0:c73:959f:8cb0]) (user=ackerleytng job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:144d:b0:398:9ef1:f8f with SMTP id adf61e73a8af0-398ecb1744amr1704318637.27.1773382406593; Thu, 12 Mar 2026 23:13:26 -0700 (PDT) Date: Fri, 13 Mar 2026 06:13:02 +0000 In-Reply-To: <20260313-gmem-inplace-conversion-v3-0-5fc12a70ec89@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260313-gmem-inplace-conversion-v3-0-5fc12a70ec89@google.com> X-Developer-Key: i=ackerleytng@google.com; a=ed25519; pk=sAZDYXdm6Iz8FHitpHeFlCMXwabodTm7p8/3/8xUxuU= X-Developer-Signature: v=1; a=ed25519-sha256; t=1773382364; l=1693; i=ackerleytng@google.com; s=20260225; h=from:subject:message-id; bh=efC+TzVwwA+lCFeRajm2dnq2MqPAbO6F5f4+fKbrYw4=; b=dXLbU8TDG6aMEm1oHbIyweTeDvQxQuyJ0+hdf+31mE9HrelOO4tSatiFFzIn09YxmWZrCjBur ALwKc2H67ijDc6hNbI8tzXF4Vo/omiqpUdsqXy6yiqfUIbMskk/03MF X-Mailer: b4 0.14.3 Message-ID: <20260313-gmem-inplace-conversion-v3-23-5fc12a70ec89@google.com> Subject: [PATCH RFC v3 23/43] KVM: selftests: Test conversion before allocation From: Ackerley Tng To: aik@amd.com, andrew.jones@linux.dev, binbin.wu@linux.intel.com, brauner@kernel.org, chao.p.peng@linux.intel.com, david@kernel.org, ira.weiny@intel.com, jmattson@google.com, jroedel@suse.de, jthoughton@google.com, michael.roth@amd.com, oupton@kernel.org, pankaj.gupta@amd.com, qperret@google.com, rick.p.edgecombe@intel.com, rientjes@google.com, shivankg@amd.com, steven.price@arm.com, tabba@google.com, willy@infradead.org, wyihan@google.com, yan.y.zhao@intel.com, forkloop@google.com, pratyush@kernel.org, suzuki.poulose@arm.com, aneesh.kumar@kernel.org, Paolo Bonzini , Sean Christopherson , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Jonathan Corbet , Shuah Khan , Shuah Khan , Vishal Annapurve , Jason Gunthorpe , Vlastimil Babka Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Ackerley Tng Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Add two test cases to the guest_memfd conversions selftest to cover the scenario where a conversion is requested before any memory has been allocated in the guest_memfd region. The KVM_MEMORY_CONVERT_GUEST ioctl can be called on a memory region at any time. If the guest has not yet faulted in any pages for that region, the kernel must record the conversion request and apply the requested state when the pages are eventually allocated. The new tests cover both conversion directions. Signed-off-by: Ackerley Tng Co-developed-by: Sean Christopherson Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/guest_memfd_conversions_test.c | 14 ++++++++++= ++++ 1 file changed, 14 insertions(+) diff --git a/tools/testing/selftests/kvm/guest_memfd_conversions_test.c b/t= ools/testing/selftests/kvm/guest_memfd_conversions_test.c index 8044581d5e5e6..b48aa5d9f8cd4 100644 --- a/tools/testing/selftests/kvm/guest_memfd_conversions_test.c +++ b/tools/testing/selftests/kvm/guest_memfd_conversions_test.c @@ -255,6 +255,20 @@ GMEM_CONVERSION_MULTIPAGE_TEST_INIT_SHARED(indexing, 4) } } =20 +/* + * Test that even if there are no folios yet, conversion requests are reco= rded + * in guest_memfd. + */ +GMEM_CONVERSION_TEST_INIT_SHARED(before_allocation_shared) +{ + test_convert_to_private(t, 0, 0, 'A'); +} + +GMEM_CONVERSION_TEST_INIT_PRIVATE(before_allocation_private) +{ + test_convert_to_shared(t, 0, 0, 'A', 'B'); +} + int main(int argc, char *argv[]) { TEST_REQUIRE(kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SW_PROTECTED_V= M)); --=20 2.53.0.851.ga537e3e6e9-goog