From: Dan Magenheimer Subject: RE: rdtscp on HVM domains Date: Thu, 3 Dec 2009 15:26:31 -0800 (PST) Message-ID: <9b015f00-3b56-4470-bdc7-0faf161c214b@default> References: Mime-Version: 1.0 Content-Type: text/plain; charset=Windows-1252 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Keir Fraser , "Xen-Devel (E-mail)" Cc: Mark Langsdorf , "Zhang, Xiantao" List-Id: xen-devel@lists.xenproject.org So it doesn't look impossible, but probably not easy either. Well, although HVM support for pvrdtscp would be nice to have, I guess we can live without it for the foreseeable future. If KVM wants to implement pvrdtscp support though, they will have to deal with this. > > So questions for VMX/SVM experts: > > 1) Is it possible for VMX (and SVM) to allow rdtscp > > to execute natively on machines that support it > > without exposing the rdtscp bit in cpuid? >=20 > Yes, in fact SVM/VMX does not know how we are emulating CPUID, so that > aspect cannot affect things anyway. The issue on VMX is that=20 > by default > RDTSCP causes #UD. To stop it causing #UD you have to set the "enable > RDTSCP" flag in the VMCS (see SDM Vol3B 21.4, "RDTSCP"),=20 > which we currently > do not do, and may not be available on all systems (what=20 > happens if the flag > is not supported is not defined in the manual, but probably=20 > such CPUs do not > implement RDTSCP and so #UD will occur with no trap to the=20 > hypervisor). The > second issue for VMX is that there is only one VMEXIT control=20 > for both RDTSC > and RDTSCP. Since we must trap-and-emulate RDTSC, we cannot avoid also > trapping RDTSCP - no way we can execute it natively. >=20 > For SVM, there is a separate control for RDTSCP, and none of=20 > this nonsense > about "enable RDTSCP". Currently we trap and always emulate=20 > as #UD. But you > could execute natively, or emulate it some other way. >=20 > > 2) Is it possible for VMX (and SVM) to trap and > > emulate rdtscp on machines that DON'T support > > rdtscp? >=20 > Hm, probably not, since such a CPU would not know the=20 > instruction and hence > would presumably just cause #UD (undefined opcode exception)=20 > directly. And > we don't trap #UD. >=20 > -- Keir >=20 >=20 >