From nobody Sat Sep 26 19:12:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1790301627; cv=pass; d=zohomail.com; s=zohoarc; b=c2oLdyD0/e83ONHGGUkG3CsgIPP11mpFhqCmnfV3a/AB1ysls8nE0l0xcVAsqsrKN6lvpFfvssCcbjW/p7JuqVLyrpGVcgvbx27VbTmDWWOBwEXn90N8VDO1kFXcXuUNkOAfYFhuFRHpOMG2T6epqp6Kx0J07qunbYguRHKovQE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790301627; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MiW2Gcdvbz4xxi4IG4aivzAZoLzzbo8XeKClAc2yeiw=; b=Crv+72Te98Esqw15brwhW0uk4CJX1yQ2TWfzc6TO+IeVfhkRy+mhRK1ZfIU+6gMjQkqs/7O0qnKphd0q7Q/ORXo0BLQlLIt+qZc0+f8N9kRXpd0qprLpQCKXGKq7folTqdNI9nNIfE0Ilz2w3aNjyUQS7lIW4q7QsVpgW1RS45c= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790301626943848.3923762224667; Thu, 24 Sep 2026 19:00:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x9vE0-0007PP-PB; Thu, 24 Sep 2026 21:59:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vDk-0007Ew-E0 for qemu-devel@nongnu.org; Thu, 24 Sep 2026 21:59:29 -0400 Received: from mail-eastus2azlp170100001.outbound.protection.outlook.com ([2a01:111:f403:c110::1] helo=BN1PR04CU002.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vDg-0006QF-KH for qemu-devel@nongnu.org; Thu, 24 Sep 2026 21:59:26 -0400 Received: from SJ0PR03CA0345.namprd03.prod.outlook.com (2603:10b6:a03:39c::20) by IA1PR12MB6626.namprd12.prod.outlook.com (2603:10b6:208:3a2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.18; Fri, 25 Sep 2026 01:59:20 +0000 Received: from MWH0EPF000A672E.namprd04.prod.outlook.com (2603:10b6:a03:39c:cafe::8e) by SJ0PR03CA0345.outlook.office365.com (2603:10b6:a03:39c::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.18 via Frontend Transport; Fri, 25 Sep 2026 01:59:19 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by MWH0EPF000A672E.mail.protection.outlook.com (10.167.249.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 25 Sep 2026 01:59:19 +0000 Received: from localhost (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Thu, 24 Sep 2026 20:59:15 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CsGPBoUk0Zi+6nagpjpahol78VUWXwayn+LVESCgOKmFS4jWElS+rZXRVFqPrUnE/pEYRuTfztDSgPOau9mC9e16F218MdSejzYIOoAJDmBLfZuB1dudPcCk6ql8PUBpdUGkjgNTNwimKDw2EwqFVcieoeVogJY9F7UMikVG5e69/pjWV+ZsbDtS60gGEhtXBQUfqMD/G92IjplEHj+9eQKwcupIxT0ngCWg64B6Ch3TWhhENqL7SUS+Y38r/3Iq0Yg8S5PBydfPfd31Enve4o9dPIQx6d2655j8MTXUOIZnmslE8K+5OIQzbil+JkbA5EPsJKnOjfhngQEETblotw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MiW2Gcdvbz4xxi4IG4aivzAZoLzzbo8XeKClAc2yeiw=; b=eOo+hz6DKt1dOcixNhjEyUGhn5xWesfCewES7NauAa1D3PaaReGTz4NMw329GtAJMLfEzlGoAc5J/M35rmBthQlb33CGH8iaTfLd3Oy9hpwZqP6cRAczAp2lwg1BRI1sW6JlVZ3jZwIz002hFd98LE3fz2/hFBQ3q0oElGN/cooKCnfKCnXZM+G4chMhSio1yW+LQnZJAVaGxOA0uS6UfYq91FySfcg1cSzmO+0ydMhn3XXgst+c2ABmRu4n1nCUMJ3CqTwPi8vUhqTw/tDNez3n7498YTURvktWdcA1Wcxmc0HFY5sXKCo5Qqeqh+y3hNjurRhrWzDbFHZEH843Pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MiW2Gcdvbz4xxi4IG4aivzAZoLzzbo8XeKClAc2yeiw=; b=St4abpqOpG2sR2uL3CD4jC4T/XUfCpO3Mpe7npkLNirQVRHajqY0DnpPAlL4k11LNAI4uCT410kJKKqWyRHsVGl11nYl2dU/rjxa1ZW1CmLPu6oFPa5REchO/QC3F66Xv1cUdEBF449h8/HTYaA0bKOmiXin0VHEGjoi4o+zdIA= X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Michael Roth To: CC: , , , , , , , , Fabiano Rosas Subject: [PATCH v6 01/12] kvm: Decouple memory attribute check from kvm_guest_memfd_supported Date: Thu, 24 Sep 2026 20:43:07 -0500 Message-ID: <20260925015700.1260501-2-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260925015700.1260501-1-michael.roth@amd.com> References: <20260925015700.1260501-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A672E:EE_|IA1PR12MB6626:EE_ X-MS-Office365-Filtering-Correlation-Id: 3fba6fec-65fe-404a-0922-08df1aa89cae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|36860700016|23010399003|1800799024|376014|10067099003|56012099006|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: 2sLmtXVV8UVvq1s1Ku2XeezEkNX60BOvH1gHxajfTW/tOO88/phNsMV3GflgdJZz1FUPPEQLx4aBs32Pt3nTT1+Elk8c9TE6WgGPt5W273oIljQCaGTftrZq+LX/h7EEULsI5nsggCKssbjqYtTR50lbzFOqFfhOvtFzimdWdEnZc004zT18KSTvJTlZHNGP+kXarsR2luyRM+QoAIjSvDv8EdhHkuu/ylxEuQTCuRYIyhr21FSpFa+Os3PDKL8H7FC+yYsFq70KgprEV2TtwAopgjFbKss1sysAMB96JIVwD3BbA2tvEamcATJqmKlAPeSvIbWsNcIV2rizECEWC1QZqn2SN+eJwqQSPV/Wpk6jvsTj4pAQEFrYmUwpNwiIraemdHg8ZAfe3IycVKvi0Ajm3A+bb1FR4CW1tAwCyShgz9na/yBIhrb2dNzXCshbccjiEB2F0G7Sx6+ugocawrmcOtXKbhIFbXKvwXeCY5qW3lsYnKQbX2bNuy1sW5AiVgs9a6hwbzdYj1MLB3MXj3l9Pe6+6bLiZWrBJ/3tZwfxf069HYvzpzY7PtBNjRbeng4YMNLKJ0ww0WR0eaGjkcBaxvbENlSY5S88a7Sz+IxFDxC0CLilrNGX434fZ9Mv3id7/t30SI94o89xC6bp0BTPgx1dh+cB1MF1pVCqkQAaYzu6/Ddnlcy/3yZk2ibUSZi1v3OIwIMHcwaNZHZNhg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(36860700016)(23010399003)(1800799024)(376014)(10067099003)(56012099006)(11063799006)(18002099003)(22082099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ULg3U+V1JM5chxW32mbZ1XDPBJEV4IkwwTLB8hnJIArbGBIvzgKPw4A7dgO9j3Oy1vjP6RIKLGOGZnV15vKmEMbSTgC14jUpZLm4T3KgzJCJgOQsIJe9NEOiuPHTSjHli1jzyjbTAmxHJvV/nzJqfhiLAO8UYYw2HloRIputlyIjB8CL4QYKZQ3QiKQYKcadRs1dYN/vjxk2p3XSlsl6xexpkEJS+wpeHp3QJt3r8MdcNE9LbtUPyY5pbAlarCHqWInZVtL2B5zmYB60/bF22iriJ+W0RnQiFGYAxx7pr92rbkanHbndHIqJohQX0Fd9ZuUQmxZ3YJqb/B35i37cMI4K+bEd5LzShpFVVVDd/nN9Oe/stA+fGrpOy4DRO/Nux82Fr40XT0M0wQv8IdLbeKlPOk+czr0/r/9+g1WRlppnXlEVJHzD79ftb82aPzTt X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2026 01:59:19.4030 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3fba6fec-65fe-404a-0922-08df1aa89cae X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A672E.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6626 Received-SPF: permerror client-ip=2a01:111:f403:c110::1; envelope-from=Michael.Roth@amd.com; helo=BN1PR04CU002.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1790301628376158500 Content-Type: text/plain; charset="utf-8" From: Xiaoyao Li With the mmap support of guest memfd, KVM allows userspace to create guest memfd serving as normal non-private memory for X86 DEFAULT VM. However, KVM doesn't support private memory attribute for X86 DEFAULT VM. Make kvm_guest_memfd_supported not rely on KVM_MEMORY_ATTRIBUTE_PRIVATE and check KVM_MEMORY_ATTRIBUTE_PRIVATE separately when the machine requires guest_memfd to serve as private memory. This allows QEMU to create guest memfd with mmap to serve as the memory backend for X86 DEFAULT VM. Signed-off-by: Xiaoyao Li Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Reviewed-by: Michael Roth Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth --- accel/kvm/kvm-all.c | 8 ++++++-- accel/stubs/kvm-stub.c | 5 +++++ include/system/kvm.h | 1 + system/physmem.c | 9 +++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 83cbd120a8..cdc7554082 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1627,6 +1627,11 @@ int kvm_set_memory_attributes_shared(hwaddr start, u= int64_t size) return kvm_set_memory_attributes(start, size, 0); } =20 +bool kvm_private_memory_attribute_supported(void) +{ + return !!(kvm_supported_memory_attributes & KVM_MEMORY_ATTRIBUTE_PRIVA= TE); +} + /* Called with KVMMemoryListener.slots_lock held */ static void kvm_set_phys_mem(KVMMemoryListener *kml, MemoryRegionSection *section, bool add) @@ -3058,8 +3063,7 @@ static int kvm_init(AccelState *as, MachineState *ms) kvm_supported_memory_attributes =3D kvm_vm_check_extension(s, KVM_CAP_= MEMORY_ATTRIBUTES); kvm_guest_memfd_supported =3D kvm_vm_check_extension(s, KVM_CAP_GUEST_MEMFD) && - kvm_vm_check_extension(s, KVM_CAP_USER_MEMORY2) && - (kvm_supported_memory_attributes & KVM_MEMORY_ATTRIBUTE_PRIVATE); + kvm_vm_check_extension(s, KVM_CAP_USER_MEMORY2); kvm_pre_fault_memory_supported =3D kvm_vm_check_extension(s, KVM_CAP_P= RE_FAULT_MEMORY); =20 if (s->kernel_irqchip_split =3D=3D ON_OFF_AUTO_AUTO) { diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index 32b4b07403..3d34e3b99d 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -143,3 +143,8 @@ int kvm_create_guest_memfd(uint64_t size, uint64_t flag= s, Error **errp) { return -ENOSYS; } + +bool kvm_private_memory_attribute_supported(void) +{ + return false; +} diff --git a/include/system/kvm.h b/include/system/kvm.h index 714b8c7b01..d29624034c 100644 --- a/include/system/kvm.h +++ b/include/system/kvm.h @@ -551,6 +551,7 @@ int kvm_create_guest_memfd(uint64_t size, uint64_t flag= s, Error **errp); =20 int kvm_set_memory_attributes_private(hwaddr start, uint64_t size); int kvm_set_memory_attributes_shared(hwaddr start, uint64_t size); +bool kvm_private_memory_attribute_supported(void); =20 int kvm_convert_memory(hwaddr start, hwaddr size, bool to_private); =20 diff --git a/system/physmem.c b/system/physmem.c index bd5f41cb02..1b3f327ed5 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2192,6 +2192,15 @@ static void ram_block_add(RAMBlock *new_block, Error= **errp) object_get_typename(OBJECT(current_machine->cgs))); goto out_free; } + + if (!kvm_private_memory_attribute_supported()) { + error_setg(errp, "cannot set up private guest memory for %s: " + "KVM does not support private memory attribute", + object_get_typename(OBJECT(current_machine->cgs))); + qemu_mutex_unlock_ramlist(); + goto out_free; + } + assert(new_block->guest_memfd < 0); =20 ret =3D ram_block_coordinated_discard_require(true); --=20 2.43.0 From nobody Sat Sep 26 19:12:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1790301632; cv=pass; d=zohomail.com; s=zohoarc; b=bTPXihMRMoCWO8G85aUcszv2YhWwmnh+pDB0QeHbu9+gZLfPOeW8xax+RQMlz+HEOmAY79IMImjOq9Iz5Cyq0raaSd5zIAyQcHlfts8xkn7SRfGdnVoYCRvMpEZlYo7wO7AWhrys9DWF5RE6Pf0UJhGyCkutQQgh/7OwTNu/8K8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790301632; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oRj3zg+9itdYyS6z7QNXQBDIItCdYPar+DU2LFF/qUc=; b=c4avd0wCaSEE2sFMSGDqvkQxgfP30NuWbGnJbvBHFYGwgPZoTJkg76cr+Pha8xNpXIunZPyO8fsnsvbwT71Ju89x8rCKXJQStn1vAOiInpD+2HRnc8GIYGb9yeHD2P2uavaygQ/25VS8D7PIvPOzkL3pE1ZwWzFGVWcMkEaTHB0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790301632108601.5013286487011; Thu, 24 Sep 2026 19:00:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x9vES-0007hg-9q; Thu, 24 Sep 2026 22:00:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vE2-0007UT-Mv for qemu-devel@nongnu.org; Thu, 24 Sep 2026 21:59:47 -0400 Received: from mail-westus2azlp170120002.outbound.protection.outlook.com ([2a01:111:f403:c007::2] helo=MW6PR02CU001.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vE0-0006R9-SI for qemu-devel@nongnu.org; Thu, 24 Sep 2026 21:59:46 -0400 Received: from SJ0PR03CA0380.namprd03.prod.outlook.com (2603:10b6:a03:3a1::25) by SJ2PR12MB8928.namprd12.prod.outlook.com (2603:10b6:a03:53e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.18; Fri, 25 Sep 2026 01:59:38 +0000 Received: from MWH0EPF000A6735.namprd04.prod.outlook.com (2603:10b6:a03:3a1:cafe::65) by SJ0PR03CA0380.outlook.office365.com (2603:10b6:a03:3a1::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.18 via Frontend Transport; Fri, 25 Sep 2026 01:59:37 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by MWH0EPF000A6735.mail.protection.outlook.com (10.167.249.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 25 Sep 2026 01:59:37 +0000 Received: from localhost (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Thu, 24 Sep 2026 20:59:36 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YWw14wvusIudRUcOeDDqJN2JyxekH+hnd0Ii54OWPVDBEDLMRoda9wCvMuWSarEJ8PQAHVCTO6uhgBTxEL+h9MhX9JxoNmIMA+fC9BsnLG4+XsH3WMc9iRUTnW2dTJGAZxQWa/OGkfwskWpND6jiygKisF/OtkC7YejdUAebI4F7nPrlZBbAQ17yiQ9sVlmS+2CUjQfoAqrfpGNna9gl1pLldqntDesaqXM/+mz3mtVhAZ8YAPWieM2CJpJQTwfNOd+72784W+J4pxc9UQlDIBBzcoGK8+lTEVwKCsndq06/I/rGyauf+u5gp8erVMQn4IusPXc1LnKEGfJ7WJZ/CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oRj3zg+9itdYyS6z7QNXQBDIItCdYPar+DU2LFF/qUc=; b=fm7crNVSKv111uxwhUo9ETfz4lJGTsXslQhEsTb+2rPneiVHBxxstlhh/RtQgv22dsR6jK7RumwoTvdiPr5o6T1WcoXDqj+X167n/fUQrXiJuCq7CfXjEJJ8g9pJuPbL4ri+GZ4eMf/RxCW3WaT8n+xG2T8yDRHR6YmyQBi09PrWmCZhqdj0+OWhdwq4qKGpAQ4Ah3U+z6/jtFULNDnGHC0mcXd5vpUuYyYX01FLb54JqFAa7zKeeu0xfJzrXEHE9L5dGUCswFrGfrEimJixNo5xKOMLuIJzQQqhlTBZ5HYKRJ3eYH2tj75nJXch95OA/lKdOIuazxP8cMpR8HeIkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oRj3zg+9itdYyS6z7QNXQBDIItCdYPar+DU2LFF/qUc=; b=M7GEPxVfGEhDCFO41hQCph6wJ/wOTHOlh3aOSk3sL+hK4+omuy8Gjnz8R4RyOPaRdcN0lNs//V5q39u2StyEXMDCWhl29UuhxKOiiGxx2/r/PLDxjFnpKa6PuSDptqYbJq54gIoSHhiqGqXcnLPEfKdO5tCW7fX7Axnfr+hlMT4= X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Michael Roth To: CC: , , , , , , , , Fabiano Rosas Subject: [PATCH v6 02/12] kvm: Detect guest-memfd flags supported Date: Thu, 24 Sep 2026 20:43:08 -0500 Message-ID: <20260925015700.1260501-3-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260925015700.1260501-1-michael.roth@amd.com> References: <20260925015700.1260501-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6735:EE_|SJ2PR12MB8928:EE_ X-MS-Office365-Filtering-Correlation-Id: 9fafb3ec-901f-4be4-a4c7-08df1aa8a782 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|82310400026|376014|1800799024|36860700016|10067099003|56012099006|11063799006|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: U2kuLGQHGXEiAt171MZGMMbPWKQd6sPUIuhTir0PmvRned6kIDP0XxD3rt7Fn0AL9TDj+PdvrV1KphCDLGQURjrxoQVKw8amDGIkclN8mmF4k6nIDykHI5c/C5crBZvoPJr23T3L3z3Sm8T/yxH38+5xhduiqk3tHTZYmQDYCVXbizNr3Oij90jHslp14JSMgh6DX8fBSR5y9JrL0do24gp85+CFitSboA2gVg6MzWuBu4ABWeTvsdAjUI2ah48rznWfEqOMksWsfReRWb5hqLcbl0NY66RRT6PG+Dx6DqrX8KmU7q1xxJB9/qmdkrMLVdutOpEbDgboxlA/EWDQ8mBDCpNEZi2XogMg5AfmSViwBr4rroQ2qkaUtCWBtDWpgOpR2eFw87T+Kqhm7IpEsFNJi55kjHsFhpLlmaLW8t4KxjxITcH3jO8dehoidPq3LOWNz0j3brap0Rox/5tmpr1pDX7sLicy4ca6YzoKQwjMxWhZv/MimHDMbodpUVKrJikaNrvUI77Ys/jkGUYMkgohaZKF/RmKif/O4rjklNTniI27BpulPQil/WPh0M3VPIiQm1RzqoZoOfeAvKiijOjl9TFOeG+sJ3BPGUJiXVOCaXG9wT5burjaKCXsOT/uzQ4HZMqkaUQnx7x40UbJEE/Cgb1GXC2YMMxSeg6M1EdO9GZDqG7+0uIjpzWRZ3dOz+wkJl1W4NPwp0EMAZSfZA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(23010399003)(82310400026)(376014)(1800799024)(36860700016)(10067099003)(56012099006)(11063799006)(6133799003)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EB5obDVUYlcn4fgwFCfpSdqJIpcwIf48Bypl1fnbs/IaNAHGAh0boYa1sBZD1qOJgdt6O1+dm0rOdtwoMw4JVDs39zA4pnZ1g3PrgD2cpAORmSr6CN5UrmWowkg0HtP7OEbVtecTOAV8Bhs6ON+2GxTW8TOsL2wnYlWMUzWmqbf8BjyuXplQbzwqlxn+xIaU8gcoi5/I3CSu+n2wUsyn5q+ZejuZGmqYYS711QHoIxK2ExQsZBAuYbjzLH8pMxWD4TwXZOEgify0hsV49iiQBnQwyG6znd/Yk7YGHn5KsaRCAl+EQ/RWhPhlzUSTDANFzCKPOAn5pBVmfyTTTY2aHjcnLZ4hqCyjJMK9iDU/BUggQCwUxRmBwtHLRCFAR4jBu86SfppgllI0EZnPrhj/mWFIn6i8X/RlWu03wIX8OUQ6Tg5J7r66yhfDKBpj/BmH X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2026 01:59:37.5736 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9fafb3ec-901f-4be4-a4c7-08df1aa8a782 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6735.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8928 Received-SPF: permerror client-ip=2a01:111:f403:c007::2; envelope-from=Michael.Roth@amd.com; helo=MW6PR02CU001.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1790301632364158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu Detect supported guest-memfd flags by the current kernel, and reject creations of guest-memfd using invalid flags. When the cap isn't available, then no flag is supported. Reviewed-by: Xiaoyao Li Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Reviewed-by: Michael Roth Signed-off-by: Michael Roth --- accel/kvm/kvm-all.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index cdc7554082..120cab1e22 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -107,6 +107,7 @@ bool kvm_pre_fault_memory_supported; static bool kvm_immediate_exit; static uint64_t kvm_supported_memory_attributes; static bool kvm_guest_memfd_supported; +static uint64_t kvm_guest_memfd_flags_supported; static hwaddr kvm_max_slot_size =3D ~0; =20 static const KVMCapabilityInfo kvm_required_capabilities[] =3D { @@ -3065,6 +3066,8 @@ static int kvm_init(AccelState *as, MachineState *ms) kvm_vm_check_extension(s, KVM_CAP_GUEST_MEMFD) && kvm_vm_check_extension(s, KVM_CAP_USER_MEMORY2); kvm_pre_fault_memory_supported =3D kvm_vm_check_extension(s, KVM_CAP_P= RE_FAULT_MEMORY); + kvm_guest_memfd_flags_supported =3D + kvm_vm_check_extension(s, KVM_CAP_GUEST_MEMFD_FLAGS); =20 if (s->kernel_irqchip_split =3D=3D ON_OFF_AUTO_AUTO) { s->kernel_irqchip_split =3D mc->default_kernel_irqchip_split ? ON_= OFF_AUTO_ON : ON_OFF_AUTO_OFF; @@ -4760,6 +4763,13 @@ int kvm_create_guest_memfd(uint64_t size, uint64_t f= lags, Error **errp) return -1; } =20 + if (flags & ~kvm_guest_memfd_flags_supported) { + error_setg(errp, "Current KVM instance does not support " + "guest-memfd flag: 0x%"PRIx64, + flags & ~kvm_guest_memfd_flags_supported); + return -1; + } + fd =3D kvm_vm_ioctl(kvm_state, KVM_CREATE_GUEST_MEMFD, &guest_memfd); if (fd < 0) { error_setg_errno(errp, errno, "Error creating KVM guest_memfd"); --=20 2.43.0 From nobody Sat Sep 26 19:12:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1790301644; cv=pass; d=zohomail.com; s=zohoarc; b=mdbbFAZuKQgxehEoBCB1anURrdSgzEW57md0C8WTpSTwPpdJK9evikNpHWZX0uq0nyF+EC5+HayQTUfyhH8tgeQkU8MANnZbgXq6P712io2rOd+/X/Jk8aDEcrffav6KejXNh2LI2WiWJLAAUyVimFlaiygSI2R44fjsk1MGilg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790301644; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KqOCq80wst6hd+j3A8zmXak1oz3A5JChzBn/NUFNwoQ=; b=OsNwWuNbv/mCCffxXUcYSAwfcxBiuK1SI7/d9VQw9yrRkmfhFOjy1+nFNJ1n8qoLZORtBfZDoLoqTGuvi/mAfAPYbFnsziwuQaC6lfhCbWI3upqF1UROhkjIZN0M6NuejPxBd0hf0nBpj4wZVksJQe6JsCeKApDmZC0+EgZaeok= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790301644730681.3118175622864; Thu, 24 Sep 2026 19:00:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x9vEX-00082t-RE; Thu, 24 Sep 2026 22:00:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vEP-0007gn-Rc for qemu-devel@nongnu.org; Thu, 24 Sep 2026 22:00:10 -0400 Received: from mail-westus3azlp170100009.outbound.protection.outlook.com ([2a01:111:f403:c107::9] helo=PH7PR06CU001.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vEN-0006dr-UH for qemu-devel@nongnu.org; Thu, 24 Sep 2026 22:00:09 -0400 Received: from MW4PR03CA0336.namprd03.prod.outlook.com (2603:10b6:303:dc::11) by PH7PR12MB5686.namprd12.prod.outlook.com (2603:10b6:510:13d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.18; Fri, 25 Sep 2026 01:59:58 +0000 Received: from MWH0EPF000A6732.namprd04.prod.outlook.com (2603:10b6:303:dc:cafe::69) by MW4PR03CA0336.outlook.office365.com (2603:10b6:303:dc::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.18 via Frontend Transport; Fri, 25 Sep 2026 01:59:58 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by MWH0EPF000A6732.mail.protection.outlook.com (10.167.249.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 25 Sep 2026 01:59:58 +0000 Received: from localhost (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Thu, 24 Sep 2026 20:59:57 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Bs81xrCK7BkxVIjQMLe+mGcqQlqgosUOt0gXI5gmNI/2W28dx2KcHkKpWoa+OvNwiOgx7KxceQK/6XJRpoV9qztoji5g+WYVqYmoFECqT7cedChq2T1SzZlYo/CRVvmJl6+Hse1K+q0c9k3wrUMdv9Ag0ymjTFIqHYkFTvchb5KvfSN/Bq4Yika+c0r1d2TugvheKBQEnoYQni46oFy9GHbYu2jwHADigGNwlOWd0V35KRsem4FU+Jn+G435nj2BQKbyMlKlET13pChVVrKsm+w7lstG8lOa21P4Uh4Iuq/lau1AqHb0w3wDJMmSowjtW0TmSXSP8aZuWZ5wo6PmJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KqOCq80wst6hd+j3A8zmXak1oz3A5JChzBn/NUFNwoQ=; b=dhIVTdpiNHJSvV7kok+fVhh0uYopU++aLfyFIhxc0mP/gcImiVFqpbSeT3+n3nxOSDBe8ac/UAdasjSJ9dNxstuOLv1jOwzijs79b8Ash2Ce5zF8va7gl2iSWZk/MMIIwCeCTscoYrKeaOCQotA5AM9oyKfsviGmjKko1RtJLGny+0SP5ZP1UJYF0AvV6AQP1idI8LQroCTLvuwL5fK7axRAq8i4Wl34dqfgdEXWYf1PDfgFLn6Xka72Xkap78cXIkgz0NOlM+YATlkNjTAD71okjSaxr9BmP3zpUqvr5vNcVrU7eZqGCKRj0GRW5hOi1sjzlJhyifzUiY0PntqNHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KqOCq80wst6hd+j3A8zmXak1oz3A5JChzBn/NUFNwoQ=; b=ts9YRq10zfsbGM1vrXGpiPw1CN+gquGMKHR0HUVlDPS0dTRhyBpPGTHU5ikWzhAK3CT/ErVjqWFJuW3N2XQJj5QZAsQHw11t4ljteZE9HaqItjnOnz5YCogR3liP1lFM4x6RYsdh/ENbR/1CD2oyvdyiHZeHHx+iRSFoFKiQz/0= X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Michael Roth To: CC: , , , , , , , , Fabiano Rosas Subject: [PATCH v6 03/12] kvm: Provide explicit error for kvm_create_guest_memfd() Date: Thu, 24 Sep 2026 20:43:09 -0500 Message-ID: <20260925015700.1260501-4-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260925015700.1260501-1-michael.roth@amd.com> References: <20260925015700.1260501-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6732:EE_|PH7PR12MB5686:EE_ X-MS-Office365-Filtering-Correlation-Id: f80cc580-5a87-445e-4d44-08df1aa8b3b8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|376014|23010399003|36860700016|10067099003|11063799006|5023799004|56012099006|6133799003|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: IioMS02GmMsFx94Kh4mIXlKiZDiaE1Ka93K4jtVy/bB/PX62kIja+ycjs/41HsCbCBLgw8VjnWtHU7ZqYMqI+0y2QDmm8RhZrGXzws0/Wg86BJwch2XkmNxqqraAIM2Yx2bIVbMuDimyyWrtqNrk6EIWg8Au4IBzSWHoGU3NYo4WCIoVzeuqT9v6ryMz0m0gpsXh8t1icMDYBzdIauEqQr4cdCe6tAiU3HgLeJzP7jv5rZrMWAGtI65VY4eWwuAj7oIXPE1dtYTcSnMEt7nGP1fA73BIVoUNH8l62gHiZ+sM/nrBj7GoLeMkLqXFYVN73RUM6Doh7WX9szJ4DZ4QECQ/cjE1tJafaTPf/cigc18mMJs77YlfGqAqKaklePdkUGt+SkfxWawRAFARtK9c9b6wLYv9PJQfS2MdD+YBxEFFPybe87/8TqQvtToPqOmxHObrgU+oC8CQlMW+KqvYaFw5+wFB06613xGWCvxRfF/nNbYcabW0VLdn/vfr9oZg4bCIsGg8OsQPg1DmPvIjj5GRYs+Ax6wawSMbQt4zpbR0G6YLQ+5IbmBUkUbPpI+UzRf3n13nNAqda54fedWEphKXWB2IoWhomVXQXMXvpFRviylb8/uhGajttk7p/igEuBdG7zL1CSzmCi5q17AxhW/TZCoupHX8osicuWSULjveKPYHLC5x3KxznYKWpsvntlQlbAu4DPwR+6sONZQuTw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(82310400026)(376014)(23010399003)(36860700016)(10067099003)(11063799006)(5023799004)(56012099006)(6133799003)(18002099003)(22082099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KbHkpUCVfSM09Hksa8lG5fwyGizg0dX1hGu+X/YDJ07yG5aAZY1yiYE3EnzUyG3DRgLe4ALk19zz7w5dcNjYZiomDah209bShYgIF/YhIF3cFBZuN/N2LdO5i7hmdo3rDjtq3T9tj0OupmcBwRYTGhTxwSNE5sfkFjpWHb939Fhxe+VOCVs9hLqWIGKiKlp2zLM7sVYfHdcRCmQ8CXZgHkU1NCLdRd8u+OGxWUwCrdvf+qcze1QT0P0qhg09scCXqpWDP/CwFqc/H+Meeztr12qpuO1EbTOGeZjNzenS2F+UFLq6Ka/Mbk+u6K5/+US+6TTMEpmTfmX5o+0lv+AZc+a4NYZd3N3Tq+hMZKzDru744ZbBayJsaQkpZ8rBoka9lWufvEeKAdJVZCxGEKkheclhM4ydyq5PhwPv4ST0TThRKGl6bR/McutrS4hiVuC7 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2026 01:59:58.0581 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f80cc580-5a87-445e-4d44-08df1aa8b3b8 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6732.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5686 Received-SPF: permerror client-ip=2a01:111:f403:c107::9; envelope-from=Michael.Roth@amd.com; helo=PH7PR06CU001.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1790301646483158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu So that there will be a verbal string returned when kvm not enabled, or kvm not compiled. Signed-off-by: Peter Xu Reviewed-by: Xiaoyao Li Reviewed-by: Fabiano Rosas Reviewed-by: Michael Roth Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth --- accel/kvm/kvm-all.c | 11 +++++++++++ accel/stubs/kvm-stub.c | 1 + 2 files changed, 12 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 120cab1e22..0b1407e4ea 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -4758,6 +4758,17 @@ int kvm_create_guest_memfd(uint64_t size, uint64_t f= lags, Error **errp) .flags =3D flags, }; =20 + /* + * kvm_create_guest_memfd() can be invoked from generic hostmem code + * where KVM might be compiled but not necessarily enabled. Because + * of this, check for KVM support explicitly before continuing with + * any KVM-specific checks. + */ + if (!kvm_enabled()) { + error_setg(errp, "guest-memfd requires KVM accelerator"); + return -1; + } + if (!kvm_guest_memfd_supported) { error_setg(errp, "KVM does not support guest_memfd"); return -1; diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index 3d34e3b99d..acbd0785e0 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -141,6 +141,7 @@ bool kvm_hwpoisoned_mem(void) =20 int kvm_create_guest_memfd(uint64_t size, uint64_t flags, Error **errp) { + error_setg(errp, "KVM is not enabled"); return -ENOSYS; } =20 --=20 2.43.0 From nobody Sat Sep 26 19:12:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1790301657; cv=pass; d=zohomail.com; s=zohoarc; b=cTtskDX1K8zBg9ZK9z218+6ZftO0ybkxk7vcOwUfEoL81KrrSuOrJ5pkTGnKcFOVZY24BvtJoYd4M4Jb6MsioVUQpWx6LVCcPFYCRAk2CEcXUEZR3yjIcUQTQZ4PR059sez84ws0oWFiFXMxK/fTstqTEco4Wh2eUiQcxFbCF/Y= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790301657; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1zVhRQe4wMp+VSD4ASdc6w5Uv239UOO8FT66sySDnn8=; b=b9XFwO7vQ2lKZPd3Zcko0D52OcNODO2HrThh0HSnhO+wyCHSZxT178qppyF9/bfbPkTycXKVd8I7T1CNaO3cH8ICzh9oFQ79pydCSdpRN5Dopt487KCC/tlQfWDiFU7/oky+gkwkU7E88NxWQhNKLdTXhQAJ6STpMTKDKZFkmL0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790301656923533.4383961105483; Thu, 24 Sep 2026 19:00:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x9vEx-00019B-5D; Thu, 24 Sep 2026 22:00:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vEq-0000fq-BY for qemu-devel@nongnu.org; Thu, 24 Sep 2026 22:00:37 -0400 Received: from mail-southcentralusazlp170130001.outbound.protection.outlook.com ([2a01:111:f403:c10c::1] helo=SA9PR02CU001.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vEn-0006gT-4q for qemu-devel@nongnu.org; Thu, 24 Sep 2026 22:00:35 -0400 Received: from MW4PR02CA0006.namprd02.prod.outlook.com (2603:10b6:303:16d::12) by SA1PR12MB9490.namprd12.prod.outlook.com (2603:10b6:806:45b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.428.22; Fri, 25 Sep 2026 02:00:24 +0000 Received: from MWH0EPF000A6733.namprd04.prod.outlook.com (2603:10b6:303:16d:cafe::27) by MW4PR02CA0006.outlook.office365.com (2603:10b6:303:16d::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.18 via Frontend Transport; Fri, 25 Sep 2026 02:00:24 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by MWH0EPF000A6733.mail.protection.outlook.com (10.167.249.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 25 Sep 2026 02:00:24 +0000 Received: from localhost (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Thu, 24 Sep 2026 21:00:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NmiTJcCbrpmXSWYqP5g5EpOlJ417rCHWo1yQJRPbJpHCXDZTXJLbXkw4aebeI8QMryqxyFod2Xo/dxTj3ufOSmj+U9ZSnlvD53VhAcdIHeTFJZmle3v8R/VfjvwDXyx6PJAcWTaquz9lgmidUhOch2NYDjhBiCmW6gxFo2JNr4q8KBhMJvMfHYBjpVxLl9fZTdo7mZDc1chovrrwyV1Xv/JkQ/ngQYZclnUZLjp3MsfdYNVLcXoLhS4/Nf+MLI2INg2+/qK0w8sHfzy6acQCQG3MzOavgCdLTXFoSgOAHi0C/8cSUN1N27VuhAvYxTcGH9aNwUf7RWER5ouMi9MTqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1zVhRQe4wMp+VSD4ASdc6w5Uv239UOO8FT66sySDnn8=; b=agyBJo0uWeo1Tb5qr4zPGodO1EId74XC7kEXGazO3EHnUSSzpibQTsWmSjKrrMC2un5gQWDpJ6XzsWscgCF+EbFVOSqj2Q9aALSLQTATWO1uLfmHC8Wwgk93EgWHFMvaaq3owPkgAtu+hRuYDI1v+3e/X16hUKNpiVw0GAho3sM2Meog4vi/tLt0KNMn6+f2OoLN2fE13i/BXKS4rkETMLs+4QvEYRBch1Wy5eaenMhYr4PPkLRo0NuaQ1S73lLG7impqaMN7/TZEi7N5Htrq0wy/5Ok6GwaKbX97tcXaVVpO0eEpCXrpeIaaF4n1NCVdy7iOg/YD7Cf9b412ViSfQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1zVhRQe4wMp+VSD4ASdc6w5Uv239UOO8FT66sySDnn8=; b=Nk5GuQkfchJmTORIEYXix9IYFVEv/OTBRnY3unL2OCU3tAuYjJtZriVJc9cYDS2bscLclwaMtg5ObsHHlhtcqbDUbAQuLopx7nh7qrskjheghgpJ4SE9Kgfv/27pA4IPUa70kRejzjs6z4QJoaaBY03uC10WTKohgJP6nfVm7yo= X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Michael Roth To: CC: , , , , , , , Subject: [PATCH v6 04/12] ramblock: Rename guest_memfd to guest_memfd_private Date: Thu, 24 Sep 2026 20:43:10 -0500 Message-ID: <20260925015700.1260501-5-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260925015700.1260501-1-michael.roth@amd.com> References: <20260925015700.1260501-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6733:EE_|SA1PR12MB9490:EE_ X-MS-Office365-Filtering-Correlation-Id: 0dea27aa-0d36-4616-fefe-08df1aa8c356 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|36860700016|1800799024|376014|82310400026|10067099003|56012099006|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: TQOg74hnDtkhH6GpTpn6VsWcCNgoDA+uERfdv9l0SO2NNKpZFht/W5b3CvVXPrf1DtPtnEZJtz3nMwDLSxAq24lpQ0hSApR/C/NPvNJGoVyJxqZzZatPm0cJb35+jIv4ZL5z18HnoFDRM1LNlXkkWZ5yWYAPOdNHBVX8c9YIbnK8/A/3sHKz2y6a/fLcytQabUx+/hIR5DC6nLfyYx2caWxw/xlSIJ/XJrOxOw0Y18FxkaPl7emejcEFZC2qmEUe/EVHvICl6ZNGqNSxDkuIDRq7NScgS5i6LDOT+R4o8JkDNeC5sWFKCf2V2C5ht7L7/YDo5a+FKv+vOCOGmS4jpSZTlsPPo2jBhW/T/YWex0YXxkylUnAx7PFrmH3Tnt0D5mYq3WTtpA1tEKjMjcZeOYKl6T1F7CbxAFODkZ8U92ahAE052XkquFjRN+UCRObwVPzCPbe8iRn3/HWi844tLft7YMH2GmrsBTtsZRolkMecXEtd6YmdjG8mvm532Y8+Oj3P0oUv8okSOYyPbAG0mc7F3VYqq+0KDoYyjcU3UmQjD/ewaVvtaMg19IBxPLNZWvrtbfXt2fbBu3bnykLXw+4fp/2+F2zD6UdC5IDguwNIZs9lgOhJ7iGE6h2qW8PKj0EC8ivNMvxtv7ihuUge46sUZD13r09W/FROf0ygi6Uf8OhWJDkMDIVjSrc7sexWI997MisbxdgkVbbNTEMdpg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(23010399003)(36860700016)(1800799024)(376014)(82310400026)(10067099003)(56012099006)(11063799006)(18002099003)(22082099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lERjaUJ6kR2QmIskxJAUh35CZkmT3O/zWLIJfG17T9kZ0U//zBL754+vFDNoPW3u58Ox8ePcJusrP+OlrvDpxGD/Qha4pxUGyj/ofgDf8y1sAy8BkrKAjrBdpRTz0I8Bn+Db+vwhQXxpOykfjD5z6YfdgjNUCIrvmRS3zTy0THoOI37HsrUg+SD1K0mNEhSfLBx/f1fZz/ntbvjP30d5GdGQkH6yY4y07/X28mpCgMj5gYUVuniXJvrNyjA2isfDcWAyF65sJmAZ7/IJ6fm6Cly4fHEiISb6LzJSPDho64KzSb8ziI4bOCD93CI/iNO6kv34MsNTwmV3mbEdbfWH93z/9H8ipIFzpdrReg7Mu/SSXUXJ7mn4TBIt8fpyQzqN2MB8b82xQFLIEHSdxBkdVcxVCteejG8yhjjkfX2ltAHT/4T+rgF/mn3JZEgvAq6i X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2026 02:00:24.2300 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0dea27aa-0d36-4616-fefe-08df1aa8c356 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6733.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB9490 Received-SPF: permerror client-ip=2a01:111:f403:c10c::1; envelope-from=Michael.Roth@amd.com; helo=SA9PR02CU001.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1790301658676158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu Rename the field to reflect the fact that the guest_memfd in this case only backs private portion of the ramblock rather than all of it. Reviewed-by: Xiaoyao Li Signed-off-by: Peter Xu Reviewed-by: Michael Roth Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth --- accel/kvm/kvm-all.c | 2 +- include/system/memory.h | 7 ++++--- include/system/ramblock.h | 7 ++++++- system/memory.c | 2 +- system/physmem.c | 33 +++++++++++++++++---------------- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 0b1407e4ea..a29b1d7a3c 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1729,7 +1729,7 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, mem->ram_start_offset =3D ram_start_offset; mem->ram =3D ram; mem->flags =3D kvm_mem_flags(mr); - mem->guest_memfd =3D mr->ram_block->guest_memfd; + mem->guest_memfd =3D mr->ram_block->guest_memfd_private; mem->guest_memfd_offset =3D mem->guest_memfd >=3D 0 ? (uint8_t*)ram - mr->ram_block->host : 0; =20 diff --git a/include/system/memory.h b/include/system/memory.h index a7e03fc3e7..aef555af80 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -1507,10 +1507,11 @@ bool memory_region_skip_iommu_map(const MemoryRegio= n *mr); void memory_region_set_skip_iommu_map(MemoryRegion *mr, bool skip); =20 /** - * memory_region_has_guest_memfd: check whether a memory region has guest_= memfd - * associated + * memory_region_has_guest_memfd: check whether a memory region has + * guest_memfd_private associated * - * Returns %true if a memory region's ram_block has valid guest_memfd assi= gned. + * Returns %true if a memory region's ram_block has valid guest_memfd_priv= ate + * assigned. * * @mr: the memory region being queried */ diff --git a/include/system/ramblock.h b/include/system/ramblock.h index 84624aca2c..0388d6cc6b 100644 --- a/include/system/ramblock.h +++ b/include/system/ramblock.h @@ -40,7 +40,12 @@ struct RAMBlock { Error *cpr_blocker; int fd; uint64_t fd_offset; - int guest_memfd; + /* + * When RAM_GUEST_MEMFD_PRIVATE flag is set, this ramblock can have + * private pages backed by guest_memfd_private specified, while shared + * pages are backed by the ramblock on its own. + */ + int guest_memfd_private; RamBlockAttributes *attributes; size_t page_size; /* dirty bitmap used during migration */ diff --git a/system/memory.c b/system/memory.c index 264dc90c0a..b07d5dc542 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1780,7 +1780,7 @@ void memory_region_set_skip_iommu_map(MemoryRegion *m= r, bool skip) =20 bool memory_region_has_guest_memfd(const MemoryRegion *mr) { - return mr->ram_block && mr->ram_block->guest_memfd >=3D 0; + return mr->ram_block && mr->ram_block->guest_memfd_private >=3D 0; } =20 uint8_t memory_region_get_dirty_log_mask(const MemoryRegion *mr) diff --git a/system/physmem.c b/system/physmem.c index 1b3f327ed5..156853c8db 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2201,7 +2201,7 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp) goto out_free; } =20 - assert(new_block->guest_memfd < 0); + assert(new_block->guest_memfd_private < 0); =20 ret =3D ram_block_coordinated_discard_require(true); if (ret < 0) { @@ -2211,9 +2211,9 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp) goto out_free; } =20 - new_block->guest_memfd =3D kvm_create_guest_memfd(new_block->max_l= ength, - 0, errp); - if (new_block->guest_memfd < 0) { + new_block->guest_memfd_private =3D + kvm_create_guest_memfd(new_block->max_length, 0, errp); + if (new_block->guest_memfd_private < 0) { qemu_mutex_unlock_ramlist(); goto out_free; } @@ -2230,7 +2230,7 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp) new_block->attributes =3D ram_block_attributes_create(new_block); if (!new_block->attributes) { error_setg(errp, "Failed to create ram block attribute"); - close(new_block->guest_memfd); + close(new_block->guest_memfd_private); ram_block_coordinated_discard_require(false); qemu_mutex_unlock_ramlist(); goto out_free; @@ -2366,7 +2366,7 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, ram= _addr_t max_size, new_block->max_length =3D max_size; new_block->resized =3D resized; new_block->flags =3D ram_flags; - new_block->guest_memfd =3D -1; + new_block->guest_memfd_private =3D -1; new_block->host =3D file_ram_alloc(new_block, max_size, fd, file_size < offset + max_size, offset, errp); @@ -2539,7 +2539,7 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ra= m_addr_t max_size, new_block->used_length =3D size; new_block->max_length =3D max_size; new_block->fd =3D -1; - new_block->guest_memfd =3D -1; + new_block->guest_memfd_private =3D -1; new_block->page_size =3D qemu_real_host_page_size(); new_block->host =3D host; new_block->flags =3D ram_flags; @@ -2590,8 +2590,8 @@ static void reclaim_ramblock(RAMBlock *block) qemu_anon_ram_free(block->host, block->max_length); } =20 - if (block->guest_memfd >=3D 0) { - close(block->guest_memfd); + if (block->guest_memfd_private >=3D 0) { + close(block->guest_memfd_private); ram_block_coordinated_discard_require(false); } =20 @@ -2839,12 +2839,12 @@ int ram_block_rebind(Error **errp) =20 RAMBLOCK_FOREACH(block) { if (block->flags & RAM_GUEST_MEMFD) { - if (block->guest_memfd >=3D 0) { - close(block->guest_memfd); + if (block->guest_memfd_private >=3D 0) { + close(block->guest_memfd_private); } - block->guest_memfd =3D kvm_create_guest_memfd(block->max_lengt= h, - 0, errp); - if (block->guest_memfd < 0) { + block->guest_memfd_private =3D kvm_create_guest_memfd( + block->max_length, 0, errp); + if (block->guest_memfd_private < 0) { qemu_mutex_unlock_ramlist(); return -1; } @@ -4272,7 +4272,7 @@ int ram_block_discard_range(RAMBlock *rb, uint64_t of= fset, size_t length) return ret; } =20 - if (rb->guest_memfd >=3D 0) { + if (rb->guest_memfd_private >=3D 0) { ret =3D ram_block_discard_guest_memfd_range(rb, offset, length); } =20 @@ -4286,7 +4286,8 @@ int ram_block_discard_guest_memfd_range(RAMBlock *rb,= uint64_t offset, =20 #ifdef CONFIG_FALLOCATE_PUNCH_HOLE /* ignore fd_offset with guest_memfd */ - ret =3D fallocate(rb->guest_memfd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KE= EP_SIZE, + ret =3D fallocate(rb->guest_memfd_private, + FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, length); =20 if (ret) { --=20 2.43.0 From nobody Sat Sep 26 19:12:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1790301667; cv=pass; d=zohomail.com; s=zohoarc; b=LOhjkizxQxyENebNwbuxWPpfhp1Ha1RnPXmGTA8IyJbUlvONt6TuMhhlF2JY2vcZ1Hn0xzEy3b1QRNDg2kZCEjPwdkbkFOck9nblK3TtLeQSbuwhQQ9p8bLfjZK29bkWUf+sY/NMSa6Dc01vnFIP219ZsZJB9KHEgMA6e0KI4Rk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790301667; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IwSrhALBYFI6TSXx0eAuRhvNGbLQwWtRVuS4xOl3fLA=; b=hxoJ8f/RkBX64w3LYEZPeHcbpFEH4fqN5DKOkL2KxoNnaGr5VF5NSAqPmcIXTVN3tVJ7KRoxIfwVnTUQonz5nVMbVZJE2p7h6t09v2Blp0pNGXJeSrVBHsRnlCGC+houhhWM6jjGCfBunNB/npOtPPBrzLyLHySbjEor+EYKq6g= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790301667221249.55798054313982; Thu, 24 Sep 2026 19:01:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x9vFG-0002sb-J4; Thu, 24 Sep 2026 22:01:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vFC-0002dO-Cu for qemu-devel@nongnu.org; Thu, 24 Sep 2026 22:00:58 -0400 Received: from mail-northcentralusazlp170120005.outbound.protection.outlook.com ([2a01:111:f403:c105::5] helo=CH5PR02CU005.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vF9-0006iA-SX for qemu-devel@nongnu.org; Thu, 24 Sep 2026 22:00:58 -0400 Received: from SJ0PR03CA0178.namprd03.prod.outlook.com (2603:10b6:a03:338::33) by DSVPR12MB922022.namprd12.prod.outlook.com (2603:10b6:8:3e9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.18; Fri, 25 Sep 2026 02:00:45 +0000 Received: from MWH0EPF000A6731.namprd04.prod.outlook.com (2603:10b6:a03:338:cafe::17) by SJ0PR03CA0178.outlook.office365.com (2603:10b6:a03:338::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.406.7 via Frontend Transport; Fri, 25 Sep 2026 02:00:45 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by MWH0EPF000A6731.mail.protection.outlook.com (10.167.249.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 25 Sep 2026 02:00:45 +0000 Received: from localhost (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Thu, 24 Sep 2026 21:00:43 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EM/9bkWmDDwg1mQIG/BSKresHS67hLuTUCipO3vcT4vT85J8jVFdAUX+d3vWuj6cRTKV97QcNw9qesE2hd2XhiboBGpndlV27da3wBZEibfxRdsxbOBNOCqreVDECqnaxWiaJp70K6h6NNfjc9JMH/Qbo1+r9UscOjBFmsGvZVY2OWp9pjcYrH06lEADpmcP1U/bBRA1vbnYyLnz9IUAO08wefj9RKpqdf88PtxHLWk4q2Q7fZgkT19JhHPreOu/lZboeFD7CggCGHX4QG1VYIWK1oR+QK/vAL2TqYh05kbq+2h8hkFqZ/HsHULoNYmAF2rjBl6n+Q5uUKF1vE5rVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IwSrhALBYFI6TSXx0eAuRhvNGbLQwWtRVuS4xOl3fLA=; b=G8jdTRLSgcqDVhLmRNsZ50jl5XgV+E/7EW0c1lrdKXkKowEKen7uvAwPvVXhe8gI3rmHmNV2rZdcCvy+52RCRF/y8XlZTo0S9xiF7OTwbixzYUWiRpFndCxuUUgQxTVNB7pgxxhnx2uG0vcAs1Q5P/prcF/P6bgpZxelZqDOzXDoac/l/Mo6hIVffrXThY32tjoIiiM/obC3W4OlM+gB5VotN5ITEdBc6jEHSz8F6tsAptIR/Yi9ZT0T0nBGnHnf0kckvRnupSzrviZrdut29N0ChIX6NQ3GJm8qt6YyHe03f2IzJmDUQiuYdzTUtIaIdAfUTB4pMyFkgypYCzdG1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IwSrhALBYFI6TSXx0eAuRhvNGbLQwWtRVuS4xOl3fLA=; b=PRTs6RKsljW8G1MEsgwzNgjECPstLkuQZaWgRrzKe/k5UHOQjAc1/CQeZ/QmLTgDh4HoOVJdyZLctMa3MDs2bPXSOjgGXnMV9DKuHUTkCJqxTR3zVsFU31LHBvUN9w25ZfLSmlXG1qGAq1gqXolAXC25Al8CMIk8cfVVYAHY33c= X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Michael Roth To: CC: , , , , , , , Subject: [PATCH v6 05/12] memory: Rename RAM_GUEST_MEMFD to RAM_GUEST_MEMFD_PRIVATE Date: Thu, 24 Sep 2026 20:43:11 -0500 Message-ID: <20260925015700.1260501-6-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260925015700.1260501-1-michael.roth@amd.com> References: <20260925015700.1260501-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6731:EE_|DSVPR12MB922022:EE_ X-MS-Office365-Filtering-Correlation-Id: c96a01ae-6ecb-46a9-af90-08df1aa8cfc2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|36860700016|1800799024|23010399003|10067099003|56012099006|11063799006|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: jOneiZYGc4jPkQ6/+Di4quV+oXxsdh+3MAcptRysfvSNB8I6B8RaTF24BD9W9sf+pyHVyHeRkACZRindQIbIV6ftqTnR2uvd0iwAlpoTtu6WA/UfE8RpAh5w7mddl4dq9ELL/M9hVx+gjOSO1F+ss3UCM0rFMPbHm+YovLqnXsSVHtIGRyOc6OBF4bwzaLZRzzFWHTJ6FUCh3GG/gDC1DBknJhDpTBK8sSn5ybKEs3pF9s0IOYEV2eWsobuWFk0YuAXZYkze6WCS6uKjUj6QPzovExGjmMbIuxC+rnlt2/u286Xa6Qp5UAJOaVZzi+LNG60tPDbOlDovv1z1dA7hWvqqE2af25+EFSZcWk/s9mIQrsCTBrehq3FRT+6pAsWRCcaH92LAbVqSs/Q70JoR5Z4JnI8evIODomu5cJA/pDAKiLORSIMoIQRn0N8vo0MFzyVvrZmDmiYoUx7JO7+h03aXOWtlVOzpj3/B39IwEDtr7dY6iEmDb9IdQLOoOZbk3V/ASfkDIYzgll0ttjof1zqas4usjW2/1cYn57/FjbBg+qCQn6J/WhPwuSCoMPpndqooljV1a9al+7JmdZRjdyBr4od+jwsyxJJ3xqvWbVBwqeLxn5Hyz0KpxRyXfFrQqnJ7n1G65N3XP8ACeiI+WM+H8WhRb+O4cwuM63jDDGcsZsLJcEw9pSEz3coYKGKOdpy1YPxG+9EGPz7+4jfe1A== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(82310400026)(36860700016)(1800799024)(23010399003)(10067099003)(56012099006)(11063799006)(6133799003)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5KKw1jHM0+dUf7T/zsZtUI7GPuBtOh2Tjbf1Az8kHllVxRhnZylYxJKSvwjX161YW+qr53jLTnrfKf61bIHvOJtojIEWM+MbcYj2PSe1Qzco6JO9umKibj7jKWsUvy2JE/nIsGUDRwM9O08Yh1c32Civ4Fpg5DOg3534Oi8zK6OYgTEI5NM88AjJUxNXOF3/Gmyxmkd0bCzi2WjWY57mo7lFeUQr7EPqI7sGLEJmYtN3E3HZ6rJaESLGvKRBxpP76njbCRTPdCRW+7OEh+ZeWWqoWitaAowbxVQTyIxwygqh9BNV8M9jhUhbZ9TvDh+dupHOdM8j1kMhUW5YADuerMw0rXwRNozS7OrMp4goT5PjRa3Y5DWhEfUUuDpHqu0N0aScusjbai8SlePEc99yhto0eQdgVjXgZDzeRs1T0+6FKeoA5Es+0nIR/2Ib3lz+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2026 02:00:45.1013 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c96a01ae-6ecb-46a9-af90-08df1aa8cfc2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6731.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DSVPR12MB922022 Received-SPF: permerror client-ip=2a01:111:f403:c105::5; envelope-from=Michael.Roth@amd.com; helo=CH5PR02CU005.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1790301668664158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu This name is too generic, and can conflict with support for using guest-memfd for shared memory. Add a _PRIVATE suffix to show what it really means: it is using guest_memfd specifically for private memory; whether or not guest_memfd is being used for shared memory is something to be configured/determined separately. This also paves way for in-place guest-memfd, which means we can have a ramblock that allocates pages completely from guest-memfd (private or shared). Reviewed-by: Xiaoyao Li Signed-off-by: Peter Xu Reviewed-by: Michael Roth Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth --- backends/hostmem-file.c | 2 +- backends/hostmem-memfd.c | 2 +- backends/hostmem-ram.c | 2 +- backends/hostmem-shm.c | 2 +- include/system/memory.h | 8 ++++---- include/system/ramblock.h | 2 +- system/memory.c | 2 +- system/physmem.c | 10 +++++----- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index 8cf27ad67e..bb7323d2bf 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -86,7 +86,7 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Err= or **errp) ram_flags |=3D fb->readonly ? RAM_READONLY_FD : 0; ram_flags |=3D fb->rom =3D=3D ON_OFF_AUTO_ON ? RAM_READONLY : 0; ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; - ram_flags |=3D backend->guest_memfd ? RAM_GUEST_MEMFD : 0; + ram_flags |=3D backend->guest_memfd ? RAM_GUEST_MEMFD_PRIVATE : 0; ram_flags |=3D fb->is_pmem ? RAM_PMEM : 0; ram_flags |=3D RAM_NAMED_FILE; return memory_region_init_ram_from_file(&backend->mr, OBJECT(backend),= name, diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index e21c5a3f2e..d917a94d73 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -60,7 +60,7 @@ have_fd: backend->aligned =3D true; ram_flags =3D backend->share ? RAM_SHARED : RAM_PRIVATE; ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; - ram_flags |=3D backend->guest_memfd ? RAM_GUEST_MEMFD : 0; + ram_flags |=3D backend->guest_memfd ? RAM_GUEST_MEMFD_PRIVATE : 0; return memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), n= ame, backend->size, ram_flags, fd, 0,= errp); } diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c index 062b1abb11..96ad29112d 100644 --- a/backends/hostmem-ram.c +++ b/backends/hostmem-ram.c @@ -30,7 +30,7 @@ ram_backend_memory_alloc(HostMemoryBackend *backend, Erro= r **errp) name =3D host_memory_backend_get_name(backend); ram_flags =3D backend->share ? RAM_SHARED : RAM_PRIVATE; ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; - ram_flags |=3D backend->guest_memfd ? RAM_GUEST_MEMFD : 0; + ram_flags |=3D backend->guest_memfd ? RAM_GUEST_MEMFD_PRIVATE : 0; return memory_region_init_ram_flags_nomigrate(&backend->mr, OBJECT(bac= kend), name, backend->size, ram_flags, errp); diff --git a/backends/hostmem-shm.c b/backends/hostmem-shm.c index 806e2670e0..e86fb2e0aa 100644 --- a/backends/hostmem-shm.c +++ b/backends/hostmem-shm.c @@ -54,7 +54,7 @@ have_fd: /* Let's do the same as memory-backend-ram,share=3Don would do. */ ram_flags =3D RAM_SHARED; ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; - ram_flags |=3D backend->guest_memfd ? RAM_GUEST_MEMFD : 0; + ram_flags |=3D backend->guest_memfd ? RAM_GUEST_MEMFD_PRIVATE : 0; =20 return memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), backend_name, backend->size, diff --git a/include/system/memory.h b/include/system/memory.h index aef555af80..932072c631 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -262,7 +262,7 @@ typedef struct IOMMUTLBEvent { #define RAM_READONLY_FD (1 << 11) =20 /* RAM can be private that has kvm guest memfd backend */ -#define RAM_GUEST_MEMFD (1 << 12) +#define RAM_GUEST_MEMFD_PRIVATE (1 << 12) =20 /* * In RAMBlock creation functions, if MAP_SHARED is 0 in the flags paramet= er, @@ -1119,7 +1119,7 @@ void memory_region_init_io(MemoryRegion *mr, * must be unique within any device * @size: size of the region. * @ram_flags: RamBlock flags. Supported flags: RAM_SHARED, RAM_NORESERVE, - * RAM_GUEST_MEMFD. + * RAM_GUEST_MEMFD_PRIVATE. * @errp: pointer to Error*, to store an error if it happens. * * Note that this function does not do anything to cause the data in the @@ -1181,7 +1181,7 @@ bool memory_region_init_resizeable_ram(MemoryRegion *= mr, * (getpagesize()) will be used. * @ram_flags: RamBlock flags. Supported flags: RAM_SHARED, RAM_PMEM, * RAM_NORESERVE, RAM_PROTECTED, RAM_NAMED_FILE, RAM_READONLY, - * RAM_READONLY_FD, RAM_GUEST_MEMFD + * RAM_READONLY_FD, RAM_GUEST_MEMFD_PRIVATE * @path: the path in which to allocate the RAM. * @offset: offset within the file referenced by path * @errp: pointer to Error*, to store an error if it happens. @@ -1212,7 +1212,7 @@ bool memory_region_init_ram_from_file(MemoryRegion *m= r, * @size: size of the region. * @ram_flags: RamBlock flags. Supported flags: RAM_SHARED, RAM_PMEM, * RAM_NORESERVE, RAM_PROTECTED, RAM_NAMED_FILE, RAM_READONLY, - * RAM_READONLY_FD, RAM_GUEST_MEMFD + * RAM_READONLY_FD, RAM_GUEST_MEMFD_PRIVATE * @fd: the fd to mmap. * @offset: offset within the file referenced by fd * @errp: pointer to Error*, to store an error if it happens. diff --git a/include/system/ramblock.h b/include/system/ramblock.h index 0388d6cc6b..1352ec1603 100644 --- a/include/system/ramblock.h +++ b/include/system/ramblock.h @@ -257,7 +257,7 @@ static inline unsigned long int ramblock_recv_bitmap_of= fset(void *host_addr, * @resized: callback after calls to qemu_ram_resize * @ram_flags: RamBlock flags. Supported flags: RAM_SHARED, RAM_PMEM, * RAM_NORESERVE, RAM_PROTECTED, RAM_NAMED_FILE, RAM_READONLY, - * RAM_READONLY_FD, RAM_GUEST_MEMFD + * RAM_READONLY_FD, RAM_GUEST_MEMFD_PRIVATE * @mem_path or @fd: specify the backing file or device * @offset: Offset into target file * @grow: extend file if necessary (but an empty file is always extended). diff --git a/system/memory.c b/system/memory.c index b07d5dc542..96e42beb2e 100644 --- a/system/memory.c +++ b/system/memory.c @@ -3597,7 +3597,7 @@ bool memory_region_init_ram_guest_memfd(MemoryRegion = *mr, Object *owner, Error **errp) { if (!memory_region_init_ram_flags_nomigrate(mr, owner, name, size, - RAM_GUEST_MEMFD, errp)) { + RAM_GUEST_MEMFD_PRIVATE, e= rrp)) { return false; } memory_region_register_ram(mr, owner); diff --git a/system/physmem.c b/system/physmem.c index 156853c8db..db3dda563d 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2184,7 +2184,7 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp) } } =20 - if (new_block->flags & RAM_GUEST_MEMFD) { + if (new_block->flags & RAM_GUEST_MEMFD_PRIVATE) { int ret; =20 if (!kvm_enabled()) { @@ -2322,7 +2322,7 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, ram= _addr_t max_size, /* Just support these ram flags by now. */ assert((ram_flags & ~(RAM_SHARED | RAM_PMEM | RAM_NORESERVE | RAM_PROTECTED | RAM_NAMED_FILE | RAM_READONLY | - RAM_READONLY_FD | RAM_GUEST_MEMFD | + RAM_READONLY_FD | RAM_GUEST_MEMFD_PRIVATE | RAM_RESIZEABLE)) =3D=3D 0); assert(max_size >=3D size); =20 @@ -2479,7 +2479,7 @@ RAMBlock *qemu_ram_alloc_internal(ram_addr_t size, ra= m_addr_t max_size, ram_flags &=3D ~RAM_PRIVATE; =20 assert((ram_flags & ~(RAM_SHARED | RAM_RESIZEABLE | RAM_PREALLOC | - RAM_NORESERVE | RAM_GUEST_MEMFD)) =3D=3D 0); + RAM_NORESERVE | RAM_GUEST_MEMFD_PRIVATE)) =3D=3D= 0); assert(!host ^ (ram_flags & RAM_PREALLOC)); assert(max_size >=3D size); =20 @@ -2562,7 +2562,7 @@ RAMBlock *qemu_ram_alloc_from_ptr(ram_addr_t size, vo= id *host, RAMBlock *qemu_ram_alloc(ram_addr_t size, uint32_t ram_flags, MemoryRegion *mr, Error **errp) { - assert((ram_flags & ~(RAM_SHARED | RAM_NORESERVE | RAM_GUEST_MEMFD | + assert((ram_flags & ~(RAM_SHARED | RAM_NORESERVE | RAM_GUEST_MEMFD_PRI= VATE | RAM_PRIVATE)) =3D=3D 0); return qemu_ram_alloc_internal(size, size, NULL, NULL, ram_flags, mr, = errp); } @@ -2838,7 +2838,7 @@ int ram_block_rebind(Error **errp) qemu_mutex_lock_ramlist(); =20 RAMBLOCK_FOREACH(block) { - if (block->flags & RAM_GUEST_MEMFD) { + if (block->flags & RAM_GUEST_MEMFD_PRIVATE) { if (block->guest_memfd_private >=3D 0) { close(block->guest_memfd_private); } --=20 2.43.0 From nobody Sat Sep 26 19:12:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1790301682; cv=pass; d=zohomail.com; s=zohoarc; b=OdTPl3zioCsSh3Uf7kASNqFcTIzejEuAOX2CoqxJLDp2mp1qGkGwj/RiooxLdWZmTyY6ALD8rDgi03pTE0HE8yf5uw4VFJ+b8HNZNPOffwfgWPNHgw9mN3ytnAYMXHsYX/gmO7M5ZcyqSmP0nmM6CllKqu2HqeI3NWMo1QvzE/U= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790301682; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=96HlfxzT8m4X5ZW4wYZd5NhRo3u1dSz/B/UcNjv/zT8=; b=L6jpl9Yf2M5yTNHlSJ3XPXOECZwVHL3EL8nYEidC6RdEWvVAMWitLIxhMp+CGt/rNP8sOWJV9Ni1Q+BveUNV6aKNLFgUBDkSAGNwkV1APBI6V8JhPNbngUEq36I9uAIIRHE6f56LvpR/ZJ4XhfhxbdYC/PK/4oc2bfUGHJSDfcA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790301682607467.3097741935586; Thu, 24 Sep 2026 19:01:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x9vFX-0003S6-WA; Thu, 24 Sep 2026 22:01:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vFU-0003Ii-2c for qemu-devel@nongnu.org; Thu, 24 Sep 2026 22:01:16 -0400 Received: from mail-northcentralusazlp170120005.outbound.protection.outlook.com ([2a01:111:f403:c105::5] helo=CH5PR02CU005.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vFS-0006jR-AA for qemu-devel@nongnu.org; Thu, 24 Sep 2026 22:01:15 -0400 Received: from MW4PR03CA0147.namprd03.prod.outlook.com (2603:10b6:303:8c::32) by DSVPR12MB999150.namprd12.prod.outlook.com (2603:10b6:8:388::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.18; Fri, 25 Sep 2026 02:01:11 +0000 Received: from MWH0EPF000A6730.namprd04.prod.outlook.com (2603:10b6:303:8c:cafe::16) by MW4PR03CA0147.outlook.office365.com (2603:10b6:303:8c::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.428.15 via Frontend Transport; Fri, 25 Sep 2026 02:01:10 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by MWH0EPF000A6730.mail.protection.outlook.com (10.167.249.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 25 Sep 2026 02:01:10 +0000 Received: from localhost (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Thu, 24 Sep 2026 21:01:09 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PHBSRLCeyHfX1GqHs/ctL3aVIZEsWB/xyIB+AmphZDsYAcCXq/OWtB8ncBzE35f2rSbLhyf071kw1I2+kjDsZYEf1riwBd4a91QhMIQgBlDyLnPPXmceqlwKy86iCWNk/73ELyMqG2G/aMT9HYYt6nvlfns0Qpp2xUcyyMhrzMXMmyhUYI3gyvB5oxxVb4/5Kvn/Prj40araAwq4UdvUQIHvDbAvG9xNtOhykl68ljBFJoUjZUOvhtPB1LwIe44/dwQY0lm5mUdzWxbcntVmh8zOyhZq5B+sM2nSbB99k4CNhQULgTZ7ffLgSNqLbQDhIndTmRgT3qit5riWQMGn8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=96HlfxzT8m4X5ZW4wYZd5NhRo3u1dSz/B/UcNjv/zT8=; b=sZM2RA4F311xL46FkNk4PakWNdIWC8FjoK92+F9XQ1k3iPA0+uk21hocQ2kAgcVJmobCVaCiZCyKHo3saBWb80GQBQkxaEr+Ew4GZQIM2mIvQ3IBxratqXcqFFaUdF8G75wyj1WlpxwAlI2YwWflJSBLdVrvf2lHeiROmWaQ5Bd+tOQDp9Aqn9EmHwQFk/hnP20P3lZnvC2Jv8Gnt1JA4UjbEk6wogY67ofZrFIdUIhY1kcAWuHTxzMa+S8cLOL1nwl5Q3hffJgGW++nQRlQqkMNQAGFBYTM2PsZGlm3OPvoKN6yJVFW8hpZ1d/RlKboBGntntBBYYpY+zHUTICjhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=96HlfxzT8m4X5ZW4wYZd5NhRo3u1dSz/B/UcNjv/zT8=; b=FInqFTdbguFmgc7r2BR30rvHroGFsQsHk/wL9ZGPOmf2KUlcKmC3TJwJuHnW2mGUridxooEOWAPp/UXycxX97ELiMj1VKfl3xDwbxjFdSJ+zG3ALik1oEgWxTveT+0w20PB2BMi/s4FLfnZjvVI3osp+5Xi/cTBMX0Jk4tbcBN8= X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Michael Roth To: CC: , , , , , , , Subject: [PATCH v6 06/12] memory: Rename memory_region_has_guest_memfd() to *_private() Date: Thu, 24 Sep 2026 20:43:12 -0500 Message-ID: <20260925015700.1260501-7-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260925015700.1260501-1-michael.roth@amd.com> References: <20260925015700.1260501-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6730:EE_|DSVPR12MB999150:EE_ X-MS-Office365-Filtering-Correlation-Id: d1d4e1f4-a134-455e-6576-08df1aa8debb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700016|82310400026|376014|23010399003|22082099003|18002099003|11063799006|56012099006|10067099003; X-Microsoft-Antispam-Message-Info: vkMkYv2WcDv+QC330HE0rXu3BwJ37k32tOLJhc8GoLXruaFQ2KP7RKCxHKxqx5dRp62WTAzdRXoVAS/4FIIFXtfR9Pn952i3TZp7a/MQ+jaPTFy2LZYfTKlNN5w4ug0moVglZwg5REIp38t6bhodobNUL/V+hT3b3uNbF8pc64AEDIhoB+DLvBXuNh1ULCcPnL3p96Ge1giNJxGTxM0P3L4kWT51IyG/iiM+EXvtARno46jhTFGBTUnN/ywyeyWkTDnlXfzhMMX5yNI4iKNLy6z3jiLzfyIjex1N0wO91Zn9T1QyL/Me9f0YBdOSOSkJsYWNqxm/V3VDoI8dWet5VVWXxseC4BRumOJh5GPZy7ClYTyGlGlgkMbgXCe3Yn9rfnnbdAt3DEtDjSMnmDYQyzD3N/5ez/BBKk7cjo9TLBELDK187vJPMAqXo0heNt6KTqxYCVAEEcj3OeY095Ao1nXT79Uqo0hM7+fQ0oPv7fjoDO1K6jWNAKWtVUNzkdWGUtrXtxd4dkXdk44fT/4erTML4N+cwjtkFPxAxOk6hevYy9mNigGVh98rfbD+eosyOXpJqa25EcXiJuIFC/g7bD95TR2y9Wf2SSFh3+ad5j5iYPtm2WehLIL6HT3YgpWjuBQjFaSs+F4P5cS9B+eHNPU/W0LE+qmXRxjuxsfu/FNOC4rbnZ9s0803/49MS8x1xX6b9T67Cy5DQDFK3S7K3A== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700016)(82310400026)(376014)(23010399003)(22082099003)(18002099003)(11063799006)(56012099006)(10067099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1cRD785DOSPvJMpV6l6F5lbL7mnYwj8rc16NDyUua9lh+V9WnIDljjoziZYF6ygF63xDbbdwwzcAUoTUUFSIKw1W5aIwvcYcdQmgRjBocFqxym8JrnuOQ5yxYkMsCWwUONBkhVRterg8M/Z5TaObxP9zgiKkxbubTukxQZYTCtdY4JTo6vS72wn6atNoWnpzqaNiLcMvEa7hbTFHHhSFH1E3sSl6qcpTl/oZII1iKc9ZRlTp4lEu3WKvdpwJ0Q7GeM1BOaZSv4iqfrg1qOMix2lVPOq3AjUfpbeSevMUnuX+QtG5/8TJgXLR5dowSODC6itWwk7BqJyS/pEavciwApjfyp2B6gQeafNpacKVbeoPP3bXCRmk78KXtfm8WaBDq6AWdsp+igWVgxKJ5/S2ABbHDbxsWKLAeSsIOQtYj/krCZwrRbj0UljDQalmvRa+ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2026 02:01:10.2823 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d1d4e1f4-a134-455e-6576-08df1aa8debb X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6730.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DSVPR12MB999150 Received-SPF: permerror client-ip=2a01:111:f403:c105::5; envelope-from=Michael.Roth@amd.com; helo=CH5PR02CU005.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1790301684669158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu Rename the function with "_private" suffix, to show that it returns true only if it has an internal guest-memfd to back private pages (rather than fully shared guest-memfd). Reviewed-by: Xiaoyao Li Signed-off-by: Peter Xu Reviewed-by: Michael Roth Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth --- accel/kvm/kvm-all.c | 6 +++--- include/system/memory.h | 4 ++-- system/memory.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index a29b1d7a3c..db52bb9ffb 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -792,7 +792,7 @@ static int kvm_mem_flags(MemoryRegion *mr) if (readonly && kvm_readonly_mem_allowed) { flags |=3D KVM_MEM_READONLY; } - if (memory_region_has_guest_memfd(mr)) { + if (memory_region_has_guest_memfd_private(mr)) { assert(kvm_guest_memfd_supported); flags |=3D KVM_MEM_GUEST_MEMFD; } @@ -1741,7 +1741,7 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, abort(); } =20 - if (memory_region_has_guest_memfd(mr)) { + if (memory_region_has_guest_memfd_private(mr)) { err =3D kvm_set_memory_attributes_private(start_addr, slot_siz= e); if (err) { error_report("%s: failed to set memory attribute private: = %s", @@ -3372,7 +3372,7 @@ int kvm_convert_memory(hwaddr start, hwaddr size, boo= l to_private) return ret; } =20 - if (!memory_region_has_guest_memfd(mr)) { + if (!memory_region_has_guest_memfd_private(mr)) { /* * Because vMMIO region must be shared, guest TD may convert vMMIO * region to shared explicitly. Don't complain such case. See diff --git a/include/system/memory.h b/include/system/memory.h index 932072c631..96ab920e7d 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -1507,7 +1507,7 @@ bool memory_region_skip_iommu_map(const MemoryRegion = *mr); void memory_region_set_skip_iommu_map(MemoryRegion *mr, bool skip); =20 /** - * memory_region_has_guest_memfd: check whether a memory region has + * memory_region_has_guest_memfd_private: check whether a memory region has * guest_memfd_private associated * * Returns %true if a memory region's ram_block has valid guest_memfd_priv= ate @@ -1515,7 +1515,7 @@ void memory_region_set_skip_iommu_map(MemoryRegion *m= r, bool skip); * * @mr: the memory region being queried */ -bool memory_region_has_guest_memfd(const MemoryRegion *mr); +bool memory_region_has_guest_memfd_private(const MemoryRegion *mr); =20 /** * memory_region_get_iommu: check whether a memory region is an iommu diff --git a/system/memory.c b/system/memory.c index 96e42beb2e..fa0a2cf563 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1778,7 +1778,7 @@ void memory_region_set_skip_iommu_map(MemoryRegion *m= r, bool skip) mr->ram_device_skip_iommu_map =3D skip; } =20 -bool memory_region_has_guest_memfd(const MemoryRegion *mr) +bool memory_region_has_guest_memfd_private(const MemoryRegion *mr) { return mr->ram_block && mr->ram_block->guest_memfd_private >=3D 0; } --=20 2.43.0 From nobody Sat Sep 26 19:12:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1790301709; cv=pass; d=zohomail.com; s=zohoarc; b=E9DX7ipBbBytl0jL+wQhckNdtwyg4cuNdnbbkFSpcqiRkWkOnkmNyIyzIfYTMIWGABQgjKtrvG3zmuvkRb44UXBS4gn5Hi7Stlk3j3oN9VEsT8PgiI0vYIjYRfCmfqJZF4XE9wbXUFfT7bsV/hJjfJFAVsC+2dk2SQ60h+kbgZE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790301709; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=alBSg339oD0X0tXU8yrztCP+ucf1ltvMwcUalYmBLII=; b=IKY8su66CaOpOJwyOg6b+19Dmvfavq5o4tPlllTWRFWt0Nkk5kQ7dcJKOBm9vQ16wzBCxw9IGoHRClnaMtD6uQOzYz3krMdvD5bbtSCMybgPp/ReUwckRKKv5kkgNFRX1kRbjs7/FghIUpfl0NbXH/cCJsp96AGPb7H1u7FVvgo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790301709018673.2786626738633; Thu, 24 Sep 2026 19:01:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x9vFs-0003yu-U8; Thu, 24 Sep 2026 22:01:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vFr-0003xm-8a for qemu-devel@nongnu.org; Thu, 24 Sep 2026 22:01:39 -0400 Received: from mail-westus2azlp170100005.outbound.protection.outlook.com ([2a01:111:f403:c005::5] helo=CO1PR03CU002.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vFo-0006l6-QN for qemu-devel@nongnu.org; Thu, 24 Sep 2026 22:01:38 -0400 Received: from MW4PR02CA0023.namprd02.prod.outlook.com (2603:10b6:303:16d::16) by LV8PR12MB9452.namprd12.prod.outlook.com (2603:10b6:408:200::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.18; Fri, 25 Sep 2026 02:01:31 +0000 Received: from MWH0EPF000A6733.namprd04.prod.outlook.com (2603:10b6:303:16d:cafe::2) by MW4PR02CA0023.outlook.office365.com (2603:10b6:303:16d::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.18 via Frontend Transport; Fri, 25 Sep 2026 02:01:31 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by MWH0EPF000A6733.mail.protection.outlook.com (10.167.249.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 25 Sep 2026 02:01:30 +0000 Received: from localhost (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Thu, 24 Sep 2026 21:01:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IVwYv2TKtl74xco3MDAfeZj4NzSrWuYnKC/D2BuOoqDR7fj3eLvC0qxkQVO/ymYXMJbu9UNNRVu7QOcSEQ+0VP79Rbpmy3x5LlVkEbUcU57+50OatVCumEvK65HTpmv3Q2cxSrpSCgjBlG54RDA37zc8/sLhUAjc9j4b/Wh8LDH+iAiJdLZIrBKCQr03idzVUOBj7smzVrT//X5206zt7u32dzLo2I6F0wEmZKpJLFZsV/dgR4RJvcR6adPGiPycenqx271P81Eo9Xx2eUPwAbIJuk0WRCOCt4VqpjIf1Lgd6DYB88THI9hfi5w5OgdJOyr03n6c7L8a57bScVy1TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=alBSg339oD0X0tXU8yrztCP+ucf1ltvMwcUalYmBLII=; b=RHTBayXYCZg+mKRVtsl3TRMuXbdc97DCSobyLNwbkZiUBNkr3HCWURkJ191QLZLFqg6eWRy48KTWOs18WSDSu6847Ih0RbOGfInGOzVOjWoY7IXEB/E4GyJ4Uh4cS9XJcI/Eh6z1Ov3WqD0YLcwuzkw8/KDbKRdn9pkF7TcNiJ/ilG1rFYAeygeB/xj1UvCYdeOCox7Lylw/ykXUaW3Kf8tCrEkfThMxvhSvEgkoY/S+8HuJ7QtS+WA6MXzeFGourQ7aNuuDXQKSe0cf9JAwDaUSPWH7a4PkCa5dWZPNToAKT0YZMCvCADQoksaiZZGlrfWU2OBl1vxPpm9YkFYmtQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=alBSg339oD0X0tXU8yrztCP+ucf1ltvMwcUalYmBLII=; b=sSxFk/UHsWvovdavBF5skSDcFQ7MUnh8xEu6F8GEuIJJORjGq3DN+0wVtXBrxCYpaCLPviEQmlUT+MYxJKnjuI38aifiyopdaZjgAxn44yDHA/2oiszRVgjhjDjaB0A/Z57Ip0gOrcwpIt1spGhxwhjq21HrL13MuZNfxQkGn/o= X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Michael Roth To: CC: , , , , , , , Subject: [PATCH v6 07/12] hostmem: Rename guest_memfd to guest_memfd_private Date: Thu, 24 Sep 2026 20:43:13 -0500 Message-ID: <20260925015700.1260501-8-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260925015700.1260501-1-michael.roth@amd.com> References: <20260925015700.1260501-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6733:EE_|LV8PR12MB9452:EE_ X-MS-Office365-Filtering-Correlation-Id: e478926f-5906-43a7-bc38-08df1aa8eb16 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|82310400026|23010399003|36860700016|6133799003|10067099003|56012099006|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: hp5qM2MTYZ67fLtcSihl1rDPqzLWnyM+tDcCme4vlKC12PmXhmaMWOvWyrxdxPu5RN1eObduTV4bMwJoYjuxyki+zploCW72yeFCan66QBZtyKDIRbdYj57ErZXHVoYU9VwuUs5rp60kjxDFOWUs5o9U7wJnvZFp3sm7MBMrT5kzEsehuroSuaoJgUnuX/TMBPc2cG0ZR3yZfKQL6iMt7TnLw1sII4XYUbwlo5Bcg4vYOvn8OOvrzHFzaCUgQFOL04DpoUYofF4plmHoN3I1/z9UkWQ+BKmM479Z8Hm4GBzw2F6MB3fpP6NqHk28X5HMvkPSJmh16SGJwBSn44ZopCOOhb8HkJzV+ZcXXbCJHzawAK/aUOeTyV4CQQhmVH7KmdGZ547Ffrm/HYcP9CowiWlorzzcx8TzJhOVC4nF+oyqAJWZoL/DtxVMUYimKnVgNSHEnNIS06T7O4PimkfGG+o2dWP5wK3l3qJhfNhKlddjxSDEl2n4+kaGHJgyS9Qku7O35igNw+Urewb/2E9qjdj8MIz4JX0WMt1S4/W44qAtVsKnDde4xsQXG5eHjTSe8e0oqZpxBGgfaAyN65xQUhc03mdLQsu1n9li6hoU0rPC1bIxhsRiEDXc5yJWKacUV1v2GM5ODSPz94VtdWnZOC502d+Kc7UJ2y9awB14ULZavjx7IlAM6xTpkJksyfsW2/H8IjzFVJ7Kq3yBouVZYg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(376014)(82310400026)(23010399003)(36860700016)(6133799003)(10067099003)(56012099006)(11063799006)(18002099003)(22082099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HAINZPBaPhvzUf5XnS9XXb0mincl3jNKsJVMEAXbc9PNJiUGbNyodMyBqSvqfurhpHQ1pEgimy2FVGKoKDAW6FTqPR2OepTpK8rHMFIDFj4CviseMQbgvEWSAqPWYa/Un2P+jHCDNBUzgp+CmXPHxvj2nHxamG4txPQL9t2tGZKHeRw5U6gyImKvOOAIzEtd/WTT6iexaBdCKhDBlQs+h3pVmujWZvA85+s+fO1arYJ4uIcsc/smki/stZwgytV9Zu82wolEsuMxTbyJAYNrRvvLHX/4pBshyPy7eMhderVhXp0WdtYcSvCtP69GEU1oN8eNuVKZ7rmDxBDPnVoauvRzNN4qMzNXbEC6c/pPe/VV1vSP5goFyR1fYgEyIwB8zxwuU3vjJDyX5ud61Z5lDKALegm7stpCbFc3OG2Pbx6Xl/1SMcfSVQxVkBRF4VqC X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2026 02:01:30.9539 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e478926f-5906-43a7-bc38-08df1aa8eb16 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6733.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9452 Received-SPF: permerror client-ip=2a01:111:f403:c005::5; envelope-from=Michael.Roth@amd.com; helo=CO1PR03CU002.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1790301711081158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu Rename the HostMemoryBackend.guest_memfd field to reflect what it really means: whether it needs guest_memfd to back its private guest memory. This will help avoid conflicts when we introduce supported for using guest_memfd for shared guest memory via hostmem. Signed-off-by: Peter Xu Reviewed-by: Xiaoyao Li Reviewed-by: Michael Roth Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth --- backends/hostmem-file.c | 2 +- backends/hostmem-memfd.c | 2 +- backends/hostmem-ram.c | 2 +- backends/hostmem-shm.c | 2 +- backends/hostmem.c | 2 +- include/system/hostmem.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index bb7323d2bf..7efecf71f5 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -86,7 +86,7 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Err= or **errp) ram_flags |=3D fb->readonly ? RAM_READONLY_FD : 0; ram_flags |=3D fb->rom =3D=3D ON_OFF_AUTO_ON ? RAM_READONLY : 0; ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; - ram_flags |=3D backend->guest_memfd ? RAM_GUEST_MEMFD_PRIVATE : 0; + ram_flags |=3D backend->guest_memfd_private ? RAM_GUEST_MEMFD_PRIVATE = : 0; ram_flags |=3D fb->is_pmem ? RAM_PMEM : 0; ram_flags |=3D RAM_NAMED_FILE; return memory_region_init_ram_from_file(&backend->mr, OBJECT(backend),= name, diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index d917a94d73..7a7855aaab 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -60,7 +60,7 @@ have_fd: backend->aligned =3D true; ram_flags =3D backend->share ? RAM_SHARED : RAM_PRIVATE; ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; - ram_flags |=3D backend->guest_memfd ? RAM_GUEST_MEMFD_PRIVATE : 0; + ram_flags |=3D backend->guest_memfd_private ? RAM_GUEST_MEMFD_PRIVATE = : 0; return memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), n= ame, backend->size, ram_flags, fd, 0,= errp); } diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c index 96ad29112d..6a507fad77 100644 --- a/backends/hostmem-ram.c +++ b/backends/hostmem-ram.c @@ -30,7 +30,7 @@ ram_backend_memory_alloc(HostMemoryBackend *backend, Erro= r **errp) name =3D host_memory_backend_get_name(backend); ram_flags =3D backend->share ? RAM_SHARED : RAM_PRIVATE; ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; - ram_flags |=3D backend->guest_memfd ? RAM_GUEST_MEMFD_PRIVATE : 0; + ram_flags |=3D backend->guest_memfd_private ? RAM_GUEST_MEMFD_PRIVATE = : 0; return memory_region_init_ram_flags_nomigrate(&backend->mr, OBJECT(bac= kend), name, backend->size, ram_flags, errp); diff --git a/backends/hostmem-shm.c b/backends/hostmem-shm.c index e86fb2e0aa..4766db6aad 100644 --- a/backends/hostmem-shm.c +++ b/backends/hostmem-shm.c @@ -54,7 +54,7 @@ have_fd: /* Let's do the same as memory-backend-ram,share=3Don would do. */ ram_flags =3D RAM_SHARED; ram_flags |=3D backend->reserve ? 0 : RAM_NORESERVE; - ram_flags |=3D backend->guest_memfd ? RAM_GUEST_MEMFD_PRIVATE : 0; + ram_flags |=3D backend->guest_memfd_private ? RAM_GUEST_MEMFD_PRIVATE = : 0; =20 return memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), backend_name, backend->size, diff --git a/backends/hostmem.c b/backends/hostmem.c index 02846b597d..a41540d50d 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -290,7 +290,7 @@ static void host_memory_backend_init(Object *obj) /* TODO: convert access to globals to compat properties */ backend->merge =3D machine_mem_merge(machine); backend->dump =3D machine_dump_guest_core(machine); - backend->guest_memfd =3D machine_require_guest_memfd(machine); + backend->guest_memfd_private =3D machine_require_guest_memfd(machine); backend->reserve =3D true; backend->prealloc_threads =3D machine->smp.cpus; } diff --git a/include/system/hostmem.h b/include/system/hostmem.h index 88fa791ac7..dcbf81aeae 100644 --- a/include/system/hostmem.h +++ b/include/system/hostmem.h @@ -76,7 +76,7 @@ struct HostMemoryBackend { uint64_t size; bool merge, dump, use_canonical_path; bool prealloc, is_mapped, share, reserve; - bool guest_memfd, aligned; + bool guest_memfd_private, aligned; uint32_t prealloc_threads; ThreadContext *prealloc_context; DECLARE_BITMAP(host_nodes, MAX_NODES + 1); --=20 2.43.0 From nobody Sat Sep 26 19:12:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1790301724; cv=pass; d=zohomail.com; s=zohoarc; b=QYLFd0ltLm3Ofq7/+LZAq0dmdqNHO53o/ebNxbG4OqM/Nml02UIzXd4ViUgy1HTDaoFWXaJh4p0ktRMJbyJyBNtx39DLXRvLY8Q66RyNGIb1/cfRbyy+uLV+Yi7n9Ti+96pYXXaTfRtx/9Mi5Zxt4f2zTnlnrlDH0+aQuaNowjc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790301724; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zMK0sSQeYcJ2SpZUHsUEOIHNVrbe+TOzK1ACkBFcx98=; b=APwKKGAuqEo3kYvtqPhU8PGNhkTyallDJ0ZijeOKske9Ny98J1gf9Kr0x9auoQ3qZgjPxXPorKky7vPiNyZxr1TrkfGzHi/FwY11DTy57LTQv61EFR6j+B4znSnvA4xTSJLxSoD/3dU4Co/MGwjXttLf1EVMleta48GMtVTFf00= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179030172410295.13987147672651; Thu, 24 Sep 2026 19:02:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x9vGC-0004IO-Ht; Thu, 24 Sep 2026 22:02:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vGB-0004Hi-ND for qemu-devel@nongnu.org; Thu, 24 Sep 2026 22:01:59 -0400 Received: from mail-westcentralusazlp170130007.outbound.protection.outlook.com ([2a01:111:f403:c112::7] helo=CY3PR05CU001.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vG9-0006mD-8H for qemu-devel@nongnu.org; Thu, 24 Sep 2026 22:01:59 -0400 Received: from MW4P220CA0001.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::6) by SA3PR12MB7878.namprd12.prod.outlook.com (2603:10b6:806:31e::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.428.22; Fri, 25 Sep 2026 02:01:52 +0000 Received: from MWH0EPF000A6734.namprd04.prod.outlook.com (2603:10b6:303:115:cafe::42) by MW4P220CA0001.outlook.office365.com (2603:10b6:303:115::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.14 via Frontend Transport; Fri, 25 Sep 2026 02:01:51 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by MWH0EPF000A6734.mail.protection.outlook.com (10.167.249.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 25 Sep 2026 02:01:51 +0000 Received: from localhost (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Thu, 24 Sep 2026 21:01:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tPxhHHYSfmu8j9AdMbxbItnK7HEI/sbRpFxgukCXHWvA6Em6Xc7rTyQvxmFIKCM2wU0e/m+RiH7BWGlaqldS6H9E9PUKER9u9f2k21QcEHHaIf666eGZChV55z9d4Sti9R7SZDeCIPnzXubAyBmRd4Uj22iXB4FiCd6FMfcDlyv6ZAJVSO8evSwOMtlTVikIu2aKrwZU30kWtjY5ldzdce0dC6IG7H0zCgy04qB6gxy0QmxKv1y9Xk43kPfJfH6S7z52ptXUCoKlD4OhSpdJXh+d7GfwhtaC2F4iiWMhP37mW+Tr6p6bv2m5wdMZ8HK1VJqSfEAp+q2CO8SU/uHnXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zMK0sSQeYcJ2SpZUHsUEOIHNVrbe+TOzK1ACkBFcx98=; b=FJW2120OfA6Zh9MG5b2FaUsVtwu5+gZs/9kKn0lFFv4L9ysg5h/5TZLHHM5ZhKgkIgftlmDJGSBHsKyH3s0L7UjoqHd5FabVFkybAxVyvUXWu/Yko+PzGWuO2hPwZ0zlebudfn6NXSkbnawv38SClYiRY1MbUgbrEk3QML7+c71OKru0TOKqjUhnaM+YBv/I4hrCw64JCBeX03DhlvqcQu9dOB7TEB4RRsu5EMCfRHOyGjI9AD1TinHvjfNr48O5tBIy58MOAqDeTdWMUq6cK5QOj2WPhN45TG7CJgjo4gRMy9XzgNyiviCJAaMR+QZNYk77mSljTlwFktBVm/OkIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zMK0sSQeYcJ2SpZUHsUEOIHNVrbe+TOzK1ACkBFcx98=; b=A7qkF+jLv2Eg4VOvYHN00o7IHCXuEJrxqPhzwOd2VNlc57RWFhS82FHIb/2pdXhM4MqBd8GfjCsWsv04s5Q9TfIYydYllldVL04gDV7E2pVHH5gVFTL4GdJk3ikScd+XfVjXzwT4opSuKs8Z1r9TfSg/EYWGNVrmVfVytyPyaBY= X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Michael Roth To: CC: , , , , , , , Subject: [PATCH v6 08/12] machine: Rename machine_require_guest_memfd() to *_private() Date: Thu, 24 Sep 2026 20:43:14 -0500 Message-ID: <20260925015700.1260501-9-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260925015700.1260501-1-michael.roth@amd.com> References: <20260925015700.1260501-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000A6734:EE_|SA3PR12MB7878:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b579063-6ae9-47e2-3b12-08df1aa8f77d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|82310400026|36860700016|376014|1800799024|6133799003|22082099003|18002099003|10067099003|11063799006|56012099006; X-Microsoft-Antispam-Message-Info: yHvnErQOM7SkpJ44qLNGx2XBNm/3/vF+XY7A1ShrmzJgpD0DERz43Ow6XuML94dHQ7FXtwbVGgTLs5NScaeYB+Xqqw+gJKnPSpo/S+Q8Z/ep4QlgKzdXEqEE5nTmRTmAkwzLlOnarKPwb0CkUhBZpj2r6xXEmQhg1hch4BLXjPPFb1Hb0dK/7hAayhRf8q0IwNMTjQUQXWXM8QL08dCr4PKwGlFKz1Y+tEhd6B3dhA9WkUxgk6Ru6tNyeeRPD5qkt9ZuxnbvtOq0Xj70cUJ7t08XDB79AVb2TSg9HeLgdGK2ojGl85d5bxnGaQEYFx3c51/+T90j++QByioQTLbszZ3GO8z8LoPtaJpT41PIIbHsGNv/CXKzPmOrOEXh0jLlPclq7xq+/pGT+yJVWFyg1Moli14P5u+cDGMRU3ulEAwyxqzr5PXnADvxx9wav49ynRzJaknu9IFzttA2lGO1H3QysUnDRz57r//x2QCFuEINgBvdcCXnYewdEaORwtoxSyWn1RwsfdYj86FDljpLoZENGBRMQAb7mAzgPC22u507bj0vJjNnBIwIuGQpCV0XS9Me+WsW//7zRw9J37bsrG2nDJ/x4M3c+9yWR283wsA2aB6r0Fsv7AJCxc5TcEKF7Z+f7ffvMYHOHq4nyAw9jQhtcMn5lEE+U8IO7blsH2/bsWZL9sAg3/smKk23WQOloPi6SH1ZSBG5R2hONueYnQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(23010399003)(82310400026)(36860700016)(376014)(1800799024)(6133799003)(22082099003)(18002099003)(10067099003)(11063799006)(56012099006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0lZ4QwVQSXYBahwSL0AS/xF2zVANzCuKdgwPegoIGOfmNlPwD6M8zWk6cFaBApPfAka/ZgfSQMqgRv2Culzza9jOQadZxGFvysjKmfGV7xTOVaYry9XA9o5k2pAZTTLh0mfpFYZdZKmWPtWOn8qDVH0YEp1/P9XsMh5gJokZgUOa8nOlCGKe1Onz/Dju1CTQquB5qbY8q3y/Q9lcJ0dpJtOw1w2n7ZCAdak9JLV1lt21O17Weic+rdXUp33LqBXj3bM89368eQ+UlvHy6WT67lWJeg/KDuIAJzrpkQbaKr663PhqVUnu21NeLU/qLKnHzh1mzKFA1N6GgQodN27hgrfCdBFMOjpYQ+DlFI6qGiQfWCUYy9lo71dLGA0wceehZdpXGu1DDrZOULfnZOEjhduv6rT6mSsRHxXtpC7E+GlZgF5WFncrJERWdbCcyuCh X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2026 02:01:51.8108 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0b579063-6ae9-47e2-3b12-08df1aa8f77d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6734.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB7878 Received-SPF: permerror client-ip=2a01:111:f403:c112::7; envelope-from=Michael.Roth@amd.com; helo=CY3PR05CU001.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1790301725063158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu Differentiate it from fully shared guest-memfd use cases. When at it, add proper brackets in kvm_handle_hc_map_gpa_range() otherwise checkpatch may complain. Suggested-by: Xiaoyao Li Reviewed-by: Xiaoyao Li Reviewed-by: Michael Roth Signed-off-by: Peter Xu Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth --- backends/hostmem.c | 2 +- hw/core/machine.c | 2 +- hw/i386/pc.c | 2 +- hw/i386/pc_sysfw.c | 4 ++-- hw/i386/x86-common.c | 4 ++-- include/hw/core/boards.h | 2 +- target/i386/kvm/kvm.c | 3 ++- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index a41540d50d..8782c8b1ea 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -290,7 +290,7 @@ static void host_memory_backend_init(Object *obj) /* TODO: convert access to globals to compat properties */ backend->merge =3D machine_mem_merge(machine); backend->dump =3D machine_dump_guest_core(machine); - backend->guest_memfd_private =3D machine_require_guest_memfd(machine); + backend->guest_memfd_private =3D machine_require_guest_memfd_private(m= achine); backend->reserve =3D true; backend->prealloc_threads =3D machine->smp.cpus; } diff --git a/hw/core/machine.c b/hw/core/machine.c index 92f7be52a1..438624ece3 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1337,7 +1337,7 @@ bool machine_mem_merge(MachineState *machine) return machine->mem_merge; } =20 -bool machine_require_guest_memfd(MachineState *machine) +bool machine_require_guest_memfd_private(MachineState *machine) { return machine->cgs && machine->cgs->require_guest_memfd; } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index b649f184de..2fd90fa739 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -873,7 +873,7 @@ void pc_memory_init(PCMachineState *pcms, =20 if (!is_tdx_vm()) { option_rom_mr =3D g_malloc(sizeof(*option_rom_mr)); - if (machine_require_guest_memfd(machine)) { + if (machine_require_guest_memfd_private(machine)) { memory_region_init_ram_guest_memfd(option_rom_mr, NULL, "pc.ro= m", PC_ROM_SIZE, &error_fatal); } else { diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 441e777191..b6a56ef1fd 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -51,7 +51,7 @@ static void pc_isa_bios_init(PCMachineState *pcms, Memory= Region *isa_bios, =20 /* map the last 128KB of the BIOS in ISA space */ isa_bios_size =3D MIN(flash_size, 128 * KiB); - if (machine_require_guest_memfd(MACHINE(pcms))) { + if (machine_require_guest_memfd_private(MACHINE(pcms))) { memory_region_init_ram_guest_memfd(isa_bios, NULL, "isa-bios", isa_bios_size, &error_fatal); } else { @@ -70,7 +70,7 @@ static void pc_isa_bios_init(PCMachineState *pcms, Memory= Region *isa_bios, ((uint8_t*)flash_ptr) + (flash_size - isa_bios_size), isa_bios_size); =20 - if (!machine_require_guest_memfd(current_machine)) { + if (!machine_require_guest_memfd_private(current_machine)) { memory_region_set_readonly(isa_bios, true); } } diff --git a/hw/i386/x86-common.c b/hw/i386/x86-common.c index ae58352760..59e92b1a1b 100644 --- a/hw/i386/x86-common.c +++ b/hw/i386/x86-common.c @@ -1036,7 +1036,7 @@ static void load_bios_from_file(X86MachineState *x86m= s, const char *bios_name, ssize_t ret; =20 /* BIOS load */ - if (machine_require_guest_memfd(MACHINE(x86ms))) { + if (machine_require_guest_memfd_private(MACHINE(x86ms))) { memory_region_init_ram_guest_memfd(&x86ms->bios, NULL, "pc.bios", bios_size, &error_fatal); if (is_tdx_vm()) { @@ -1106,7 +1106,7 @@ void x86_bios_rom_init(X86MachineState *x86ms, const = char *default_firmware, bios_size =3D get_bios_size(x86ms, bios_name, filename); load_bios_from_file(x86ms, bios_name, filename, bios_size, isapc_ram_f= w); =20 - if (!machine_require_guest_memfd(MACHINE(x86ms))) { + if (!machine_require_guest_memfd_private(MACHINE(x86ms))) { /* map the last 128KB of the BIOS in ISA space */ x86_isa_bios_init(&x86ms->isa_bios, rom_memory, &x86ms->bios, !isapc_ram_fw); diff --git a/include/hw/core/boards.h b/include/hw/core/boards.h index 3b86724cf0..d0e4ad9820 100644 --- a/include/hw/core/boards.h +++ b/include/hw/core/boards.h @@ -43,7 +43,7 @@ bool machine_usb(MachineState *machine); int machine_phandle_start(MachineState *machine); bool machine_dump_guest_core(MachineState *machine); bool machine_mem_merge(MachineState *machine); -bool machine_require_guest_memfd(MachineState *machine); +bool machine_require_guest_memfd_private(MachineState *machine); HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine= ); void machine_set_cpu_numa_node(MachineState *machine, const CpuInstanceProperties *props, diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 1eeadb99ad..a72b6e6b74 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -6488,8 +6488,9 @@ static int kvm_handle_hc_map_gpa_range(X86CPU *cpu, s= truct kvm_run *run) uint64_t gpa, size, attributes; int ret; =20 - if (!machine_require_guest_memfd(current_machine)) + if (!machine_require_guest_memfd_private(current_machine)) { return -EINVAL; + } =20 gpa =3D run->hypercall.args[0]; size =3D run->hypercall.args[1] * TARGET_PAGE_SIZE; --=20 2.43.0 From nobody Sat Sep 26 19:12:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1790301777; cv=pass; d=zohomail.com; s=zohoarc; b=XNP82AX/onCtk4Nl23hVGm9BGSMzeA3/urv3876ZAXUIOM1RGK63+tusm76fT+tWNBlvV3cTPqyPtW0kUUb4KzgcqGPQQeKshwBQ+kqDGAgJfNGPjBChArYsawiuCU3BnBbyWjV3++GndHqd1be3FqR9ODCnRXrN9ZLSe+wk+hw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790301777; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BECacQwit5Mgcm4ZB2gEjUe7RJhqbuPwWcOYNchuMdQ=; b=R99j3f4Etq1opZL/NWHjfeFf9buFjyIbSpo60GdM3hPjpYnXw8v3Vph5G6eSjPNzGlLBOkvV41egEuA2pYWra5BVXKSABtyYHjt9zkkMAbh2VRjoNXTXwMvg/VrkEJm9JWBMId9KJvj2kCA/nvshx0rjvehET1+B3MTvXYhGpVY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790301777232914.786791920863; Thu, 24 Sep 2026 19:02:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x9vGu-0004ef-TN; Thu, 24 Sep 2026 22:02:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vGs-0004eI-Px for qemu-devel@nongnu.org; Thu, 24 Sep 2026 22:02:42 -0400 Received: from mail-northcentralusazon11013013.outbound.protection.outlook.com ([40.107.201.13] helo=CH4PR04CU002.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vGq-0006pc-Jf for qemu-devel@nongnu.org; Thu, 24 Sep 2026 22:02:42 -0400 Received: from MW4PR03CA0265.namprd03.prod.outlook.com (2603:10b6:303:b4::30) by DM4PR12MB6495.namprd12.prod.outlook.com (2603:10b6:8:bc::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.18; Fri, 25 Sep 2026 01:57:33 +0000 Received: from BY1PEPF000264AF.namprd02.prod.outlook.com (2603:10b6:303:b4:cafe::22) by MW4PR03CA0265.outlook.office365.com (2603:10b6:303:b4::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.406.9 via Frontend Transport; Fri, 25 Sep 2026 01:57:33 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by BY1PEPF000264AF.mail.protection.outlook.com (10.167.242.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 25 Sep 2026 01:57:32 +0000 Received: from localhost (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Thu, 24 Sep 2026 20:57:31 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jr1YiR4nSYbQ+wzDLhPZIqk18Z5oBIjr5tGLcvjCYMeUNoY1ZkWgjI0zm8ncep/pFWe5Gt1PX5X3XPSwqIarcVyBcRqNRjzF7vZnWFFuLc1xOiHL9fjx1mqSTs1VhbFtkN23GOoKtlkApnS73/9XGZzTj05Evnz6K7GF/e1WU7YOKSxsrYkf5qn5DQo96OIeHG2dYacWj/RoACrYkJwUFmbV+zQ4s/FYQEK8M6zLfxY6EaG2o5bDk52JPgwWT94iPtNaMBVVnetzp5hLEoUm6Hq1Guvc9aCKbXWMQVyuC3/zeKCOe4/ix9jQqIG0Th1VLTDjjn2hFBHGzzCpoTrf7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BECacQwit5Mgcm4ZB2gEjUe7RJhqbuPwWcOYNchuMdQ=; b=Ocdtbdm5riEvAmpiLnvc9NfU8HUZ7e2SdaP8SRjdxJCBh/d84BHAOraFVZBM0LJyZSWBqhJlSQ+2tGTH3VdbbZxBw8NkEQddUKV3FlxpAMDtQFS6u7NeLIWoKVZwycNPt++Q3fCMopmZnZeidYMY00Xbf86HpwWxju0v0xQpxsAAo2r2Qm+/jnZkyrO8hp2HW6Ft2VBNhX71NTOdx2xs3RfMBPMSOgmcIMoY+LiIaUw09Yw9Ez70WEhKFtgvhbPbQle9JnjaPwAqcYH5xNPS98d4Ex+q8gk+iQnmxknx7l6VkbBA7Y/M9A/R6pOfURGaQ3p9wNbwBPgBX+ueuliQIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BECacQwit5Mgcm4ZB2gEjUe7RJhqbuPwWcOYNchuMdQ=; b=oCj9VBMIjr5A8Pixf+gfOWPeiWOiapv4NhmvQ/+/rOBTNPkUk7oTlsbA0b0rBEYq7UHOEVVIl489XwnjgU44wwuNm9VRXe5kRCtnrTrafIE9c9dWDjQFL/Jw2M6RGe88MbEVAl3FmpwxMptG3qZXpAiaB1Ez/SoL+3PnC3BGQtc= X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Michael Roth To: CC: , , , , , , , Subject: [PATCH v6 09/12] memory: Rename memory_region_init_ram_guest_memfd() to *_private() Date: Thu, 24 Sep 2026 20:43:15 -0500 Message-ID: <20260925015700.1260501-10-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260925015700.1260501-1-michael.roth@amd.com> References: <20260925015700.1260501-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PEPF000264AF:EE_|DM4PR12MB6495:EE_ X-MS-Office365-Filtering-Correlation-Id: fe65c1e3-1173-4300-e695-08df1aa85d19 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|376014|36860700016|82310400026|1800799024|11063799006|10067099003|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: VcPp59FG3GJqA+0GF5De79gGbHuGzALuI6rNsJD09c5qeWBay9xb71OQ9VbtsY+gMInSVSGchQ7FrQGhU64wctuR7D4Di5NtZhlmfvIFZ3vT5pr/vvtq+jjzOLoW2DnToEwG7E6vMwMuRbo/lnQZ7wshEUWeJDkneM1fH3B33xBtdX+yozFxIiOlw3/2170gR2a7nTM3CorazCbv7giufpcujkqbLsj5kSr2tWDyPzAfbFlANY6/U7WeS/XmM81f+QXQxhReaYFUQRz+psXiBy8aOhQd6oi4parO/mVLf4lV5I5SRoEELI5e+tsXA0AymZakLnRPBQOOZQcJcKgmw72bPTOFdA0gOcZ/ODgj8Ldigv4G7j/WVxUN6g6vTU7MtN/bK9/6KWETI8OEYAbkgkdiB+4Cl3OFHKTmanGcF63JpedIHRMwBiuI5/OOgxXO/IL19B6Is+8CuGPrlgIwgehiYPyaFnoXGMruNhDoa25BVVNOU8+24KTup/JAxSTjlEksVG34JrwjLyE6buLMFRI8An/YvOCB5w9QWRhQSSgiqRJm1bOWwumukmrXtNeW3gc4IHIKOaEXKkXI3HuOhgrhbdcRO1wg2QkUfhEEskKBQzD59S2erPwu4TzJe2Ep3roQZIZf8EnK6kAcnv2jl2oiUUBSifSSr67saQbWGIeDY/8caiPPvpX/Ljsqbu7nMfDGMJgU9tctBLanZeF6gw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(23010399003)(376014)(36860700016)(82310400026)(1800799024)(11063799006)(10067099003)(56012099006)(18002099003)(22082099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TwQNKRPiaK5qqO6B81YdVAjm5OjFy/taz9fx5eMKCkH5hFzFtCbC7EYRDyNdhG5Xb2hms9+8tg+pXWG2yFUVSgtTJgO37hosVLUCbQZkiA2f+dgacrJGTqR0qrGlv5dxnqNOXlM9kGb106bJPiJljXKIfxLNyF+iO5A7drwA5qwkXiac/kfxhOVFZdfErDslk+JTij/TotqaoTcUK7lISMLrrmK6mTnPHIH1aWNLDkNZiATB5vIVGbh8WXubfqj8eubq/Ye0ZMtli/JQjCmn8PFRtH042Emp+GDtHPYyR2GoqWg/euT9KFdASSikzq25SaKzcYYFBRi0mKtjPNdsOoEcNuKNzfEyLv6ZNJgQrlAI0PBxoMGyjvl3xua9yVInsi5jQnSX3VyKodFAVOgDtVOiNMs9bECLMczSIQ8tj0/R66SwYzxBgHHBwF11W9dq X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2026 01:57:32.7407 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe65c1e3-1173-4300-e695-08df1aa85d19 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BY1PEPF000264AF.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6495 Received-SPF: permerror client-ip=40.107.201.13; envelope-from=Michael.Roth@amd.com; helo=CH4PR04CU002.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1790301779180158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu Differentiate it from fully shared guest-memfd use cases. Suggested-by: Xiaoyao Li Reviewed-by: Xiaoyao Li Reviewed-by: Michael Roth Signed-off-by: Peter Xu Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth --- backends/igvm.c | 4 ++-- hw/i386/pc.c | 4 ++-- hw/i386/pc_sysfw.c | 4 ++-- hw/i386/x86-common.c | 4 ++-- include/system/memory.h | 10 +++++----- system/memory.c | 8 +++++--- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/backends/igvm.c b/backends/igvm.c index ec7bee428b..58f3097e85 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -291,8 +291,8 @@ static void *qigvm_prepare_memory(QIgvm *ctx, uint64_t = addr, uint64_t size, imr->mr =3D g_new0(MemoryRegion, 1); if (ctx->machine_state->cgs && ctx->machine_state->cgs->require_guest_memfd) { - if (!memory_region_init_ram_guest_memfd(imr->mr, NULL, - region_name, size, err= p)) { + if (!memory_region_init_ram_guest_memfd_private( + imr->mr, NULL, region_name, size, errp)) { g_free(imr->mr); g_free(imr); return NULL; diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2fd90fa739..1ae0c4f614 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -874,8 +874,8 @@ void pc_memory_init(PCMachineState *pcms, if (!is_tdx_vm()) { option_rom_mr =3D g_malloc(sizeof(*option_rom_mr)); if (machine_require_guest_memfd_private(machine)) { - memory_region_init_ram_guest_memfd(option_rom_mr, NULL, "pc.ro= m", - PC_ROM_SIZE, &error_fatal); + memory_region_init_ram_guest_memfd_private( + option_rom_mr, NULL, "pc.rom", PC_ROM_SIZE, &error_fatal); } else { memory_region_init_ram(option_rom_mr, NULL, "pc.rom", PC_ROM_S= IZE, &error_fatal); diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index b6a56ef1fd..6ff0b9baae 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -52,8 +52,8 @@ static void pc_isa_bios_init(PCMachineState *pcms, Memory= Region *isa_bios, /* map the last 128KB of the BIOS in ISA space */ isa_bios_size =3D MIN(flash_size, 128 * KiB); if (machine_require_guest_memfd_private(MACHINE(pcms))) { - memory_region_init_ram_guest_memfd(isa_bios, NULL, "isa-bios", - isa_bios_size, &error_fatal); + memory_region_init_ram_guest_memfd_private( + isa_bios, NULL, "isa-bios", isa_bios_size, &error_fatal); } else { memory_region_init_ram(isa_bios, NULL, "isa-bios", isa_bios_size, &error_fatal); diff --git a/hw/i386/x86-common.c b/hw/i386/x86-common.c index 59e92b1a1b..fa18bf1aec 100644 --- a/hw/i386/x86-common.c +++ b/hw/i386/x86-common.c @@ -1037,8 +1037,8 @@ static void load_bios_from_file(X86MachineState *x86m= s, const char *bios_name, =20 /* BIOS load */ if (machine_require_guest_memfd_private(MACHINE(x86ms))) { - memory_region_init_ram_guest_memfd(&x86ms->bios, NULL, "pc.bios", - bios_size, &error_fatal); + memory_region_init_ram_guest_memfd_private( + &x86ms->bios, NULL, "pc.bios", bios_size, &error_fatal); if (is_tdx_vm()) { tdx_set_tdvf_region(&x86ms->bios); } diff --git a/include/system/memory.h b/include/system/memory.h index 96ab920e7d..027ca81bd2 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -1358,11 +1358,11 @@ bool memory_region_init_ram(MemoryRegion *mr, uint64_t size, Error **errp); =20 -bool memory_region_init_ram_guest_memfd(MemoryRegion *mr, - Object *owner, - const char *name, - uint64_t size, - Error **errp); +bool memory_region_init_ram_guest_memfd_private(MemoryRegion *mr, + Object *owner, + const char *name, + uint64_t size, + Error **errp); =20 /** * memory_region_init_rom: Initialize a ROM memory region. diff --git a/system/memory.c b/system/memory.c index fa0a2cf563..f1910af8a0 100644 --- a/system/memory.c +++ b/system/memory.c @@ -3592,9 +3592,11 @@ bool memory_region_init_ram(MemoryRegion *mr, Object= *owner, return true; } =20 -bool memory_region_init_ram_guest_memfd(MemoryRegion *mr, Object *owner, - const char *name, uint64_t size, - Error **errp) +bool memory_region_init_ram_guest_memfd_private(MemoryRegion *mr, + Object *owner, + const char *name, + uint64_t size, + Error **errp) { if (!memory_region_init_ram_flags_nomigrate(mr, owner, name, size, RAM_GUEST_MEMFD_PRIVATE, e= rrp)) { --=20 2.43.0 From nobody Sat Sep 26 19:12:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1790301555; cv=pass; d=zohomail.com; s=zohoarc; b=gqQXyHID8KS+WRrSYxCp3gZYyNOuq0XRuCPvBMoQs7LmBbpZMIz3Ba/MZiTMEMmuKgCc5rPJI3l3fhoumWeQEu7WauqFybXH9db0ZGjYa923pIlHH5PHwPDFNjz8LGIe/5nPqLE+IQnz/ATTCgZDtlKBlvEs02IT+SlEnVnIJi8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790301555; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TxsrZcmZDsQTiSmN44Erkta9rx/Yp2yW8Xpaom/wmOM=; b=bole7f5nCF/LW/JFCUr+rM0oVvAKjM3v2ZVNPEamggHYL76UvP6zdN7f1pxao7ChfP9QBhgxS03c2w2nCENz4MX6+Gze6y1DYj4v6JQ0BY9smtJysrqLeF4yXuhgDAF2T2CF/UixwRWhZ3rtUHf4eaBeY6a0SYwg1EjLANTBj5A= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790301555222269.61478336210826; Thu, 24 Sep 2026 18:59:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x9vCR-0004WX-29; Thu, 24 Sep 2026 21:58:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vCN-0004RY-Hi for qemu-devel@nongnu.org; Thu, 24 Sep 2026 21:58:03 -0400 Received: from mail-eastusazlp170120007.outbound.protection.outlook.com ([2a01:111:f403:c101::7] helo=BL0PR03CU003.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vCJ-0006Lj-Te for qemu-devel@nongnu.org; Thu, 24 Sep 2026 21:58:02 -0400 Received: from BY3PR04CA0016.namprd04.prod.outlook.com (2603:10b6:a03:217::21) by LV2PR12MB5870.namprd12.prod.outlook.com (2603:10b6:408:175::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.18; Fri, 25 Sep 2026 01:57:54 +0000 Received: from BY1PEPF000264B6.namprd02.prod.outlook.com (2603:10b6:a03:217:cafe::93) by BY3PR04CA0016.outlook.office365.com (2603:10b6:a03:217::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.18 via Frontend Transport; Fri, 25 Sep 2026 01:57:53 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by BY1PEPF000264B6.mail.protection.outlook.com (10.167.242.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 25 Sep 2026 01:57:53 +0000 Received: from localhost (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Thu, 24 Sep 2026 20:57:52 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nUUMP4fdoQNhIWbrE8xVOJtKXALNcQtVRUiLdVrtHLBEy9AzCsijgj97VkfRZ13lZmvBJf8IvMGcEe+at5hTY2dqmAoXaNhyjIpko73prea5g8Mp9Zz2EWIeoatR6hbXanAXPmxIPxmwXlax+/VlC9lF8Q8coNDamJa+a8+jbpD9UIJmQOe8wVYyFsbOQKzFyzDWDFtJlpxL2VHBpivvA5bu4O6/Bo5ZvpBlHmuoB/W3UxzSJMQdr7zfRmvZTAfMZ3Bjpt76I4gPBOfpSWm5UMCf5quqSwgzNjbU9gcQ1N1bqpN/OSuJ8vXKEVpK0EGgvplhkdibLnc6rLAbniQwpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TxsrZcmZDsQTiSmN44Erkta9rx/Yp2yW8Xpaom/wmOM=; b=mLkdGxlfzRAbIyAU+BuA18ga+OirxB+vY23pTkkQG3yKp+SOVkseqe8noG75iSKcEvGP85DTQZHpdjWth+StA/0PUyK6pKyrFd1vPJ1qVOtqp/w1UTw+CnIL+9o2ik4neVfzei4lXZXINH3I5W22b1gZ5akMZBiXk1bOenGgFCCGI2nVWodcf4tu4XQfQAWd+HIUFrXDMTnWuFhGZt0O5o61i6Z5QdGFmX9dvj2EvCn03B+jzWVnZDQu0K/uzuMmeVulJA6BBoBrT5PHi3nvASfW7zY5smr19qh2aHqcviUQMFaR0tVzKJVE+Y3hlOcTdyq3PIYJOG/XghQMKMcLMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TxsrZcmZDsQTiSmN44Erkta9rx/Yp2yW8Xpaom/wmOM=; b=w0QL+Y6wO4SB9WqQhU6Tr1Xz7nUYkWktwq7kiBjrne9LoRTRW/BgL6eA7UFfwef3prF8eh+MFHkeDQv5qp11QwLZzxUquZLBTi2myM6yNs9lAa+R8ikUieobRmxuOPQtNflsxakkwJwBsFeegm1hkxbMrMsMYxRWOQxszoN21KU= X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Michael Roth To: CC: , , , , , , , , Fabiano Rosas Subject: [PATCH v6 10/12] hostmem: Support fully shared guest memfd to back a VM Date: Thu, 24 Sep 2026 20:43:16 -0500 Message-ID: <20260925015700.1260501-11-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260925015700.1260501-1-michael.roth@amd.com> References: <20260925015700.1260501-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PEPF000264B6:EE_|LV2PR12MB5870:EE_ X-MS-Office365-Filtering-Correlation-Id: 04c36e74-baa6-4ff6-dbcd-08df1aa86980 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|1800799024|376014|82310400026|23010399003|10067099003|56012099006|11063799006|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: zF/dFiet0pyGJI2NQEsqIDnvZkd3tedrXDOjzgVq+W+vDONieJnhZTRmQlM7MgrI7ApI62SjkFQTRsORmapDanRTBItu6ArfAwwqu9tPBlflmvwu6Z4QkeK0BGB9v9OmYyS+fYtCXCiF173UIC8MdT7vaqxsrrBL9aY4DN14MLN6uueNvJN97Idm76m/3DGcWchY2FnhVuEJJskl6X5iosuFYeeT1WPTI7XKn+r/lx/a5C2nvOkzMQF0Us81YreTr70Cy5s9HrllKoykwDaub3XawxmzTCpW6nhfORaXriT/LdFy577ejJR2bZWpuYeHZbQvn6+JGGrgQpoJBJSspFGkSoyPALe/wMnD31ELv7uLvFkwQU39O1+pjbDawvfveJ2uFKu06O7xtWRLWjvkHcBR58J8ApS+OdeI/Y1U/idvqTDO0mJj3XBE0y08pZHbmJqNeuscmPemb09CyUf6/S06FtfAcB7M2U2/aFv19bnCYrgi8kh2V9mrIKzsChtqDFfw0kMjgvIu36Hy/lM70JsOYm1odRG/vr66r+9fk30TT6Meb/FzG7bQRZSa/NhoAfkB+T+SgouzJkmm3zHrcLxdybzFmi5dc1wzdoxH40mF8sKnT1o2zdOvA8ssgnIgYqDNhnMQD7+ysxQm7lmuKgZNtbVoF0EPlAl0Qm6tT/e6lJTwgnMf0WI6xrvW2Ddunlwkvnm0Ya4i08HbXLMwaQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700016)(1800799024)(376014)(82310400026)(23010399003)(10067099003)(56012099006)(11063799006)(6133799003)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zrTMdZ7tDGLOgz1+ERG94lzdCqMFVsDVrUdzmpgIcrSf8AtVfo1fCZrAVzm3+oOctRx61qNYeDtRGfDrRYnxNjv9KIxKnc03y1LWRCkIxUZlKYZUTn5R96DooIijUHTJAfwtmAo4wnyd5Zk1dmaaJxz6GEIvzxJ8w5rm9TR/WcvIWCP8t/r1+ZcVJFIvRYnjN1xpZhmVUzNzpVMnfahc7ca7lcGBdDYPpJcSImQrwiqMGFsewvpVeVN1iF82+tyfA57Vi8b/qH5dbhIJufCQGToxzNXcgbXkh0Sjh/BFboTuOWxdOmDHlozKVXMZB9Kv5x40g4iRCEb3f4LJ+IPGzvlq6Ae+nyltXo6MLCCzLl+0JEJKzDQu0OftBpDZa9DchZbVBwZxw8+27QypWIBW71GdnrQLfqwJ8VbDv2H+XgmZELGQFS9bklEoYeYTmmXj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2026 01:57:53.5535 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 04c36e74-baa6-4ff6-dbcd-08df1aa86980 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BY1PEPF000264B6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5870 Received-SPF: permerror client-ip=2a01:111:f403:c101::7; envelope-from=Michael.Roth@amd.com; helo=BL0PR03CU003.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1790301556126158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu Host backends supports guest-memfd now by detecting whether it's a confidential VM. There's no way to choose it yet from the memory level to use it fully shared. If we use guest-memfd, it so far always implies we need two layers of memory backends, while the guest-memfd only provides the private set of pages. This patch introduces a way so that QEMU can consume guest memfd as the only source of memory to back the object (aka, fully shared). To use the fully shared guest-memfd, one can add a memfd object with: -object memory-backend-memfd,x-guest-memfd=3Don,share=3Don Note that share=3Don is required with fully shared guest_memfd. Since guest-memfd is not yet a drop-in replacement for memfd (e.g. lack of hugepage support), the option is tagged as experimental for now so that it can be made available for early enablement/testing without causing any surprises for other users. PS: there's a trivial touch-up on fd<0 check, because the stub to create guest-memfd may return negative but not -1. Reviewed-by: Xiaoyao Li Reviewed-by: Fabiano Rosas Reviewed-by: David Hildenbrand Signed-off-by: Peter Xu [mdr: add accompanying guest-memfd doc, mark as experimental] Co-developed-by: Michael Roth Signed-off-by: Michael Roth --- backends/hostmem-memfd.c | 67 ++++++++++++++++++++-- docs/system/confidential-guest-support.rst | 2 + docs/system/guest-memfd.rst | 60 +++++++++++++++++++ docs/system/index.rst | 1 + qapi/qom.json | 7 ++- 5 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 docs/system/guest-memfd.rst diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index 7a7855aaab..a164bb659f 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -18,6 +18,9 @@ #include "qapi/error.h" #include "qom/object.h" #include "migration/cpr.h" +#include "system/kvm.h" +#include +#include "qapi/qapi-visit-common.h" =20 OBJECT_DECLARE_SIMPLE_TYPE(HostMemoryBackendMemfd, MEMORY_BACKEND_MEMFD) =20 @@ -28,6 +31,13 @@ struct HostMemoryBackendMemfd { bool hugetlb; uint64_t hugetlbsize; bool seal; + /* + * NOTE: this differs from HostMemoryBackend's guest_memfd_private, + * which represents an internally private guest-memfd that only backs + * private pages. Instead, this flag marks the memory backend will + * 100% use the guest-memfd pages in-place. + */ + OnOffAuto guest_memfd; }; =20 static bool @@ -47,11 +57,31 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, = Error **errp) goto have_fd; } =20 - fd =3D qemu_memfd_create(TYPE_MEMORY_BACKEND_MEMFD, backend->size, - m->hugetlb, m->hugetlbsize, m->seal ? - F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL : 0, - errp); - if (fd =3D=3D -1) { + if (m->guest_memfd =3D=3D ON_OFF_AUTO_ON) { + /* + * NOTE: x-guest-memfd ignores seal=3Don/off because it always + * implicitly seals the FD by definition. + */ + if (!backend->share) { + error_setg(errp, "x-guest-memfd=3Don must be used with share= =3Don"); + return false; + } else if (m->hugetlb) { + error_setg(errp, "x-guest-memfd=3Don doesn't support hugetlb= =3Don"); + return false; + } + + fd =3D kvm_create_guest_memfd(backend->size, + GUEST_MEMFD_FLAG_MMAP | + GUEST_MEMFD_FLAG_INIT_SHARED, + errp); + } else { + fd =3D qemu_memfd_create(TYPE_MEMORY_BACKEND_MEMFD, backend->size, + m->hugetlb, m->hugetlbsize, m->seal ? + F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL := 0, + errp); + } + + if (fd < 0) { return false; } cpr_save_fd(name, 0, fd); @@ -65,6 +95,26 @@ have_fd: backend->size, ram_flags, fd, 0,= errp); } =20 +static void +memfd_backend_get_guest_memfd(Object *o, Visitor *v, + const char *value, void *opaque, + Error **errp) +{ + HostMemoryBackendMemfd *m =3D MEMORY_BACKEND_MEMFD(o); + + visit_type_OnOffAuto(v, value, &m->guest_memfd, errp); +} + +static void +memfd_backend_set_guest_memfd(Object *o, Visitor *v, + const char *value, void *opaque, + Error **errp) +{ + HostMemoryBackendMemfd *m =3D MEMORY_BACKEND_MEMFD(o); + + visit_type_OnOffAuto(v, value, &m->guest_memfd, errp); +} + static bool memfd_backend_get_hugetlb(Object *o, Error **errp) { @@ -152,6 +202,13 @@ memfd_backend_class_init(ObjectClass *oc, const void *= data) object_class_property_set_description(oc, "hugetlbsize", "Huge pages size (ex: 2M, 1G= )"); } + + object_class_property_add(oc, "x-guest-memfd", "OnOffAuto", + memfd_backend_get_guest_memfd, + memfd_backend_set_guest_memfd, NULL, NULL); + object_class_property_set_description(oc, "x-guest-memfd", + "Use guest memfd"); + object_class_property_add_bool(oc, "seal", memfd_backend_get_seal, memfd_backend_set_seal); diff --git a/docs/system/confidential-guest-support.rst b/docs/system/confi= dential-guest-support.rst index 562a7c3c28..58732d658f 100644 --- a/docs/system/confidential-guest-support.rst +++ b/docs/system/confidential-guest-support.rst @@ -1,3 +1,5 @@ +.. _confidential-guest-support: + Confidential Guest Support =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D =20 diff --git a/docs/system/guest-memfd.rst b/docs/system/guest-memfd.rst new file mode 100644 index 0000000000..f7cef19283 --- /dev/null +++ b/docs/system/guest-memfd.rst @@ -0,0 +1,60 @@ +.. _guest-memfd: + +guest-memfd support +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Recent kernels allow for the creation of a guest-memfd file +descriptor, which can be used to back VMs in a similar manner as a +memfd file descriptor, but is intended specifically for this purpose +and allows for closer coordination between KVM and the management of +this memory to enable more advanced/VM-specific use-cases. + +Initially this additional functionality centered around providing a +common/centralized place for managing kernel-side memory handing +requirements for various Confidential Guest architectures. (For more +on Confidential Guests, see :ref:`confidential-guest-support`). + +guest_memfd has since evolved to become a more general-purpose way to +allocate/manage guest memory and potentially allow for things like +providing additional memory isolation within the kernel[1] and support +for persisting a guest's state across kexec to allow for live-updating +the host kernel with minimal guest downtime[2]. + +Usage +----- + +For Confidential Guests, guest-memfd is currently utilized internally +by QEMU to handle private guest memory, independently of whatever +memory backend the user has configured for normal/non-private/shared +guest memory. To avoid doubling memory, QEMU discards memory in +response to the guest converting GPA ranges between shared/private. +(e.g. if GPA X is converted from private to shared, the guest-memfd FD +offset corresponding to GPA x will be truncated since the memory will +be provided by the memory backend the user configured for shared +memory, and vice-versa). This is handled automatically/internally for +Confidential Guests that rely on this handling and is not directly +exposed by QEMU command-line options. + +For non-Confidential guests, guest-memfd can be used in a manner that +is somewhat interchangeable with a normal memfd. Currently, this is +handled by using the same memory-backend implementation as memfd, but +with an additional 'x-guest-memfd=3Don' option. E.g.:: + + qemu ... \ + -object memory-backend-memfd,id=3DID,size=3DSIZE,share=3Don,x-guest-= memfd=3Don + +Note that the share=3Don option is required for guest-memfd, since it +does not support anonymous memory allocations or COW-like semantics. + +Also note that there are a couple of limitations in using guest_memfd +in this way compared to a normal memfd, which is why the option is +exposed as an experimental for the time being: + + * guest_memfd does not currently support the hugetlb=3Don option + * guest_memfd does not currently support Transparent Huge Pages + +References +---------- + +- `[1] directmap removal `__ +- `[2] LUO `__ diff --git a/docs/system/index.rst b/docs/system/index.rst index 4509630fa4..060850a739 100644 --- a/docs/system/index.rst +++ b/docs/system/index.rst @@ -44,3 +44,4 @@ or Hypervisor.Framework. vm-templating sriov qemu-colo + guest-memfd diff --git a/qapi/qom.json b/qapi/qom.json index 5895c97750..602b17ad83 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -780,13 +780,18 @@ # @seal: if true, create a sealed-file, which will block further # resizing of the memory (default: true) # +# @x-guest-memfd: if 'on', use guest-memfd to back the memory region. +# See the "guest-memfd" QEMU documentation for more details. +# (default: auto, since: 11.2) +# # Since: 2.12 ## { 'struct': 'MemoryBackendMemfdProperties', 'base': 'MemoryBackendProperties', 'data': { '*hugetlb': 'bool', '*hugetlbsize': 'size', - '*seal': 'bool' }, + '*seal': 'bool', + '*x-guest-memfd': 'OnOffAuto' }, 'if': 'CONFIG_LINUX' } =20 ## --=20 2.43.0 From nobody Sat Sep 26 19:12:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1790301638; cv=pass; d=zohomail.com; s=zohoarc; b=SG1HoRWNhf1fK3Ypixfb74CPLUCoUG7bXJLboLQkgRDvHHdEZ63hBNVD5551QQbRINKZdvttnEQLikHKNYVGtXaJ5B/GlLbgDKcdV0wH5QwCYtCpTBVC1NzGA3B+SFiP3VMNBi3utDGGCSt1Ccrg0Gm5m+L7IkTs/KqmNWTUDb8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790301638; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=D9OYJPTL/BO7s6n1zQrdhhnt47uw+t9+pZvpGlU6Lr4=; b=nwt7v1GqdbGp3JkC4n8rXeYUSMzKTQIfiDDzIqqok02hIAzqmOm7MBVPWKuwVH1Pq2YuSeq4KyHD9G0f3CEbrcFBLgcdsynrnH52ZEM4DeUrBQrpw34P/1aTazJOAgrEbOmsoS/cYKk8UeCvDDsd13bKhRPeu6mFUH0dsEc0MLI= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1790301638037613.2119371509483; Thu, 24 Sep 2026 19:00:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x9vD1-00069h-Fn; Thu, 24 Sep 2026 21:58:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vCz-00062l-0P for qemu-devel@nongnu.org; Thu, 24 Sep 2026 21:58:41 -0400 Received: from mail-eastus2azlp170100001.outbound.protection.outlook.com ([2a01:111:f403:c110::1] helo=BN1PR04CU002.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vCx-0006OA-1w for qemu-devel@nongnu.org; Thu, 24 Sep 2026 21:58:40 -0400 Received: from MW4PR02CA0012.namprd02.prod.outlook.com (2603:10b6:303:16d::35) by CY1PR12MB9674.namprd12.prod.outlook.com (2603:10b6:930:106::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.18; Fri, 25 Sep 2026 01:58:35 +0000 Received: from BY1PEPF000264B0.namprd02.prod.outlook.com (2603:10b6:303:16d:cafe::23) by MW4PR02CA0012.outlook.office365.com (2603:10b6:303:16d::35) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.18 via Frontend Transport; Fri, 25 Sep 2026 01:58:35 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by BY1PEPF000264B0.mail.protection.outlook.com (10.167.242.119) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 25 Sep 2026 01:58:34 +0000 Received: from localhost (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Thu, 24 Sep 2026 20:58:34 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=m2Rge6FJxjGkd7En5PUogRtRkAV8L6Zh5lL/JErpjekaceSgOivCAXjQ0zd9h0qgoD6ZHGZC/rfadShdctq+elGyPn54ks7pXnNsOXMiiVpEdgzQ3cMpR4xQCKFMY9cHslpAbRKgsz4PzXoJrXAAKKTDqaviQ0O9TDQmysF470spfWwTccqlXG+QxA9qYb7t5jxgXmWxO6t7P3/8eUHkFVBISLYk0lXBL/hYD0HJvQsgtypWgViLpZMlRZsM3GkQtWI6lmS44XyDCYGsBN1JohLh56tgpBqhV7ykcZBte0k93jUX3l1drPlhwTaWc+7PMO/gVrnfU6v4VN54/ojJmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=D9OYJPTL/BO7s6n1zQrdhhnt47uw+t9+pZvpGlU6Lr4=; b=iW1s2bLMd0q24kDB8J3PGphAhNkHlJStMPsdBfbx+Xm4U8ks7spJ3SRgeOEOotjF1pz1poR7yh3XhpGVeGPUolMiJTESDncpKH/lVsFFf4ftFnYW6+LxvEI/Bc55UWkli1RTz0tsaRPdzAMZJmmVAHHEGIg8RBU7mWgU8jaeW8hyeh77JEr/mp7HCUiQHVzWcpe3v+i2ct4qhyftrh4I3cC7gd1CwuS33zaOnNCkZebjwL++g1qAj+miDGjlU+f2fXQnddhM92gudHRsWJ0wqytOEKtjuCBhrjkDSYtRKbvMMpA8LInRnkQWzwKn2iSuwDTEPD9rsBQn8zXiQ5q8kA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=D9OYJPTL/BO7s6n1zQrdhhnt47uw+t9+pZvpGlU6Lr4=; b=Cjgf16aQEcFJ4wuFiNkfopBEhbZ49ieMlC+cOVFFxlerEP1u/G7ifRqpDzDHnQ+nDtDIWQoHjzwHykH9GQCjRqAT12YC8gs1LF/aSy9t25Ij40Ri2J/zZktMT4kHrpTi3k1i0YZVLbvt6fmqmny4ATVgh5juwINR/oSQAuXlP+Y= X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Michael Roth To: CC: , , , , , , , Subject: [PATCH v6 11/12] tests/migration-test: Support guest-memfd init shared mem type Date: Thu, 24 Sep 2026 20:43:17 -0500 Message-ID: <20260925015700.1260501-12-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260925015700.1260501-1-michael.roth@amd.com> References: <20260925015700.1260501-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PEPF000264B0:EE_|CY1PR12MB9674:EE_ X-MS-Office365-Filtering-Correlation-Id: b12d2c10-2740-4c89-fa0e-08df1aa8822b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|82310400026|376014|1800799024|23010399003|10067099003|11063799006|18002099003|22082099003|56012099006; X-Microsoft-Antispam-Message-Info: IMDYwQEdIkHx0HoDhpmDNu/2diMlt0S5q7BJsHYRqF/jF4TMsSttlJM7kYHHiHjy/XhsjQEvbGYXJg+hFs+cgkMJjean15BV00YdjWUfpTWuWF+Mdag0V8/D3kM4v1bFTDqYE0jdk4BsKVKwVQy81oReswluW0o251cTDkI9MjZ1ITsi/AxhpVx5cNtrBuWimmKc8jW4cN7Q5Vc5Kum6y9z7KhPqQmOSaMi5H/OWM/P3/5+iMGa9Uh/hrkEFhWkyh6vAxMk6s4ycf/+3A+Rawhs9d1fj239FIhZoPHmWk1uVigCytjpg1A3FLRsjT00AQ0YajOLllL9cmiMv1qhMZWFT2UT4pIiUC4Q/dt8Z4VDcmCW8N8W1RTFHsGbxTtkWeRcGRLmk4xqIaVaAPvVKf0bcn1o3VHY6yBvwjazJG0PheYjZc0m8fscn9Uyi8YeTZCsljXhMKDGeqj31AvWKYSXJoo5Up69Ae75E/nrO9pujWI/DZCP8qf7DyXyS3pykiEebfgARlyQV71d7ZCFJllN+P5ui9BvXh8XFQ9j9jImwKoxTKJWTBv+thsWT1iyILeBZEzoZ8nC7dzPuPBWq46yelL7uVwDk2XTrn8l8CbCeqGmaA1HXCj1j3S3zrhzdH5h9Wu3OXq0cWGiy3sTAG+7hNODe3ZX5Ew0J0BLinLbLJGNCm72kVck7dKDRdrTF/DEXd+XCHuJ9F/jzR37Dzg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700016)(82310400026)(376014)(1800799024)(23010399003)(10067099003)(11063799006)(18002099003)(22082099003)(56012099006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: V3tZncnMsgTEBwhb3sY+xk+wNmm+FFJ6KzC+BK61b2oW0rjr1MoVwq6L0eBmuBrT4uYFZmyzT4aFVaqFbEneCtRmrjGI7xsBNATLYIyAhGRqo/fH6vAuuaMXG6koRK492Wm4re/tbFw+/5q+5xTwqqoKv8xlIKTJHu6arGWlOj/xysY8GUy3DbC4iVRSPZRExBHZ6rAqmkeFVSOlNeAHlHfzrmpMwzPWpG7nXAYoCdH3ewd6BeVmC59MldC/MfAhfKP4Qt6jpS1K8dATFR1O6afEZmlY0SLiuIS/IzS+4jNRhVibu9PEZbkrYMuKXsIf7vQV3AvcK7Xnp35uJ0yJwz8gMLodosa6dJmqKgSPiLXXsyfTN29PI8X40BEy1D9rKA0P75k+cAhTM5UjuYI5SISo36wvnBm2N/W+WdjWGGwn2KsWOwB9I7NeOjGz9PYZ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2026 01:58:34.9340 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b12d2c10-2740-4c89-fa0e-08df1aa8822b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BY1PEPF000264B0.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB9674 Received-SPF: permerror client-ip=2a01:111:f403:c110::1; envelope-from=Michael.Roth@amd.com; helo=BN1PR04CU002.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1790301638715158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu Support the guest-memfd type when the fd has init share enabled. It means the gmemfd can be used similarly to memfd. Signed-off-by: Peter Xu Signed-off-by: Michael Roth --- tests/qtest/migration/framework.c | 60 +++++++++++++++++++++++++++++++ tests/qtest/migration/framework.h | 4 +++ 2 files changed, 64 insertions(+) diff --git a/tests/qtest/migration/framework.c b/tests/qtest/migration/fram= ework.c index a830b96f41..93225e3720 100644 --- a/tests/qtest/migration/framework.c +++ b/tests/qtest/migration/framework.c @@ -26,6 +26,10 @@ #include "qemu/range.h" #include "qemu/sockets.h" =20 +#ifdef CONFIG_LINUX +#include +#include +#endif =20 #define QEMU_VM_FILE_MAGIC 0x5145564d #define QEMU_ENV_SRC "QTEST_QEMU_BINARY_SRC" @@ -296,6 +300,9 @@ static char *migrate_mem_type_get_opts(MemType type, co= nst char *memory_size) case MEM_TYPE_MEMFD: backend =3D g_strdup("-object memory-backend-memfd"); break; + case MEM_TYPE_GUEST_MEMFD: + backend =3D g_strdup("-object memory-backend-memfd,x-guest-memfd= =3Don"); + break; default: g_assert_not_reached(); break; @@ -444,8 +451,55 @@ int migrate_args(char **from, char **to, MigrateStart = *args) return 0; } =20 +static bool kvm_guest_memfd_init_shared_supported(const char **reason) +{ + assert(*reason =3D=3D NULL); + +#ifdef CONFIG_LINUX + int ret, fd =3D -1; + + if (!migration_get_env()->has_kvm) { + *reason =3D "KVM is not enabled in the current QEMU build"; + goto out; + } + + fd =3D open("/dev/kvm", O_RDWR); + if (fd < 0) { + *reason =3D "KVM module isn't available or missing permission"; + goto out; + } + + ret =3D ioctl(fd, KVM_CHECK_EXTENSION, KVM_CAP_GUEST_MEMFD); + if (!ret) { + *reason =3D "KVM module doesn't support guest-memfd"; + goto out; + } + + ret =3D ioctl(fd, KVM_CHECK_EXTENSION, KVM_CAP_GUEST_MEMFD_FLAGS); + if (ret < 0) { + *reason =3D "KVM doesn't support KVM_CAP_GUEST_MEMFD_FLAGS"; + goto out; + } + + if (!(ret & GUEST_MEMFD_FLAG_INIT_SHARED)) { + *reason =3D "KVM doesn't support GUEST_MEMFD_FLAG_INIT_SHARED"; + goto out; + } +out: + if (fd >=3D 0) { + close(fd); + } +#else + *reason =3D "KVM not supported on non-Linux OS"; +#endif + + return !*reason; +} + static bool migrate_mem_type_prepare(MemType type) { + const char *reason =3D NULL; + switch (type) { case MEM_TYPE_SHMEM: if (!g_file_test("/dev/shm", G_FILE_TEST_IS_DIR)) { @@ -453,6 +507,12 @@ static bool migrate_mem_type_prepare(MemType type) return false; } break; + case MEM_TYPE_GUEST_MEMFD: + if (!kvm_guest_memfd_init_shared_supported(&reason)) { + g_test_skip(reason); + return false; + } + break; default: break; } diff --git a/tests/qtest/migration/framework.h b/tests/qtest/migration/fram= ework.h index 941cbd7102..10761f6e28 100644 --- a/tests/qtest/migration/framework.h +++ b/tests/qtest/migration/framework.h @@ -34,6 +34,10 @@ typedef enum { * but only anonymously allocated. */ MEM_TYPE_MEMFD, + /* + * Use guest-memfd, shared mappings. + */ + MEM_TYPE_GUEST_MEMFD, MEM_TYPE_NUM, } MemType; =20 --=20 2.43.0 From nobody Sat Sep 26 19:12:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1790301619; cv=pass; d=zohomail.com; s=zohoarc; b=Il6jzuT8ja/Ms+/jlmnpxi1hrl7myr/qDtVk9VQ5sOmKPrAEinW1qo+oYYn7dbX4D+b/OxUxXTxpTRrkTBANcwK/x4NdYIdwzEsjDMj1DlaXw88/vxtOQJnPq2BBxDJfGcHo354Le9W0YKfI2nkYxt4TpQhGj7iXEJGJ8Kfuxmc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790301619; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HSTCCE6BfYc8QrNONzuGB+zj+mnTqlqFaqy3Qctgdy8=; b=k72Qfos4UVoFm/TIk1a2+5TV7zSVmmIAuIHczYUz+LdbAVbY0nLCwrooYuyp5dBoYEsPuK2ZTACjBG7N9zZMmAgWh8Wm9se5d1VRhYfYVxlrQrJK5F9A5Bu15PGExBF1DtV3noTDqaAp0glRQb1hYAVc4fRAE7qUjRrsFP6TxfE= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 179030161946281.0979088566803; Thu, 24 Sep 2026 19:00:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x9vDX-0006qN-7Y; Thu, 24 Sep 2026 21:59:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vDN-0006hS-4x for qemu-devel@nongnu.org; Thu, 24 Sep 2026 21:59:05 -0400 Received: from mail-westusazlp170100001.outbound.protection.outlook.com ([2a01:111:f403:c000::1] helo=BYAPR05CU005.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x9vDJ-0006Oj-5N for qemu-devel@nongnu.org; Thu, 24 Sep 2026 21:59:04 -0400 Received: from BY3PR04CA0024.namprd04.prod.outlook.com (2603:10b6:a03:217::29) by CY8PR12MB7539.namprd12.prod.outlook.com (2603:10b6:930:96::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.18; Fri, 25 Sep 2026 01:58:56 +0000 Received: from BY1PEPF000264B6.namprd02.prod.outlook.com (2603:10b6:a03:217:cafe::22) by BY3PR04CA0024.outlook.office365.com (2603:10b6:a03:217::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.17 via Frontend Transport; Fri, 25 Sep 2026 01:58:56 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by BY1PEPF000264B6.mail.protection.outlook.com (10.167.242.123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.8 via Frontend Transport; Fri, 25 Sep 2026 01:58:55 +0000 Received: from localhost (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.49; Thu, 24 Sep 2026 20:58:54 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mVaIQAvM4cets1fDnmfcktryX9cvwAJt6PMx5IB81dzCSt26sg+hUjCeMDNUiY/bEjiA5eXPNyZVcmx2n62gy2LlkX5XH/OS2BSPNRJUaztXeThmse7ur8q1vtkNBW9DJyPU4a79cIKh2Z9G89FdvVejZcbK9tG43CsS/GOmbmtHsHK9wiSGoE7vdfDxOZwiRxf5on2OV9WB0fmwCb5cLrCKWu1teWuJzOZZIIPCEfnpK6KMrzMMU8wEide2q7QIlLJfaqwFKRQ4ZdIgoHR7l78JlWAcRj0BlcWOcJhSB3Zk8+WkoUz0O/ZdwEUpPKpu4MTmn7WTPPDuM4uQUXYSbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HSTCCE6BfYc8QrNONzuGB+zj+mnTqlqFaqy3Qctgdy8=; b=g7zp8x16EQkq/5WtjCxa1YJTqC/joyt0EGcNMcKhBUc7vSORuhz9v+2YLpsZy8z5elB/OqBas3TuCWh0/ZBoq8QDLnPvAYkcjT2zIVglQmYETxeuPgCF/cAszF6imJMNx2bJuZP/tv5BK3zCxMS4uGcZTwwOv5SjRZ/bbBCkDEEHv7VlVFlYSXLcJBTNIuueZpLFQYH4gyls4Nb66I4FdA6wfTg3uXrGPXEaX1vmBTjHjgMWcJcveHpHncpCXz0niKC3jOQn/twKZw+axxyLPaA4IDHXkYmbrDkfkKowfwNjTUp/dtQiv+j6JIf+SlOpUKoV1N2to4LE+aGOiyM65w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HSTCCE6BfYc8QrNONzuGB+zj+mnTqlqFaqy3Qctgdy8=; b=av1UZlKiOTmGf27f/zU5l0CCJFx/BiEXIsTqAGACz7F3Sfon2t/AvgfALCyHuWd0saGtB9Cdx5cZMUMN2B2xuNxz0+O/aDkiGDlugwnW8KFXlvbZFcHRE18HfMlrk/SWPA3RhPu0uxiZsbBG+gqSJCGsePCBWZXEIOw4a314ObU= X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C From: Michael Roth To: CC: , , , , , , , , Fabiano Rosas Subject: [PATCH v6 12/12] tests/migration-test: Add a precopy test for guest-memfd Date: Thu, 24 Sep 2026 20:43:18 -0500 Message-ID: <20260925015700.1260501-13-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260925015700.1260501-1-michael.roth@amd.com> References: <20260925015700.1260501-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PEPF000264B6:EE_|CY8PR12MB7539:EE_ X-MS-Office365-Filtering-Correlation-Id: 5659f92c-035c-429f-4d81-08df1aa88eb4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|23010399003|36860700016|10067099003|11063799006|56012099006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: uE6cRwbWrwhMheoGh9/BKqLVTNfnpqojsyhKXpIi/qvgr709PcWbXYnnr0vYnEV5hSbG/wbmgsrH/3XyQi8AMQAbLrhwOVaZXcSp5IgAYdfONyODgTauUIMazebSjarpyJ0Xa0FRln4Wd14GPEkHkRT4OluRMMzLc+5xsa9+DZNMY8UooHt2eZf+dh/hdFurBkqFjUsEyJ2IoieRoINwUKo1HQUTm0ESKRgYwsj0y287fa8acaEGnpQQBzErNX84Rolh6aTLx/KzYGm61Nx1gZA/OkNqevqP3R0irnmGHMYPPE1a+JCe8n28S5WvLLY0iO1EOtYLPk93obxx1BchJVakmBvwivqAcjqIDQHt3n9A4wcoGo/K1KLMkSVfMGWYLwMtmAWx8FT0KrqKKrfvdG0Ul1M9TiySGmOlzFKA3XttZRT2bTJmwaYzU/Bof9eufpGjv/R7GDEhvCsaf/94AUZD6L3LCtZA5Qlw7+Cx5HwApbHYtnoXo2fK71jPhsyoSDX74AV1tNdNrP+HGxS5WfUoAG+p/etgvdB69lZcrMMOyojay6P+AITeMGmDrhyokVGRgWOKGAWfSU+JHEWlt3fNY4fktYpH8Dr+X4olXkOZbDFEMPY7W57/PONTkj1e/2vZgEWUar0ot2Udz24LZacTXVvcVeYNeHCC3CccPwAISFYoUTjlHe2Dp+nkTAxuldKd9JA3YVwfhSh53Wb4bA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb07.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(82310400026)(1800799024)(23010399003)(36860700016)(10067099003)(11063799006)(56012099006)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: e7wQu1zCQ7LdALXkcZgVBjo1iMMhbmqLbWzvNn7u5F508ti8cetEsHu7tOX98sZNKQ8i4UQagiIDZtD9B3XRQ893Z9A6xo2YXFdDD2saOInV+1WWTQDjzrIvrieh+ckTALQeIF79MD2H+hR2xkJSdPq4BAefizRMgnGMXHhlPbvagzsW3P11Mm2VWnBLJPW5S//3gqu2rk8qChUC9DWuJ4E5xOiVIhLH3v06Kokmv98iJJRCJ6NZiJjT2a7itoh4+GfE00cjwFci47kXn3nAp3A0iTR7b9tjbE1iQhgglW78JcsrnZiJVZfMncA/a5zSLjyX27q5ADJWU2E39dxpZfSnQHvaUxDZvZS5cz7n/WMskYQ3I0uv+TSW/rJrEPgsK+5ua+sPbQGZjWmQMa4DMzWBpDrAbkXqLEUzP/VpCHTq1xFjz7CWHvgSPgFVg0ll X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2026 01:58:55.9625 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5659f92c-035c-429f-4d81-08df1aa88eb4 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BY1PEPF000264B6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7539 Received-SPF: permerror client-ip=2a01:111:f403:c000::1; envelope-from=Michael.Roth@amd.com; helo=BYAPR05CU005.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1790301620279158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu Add a plain tcp test for guest-memfd. Note that the test will be automatically skipped whenever not supported (e.g. qemu compiled without KVM, or host kernel doesn't support kvm, or old kernels, etc.). Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Signed-off-by: Michael Roth --- tests/qtest/migration/precopy-tests.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/qtest/migration/precopy-tests.c b/tests/qtest/migration/= precopy-tests.c index a23d51126b..d57ffcac23 100644 --- a/tests/qtest/migration/precopy-tests.c +++ b/tests/qtest/migration/precopy-tests.c @@ -182,6 +182,13 @@ static void test_precopy_tcp_plain(char *name, Migrate= Common *args) test_precopy_common(args); } =20 +static void test_precopy_tcp_plain_gmemfd(char *name, MigrateCommon *args) +{ + args->start.mem_type =3D MEM_TYPE_GUEST_MEMFD; + + test_precopy_common(args); +} + static void test_precopy_tcp_switchover_ack(char *name, MigrateCommon *arg= s) { /* @@ -1108,6 +1115,8 @@ void migration_test_add_precopy(MigrationTestEnv *env) return; } =20 + migration_test_add("/migration/precopy/tcp/plain/guest-memfd", + test_precopy_tcp_plain_gmemfd); migration_test_add("/migration/precopy/tcp/plain/switchover-ack", test_precopy_tcp_switchover_ack); =20 --=20 2.43.0