From nobody Mon Nov 23 05:00:09 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1790781266; cv=none; d=zohomail.com; s=zohoarc; b=hgO/SJexor50m4kg73cBnfbddQmR94fkv6HWYeveFt2ScPx/Vc9cIZ3o3PQBsc6AjzOst7RDvgsWvR+KA4AxLbzS6fjKZ5U5zjOFONMRxMu6g6b9aZyo0rxaFbdg06bc9qmO84x+hKzOk/a0GGRZxMGNU/PZiXhiCr/L/1LVt5g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790781266; h=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=K0D/I8J3LUwWZpGiIfgIGNPj1aa/cXIqgnPtn4aAiB4=; b=hOT3KYAHErChSc7UFqJFD1cYBNIDBgcxL0K4h2GlaqYLyv5N8XhjrM/O9BqcFBjxK3mr1Am44AADmee30XGKNzAphpPkjE1ffDPaSpdSZsOfXrCSOmYFcfjrgb8C8ONb/ruDial9PjoTomXbvkymsqFS5j5KS132+CekDDQbW2o= ARC-Authentication-Results: i=1; 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; 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 1790781266451436.1947251531716; Wed, 30 Sep 2026 08:14:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBw0O-0002Tx-71; Wed, 30 Sep 2026 11:14: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 1xBw0G-0002Sh-Bq for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:13:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xBw0D-0000gO-CL for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:13:52 -0400 Received: from mail-yx1-f70.google.com (mail-yx1-f70.google.com [74.125.224.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-574-1EO9ZqrrMHSPGrW2y3qphQ-1; Wed, 30 Sep 2026 11:13:44 -0400 Received: by mail-yx1-f70.google.com with SMTP id 956f58d0204a3-6741d08bf9cso6323717d50.1 for ; Wed, 30 Sep 2026 08:13:44 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-917a881aba3sm1829356d6.2.2026.09.30.08.13.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 08:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790781228; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K0D/I8J3LUwWZpGiIfgIGNPj1aa/cXIqgnPtn4aAiB4=; b=JpMddp/xGiFW13jiSITamJriJLmLUdZFsvvr2QvpynU7JfdAJFzyIexZ4xDaEL0pP3yvGB 9KCt57Gm3h/utcBI4sQ3ljgF1BhVGmubkEN7m3oXja1aw35B1f0y6XQNgQeEBnS03ClCcY 8fx+mBSOJv+pM8/QfERscAl/+XPp9CM= X-MC-Unique: 1EO9ZqrrMHSPGrW2y3qphQ-1 X-Mimecast-MFC-AGG-ID: 1EO9ZqrrMHSPGrW2y3qphQ_1790781224 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790781224; x=1791386024; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=K0D/I8J3LUwWZpGiIfgIGNPj1aa/cXIqgnPtn4aAiB4=; b=koKYeQBC5sQdf92Ceq7j03OAZYcizdol4JAvL9wM22et0vvwRCe+VZv5Yrrw9MepVS q2zQO7+STZQatIqPhPfaSfW2dmadT3pEmfRuPuxZtEOWwplJjsxc9SOqADJLC+kuwR4q RoQ+VbsCAGleqDkxHeIPSsXTc3TnurExgAJ2MwyREISeX/FkZwgDJy7NhZZ+2ZUmzCks 1Grf1ZFg93Rmn3vU9waTKLd8yhvlMoiNziVIAK/9GY0850yXlSKfiezzUtAVnL1/0a/f qpoTf1TQOdHlM1maHqqaEHow0fC5Qf2ALZPvP5/+o3rJxud+5u1/v/V5P0cbv3dE7ZJX d1gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790781224; x=1791386024; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=K0D/I8J3LUwWZpGiIfgIGNPj1aa/cXIqgnPtn4aAiB4=; b=G5spFMZW7ueOR3jZuha0EQCx6z5QqrlneefTe7EetIvungna5eSnZSHRJGyNqkFe7b /XrZkm+XJZ60K5oC/0TBybQWaiGuFdAMQ9zRKJYAbMRGwekCxgzKrSVm9XQQM+yaM2gU pVItrfkayRj5NQc0Cc0Hbs1e6xLE71ajdJa2ZRJPzHmBbsvoOpv+3+t1II5XCADtmEzr cXZrlrOKEu6EaTs84ueEg3kQMBLr9AW9RamtIVF5THBWnAwUVvbY5YFUmXY/bAy9uVkJ +EmXU09t1cSyHEl0Wt8Nis4p/GezKHHi7bi5iOn5Gdrztp1Gdoe+rvEL8lUhsNWBk0Xa elbg== X-Gm-Message-State: AFq9FYL/8vVJxDweYq/t5YTpj6eknUcm2o5pxIN+HQFXnPSWltbk1JEB EGSd0JfSQKB8h9xNjpTsAZzYvdNSjjMTg8RRIAlVJDlYbjJSOlbBAbgBaMr3ncF6FAH8gUUuv3b wrNTG3mK/CF5IDbSZsu0PNvuiOOscli600Q6O9heLl7MdNmAfYcAwgRlhiCzUGqum5leCO4ec44 g91pFBtvz02ugqqLmBcmOXjMSylLQTFRjK1WrTXbj4 X-Gm-Gg: AYBFou0BAUNOZWZx3IR8+kLJ0NTEL7I4opzQkPE2PEhWT/14+WzS9740DoOV+6Pyp0t zItxi93SOHcN22utvy5E5/jXRyRd++dKEJENfyP3wHSNGcOdpFIiuAfaHFRVol180OI/r499L2e imgZT2stW4gSMvoNUk5+6sUE138QBNP6BNr5poKuZch+MXW9bwfSTdhYbG+k4OjxVJ30ax4JVvn O1gqhAhujqw73in3nN8epOmz99sjFHSca/ydyAC/q6iaHICdEOV6yU7fDXQgSMoCYYGe9+O7LWL BdON02PagRK7JYdpXOdJgpqyGj8B7j/zHPBb78I8J4D9Uvkc1mI8rE7U3MmwltruPho14KU= X-Received: by 2002:a05:690e:12c4:b0:676:8b46:d3e6 with SMTP id 956f58d0204a3-6768b46ddefmr642157d50.63.1790781223978; Wed, 30 Sep 2026 08:13:43 -0700 (PDT) X-Received: by 2002:a05:690e:12c4:b0:676:8b46:d3e6 with SMTP id 956f58d0204a3-6768b46ddefmr642132d50.63.1790781223287; Wed, 30 Sep 2026 08:13:43 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , Xiaoyao Li , Fabiano Rosas , Michael Roth , David Hildenbrand Subject: [PULL 01/12] kvm: Decouple memory attribute check from kvm_guest_memfd_supported Date: Wed, 30 Sep 2026 11:13:29 -0400 Message-ID: <20260930151340.2817042-2-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930151340.2817042-1-peterx@redhat.com> References: <20260930151340.2817042-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 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_BL_SPAMCOP_NET=1.347, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 @redhat.com) X-ZM-MESSAGEID: 1790781269608158500 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 Reviewed-by: Fabiano Rosas Reviewed-by: Michael Roth Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth Link: https://lore.kernel.org/r/20260929235109.1398509-2-michael.roth@amd.c= om Signed-off-by: Peter Xu --- include/system/kvm.h | 1 + accel/kvm/kvm-all.c | 8 ++++++-- accel/stubs/kvm-stub.c | 5 +++++ system/physmem.c | 9 +++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) 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/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/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.55.0 From nobody Mon Nov 23 05:00:09 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1790781300; cv=none; d=zohomail.com; s=zohoarc; b=iaUE5W8wHGAhoyyuM2cJvX+Fx5uF66G3dPEbAt00kYRH3Gtj3ZTen0crOOEMf/HjlfQc6rRxMUSQ74Nn228J07tW+tetkFUmqlqVYf3LrumEjHBDf/dRJ4mnBa9OqV9mSuFZDxlSBGQtCH1KueSnySnsAx8WzkRLcxNjFf/6jm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790781300; h=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=EoRCo81I/eGkPgW+8ugkZwxe3C1k/nICl5X7HO6q8Fw=; b=mE2X4BO0hnYzvOIAGLgmQGlwrClVu5+M0ZoJpedTe3kE2USMil5SvwX8kJUmxIR6Xl3PRuYwB5YTvMmFcnK7umxRNgoPUWGzzLjPShv3q8ekya/w5GChO93EB4/UEY8LEaDemjJEPFVJcHR5UY5m0ccawNN2Bn6A9T8czszuWWs= ARC-Authentication-Results: i=1; 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; 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 1790781300296543.5148854693449; Wed, 30 Sep 2026 08:15:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBw0R-0002UG-HA; Wed, 30 Sep 2026 11:14:05 -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 1xBw0H-0002Sw-6p for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:13:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xBw0F-0000gS-Jr for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:13:52 -0400 Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-267-r_YTaUwvNkyHA_RTQMcwZA-1; Wed, 30 Sep 2026 11:13:46 -0400 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-879b1d03d5fso85978197b3.0 for ; Wed, 30 Sep 2026 08:13:46 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-917a8a2feedsm1652086d6.33.2026.09.30.08.13.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 08:13:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790781229; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EoRCo81I/eGkPgW+8ugkZwxe3C1k/nICl5X7HO6q8Fw=; b=iG5Banwo4NRIhqwDJAsCqf3QMTgaUB5UEsnkLArAbTbb2PTFW80e0VSQy/l6UCMdfQqkL6 89Qg7KWZsvLcNw3g582/GMZl3+VTGT4aJ1dpQzhP4fxzQOTjM6LSGfS2YbPBVYoUlA99F/ 1SDWnijdT41P7a5V+hZIkLKYHJQgIMs= X-MC-Unique: r_YTaUwvNkyHA_RTQMcwZA-1 X-Mimecast-MFC-AGG-ID: r_YTaUwvNkyHA_RTQMcwZA_1790781226 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790781226; x=1791386026; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=EoRCo81I/eGkPgW+8ugkZwxe3C1k/nICl5X7HO6q8Fw=; b=PHnkq7kArLLKYtgSQ643LH+7Gk30Ziqa2p9R3AdaksBrjO/h1K74h2heM+p33VYDM9 AxkmSoFQmZAdyh+TvXQvLRjIDRcRPGi6UrLOP1o2ukzTtefWrhyL1ZL39G3FHMzQwODZ ZoGJfN7wjmYcRk5GE9m5OAxlM/ufhQXMOiqMQYNMTAQtU9mH1vhlcXYWu6pe0zH5cVq8 KqDGO/aZgN6VL59utUjhYPgUottTNQZ8u//iIb+ju4dza69fivGzPUNxjH0/U4HLZYsM fXy68+VhX8Sp13EN3GQtXaSOBZ+QmBleZXLqBPrkG8p5frquONkNxZBHrwjB6RrLW5Y6 VILA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790781226; x=1791386026; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=EoRCo81I/eGkPgW+8ugkZwxe3C1k/nICl5X7HO6q8Fw=; b=db2nZZstuAuHLzcbXGBeFdd+VUnufV2C/pPPQu6vD2tDe0mWkHW1gG61Scv0MWBn4L Fy9F2hV7neNPTiorJrwUda4gnW6ZBhK8mSyb3uUn8rdLRZOhtdxzUqb0lQbLTKfWfaSY QhPuu0SER/xL2mggIVYkmwk7KC4+gqUp7H7/NQKY0G2NsgbPiYEmf+4ui2w7JWEPVf84 PFklO6+bwzdYcfNNAfpMRIUf/2mqiEnDA1WEevY+Fp80b97ScR/ghTf6cTCbb5CwrXYA Lcn+/TUr81ANXU1bdmp3Pt5M4CRVYgW0WssKBzJWsQ9Kzh6m22AaPmsZb5u7m5GqRabc PvLA== X-Gm-Message-State: AFq9FYJ3wJbF0P0/A5jv0AbPbVI9tH1ffbxyCTKz9EeXJR/eqqfp5lL1 NilYeKanQU9N61IzNZhChHXL19lFFuuqM+gp5iQxyj9P6yU6TSG9TLOBCR6/gVFvIWmDqKlsDLE JO37ntdwzkpU5o+JUcsql0khKlEoJxzXBq0xy8cKymMiPS0mIeSFzT5j07PGFjlbwLXg1TwXWlz e7n7fF2ak9cYN7N2y16Hp0TZ1n8MEXJNN2/gfdwNLX X-Gm-Gg: AYBFou1JbZpZaWDRs7e3NVDcCXYooQVF9/O+KAmYeWUHi7EWF555kyLd9i1NOafeSF4 3yPnnnidThTDxUu9cGgR5soba4/pn56gbfNGZWlTAd2kug1j7Nn5ZMAaJQs14JWmMFv0wTOHqD5 TaMfX62tcCylp3LtVUgOeoMjiMlItdAhmbEK1BImbtJDmSu3yaKsaKPsEfuXEaA/W1GMQZnfSzl kAiASzBSosMAb2kA6x5O4cOv4p6BwFBbNDJfMtCboZ7kuHuQanEA2iQqSQPsyUd1k2WWjOybXFr ugXgYhAZq9A+lusHuqG8BTAiRkSInjZXsepkrMVNJTp0SIFWHkuqThnrQJJ3ob6kVpYDM2w= X-Received: by 2002:a05:690e:b45:b0:676:8c59:2a36 with SMTP id 956f58d0204a3-6768c593f17mr366079d50.57.1790781225679; Wed, 30 Sep 2026 08:13:45 -0700 (PDT) X-Received: by 2002:a05:690e:b45:b0:676:8c59:2a36 with SMTP id 956f58d0204a3-6768c593f17mr366032d50.57.1790781224946; Wed, 30 Sep 2026 08:13:44 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , Xiaoyao Li , Fabiano Rosas , Michael Roth Subject: [PULL 02/12] kvm: Detect guest-memfd flags supported Date: Wed, 30 Sep 2026 11:13:30 -0400 Message-ID: <20260930151340.2817042-3-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930151340.2817042-1-peterx@redhat.com> References: <20260930151340.2817042-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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 @redhat.com) X-ZM-MESSAGEID: 1790781301693158500 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Fabiano Rosas Reviewed-by: Michael Roth Signed-off-by: Michael Roth Link: https://lore.kernel.org/r/20260929235109.1398509-3-michael.roth@amd.c= om Signed-off-by: Peter Xu --- 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.55.0 From nobody Mon Nov 23 05:00:09 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1790781307; cv=none; d=zohomail.com; s=zohoarc; b=DDN2OZ/TucIS0i6M8DHFNp0EOEMVVggt/jzqSMHH3u7XkmsLN4HXVHV5rKDLtoA6v31uCnm6hesVdPZhcHDit5tTLCnfppPgHu5pMkWbrr9M4Snc+e/usZFSsQHntNeMSLZeh3v0+htX8IVgeo/LdhBi9By3x86ZgpKrGtBoUTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790781307; h=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=g/RpTFZOW17YdtVyJADct+Kt0iPKlWuajd/Kl0cEdYM=; b=ZTs4NVEA3dRjQuInw1PfrKVHkHzaVTc6Dk4Em7hRDOwDCpfAmTIP2CQ8EP/nmexyfWS+vuyqTDTI9dfNY2EmaCT4yuQocd1ZcDAT3u6Jk70MKjYymZ/r/A/u8Py6RgrKllYr2Yq/J4oaqMF/eOe47GCs+XIimLBirxJNIKgX+pU= ARC-Authentication-Results: i=1; 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; 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 1790781307644954.4100015559098; Wed, 30 Sep 2026 08:15:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBw0T-0002Ua-GI; Wed, 30 Sep 2026 11:14:05 -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 1xBw0H-0002Sx-Ju for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:13:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xBw0F-0000gb-U1 for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:13:53 -0400 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-599-oEOP95xfPZCB9er_dR993Q-1; Wed, 30 Sep 2026 11:13:48 -0400 Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-5337f26ee19so9447991cf.2 for ; Wed, 30 Sep 2026 08:13:48 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-533824ba4a2sm1529871cf.18.2026.09.30.08.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 08:13:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790781231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g/RpTFZOW17YdtVyJADct+Kt0iPKlWuajd/Kl0cEdYM=; b=cn4OsMpG2zAp9hqc8zHmiH/5ZMYn1WML/hWQB45eye/YxqMtcN9RC7csQ4AvZUpMT9oE5X qx3y4d1EeNPgtMD4ZdbKzXjjK1B/b2c/nVViVcEuFBwb3UsQzWE/0fpy3/tGOX54vFMHyz TWgM2kzNiFVzlOx+AZ1xQbYQAfl1HLY= X-MC-Unique: oEOP95xfPZCB9er_dR993Q-1 X-Mimecast-MFC-AGG-ID: oEOP95xfPZCB9er_dR993Q_1790781228 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790781228; x=1791386028; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=g/RpTFZOW17YdtVyJADct+Kt0iPKlWuajd/Kl0cEdYM=; b=S/s9grnGDwBOx7SCbvPrUaDeJPSTP1CweedXng3FRuvJCVu0kQWpH7LOml0fVKvAu2 FaqgY46qP8RauxoLaeW43UjS/h1OruhNzqx+FTIJl+SHLCNxaa/aF71OMZbSUYXFSFRy lUJTeg4XG3KmQLaJYc20I87I1WtEhpaTpXS/y4w5P3YhlDwIPTZ1O/Km2H8CHK9LQt4e YHHC2CQqg6wQ5TTQeNBJrdFST9K5z09VUAvS9D/x9Am4xAhT/pW2Un/dBlpwqgqEEsZ1 CvE2Mvqtca+lPbqEOU2d/6u/uJDBpQfJXbI9QN6T2aDh/6AmyFWMBbaNxCjqyZ8wdWtl bj/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790781228; x=1791386028; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=g/RpTFZOW17YdtVyJADct+Kt0iPKlWuajd/Kl0cEdYM=; b=2HY32UZMQX6AVNF0UuKJwS9J0WL2a3B7Zjhr/YH40ztzVqSnkOk9lgfK1dP73j7Ta6 V+CeKuuzG3VWfahO6R7VsIoqI6qYyHpFQg8Cy58k1VqjPs1jyQhNozmHDumlz/9IM7+1 KqaJ594Ojp6AedKs+T6wibx1Mp5U37MXe3VYQC4BRGR2UxDcxCl2knw9af8KtG6iY8hC yOT2KZjYsFJy5wrzBVuLoYIOzome9oG6o/JBbXj4+JZY0nQOTuk7KA3UNKMMtKRcNz40 M/uP97XD/SttwwzmQr+SA907KCpd6LaMrwzbA0ERpw+jqLNrblAP+WdVCTucTYMftBB1 rADA== X-Gm-Message-State: AFuF++nA8e87YphBUEmuCUD5wTSa0B2Dmw7NSyb1RNn5reRgrHsA/lxI ZtkfsTRBI0blRKuquhORKgT3t8SunkNBp4Ry9NM7Zd5d4pG/G2Z988O+EdIOha5OQg2k5ZMiUBD k+hKZdh9NLJCtqqGesGu3AJCxttcAhh6C0rR0MJgvNiSdKg6L+8MlZNehWzluTLq13gCx/G8luE bTtp7mves2HZJHZvdieUu3McPj95IgGOezyILrFEwD X-Gm-Gg: AYBFou3oXiw2DLkxEuEA4+CPZ7EGBsOWhF/lZvN0vgz6HoKEYXj3QF68v+3lyJ7WJtQ +6LQxQHIA0DiH/BsKFHGE0VpqfRRB5uiRm/n2pEyUhVa/YZHrmO5PprmGo08frpZqnbL28VRmkw DpBx+Ub+lq+/NBK8f6EMqzJ3/w0X73NDHbieHiQK3DCX8Mq8OqbT4cwwNOVMI8kPVQJCk8IjrLP P5nUZ3IhreWkxsW+dHGhYObwPxPDSkeux20Y/vlOHwAeq2ei1V1Q5eEA3QMwphyR+pPOvNmnFXw JGvH/0uYLjO5EtfEbNt/Z63kCivbMZDzWzXGZT+LYpkOy4aq8CMmYKhO/mrgajKgyXx692s= X-Received: by 2002:ac8:5f46:0:b0:533:2717:6221 with SMTP id d75a77b69052e-533742f520bmr33417641cf.31.1790781227466; Wed, 30 Sep 2026 08:13:47 -0700 (PDT) X-Received: by 2002:ac8:5f46:0:b0:533:2717:6221 with SMTP id d75a77b69052e-533742f520bmr33416781cf.31.1790781226727; Wed, 30 Sep 2026 08:13:46 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , Xiaoyao Li , Fabiano Rosas , Michael Roth , David Hildenbrand Subject: [PULL 03/12] kvm: Provide explicit error for kvm_create_guest_memfd() Date: Wed, 30 Sep 2026 11:13:31 -0400 Message-ID: <20260930151340.2817042-4-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930151340.2817042-1-peterx@redhat.com> References: <20260930151340.2817042-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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 @redhat.com) X-ZM-MESSAGEID: 1790781309909158500 Content-Type: text/plain; charset="utf-8" So that there will be a verbal string returned when kvm not enabled, or kvm not compiled. Reviewed-by: Xiaoyao Li Reviewed-by: Fabiano Rosas Reviewed-by: Michael Roth Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth Link: https://lore.kernel.org/r/20260929235109.1398509-4-michael.roth@amd.c= om Signed-off-by: Peter Xu --- 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.55.0 From nobody Mon Nov 23 05:00:09 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1790781281; cv=none; d=zohomail.com; s=zohoarc; b=nE5xuAYgZBwnwBnt3YZqEPNNdp3iAWbD7WbrTkhqnUGaXP0FGLKOL+tP2Ng/9N/gdLSPS9Pz9PewaDjJycLIwWfzrsx4M3GoogITR4nhEC6LQ1940+X9szz+b+UlxgfYZvEGcFGTHt140mDum1iH5P1W0sf4jeHB3Y+XSoPP9AM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790781281; h=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=vzXXBfHGQcvgtdh3Dg0ExgY6+4z4PmR3YA+bAO8qOHc=; b=bN89WaptBLy/IqXGo4w/SCpoEXI4i30Q4R4NTLYnBzdJuGKDT9Fx1e8i+nOoys9qdDuEtXi3C8rM6bKPGgHMu/bw4F1wjBFLDpokeFAAMOY/DGdsU/zrobpXY0BVDFUEKypLyMQeW6U+JD3qHrPp5QmMPCk1JIJjBtD6UP4LfRU= ARC-Authentication-Results: i=1; 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; 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 1790781281654647.8808392162964; Wed, 30 Sep 2026 08:14:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBw0U-0002Uw-Bf; Wed, 30 Sep 2026 11:14:06 -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 1xBw0J-0002TH-C4 for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:13:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xBw0G-0000gd-6E for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:13:54 -0400 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-QDBbzL4PN_OokzFRXFM9hg-1; Wed, 30 Sep 2026 11:13:50 -0400 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-917a438816dso7963196d6.3 for ; Wed, 30 Sep 2026 08:13:49 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-917a8a642ebsm1547976d6.41.2026.09.30.08.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 08:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790781231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vzXXBfHGQcvgtdh3Dg0ExgY6+4z4PmR3YA+bAO8qOHc=; b=IbcouEExI15T+1Ek1fvpUg0q6X9f9mX5/RMW9oFZxCluaIWLL0jYfJfMU8bvspuLxPAvLE zqlxQwmOoshQlFU1gPCsklDVZWYdSKKsA58Gw9ih3bcqEVrPp9ALEv7C+fO/f+KlSqdV+Z uCpXBKgeWP6Hdk9lmluEi/+EP0iZx68= X-MC-Unique: QDBbzL4PN_OokzFRXFM9hg-1 X-Mimecast-MFC-AGG-ID: QDBbzL4PN_OokzFRXFM9hg_1790781229 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790781229; x=1791386029; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=vzXXBfHGQcvgtdh3Dg0ExgY6+4z4PmR3YA+bAO8qOHc=; b=aeUiVTZXos1uAHcpicaiJw8lqB3kKtnViS2jbDOw/63nHDZOs1iLQMvapmh7ulTjro 79DboZ3Gbn7RdaTeQbC7kJBT4aMmIu3t2v5vWbLjAf+9so1840qkZWi7FP8fK7iLVVs4 P2KmvSxMVpkMVt+HfRqkyuEbQoO+QppjE3dHkpgfmyQIakI+qI/m1igt4AaZne6L/zpr UfqZ/CFX0nG44piVlR3RSb0gBuFMV5JMj18Ei2jk10rdxNK54HEr10ku4z4pfQhCKRgB wx+Fy+/ku5QufJogw1KRzFIwHNWVLdFqMmHpgiwRpU9lz/HrkjdLjz3jmjIZkRgWnB8X jXFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790781229; x=1791386029; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=vzXXBfHGQcvgtdh3Dg0ExgY6+4z4PmR3YA+bAO8qOHc=; b=SA6uyNAFH2Awve5wkXkHVh3RgAowCAjd4C5vAXqwH/pY6RMBnRbbGBX/mPCPoN9jHj I7AwcUXdCa0AkpVPZe0mQKMZ/rwLbUuqG3b+OFavOZho8JecN+zUrOLe/ACX+81b1glv TponotqhpeWo1hftIEjqA7FIzaUp5tZBuhOOp66g7JiTh4B1xI3ZNP7p6Yh9B7Hw0M2I XkKHatCabkh+/ctQOFk0S0m+42BRn8GlUSE5PJGuYa4aiE8SnuntEU/WkGBYxXJAq2DB 6vIWQp8U7yBJZYWFyl+5M8Psx1YXkezAlsyRlSFgLDa0GbB3gLGpuN3A97ZARK/Ze2zs UVkA== X-Gm-Message-State: AFq9FYKVciVdGmSyV1EPnSf3qaVlm3KHOSuCoYUBL9ijvLx3OduTcEQ8 u/rWkMuCtpCCUjOSeEVxqSUY62r8O5ulmCfzq8biaONpAw91PepZ5KvPtnEjCm8WaKjj7rEWxS5 2hN3DdsSrlbqV+lzOxTVzm2/pdqTk5W1kYgbIxbXBAS7/duu/deb+eehOvEw+7I0gZKh/XtDKFR j2lCBz8TTnZlsB28UWOe0j7ZoSejaK6/ZNI2OZsrnS X-Gm-Gg: AYBFou0QPBmskzmHc7pf3V6hDd0IeB0kem0aVR93WLCYB/lkIy0Ezy1hkccjrQp7cRe qrOq9WjULkEIl3vaO9m9nQXXudVmtjwrlGdVno1riffcV6bPiNkTgF4F5wEIKR3lqfuUPGuhG8h bBtaOrb7a8lnE1gLePG5Js85ZYM23BZWpiiy4xWMiE7gh3AAvUGhaW6736pXbTW34yKcOULo7ig 3gZqMIUkAcOTC3ZIW+VwZDZ5SXvqF2JdJ+/dQrIgFGhIdo1TOL2y+ikK8rC/JKX9QM65JAHbN0r 2cxsJX1VDfmDok6N9XMuafws3aghFYJ8yv393YBBunvCNmprPcwoTxR6ZHd9+9RGMnWJA6M= X-Received: by 2002:a05:6214:21c1:b0:915:e8dd:4c02 with SMTP id 6a1803df08f44-917a0b8bcf6mr30587176d6.23.1790781229162; Wed, 30 Sep 2026 08:13:49 -0700 (PDT) X-Received: by 2002:a05:6214:21c1:b0:915:e8dd:4c02 with SMTP id 6a1803df08f44-917a0b8bcf6mr30586366d6.23.1790781228487; Wed, 30 Sep 2026 08:13:48 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , Xiaoyao Li , Michael Roth , David Hildenbrand Subject: [PULL 04/12] ramblock: Rename guest_memfd to guest_memfd_private Date: Wed, 30 Sep 2026 11:13:32 -0400 Message-ID: <20260930151340.2817042-5-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930151340.2817042-1-peterx@redhat.com> References: <20260930151340.2817042-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1790781283678158500 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Michael Roth Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth Link: https://lore.kernel.org/r/20260929235109.1398509-5-michael.roth@amd.c= om Signed-off-by: Peter Xu --- include/system/memory.h | 7 ++++--- include/system/ramblock.h | 7 ++++++- accel/kvm/kvm-all.c | 2 +- system/memory.c | 2 +- system/physmem.c | 33 +++++++++++++++++---------------- 5 files changed, 29 insertions(+), 22 deletions(-) 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/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/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.55.0 From nobody Mon Nov 23 05:00:09 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1790781294; cv=none; d=zohomail.com; s=zohoarc; b=lZYoMmnB02kIpcL++2FzmB08P7Z+ePVPYvG3cGCr3jT8YXUulbrQNE9wyB7p1Mpds8byER6r8yiogRLbeKD9dkYUOg1OLEHUSyaWkll4F3tzEj4Ahqg6j1NoR0gUSN+vj4gXIYVH0bu2F8hgytCZbwoY4jtOny394Vs64jB7/RE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790781294; h=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=AN8FWwbJqRHvFRPAEkIAwjHl7xfg/WsFk2YJV98zyzY=; b=bGEYuvlMlSJeGbKGAmvEemcB+z4Yc6hgucMxlC26NcQCPvPu67WLuUQmX8dHYe74tcUOHhjXnnncE3yuDNRz6swcgVSR++zagxGd5kw+0PWYHsnWf07HHMzmf27xqnjY1xPOlsKc0/X+3Jt75nK/cwlfkWgwyKQMQpxvAGf0MIg= ARC-Authentication-Results: i=1; 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; 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 1790781294848628.7134211638341; Wed, 30 Sep 2026 08:14:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBw0U-0002Ur-8r; Wed, 30 Sep 2026 11:14:06 -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 1xBw0L-0002Ti-A7 for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:13:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xBw0J-0000hG-5J for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:13:57 -0400 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-13-QXgUaw_yMgG82TikIhe-UA-1; Wed, 30 Sep 2026 11:13:52 -0400 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-5332841f932so83265891cf.2 for ; Wed, 30 Sep 2026 08:13:52 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5338242f8d1sm1395211cf.9.2026.09.30.08.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 08:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790781233; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AN8FWwbJqRHvFRPAEkIAwjHl7xfg/WsFk2YJV98zyzY=; b=aEFztNIXZy4dm4ehG/jcVx9CFdRgPDOIFCfgX4VTv7hpCLpWYBClcoweoFui5aO9TiiXIE bOVPjw1zRumK6ccoF0fbHIWDA2CO+9KkdGKw1540eKq71pz40SPqdwc2j4TvMnR4cIgzRD V39+dlLcJgCTWiAM49X2+ZnKY1PWPMs= X-MC-Unique: QXgUaw_yMgG82TikIhe-UA-1 X-Mimecast-MFC-AGG-ID: QXgUaw_yMgG82TikIhe-UA_1790781231 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790781231; x=1791386031; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=AN8FWwbJqRHvFRPAEkIAwjHl7xfg/WsFk2YJV98zyzY=; b=ZCfY/VP7qg6M1HXu1LA5aPb4df87bHfbKFuQvn2Y1aEiSurVzK4ul3gXJqAnC43bUf y0tbcIXI2m+M1+0Olefsphv3KQtBQF0aFKO4lj705WBZIEcxnyhOfsbjJs0Sr5zeMEY8 IrfnUT8/b1KwIorNRFEtMm97ALLLx+gQbj0xApjs8Eah0i7f6AGM0TtgqXwEplmcRWj4 /KRHRVsgw5wQDgeZqWVL9zzNnokJt7BC7PYHo5hHHGXVg6DzMUfptaOe770wsty1xfmF aQS3xwfBUqQ63+KwD6pCeoDy6ifyma+1RPDafAqObgb3y1U8qrVBaZyDLYpY4Ilzo/fs tzTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790781231; x=1791386031; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=AN8FWwbJqRHvFRPAEkIAwjHl7xfg/WsFk2YJV98zyzY=; b=l8eAJ8GBz/oxXnmI6pcGBYDmUl8KwP6AeMGEkssx1XNJOH3dYjfv6XaBydajM4piJQ YBPl3Vx/3JnGuTobaNXlNeLbLxDmb5y0HZzepV5h3hQTwKEktFbVIdQl/scn0bhCTk7F qSSsPTUn0/YqcsnFS4C2KNIRQh5NxrePzm940f0Ck7pDiteRR9wv2QjBwilTR+8HM7gy F73ogMU2zLcg1jutqGz1P280J8uJnveQiqhSG69wiqPEOoxPxxdEHvtl5oTbFxHwrkV6 VkqIpVQMwDxdLJ6LugQkXgUZ3b2AvIW5ADAMPghUByeDihTZZz+hZEo3WijLx0E17/Mi hBbQ== X-Gm-Message-State: AFuF++lDj7Q1+ek16T5nvtV1ecrPXYc05Gx7bY9RaJsyIQ5FuOk0S3RB C/K9fAnJCh5LoVF2T0fplxaDB0xVvQV0tRE+wAVfv9iEq8TeMB9z0yaYkhyhliWbWp+w0LUUDyr /grFTBjLa9mGnoqeC2U+6jA8xNGRMo9LjBonJ5iWEqxd56+iZNmVkQdNBippcSi3xDF/aHjZja7 v0bqTIG5+lIvGiHDYuqFInM8M7bYeLhE6U/1qumpDT X-Gm-Gg: AYBFou3CSZX7sOfIFJ37CpSzBiWCKFfXMJ0h7SydxHgBTc/yGwE6clxCswQ/eowyzTf J3sr+euCNncOqlJS8zTwYK0FOuPHirZENn4YQJI7qd6MIDO7xsoaLuGOFywU0u2vlgJ2XtmyI6y hOtjiGYL0E0GHw2hM/iXa7zVHNI97elrcYYo+sST10bdjJvrkn6c5TqGv6cPYUfhRif/IffXusM vH0WmsCeWRklxSwSrScmjQTvwgW6rH3Z6SnG8zy15Gi+O6Y5UBWdMMz5BLVXX7o8smru9n4Dlrb SJtV7vXdWtOBIu9eynM2o5hyzSDgJYBjxEiXN1ywnyxj8xqBaxNr9K6eF5rxgIHphv1Rk08= X-Received: by 2002:ac8:598c:0:b0:530:b2e3:86c7 with SMTP id d75a77b69052e-53374db3985mr29646721cf.57.1790781231215; Wed, 30 Sep 2026 08:13:51 -0700 (PDT) X-Received: by 2002:ac8:598c:0:b0:530:b2e3:86c7 with SMTP id d75a77b69052e-53374db3985mr29645621cf.57.1790781230236; Wed, 30 Sep 2026 08:13:50 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , Xiaoyao Li , Michael Roth , David Hildenbrand Subject: [PULL 05/12] memory: Rename RAM_GUEST_MEMFD to RAM_GUEST_MEMFD_PRIVATE Date: Wed, 30 Sep 2026 11:13:33 -0400 Message-ID: <20260930151340.2817042-6-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930151340.2817042-1-peterx@redhat.com> References: <20260930151340.2817042-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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 @redhat.com) X-ZM-MESSAGEID: 1790781295713158500 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Michael Roth Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth Link: https://lore.kernel.org/r/20260929235109.1398509-6-michael.roth@amd.c= om Signed-off-by: Peter Xu --- include/system/memory.h | 8 ++++---- include/system/ramblock.h | 2 +- backends/hostmem-file.c | 2 +- backends/hostmem-memfd.c | 2 +- backends/hostmem-ram.c | 2 +- backends/hostmem-shm.c | 2 +- system/memory.c | 2 +- system/physmem.c | 10 +++++----- 8 files changed, 15 insertions(+), 15 deletions(-) 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/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/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.55.0 From nobody Mon Nov 23 05:00:09 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1790781329; cv=none; d=zohomail.com; s=zohoarc; b=FfB58kIxpiDqrTGPbcDjmTaIiuVGvwZMigH2PyTwCJ8LU5QwWZVL79E9OECO+ODU3g2eLrORLivomKs/cweNEKj13Ke2guZY2UfF6zoinrFl977I7Hr16lN7vhMKtccp1W4c3iJ5b5Mjwume+2qZ+eR/20sI+I+KAXcE2v31oW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790781329; h=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=/+/Uh5MYYSNZUM3uVjI0Pna/C+eoWM439GTWlhwfHBc=; b=Nyg1Nf4vtd4kG0LYbI1LONMS5Z65c9Xhu5BVphJwS7wJ/J8J13Jo0gdKGfGO+aEVrrNlL6ktF38OgkzYDUPzQLTxh69hOeXNfnvGW6Wr2BENgE8fQjqYW1VZmNuHiYWSCEQ/q6wu3FF4ew6ezvnZScMYJj9osyWyGNsaF2rzKFk= ARC-Authentication-Results: i=1; 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; 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 1790781329246196.52454796083327; Wed, 30 Sep 2026 08:15:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBw0W-0002YI-MB; Wed, 30 Sep 2026 11:14:08 -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 1xBw0L-0002Tl-Ki for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:13:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xBw0J-0000hN-Nb for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:13:57 -0400 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-172-2AKykEAgNp6HE8wVjMkihg-1; Wed, 30 Sep 2026 11:13:53 -0400 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-93a183a0e93so1167463885a.1 for ; Wed, 30 Sep 2026 08:13:53 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93ca7eb02casm139847185a.5.2026.09.30.08.13.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 08:13:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790781235; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/+/Uh5MYYSNZUM3uVjI0Pna/C+eoWM439GTWlhwfHBc=; b=StOtWEk6uiDARr/0y2n/VNG0EKPTL4syGk0RH8ZB3XRWgTanvrb8cY36K3X6j33UJ+/yaF Rix0wsA75els6nFkHOsOvhLH3ESpCx+dN8GfR+AGewZK+hsQsp6SlKBfEczZwnTgBhb3uq RzNI/T4NHtCyVJuF3WFimzuHeBjcf+c= X-MC-Unique: 2AKykEAgNp6HE8wVjMkihg-1 X-Mimecast-MFC-AGG-ID: 2AKykEAgNp6HE8wVjMkihg_1790781233 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790781233; x=1791386033; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/+/Uh5MYYSNZUM3uVjI0Pna/C+eoWM439GTWlhwfHBc=; b=GytH7VXsSPg/xH2wQlrC6lm9BUT3Ip7GCVeQtqWGamgYJZ/2ScV1Rx/iYLKhqciB/e U7VyZYewj4/wtcOl5SDRJiirlr90YlL5IsbttQ6MQueBwIMTsRg63Iq8eKGc7G/tiscJ mTBrL7DBJQHN86DXnFvNW7y4RW1xAvIKXS0q/navxi1ys4buvZq88bcIXCOmYygOGuH2 ZNap+F68ExdRIFwkbTt2tp35hHJtJAZk82Udf4Xr3K8lJfeosF07JUbf+gORA1UInTne WKBoYCLaJfN11SZsw7ovqCRsTXUyCIsBXCGwuL8sC7+aE7pIJi4caqr8V3NcJV/a8cQT WhSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790781233; x=1791386033; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=/+/Uh5MYYSNZUM3uVjI0Pna/C+eoWM439GTWlhwfHBc=; b=Zasbi/p8SSv4mvBdu5y/prAYMzJP70d3JNKjgBWmkLCVHSJdKt6ECsPMA0WJYLEO4Y vorP+yraJtrsMKVCrv3xwpz/zRDCNfHaWlowm6FagYDALq0iI80beWJsHBeE055BusuT IP+UoDcw6c2uEQtMh+RbGQo2kPIBoYttSyxPiubk5e3RWHyi9VthK70jrn0Czo61dHaz ETCe3TfywXjXM9FpRRF+d+/mK3ILgadSvqhFb++p/cZ6x738cRtj7Ms9+eCgG9R2mr/e AopyqWBUDJKKWDY+q1pcLvcP68Zi93Ev9tjngry/ploKTzYU+j97UG4KxgjnKzDqZL8J +4Cw== X-Gm-Message-State: AFuF++kNNcqtr57DldA5JHgRTLgcDecE9O0BfG+1LNpqDcoRKywdoeBd LtRqvmD2kewJGLAI8NqjAm2mgjGs8s6URKdFcSSLwx+Df13vxv3zSnMSTUntuT8pJKfGCnWUAGC ItcOmHGfp6iYhCvDdIew6bD/Db7G7qQA1gVp7bsJQuHFboSO6Be+50zrUdlYbyGk7FM0V7m6Emr MEScM27SqufG37/4WTLUjygtOlDMbL1nGxDAR/0Ik6 X-Gm-Gg: AYBFou2Ns8l3mcnIBx6T1M3TtOY20lbODjNReLT9ATIRqhPvvwmx6DFHF7cZYpkfawe TABRshxhUKwGwmTgMKb/S166IuoKuzIo3OsmIydFtqTmXp7H18jwlxFB9J6G+of8C3z8DyZpdlF mOMd6O9s31cKfu5P/keAHIdODzuk0O7aB6546kq32+inTczKhhv2hHN+RDqXBSlbbkRoG2fFOAI O9kn8wxM7O7Osh1GE2+3bkhYrWp6yVsNhdnPWMv6DTVC2+TIne8qA6oUWd8y3asuoeyeGy/GY0T TO9b8IsvgqiL7yiF6HPCwe4tmKN6W8UoHaN49slYwp4m9fSnCqzmtXEx1dhQSFG4sJosLHc= X-Received: by 2002:a05:620a:4889:b0:939:c1d4:e2e1 with SMTP id af79cd13be357-93ca979091amr280166085a.25.1790781232662; Wed, 30 Sep 2026 08:13:52 -0700 (PDT) X-Received: by 2002:a05:620a:4889:b0:939:c1d4:e2e1 with SMTP id af79cd13be357-93ca979091amr280160785a.25.1790781232111; Wed, 30 Sep 2026 08:13:52 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , Xiaoyao Li , Michael Roth , David Hildenbrand Subject: [PULL 06/12] memory: Rename memory_region_has_guest_memfd() to *_private() Date: Wed, 30 Sep 2026 11:13:34 -0400 Message-ID: <20260930151340.2817042-7-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930151340.2817042-1-peterx@redhat.com> References: <20260930151340.2817042-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1790781332270158500 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Michael Roth Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth Link: https://lore.kernel.org/r/20260929235109.1398509-7-michael.roth@amd.c= om Signed-off-by: Peter Xu --- include/system/memory.h | 4 ++-- accel/kvm/kvm-all.c | 6 +++--- system/memory.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) 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/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/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.55.0 From nobody Mon Nov 23 05:00:09 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1790781300; cv=none; d=zohomail.com; s=zohoarc; b=GLjtEsVJxb5PEx/Fc7XneN/dXOSW6naO8UB08LzNhZSEzo/As7coli50ImDbdp+aNoEWy1qnlnuqXKNFDWX0liwdBLvlmuap+P/qK6gEirWSnj7paxBQ+refe+0yFRzkLas8/f/9ucRVUKibKd3B+v+sK8R80POaLiEMMjsgieo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790781300; h=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=94CrXL6cQbmTN7H2hegnOb8GVXr5vOIwKBuBKE6Q3T8=; b=NqTXql8IEWFkwc/10oP6a3Mxc9e/mTg1ixzxNYN3rXsmzw0n3gxNYxHl5Iig/57aGlPhgnK4KVmngdm5JOwr/rht1BOU8kDQ9q3FENuUX4m/WZ8h7mEr0OMjurV919Yg1PL8iw4zXOVq70n5hebnQMasaCrAH0kPYFK31PnjBOE= ARC-Authentication-Results: i=1; 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; 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 1790781300889462.83155309531946; Wed, 30 Sep 2026 08:15:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBw0V-0002XO-F5; Wed, 30 Sep 2026 11:14: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 1xBw0N-0002U8-TK for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:14:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xBw0M-0000hf-2z for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:13:59 -0400 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-660-KusSGb5rP3ut7tfhSZmhfw-1; Wed, 30 Sep 2026 11:13:55 -0400 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-93cafdbdb7cso67198885a.0 for ; Wed, 30 Sep 2026 08:13:55 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93ca807dd0csm136663885a.15.2026.09.30.08.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 08:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790781237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=94CrXL6cQbmTN7H2hegnOb8GVXr5vOIwKBuBKE6Q3T8=; b=OSfJUJxrfVBLGdQnTb3kaD2oFyhk/562K3y6dHsd+hDLLoQyIi50BmCg0tF/dKuszp1MIe 1jdWP1X32C+/2lcdwvRrWamCFVNI0wor86PW2xv2PZzqWnBCzUvNTlQOnyODMQmk0LKGLX GAUmV1j1yymqEaQkNXDNzfW/l4qtAq8= X-MC-Unique: KusSGb5rP3ut7tfhSZmhfw-1 X-Mimecast-MFC-AGG-ID: KusSGb5rP3ut7tfhSZmhfw_1790781235 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790781235; x=1791386035; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=94CrXL6cQbmTN7H2hegnOb8GVXr5vOIwKBuBKE6Q3T8=; b=ncyWFIY/3V2UVv5y5XvuRktSUeCoICcVvxuKO5BAVRmcHZenJkR+iI3m2QubdB8EVj 6d356jVPhDtKdqBT/s5M7738XbyMk/B3wDbpmnURuy15gf8sogQ8C2LElwTmZUlhsY/6 OxDS8LMeuVe6Jefo7wXD2g2cIS89fc4NXK/JSqwWD/qdm5w8bfizHGVkxXDe6gPGbXjM zjJL0ynsBW7kqQVJqqxlONIITHGXvmG8Ek1qqY//CspU6ZPgNVpBc9nTZek8Lmvfg6Go 40VrELnnidZCYfPkpqsbluftklovzOar6ZMUhryO/HMI0k/JlzS6gmbxumCN3ox8fWFr nwRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790781235; x=1791386035; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=94CrXL6cQbmTN7H2hegnOb8GVXr5vOIwKBuBKE6Q3T8=; b=h3fMrlHlIOh4zG/PSF1IuzsXZ36pEMsdvUhF3rRh9L3jnUD5ymqgsiezbR9EiyPOu+ vmwpjBLyvvWTC54qYBCImjkQZACY8MAfoUkm5V/YgqEBNMO8C2T1pRvcU18g29pCcZwV C8vRCw60aBChvefbYtVaBwAnqS5GT17IoNQqDSBFXX+SSQ1EHonhkbFILPSTHZ8tXQCh wejoSB/jQbIUeDmEUz0c6kZ+bu6zx2htE5yN8+ukRwRkwimSbCsRjN5KnLgGo5HDFcJW cCEz/go9nkEU9KPD+ro2wTo9A8OvUv329vuvQTAFtSh64B85G49/BVMEIQYST66v5NNy X7rw== X-Gm-Message-State: AFuF++lHhUH/Z2FYwUaQf1J1p/k7XrAja3kIePRchSe6lgNe6tTAaSjk +rRbD5I72K7kLW1BCn0/6QwAh1s4LX2zNCWLWS1yUukslJ5FIx0FoZMKF+fYPTFC+cXtCaHGt2s dzrjWLb5NHyCLM7AHzAMNLk43i5YEHiNFrh1yEn/4KDJM+sXdRWOwpIjEwMOfVbrDn9lpCIIZD7 a1i7lNN4jhHaoUUbI97Yv+Yta9JZu9q6Z4InH6XENJ X-Gm-Gg: AYBFou0Bh5ms5PW+0BIojx9LjCQDOymovz06zpHlLtAIGqILIWeByAdgaRsxa6ydWEa RdjEnuzlePYu2FfXbqVYlU8Y/4chPPCAek0W6Mi5+gzugESIPtsR+vu4lgNzw8x7/EOgnyV6YKD Kpgjc6EdU9obpDXK3B75aUyfYXsx4nNJ20LXG2z8o4akP4f1KGV7aV4gql/HqX2HaHqZUPZUFU9 2wmhOa1wpcscX870QCoooBJ/qEwI+2is4NnVATfzXzx2j0w/cRL1bkQr4IeIdIOuAd6MGvJgpnq /iBwo764VrhIdXLUW8YPkPEJbIEdjHlgyzIDihfLv7BnjoQzlDyxWcb15c8TLQGGkDqg7VQ= X-Received: by 2002:a05:620a:c41:b0:93b:cb64:25a5 with SMTP id af79cd13be357-93ca96c929amr298262785a.12.1790781234481; Wed, 30 Sep 2026 08:13:54 -0700 (PDT) X-Received: by 2002:a05:620a:c41:b0:93b:cb64:25a5 with SMTP id af79cd13be357-93ca96c929amr298253985a.12.1790781233782; Wed, 30 Sep 2026 08:13:53 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , Xiaoyao Li , Michael Roth , David Hildenbrand Subject: [PULL 07/12] hostmem: Rename guest_memfd to guest_memfd_private Date: Wed, 30 Sep 2026 11:13:35 -0400 Message-ID: <20260930151340.2817042-8-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930151340.2817042-1-peterx@redhat.com> References: <20260930151340.2817042-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1790781301715158500 Content-Type: text/plain; charset="utf-8" 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. Reviewed-by: Xiaoyao Li Reviewed-by: Michael Roth Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth Link: https://lore.kernel.org/r/20260929235109.1398509-8-michael.roth@amd.c= om Signed-off-by: Peter Xu --- include/system/hostmem.h | 2 +- backends/hostmem-file.c | 2 +- backends/hostmem-memfd.c | 2 +- backends/hostmem-ram.c | 2 +- backends/hostmem-shm.c | 2 +- backends/hostmem.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) 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); 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; } --=20 2.55.0 From nobody Mon Nov 23 05:00:09 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1790781311; cv=none; d=zohomail.com; s=zohoarc; b=aj4aGU/as3PXDRG679MGFbwkUSDgwRiQ00iXocmZ5cYBBqtjdiJ3I8T7vSiCLwTw1Zs6Ece3x498XNr878MYN/q/d6Po948pedutXMxODyB61l8LzGUZJPiFgDQChRH5UJ1TupFJDipC8kqzKgx3e2BD7IxgOJd573MQ5btayyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790781311; h=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=soivliGS3V3qOZBKXvbV1mUa7dYCQpqfRa1KAw9iuwc=; b=KFwzz+v7Oc4Kb5un1V5/R0PfZII5a0lgiF0mNPlU1+xFSiqZSQUz94pMi4Po2+6nliQ9PQv8DWsfdbXvMyeQC/a+XQjPHelaSDy+437eFWfrw2ivz6EYu/2OaAq7BzjllOSVYlmGKB+1EIRG6ldG3FeAbz4/UB/51QqOPsV3DpM= ARC-Authentication-Results: i=1; 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; 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 17907813117271003.9669788896755; Wed, 30 Sep 2026 08:15:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBw0X-0002ZI-NO; Wed, 30 Sep 2026 11:14: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 1xBw0P-0002UD-II for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:14:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xBw0N-0000iC-Fk for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:14:01 -0400 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-171-Cz3ymEkgP7SS1fLA4mgwTg-1; Wed, 30 Sep 2026 11:13:57 -0400 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-93cafdbdb7cso67204085a.0 for ; Wed, 30 Sep 2026 08:13:57 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93ca7eb1207sm137644085a.4.2026.09.30.08.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 08:13:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790781238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=soivliGS3V3qOZBKXvbV1mUa7dYCQpqfRa1KAw9iuwc=; b=dd6BWahYHUq39rvC3K0Vq/YDBe1URnLOV9JYNzBD9CsPwhfUc5x868qFFDkB6kIFADIJia 9WsGTGRqZa7ClGRHdW1oqirydyy05zfj1JNxFeM2vengEPJ8nXz3LF5hiaq8kO1Kl+FDKD 6/B8w6dZNb15sVjLRXGNgI8xAQCUBxw= X-MC-Unique: Cz3ymEkgP7SS1fLA4mgwTg-1 X-Mimecast-MFC-AGG-ID: Cz3ymEkgP7SS1fLA4mgwTg_1790781237 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790781236; x=1791386036; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=soivliGS3V3qOZBKXvbV1mUa7dYCQpqfRa1KAw9iuwc=; b=BSzlFZbcZdDvdkmHp7kpzO9AkNi/yyRsVSBjjEcWotdWgFqfYagaIROJK7SFaGwF9v /jTP/cb5s4Taq/cQbjpPCSvzpdN2ZEEnXN04/u09PTINMcAYBsXLZIT6zsjYD/Xe9xbO MEFmF9SAC6uqg4Y1el4hUqFkUzsbSpcMRLjIVPz37j6x2vxkEdMUryH97jB9jFTRxcs9 aFBOZEWLgz2t5T7SOz1806Y72HfKRtIkdd8oZwAh9mBy8eFjo24Q+e+UAfZDVM7vUtY4 zk+e1ZCnQKezWb2OpLjp6/CDU3EwvH8h+REuHehqoeqmT+2V8J+zJNEd4QshHeGj1N/4 9EtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790781236; x=1791386036; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=soivliGS3V3qOZBKXvbV1mUa7dYCQpqfRa1KAw9iuwc=; b=ec1mCA4bkaaT0TRf0Ju5Kw4O2FA2GkV34ewRva3Kp43Np//U97D6a3JbYZALBG8rMJ rbnnRFRlGAa61DFaWa7mJJt6McXCb+0Rg5nzKurhLk5amnyzlbXEKxOF66ZBQEBJy9Kk tPMQl/Mo1T1Mm7FSSXOaCen+JgjqnP+ontjcwtItoRAYRMWK19BAfYnVj1DwkSAAeTLw ZXGshbzzpLgkGUDgOu81NBntlqSZsddqz6RGdykmANwEvwzFQVe0WV8JJtEGshf968zV GGWaiDZ+et1OPLxvAXNUO+unukZsp/FDs7KXcZrSzrxQ/XunCPLaufBMdnmYJMOE+ccm LsuA== X-Gm-Message-State: AFuF++kCF5CExmjwIAy6cjO22DJ+i9uK6kg/9vPwU3y4xU3bqFUgzmrC l2jh4wGInJGrceVElNaUbgB+GPhd/rBQYXsSrSwoABsD2oKkkD7pvXuDrcDMNZBFu+uigKPTGsH v9nt/GR173rARwlkLAtVK4qKVmNNUi33rnzG/XcT+8fdgKr7G+Vtq9q4lxw+Lu695CUKsRCkXev I6ULZ8u2nC8lAlgW0IdCtQlKL2BGoFSee/tm3QqYMo X-Gm-Gg: AYBFou0oeQ2sRmm0MZOqYf4XLPtO9dIQiIlwWTM8TZ5YgIVbk4+mMORi0+lsuPe1/zX v8gDXNKwKc2pgiHL4WUhpnbr5cKJEnrgroYt2dvkRjYWOj5q386qzyvynhwWpsdrSUbyOEnS/Ch +APFHHrkgiKUZLe+vsJnQhktv/s8F6Zl3zUT4ua9QOocTqYdmoa7g9pbtJu+dynSO5//ApFAujl 5YYxMBK24gbQNgiDRmBqHb+tYqO/hdXoOGoq1E5CnT4+5y4TwFuVPAp6uCOxxHAgFFCL7Wxc2Q2 R0WBq9q3m2afu8BezWZpPEaZXDDoHW72P2bhLPLO1ar3eKt8JetVtsWZ6IdKW7jDihKoThg= X-Received: by 2002:a05:620a:489a:b0:93c:60ea:d0b with SMTP id af79cd13be357-93ca9744bd1mr289329185a.21.1790781236401; Wed, 30 Sep 2026 08:13:56 -0700 (PDT) X-Received: by 2002:a05:620a:489a:b0:93c:60ea:d0b with SMTP id af79cd13be357-93ca9744bd1mr289318785a.21.1790781235558; Wed, 30 Sep 2026 08:13:55 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , Xiaoyao Li , Michael Roth , David Hildenbrand Subject: [PULL 08/12] machine: Rename machine_require_guest_memfd() to *_private() Date: Wed, 30 Sep 2026 11:13:36 -0400 Message-ID: <20260930151340.2817042-9-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930151340.2817042-1-peterx@redhat.com> References: <20260930151340.2817042-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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 @redhat.com) X-ZM-MESSAGEID: 1790781313869158501 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth Link: https://lore.kernel.org/r/20260929235109.1398509-9-michael.roth@amd.c= om Signed-off-by: Peter Xu --- include/hw/core/boards.h | 2 +- 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 ++-- target/i386/kvm/kvm.c | 3 ++- 7 files changed, 10 insertions(+), 9 deletions(-) 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/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/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.55.0 From nobody Mon Nov 23 05:00:09 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1790781286; cv=none; d=zohomail.com; s=zohoarc; b=YbAjIsa9UCB155Vy1ml2fVdmvyBVToSGZmjKrXOtcNDsHR45bZxjPVLx4LVzfUjWudsSt9o3lVr+hXE4HtuVopJDbaBxodjpF1VqZfYd89X4g2UoiwpXUOPSXrAoJtFHRpijaS1naj2/TGcn05rZcgo3G1pkkQmV2/Hfb7cMEc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790781286; h=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=J4WCzyxeLEnqop8Uya3q9OBPLKDNbeEY9ZKJooArDxM=; b=nuPMTW+oqN/EUAdcYqYoC03YxN8BvUbIEp4WjE+sqLhOYcXKywue/4YZF1UaV4tjeZkllhhXfFzpmqkzo6YblPll09vN73/9EMTR6JfGahrcZreUbBFL+TSvPwpv49l+KaAVgIgc04GOWk1ZOZ0vFRG9wXILPlFgg/phvUZioS8= ARC-Authentication-Results: i=1; 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; 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 1790781286069499.54491398536175; Wed, 30 Sep 2026 08:14:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBw0Y-0002Zf-Fz; Wed, 30 Sep 2026 11:14:10 -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 1xBw0S-0002Ub-Ma for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:14:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xBw0Q-0000j6-2y for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:14:04 -0400 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-49Ha1vakMFGFizvQMp_wsg-1; Wed, 30 Sep 2026 11:13:59 -0400 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-92e82060977so376316685a.1 for ; Wed, 30 Sep 2026 08:13:59 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93ca82d36c4sm137695385a.29.2026.09.30.08.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 08:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790781241; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J4WCzyxeLEnqop8Uya3q9OBPLKDNbeEY9ZKJooArDxM=; b=gBxTlWj5s8reBG8iaYHElHpuvH4RkeLMPjIuTKyD/LBmyXbZ3Hyh/uUh2MTE5CSzhLSmz1 7eL3LHs6fzQHMaw+ymvQkLCb7yxXtqtPqL5zv0u2M92haWPRxp8G6WIGpr0yiL8Sle+wls AENQrez01XUGrIL+RxsmS5iSEoZ1QCg= X-MC-Unique: 49Ha1vakMFGFizvQMp_wsg-1 X-Mimecast-MFC-AGG-ID: 49Ha1vakMFGFizvQMp_wsg_1790781239 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790781239; x=1791386039; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=J4WCzyxeLEnqop8Uya3q9OBPLKDNbeEY9ZKJooArDxM=; b=EKNMT/hXsWpeDh9ZtCG8Vg7PCcrxx0w5nlJJJMZzFvaaXD+OHD6no6lRWk/PWEObmQ tjRkPOeBaUMlEXZA4dUiHPESgOafhzdPPJVUdhhf3tK/TVdBYykMiWej00U2x6HnCR8p w5pebUPiElJkusBULANBA/JdDwNFoqQ3W5cKckl2dzV4Kwcl1KFSW01zk/67nAvXuAFo TybtCH9dm0DZLx921l0ZqncgaejdNg2tFN7hvOXmVJphbxLfJOf1uHzst4v9j20mJguR E4CquleBQdeePeIeR6xPcGdkiEds0VkUCMIruLkfOtNkwj5mZH3pWk4bsmAQ0PUwYmuf TJpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790781239; x=1791386039; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=J4WCzyxeLEnqop8Uya3q9OBPLKDNbeEY9ZKJooArDxM=; b=JL4jQPF2yYWhhLY9sPVAPwALVgue8YwP/FyhjnStrUoWzUqg5CNn2hBIf+MkYumZl1 +ujbR7ieOe2aRdo94v1w4umCxwJIjtrQYRm17DCyOZCax4WoboVw15RR49RXne+95UBm 2cvAqi91v9ok4e9Vixr6lImn9lOZeYM0tdCYls3yagQZTxicggdsTZVWm+fr0AiqNL/z WzhJAwA/JX7AG0exzP8OGj5gOWwDy2NbqhklwbGfhqrBDO/mupt6xDrZsLzsOWob9Sa2 QKhdv2tLjuGSNdsSEaR2AsFvr5SmzmBh5imJOSZb4Ulu+CD2n91eAxoXe8exVGj95EIq B38A== X-Gm-Message-State: AFuF++kzo6MM88YdIE+UHteunFr2STgX+JN8iifzfA88IpXDUN562vkd YuzgpM1yEkksw1XY1eidpezbdaCu2FOJ2IlLyy5gSmsExVu6NUl1ETOQZycYVuWmMlwXI5oa0QT LzfH1x/Ohm/yMVZbPUJ5paSd7Lo3tL3NXeyduNgAMF2gJe+jPxj85xVCxGak5GbsP3vxtxxdEbg lq2lW07OJSG3n252F4GU6DYTWh5QSoQQ2fNplKoP5d X-Gm-Gg: AYBFou3AcN7Xs5l/uV18YCR7aKfXmrLC675Ou/4WcMC60n7gaAk/aQRM176C8LyCh9+ SXonQWocLKso1Qeyc2swmr9z57ucxgBt5cxAOlfvtIdHKHIdN1KbTZQfA/qNSMpuvJxq6bNVfvf xjOz2iegmIc1ApNB2hKTmfBAAa7wBMa0l86+UVrpLpG0d+DsLjSVwmDWljwc6NW2S8ysp8XSwba 5FD3Su4GrRAunj1YZy7Hb4+osvLBifKfdrECEu7cA8ByRN7XUDOVMlGQnxLUv1gKzuVGfLfduKf cJjPTu8Nx7N5X4fEl15sEbALpGUug8gIAKvDZLva56GGQNUWJj7XF7jTwnk9PMOCqoH9jqg= X-Received: by 2002:a05:620a:298c:b0:93c:5ff3:2248 with SMTP id af79cd13be357-93ca9a65272mr254587585a.14.1790781238624; Wed, 30 Sep 2026 08:13:58 -0700 (PDT) X-Received: by 2002:a05:620a:298c:b0:93c:5ff3:2248 with SMTP id af79cd13be357-93ca9a65272mr254578185a.14.1790781237773; Wed, 30 Sep 2026 08:13:57 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , Xiaoyao Li , Michael Roth , David Hildenbrand Subject: [PULL 09/12] memory: Rename memory_region_init_ram_guest_memfd() to *_private() Date: Wed, 30 Sep 2026 11:13:37 -0400 Message-ID: <20260930151340.2817042-10-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930151340.2817042-1-peterx@redhat.com> References: <20260930151340.2817042-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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 @redhat.com) X-ZM-MESSAGEID: 1790781287798158500 Content-Type: text/plain; charset="utf-8" Differentiate it from fully shared guest-memfd use cases. Suggested-by: Xiaoyao Li Reviewed-by: Xiaoyao Li Reviewed-by: Michael Roth Reviewed-by: David Hildenbrand Signed-off-by: Michael Roth Link: https://lore.kernel.org/r/20260929235109.1398509-10-michael.roth@amd.= com Signed-off-by: Peter Xu --- include/system/memory.h | 10 +++++----- backends/igvm.c | 4 ++-- hw/i386/pc.c | 4 ++-- hw/i386/pc_sysfw.c | 4 ++-- hw/i386/x86-common.c | 4 ++-- system/memory.c | 8 +++++--- 6 files changed, 18 insertions(+), 16 deletions(-) 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/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/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.55.0 From nobody Mon Nov 23 05:00:09 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1790781326; cv=none; d=zohomail.com; s=zohoarc; b=L3+/1z+ip4jckKsEdF63jwCrlNVzR3lb28r0GNtEitPSB3XKQuxtRVvRq2U8OjzoZVB19G6nRWhR5uyMJE6GzMfoYVTMVTmYs1m3aBNmvbLexJ7aKUzFHDm8VqxvekHGMMQqwqq+NiaHspC/gPVp3HhERT9WtO2arctDPha39Uo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790781326; h=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=OAkMCzIG6pkTbKrpmXD51Qfgv+c+dPd+iK7uwg/2tGk=; b=ZomZEiYg431sKVp1H1SBNRFdI1/F5aErUj3k/AkDP4zN8HBJOeUJ9BKLiBp5cXoXGwAb5O3KCkppIrBFOJHsyFd8yN4QzY76/+KRiSlUK/HOJ22/Srtz3+boZz2u34nHshXuJv/lkZnMqJ423WwYDi/hlZ3bOPbzPdXPOD9RR4w= ARC-Authentication-Results: i=1; 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; 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 1790781326503193.74999393938413; Wed, 30 Sep 2026 08:15:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBw0W-0002YN-Ni; Wed, 30 Sep 2026 11:14:08 -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 1xBw0T-0002Ue-Il for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:14:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xBw0R-0000jZ-BF for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:14:05 -0400 Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-558-74tbDB3LMQiXHI4X-j35xg-1; Wed, 30 Sep 2026 11:14:01 -0400 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-8a9977a4261so72038467b3.2 for ; Wed, 30 Sep 2026 08:14:00 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-917a8991572sm1701236d6.8.2026.09.30.08.13.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 08:13:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790781242; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OAkMCzIG6pkTbKrpmXD51Qfgv+c+dPd+iK7uwg/2tGk=; b=J72iep1SZ5YzNTkpTQCGvONHecaCPnZmwpgK+u00krvAcC2LD6PIPxAzt50dZdqOAaGuZA j39o3Nt0O5e7iToGufTBdPEAE3Gf4ZU/KAlSDBV0K2W/+/z4ulGCVUjZWT70qOBMxPxEnY KacCSebMFASzvaOYnbm76Tpa8KhmzGw= X-MC-Unique: 74tbDB3LMQiXHI4X-j35xg-1 X-Mimecast-MFC-AGG-ID: 74tbDB3LMQiXHI4X-j35xg_1790781240 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790781240; x=1791386040; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OAkMCzIG6pkTbKrpmXD51Qfgv+c+dPd+iK7uwg/2tGk=; b=Hqjv0S+p2Jl5dXJGn6LEXMeYF0hZr5huSKSofUVjkD9qZc7YtYhrCQeEMoLoiERNvC KXbzpuPtcOd6IsLTJFqUhdHTxInM8A1XkjdkgrHG+R+lTwt3Ex5kix6lzmH8Y+mzlD70 mzqWTgnS67IV1xGBRJ4YvARUescNyht+kd2AMXsU1zfrQ/9UoPZG123L35gsoejCL3SJ WS3bsRTCoXqZmk4gVwtkmXwjBEJ3xoK01jAB/iQpBIqYsiVXujVXmrNXGZz9wW28tsCW 2FMQjiiyTcRcTakuCs2XcKngLl6sMu3ngBWUjpsErUnXCMp6YCMnyTA0kV99oWnz7EML IYiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790781240; x=1791386040; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=OAkMCzIG6pkTbKrpmXD51Qfgv+c+dPd+iK7uwg/2tGk=; b=A1SYkJeN/qeHsbVpr9dMcimXjO68BUywr5yYYvIg+E9I+8Rf9zIVczmvsOKh5EaQPN pMboXawoAaCJa+bIwnQ44JNyzKaqoJIksSWllPacmJ4GIhXfqftsQHB307Q2pZf8YSrb wukJ+NohS/9bHdzP0yEPf74RVHfjOGd7Gv6DOsGEcdM/pvzCaOj8VpVB3i7YG1U+6F2G UIYiT1/iP30hbS5PJIQjlCf8m83SAlh17D8C2ny1615XPgGVeHao1kx+5Tnukf5Wn0R7 IYIbA0pv7+m0XzQPXLNln9TA1FDRQeHPVNUrKG/lG6SoHy0vZLKhWwV2lCh7PEIq8Uj8 DO6A== X-Gm-Message-State: AFq9FYIg4rga2gsd2dIeHPTbFFcdMG0BqzSd6LkL3FPL3CcK1aDSCbid pxWci9CeI0XrxtO0GBDKzF+vZ9IAbqHaO2Bc0uLaaRSrc3DzMaIzeu1PvgaeYQNSDhN1k+k4ef1 /p8H34R6LTZrqr93oafVyhQSPjAGhenP8aHzhvR394qhY+vSu5QsgihG+C9heee086y9rgvnLot A/ScKIPN9XhpxwyyHq6IBTMZ2t5OqqKgaUigOxDXG5 X-Gm-Gg: AYBFou3+cHbidGkcY0A1ggzgsKLQuJXHLy0dzt7ZNyvwtr6gFvswMmUswvVt54yrpT/ jFq0ssjnO0eE501puJbw43tR7Ge2YWJ5YTVTamvb82KM1AEKslry39wOssOyuRYA0zx2Mcme4Zf eqlRLYygF08Y+jurtKhy8DbQrU52YvxqLHLiRvJX7qCQdfFHsOhiJNJbXqHxSRyJwocgErQkPbp Z8Q8YwjNzVfiEBr4Nt1k+VLzkRYQ8gVQYc4U1mLC1I8PyiHLB9W7oMu1qvT6TjL98p31307XHFZ GQbWY2+19j/MlA4rr5VOhbDkMZ/t1Krt+nM8rWzkxmz5gjmrRd7vM0GvhnuEJ3CTiGJxRdk= X-Received: by 2002:a05:690c:4f12:b0:8a8:4931:6190 with SMTP id 00721157ae682-8ac93c01368mr6331777b3.59.1790781240142; Wed, 30 Sep 2026 08:14:00 -0700 (PDT) X-Received: by 2002:a05:690c:4f12:b0:8a8:4931:6190 with SMTP id 00721157ae682-8ac93c01368mr6331407b3.59.1790781239488; Wed, 30 Sep 2026 08:13:59 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , Xiaoyao Li , Fabiano Rosas , David Hildenbrand , Michael Roth , Markus Armbruster Subject: [PULL 10/12] hostmem: Support fully shared guest memfd to back a VM Date: Wed, 30 Sep 2026 11:13:38 -0400 Message-ID: <20260930151340.2817042-11-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930151340.2817042-1-peterx@redhat.com> References: <20260930151340.2817042-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1790781328126158500 Content-Type: text/plain; charset="utf-8" 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 Co-developed-by: Michael Roth Signed-off-by: Michael Roth Acked-by: Markus Armbruster Link: https://lore.kernel.org/r/20260929235109.1398509-11-michael.roth@amd.= com Signed-off-by: Peter Xu --- docs/system/confidential-guest-support.rst | 2 + docs/system/guest-memfd.rst | 60 +++++++++++++++++++ docs/system/index.rst | 1 + qapi/qom.json | 15 ++++- backends/hostmem-memfd.c | 67 ++++++++++++++++++++-- 5 files changed, 139 insertions(+), 6 deletions(-) create mode 100644 docs/system/guest-memfd.rst 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 ## 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); --=20 2.55.0 From nobody Mon Nov 23 05:00:09 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1790781349; cv=none; d=zohomail.com; s=zohoarc; b=a8ErSlu9WnUIddnlT+U+aeet4Ozp9fpEKeTTHkXf0PTjGV62pvD30U5k78BApi1Cd2v+Tf0QiDvGP8CNj7z3syF2z/tEhY5y6mPQPDnYzLd1HbuAZvGGZYWnXILSyJRqu3TMnYFiwD0Iky8HzvhTj8Z3dHM3MoXVVrOecjPNYv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790781349; h=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=EN6eRhCXMBdbbKqBU4HbeNBBeUVb05+KYNAQ+SJ/VMU=; b=l9fM6e4le4kfcBOBEYOyP0XVyGdtClXjV1M4wFQQgP+vx1yI1q7Ixh6rSwes4Lx1gR17wAx8BKRneTNQi7pO58a2utMp0mwL7eOlbAE5RZK3UY+gVgg1DrTyT5+JNHbjgLKmBvSDmy3visYKfEFftCCJXZdKg+lqu7uDaRRYAMs= ARC-Authentication-Results: i=1; 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; 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 1790781348963528.9541421103626; Wed, 30 Sep 2026 08:15:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBw0X-0002ZQ-Si; Wed, 30 Sep 2026 11:14: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 1xBw0V-0002XQ-Dp for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:14:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xBw0S-0000k3-Ur for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:14:06 -0400 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-450-LPleVmQ-MxKfQ-kcsY08pw-1; Wed, 30 Sep 2026 11:14:02 -0400 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-91789a9107fso35426896d6.1 for ; Wed, 30 Sep 2026 08:14:02 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93ca83283besm136888585a.40.2026.09.30.08.14.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 08:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790781244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EN6eRhCXMBdbbKqBU4HbeNBBeUVb05+KYNAQ+SJ/VMU=; b=EMb4w40c+TAh0pH4vlq5NxPuiu7LJSak9QJPUPx7JnuddROIhT5Qb4K5JmLQNSVRwQssGA QSqUQsGXh4b7nMLz1kSEpNGTOMPP6KF1fk4ewOnL64KMN010ykgunAmXPfqLrIyQVDfQFW WRqjEPkDpN1q0XZMHssUYaRin1p+DFQ= X-MC-Unique: LPleVmQ-MxKfQ-kcsY08pw-1 X-Mimecast-MFC-AGG-ID: LPleVmQ-MxKfQ-kcsY08pw_1790781242 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790781242; x=1791386042; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=EN6eRhCXMBdbbKqBU4HbeNBBeUVb05+KYNAQ+SJ/VMU=; b=CCAjimzChW8lfSr4GFRlro+arDx0nYbLu2U2vswRSRPqL9oKw4Bl0KAQsWeXnIN/v9 wz5Ig0w8vsAFe5cZ5otPtVR9d6M8/BuNtSh5aDv87kE0Y9OJ3lsx3hwvsFZ4Z0yryDca KZx0RywVMrX7ltvD4NJZksNI5QCjZ0baMKs9UX4OTpifM6Ff+jcFHbSYwnWVMe/8JNvR gfUy0GNfiemaOsjAZHPAaKEUTtR6VjA+/r0Tp2LbPyCOwWdcmHSEpqi+hMuX2cMM3pmF VMRpsjgy/MB2aHL81yvauCOHPStDxKHkmfO0c4mePOomDj0LrqzdNpGUoM0UZlo8Eytd gszw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790781242; x=1791386042; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=EN6eRhCXMBdbbKqBU4HbeNBBeUVb05+KYNAQ+SJ/VMU=; b=Numb5g4yIdZ/rJRcGL9sl2zqIcMQrdEA0FlRLMMFKpD0/ZXVrhmEPTS1q2ApcDIAn6 kFr1pJFtSopXQrGN16dRaBztr1y6h3XxDIS7qVAQu8hjnz4iWwN+6nWl047+gsDLpFEr K0sniUrswGkjKj6hXdUbPWD0Ax6q4teryNqq0/b/T0XCy88FEVkibSVGjrinxQjCafWP hI0RP+/xjas+k2/ny3tY7Nd7lMkdq4eI9/3J6yu0GnnD9eDEHIpN5RYShjjor5YX9HnX JCAx5SUUuHQVe2Bs875NR3bL8m3juRixMjgWSzL71I8NbiLXB4ROwwFEAM8XV8RRRZdf HJ8g== X-Gm-Message-State: AFuF++k4UdY7mNv4VOMwf5COg7Y17uFIZcbSIdQ2WTNrtS0eEZMq8LKB 0EiYoNC7fNJEyC6O8tci8WO5XfwGzHiQcnUI2ibAmCMMhiqQuvmdwHvJ6jWG2HX6YwgkaPKi94x cm8ctobj4AwpsXftivhCtZgQY9kGRjyh64mZvcbDPbuhK5sh/7CZWsundx9MK+dNvXKK6tR+nJ/ u2JG/xaXYJ+NI6nVup2RLaMDat2s03okoxtXqs+4b3 X-Gm-Gg: AYBFou3MaoUOZktJYdPeHDohWkDawSeHKlnfHfYmrIkaMv0AzCaiAt0CSk+z0i2wjkk VCQWaVzfYk/9uXaYGcs6xGpMR54/yes2RXJbHXJE8APSHttOO9Fk8cVCWp8izSKXBitYPTebQgP eaoLL4oKdviRX7g3ICAt0eKltqL45pUgLa6muAr9n2It5V2Pbg05lioPIC3F6lAby3xZ3FUELDO fLZTI7EFcUL3Cb37mdzfGMtpi3H9rhj/NLMHQx3REWgL14L+IfQ4AZkh+J9ilv6c8hM/C/ojWca UCVWI9T5I7ztd2B2N3aUQzFg+w2p8K6mu03HD/YgtbAruBDynKQYpfSpVcQueH+DJWaRots= X-Received: by 2002:a05:620a:2793:b0:939:993e:bffb with SMTP id af79cd13be357-93ca97440b2mr293562185a.22.1790781241693; Wed, 30 Sep 2026 08:14:01 -0700 (PDT) X-Received: by 2002:a05:620a:2793:b0:939:993e:bffb with SMTP id af79cd13be357-93ca97440b2mr293555085a.22.1790781241081; Wed, 30 Sep 2026 08:14:01 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , Michael Roth Subject: [PULL 11/12] tests/migration-test: Support guest-memfd init shared mem type Date: Wed, 30 Sep 2026 11:13:39 -0400 Message-ID: <20260930151340.2817042-12-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930151340.2817042-1-peterx@redhat.com> References: <20260930151340.2817042-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1790781350275158500 Content-Type: text/plain; charset="utf-8" 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: Michael Roth Link: https://lore.kernel.org/r/20260929235109.1398509-12-michael.roth@amd.= com Signed-off-by: Peter Xu --- tests/qtest/migration/framework.h | 4 +++ tests/qtest/migration/framework.c | 60 +++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) 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 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; } --=20 2.55.0 From nobody Mon Nov 23 05:00:09 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; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1790781343; cv=none; d=zohomail.com; s=zohoarc; b=e6daDgb5q0YvxQeD/mAlmaTTlP8j9otCoK05wjcNGogw6Qzd7NZ3woYNpmql1NeaE12KHvFEvrncuW2HmQF8U3zciWPtQhQ2u4DrMHn0YysaAt6XyAWkl3VAuxqJ5oXZMRW4ViNqrYVYFV2h5+JpyF1GAettL3Of4OhPvIzikZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790781343; h=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=SX/NPkX49pXCc6ef7nu6Mpt5rBrWjUkLaeEJs6w9K1Q=; b=YCVM1d8dYH5HNDv1GDiRynNtlANxEzZXc8KVvnIAJ70I7ceHfjru+MVXdNUOa5YADQNwKKDVvvFOe4mRYQ13nQnR9yj0RFYS1nEdTJkbBWnI11jAIKI/nRhRQGn+kFEgXGJhcSfjZXJg3b6A7Z8pei36XX/L2NCSP7jGAh4bPCk= ARC-Authentication-Results: i=1; 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; 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 179078134323738.594695118493405; Wed, 30 Sep 2026 08:15:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xBw0Z-0002aM-1E; Wed, 30 Sep 2026 11:14:11 -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 1xBw0W-0002YR-Ns for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:14:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xBw0U-0000lA-U0 for qemu-devel@nongnu.org; Wed, 30 Sep 2026 11:14:08 -0400 Received: from mail-yw1-f200.google.com (mail-yw1-f200.google.com [209.85.128.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-652-WE2Wh1l7ME-CDIyikn69JA-1; Wed, 30 Sep 2026 11:14:04 -0400 Received: by mail-yw1-f200.google.com with SMTP id 00721157ae682-8acb6172b5fso6203897b3.0 for ; Wed, 30 Sep 2026 08:14:04 -0700 (PDT) Received: from localhost ([142.188.212.246]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-917a89edf7fsm1659176d6.21.2026.09.30.08.14.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Sep 2026 08:14:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790781246; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SX/NPkX49pXCc6ef7nu6Mpt5rBrWjUkLaeEJs6w9K1Q=; b=DRpP/9Tr3YetDLqliYVmfqETTfAGUrRZDjoH1lMvl3KREdYeDVwfdXzHcULso8ilhXG5cY 5+6qp7aRkiK17JftL6ASp7a500t/u1xQBP+gcZhmMLM+xzA40wjTqD1lU/E15VHg4lcjf+ lZOugWTMOFGEP7I8teIsrgDdfBuvo3w= X-MC-Unique: WE2Wh1l7ME-CDIyikn69JA-1 X-Mimecast-MFC-AGG-ID: WE2Wh1l7ME-CDIyikn69JA_1790781244 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790781244; x=1791386044; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=SX/NPkX49pXCc6ef7nu6Mpt5rBrWjUkLaeEJs6w9K1Q=; b=C+xYpbGluje56BO7pwPPIl0K74Os8NlfNTATCi4kaHHm/ZPjwy9PnPNfuvGnKy9Gbb bx9S/uHQXiOvyJ9r9slME1ik5FEvXqjxoIsA3ZxtCQ5PJwo/82wxbszlFmgOXlm82M5+ PzRvglzKmc15x9YwlRojOGv1SA5WE1I4mxlOSqyg0jqo1xGW61aCa0RmW0wy1aYF18sT SiT5QYab/3x6SPyb8RjKLUYNPm5D9hPwvJsv9wsh+aHR9lnhMSFphuRjgsrnYAYt+Rkr UN1ExzZ187yQbSlGxBw6q2fWh4bqvFClVyNgWijAC1E+1VKng7YQTG9k1UnrM0+Xoixa pDyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790781244; x=1791386044; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=SX/NPkX49pXCc6ef7nu6Mpt5rBrWjUkLaeEJs6w9K1Q=; b=KOvw/26sIPd2Xb+Yav7VYGbffszdKuba6+p8UqqqeXhV65rreGDxspp48QTpChszsr TYeedySlJ/knxHsHyWv2JYEIs+5T+ifJ0491y7dOvBpvMD6yaVWbyfejdjYliT388Q8Z GRLU/qejtOKocMgBztXD4Een+seOpOm7rkzMWF4YL/Hf072S2jeaoVQJOnUweru3gUjC 0sZmwSpeyBea/lFKHh1TLWjvnxbXBZb5lPOKnukli0QrLIERO7iERok5jpE5q7MKZWwU SQFtRfEmFGc9+4IZSTJK6X1q5fzVFtHkOOBevonVogSKZ0BIFCspxmYbHiD0Ldp+HDUB CcGQ== X-Gm-Message-State: AFq9FYKcgXM3FU/DSmDNuts4HzqFjEm3OvMEBFAW+UPfkyh6XpS+s5cd rGy5+uxxNQfIgxV2Jr0v9XklDLeAFWdoXDrMw/Hhqyo6JBImMwTQAyJjss6QMLwLQdEAvxoJBse LvAMLn1rbxQwR6i1NRsmCexCiWpPB8NNJ5LXx54rLX6zELp6xHkPnzQgRkhBD1ZJEyyySX/CeTD rTQe0wXkHcwzS2euoB1mJb/Q6I/XtBCpiCgHzGQzKe X-Gm-Gg: AYBFou086O3Nb4NYQ/A2BfU7ndBsWPanHaiDsxvxLkQfiye1yTTBDVL2RvAUWgeaHBS TC7sPgAxGdhloLxWDrifPuBISfa4vaJ9JuS1ipzyAffrGbEMSQkvapQT4FF9+0NE82weotuTa3V yux1zoMTlliO0URr0Ci9rbb2HxdTdDLafyMRsn43pxkmomt3su6mT6YukpoPXBead+4eUzfBbdC cllWLVSvpIj6ay5Iu0mwmXkn37YCQo5MwxK+PUrrUKQfCN1rvMXRDGjF+k/AKqMbC+nUAvKafbx 6OyNUWqx36oELUQYGgOCv9VKylo1P04UQBlksn+3afXOmSpjrZr37wD6qB424h9JSa+eqFs= X-Received: by 2002:a05:690e:4503:20b0:671:83b7:d703 with SMTP id 956f58d0204a3-676834fc559mr684075d50.91.1790781243651; Wed, 30 Sep 2026 08:14:03 -0700 (PDT) X-Received: by 2002:a05:690e:4503:20b0:671:83b7:d703 with SMTP id 956f58d0204a3-676834fc559mr684048d50.91.1790781242787; Wed, 30 Sep 2026 08:14:02 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , Fabiano Rosas , Michael Roth Subject: [PULL 12/12] tests/migration-test: Add a precopy test for guest-memfd Date: Wed, 30 Sep 2026 11:13:40 -0400 Message-ID: <20260930151340.2817042-13-peterx@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930151340.2817042-1-peterx@redhat.com> References: <20260930151340.2817042-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 client-ip=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.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_H3=0.001, RCVD_IN_MSPIKE_WL=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 @redhat.com) X-ZM-MESSAGEID: 1790781344112158500 Content-Type: text/plain; charset="utf-8" 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.). Reviewed-by: Fabiano Rosas Signed-off-by: Michael Roth Link: https://lore.kernel.org/r/20260929235109.1398509-13-michael.roth@amd.= com Signed-off-by: Peter Xu --- 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.55.0