From: Juergen Gross <jgross@suse.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org,
linux-hyperv@vger.kernel.org
Cc: mikelley@microsoft.com, Juergen Gross <jgross@suse.com>,
"K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>,
Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: [PATCH v6 04/16] x86/hyperv: set MTRR state when running as SEV-SNP Hyper-V guest
Date: Tue, 2 May 2023 14:09:19 +0200 [thread overview]
Message-ID: <20230502120931.20719-5-jgross@suse.com> (raw)
In-Reply-To: <20230502120931.20719-1-jgross@suse.com>
In order to avoid mappings using the UC- cache attribute, set the
MTRR state to use WB caching as the default.
This is needed in order to cope with the fact that PAT is enabled,
while MTRRs are not supported by the hypervisor.
Fixes: 90b926e68f50 ("x86/pat: Fix pat_x_mtrr_type() for MTRR disabled case")
Signed-off-by: Juergen Gross <jgross@suse.com>
---
V2:
- new patch
V6:
- rebase to tip/master, move code to hv_vtom_init() (Michael Kelley)
---
arch/x86/hyperv/ivm.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/x86/hyperv/ivm.c b/arch/x86/hyperv/ivm.c
index cc92388b7a99..6f7c1b5606ad 100644
--- a/arch/x86/hyperv/ivm.c
+++ b/arch/x86/hyperv/ivm.c
@@ -17,6 +17,7 @@
#include <asm/mem_encrypt.h>
#include <asm/mshyperv.h>
#include <asm/hypervisor.h>
+#include <asm/mtrr.h>
#ifdef CONFIG_AMD_MEM_ENCRYPT
@@ -372,6 +373,9 @@ void __init hv_vtom_init(void)
x86_platform.guest.enc_cache_flush_required = hv_vtom_cache_flush_required;
x86_platform.guest.enc_tlb_flush_required = hv_vtom_tlb_flush_required;
x86_platform.guest.enc_status_change_finish = hv_vtom_set_host_visibility;
+
+ /* Set WB as the default cache mode. */
+ mtrr_overwrite_state(NULL, 0, MTRR_TYPE_WRBACK);
}
#endif /* CONFIG_AMD_MEM_ENCRYPT */
--
2.35.3
next prev parent reply other threads:[~2023-05-02 12:10 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-02 12:09 [PATCH v6 00/16] x86/mtrr: fix handling with PAT but without MTRR Juergen Gross
2023-05-02 12:09 ` Juergen Gross [this message]
2023-05-03 4:22 ` Michael Kelley (LINUX)
2023-05-03 18:14 ` Sohil Mehta
2023-05-03 19:12 ` Borislav Petkov
2023-05-09 20:14 ` Borislav Petkov
2023-05-09 23:36 ` Borislav Petkov
2023-05-10 13:30 ` Borislav Petkov
2023-05-10 13:31 ` Borislav Petkov
2023-05-10 15:53 ` Juergen Gross
2023-05-11 16:32 ` Borislav Petkov
2023-05-22 14:17 ` Juergen Gross
2023-05-30 15:28 ` Borislav Petkov
2023-05-31 7:28 ` Juergen Gross
2023-05-31 8:35 ` Borislav Petkov
2023-05-31 9:31 ` Juergen Gross
2023-05-31 9:58 ` Borislav Petkov
2023-05-31 14:20 ` Juergen Gross
[not found] ` <20230531174857.GDZHeIib57h5lT5Vh1@fat_crate.local>
2023-06-01 6:39 ` Juergen Gross
2023-06-01 12:48 ` Borislav Petkov
2023-06-01 12:53 ` Juergen Gross
2023-06-01 8:19 ` Juergen Gross
2023-06-01 13:22 ` Borislav Petkov
2023-06-01 14:33 ` Borislav Petkov
2023-06-01 14:34 ` Juergen Gross
2023-06-01 13:10 ` Juergen Gross
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=20230502120931.20719-5-jgross@suse.com \
--to=jgross@suse.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikelley@microsoft.com \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=wei.liu@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).