Xen: Hybrid extension patchset for hypervisor
Hi Keir & Jeremy
Here is the hypervisor part of hybrid extension support.
Please review, thanks!
Signature · 2 lines
regards Yang, Sheng
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253081544 -28800
# Node ID f92ed10b9522a4dd83a5e31f7f1a8c83bd33d70d # Parent e5d904a6c9e6e585ec02124dc8b6592f525ef6ba Add user controlled cpuid 0x40000002.edx
So that user can turn on/off hybrid feature through configuration file.
xen/arch/x86/traps.c +9 -0
@@ -659,6 +659,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 >2 )
@@ -689,6 +690,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 ;default :
xen/include/public/arch-x86/cpuid.h +3 -0
@@ -65,4 +65,7 @@#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 0x0ul +#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253085983 -28800
# Node ID 2d68b9d29b425f138345c7b9e0e8bc66b84c7ba1 # Parent f92ed10b9522a4dd83a5e31f7f1a8c83bd33d70d Add HVMOP_enable_hybrid hypercall
As the entry of hybrid.
xen/arch/x86/hvm/hvm.c +51 -6
81 lines not on this page · raw message
xen/include/public/arch-x86/cpuid.h +3 -1
@@ -66,6 +66,8 @@#define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0)/* Mask unsupported CPUID specified by user */ -#define XEN_CPUID_FEAT2_MASK 0x0ul +#define XEN_CPUID_FEAT2_MASK 0x1ul +#define _XEN_CPUID_FEAT2_HYBRID 0 +#define XEN_CPUID_FEAT2_HYBRID (1u<<0)#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
xen/include/public/hvm/hvm_op.h +7 -0
@@ -125,6 +125,13 @@typedef struct xen_hvm_set_mem_type xen_hvm_set_mem_type_t ;DEFINE_XEN_GUEST_HANDLE (xen_hvm_set_mem_type_t); +#define HVMOP_enable_hybrid 9 +struct xen_hvm_hybrid_type { +domid_t domid; +uint64_t flags; +#define HVM_HYBRID_TIMER (1ull<<1) +#define HVM_HYBRID_EVTCHN (1ull<<2) +};#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
xen/include/xen/sched.h +11 -0
@@ -269,6 +269,11 @@/* VRAM dirty support. */ struct sh_dirty_vram *dirty_vram; + +#define XEN_HYBRID_ENABLED (1u << 0) +#define XEN_HYBRID_TIMER_ENABLED (1u << 1) +#define XEN_HYBRID_EVTCHN_ENABLED (1u << 2) +uint64_t hybrid_enabled; };struct domain_setup_info
@@ -551,6 +556,12 @@#define is_hvm_domain (d) ((d)->is_hvm)#define is_hvm_vcpu (v) (is_hvm_domain(v->domain))#define need_iommu (d) ((d)->need_iommu && !(d)->is_hvm) +#define is_hybrid_domain (d) ((d)->hybrid_enabled & XEN_HYBRID_ENABLED) +#define is_hybrid_vcpu (v) (is_hybrid_domain(v->domain)) +#define is_hybrid_timer_enabled_domain (d) (is_hybrid_domain(d) && \ + (d)->hybrid_enabled & XEN_HYBRID_TIMER_ENABLED) +#define is_hybrid_evtchn_enabled_domain (d) (is_hybrid_domain(d) && \ + (d)->hybrid_enabled & XEN_HYBRID_EVTCHN_ENABLED)void set_vcpu_migration_delay (unsigned int delay);unsigned int get_vcpu_migration_delay (void );
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253088144 -28800
# Node ID 91c520c2cefccc8c654839d9b38d04bd8801a391 # Parent 2d68b9d29b425f138345c7b9e0e8bc66b84c7ba1 Add pvtimer support for HVM
We need sync TSC with hypervisor, and update guest wallclock time if we want to enable pvtimer. The timer interrupt delivered through IRQ0.
xen/arch/x86/hvm/hvm.c +5 -0
@@ -2792,6 +2792,11 @@ d->hybrid_enabled =XEN_HYBRID_ENABLED ;printk ("HVM: Hybrid domain enabled\n" ); +if (a.flags &HVM_HYBRID_TIMER ) { + hvm_funcs.set_tsc_offset (d->vcpu[0 ],0 ); +update_domain_wallclock_time (d); + d->hybrid_enabled |=XEN_HYBRID_TIMER_ENABLED ; + } param_fail5:rcu_unlock_domain (d);break ;
xen/arch/x86/time.c +7 -0
@@ -30,6 +30,8 @@#include <asm/div64.h> #include <asm/hpet.h> #include <io_ports.h> + +#include <asm/hvm/irq.h> /* opt_clocksource: Force clocksource to one of: pit, hpet, cyclone, acpi. */ static char opt_clocksource[10 ];
@@ -1323,6 +1325,11 @@void send_timer_event (struct vcpu *v) {send_guest_vcpu_virq (v,VIRQ_TIMER ); +if (is_hybrid_timer_enabled_domain (v->domain) && + !is_hybrid_evtchn_enabled_domain (v->domain)) { +hvm_isa_irq_deassert (v->domain,0 ); +hvm_isa_irq_assert (v->domain,0 ); + } }/* Return secs after 00:00:00 localtime, 1 January, 1970. */
xen/include/public/arch-x86/cpuid.h +3 -1
@@ -66,8 +66,10 @@#define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0)/* Mask unsupported CPUID specified by user */ -#define XEN_CPUID_FEAT2_MASK 0x1ul +#define XEN_CPUID_FEAT2_MASK 0x3ul#define _XEN_CPUID_FEAT2_HYBRID 0#define XEN_CPUID_FEAT2_HYBRID (1u<<0) +#define _XEN_CPUID_FEAT2_HYBRID_TIMER 1 +#define XEN_CPUID_FEAT2_HYBRID_TIMER (1u<<1)#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253088147 -28800
# Node ID 78e51528eba7c5fd328c90acd4edc58ba46b58e8 # Parent 91c520c2cefccc8c654839d9b38d04bd8801a391 Add a new type of HVM callback
HVMIRQ_callback_vector specific one vector to trigger irq handler in the guest. And it don't need EOI action for it use IDT directly.
xen/arch/x86/hvm/irq.c +16 -1
@@ -165,6 +165,8 @@__hvm_pci_intx_assert (d, pdev, pintx); else__hvm_pci_intx_deassert (d ,pdev ,pintx ); +case HVMIRQ_callback_vector: +vcpu_kick (v);default :break ; }
@@ -251,7 +253,7 @@ via_type = (uint8_t )(via >>56 ) +1 ;if ( ((via_type == HVMIRQ_callback_gsi) && (via ==0 )) || - (via_type > HVMIRQ_callback_pci_intx) ) + (via_type > HVMIRQ_callback_vector) ) via_type = HVMIRQ_callback_none;spin_lock (&d->arch.hvm_domain.irq_lock);
@@ -297,6 +299,9 @@if ( hvm_irq->callback_via_asserted )__hvm_pci_intx_assert (d, pdev, pintx);break ; +case HVMIRQ_callback_vector: + hvm_irq->callback_via.vector = (uint8_t )via; +break ;default :break ; }
@@ -312,6 +317,10 @@case HVMIRQ_callback_pci_intx:printk ("PCI INTx Dev 0x%02x Int%c\n" , pdev,'A' + pintx);break ; +case HVMIRQ_callback_vector: +printk ("Set HVMIRQ_callback_vector to %u\n" , + hvm_irq->callback_via.vector); +break ;default :printk ("None\n" );break ;
@@ -322,6 +331,10 @@ {struct hvm_domain *plat = &v->domain->arch.hvm_domain;int vector; + +if (plat->irq.callback_via_type == HVMIRQ_callback_vector && +vcpu_info (v, evtchn_upcall_pending)) +return hvm_intack_vector (plat->irq.callback_via.vector);if (unlikely (v->nmi_pending) )return hvm_intack_nmi;
@@ -357,6 +370,8 @@case hvm_intsrc_lapic:if ( !vlapic_ack_pending_irq (v, intack.vector) ) intack = hvm_intack_none; +break ; +case hvm_intsrc_vector:break ;default : intack = hvm_intack_none;
xen/arch/x86/hvm/vmx/intr.c +2 -1
@@ -161,7 +161,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/include/asm-x86/hvm/hvm.h +3 -1
@@ -31,7 +31,8 @@ hvm_intsrc_none, hvm_intsrc_pic, hvm_intsrc_lapic, - hvm_intsrc_nmi + hvm_intsrc_nmi, + hvm_intsrc_vector, };struct hvm_intack {uint8_t source;/* enum hvm_intsrc */
@@ -41,6 +42,7 @@#define hvm_intack_pic (vec) ( (struct hvm_intack) { hvm_intsrc_pic, vec } )#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_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. */
# HG changeset patch
# User Sheng Yang <[email protected]>
# Date 1253088148 -28800
# Node ID 183fa85d47d9411e6e21c4534d8e231feeac96a7 # Parent 78e51528eba7c5fd328c90acd4edc58ba46b58e8 Enable event channel and QEmu device support for hybrid guest
Each VIRQ from 24 to 40 binding to a QEmu emulated pin, so that if device assert the pin, one VIRQ would be delivered to the guest instead.
xen/arch/x86/hvm/hvm.c +2 -0
@@ -2797,6 +2797,8 @@update_domain_wallclock_time (d); d->hybrid_enabled |=XEN_HYBRID_TIMER_ENABLED ; } +if (a.flags &HVM_HYBRID_EVTCHN ) + d->hybrid_enabled |=XEN_HYBRID_EVTCHN_ENABLED ; param_fail5:rcu_unlock_domain (d);break ;
xen/arch/x86/hvm/irq.c +33 -7
@@ -46,8 +46,18 @@if ( (hvm_irq->pci_link_assert_count[link]++ ==0 ) && isa_irq && (hvm_irq->gsi_assert_count[isa_irq]++ ==0 ) ) { -vioapic_irq_positive_edge (d, isa_irq); -vpic_irq_positive_edge (d, isa_irq); +if ( !is_hybrid_evtchn_enabled_domain (d) ) + { +vioapic_irq_positive_edge (d, isa_irq); +vpic_irq_positive_edge (d, isa_irq); + } +else + { +/* TODO fix the critical region here */ +spin_unlock (&d->arch.hvm_domain.irq_lock); +send_guest_global_virq (d,VIRQ_EMUL_PIN (isa_irq)); +spin_lock (&d->arch.hvm_domain.irq_lock); + } } }
@@ -76,8 +86,10 @@ link =hvm_pci_intx_link (device, intx); isa_irq = hvm_irq->pci_link.route[link];if ( (--hvm_irq->pci_link_assert_count[link] ==0 ) && isa_irq && - (--hvm_irq->gsi_assert_count[isa_irq] ==0 ) ) -vpic_irq_negative_edge (d, isa_irq); + (--hvm_irq->gsi_assert_count[isa_irq] ==0 ) ) { +if ( !is_hybrid_evtchn_enabled_domain (d) ) +vpic_irq_negative_edge (d, isa_irq); + } } void hvm_pci_intx_deassert(
@@ -93,6 +105,7 @@ {struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq); +int send_virq =0 ;ASSERT (isa_irq <=15 );
@@ -101,11 +114,21 @@if ( !__test_and_set_bit (isa_irq, &hvm_irq->isa_irq.i) && (hvm_irq->gsi_assert_count[gsi]++ ==0 ) ) { -vioapic_irq_positive_edge (d, gsi); -vpic_irq_positive_edge (d, isa_irq); +if ( !is_hybrid_evtchn_enabled_domain (d) ) + { +vioapic_irq_positive_edge (d, gsi); +vpic_irq_positive_edge (d, isa_irq); + } +else + { + send_virq =1 ; + } }spin_unlock (&d->arch.hvm_domain.irq_lock); + +if (send_virq) +send_guest_global_virq (d,VIRQ_EMUL_PIN (isa_irq)); } void hvm_isa_irq_deassert(
@@ -120,7 +143,10 @@if (__test_and_clear_bit (isa_irq, &hvm_irq->isa_irq.i) && (--hvm_irq->gsi_assert_count[gsi] ==0 ) ) -vpic_irq_negative_edge (d, isa_irq); + { +if ( !is_hybrid_evtchn_enabled_domain (d) ) +vpic_irq_negative_edge (d, isa_irq); + }spin_unlock (&d->arch.hvm_domain.irq_lock); }
xen/include/public/xen.h +6 -1
@@ -159,7 +159,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/* * MMU-UPDATE REQUESTS
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253088149 -28800
# Node ID 86c908c45ac908767b6b6bdbd9e8d863b34a84a8 # Parent 183fa85d47d9411e6e21c4534d8e231feeac96a7 Reserved E820 for hybrid gnttab support
tools/firmware/hvmloader/config.h +5 -1
@@ -16,8 +16,12 @@/* MMIO hole: Hardcoded defaults, which can be dynamically expanded. */ #define PCI_MEM_START 0xf0000000 -#define PCI_MEM_END 0xfc000000 +#define PCI_MEM_END 0xfbfe0000extern unsigned long pci_mem_start, pci_mem_end; + +/* Reserve 128KB for grant table */ +#define GNTTAB_MEMBASE 0xfbfe0000 +#define GNTTAB_MEMSIZE 0x20000/* We reserve 16MB for special BIOS mappings, etc. */ #define RESERVED_MEMBASE 0xfc000000
tools/firmware/hvmloader/hvmloader.c +6 -0
@@ -602,6 +602,12 @@ e820[nr].type =E820_RAM ; nr++; +/* Reserved for grant table */ + e820[nr].addr =GNTTAB_MEMBASE ; + e820[nr].size =GNTTAB_MEMSIZE ; + e820[nr].type =E820_RESERVED ; + nr++; +/* * Explicitly reserve space for special pages. * This space starts at RESERVED_MEMBASE an extends to cover various
# HG changeset patch
# User Sheng Yang <[email protected]>
# Date 1253088151 -28800
# Node ID 607b7ad0488a9db6202e0a6178027684ac0eb027 # Parent 86c908c45ac908767b6b6bdbd9e8d863b34a84a8 Enable event channel feature in CPUID for configuration file
xen/include/public/arch-x86/cpuid.h +3 -1
@@ -66,10 +66,12 @@#define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0)/* Mask unsupported CPUID specified by user */ -#define XEN_CPUID_FEAT2_MASK 0x3ul +#define XEN_CPUID_FEAT2_MASK 0x7ul#define _XEN_CPUID_FEAT2_HYBRID 0#define XEN_CPUID_FEAT2_HYBRID (1u<<0)#define _XEN_CPUID_FEAT2_HYBRID_TIMER 1#define XEN_CPUID_FEAT2_HYBRID_TIMER (1u<<1) +#define _XEN_CPUID_FEAT2_HYBRID_EVTCHN 2 +#define XEN_CPUID_FEAT2_HYBRID_EVTCHN (1u<<2)#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 5 lines · Sheng
Hi Keir & Jeremy
Here is the hypervisor part of hybrid extension support.
Please review, thanks!
The principle is okay I guess. These changes would have to be trickled in with a really good explanation and justification for each one. For example, I'm not clear why the enable-hybrid hypercall is needed. Why not just provide access to evtchn and timer hypercalls always, and guest sues them if it is capable of it? I'm also not sure why PV timer events get routed to irq0 -- why not via an event channel as usual, now that you are enabling HVM guests to use the evtchn subsystem? What's a hybrid gnttab, and why does it need an explciit reserved e820 region? And so on.
The general principle of these patches seems to be to create a set of individual, and perhaps largely independent, accelerations/enlightenments to the HVM interface. I can at least agree with and support that aim.
-- Keir
Quoted 9 lines · Keir Fraser
The principle is okay I guess. These changes would have to be trickled in with a really good explanation and justification for each one. For example, I'm not clear why the enable-hybrid hypercall is needed. Why not just provide access to evtchn and timer hypercalls always, and guest sues them if it is capable of it? I'm also not sure why PV timer events get routed to irq0 -- why not via an event channel as usual, now that you are enabling HVM guests to use the evtchn subsystem? What's a hybrid gnttab, and why does it need an explciit reserved e820 region? And so on.
Quoted 3 lines
The general principle of these patches seems to be to create a set of individual, and perhaps largely independent, accelerations/enlightenments to the HVM interface. I can at least agree with and support that aim.
By the way, if your intention is to speed up 64-bit guest performance, then I think you should compare with running a full PV guest in a VMCS container. That is runs in VMX non-root mode but still retains the usual full-PV interfaces. I think that would be no more code than you are proposing here, and would avoid scattering a bunch more code around the guest OS, to which there is bound to be resistance.
-- Keir
Keir Fraser wrote on Wed, 16 Sep 2009 at 07:04:10:
Quoted 16 lines · Keir Fraser
Quoted 11 lines
The principle is okay I guess. These changes would have to be trickled in with a really good explanation and justification for each one. For example, I'm not clear why the enable-hybrid hypercall is needed. Why not just provide access to evtchn and timer hypercalls always, and guest sues them if it is capable of it? I'm also not sure why PV timer events get routed to irq0 -- why not via an event channel as usual, now that you are enabling HVM guests to use the evtchn subsystem? What's a hybrid gnttab, and why does it need an explciit reserved e820 region? And so on.
Quoted 4 lines
The general principle of these patches seems to be to create a set of individual, and perhaps largely independent, accelerations/enlightenments to the HVM interface. I can at least agree with and support that aim.
Quoted 6 lines
By the way, if your intention is to speed up 64-bit guest performance,
then I think you should compare with running a full PV guest in a VMCS container. That is runs in VMX non-root mode but still retains the usual full-PV interfaces. I think that would be no more code than you are proposing here, and would avoid scattering a bunch more code around the guest OS, to which there is bound to be resistance.
Do you mean running the existing 64-bit PV kernel binaries in a VMCS container?
Based on our data, what we would want in PV 64-bit guests are, fundamentally:
- have the kernel run in ring 0 (so that it can regain the performance enhancements)
- use hardware-based MMU virtualization (e.g. EPT-based) if present
Quoted 3 lines
-- Keir
Jun
___
Intel Open Source Technology Center
Quoted 11 lines · Jun
Keir Fraser wrote on Wed, 16 Sep 2009 at 07:04:10:
Quoted 7 lines
By the way, if your intention is to speed up 64-bit guest performance,
then I think you should compare with running a full PV guest in a VMCS container. That is runs in VMX non-root mode but still retains the usual full-PV interfaces. I think that would be no more code than you are proposing here, and would avoid scattering a bunch more code around the guest OS, to which there is bound to be resistance.Do you mean running the existing 64-bit PV kernel binaries in a VMCS container?
Yes. I don't think there's any deep problem in doing that.
Quoted 3 lines
Based on our data, what we would want in PV 64-bit guests are, fundamentally:
- have the kernel run in ring 0 (so that it can regain the performance enhancements)
That's no problem. PV kernels don't currently assume they're running in any particular ring, so they'd be happy to run in ring 0 if that's how they're started (if there are problems, I'd consider that a bug). We could then check for ring 0 and enable syscall/sysenter.
Quoted 2 lines
- use hardware-based MMU virtualization (e.g. EPT-based) if present
We could do that with minimal API/ABI changes by:
* Providing an identity p2m table
* Changing the hypercall page to make pte writes simple memory writes (no hypercalls); xen would still keep track of pinned pages and trap'n'emulate on them for back-compatibility (but fast-path with no validation). We could expose the presence of HAP via xen_features so that guests know they can avoid marking pagetables RO, etc.
* Similarly, cr3 changes can be fast-pathed within the hypercall page.
* Whatever else I've overlooked.
This would be very similar to how xenner gets PV guests running under kvm.
The tricky part might be in getting IO working, since it relies on getting real MFNs for DMA.
At any rate, the changes need only be very localized within the Xen-specific code. I would not want to introduce a new or significantly different kernel<->hypervisor ABI for any new modes (we have enough already).
J
Quoted 15 lines · Jeremy Fitzhardinge
Quoted 11 lines · Jun
Keir Fraser wrote on Wed, 16 Sep 2009 at 07:04:10:
Quoted 7 lines
By the way, if your intention is to speed up 64-bit guest performance,
then I think you should compare with running a full PV guest in a VMCS container. That is runs in VMX non-root mode but still retains the usual full-PV interfaces. I think that would be no more code than you are proposing here, and would avoid scattering a bunch more code around the guest OS, to which there is bound to be resistance.Do you mean running the existing 64-bit PV kernel binaries in a VMCS container?
Yes. I don't think there's any deep problem in doing that.
Quoted 8 lines
Quoted 3 lines
Based on our data, what we would want in PV 64-bit guests are, fundamentally:
- have the kernel run in ring 0 (so that it can regain the performance enhancements)That's no problem. PV kernels don't currently assume they're running in any particular ring, so they'd be happy to run in ring 0 if that's how they're started (if there are problems, I'd consider that a bug). We could then check for ring 0 and enable syscall/sysenter.
XENFEAT_supervisor_mode_kernel is supposed to enable this behaviour, although it hasn't been actively used for several years and never in the pvops kernel so you can bet it has bit-rotted...
Quoted 6 lines
Quoted 3 lines
- use hardware-based MMU virtualization (e.g. EPT-based) if present
We could do that with minimal API/ABI changes by:
Quoted 9 lines
* Providing an identity p2m table
* Changing the hypercall page to make pte writes simple memory writes (no hypercalls); xen would still keep track of pinned pages and trap'n'emulate on them for back-compatibility (but fast-path with no validation). We could expose the presence of HAP viaxen_featuresso that guests know they can avoid marking pagetables RO, etc.
* Similarly, cr3 changes can be fast-pathed within the hypercall page.
* Whatever else I've overlooked.
Some combination of XENFEAT_writable_page_tables XENFEAT_writable_descriptor_tables and XENFEAT_auto_translated_physmap might be of interest for this bit.
Ian.
Quoted 4 lines · Ian Campbell
Quoted 4 lines
Quoted 4 lines
Based on our data, what we would want in PV 64-bit guests are, fundamentally:
- have the kernel run in ring 0 (so that it can regain the performance enhancements)
Quoted 9 lines
Quoted 5 lines
That's no problem. PV kernels don't currently assume they're running in any particular ring, so they'd be happy to run in ring 0 if that's how they're started (if there are problems, I'd consider that a bug). We could then check for ring 0 and enable syscall/sysenter.
XENFEAT_supervisor_mode_kernelis supposed to enable this behaviour, although it hasn't been actively used for several years and never in the pvops kernel so you can bet it has bit-rotted...
That tends to have a slightly different meaning, viz "dom0 really *is* privileged and can do anything it feels like". It isn't necessary to have a specific feature/mechanism for "kernel happens to be in ring 0"; it can look at its own cs ring number.
Quoted 12 lines
Quoted 12 lines
We could do that with minimal API/ABI changes by:
* Providing an identity p2m table
* Changing the hypercall page to make pte writes simple memory writes (no hypercalls); xen would still keep track of pinned pages and trap'n'emulate on them for back-compatibility (but fast-path with no validation). We could expose the presence of HAP viaxen_featuresso that guests know they can avoid marking pagetables RO, etc.
* Similarly, cr3 changes can be fast-pathed within the hypercall page.
* Whatever else I've overlooked.
Quoted 3 lines
Some combination of
XENFEAT_writable_page_tablesXENFEAT_writable_descriptor_tablesandXENFEAT_auto_translated_physmapmight be of interest for this bit.
Making use of XENFEAT_auto_translated_physmap would avoid the need for identity p2m/m2p tables, but I'm not sure whether it still works. I got close to completely removing all references to it at one point, but I think ia64 uses it?
Quoted 15 lines · Jeremy Fitzhardinge
Quoted 4 lines · Ian Campbell
Quoted 4 lines
Quoted 4 lines
Based on our data, what we would want in PV 64-bit guests are, fundamentally:
- have the kernel run in ring 0 (so that it can regain the performance enhancements)Quoted 9 lines
Quoted 5 lines
That's no problem. PV kernels don't currently assume they're running in any particular ring, so they'd be happy to run in ring 0 if that's how they're started (if there are problems, I'd consider that a bug). We could then check for ring 0 and enable syscall/sysenter.
XENFEAT_supervisor_mode_kernelis supposed to enable this behaviour, although it hasn't been actively used for several years and never in the pvops kernel so you can bet it has bit-rotted...
Quoted 4 lines
That tends to have a slightly different meaning, viz "dom0 really *is* privileged and can do anything it feels like". It isn't necessary to have a specific feature/mechanism for "kernel happens to be in ring 0"; it can look at its own cs ring number.
In practise, at least for the 2.6.18-xen tree (which is the only one where I expect it was ever completely implemented), it is only used to set the kernel CS and DS and to gate sysenter setup (for which I think we have a better mechanism today) but you are right that in principle it could be more far reaching than that.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
We could do that with minimal API/ABI changes by:
* Providing an identity p2m table
* Changing the hypercall page to make pte writes simple memory writes (no hypercalls); xen would still keep track of pinned pages and trap'n'emulate on them for back-compatibility (but fast-path with no validation). We could expose the presence of HAP viaxen_featuresso that guests know they can avoid marking pagetables RO, etc.
* Similarly, cr3 changes can be fast-pathed within the hypercall page.
* Whatever else I've overlooked.
Quoted 8 lines
Quoted 3 lines
Some combination of
XENFEAT_writable_page_tablesXENFEAT_writable_descriptor_tablesandXENFEAT_auto_translated_physmapmight be of interest for this bit.Making use of
XENFEAT_auto_translated_physmapwould avoid the need for identity p2m/m2p tables, but I'm not sure whether it still works. I got close to completely removing all references to it at one point, but I think ia64 uses it?
I very much expect that it'll need fixing/(re)implementing on both the kernel and hypervisor side...
Ian.
Ian Campbell wrote on Thu, 17 Sep 2009 at 02:16:25:
Quoted 16 lines · Jeremy Fitzhardinge
Quoted 15 lines
Quoted 15 lines
Quoted 12 lines
We could do that with minimal API/ABI changes by:
* Providing an identity p2m table
* Changing the hypercall page to make pte writes simple memory writes (no hypercalls); xen would still keep track of pinned pages and trap'n'emulate on them for back-compatibility (but fast- path with no validation). We could expose the presence of HAP viaxen_featuresso that guests know they can avoid marking pagetables RO, etc.
* Similarly, cr3 changes can be fast-pathed within the hypercall page. * Whatever else I've overlooked.Some combination of
XENFEAT_writable_page_tablesXENFEAT_writable_descriptor_tablesandXENFEAT_auto_translated_physmapmight be of interest for this bit.
Quoted 7 lines
Quoted 4 lines
Making use of
XENFEAT_auto_translated_physmapwould avoid the need for
identity p2m/m2p tables, but I'm not sure whether it still works. I got close to completely removing all references to it at one point, but I think ia64 uses it?I very much expect that it'll need fixing/(re)implementing on both the kernel and hypervisor side...
To me, leveraging the native MMU code, rather than using existing API/ABI, would simplify both the guest and hypervisor side if hardware MMU virtualization is present. For example:
- today a 64-bit PV guest builds/switches page tables depending on the kernel/user mode. It's not required anymore.
- we can automatically get large page support (2MB, 1GB)
I thought pv_xxx_ps (such as pv_time, pv_cpu_ops, pv_mmu_ops, etc.) was designed to choose the right pv_ops accordingly depending on the features available.
Quoted 2 lines
Ian.
Jun
___
Intel Open Source Technology Center
Quoted 6 lines · Jun
Quoted 3 lines
I very much expect that it'll need fixing/(re)implementing on both the kernel and hypervisor side...
To me, leveraging the native MMU code, rather than using existing API/ABI, would simplify both the guest and hypervisor side if hardware MMU virtualization is present. For example:
- today a 64-bit PV guest builds/switches page tables depending on the kernel/user mode. It's not required anymore.
The two pagetables are largely shared, so it really comes down to maintaining an additional L4 page. If the domain is running in a HAP container, then then the "kernel" pagetable would have proper U/S bit its pagetable entries (ie, Xen wouldn't strip them off, or set global on user mappings) and then loading a new pagetable would just mean reloading cr3 with the kernel pagetable. In other words, we can still do an efficient pagetable swap without needing to change the guest or the ABI at all; the user pagetable would be unused and ignored, but that isn't a huge burden.
Quoted 2 lines
- we can automatically get large page support (2MB, 1GB)
Once the requirement to mark pagetable pages RO goes away, then it would be easy to add large-page support.
Quoted 2 lines
I thought
pv_xxx_ps(such aspv_time,pv_cpu_ops,pv_mmu_ops, etc.) was designed to choose the rightpv_opsaccordingly depending on the features available.
Sure. It would be easy to either use new special-purpose just plain native versions of those ops if that's the right thing to do; but it would be nice if a current unmodified PV guest worked within a HVM container and got at least some benefit from doing so. Also, pagetable issues have repercussions beyond just the raw pagetable update functions.
Of course you can get both these features just by booting the kernel as an hvm guest. But if we're talking about giving PV kernels some benefits from hvm/hap hardware features, I think we should looking at it from the perspective of starting with a PV kernel then adding incremental changes.
J
Jeremy Fitzhardinge wrote on Thu, 17 Sep 2009 at 10:34:51:
Quoted 11 lines · Jun
Quoted 1 line
I thought
pv_xxx_ps(such aspv_time,pv_cpu_ops,pv_mmu_ops, etc.)was designed to choose the right
pv_opsaccordingly depending on the features available.Quoted 1 line
Sure. It would be easy to either use new special-purpose just plain
native versions of those ops if that's the right thing to do; but it would be nice if a current unmodified PV guest worked within a HVM container and got at least some benefit from doing so. Also, pagetable issues have repercussions beyond just the raw pagetable update functions.
Quoted 6 lines
Of course you can get both these features just by booting the kernel as an hvm guest. But if we're talking about giving PV kernels some benefits from hvm/hap hardware features, I think we should looking at it from the perspective of starting with a PV kernel then adding incremental changes.
Even if we start from PV kernels, I think what we should do is to implement ability (as "incremental changes") for PV guests to stop using PV MMU (and PV CPU) at boot time depending on the H/W features available rather than to keep using the same ABI, because we may not need them in the near future. Then, such PV kernels would be at par or faster/more efficient than pure HVM guests on machines with HAP enabled because of the other PV features.
Jun
___
Intel Open Source Technology Center
Quoted 2 lines · Jun
Even if we start from PV kernels, I think what we should do is to implement ability (as "incremental changes") for PV guests to stop using PV MMU (and PV CPU) at boot time depending on the H/W features available rather than to keep using the same ABI, because we may not need them in the near future. Then, such PV kernels would be at par or faster/more efficient than pure HVM guests on machines with HAP enabled because of the other PV features.
Sure, that's no problem. So long as the current ABI keeps working, we can easily switch to something else more appropriate where possible.
J
Quoted 6 lines · Ian Campbell
In practise, at least for the 2.6.18-xen tree (which is the only one where I expect it was ever completely implemented), it is only used to set the kernel CS and DS and to gate sysenter setup (for which I think we have a better mechanism today) but you are right that in principle it could be more far reaching than that.
Yeah. Looks like the only other thing it allows is that the guest can set arbitrary gdt entries.
Quoted 8 lines
Quoted 5 lines
Making use of
XENFEAT_auto_translated_physmapwould avoid the need for identity p2m/m2p tables, but I'm not sure whether it still works. I got close to completely removing all references to it at one point, but I think ia64 uses it?I very much expect that it'll need fixing/(re)implementing on both the kernel and hypervisor side...
Yeah, I think the Xen side is missing altogether on x86 now. I don't think its worth recovering it unless its the ABI for making HAP available to guests. If IA64 is using it, then I think big parts of the kernel are probably in OK shape (drivers, etc).
J
Quoted 19 lines · Keir Fraser
Quoted 6 lines · Sheng
Hi Keir & Jeremy
Here is the hypervisor part of hybrid extension support.
Please review, thanks!
The principle is okay I guess. These changes would have to be trickled in with a really good explanation and justification for each one. For example, I'm not clear why the enable-hybrid hypercall is needed. Why not just provide access to evtchn and timer hypercalls always, and guest sues them if it is capable of it? I'm also not sure why PV timer events get routed to irq0 -- why not via an event channel as usual, now that you are enabling HVM guests to use the evtchn subsystem? What's a hybrid gnttab, and why does it need an explciit reserved e820 region? And so on.
Quoted 6 lines
The general principle of these patches seems to be to create a set of individual, and perhaps largely independent, accelerations/enlightenments to the HVM interface. I can at least agree with and support that aim.
-- Keir
I did not see the hypervisor part of these patches appear in my xen-devel inbox. Is this a problem on my end, or were they not sent to the list? If so, I'm interested in them, so it'd be great if they could be sent to the list.
Thanks,
- Frank
Quoted 23 lines · On Thursday 17 September 2009 03:11:49 Frank van der Linden wrote:
Quoted 16 lines · Keir Fraser
Quoted 5 lines · Sheng
Hi Keir & Jeremy
Here is the hypervisor part of hybrid extension support.
Please review, thanks!
The principle is okay I guess. These changes would have to be trickled in with a really good explanation and justification for each one. For example, I'm not clear why the enable-hybrid hypercall is needed. Why not just provide access to evtchn and timer hypercalls always, and guest sues them if it is capable of it? I'm also not sure why PV timer events get routed to irq0 -- why not via an event channel as usual, now that you are enabling HVM guests to use the evtchn subsystem? What's a hybrid gnttab, and why does it need an explciit reserved e820 region? And so on.
Quoted 5 lines
The general principle of these patches seems to be to create a set of individual, and perhaps largely independent, accelerations/enlightenments to the HVM interface. I can at least agree with and support that aim.
-- Keir
Quoted 8 lines
I did not see the hypervisor part of these patches appear in my xen-devel inbox. Is this a problem on my end, or were they not sent to the list? If so, I'm interested in them, so it'd be great if they could be sent to the list.
Thanks,
- Frank
It's quite strange...
Here is the patches(attached). Send them again...
Signature · 2 lines
regards Yang, Sheng
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253081544 -28800
# Node ID f92ed10b9522a4dd83a5e31f7f1a8c83bd33d70d # Parent e5d904a6c9e6e585ec02124dc8b6592f525ef6ba Add user controlled cpuid 0x40000002.edx
So that user can turn on/off hybrid feature through configuration file.
xen/arch/x86/traps.c +9 -0
@@ -659,6 +659,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 >2 )
@@ -689,6 +690,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 ;default :
xen/include/public/arch-x86/cpuid.h +3 -0
@@ -65,4 +65,7 @@#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 0x0ul +#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253085983 -28800
# Node ID 2d68b9d29b425f138345c7b9e0e8bc66b84c7ba1 # Parent f92ed10b9522a4dd83a5e31f7f1a8c83bd33d70d Add HVMOP_enable_hybrid hypercall
As the entry of hybrid.
xen/arch/x86/hvm/hvm.c +51 -6
81 lines not on this page · raw message
xen/include/public/arch-x86/cpuid.h +3 -1
@@ -66,6 +66,8 @@#define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0)/* Mask unsupported CPUID specified by user */ -#define XEN_CPUID_FEAT2_MASK 0x0ul +#define XEN_CPUID_FEAT2_MASK 0x1ul +#define _XEN_CPUID_FEAT2_HYBRID 0 +#define XEN_CPUID_FEAT2_HYBRID (1u<<0)#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
xen/include/public/hvm/hvm_op.h +7 -0
@@ -125,6 +125,13 @@typedef struct xen_hvm_set_mem_type xen_hvm_set_mem_type_t ;DEFINE_XEN_GUEST_HANDLE (xen_hvm_set_mem_type_t); +#define HVMOP_enable_hybrid 9 +struct xen_hvm_hybrid_type { +domid_t domid; +uint64_t flags; +#define HVM_HYBRID_TIMER (1ull<<1) +#define HVM_HYBRID_EVTCHN (1ull<<2) +};#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
xen/include/xen/sched.h +11 -0
@@ -269,6 +269,11 @@/* VRAM dirty support. */ struct sh_dirty_vram *dirty_vram; + +#define XEN_HYBRID_ENABLED (1u << 0) +#define XEN_HYBRID_TIMER_ENABLED (1u << 1) +#define XEN_HYBRID_EVTCHN_ENABLED (1u << 2) +uint64_t hybrid_enabled; };struct domain_setup_info
@@ -551,6 +556,12 @@#define is_hvm_domain (d) ((d)->is_hvm)#define is_hvm_vcpu (v) (is_hvm_domain(v->domain))#define need_iommu (d) ((d)->need_iommu && !(d)->is_hvm) +#define is_hybrid_domain (d) ((d)->hybrid_enabled & XEN_HYBRID_ENABLED) +#define is_hybrid_vcpu (v) (is_hybrid_domain(v->domain)) +#define is_hybrid_timer_enabled_domain (d) (is_hybrid_domain(d) && \ + (d)->hybrid_enabled & XEN_HYBRID_TIMER_ENABLED) +#define is_hybrid_evtchn_enabled_domain (d) (is_hybrid_domain(d) && \ + (d)->hybrid_enabled & XEN_HYBRID_EVTCHN_ENABLED)void set_vcpu_migration_delay (unsigned int delay);unsigned int get_vcpu_migration_delay (void );
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253088144 -28800
# Node ID 91c520c2cefccc8c654839d9b38d04bd8801a391 # Parent 2d68b9d29b425f138345c7b9e0e8bc66b84c7ba1 Add pvtimer support for HVM
We need sync TSC with hypervisor, and update guest wallclock time if we want to enable pvtimer. The timer interrupt delivered through IRQ0.
xen/arch/x86/hvm/hvm.c +5 -0
@@ -2792,6 +2792,11 @@ d->hybrid_enabled =XEN_HYBRID_ENABLED ;printk ("HVM: Hybrid domain enabled\n" ); +if (a.flags &HVM_HYBRID_TIMER ) { + hvm_funcs.set_tsc_offset (d->vcpu[0 ],0 ); +update_domain_wallclock_time (d); + d->hybrid_enabled |=XEN_HYBRID_TIMER_ENABLED ; + } param_fail5:rcu_unlock_domain (d);break ;
xen/arch/x86/time.c +7 -0
@@ -30,6 +30,8 @@#include <asm/div64.h> #include <asm/hpet.h> #include <io_ports.h> + +#include <asm/hvm/irq.h> /* opt_clocksource: Force clocksource to one of: pit, hpet, cyclone, acpi. */ static char opt_clocksource[10 ];
@@ -1323,6 +1325,11 @@void send_timer_event (struct vcpu *v) {send_guest_vcpu_virq (v,VIRQ_TIMER ); +if (is_hybrid_timer_enabled_domain (v->domain) && + !is_hybrid_evtchn_enabled_domain (v->domain)) { +hvm_isa_irq_deassert (v->domain,0 ); +hvm_isa_irq_assert (v->domain,0 ); + } }/* Return secs after 00:00:00 localtime, 1 January, 1970. */
xen/include/public/arch-x86/cpuid.h +3 -1
@@ -66,8 +66,10 @@#define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0)/* Mask unsupported CPUID specified by user */ -#define XEN_CPUID_FEAT2_MASK 0x1ul +#define XEN_CPUID_FEAT2_MASK 0x3ul#define _XEN_CPUID_FEAT2_HYBRID 0#define XEN_CPUID_FEAT2_HYBRID (1u<<0) +#define _XEN_CPUID_FEAT2_HYBRID_TIMER 1 +#define XEN_CPUID_FEAT2_HYBRID_TIMER (1u<<1)#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253088147 -28800
# Node ID 78e51528eba7c5fd328c90acd4edc58ba46b58e8 # Parent 91c520c2cefccc8c654839d9b38d04bd8801a391 Add a new type of HVM callback
HVMIRQ_callback_vector specific one vector to trigger irq handler in the guest. And it don't need EOI action for it use IDT directly.
xen/arch/x86/hvm/irq.c +16 -1
@@ -165,6 +165,8 @@__hvm_pci_intx_assert (d, pdev, pintx); else__hvm_pci_intx_deassert (d ,pdev ,pintx ); +case HVMIRQ_callback_vector: +vcpu_kick (v);default :break ; }
@@ -251,7 +253,7 @@ via_type = (uint8_t )(via >>56 ) +1 ;if ( ((via_type == HVMIRQ_callback_gsi) && (via ==0 )) || - (via_type > HVMIRQ_callback_pci_intx) ) + (via_type > HVMIRQ_callback_vector) ) via_type = HVMIRQ_callback_none;spin_lock (&d->arch.hvm_domain.irq_lock);
@@ -297,6 +299,9 @@if ( hvm_irq->callback_via_asserted )__hvm_pci_intx_assert (d, pdev, pintx);break ; +case HVMIRQ_callback_vector: + hvm_irq->callback_via.vector = (uint8_t )via; +break ;default :break ; }
@@ -312,6 +317,10 @@case HVMIRQ_callback_pci_intx:printk ("PCI INTx Dev 0x%02x Int%c\n" , pdev,'A' + pintx);break ; +case HVMIRQ_callback_vector: +printk ("Set HVMIRQ_callback_vector to %u\n" , + hvm_irq->callback_via.vector); +break ;default :printk ("None\n" );break ;
@@ -322,6 +331,10 @@ {struct hvm_domain *plat = &v->domain->arch.hvm_domain;int vector; + +if (plat->irq.callback_via_type == HVMIRQ_callback_vector && +vcpu_info (v, evtchn_upcall_pending)) +return hvm_intack_vector (plat->irq.callback_via.vector);if (unlikely (v->nmi_pending) )return hvm_intack_nmi;
@@ -357,6 +370,8 @@case hvm_intsrc_lapic:if ( !vlapic_ack_pending_irq (v, intack.vector) ) intack = hvm_intack_none; +break ; +case hvm_intsrc_vector:break ;default : intack = hvm_intack_none;
xen/arch/x86/hvm/vmx/intr.c +2 -1
@@ -161,7 +161,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/include/asm-x86/hvm/hvm.h +3 -1
@@ -31,7 +31,8 @@ hvm_intsrc_none, hvm_intsrc_pic, hvm_intsrc_lapic, - hvm_intsrc_nmi + hvm_intsrc_nmi, + hvm_intsrc_vector, };struct hvm_intack {uint8_t source;/* enum hvm_intsrc */
@@ -41,6 +42,7 @@#define hvm_intack_pic (vec) ( (struct hvm_intack) { hvm_intsrc_pic, vec } )#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_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. */
# HG changeset patch
# User Sheng Yang <[email protected]>
# Date 1253088148 -28800
# Node ID 183fa85d47d9411e6e21c4534d8e231feeac96a7 # Parent 78e51528eba7c5fd328c90acd4edc58ba46b58e8 Enable event channel and QEmu device support for hybrid guest
Each VIRQ from 24 to 40 binding to a QEmu emulated pin, so that if device assert the pin, one VIRQ would be delivered to the guest instead.
xen/arch/x86/hvm/hvm.c +2 -0
@@ -2797,6 +2797,8 @@update_domain_wallclock_time (d); d->hybrid_enabled |=XEN_HYBRID_TIMER_ENABLED ; } +if (a.flags &HVM_HYBRID_EVTCHN ) + d->hybrid_enabled |=XEN_HYBRID_EVTCHN_ENABLED ; param_fail5:rcu_unlock_domain (d);break ;
xen/arch/x86/hvm/irq.c +33 -7
@@ -46,8 +46,18 @@if ( (hvm_irq->pci_link_assert_count[link]++ ==0 ) && isa_irq && (hvm_irq->gsi_assert_count[isa_irq]++ ==0 ) ) { -vioapic_irq_positive_edge (d, isa_irq); -vpic_irq_positive_edge (d, isa_irq); +if ( !is_hybrid_evtchn_enabled_domain (d) ) + { +vioapic_irq_positive_edge (d, isa_irq); +vpic_irq_positive_edge (d, isa_irq); + } +else + { +/* TODO fix the critical region here */ +spin_unlock (&d->arch.hvm_domain.irq_lock); +send_guest_global_virq (d,VIRQ_EMUL_PIN (isa_irq)); +spin_lock (&d->arch.hvm_domain.irq_lock); + } } }
@@ -76,8 +86,10 @@ link =hvm_pci_intx_link (device, intx); isa_irq = hvm_irq->pci_link.route[link];if ( (--hvm_irq->pci_link_assert_count[link] ==0 ) && isa_irq && - (--hvm_irq->gsi_assert_count[isa_irq] ==0 ) ) -vpic_irq_negative_edge (d, isa_irq); + (--hvm_irq->gsi_assert_count[isa_irq] ==0 ) ) { +if ( !is_hybrid_evtchn_enabled_domain (d) ) +vpic_irq_negative_edge (d, isa_irq); + } } void hvm_pci_intx_deassert(
@@ -93,6 +105,7 @@ {struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq); +int send_virq =0 ;ASSERT (isa_irq <=15 );
@@ -101,11 +114,21 @@if ( !__test_and_set_bit (isa_irq, &hvm_irq->isa_irq.i) && (hvm_irq->gsi_assert_count[gsi]++ ==0 ) ) { -vioapic_irq_positive_edge (d, gsi); -vpic_irq_positive_edge (d, isa_irq); +if ( !is_hybrid_evtchn_enabled_domain (d) ) + { +vioapic_irq_positive_edge (d, gsi); +vpic_irq_positive_edge (d, isa_irq); + } +else + { + send_virq =1 ; + } }spin_unlock (&d->arch.hvm_domain.irq_lock); + +if (send_virq) +send_guest_global_virq (d,VIRQ_EMUL_PIN (isa_irq)); } void hvm_isa_irq_deassert(
@@ -120,7 +143,10 @@if (__test_and_clear_bit (isa_irq, &hvm_irq->isa_irq.i) && (--hvm_irq->gsi_assert_count[gsi] ==0 ) ) -vpic_irq_negative_edge (d, isa_irq); + { +if ( !is_hybrid_evtchn_enabled_domain (d) ) +vpic_irq_negative_edge (d, isa_irq); + }spin_unlock (&d->arch.hvm_domain.irq_lock); }
xen/include/public/xen.h +6 -1
@@ -159,7 +159,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/* * MMU-UPDATE REQUESTS
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253088149 -28800
# Node ID 86c908c45ac908767b6b6bdbd9e8d863b34a84a8 # Parent 183fa85d47d9411e6e21c4534d8e231feeac96a7 Reserved E820 for hybrid gnttab support
tools/firmware/hvmloader/config.h +5 -1
@@ -16,8 +16,12 @@/* MMIO hole: Hardcoded defaults, which can be dynamically expanded. */ #define PCI_MEM_START 0xf0000000 -#define PCI_MEM_END 0xfc000000 +#define PCI_MEM_END 0xfbfe0000extern unsigned long pci_mem_start, pci_mem_end; + +/* Reserve 128KB for grant table */ +#define GNTTAB_MEMBASE 0xfbfe0000 +#define GNTTAB_MEMSIZE 0x20000/* We reserve 16MB for special BIOS mappings, etc. */ #define RESERVED_MEMBASE 0xfc000000
tools/firmware/hvmloader/hvmloader.c +6 -0
@@ -602,6 +602,12 @@ e820[nr].type =E820_RAM ; nr++; +/* Reserved for grant table */ + e820[nr].addr =GNTTAB_MEMBASE ; + e820[nr].size =GNTTAB_MEMSIZE ; + e820[nr].type =E820_RESERVED ; + nr++; +/* * Explicitly reserve space for special pages. * This space starts at RESERVED_MEMBASE an extends to cover various
# HG changeset patch
# User Sheng Yang <[email protected]>
# Date 1253088151 -28800
# Node ID 607b7ad0488a9db6202e0a6178027684ac0eb027 # Parent 86c908c45ac908767b6b6bdbd9e8d863b34a84a8 Enable event channel feature in CPUID for configuration file
xen/include/public/arch-x86/cpuid.h +3 -1
@@ -66,10 +66,12 @@#define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0)/* Mask unsupported CPUID specified by user */ -#define XEN_CPUID_FEAT2_MASK 0x3ul +#define XEN_CPUID_FEAT2_MASK 0x7ul#define _XEN_CPUID_FEAT2_HYBRID 0#define XEN_CPUID_FEAT2_HYBRID (1u<<0)#define _XEN_CPUID_FEAT2_HYBRID_TIMER 1#define XEN_CPUID_FEAT2_HYBRID_TIMER (1u<<1) +#define _XEN_CPUID_FEAT2_HYBRID_EVTCHN 2 +#define XEN_CPUID_FEAT2_HYBRID_EVTCHN (1u<<2)#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 4 lines · Frank van der Linden
I did not see the hypervisor part of these patches appear in my xen-devel inbox. Is this a problem on my end, or were they not sent to the list? If so, I'm interested in them, so it'd be great if they could be sent to the list.
They were sent to the list with the subject heading "Xen: Hybrid extension patchset for hypervisor".
-- Keir
Quoted 8 lines · On Thursday 17 September 2009 14:25:52 Keir Fraser wrote:
On 16/09/2009 20:11, "Frank van der Linden" <[email protected]>
Quoted 4 lines · wrote:
I did not see the hypervisor part of these patches appear in my xen-devel inbox. Is this a problem on my end, or were they not sent to the list? If so, I'm interested in them, so it'd be great if they could be sent to the list.
Quoted 4 lines
They were sent to the list with the subject heading "Xen: Hybrid extension patchset for hypervisor".
-- Keir
I found I can't find them(also the last one I sent, with attached patches) in the http://news.gmane.org/gmane.comp.emulators.xen.devel
Seems something bad happened in the mailserver? Try another mailbox...
Signature · 2 lines
regards Yang, Sheng
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253081544 -28800
# Node ID f92ed10b9522a4dd83a5e31f7f1a8c83bd33d70d # Parent e5d904a6c9e6e585ec02124dc8b6592f525ef6ba Add user controlled cpuid 0x40000002.edx
So that user can turn on/off hybrid feature through configuration file.
xen/arch/x86/traps.c +9 -0
@@ -659,6 +659,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 >2 )
@@ -689,6 +690,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 ;default :
xen/include/public/arch-x86/cpuid.h +3 -0
@@ -65,4 +65,7 @@#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 0x0ul +#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253085983 -28800
# Node ID 2d68b9d29b425f138345c7b9e0e8bc66b84c7ba1 # Parent f92ed10b9522a4dd83a5e31f7f1a8c83bd33d70d Add HVMOP_enable_hybrid hypercall
As the entry of hybrid.
xen/arch/x86/hvm/hvm.c +51 -6
81 lines not on this page · raw message
xen/include/public/arch-x86/cpuid.h +3 -1
@@ -66,6 +66,8 @@#define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0)/* Mask unsupported CPUID specified by user */ -#define XEN_CPUID_FEAT2_MASK 0x0ul +#define XEN_CPUID_FEAT2_MASK 0x1ul +#define _XEN_CPUID_FEAT2_HYBRID 0 +#define XEN_CPUID_FEAT2_HYBRID (1u<<0)#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
xen/include/public/hvm/hvm_op.h +7 -0
@@ -125,6 +125,13 @@typedef struct xen_hvm_set_mem_type xen_hvm_set_mem_type_t ;DEFINE_XEN_GUEST_HANDLE (xen_hvm_set_mem_type_t); +#define HVMOP_enable_hybrid 9 +struct xen_hvm_hybrid_type { +domid_t domid; +uint64_t flags; +#define HVM_HYBRID_TIMER (1ull<<1) +#define HVM_HYBRID_EVTCHN (1ull<<2) +};#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */
xen/include/xen/sched.h +11 -0
@@ -269,6 +269,11 @@/* VRAM dirty support. */ struct sh_dirty_vram *dirty_vram; + +#define XEN_HYBRID_ENABLED (1u << 0) +#define XEN_HYBRID_TIMER_ENABLED (1u << 1) +#define XEN_HYBRID_EVTCHN_ENABLED (1u << 2) +uint64_t hybrid_enabled; };struct domain_setup_info
@@ -551,6 +556,12 @@#define is_hvm_domain (d) ((d)->is_hvm)#define is_hvm_vcpu (v) (is_hvm_domain(v->domain))#define need_iommu (d) ((d)->need_iommu && !(d)->is_hvm) +#define is_hybrid_domain (d) ((d)->hybrid_enabled & XEN_HYBRID_ENABLED) +#define is_hybrid_vcpu (v) (is_hybrid_domain(v->domain)) +#define is_hybrid_timer_enabled_domain (d) (is_hybrid_domain(d) && \ + (d)->hybrid_enabled & XEN_HYBRID_TIMER_ENABLED) +#define is_hybrid_evtchn_enabled_domain (d) (is_hybrid_domain(d) && \ + (d)->hybrid_enabled & XEN_HYBRID_EVTCHN_ENABLED)void set_vcpu_migration_delay (unsigned int delay);unsigned int get_vcpu_migration_delay (void );
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253088144 -28800
# Node ID 91c520c2cefccc8c654839d9b38d04bd8801a391 # Parent 2d68b9d29b425f138345c7b9e0e8bc66b84c7ba1 Add pvtimer support for HVM
We need sync TSC with hypervisor, and update guest wallclock time if we want to enable pvtimer. The timer interrupt delivered through IRQ0.
xen/arch/x86/hvm/hvm.c +5 -0
@@ -2792,6 +2792,11 @@ d->hybrid_enabled =XEN_HYBRID_ENABLED ;printk ("HVM: Hybrid domain enabled\n" ); +if (a.flags &HVM_HYBRID_TIMER ) { + hvm_funcs.set_tsc_offset (d->vcpu[0 ],0 ); +update_domain_wallclock_time (d); + d->hybrid_enabled |=XEN_HYBRID_TIMER_ENABLED ; + } param_fail5:rcu_unlock_domain (d);break ;
xen/arch/x86/time.c +7 -0
@@ -30,6 +30,8 @@#include <asm/div64.h> #include <asm/hpet.h> #include <io_ports.h> + +#include <asm/hvm/irq.h> /* opt_clocksource: Force clocksource to one of: pit, hpet, cyclone, acpi. */ static char opt_clocksource[10 ];
@@ -1323,6 +1325,11 @@void send_timer_event (struct vcpu *v) {send_guest_vcpu_virq (v,VIRQ_TIMER ); +if (is_hybrid_timer_enabled_domain (v->domain) && + !is_hybrid_evtchn_enabled_domain (v->domain)) { +hvm_isa_irq_deassert (v->domain,0 ); +hvm_isa_irq_assert (v->domain,0 ); + } }/* Return secs after 00:00:00 localtime, 1 January, 1970. */
xen/include/public/arch-x86/cpuid.h +3 -1
@@ -66,8 +66,10 @@#define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0)/* Mask unsupported CPUID specified by user */ -#define XEN_CPUID_FEAT2_MASK 0x1ul +#define XEN_CPUID_FEAT2_MASK 0x3ul#define _XEN_CPUID_FEAT2_HYBRID 0#define XEN_CPUID_FEAT2_HYBRID (1u<<0) +#define _XEN_CPUID_FEAT2_HYBRID_TIMER 1 +#define XEN_CPUID_FEAT2_HYBRID_TIMER (1u<<1)#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253088147 -28800
# Node ID 78e51528eba7c5fd328c90acd4edc58ba46b58e8 # Parent 91c520c2cefccc8c654839d9b38d04bd8801a391 Add a new type of HVM callback
HVMIRQ_callback_vector specific one vector to trigger irq handler in the guest. And it don't need EOI action for it use IDT directly.
xen/arch/x86/hvm/irq.c +16 -1
@@ -165,6 +165,8 @@__hvm_pci_intx_assert (d, pdev, pintx); else__hvm_pci_intx_deassert (d ,pdev ,pintx ); +case HVMIRQ_callback_vector: +vcpu_kick (v);default :break ; }
@@ -251,7 +253,7 @@ via_type = (uint8_t )(via >>56 ) +1 ;if ( ((via_type == HVMIRQ_callback_gsi) && (via ==0 )) || - (via_type > HVMIRQ_callback_pci_intx) ) + (via_type > HVMIRQ_callback_vector) ) via_type = HVMIRQ_callback_none;spin_lock (&d->arch.hvm_domain.irq_lock);
@@ -297,6 +299,9 @@if ( hvm_irq->callback_via_asserted )__hvm_pci_intx_assert (d, pdev, pintx);break ; +case HVMIRQ_callback_vector: + hvm_irq->callback_via.vector = (uint8_t )via; +break ;default :break ; }
@@ -312,6 +317,10 @@case HVMIRQ_callback_pci_intx:printk ("PCI INTx Dev 0x%02x Int%c\n" , pdev,'A' + pintx);break ; +case HVMIRQ_callback_vector: +printk ("Set HVMIRQ_callback_vector to %u\n" , + hvm_irq->callback_via.vector); +break ;default :printk ("None\n" );break ;
@@ -322,6 +331,10 @@ {struct hvm_domain *plat = &v->domain->arch.hvm_domain;int vector; + +if (plat->irq.callback_via_type == HVMIRQ_callback_vector && +vcpu_info (v, evtchn_upcall_pending)) +return hvm_intack_vector (plat->irq.callback_via.vector);if (unlikely (v->nmi_pending) )return hvm_intack_nmi;
@@ -357,6 +370,8 @@case hvm_intsrc_lapic:if ( !vlapic_ack_pending_irq (v, intack.vector) ) intack = hvm_intack_none; +break ; +case hvm_intsrc_vector:break ;default : intack = hvm_intack_none;
xen/arch/x86/hvm/vmx/intr.c +2 -1
@@ -161,7 +161,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/include/asm-x86/hvm/hvm.h +3 -1
@@ -31,7 +31,8 @@ hvm_intsrc_none, hvm_intsrc_pic, hvm_intsrc_lapic, - hvm_intsrc_nmi + hvm_intsrc_nmi, + hvm_intsrc_vector, };struct hvm_intack {uint8_t source;/* enum hvm_intsrc */
@@ -41,6 +42,7 @@#define hvm_intack_pic (vec) ( (struct hvm_intack) { hvm_intsrc_pic, vec } )#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_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. */
# HG changeset patch
# User Sheng Yang <[email protected]>
# Date 1253088148 -28800
# Node ID 183fa85d47d9411e6e21c4534d8e231feeac96a7 # Parent 78e51528eba7c5fd328c90acd4edc58ba46b58e8 Enable event channel and QEmu device support for hybrid guest
Each VIRQ from 24 to 40 binding to a QEmu emulated pin, so that if device assert the pin, one VIRQ would be delivered to the guest instead.
xen/arch/x86/hvm/hvm.c +2 -0
@@ -2797,6 +2797,8 @@update_domain_wallclock_time (d); d->hybrid_enabled |=XEN_HYBRID_TIMER_ENABLED ; } +if (a.flags &HVM_HYBRID_EVTCHN ) + d->hybrid_enabled |=XEN_HYBRID_EVTCHN_ENABLED ; param_fail5:rcu_unlock_domain (d);break ;
xen/arch/x86/hvm/irq.c +33 -7
@@ -46,8 +46,18 @@if ( (hvm_irq->pci_link_assert_count[link]++ ==0 ) && isa_irq && (hvm_irq->gsi_assert_count[isa_irq]++ ==0 ) ) { -vioapic_irq_positive_edge (d, isa_irq); -vpic_irq_positive_edge (d, isa_irq); +if ( !is_hybrid_evtchn_enabled_domain (d) ) + { +vioapic_irq_positive_edge (d, isa_irq); +vpic_irq_positive_edge (d, isa_irq); + } +else + { +/* TODO fix the critical region here */ +spin_unlock (&d->arch.hvm_domain.irq_lock); +send_guest_global_virq (d,VIRQ_EMUL_PIN (isa_irq)); +spin_lock (&d->arch.hvm_domain.irq_lock); + } } }
@@ -76,8 +86,10 @@ link =hvm_pci_intx_link (device, intx); isa_irq = hvm_irq->pci_link.route[link];if ( (--hvm_irq->pci_link_assert_count[link] ==0 ) && isa_irq && - (--hvm_irq->gsi_assert_count[isa_irq] ==0 ) ) -vpic_irq_negative_edge (d, isa_irq); + (--hvm_irq->gsi_assert_count[isa_irq] ==0 ) ) { +if ( !is_hybrid_evtchn_enabled_domain (d) ) +vpic_irq_negative_edge (d, isa_irq); + } } void hvm_pci_intx_deassert(
@@ -93,6 +105,7 @@ {struct hvm_irq *hvm_irq = &d->arch.hvm_domain.irq;unsigned int gsi =hvm_isa_irq_to_gsi (isa_irq); +int send_virq =0 ;ASSERT (isa_irq <=15 );
@@ -101,11 +114,21 @@if ( !__test_and_set_bit (isa_irq, &hvm_irq->isa_irq.i) && (hvm_irq->gsi_assert_count[gsi]++ ==0 ) ) { -vioapic_irq_positive_edge (d, gsi); -vpic_irq_positive_edge (d, isa_irq); +if ( !is_hybrid_evtchn_enabled_domain (d) ) + { +vioapic_irq_positive_edge (d, gsi); +vpic_irq_positive_edge (d, isa_irq); + } +else + { + send_virq =1 ; + } }spin_unlock (&d->arch.hvm_domain.irq_lock); + +if (send_virq) +send_guest_global_virq (d,VIRQ_EMUL_PIN (isa_irq)); } void hvm_isa_irq_deassert(
@@ -120,7 +143,10 @@if (__test_and_clear_bit (isa_irq, &hvm_irq->isa_irq.i) && (--hvm_irq->gsi_assert_count[gsi] ==0 ) ) -vpic_irq_negative_edge (d, isa_irq); + { +if ( !is_hybrid_evtchn_enabled_domain (d) ) +vpic_irq_negative_edge (d, isa_irq); + }spin_unlock (&d->arch.hvm_domain.irq_lock); }
xen/include/public/xen.h +6 -1
@@ -159,7 +159,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/* * MMU-UPDATE REQUESTS
# HG changeset patch
# User Sheng Yang <[email protected]> # Date 1253088149 -28800
# Node ID 86c908c45ac908767b6b6bdbd9e8d863b34a84a8 # Parent 183fa85d47d9411e6e21c4534d8e231feeac96a7 Reserved E820 for hybrid gnttab support
tools/firmware/hvmloader/config.h +5 -1
@@ -16,8 +16,12 @@/* MMIO hole: Hardcoded defaults, which can be dynamically expanded. */ #define PCI_MEM_START 0xf0000000 -#define PCI_MEM_END 0xfc000000 +#define PCI_MEM_END 0xfbfe0000extern unsigned long pci_mem_start, pci_mem_end; + +/* Reserve 128KB for grant table */ +#define GNTTAB_MEMBASE 0xfbfe0000 +#define GNTTAB_MEMSIZE 0x20000/* We reserve 16MB for special BIOS mappings, etc. */ #define RESERVED_MEMBASE 0xfc000000
tools/firmware/hvmloader/hvmloader.c +6 -0
@@ -602,6 +602,12 @@ e820[nr].type =E820_RAM ; nr++; +/* Reserved for grant table */ + e820[nr].addr =GNTTAB_MEMBASE ; + e820[nr].size =GNTTAB_MEMSIZE ; + e820[nr].type =E820_RESERVED ; + nr++; +/* * Explicitly reserve space for special pages. * This space starts at RESERVED_MEMBASE an extends to cover various
# HG changeset patch
# User Sheng Yang <[email protected]>
# Date 1253088151 -28800
# Node ID 607b7ad0488a9db6202e0a6178027684ac0eb027 # Parent 86c908c45ac908767b6b6bdbd9e8d863b34a84a8 Enable event channel feature in CPUID for configuration file
xen/include/public/arch-x86/cpuid.h +3 -1
@@ -66,10 +66,12 @@#define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0)/* Mask unsupported CPUID specified by user */ -#define XEN_CPUID_FEAT2_MASK 0x3ul +#define XEN_CPUID_FEAT2_MASK 0x7ul#define _XEN_CPUID_FEAT2_HYBRID 0#define XEN_CPUID_FEAT2_HYBRID (1u<<0)#define _XEN_CPUID_FEAT2_HYBRID_TIMER 1#define XEN_CPUID_FEAT2_HYBRID_TIMER (1u<<1) +#define _XEN_CPUID_FEAT2_HYBRID_EVTCHN 2 +#define XEN_CPUID_FEAT2_HYBRID_EVTCHN (1u<<2)#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 7 lines · On Wednesday 16 September 2009 17:08:20 Keir Fraser wrote:
Quoted 5 lines · Sheng
Hi Keir & Jeremy
Here is the hypervisor part of hybrid extension support.
Please review, thanks!
Quoted 7 lines
The principle is okay I guess. These changes would have to be trickled in with a really good explanation and justification for each one.
For
example, I'm not clear why the enable-hybrid hypercall is needed. Why not just provide access to evtchn and timer hypercalls always, and guest sues them if it is capable of it?
We have purposed a component independence approach, that means user can enable PV timer or evtchn separately. Currently we have some limit with event channel implementation, e.g. no passthrough device support, and SMP is also not ready at this time(but in progress). (And I think there would be some version issue later, if we support more features).
The enable-hybrid hypercall is there because we can do adjust some hypervisor behaviour if we know guest would be hybrid rather than hvm or pv. For example, HVM assume TSC is start from 0, but pv timer assume TSC is no different with native. So we need modify tsc offset to 0 to make pv timer work. And we may also do some optimization in hypervisor if we know that guest is hybrid rather than hvm/pv.
Quoted 3 lines
I'm also not sure why PV timer events get
routed to irq0 -- why not via an event channel as usual, now that you are enabling HVM guests to use the evtchn subsystem?
As stated above, we support a mode that using PV timer without event channel. But I am thinking maybe we can let evtchn co-exist with IOAPIC/LAPIC, then pv timer use evtchn, others goes to normal hardware way. And another feature can replace IOAPIC/LAPIC with evtchn.
Quoted 2 lines
What's a hybrid gnttab,
and why does it need an explciit reserved e820 region? And so on.
We need some memory to map gnttab. It was provided by a QEmu emulated device in HVM, but we think it's not elegant that a basic feature depends on a device, so we got this e820 region...
Quoted 3 lines
The general principle of these patches seems to be to create a set of individual, and perhaps largely independent, accelerations/enlightenments to the HVM interface. I can at least agree with and support that aim.
Thanks. :)
Signature · 2 lines
regards Yang, Sheng
Quoted 2 lines
-- Keir