From: "Jürgen Groß" <jgross@suse.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
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>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Binbin Wu <binbin.wu@intel.com>,
Tom Lendacky <thomas.lendacky@amd.com>
Subject: Re: [PATCH] x86/kvm: Override default caching mode for SEV-SNP and TDX
Date: Tue, 15 Oct 2024 14:37:18 +0200 [thread overview]
Message-ID: <2263013c-4cfe-4ed8-ab24-f01f15bb41ca@suse.com> (raw)
In-Reply-To: <w2jymc2d37lzcdgppyeokmcifnrxlto2om4alopfivbmfhaxpq@lxlez6fsjo7f>
[-- Attachment #1.1.1: Type: text/plain, Size: 1948 bytes --]
On 15.10.24 14:31, Kirill A. Shutemov wrote:
> On Tue, Oct 15, 2024 at 12:12:51PM +0200, Jürgen Groß wrote:
>> On 15.10.24 11:58, Kirill A. Shutemov wrote:
>>> AMD SEV-SNP and Intel TDX have limited access to MTRR: either it is not
>>> advertised in CPUID or it cannot be programmed (on TDX, due to #VE on
>>> CR0.CD clear).
>>>
>>> This results in guests using uncached mappings where it shouldn't and
>>> pmd/pud_set_huge() failures due to non-uniform memory type reported by
>>> mtrr_type_lookup().
>>>
>>> Override MTRR state, making it WB by default as the kernel does for
>>> Hyper-V guests.
>>>
>>> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
>>> Suggested-by: Binbin Wu <binbin.wu@intel.com>
>>> Cc: Juergen Gross <jgross@suse.com>
>>> Cc: Tom Lendacky <thomas.lendacky@amd.com>
>>> ---
>>> arch/x86/kernel/kvm.c | 4 ++++
>>> 1 file changed, 4 insertions(+)
>>>
>>> diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
>>> index 263f8aed4e2c..21e9e4845354 100644
>>> --- a/arch/x86/kernel/kvm.c
>>> +++ b/arch/x86/kernel/kvm.c
>>> @@ -37,6 +37,7 @@
>>> #include <asm/apic.h>
>>> #include <asm/apicdef.h>
>>> #include <asm/hypervisor.h>
>>> +#include <asm/mtrr.h>
>>> #include <asm/tlb.h>
>>> #include <asm/cpuidle_haltpoll.h>
>>> #include <asm/ptrace.h>
>>> @@ -980,6 +981,9 @@ static void __init kvm_init_platform(void)
>>> }
>>> kvmclock_init();
>>> x86_platform.apic_post_init = kvm_apic_init;
>>> +
>>> + /* Set WB as the default cache mode for SEV-SNP and TDX */
>>> + mtrr_overwrite_state(NULL, 0, MTRR_TYPE_WRBACK);
>>
>> Do you really want to do this for _all_ KVM guests?
>>
>> I'd expect this call to be conditional on TDX or SEV-SNP.
>
> mtrr_overwrite_state() checks it internally.
Ah, right, I forgot I added that check on request by Boris. :-)
Reviewed-by: Juergen Gross <jgross@suse.com>
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
next prev parent reply other threads:[~2024-10-15 12:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-15 9:58 Kirill A. Shutemov
2024-10-15 10:12 ` Jürgen Groß
2024-10-15 12:31 ` Kirill A. Shutemov
2024-10-15 12:37 ` Jürgen Groß [this message]
2024-10-15 13:14 ` Dave Hansen
2024-10-15 13:54 ` Kirill A. Shutemov
2024-10-15 14:00 ` Juergen Gross
2024-10-16 10:50 ` [PATCH] x86/mtrr: Rename mtrr_overwrite_state() to guest_force_mtrr_state() Kirill A. Shutemov
2024-10-19 5:11 ` Michael Kelley
2024-10-29 15:13 ` Kirill A. Shutemov
2024-10-29 17:37 ` Dave Hansen
2024-10-29 19:32 ` Kirill A. Shutemov
2024-10-20 11:07 ` [PATCH] x86/kvm: Override default caching mode for SEV-SNP and TDX Paolo Bonzini
2025-01-24 20:59 ` Sean Christopherson
2025-01-28 9:40 ` 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=2263013c-4cfe-4ed8-ab24-f01f15bb41ca@suse.com \
--to=jgross@suse.com \
--cc=binbin.wu@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=vkuznets@redhat.com \
--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
all inboxes | Powered by JetHome®