: PVH xen: introduce vmx_pvh.c
RFC PATCH 10/16 : PVH xen: introduce vmx_pvh.c
The heart of this patch is vmx exit handler for PVH guest. It is nicely isolated in a separate module. A call to it is added to vmx_pvh_vmexit_handler().
xen/arch/x86/hvm/vmx/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-y += vmcs.o obj-y += vmx.o obj-y += vpmu_core2.o obj-y += vvmx.o +obj-y += vmx_pvh.o
xen/arch/x86/hvm/vmx/vmx.c +11 -1
@@ -1546,7 +1546,9 @@ static struct hvm_function_table __read_ .nhvm_intr_blocked = nvmx_intr_blocked, .nhvm_domain_relinquish_resources = nvmx_domain_relinquish_resources, .update_eoi_exit_bitmap = vmx_update_eoi_exit_bitmap, - .virtual_intr_delivery_enabled = vmx_virtual_intr_delivery_enabled + .virtual_intr_delivery_enabled = vmx_virtual_intr_delivery_enabled, + .pvh_set_vcpu_info = vmx_pvh_set_vcpu_info, + .pvh_read_descriptor = vmx_pvh_read_descriptor };struct hvm_function_table *__init start_vmx (void )
@@ -2280,6 +2282,14 @@ void vmx_vmexit_handler(struct cpu_user_perfc_incra (vmexits, exit_reason); +if (is_pvh_vcpu (v) ) { +if (unlikely (exit_reason &VMX_EXIT_REASONS_FAILED_VMENTRY ) ) +return vmx_failed_vmentry (exit_reason, regs); + +vmx_pvh_vmexit_handler (regs); +return ; + } +/* Handle the interrupt we missed before allowing any more in. */ switch ( (uint16_t )exit_reason ) {
xen/arch/x86/hvm/vmx/vmx_pvh.c new file +849 -0
849 lines not on this page · raw message
xen/include/asm-x86/hvm/vmx/vmx.h +22 -0
@@ -156,11 +156,28 @@ void vmx_update_cpu_exec_control(struct# define VMX_CONTROL_REG_ACCESS_TYPE_LMSW 3/* 10:8 - general purpose register operand */ #define VMX_CONTROL_REG_ACCESS_GPR (eq) (((eq) >> 8) & 0xf) +#define VMX_CONTROL_REG_ACCESS_GPR_EAX 0 +#define VMX_CONTROL_REG_ACCESS_GPR_ECX 1 +#define VMX_CONTROL_REG_ACCESS_GPR_EDX 2 +#define VMX_CONTROL_REG_ACCESS_GPR_EBX 3 +#define VMX_CONTROL_REG_ACCESS_GPR_ESP 4 +#define VMX_CONTROL_REG_ACCESS_GPR_EBP 5 +#define VMX_CONTROL_REG_ACCESS_GPR_ESI 6 +#define VMX_CONTROL_REG_ACCESS_GPR_EDI 7 +#define VMX_CONTROL_REG_ACCESS_GPR_R8 8 +#define VMX_CONTROL_REG_ACCESS_GPR_R9 9 +#define VMX_CONTROL_REG_ACCESS_GPR_R10 10 +#define VMX_CONTROL_REG_ACCESS_GPR_R11 11 +#define VMX_CONTROL_REG_ACCESS_GPR_R12 12 +#define VMX_CONTROL_REG_ACCESS_GPR_R13 13 +#define VMX_CONTROL_REG_ACCESS_GPR_R14 14 +#define VMX_CONTROL_REG_ACCESS_GPR_R15 15/* * Access Rights */ #define X86_SEG_AR_SEG_TYPE 0xf/* 3:0, segment type */ +#define X86_SEG_AR_SEG_TYPE_CODE (1u << 3)/* code (vs data) segment */ #define X86_SEG_AR_DESC_TYPE (1u << 4)/* 4, descriptor type */ #define X86_SEG_AR_DPL 0x60/* 6:5, descriptor privilege level */ #define X86_SEG_AR_SEG_PRESENT (1u << 7)/* 7, segment present */
@@ -420,6 +437,11 @@ void setup_ept_dump(void);void update_guest_eip (void );void vmx_dr_access (unsigned long exit_qualification,struct cpu_user_regs *regs);void vmx_do_extint (struct cpu_user_regs *regs); +void vmx_pvh_vmexit_handler (struct cpu_user_regs *regs); +int vmx_pvh_set_vcpu_info (struct vcpu *v,struct vcpu_guest_context *ctxtp); +int vmx_pvh_read_descriptor (unsigned int sel,const struct vcpu *v, +const struct cpu_user_regs *regs,unsigned long *base, +unsigned long *limit,unsigned int *ar);/* EPT violation qualifications definitions */ #define _EPT_READ_VIOLATION 0
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor
The heart of this patch is vmx exit handler for PVH guest. It is nicely isolated in a separate module. A call to it is added to
vmx_pvh_vmexit_handler().
I'm sorry to say that, but this patch doesn't look worth commenting on in detail: It's completely unsorted (mixing VMX and generic stuff) and appears heavily redundant with other code. I think this needs to be sorted out cleanly first.
Jan
Quoted 10 lines · On Mon, 14 Jan 2013 11:59:30 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
On 12.01.13 at 03:01, Mukesh Rathor <[email protected]> wrote:
The heart of this patch is vmx exit handler for PVH guest. It is nicely isolated in a separate module. A call to it is added to
vmx_pvh_vmexit_handler().I'm sorry to say that, but this patch doesn't look worth commenting on in detail: It's completely unsorted (mixing VMX and generic stuff) and appears heavily redundant with other code. I think this needs to be sorted out cleanly first.
Hi Jan,
Not sure what you are referring to when you generic stuff, but it's all VMX stuff, mainly vmx exit handler. We had discussed it during the hackathon and the xen summit prior, and we wanted to keep functions and code for PVH as much separate as possible to avoid filling existing HVM code with if PVH statements. I can look into moving some stuff to common code if you have issues with any specific ones? Or do you not want a separate exit handler for PVH case at all? I think keeping it separate is much better thing to do....
thanks for looking at the patches.
Mukesh
Quoted 13 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor
Quoted 10 lines · On Mon, 14 Jan 2013 11:59:30 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
On 12.01.13 at 03:01, Mukesh Rathor <[email protected]> wrote:
The heart of this patch is vmx exit handler for PVH guest. It is nicely isolated in a separate module. A call to it is added to
vmx_pvh_vmexit_handler().I'm sorry to say that, but this patch doesn't look worth commenting on in detail: It's completely unsorted (mixing VMX and generic stuff) and appears heavily redundant with other code. I think this needs to be sorted out cleanly first.
Quoted 8 lines
Not sure what you are referring to when you generic stuff, but it's all VMX stuff, mainly vmx exit handler. We had discussed it during the hackathon and the xen summit prior, and we wanted to keep functions and code for PVH as much separate as possible to avoid filling existing HVM code with if PVH statements. I can look into moving some stuff to common code if you have issues with any specific ones? Or do you not want a separate exit handler for PVH case at all? I think keeping it separate is much better thing to do....
The main thing are the hypercall wrappers - they're definitely not VMX-specific, and hence don't belong in VMX-specific code. Besides that, the sub-hypercall filtering you do there looks pretty fragile too. But stuff like get_gpr_ptr() doesn't belong here either (and I actually doubt the function should be added in the first place - iirc we already have a function doing just that, and it wasn't that long ago that I consolidated three(?) incarnations into just one; I guess you understand that I don't want to see another one appearing without good reason).
Jan
Quoted 25 lines · On Tue, 15 Jan 2013 08:46:35 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 15 lines
Quoted 2 lines
Quoted 2 lines
On 15.01.13 at 01:54, Mukesh Rathor <[email protected]> wrote:
Quoted 10 lines · On Mon, 14 Jan 2013 11:59:30 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
On 12.01.13 at 03:01, Mukesh Rathor <[email protected]> wrote:
The heart of this patch is vmx exit handler for PVH guest. It is nicely isolated in a separate module. A call to it is added to
vmx_pvh_vmexit_handler().I'm sorry to say that, but this patch doesn't look worth commenting on in detail: It's completely unsorted (mixing VMX and generic stuff) and appears heavily redundant with other code. I think this needs to be sorted out cleanly first.
Quoted 9 lines
Not sure what you are referring to when you generic stuff, but it's all VMX stuff, mainly vmx exit handler. We had discussed it during the hackathon and the xen summit prior, and we wanted to keep functions and code for PVH as much separate as possible to avoid filling existing HVM code with if PVH statements. I can look into moving some stuff to common code if you have issues with any specific ones? Or do you not want a separate exit handler for PVH case at all? I think keeping it separate is much better thing to do....
Quoted 2 lines
The main thing are the hypercall wrappers - they're definitely not VMX-specific, and hence don't belong in VMX-specific code. Besides
Ah, I see. The HVM hcalls are in hvm.c and not vmx.c. Since PVH needs slightly different hcalls and restricts certain ones ok for HVM, I really prefer to not pollute hvm_do_hypercall() with if PVH everywhere. I could add a new function to hvm.c, pvh_hvm_do_hypercall(), or create a new file hvm_pvh.c and add it there. What would you suggest?
Quoted 3 lines
too. But stuff like
get_gpr_ptr()doesn't belong here either (and I actually doubt the function should be added in the first place - iirc we already have a function doing just that, and it wasn't that long
Yup, decode_register() does that, and it's non-static. I missed it because it was added later, and wasn't in the tree I was using. I'll use that, less code for me.
thanks,
Mukesh
Quoted 10 lines
Quoted 1 line
Quoted 1 line · Mukesh Rathor
Quoted 2 lines · On Tue, 15 Jan 2013 08:46:35 +0000 "Jan Beulich" <[email protected]> wrote:
The main thing are the hypercall wrappers - they're definitely not VMX-specific, and hence don't belong in VMX-specific code. Besides
Ah, I see. The HVM hcalls are in
hvm.cand notvmx.c. Since PVH needs slightly different hcalls and restricts certain ones ok for HVM, I really prefer to not pollutehvm_do_hypercall()with if PVH everywhere. I could add a new function tohvm.c,pvh_hvm_do_hypercall(), or create a new filehvm_pvh.cand add it there. What would you suggest?
The only mail with that patch that I have definitely has these in xen/arch/x86/hvm/vmx/vmx_pvh.c.
So yes, the correct thing - if adjustments to the existing ones makes the code too ugly - would be for them to go into xen/arch/x86/hvm/pvh.c.
Jan
Quoted 3 lines · Mukesh Rathor
The heart of this patch is vmx exit handler for PVH guest. It is nicely isolated in a separate module. A call to it is added to
vmx_pvh_vmexit_handler().
Not looking at this in fine detail yet (considering the various 'fixme's still around in it), but one or two things:
Quoted 7 lines
xen/arch/x86/hvm/vmx/vmx_pvh.c new file +7
-0+static noinline int vmxit_exception(struct cpu_user_regs *regs) +{ +unsigned int vector = (__vmread (VM_EXIT_INTR_INFO )) &INTR_INFO_VECTOR_MASK ; +int rc=1 ; +struct vcpu *vp = current; + + dbgp2(" EXCPT: vec:%d cs:%lx r.IP:%lx\n", vector, vmr(GUEST_CS_SELECTOR),
xen/arch/x86/hvm/vmx/vmx_pvh.c line 168
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx_pvh.c new file +10
-0+ regs->eip); + +if (vector == TRAP_debug) { +unsigned long exit_qualification =__vmread (EXIT_QUALIFICATION ); +write_debugreg (6 , exit_qualification |0xffff0ff0 ); + regs->rip =vmr (GUEST_RIP ); + regs->rsp =vmr (GUEST_RSP ); + rc =0 ; + +/* gdbsx or another debugger */
This is a hard tab. Actually, the whitespace in this file needs attention generally.
Quoted 13 lines
xen/arch/x86/hvm/vmx/vmx_pvh.c new file +13
-0+void vmx_pvh_vmexit_handler (struct cpu_user_regs *regs) +{ +unsigned long exit_qualification; +unsigned int vector, exit_reason =__vmread (VM_EXIT_REASON ); +int rc=0 , ccpu =smp_processor_id (); +struct vcpu *vp = current; + +dbgp1 ("PVH:[%d]left VMCS exitreas:%d RIP:%lx RSP:%lx EFLAGS:%lx CR0:%lx\n" , + ccpu, exit_reason,vmr (GUEST_RIP ),vmr (GUEST_RSP ), regs->rflags, +vmr (GUEST_CR0 )); + +/* for guest_kernel_mode() */ + regs->cs =vmr (GUEST_CS_SELECTOR );
xen/arch/x86/hvm/vmx/vmx_pvh.c line 642
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx_pvh.c new file +10
-0+ +switch ( (uint16_t )exit_reason ) + { +case EXIT_REASON_EXCEPTION_NMI : +case EXIT_REASON_EXTERNAL_INTERRUPT : +case EXIT_REASON_MCE_DURING_VMENTRY : +break ; +default : +local_irq_enable (); + }
That's a bit risky: EXIT_REASON_EXCEPTION_NMI includes a lot of cases that might not be safe to handle with interrupts disabled. Also I think it means there are paths through this function that don't enable irqs at all.
I think it'd be better to do it the way vmx_vmexit_handler() does:
explicitly sort out the things that _must_ be done with irqs disabled first, so it's clear which code runs with irqs enabled and which doesn't.
Quoted 36 lines
xen/arch/x86/hvm/vmx/vmx_pvh.c new file +36
-0+switch ( (uint16_t )exit_reason ) + { +case EXIT_REASON_EXCEPTION_NMI :/* 0 */ + rc =vmxit_exception (regs); +break ; + +case EXIT_REASON_EXTERNAL_INTERRUPT :/* 1 */ + { + vector =__vmread (VM_EXIT_INTR_INFO ); + vector &=INTR_INFO_VECTOR_MASK ; +vmx_do_extint (regs); +break ; + } + +case EXIT_REASON_TRIPLE_FAULT :/* 2 */ + { +dbgp0 ("PVH:Triple Flt:[%d]exitreas:%d RIP:%lx RSP:%lx EFLAGS:%lx CR3:%lx\n" , + ccpu, exit_reason,vmr (GUEST_RIP ),vmr (GUEST_RSP ), + regs->rflags,vmr (GUEST_CR3 )); + + vp->arch.hvm_vcpu.guest_cr[3 ] = vp->arch.hvm_vcpu.hw_cr[3 ] = +__vmread (GUEST_CR3 ); + rc =1 ; +break ; + } +case EXIT_REASON_PENDING_VIRT_INTR :/* 7 */ + { +struct vcpu *v = current; +/* Disable the interrupt window. */ + v->arch.hvm_vmx.exec_control &= ~CPU_BASED_VIRTUAL_INTR_PENDING ; +__vmwrite (CPU_BASED_VM_EXEC_CONTROL , v->arch.hvm_vmx.exec_control); +break ; + } + +case EXIT_REASON_CPUID :/* 10 */ + {
xen/arch/x86/hvm/vmx/vmx_pvh.c line 689
Quoted 10 lines
xen/arch/x86/hvm/vmx/vmx_pvh.c new file +10
-0+if (guest_kernel_mode (vp, regs) ) { +pv_cpuid (regs); + +/* Because we are setting CR4.OSFXSR to 0, we need to disable +* this because, during boot, user process "init" (which doesn't +* do cpuid), will do 'pxor xmm0,xmm0' and cause #UD. For now +* disable this. HVM doesn't allow setting of CR4.OSFXSR. +* fixme: this and also look at CR4.OSXSAVE */ + +__clear_bit (X86_FEATURE_FXSR , ®s->edx);
Shouldn't this be gated on which leaf the guest asked for?
Tim.
Quoted 10 lines · On Thu, 24 Jan 2013 16:31:22 +0000 Tim Deegan <[email protected]> wrote:
At 18:01 -0800 on 11 Jan (1357927270), Mukesh Rathor wrote:
That's a bit risky:EXIT_REASON_EXCEPTION_NMIincludes a lot of cases that might not be safe to handle with interrupts disabled. Also I think it means there are paths through this function that don't enable irqs at all.I think it'd be better to do it the way
vmx_vmexit_handler()does:
explicitly sort out the things that _must_ be done with irqs disabled first, so it's clear which code runs with irqs enabled and which doesn't.
Yup, fixed already.
Quoted 2 lines
This is a hard tab. Actually, the whitespace in this file needs attention generally.
rats, i turn tab on when making linux changes, and then on xen side sometimes forget to turn them off. anyways, fixed.
thanks,
mukesh
Quoted 7 lines · On Thu, 24 Jan 2013 16:31:22 +0000 Tim Deegan <[email protected]> wrote:
Quoted 3 lines · Mukesh Rathor
The heart of this patch is vmx exit handler for PVH guest. It is nicely isolated in a separate module. A call to it is added to
vmx_pvh_vmexit_handler().Not looking at this in fine detail yet (considering the various 'fixme's still around in it), but one or two things:
That's where I need suggestions/help ;).
Quoted 14 lines · On Thu, 24 Jan 2013 09:21:45 +0000 "Jan Beulich" <[email protected]> wrote:
Quoted 7 lines
Quoted 2 lines
Quoted 2 lines
On 24.01.13 at 02:59, Mukesh Rathor <[email protected]> wrote:
Quoted 2 lines · On Tue, 15 Jan 2013 08:46:35 +0000 "Jan Beulich" <[email protected]> wrote:
The main thing are the hypercall wrappers - they're definitely not VMX-specific, and hence don't belong in VMX-specific code. Besides
Quoted 6 lines
Ah, I see. The HVM hcalls are in
hvm.cand notvmx.c. Since PVH needs slightly different hcalls and restricts certain ones ok for HVM, I really prefer to not pollutehvm_do_hypercall()with if PVH everywhere. I could add a new function tohvm.c,pvh_hvm_do_hypercall(), or create a new filehvm_pvh.cand add it there. What would you suggest?
Quoted 2 lines
The only mail with that patch that I have definitely has these in
xen/arch/x86/hvm/vmx/vmx_pvh.c.
I meant for an HVM guest, the hcalls are in hvm.c and not vmx.c. I kinda tried to follow that.
Quoted 3 lines
So yes, the correct thing - if adjustments to the existing ones makes the code too ugly - would be for them to go into
xen/arch/x86/hvm/pvh.c.
Ok, will do it.
Quoted 12 lines · On Thu, 24 Jan 2013 16:31:22 +0000 Tim Deegan <[email protected]> wrote:
Quoted 11 lines · Mukesh Rathor
xen/arch/x86/hvm/vmx/vmx_pvh.c new file +7
-0+ +case EXIT_REASON_CPUID :/* 10 */ + { +if (guest_kernel_mode (vp, regs) ) { +pv_cpuid (regs); + +/* Because we are setting CR4.OSFXSR to 0, we need to disable
+ * this because, during boot, user process
"init" (which doesn't
+ * do cpuid), will do 'pxor xmm0,xmm0' and cause
Quoted 8 lines
xen/arch/x86/hvm/vmx/vmx_pvh.c line 689
Quoted 6 lines
#UD. For now
+ * disable this. HVM doesn't allow setting of
CR4.OSFXSR.xen/arch/x86/hvm/vmx/vmx_pvh.c new file +3
-0+* fixme: this and also look at CR4.OSXSAVE */ + +__clear_bit (X86_FEATURE_FXSR , ®s->edx);Shouldn't this be gated on which leaf the guest asked for?
Yup, looking at it. X86_FEATURE_FXSR is EAX==1, but it doesn't work. The user process "init" running nash is executing pxor %xmm0, %xmm0 and taking #UD. Strangely, it works with EAX==0, meaning if I clear the bit for EAX==0, changing the intel string "ineI". This user process doesn't do cpuid, so it must be affected by it some other way.
Pretty hard to debug since it's in nash user code from ramdisk and I am not able to set breakpoint or put printf's easily to figure why clearing bit for EAX==0 makes it work, or what's going on for PV and HVM guest. CR0.EM is 0, so UD is coming from CR4.OSFXSR==0. Reading the SDMs to learn OSFXSR stuff better....
Will continue investigating.
Thanks,
Mukesh
Quoted 30 lines · Mukesh Rathor
Quoted 12 lines · On Thu, 24 Jan 2013 16:31:22 +0000 Tim Deegan <[email protected]> wrote:
Quoted 11 lines · Mukesh Rathor
xen/arch/x86/hvm/vmx/vmx_pvh.c new file +7
-0+ +case EXIT_REASON_CPUID :/* 10 */ + { +if (guest_kernel_mode (vp, regs) ) { +pv_cpuid (regs); + +/* Because we are setting CR4.OSFXSR to 0, we need to disable
+ * this because, during boot, user process
"init" (which doesn't
+ * do cpuid), will do 'pxor xmm0,xmm0' and causeQuoted 8 lines
xen/arch/x86/hvm/vmx/vmx_pvh.c line 689
Quoted 6 lines
#UD. For now
+ * disable this. HVM doesn't allow setting of
CR4.OSFXSR.xen/arch/x86/hvm/vmx/vmx_pvh.c new file +3
-0+* fixme: this and also look at CR4.OSXSAVE */ + +__clear_bit (X86_FEATURE_FXSR , ®s->edx);Shouldn't this be gated on which leaf the guest asked for?
Yup, looking at it.
X86_FEATURE_FXSRis EAX==1, but it doesn't work. The user process "init" running nash is executing pxor %xmm0, %xmm0 and taking #UD. Strangely, it works with EAX==0, meaning if I clear the bit for EAX==0, changing the intel string "ineI". This user process doesn't do cpuid, so it must be affected by it some other way.
Quoted 5 lines
Pretty hard to debug since it's in nash user code from ramdisk and I am not able to set breakpoint or put printf's easily to figure why clearing bit for EAX==0 makes it work, or what's going on for PV and HVM guest. CR0.EM is 0, so UD is coming from CR4.OSFXSR==0. Reading the SDMs to learn OSFXSR stuff better....
Perhaps you need to clear the FXSR feature bit in leaf 0x80000001:EDX as well?
Tim.
Quoted 32 lines · On Wed, 20 Feb 2013 09:58:28 +0000 Tim Deegan <[email protected]> wrote:
Quoted 31 lines · Mukesh Rathor
Quoted 12 lines · On Thu, 24 Jan 2013 16:31:22 +0000 Tim Deegan <[email protected]> wrote:
Quoted 11 lines · Mukesh Rathor
xen/arch/x86/hvm/vmx/vmx_pvh.c new file +7
-0+ +case EXIT_REASON_CPUID :/* 10 */ + { +if (guest_kernel_mode (vp, regs) ) { +pv_cpuid (regs); + +/* Because we are setting CR4.OSFXSR to 0, we need to disable
+ * this because, during boot, user process
"init" (which doesn't
+ * do cpuid), will do 'pxor xmm0,xmm0' andQuoted 8 lines
xen/arch/x86/hvm/vmx/vmx_pvh.c line 689
Quoted 6 lines
cause #UD. For now
+ * disable this. HVM doesn't allow setting of
CR4.OSFXSR.xen/arch/x86/hvm/vmx/vmx_pvh.c new file +3
-0+* fixme: this and also look at CR4.OSXSAVE */ + +__clear_bit (X86_FEATURE_FXSR , ®s->edx);Shouldn't this be gated on which leaf the guest asked for?
Yup, looking at it.
X86_FEATURE_FXSRis EAX==1, but it doesn't work. The user process "init" running nash is executing pxor %xmm0, %xmm0 and taking #UD. Strangely, it works with EAX==0, meaning if I clear the bit for EAX==0, changing the intel string "ineI". This user process doesn't do cpuid, so it must be affected by it some other way.
Quoted 8 lines
Quoted 5 lines
Pretty hard to debug since it's in nash user code from ramdisk and I am not able to set breakpoint or put printf's easily to figure why clearing bit for EAX==0 makes it work, or what's going on for PV and HVM guest. CR0.EM is 0, so UD is coming from CR4.OSFXSR==0. Reading the SDMs to learn OSFXSR stuff better....
Perhaps you need to clear the FXSR feature bit in leaf 0x80000001:EDX as well?
That appears to be AMD only.
Quoted 41 lines · Mukesh Rathor
Quoted 38 lines · On Wed, 20 Feb 2013 09:58:28 +0000 Tim Deegan <[email protected]> wrote:
Quoted 36 lines · Mukesh Rathor
Quoted 12 lines · On Thu, 24 Jan 2013 16:31:22 +0000 Tim Deegan <[email protected]> wrote:
Quoted 11 lines · Mukesh Rathor
xen/arch/x86/hvm/vmx/vmx_pvh.c new file +7
-0+ +case EXIT_REASON_CPUID :/* 10 */ + { +if (guest_kernel_mode (vp, regs) ) { +pv_cpuid (regs); + +/* Because we are setting CR4.OSFXSR to 0, we need to disable
+ * this because, during boot, user process
"init" (which doesn't
+ * do cpuid), will do 'pxor xmm0,xmm0' andQuoted 8 lines
xen/arch/x86/hvm/vmx/vmx_pvh.c line 689
Quoted 6 lines
cause #UD. For now
+ * disable this. HVM doesn't allow setting of
CR4.OSFXSR.xen/arch/x86/hvm/vmx/vmx_pvh.c new file +3
-0+* fixme: this and also look at CR4.OSXSAVE */ + +__clear_bit (X86_FEATURE_FXSR , ®s->edx);Shouldn't this be gated on which leaf the guest asked for?
Yup, looking at it.
X86_FEATURE_FXSRis EAX==1, but it doesn't work. The user process "init" running nash is executing pxor %xmm0, %xmm0 and taking #UD. Strangely, it works with EAX==0, meaning if I clear the bit for EAX==0, changing the intel string "ineI". This user process doesn't do cpuid, so it must be affected by it some other way.Pretty hard to debug since it's in nash user code from ramdisk and I am not able to set breakpoint or put printf's easily to figure why clearing bit for EAX==0 makes it work, or what's going on for PV and HVM guest. CR0.EM is 0, so UD is coming from CR4.OSFXSR==0. Reading the SDMs to learn OSFXSR stuff better....
Quoted 4 lines
Quoted 2 lines
Perhaps you need to clear the FXSR feature bit in leaf 0x80000001:EDX as well?
That appears to be AMD only.
It still needs to be handled. :) You are testing this stuff on AMD as
well, right?
Tim.
Quoted 43 lines · On Thu, 21 Feb 2013 09:10:01 +0000 Tim Deegan <[email protected]> wrote:
Quoted 42 lines · Mukesh Rathor
Quoted 39 lines · On Wed, 20 Feb 2013 09:58:28 +0000 Tim Deegan <[email protected]> wrote:
Quoted 37 lines · Mukesh Rathor
Quoted 12 lines · On Thu, 24 Jan 2013 16:31:22 +0000 Tim Deegan <[email protected]> wrote:
Quoted 11 lines · Mukesh Rathor
xen/arch/x86/hvm/vmx/vmx_pvh.c new file +7
-0+ +case EXIT_REASON_CPUID :/* 10 */ + { +if (guest_kernel_mode (vp, regs) ) { +pv_cpuid (regs); + +/* Because we are setting CR4.OSFXSR to 0, we need to disable
+ * this because, during boot, user process
"init" (which doesn't
+ * do cpuid), will do 'pxor xmm0,xmm0' andQuoted 8 lines
Quoted 6 lines
cause #UD. For now
+ * disable this. HVM doesn't allow setting
of CR4.OSFXSR.
+ * fixme: this and also look at
CR4.OSXSAVE */ +
+__clear_bit(X86_FEATURE_FXSR, ®s->edx);Shouldn't this be gated on which leaf the guest asked for?
Yup, looking at it.
X86_FEATURE_FXSRis EAX==1, but it doesn't work. The user process "init" running nash is executing pxor %xmm0, %xmm0 and taking #UD. Strangely, it works with EAX==0, meaning if I clear the bit for EAX==0, changing the intel string "ineI". This user process doesn't do cpuid, so it must be affected by it some other way.Pretty hard to debug since it's in nash user code from ramdisk and I am not able to set breakpoint or put printf's easily to figure why clearing bit for EAX==0 makes it work, or what's going on for PV and HVM guest. CR0.EM is 0, so UD is coming from CR4.OSFXSR==0. Reading the SDMs to learn OSFXSR stuff better....
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Perhaps you need to clear the FXSR feature bit in leaf 0x80000001:EDX as well?
That appears to be AMD only.
It still needs to be handled. :) You are testing this stuff on AMD
as well, right?
Right, in pvh_svm.c when its ported. I had talked to someone from AMD at xen summit who said he'd port it to AMD as soon as phase I patch is checked in. It shouldn't be too hard to do that. I estimate a week or two if I was to do SVM changes.
Right now my hurdle working on Version 2 of the patch is all this SSE stuff that I'm trying to figure out. I was hoping to punt it to phase II by turning off whatever bits in CPUID, but nothing works.
Thanks,
Mukesh
Quoted 7 lines · Mukesh Rathor
Quoted 2 lines
It still needs to be handled. :) You are testing this stuff on AMD
as well, right?Right, in
pvh_svm.cwhen its ported. I had talked to someone from AMD at xen summit who said he'd port it to AMD as soon as phase I patch is checked in. It shouldn't be too hard to do that. I estimate a week or two if I was to do SVM changes.
OK, so long as there's a plan. :)
Cheers,
Tim.