From nobody Mon Oct 27 11:10:18 2025 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=1761246052; cv=none; d=zohomail.com; s=zohoarc; b=gyWfh382XHfCb6X6TKXF1wOFXzqy+wl64HEdGJfi8C9jUP/JtrPOpidif2ap+EPylyR3j07g+HDoFtz+UK/xIGwsairSGIvSPuy30NmGeg+pujjC9rzCMSmwDyoAsnvu8kAGyVZZ+fvwIzo2tqNqqR0UCf4APYUnewwxxPmxB7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761246052; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1mFytEungiXULgeCax6m/2twHAUSzEp8s0ufZE1rBhA=; b=jbbBU0y/qE9UrFiV0wEzhjCUmEsAut259UtVRe/6Xt1QKzAVh6ABFi0Q3ePHq9XD/Mj47bQi5OSeYO1B1/suNIENoJk/Q+q2VjzHlTriJd+O8Tv0LQ3T1ekdBcWnpHUa9Xw1lUVuI1r5TzFLY/bVB/+z/uBBFo4w9X6iIeAjpDY= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761246052827902.5267586886598; Thu, 23 Oct 2025 12:00:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vC0X5-0006Xv-Tl; Thu, 23 Oct 2025 14:59:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vC0X1-0006W4-7b for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:27 -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 1vC0Ww-0003Cu-Qf for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:26 -0400 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-204-wZPNPikJNgO4wYlmYLWbjQ-1; Thu, 23 Oct 2025 14:59:20 -0400 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-88f3c733d98so786485985a.0 for ; Thu, 23 Oct 2025 11:59:20 -0700 (PDT) Received: from x1.com ([142.188.210.50]) by smtp.gmail.com with ESMTPSA id af79cd13be357-89c0ec61770sm213940585a.26.2025.10.23.11.59.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 11:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761245961; 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=1mFytEungiXULgeCax6m/2twHAUSzEp8s0ufZE1rBhA=; b=FA0WICfy5J60CVPfDNw97bLXTMiODfZHN2drbxC7WGDGKmMOGYVvf7Z+Vw0buwIBp+atS/ Y50ha55TuYSCJ26wP6RiPwryu3TM1bY34JqobR7aHIHN5Q5oMUgbRO7D24ZanEGNk0dGOU zwnua3XAFhGJcKTGFqyo2b8LNWg7VaU= X-MC-Unique: wZPNPikJNgO4wYlmYLWbjQ-1 X-Mimecast-MFC-AGG-ID: wZPNPikJNgO4wYlmYLWbjQ_1761245960 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761245959; x=1761850759; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1mFytEungiXULgeCax6m/2twHAUSzEp8s0ufZE1rBhA=; b=S/+gUHkNsiHFSxhXHPr8hQzorbEynXm31WvRymw2Xh+bC1BMA3FjYc3tIbRnZ9YWhA GNUE6xC07bMsD17TTLcULxDNWpBDv7ofKhsfYyC+a9K/UX2Dg0Pysl1hX/tS6loWfrU7 ggy/AFtR8DLYqkG6QhgW9naV7/xR67qGva4j/U435V3U/vhmi4tEKPHxhb2smlfqoFkn 0rjgyYkuT2ooD2vxzolb4IPlOh2h1E2pzGwmmmHx2yevXtIyAsLBdEL8BiDY10bvymLj O39ZtImn+sW99775vYrtgcrJSmKlLwxNjop0fglh6c4nrAqCo9TduUsrwylzPNpR/yKI +Veg== X-Gm-Message-State: AOJu0YzDqk0aWch6GB8YL4Kyv4hoZRqma8czUJiBH9RVADHI6jkWnc7F ZDNXxCAIifT9yEf9QIAfIqvtmYNFViB7zq7WHGk0aAM/g91yEcnZwtsxaTIe/LLzUGhe7WiVTQl PULx4Nb2RqCOWiQTsvKsR6KoFKTJyy8A75CKOd3fxl/lfQgII/eFM/qiwKCF5jrslOAm+335pf5 f0syQ1VAIngGALxKQXc71b4LGR8tANbB6jEvS1aA== X-Gm-Gg: ASbGnct3zNlOys6Os9FaztBChlDow8We0QN/6CbcnsyK4sA/UabTLgXapJhR0bfOfdv Cb1+L4RzxWJyw3V3IqzqvdsC3qPlcoQRGn/L2q8J0JutpnLTYfvvDR6g1TZnFkUPd/jWBAFEcgE k5yGBolczHWE6QUDTl0P2/C4ywGuHXp4cZNv1uR/vmap2D0fhmdTYszsg7pgmFkYspIlFtRgpr0 j0ampwOawQ2igAQChwwn04i8gG1Pt9fGTcm5q79YGmN4Z6IEhd/9wI6NS7z0GWiTm2ZZcz3KNf7 IR6oniN5n/DDaCsPzt7/dHJVF8pOJ4Hk5h6utQ4ctVNPsFDaFPX5T57C6BJGqc1q X-Received: by 2002:a05:620a:4489:b0:891:5a6a:fe9b with SMTP id af79cd13be357-89ae1dfacf9mr767328585a.33.1761245958920; Thu, 23 Oct 2025 11:59:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHg8WPzYES7Qqz1a2GKpfMW02O1vfBqoxtXQLbjRKQWONYUKZpSh2ZbT96B+Sm2M92H5p/8Pg== X-Received: by 2002:a05:620a:4489:b0:891:5a6a:fe9b with SMTP id af79cd13be357-89ae1dfacf9mr767322385a.33.1761245958203; Thu, 23 Oct 2025 11:59:18 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Paolo Bonzini , Fabiano Rosas , Chenyi Qiang , David Hildenbrand , Alexey Kardashevskiy , Li Xiaoyao , Juraj Marcin Subject: [PATCH 1/8] linux-headers: Update to v6.18-rc2 Date: Thu, 23 Oct 2025 14:59:06 -0400 Message-ID: <20251023185913.2923322-2-peterx@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251023185913.2923322-1-peterx@redhat.com> References: <20251023185913.2923322-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=lists.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 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: 1761246059462158500 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Xu --- include/standard-headers/linux/ethtool.h | 1 + include/standard-headers/linux/fuse.h | 22 ++++++++++-- .../linux/input-event-codes.h | 1 + include/standard-headers/linux/input.h | 22 +++++++++++- include/standard-headers/linux/pci_regs.h | 10 ++++++ include/standard-headers/linux/virtio_ids.h | 1 + linux-headers/asm-loongarch/kvm.h | 1 + linux-headers/asm-riscv/kvm.h | 23 ++++++++++++- linux-headers/asm-riscv/ptrace.h | 4 +-- linux-headers/asm-x86/kvm.h | 34 +++++++++++++++++++ linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 1 + linux-headers/linux/kvm.h | 3 ++ linux-headers/linux/psp-sev.h | 10 +++++- linux-headers/linux/stddef.h | 1 - linux-headers/linux/vduse.h | 2 +- linux-headers/linux/vhost.h | 4 +-- 17 files changed, 130 insertions(+), 11 deletions(-) diff --git a/include/standard-headers/linux/ethtool.h b/include/standard-he= aders/linux/ethtool.h index eb80314028..dc24512d28 100644 --- a/include/standard-headers/linux/ethtool.h +++ b/include/standard-headers/linux/ethtool.h @@ -2380,6 +2380,7 @@ enum { #define RXH_L4_B_0_1 (1 << 6) /* src port in case of TCP/UDP/SCTP */ #define RXH_L4_B_2_3 (1 << 7) /* dst port in case of TCP/UDP/SCTP */ #define RXH_GTP_TEID (1 << 8) /* teid in case of GTP */ +#define RXH_IP6_FL (1 << 9) /* IPv6 flow label */ #define RXH_DISCARD (1 << 31) =20 #define RX_CLS_FLOW_DISC 0xffffffffffffffffULL diff --git a/include/standard-headers/linux/fuse.h b/include/standard-heade= rs/linux/fuse.h index d8b2fd67e1..abf3a78858 100644 --- a/include/standard-headers/linux/fuse.h +++ b/include/standard-headers/linux/fuse.h @@ -235,6 +235,11 @@ * * 7.44 * - add FUSE_NOTIFY_INC_EPOCH + * + * 7.45 + * - add FUSE_COPY_FILE_RANGE_64 + * - add struct fuse_copy_file_range_out + * - add FUSE_NOTIFY_PRUNE */ =20 #ifndef _LINUX_FUSE_H @@ -266,7 +271,7 @@ #define FUSE_KERNEL_VERSION 7 =20 /** Minor version number of this interface */ -#define FUSE_KERNEL_MINOR_VERSION 44 +#define FUSE_KERNEL_MINOR_VERSION 45 =20 /** The node ID of the root inode */ #define FUSE_ROOT_ID 1 @@ -653,6 +658,7 @@ enum fuse_opcode { FUSE_SYNCFS =3D 50, FUSE_TMPFILE =3D 51, FUSE_STATX =3D 52, + FUSE_COPY_FILE_RANGE_64 =3D 53, =20 /* CUSE specific operations */ CUSE_INIT =3D 4096, @@ -671,7 +677,7 @@ enum fuse_notify_code { FUSE_NOTIFY_DELETE =3D 6, FUSE_NOTIFY_RESEND =3D 7, FUSE_NOTIFY_INC_EPOCH =3D 8, - FUSE_NOTIFY_CODE_MAX, + FUSE_NOTIFY_PRUNE =3D 9, }; =20 /* The read buffer is required to be at least 8k, but may be much larger */ @@ -1110,6 +1116,12 @@ struct fuse_notify_retrieve_in { uint64_t dummy4; }; =20 +struct fuse_notify_prune_out { + uint32_t count; + uint32_t padding; + uint64_t spare; +}; + struct fuse_backing_map { int32_t fd; uint32_t flags; @@ -1122,6 +1134,7 @@ struct fuse_backing_map { #define FUSE_DEV_IOC_BACKING_OPEN _IOW(FUSE_DEV_IOC_MAGIC, 1, \ struct fuse_backing_map) #define FUSE_DEV_IOC_BACKING_CLOSE _IOW(FUSE_DEV_IOC_MAGIC, 2, uint32_t) +#define FUSE_DEV_IOC_SYNC_INIT _IO(FUSE_DEV_IOC_MAGIC, 3) =20 struct fuse_lseek_in { uint64_t fh; @@ -1144,6 +1157,11 @@ struct fuse_copy_file_range_in { uint64_t flags; }; =20 +/* For FUSE_COPY_FILE_RANGE_64 */ +struct fuse_copy_file_range_out { + uint64_t bytes_copied; +}; + #define FUSE_SETUPMAPPING_FLAG_WRITE (1ull << 0) #define FUSE_SETUPMAPPING_FLAG_READ (1ull << 1) struct fuse_setupmapping_in { diff --git a/include/standard-headers/linux/input-event-codes.h b/include/s= tandard-headers/linux/input-event-codes.h index 00dc9caac9..c914ccd723 100644 --- a/include/standard-headers/linux/input-event-codes.h +++ b/include/standard-headers/linux/input-event-codes.h @@ -27,6 +27,7 @@ #define INPUT_PROP_TOPBUTTONPAD 0x04 /* softbuttons at top of pad */ #define INPUT_PROP_POINTING_STICK 0x05 /* is a pointing stick */ #define INPUT_PROP_ACCELEROMETER 0x06 /* has accelerometer */ +#define INPUT_PROP_HAPTIC_TOUCHPAD 0x07 /* is a haptic touchpad */ =20 #define INPUT_PROP_MAX 0x1f #define INPUT_PROP_CNT (INPUT_PROP_MAX + 1) diff --git a/include/standard-headers/linux/input.h b/include/standard-head= ers/linux/input.h index d4512c20b5..9aff211dd5 100644 --- a/include/standard-headers/linux/input.h +++ b/include/standard-headers/linux/input.h @@ -426,6 +426,24 @@ struct ff_rumble_effect { uint16_t weak_magnitude; }; =20 +/** + * struct ff_haptic_effect + * @hid_usage: hid_usage according to Haptics page (WAVEFORM_CLICK, etc.) + * @vendor_id: the waveform vendor ID if hid_usage is in the vendor-define= d range + * @vendor_waveform_page: the vendor waveform page if hid_usage is in the = vendor-defined range + * @intensity: strength of the effect as percentage + * @repeat_count: number of times to retrigger effect + * @retrigger_period: time before effect is retriggered (in ms) + */ +struct ff_haptic_effect { + uint16_t hid_usage; + uint16_t vendor_id; + uint8_t vendor_waveform_page; + uint16_t intensity; + uint16_t repeat_count; + uint16_t retrigger_period; +}; + /** * struct ff_effect - defines force feedback effect * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING, @@ -462,6 +480,7 @@ struct ff_effect { struct ff_periodic_effect periodic; struct ff_condition_effect condition[2]; /* One for each axis */ struct ff_rumble_effect rumble; + struct ff_haptic_effect haptic; } u; }; =20 @@ -469,6 +488,7 @@ struct ff_effect { * Force feedback effect types */ =20 +#define FF_HAPTIC 0x4f #define FF_RUMBLE 0x50 #define FF_PERIODIC 0x51 #define FF_CONSTANT 0x52 @@ -478,7 +498,7 @@ struct ff_effect { #define FF_INERTIA 0x56 #define FF_RAMP 0x57 =20 -#define FF_EFFECT_MIN FF_RUMBLE +#define FF_EFFECT_MIN FF_HAPTIC #define FF_EFFECT_MAX FF_RAMP =20 /* diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-h= eaders/linux/pci_regs.h index f5b17745de..07e06aafec 100644 --- a/include/standard-headers/linux/pci_regs.h +++ b/include/standard-headers/linux/pci_regs.h @@ -207,6 +207,9 @@ =20 /* Capability lists */ =20 +#define PCI_CAP_ID_MASK 0x00ff /* Capability ID mask */ +#define PCI_CAP_LIST_NEXT_MASK 0xff00 /* Next Capability Pointer mask */ + #define PCI_CAP_LIST_ID 0 /* Capability ID */ #define PCI_CAP_ID_PM 0x01 /* Power Management */ #define PCI_CAP_ID_AGP 0x02 /* Accelerated Graphics Port */ @@ -776,6 +779,12 @@ #define PCI_ERR_UNC_MCBTLP 0x00800000 /* MC blocked TLP */ #define PCI_ERR_UNC_ATOMEG 0x01000000 /* Atomic egress blocked */ #define PCI_ERR_UNC_TLPPRE 0x02000000 /* TLP prefix blocked */ +#define PCI_ERR_UNC_POISON_BLK 0x04000000 /* Poisoned TLP Egress Blocked = */ +#define PCI_ERR_UNC_DMWR_BLK 0x08000000 /* DMWr Request Egress Blocked */ +#define PCI_ERR_UNC_IDE_CHECK 0x10000000 /* IDE Check Failed */ +#define PCI_ERR_UNC_MISR_IDE 0x20000000 /* Misrouted IDE TLP */ +#define PCI_ERR_UNC_PCRC_CHECK 0x40000000 /* PCRC Check Failed */ +#define PCI_ERR_UNC_XLAT_BLK 0x80000000 /* TLP Translation Egress Blocked= */ #define PCI_ERR_UNCOR_MASK 0x08 /* Uncorrectable Error Mask */ /* Same bits as above */ #define PCI_ERR_UNCOR_SEVER 0x0c /* Uncorrectable Error Severity */ @@ -798,6 +807,7 @@ #define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */ #define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */ #define PCI_ERR_CAP_PREFIX_LOG_PRESENT 0x00000800 /* TLP Prefix Log Prese= nt */ +#define PCI_ERR_CAP_COMP_TIME_LOG 0x00001000 /* Completion Timeout Prefix= /Header Log Capable */ #define PCI_ERR_CAP_TLP_LOG_FLIT 0x00040000 /* TLP was logged in Flit Mod= e */ #define PCI_ERR_CAP_TLP_LOG_SIZE 0x00f80000 /* Logged TLP Size (only in F= lit mode) */ #define PCI_ERR_HEADER_LOG 0x1c /* Header Log Register (16 bytes) */ diff --git a/include/standard-headers/linux/virtio_ids.h b/include/standard= -headers/linux/virtio_ids.h index 7aa2eb7662..6c12db16fa 100644 --- a/include/standard-headers/linux/virtio_ids.h +++ b/include/standard-headers/linux/virtio_ids.h @@ -68,6 +68,7 @@ #define VIRTIO_ID_AUDIO_POLICY 39 /* virtio audio policy */ #define VIRTIO_ID_BT 40 /* virtio bluetooth */ #define VIRTIO_ID_GPIO 41 /* virtio gpio */ +#define VIRTIO_ID_SPI 45 /* virtio spi */ =20 /* * Virtio Transitional IDs diff --git a/linux-headers/asm-loongarch/kvm.h b/linux-headers/asm-loongarc= h/kvm.h index 5f354f5c68..57ba1a563b 100644 --- a/linux-headers/asm-loongarch/kvm.h +++ b/linux-headers/asm-loongarch/kvm.h @@ -103,6 +103,7 @@ struct kvm_fpu { #define KVM_LOONGARCH_VM_FEAT_PMU 5 #define KVM_LOONGARCH_VM_FEAT_PV_IPI 6 #define KVM_LOONGARCH_VM_FEAT_PV_STEALTIME 7 +#define KVM_LOONGARCH_VM_FEAT_PTW 8 =20 /* Device Control API on vcpu fd */ #define KVM_LOONGARCH_VCPU_CPUCFG 0 diff --git a/linux-headers/asm-riscv/kvm.h b/linux-headers/asm-riscv/kvm.h index ef27d4289d..759a4852c0 100644 --- a/linux-headers/asm-riscv/kvm.h +++ b/linux-headers/asm-riscv/kvm.h @@ -9,7 +9,7 @@ #ifndef __LINUX_KVM_RISCV_H #define __LINUX_KVM_RISCV_H =20 -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ =20 #include #include @@ -56,6 +56,7 @@ struct kvm_riscv_config { unsigned long mimpid; unsigned long zicboz_block_size; unsigned long satp_mode; + unsigned long zicbop_block_size; }; =20 /* CORE registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */ @@ -185,6 +186,10 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_ZICCRSE, KVM_RISCV_ISA_EXT_ZAAMO, KVM_RISCV_ISA_EXT_ZALRSC, + KVM_RISCV_ISA_EXT_ZICBOP, + KVM_RISCV_ISA_EXT_ZFBFMIN, + KVM_RISCV_ISA_EXT_ZVFBFMIN, + KVM_RISCV_ISA_EXT_ZVFBFWMA, KVM_RISCV_ISA_EXT_MAX, }; =20 @@ -205,6 +210,7 @@ enum KVM_RISCV_SBI_EXT_ID { KVM_RISCV_SBI_EXT_DBCN, KVM_RISCV_SBI_EXT_STA, KVM_RISCV_SBI_EXT_SUSP, + KVM_RISCV_SBI_EXT_FWFT, KVM_RISCV_SBI_EXT_MAX, }; =20 @@ -214,6 +220,18 @@ struct kvm_riscv_sbi_sta { unsigned long shmem_hi; }; =20 +struct kvm_riscv_sbi_fwft_feature { + unsigned long enable; + unsigned long flags; + unsigned long value; +}; + +/* SBI FWFT extension registers for KVM_GET_ONE_REG and KVM_SET_ONE_REG */ +struct kvm_riscv_sbi_fwft { + struct kvm_riscv_sbi_fwft_feature misaligned_deleg; + struct kvm_riscv_sbi_fwft_feature pointer_masking; +}; + /* Possible states for kvm_riscv_timer */ #define KVM_RISCV_TIMER_STATE_OFF 0 #define KVM_RISCV_TIMER_STATE_ON 1 @@ -297,6 +315,9 @@ struct kvm_riscv_sbi_sta { #define KVM_REG_RISCV_SBI_STA (0x0 << KVM_REG_RISCV_SUBTYPE_SHIFT) #define KVM_REG_RISCV_SBI_STA_REG(name) \ (offsetof(struct kvm_riscv_sbi_sta, name) / sizeof(unsigned long)) +#define KVM_REG_RISCV_SBI_FWFT (0x1 << KVM_REG_RISCV_SUBTYPE_SHIFT) +#define KVM_REG_RISCV_SBI_FWFT_REG(name) \ + (offsetof(struct kvm_riscv_sbi_fwft, name) / sizeof(unsigned long)) =20 /* Device Control API: RISC-V AIA */ #define KVM_DEV_RISCV_APLIC_ALIGN 0x1000 diff --git a/linux-headers/asm-riscv/ptrace.h b/linux-headers/asm-riscv/ptr= ace.h index 1e3166caca..a3f8211ede 100644 --- a/linux-headers/asm-riscv/ptrace.h +++ b/linux-headers/asm-riscv/ptrace.h @@ -6,7 +6,7 @@ #ifndef _ASM_RISCV_PTRACE_H #define _ASM_RISCV_PTRACE_H =20 -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ =20 #include =20 @@ -127,6 +127,6 @@ struct __riscv_v_regset_state { */ #define RISCV_MAX_VLENB (8192) =20 -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ =20 #endif /* _ASM_RISCV_PTRACE_H */ diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index f0c1a730d9..3bb38f6c3a 100644 --- a/linux-headers/asm-x86/kvm.h +++ b/linux-headers/asm-x86/kvm.h @@ -35,6 +35,11 @@ #define MC_VECTOR 18 #define XM_VECTOR 19 #define VE_VECTOR 20 +#define CP_VECTOR 21 + +#define HV_VECTOR 28 +#define VC_VECTOR 29 +#define SX_VECTOR 30 =20 /* Select x86 specific features in */ #define __KVM_HAVE_PIT @@ -409,6 +414,35 @@ struct kvm_xcrs { __u64 padding[16]; }; =20 +#define KVM_X86_REG_TYPE_MSR 2 +#define KVM_X86_REG_TYPE_KVM 3 + +#define KVM_X86_KVM_REG_SIZE(reg) \ +({ \ + reg =3D=3D KVM_REG_GUEST_SSP ? KVM_REG_SIZE_U64 : 0; \ +}) + +#define KVM_X86_REG_TYPE_SIZE(type, reg) \ +({ \ + __u64 type_size =3D (__u64)type << 32; \ + \ + type_size |=3D type =3D=3D KVM_X86_REG_TYPE_MSR ? KVM_REG_SIZE_U64 : \ + type =3D=3D KVM_X86_REG_TYPE_KVM ? KVM_X86_KVM_REG_SIZE(reg) : \ + 0; \ + type_size; \ +}) + +#define KVM_X86_REG_ID(type, index) \ + (KVM_REG_X86 | KVM_X86_REG_TYPE_SIZE(type, index) | index) + +#define KVM_X86_REG_MSR(index) \ + KVM_X86_REG_ID(KVM_X86_REG_TYPE_MSR, index) +#define KVM_X86_REG_KVM(index) \ + KVM_X86_REG_ID(KVM_X86_REG_TYPE_KVM, index) + +/* KVM-defined registers starting from 0 */ +#define KVM_REG_GUEST_SSP 0 + #define KVM_SYNC_X86_REGS (1UL << 0) #define KVM_SYNC_X86_SREGS (1UL << 1) #define KVM_SYNC_X86_EVENTS (1UL << 2) diff --git a/linux-headers/asm-x86/unistd_64.h b/linux-headers/asm-x86/unis= td_64.h index 2f55bebb81..26c258d1a6 100644 --- a/linux-headers/asm-x86/unistd_64.h +++ b/linux-headers/asm-x86/unistd_64.h @@ -337,6 +337,7 @@ #define __NR_io_pgetevents 333 #define __NR_rseq 334 #define __NR_uretprobe 335 +#define __NR_uprobe 336 #define __NR_pidfd_send_signal 424 #define __NR_io_uring_setup 425 #define __NR_io_uring_enter 426 diff --git a/linux-headers/asm-x86/unistd_x32.h b/linux-headers/asm-x86/uni= std_x32.h index 8cc8673f15..65c2aed946 100644 --- a/linux-headers/asm-x86/unistd_x32.h +++ b/linux-headers/asm-x86/unistd_x32.h @@ -290,6 +290,7 @@ #define __NR_io_pgetevents (__X32_SYSCALL_BIT + 333) #define __NR_rseq (__X32_SYSCALL_BIT + 334) #define __NR_uretprobe (__X32_SYSCALL_BIT + 335) +#define __NR_uprobe (__X32_SYSCALL_BIT + 336) #define __NR_pidfd_send_signal (__X32_SYSCALL_BIT + 424) #define __NR_io_uring_setup (__X32_SYSCALL_BIT + 425) #define __NR_io_uring_enter (__X32_SYSCALL_BIT + 426) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index be704965d8..4ea28ef7ca 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -954,6 +954,7 @@ struct kvm_enable_cap { #define KVM_CAP_ARM_EL2_E2H0 241 #define KVM_CAP_RISCV_MP_STATE_RESET 242 #define KVM_CAP_ARM_CACHEABLE_PFNMAP_SUPPORTED 243 +#define KVM_CAP_GUEST_MEMFD_FLAGS 244 =20 struct kvm_irq_routing_irqchip { __u32 irqchip; @@ -1590,6 +1591,8 @@ struct kvm_memory_attributes { #define KVM_MEMORY_ATTRIBUTE_PRIVATE (1ULL << 3) =20 #define KVM_CREATE_GUEST_MEMFD _IOWR(KVMIO, 0xd4, struct kvm_create_guest= _memfd) +#define GUEST_MEMFD_FLAG_MMAP (1ULL << 0) +#define GUEST_MEMFD_FLAG_INIT_SHARED (1ULL << 1) =20 struct kvm_create_guest_memfd { __u64 size; diff --git a/linux-headers/linux/psp-sev.h b/linux-headers/linux/psp-sev.h index 113c4ceb78..c525125ea8 100644 --- a/linux-headers/linux/psp-sev.h +++ b/linux-headers/linux/psp-sev.h @@ -185,6 +185,10 @@ struct sev_user_data_get_id2 { * @mask_chip_id: whether chip id is present in attestation reports or not * @mask_chip_key: whether attestation reports are signed or not * @vlek_en: VLEK (Version Loaded Endorsement Key) hashstick is loaded + * @feature_info: whether SNP_FEATURE_INFO command is available + * @rapl_dis: whether RAPL is disabled + * @ciphertext_hiding_cap: whether platform has ciphertext hiding capabili= ty + * @ciphertext_hiding_en: whether ciphertext hiding is enabled * @rsvd1: reserved * @guest_count: the number of guest currently managed by the firmware * @current_tcb_version: current TCB version @@ -200,7 +204,11 @@ struct sev_user_data_snp_status { __u32 mask_chip_id:1; /* Out */ __u32 mask_chip_key:1; /* Out */ __u32 vlek_en:1; /* Out */ - __u32 rsvd1:29; + __u32 feature_info:1; /* Out */ + __u32 rapl_dis:1; /* Out */ + __u32 ciphertext_hiding_cap:1; /* Out */ + __u32 ciphertext_hiding_en:1; /* Out */ + __u32 rsvd1:25; __u32 guest_count; /* Out */ __u64 current_tcb_version; /* Out */ __u64 reported_tcb_version; /* Out */ diff --git a/linux-headers/linux/stddef.h b/linux-headers/linux/stddef.h index e1fcfcf3b3..48ee4438e0 100644 --- a/linux-headers/linux/stddef.h +++ b/linux-headers/linux/stddef.h @@ -3,7 +3,6 @@ #define _LINUX_STDDEF_H =20 =20 - #ifndef __always_inline #define __always_inline __inline__ #endif diff --git a/linux-headers/linux/vduse.h b/linux-headers/linux/vduse.h index f46269af34..da6ac89af1 100644 --- a/linux-headers/linux/vduse.h +++ b/linux-headers/linux/vduse.h @@ -237,7 +237,7 @@ struct vduse_iova_umem { * struct vduse_iova_info - information of one IOVA region * @start: start of the IOVA region * @last: last of the IOVA region - * @capability: capability of the IOVA regsion + * @capability: capability of the IOVA region * @reserved: for future use, needs to be initialized to zero * * Structure used by VDUSE_IOTLB_GET_INFO ioctl to get information of diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h index 283348b64a..c57674a6aa 100644 --- a/linux-headers/linux/vhost.h +++ b/linux-headers/linux/vhost.h @@ -260,7 +260,7 @@ * When fork_owner is set to VHOST_FORK_OWNER_KTHREAD: * - Vhost will create vhost workers as kernel threads. */ -#define VHOST_SET_FORK_FROM_OWNER _IOW(VHOST_VIRTIO, 0x83, __u8) +#define VHOST_SET_FORK_FROM_OWNER _IOW(VHOST_VIRTIO, 0x84, __u8) =20 /** * VHOST_GET_FORK_OWNER - Get the current fork_owner flag for the vhost de= vice. @@ -268,6 +268,6 @@ * * @return: An 8-bit value indicating the current thread mode. */ -#define VHOST_GET_FORK_FROM_OWNER _IOR(VHOST_VIRTIO, 0x84, __u8) +#define VHOST_GET_FORK_FROM_OWNER _IOR(VHOST_VIRTIO, 0x85, __u8) =20 #endif --=20 2.50.1 From nobody Mon Oct 27 11:10:18 2025 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=1761246029; cv=none; d=zohomail.com; s=zohoarc; b=C+0uaA90vKzXtnPvup6YkrkKVJO8S51ztM9tcKfw2hjcIzSdhstviOxPO26fXo16KDz485onHDrhoCOVNIrZRMDCLCeBkguzbTj0sCkE1su3jy1IHAzeW6uIZWNg+HbhUsfBjp09eZPVW7xoogyule6/AXFztGYKcAS9e2uYP8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761246029; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GMvVz+L6/dBIaEXwH2WldpTrPwKHBCrsIkQZ6bHOmlg=; b=IkPkoN2nJH32LIpCWI9Lbs4RTBd1KgEXg5RFfnuAA01r+CCLRPcmnMNSxOAybhW8a8Pk0XDoy27oTgw9W14lfC8Jh3u6Iiq25LEElzv3sQVtt9fodOirHqAcGg68ocnAkIBg/ZBHFCHOAzYZSlT6/ng+5uoGCe2egNhwpGEhYB8= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761246029908611.2255112137444; Thu, 23 Oct 2025 12:00:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vC0X1-0006WO-OA; Thu, 23 Oct 2025 14:59:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vC0X0-0006VM-3y for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:26 -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 1vC0Wx-0003Cw-4o for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:25 -0400 Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-348-PkMf87woO2mWl9vnpqpVeg-1; Thu, 23 Oct 2025 14:59:21 -0400 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-87c2085ff29so31372636d6.2 for ; Thu, 23 Oct 2025 11:59:21 -0700 (PDT) Received: from x1.com ([142.188.210.50]) by smtp.gmail.com with ESMTPSA id af79cd13be357-89c0ec61770sm213940585a.26.2025.10.23.11.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 11:59:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761245962; 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=GMvVz+L6/dBIaEXwH2WldpTrPwKHBCrsIkQZ6bHOmlg=; b=SCZrlMcv0pMQOHCMOfJ9KDhXtBmnl2/iHqVoHWCywekIXEAVXqk0ZmpQ7fvHhUlo5LN0uf xBgDIMNPSDk723RiYzBAmmwwX/83BJw1wEK+B1klQfr9rDJHdu8kOYet7LA798Pvbzct/+ FhfhwCHqzS8BQ02ApKilD27pbVv1MEU= X-MC-Unique: PkMf87woO2mWl9vnpqpVeg-1 X-Mimecast-MFC-AGG-ID: PkMf87woO2mWl9vnpqpVeg_1761245960 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761245960; x=1761850760; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GMvVz+L6/dBIaEXwH2WldpTrPwKHBCrsIkQZ6bHOmlg=; b=WdDtUq5tLRfjT4frCdXyhjyj6JIFkYigk3aAN/tkgS1Bbtct4S9ITZwZULgmLnFqph mlKD9B9gvZFgbjxat4himCAD7bWOu1nm42DCv90KPzouM+SSs/Og1w55mqjTsXMAPVQa NEzDQykx9ywZUxm1JcOaVYF+UloO2RhDSjDUljdwxYQuKOT2NVIbmuAIM8poOvAhVdDx Y6gLSXG1XjC9RNfkiZGxceGcRl1T/OOm1yYlnEyMNPTz7hX6JMxlAjpxtJFs8gWxAqAh KMB9I6BPNYsHG8FBbtcgG2M1/9wjxDeVMqWBE373UAoSFqDtphs5M35ynJ2gH9z19aUq hdTQ== X-Gm-Message-State: AOJu0YzWMz2PHaeguA2Z2jfjGBs2U8DOjv6Vsp/QZZJpv6E5BVWjhgyV 8IIoAg8nIZenRAC/2fFecYX4j9Lk7g4H96uESHAv0u/HBfs2S8TXRh6TDDM7pbrwWDBIU7GIX6u szMaVKVAAWnUocuUoxMb4E8VH50Osjqaw+EXeO4sh0JmQb9DMx6dCNlYwDBrPGSZN8xYN/GaQoy neEwf1p6ZBNYNZSKgxB/foWWB/TUjzdThI8sGmWA== X-Gm-Gg: ASbGncsRUNYKPyQTHN57ezTV0BrcB27ty3dM16o12P8G1yVp0DtT0DE1fKxaxOI42VV QwnNGzQxbe5lfIsTZ08WUeeAP2LlYARHlQwghyJhwJV28lzT7J+kpa+LPcgCPEtYC5Gi21spEfd yqEum8gS5xcEbAWHMzXOSHlVOjEqh5SUT0QZkGD9zeDn1HGdahRFz2/1akdGopY1G45eAfcR36a G56k1XBXlxJjZqvc9RFmQKhCqfbV7uaXDLp2fVXy5Sr/UTOWS/hzqI9MIc2QkWkNGWsEJBebkzv YyV4Ozrx2wMQ1vSPmpnCPaoSDzNCEicLeUSJTRq2mXQrhQ4AZ0z4wN++pq5HorA0 X-Received: by 2002:a05:620a:2544:b0:88e:4d7b:f5c8 with SMTP id af79cd13be357-8906e9a512emr2944299985a.20.1761245959970; Thu, 23 Oct 2025 11:59:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUDFsev2NEXB3iNCGbhCvmrUtyeqtwaRcWE5jIjIy2673QW5/kNt0AD4pd8A3m4oUSSloV0w== X-Received: by 2002:a05:620a:2544:b0:88e:4d7b:f5c8 with SMTP id af79cd13be357-8906e9a512emr2944295785a.20.1761245959343; Thu, 23 Oct 2025 11:59:19 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Paolo Bonzini , Fabiano Rosas , Chenyi Qiang , David Hildenbrand , Alexey Kardashevskiy , Li Xiaoyao , Juraj Marcin Subject: [PATCH 2/8] kvm: Allow kvm_guest_memfd_supported for non-private use case Date: Thu, 23 Oct 2025 14:59:07 -0400 Message-ID: <20251023185913.2923322-3-peterx@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251023185913.2923322-1-peterx@redhat.com> References: <20251023185913.2923322-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=lists.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 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: 1761246032975154100 Content-Type: text/plain; charset="utf-8" Guest-memfd is not 100% attached to private, it's a VM-specific memory provider. Allow it to be created even without private attributes, for example, when the VM can use the guest-memfd memory completely shared. Signed-off-by: Peter Xu --- accel/kvm/kvm-all.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index f9254ae654..1425dfd8b3 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -2779,10 +2779,8 @@ static int kvm_init(AccelState *as, MachineState *ms) } =20 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_guest_memfd_supported =3D 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); =20 if (s->kernel_irqchip_split =3D=3D ON_OFF_AUTO_AUTO) { --=20 2.50.1 From nobody Mon Oct 27 11:10:18 2025 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=1761246042; cv=none; d=zohomail.com; s=zohoarc; b=fGe66+4LzemAz/O9HLzfpmCuA6pBdOEhmiZ8RMB7mcb9px+BEgHZEXr6g/a4cOgRwyc2/+gxn3I2y3yV2MWYvfJwKJvmgw5KrzpeBuR76io/FBkdmP+Unc3wf65lHqVRQfxa3RRJWdfBARTBkAIv9iEBfMEsmKbpD8++QItX0jk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761246042; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HRTTmoaq0zaDqH3fG/L/qN1Tnwdx1HwmDmOIEom+u00=; b=YksxM/j936dV0Jurd3+7Rg0zjJitnGQEr+qCW4yQ5p0pXbDdFIt3pRR77U62SbaACxbUnI50z2yybWaALz5g8L7Zjxn1emHGS/c9VrYPRFN3NQ2Vt36xmh6QfSgVHujOs+f8VljXwUxQxXi3fGpE2aNszeQI6Ks6irTQ0hFgROg= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761246042152967.2835607760137; Thu, 23 Oct 2025 12:00:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vC0X2-0006Wm-Qd; Thu, 23 Oct 2025 14:59:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vC0X0-0006VU-AD for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:26 -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 1vC0Wy-0003D5-N2 for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:26 -0400 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-56-Dz-76K7ZPGaJ_rW_SThutQ-1; Thu, 23 Oct 2025 14:59:22 -0400 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-4e8aafb21d6so34719901cf.1 for ; Thu, 23 Oct 2025 11:59:22 -0700 (PDT) Received: from x1.com ([142.188.210.50]) by smtp.gmail.com with ESMTPSA id af79cd13be357-89c0ec61770sm213940585a.26.2025.10.23.11.59.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 11:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761245964; 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=HRTTmoaq0zaDqH3fG/L/qN1Tnwdx1HwmDmOIEom+u00=; b=Pildkvs0siQdMGW5pRu1BOxyf4nTWR9PFtbioTEuVBoZ41NBWEXScmfkHgUMu/XCM5vvcG /s+DHyH+AJCPruWWNAAXSe4EEVaw3f+S8GEQ1z5uSJYxxXTiHSFEfPl9z7wEvKrH1CsGx+ RmlUIV8izXSiNqVvOxFHNlhpdKn+Sp8= X-MC-Unique: Dz-76K7ZPGaJ_rW_SThutQ-1 X-Mimecast-MFC-AGG-ID: Dz-76K7ZPGaJ_rW_SThutQ_1761245962 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761245961; x=1761850761; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HRTTmoaq0zaDqH3fG/L/qN1Tnwdx1HwmDmOIEom+u00=; b=A2C6SdSu0KAVngHXiRrbsDmjdrFyAC3aUk8BfIsOJNJxLURQ2/19HpLsVBkRhvZ3WU nVFw7RihM28HYlvXbu1WhNtlmuBGDnEIVCACJIl6XlacHXJpXkAMVvb6FKZaGjnRRR/8 WJm6fa57aAqNIhJS3l598/+XnjdfXAYhJ9lmPe86S3y3NU+g070NbTf/+e+yFyazNzSx mXG4HbXXoJUebE7Tau98lCYOVmVq/TR4r5AkzvTNLES7wSbLE2oGgUGpM/qtSyDBSBgz AyZragaVvxTFU33/HH0vc3coC+atCmjhqYY9mAZQ+ZZa4N40doflNGI2I+ed2hhjnjfT Z9rA== X-Gm-Message-State: AOJu0YzkEiTfClsq0L2T0frCuJHPQhoImaBzoD5qwrbXj7QW49aAIEEt XjhgU77Mm5+r5vw7FsJiAZOWlQ+iX8rA5vB3J1pbV8nfeksPHAE14Ox4gkWFWPpOxXkiHEIaM/8 ZvZJjUf4/0hOY299MyzzJb0+IkmU4Usp3EPHWvPep4WuKcdo6nC6DYZld99aTUs4IhaXnX3Rvm/ yc37FzbDE5yBoiIJZob/fbMy1HGTG9yY68SJQytw== X-Gm-Gg: ASbGncuvU53eA0IVqLdX1CDmOFQekNyzCtPM80lEWOSsUvsvmExFEfvAy0rwE3DK4xN vwW7cdkssKQiEOoMu00b/2J6tQjQ5NhILlhbSb7iGjdLeyUmHkTVfn8jxVyzuF8wjjYtnWzgTNs SbamtQtZ9UrDaJUwwx3nFd4PwM0Y7wMwsEdQaqZhowYd4oTJ79/iKpGg00u+gpIwy9O5aZYM61M 5d0oBF1d8+eDRcYMFr1JmxA7krKEDl1J+urHEPCXguw+06KE7hP2HehOYOokpyQw218ecfTTtTJ 88IFj6rwRacNE0LnbzVxYazkR7voysJXJxzE2Xww7dHHqv/GYAHgMAJZEWdRcOIY X-Received: by 2002:ac8:7f50:0:b0:4e8:999b:70a9 with SMTP id d75a77b69052e-4e89d4123dfmr287742991cf.72.1761245961453; Thu, 23 Oct 2025 11:59:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGtN2EKGQiuWXAwjxgnuReXI7clSUHSfILXljN56JpaXjq03cI9daFUDSu5aeYG80P7zIHwDg== X-Received: by 2002:ac8:7f50:0:b0:4e8:999b:70a9 with SMTP id d75a77b69052e-4e89d4123dfmr287742501cf.72.1761245960702; Thu, 23 Oct 2025 11:59:20 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Paolo Bonzini , Fabiano Rosas , Chenyi Qiang , David Hildenbrand , Alexey Kardashevskiy , Li Xiaoyao , Juraj Marcin Subject: [PATCH 3/8] kvm: Detect guest-memfd flags supported Date: Thu, 23 Oct 2025 14:59:08 -0400 Message-ID: <20251023185913.2923322-4-peterx@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251023185913.2923322-1-peterx@redhat.com> References: <20251023185913.2923322-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=lists.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 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: 1761246049030158500 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. Signed-off-by: Peter Xu --- accel/kvm/kvm-all.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index 1425dfd8b3..48a8f6424f 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -108,6 +108,7 @@ static int kvm_sstep_flags; 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_capabilites[] =3D { @@ -2781,6 +2782,11 @@ 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); + ret =3D kvm_vm_check_extension(s, KVM_CAP_GUEST_MEMFD_FLAGS); + if (ret > 0) + kvm_guest_memfd_flags_supported =3D (uint64_t)ret; + else + kvm_guest_memfd_flags_supported =3D 0; 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) { @@ -4486,6 +4492,12 @@ 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, "KVM does not support guest-memfd flag: 0x%"PRIx6= 4, + 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.50.1 From nobody Mon Oct 27 11:10:18 2025 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=1761246093; cv=none; d=zohomail.com; s=zohoarc; b=QqZOu21w68jouhhXzBfiqXbz9J3E2J/QYmdmTXdyirJN7MXE9GeLqZEt6ogGXFfRFjPJbr1K1AOk2TXGcTkL8A5SA3GdOgRbxKiTd9xfgzows4bRkZ0WAcyvOrX2Yq27rXXGi26QDA3mXglu/dqzR0fk/9AOvSy23p9ICkQNx0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761246093; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wXNchoUnOoPSy+plqVmY72NjzGvh8U57fWb0kC1DiMw=; b=n7K56vE7mHZ4WSdbsP4IiiyEDHP8WXUlX5bswABN7CME6Yw5CaTmdZGDgxLnEHI1DbqZohaox5g+RmDMiFW4sKozo9IlPMiUfn7zGstaxM0iXZM4FecdO49/sEHKpeoaZx4mKYk2hNqc4Tx8meWVKUrgqQpwlyhpIsFBeaOvX+8= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761246093446975.7798242124463; Thu, 23 Oct 2025 12:01:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vC0X6-0006Xy-2m; Thu, 23 Oct 2025 14:59:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vC0X1-0006WE-IF for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:27 -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 1vC0Wz-0003DH-Go for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:27 -0400 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-462-CuNKT0XoPVmOgyr00l-uXg-1; Thu, 23 Oct 2025 14:59:23 -0400 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-8910b0fb780so186180285a.3 for ; Thu, 23 Oct 2025 11:59:23 -0700 (PDT) Received: from x1.com ([142.188.210.50]) by smtp.gmail.com with ESMTPSA id af79cd13be357-89c0ec61770sm213940585a.26.2025.10.23.11.59.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 11:59:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761245964; 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=wXNchoUnOoPSy+plqVmY72NjzGvh8U57fWb0kC1DiMw=; b=FgLc/kAaB57O0rmUiTNdJixWKkK8q1ggAOan/ZpuKevgsql3zViqFboxMhTl8DGzCfoxov BCRXFUZY8US2f3dYkwm3L8/jmVv9/+7OR4Pgju+Tc6OhSRgpSPBprBWSqG8uTO+Ome6DWJ F/KOf4eQVziJBcYziN82OjmArEZMy98= X-MC-Unique: CuNKT0XoPVmOgyr00l-uXg-1 X-Mimecast-MFC-AGG-ID: CuNKT0XoPVmOgyr00l-uXg_1761245963 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761245963; x=1761850763; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wXNchoUnOoPSy+plqVmY72NjzGvh8U57fWb0kC1DiMw=; b=PNfuRgvOarQGvG7eZpmqqwffdy4DfDvandE3dUyvP90EAilmHag5oKQB2CCne+vYSA 2qU7/3/J4YmGuCRAr6W6gRTk26E5uKXFDJvc9O3EH1W34LGgKVzwZAitPLPanadzkpQG zv6Zo3sXsaui7trMHEWQ57ZhptRzqvwePxtgLxMPDm+ZJe07JFysGQsdbTRNfijqHNE4 JXCrW824C4vwcv27Wbq7Al3Pq1NPuw4Zg2i/0fzWHOVyjRWa0xEAt2wMxmJt+iwV5Ehl pXFstg5DCyN7fkFaG7a2b2wKRPc3PV1bPTIOFJ2MeLWA1iuNBfWUy80dbIcQium3rc2m ziEw== X-Gm-Message-State: AOJu0YxTImb4N6GlEq+nZIh04IUUAijQoMRLYOG2UIlOQMIe02qYfVwI CVdGxP5ZJ6VpTtUdBW9Jp/jrjVkIhkoLwKUOELAYtBmlEj5g64Qhj/L2NCdA98C37Yg0FuEOh7p jV8AVnC5WPYQMsOeEDyup/GS3oNfANFIebPZxn1NzV5PiknAWqmtSvJ+EKlmIwKcge4sw463/7Y yVCo3dmbZE5I9CGMk2BqvsrI1mu0y8TyNGCXWekg== X-Gm-Gg: ASbGncvBjnrpilUhPwu/qtFI8eBf86LVtaUbp4wwgvmf2YHCSeUgspwnWo/LQF5vU+R MJ0xwkihQT+ha2gEGwomKlAGQJ1ti9go0JTkE0eDUquRvnE89gnH368kofNIcqQ+z40ymhkERwZ x89mGIH3W/yfiZ5Gj2q2vdrJUxlWK0dJSqPfPavZ0lYaQ+TyBrP+kX/pcUZ2SL9VqwglfIDcwfw WcGXrqXEKaLWJbMFe2UxCGKmoRzR5UyY1TQbUyaCAJkBsqzjQMBlGa1DNhKyFe+GFfP4VlwVwTP NbRBrhlufI6dOZDs1clANiKYY8A7k/TzzoXv6ipLJPhxRQj4ij3wogW2t5KoMqoS X-Received: by 2002:a05:620a:2685:b0:891:9a42:af0 with SMTP id af79cd13be357-8919a420ba6mr2603409185a.25.1761245962672; Thu, 23 Oct 2025 11:59:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEq/z4ltPoLTBhfBNUy0/LnzBNbfaP4+ZaZAXp6VGAqpgFzNb6xddwKB0GzcZrbc8H7kLbStQ== X-Received: by 2002:a05:620a:2685:b0:891:9a42:af0 with SMTP id af79cd13be357-8919a420ba6mr2603404685a.25.1761245962072; Thu, 23 Oct 2025 11:59:22 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Paolo Bonzini , Fabiano Rosas , Chenyi Qiang , David Hildenbrand , Alexey Kardashevskiy , Li Xiaoyao , Juraj Marcin Subject: [PATCH 4/8] memory: Rename RAM_GUEST_MEMFD to RAM_GUEST_MEMFD_PRIVATE Date: Thu, 23 Oct 2025 14:59:09 -0400 Message-ID: <20251023185913.2923322-5-peterx@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251023185913.2923322-1-peterx@redhat.com> References: <20251023185913.2923322-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=lists.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 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: 1761246097786158500 Content-Type: text/plain; charset="utf-8" This name is too generic, and can conflict with in-place guest-memfd support. Add a _PRIVATE suffix to show what it really means: it is always silently using an internal guest-memfd to back a shared host backend, rather than used in-place. This paves way for in-place guest-memfd, which means we can have a ramblock that allocates pages completely from guest-memfd (private or shared). Signed-off-by: Peter Xu --- include/system/memory.h | 8 ++++---- include/system/ram_addr.h | 2 +- backends/hostmem-file.c | 2 +- backends/hostmem-memfd.c | 2 +- backends/hostmem-ram.c | 2 +- system/memory.c | 2 +- system/physmem.c | 8 ++++---- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/system/memory.h b/include/system/memory.h index 3bd5ffa5e0..2c1a5e06b4 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -263,7 +263,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, @@ -1401,7 +1401,7 @@ bool memory_region_init_ram_nomigrate(MemoryRegion *m= r, * 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 @@ -1463,7 +1463,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. @@ -1493,7 +1493,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/ram_addr.h b/include/system/ram_addr.h index 683485980c..930d3824d7 100644 --- a/include/system/ram_addr.h +++ b/include/system/ram_addr.h @@ -92,7 +92,7 @@ static inline unsigned long int ramblock_recv_bitmap_offs= et(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 8e3219c061..1f20cd8fd6 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 923239f9cf..3f3e485709 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/system/memory.c b/system/memory.c index 8b84661ae3..006b03ce1c 100644 --- a/system/memory.c +++ b/system/memory.c @@ -3755,7 +3755,7 @@ bool memory_region_init_ram_guest_memfd(MemoryRegion = *mr, DeviceState *owner_dev; =20 if (!memory_region_init_ram_flags_nomigrate(mr, owner, name, size, - RAM_GUEST_MEMFD, errp)) { + RAM_GUEST_MEMFD_PRIVATE, e= rrp)) { return false; } /* This will assert if owner is neither NULL nor a DeviceState. diff --git a/system/physmem.c b/system/physmem.c index a340ca3e61..1a186739a8 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2203,7 +2203,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()) { @@ -2333,7 +2333,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 @@ -2490,7 +2490,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 @@ -2573,7 +2573,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); } --=20 2.50.1 From nobody Mon Oct 27 11:10:18 2025 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=1761246094; cv=none; d=zohomail.com; s=zohoarc; b=VAB3XgjYPdd5GC05JySIRAhF+QZxKC+7noC7vY23NQ9vX0sUavUjfFAqqRN9jgLcoStaNvxxFDcrN4S/eRuCKuGL2QmCwN/bHvrBKApz0gl+RaYRMrbrwpYMlIeTkkJ1Qa1/b150QQmoVl19CHez93HC7ZKPw587ESg5fJ4q5Mc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761246094; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=I+2r7MuA6OG87fdVMOc0DGwzybnlDA/AOjyEzzWkuQU=; b=hhUx91iYVYAjSNsWsQwZLei7Tkm/gZ9IVuZhbchCVkiJQXFdqyom+4J23cDhyRcr81ZppofTJZvA4ybYHcdR1arXOSHjWSHQYN3H11Y9rviJdyHV0ff6dKtuEzongau2b2P13Pu5i+RFPVq36G2G3+6ryQEF1vteZ5ZCyWVAA28= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176124609421563.86708591215756; Thu, 23 Oct 2025 12:01:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vC0X6-0006Y3-J8; Thu, 23 Oct 2025 14:59:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vC0X4-0006XP-0e for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:30 -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 1vC0X2-0003Da-4Y for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:29 -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-695-7bevD59KNVSlsCNeug6HTw-1; Thu, 23 Oct 2025 14:59:25 -0400 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-890f1090e81so341656585a.0 for ; Thu, 23 Oct 2025 11:59:25 -0700 (PDT) Received: from x1.com ([142.188.210.50]) by smtp.gmail.com with ESMTPSA id af79cd13be357-89c0ec61770sm213940585a.26.2025.10.23.11.59.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 11:59:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761245966; 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=I+2r7MuA6OG87fdVMOc0DGwzybnlDA/AOjyEzzWkuQU=; b=M6gMVNAzyhPVQevBJMPvwXgMxKEOawQUJikXPwTpva0mqiSBl58PNUjLBIpcSqyauTiMGg WzmyId41HJHXIFPDoymvhmPrfmSfQIPiRSaHABjgvY4ZhXem8RxJ0321QwwqRcSdZIZ2hH 6ZS1ya+RcS8Kxk7cUHWOu20ggAh6KMQ= X-MC-Unique: 7bevD59KNVSlsCNeug6HTw-1 X-Mimecast-MFC-AGG-ID: 7bevD59KNVSlsCNeug6HTw_1761245965 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761245964; x=1761850764; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I+2r7MuA6OG87fdVMOc0DGwzybnlDA/AOjyEzzWkuQU=; b=ejDh4hOCqDu8xfuz4nEEphf3BYL4R5XYY04LOf+05FTWEnOcu7xrFGs46VIoun+t6H vt3KH3L7yazg80iCkvKygZV1C5Oi+yzCohUVbWYPrX6nXC7CYPyAUBzaOWxunfOemPvr DYtbabANqZ5UH+2OT2LnjMLxqTtt4J6Bhk9zeLBj4ICwVP0ckgl7r92zeYgvsZYIssiZ ShX6bJ/IDmBg1T08XAkvTnzluhhVmVpJZqFkpMlbZlGDUnwcCcrWLdZY3NRgYAUf35rr uj4gbUf6s9oKhYJ76gvJ/x72Mo3dKCvR/hKUOGgnTvr5hfbNTUs4sSHxlu805I1cOAZ0 3GEw== X-Gm-Message-State: AOJu0YxDH0kdoVryu3FcdDg+TH2MA82FJSe8zAdPo8SPqKY49HR/Lfqi gQyoBCVz5lqLZ8DPVtrYTutJ1mTAjXWV9chOEGXcB16DiOzQDi+h00zgs9QrCecVHNkq0bFWAjq sU7tZuQCZSPk1+7iy/YLukhiHrSLr1d3wC1HpF34Zw6PqSbDLFy2pkSoF2jO1czuP1+y/Mk3SFM EgOQ+HSfe7P0Z1P5VXdiIpasAM1Aw61OO7qCElZg== X-Gm-Gg: ASbGnctfRVeQ2v0Pf7y/M9xJAi7AAN/t1NHuf1VGTuCHS87YtaZhHGmWkZitKn7kV3q RhqzBo+ZBMtWnd6GAwJDgIs+TclRcIOIG118VWNlA2vjKo5B57Xfv6r90jTKOsdHLVWqsmUlM9j PJOJ8Jpicq8/erQ+C2tzxVEG0M466Vx9wEOKzHCwrWx7PiFAa3LaC4NOLiY3E7gtggfn8bCnWrp l0mhoymYYkHoRwD6hEdix5lJbdEEsFrd9d/NyShVTZgodLJ65HhlSnzkWMrRZFNg+CUhra+0JBu lX/G2wk3oP9oQD1feGflmAzKETX4j7EvcN7FtQR3MrvTN4/GdEF+1hseg4HVBDzd X-Received: by 2002:a05:620a:1a8f:b0:891:b6a0:e5a0 with SMTP id af79cd13be357-891b6a0ea70mr2621714285a.45.1761245964347; Thu, 23 Oct 2025 11:59:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+6c23nrFjW6XD74agtX7hTw4prNuPB7Q96hvWgAMBJ7tZ5C5THcnbfSeAM7s92C2jl+3bnA== X-Received: by 2002:a05:620a:1a8f:b0:891:b6a0:e5a0 with SMTP id af79cd13be357-891b6a0ea70mr2621709485a.45.1761245963803; Thu, 23 Oct 2025 11:59:23 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Paolo Bonzini , Fabiano Rosas , Chenyi Qiang , David Hildenbrand , Alexey Kardashevskiy , Li Xiaoyao , Juraj Marcin Subject: [PATCH 5/8] memory: Rename memory_region_has_guest_memfd() to *_private() Date: Thu, 23 Oct 2025 14:59:10 -0400 Message-ID: <20251023185913.2923322-6-peterx@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251023185913.2923322-1-peterx@redhat.com> References: <20251023185913.2923322-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=lists.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 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: 1761246097691158500 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 in-place guest-memfd). Signed-off-by: Peter Xu --- include/system/memory.h | 6 +++--- accel/kvm/kvm-all.c | 6 +++--- system/memory.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/system/memory.h b/include/system/memory.h index 2c1a5e06b4..4428701a9f 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -1823,14 +1823,14 @@ static inline bool memory_region_is_romd(MemoryRegi= on *mr) bool memory_region_is_protected(MemoryRegion *mr); =20 /** - * memory_region_has_guest_memfd: check whether a memory region has guest_= memfd - * associated + * memory_region_has_guest_memfd_private: check whether a memory region has + * guest_memfd associated * * Returns %true if a memory region's ram_block has valid guest_memfd assi= gned. * * @mr: the memory region being queried */ -bool memory_region_has_guest_memfd(MemoryRegion *mr); +bool memory_region_has_guest_memfd_private(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 48a8f6424f..6521648ce9 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -666,7 +666,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; } @@ -1610,7 +1610,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", @@ -3096,7 +3096,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 006b03ce1c..5f05e5d73e 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1897,7 +1897,7 @@ bool memory_region_is_protected(MemoryRegion *mr) return mr->ram && (mr->ram_block->flags & RAM_PROTECTED); } =20 -bool memory_region_has_guest_memfd(MemoryRegion *mr) +bool memory_region_has_guest_memfd_private(MemoryRegion *mr) { return mr->ram_block && mr->ram_block->guest_memfd >=3D 0; } --=20 2.50.1 From nobody Mon Oct 27 11:10:18 2025 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=1761246029; cv=none; d=zohomail.com; s=zohoarc; b=lkepPnuJ1cjjuFD4F+eegQxYMtkrI1jSR4zrPbyf9hDEcmVMWBiy3SPwGsO7dcUWZE5iTFEcA/4T1kBuASoIjS+LNoUzqR6yZZng9rgjoeZZsMvFdex4JlSji7n2w025jivcWFncK6NhAEVVc9HnxvaIWxvwT+8DhXhMbdjEaXw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761246029; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ddoI5PUvCOx89l9nf1b26NK5AXWAmqNwKGvoCyq2LJc=; b=PQSoCk26spI00KclqUwmQ1n0hA15ZUm9UmVZ5WTnSM83s9odsDnNt5Xsp7K40bjX6JeBZeh2hfW0OgC9dpbXPUpfeCbhWZH0Du9LS1/P36OScOgRpE6v4kExw1x7fx4bf7TrYprRdIuBP47sgv/g6YdZw3WtVw/tYSqnnewiydA= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761246029089725.0643798914227; Thu, 23 Oct 2025 12:00:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vC0X7-0006YN-KH; Thu, 23 Oct 2025 14:59:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vC0X5-0006Xm-KH for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:31 -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 1vC0X3-0003Dp-Qv for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:31 -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-642-ya9LWEylOYSK5wDDXpmEag-1; Thu, 23 Oct 2025 14:59:27 -0400 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-891504015e5so345979985a.3 for ; Thu, 23 Oct 2025 11:59:27 -0700 (PDT) Received: from x1.com ([142.188.210.50]) by smtp.gmail.com with ESMTPSA id af79cd13be357-89c0ec61770sm213940585a.26.2025.10.23.11.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 11:59:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761245969; 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=ddoI5PUvCOx89l9nf1b26NK5AXWAmqNwKGvoCyq2LJc=; b=FGCw81jqYIUx6ShsX/n/Ldxmt3HY/+/gVdQiW4ETPQ/lZyqKSeN7AJAHibRKBm/6ruq/iV 37EdUWQDRJO/sO7LkRolKroYY4VTIhsD7nsWJdzhjaFq0jyWnXu3fIg5hgUCC9Fys9/uRh 0Ba0apKctK8vr+pQv12OIMg1lmPXLlA= X-MC-Unique: ya9LWEylOYSK5wDDXpmEag-1 X-Mimecast-MFC-AGG-ID: ya9LWEylOYSK5wDDXpmEag_1761245967 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761245967; x=1761850767; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ddoI5PUvCOx89l9nf1b26NK5AXWAmqNwKGvoCyq2LJc=; b=VT8xZ/hg0a9dhN5A7kc9ctmpU+087SNk4BRSz8LyysbxtUUa6Z2dczfEsWAs12MIkO 0j+P5tMT1qYgZfKsEFy0eKvBBEtGbBrFcVoBfdVShw4qz0nIAeDjYpGAjU7XvOdaUcha 1YHhId8mnAsPovKhEid5K6EYqoy7b3McyBLLUiERr4oMLrPRooAn4KrgbQV2qtOM1JSz SvzPRi6ZLMAJNofgdZXccJEKrK538CM4NvVmSK6V21yC0IOxPP/geUTKqIV3aGs5eKjj ISTiAl8iZSRoxKESwjdICsBR9SF+vWIz3voXle67U1KZlc+AG89x8h0qymLFEhorkF9a mOiA== X-Gm-Message-State: AOJu0Yz50CHxTwi6jjnouCpMyAbQssQ9mZga4mhAQFJkwe7CrZe0oyka /DmFbhgzTyR5S846Vp3Eo7kAnKSokJUnz1fD8nwEd9Z6WRYXZ844etY+br+i+EXdIjXv2iYpVAh SU38UIlDC8aRe4Pe/duZoPM0OfzYoSLeoB3L5FmC/HYT7tgIYY0nN0degQ9kk3If9JAPJtxQuGa 07n1P6zRflRgshY5dJwDW/vVF/GY6pWuofxJYSoQ== X-Gm-Gg: ASbGnctfijTJc8In6FxstjrJ/t2BiJxotpCpEz6kqnM1C+LXqfJokuFMjWIDalErw9A 0hsgbHFfRv5bMAeRLkCZmQz3gpVJH4WSF1NWK4U5RQo2C9lM4v1XUPEVXhPq61Mmu5O8160VWkU DsxcIakWPV8PG8Mh3fl24FEcBwwbZ3JMvD8OCv9xjaeGx3Npg3APmfSB4fetabjQ5JLpKIQPaeO doJQKQSY3zygwSxUJFc5Vdj9C5Bmrr6VffqXp43qVq88TCmaWrWibKwp7WGNkXqA9Z7x4LGVuCG Ix7Dn2nCJtlfnD3s0j193xKv5Q6bGZwAkTeMKzZf53q1/w68/HnHCVVWM6Q1HGHd X-Received: by 2002:a05:620a:2683:b0:891:a32a:c4d1 with SMTP id af79cd13be357-891a32ac4e4mr2818461385a.75.1761245966569; Thu, 23 Oct 2025 11:59:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFaJb2Es24fbMyfm6wO2b3LNNq1JtBztxno9536w3X4l+OAZWTECeYI5vHnG9yL7Q0rEOJDaA== X-Received: by 2002:a05:620a:2683:b0:891:a32a:c4d1 with SMTP id af79cd13be357-891a32ac4e4mr2818456085a.75.1761245965660; Thu, 23 Oct 2025 11:59:25 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Paolo Bonzini , Fabiano Rosas , Chenyi Qiang , David Hildenbrand , Alexey Kardashevskiy , Li Xiaoyao , Juraj Marcin Subject: [PATCH 6/8] ramblock: Rename guest_memfd to guest_memfd_private Date: Thu, 23 Oct 2025 14:59:11 -0400 Message-ID: <20251023185913.2923322-7-peterx@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251023185913.2923322-1-peterx@redhat.com> References: <20251023185913.2923322-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=lists.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 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: 1761246033300154100 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. Signed-off-by: Peter Xu --- include/system/memory.h | 2 +- include/system/ramblock.h | 7 ++++++- accel/kvm/kvm-all.c | 2 +- system/memory.c | 2 +- system/physmem.c | 21 +++++++++++---------- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/include/system/memory.h b/include/system/memory.h index 4428701a9f..5c38018f4a 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -1826,7 +1826,7 @@ bool memory_region_is_protected(MemoryRegion *mr); * memory_region_has_guest_memfd_private: check whether a memory region has * guest_memfd 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 guest_memfd_private as= signed. * * @mr: the memory region being queried */ diff --git a/include/system/ramblock.h b/include/system/ramblock.h index 76694fe1b5..9ecf7f970c 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 6521648ce9..687f33a2bb 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -1598,7 +1598,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 5f05e5d73e..dadcc21d0e 100644 --- a/system/memory.c +++ b/system/memory.c @@ -1899,7 +1899,7 @@ bool memory_region_is_protected(MemoryRegion *mr) =20 bool memory_region_has_guest_memfd_private(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(MemoryRegion *mr) diff --git a/system/physmem.c b/system/physmem.c index 1a186739a8..66fa4c7b6a 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2211,7 +2211,7 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp) object_get_typename(OBJECT(current_machine->cgs))); goto out_free; } - 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) { @@ -2221,9 +2221,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; } @@ -2240,7 +2240,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; @@ -2377,7 +2377,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); @@ -2550,7 +2550,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; @@ -2601,9 +2601,9 @@ static void reclaim_ramblock(RAMBlock *block) qemu_anon_ram_free(block->host, block->max_length); } =20 - if (block->guest_memfd >=3D 0) { + if (block->guest_memfd_private >=3D 0) { ram_block_attributes_destroy(block->attributes); - close(block->guest_memfd); + close(block->guest_memfd_private); ram_block_coordinated_discard_require(false); } =20 @@ -4211,7 +4211,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.50.1 From nobody Mon Oct 27 11:10:18 2025 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=1761246036; cv=none; d=zohomail.com; s=zohoarc; b=Vm9JvXZtAOxlHkjAmEVY3JrEq29wBx2cRumXmrJMn51OLztzyZ7AYjjg2dbx2wP6vFzF/8HiRuqDNx7MV10N1FDPyfr57q0QQCjgRxqNJby2F8fLG+kdk/kcZZPGVutjrds0Xhly02Zao7dNqklREXcm7iGEJooN9KMNNoOaGRA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761246036; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3YB+xOGWDMtE1OJfHdAxqd5sOxAtxUDFVH7AXA1Dk0w=; b=QApe4ej7WVcceiNbtZiDXaFk/eAT3+iKm3uRRgVBerbyfxWqxvKda6oO4v53zpO8WnzwbGN/6nJ5Hxx4PpPORec9FIukAqGGD8NZQOpGW7u2LcokP+lEuRzpg1+ZtQFf2aXqUvIiIHmI2OB2VvPsaTWxFrTDvQoN99DBr2sb39g= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761246036661991.0771426677036; Thu, 23 Oct 2025 12:00:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vC0XB-0006aY-Kl; Thu, 23 Oct 2025 14:59:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vC0X7-0006Ya-NJ for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:33 -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 1vC0X5-0003E1-9q for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:32 -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-271-xqi5XLMZMOeBPxshN1nXRg-1; Thu, 23 Oct 2025 14:59:28 -0400 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-890f1090e81so341667085a.0 for ; Thu, 23 Oct 2025 11:59:28 -0700 (PDT) Received: from x1.com ([142.188.210.50]) by smtp.gmail.com with ESMTPSA id af79cd13be357-89c0ec61770sm213940585a.26.2025.10.23.11.59.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 11:59:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761245970; 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=3YB+xOGWDMtE1OJfHdAxqd5sOxAtxUDFVH7AXA1Dk0w=; b=XAbm0SPEe82jc3R5zhMZ08f4m50qJs3EdCnDR3uL5z7+j3mE+8ZkbLuEHM1gvteVj1G+ZC r7IbB9ekbtZrkXvp6O+hAvUk56YwMqmon7hFf8cMypcGm/2XTnbwzNBHkoMZawiL+9jBey b/S7Yu2uV2NtV9RzIswJHi9OXP177zI= X-MC-Unique: xqi5XLMZMOeBPxshN1nXRg-1 X-Mimecast-MFC-AGG-ID: xqi5XLMZMOeBPxshN1nXRg_1761245968 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761245968; x=1761850768; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3YB+xOGWDMtE1OJfHdAxqd5sOxAtxUDFVH7AXA1Dk0w=; b=gZ7AA2t21JD9Vl4NiRjDALGD6yI4rqJwkLOo1aDyDmQNZ1Stdhsw4MiX7TY28/7JB+ IwmFHZUQp02coOcpWISqN/xcAYk3/JJMxKcsGqSkxd6tjy/nAmUwNadC63pk7cVRYZ5s XWM7T6zOOqbpJh8z+dpNf8uuvc1uAUMh8XRATbilQ1mAGTw6vGYxR5Cj+NhcSjYmhj0Z o3U9gavuXwb+pT0yZcWijTYSHrArXnwh3y91iwcv2Ptz309qyOOLV6HJ/+0R5pWK49b5 jvurlawFq4LfGmmDQwZ3T2mXWJMqBBtmxjkdfqLTAaUQyC09yA/For+ef52XYUWLWjdp +VrA== X-Gm-Message-State: AOJu0YzaAoJZkaCek6tX1TPVEDIPcg5fQ2YTU06Xbvu2yjhSrJYY9h5K tFld1bCSBusfLPMWGBqjLSD9W/qJ6/n2BklxF14f7UQRBiwQ1tAAXE5Ixb4wBKtJlOqvse2rFTx BE1bZtmQh5x/c+969/OAOxHfgt7Y+Gcyi53LPRFzWd1vwEk5J9++4nn4HRU476fxGbrg9uVwlW6 RGxb9fBSS+blSzhipYx5FougkDRJt/5gRq/GstFA== X-Gm-Gg: ASbGncs7s+9kZWtpjdmc+KmtTe9LKcBKs2Wc6hROuugoD3qOs1zB2vweaT3ydW7qa1Y cVRJx/1h7T9vzXtavUVp19ppcIpsBsi4DwgktUwkqbA08YPXC4ng8kRyb2cfC9huv6YryVkqNJJ gxNisVlF2iM1YHqdFsGYRL9O6/qlVNrBdujXwOEi48wz7Rov8ZYHr1NUBFHkGWi7nROyORXu6X0 QrwfAF3zZRzB9s+MUL/pzlFKGXbaxmaejDC2IEaH5sFvhALF1u8AwoA2kujzrCpMJC2P2v+lQEU JxWM29KwQlVGvRMeFr8IshvbDEQ5BVy6SbPjjFxbBzoSw83uNuEBtIFSpR7GLiPf X-Received: by 2002:a05:620a:2586:b0:844:c04c:6a9f with SMTP id af79cd13be357-89070603bf9mr2770581685a.72.1761245967588; Thu, 23 Oct 2025 11:59:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6w20327bFVAP6AIV1bCFZSr9pU4iSoe5jW81ZihAUC2O5/zPeIQUWvu/dTLlswfo3XpO7+w== X-Received: by 2002:a05:620a:2586:b0:844:c04c:6a9f with SMTP id af79cd13be357-89070603bf9mr2770577885a.72.1761245966971; Thu, 23 Oct 2025 11:59:26 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Paolo Bonzini , Fabiano Rosas , Chenyi Qiang , David Hildenbrand , Alexey Kardashevskiy , Li Xiaoyao , Juraj Marcin Subject: [PATCH 7/8] hostmem: Rename guest_memfd to guest_memfd_private Date: Thu, 23 Oct 2025 14:59:12 -0400 Message-ID: <20251023185913.2923322-8-peterx@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251023185913.2923322-1-peterx@redhat.com> References: <20251023185913.2923322-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=lists.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 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: 1761246047290158500 Content-Type: text/plain; charset="utf-8" Rename the HostMemoryBackend.guest_memfd field to reflect what it really means, on whether it needs guest_memfd to back its private portion of mapping. This will help on clearance when we introduce in-place guest_memfd for hostmem. 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.c | 2 +- 5 files changed, 5 insertions(+), 5 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 1f20cd8fd6..0e4cfd6dc6 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 3f3e485709..ea93f034e4 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.c b/backends/hostmem.c index 35734d6f4d..70450733db 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -288,7 +288,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.50.1 From nobody Mon Oct 27 11:10:18 2025 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=1761246040; cv=none; d=zohomail.com; s=zohoarc; b=S3+RpPlDXhGWLnXc5wtIj+j1kLMS8doeNmNn/dD7atPRE3/ycCIfNNEk8P7REQN1RbU5iepTSJapEP4Q1huFop9kPJR1bDNYmZuZnB3Ft0VKHMgOc4MLAtBYOMvQ+aGH8/YtpASCkhZWbBI/91edV89DPaLPSVTKo2g825k2DnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761246040; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=K+mpVlWrgRBpecPbzFIQUbJyLDt7bDmktG7fUEU0KxA=; b=GRrweeuAZsXAu1p8tvd7DJf3pet+xdrOKckJ1K/0Haj9NE0/XS+jPrH986Q32i9gP7ZgK+atyFxCvvt3aLEboJfoZMGO+yRoYrfwekEBeXLuO4GVD0EN7smKRGPjhudhgYq6KjXOyI9b4Hixnq9UBFnGS1UIapRMg52YEE8TGI0= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761246040483395.73392108196344; Thu, 23 Oct 2025 12:00:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vC0XB-0006ad-LD; Thu, 23 Oct 2025 14:59:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vC0X9-0006ZW-Oc for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:35 -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 1vC0X7-0003EN-Gx for qemu-devel@nongnu.org; Thu, 23 Oct 2025 14:59:35 -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-447-DPLhGyLsPNmHAjBVEas3KQ-1; Thu, 23 Oct 2025 14:59:31 -0400 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-4e88947a773so55467631cf.2 for ; Thu, 23 Oct 2025 11:59:31 -0700 (PDT) Received: from x1.com ([142.188.210.50]) by smtp.gmail.com with ESMTPSA id af79cd13be357-89c0ec61770sm213940585a.26.2025.10.23.11.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Oct 2025 11:59:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761245972; 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=K+mpVlWrgRBpecPbzFIQUbJyLDt7bDmktG7fUEU0KxA=; b=eweVEquhuypUKmETjLiXV1fxvEafmtLf9iuJkZuhYrKAZFrXq180mLV/r2KYT7iT3IAJbi 2jipm8aP3O7eqCSqSSubjE06gRlct6QHN66MQpO4hAiRL9jGwDbY7HyuFOPNhkzv7XHGlr Bkemgpno+3SVJf64vwCYqOXduSKAIoI= X-MC-Unique: DPLhGyLsPNmHAjBVEas3KQ-1 X-Mimecast-MFC-AGG-ID: DPLhGyLsPNmHAjBVEas3KQ_1761245971 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761245970; x=1761850770; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K+mpVlWrgRBpecPbzFIQUbJyLDt7bDmktG7fUEU0KxA=; b=mtBT3XgPPCz6MvWt0M8T73/2F4zW2utxc8J8pl1fVQIYRO9y3qlyQUwixzxyFuAZ09 ZCqs+3HoKK6ewpiJhWhTVRv9feIOJw3H+DmInOzUMcugK7aNZPFzOEOl+UY0pwDrIOcp q713AXlqUjywQFUcSrXHUi036gAKo2pjWRPPW8RViPs4wqC0zjSJvjGRBQxTl/O7xLAM ChnUEko2+JQfgy3cxFsNXizEn/3wu6m77d5Bmbh82Yz7Tcn0NomxfzPojFL1eFPYxohJ Eg2bJqiKkfNw+nn7Wf9RxfgvTNvXNBPqwet4/LmXqrl1trZ9Le9YYqOT12qb8EKZgxCp tZaw== X-Gm-Message-State: AOJu0YxwVobw/va+mt5jDOOHXFF1lwzt+6MT5Mzhm+C81bHxAkFAyrwA QUqQkIJ+JpLqEUo/QNbq9CDDQJ+W+pbCsIMCv30nBr5qY6Nf3xlun0LPSTR7RXM22yX3qmCC9mc leRJa3FRVvlZsvQkjjvyD9qPrAsvOToraOC519J3zyagOoDi02YyMfdml8fnY0T9pAgi1xO1Agz CY9dyd2AlEnXSwFBkChWXrA+j/DiVZYIgk0/NFgw== X-Gm-Gg: ASbGncsZO4K01n1D7M0gUu/oVQRNAwgcAMYpqqG2n/L05Uc8LT+T9cGxhJGYNtIr8eQ CTcj36dir6qaIDNkyBbG0h1oHVAFgIc0p/46I4dDrDJbzzcWc3kLhIkToydMj0i0wQUt+voZXAF EXwg+ik+4NSosP9d5E30gQQG1du7gPHZ4MxWNRlW8NgQsqOmdvHItWDAO7NKCEpsoiEftVJo2Qc 32G083V5c8FmvRksUOomUN9hBeUyg+Q3dpx9ncfJdPd8SVs4VCaD//hxQoDAaaTKWdvwTvNd9E4 Nh1t4+hQfKMa66+ZpjFMJpWejmlvGOk1l6rHoKY65CyroUmzhBhZ4dM8J42x8Yhx X-Received: by 2002:a05:622a:650:b0:4e8:aa22:def3 with SMTP id d75a77b69052e-4e8aa22e558mr281838921cf.19.1761245970122; Thu, 23 Oct 2025 11:59:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmmnB/tCoG176yVHb77uscDJtQGtynoLcszG/HybtMkf0gbPzCuCZnyL3Y0+CbppV1GJj1Yw== X-Received: by 2002:a05:622a:650:b0:4e8:aa22:def3 with SMTP id d75a77b69052e-4e8aa22e558mr281838381cf.19.1761245969190; Thu, 23 Oct 2025 11:59:29 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: peterx@redhat.com, Paolo Bonzini , Fabiano Rosas , Chenyi Qiang , David Hildenbrand , Alexey Kardashevskiy , Li Xiaoyao , Juraj Marcin Subject: [PATCH 8/8] hostmem: Support in-place guest memfd to back a VM Date: Thu, 23 Oct 2025 14:59:13 -0400 Message-ID: <20251023185913.2923322-9-peterx@redhat.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20251023185913.2923322-1-peterx@redhat.com> References: <20251023185913.2923322-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=lists.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 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: 1761246051198158500 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 in-place. 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, in place), rather than having another backend supporting the pages converted to shared. To use the in-place guest-memfd, one can add a memfd object with: -object memory-backend-memfd,guest-memfd=3Don,share=3Don Note that share=3Don is required with in-place guest_memfd. Signed-off-by: Peter Xu --- qapi/qom.json | 6 +++- backends/hostmem-memfd.c | 66 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 67 insertions(+), 5 deletions(-) diff --git a/qapi/qom.json b/qapi/qom.json index 830cb2ffe7..6b090fe9a0 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -764,13 +764,17 @@ # @seal: if true, create a sealed-file, which will block further # resizing of the memory (default: true) # +# @guest-memfd: if true, use guest-memfd to back the memory region. +# (default: false, since: 10.2) +# # Since: 2.12 ## { 'struct': 'MemoryBackendMemfdProperties', 'base': 'MemoryBackendProperties', 'data': { '*hugetlb': 'bool', '*hugetlbsize': 'size', - '*seal': 'bool' }, + '*seal': 'bool', + '*guest-memfd': 'bool' }, 'if': 'CONFIG_LINUX' } =20 ## diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index ea93f034e4..1fa16c1e1d 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -18,6 +18,8 @@ #include "qapi/error.h" #include "qom/object.h" #include "migration/cpr.h" +#include "system/kvm.h" +#include =20 OBJECT_DECLARE_SIMPLE_TYPE(HostMemoryBackendMemfd, MEMORY_BACKEND_MEMFD) =20 @@ -28,6 +30,13 @@ struct HostMemoryBackendMemfd { bool hugetlb; uint64_t hugetlbsize; bool seal; + /* + * NOTE: this differs from HostMemoryBackend's guest_memfd_private, + * which represents a 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. + */ + bool guest_memfd; }; =20 static bool @@ -47,10 +56,40 @@ 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 (m->guest_memfd) { + /* User choose to use in-place guest-memfd to back the VM.. */ + if (!backend->share) { + error_setg(errp, "In-place guest-memfd must be used with share= =3Don"); + return false; + } + + /* + * This is the request to have a guest-memfd to back private pages. + * In-place guest-memfd doesn't work like that. Disable it for now + * to make it simple, so that each memory backend can only have + * guest-memfd either as private, or fully shared. + */ + if (backend->guest_memfd_private) { + error_setg(errp, "In-place guest-memfd cannot be used with ano= ther " + "private guest-memfd"); + return false; + } + + /* TODO: add huge page support */ + fd =3D kvm_create_guest_memfd(backend->size, + GUEST_MEMFD_FLAG_MMAP | + GUEST_MEMFD_FLAG_INIT_SHARED, + errp); + if (fd < 0) { + return false; + } + } 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 =3D=3D -1) { return false; } @@ -65,6 +104,18 @@ have_fd: backend->size, ram_flags, fd, 0,= errp); } =20 +static bool +memfd_backend_get_guest_memfd(Object *o, Error **errp) +{ + return MEMORY_BACKEND_MEMFD(o)->guest_memfd; +} + +static void +memfd_backend_set_guest_memfd(Object *o, bool value, Error **errp) +{ + MEMORY_BACKEND_MEMFD(o)->guest_memfd =3D value; +} + static bool memfd_backend_get_hugetlb(Object *o, Error **errp) { @@ -152,6 +203,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_bool(oc, "guest-memfd", + memfd_backend_get_guest_memfd, + memfd_backend_set_guest_memfd); + 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.50.1