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

Xiaoyao Li
2023-11-30T07:38:02Z

On 11/20/2023 5:24 PM, David Hildenbrand wrote:
>>   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) &&

get it.

Thanks!

>> +        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.

How to handle it please see the reply to patch 3.