From: Juergen Gross <jgross@suse.com>
Date: Thu, 15 Jun 2023 12:39:59 +0000 (+0200)
Subject: x86/xen: Set default memory type for PV guests to WB
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=30d65d1b19850c9bc8c17dba8ebe9be5e0c17054;p=linux.git

x86/xen: Set default memory type for PV guests to WB

When running as an unprivileged PV guest under Xen (not dom0), the
default MTRR memory type should be write-back.

Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Link: https://lore.kernel.org/r/20230615123959.12298-1-jgross@suse.com
---

diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 8732b85d56505..93b658248d013 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -187,6 +187,8 @@ static void __init xen_pv_init_platform(void)
 
 	if (xen_initial_domain())
 		xen_set_mtrr_data();
+	else
+		mtrr_overwrite_state(NULL, 0, MTRR_TYPE_WRBACK);
 }
 
 static void __init xen_pv_guest_late_init(void)