WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] RE: expose MWAIT to dom0

To: Keir Fraser <keir.xen@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] RE: expose MWAIT to dom0
From: "Tian, Kevin" <kevin.tian@xxxxxxxxx>
Date: Mon, 15 Aug 2011 15:57:18 +0800
Accept-language: en-US
Acceptlanguage: en-US
Cc: "Zhang, Yang Z" <yang.z.zhang@xxxxxxxxx>, "'Keir Fraser \(keir@xxxxxxx\)'" <keir@xxxxxxx>, "Wei, Gang" <gang.wei@xxxxxxxxx>
Delivery-date: Mon, 15 Aug 2011 00:59:27 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <CA6E8CF9.1F344%keir.xen@xxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <625BA99ED14B2D499DC4E29D8138F15062D2E80D67@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> <CA6E8CF9.1F344%keir.xen@xxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: Acxa+ymibBfDa2PpTRKdAF4mJFeEFAAHRLo3AACWc5AAASamtgAADcSg
Thread-topic: expose MWAIT to dom0
> From: Keir Fraser [mailto:keir.xen@xxxxxxxxx]
> Sent: Monday, August 15, 2011 3:45 PM
> 
> On 15/08/2011 08:13, "Tian, Kevin" <kevin.tian@xxxxxxxxx> wrote:
> 
> >> Well the problem is some older kernels will try to use MWAIT if they see 
> >> the
> >> feature in CPUID. Of course that doesn't work outside ring 0.
> >>
> >
> > if those old kernels are still of interest, then possibly a boot option in 
> > Xen
> > would
> > be applausive. Or can we just allow selectively exposing MWAIT when xen
> > cpuidle is enabled?
> 
> The kernel could unconditionally advertise MWAIT from its cpuid pv_ops hook?
> If all that's doing is causing relevant parts of BIOS tables to be parsed,
> would that be safe when MWAIT is not in fact available?

It's not safe to unconditionally advertise MWAIT, since if underlying CPU 
doesn't
support it you'll get invalid op in Xen when attempting to use it. This is why I
want to see MWAIT expose to guest base on real cpu capability, even when I
say selectively expose it under xen cpuidle. :-)

> 
> Else the kernel could get the flag from the real non paravirtualised CPUID
> instruction.

linux uses cpu_has to extract mwait capability. To use real cpuid instruction, 
then
we need change Linux code which is not worthy though, like below:
       if (!cpu_has(c, X86_FEATURE_MWAIT))
               buf[2] &= ~(ACPI_PDC_C_C2C3_FFH);
If we make it into cpu_has bits, then it lacks of original guarding effect.

So how about the change like below?

emulate_forced_invalid_op:
-        __clear_bit(X86_FEATURE_MWAIT % 32, &c);
+        if ( !IS_PRIV(current->domain) || !xen_cpuidle )
+            __clear_bit(X86_FEATURE_MWAIT % 32, &c);


Thanks
Kevin

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel