qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Huang, FangSheng (Jerry)" <FangSheng.Huang@amd.com>
To: David Hildenbrand <david@redhat.com>, <qemu-devel@nongnu.org>
Cc: <Zhigang.Luo@amd.com>, <Lianjie.Shi@amd.com>,
	Igor Mammedov <imammedo@redhat.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH] numa: add 'spm' option for special purpose memory
Date: Thu, 25 Sep 2025 19:11:35 +0800	[thread overview]
Message-ID: <ab4ad769-2ef3-40a3-8a2d-9d533f2a3eec@amd.com> (raw)
In-Reply-To: <d5a087bb-5ed9-4463-9674-7c1748852198@amd.com>

Hi David,

I need to update you on the SPM (Soft Reserved Memory) implementation. 
While
working on the OVMF patch, I discovered an issue in the current QEMU SPM 
patch
that causes overlapping E820 entries, leading to memory allocation 
conflicts in OVMF/UEFI firmware.

I'm currently working on fixing this issue and have already implemented a
preliminary solution. I'll keep you updated on the progress and send the
updated patches once the fix is properly tested and validated.

On 9/25/2025 3:39 PM, Huang, FangSheng (Jerry) wrote:
> 
> Hi David,
> 
> Thank you for the quick response and for bringing Igor and Jonathan into 
> the discussion!
> 
> On 9/25/2025 1:03 AM, David Hildenbrand wrote:
>> On 24.09.25 12:33, fanhuang wrote:
>>> Hi David,
>>
>> Hi!
>>
>> CCing Igor and Jonathan.
>>
>>>
>>> I hope this email finds you well. It's been several months since 
>>> Zhigang last discussion about the Special Purpose Memory (SPM) 
>>> implementation in QEMU with you, and I wanted to provide some 
>>> background context before presenting the new patch based on your 
>>> valuable suggestions.
>>>
>>> Previous Discussion Summary
>>> ===========================
>>> Back in December 2024, we had an extensive discussion regarding my 
>>> original patch that added the `hmem` option to `memory-backend-file`. 
>>> During that conversation, you raised several important concerns about 
>>> the design approach:
>>>
>>> Original Approach (December 2024)
>>> ----------------------------------
>>> - Zhigang's patch: Added `hmem=on` option to `memory-backend-file`
>>> - QEMU cmdline example:
>>>    -object memory-backend-file,size=16G,id=m1,mem-path=/dev/ 
>>> dax0.0,prealloc=on,align=1G,hmem=on
>>>    -numa node,nodeid=1,memdev=m1
>>>
>>> Your Concerns and Suggestions
>>> -----------------------------
>>> You correctly identified some issues with the original approach:
>>> - Configuration Safety: Users could create problematic configurations 
>>> like:
>>>     -object memory-backend-file,size=16G,id=unused,mem- 
>>> path=whatever,hmem=on
>>>
>>> - Your Recommendation: You proposed a cleaner approach using NUMA 
>>> node configuration:
>>>     -numa node,nodeid=1,memdev=m1,spm=on
>>
>> Oh my, I don't remember all the details from that discussion :)
>>
>> I assume that any memory devices (DIMM/NVDIMM/virtio-mem) we would
>> cold/hotplug to such a NUMA node would not be indicated as spm, correct?
>>
> Yes, that's absolutely correct. The `spm=on` option only affects the boot
> memory that is assigned to the NUMA node through the `memdev=` parameter.
>>>
>>> Project Context
>>> ===============
>>> To refresh your memory on the use case:
>>> - Objective: Pass `EFI_MEMORY_SP` (Special Purpose Memory) type 
>>> memory from host to QEMU virtual machine
>>> - Application: Memory reserved for specific PCI devices (e.g., VFIO- 
>>> PCI devices)
>>> - Guest Behavior: The SPM memory should be recognized by the guest OS 
>>> and claimed by hmem-dax driver
>>>
>>> Complete QEMU Configuration Example:
>>> -object memory-backend-ram,size=8G,id=m0
>>> -object memory-backend-file,size=16G,id=m1,mem-path=/dev/ 
>>> dax0.0,prealloc=on,align=1G
>>> -numa node,nodeid=0,memdev=m0
>>> -numa node,nodeid=1,memdev=m1,spm=on  # <-- New approach based on 
>>> your suggestion
>>
>> The only alternative I could think of is gluing it to a memory device. 
>> For example,
>> have something like:
>>
>> -numa node,nodeid=0,memdev=m0 \
>> -numa node,nodeid=1 \
>> -device pc-dimm,id=sp0,memdev=m1,sp=true
>>
>> But we would not want (and cannot easily) use DIMMs for that purpose.
>>
>>>
>>> New Patch Implementation
>>> ========================
>>> Following your recommendations, I have completely redesigned the 
>>> implementation:
>>>
>>> Key Changes:
>>> 1. Removed `hmem` option from `memory-backend-file`
>>> 2. Added `spm` (special-purpose) option to NUMA node configuration
>>
>> That definitely sounds better to me: essentially "spm" would say: the 
>> boot memory assigned to this
>> node (through memdev=) will be indicated as EFI_MEMORY_SP.
>>
> Thanks, that's exactly how the implementation works. The `spm=on` option
> ensures that when QEMU builds the EFI memory map, the memory region
> corresponding to the specified `memdev` will be marked with the
> EFI_MEMORY_SP attribute.>>
>>> I would appreciate your review of the new patch implementation. The 
>>> design now follows your suggested approach of using NUMA node 
>>> configuration rather than memory backend options, which should 
>>> resolve the safety and scope issues we discussed.
>>> Thank you for your time and valuable guidance on this implementation.
>>>
>>> Please note that I'm located in UTC+8 timezone, so there might be 
>>> some delay in my responses to your emails due to the time difference. 
>>> I appreciate your patience and understanding.
>>
>> No worries :)
>>
> 



  reply	other threads:[~2025-09-25 11:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-24 10:33 [PATCH] numa: add 'spm' option for special purpose memory fanhuang
2025-09-24 10:33 ` fanhuang
2025-09-24 17:03 ` David Hildenbrand
2025-09-25  7:39   ` Huang, FangSheng (Jerry)
2025-09-25 11:11     ` Huang, FangSheng (Jerry) [this message]
2025-10-02 14:11 ` Igor Mammedov
2025-10-02 14:19   ` David Hildenbrand
2025-10-02 14:59     ` Igor Mammedov
2025-10-02 15:51       ` David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab4ad769-2ef3-40a3-8a2d-9d533f2a3eec@amd.com \
    --to=fangsheng.huang@amd.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=Lianjie.Shi@amd.com \
    --cc=Zhigang.Luo@amd.com \
    --cc=david@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).