From: Oscar Salvador <osalvador@suse.de>
To: Huang Ying <ying.huang@intel.com>
Cc: 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>,
x86@kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org,
linux-kernel@vger.kernel.org,
Dan Williams <dan.j.williams@intel.com>,
Kai Huang <kai.huang@intel.com>,
David Hildenbrand <david@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Andy Lutomirski <luto@kernel.org>
Subject: Re: [PATCH -V3] x86/tdx, memory hotplug: Check whole hot-adding memory range for TDX
Date: Tue, 22 Oct 2024 09:49:06 +0200 [thread overview]
Message-ID: <ZxdY8ty-nAj3dlQQ@localhost.localdomain> (raw)
In-Reply-To: <20241022031617.159969-1-ying.huang@intel.com>
On Tue, Oct 22, 2024 at 11:16:17AM +0800, Huang Ying wrote:
> On systems with TDX (Trust Domain eXtensions) enabled, current kernel
> checks the TDX compatibility of the hot-added memory ranges through a
> memory hotplug notifier 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, current kernel will show the error message
> like below in the kernel log,
>
> online_pages [mem 0xXXXXXXXXXX-0xXXXXXXXXXX] failed
>
> Both are too general to root cause the problem. This may confuse
> users. One solution is to print some error messages in the TDX memory
> hotplug notifier. However, kernel calls memory hotplug notifiers 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.
>
> Therefore, this patch checks the TDX compatibility of the whole
> hot-adding memory range through a newly added architecture specific
> function (arch_check_hotplug_memory_range()). If this patch rejects
> the memory hot-adding for TDX compatibility, it will output a kernel
> log message like 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 kernel will reject
> the whole CXL memory range. While the CXL memory can still be used
> via devdax interface.
>
> This also makes the original TDX memory hotplug notifier useless, so
> this patch deletes it.
>
> Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
Acked-by: Oscar Salvador <osalvador@suse.de>
One question below:
...
> +int tdx_check_hotplug_memory_range(u64 start, u64 size)
> {
> - struct memory_notify *mn = v;
> -
> - if (action != MEM_GOING_ONLINE)
> - return NOTIFY_OK;
> + u64 start_pfn = PHYS_PFN(start);
> + u64 end_pfn = PHYS_PFN(start + size);
>
> /*
> * Empty list means TDX isn't enabled. Allow any memory
> - * to go online.
> + * to be hot-added.
> */
> if (list_empty(&tdx_memlist))
> - return NOTIFY_OK;
> + return 0;
>
> /*
> * The TDX memory configuration is static and can not be
> - * changed. Reject onlining any memory which is outside of
> + * changed. Reject hot-adding any memory which is outside of
> * the static configuration whether it supports TDX or not.
> */
> - if (is_tdx_memory(mn->start_pfn, mn->start_pfn + mn->nr_pages))
> - return NOTIFY_OK;
> + if (is_tdx_memory(start_pfn, end_pfn))
> + return 0;
>
> - return NOTIFY_BAD;
> + pr_info("Reject hot-adding memory range: %#llx-%#llx for TDX compatibility.\n",
> + start, start + size);
Why not using pr_err() here?
I was checking which kind of information level we use when failing at
hot-adding memory, and we seem to be using pr_err(), and pr_debug() when
onlining/offlining.
Not a big deal, and not saying it is wrong, but was just wondering the reasoning
behind.
--
Oscar Salvador
SUSE Labs
next prev parent reply other threads:[~2024-10-22 7:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-22 3:16 Huang Ying
2024-10-22 7:49 ` Oscar Salvador [this message]
2024-10-22 8:31 ` Huang, Ying
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=ZxdY8ty-nAj3dlQQ@localhost.localdomain \
--to=osalvador@suse.de \
--cc=bp@alien8.de \
--cc=dan.j.williams@intel.com \
--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=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