Sheng Yang
2010-Mar-12 02:57 UTC
[Xen-devel] [PATCH][v9 0/6] PV extension of HVM (Hybrid) for Xen
The 9th version of patchset to enable PV extension of HVM support in Linux kernel of Xen. The patch based on upstream 2.6.32. The PV extension of HVM is started from real mode like HVM guest, but also with a a range of PV features(e.g. PV timer now, and event channel, PV drivers in the future). So guest with this feature can takes the advantages of both H/W virtualization and Para-Virtualization. The first two of the patchset imported several header file from Jeremy''s tree and Xen tree, respect to Jeremy and Keir''s works. The whole patchset based on Linux upstream. You need a line like: cpuid = [ ''0x40000002:edx=0x7'' ] in HVM configuration file to expose all PV feature to guest, and CONFIG_XEN in the guest kernel configuration file to enable the PV extension support. It would implicit enable CONFIG_XEN_HVM_PV if CONFIG_X86_64 is selected as well. And the compiled image can be used as native/pv domU/hvm guest/pv feature hvm kernel. Change from v8: 1. Delay the controversial part of evtchn. 2. Rebase to 2.6.32 so it can be picked up by Jeremy for more test easily. Change from v7: 1. Move evtchn related macro to patch 7. So that the patch 1-6 can be cleanly applied. Change from v6: 1. Make PV clocksource as a separate feature rather than default one. Notice PV evtchn still depends on it. 2. Some comments update. Change from v5: Update the comments from Jeremy. Change from v4: 1. Add a new CONFIG_XEN_HVM_PV to enable the feature in kernel 2. Separate the related code form enlighted.c to hvmpv.c 3. Separate the feature "PV clocksource" from evtchn. Now we can support HVM guest with PV clocksource. This would be enabled by default. 4. Drop PV halt and pv drivers in this edition. We can work on that later. 5. Update the patchset following Jeremy''s comments. Change from v3: 1. Rebase to Linux 2.6.33 release. 2. change the name to "PV extension of HVM" 3. Some minor coding polishing. Change from v2: 1. change the name "hybrid" to "PV featured HVM". 2. Unified the PV driver''s judgement of xen_domain() to xen_evtchn_enabled(). 3. Move the function(evtchn) initialize hypercall near the real enabling place, rather than a unified place before function enabled. 4. Remove the reserved E820 region for grant table. Use QEmu Xen platform device''s MMIO instead. The major change from v1: 1. SMP support. 2. Modify the entrance point to avoid most of genernic kernel modification. 3. Binding PV timer with event channel mechanism. -- regards Yang, Sheng Jeremy Fitzhardinge (1): xen: add support for hvm_op Keir Fraser (1): xen: Import cpuid.h from Xen Sheng Yang (5): xen: Make pv drivers only work with xen_pv_domain() xen/hvm: Xen PV extension of HVM initialization x86/xen: The entrance for PV extension of HVM xen: Enable PV clocksource for HVM xen: Enable event channel of PV extension of HVM arch/x86/include/asm/xen/cpuid.h | 75 +++++++++++ arch/x86/include/asm/xen/hypercall.h | 6 + arch/x86/include/asm/xen/hypervisor.h | 6 + arch/x86/kernel/setup.c | 4 + arch/x86/xen/Kconfig | 4 + arch/x86/xen/Makefile | 1 + arch/x86/xen/enlighten.c | 6 +- arch/x86/xen/hvmpv.c | 228 +++++++++++++++++++++++++++++++++ arch/x86/xen/irq.c | 9 ++ arch/x86/xen/smp.c | 76 +++++++++++- arch/x86/xen/time.c | 12 ++- arch/x86/xen/xen-ops.h | 17 +++ drivers/block/xen-blkfront.c | 2 +- drivers/input/xen-kbdfront.c | 2 +- drivers/net/xen-netfront.c | 2 +- drivers/video/xen-fbfront.c | 2 +- drivers/xen/events.c | 74 ++++++++++- drivers/xen/grant-table.c | 2 +- drivers/xen/xenbus/xenbus_probe.c | 4 +- include/xen/events.h | 4 + include/xen/hvm.h | 28 ++++ include/xen/interface/hvm/hvm_op.h | 80 ++++++++++++ include/xen/interface/hvm/params.h | 111 ++++++++++++++++ include/xen/interface/xen.h | 6 +- include/xen/xen.h | 15 ++ 25 files changed, 754 insertions(+), 22 deletions(-) create mode 100644 arch/x86/include/asm/xen/cpuid.h create mode 100644 arch/x86/xen/hvmpv.c create mode 100644 include/xen/hvm.h create mode 100644 include/xen/interface/hvm/hvm_op.h create mode 100644 include/xen/interface/hvm/params.h _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Add support for hvm_op hypercall. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Signed-off-by: Sheng Yang <sheng@linux.intel.com> --- arch/x86/include/asm/xen/hypercall.h | 6 ++ include/xen/hvm.h | 23 +++++++ include/xen/interface/hvm/hvm_op.h | 72 ++++++++++++++++++++++ include/xen/interface/hvm/params.h | 111 ++++++++++++++++++++++++++++++++++ 4 files changed, 212 insertions(+), 0 deletions(-) create mode 100644 include/xen/hvm.h create mode 100644 include/xen/interface/hvm/hvm_op.h create mode 100644 include/xen/interface/hvm/params.h diff --git a/arch/x86/include/asm/xen/hypercall.h b/arch/x86/include/asm/xen/hypercall.h index 9c371e4..47c2ebb 100644 --- a/arch/x86/include/asm/xen/hypercall.h +++ b/arch/x86/include/asm/xen/hypercall.h @@ -417,6 +417,12 @@ HYPERVISOR_nmi_op(unsigned long op, unsigned long arg) return _hypercall2(int, nmi_op, op, arg); } +static inline unsigned long __must_check +HYPERVISOR_hvm_op(int op, void *arg) +{ + return _hypercall2(unsigned long, hvm_op, op, arg); +} + static inline void MULTI_fpu_taskswitch(struct multicall_entry *mcl, int set) { diff --git a/include/xen/hvm.h b/include/xen/hvm.h new file mode 100644 index 0000000..4ea8887 --- /dev/null +++ b/include/xen/hvm.h @@ -0,0 +1,23 @@ +/* Simple wrappers around HVM functions */ +#ifndef XEN_HVM_H__ +#define XEN_HVM_H__ + +#include <xen/interface/hvm/params.h> + +static inline unsigned long hvm_get_parameter(int idx) +{ + struct xen_hvm_param xhv; + int r; + + xhv.domid = DOMID_SELF; + xhv.index = idx; + r = HYPERVISOR_hvm_op(HVMOP_get_param, &xhv); + if (r < 0) { + printk(KERN_ERR "cannot get hvm parameter %d: %d.\n", + idx, r); + return 0; + } + return xhv.value; +} + +#endif /* XEN_HVM_H__ */ diff --git a/include/xen/interface/hvm/hvm_op.h b/include/xen/interface/hvm/hvm_op.h new file mode 100644 index 0000000..7c74ba4 --- /dev/null +++ b/include/xen/interface/hvm/hvm_op.h @@ -0,0 +1,72 @@ +/* + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef __XEN_PUBLIC_HVM_HVM_OP_H__ +#define __XEN_PUBLIC_HVM_HVM_OP_H__ + +/* Get/set subcommands: extra argument == pointer to xen_hvm_param struct. */ +#define HVMOP_set_param 0 +#define HVMOP_get_param 1 +struct xen_hvm_param { + domid_t domid; /* IN */ + uint32_t index; /* IN */ + uint64_t value; /* IN/OUT */ +}; +DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_param); + +/* Set the logical level of one of a domain''s PCI INTx wires. */ +#define HVMOP_set_pci_intx_level 2 +struct xen_hvm_set_pci_intx_level { + /* Domain to be updated. */ + domid_t domid; + /* PCI INTx identification in PCI topology (domain:bus:device:intx). */ + uint8_t domain, bus, device, intx; + /* Assertion level (0 = unasserted, 1 = asserted). */ + uint8_t level; +}; +DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_set_pci_intx_level); + +/* Set the logical level of one of a domain''s ISA IRQ wires. */ +#define HVMOP_set_isa_irq_level 3 +struct xen_hvm_set_isa_irq_level { + /* Domain to be updated. */ + domid_t domid; + /* ISA device identification, by ISA IRQ (0-15). */ + uint8_t isa_irq; + /* Assertion level (0 = unasserted, 1 = asserted). */ + uint8_t level; +}; +DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_set_isa_irq_level); + +#define HVMOP_set_pci_link_route 4 +struct xen_hvm_set_pci_link_route { + /* Domain to be updated. */ + domid_t domid; + /* PCI link identifier (0-3). */ + uint8_t link; + /* ISA IRQ (1-15), or 0 (disable link). */ + uint8_t isa_irq; +}; +DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_set_pci_link_route); + +/* Flushes all VCPU TLBs: @arg must be NULL. */ +#define HVMOP_flush_tlbs 5 + +#endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */ diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h new file mode 100644 index 0000000..15d828f --- /dev/null +++ b/include/xen/interface/hvm/params.h @@ -0,0 +1,111 @@ +/* + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef __XEN_PUBLIC_HVM_PARAMS_H__ +#define __XEN_PUBLIC_HVM_PARAMS_H__ + +#include "hvm_op.h" + +/* + * Parameter space for HVMOP_{set,get}_param. + */ + +/* + * How should CPU0 event-channel notifications be delivered? + * val[63:56] == 0: val[55:0] is a delivery GSI (Global System Interrupt). + * val[63:56] == 1: val[55:0] is a delivery PCI INTx line, as follows: + * Domain = val[47:32], Bus = val[31:16], + * DevFn = val[15: 8], IntX = val[ 1: 0] + * If val == 0 then CPU0 event-channel notifications are not delivered. + */ +#define HVM_PARAM_CALLBACK_IRQ 0 + +/* + * These are not used by Xen. They are here for convenience of HVM-guest + * xenbus implementations. + */ +#define HVM_PARAM_STORE_PFN 1 +#define HVM_PARAM_STORE_EVTCHN 2 + +#define HVM_PARAM_PAE_ENABLED 4 + +#define HVM_PARAM_IOREQ_PFN 5 + +#define HVM_PARAM_BUFIOREQ_PFN 6 + +#ifdef __ia64__ + +#define HVM_PARAM_NVRAM_FD 7 +#define HVM_PARAM_VHPT_SIZE 8 +#define HVM_PARAM_BUFPIOREQ_PFN 9 + +#elif defined(__i386__) || defined(__x86_64__) + +/* Expose Viridian interfaces to this HVM guest? */ +#define HVM_PARAM_VIRIDIAN 9 + +#endif + +/* + * Set mode for virtual timers (currently x86 only): + * delay_for_missed_ticks (default): + * Do not advance a vcpu''s time beyond the correct delivery time for + * interrupts that have been missed due to preemption. Deliver missed + * interrupts when the vcpu is rescheduled and advance the vcpu''s virtual + * time stepwise for each one. + * no_delay_for_missed_ticks: + * As above, missed interrupts are delivered, but guest time always tracks + * wallclock (i.e., real) time while doing so. + * no_missed_ticks_pending: + * No missed interrupts are held pending. Instead, to ensure ticks are + * delivered at some non-zero rate, if we detect missed ticks then the + * internal tick alarm is not disabled if the VCPU is preempted during the + * next tick period. + * one_missed_tick_pending: + * Missed interrupts are collapsed together and delivered as one ''late tick''. + * Guest time always tracks wallclock (i.e., real) time. + */ +#define HVM_PARAM_TIMER_MODE 10 +#define HVMPTM_delay_for_missed_ticks 0 +#define HVMPTM_no_delay_for_missed_ticks 1 +#define HVMPTM_no_missed_ticks_pending 2 +#define HVMPTM_one_missed_tick_pending 3 + +/* Boolean: Enable virtual HPET (high-precision event timer)? (x86-only) */ +#define HVM_PARAM_HPET_ENABLED 11 + +/* Identity-map page directory used by Intel EPT when CR0.PG=0. */ +#define HVM_PARAM_IDENT_PT 12 + +/* Device Model domain, defaults to 0. */ +#define HVM_PARAM_DM_DOMAIN 13 + +/* ACPI S state: currently support S0 and S3 on x86. */ +#define HVM_PARAM_ACPI_S_STATE 14 + +/* TSS used on Intel when CR0.PE=0. */ +#define HVM_PARAM_VM86_TSS 15 + +/* Boolean: Enable aligning all periodic vpts to reduce interrupts */ +#define HVM_PARAM_VPT_ALIGN 16 + +#define HVM_NR_PARAMS 17 + +#endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */ -- 1.7.0.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
From: Keir Fraser <keir.fraser@citrix.com> Which would be used by CPUID detection later Signed-off-by: Keir Fraser <keir.fraser@citrix.com> Signed-off-by: Sheng Yang <sheng@linux.intel.com> --- arch/x86/include/asm/xen/cpuid.h | 68 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 68 insertions(+), 0 deletions(-) create mode 100644 arch/x86/include/asm/xen/cpuid.h diff --git a/arch/x86/include/asm/xen/cpuid.h b/arch/x86/include/asm/xen/cpuid.h new file mode 100644 index 0000000..8787f03 --- /dev/null +++ b/arch/x86/include/asm/xen/cpuid.h @@ -0,0 +1,68 @@ +/****************************************************************************** + * arch/include/asm/xen/cpuid.h + * + * CPUID interface to Xen. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2007 Citrix Systems, Inc. + * + * Authors: + * Keir Fraser <keir.fraser@citrix.com> + */ + +#ifndef __ASM_X86_XEN_CPUID_H__ +#define __ASM_X86_XEN_CPUID_H__ + +/* Xen identification leaves start at 0x40000000. */ +#define XEN_CPUID_FIRST_LEAF 0x40000000 +#define XEN_CPUID_LEAF(i) (XEN_CPUID_FIRST_LEAF + (i)) + +/* + * Leaf 1 (0x40000000) + * EAX: Largest Xen-information leaf. All leaves up to an including @EAX + * are supported by the Xen host. + * EBX-EDX: "XenVMMXenVMM" signature, allowing positive identification + * of a Xen host. + */ +#define XEN_CPUID_SIGNATURE_EBX 0x566e6558 /* "XenV" */ +#define XEN_CPUID_SIGNATURE_ECX 0x65584d4d /* "MMXe" */ +#define XEN_CPUID_SIGNATURE_EDX 0x4d4d566e /* "nVMM" */ + +/* + * Leaf 2 (0x40000001) + * EAX[31:16]: Xen major version. + * EAX[15: 0]: Xen minor version. + * EBX-EDX: Reserved (currently all zeroes). + */ + +/* + * Leaf 3 (0x40000002) + * EAX: Number of hypercall transfer pages. This register is always guaranteed + * to specify one hypercall page. + * EBX: Base address of Xen-specific MSRs. + * ECX: Features 1. Unused bits are set to zero. + * EDX: Features 2. Unused bits are set to zero. + */ + +/* Does the host support MMU_PT_UPDATE_PRESERVE_AD for this guest? */ +#define _XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD 0 +#define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0) + +#endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */ -- 1.7.0.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Sheng Yang
2010-Mar-12 02:57 UTC
[Xen-devel] [PATCH][v9 3/6] xen: Make pv drivers only work with xen_pv_domain()
Otherwise they would still try to enable with HVM domain type. Signed-off-by: Sheng Yang <sheng@linux.intel.com> --- drivers/block/xen-blkfront.c | 2 +- drivers/input/xen-kbdfront.c | 2 +- drivers/net/xen-netfront.c | 2 +- drivers/video/xen-fbfront.c | 2 +- drivers/xen/grant-table.c | 2 +- drivers/xen/xenbus/xenbus_probe.c | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index b8578bb..f2f4d4e 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -1067,7 +1067,7 @@ static struct xenbus_driver blkfront = { static int __init xlblk_init(void) { - if (!xen_domain()) + if (!xen_pv_domain()) return -ENODEV; if (register_blkdev(XENVBD_MAJOR, DEV_NAME)) { diff --git a/drivers/input/xen-kbdfront.c b/drivers/input/xen-kbdfront.c index b115726..8ec2201 100644 --- a/drivers/input/xen-kbdfront.c +++ b/drivers/input/xen-kbdfront.c @@ -335,7 +335,7 @@ static struct xenbus_driver xenkbd_driver = { static int __init xenkbd_init(void) { - if (!xen_domain()) + if (!xen_pv_domain()) return -ENODEV; /* Nothing to do if running in dom0. */ diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index baa051d..6132286 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -1803,7 +1803,7 @@ static struct xenbus_driver netfront_driver = { static int __init netif_init(void) { - if (!xen_domain()) + if (!xen_pv_domain()) return -ENODEV; if (xen_initial_domain()) diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c index 54cd916..450f958 100644 --- a/drivers/video/xen-fbfront.c +++ b/drivers/video/xen-fbfront.c @@ -680,7 +680,7 @@ static struct xenbus_driver xenfb_driver = { static int __init xenfb_init(void) { - if (!xen_domain()) + if (!xen_pv_domain()) return -ENODEV; /* Nothing to do if running in dom0. */ diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 7d8f531..f6d9b8c 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c @@ -509,7 +509,7 @@ static int __devinit gnttab_init(void) unsigned int max_nr_glist_frames, nr_glist_frames; unsigned int nr_init_grefs; - if (!xen_domain()) + if (!xen_pv_domain()) return -ENODEV; nr_grant_frames = 1; diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index d42e25d..bce893e 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -784,7 +784,7 @@ static int __init xenbus_probe_init(void) DPRINTK(""); err = -ENODEV; - if (!xen_domain()) + if (!xen_pv_domain()) goto out_error; /* Register ourselves with the kernel bus subsystem */ @@ -915,7 +915,7 @@ static void wait_for_devices(struct xenbus_driver *xendrv) unsigned long timeout = jiffies + 10*HZ; struct device_driver *drv = xendrv ? &xendrv->driver : NULL; - if (!ready_to_wait_for_devices || !xen_domain()) + if (!ready_to_wait_for_devices || !xen_pv_domain()) return; while (exists_disconnected_device(drv)) { -- 1.7.0.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Sheng Yang
2010-Mar-12 02:57 UTC
[Xen-devel] [PATCH][v9 4/6] xen/hvm: Xen PV extension of HVM initialization
The PV extended HVM(once known as Hybrid) is started from real mode like HVM guest, but also with a component based PV feature selection(e.g. PV halt, PV timer, event channel, then PV drivers). So guest can takes the advantages of both H/W virtualization and Para-Virtualization. This patch introduced the PV extension of HVM guest initialization. Guest would detect the capability using CPUID 0x40000002.edx, then call HVMOP_enable_pv hypercall to enable pv support in hypervisor. Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Yaozu (Eddie) Dong <eddie.dong@intel.com> --- arch/x86/include/asm/xen/cpuid.h | 5 + arch/x86/include/asm/xen/hypervisor.h | 12 +++ arch/x86/xen/Kconfig | 4 + arch/x86/xen/Makefile | 1 + arch/x86/xen/hvmpv.c | 135 +++++++++++++++++++++++++++++++++ include/xen/interface/hvm/hvm_op.h | 8 ++ 6 files changed, 165 insertions(+), 0 deletions(-) create mode 100644 arch/x86/xen/hvmpv.c diff --git a/arch/x86/include/asm/xen/cpuid.h b/arch/x86/include/asm/xen/cpuid.h index 8787f03..b3a0b3a 100644 --- a/arch/x86/include/asm/xen/cpuid.h +++ b/arch/x86/include/asm/xen/cpuid.h @@ -65,4 +65,9 @@ #define _XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD 0 #define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0) +#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) + #endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */ diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h index d5b7e90..7569f64 100644 --- a/arch/x86/include/asm/xen/hypervisor.h +++ b/arch/x86/include/asm/xen/hypervisor.h @@ -55,6 +55,18 @@ extern enum xen_domain_type xen_domain_type; #define xen_hvm_domain() (xen_domain() && \ xen_domain_type == XEN_HVM_DOMAIN) +#ifdef CONFIG_XEN_HVM_PV + +#define XEN_HVM_PV_CLOCK_ENABLED (1u << 0) +#define XEN_HVM_PV_EVTCHN_ENABLED (1u << 1) +extern u32 xen_hvm_pv_features; + +#define xen_hvm_pv_clock_enabled() \ + (xen_hvm_pv_features & XEN_HVM_PV_CLOCK_ENABLED) +#else +#define xen_hvm_pv_clock_enabled() 0 +#endif /* CONFIG_XEN_HVM_PV */ + #ifdef CONFIG_XEN_DOM0 #include <xen/interface/xen.h> diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig index b83e119..74fc233 100644 --- a/arch/x86/xen/Kconfig +++ b/arch/x86/xen/Kconfig @@ -36,3 +36,7 @@ config XEN_DEBUG_FS help Enable statistics output and various tuning options in debugfs. Enabling this option may incur a significant performance overhead. + +config XEN_HVM_PV + def_bool y + depends on XEN && X86_64 diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile index 3bb4fc2..73bd5db 100644 --- a/arch/x86/xen/Makefile +++ b/arch/x86/xen/Makefile @@ -17,4 +17,5 @@ obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \ obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= spinlock.o obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o +obj-$(CONFIG_XEN_HVM_PV) += hvmpv.o diff --git a/arch/x86/xen/hvmpv.c b/arch/x86/xen/hvmpv.c new file mode 100644 index 0000000..a24a1e9 --- /dev/null +++ b/arch/x86/xen/hvmpv.c @@ -0,0 +1,135 @@ +/* + * PV extension of HVM implementation. + * + * Sheng Yang <sheng@linux.intel.com>, Intel Corporation, 2010 + * + */ +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/percpu.h> +#include <linux/module.h> + +#include <xen/features.h> +#include <xen/events.h> +#include <xen/hvm.h> +#include <xen/interface/xen.h> +#include <xen/interface/version.h> +#include <xen/interface/memory.h> + +#include <asm/xen/cpuid.h> +#include <asm/xen/hypercall.h> +#include <asm/xen/hypervisor.h> + +#include "xen-ops.h" + +u32 xen_hvm_pv_features; +EXPORT_SYMBOL_GPL(xen_hvm_pv_features); + +static const struct pv_info xen_hvm_pv_info __initdata = { + .paravirt_enabled = 1, + .shared_kernel_pmd = 0, + .kernel_rpl = 0, + .name = "Xen", +}; + +static void __init xen_hvm_pv_banner(void) +{ + unsigned version = HYPERVISOR_xen_version(XENVER_version, NULL); + struct xen_extraversion extra; + HYPERVISOR_xen_version(XENVER_extraversion, &extra); + + printk(KERN_INFO "Booting PV extended HVM kernel on %s\n", + pv_info.name); + printk(KERN_INFO "Xen version: %d.%d%s\n", + version >> 16, version & 0xffff, extra.extraversion); +} + +static int __init xen_para_available(void) +{ + uint32_t eax, ebx, ecx, edx; + cpuid(XEN_CPUID_LEAF(0), &eax, &ebx, &ecx, &edx); + + if (ebx == XEN_CPUID_SIGNATURE_EBX && + ecx == XEN_CPUID_SIGNATURE_ECX && + edx == XEN_CPUID_SIGNATURE_EDX && + ((eax - XEN_CPUID_LEAF(0)) >= 2)) + return 1; + + return 0; +} + +static int __init enable_hvm_pv(u64 flags) +{ + struct xen_hvm_pv_type a; + + a.flags = flags; + return HYPERVISOR_hvm_op(HVMOP_enable_pv, &a); +} + +static int __init init_hvm_pv_info(void) +{ + uint32_t ecx, edx, pages, msr; + u64 pfn; + + if (!xen_para_available()) + return -EINVAL; + + cpuid(XEN_CPUID_LEAF(2), &pages, &msr, &ecx, &edx); + + /* Check if hvm_pv mode is supported */ + if (!(edx & XEN_CPUID_FEAT2_HVM_PV)) + return -ENODEV; + + if (pages < 1) + return -ENODEV; + + pfn = __pa(hypercall_page); + if (wrmsr_safe(msr, (u32)pfn, ((u64)pfn) >> 32)) + return -ENODEV; + + return 0; +} + +static struct shared_info shared_info_page __page_aligned_bss; + +static int __init init_shared_info(void) +{ + struct xen_add_to_physmap xatp; + + xatp.domid = DOMID_SELF; + xatp.idx = 0; + xatp.space = XENMAPSPACE_shared_info; + xatp.gpfn = __pa(&shared_info_page) >> PAGE_SHIFT; + if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp)) + return -EINVAL; + + HYPERVISOR_shared_info = (struct shared_info *)&shared_info_page; + + per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0]; + + return 0; +} + +void __init xen_guest_init(void) +{ + int r; + + /* Ensure the we won''t confused with others */ + if (xen_domain()) + return; + + r = init_hvm_pv_info(); + if (r < 0) + return; + + r = init_shared_info(); + if (r < 0) + return; + + xen_setup_features(); + + x86_init.oem.banner = xen_hvm_pv_banner; + pv_info = xen_hvm_pv_info; + + xen_domain_type = XEN_HVM_DOMAIN; +} diff --git a/include/xen/interface/hvm/hvm_op.h b/include/xen/interface/hvm/hvm_op.h index 7c74ba4..d229b50 100644 --- a/include/xen/interface/hvm/hvm_op.h +++ b/include/xen/interface/hvm/hvm_op.h @@ -69,4 +69,12 @@ DEFINE_GUEST_HANDLE_STRUCT(xen_hvm_set_pci_link_route); /* Flushes all VCPU TLBs: @arg must be NULL. */ #define HVMOP_flush_tlbs 5 +/* Enable PV extended HVM features. Should called by BSP */ +#define HVMOP_enable_pv 9 +struct xen_hvm_pv_type { + /* The features want to be enabled */ + uint32_t flags; +#define HVM_PV_CLOCK (1ull<<0) +}; + #endif /* __XEN_PUBLIC_HVM_HVM_OP_H__ */ -- 1.7.0.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Sheng Yang
2010-Mar-12 02:57 UTC
[Xen-devel] [PATCH][v9 5/6] x86/xen: The entrance for PV extension of HVM
xen_guest_init() would setup the environment. Signed-off-by: Sheng Yang <sheng@linux.intel.com> --- arch/x86/include/asm/xen/hypervisor.h | 6 ++++++ arch/x86/kernel/setup.c | 4 ++++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h index 7569f64..f7d61a5 100644 --- a/arch/x86/include/asm/xen/hypervisor.h +++ b/arch/x86/include/asm/xen/hypervisor.h @@ -76,4 +76,10 @@ extern u32 xen_hvm_pv_features; #define xen_initial_domain() (0) #endif /* CONFIG_XEN_DOM0 */ +#ifdef CONFIG_XEN_HVM_PV +void xen_guest_init(void); +#else +static inline void xen_guest_init(void) {}; +#endif + #endif /* _ASM_X86_XEN_HYPERVISOR_H */ diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 2a34f9c..9bfb8ce 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -110,6 +110,8 @@ #include <asm/numa_64.h> #endif +#include <asm/xen/hypervisor.h> + /* * end_pfn only includes RAM, while max_pfn_mapped includes all e820 entries. * The direct mapping extends to max_pfn_mapped, so that we can directly access @@ -753,6 +755,8 @@ void __init setup_arch(char **cmdline_p) x86_init.oem.arch_setup(); + xen_guest_init(); + setup_memory_map(); parse_setup_data(); /* update the e820_saved too */ -- 1.7.0.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Sheng Yang
2010-Mar-12 02:57 UTC
[Xen-devel] [PATCH][v9 6/6] xen: Enable PV clocksource for HVM
PV clocksource can provide a reliable clocksource for HVM running on Xen. To enable it, put following line to the HVM configure file: cpuid = [ ''0x40000002:edx=0x3'' ] It would set bit 0 and bit 1 in 0x40000002:edx, which enable PV extension framework and PV clocksource. Signed-off-by: Sheng Yang <sheng@linux.intel.com> --- arch/x86/xen/hvmpv.c | 24 ++++++++++++++++++++++++ arch/x86/xen/time.c | 12 +++++++++++- arch/x86/xen/xen-ops.h | 1 + 3 files changed, 36 insertions(+), 1 deletions(-) diff --git a/arch/x86/xen/hvmpv.c b/arch/x86/xen/hvmpv.c index a24a1e9..1961cf0 100644 --- a/arch/x86/xen/hvmpv.c +++ b/arch/x86/xen/hvmpv.c @@ -42,6 +42,8 @@ static void __init xen_hvm_pv_banner(void) pv_info.name); printk(KERN_INFO "Xen version: %d.%d%s\n", version >> 16, version & 0xffff, extra.extraversion); + if (xen_hvm_pv_clock_enabled()) + printk(KERN_INFO "PV feature: PV clocksource enabled\n"); } static int __init xen_para_available(void) @@ -80,6 +82,9 @@ static int __init init_hvm_pv_info(void) if (!(edx & XEN_CPUID_FEAT2_HVM_PV)) return -ENODEV; + if (edx & XEN_CPUID_FEAT2_HVM_PV_CLOCK) + xen_hvm_pv_features |= XEN_HVM_PV_CLOCK_ENABLED; + if (pages < 1) return -ENODEV; @@ -110,6 +115,23 @@ static int __init init_shared_info(void) return 0; } +static void __init init_pv_clocksource(void) +{ + if (!xen_hvm_pv_clock_enabled()) + return; + + if (enable_hvm_pv(HVM_PV_CLOCK)) + BUG(); + + pv_time_ops.sched_clock = xen_sched_clock; + + x86_platform.calibrate_tsc = xen_tsc_khz; + x86_platform.get_wallclock = xen_get_wallclock; + x86_platform.set_wallclock = xen_set_wallclock; + + xen_register_clocksource(); +} + void __init xen_guest_init(void) { int r; @@ -132,4 +154,6 @@ void __init xen_guest_init(void) pv_info = xen_hvm_pv_info; xen_domain_type = XEN_HVM_DOMAIN; + + init_pv_clocksource(); } diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c index 0a5aa44..d1c1c50 100644 --- a/arch/x86/xen/time.c +++ b/arch/x86/xen/time.c @@ -474,11 +474,21 @@ void xen_timer_resume(void) } } +static bool xen_clocksource_enabled; + +void xen_register_clocksource(void) +{ + if (!xen_clocksource_enabled) { + clocksource_register(&xen_clocksource); + xen_clocksource_enabled = 1; + } +} + __init void xen_time_init(void) { int cpu = smp_processor_id(); - clocksource_register(&xen_clocksource); + xen_register_clocksource(); if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL) == 0) { /* Successfully turned off 100Hz tick, so we have the diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index 355fa6b..2aeaf51 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h @@ -46,6 +46,7 @@ cycle_t xen_clocksource_read(void); void xen_setup_cpu_clockevents(void); unsigned long xen_tsc_khz(void); void __init xen_time_init(void); +void xen_register_clocksource(void); unsigned long xen_get_wallclock(void); int xen_set_wallclock(unsigned long time); unsigned long long xen_sched_clock(void); -- 1.7.0.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2010-Mar-12 20:35 UTC
Re: [Xen-devel] [PATCH][v9 4/6] xen/hvm: Xen PV extension of HVM initialization
On 03/11/2010 06:57 PM, Sheng Yang wrote:> The PV extended HVM(once known as Hybrid) is started from real mode like > HVM guest, but also with a component based PV feature selection(e.g. PV halt, > PV timer, event channel, then PV drivers). So guest can takes the advantages > of both H/W virtualization and Para-Virtualization. > > This patch introduced the PV extension of HVM guest initialization. > > Guest would detect the capability using CPUID 0x40000002.edx, then call > HVMOP_enable_pv hypercall to enable pv support in hypervisor. > > Signed-off-by: Sheng Yang<sheng@linux.intel.com> > Signed-off-by: Yaozu (Eddie) Dong<eddie.dong@intel.com> > --- > arch/x86/include/asm/xen/cpuid.h | 5 + > arch/x86/include/asm/xen/hypervisor.h | 12 +++ > arch/x86/xen/Kconfig | 4 + > arch/x86/xen/Makefile | 1 + > arch/x86/xen/hvmpv.c | 135 +++++++++++++++++++++++++++++++++ > include/xen/interface/hvm/hvm_op.h | 8 ++ > 6 files changed, 165 insertions(+), 0 deletions(-) > create mode 100644 arch/x86/xen/hvmpv.c > > diff --git a/arch/x86/include/asm/xen/cpuid.h b/arch/x86/include/asm/xen/cpuid.h > index 8787f03..b3a0b3a 100644 > --- a/arch/x86/include/asm/xen/cpuid.h > +++ b/arch/x86/include/asm/xen/cpuid.h > @@ -65,4 +65,9 @@ > #define _XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD 0 > #define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0) > > +#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) > + > #endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */ > diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h > index d5b7e90..7569f64 100644 > --- a/arch/x86/include/asm/xen/hypervisor.h > +++ b/arch/x86/include/asm/xen/hypervisor.h > @@ -55,6 +55,18 @@ extern enum xen_domain_type xen_domain_type; > #define xen_hvm_domain() (xen_domain()&& \ > xen_domain_type == XEN_HVM_DOMAIN) > > +#ifdef CONFIG_XEN_HVM_PV > + > +#define XEN_HVM_PV_CLOCK_ENABLED (1u<< 0) >Why is this flag needed? As far as I understand it, there''s no real underlying hypervisor change needed to make HVM access to pv clock possible; its just a field in the shared_info''s vcpu struct after all. Even if you enable this feature unconditionally, the user can still control whether the Xen clocksource is used with the "clocksource=" kernel command-line parameter. Also, there''s nothing about this which is 64-bit specific is there? Thanks, J _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2010-Mar-12 20:37 UTC
Re: [Xen-devel] [PATCH][v9 6/6] xen: Enable PV clocksource for HVM
On 03/11/2010 06:57 PM, Sheng Yang wrote:> PV clocksource can provide a reliable clocksource for HVM running on Xen. > > To enable it, put following line to the HVM configure file: > > cpuid = [ ''0x40000002:edx=0x3'' ] > > It would set bit 0 and bit 1 in 0x40000002:edx, which enable PV extension > framework and PV clocksource. >I guess my previous comment would be better made here. I don''t see any reason to make the Xen pv clocksource conditional at runtime. If the user wants to disable/override it, then they can either boot with a clocksource= parameter on the kernel command line, or change it on the fly via /sys. J> Signed-off-by: Sheng Yang<sheng@linux.intel.com> > --- > arch/x86/xen/hvmpv.c | 24 ++++++++++++++++++++++++ > arch/x86/xen/time.c | 12 +++++++++++- > arch/x86/xen/xen-ops.h | 1 + > 3 files changed, 36 insertions(+), 1 deletions(-) > > diff --git a/arch/x86/xen/hvmpv.c b/arch/x86/xen/hvmpv.c > index a24a1e9..1961cf0 100644 > --- a/arch/x86/xen/hvmpv.c > +++ b/arch/x86/xen/hvmpv.c > @@ -42,6 +42,8 @@ static void __init xen_hvm_pv_banner(void) > pv_info.name); > printk(KERN_INFO "Xen version: %d.%d%s\n", > version>> 16, version& 0xffff, extra.extraversion); > + if (xen_hvm_pv_clock_enabled()) > + printk(KERN_INFO "PV feature: PV clocksource enabled\n"); > } > > static int __init xen_para_available(void) > @@ -80,6 +82,9 @@ static int __init init_hvm_pv_info(void) > if (!(edx& XEN_CPUID_FEAT2_HVM_PV)) > return -ENODEV; > > + if (edx& XEN_CPUID_FEAT2_HVM_PV_CLOCK) > + xen_hvm_pv_features |= XEN_HVM_PV_CLOCK_ENABLED; > + > if (pages< 1) > return -ENODEV; > > @@ -110,6 +115,23 @@ static int __init init_shared_info(void) > return 0; > } > > +static void __init init_pv_clocksource(void) > +{ > + if (!xen_hvm_pv_clock_enabled()) > + return; > + > + if (enable_hvm_pv(HVM_PV_CLOCK)) > + BUG(); > + > + pv_time_ops.sched_clock = xen_sched_clock; > + > + x86_platform.calibrate_tsc = xen_tsc_khz; > + x86_platform.get_wallclock = xen_get_wallclock; > + x86_platform.set_wallclock = xen_set_wallclock; > + > + xen_register_clocksource(); > +} > + > void __init xen_guest_init(void) > { > int r; > @@ -132,4 +154,6 @@ void __init xen_guest_init(void) > pv_info = xen_hvm_pv_info; > > xen_domain_type = XEN_HVM_DOMAIN; > + > + init_pv_clocksource(); > } > diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c > index 0a5aa44..d1c1c50 100644 > --- a/arch/x86/xen/time.c > +++ b/arch/x86/xen/time.c > @@ -474,11 +474,21 @@ void xen_timer_resume(void) > } > } > > +static bool xen_clocksource_enabled; > + > +void xen_register_clocksource(void) > +{ > + if (!xen_clocksource_enabled) { > + clocksource_register(&xen_clocksource); > + xen_clocksource_enabled = 1; > + } > +} > + > __init void xen_time_init(void) > { > int cpu = smp_processor_id(); > > - clocksource_register(&xen_clocksource); > + xen_register_clocksource(); > > if (HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL) == 0) { > /* Successfully turned off 100Hz tick, so we have the > diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h > index 355fa6b..2aeaf51 100644 > --- a/arch/x86/xen/xen-ops.h > +++ b/arch/x86/xen/xen-ops.h > @@ -46,6 +46,7 @@ cycle_t xen_clocksource_read(void); > void xen_setup_cpu_clockevents(void); > unsigned long xen_tsc_khz(void); > void __init xen_time_init(void); > +void xen_register_clocksource(void); > unsigned long xen_get_wallclock(void); > int xen_set_wallclock(unsigned long time); > unsigned long long xen_sched_clock(void); >_______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Sheng Yang
2010-Mar-15 01:45 UTC
Re: [Xen-devel] [PATCH][v9 4/6] xen/hvm: Xen PV extension of HVM initialization
On Saturday 13 March 2010 04:35:53 Jeremy Fitzhardinge wrote:> On 03/11/2010 06:57 PM, Sheng Yang wrote: > > The PV extended HVM(once known as Hybrid) is started from real mode like > > HVM guest, but also with a component based PV feature selection(e.g. PV > > halt, PV timer, event channel, then PV drivers). So guest can takes the > > advantages of both H/W virtualization and Para-Virtualization. > > > > This patch introduced the PV extension of HVM guest initialization. > > > > Guest would detect the capability using CPUID 0x40000002.edx, then call > > HVMOP_enable_pv hypercall to enable pv support in hypervisor. > > > > Signed-off-by: Sheng Yang<sheng@linux.intel.com> > > Signed-off-by: Yaozu (Eddie) Dong<eddie.dong@intel.com> > > --- > > arch/x86/include/asm/xen/cpuid.h | 5 + > > arch/x86/include/asm/xen/hypervisor.h | 12 +++ > > arch/x86/xen/Kconfig | 4 + > > arch/x86/xen/Makefile | 1 + > > arch/x86/xen/hvmpv.c | 135 > > +++++++++++++++++++++++++++++++++ include/xen/interface/hvm/hvm_op.h | > > 8 ++ > > 6 files changed, 165 insertions(+), 0 deletions(-) > > create mode 100644 arch/x86/xen/hvmpv.c > > > > diff --git a/arch/x86/include/asm/xen/cpuid.h > > b/arch/x86/include/asm/xen/cpuid.h index 8787f03..b3a0b3a 100644 > > --- a/arch/x86/include/asm/xen/cpuid.h > > +++ b/arch/x86/include/asm/xen/cpuid.h > > @@ -65,4 +65,9 @@ > > #define _XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD 0 > > #define XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD (1u<<0) > > > > +#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) > > + > > #endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */ > > diff --git a/arch/x86/include/asm/xen/hypervisor.h > > b/arch/x86/include/asm/xen/hypervisor.h index d5b7e90..7569f64 100644 > > --- a/arch/x86/include/asm/xen/hypervisor.h > > +++ b/arch/x86/include/asm/xen/hypervisor.h > > @@ -55,6 +55,18 @@ extern enum xen_domain_type xen_domain_type; > > #define xen_hvm_domain() (xen_domain()&& \ > > xen_domain_type == XEN_HVM_DOMAIN) > > > > +#ifdef CONFIG_XEN_HVM_PV > > + > > +#define XEN_HVM_PV_CLOCK_ENABLED (1u<< 0) > > Why is this flag needed? As far as I understand it, there''s no real > underlying hypervisor change needed to make HVM access to pv clock > possible; its just a field in the shared_info''s vcpu struct after all. > Even if you enable this feature unconditionally, the user can still > control whether the Xen clocksource is used with the "clocksource=" > kernel command-line parameter.But we should make sure Xen have ability to support such kind of operation. The CPUID would show if Xen have such ability, and if it does, the feature would be enabled unconditionally. Guest kernel always enable all features it can do unconditionally, but Xen should offer the support for them.> Also, there''s nothing about this which is 64-bit specific is there?64 bit things are mostly evtchn/interrupt related. I think no such limit here. But I think it''s better to do it step by step, so leave it after evtchn solution settled. -- regards Yang, Sheng _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Stefano Stabellini
2010-Mar-15 12:04 UTC
Re: [Xen-devel] [PATCH][v9 4/6] xen/hvm: Xen PV extension of HVM initialization
On Mon, 15 Mar 2010, Sheng Yang wrote:> > > +#ifdef CONFIG_XEN_HVM_PV > > > + > > > +#define XEN_HVM_PV_CLOCK_ENABLED (1u<< 0) > > > > Why is this flag needed? As far as I understand it, there''s no real > > underlying hypervisor change needed to make HVM access to pv clock > > possible; its just a field in the shared_info''s vcpu struct after all. > > Even if you enable this feature unconditionally, the user can still > > control whether the Xen clocksource is used with the "clocksource=" > > kernel command-line parameter. > > But we should make sure Xen have ability to support such kind of operation. > The CPUID would show if Xen have such ability, and if it does, the feature > would be enabled unconditionally. Guest kernel always enable all features it > can do unconditionally, but Xen should offer the support for them. >In my opinion once the guest knows that is running on Xen HVM (that is from xen_cpuid_base() or xen_para_available()) it should assume that the pv clocksource is available, therefore XEN_HVM_PV_CLOCK_ENABLED should not be needed. In other words the mere presence of Xen should imply XEN_HVM_PV_CLOCK_ENABLED.> > Also, there''s nothing about this which is 64-bit specific is there? > > 64 bit things are mostly evtchn/interrupt related. I think no such limit here. > But I think it''s better to do it step by step, so leave it after evtchn > solution settled. >Do you mean write generic code now, then introduce the 64 bit limitation later? Or the other way around? I don''t have a strong opinion here so I am OK with both approaches, but I would prefer to add the limitation later (maybe we''ll be able to make it work on 32 bit too...). _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2010-Mar-15 22:59 UTC
Re: [Xen-devel] [PATCH][v9 4/6] xen/hvm: Xen PV extension of HVM initialization
On 03/15/2010 05:04 AM, Stefano Stabellini wrote:>> But we should make sure Xen have ability to support such kind of operation. >> The CPUID would show if Xen have such ability, and if it does, the feature >> would be enabled unconditionally. Guest kernel always enable all features it >> can do unconditionally, but Xen should offer the support for them. >> >> > In my opinion once the guest knows that is running on Xen HVM (that is > from xen_cpuid_base() or xen_para_available()) it should assume > that the pv clocksource is available, therefore XEN_HVM_PV_CLOCK_ENABLED > should not be needed. > In other words the mere presence of Xen should imply > XEN_HVM_PV_CLOCK_ENABLED. >The only reason why we wouldn''t want to do this is if we want to withdraw this feature at some point in the future. We''re stuck with it indefinitely for PV, but I don''t know if that''s necessarily going to be the case for HVM. On the other hand, if other - better - mechanisms become available, we can give them their own clocksource driver with a higher priority than the Xen pvclock one, and users can still select clocksources on the kernel command line.> Do you mean write generic code now, then introduce the 64 bit > limitation later? Or the other way around? > I don''t have a strong opinion here so I am OK with both approaches, but > I would prefer to add the limitation later (maybe we''ll be able to make > it work on 32 bit too...). >Seems like making it work for both 32 and 64-bit is the easiest thing to do. J _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Sheng Yang
2010-Mar-16 01:51 UTC
Re: [Xen-devel] [PATCH][v9 4/6] xen/hvm: Xen PV extension of HVM initialization
On Tuesday 16 March 2010 06:59:58 Jeremy Fitzhardinge wrote:> On 03/15/2010 05:04 AM, Stefano Stabellini wrote: > >> But we should make sure Xen have ability to support such kind of > >> operation. The CPUID would show if Xen have such ability, and if it > >> does, the feature would be enabled unconditionally. Guest kernel always > >> enable all features it can do unconditionally, but Xen should offer the > >> support for them. > > > > In my opinion once the guest knows that is running on Xen HVM (that is > > from xen_cpuid_base() or xen_para_available()) it should assume > > that the pv clocksource is available, therefore XEN_HVM_PV_CLOCK_ENABLED > > should not be needed. > > In other words the mere presence of Xen should imply > > XEN_HVM_PV_CLOCK_ENABLED. > > The only reason why we wouldn''t want to do this is if we want to > withdraw this feature at some point in the future. We''re stuck with it > indefinitely for PV, but I don''t know if that''s necessarily going to be > the case for HVM. On the other hand, if other - better - mechanisms > become available, we can give them their own clocksource driver with a > higher priority than the Xen pvclock one, and users can still select > clocksources on the kernel command line.So you think about adding a new XENFEAT?> > > Do you mean write generic code now, then introduce the 64 bit > > limitation later? Or the other way around? > > I don''t have a strong opinion here so I am OK with both approaches, but > > I would prefer to add the limitation later (maybe we''ll be able to make > > it work on 32 bit too...). > > Seems like making it work for both 32 and 64-bit is the easiest thing to > do.If it is, it should be fine. But I had encountered some issues on 32 bits. -- regards Yang, Sheng _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2010-Mar-16 17:12 UTC
Re: [Xen-devel] [PATCH][v9 4/6] xen/hvm: Xen PV extension of HVM initialization
On 03/15/2010 06:51 PM, Sheng Yang wrote:> On Tuesday 16 March 2010 06:59:58 Jeremy Fitzhardinge wrote: > >> On 03/15/2010 05:04 AM, Stefano Stabellini wrote: >> >>>> But we should make sure Xen have ability to support such kind of >>>> operation. The CPUID would show if Xen have such ability, and if it >>>> does, the feature would be enabled unconditionally. Guest kernel always >>>> enable all features it can do unconditionally, but Xen should offer the >>>> support for them. >>>> >>> In my opinion once the guest knows that is running on Xen HVM (that is >>> from xen_cpuid_base() or xen_para_available()) it should assume >>> that the pv clocksource is available, therefore XEN_HVM_PV_CLOCK_ENABLED >>> should not be needed. >>> In other words the mere presence of Xen should imply >>> XEN_HVM_PV_CLOCK_ENABLED. >>> >> The only reason why we wouldn''t want to do this is if we want to >> withdraw this feature at some point in the future. We''re stuck with it >> indefinitely for PV, but I don''t know if that''s necessarily going to be >> the case for HVM. On the other hand, if other - better - mechanisms >> become available, we can give them their own clocksource driver with a >> higher priority than the Xen pvclock one, and users can still select >> clocksources on the kernel command line. >> > So you think about adding a new XENFEAT? >I think that''s a bit arbitrary. If we need a new vcpuop to make it work properly anyway (set tsc offset), then the presence of that should be a good indicator. In other words, make it depend on its actual fixed pre-reqs, rather than a specific flag for the feature.>> Seems like making it work for both 32 and 64-bit is the easiest thing to >> do. >> > If it is, it should be fine. But I had encountered some issues on 32 bits. >What kinds of issues? J _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2010-Mar-16 17:20 UTC
Re: [Xen-devel] [PATCH][v9 4/6] xen/hvm: Xen PV extension of HVM initialization
On Tue, 2010-03-16 at 17:12 +0000, Jeremy Fitzhardinge wrote:> If we need a new vcpuop to make it work > properly anyway (set tsc offset), then the presence of that should be > a > good indicator. In other words, make it depend on its actual fixed > pre-reqs, rather than a specific flag for the feature.I don''t think a new hypercall is required. Xen should simply pre-account for the TSC offset which HVM guests are subject to in __update_vcpu_system_time. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2010-Mar-16 17:29 UTC
Re: [Xen-devel] [PATCH][v9 4/6] xen/hvm: Xen PV extension of HVM initialization
On 03/16/2010 10:20 AM, Ian Campbell wrote:> I don''t think a new hypercall is required. Xen should simply pre-account > for the TSC offset which HVM guests are subject to in > __update_vcpu_system_time. >Yes, that would work too. J _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel