From: Dan Williams <dan.j.williams@intel.com>
To: David Hildenbrand <david@redhat.com>,
Dan Williams <dan.j.williams@intel.com>,
Huang Ying <ying.huang@intel.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "Borislav Petkov" <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Cc: <x86@kernel.org>, Andrew Morton <akpm@linux-foundation.org>,
"Oscar Salvador" <osalvador@suse.de>,
<linux-coco@lists.linux.dev>, <linux-mm@kvack.org>,
<linux-kernel@vger.kernel.org>, Kai Huang <kai.huang@intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Andy Lutomirski <luto@kernel.org>
Subject: Re: [PATCH] tdx, memory hotplug: Check whole hot-adding memory range for TDX
Date: Tue, 1 Oct 2024 01:08:03 -0700 [thread overview]
Message-ID: <66fbade318730_964f2294d1@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <c9dcdc44-7031-4541-96a2-70a071accb61@redhat.com>
David Hildenbrand wrote:
> On 01.10.24 08:45, Dan Williams wrote:
> > David Hildenbrand wrote:
> >> On 30.09.24 07:51, Huang Ying wrote:
> >>> On systems with TDX (Trust Domain eXtensions) enabled, memory ranges
> >>> hot-added must be checked for compatibility by TDX. This is currently
> >>> implemented through memory hotplug notifiers for each memory_block.
> >>> If a memory range which isn't TDX compatible is hot-added, for
> >>> example, some CXL memory, the command line as follows,
> >>>
> >>> $ echo 1 > /sys/devices/system/node/nodeX/memoryY/online
> >>>
> >>> will report something like,
> >>>
> >>> bash: echo: write error: Operation not permitted
> >>>
> >>> If pr_debug() is enabled, the error message like below will be shown
> >>> in the kernel log,
> >>>
> >>> online_pages [mem 0xXXXXXXXXXX-0xXXXXXXXXXX] failed
> >>>
> >>> Both are too general to root cause the problem. This will confuse
> >>> users. One solution is to print some error messages in the TDX memory
> >>> hotplug notifier. However, memory hotplug notifiers are called for
> >>> each memory block, so this may lead to a large volume of messages in
> >>> the kernel log if a large number of memory blocks are onlined with a
> >>> script or automatically. For example, the typical size of memory
> >>> block is 128MB on x86_64, when online 64GB CXL memory, 512 messages
> >>> will be logged.
> >>
> >> ratelimiting would likely help here a lot, but I agree that it is
> >> suboptimal.
> >>
> >>>
> >>> Therefore, in this patch, the whole hot-adding memory range is checked
> >>> for TDX compatibility through a newly added architecture specific
> >>> function (arch_check_hotplug_memory_range()). If rejected, the memory
> >>> hot-adding will be aborted with a proper kernel log message. Which
> >>> looks like something as below,
> >>>
> >>> virt/tdx: Reject hot-adding memory range: 0xXXXXXXXX-0xXXXXXXXX for TDX compatibility.
> >> > > The target use case is to support CXL memory on TDX enabled systems.
> >>> If the CXL memory isn't compatible with TDX, the whole CXL memory
> >>> range hot-adding will be rejected. While the CXL memory can still be
> >>> used via devdax interface.
> >>
> >> I'm curious, why can that memory be used through devdax but not through
> >> the buddy? I'm probably missing something important :)
> >
> > TDX requires memory that supports integrity and encryption. Until
> > platforms and expanders with a technology called CXL TSP arrives, CXL
> > memory is not able to join the TCB.
> >
> > The TDX code for simplicity assumes that only memory present at boot
> > might be capable of TDX and that everything else is not.
>
> So is there ever a chance where add_memory() would actually work now
> with TDX? Or can we just simplify and unconditionally reject
> add_memory() if TDX is enabled?
Only if the memory address range is enumerated by the platform firmware
(mcheck) at boot time.
This will eventually be possible with the CXL dynamic-capacity (DCD)
capability once CXL TSP arrives. In that scenario the CXL DCD expander
is brought into the TCB at boot time and assigned a fixed address range
where future memory could arrive. I.e. the CXL device is brought into
the TCB at boot, but the memory it provides can arrive later.
> > Confidential VMs use guest_mem_fd to allocate memory, and that only
> > pulls from the page allocator as a backend.
> >
> > This ability to use devdax in an offline mode is a hack to not
>
> Thanks, I was missing the "hack" of it, and somehow (once again) assumed
> that we would be hotplugging memory into confidential VMs.
When / if dynamic capacity and this security-protocol for CXL arrives
that may yet happen. For now it is safe to block adding anything which
mcheck does not like which is everything but memory present at boot
(is_tdx_memory()).
next prev parent reply other threads:[~2024-10-01 8:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-30 5:51 [PATCH] tdx, memory hotplug: Check whole hot-adding memory range for TDX Huang Ying
2024-09-30 8:58 ` David Hildenbrand
2024-09-30 23:51 ` Huang, Ying
2024-10-01 7:54 ` David Hildenbrand
2024-10-03 20:39 ` Yang Shi
2024-10-03 23:32 ` Dan Williams
2024-10-04 1:10 ` Yang Shi
2024-10-04 3:15 ` Dan Williams
2024-10-04 10:21 ` David Hildenbrand
2024-10-04 15:54 ` Yang Shi
2024-10-04 15:46 ` Yang Shi
2024-10-10 17:52 ` James Morse
2024-10-10 18:28 ` Dan Williams
2024-10-10 19:46 ` Yang Shi
2024-10-01 6:45 ` Dan Williams
2024-10-01 7:56 ` David Hildenbrand
2024-10-01 8:08 ` Dan Williams [this message]
2024-10-04 10:16 ` 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=66fbade318730_964f2294d1@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=david@redhat.com \
--cc=hpa@zytor.com \
--cc=kai.huang@intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=osalvador@suse.de \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=ying.huang@intel.com \
/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).