From nobody Thu Oct 1 05:47:20 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=1790726112; cv=pass; d=zohomail.com; s=zohoarc; b=HKBmCR6NZp5SNGdez+P2y56ahqs12NGvu1uC+MGZ73uEE2qxglbJEXKJ1JnAtaLrW786aQjLtxar+nBdfc6Uo4bVKBGizP4DlQzUqETImOdGqFitp19FcfqfekT5h3Eb9ixOxkg9QZKYSRuG185YBB/c26jiQfgJDgo+RXjFnR8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790726112; 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=CZ94ONsGB9Hoy/WixHPGL8OwCS9Q5Ou4MKqiR9bqQiZJRHvww7HiiFLUoiXKmR+6njJllRxPN8we4/8sWdTKvHfq64LiMsrMEAyPmRp7qUmUkHN5Fz8YUWDdBHvmHDS40gxqnt0zuXJ5RU27X0MGcvShcRWqAIZ3g0FEFe0Ypy0= 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 1790726112023982.2610441398642; Tue, 29 Sep 2026 16:55:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBhf9-0006u1-BV; Tue, 29 Sep 2026 19:55: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 1xBhf6-0006r4-Rn for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:55:05 -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 1xBhf4-0007lD-TU for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:55:04 -0400 Received: from BN9PR03CA0953.namprd03.prod.outlook.com (2603:10b6:408:108::28) by PH8PR12MB6868.namprd12.prod.outlook.com (2603:10b6:510:1cb::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.24; Tue, 29 Sep 2026 23:54:52 +0000 Received: from BN2PEPF0000A893.namprd04.prod.outlook.com (2603:10b6:408:108:cafe::94) by BN9PR03CA0953.outlook.office365.com (2603:10b6:408:108::28) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.472.15 via Frontend Transport; Tue, 29 Sep 2026 23:54:52 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by BN2PEPF0000A893.mail.protection.outlook.com (10.167.248.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.14 via Frontend Transport; Tue, 29 Sep 2026 23:54:52 +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; Tue, 29 Sep 2026 18:54:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YenykbT/WD18ijmNp3cyBNrJKrYSMYLZZuYGUGdaXMFV0V88gpLzgac+SOt9jxYsDiUmwU4sNhrmXoHmKShvxjkpHtIG41qUHV/yShD4uJeekUZystM29vj3NRMx1sjtZRBE6M5kWiJz5A9wBR4JC4YkNurIvkMK7fEzXreVHSDZJnU3pLpY/eAhyHnBo6biKYHxudvF1SZCNFJnf+NUx4cCO7NxRHUMqgMas01khllsF1In9BzkL0VKwhqjrOeC1pgBSSZoR+zAXauxwYdgC3hdtCvHCZrn+tnZIX0t0qWU/PAxfovrLdl/DrqaJtMNNaf7s8pPMugPRdCb4Wqy8w== 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=SAAq3ZrzE//QCVHwLVj27r0xvYOkAbvt8ZLDtZ46JQHXidQVaPfsNtMKLbvrL/YjmGiEIGDGdN/b4FMFYcbjZJs3DMNuqXgGdCaplzfitHTYM2r3l7sPhC4w+Hpb7BZZJxWS3lsDYR3cZ+x6TYfWKZxlO1/dxs+ziJFTKbVj5+d0JoehGCrRSbJC5abP7oUSeEVowZj9CUx74uNPsDsioCnJm5Gu11d1841fB6g+CMwPOAYJGFBROCNaRTGSXWMQdghXOBT/gKdascyML5SIcdobDDgbk4S9zGjF7Z+WxCqUzO8vnr3YBDZrWM6nDBLM0C/4YTESCqDse26oc4kypQ== 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=l0qDwn7mqObWAu4wadnjerR10FLLZrU7iPThC/mcaGJASxEq39Y2DCu/MQIp3ScoL63cTX5eGSfDUACrc3A8E4T10S9rk2w3wivAwMTlIXS+qvXqdW3XGSQQMCIafmtX5vRDQAh73n8TpLs6fS9NIa99xrkMTRE3pc3FbGtL9HQ= 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: , , , , , , , Peter Xu , Fabiano Rosas Subject: [PATCH v7 01/12] kvm: Decouple memory attribute check from kvm_guest_memfd_supported Date: Tue, 29 Sep 2026 18:50:07 -0500 Message-ID: <20260929235109.1398509-2-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260929235109.1398509-1-michael.roth@amd.com> References: <20260929235109.1398509-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000A893:EE_|PH8PR12MB6868:EE_ X-MS-Office365-Filtering-Correlation-Id: 098228b7-fb25-4e5a-d3d4-08df1e850dea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|82310400026|36860700016|23010399003|18002099003|22082099003|56012099006|11063799006|10067099003; X-Microsoft-Antispam-Message-Info: a8eOOD6WSGETozjBX4iK+QaiDKPdc7MDnYq3gZGT3E2Vh4vdQ8O3L/bLmrmIufESMClvITTT+WhENMkPuhFHegM17mcwvNF6I1sM+wzuE3BTZrquF3ibH4SDUAOToDeSs36waSsgmM6SObZQ/6C1IzxFK4zMxPaPaUDQXjumZMGV71PHyFrniGMgsU8L7DL4dG0kKJxMQIh3yNwRWKAcPKVLVG/oLAOHDkZpKEq+NrWQfXybxhl5eOcUw4qbRdakufoWF/5ly6GsfCJ76+4wXjs4Ys/yZSr83IgmNwEKQvZU4QaVx5j7e0ciA6o1dfp8a1WBVu3v7vs/vXGw+S8C1TeoVvSeeicWXkZqW0sl/u/3YL6yI+DNup5GapNk5fUlMDWbtRB7a1DLV2lld+Ouqkcp+mZmMU9m1A9hCZCTZxTnseNEE1T0Hrh3OyBaXOuIbrMmq/1Au39TsH2Eu7miSCcl/b1wAFwAcD5QG71qJkCheyL6Z4+KVqd9os45/i3Hhlz8MUm6ecsYNIuadP50nbvcInQs3Y4U/uqtLtl4KSl8JnLbQiRBQNp7uRi9Rxwb0AQvjIyjvy8Putc8OAhhGHRmcWAylKoElV07mfYFYsoQKhtTtnq6NgYIAEeiA3HtsVQ/qyCLoGwcTIygVGtrR1gTsK3RaNi1NQ8SCHPEb9ktVxjYhDLbLcyRJHr9EsOnP0xy3x38tKpmwOQJ69Rykw== 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)(1800799024)(82310400026)(36860700016)(23010399003)(18002099003)(22082099003)(56012099006)(11063799006)(10067099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YhS85HiTUPTT8O7BIuo0K3kUZEJ3zJm8KrAycKfH65WpnaFA3g/e2GH+ZlOpXYb9aWn1eKC2fO/IobxfuJIFxp6f6YYh4bKgQhGjal48LeUcsF5KsHLtHcVPP6j46MDVTOE6jDhtCcmxZiVB5ftESKIzoLYjI+BdYjZ5LvEvd6FKHysaxhOWNXUT/dBz1C2GDNaF+dnZVi9waqGkJIjF0VRNDBPbSwT4jWyiKfU3gAVFSreBpZAjBCuElymp7OODGe9pGwvlXHQpCVhFGdt1KRyiMPSiyTxxoy1QQ8geMRlTvkFPNwZADMHxchkEnOvAx2lh413HwjLVcv75xjQyChC/++Tg/xiLuZL9EUlejpihMH1oSFXGZYxJReQtxq+A0Jds5sUU3oagYcPKT3ChaDyie3sOj/wYbhnydsj4r9xIUjqfoGh9bYy7Et3sapsv X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2026 23:54:52.2450 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 098228b7-fb25-4e5a-d3d4-08df1e850dea 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: BN2PEPF0000A893.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6868 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.341, 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: 1790726112702158500 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 Thu Oct 1 05:47:20 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=1790726135; cv=pass; d=zohomail.com; s=zohoarc; b=J6IqQmzzVP9+tZzH6zui+dGCswpXxOQaft1m/8n2ScDCXE9YcmA68TCMldWxR2IoH3D0oqqdW5Iywj4ctMkYtWGj3pHcZ9lyEDxxkzqW2GJwHEKrqACufippUCchcjetFKwlAQrPC/xevoEDGau3r/W+bRZYERKeOsaZgMb1JWA= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790726135; 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=mCNsU1ZjEryuq5Bu+SVoug5/jCAZCDIpeQK2Gc5Qt+T8CW2toSx00EVUiU1EaGbo7PdyAswc8hgPPN7+C15ed/LpaEqwuY54GxTisSb0uw0UgwsaHgD0lqyCJuvYlkohMSpNg8ruj7SwAj9YK1fc6A6Z+1uSzsNUW007HrL+CzA= 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 179072613589099.24173237050661; Tue, 29 Sep 2026 16:55:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBhfY-0007Gz-FG; Tue, 29 Sep 2026 19:55:32 -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 1xBhfR-00078y-Dk for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:55:25 -0400 Received: from mail-northcentralusazlp170130007.outbound.protection.outlook.com ([2a01:111:f403:c105::7] 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 1xBhfP-0007za-IM for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:55:25 -0400 Received: from BN0PR02CA0037.namprd02.prod.outlook.com (2603:10b6:408:e5::12) by DS0PR12MB8043.namprd12.prod.outlook.com (2603:10b6:8:14d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.25; Tue, 29 Sep 2026 23:55:18 +0000 Received: from BN2PEPF0000A890.namprd04.prod.outlook.com (2603:10b6:408:e5:cafe::10) by BN0PR02CA0037.outlook.office365.com (2603:10b6:408:e5::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.24 via Frontend Transport; Tue, 29 Sep 2026 23:55:17 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by BN2PEPF0000A890.mail.protection.outlook.com (10.167.248.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.14 via Frontend Transport; Tue, 29 Sep 2026 23:55:17 +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; Tue, 29 Sep 2026 18:55:17 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=i6xiiUVPoB7PcSBvch5FOMzwMmkJvylVNrz8w4+CiA7i9DM8ZQ8pkDmm+tt6NfmdeJYUlbasaCSsm9hhcO8Sco+SX2wawRZFgtK46YTgSdNsBlmhfBHNhpjvrFp9t9sory8pE/vpcVvfhNLN5lOeM+Pj/cAOqwsn439ujqP9qJjHv16AE3+kjLoM5gu2A8bHq/WfT1cBQxWhQQulRoDVP/TrJpE8rhMx8CzZnpNJOOTjfe/f/4b+r6OLlWrkYBy2pJFH24fspgBxoz44z6Dr9kErtuRFvP+zvFjJFDo0V2JVP9rKeH8jOLc4IVAikwY8H6qp3FJwx1OdTqhWxP82Fg== 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=cCJe3FugwfyGkMt1EOcp66reyR3J3D7XOha+PgeIRKFmBG56FdPI11H7rHI8fm1ZyEzsDDEyZdMf+VeYUXDiJ9aT3v92Om6Rf3juNuUT07Pi8OxBe6Gmi4RL3XxGabYwK/RzligsYY5cmcXaW6ZLRXnD4aBjzzvyAIlmHpLPl4CWDj4cb+sSprbOA0mHJ4IsmoNeTVSy8gDDym2ALqmqBparJIynK5WuZ4uu/Ug7zpPAAJIwzvregYKAx1RUlIElQh9t899LW6tad4hFrj/qoQgCEfOY+xrsbCCIjLQIVyPrHqPe9Y6aWHBVEI55dH1VbzWgBSzFpaeQO52ykEu+CQ== 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=bTqnt9IeslzIjFx9rglkSd67is7ESGvfnWQQIaMpTsqp2hUruLEhsuP+8pLXQFbtw8BMOHATvxYlSWDc+81ImZWpcqjestze9JevdCpj/RLwbkX8KYbIU/MieWMwaeo4nADVtNOW8sYZJsOPmkF/sgT7lQT1Dn5dPrgVLDNPlac= 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: , , , , , , , Peter Xu , Fabiano Rosas Subject: [PATCH v7 02/12] kvm: Detect guest-memfd flags supported Date: Tue, 29 Sep 2026 18:50:08 -0500 Message-ID: <20260929235109.1398509-3-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260929235109.1398509-1-michael.roth@amd.com> References: <20260929235109.1398509-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000A890:EE_|DS0PR12MB8043:EE_ X-MS-Office365-Filtering-Correlation-Id: ec180172-d1e3-4fd8-8143-08df1e851d36 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|23010399003|1800799024|376014|36860700016|10067099003|11063799006|56012099006|22082099003|18002099003|6133799003; X-Microsoft-Antispam-Message-Info: TaKRQ/LCNafRw6FU3gr5FmRM3UBjlvM6fiLJaKuppr6tcwlxyixL87nZXXAamHDMowu4lxiw1zhmAMxuhEDVtfcCXp6TnceW2+Vpbns589/02zaZzd/ac0hQY9snWXY5O19ReKkjQfLmKOrDg8t3yBaNm+uCeCaXfRpkfaqQDkmB2m6RjuF69gqwU8mxuCz2IXESkVjVt6RDoPe5XSka+1PjedSpSInuG9vmdcLeWkA3is8MXDs5oeQa/k0iHD9Hs+DROdGHP+YsHbNuA2hohvKsLS0Dk67paWqmmIBiCM2J0cYcXEnAcUr2t9ZUYpHWhsapH9DxoltpEjBSavqVkoymHz1IVLlk8Z8c7KWJ4AZDbKfNYhAeE3Ru585TXyOYRg4LqlTMGLDHnyWQFOLQjJPES9UEIj7EEudfdqOs+RltcXVpiXiQZUeLHS/BMs5jorgODiO8/RvWDr4J+w6+GiwLyZkurXIJ4abXb3QEXfDi2deRvL1Al69P+ItDYIEltPyJZn7a4vwTm4Hakrl4W5pJ2kzbEwAd5pYw4pQsn3Z8NZmTE0h+ju7c2qcEc6RG2dIbGqhGGjeP/N76MZ+PkeYIhvFzu8JxDys/vV8R0mEGqxuogHtOHlLiKQ12lnInX50Kav2kurBddZDbn8NW2cjiXX+Q6zhFktxXbMnC6q+bbYK2vKk7M6zlyAZu3flBHPWXN4D8lsRyabfbMZQYRA== 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)(23010399003)(1800799024)(376014)(36860700016)(10067099003)(11063799006)(56012099006)(22082099003)(18002099003)(6133799003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: u/1IrETqjCdPkk1zb4tR5R9OUBPTpGqEfWKbe9FyYCt8F5qWQy+2AKBl0zaPcz/8gKp+v1NUlZ9AJuGwtEXQ1tmppfGVwCnn1izS84dFOsDRhJYN4VygOx0G6WTU3LJ15RqS4ZoXYtMqncC9Y/PzMtEYXIbJ4jqbj9Fft+Yg+fH8A9yDkOebSdt5p1VYovsIEGhtmUkpzV1bRhbE41phqsALEI8ZJB8Svg5lYUQlANQbmt2OqvgeRxVpOa47rdnlJPre3EOb4owbEjpMRgds8GRXQWTu9o+fRl51eJ8U7zWCpkTwF2QWuK+h18fNFQgQ5xRTyBVftXPwXa47M7FTdWTGI5FrSr1al6qjirEVDlhyoUy7syLxseTdhyKyZEUFuzRsp1W/nPTi1gErWD5CqGAkArYrBiJRiak7W6VcXeTvGfxU3rBM4dEw19Tv5oAU X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2026 23:55:17.9060 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec180172-d1e3-4fd8-8143-08df1e851d36 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: BN2PEPF0000A890.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8043 Received-SPF: permerror client-ip=2a01:111:f403:c105::7; envelope-from=Michael.Roth@amd.com; helo=CH4PR04CU002.outbound.protection.outlook.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.341, 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: 1790726138769158500 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 Thu Oct 1 05:47:20 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=1790726165; cv=pass; d=zohomail.com; s=zohoarc; b=ZFTYozrOcwWg8dXYDkM6Oc5/yRoGCoUIyokW2IZ+MuFBiqHRe4VdVAOKpJ9qRi6LMoCtH1TyqegOifXDjv4Ya64gSi/LMvsL5nOZPInMhleCej3qEpd5W8IcU3w1pTY+T5ds5Bv09zJoNT/qTvOnHWPxn1v2Q8+KcYhqDuSfvE8= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790726165; 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=k1aGukasrbDAZQKN0HnubO5I8niFYbUBYNJ2FO39o5iubJDUBQYz/WCsDedCJUa2GRfeG/fOor9trHTSyvFGJW7wTjTlY7fqz7bEcE2zg8AEBbKfJhmgSXTu4A0YHex6hEXDtx3372yy23eiklIgiWmhdr5UX5qqkxWKMDBUuqI= 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 1790726165092691.1125708110102; Tue, 29 Sep 2026 16:56:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBhfq-0007iF-63; Tue, 29 Sep 2026 19:55:50 -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 1xBhfo-0007gx-5e for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:55:48 -0400 Received: from mail-westusazlp170120002.outbound.protection.outlook.com ([2a01:111:f403:c001::2] helo=SJ2PR03CU001.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 1xBhfm-00086G-KM for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:55:47 -0400 Received: from BN8PR04CA0042.namprd04.prod.outlook.com (2603:10b6:408:d4::16) by SA1PR12MB7221.namprd12.prod.outlook.com (2603:10b6:806:2bd::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.24; Tue, 29 Sep 2026 23:55:38 +0000 Received: from BN2PEPF0000A88E.namprd04.prod.outlook.com (2603:10b6:408:d4:cafe::3f) by BN8PR04CA0042.outlook.office365.com (2603:10b6:408:d4::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.25 via Frontend Transport; Tue, 29 Sep 2026 23:55:38 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by BN2PEPF0000A88E.mail.protection.outlook.com (10.167.248.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.14 via Frontend Transport; Tue, 29 Sep 2026 23:55:38 +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; Tue, 29 Sep 2026 18:55:37 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MrtbiCjv+Ew+jDmSCIvBfrKBH6naYr/nq4oWOnYVYtiEYDNNC2+L6+xSqDm+HFl879LmkOOAqnY61W0gn7D7dTk4XvtFY1VZvJuBYCd3HP6/LqeaXO26FI9fA/PbPZdyFynmCobknVWJbMXLqMDmDMAaE6WMZPC+Ly19Ra6oZQdqV84T1GhWbl9l+j2IXRICF8FZwDc67yks3dJuUKZ7AQBpQanTa+PRdmXBVc0CWdC/zJTswcd2rn0N+qGjdPqOBbVHY7sX5Vzahb97kaZHmuLwV/eYWtQrk3vwBppwyRf2L/zpLrz2dA5tyqhGMbDewfNcu1yigCkhkbG1+p9Czw== 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=tbZyPof5Do7lZEiBoQXssmXBpRTP15BtFQMJFmiiy//dnuSx6OILJoKDhmiDsBmJi0mtc4q84usj6ItxfRwXhsG4yDSCY2ooPy3fH/Bg1YezVRjqdbG2oAqj5w5vG/vIItGEW53HWHB+TziYRdsphpbwqWFlRa87HWNEgWz436j+0uAJVMAnTWcGPD9K+yxUqq0W+WAolaxTOPkRcX9wGr8ek710eb3evooCfPw/gCTMtf5POmT2yG3r9BbnVulowayKmfx4v9UvSyXNziOW9UV2DrA3Y3NpAn6e9y0csXZYW17DT221RLoqZ7l6GSxR4VEpyOmmZqUPyHnZ/LxMkQ== 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=1U+1OxgYjU6AZwS+PElmdgAveU/dq/+kk2mC6x5eu/sxbFiSgAs+kKMqfbDSx1ctILPzNmQJ4W4M5gHYKFjdaWsphKuWM+KEccSaj0nB+8b1wkqd6dncYHKp1CtHGlyldcwVOZI7v1opdltlltAehzU2G0qYATODdKSWTR7Xb8c= 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: , , , , , , , Peter Xu , Fabiano Rosas Subject: [PATCH v7 03/12] kvm: Provide explicit error for kvm_create_guest_memfd() Date: Tue, 29 Sep 2026 18:50:09 -0500 Message-ID: <20260929235109.1398509-4-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260929235109.1398509-1-michael.roth@amd.com> References: <20260929235109.1398509-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000A88E:EE_|SA1PR12MB7221:EE_ X-MS-Office365-Filtering-Correlation-Id: 696d2d23-0f39-480c-d695-08df1e852989 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700016|23010399003|10067099003|56012099006|11063799006|5023799004|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: j6T5hju713yt8ZxtBl/xMG5ydLk2sorXHKoNXirhFdyYaz2fSPCYw6G8Qcj/idSrlir8FnlLT9s9AeM+4a157UaR98UPL9x/4PGyANThtX65IBpr8V9Woq3VGEZIaMvpbupMzOLve/0lyNSGjxLkoqKEHIXUWbX9Hftcs42Yjk1CznB/HkgJlQ2D889mng1+y/wBNsPe2dR2YEn4PMYPGcLih19NXjE0oVWCpcwau9WGEmUHrofVImfIzxaXub++v4sxfQ+31cg0yLd3EA0T/MbmbVMK2lDZMoLnm4n41jWtGYIIks17fzuyBT4wcmJkAMDxdq6Ve+jpqk3lKIJJ0oH/4LkKuF0lZYgsFEHOV+ifqcMrP2Aa+t18FqGDvn19IKDHJzyAsYG2i9QQ8etqE6c0xTCfs9InB3K3VHNo+l7o47zWBg7HHY8wdOjVRpxepBJyp2hd9Ka8tldo86qnf+BbBsckFBkE0Qy6b8NrmUnSDczCsfD9+eqzflqTe240r0bTm8Unfv2gRGDkbSda3vrNRCqajxvt1+gE86c5oZ3xpkY0dflsUsLw0uWDFkT1CZRbBiR0+Ry3YE6cEikTyZXs8lNxcB4seqQ/6TKVP0yToGnqdB/L1tW3gq+8Hb3GHvhtUFA0tASBCi4XmBaSV8IU/W9Cao1+8yachQ6QfOCy7YhDnOahN1lSCCpsFqtM559qbhBphju32T6YorNpWg== 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)(36860700016)(23010399003)(10067099003)(56012099006)(11063799006)(5023799004)(6133799003)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CkQCzd0pf4DDVt2Cdr4XBomoHadEzxK0HB7IYzbmQxBCHvRcCcwiae/QKTsI2aFTkTT6vFx+JIJ1Lhq5ToWpAUSmfxzlQiqTWLMySC/7fd7yV9Jvp3F+f0IixKy+koeoQpa4ON+DKZesda+UmPLqmrYjnzGjvaGGWg+EKbqEDmB+ThakFpIKEI/BDiUVFgpcmMOYJsnYEtKtzYvzk3QY3HGROKto3P7XGpLIy/7LvDL1yH/X0d1xh7IT8c+CI/Rvf7TuVNUGo3qWgQYXSDd+osux6104M5Y1nDJQZBpW1Y8ADEoDsse1k/hA3rne2PxP+objomErl/nCS5umcSlDmb79NmeeezOUhWSeQTVAReEuzIpRNpw08bO2oP3SOxvbbt+YPjyXKKVp3NRpVz2klh9xzAJ6sqiR83theSqgh2v8WWTcqeWM696feqNqUhPP X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2026 23:55:38.5859 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 696d2d23-0f39-480c-d695-08df1e852989 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: BN2PEPF0000A88E.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7221 Received-SPF: permerror client-ip=2a01:111:f403:c001::2; envelope-from=Michael.Roth@amd.com; helo=SJ2PR03CU001.outbound.protection.outlook.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.341, 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: 1790726166661158500 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 Thu Oct 1 05:47:20 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=1790726174; cv=pass; d=zohomail.com; s=zohoarc; b=LelKd/wqFXii+xBP+ZeV074JaSgk617wB7xZZq4KKS5POIBqbHFVE00Y5MZeeUCIK9RA6X+JXzlTgmzs/W88DNAwyZ1Cou80Qf6eAO02lXDtRRS3F1sPyZoZuWLBnla3+UM7yFjBBqm30YvikgVJm6G8oq5EYVs55Kt/+ChWNeg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790726174; 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=TxC/dHR+rfwNip6qISSeroyBDtmqucHq4dvkk++DD7mIF0aIA4J1mzjlo4mip259BAfSYpSKLCmo0snTjGYphDPYtpiBtMCeJK3I6wBYFGmdT9xY7Daw2rFVOwhoLqKSkXOBAjbogJiMKAXJVuHtu3GiRUKrjNemj1QtjywQack= 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 1790726174575746.650635182177; Tue, 29 Sep 2026 16:56:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBhg9-00082u-Va; Tue, 29 Sep 2026 19:56:09 -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 1xBhg8-00082g-Sk for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:56:08 -0400 Received: from mail-southcentralusazlp170110003.outbound.protection.outlook.com ([2a01:111:f403:c10d::3] helo=SN4PR0501CU005.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 1xBhg6-00086w-F6 for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:56:08 -0400 Received: from BN0PR07CA0029.namprd07.prod.outlook.com (2603:10b6:408:141::11) by DS0PR12MB9725.namprd12.prod.outlook.com (2603:10b6:8:226::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.23; Tue, 29 Sep 2026 23:56:00 +0000 Received: from BN2PEPF0000A892.namprd04.prod.outlook.com (2603:10b6:408:141:cafe::c) by BN0PR07CA0029.outlook.office365.com (2603:10b6:408:141::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.24 via Frontend Transport; Tue, 29 Sep 2026 23:56:00 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by BN2PEPF0000A892.mail.protection.outlook.com (10.167.248.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.14 via Frontend Transport; Tue, 29 Sep 2026 23:56:00 +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; Tue, 29 Sep 2026 18:55:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=cdj1DKUtUaXL9bT4QedvJTImupv0N246jTnh9ND2H8SaPGop//+Pezu4n3DxrN1iYnwa5Uf7LPjPoeboqYxNjHBdT65jtzXnL5SlRFquRP0vq5te30CF4Dnf33S9M9Ag8CCvlNw6PDC+L7m4ibOvQWCPktYZMkJ/rhVnH5kEDVziXY12d6BFJmiKJuItbLL2MdgVlYiVSapLVHIIUR47BHOP8KmZPyqfgBqiFVjGZaUW8DK+bG/6HHVbi8ynFES7FdIGKI09AZOUOJp/HjkyMs/yVXS757CJyR3QXLSWGWewMFboNkCr+mcuWOdHKUTHoE3AW0n+j5d5ggpalWY/zQ== 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=ZkJ8rGEDboiVX+ded7HNQwmhmwknvGvFP2vxwvaY4yST4PTe3s51Y7U+HtxxrbzMxhmJ65rieibRTjLFedbxpkx0McPZ7P1h4Y7962HRC/2Cu3y3zaYyZpi66qpCcTH6cmAG1VdTy7wRzrqSwb4AqBMCoUcvqJqZEny0gPwi4BEw52hHawOQZxEvwwfXnXCKVg3OCGBBmffnTWSUNVS8C1z4u1nNUELHf7OqbzmzSzedGC03hAIPwpaw6jzOMR0sj33Qpx4oU3hgjrO0GDFk/TsMmdRrDMaA/0hQOY8XyqA+V30nL3oqr8J7DYf7/l/gsNcx0cprGtRgSEOMozIf3Q== 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=qaSjmDCvQ1MySk9JSkck8ZLvz0DG8mIh55y9FYF83q4v+TpscwzMXXh8v0vaM5JpSH8vKtzDf49KFg/5EY4w2khZpyjhKvvc592aaaFUj3l94R3lefNt8+kUUXyvDJAnh3jTv3NW2G3cmbPWRv3jZXdO6m+X3JWSvBqPQji81NI= 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: , , , , , , , Peter Xu Subject: [PATCH v7 04/12] ramblock: Rename guest_memfd to guest_memfd_private Date: Tue, 29 Sep 2026 18:50:10 -0500 Message-ID: <20260929235109.1398509-5-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260929235109.1398509-1-michael.roth@amd.com> References: <20260929235109.1398509-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000A892:EE_|DS0PR12MB9725:EE_ X-MS-Office365-Filtering-Correlation-Id: 3db1ac11-7ceb-4883-5b94-08df1e853683 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|82310400026|1800799024|23010399003|376014|56012099006|11063799006|10067099003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: C1b0iZPSQc/B83gBt6zSW6Nfbb+u8rz+7BOsVxAa4ndfczqNvzfX+rD2HqMIIZFTTD3UbkucHh2EmjfIABNNCszUDJ5BqBhDn8gJuMqTS3TcZezPHJ6rnkDHElqQYtZhWVR6GuqdKBBTLBsT2A7jpl/vVatHel4c1LPDlYUuzKvAF8aNWbIGbK4OiHo5TBA6w3K6GajuX5/fEcfcpPqsASkwy9p4DhUglfA0nLkZJShvRwb/JA7mBKiIihcu7dfttb4k7qZgmzjWIMHiCAwdpRFhR8Hqo0i6CqlE84Nmgktmencf4tgo922MHMnz2EtN8Qv0aAF/vevzeLJB3v2hJYOfGM05Q8fou3Rt247qIt2VWs3VJgepOectdUBisYVc5JBHw8DgUDHLXU/75dcNRL2L9ONeQH8vggyvt01a/GIDW1/m9YJDjZCzyZlw+cwClxSw+NCMvfBN6NRX0B7yoVreE41O1iHdqpiqGG0z8HrTFA9pkUFQnR8HWHZOxEWlFLSm0s2DF4IvpO6qebsGWejG3Ajtt/MjcJCLyrZbimGtwHlb2LxM6udKBaGdBohNG92rUvkTDa4TtajKbGLkmK/1YZAdJb024RPCTg3CrnAKv8VJY5YbPgfRz2VrOz7fgIk85+fw8haoQ9HYTgUejb1ImPBsT3G0ETL796SWpxZfTvWLa1m6hdvo7kH1qisXwgfXZ6SbBm9G0ZzNes+WMQ== 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)(1800799024)(23010399003)(376014)(56012099006)(11063799006)(10067099003)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TLTu8wn5eO/ceKr5//mWie9boOPiMqIE9QBiBBLKfQ6kqda/j4rPmqEq8nvxfe4RYn48eCcCjD8RiJbeL1LXpRVer2b/q5WT8gZE4kKivoK3fK6dtLI4GyXeTdhwiHM+sya6NWZSQoDBfO+frhpA+c/aGHA/DOVMLvcJHDAK1fE7d00zyTgwN06buL2HZer65q0VUgkNvsSdBQAtu5C2daBWg60RR8duKyKHF98xQp2WC0y8ZrypMJAV+w2nnUq4OEn9YFvswbLokFWZccPED3V/GOBXswESk2r86xDeYbEc4Bs8fGJTmcdLYAoz7DtL95494/0XPxeD5FpJFL6b94ckR3i+OplFzGcCc2cBKrHi+LLPd9Orn8zcSW0/SWfcsnXWeBmUVvDlXK71zhGEDXAkp8FwCH6nNNED6UuArS8cDggR6IIww40IPmxzht3I X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2026 23:56:00.3542 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3db1ac11-7ceb-4883-5b94-08df1e853683 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: BN2PEPF0000A892.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9725 Received-SPF: permerror client-ip=2a01:111:f403:c10d::3; envelope-from=Michael.Roth@amd.com; helo=SN4PR0501CU005.outbound.protection.outlook.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.341, 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: 1790726174792158500 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 Thu Oct 1 05:47:20 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=1790726199; cv=pass; d=zohomail.com; s=zohoarc; b=Rebu6SDmoWTq66T97jUMXeW5utXlm5itRASAOC8LVbssHMx0Kbw6mtZeCAgbBTRb0R/S80XcpkhzjFBPPmDBlyCWERHhHp2HorzjrK3mkVUiRKyJSUeCzY+XPEijRDyWVK8TNC5IuIwVmjQca9whxAoHlyvqmwWzTpIBt7w7C6w= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790726199; 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=JGWbVSLb71IFq+wGlGrgQmt+GlopUwGjref0umao9LyDZNm8rCgPuyJKEndb4HNJUTiV3F4wVXid+6JuEEhjqGzRortR2ido6a49kuTEbpwt9yeDLJrxu6uRCyZqgnRLR30hmIvRr5UGmseLte5F/AzanMsbs2C9TPy1F9E0wRo= 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 1790726199163647.641220567326; Tue, 29 Sep 2026 16:56:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBhgT-000050-TV; Tue, 29 Sep 2026 19:56:30 -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 1xBhgR-0008UD-6A for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:56:27 -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 1xBhgO-00087Q-VC for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:56:26 -0400 Received: from BN8PR04CA0038.namprd04.prod.outlook.com (2603:10b6:408:d4::12) by CY1PR12MB9652.namprd12.prod.outlook.com (2603:10b6:930:106::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.26; Tue, 29 Sep 2026 23:56:20 +0000 Received: from BN2PEPF0000A88E.namprd04.prod.outlook.com (2603:10b6:408:d4:cafe::86) by BN8PR04CA0038.outlook.office365.com (2603:10b6:408:d4::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.24 via Frontend Transport; Tue, 29 Sep 2026 23:56:19 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by BN2PEPF0000A88E.mail.protection.outlook.com (10.167.248.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.14 via Frontend Transport; Tue, 29 Sep 2026 23:56: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; Tue, 29 Sep 2026 18:56:19 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oda93RUVZWR5yhuir91r2azzdJVppbw1mz3FQSvNV6W2c2MWETKauYGOY5IFYKykoNyPWM9YmPURPmLSy/Wzh4cYxhV/6xeMepVqrzhoMg+5P6i6f5+EG83VEJvTzAvq2q2kQCIHoiA7qxnkwml3Ov+SRyT6xFXB8Pf8GNXDok0MvOAQdqLOytbBKreWzpI4KTUFWxU20MHQ3bNjrGWIANephYzkcMEqp4lIVhF7W7KFEqTWls2oNyVBFG+OxTgIWNFQr+42CPxFwtqox3ibUYHhBZhUSEBZ4U9889sZOt2tViOfqDu8wnBRw1BaWpG94u3+rfyG6mkVXvgM/oTC3w== 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=ULl2qLnmnrOj+1R7mvTEf1B8So+0BvYtuLHJer76hsk18hXdGjU28t9Ml2KxpAfvcxJYTRdT74+G0Z8T4e8NoiXRF1gGlZM6DgGjwa26ZIq6wCwVCth+zpu8w1kWlDba+TJ50tUooHGOHjOb5zXgWXFKZiZ2HgsMCRoprX3R37RO1QTRkCKI3LOalL7jGjXnz3FVYnt6BCXSDIS38vjYRslvQLzA8PfltHqG9vJ08zCibEkr7JLatSVNSLrfAHWX3jXs2JauvXILA1Ms30S00nmVzTrbY/OMxNqSzp/02ZBJ1iGgBl8ohz+ad8w0xYjTIQkiRcanVNfYJyxc5HdrrA== 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=hVoaKRixbJWwx06XmdouQsXj/sECH8Pr6q6dQJONscPtrukOtuSOi+n4mLXo9ruTlEDNXUCI4PiTBFKpmxdFLIwanVb1qVswAIkjUlbecGlyyaoxtfScgCZsreKGALNBl3wwj1+j+EQvEKOARAQqarvCiaKLd/tX1i7IOel6bA4= 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: , , , , , , , Peter Xu Subject: [PATCH v7 05/12] memory: Rename RAM_GUEST_MEMFD to RAM_GUEST_MEMFD_PRIVATE Date: Tue, 29 Sep 2026 18:50:11 -0500 Message-ID: <20260929235109.1398509-6-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260929235109.1398509-1-michael.roth@amd.com> References: <20260929235109.1398509-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000A88E:EE_|CY1PR12MB9652:EE_ X-MS-Office365-Filtering-Correlation-Id: c2561eb3-0dc4-470c-737c-08df1e85422a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700016|82310400026|23010399003|376014|10067099003|11063799006|56012099006|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: iKvS9nNrmB+BdVJYVAqTq0qtZrP8jD1fk4aHUH80VmKs3Afx+UGewz6mPbGXnxkPIyEcQAlwkOnH/x3P14qJW0GZnIQyQVZ2Stj0WUOmCOTwSJ7uVcdkDW1q1cYMIYaIgBD/0tcw6C93pQU7nf2w7IBDBEnxWlp93uTCG2Blll7we7NbtHxXt+aHCRtP28Pi06Y+BIU72Af4RcnWHXqIDWfVlBw6sjL7N6v2NTqiRBUH6A3D9tDUmrSk9dgitb6LHORQc2XXyQfKEtq2kW+NKiRF7liFxtf/oLXVRg9FuZMKxglvIw259z7xQqr5o/tii1UjXEL7haSUyOogF8idS39LMxdihPWb+Tn951ObkGtNBTdX17w/oa/BtizdGuonLBP9acih5tpOHALVrpI3HLLwXAeGtiylqkPBfDbaMAt+4MZK4p61L4sp0MjyqTZXi/EkdfbdquVGcwxbRKGDikGU+3jNYZCFMyRXwK8ivcC7aeHrxvA3uZrILPPW+7HJNwJOb1Hl/jbtPKsWcowWnZUeeIH5H5mvx3rSJwq81anQZroepAqg5HBEepTjfUDVM7TBjHbdFfBZXIgeZLZ2/b3MOC/NEu3zKpAlwMl5BJW7zD+odqpGhzljTsUcedqC6FPLJ1qxO1bCPuRsuZ6Ee98k6u98S2Ra7uUzTio+Qd83eDFf5iX98IhellaXKvvABmcpnLu7pHVey0NW03sS/w== 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)(23010399003)(376014)(10067099003)(11063799006)(56012099006)(6133799003)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WNBZhRzSU0gsOojuDg0hKSRz79pTwpat9RF/LRSVxcYVZ+MAqiY2KKlyhXmqJ80GBJzi2HN2s7Z286xNERcfPmKgnL6/ejARD2zt8xSmTEA5aBnR3cOMAT+wzZLw2vvAZJY0yaNBPLCnRR1yO4DRSXvFyWivzialeTXPDsOvrSGm2n8GQpMmedTlI2/Ml95WKETzWOywJ7nZudJeSklxp9POoScntjmlw3/QWLY+v6Pve2fHKM/3IFLjR/vKBXvUOjOD4HxCJk6hgiXHRHgPpqw3kxgaENWw2eUHU6OB0YPkQVRKvnMj9hROR5oeb0b6iXqlE92FmGEFmRLJgm5Ky+t8tw9R53zrePa/WAqkbHLDbCPUxvFc/qfel/mt4cvLNUk/FYClifQ1s/+X6YfDMcRj/+J3Ba+B/sBsdg0E78pFtvutJdpCx/7G9W4IDi9Q X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2026 23:56:19.9028 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c2561eb3-0dc4-470c-737c-08df1e85422a 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: BN2PEPF0000A88E.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB9652 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.341, 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: 1790726200998158500 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 Thu Oct 1 05:47:20 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=1790726226; cv=pass; d=zohomail.com; s=zohoarc; b=dt87rP9WUO0rq8uu4PPbpmXZphuqpPup9pGayngJjvLRyLYeqm7rN8HBa9zNRaNAoXHHf4W3gVzIF/7CShSvosFBhEbJz4DvFiv1OosC0Xo+hoPKGeVdGKV7LMI8wjAmuDdRXnzGGvnRRCm8yqa2HNZUj+g3V5QulN7llPnXPVM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790726226; 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=chUscuemkU9iv3Ry1nCd+aYi4wdfDWLOBi9RZ1yDd292eolPGvoRx7l4YNo7Wf8bZzkwQngoz7naemXqiH01kl9a4auioQ8EBpM/aOxNcZY6fqgkS70Ub7S60KXKhTLfcpinVaEy2WI7qBnFukBu093iNkyoomuuoj64hMYDMvE= 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 17907262263541001.2706865614842; Tue, 29 Sep 2026 16:57:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBhgt-0000w6-LV; Tue, 29 Sep 2026 19:56:55 -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 1xBhgr-0000ro-I0 for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:56:53 -0400 Received: from mail-southcentralusazlp170110003.outbound.protection.outlook.com ([2a01:111:f403:c10d::3] helo=SN4PR0501CU005.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 1xBhgp-00088u-Rn for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:56:53 -0400 Received: from BN1PR12CA0019.namprd12.prod.outlook.com (2603:10b6:408:e1::24) by DS2PR12MB432622.namprd12.prod.outlook.com (2603:10b6:8:70b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.26; Tue, 29 Sep 2026 23:56:45 +0000 Received: from BN2PEPF0000A88F.namprd04.prod.outlook.com (2603:10b6:408:e1:cafe::83) by BN1PR12CA0019.outlook.office365.com (2603:10b6:408:e1::24) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.24 via Frontend Transport; Tue, 29 Sep 2026 23:56:45 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by BN2PEPF0000A88F.mail.protection.outlook.com (10.167.248.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.14 via Frontend Transport; Tue, 29 Sep 2026 23:56: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; Tue, 29 Sep 2026 18:56:44 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NTcBcLQ0SMCBKJPiUxmpC/N8Gu8hcPYCUZQ6B7fkxhmBC/ISGo/Qe/+nFTufI+g6BvsXD/jSUrNwZQ6zcxEMkWqIceDWPUDeuibZzdKfEQ8goOEwmN2SYrvIfx/NC9Rz/fJ5xWRPx0wPNFd4t1KID1Un+/t6yiiaXBD7stnOPnZ+T1KUb/Q8/15pbWppTzWTFzwvd7gRgnrRIDMc206e0xnNMHqQ9IUQQYgyePq+IMpvE9L4KxTDpLRcBGI4FPD9ieRNW6yU/V55/alqYJqLKlN44JGgmM6I9nnNcFkjvbTWU+J4Xdwf5pIhcox3cWMStTmgsxIRld3AaDlg/lPBgw== 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=iHYN3IjLAYqDLmrQ7bFbBTEqOztDz/I6sdrXSO5sVx5wR1RqoHpS7pwm2txm4o9vGuVdjbSpZCYp4+yAbr3YQLFSRGANKGbteMudDZlD9Gh6ubmFL84jzWpkRYGkOIRbfQPPZCBxTTVmdH9vTnfNLcYQb7Iqjzs2np6/PYUh3RZHX4GxLlGCX2KW/ovPKL4NsbhnVnco2NUvQoB+SawstAKxFJsbxSCToexXhqGksFmwvug/k1KrQVQ6BaHmLIg3w/roVUZamRFqT0uJuN0zyYxTGQy8Swog85jQRRLkPcDpo+dRGv9UaUAVLBaLMxzE94UwDDr5hyUZjQlLGXljdg== 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=KSxqQnCUqaEVTB0+67T2ui7SEjvSKM96wxHqnaxdeHxMIhi7CVJ/MWNTE4AGAl5J9Ha+ySsUOGjIrXuj3N1XKTqlEQKdCxSQTxD7hOD4r+RLKXArV3iiGdT2OxtfE/InsTGgGYTMDVgqEe+m6GxPHE19bi6ihALU8G3CfDe0r5w= 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: , , , , , , , Peter Xu Subject: [PATCH v7 06/12] memory: Rename memory_region_has_guest_memfd() to *_private() Date: Tue, 29 Sep 2026 18:50:12 -0500 Message-ID: <20260929235109.1398509-7-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260929235109.1398509-1-michael.roth@amd.com> References: <20260929235109.1398509-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000A88F:EE_|DS2PR12MB432622:EE_ X-MS-Office365-Filtering-Correlation-Id: e5841868-adc5-4ba9-585d-08df1e855178 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|23010399003|36860700016|1800799024|82310400026|10067099003|11063799006|56012099006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: aP7Rwq/x59+bXSZSdbKEBlkyKNVByALuYLYHVp8Qdzha1XfkV0ScqBCRGuhdUrewBCeGmxCYKlnES/fzmcjfFIMkzrWMhFq2VJ36fd+lCaIcMCOaR6JoFhkfsKBdV8G8CHyIjFAr+7e7SZoySJ7o0TQPnIPyMw26/u7rbBwa6FGVILvLsdIfbsYKauTU07pkOJDZtBzDswYuyZJ/M7NmW2fzylSVle0rJmChl2Ozf2KQlCFgPSQmQEO1j55D3Syy8CilQ5sGE1ZjAmQ6AF3+Kq0d++epR074xYyVlkxHiSw7M3MiQknqDv/2Q/KVVI3hJbOJddAQj8uu8HeHFu0Pa78KEpRREE5e1Yq3IlzVT+PgmqjZORtgUIBlh8oa/2IPH2bo8u12b9zAC3pXfjbUgMvXa9CFcxowYXEHW7hx1iVWFYQYb6qkbu/B5Yjf0quMpMMtID4VsVwS42+HmylAQfjfrBeZAji8immk8A+TxGc5yPtaR5vSGJV5SfaLcuxoidLZLBk+GYVjV/eqkgaQnOJ/o9Jv7jaieBK1jWGl1rq6/gZXZ4SPHWe81QrV3LS+T7J3Jpinlsp7BRzISweUV45TV0WHYcZ9UcmJ4e1Vpm+CDdxIzNfDB0cjitdnM+nKOHHHEoZtf8I7yj5hM9TwEWkGA1PqE3uQjtXIhbRGupj7S9qKARFNe0hYEdg0gN0v6YO0YoqhkyilqecIG/Ahpg== 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)(23010399003)(36860700016)(1800799024)(82310400026)(10067099003)(11063799006)(56012099006)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9LYy2tgh7DoGAsoIOWnSBMxnNOaANyEHGG99yY+5rfcCtQsjI6KtWnzgiitLebDj9Au5mS64OoJzLiIed9+OZ0CPWPXG4KnALBExA4k+1k3Y9L0oWGFE1uV0ZxFer06E5ZFL/c2NFsu7ya9TRfxBlmmhw31NZltGXfJ7d88I6g60q76JpnXzxHnfQcwkeUsuocCntZqKSEIQd0oaVZ7dOvYsvGSz8IECvvdWhlpl2XX3pAY+HvsQQaUXWWsLBvdsazXj22MCuC5wVgv6qyrUgDNmnehim9lpsO4hMyI6YIqato3cwmzL5AYBtWdfgLjhJ1qe/LFRUoRlpvl8hcGIVHoRF9U4fGAhSxwfKhcd/wgNmgpcnPiT/1P40LocsTtCx1nelr4KpUZ8bqvdK+bXiOUbDKmyOgJUBWBInJflWzpEPdnNj+fLYI9R3GFo5Qs0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2026 23:56:45.5778 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5841868-adc5-4ba9-585d-08df1e855178 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: BN2PEPF0000A88F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS2PR12MB432622 Received-SPF: permerror client-ip=2a01:111:f403:c10d::3; envelope-from=Michael.Roth@amd.com; helo=SN4PR0501CU005.outbound.protection.outlook.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.341, 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: 1790726226980158500 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 Thu Oct 1 05:47:20 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=1790726205; cv=pass; d=zohomail.com; s=zohoarc; b=iHU1FY6qTmoR6mai259RvJ0WULCE1t4rblaivPjuWcWwn/T1TCHqd8LF+mM4P3skTnkOutaETNNBQb92LlKwy2u2lBH/SiDqKezD91Q934L5f1HLj8/TdrBKpCEibo/yXaHl94759rOxtYsVR0NBGQ9kShFxIX7PEkfd/hdRQx0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790726205; 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=DVrMPLDZACtV/32rOjX5vyTHEp/GrVlFxcBUd9KEOv5SgkJeOPk5tdQjHJk27UcjzglA7xwhEigNxdNbE2g9xSBSrQBYe00mLsS64Uo8zDTaHy5eII7wZPkgZ3QimyhjreQmkNGPi058LWToTObaToNZ24EiKBrCgYJKFAgPdu8= 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 17907262056011012.0104793091433; Tue, 29 Sep 2026 16:56:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBhgf-0000cZ-Um; Tue, 29 Sep 2026 19:56:41 -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 1xBhge-0000YO-6T for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:56:40 -0400 Received: from mail-eastus2azon11011056.outbound.protection.outlook.com ([52.101.57.56] helo=BN8PR05CU002.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 1xBhgc-00087x-6i for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:56:39 -0400 Received: from SJ0PR03CA0155.namprd03.prod.outlook.com (2603:10b6:a03:338::10) by IA4PR12MB9787.namprd12.prod.outlook.com (2603:10b6:208:54d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.26; Tue, 29 Sep 2026 23:51:31 +0000 Received: from SJ1PEPF000037A5.namprd04.prod.outlook.com (2603:10b6:a03:338:cafe::66) by SJ0PR03CA0155.outlook.office365.com (2603:10b6:a03:338::10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.406.7 via Frontend Transport; Tue, 29 Sep 2026 23:51:31 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by SJ1PEPF000037A5.mail.protection.outlook.com (10.167.244.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.14 via Frontend Transport; Tue, 29 Sep 2026 23:51:31 +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; Tue, 29 Sep 2026 18:51:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BwquXSIuKt3ZfYsZNz2yq5ERlYxF7ZCftWKY1OKALKFUs8kbPGzSnpf9LpyMppUGg4EuUgy0Nqu1UyBzMjH/v2LLTjXXqj7YKaBG+v12x9kZAeOniKFGw3RTRMuOOwVNiCznU3BxmLJMWxNrJMWFbPcyirR/fSKqSB9x9ZWvHWoZ6ZpZ/OS/bRQ90iQVgWjJ3USbha4iYw/7hkkKFAkIdRZ6wVFsxTTK050syPUAGKtsTcdEHXaeuMcl+1Dw/hOKj9omtiHpStKib6Myx/49z1U/mDYpmD4IVbbRA4hvDGY/3OVQre9MX0y2RQ09hPwzjNuRsiiw0RfaG6YGwEugrA== 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=Ju+3gbTgryxlItbhLkwmmT4A1uar0o2z/eGdi8hcX+H8kzv4PitpFX66BTKTFeTKRoAn2TgmH2HS3aAj8ylnydz6LH991QWMvthkqOU5DOBwwt5LN94TyE3d4sDaUSd8ZVCutvgqu9Hp//aLWIA5lsBzXbFYqsNo/2rtC5O5kGHBkwQpXIyHG92e4eSCI7kaMK0jYblAmeeOYo+B9TkL9qjHyn23/T1LKHleVeb3vX9+ZJibkXLjZu/Op1tdoYBIH/NYG0HCS9pBMjFRIai79zhK8cNRMLRMQIx5nR4DoVyqo2GT0Cx8N8F+8GSBYvRM+bQlBZKl2zsN6iA6HttK2A== 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=WsitBd4xI3jzfnClZnRc0YGiy8wXjg+ePo9haS6xfS+Nyd54ZDwS8dwSFoxRdgYwKJctqEp/blha7sAbf+UDfDv+RJ5laYv+/RgMeukjAlgSAWOR37y8V9caZMXzrIOVEiW8eNw1UjeLbqAAMlphXH8xvOIpBq2rG9T24/CJu8g= 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: , , , , , , , Peter Xu Subject: [PATCH v7 07/12] hostmem: Rename guest_memfd to guest_memfd_private Date: Tue, 29 Sep 2026 18:50:13 -0500 Message-ID: <20260929235109.1398509-8-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260929235109.1398509-1-michael.roth@amd.com> References: <20260929235109.1398509-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000037A5:EE_|IA4PR12MB9787:EE_ X-MS-Office365-Filtering-Correlation-Id: 40a28baa-c8c5-4084-9f2a-08df1e849641 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|82310400026|1800799024|36860700016|376014|11063799006|56012099006|10067099003|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: ovd3U4rdsePG3c1sOkeIJKiNFRgCmN/L1Cm7Z2iaXSqiZXSttgsM0cBzpKZEzg5rlEH2ahv3sYbIYL7lg5JvRUXDzQR1BuRjX3RIj8Z0WzQCC/dYzX/bAj8hUjyNFG+EntTAlq8vUEj6g4NfmWw6H+pTVR3sQ51IESgwvI6o0fJKlfxkNifdFebhW9Wf66trW4pATVQycpDIjRce11pGNBFHG+U2FfxM/TIrsBGDgEo4G50KaUHqS6/5gPk3C1ALKtYOxPHmKz+nj7kVWMgwgc7zRstzAjir6eHGIpi4MMrwKcYQWpewXWcIQwFQeN4vhekDmIxzfCxzKYUFNhVq0RrPpDOGp99USNOB5wH0O9dc738UeXCGs+MeVlgh+slplG7THS5bwJzPYqAy+3DPYVkiL9wYRJUu3eeyxsVQxR5upoTgXYu29uWO2RJbbM34EdJsN4GzByLnsw0bPsSyn1oma1ZzV6xBJxX7oC6rbAFVnSYCAWaVjS7IqnRbAku0/QgcvwZKXjN4uvknyY5fxxCweB14EmytcX+QSHjlIcWBIKimas3HglL1C5UF3yWQatdLEdj4AVaqA0qg5oMW2OfquNTMuQ9BnyDtTVOoRtlsZlaeRmKUYN9EqCTDERj0lnGSJKZO0DRsR8FtEB2OMIDUGdu1viozLf9xOjdGL9gKiGuGhDzCL3GLxyM2YIPLcRa10mYJ9BF1kvP/RXCaEg== 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)(1800799024)(36860700016)(376014)(11063799006)(56012099006)(10067099003)(6133799003)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KbaQj7MXedSiirvDFmxC41bBSFtXHfiYe4wSf66zD9RHcQs+QM/eJisXnLSvFCSTwmtrzSO5SQ5JU+W8Z4qkh9rSi0t0jRd9rdGWY9GA+lzsiFCC7wdU4FZhfVwMYqCSzp+U08TmfwyIwve846i1i3dOKMWh5vbaoqv2q9lzbbTxad+NTLPqCffjFv0Aq1BHMy+2M36hNFQhUxfndg2hRWmPzkIVS8ET5v1upyI7Pll8gljolaXsJFGWgGpmQ6r8wptgf+C8glmwVODay0QTs76cJWpIf8FPYD8BOInLZISKxiCxP+TFQq8tLIqjgFI/Sc2rj2Ol2ykULEGTfwClDixs07yU2iPIxtCZvTTJaAqib4N499eXFf88t9JtGzfkXzuedutrCFFG4LhrzYrsU1oiZryNfk5B/5UACk11vfMjB6Tg5YVxL6Jg5U2BdsuE X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2026 23:51:31.4016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 40a28baa-c8c5-4084-9f2a-08df1e849641 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: SJ1PEPF000037A5.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA4PR12MB9787 Received-SPF: permerror client-ip=52.101.57.56; envelope-from=Michael.Roth@amd.com; helo=BN8PR05CU002.outbound.protection.outlook.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.341, 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: 1790726206923158500 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 Thu Oct 1 05:47:20 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=1790725936; cv=pass; d=zohomail.com; s=zohoarc; b=ELC+fOhwMmn7z8oiiht80XHGT6SfgdqBFLTgR87m5J8SRbI2ua/pvFHbdxr79ojDdBleUqVA+LSe4wxzq/7IHyuNeYfaHrAzQjliayFST3t355QQsOddAL5cNd0Zcop4qFu6PEk3s3ETP/dukyKw2INQ/Q3tH1BIbZdFIr0OyHc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790725936; 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=BgrKoC+xhjyQ+OcHZp4FAiTsvqB2tRDZZG49quUv7N6jfbci5Y87JNwDIZZgOVzymgMI8bg6t/7Gb4p3nQID2LHcF6PEsA939pqv4xXEKPut6V/5qIv3Y5Cbjcs300PCWhGDsppaFkb6Jeg5EdB7Uczn5kFb84BMlPYhO+dO3QU= 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 1790725936335162.47921777747626; Tue, 29 Sep 2026 16:52:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBhcC-0004ac-1g; Tue, 29 Sep 2026 19:52:04 -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 1xBhc9-0004aK-Ed for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:52:01 -0400 Received: from mail-northcentralusazlp170100001.outbound.protection.outlook.com ([2a01:111:f403:c105::1] helo=CH1PR05CU001.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 1xBhc7-0007bv-1Q for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:52:01 -0400 Received: from SJ0PR13CA0212.namprd13.prod.outlook.com (2603:10b6:a03:2c1::7) by IA0PR12MB7532.namprd12.prod.outlook.com (2603:10b6:208:43e::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.24; Tue, 29 Sep 2026 23:51:52 +0000 Received: from SJ1PEPF000037A2.namprd04.prod.outlook.com (2603:10b6:a03:2c1:cafe::35) by SJ0PR13CA0212.outlook.office365.com (2603:10b6:a03:2c1::7) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.472.14 via Frontend Transport; Tue, 29 Sep 2026 23:51:52 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by SJ1PEPF000037A2.mail.protection.outlook.com (10.167.244.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.14 via Frontend Transport; Tue, 29 Sep 2026 23:51:52 +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; Tue, 29 Sep 2026 18:51:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fS3+LI71B0s0uaekGDjbnItoo7WOSu3cGENifWJI6Nno6CxhkheF7ONnNQs6Ryv709d9xNqgekbFgjqE1A2Kt6/c8R0TanmuJCYDYUzA74FXnw2G0D2kMeGFNVCct6UlNojjPDKu72IoWdFxv0OayNSWmUGTEyGpX1HnqXpAGRWmJ5dxxLjVO2UViAsGmchDzqTxDtTzMCNfq6L1t/nI3lHT35Q+yEi7xnxej4Est0WsgktCsSVL1wzg8gPagJMybWb5mOBmDQVdbp9hTHfpnSYb98N3tVLye/2Qw0G1RoO5hH1WIXO2O2ubGdd8ajT2xqw3A7QNokM2fHbJTq7QNg== 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=fXHolTqqrHUL5PRfE6CBOQXpq+g0Qyrlk6HPzJbm1JkpZoaumDGKVLrbrX1g4xVjs8wvxWxNdlzzSnAY5EnzI8V2Y5LkQU6e6a3FzInQ88gByfTpjB4ZpzNC9Tbk1tvrCMMxpxgQaHnEv6H8mm/WkKm/B2NHqprvdxrbHQFNEiq4avXkLSEmUUcdG96+ekiM8Y56N0/5kevqzLYw5orQj1zuXrljtpNvtSLYqBnQQFPxy5nVV4k0nIerx3qzC13C7tadit3sBMrFDQFKvS2WcOQ1JK+pbT3My34ju/+jIsZP4Igm1WNU5aSRfP5LmTY1y1bWEvLjFcD6lqv5CNGsFg== 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=XmGQfux3m8Lr9bJW7J2ubxBiPmYDaUWGD7SsRkeFNWVo1ZATZjSSL1E834hZcNMnKK3S7j8+iUL7TFJa3ZIc8CWJN3LMRUK/X/ro5JLbDG4gmG0vI1DVm+QOCATkMPz8NFi2LaltuDdx5uOgdqW+1D2TODLgC980irjM1r77C9o= 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: , , , , , , , Peter Xu Subject: [PATCH v7 08/12] machine: Rename machine_require_guest_memfd() to *_private() Date: Tue, 29 Sep 2026 18:50:14 -0500 Message-ID: <20260929235109.1398509-9-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260929235109.1398509-1-michael.roth@amd.com> References: <20260929235109.1398509-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000037A2:EE_|IA0PR12MB7532:EE_ X-MS-Office365-Filtering-Correlation-Id: 990ae0c0-54d5-4bbb-8097-08df1e84a293 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|23010399003|376014|36860700016|10067099003|56012099006|11063799006|6133799003|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: 74JaJ7BYsj9gc/TWS0w3/JDdsjkI7VGBQGerO+mvRrzsQSXgP4sD54wHYE58Y8YpD67XN6XBMusjJMsgSdKxtKQG9IaIyIqtkMA5yOmkznXLiaVO7RNyvT87Kh4o9u5RNVzvyOMSU5iXW69WKY92dOX6Q1uSgsmGclqW8f0SDhixrl92/j1uXJ6zfW33IbVU6193L5kkwDI70MopzBfErtEXgKLVO65GhYlJ7dmfpM0zI/pq75EnyYjr7NtAr+MKNxwb/cRbZenhPIBU8snHBOW9R+mvH8TpDcdzrUAMR7gOZuaV9K7kerOSpRaAMJfQUCdidEiJh3vYBb4wl3gqxFU2YhUmyLF8r7jZ0f2LiauqtCIbdbwa74p97LXxGGLaHfIfR+KS+GcyXMeH1egDFA0XYp+G4V9v2BdX5G9GQwXrVBwDNj7tGRCibxCH7j+rJx3rcZo1iS3LmuH2mY/o7l3KmC1hK/IhNPD8u2v2+uUbt5OX1PR9IV3idGvsQ7h+s8AcNUmwPxyfAL8K4dQ9yoH4EC2Jq6s4C9v8i/73Y6eOPS2KGrLRhdKICgnZ2CkjcM1VO6llZbHhWt/nFp9YjVnGGmz0C7AjrAFlxdOFhM9BHZGn75LVJLBWkn0gK/lsAFX4BgLTyAgLJah10GiDRGBegDjDLiNgRVTOjQMnK9qVo8lounccTuVLUnVwKhN9+s40yQ2+ZpszcrXcwQ/eYw== 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)(23010399003)(376014)(36860700016)(10067099003)(56012099006)(11063799006)(6133799003)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9n9YqmvUe7inbGitUbDuYWzfYtm69TZ4swiuwczPQqrs+5dd47yOGQbgFluapyPVNKrzNyC3Mwuz/O6CDorB8M4CYx9gjKMTcv3mrn73QILj4XTa7MxC57AXnlIR64b5GrdOvcC+3CRFdA5l1fts8Li6OioNicQgot23QaIiXeqR+O0ikYgvN7RB22hlylMUNiQbi6aD0IYLkFExBixBgT1NjAH2z+vw3jSviAg22t+a4JiCfdJVtr/ByxmsVTiIXmCDhiuEAw7wSdVTG0lE6O3BEZ+hlYs2QKRrnD3dG+cE9KdC+VloNn6vVCqEHnRZzQld7LvjYrtD/KPWoFGMfgEnDb4Zq155JGaRHUPszVt+p+LM0Arobe6utY0mJRmcSBdRv7o5EOti0ly8kgXo/d5bRkcAi51958kCjZlHuYW5ehef2mlecpWVcDCltRK6 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2026 23:51:52.0715 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 990ae0c0-54d5-4bbb-8097-08df1e84a293 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: SJ1PEPF000037A2.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7532 Received-SPF: permerror client-ip=2a01:111:f403:c105::1; envelope-from=Michael.Roth@amd.com; helo=CH1PR05CU001.outbound.protection.outlook.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.341, 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: 1790725938252158500 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 Thu Oct 1 05:47:20 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=1790725981; cv=pass; d=zohomail.com; s=zohoarc; b=Ij76YxK7j5BJTHSDsQuCqk0wDvQNRgnrcpjJ9cutG9iNc+Zb8zVmIG+zwuKRl0Wmdwyo2UKqswRFxxr9qHRP/6+D4fxFiPqCxQDlT/VeHMaNqov0AlQb0DnNKdet4gEsBqqlHaqvsglboHvu463Y2JM0M79nrZ6b15BURYfRjGE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790725981; 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=Po7e5wP8RZ/WC23fMjPjof0IiYbe0AmBO3PkVreDbJlpF/XwHIh0CMGZo4v0GZcF1sRCKw0u+Ui6NlLS/hcDMhr5tQ4FjQezdpa4RGdKUEkE6RF2l0kmP5vGTQJrZ1H/fAUzqbIrTS9eGMF34meeNZ86FvEvQ1KB5s6AEYLWMz4= 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 1790725981363919.7324619858529; Tue, 29 Sep 2026 16:53:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBhd2-0004uk-Si; Tue, 29 Sep 2026 19:52:57 -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 1xBhd0-0004uY-KL for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:52:54 -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 1xBhcy-0007dL-Ih for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:52:54 -0400 Received: from SJ0P220CA0028.NAMP220.PROD.OUTLOOK.COM (2603:10b6:a03:41b::11) by SA1PR12MB7102.namprd12.prod.outlook.com (2603:10b6:806:29f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.18; Tue, 29 Sep 2026 23:52:44 +0000 Received: from SJ1PEPF000037A7.namprd04.prod.outlook.com (2603:10b6:a03:41b:cafe::59) by SJ0P220CA0028.outlook.office365.com (2603:10b6:a03:41b::11) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.472.15 via Frontend Transport; Tue, 29 Sep 2026 23:52:43 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by SJ1PEPF000037A7.mail.protection.outlook.com (10.167.244.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.14 via Frontend Transport; Tue, 29 Sep 2026 23:52:43 +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; Tue, 29 Sep 2026 18:52:42 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ajdjAxxCCLYiiUVfFQjiF65ntoZLJ0DjdeEnE4qekuWrQjvmDpK3Q69QqeQ3jfPha6I0tDBeFA9WpVk7AbidIDYVQyt8fQPWmSeQKSrJ/CPJ6nciJqQ52d7cthNC+CWFJS2F+GexrTLK7spuAZWE7e7DHnTq4l/zZgxT3orKlKkIxGMa6KJeFjbuLFcNcXFMe58Vm4uiMfRNQ0demem+Dpyg6FHOrj8+pxWTjG0EDQqKKaPMiwtJzQq0LKppFQCDKitK9Be7To3q/CTY6rkX+hKo4e3Jibr/wnZdQip33EZsZOwaVY/B6IIa1AB4uNqFJ/7TcLYSNq4g8pEpGNU23Q== 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=hWXBvzYTzcb9sisR414gDCdF53qK1eix3l2OBQfuApu6ad1A8RY/Sp0JMz3rR2A59vViK0fGaQKU9H1QVl1bE/JvDciLa5xfpeTjo47emw6trS//r+d9x3b+J0QrTGuPO+16sk0n/mN5XPeTVlW/ul2n3GmKeHoZu/528Wod1rfQ39VZt0W1pqf5gpVQfuq9z+SHgvhhpeOmBbVil8VQtojwmofHSEZy2Hjf826tHfML74BP3//wMFMCuuFcVgo192ul2qoOGszNp8IKUPneB2wUOtq1UR41sngeiVxxzgxg9lGUPkGJR9F/Brix7SvUYynEgvgZc8cDm5JhHWXK2A== 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=uQ2WvJf0Pj+kTh7jiXyPsly1b+s2LDx2wrd8Xf3L08SQL8s11u9JgN4Qa+daj+6JKNFbJD9Ax+tp/gLR5Nbo/e1fwWyf/kZEvnvXug7GrrbtZaIw1RIr2JkPYmVt3tELYdRvRDY28y3wM0U7i8fuWl4ssUK8p6J9LqEB+1wfPYw= 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: , , , , , , , Peter Xu Subject: [PATCH v7 09/12] memory: Rename memory_region_init_ram_guest_memfd() to *_private() Date: Tue, 29 Sep 2026 18:50:15 -0500 Message-ID: <20260929235109.1398509-10-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260929235109.1398509-1-michael.roth@amd.com> References: <20260929235109.1398509-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000037A7:EE_|SA1PR12MB7102:EE_ X-MS-Office365-Filtering-Correlation-Id: e85c209e-f644-481f-3d04-08df1e84c139 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|23010399003|36860700016|376014|22082099003|18002099003|11063799006|56012099006|10067099003; X-Microsoft-Antispam-Message-Info: LfzMgt8LkdHw/f/PTOyrg+eUNob76Y+Le/QX5Px2O/zpSeGY2yl27StjwfakcsrQbVZNRZ3xszv2LXg3cXVszx/HFHZ3G3d7xLfvlgEqnmNZTORBPw6z0YUkAo78G2YA6Ffzf1CAMvQ/S9xDUD+B5j/li5Yr4/nwY4baHe0TnQ9k0BgyL8ZW++J2Roj9k7PEpwGDJGeKgxapZlNAIXIri2brJARy8wQLI4vh0BjayTE9MmsjBYdsz/hDpHctyAFnATelVIEQMbQjOFzdOD90hh6MuqgtZh6DI7F+5xPgYaStmHLrL2Pbnp835vzHJ8V3bdgPyp98FfOp9uoLKRoQSrLojkBoExwk3oCAefEg1xL4rbqK4JZ/262fHiwU9l18yUyXrGN1Ap099Qzlhs2bPFuxde0VFuA5AQ7x0HJZeSvLlbVoNRsgr2uoCiI5kTr/r5Oi8f4slZEV0RnsQY1WToxSHTdamE1/3cki9+snfFaeJ43aMBeJYuaQopISHr2vk8m8vsY6xlLf+JCedqrD9DGzzGrZLU8Eyzo3vmaXn8Qg+/oQRuYPPRWSBAmCSp2hxhofu7W/t+T1dhKDxYEkWUBD7K9IHpIw04PX51oOr+30Myml2zzqkvWHcLijlEy3hfE37pDiSu6XOUE7jnhlN7Rl5Rw5ifIxKW738/aMLYN4d2cULPT+B0hTg8CxIilQ2bp8IFOdmqZfSaSZUaGjBg== 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)(23010399003)(36860700016)(376014)(22082099003)(18002099003)(11063799006)(56012099006)(10067099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TEGf1tfDTx5EuSUOG0S4PZ8Cx7TWkFc5VU84ROeLGlZSvrL0/jyNjrZ6E9ptDh9uhzo5ltNURRIcFNA/VbMxBEtR3VYdm0CHWLAlfV6cSVeJ390NMwdmdp4F5onxmD1/HADLozahY/zznthZgs8OGw3wnNxBTL7ET03WDnClOyt7mceSGVYuf9RbK5kLUcGkaixQ/GcV0ba86++OkSHod/FJfrOaud+/NqNdn9HFw5NrWhNwIL2ZCAqroSjAF7croJeNxQBri4qsJb3RryeF+gwrYEizmIFFllLuFGD9BSmNqwmeCV/KL+8QnGMO4RoSPz1VtUtXIX4bDYW2s9UOkVPsJNItrnX9m1sYRUnttESLKgxW+LMYLjudiN/eGcGGA0/c89FQ5mqkoafGivQ7BMWCZA0W1F9W31PCFTYHNQovmTgul9XqVjyXxegrJyGo X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2026 23:52:43.4903 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e85c209e-f644-481f-3d04-08df1e84c139 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: SJ1PEPF000037A7.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB7102 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.341, 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: 1790725984029158500 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 Thu Oct 1 05:47:20 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=1790726017; cv=pass; d=zohomail.com; s=zohoarc; b=bu7ZHHhbdWL9JKvKhz41EvdT5Qylj+sS68IOpJmqoOGNifwAQK8DnmJLOPQ3Hin8ybsRuvfNzSzyl3FvugF3AuZSdfLjokEpJefe0iyhP/Ip6D092QuNmJtN9oljDd2U8RgiI0gH95wE9Uvse9vnUYHsylP85T1fE6xtf5D3SFw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790726017; 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=G4kdaKObGew8ua62Lt38EVBF5GfExmZn+AzbPJ6q/WA=; b=XgG1dw1eaX6whe5JiYg92su1Otxl85m+rolCXxH3xRs+k5IPKgNyPv/+UTtG8x8ZBVBZSgwOO4iBitWUDtGKE2qP5P/TcMO/NaOkFMo6VvXttj8Nd4FqULU+A3Av7dWJL6uZsyO2eYLgBvAIvmk/Ijaks01Dom21uedaPNn8+24= 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 17907260177141014.1477200268109; Tue, 29 Sep 2026 16:53:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBhdS-0005F0-Ay; Tue, 29 Sep 2026 19:53:22 -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 1xBhdR-0005Ed-2T for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:53:21 -0400 Received: from mail-westusazlp170120002.outbound.protection.outlook.com ([2a01:111:f403:c001::2] helo=SJ2PR03CU001.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 1xBhdO-0007fj-5Z for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:53:20 -0400 Received: from SJ0PR03CA0204.namprd03.prod.outlook.com (2603:10b6:a03:2ef::29) by DS0PR12MB8814.namprd12.prod.outlook.com (2603:10b6:8:14e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.26; Tue, 29 Sep 2026 23:53:09 +0000 Received: from SJ1PEPF000037A1.namprd04.prod.outlook.com (2603:10b6:a03:2ef:cafe::52) by SJ0PR03CA0204.outlook.office365.com (2603:10b6:a03:2ef::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.24 via Frontend Transport; Tue, 29 Sep 2026 23:53:09 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by SJ1PEPF000037A1.mail.protection.outlook.com (10.167.244.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.14 via Frontend Transport; Tue, 29 Sep 2026 23:53:09 +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; Tue, 29 Sep 2026 18:53:08 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=SpOF7zHoMvpEQ3ztH3101q4sZT4MKEUt1LzDoKvaYLYuQQrz4ziRq8tch/OF/XCWY2xKEIOugwV0dNmeS9V0neXMm1MXs89ZEQeuG6javsNKVLCrnkr5UXS0JT0ByQAW0VsBAjlW6yLI77i9jLXyAU2yH+toEnEjXcyzWDswt9vvirKuCSkZpLIyyOYgFLXwvcvWbydVoZnhYxI/kviZjRgGYK0hL4KZCMyXCC7KsN+x593cIcS0rARQ+KWZa6woaCtgi/RUKsDIe0cJ9V55CxafU+61ZhPjcV+oMsqBB+mh34g0Tk5Hd+o/6WCisomnowd1GrnGI5kkHz+GEnI5Ew== 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=G4kdaKObGew8ua62Lt38EVBF5GfExmZn+AzbPJ6q/WA=; b=PXdDYZ2fjTYB7Vb9sNTlZxFp28iIRQoD9jkiYL5nygvzbEOxCecamvAyIsiaf9MNk494EcZ5aCLqLSkqIdd3/w/vBKN4qCycZWaIChmrrhN1mlleCOghiDP+Zt2Ifr+WRyFAR6n0euZNkqtnl5EbecewlvrmZ4ATY49+mivpSMfB1VOzGXwUDONS09uaYDoIrv0HsZjLUJYp7i08qvlwBZpe5EWPT8VBCN6Hu/ckBqCtpYl8xfws6w6jnz9ol9C+RYrWAsK3AbKy18IS+MmVp87n0i8t8ZxZCgPCNxzKk/V9vufjEPtQVSniTLRbJpNrrEBb3YCMvhITdr9HWhz1zw== 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=G4kdaKObGew8ua62Lt38EVBF5GfExmZn+AzbPJ6q/WA=; b=cXstdoiYqv4/qDpCug/reTl/Ps9qQWhTCYyvL2rK9PBGjVnLeAU2rAmb6CP19+1wv+w7dT7971mNSdyUnoleRUpRaMKxOakty2v4xzToD3YUXoqsXNQf0JSo0YlNsovFlvDifrx1ic28zQqSbDiyGqQwcoYFFRAvMts4WN6R/lw= 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: , , , , , , , Peter Xu , Fabiano Rosas Subject: [PATCH v7 10/12] hostmem: Support fully shared guest memfd to back a VM Date: Tue, 29 Sep 2026 18:50:16 -0500 Message-ID: <20260929235109.1398509-11-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260929235109.1398509-1-michael.roth@amd.com> References: <20260929235109.1398509-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000037A1:EE_|DS0PR12MB8814:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c3d3e9e-f68e-42a5-c380-08df1e84d08a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700016|82310400026|23010399003|10067099003|56012099006|6133799003|18002099003|22082099003|260925021311599003|260925021911599003|260925022911599003|11063799006; X-Microsoft-Antispam-Message-Info: pD0c5hjRZgIrOg1WGNa+8Yhekq1yG/a1T8DTd/eZBpvKOOovZPl366xhI/o845DPHA8FPKpAPEuybqqff8iScUQnesx7N6h6SCn4ujBd6vaHY9eZ4pb152RfVMqrD8p91XCzidhDx67ePTbtZiwslT9XJGsh6nH104g8x7AqXVQuOoSe7r/oegaXMU3ZjtG8UzkzLwpEzzJaLlrfBejEkwtckDfEJ4Fk7WOFfCSk6HydOjbfmJ/yMIq1ojI6WkpIzJekhD4wM4QgFhxT2EVEKPN0X0581kU8wamJWSQg6kD6D6m7trPECgwFt/7/XlbQe62oWRzWFxyCnOCkHE6iplzhCQPKrTMTlqt/A9q114WZEuB8IKCxpYJ2OnGT9NPC0wKwY71G6g2Oy2/z5BO2N0AZIWj70qP3+CJzLoS99g+6OfZZIpDI6Jq2Nbmn1M8t8PHUlJdnZCUKJUBv0IiuckQQfZ88S1vFpi75v8CP2gM4xST9PCJ1DXz8IeXbxTX8et4d2ArWa0b2jrdgX7CTZanFR9ix/P1Ly4cOgosqGIyAhgCIMGhJyMALoemjbukDYXNgwH1qKS2Nsvq+mPCr3bS58H5YEZ8WS5sSsg99lQFSv7SCbFjwAuGSXCI21ok9LL9iv7KGOaIjqkRqSTC9HCyVe1XBkBlV37djjePTTnnWa247gD03Yy6x3Sgq/R/9TbtQp+RvuQ8MOe3UJhh8jA== 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)(36860700016)(82310400026)(23010399003)(10067099003)(56012099006)(6133799003)(18002099003)(22082099003)(260925021311599003)(260925021911599003)(260925022911599003)(11063799006); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: u8+y4bwSN5HpT9ddi9E8xWTM0SDbc30KnSrQUnKwSqJeGPBuB6BebV/GalWsx8cGZG2koU4iuF67GYmJesLWFXYsmqIp0HDzEQpL9TFeHCyFBTc+fbalawdRyVvPyVr11Z7//FFJ122hl+HDO7FpWkgXpd2LzaKYV+uajdV6zqsoqK0r3pQ1seWNE4TMr9TmUcxXY/NpN7yF/3c0K9dUHo2hH1Pug7rSNUj75tx5iKXziwyTwRFTsiKCzt/Rtuh5XiJvkBFJ3ByB0Zugy6qwBjtriwqadgt6uS8AudIgeVuontVkslsQfwMlotHP1BoGPq13uEM+ClF7GgB0rBlRMqQLzopeg9nT8ubzKSiRMDpo0dnrRPeQqvuhBFoyBCbfF34A7ceWMTCzoFiWCantXaCO28jm5U1qfrp9aoKdgASzMgakI0kEvgG8wRQ5h7JS X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2026 23:53:09.1902 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c3d3e9e-f68e-42a5-c380-08df1e84d08a 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: SJ1PEPF000037A1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8814 Received-SPF: permerror client-ip=2a01:111:f403:c001::2; envelope-from=Michael.Roth@amd.com; helo=SJ2PR03CU001.outbound.protection.outlook.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.341, 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: 1790726020271158500 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 Acked-by: Markus Armbruster --- 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 | 15 ++++- 5 files changed, 139 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..666593ff6c 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: guest-memfd ignores seal=3Don/off because it always + * implicitly seals the FD by definition. + */ + if (!backend->share) { + error_setg(errp, "guest-memfd=3Don must be used with share=3Do= n"); + return false; + } else if (m->hugetlb) { + error_setg(errp, "guest-memfd=3Don doesn't support hugetlb=3Do= n"); + 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, "guest-memfd", "OnOffAuto", + memfd_backend_get_guest_memfd, + memfd_backend_set_guest_memfd, NULL, NULL); + object_class_property_set_description(oc, "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..d62a214a91 --- /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 'guest-memfd=3Don' option. E.g.:: + + qemu ... \ + -object memory-backend-memfd,id=3DID,size=3DSIZE,share=3Don,guest-me= mfd=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..b61bfdf386 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -780,13 +780,26 @@ # @seal: if true, create a sealed-file, which will block further # resizing of the memory (default: true) # +# @guest-memfd: if 'on', use guest-memfd to back the memory region. +# See the :doc:`/system/guest-memfd` documentation for more +# details. If 'auto', the option will default to 'off' +# currently, but in the future it may result in the option being +# set to 'on' for QEMU configurations that explicitly require it. +# (default: auto, since: 11.2) +# +# Features: +# +# @unstable: Member @guest-memfd is experimental. +# # Since: 2.12 ## { 'struct': 'MemoryBackendMemfdProperties', 'base': 'MemoryBackendProperties', 'data': { '*hugetlb': 'bool', '*hugetlbsize': 'size', - '*seal': 'bool' }, + '*seal': 'bool', + '*guest-memfd': { 'type': 'OnOffAuto', + 'features': [ 'unstable' ] } }, 'if': 'CONFIG_LINUX' } =20 ## --=20 2.43.0 From nobody Thu Oct 1 05:47:20 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=1790726031; cv=pass; d=zohomail.com; s=zohoarc; b=XXZq9s45b3REct6cUS+b3L4NCmAMxQIJOqf4nzOlDQWck0zN65Hz2/jEo/Y1SFPDMuPbnm+e2ZNyZW6tc33W+ADbWNsEjPKzmbIwgrOJ2ipDJUUENGQJmi66ONioXnGcnhz0UFeqoAqzdMKNdqOnVDBNWufdBmakaFKak6sGb7k= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790726031; 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=5P5HWQNB0J3KbNCbUQKTE8hkk3j6uhxgHWRLYGcvbiM=; b=Gxu9ZBKS4M2RFs7gXPhIHGjeYxap0WEUqdUigPs3rhOgqB0lH+LhEK0ilQeuEXgYJ7LaCe+KN44waiZ2FnVuJI1M0GQkLR+JxLtw5oltoe1vPU7adcfjnjERppzJem/SilBaj5tcjE3+nYdsm0+sxmObosXF0JEBxSi51Tx+X88= 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 1790726031751727.6064252382793; Tue, 29 Sep 2026 16:53:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBhds-0005bc-1o; Tue, 29 Sep 2026 19:53:48 -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 1xBhdk-0005YZ-Td for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:53:43 -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 1xBhdi-0007gq-VN for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:53:40 -0400 Received: from SJ0PR13CA0218.namprd13.prod.outlook.com (2603:10b6:a03:2c1::13) by MN6PR12MB8514.namprd12.prod.outlook.com (2603:10b6:208:474::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.24; Tue, 29 Sep 2026 23:53:32 +0000 Received: from SJ1PEPF000037A2.namprd04.prod.outlook.com (2603:10b6:a03:2c1:cafe::68) by SJ0PR13CA0218.outlook.office365.com (2603:10b6:a03:2c1::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.472.15 via Frontend Transport; Tue, 29 Sep 2026 23:53:31 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by SJ1PEPF000037A2.mail.protection.outlook.com (10.167.244.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.14 via Frontend Transport; Tue, 29 Sep 2026 23:53:31 +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; Tue, 29 Sep 2026 18:53:28 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=K1zp8DmrWLwPuukffnBbXbzAI0UquRs8kEFNXmpeEtfDRo2rct8d8L8vYXh6yO1aHa5QaaYkaVro809akmP2XweTFb4VWknUCU0wehXhnuTXMY52zb2tyHAEw1Y/U/PuOR1q4xhwpxFgmrv08Pao8C+hEENIXV5QapeO5iN0nhIpNCsXARrqH2/sFMg/v2PzlscstGLIC8p2Enx4WbaLl9Y3OBj+JpK3Z1SS5VR5597xh6KpYrQOv0EeeTfS8hE9m1/f9v6W7ltk/qEqg0ICUP+Vs0TNW7fKCy4+78bZGNEKx8oZbhPtE9fKbysZzqKh7Gd8/jbOGqLVGrBdYgb85Q== 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=5P5HWQNB0J3KbNCbUQKTE8hkk3j6uhxgHWRLYGcvbiM=; b=HFXmDw3mC2oinORBwrurgCNOG0l3hLTRKOqjbf59C8ufJX2EtD0r6Q+f5JuPOtNQRJlngIQEZai6h0YuTe8xXTC8uvNwBww1BEsVD5+bswNx0Lq38rFeH86u3Da6I55L/X9rxR214T8uDYxh8jWFYpkbe/luwGA1YfsZ4v1WfVdkR6G+kp9DXpj//NZro2RIs4Rj9rQJTYurkr5TKKZyeTyjYJEf/HHl3ryAD2aFK09SvKI6T7p6A3ak3lqQRUiMbRJw3u+d5LPjX24Yf4ZVSNQ3vcZcxyrzw2vH70lGZjQn8Sh+BBxQQJtgAWi/CGotBwXA9pH53BH+Bl0CSbThuA== 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=5P5HWQNB0J3KbNCbUQKTE8hkk3j6uhxgHWRLYGcvbiM=; b=YD7mkToDc9i1s0UxUyvouAI4MYXszJqTgImcfgC/HxfMkeK1qimEKDDBDYDHH8/Szh7e+LfuLncAdBq5NojLKCyGLYvejDUVpWFtPMKYEiTCZQPaWIrm2PwpnIOd9z/sH0gjMTji9nvTHJL+siYh0KW/bfhh1Zh1ESznBqBKdq4= 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: , , , , , , , Peter Xu Subject: [PATCH v7 11/12] tests/migration-test: Support guest-memfd init shared mem type Date: Tue, 29 Sep 2026 18:50:17 -0500 Message-ID: <20260929235109.1398509-12-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260929235109.1398509-1-michael.roth@amd.com> References: <20260929235109.1398509-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ1PEPF000037A2:EE_|MN6PR12MB8514:EE_ X-MS-Office365-Filtering-Correlation-Id: 518d1b7f-bce9-443e-28a7-08df1e84de11 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|36860700016|1800799024|23010399003|10067099003|11063799006|56012099006|22082099003|18002099003; X-Microsoft-Antispam-Message-Info: qnmKh7phU3hA58rm37Jgs/YWo7vHSup9eCAH+ygdC25jgheGc9Sh00jCf7VJHlhqE8UC8VP5pAcvd8+Ui+WOy1bJAkw27GtQHubZsT2gD/Tgr3WMHXGRG2ojZZeNma8Nk0esCyU0IS+JU4xkf21oz54NhUYSw6YLcTMpcdlyt0YZUnvXAcgSvghWLa4lDgj6s4XvKByyQc9McI5TbWf9tcWzSzmrRBz5dfYXwszzZWtQ3jW/BgbJ3NwXLaN9s/N0xS4zYOjAvgLoqmGlhM0+IyTG7Cvr3uUIW+64PGh2rj0aQkjx8saP1mJP6OHEdtk1dnq8M7SgZ3VwCSmj1ps3qa1fSZ3cLQoD7B0NbNhcT2fT7Mxx+5hcARH/s32WZ3eXkJlbp5BUrKfhJg1q3n643mqpzchtxFCqq7Jah3F5msF2Lr85lhGRPVFA0lwc0E+iIyUzGgrdB2VZ8ET1UXlF3xyG47CHIv2RRwZvEe9VzoORrlUIQwV4TBNpT/o5SvWH+HYy29Gvq922PkL7iPqZWnuc+KCAgIp0hJ9/4+TQO1TZ16EoNK1G05kyFLKcQs2D38PfQ+ZIC0d+2Ssnzi8dZFOOf4U3EzY9upK7TojxM75A6enk/ZnGBKc1/NXE1FoJy3BpF1gVkinCqoNnR2d1hUCHbwdDUPFrPZiZZSrl9O2shuvIXSx9EkFMU/ooOSvVCqdBlhw23Whi0vmoyzPE9Q== 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)(376014)(36860700016)(1800799024)(23010399003)(10067099003)(11063799006)(56012099006)(22082099003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eQQZ2YjmbNM/a53g2Paa/gl7H8gkDQl+1hQWzK5uGWXPgnsVRLavETiMtzqFIE+w8wBoAsG2c5aM1XN2V9qhWNUduv+ZsRxJEgdl2uVI0nSeN5tK/yGKyQABTBWf77hKX0xSKg3lMXPp8iMRoWMO6WiEjUEppInyyW8EPFTWw5R48uV0uETusupR3wUTn6ZsWKlRLFJ8jpIRjDW4fzQPo4SF2vxFhMvP3VcHk70JUi7/WiN4QNw9cElzko6l0lJ8MvPbUgnbbbzAK9yyC73DoXBv9Evy2A+Ok+Pk89WlEwIC8Dk1yUo2ZJ9rxa/Xzz6de7Ni6zy7AK8aay3++c4kCnqL3zPfzL8b5puKdePeRAQcJnCEF8uyWv2OdX4vbQBUaS9/5NOD4hbgfXssl0MzQmHX6CK90gd/Pcciye/Z5TDXEY+GWxoDAckVxyyrp64N X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2026 23:53:31.8816 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 518d1b7f-bce9-443e-28a7-08df1e84de11 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: SJ1PEPF000037A2.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR12MB8514 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: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.341, 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: 1790726032536158500 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..b7aef6b21c 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,guest-memfd=3Do= n"); + 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 Thu Oct 1 05:47:20 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=1790726044; cv=pass; d=zohomail.com; s=zohoarc; b=jn4f5xQprW18XrwKvh0Rpmn51rEuHMmTstyAM9RYCGnfke8AMHT7ns7a/mqbyKbjUxKVp1dj0yetnFRh7t8sCGpbucGt9PlDpQESNT58XXOsR8v0baKwVdIVyBH8djfqIJhIUivbOEHz1CaLWNtiBSbWGzLNmJAZle16B7WDA68= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790726044; 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=H6laPABROrb7CV+UWNAil5v2W0f01CICFieorKATH8zSQOhOneY9+k8oaO/l/kE8KE01j4IhkbNsZKKhSBCCYmDQoewxJQ/77ELCWat1hYORcKaE1/A5iMD8Yp1HceI+zJhjlkkuhUxTvFcNB14WURYGInMrZVv23K7zwE0zTOU= 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 179072604488688.04907166825546; Tue, 29 Sep 2026 16:54:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBhe5-0005wV-9s; Tue, 29 Sep 2026 19:54:01 -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 1xBhe3-0005w0-PM for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:53:59 -0400 Received: from mail-westus3azlp170120001.outbound.protection.outlook.com ([2a01:111:f403:c107::1] helo=PH8PR06CU001.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 1xBhe2-0007i0-1m for qemu-devel@nongnu.org; Tue, 29 Sep 2026 19:53:59 -0400 Received: from BN9PR03CA0946.namprd03.prod.outlook.com (2603:10b6:408:108::21) by PH7PR12MB5618.namprd12.prod.outlook.com (2603:10b6:510:134::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.24; Tue, 29 Sep 2026 23:53:52 +0000 Received: from BN2PEPF0000A891.namprd04.prod.outlook.com (2603:10b6:408:108:cafe::1f) by BN9PR03CA0946.outlook.office365.com (2603:10b6:408:108::21) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.24 via Frontend Transport; Tue, 29 Sep 2026 23:53:52 +0000 Received: from satlexmb07.amd.com (165.204.84.17) by BN2PEPF0000A891.mail.protection.outlook.com (10.167.248.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.14 via Frontend Transport; Tue, 29 Sep 2026 23:53:52 +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; Tue, 29 Sep 2026 18:53:49 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d0eG/hUC8moz33MatSl3Z2/rYhrr06akzhVFig71i2iKjX1iSyKAgYghyxNNjPvXbDln/HGnfwQ15/Zcb7pLgt4MROki6a2mwP5j6y/RsBaI63YfxRj+nXmNAKRzhYN++8bADEqDmq07Vp1FRgYU0IzDotmgCLQ3r1rdvPgrrP9qLJvQMHcvgQdD/tSaYOztk0NO9vr5VWeeccXYhB4H8gCdkWs+OeFprmtHpsxnGgWdkKDaADbSIvWYl1FgUcDHKiCsArTh5pAkktkJeGy0Tc+0jPxmKC4utdEc/RM6EY7cJTRy19XbF619ZxMd4VbdKk6S6bMvW+O2EligFkKjsw== 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=ogoF9yWAH8taoD/TVAE65UORB6z1TVmiII5dyEyqTqxErJyRLjKFhR96qSS1Muy/A0eljBahO6vU/lRcF+9UwhrcFSxhTfaLAT8EwL4sDjjDJLVcDo6CDphwxUklq6ZgLUy5dxpKmv/esaV12UaJkWgqen9b5oRNkDip4aFnxPEw6qOlV+6ZUt/HFF+Mo9ZAmOz4x3ckTvCxbNiVCQ+lwdDV7ip90jyEskkgUOlto7glYwDY4YLJJBzO+cx6rsq1wLaE7AiTq7VmA36QbW83TUUzCJ3L6Em0ujZAxLVEZyPmJ1QO+w7IAJ1leKpDvYRxWJgl0dTEW2pNbqfYI56dLw== 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=cDv+J7V4wR3Lyqyub/Zh2ApokVeMimdD/hBiCbEQoggddGnrrLK8RmFGBfKtZ31fAJTDTWi0j/XjDfWBKE72KiUrpkA/VlTisz+jZa5qQWLotc5h7VUtlOIfz7Xnjd/lFUsci1yHY2X8STvuQmSgibruX7v+Cb/6H9Ts0SIvYu0= 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: , , , , , , , Peter Xu , Fabiano Rosas Subject: [PATCH v7 12/12] tests/migration-test: Add a precopy test for guest-memfd Date: Tue, 29 Sep 2026 18:50:18 -0500 Message-ID: <20260929235109.1398509-13-michael.roth@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260929235109.1398509-1-michael.roth@amd.com> References: <20260929235109.1398509-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF0000A891:EE_|PH7PR12MB5618:EE_ X-MS-Office365-Filtering-Correlation-Id: 9638c421-6c9f-4925-c4ea-08df1e84ea09 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|376014|82310400026|36860700016|1800799024|10067099003|11063799006|56012099006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: TfF0PCLuZIj1DdLkhJKaHhxr+L3mMJPk9kG/0woITnU/B9DHNIuEm8SRY1kGhbvSzDaTDgY/crd6P21Go5OVYIOlUO/+bNCss3CfiQc7O3CpZZqooOC7x3YGS+M4vehXXQDAbe+bFJG884ghbwBhV3dxmMS8nxdt9AviJqHfs5O3wmb5wK0c95w1UoUItjIsEGhoJpy8pdRF5vZL68fj7v8k10TEC0wLw2JzIeNRccXPn1pd7FT77x+kTVtoDsijUvX+LXhn+6Ce0vCllW0nDrzcAseufGEJ/dnf87rQpl6ScdP4Q0DcCtNsd2ux21Wb43L/PbarPZYYEZLzRaawCmUwCOk3/7Obo1LtgfV088K27kiYPHR7IbEySc5ivE/9hw/jiQQK0liRWvQ3dP6UxYpn3Luux7hcwsnXQOzuNInmCKyq0pRjF6PfCLEtw5h9so86linMJDhxqq567CAbfN+XRbaNXLlPaoCFwCzsb2HMtZ5HV1ckV5tLGqatb1vVGlj9ufKuAZ+O5h2zArQLztFMBmkTHMiFZFTYRR3pVWtEX4EsBWpxnI8ZkTJlfc9/1Z+7eA46lj7+gcxSuuiQjdGmIzrZb+zUFoEdpdcSZ+/tIRWC8Ny1KXy/MK2yizo2XJRjBQzbEApcbXIwCuGSBCnq5BYrg1zwwnkaXV9VzY1wwh8bAsH3n+qXikXpuFPebaz/h5+P+DxoaZ9MqELeRA== 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)(82310400026)(36860700016)(1800799024)(10067099003)(11063799006)(56012099006)(18002099003)(22082099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7AGMj24oVu8IGOgemUWGtWKdg8yV9nDrKkpGjzXMqCvCofhLausf7gXmskbAEPwFr8EW2jgIL6SaTeER/YuWETUgBr1U9ScXE5rqKi5uf/WxEatRd8KM9OAzoCjfRJxbbZdMVNkxuuhCoT+FHyb2GfbITl84d/A/Fb2LrBtkalM5m+kMLjFMD7q2WXXCWZp3lfFagUejKK5tKiV/xMU+w2V1xRPjNrszsbzh+RcaOFSj1x07qXagzW/BnN9tBJShto1Hdap+IJw+NnO3FptfUcv1yXq4MCn7glldT+v2XYUIVfbl+6XlMCNxRReUE3Laj0zsKumMR56uvUBO2HmaSfvdDe/Pc4J5EKrH46ZqPU996w22MgNUbc9qqxIEMIJOAjHC0Ta4O9GGo6vSEaiCDxqqSpLSbngaaPm6dTsRKo6WZnFelfPRKcUeRUArHClI X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2026 23:53:52.0503 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9638c421-6c9f-4925-c4ea-08df1e84ea09 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: BN2PEPF0000A891.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5618 Received-SPF: permerror client-ip=2a01:111:f403:c107::1; envelope-from=Michael.Roth@amd.com; helo=PH8PR06CU001.outbound.protection.outlook.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.341, 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: 1790726046328158500 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