From: John Byrne <john.l.byrne@hp.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] Fix softtsc for AMD-V
Date: Thu, 14 Aug 2008 10:25:20 -0700 [thread overview]
Message-ID: <48A46A80.4040804@hp.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 221 bytes --]
The softtsc code for AMD does not update the ip; enabling it on AMD-V
results in the domain spinning on the RDTSC instruction. The patch is
against xen-unstable 18331.
Signed-off-by: John Byrne <john.l.byrne@hp.com>
[-- Attachment #2: softtsc_amd.patch --]
[-- Type: text/plain, Size: 2004 bytes --]
diff -r d09404ad5730 xen/arch/x86/hvm/svm/emulate.c
--- a/xen/arch/x86/hvm/svm/emulate.c Thu Aug 14 16:26:06 2008 +0100
+++ b/xen/arch/x86/hvm/svm/emulate.c Thu Aug 14 12:05:44 2008 -0500
@@ -71,6 +71,7 @@ MAKE_INSTR(VMCALL, 3, 0x0f, 0x01, 0xd9);
MAKE_INSTR(VMCALL, 3, 0x0f, 0x01, 0xd9);
MAKE_INSTR(HLT, 1, 0xf4);
MAKE_INSTR(INT3, 1, 0xcc);
+MAKE_INSTR(RDTSC, 2, 0x0f, 0x31);
static const u8 *opc_bytes[INSTR_MAX_COUNT] =
{
@@ -81,7 +82,8 @@ static const u8 *opc_bytes[INSTR_MAX_COU
[INSTR_WRMSR] = OPCODE_WRMSR,
[INSTR_VMCALL] = OPCODE_VMCALL,
[INSTR_HLT] = OPCODE_HLT,
- [INSTR_INT3] = OPCODE_INT3
+ [INSTR_INT3] = OPCODE_INT3,
+ [INSTR_RDTSC] = OPCODE_RDTSC
};
static int fetch(struct vcpu *v, u8 *buf, unsigned long addr, int len)
diff -r d09404ad5730 xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c Thu Aug 14 16:26:06 2008 +0100
+++ b/xen/arch/x86/hvm/svm/svm.c Thu Aug 14 12:05:44 2008 -0500
@@ -1128,6 +1128,17 @@ static void svm_vmexit_do_hlt(struct vmc
hvm_hlt(regs->eflags);
}
+static void svm_vmexit_do_rdtsc(struct cpu_user_regs *regs)
+{
+ unsigned int inst_len;
+
+ if ( (inst_len = __get_instruction_length(current, INSTR_RDTSC)) == 0 )
+ return;
+ __update_guest_eip(regs, inst_len);
+
+ hvm_rdtsc_intercept(regs);
+}
+
static void wbinvd_ipi(void *info)
{
wbinvd();
@@ -1344,7 +1355,7 @@ asmlinkage void svm_vmexit_handler(struc
break;
case VMEXIT_RDTSC:
- hvm_rdtsc_intercept(regs);
+ svm_vmexit_do_rdtsc(regs);
break;
case VMEXIT_RDTSCP:
diff -r d09404ad5730 xen/include/asm-x86/hvm/svm/emulate.h
--- a/xen/include/asm-x86/hvm/svm/emulate.h Thu Aug 14 16:26:06 2008 +0100
+++ b/xen/include/asm-x86/hvm/svm/emulate.h Thu Aug 14 12:05:45 2008 -0500
@@ -30,6 +30,7 @@ enum instruction_index {
INSTR_VMCALL,
INSTR_HLT,
INSTR_INT3,
+ INSTR_RDTSC,
INSTR_MAX_COUNT /* Must be last - Number of instructions supported */
};
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
reply other threads:[~2008-08-14 17:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=48A46A80.4040804@hp.com \
--to=john.l.byrne@hp.com \
--cc=xen-devel@lists.xensource.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.