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

Xiaoyao Li
2023-11-30T08:31:53Z

On 11/18/2023 4:35 AM, Isaku Yamahata wrote:
> On Wed, Nov 15, 2023 at 02:14:11AM -0500,
> Xiaoyao Li <xiaoyao.li@intel.com> wrote:
>
>> 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 &&
>> + 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);
>> + if (new_block->guest_memfd < 0) {
>> + qemu_mutex_unlock_ramlist();
>> + return;
>> + }
>> + }
>> +#endif
>> +
>
> We should define kvm_create_guest_memfd() stub in accel/stub/kvm-stub.c.
> We can remove this #ifdef.

Nice suggestion! Will use stub.