PV extension of HVM(hybrid) support in Xen
PATCH v7 1/1 PV extension of HVM(hybrid) support in Xen
Hi Keir
Here is the v7 of hybrid patch in Xen.
Change from v6:
1. Minor comments fix.
2. Make PV clocksource to be a feature can be controlled by CPUID.
Change from v5:
Address the comments from Tim.
Change from v4:
1. Add support for PV clocksource on HVM. (Replace evtchn enabling with pv clock enabling).
2. Update the patch following Tim's comments.
Change from v3:
1. Minor polish the patchset. Replace several specific is_hvm_pv_evtchn_domain() judgement.
2. Name changed...
Change from v2:
1. Change the name "hybrid" to "PV featured HVM", as well as flag and macro names.
Signature · 2 lines
regards Yang, Sheng
xen/arch/x86/domain.c +9 -0
@@ -686,7 +686,16 @@if (is_hvm_vcpu (v) ) { +unsigned long eip, cs; +hvm_set_info_guest (v); + + eip =c (user_regs.eip); +if (eip !=0 ) { + cs = eip >>12 <<8 ; +hvm_vcpu_reset_state (v, cs,0 ); + hvm_funcs.set_tsc_offset (v,0 ); + } goto out; }
xen/arch/x86/hvm/hvm.c +41 -0
59 lines not on this page · raw message
xen/arch/x86/hvm/irq.c +50 -14
136 lines not on this page · raw message
xen/arch/x86/hvm/vlapic.c +4 -0
@@ -289,6 +289,10 @@return X86EMUL_RETRY ;hvm_vcpu_reset_state (v, trampoline_vector <<8 ,0 ); + +/* Adjust TSC for PV clock */ +if (is_hvm_pv_clock_enabled_domain (v->domain)) + hvm_funcs.set_tsc_offset (v,0 );vcpu_unpause (v);
xen/arch/x86/hvm/vmx/intr.c +2 -1
@@ -164,7 +164,8 @@ {HVMTRACE_2D (INJ_VIRQ , intack.vector,/*fake=*/ 0 );vmx_inject_extint (intack.vector); -pt_intr_post (v, intack); +if (intack.source != hvm_intsrc_vector) +pt_intr_post (v, intack); }/* Is there another IRQ to queue up behind this one? */
xen/arch/x86/traps.c +9 -0
@@ -686,6 +686,7 @@struct domain *d = current->domain;/* Optionally shift out of the way of Viridian architectural leaves. */ uint32_t base =is_viridian_domain (d) ?0x40000100 :0x40000000 ; +unsigned int tmp_eax, tmp_ebx, tmp_ecx, tmp_edx; idx -= base;if ( idx >3 )
@@ -716,6 +717,14 @@ *edx =0 ;/* Features 2 */ if ( !is_hvm_vcpu (current) ) *ecx |=XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD ; + +/* Check if additional feature specified, e.g. Hybrid */ +if ( !is_viridian_domain (d) ) { +domain_cpuid (d,0x40000002 ,0 , + &tmp_eax, &tmp_ebx, &tmp_ecx, &tmp_edx); +if (tmp_edx !=0 ) + *edx = tmp_edx &XEN_CPUID_FEAT2_MASK ; + }break ;case 3 :
xen/include/asm-x86/hvm/hvm.h +3 -1
@@ -33,7 +33,8 @@ hvm_intsrc_pic, hvm_intsrc_lapic, hvm_intsrc_nmi, - hvm_intsrc_mce + hvm_intsrc_mce, + hvm_intsrc_vector, };struct hvm_intack {uint8_t source;/* enum hvm_intsrc */
@@ -44,6 +45,7 @@#define hvm_intack_lapic (vec) ( (struct hvm_intack) { hvm_intsrc_lapic, vec } )#define hvm_intack_nmi ( (struct hvm_intack) { hvm_intsrc_nmi, 2 } )#define hvm_intack_mce ( (struct hvm_intack) { hvm_intsrc_mce, 18 } ) +#define hvm_intack_vector (vec)( (struct hvm_intack) { hvm_intsrc_vector, vec } )enum hvm_intblk { hvm_intblk_none,/* not blocked (deliverable) */ hvm_intblk_shadow,/* MOV-SS or STI shadow */
xen/include/asm-x86/hvm/irq.h +3 -1
@@ -54,12 +54,14 @@enum { HVMIRQ_callback_none, HVMIRQ_callback_gsi, - HVMIRQ_callback_pci_intx + HVMIRQ_callback_pci_intx, + HVMIRQ_callback_vector, } callback_via_type; };union {uint32_t gsi;struct {uint8_t dev, intx; } pci; +uint32_t vector; } callback_via;/* Number of INTx wires asserting each PCI-ISA link. */
xen/include/public/arch-x86/cpuid.h +9 -0
@@ -65,4 +65,13 @@#define _XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD 0#define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0) +/* Mask unsupported CPUID specified by user */ +#define XEN_CPUID_FEAT2_MASK 0x7ul +#define _XEN_CPUID_FEAT2_HVM_PV 0 +#define XEN_CPUID_FEAT2_HVM_PV (1u<<0) +#define _XEN_CPUID_FEAT2_HVM_PV_CLOCK 1 +#define XEN_CPUID_FEAT2_HVM_PV_CLOCK (1u<<1) +#define _XEN_CPUID_FEAT2_HVM_PV_EVTCHN 2 +#define XEN_CPUID_FEAT2_HVM_PV_EVTCHN (1u<<2) +#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
xen/include/public/hvm/hvm_op.h +9 -0
@@ -127,6 +127,15 @@typedef struct xen_hvm_set_mem_type xen_hvm_set_mem_type_t ;DEFINE_XEN_GUEST_HANDLE (xen_hvm_set_mem_type_t); +/* Enable PV extended HVM mode. Should called by BSP */ +#define HVMOP_enable_pv 9 +struct xen_hvm_pv_type { +/* Should be DOMID_SELF so far */ +domid_t domid; +/* The features want to enable */ +uint32_t flags; +#define HVM_PV_CLOCK (1ull<<0) +};#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
xen/include/public/xen.h +6 -1
@@ -158,7 +158,12 @@#define VIRQ_ARCH_6 22#define VIRQ_ARCH_7 23 -#define NR_VIRQS 24 +#define VIRQ_EMUL_PIN_START 24 +#define VIRQ_EMUL_PIN_END 39 +#define VIRQ_EMUL_PIN_NUM 16 +#define VIRQ_EMUL_PIN (x) (VIRQ_EMUL_PIN_START + x) + +#define NR_VIRQS 40/* * HYPERVISOR_mmu_update(reqs, count, pdone, foreigndom)
xen/include/xen/sched.h +6 -0
@@ -311,6 +311,9 @@/* Memory paging support */ struct mem_event_domain mem_event; + +#define XEN_HVM_PV_CLOCK_ENABLED (1u << 0) +uint64_t hvm_pv_enabled; };struct domain_setup_info
@@ -597,6 +600,9 @@#define is_hvm_vcpu (v) (is_hvm_domain(v->domain))#define need_iommu (d) ((d)->need_iommu) +#define is_hvm_pv_clock_enabled_domain (d) \ + ((d)->hvm_pv_enabled & XEN_HVM_PV_CLOCK_ENABLED) +void set_vcpu_migration_delay (unsigned int delay);unsigned int get_vcpu_migration_delay (void );
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Once again: please sort this out between yourself and Stefano so we only have one patchset doing this feature.
At 07:21 +0000 on 08 Mar (1268032899), Sheng Yang wrote:
Content-Description: hybrid-xen.patch
Quoted 6 lines
xen/arch/x86/domain.c +0
-0@@ -686,7 +686,16 @@if (is_hvm_vcpu (v) )
xen/arch/x86/domain.c line 697
Quoted 10 lines
xen/arch/x86/domain.c +8
-0{ +unsigned long eip, cs; +hvm_set_info_guest (v); + + eip =c (user_regs.eip); +if (eip !=0 ) { + cs = eip >>12 <<8 ; +hvm_vcpu_reset_state (v, cs,0 ); + hvm_funcs.set_tsc_offset (v,0 );
Shouldn't this be gated on (d->hvm_pv_enabled & XEN_HVM_PV_CLOCK_ENABLED) rather than (eip != 0)?
Quoted 13 lines
xen/arch/x86/traps.c +1
-0@@ -686,6 +686,7 @@struct domain *d = current->domain;/* Optionally shift out of the way of Viridian architectural leaves. */ uint32_t base =is_viridian_domain (d) ?0x40000100 :0x40000000 ; +unsigned int tmp_eax, tmp_ebx, tmp_ecx, tmp_edx; idx -= base;if ( idx >3 )@@ -716,6 +717,14 @@ *edx =0 ;/* Features 2 */
xen/arch/x86/traps.c line 727
Quoted 10 lines
xen/arch/x86/traps.c +8
-0if ( !is_hvm_vcpu (current) ) *ecx |=XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD ; + +/* Check if additional feature specified, e.g. Hybrid */ +if ( !is_viridian_domain (d) ) { +domain_cpuid (d,0x40000002 ,0 , + &tmp_eax, &tmp_ebx, &tmp_ecx, &tmp_edx); +if (tmp_edx !=0 ) + *edx = tmp_edx &XEN_CPUID_FEAT2_MASK ; + }
Maybe use cpuid_edx() here?
xen/include/public/hvm/hvm_op.h line 130
Quoted 8 lines
xen/include/public/hvm/hvm_op.h +1
-0@@ -127,6 +127,15 @@typedef struct xen_hvm_set_mem_type xen_hvm_set_mem_type_t ;DEFINE_XEN_GUEST_HANDLE (xen_hvm_set_mem_type_t); +/* Enable PV extended HVM mode. Should called by BSP */
This comment doesn't really explain what the hypercall does.
xen/include/public/hvm/hvm_op.h line 134
Quoted 4 lines
xen/include/public/hvm/hvm_op.h +4
-0+#define HVMOP_enable_pv 9 +struct xen_hvm_pv_type { +/* Should be DOMID_SELF so far */ +domid_t domid;
Please just kill this field rather than requiring the caller to set it to DOMID_SELF and then checking that he did it.
Quoted 7 lines
xen/include/public/hvm/hvm_op.h +4
-0+/* The features want to enable */ +uint32_t flags; +#define HVM_PV_CLOCK (1ull<<0) +};#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
Signature · 3 lines
Tim Deegan <[email protected]> Principal Software Engineer, XenServer Engineering Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)
Quoted 2 lines · On Wednesday 10 March 2010 22:44:46 Tim Deegan wrote:
Once again: please sort this out between yourself and Stefano so we only have one patchset doing this feature.
I would work with Stefano on PV evtchn for HVM. And the PV clocksource would be a standalone feature.
Quoted 9 lines
At 07:21 +0000 on 08 Mar (1268032899), Sheng Yang wrote:
Content-Description: hybrid-xen.patchQuoted 5 lines
xen/arch/x86/domain.c +0
-0@@ -686,7 +686,16 @@
Quoted 14 lines
xen/arch/x86/domain.c line 697
Quoted 11 lines
xen/arch/x86/domain.c +8
-0if (is_hvm_vcpu (v) ) { +unsigned long eip, cs; +hvm_set_info_guest (v); + + eip =c (user_regs.eip); +if (eip !=0 ) { + cs = eip >>12 <<8 ; +hvm_vcpu_reset_state (v, cs,0 ); + hvm_funcs.set_tsc_offset (v,0 );Shouldn't this be gated on (
d->hvm_pv_enabled&XEN_HVM_PV_CLOCK_ENABLED) rather than (eip != 0)?
Um... I think no other HVM should call this, and evtchn shouldn't work without PV clocksource... And it have two meaning here: one is setting up the start up IP for AP, another is initial PV clock.
I would update this to get it more clear.
Quoted 10 lines
Quoted 10 lines
xen/arch/x86/traps.c +0
-0@@ -686,6 +686,7 @@struct domain *d = current->domain;/* Optionally shift out of the way of Viridian architectural leaves. */ uint32_t base =is_viridian_domain (d) ?0x40000100 :0x40000000 ; + unsigned int tmp_eax, tmp_ebx, tmp_ecx, tmp_edx;
Quoted 16 lines
Quoted 4 lines
xen/arch/x86/traps.c +0
-0idx -= base;if ( idx >3 )@@ -716,6 +717,14 @@ *edx =0 ;/* Features 2 */ xen/arch/x86/traps.c line 727
Quoted 10 lines
xen/arch/x86/traps.c +8
-0if ( !is_hvm_vcpu (current) ) *ecx |=XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD ; + +/* Check if additional feature specified, e.g. Hybrid */ +if ( !is_viridian_domain (d) ) { +domain_cpuid (d,0x40000002 ,0 , + &tmp_eax, &tmp_ebx, &tmp_ecx, &tmp_edx); +if (tmp_edx !=0 ) + *edx = tmp_edx &XEN_CPUID_FEAT2_MASK ; + }Maybe use
cpuid_edx()here?
Um? It's not native cpuid, but the one configuration file specific.
Quoted 12 lines
xen/arch/x86/traps.c line 130
Quoted 9 lines
(quoted diff) +0
-0
b/xen/include/public/hvm/hvm_op.h---a/xen/include/public/hvm/hvm_op.h+++b/xen/include/public/hvm/hvm_op.hxen/arch/x86/traps.c +1
-0@@ -127,6 +127,15 @@typedef struct xen_hvm_set_mem_type xen_hvm_set_mem_type_t ;DEFINE_XEN_GUEST_HANDLE (xen_hvm_set_mem_type_t); +/* Enable PV extended HVM mode. Should called by BSP */ This comment doesn't really explain what the hypercall does.
Quoted 7 lines
xen/arch/x86/traps.c line 134
Quoted 4 lines
xen/arch/x86/traps.c +4
-0+#define HVMOP_enable_pv 9 +struct xen_hvm_pv_type { +/* Should be DOMID_SELF so far */ +domid_t domid;Please just kill this field rather than requiring the caller to set it to
DOMID_SELFand then checking that he did it.
OK.
Signature · 2 lines
regards Yang, Sheng
Quoted 8 lines
Quoted 7 lines
xen/arch/x86/traps.c +4
-0+/* The features want to enable */ +uint32_t flags; +#define HVM_PV_CLOCK (1ull<<0) +};#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
Quoted 7 lines · Sheng Yang
Quoted 2 lines
Shouldn't this be gated on (
d->hvm_pv_enabled&XEN_HVM_PV_CLOCK_ENABLED) rather than (eip != 0)?Um... I think no other HVM should call this, and evtchn shouldn't work without PV clocksource... And it have two meaning here: one is setting up the start up IP for AP, another is initial PV clock. I would update this to get it more clear.
Yes, I was just talking about the last line, where you set the offset to zero. Since you have introduced a flag that says whether the clocksource is enabled, you should use it.
Quoted 3 lines
Quoted 1 line
Maybe use
cpuid_edx()here?Um? It's not native cpuid, but the one configuration file specific.
Yes, you're quite right. I misread the code.
Thanks,
Tim.
Signature · 3 lines
Tim Deegan <[email protected]> Principal Software Engineer, XenServer Engineering Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)