Skip to contentSkip to conversation

XEN monitor/mwait patch for AMD SVM

PATCH Boppuri, Navin 2 participants 7 messages May 22, 2009 – May 25, 2009

lore
Share & tools
lore
#0 lore raw

This patch clears the monitor/mwait bit in the cpuid intercept code for AMD's SVM. This is to disallow VM's that may try and use the monitor/mwait feature on AMD processors which is currently not supported in XEN.

Regards,

Navin Boppuri

AMD

Operating Systems Research Center

CSG Platform Software Organization

Lonestar Campus, Austin, TX.

T 512.602.5803

xen/arch/x86/cpu/amd.c +1 -3
diff -r 6f7000810e59 xen/arch/x86/cpu/amd.c
@@ -224,8 +224,6 @@
 	}
 }
 
-int force_mwait __cpuinitdata;
-
 static void disable_c1e(void *unused)
 {
 	u32 lo, hi;
@@ -486,7 +484,7 @@
 #endif
 
 	/* Pointless to use MWAIT on Family10 as it does not deep sleep. */
-	if (c->x86 == 0x10 && !force_mwait)
+	if (c->x86 == 0x10)
 		clear_bit(X86_FEATURE_MWAIT, c->x86_capability);
 
 	/* K6s reports MCEs but don't actually have all the MSRs */
xen/arch/x86/hvm/svm/svm.c +9 -0
diff -r 6f7000810e59 xen/arch/x86/hvm/svm/svm.c
@@ -919,6 +919,15 @@
             __clear_bit(X86_FEATURE_APIC & 31, edx);
     }
 
+    if ( input == 0x00000001 )
+    {
+	/* Clear mwait/monitor support since we don't want
+ 	 * guest OS'es to use this instruction pair
+ 	 * on AMD CPUs
+ 	 */
+	__clear_bit(X86_FEATURE_MWAIT %32, ecx);
+    }
+
     HVMTRACE_5D (CPUID, v, input, *eax, *ebx, *ecx, *edx);
 }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 5 lines · Navin

This patch clears the monitor/mwait bit in the cpuid intercept code for AMD¹s SVM. This is to disallow VM¹s that may try and use the monitor/mwait feature on AMD processors which is currently not supported in XEN.

What Xen version is this patch against? We already hide MWAIT from HVM guests as far as I am aware. See tools/libxc/xc_cpuid_x86.c:xc_cpuid_hvm_policy(), and note that features are *whitelisted* and also that MWAIT is *not* mentioned.

So I think your patch is not needed, and also inappropriate since we implement CPUID filtering policy in libxc these days.

-- Keir

#2 lore raw

Keir,

Sorry but the patch is against the latest tip of the xen unstable tree (changeset: 18646).

I understand that MWAIT is not mentioned in the whitelist for HVM policy. However, one could modify the guest config file and set the cpuid bit for monitor/mwait and enable this feature by force. I was able to do just this in my test configuration. This patch should cover such mods for cpuid in addition to the cpuid policy in libxc.

Thank you.
-Navin

Quoted 28 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Friday, May 22, 2009 11:40 AM
To: Boppuri, Navin; [email protected]
Subject: Re: XEN monitor/mwait patch for AMD SVM

Quoted 1 line · Navin

This patch clears the monitor/mwait bit in the cpuid intercept code for

AMD¹s

Quoted 1 line

SVM. This is to disallow VM¹s that may try and use the monitor/mwait

feature

Quoted 3 lines

on AMD processors which is currently not supported in XEN.

What Xen version is this patch against? We already hide MWAIT from HVM guests as far as I am aware. See tools/libxc/xc_cpuid_x86.c:xc_cpuid_hvm_policy(), and note that features are
*whitelisted* and also that MWAIT is *not* mentioned.

So I think your patch is not needed, and also inappropriate since we implement CPUID filtering policy in libxc these days.

-- Keir

#3 lore raw

That's firmly in the 'Doctor, it hurts when I...' category I'm afraid. No way will I apply this type of patch.

-- Keir

Quoted 44 lines · Navin

Keir,

Sorry but the patch is against the latest tip of the xen unstable tree (changeset: 18646).

I understand that MWAIT is not mentioned in the whitelist for HVM policy. However, one could modify the guest config file and set the cpuid bit for monitor/mwait and enable this feature by force. I was able to do just this in my test configuration. This patch should cover such mods for cpuid in addition to the cpuid policy in libxc.

Thank you.
-Navin

Quoted 28 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Friday, May 22, 2009 11:40 AM
To: Boppuri, Navin; [email protected]
Subject: Re: XEN monitor/mwait patch for AMD SVM

Quoted 1 line · Navin

This patch clears the monitor/mwait bit in the cpuid intercept code for

AMD¹s

Quoted 1 line

SVM. This is to disallow VM¹s that may try and use the monitor/mwait

feature

Quoted 3 lines

on AMD processors which is currently not supported in XEN.

What Xen version is this patch against? We already hide MWAIT from HVM guests as far as I am aware. See tools/libxc/xc_cpuid_x86.c:xc_cpuid_hvm_policy(), and note that features are
*whitelisted* and also that MWAIT is *not* mentioned.

So I think your patch is not needed, and also inappropriate since we implement CPUID filtering policy in libxc these days.

-- Keir

#4 lore raw

:) Point taken! Thank you for considering the request though.

-Navin

Quoted 65 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Friday, May 22, 2009 12:19 PM
To: Boppuri, Navin; [email protected]
Subject: Re: XEN monitor/mwait patch for AMD SVM

That's firmly in the 'Doctor, it hurts when I...' category I'm afraid. No way will I apply this type of patch.

-- Keir

Quoted 6 lines · Navin

Keir,

Sorry but the patch is against the latest tip of the xen unstable tree (changeset: 18646).

I understand that MWAIT is not mentioned in the whitelist for HVM

policy.

Quoted 1 line

However, one could modify the guest config file and set the cpuid bit

for

Quoted 1 line

monitor/mwait and enable this feature by force. I was able to do just

this in

Quoted 1 line

my test configuration. This patch should cover such mods for cpuid in

addition

Quoted 14 lines

to the cpuid policy in libxc.

Thank you.
-Navin

Quoted 9 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Friday, May 22, 2009 11:40 AM
To: Boppuri, Navin; [email protected]
Subject: Re: XEN monitor/mwait patch for AMD SVM

Quoted 1 line · Navin

This patch clears the monitor/mwait bit in the cpuid intercept code

for

Quoted 10 lines
Quoted 10 lines

AMD¹s

Quoted 1 line

SVM. This is to disallow VM¹s that may try and use the monitor/mwait

feature

Quoted 3 lines

on AMD processors which is currently not supported in XEN.

What Xen version is this patch against? We already hide MWAIT from HVM guests as far as I am aware. See tools/libxc/xc_cpuid_x86.c:xc_cpuid_hvm_policy(), and note that

features

Quoted 11 lines
Quoted 9 lines

are
*whitelisted* and also that MWAIT is *not* mentioned.

So I think your patch is not needed, and also inappropriate since we implement CPUID filtering policy in libxc these days.

-- Keir

#5 lore raw

No problem. In general, we aren't too afraid of having 'power user' options in the domain config file that can cause real problems if misapplied. Especially this CPUID config, which most end users have not a prayer of understanding and probably should not touch at all unless told to. The expectation is that most vendors will wrap up that layer with a GUI wizard of some sort to hide most of the complexity and power.

-- Keir

Quoted 71 lines · Navin

:) Point taken! Thank you for considering the request though.

-Navin

Quoted 65 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Friday, May 22, 2009 12:19 PM
To: Boppuri, Navin; [email protected]
Subject: Re: XEN monitor/mwait patch for AMD SVM

That's firmly in the 'Doctor, it hurts when I...' category I'm afraid. No way will I apply this type of patch.

-- Keir

Quoted 6 lines · Navin

Keir,

Sorry but the patch is against the latest tip of the xen unstable tree (changeset: 18646).

I understand that MWAIT is not mentioned in the whitelist for HVM

policy.

Quoted 1 line

However, one could modify the guest config file and set the cpuid bit

for

Quoted 1 line

monitor/mwait and enable this feature by force. I was able to do just

this in

Quoted 1 line

my test configuration. This patch should cover such mods for cpuid in

addition

Quoted 14 lines

to the cpuid policy in libxc.

Thank you.
-Navin

Quoted 9 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Friday, May 22, 2009 11:40 AM
To: Boppuri, Navin; [email protected]
Subject: Re: XEN monitor/mwait patch for AMD SVM

Quoted 1 line · Navin

This patch clears the monitor/mwait bit in the cpuid intercept code

for

Quoted 10 lines
Quoted 10 lines

AMD¹s

Quoted 1 line

SVM. This is to disallow VM¹s that may try and use the monitor/mwait

feature

Quoted 3 lines

on AMD processors which is currently not supported in XEN.

What Xen version is this patch against? We already hide MWAIT from HVM guests as far as I am aware. See tools/libxc/xc_cpuid_x86.c:xc_cpuid_hvm_policy(), and note that

features

Quoted 11 lines
Quoted 9 lines

are
*whitelisted* and also that MWAIT is *not* mentioned.

So I think your patch is not needed, and also inappropriate since we implement CPUID filtering policy in libxc these days.

-- Keir

#6 lore raw

Keir,

Sounds good. As long as we are consistent about the fact that all configuration policies are managed using libxc, I'm more than satisfied with this approach to prevent use of mwait/monitor instructions in a guest.

Thanks again.
-Navin

Quoted 93 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Saturday, May 23, 2009 9:39 AM
To: Boppuri, Navin; [email protected]
Subject: Re: XEN monitor/mwait patch for AMD SVM

No problem. In general, we aren't too afraid of having 'power user' options
in the domain config file that can cause real problems if misapplied. Especially this CPUID config, which most end users have not a prayer of understanding and probably should not touch at all unless told to. The expectation is that most vendors will wrap up that layer with a GUI wizard of some sort to hide most of the complexity and power.

-- Keir

Quoted 11 lines · Navin

:) Point taken! Thank you for considering the request though.

-Navin

Quoted 7 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Friday, May 22, 2009 12:19 PM
To: Boppuri, Navin; [email protected]
Subject: Re: XEN monitor/mwait patch for AMD SVM

That's firmly in the 'Doctor, it hurts when I...' category I'm afraid.

No

Quoted 34 lines
Quoted 34 lines

way will I apply this type of patch.

-- Keir

Quoted 6 lines · Navin

Keir,

Sorry but the patch is against the latest tip of the xen unstable tree (changeset: 18646).

I understand that MWAIT is not mentioned in the whitelist for HVM

policy.

Quoted 1 line

However, one could modify the guest config file and set the cpuid bit

for

Quoted 1 line

monitor/mwait and enable this feature by force. I was able to do just

this in

Quoted 1 line

my test configuration. This patch should cover such mods for cpuid in

addition

Quoted 14 lines

to the cpuid policy in libxc.

Thank you.
-Navin

Quoted 9 lines

-----Original Message-----
From: Keir Fraser [mailto:[email protected]]
Sent: Friday, May 22, 2009 11:40 AM
To: Boppuri, Navin; [email protected]
Subject: Re: XEN monitor/mwait patch for AMD SVM

Quoted 1 line · Navin

This patch clears the monitor/mwait bit in the cpuid intercept code

for

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

AMD¹s

Quoted 1 line

SVM. This is to disallow VM¹s that may try and use the monitor/mwait

feature

Quoted 3 lines

on AMD processors which is currently not supported in XEN.

What Xen version is this patch against? We already hide MWAIT from

HVM

Quoted 18 lines
Quoted 16 lines
Quoted 2 lines
Quoted 2 lines

guests as far as I am aware. See tools/libxc/xc_cpuid_x86.c:xc_cpuid_hvm_policy(), and note that

features

Quoted 11 lines
Quoted 9 lines

are
*whitelisted* and also that MWAIT is *not* mentioned.

So I think your patch is not needed, and also inappropriate since we implement CPUID filtering policy in libxc these days.

-- Keir