Re: [PATCH v3 02/70] RAMBlock: Add support of KVM private guest memfd

David Hildenbrand
2023-11-20T09:24:22Z

> uint8_t memory_region_get_dirty_log_mask(MemoryRegion *mr)
> {
> uint8_t mask = mr->dirty_log_mask;
> diff --git a/system/physmem.c b/system/physmem.c
> index fc2b0fee0188..0af2213cbd9c 100644
> --- a/system/physmem.c
> +++ b/system/physmem.c
> @@ -1841,6 +1841,20 @@ static void ram_block_add(RAMBlock *new_block, Error **errp)
> }
> }
>
> +#ifdef CONFIG_KVM
> + if (kvm_enabled() && new_block->flags & RAM_GUEST_MEMFD &&

I recall that we prefer to write this as

if (kvm_enabled() && (new_block->flags & RAM_GUEST_MEMFD) &&

> + new_block->guest_memfd < 0) {
> + /* TODO: to decide if KVM_GUEST_MEMFD_ALLOW_HUGEPAGE is supported */
> + uint64_t flags = 0;
> + new_block->guest_memfd = kvm_create_guest_memfd(new_block->max_length,
> + flags, errp);

Get rid of "flags" and just pass 0". Whatever code wants to pass flags
later can decide how to do that.

--
Cheers,

David / dhildenb