Re: [POC PATCH 3/5] memory/guest_memfd: Enable in-place conversion when available

2025-07-16 Thread Chenyi Qiang
On 7/15/2025 11:31 AM, Xiaoyao Li wrote: > From: Yan Zhao > > (This is just the POC code to use in-place conversion gmem.) > > Try to use in-place conversion gmem when it is supported. > > When in-place conversion is enabled, there is no need to discard memory > since it still needs to be us

Re: [PATCH v7 3/5] memory: Unify the definiton of ReplayRamPopulate() and ReplayRamDiscard()

2025-06-19 Thread Chenyi Qiang
On 6/19/2025 10:29 PM, Peter Xu wrote: > On Thu, Jun 19, 2025 at 11:06:46AM +0800, Chenyi Qiang wrote: >> To fix the build error with --enable-docs configuration, Add the below fixup > > Thanks, this works for me. > > Though I just noticed it has more than the d

Re: [PATCH v7 4/5] ram-block-attributes: Introduce RamBlockAttributes to manage RAMBlock with guest_memfd

2025-06-19 Thread Chenyi Qiang
On 6/12/2025 4:27 PM, Chenyi Qiang wrote: > Commit 852f0048f3 ("RAMBlock: make guest_memfd require uncoordinated > discard") highlighted that subsystems like VFIO may disable RAM block > discard. However, guest_memfd relies on discard operations for page > conversion betw

Re: [PATCH v7 0/5] Enable shared device assignment

2025-06-18 Thread Chenyi Qiang
On 6/19/2025 6:22 AM, Peter Xu wrote: > On Thu, Jun 12, 2025 at 04:27:41PM +0800, Chenyi Qiang wrote: >> This is the v7 series of the shared device assignment support. > > Building doc fails, see: > > https://gitlab.com/peterx/qemu/-/jobs/10396029551 > > You

Re: [PATCH v7 3/5] memory: Unify the definiton of ReplayRamPopulate() and ReplayRamDiscard()

2025-06-18 Thread Chenyi Qiang
On 6/12/2025 4:27 PM, Chenyi Qiang wrote: > Update ReplayRamDiscard() function to return the result and unify the > ReplayRamPopulate() and ReplayRamDiscard() to ReplayRamDiscardState() at > the same time due to their identical definitions. This unification > simplifies related stru

[PATCH v7 3/5] memory: Unify the definiton of ReplayRamPopulate() and ReplayRamDiscard()

2025-06-12 Thread Chenyi Qiang
. Reviewed-by: David Hildenbrand Reviewed-by: Pankaj Gupta Reviewed-by: Xiaoyao Li Signed-off-by: Chenyi Qiang --- Changes in v7: - Add Reviewed-by from Xiaoyao and Pankaj. Changes in v6: - Add Reviewed-by from David - Add a documentation comment for the prototype change Changes in v5

[PATCH v7 5/5] physmem: Support coordinated discarding of RAM with guest_memfd

2025-06-12 Thread Chenyi Qiang
hange() helper invokes. As coordinate discarding of RAM with guest_memfd is now supported, only block uncoordinated discard. Tested-by: Alexey Kardashevskiy Reviewed-by: Alexey Kardashevskiy Acked-by: David Hildenbrand Signed-off-by: Chenyi Qiang --- Changes in v7: - Add some document abou

[PATCH v7 4/5] ram-block-attributes: Introduce RamBlockAttributes to manage RAMBlock with guest_memfd

2025-06-12 Thread Chenyi Qiang
by: Alexey Kardashevskiy Reviewed-by: Alexey Kardashevskiy Reviewed-by: Pankaj Gupta Signed-off-by: Chenyi Qiang --- Changes in v7: - Unwrap the two helpers(is_range_populated() and is is_range_discarded()). (Alexey) - Use bit to do the iteration instead of offset without additional va

[PATCH v7 1/5] memory: Export a helper to get intersection of a MemoryRegionSection with a given range

2025-06-12 Thread Chenyi Qiang
Reviewed-by: Pankaj Gupta Reviewed-by: David Hildenbrand Reviewed-by: Zhao Liu Reviewed-by: Xiaoyao Li Signed-off-by: Chenyi Qiang --- Changes in v7: - Add Reivewed-by from Xiaoyao and Pankaj Changes in v6: - No change. Changes in v5: - Indent change for int128 ops to avoid the line

[PATCH v7 2/5] memory: Change memory_region_set_ram_discard_manager() to return the result

2025-06-12 Thread Chenyi Qiang
Hildenbrand Reviewed-by: David Hildenbrand Reviewed-by: Pankaj Gupta Tested-by: Alexey Kardashevskiy Reviewed-by: Alexey Kardashevskiy Reviewed-by: Xiaoyao Li Signed-off-by: Chenyi Qiang --- Changes in v7: - Add Reviewed-by from Pankaj, Alexey and Xiaoyao Changes in v6: - Add Reviewed-by from

[PATCH v7 0/5] Enable shared device assignment

2025-06-12 Thread Chenyi Qiang
inux-iommu/0-v2-5c26bde5c22d+58b-iommu_pt_...@nvidia.com/ [4] https://lore.kernel.org/qemu-devel/d1a71e00-243b-4751-ab73-c05a4e090...@redhat.com/ [5] https://lore.kernel.org/qemu-devel/013b36a9-9310-4073-b54c-9c511f23d...@linux.intel.com/ Chenyi Qiang (5): memory: Export a helper to get interse

Re: [PATCH v6 0/5] Enable shared device assignment

2025-06-08 Thread Chenyi Qiang
/2025 4:32 PM, Chenyi Qiang wrote: > This is the v6 series of the shared device assignment support. > > Compared with the last version [1], this series retains the basic support > and removes the additional complex error handling, which can be added > back when necessary. Meanwhile, t

Re: [PATCH v6 4/5] ram-block-attributes: Introduce RamBlockAttributes to manage RAMBlock with guest_memfd

2025-06-04 Thread Chenyi Qiang
On 6/4/2025 7:04 PM, Alexey Kardashevskiy wrote: > > > On 30/5/25 18:32, Chenyi Qiang wrote: >> Commit 852f0048f3 ("RAMBlock: make guest_memfd require uncoordinated >> discard") highlighted that subsystems like VFIO may disable RAM block >> discard. H

Re: [PATCH v6 4/5] ram-block-attributes: Introduce RamBlockAttributes to manage RAMBlock with guest_memfd

2025-06-04 Thread Chenyi Qiang
On 6/5/2025 8:35 AM, Alexey Kardashevskiy wrote: > > > On 4/6/25 21:04, Alexey Kardashevskiy wrote: >> >> >> On 30/5/25 18:32, Chenyi Qiang wrote: >>> Commit 852f0048f3 ("RAMBlock: make guest_memfd require uncoordinated >>> discard") high

Re: [PATCH v6 4/5] ram-block-attributes: Introduce RamBlockAttributes to manage RAMBlock with guest_memfd

2025-06-03 Thread Chenyi Qiang
orresponding shared <-> private > conversions in addition to VFIO discard <-> populate conversions. > Since per RAMBlock bitmap set is disjoint for both the above cases, > so can be reused for live migration use-case as well when deciding which > page is private vs shared. &g

Re: [PATCH v6 4/5] ram-block-attributes: Introduce RamBlockAttributes to manage RAMBlock with guest_memfd

2025-06-02 Thread Chenyi Qiang
On 6/3/2025 1:26 PM, Gupta, Pankaj wrote: > On 6/3/2025 3:26 AM, Chenyi Qiang wrote: >> >> >> On 6/1/2025 5:58 PM, Gupta, Pankaj wrote: >>> On 5/30/2025 10:32 AM, Chenyi Qiang wrote: >>>> Commit 852f0048f3 ("RAMBlock: make guest_memfd requir

Re: [PATCH v6 4/5] ram-block-attributes: Introduce RamBlockAttributes to manage RAMBlock with guest_memfd

2025-06-02 Thread Chenyi Qiang
On 6/3/2025 5:10 AM, David Hildenbrand wrote: > On 30.05.25 10:32, Chenyi Qiang wrote: >> Commit 852f0048f3 ("RAMBlock: make guest_memfd require uncoordinated >> discard") highlighted that subsystems like VFIO may disable RAM block >> discard. However, guest_mem

Re: [PATCH v6 4/5] ram-block-attributes: Introduce RamBlockAttributes to manage RAMBlock with guest_memfd

2025-06-02 Thread Chenyi Qiang
On 6/1/2025 5:58 PM, Gupta, Pankaj wrote: > On 5/30/2025 10:32 AM, Chenyi Qiang wrote: >> Commit 852f0048f3 ("RAMBlock: make guest_memfd require uncoordinated >> discard") highlighted that subsystems like VFIO may disable RAM block >> discard. However, guest_mem

[PATCH v6 2/5] memory: Change memory_region_set_ram_discard_manager() to return the result

2025-05-30 Thread Chenyi Qiang
Hildenbrand Reviewed-by: David Hildenbrand Signed-off-by: Chenyi Qiang --- Changes in v6: - Add Reviewed-by from David. Changes in v5: - Nit in commit message (return false -> -EBUSY) - Add set_ram_discard_manager(NULL) when ram_block_discard_range() fails. Changes in v3: - M

[PATCH v6 4/5] ram-block-attributes: Introduce RamBlockAttributes to manage RAMBlock with guest_memfd

2025-05-30 Thread Chenyi Qiang
ing out of the picture as it is not required. Signed-off-by: Chenyi Qiang --- Changes in v6: - Change the object type name from RamBlockAttribute to RamBlockAttributes. (David) - Save the associated RAMBlock instead MemoryRegion in RamBlockAttributes. (David) - Squash the st

[PATCH v6 3/5] memory: Unify the definiton of ReplayRamPopulate() and ReplayRamDiscard()

2025-05-30 Thread Chenyi Qiang
. Reviewed-by: David Hildenbrand Signed-off-by: Chenyi Qiang --- Changes in v6: - Add Reviewed-by from David - Add a documentation comment for the prototype change Changes in v5: - Rename ReplayRamStateChange to ReplayRamDiscardState (David) - return data->fn(s, data->opaque) i

[PATCH v6 5/5] physmem: Support coordinated discarding of RAM with guest_memfd

2025-05-30 Thread Chenyi Qiang
hange() helper invokes. As coordinate discarding of RAM with guest_memfd is now supported, only block uncoordinated discard. Signed-off-by: Chenyi Qiang --- Changes in v6: - Squash the unblocking of cooridnate discard into this commit. - Remove the checks in migration path. Changes

[PATCH v6 1/5] memory: Export a helper to get intersection of a MemoryRegionSection with a given range

2025-05-30 Thread Chenyi Qiang
Reviewed-by: David Hildenbrand Reviewed-by: Zhao Liu Signed-off-by: Chenyi Qiang --- Changes in v6: - No change. Changes in v5: - Indent change for int128 ops to avoid the line over 80 - Add two Review-by from Alexey and Zhao Changes in v4: - No change. --- hw/virtio/virtio-mem.c

[PATCH v6 0/5] Enable shared device assignment

2025-05-30 Thread Chenyi Qiang
l.org/qemu-devel/d1a71e00-243b-4751-ab73-c05a4e090...@redhat.com/ [5] https://lore.kernel.org/qemu-devel/013b36a9-9310-4073-b54c-9c511f23d...@linux.intel.com/ Chenyi Qiang (5): memory: Export a helper to get intersection of a MemoryRegionSection with a given range memo

Re: [PATCH v5 07/10] RAMBlock: Make guest_memfd require coordinate discard

2025-05-27 Thread Chenyi Qiang
On 5/27/2025 7:20 PM, David Hildenbrand wrote: > On 27.05.25 07:47, Chenyi Qiang wrote: >> >> >> On 5/26/2025 5:08 PM, David Hildenbrand wrote: >>> On 20.05.25 12:28, Chenyi Qiang wrote: >>>> As guest_memfd is now managed by RamBlockAttribu

Re: [PATCH v5 10/10] ram-block-attribute: Add more error handling during state changes

2025-05-27 Thread Chenyi Qiang
On 5/27/2025 5:11 PM, Alexey Kardashevskiy wrote: > > > On 20/5/25 20:28, Chenyi Qiang wrote: >> The current error handling is simple with the following assumption: >> - QEMU will quit instead of resuming the guest if kvm_convert_memory() >>    fails, thus no ne

Re: [PATCH v5 05/10] ram-block-attribute: Introduce a helper to notify shared/private state changes

2025-05-27 Thread Chenyi Qiang
On 5/27/2025 3:35 PM, Alexey Kardashevskiy wrote: > > > On 20/5/25 20:28, Chenyi Qiang wrote: >> A new state_change() helper is introduced for RamBlockAttribute >> to efficiently notify all registered RamDiscardListeners, including >> VFIO listeners, about

Re: [PATCH v5 07/10] RAMBlock: Make guest_memfd require coordinate discard

2025-05-27 Thread Chenyi Qiang
On 5/27/2025 3:42 PM, Alexey Kardashevskiy wrote: > > > On 27/5/25 15:47, Chenyi Qiang wrote: >> >> >> On 5/26/2025 5:08 PM, David Hildenbrand wrote: >>> On 20.05.25 12:28, Chenyi Qiang wrote: >>>> As guest_memfd is now managed by RamBlockA

Re: [PATCH v5 07/10] RAMBlock: Make guest_memfd require coordinate discard

2025-05-26 Thread Chenyi Qiang
On 5/26/2025 5:08 PM, David Hildenbrand wrote: > On 20.05.25 12:28, Chenyi Qiang wrote: >> As guest_memfd is now managed by RamBlockAttribute with >> RamDiscardManager, only block uncoordinated discard. >> >> Signed-off-by: Chenyi Qiang >> --- >>

Re: [PATCH v5 08/10] memory: Change NotifyRamDiscard() definition to return the result

2025-05-26 Thread Chenyi Qiang
On 5/26/2025 8:44 PM, Cédric Le Goater wrote: > On 5/26/25 12:36, Cédric Le Goater wrote: >> On 5/20/25 12:28, Chenyi Qiang wrote: >>> So that the caller can check the result of NotifyRamDiscard() handler if >>> the operation fails. >>> >>> Signed-of

Re: [PATCH v5 04/10] ram-block-attribute: Introduce RamBlockAttribute to manage RAMBlock with guest_memfd

2025-05-26 Thread Chenyi Qiang
On 5/27/2025 9:20 AM, Alexey Kardashevskiy wrote: > > > On 27/5/25 11:15, Chenyi Qiang wrote: >> >> >> On 5/26/2025 7:16 PM, Alexey Kardashevskiy wrote: >>> >>> >>> On 26/5/25 19:28, Chenyi Qiang wrote: >>>> >>>&g

Re: [PATCH v5 04/10] ram-block-attribute: Introduce RamBlockAttribute to manage RAMBlock with guest_memfd

2025-05-26 Thread Chenyi Qiang
On 5/26/2025 7:16 PM, Alexey Kardashevskiy wrote: > > > On 26/5/25 19:28, Chenyi Qiang wrote: >> >> >> On 5/26/2025 5:01 PM, David Hildenbrand wrote: >>> On 20.05.25 12:28, Chenyi Qiang wrote: >>>> Commit 852f0048f3 ("RAMBlock: make guest_m

Re: [PATCH v5 10/10] ram-block-attribute: Add more error handling during state changes

2025-05-26 Thread Chenyi Qiang
On 5/26/2025 8:10 PM, David Hildenbrand wrote: > On 26.05.25 12:19, Chenyi Qiang wrote: >> >> >> On 5/26/2025 5:17 PM, David Hildenbrand wrote: >>> On 20.05.25 12:28, Chenyi Qiang wrote: >>>> The current error handling is simple with the following as

Re: [PATCH v5 00/10] Enable shared device assignment

2025-05-26 Thread Chenyi Qiang
On 5/26/2025 7:37 PM, Cédric Le Goater wrote: > On 5/20/25 12:28, Chenyi Qiang wrote: >> This is the v5 series of the shared device assignment support. >> >> As discussed in the v4 series [1], the GenericStateManager parent class >> and PrivateSharedManager child int

Re: [PATCH v5 06/10] memory: Attach RamBlockAttribute to guest_memfd-backed RAMBlocks

2025-05-26 Thread Chenyi Qiang
On 5/26/2025 5:06 PM, David Hildenbrand wrote: > On 20.05.25 12:28, Chenyi Qiang wrote: >> A new field, ram_shared, was introduced in RAMBlock to link to a >> RamBlockAttribute object, which centralizes all guest_memfd state >> information (such as fd and shared_bitm

Re: [PATCH v5 03/10] memory: Unify the definiton of ReplayRamPopulate() and ReplayRamDiscard()

2025-05-26 Thread Chenyi Qiang
On 5/26/2025 5:35 PM, Philippe Mathieu-Daudé wrote: > Hi Chenyi Qiang, > > On 20/5/25 12:28, Chenyi Qiang wrote: >> Update ReplayRamDiscard() function to return the result and unify the >> ReplayRamPopulate() and ReplayRamDiscard() to ReplayRamDiscardState() at >>

Re: [PATCH v5 10/10] ram-block-attribute: Add more error handling during state changes

2025-05-26 Thread Chenyi Qiang
On 5/26/2025 5:17 PM, David Hildenbrand wrote: > On 20.05.25 12:28, Chenyi Qiang wrote: >> The current error handling is simple with the following assumption: >> - QEMU will quit instead of resuming the guest if kvm_convert_memory() >>    fails, thus no need to do rollb

Re: [PATCH v5 04/10] ram-block-attribute: Introduce RamBlockAttribute to manage RAMBlock with guest_memfd

2025-05-26 Thread Chenyi Qiang
On 5/26/2025 5:01 PM, David Hildenbrand wrote: > On 20.05.25 12:28, Chenyi Qiang wrote: >> Commit 852f0048f3 ("RAMBlock: make guest_memfd require uncoordinated >> discard") highlighted that subsystems like VFIO may disable RAM block >> discard. However, guest_mem

[PATCH v5 07/10] RAMBlock: Make guest_memfd require coordinate discard

2025-05-20 Thread Chenyi Qiang
As guest_memfd is now managed by RamBlockAttribute with RamDiscardManager, only block uncoordinated discard. Signed-off-by: Chenyi Qiang --- Changes in v5: - Revert to use RamDiscardManager. Changes in v4: - Modify commit message (RamDiscardManager->PrivateSharedManager). Changes in

[PATCH v5 08/10] memory: Change NotifyRamDiscard() definition to return the result

2025-05-20 Thread Chenyi Qiang
So that the caller can check the result of NotifyRamDiscard() handler if the operation fails. Signed-off-by: Chenyi Qiang --- Changes in v5: - Revert to use of NotifyRamDiscard() Changes in v4: - Newly added. --- hw/vfio/listener.c | 6 -- include/system/memory.h | 4

[PATCH v5 06/10] memory: Attach RamBlockAttribute to guest_memfd-backed RAMBlocks

2025-05-20 Thread Chenyi Qiang
to be avoided since it is not supported yet in confidential VMs. Additionally, use the ram_block_attribute_state_change() helper to notify the registered RamDiscardListener of these changes. Signed-off-by: Chenyi Qiang --- Changes in v5: - Revert to use RamDiscardManager interface. - Mov

[PATCH v5 09/10] KVM: Introduce RamDiscardListener for attribute changes during memory conversions

2025-05-20 Thread Chenyi Qiang
, although it is currently unlikely to happen. With in-place conversion guest_memfd in the future, it would be more likely to encounter errors and require error handling. For now, simply return the result, and kvm_convert_memory() will cause QEMU to quit if any issue arises. Signed-off-by: Chenyi

[PATCH v5 10/10] ram-block-attribute: Add more error handling during state changes

2025-05-20 Thread Chenyi Qiang
. Signed-off-by: Chenyi Qiang --- system/ram-block-attribute.c | 116 +++ 1 file changed, 90 insertions(+), 26 deletions(-) diff --git a/system/ram-block-attribute.c b/system/ram-block-attribute.c index 387501b569..0af3396aa4 100644 --- a/system/ram-block-attribute.c

[PATCH v5 05/10] ram-block-attribute: Introduce a helper to notify shared/private state changes

2025-05-20 Thread Chenyi Qiang
callbacks, allowing listeners to handle memory based on the latest status. Signed-off-by: Chenyi Qiang --- Change in v5: - Move the state_change() back to a helper instead of a callback of the class since there's no child for the RamBlockAttributeClass. - Remove the error handling and

[PATCH v5 04/10] ram-block-attribute: Introduce RamBlockAttribute to manage RAMBlock with guest_memfd

2025-05-20 Thread Chenyi Qiang
_mapping.c', 'memory.c', 'physmem.c', diff --git a/system/ram-block-attribute.c b/system/ram-block-attribute.c new file mode 100644 index 00..8d4a24738c --- /dev/null +++ b/system/ram-block-attribute.c @@ -0,0 +1,311 @@ +/* + * QEMU ram block attribute + * + * Copyri

[PATCH v5 03/10] memory: Unify the definiton of ReplayRamPopulate() and ReplayRamDiscard()

2025-05-20 Thread Chenyi Qiang
. Signed-off-by: Chenyi Qiang --- Changes in v5: - Rename ReplayRamStateChange to ReplayRamDiscardState (David) - return data->fn(s, data->opaque) instead of 0 in virtio_mem_rdm_replay_discarded_cb(). (Alexey) Changes in v4: - Modify the commit message. We won't use Replay(

[PATCH v5 00/10] Enable shared device assignment

2025-05-20 Thread Chenyi Qiang
f8-8c9c30439...@redhat.com/ [4] https://lore.kernel.org/qemu-devel/20240423150951.41600-54-pbonz...@redhat.com/ [5] https://lore.kernel.org/kvm/cover.1747264138.git.ackerley...@google.com/ [6] https://lore.kernel.org/linux-iommu/0-v2-5c26bde5c22d+58b-iommu_pt_...@nvidia.com/ Chenyi Qiang (10):

[PATCH v5 01/10] memory: Export a helper to get intersection of a MemoryRegionSection with a given range

2025-05-20 Thread Chenyi Qiang
Reviewed-by: David Hildenbrand Reviewed-by: Zhao Liu Signed-off-by: Chenyi Qiang --- Changes in v5: - Indent change for int128 ops to avoid the line over 80 - Add two Review-by from Alexey and Zhao Changes in v4: - No change. Changes in v3: - No change Changes in v2: - Make

[PATCH v5 02/10] memory: Change memory_region_set_ram_discard_manager() to return the result

2025-05-20 Thread Chenyi Qiang
Hildenbrand Signed-off-by: Chenyi Qiang --- Changes in v5: - Nit in commit message (return false -> -EBUSY) - Add set_ram_discard_manager(NULL) when ram_block_discard_range() fails. Changes in v4: - No change. Changes in v3: - Move set_ram_discard_manager() up to avoid a g_f

Re: [PATCH v4 07/13] ram-block-attribute: Introduce RamBlockAttribute to manage RAMBLock with guest_memfd

2025-05-13 Thread Chenyi Qiang
On 5/13/2025 4:31 PM, Zhao Liu wrote: diff --git a/include/exec/ramblock.h b/include/exec/ramblock.h index 0babd105c0..b8b5469db9 100644 --- a/include/exec/ramblock.h +++ b/include/exec/ramblock.h @@ -23,6 +23,10 @@ #include "cpu-common.h" #include "qemu/rcu.

Re: [PATCH v4 07/13] ram-block-attribute: Introduce RamBlockAttribute to manage RAMBLock with guest_memfd

2025-05-12 Thread Chenyi Qiang
Thanks Zhao for your review! On 5/12/2025 4:07 PM, Zhao Liu wrote: > [snip] > >> --- >> include/exec/ramblock.h | 24 +++ >> system/meson.build | 1 + >> system/ram-block-attribute.c | 282 +++ >> 3 files changed, 307 insertions(+) >> create mod

Re: [PATCH v4 11/13] KVM: Introduce CVMPrivateSharedListener for attribute changes during page conversions

2025-05-11 Thread Chenyi Qiang
On 5/9/2025 5:03 PM, Baolu Lu wrote: > On 4/7/2025 3:49 PM, Chenyi Qiang wrote: >> With the introduction of the RamBlockAttribute object to manage >> RAMBlocks with guest_memfd and the implementation of >> PrivateSharedManager interface to convey page conversion events, it

Re: [PATCH v4 07/13] ram-block-attribute: Introduce RamBlockAttribute to manage RAMBLock with guest_memfd

2025-05-09 Thread Chenyi Qiang
On 5/9/2025 4:18 PM, David Hildenbrand wrote: >>>> >>>> Signed-off-by: Chenyi Qiang >>> >>> <...> >>> >>>> + >>>> +int ram_block_attribute_realize(RamBlockAttribute *attr, MemoryRegion >&g

Re: [PATCH v4 10/13] memory: Change NotifyStateClear() definition to return the result

2025-05-09 Thread Chenyi Qiang
On 5/9/2025 4:22 PM, Baolu Lu wrote: > On 4/27/2025 10:26 AM, Chenyi Qiang wrote: >> Hi David, >> >> Any thought on patch 10-12, which is to move the change attribute into a >> priority listener. A problem is how to handle the error handling of >> private_

Re: [PATCH v4 12/13] ram-block-attribute: Add priority listener support for PrivateSharedListener

2025-05-09 Thread Chenyi Qiang
On 5/9/2025 5:23 PM, Baolu Lu wrote: > On 4/7/2025 3:49 PM, Chenyi Qiang wrote: >> In-place page conversion requires operations to follow a specific >> sequence: unmap-before-conversion-to-private and >> map-after-conversion-to-shared. Currently, both attribute changes and

Re: [PATCH v4 10/13] memory: Change NotifyStateClear() definition to return the result

2025-05-09 Thread Chenyi Qiang
On 5/9/2025 4:20 PM, David Hildenbrand wrote: > On 09.05.25 04:38, Chao Gao wrote: >> On Sun, Apr 27, 2025 at 10:26:52AM +0800, Chenyi Qiang wrote: >>> Hi David, >>> >>> Any thought on patch 10-12, which is to move the change attribute into a >>>

Re: [PATCH v4 07/13] ram-block-attribute: Introduce RamBlockAttribute to manage RAMBLock with guest_memfd

2025-05-09 Thread Chenyi Qiang
Thanks Baolu for your review! On 5/9/2025 2:41 PM, Baolu Lu wrote: > On 4/7/25 15:49, Chenyi Qiang wrote: >> Commit 852f0048f3 ("RAMBlock: make guest_memfd require uncoordinated >> discard") highlighted that subsystems like VFIO may disable RAM block >> discard.

Re: [PATCH v4 10/13] memory: Change NotifyStateClear() definition to return the result

2025-04-26 Thread Chenyi Qiang
set_attribute_private(). At present, I simply raise an assert instead of adding any rollback work (see patch 11). On 4/7/2025 3:49 PM, Chenyi Qiang wrote: > So that the caller can check the result of NotifyStateClear() handler if > the operation fails. > > Signed-off-by:

Re: [PATCH v4 03/13] memory: Unify the definiton of ReplayRamPopulate() and ReplayRamDiscard()

2025-04-26 Thread Chenyi Qiang
On 4/25/2025 8:42 PM, David Hildenbrand wrote: > On 07.04.25 09:49, Chenyi Qiang wrote: >> Update ReplayRamDiscard() function to return the result and unify the >> ReplayRamPopulate() and ReplayRamDiscard() to ReplayStateChange() at >> the same time due to their identi

Re: [PATCH v4 05/13] memory: Introduce PrivateSharedManager Interface as child of GenericStateManager

2025-04-26 Thread Chenyi Qiang
On 4/25/2025 8:57 PM, David Hildenbrand wrote: > On 07.04.25 09:49, Chenyi Qiang wrote: >> To manage the private and shared RAM states in confidential VMs, >> introduce a new class of PrivateShareManager as a child of >> GenericStateManager, which inherits the six interf

Re: [PATCH v4 04/13] memory: Introduce generic state change parent class for RamDiscardManager

2025-04-26 Thread Chenyi Qiang
Thanks David for your review! On 4/25/2025 8:49 PM, David Hildenbrand wrote: > On 09.04.25 11:56, Alexey Kardashevskiy wrote: >> >> >> On 7/4/25 17:49, Chenyi Qiang wrote: >>> RamDiscardManager is an interface used by virtio-mem to adjust VFIO >>> mapping

Re: [PATCH v4 04/13] memory: Introduce generic state change parent class for RamDiscardManager

2025-04-17 Thread Chenyi Qiang
On 4/18/2025 7:10 AM, Alexey Kardashevskiy wrote: > > > On 16/4/25 13:32, Chenyi Qiang wrote: >> >> >> On 4/10/2025 9:44 AM, Chenyi Qiang wrote: >>> >>> >>> On 4/10/2025 8:11 AM, Alexey Kardashevskiy wrote: >>>> >>>>

Re: [PATCH v4 04/13] memory: Introduce generic state change parent class for RamDiscardManager

2025-04-15 Thread Chenyi Qiang
On 4/10/2025 9:44 AM, Chenyi Qiang wrote: > > > On 4/10/2025 8:11 AM, Alexey Kardashevskiy wrote: >> >> >> On 9/4/25 22:57, Chenyi Qiang wrote: >>> >>> >>> On 4/9/2025 5:56 PM, Alexey Kardashevskiy wrote: >>>> >>&g

Re: [PATCH v4 02/13] memory: Change memory_region_set_ram_discard_manager() to return the result

2025-04-10 Thread Chenyi Qiang
On 4/9/2025 1:35 PM, Alexey Kardashevskiy wrote: > > > On 7/4/25 17:49, Chenyi Qiang wrote: >> Modify memory_region_set_ram_discard_manager() to return false if a >> RamDiscardManager is already set in the MemoryRegion. The caller must >> handle this failure, suc

Re: [PATCH v4 07/13] ram-block-attribute: Introduce RamBlockAttribute to manage RAMBLock with guest_memfd

2025-04-10 Thread Chenyi Qiang
On 4/9/2025 5:57 PM, Alexey Kardashevskiy wrote: > > > On 7/4/25 17:49, Chenyi Qiang wrote: >> Commit 852f0048f3 ("RAMBlock: make guest_memfd require uncoordinated >> discard") highlighted that subsystems like VFIO may disable RAM block >> discard. H

Re: [PATCH v4 06/13] vfio: Add the support for PrivateSharedManager Interface

2025-04-09 Thread Chenyi Qiang
On 4/9/2025 5:58 PM, Alexey Kardashevskiy wrote: > > > On 7/4/25 17:49, Chenyi Qiang wrote: >> Subsystems like VFIO previously disabled ram block discard and only >> allowed coordinated discarding via RamDiscardManager. However, >> guest_memfd in confidential VMs r

Re: [PATCH v4 05/13] memory: Introduce PrivateSharedManager Interface as child of GenericStateManager

2025-04-09 Thread Chenyi Qiang
On 4/9/2025 5:56 PM, Alexey Kardashevskiy wrote: > > > On 7/4/25 17:49, Chenyi Qiang wrote: >> To manage the private and shared RAM states in confidential VMs, >> introduce a new class of PrivateShareManager as a child of > > missing "d" in

Re: [PATCH v4 04/13] memory: Introduce generic state change parent class for RamDiscardManager

2025-04-09 Thread Chenyi Qiang
On 4/10/2025 8:11 AM, Alexey Kardashevskiy wrote: > > > On 9/4/25 22:57, Chenyi Qiang wrote: >> >> >> On 4/9/2025 5:56 PM, Alexey Kardashevskiy wrote: >>> >>> >>> On 7/4/25 17:49, Chenyi Qiang wrote: >>>> RamDiscardManager

Re: [PATCH v4 04/13] memory: Introduce generic state change parent class for RamDiscardManager

2025-04-09 Thread Chenyi Qiang
On 4/9/2025 5:56 PM, Alexey Kardashevskiy wrote: > > > On 7/4/25 17:49, Chenyi Qiang wrote: >> RamDiscardManager is an interface used by virtio-mem to adjust VFIO >> mappings in relation to VM page assignment. It manages the state of >> populated and discard for the

Re: [PATCH v4 01/13] memory: Export a helper to get intersection of a MemoryRegionSection with a given range

2025-04-09 Thread Chenyi Qiang
On 4/9/2025 2:45 PM, Alexey Kardashevskiy wrote: > > > On 9/4/25 16:26, Chenyi Qiang wrote: >> >> >> On 4/9/2025 10:47 AM, Alexey Kardashevskiy wrote: >>> >>> On 7/4/25 17:49, Chenyi Qiang wrote: >>>> Rename the helper to memory_regi

Re: [PATCH v4 03/13] memory: Unify the definiton of ReplayRamPopulate() and ReplayRamDiscard()

2025-04-09 Thread Chenyi Qiang
On 4/9/2025 1:43 PM, Alexey Kardashevskiy wrote: > > > On 7/4/25 17:49, Chenyi Qiang wrote: >> Update ReplayRamDiscard() function to return the result and unify the >> ReplayRamPopulate() and ReplayRamDiscard() to ReplayStateChange() at >> the same time due to

Re: [PATCH v4 01/13] memory: Export a helper to get intersection of a MemoryRegionSection with a given range

2025-04-08 Thread Chenyi Qiang
On 4/9/2025 10:47 AM, Alexey Kardashevskiy wrote: > > On 7/4/25 17:49, Chenyi Qiang wrote: >> Rename the helper to memory_region_section_intersect_range() to make it >> more generic. Meanwhile, define the @end as Int128 and replace the >> related operations with I

Re: [PATCH v4 02/13] memory: Change memory_region_set_ram_discard_manager() to return the result

2025-04-07 Thread Chenyi Qiang
On 4/7/2025 5:53 PM, Xiaoyao Li wrote: > On 4/7/2025 3:49 PM, Chenyi Qiang wrote: >> Modify memory_region_set_ram_discard_manager() to return false if a >> RamDiscardManager is already set in the MemoryRegion. > > It doesn't return false, but -EBUSY. Nice catch! Fo

[PATCH v4 00/13] Enable shared device assignment

2025-04-07 Thread Chenyi Qiang
kernel.org/lkml/cover.1726009989.git.ackerley...@google.com/ [3] https://lore.kernel.org/linux-iommu/7-v1-01fa10580981+1d-iommu_pt_...@nvidia.com/ Chenyi Qiang (13): memory: Export a helper to get intersection of a MemoryRegionSection with a given range

[PATCH v4 05/13] memory: Introduce PrivateSharedManager Interface as child of GenericStateManager

2025-04-07 Thread Chenyi Qiang
flexibility for addressing specific requirements of confidential VMs in the future. Signed-off-by: Chenyi Qiang --- Changes in v4: - Newly added. --- include/exec/memory.h | 44 +-- system/memory.c | 17 + 2 files changed, 59

[PATCH v4 03/13] memory: Unify the definiton of ReplayRamPopulate() and ReplayRamDiscard()

2025-04-07 Thread Chenyi Qiang
maintainable. Signed-off-by: Chenyi Qiang --- Changes in v4: - Modify the commit message. We won't use Replay() operation when doing the attribute change like v3. Changes in v3: - Newly added. --- hw/virtio/virtio-mem.c | 20 ++-- include/exec/memory.h

[PATCH v4 09/13] memory: Attach RamBlockAttribute to guest_memfd-backed RAMBlocks

2025-04-07 Thread Chenyi Qiang
/uninitialize the RamBlockAttribute object. The object is registered/unregistered in the target RAMBlock's MemoryRegion when creating guest_memfd. Additionally, use the private_shared_manager_state_change() helper to notify the registered PrivateSharedListener of these changes. Signed-off-by: Chenyi

[PATCH v4 13/13] RAMBlock: Make guest_memfd require coordinate discard

2025-04-07 Thread Chenyi Qiang
As guest_memfd is now managed by ram_block_attribute with PrivateSharedManager, only block uncoordinated discard. Signed-off-by: Chenyi Qiang --- Changes in v4: - Modify commit message (RamDiscardManager->PrivateSharedManager). Changes in v3: - No change. Changes in v2: - Cha

[PATCH v4 07/13] ram-block-attribute: Introduce RamBlockAttribute to manage RAMBLock with guest_memfd

2025-04-07 Thread Chenyi Qiang
lable, all operations are performed with 4K granularity. Signed-off-by: Chenyi Qiang --- Changes in v4: - Change the name from memory-attribute-manager to ram-block-attribute. - Implement the newly-introduced PrivateSharedManager instead of RamDiscardManager and change rela

[PATCH v4 06/13] vfio: Add the support for PrivateSharedManager Interface

2025-04-07 Thread Chenyi Qiang
and PrivateSharedListener, allowing for extraction of common parts opportunisticlly. Signed-off-by: Chenyi Qiang --- Changes in v4 - Newly added. --- hw/vfio/common.c | 104 +++--- hw/vfio/container-base.c | 1 + include/hw/vfio/vfio

[PATCH v4 11/13] KVM: Introduce CVMPrivateSharedListener for attribute changes during page conversions

2025-04-07 Thread Chenyi Qiang
for the to_private case, an assert is used to prevent the guest from continuing with a partially changed attribute state. Signed-off-by: Chenyi Qiang --- Changes in v4: - Newly added. --- accel/kvm/kvm-all.c | 73 ++--- include/system/confidential-guest

[PATCH v4 04/13] memory: Introduce generic state change parent class for RamDiscardManager

2025-04-07 Thread Chenyi Qiang
RamDiscardManager (virtio-mem, migration, etc.) to switch to use GenericStateChange helpers. It can provide a more flexible and resuable framework for RAM state management, facilitating future enhancements and use cases. Signed-off-by: Chenyi Qiang --- Changes in v4: - Newly added. --- hw

[PATCH v4 08/13] ram-block-attribute: Introduce a callback to notify shared/private state changes

2025-04-07 Thread Chenyi Qiang
the class. Signed-off-by: Chenyi Qiang --- Changes in v4: - Add the state_change() callback in PrivateSharedManagerClass instead of the RamBlockAttribute. Changes in v3: - Move the bitmap update before notifier callbacks. - Call the notifier callbacks directly in notify_discar

[PATCH v4 10/13] memory: Change NotifyStateClear() definition to return the result

2025-04-07 Thread Chenyi Qiang
So that the caller can check the result of NotifyStateClear() handler if the operation fails. Signed-off-by: Chenyi Qiang --- Changes in v4: - Newly added. --- hw/vfio/common.c | 18 ++ include/exec/memory.h | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions

[PATCH v4 12/13] ram-block-attribute: Add priority listener support for PrivateSharedListener

2025-04-07 Thread Chenyi Qiang
sequence, priority support is added to PrivateSharedListener so that listeners are stored in a determined order based on priority. A tail queue is used to store listeners, allowing traversal in either direction. Signed-off-by: Chenyi Qiang --- Changes in v4: - Newly added. --- accel/kvm/kvm-all.c

[PATCH v4 02/13] memory: Change memory_region_set_ram_discard_manager() to return the result

2025-04-07 Thread Chenyi Qiang
Signed-off-by: Chenyi Qiang --- Changes in v4: - No change. Changes in v3: - Move set_ram_discard_manager() up to avoid a g_free() - Clean up set_ram_discard_manager() definition Changes in v2: - newly added. --- hw/virtio/virtio-mem.c | 29 - include

[PATCH v4 01/13] memory: Export a helper to get intersection of a MemoryRegionSection with a given range

2025-04-07 Thread Chenyi Qiang
Signed-off-by: Chenyi Qiang --- Changes in v4: - No change. Changes in v3: - No change Changes in v2: - Make memory_region_section_intersect_range() an inline function. - Add Reviewed-by from David - Define the @end as Int128 and use the related Int128_* ops as a wilder API

Re: [PATCH v3 6/7] memory: Attach MemoryAttributeManager to guest_memfd-backed RAMBlocks

2025-03-31 Thread Chenyi Qiang
On 3/14/2025 6:23 PM, Chenyi Qiang wrote: > > > On 3/14/2025 5:50 PM, David Hildenbrand wrote: >> On 14.03.25 10:30, Chenyi Qiang wrote: >>> >>> >>> On 3/14/2025 5:00 PM, David Hildenbrand wrote: >>>> On 14.03.25 09:21, Che

Re: [PATCH v3 4/7] memory-attribute-manager: Introduce MemoryAttributeManager to manage RAMBLock with guest_memfd

2025-03-23 Thread Chenyi Qiang
On 3/20/2025 11:15 AM, Chenyi Qiang wrote: > > > On 3/19/2025 7:56 PM, Gupta, Pankaj wrote: >> On 3/19/2025 12:23 PM, Chenyi Qiang wrote: >>> >>> >>> On 3/19/2025 4:55 PM, Gupta, Pankaj wrote: >>>> >>>>&g

Re: [PATCH v3 4/7] memory-attribute-manager: Introduce MemoryAttributeManager to manage RAMBLock with guest_memfd

2025-03-19 Thread Chenyi Qiang
On 3/19/2025 7:56 PM, Gupta, Pankaj wrote: > On 3/19/2025 12:23 PM, Chenyi Qiang wrote: >> >> >> On 3/19/2025 4:55 PM, Gupta, Pankaj wrote: >>> >>>>>>>>> As the commit 852f0048f3 ("RAMBlock: make guest_memfd require >>>&g

Re: [PATCH v3 4/7] memory-attribute-manager: Introduce MemoryAttributeManager to manage RAMBLock with guest_memfd

2025-03-19 Thread Chenyi Qiang
On 3/19/2025 4:55 PM, Gupta, Pankaj wrote: > >>> As the commit 852f0048f3 ("RAMBlock: make guest_memfd require >>> uncoordinated discard") highlighted, some subsystems like VFIO may >>> disable ram block discard. However, guest_memfd relies on the >>> discard >>> operation t

Re: [PATCH v3 4/7] memory-attribute-manager: Introduce MemoryAttributeManager to manage RAMBLock with guest_memfd

2025-03-17 Thread Chenyi Qiang
On 3/18/2025 1:01 AM, Gupta, Pankaj wrote: > On 3/17/2025 11:36 AM, David Hildenbrand wrote: >> On 17.03.25 03:54, Chenyi Qiang wrote: >>> >>> >>> On 3/14/2025 8:11 PM, Gupta, Pankaj wrote: >>>> On 3/10/2025 9:18 AM, Chenyi Qiang wrote:

Re: [PATCH v3 6/7] memory: Attach MemoryAttributeManager to guest_memfd-backed RAMBlocks

2025-03-17 Thread Chenyi Qiang
On 3/17/2025 5:45 PM, Tony Lindgren wrote: > On Mon, Mar 17, 2025 at 03:32:16PM +0800, Chenyi Qiang wrote: >> >> >> On 3/17/2025 2:18 PM, Tony Lindgren wrote: >>> Hi, >>> >>> On Mon, Mar 10, 2025 at 04:18:34PM +0800, Chenyi Qiang wrote: >>

Re: [PATCH v3 6/7] memory: Attach MemoryAttributeManager to guest_memfd-backed RAMBlocks

2025-03-17 Thread Chenyi Qiang
On 3/17/2025 2:18 PM, Tony Lindgren wrote: > Hi, > > On Mon, Mar 10, 2025 at 04:18:34PM +0800, Chenyi Qiang wrote: >> --- a/system/physmem.c >> +++ b/system/physmem.c >> @@ -1885,6 +1886,16 @@ static void ram_block_add(RAMBlock *

Re: [PATCH v3 3/7] memory: Unify the definiton of ReplayRamPopulate() and ReplayRamDiscard()

2025-03-16 Thread Chenyi Qiang
On 3/17/2025 11:00 AM, Kishen Maloor wrote: > On 3/10/25 1:18 AM, Chenyi Qiang wrote: >> ... >> diff --git a/migration/ram.c b/migration/ram.c >> index ce28328141..053730367b 100644 >> --- a/migration/ram.c >> +++ b/migration/ram.c >>

Re: [PATCH v3 4/7] memory-attribute-manager: Introduce MemoryAttributeManager to manage RAMBLock with guest_memfd

2025-03-16 Thread Chenyi Qiang
On 3/14/2025 8:11 PM, Gupta, Pankaj wrote: > On 3/10/2025 9:18 AM, Chenyi Qiang wrote: >> As the commit 852f0048f3 ("RAMBlock: make guest_memfd require >> uncoordinated discard") highlighted, some subsystems like VFIO may >> disable ram block discard. However, gu

Re: [PATCH v3 6/7] memory: Attach MemoryAttributeManager to guest_memfd-backed RAMBlocks

2025-03-15 Thread Chenyi Qiang
10/2025 4:18 PM, Chenyi Qiang wrote: > Introduce a new field, memory_attribute_manager, in RAMBlock to link to > an MemoryAttributeManager object. This change centralizes all > guest_memfd state information (like fd and shared_bitmap) within a > RAMBlock, making it easier to manage.

Re: [PATCH v3 6/7] memory: Attach MemoryAttributeManager to guest_memfd-backed RAMBlocks

2025-03-14 Thread Chenyi Qiang
On 3/14/2025 5:50 PM, David Hildenbrand wrote: > On 14.03.25 10:30, Chenyi Qiang wrote: >> >> >> On 3/14/2025 5:00 PM, David Hildenbrand wrote: >>> On 14.03.25 09:21, Chenyi Qiang wrote: >>>> Hi David & Alexey, >>> >>> Hi, >&g

Re: [PATCH v3 6/7] memory: Attach MemoryAttributeManager to guest_memfd-backed RAMBlocks

2025-03-14 Thread Chenyi Qiang
On 3/14/2025 5:00 PM, David Hildenbrand wrote: > On 14.03.25 09:21, Chenyi Qiang wrote: >> Hi David & Alexey, > > Hi, > >> >> To keep the bitmap aligned, I add the undo operation for >> set_memory_attributes() and use the bitmap + replay callback to

[PATCH v3 1/7] memory: Export a helper to get intersection of a MemoryRegionSection with a given range

2025-03-10 Thread Chenyi Qiang
Signed-off-by: Chenyi Qiang --- Changes in v3: - No change Changes in v2: - Make memory_region_section_intersect_range() an inline function. - Add Reviewed-by from David - Define the @end as Int128 and use the related Int128_* ops as a wilder API (Alexey) --- hw/virtio/virtio

  1   2   3   4   >