From: Tom Lendacky <thomas.lendacky@amd.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
"Maciej W. Rozycki" <macro@orcam.me.uk>,
Ashish Kalra <ashish.kalra@amd.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Kevin Loughlin <kevinloughlin@google.com>,
linux-kernel@vger.kernel.org,
Rick Edgecombe <rick.p.edgecombe@intel.com>,
Isaku Yamahata <isaku.yamahata@intel.com>
Subject: Re: [PATCH] x86/tdx: Fix crash on kexec with CONFIG_EISA
Date: Mon, 26 Aug 2024 10:52:02 -0500 [thread overview]
Message-ID: <c2ef105b-c42c-e0f4-6bf3-761dafc8e92e@amd.com> (raw)
In-Reply-To: <g3tswlyhrnuzfqf2upq6h23manyrzhnxttnay66nycy2moi4es@5n4oblzpzcjc>
On 8/26/24 07:25, Kirill A. Shutemov wrote:
> On Sat, Aug 24, 2024 at 11:29:39PM +0100, Maciej W. Rozycki wrote:
>> On Thu, 22 Aug 2024, Kirill A. Shutemov wrote:
>>
>>> This issue causes real problems:
>>>
>>> 1. If the kernel is compiled with EISA support, it will attempt to probe
>>> EISA by reading 4 bytes from the 0x0FFFD9 address (see eisa_bus_probe()).
>>> The kernel treats this read as MMIO and accesses this memory via
>>> shared mapping as we do for MMIO.
>>>
>>> KVM converts memory to shared upon such access.
>>>
>>> 2. The same memory range (0xF0000-0x100000) is scanned to look for the MP
>>> table (see mpparse_find_mptable()). However, this is not MMIO and it
>>> is accessed via private mapping.
>>>
>>> This will cause a crash if the memory is not private.
>>>
>>> During normal boot, the kernel scans for SMP information before probing
>>> for EISA, and it boots fine. However, the memory becomes shared and causes
>>> issues on kexec when the second kernel attempts to scan for SMP information.
>>
>> ISTM that `eisa_bus_probe' has to be updated to `memremap' analogously to
>> `mpparse_find_mptable', complementing changes such as commit f7750a795687
>> ("x86, mpparse, x86/acpi, x86/PCI, x86/dmi, SFI: Use memremap() for RAM
>> mappings") or commit 5997efb96756 ("x86/boot: Use memremap() to map the
>> MPF and MPC data"). Both just access BIOS memory.
>>
>> Can you please try and verify if my proposed change at:
>> <https://lore.kernel.org/r/alpine.DEB.2.21.2408242025210.30766@angie.orcam.me.uk>
>> has fixed the problem for you?
>
> I like the direction your patch took. I hate sprinkling
> X86_FEATURE_TDX_GUEST checks over the kernel.
>
> Unfortunately, it is not enough to fix the issue. memremap() in this case
> will still boil down to ioremap() that would set shared bit:
>
> memremap()
> arch_memremap_wb()
> ioremap_cache()
> __ioremap_caller(.encrytped = false)
>
> I think arch_memremap_wb() should be mapped ioremap_encrypted() in x86
> case. See the patch below.
>
> It seems to be working fine on TDX, but I am not sure about SEV.
>
> Tom, any comments?
I haven't dug through the code that thoroughly, but I don't think making
arch_memremap_wb() be ioremap_encrypted() will work for SME, where some
data, e.g. setup data, is unencrypted and needs to be mapped shared.
Let me add @Ashish to the thread and have him investigate this since he
has been working on the kexec support under SNP. Can someone provide the
specific kernel options that need to be in place?
Thanks,
Tom
>
> diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
> index 1d60427379c9..ef79cbef1ef8 100644
> --- a/arch/x86/include/asm/io.h
> +++ b/arch/x86/include/asm/io.h
> @@ -180,6 +180,8 @@ extern void __iomem *ioremap_prot(resource_size_t offset, unsigned long size, un
> extern void __iomem *ioremap_encrypted(resource_size_t phys_addr, unsigned long size);
> #define ioremap_encrypted ioremap_encrypted
>
> +#define arch_memremap_wb ioremap_encrypted
> +
> /**
> * ioremap - map bus memory into CPU space
> * @offset: bus address of the memory
next prev parent reply other threads:[~2024-08-26 15:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-22 9:51 [PATCH] x86/tdx: Fix crash on kexec with CONFIG_EISA Kirill A. Shutemov
2024-08-24 22:29 ` Maciej W. Rozycki
2024-08-26 12:25 ` Kirill A. Shutemov
2024-08-26 15:52 ` Tom Lendacky [this message]
2024-08-27 22:15 ` Kalra, Ashish
2024-08-28 6:21 ` Kirill A. Shutemov
2024-08-28 19:43 ` Kalra, Ashish
2024-08-29 12:53 ` Kirill A. Shutemov
2024-08-30 20:47 ` Kalra, Ashish
2024-09-10 12:58 ` Kirill A. Shutemov
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=c2ef105b-c42c-e0f4-6bf3-761dafc8e92e@amd.com \
--to=thomas.lendacky@amd.com \
--cc=ashish.kalra@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=isaku.yamahata@intel.com \
--cc=kevinloughlin@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=macro@orcam.me.uk \
--cc=mingo@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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