|
From: | David Hildenbrand |
Subject: | Re: [PATCH] hostmem-file: add the 'hmem' option |
Date: | Tue, 10 Dec 2024 20:54:43 +0100 |
User-agent: | Mozilla Thunderbird |
On 10.12.24 20:32, Luo, Zhigang wrote:
[AMD Official Use Only - AMD Internal Distribution Only] Hi David,
Hi,
Thanks for your comments. Let me give you some background for this patch. I am currently engaged in a project that requires to pass the EFI_MEMORY_SP(Special Purpose Memory) type memory from host to a virtual machine within QEMU. This memory needs to be EFI_MEMORY_SP type in the virtual machine as well.This particular memory type is essential for the functionality of my project.Which exact guest memory will be backed by this memory? All guest-memory?[Luo, Zhigang] not all guest-memory. Only the memory reserved for specific device.
Can you show me an example QEMU cmdline, and how you would pass that hostmem-file object to the device?
And, what is the guest OS going to do with this memory?[Luo, Zhigang] the device driver in guest will use this reserved memory.
Okay, so just like CXL memory.
Usually, this SP memory (dax, cxl, ...) is not used as boot memory. Like on a bare metal system, one would expect that only CXL memory will be marked as special and put aside to the cxl driver, such that the OS can boot on ordinary DIMMs, such that cxl can online it etc. So maybe you would want to expose this memory using CXL-mem device to the VM? Or a DIMM? I assume the alternative is to tell the VM on the Linux kernel cmdline to set EFI_MEMORY_SP on this memory. I recall that there is a way to achieve that.[Luo, Zhigang] I know this option. but it requires the end user to know where is the memory location in guest side(start address, size).
Right.
In Linux, the SPM memory will be claimed by hmem-dax driver by default. Withthis patch I can use the following config to pass the SPM memory to guest VM.-object memory-backend-file,size=30G,id=m1,mem-path=/dev/dax0.0,prealloc=on,al ign=1G,hmem=on I was thinking to change the option name from "hmem" to "spm" to avoidconfusion. Likely it should be specified elsewhere, that you want specific guest RAM ranges to be EFI_MEMORY_SP. For a DIMM, it could be a property, similarly maybe for CXL- mem devices (no expert on that). For boot memory / machine memory it could be a machine property. But I'll first have to learn which ranges you actually want to expose that way, and what the VM will do with that information.[Luo, Zhigang] we want to expose the SPM memory reserved for specific device. And we will pass the SPM memory and the device to guest. Then the device driver can use the SPM memory in guest side.
Then the device driver should likely have a way to configure that, not the memory backend.
After all, the device driver will map it somehow into guest physical address space (how?).
Do you have any suggestions to achieve this more reasonable?The problem with qemu_ram_foreach_block() is that you would indicate also DIMMs, virtio-mem, ... and even RAMBlocks that are not even used for backing anything to the VM as EFI_MEMORY_SP, which is wrong.[Luo, Zhigang] qemu_ram_foreach_block() will list all memory block, but in pc_update_hmem_memory(), only the memory block with "hmem" flag will be updated to SPM memory.
Yes, but imagine a user passing such a memory backend to a DIMM/virtio-mem/boot memory etc. It will have very undesired side effects.
-- Cheers, David / dhildenb
[Prev in Thread] | Current Thread | [Next in Thread] |