Hi Ingo, This branch has the basics of Xen dom0 support. It is not sufficient to get a booting system (it implements no access to physical devices), but it is enough to at least get the kernel to start and print some console messages. This is essentially unchanged from the last time I posted it. The following changes since commit e7c064889606aab3569669078c69b87b2c527e72: Jeremy Fitzhardinge (1): xen: add FIX_TEXT_POKE to fixmap are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git xen-tip/dom0/core Christophe Saout (1): paravirtualize IO permission bitmap Ian Campbell (4): xen: disable PAT xen/dom0: Use host E820 map xen: implement XENMEM_machphys_mapping xen: clear reserved bits in l3 entries given in the initial pagetables Jeremy Fitzhardinge (7): xen dom0: Make hvc_xen console work for dom0. xen/dom0: use _PAGE_IOMAP in ioremap to do machine mappings xen: allow enable use of VGA console on dom0 xen/dom0: add XEN_DOM0 config option x86: make /dev/mem mappings _PAGE_IOMAP x86: don''t need "changed" parameter for set_io_bitmap() xen: checkpatch cleanups Juan Quintela (2): xen dom0: Initialize xenbus for dom0. xen dom0: Set up basic IO permissions for dom0. Stephen Tweedie (2): xen dom0: Add support for the platform_ops hypercall xen mtrr: Add mtrr_ops support for Xen mtrr arch/x86/include/asm/paravirt.h | 9 ++ arch/x86/include/asm/pat.h | 5 + arch/x86/include/asm/processor.h | 4 + arch/x86/include/asm/xen/hypercall.h | 8 + arch/x86/include/asm/xen/interface.h | 6 +- arch/x86/include/asm/xen/interface_32.h | 5 + arch/x86/include/asm/xen/interface_64.h | 13 +-- arch/x86/include/asm/xen/page.h | 15 +-- arch/x86/kernel/cpu/mtrr/Makefile | 1 + arch/x86/kernel/cpu/mtrr/amd.c | 1 + arch/x86/kernel/cpu/mtrr/centaur.c | 1 + arch/x86/kernel/cpu/mtrr/cyrix.c | 1 + arch/x86/kernel/cpu/mtrr/generic.c | 1 + arch/x86/kernel/cpu/mtrr/main.c | 11 +- arch/x86/kernel/cpu/mtrr/mtrr.h | 5 + arch/x86/kernel/cpu/mtrr/xen.c | 56 ++++++++ arch/x86/kernel/ioport.c | 29 +++- arch/x86/kernel/paravirt.c | 1 + arch/x86/kernel/process.c | 27 +--- arch/x86/mm/pat.c | 7 +- arch/x86/xen/Kconfig | 26 ++++ arch/x86/xen/Makefile | 3 +- arch/x86/xen/enlighten.c | 51 +++++++- arch/x86/xen/mmu.c | 123 +++++++++++++++++- arch/x86/xen/setup.c | 51 +++++++- arch/x86/xen/vga.c | 68 ++++++++++ arch/x86/xen/xen-ops.h | 12 ++ drivers/char/hvc_xen.c | 99 +++++++++----- drivers/xen/events.c | 2 +- drivers/xen/xenbus/xenbus_probe.c | 30 ++++- include/xen/events.h | 2 + include/xen/interface/memory.h | 42 ++++++ include/xen/interface/platform.h | 222 +++++++++++++++++++++++++++++++ include/xen/interface/xen.h | 41 ++++++ 34 files changed, 873 insertions(+), 105 deletions(-) create mode 100644 arch/x86/kernel/cpu/mtrr/xen.c create mode 100644 arch/x86/xen/vga.c create mode 100644 include/xen/interface/platform.h Thanks, J _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 01/16] xen dom0: Make hvc_xen console work for dom0.
Impact: Add Xen dom0 console Use the console hypercalls for dom0 console. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Signed-off-by: Juan Quintela <quintela@redhat.com> --- drivers/char/hvc_xen.c | 101 ++++++++++++++++++++++++++++++++---------------- drivers/xen/events.c | 2 +- include/xen/events.h | 2 + 3 files changed, 70 insertions(+), 35 deletions(-) diff --git a/drivers/char/hvc_xen.c b/drivers/char/hvc_xen.c index eba999f..81d9186 100644 --- a/drivers/char/hvc_xen.c +++ b/drivers/char/hvc_xen.c @@ -55,7 +55,7 @@ static inline void notify_daemon(void) notify_remote_via_evtchn(xen_start_info->console.domU.evtchn); } -static int write_console(uint32_t vtermno, const char *data, int len) +static int domU_write_console(uint32_t vtermno, const char *data, int len) { struct xencons_interface *intf = xencons_interface(); XENCONS_RING_IDX cons, prod; @@ -76,7 +76,7 @@ static int write_console(uint32_t vtermno, const char *data, int len) return sent; } -static int read_console(uint32_t vtermno, char *buf, int len) +static int domU_read_console(uint32_t vtermno, char *buf, int len) { struct xencons_interface *intf = xencons_interface(); XENCONS_RING_IDX cons, prod; @@ -97,28 +97,63 @@ static int read_console(uint32_t vtermno, char *buf, int len) return recv; } -static struct hv_ops hvc_ops = { - .get_chars = read_console, - .put_chars = write_console, +static struct hv_ops domU_hvc_ops = { + .get_chars = domU_read_console, + .put_chars = domU_write_console, .notifier_add = notifier_add_irq, .notifier_del = notifier_del_irq, .notifier_hangup = notifier_hangup_irq, }; -static int __init xen_init(void) +static int dom0_read_console(uint32_t vtermno, char *buf, int len) +{ + return HYPERVISOR_console_io(CONSOLEIO_read, len, buf); +} + +/* + * Either for a dom0 to write to the system console, or a domU with a + * debug version of Xen + */ +static int dom0_write_console(uint32_t vtermno, const char *str, int len) +{ + int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (char *)str); + if (rc < 0) + return 0; + + return len; +} + +static struct hv_ops dom0_hvc_ops = { + .get_chars = dom0_read_console, + .put_chars = dom0_write_console, + .notifier_add = notifier_add_irq, + .notifier_del = notifier_del_irq, + .notifier_hangup = notifier_hangup_irq, +}; + +static int __init xen_hvc_init(void) { struct hvc_struct *hp; + struct hv_ops *ops; - if (!xen_pv_domain() || - xen_initial_domain() || - !xen_start_info->console.domU.evtchn) - return -ENODEV; + if (!xen_pv_domain()) + return -ENODEV; + + if (xen_initial_domain()) { + ops = &dom0_hvc_ops; + xencons_irq = bind_virq_to_irq(VIRQ_CONSOLE, 0); + } else { + if (!xen_start_info->console.domU.evtchn) + return -ENODEV; + + ops = &domU_hvc_ops; + xencons_irq = bind_evtchn_to_irq(xen_start_info->console.domU.evtchn); + } - xencons_irq = bind_evtchn_to_irq(xen_start_info->console.domU.evtchn); if (xencons_irq < 0) xencons_irq = 0; /* NO_IRQ */ - hp = hvc_alloc(HVC_COOKIE, xencons_irq, &hvc_ops, 256); + hp = hvc_alloc(HVC_COOKIE, xencons_irq, ops, 256); if (IS_ERR(hp)) return PTR_ERR(hp); @@ -135,7 +170,7 @@ void xen_console_resume(void) rebind_evtchn_irq(xen_start_info->console.domU.evtchn, xencons_irq); } -static void __exit xen_fini(void) +static void __exit xen_hvc_fini(void) { if (hvc) hvc_remove(hvc); @@ -143,29 +178,24 @@ static void __exit xen_fini(void) static int xen_cons_init(void) { + struct hv_ops *ops; + if (!xen_pv_domain()) return 0; - hvc_instantiate(HVC_COOKIE, 0, &hvc_ops); + ops = &domU_hvc_ops; + if (xen_initial_domain()) + ops = &dom0_hvc_ops; + + hvc_instantiate(HVC_COOKIE, 0, ops); + return 0; } -module_init(xen_init); -module_exit(xen_fini); +module_init(xen_hvc_init); +module_exit(xen_hvc_fini); console_initcall(xen_cons_init); -static void raw_console_write(const char *str, int len) -{ - while(len > 0) { - int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (char *)str); - if (rc <= 0) - break; - - str += rc; - len -= rc; - } -} - #ifdef CONFIG_EARLY_PRINTK static void xenboot_write_console(struct console *console, const char *string, unsigned len) @@ -173,19 +203,22 @@ static void xenboot_write_console(struct console *console, const char *string, unsigned int linelen, off = 0; const char *pos; - raw_console_write(string, len); + dom0_write_console(0, string, len); + + if (xen_initial_domain()) + return; - write_console(0, "(early) ", 8); + domU_write_console(0, "(early) ", 8); while (off < len && NULL != (pos = strchr(string+off, ''\n''))) { linelen = pos-string+off; if (off + linelen > len) break; - write_console(0, string+off, linelen); - write_console(0, "\r\n", 2); + domU_write_console(0, string+off, linelen); + domU_write_console(0, "\r\n", 2); off += linelen + 1; } if (off < len) - write_console(0, string+off, len-off); + domU_write_console(0, string+off, len-off); } struct console xenboot_console = { @@ -197,7 +230,7 @@ struct console xenboot_console = { void xen_raw_console_write(const char *str) { - raw_console_write(str, strlen(str)); + dom0_write_console(0, str, strlen(str)); } void xen_raw_printk(const char *fmt, ...) diff --git a/drivers/xen/events.c b/drivers/xen/events.c index 1cd2a0e..97f4b39 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c @@ -410,7 +410,7 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu) } -static int bind_virq_to_irq(unsigned int virq, unsigned int cpu) +int bind_virq_to_irq(unsigned int virq, unsigned int cpu) { struct evtchn_bind_virq bind_virq; int evtchn, irq; diff --git a/include/xen/events.h b/include/xen/events.h index e68d59a..9f24b64 100644 --- a/include/xen/events.h +++ b/include/xen/events.h @@ -12,6 +12,8 @@ int bind_evtchn_to_irqhandler(unsigned int evtchn, irq_handler_t handler, unsigned long irqflags, const char *devname, void *dev_id); +int bind_virq_to_irq(unsigned int virq, unsigned int cpu); + int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu, irq_handler_t handler, unsigned long irqflags, const char *devname, -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 02/16] xen dom0: Initialize xenbus for dom0.
From: Juan Quintela <quintela@redhat.com> Impact: initialize Xenbus Do initial xenbus/xenstore setup in dom0. In dom0 we need to actually allocate the xenstore resources, rather than being given them from outside. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Signed-off-by: Juan Quintela <quintela@redhat.com> --- drivers/xen/xenbus/xenbus_probe.c | 30 +++++++++++++++++++++++++++++- 1 files changed, 29 insertions(+), 1 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index d42e25d..6a05725 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -780,6 +780,7 @@ void xenbus_probe(struct work_struct *unused) static int __init xenbus_probe_init(void) { int err = 0; + unsigned long page = 0; DPRINTK(""); @@ -800,7 +801,31 @@ static int __init xenbus_probe_init(void) * Domain0 doesn''t have a store_evtchn or store_mfn yet. */ if (xen_initial_domain()) { - /* dom0 not yet supported */ + struct evtchn_alloc_unbound alloc_unbound; + + /* Allocate Xenstore page */ + page = get_zeroed_page(GFP_KERNEL); + if (!page) + return -ENOMEM; + + xen_store_mfn = xen_start_info->store_mfn + pfn_to_mfn(virt_to_phys((void *)page) >> + PAGE_SHIFT); + + /* Next allocate a local port which xenstored can bind to */ + alloc_unbound.dom = DOMID_SELF; + alloc_unbound.remote_dom = 0; + + err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, + &alloc_unbound); + if (err == -ENOSYS) + goto out_unreg_front; + + BUG_ON(err); + xen_store_evtchn = xen_start_info->store_evtchn + alloc_unbound.port; + + xen_store_interface = mfn_to_virt(xen_store_mfn); } else { xenstored_ready = 1; xen_store_evtchn = xen_start_info->store_evtchn; @@ -836,6 +861,9 @@ static int __init xenbus_probe_init(void) bus_unregister(&xenbus_frontend.bus); out_error: + if (page != 0) + free_page(page); + return err; } -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 03/16] xen dom0: Set up basic IO permissions for dom0.
From: Juan Quintela <quintela@redhat.com> Impact: set iopl for dom0 kernel; map ISA Add the direct mapping area for ISA bus access, and enable IO space access for the guest when running as dom0. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Signed-off-by: Juan Quintela <quintela@redhat.com> --- arch/x86/xen/enlighten.c | 8 ++++++++ arch/x86/xen/mmu.c | 24 ++++++++++++++++++++++++ arch/x86/xen/setup.c | 6 +++++- arch/x86/xen/xen-ops.h | 1 + 4 files changed, 38 insertions(+), 1 deletions(-) diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 12a3159..f917381 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -994,6 +994,7 @@ asmlinkage void __init xen_start_kernel(void) xen_raw_console_write("mapping kernel into physical memory\n"); pgd = xen_setup_kernel_pagetable(pgd, xen_start_info->nr_pages); + xen_ident_map_ISA(); init_mm.pgd = pgd; @@ -1003,6 +1004,13 @@ asmlinkage void __init xen_start_kernel(void) if (xen_feature(XENFEAT_supervisor_mode_kernel)) pv_info.kernel_rpl = 0; + if (xen_initial_domain()) { + struct physdev_set_iopl set_iopl; + set_iopl.iopl = 1; + if (HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl) == -1) + BUG(); + } + /* set the limit of our address space */ xen_reserve_top(); diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index a96f5b9..33575ec 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c @@ -1615,6 +1615,7 @@ static void *m2v(phys_addr_t maddr) return __ka(m2p(maddr)); } +/* Set the page permissions on an identity-mapped pages */ static void set_page_prot(void *addr, pgprot_t prot) { unsigned long pfn = __pa(addr) >> PAGE_SHIFT; @@ -1835,6 +1836,29 @@ static void xen_set_fixmap(unsigned idx, unsigned long phys, pgprot_t prot) #endif } +__init void xen_ident_map_ISA(void) +{ + unsigned long pa; + + /* + * If we''re dom0, then linear map the ISA machine addresses into + * the kernel''s address space. + */ + if (!xen_initial_domain()) + return; + + xen_raw_printk("Xen: setup ISA identity maps\n"); + + for (pa = ISA_START_ADDRESS; pa < ISA_END_ADDRESS; pa += PAGE_SIZE) { + pte_t pte = mfn_pte(PFN_DOWN(pa), PAGE_KERNEL_IO); + + if (HYPERVISOR_update_va_mapping(PAGE_OFFSET + pa, pte, 0)) + BUG(); + } + + xen_flush_tlb(); +} + __init void xen_post_allocator_init(void) { pv_mmu_ops.set_pte = xen_set_pte; diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index 15c6c68..3e4cf46 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c @@ -51,6 +51,9 @@ char * __init xen_memory_setup(void) * Even though this is normal, usable memory under Xen, reserve * ISA memory anyway because too many things think they can poke * about in there. + * + * In a dom0 kernel, this region is identity mapped with the + * hardware ISA area, so it really is out of bounds. */ e820_add_region(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RESERVED); @@ -188,7 +191,8 @@ void __init xen_arch_setup(void) pm_idle = xen_idle; - paravirt_disable_iospace(); + if (!xen_initial_domain()) + paravirt_disable_iospace(); fiddle_vdso(); } diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index 5c50a10..6ff6203 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h @@ -29,6 +29,7 @@ void xen_setup_machphys_mapping(void); pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn); void xen_ident_map_ISA(void); void xen_reserve_top(void); +void xen_ident_map_ISA(void); void xen_post_allocator_init(void); -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 04/16] xen dom0: Add support for the platform_ops hypercall
From: Stephen Tweedie <sct@redhat.com> Impact: add hypercall definitions Minimal changes to get platform ops (renamed dom0_ops on pv_ops) working on pv_ops builds. Pulls in upstream linux-2.6.18-xen.hg''s platform.h Signed-off-by: Stephen Tweedie <sct@redhat.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/include/asm/xen/hypercall.h | 8 ++ include/xen/interface/platform.h | 232 ++++++++++++++++++++++++++++++++++ include/xen/interface/xen.h | 2 + 3 files changed, 242 insertions(+), 0 deletions(-) create mode 100644 include/xen/interface/platform.h diff --git a/arch/x86/include/asm/xen/hypercall.h b/arch/x86/include/asm/xen/hypercall.h index 9c371e4..6528f3b 100644 --- a/arch/x86/include/asm/xen/hypercall.h +++ b/arch/x86/include/asm/xen/hypercall.h @@ -45,6 +45,7 @@ #include <xen/interface/xen.h> #include <xen/interface/sched.h> #include <xen/interface/physdev.h> +#include <xen/interface/platform.h> /* * The hypercall asms have to meet several constraints: @@ -282,6 +283,13 @@ HYPERVISOR_set_timer_op(u64 timeout) } static inline int +HYPERVISOR_dom0_op(struct xen_platform_op *platform_op) +{ + platform_op->interface_version = XENPF_INTERFACE_VERSION; + return _hypercall1(int, dom0_op, platform_op); +} + +static inline int HYPERVISOR_set_debugreg(int reg, unsigned long value) { return _hypercall2(int, set_debugreg, reg, value); diff --git a/include/xen/interface/platform.h b/include/xen/interface/platform.h new file mode 100644 index 0000000..da548f3 --- /dev/null +++ b/include/xen/interface/platform.h @@ -0,0 +1,232 @@ +/****************************************************************************** + * platform.h + * + * Hardware platform operations. Intended for use by domain-0 kernel. + * + * 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) 2002-2006, K Fraser + */ + +#ifndef __XEN_PUBLIC_PLATFORM_H__ +#define __XEN_PUBLIC_PLATFORM_H__ + +#include "xen.h" + +#define XENPF_INTERFACE_VERSION 0x03000001 + +/* + * Set clock such that it would read <secs,nsecs> after 00:00:00 UTC, + * 1 January, 1970 if the current system time was <system_time>. + */ +#define XENPF_settime 17 +struct xenpf_settime { + /* IN variables. */ + uint32_t secs; + uint32_t nsecs; + uint64_t system_time; +}; +typedef struct xenpf_settime xenpf_settime_t; +DEFINE_GUEST_HANDLE_STRUCT(xenpf_settime_t); + +/* + * Request memory range (@mfn, @mfn+@nr_mfns-1) to have type @type. + * On x86, @type is an architecture-defined MTRR memory type. + * On success, returns the MTRR that was used (@reg) and a handle that can + * be passed to XENPF_DEL_MEMTYPE to accurately tear down the new setting. + * (x86-specific). + */ +#define XENPF_add_memtype 31 +struct xenpf_add_memtype { + /* IN variables. */ + unsigned long mfn; + uint64_t nr_mfns; + uint32_t type; + /* OUT variables. */ + uint32_t handle; + uint32_t reg; +}; +typedef struct xenpf_add_memtype xenpf_add_memtype_t; +DEFINE_GUEST_HANDLE_STRUCT(xenpf_add_memtype_t); + +/* + * Tear down an existing memory-range type. If @handle is remembered then it + * should be passed in to accurately tear down the correct setting (in case + * of overlapping memory regions with differing types). If it is not known + * then @handle should be set to zero. In all cases @reg must be set. + * (x86-specific). + */ +#define XENPF_del_memtype 32 +struct xenpf_del_memtype { + /* IN variables. */ + uint32_t handle; + uint32_t reg; +}; +typedef struct xenpf_del_memtype xenpf_del_memtype_t; +DEFINE_GUEST_HANDLE_STRUCT(xenpf_del_memtype_t); + +/* Read current type of an MTRR (x86-specific). */ +#define XENPF_read_memtype 33 +struct xenpf_read_memtype { + /* IN variables. */ + uint32_t reg; + /* OUT variables. */ + unsigned long mfn; + uint64_t nr_mfns; + uint32_t type; +}; +typedef struct xenpf_read_memtype xenpf_read_memtype_t; +DEFINE_GUEST_HANDLE_STRUCT(xenpf_read_memtype_t); + +#define XENPF_microcode_update 35 +struct xenpf_microcode_update { + /* IN variables. */ + GUEST_HANDLE(void) data; /* Pointer to microcode data */ + uint32_t length; /* Length of microcode data. */ +}; +typedef struct xenpf_microcode_update xenpf_microcode_update_t; +DEFINE_GUEST_HANDLE_STRUCT(xenpf_microcode_update_t); + +#define XENPF_platform_quirk 39 +#define QUIRK_NOIRQBALANCING 1 /* Do not restrict IO-APIC RTE targets */ +#define QUIRK_IOAPIC_BAD_REGSEL 2 /* IO-APIC REGSEL forgets its value */ +#define QUIRK_IOAPIC_GOOD_REGSEL 3 /* IO-APIC REGSEL behaves properly */ +struct xenpf_platform_quirk { + /* IN variables. */ + uint32_t quirk_id; +}; +typedef struct xenpf_platform_quirk xenpf_platform_quirk_t; +DEFINE_GUEST_HANDLE_STRUCT(xenpf_platform_quirk_t); + +#define XENPF_firmware_info 50 +#define XEN_FW_DISK_INFO 1 /* from int 13 AH=08/41/48 */ +#define XEN_FW_DISK_MBR_SIGNATURE 2 /* from MBR offset 0x1b8 */ +#define XEN_FW_VBEDDC_INFO 3 /* from int 10 AX=4f15 */ +struct xenpf_firmware_info { + /* IN variables. */ + uint32_t type; + uint32_t index; + /* OUT variables. */ + union { + struct { + /* Int13, Fn48: Check Extensions Present. */ + uint8_t device; /* %dl: bios device number */ + uint8_t version; /* %ah: major version */ + uint16_t interface_support; /* %cx: support bitmap */ + /* Int13, Fn08: Legacy Get Device Parameters. */ + uint16_t legacy_max_cylinder; /* %cl[7:6]:%ch: max cyl # */ + uint8_t legacy_max_head; /* %dh: max head # */ + uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector # */ + /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */ + /* NB. First uint16_t of buffer must be set to buffer size. */ + GUEST_HANDLE(void) edd_params; + } disk_info; /* XEN_FW_DISK_INFO */ + struct { + uint8_t device; /* bios device number */ + uint32_t mbr_signature; /* offset 0x1b8 in mbr */ + } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */ + struct { + /* Int10, AX=4F15: Get EDID info. */ + uint8_t capabilities; + uint8_t edid_transfer_time; + /* must refer to 128-byte buffer */ + GUEST_HANDLE(uchar) edid; + } vbeddc_info; /* XEN_FW_VBEDDC_INFO */ + } u; +}; +typedef struct xenpf_firmware_info xenpf_firmware_info_t; +DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmware_info_t); + +#define XENPF_enter_acpi_sleep 51 +struct xenpf_enter_acpi_sleep { + /* IN variables */ + uint16_t pm1a_cnt_val; /* PM1a control value. */ + uint16_t pm1b_cnt_val; /* PM1b control value. */ + uint32_t sleep_state; /* Which state to enter (Sn). */ + uint32_t flags; /* Must be zero. */ +}; +typedef struct xenpf_enter_acpi_sleep xenpf_enter_acpi_sleep_t; +DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t); + +#define XENPF_change_freq 52 +struct xenpf_change_freq { + /* IN variables */ + uint32_t flags; /* Must be zero. */ + uint32_t cpu; /* Physical cpu. */ + uint64_t freq; /* New frequency (Hz). */ +}; +typedef struct xenpf_change_freq xenpf_change_freq_t; +DEFINE_GUEST_HANDLE_STRUCT(xenpf_change_freq_t); + +/* + * Get idle times (nanoseconds since boot) for physical CPUs specified in the + * @cpumap_bitmap with range [0..@cpumap_nr_cpus-1]. The @idletime array is + * indexed by CPU number; only entries with the corresponding @cpumap_bitmap + * bit set are written to. On return, @cpumap_bitmap is modified so that any + * non-existent CPUs are cleared. Such CPUs have their @idletime array entry + * cleared. + */ +#define XENPF_getidletime 53 +struct xenpf_getidletime { + /* IN/OUT variables */ + /* IN: CPUs to interrogate; OUT: subset of IN which are present */ + GUEST_HANDLE(uchar) cpumap_bitmap; + /* IN variables */ + /* Size of cpumap bitmap. */ + uint32_t cpumap_nr_cpus; + /* Must be indexable for every cpu in cpumap_bitmap. */ + GUEST_HANDLE(uint64_t) idletime; + /* OUT variables */ + /* System time when the idletime snapshots were taken. */ + uint64_t now; +}; +typedef struct xenpf_getidletime xenpf_getidletime_t; +DEFINE_GUEST_HANDLE_STRUCT(xenpf_getidletime_t); + +struct xen_platform_op { + uint32_t cmd; + uint32_t interface_version; /* XENPF_INTERFACE_VERSION */ + union { + struct xenpf_settime settime; + struct xenpf_add_memtype add_memtype; + struct xenpf_del_memtype del_memtype; + struct xenpf_read_memtype read_memtype; + struct xenpf_microcode_update microcode; + struct xenpf_platform_quirk platform_quirk; + struct xenpf_firmware_info firmware_info; + struct xenpf_enter_acpi_sleep enter_acpi_sleep; + struct xenpf_change_freq change_freq; + struct xenpf_getidletime getidletime; + uint8_t pad[128]; + } u; +}; +typedef struct xen_platform_op xen_platform_op_t; +DEFINE_GUEST_HANDLE_STRUCT(xen_platform_op_t); + +#endif /* __XEN_PUBLIC_PLATFORM_H__ */ + +/* + * Local variables: + * mode: C + * c-set-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h index 2befa3e..18b5599 100644 --- a/include/xen/interface/xen.h +++ b/include/xen/interface/xen.h @@ -461,6 +461,8 @@ typedef uint8_t xen_domain_handle_t[16]; #define __mk_unsigned_long(x) x ## UL #define mk_unsigned_long(x) __mk_unsigned_long(x) +DEFINE_GUEST_HANDLE(uint64_t); + #else /* __ASSEMBLY__ */ /* In assembly code we cannot use C numeric constant suffixes. */ -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 05/16] xen mtrr: Add mtrr_ops support for Xen mtrr
From: Stephen Tweedie <sct@redhat.com> Impact: add basic MTRR support (enough to get started) Add a Xen mtrr type, and reorganise mtrr initialisation slightly to allow the mtrr driver to set up num_var_ranges (Xen needs to do this by querying the hypervisor itself.) Only the boot path is handled for now: we set up a xen-specific mtrr_if and set up the mtrr tables based on hypervisor information, but we don''t yet handle mtrr entry add/delete. Signed-off-by: Stephen Tweedie <sct@redhat.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/kernel/cpu/mtrr/Makefile | 1 + arch/x86/kernel/cpu/mtrr/amd.c | 1 + arch/x86/kernel/cpu/mtrr/centaur.c | 1 + arch/x86/kernel/cpu/mtrr/cyrix.c | 1 + arch/x86/kernel/cpu/mtrr/generic.c | 1 + arch/x86/kernel/cpu/mtrr/main.c | 11 +++++-- arch/x86/kernel/cpu/mtrr/mtrr.h | 5 +++ arch/x86/kernel/cpu/mtrr/xen.c | 59 ++++++++++++++++++++++++++++++++++++ 8 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 arch/x86/kernel/cpu/mtrr/xen.c diff --git a/arch/x86/kernel/cpu/mtrr/Makefile b/arch/x86/kernel/cpu/mtrr/Makefile index f4361b5..404e458 100644 --- a/arch/x86/kernel/cpu/mtrr/Makefile +++ b/arch/x86/kernel/cpu/mtrr/Makefile @@ -1,3 +1,4 @@ obj-y := main.o if.o generic.o state.o cleanup.o obj-$(CONFIG_X86_32) += amd.o cyrix.o centaur.o +obj-$(CONFIG_XEN_DOM0) += xen.o diff --git a/arch/x86/kernel/cpu/mtrr/amd.c b/arch/x86/kernel/cpu/mtrr/amd.c index ee2331b..7bf23de 100644 --- a/arch/x86/kernel/cpu/mtrr/amd.c +++ b/arch/x86/kernel/cpu/mtrr/amd.c @@ -108,6 +108,7 @@ static struct mtrr_ops amd_mtrr_ops = { .get_free_region = generic_get_free_region, .validate_add_page = amd_validate_add_page, .have_wrcomb = positive_have_wrcomb, + .num_var_ranges = common_num_var_ranges, }; int __init amd_init_mtrr(void) diff --git a/arch/x86/kernel/cpu/mtrr/centaur.c b/arch/x86/kernel/cpu/mtrr/centaur.c index cb9aa3a..7e3f74f 100644 --- a/arch/x86/kernel/cpu/mtrr/centaur.c +++ b/arch/x86/kernel/cpu/mtrr/centaur.c @@ -213,6 +213,7 @@ static struct mtrr_ops centaur_mtrr_ops = { .get_free_region = centaur_get_free_region, .validate_add_page = centaur_validate_add_page, .have_wrcomb = positive_have_wrcomb, + .num_var_ranges = common_num_var_ranges, }; int __init centaur_init_mtrr(void) diff --git a/arch/x86/kernel/cpu/mtrr/cyrix.c b/arch/x86/kernel/cpu/mtrr/cyrix.c index ff14c32..c7bb5e3 100644 --- a/arch/x86/kernel/cpu/mtrr/cyrix.c +++ b/arch/x86/kernel/cpu/mtrr/cyrix.c @@ -263,6 +263,7 @@ static struct mtrr_ops cyrix_mtrr_ops = { .get_free_region = cyrix_get_free_region, .validate_add_page = generic_validate_add_page, .have_wrcomb = positive_have_wrcomb, + .num_var_ranges = common_num_var_ranges, }; int __init cyrix_init_mtrr(void) diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c index 0b776c0..c66dda1 100644 --- a/arch/x86/kernel/cpu/mtrr/generic.c +++ b/arch/x86/kernel/cpu/mtrr/generic.c @@ -722,4 +722,5 @@ struct mtrr_ops generic_mtrr_ops = { .set = generic_set_mtrr, .validate_add_page = generic_validate_add_page, .have_wrcomb = generic_have_wrcomb, + .num_var_ranges = common_num_var_ranges, }; diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c index 03cda01..fd5ac04 100644 --- a/arch/x86/kernel/cpu/mtrr/main.c +++ b/arch/x86/kernel/cpu/mtrr/main.c @@ -99,7 +99,7 @@ static int have_wrcomb(void) } /* This function returns the number of variable MTRRs */ -static void __init set_num_var_ranges(void) +int __init common_num_var_ranges(void) { unsigned long config = 0, dummy; @@ -109,7 +109,7 @@ static void __init set_num_var_ranges(void) config = 2; else if (is_cpu(CYRIX) || is_cpu(CENTAUR)) config = 8; - num_var_ranges = config & 0xff; + return config & 0xff; } static void __init init_table(void) @@ -622,12 +622,17 @@ int __initdata changed_by_mtrr_cleanup; void __init mtrr_bp_init(void) { u32 phys_addr; + init_ifs(); phys_addr = 32; if (cpu_has_mtrr) { mtrr_if = &generic_mtrr_ops; +#ifdef CONFIG_XEN_DOM0 + xen_init_mtrr(); +#endif + size_or_mask = 0xff000000; /* 36 bits */ size_and_mask = 0x00f00000; phys_addr = 36; @@ -685,7 +690,7 @@ void __init mtrr_bp_init(void) } if (mtrr_if) { - set_num_var_ranges(); + num_var_ranges = mtrr_if->num_var_ranges(); init_table(); if (use_intel()) { get_mtrr_state(); diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h index 77f67f7..3502f6c 100644 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h @@ -41,6 +41,8 @@ struct mtrr_ops { int (*validate_add_page)(unsigned long base, unsigned long size, unsigned int type); int (*have_wrcomb)(void); + + int (*num_var_ranges)(void); }; extern int generic_get_free_region(unsigned long base, unsigned long size, @@ -52,6 +54,8 @@ extern struct mtrr_ops generic_mtrr_ops; extern int positive_have_wrcomb(void); +extern int __init common_num_var_ranges(void); + /* library functions for processor-specific routines */ struct set_mtrr_context { unsigned long flags; @@ -89,6 +93,7 @@ void mtrr_wrmsr(unsigned, unsigned, unsigned); int amd_init_mtrr(void); int cyrix_init_mtrr(void); int centaur_init_mtrr(void); +void xen_init_mtrr(void); extern int changed_by_mtrr_cleanup; extern int mtrr_cleanup(unsigned address_bits); diff --git a/arch/x86/kernel/cpu/mtrr/xen.c b/arch/x86/kernel/cpu/mtrr/xen.c new file mode 100644 index 0000000..db3ef39 --- /dev/null +++ b/arch/x86/kernel/cpu/mtrr/xen.c @@ -0,0 +1,59 @@ +#include <linux/init.h> +#include <linux/proc_fs.h> +#include <linux/ctype.h> +#include <linux/module.h> +#include <linux/seq_file.h> +#include <asm/uaccess.h> +#include <linux/mutex.h> + +#include <asm/mtrr.h> +#include "mtrr.h" + +#include <xen/interface/platform.h> +#include <asm/xen/hypervisor.h> +#include <asm/xen/hypercall.h> + +static int __init xen_num_var_ranges(void); + +/* DOM0 TODO: Need to fill in the remaining mtrr methods to have full + * working userland mtrr support. */ +static struct mtrr_ops xen_mtrr_ops = { + .vendor = X86_VENDOR_UNKNOWN, +// .set = xen_set_mtrr, +// .get = xen_get_mtrr, + .get_free_region = generic_get_free_region, +// .validate_add_page = xen_validate_add_page, + .have_wrcomb = positive_have_wrcomb, + .use_intel_if = 0, + .num_var_ranges = xen_num_var_ranges, +}; + +static int __init xen_num_var_ranges(void) +{ + int ranges; + struct xen_platform_op op; + + for (ranges = 0; ; ranges++) { + op.cmd = XENPF_read_memtype; + op.u.read_memtype.reg = ranges; + if (HYPERVISOR_dom0_op(&op) != 0) + break; + } + return ranges; +} + +void __init xen_init_mtrr(void) +{ + struct cpuinfo_x86 *c = &boot_cpu_data; + + if (!xen_initial_domain()) + return; + + if ((!cpu_has(c, X86_FEATURE_MTRR)) && + (!cpu_has(c, X86_FEATURE_K6_MTRR)) && + (!cpu_has(c, X86_FEATURE_CYRIX_ARR)) && + (!cpu_has(c, X86_FEATURE_CENTAUR_MCR))) + return; + + mtrr_if = &xen_mtrr_ops; +} -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
From: Ian Campbell <ian.campbell@citrix.com> Impact: disable PAT under Xen Xen imposes a particular PAT layout on all paravirtual guests which does not match the layout Linux would like to use. Force PAT to be disabled until this is resolved. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/include/asm/pat.h | 5 +++++ arch/x86/mm/pat.c | 5 ----- arch/x86/xen/enlighten.c | 3 +++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/pat.h b/arch/x86/include/asm/pat.h index 2cd07b9..d434a4e 100644 --- a/arch/x86/include/asm/pat.h +++ b/arch/x86/include/asm/pat.h @@ -6,8 +6,13 @@ #ifdef CONFIG_X86_PAT extern int pat_enabled; +extern void pat_disable(const char *reason); #else static const int pat_enabled; +static inline void pat_disable(const char *reason) +{ + (void)reason; +} #endif extern void pat_init(void); diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index 640339e..4d2a4df 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -43,11 +43,6 @@ static int __init nopat(char *str) return 0; } early_param("nopat", nopat); -#else -static inline void pat_disable(const char *reason) -{ - (void)reason; -} #endif diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index f917381..48c91dc 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -49,6 +49,7 @@ #include <asm/pgtable.h> #include <asm/tlbflush.h> #include <asm/reboot.h> +#include <asm/pat.h> #include "xen-ops.h" #include "mmu.h" @@ -1034,6 +1035,8 @@ asmlinkage void __init xen_start_kernel(void) add_preferred_console("hvc", 0, NULL); } + pat_disable("PAT disabled on Xen"); + xen_raw_console_write("about to get started...\n"); /* Start the world */ -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 07/16] xen/dom0: use _PAGE_IOMAP in ioremap to do machine mappings
Impact: allow Xen domain to map real hardware In a Xen domain, ioremap operates on machine addresses, not pseudo-physical addresses. We use _PAGE_IOMAP to determine whether a mapping is intended for machine addresses. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/include/asm/xen/page.h | 8 +--- arch/x86/xen/enlighten.c | 4 ++- arch/x86/xen/mmu.c | 69 +++++++++++++++++++++++++++++++++++++- 3 files changed, 72 insertions(+), 9 deletions(-) diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h index 018a0a4..bf5f7d3 100644 --- a/arch/x86/include/asm/xen/page.h +++ b/arch/x86/include/asm/xen/page.h @@ -112,13 +112,9 @@ static inline xpaddr_t machine_to_phys(xmaddr_t machine) */ static inline unsigned long mfn_to_local_pfn(unsigned long mfn) { - extern unsigned long max_mapnr; unsigned long pfn = mfn_to_pfn(mfn); - if ((pfn < max_mapnr) - && !xen_feature(XENFEAT_auto_translated_physmap) - && (get_phys_to_machine(pfn) != mfn)) - return max_mapnr; /* force !pfn_valid() */ - /* XXX fixme; not true with sparsemem */ + if (get_phys_to_machine(pfn) != mfn) + return -1; /* force !pfn_valid() */ return pfn; } diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 48c91dc..72ac8a6 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -978,7 +978,9 @@ asmlinkage void __init xen_start_kernel(void) /* Prevent unwanted bits from being set in PTEs. */ __supported_pte_mask &= ~_PAGE_GLOBAL; - if (!xen_initial_domain()) + if (xen_initial_domain()) + __supported_pte_mask |= _PAGE_IOMAP; + else __supported_pte_mask &= ~(_PAGE_PWT | _PAGE_PCD); #ifdef CONFIG_X86_64 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index 33575ec..8962bf4 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c @@ -375,6 +375,28 @@ static bool xen_page_pinned(void *ptr) return PagePinned(page); } +static bool xen_iomap_pte(pte_t pte) +{ + return xen_initial_domain() && (pte_flags(pte) & _PAGE_IOMAP); +} + +static void xen_set_iomap_pte(pte_t *ptep, pte_t pteval) +{ + struct multicall_space mcs; + struct mmu_update *u; + + mcs = xen_mc_entry(sizeof(*u)); + u = mcs.args; + + /* ptep might be kmapped when using 32-bit HIGHPTE */ + u->ptr = arbitrary_virt_to_machine(ptep).maddr; + u->val = pte_val_ma(pteval); + + MULTI_mmu_update(mcs.mc, mcs.args, 1, NULL, DOMID_IO); + + xen_mc_issue(PARAVIRT_LAZY_MMU); +} + static void xen_extend_mmu_update(const struct mmu_update *update) { struct multicall_space mcs; @@ -451,6 +473,11 @@ void set_pte_mfn(unsigned long vaddr, unsigned long mfn, pgprot_t flags) void xen_set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pteval) { + if (xen_iomap_pte(pteval)) { + xen_set_iomap_pte(ptep, pteval); + goto out; + } + ADD_STATS(set_pte_at, 1); // ADD_STATS(set_pte_at_pinned, xen_page_pinned(ptep)); ADD_STATS(set_pte_at_current, mm == current->mm); @@ -521,8 +548,25 @@ static pteval_t pte_pfn_to_mfn(pteval_t val) return val; } +static pteval_t iomap_pte(pteval_t val) +{ + if (val & _PAGE_PRESENT) { + unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT; + pteval_t flags = val & PTE_FLAGS_MASK; + + /* We assume the pte frame number is a MFN, so + just use it as-is. */ + val = ((pteval_t)pfn << PAGE_SHIFT) | flags; + } + + return val; +} + pteval_t xen_pte_val(pte_t pte) { + if (xen_initial_domain() && (pte.pte & _PAGE_IOMAP)) + return pte.pte; + return pte_mfn_to_pfn(pte.pte); } PV_CALLEE_SAVE_REGS_THUNK(xen_pte_val); @@ -535,7 +579,11 @@ PV_CALLEE_SAVE_REGS_THUNK(xen_pgd_val); pte_t xen_make_pte(pteval_t pte) { - pte = pte_pfn_to_mfn(pte); + if (unlikely(xen_initial_domain() && (pte & _PAGE_IOMAP))) + pte = iomap_pte(pte); + else + pte = pte_pfn_to_mfn(pte); + return native_make_pte(pte); } PV_CALLEE_SAVE_REGS_THUNK(xen_make_pte); @@ -591,6 +639,11 @@ void xen_set_pud(pud_t *ptr, pud_t val) void xen_set_pte(pte_t *ptep, pte_t pte) { + if (xen_iomap_pte(pte)) { + xen_set_iomap_pte(ptep, pte); + return; + } + ADD_STATS(pte_update, 1); // ADD_STATS(pte_update_pinned, xen_page_pinned(ptep)); ADD_STATS(pte_update_batched, paravirt_get_lazy_mode() == PARAVIRT_LAZY_MMU); @@ -607,6 +660,11 @@ void xen_set_pte(pte_t *ptep, pte_t pte) #ifdef CONFIG_X86_PAE void xen_set_pte_atomic(pte_t *ptep, pte_t pte) { + if (xen_iomap_pte(pte)) { + xen_set_iomap_pte(ptep, pte); + return; + } + set_64bit((u64 *)ptep, native_pte_val(pte)); } @@ -1819,9 +1877,16 @@ static void xen_set_fixmap(unsigned idx, unsigned long phys, pgprot_t prot) pte = pfn_pte(phys, prot); break; - default: + case FIX_PARAVIRT_BOOTMAP: + /* This is an MFN, but it isn''t an IO mapping from the + IO domain */ pte = mfn_pte(phys, prot); break; + + default: + /* By default, set_fixmap is used for hardware mappings */ + pte = mfn_pte(phys, __pgprot(pgprot_val(prot) | _PAGE_IOMAP)); + break; } __native_set_fixmap(idx, pte); -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 08/16] xen/dom0: Use host E820 map
From: Ian Campbell <ian.campbell@citrix.com> Impact: synthesize virtual E820 using real one as template Unlike the non-paravirt Xen port we do not have distinct psuedo-physical and I/O memory resource-spaces and therefore resources in the two can clash. Fix this by registering a memory map which matches the underlying I/O map. Currently this wastes the memory in the reserved regions. Eventually we should remap this memory to the end of the address space. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/xen/setup.c | 45 +++++++++++++++++++++++++++++++++++++-- include/xen/interface/memory.h | 29 +++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index 3e4cf46..175396c 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c @@ -19,6 +19,7 @@ #include <xen/page.h> #include <xen/interface/callback.h> +#include <xen/interface/memory.h> #include <xen/interface/physdev.h> #include <xen/features.h> @@ -36,16 +37,54 @@ extern void xen_syscall32_target(void); /** * machine_specific_memory_setup - Hook for machine specific memory setup. **/ - char * __init xen_memory_setup(void) { unsigned long max_pfn = xen_start_info->nr_pages; + unsigned long long mem_end; + int rc; + struct xen_memory_map memmap; + /* + * This is rather large for a stack variable but this early in + * the boot process we know we have plenty slack space. + */ + struct e820entry map[E820MAX]; + int op = xen_initial_domain() ? + XENMEM_machine_memory_map : + XENMEM_memory_map; + int i; max_pfn = min(MAX_DOMAIN_PAGES, max_pfn); + mem_end = PFN_PHYS((u64)max_pfn); + + memmap.nr_entries = E820MAX; + set_xen_guest_handle(memmap.buffer, map); + + rc = HYPERVISOR_memory_op(op, &memmap); + if (rc == -ENOSYS) { + memmap.nr_entries = 1; + map[0].addr = 0ULL; + map[0].size = mem_end; + /* 8MB slack (to balance backend allocations). */ + map[0].size += 8ULL << 20; + map[0].type = E820_RAM; + rc = 0; + } + BUG_ON(rc); e820.nr_map = 0; - - e820_add_region(0, PFN_PHYS((u64)max_pfn), E820_RAM); + for (i = 0; i < memmap.nr_entries; i++) { + unsigned long long end = map[i].addr + map[i].size; + if (map[i].type == E820_RAM) { + if (map[i].addr > mem_end) + continue; + if (end > mem_end) { + /* Truncate region to max_mem. */ + map[i].size -= end - mem_end; + } + } + if (map[i].size > 0) + e820_add_region(map[i].addr, map[i].size, map[i].type); + } /* * Even though this is normal, usable memory under Xen, reserve diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h index af36ead..e6c6bcb 100644 --- a/include/xen/interface/memory.h +++ b/include/xen/interface/memory.h @@ -142,4 +142,33 @@ struct xen_translate_gpfn_list { }; DEFINE_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list); +/* + * Returns the pseudo-physical memory map as it was when the domain + * was started (specified by XENMEM_set_memory_map). + * arg == addr of struct xen_memory_map. + */ +#define XENMEM_memory_map 9 +struct xen_memory_map { + /* + * On call the number of entries which can be stored in buffer. On + * return the number of entries which have been stored in + * buffer. + */ + unsigned int nr_entries; + + /* + * Entries in the buffer are in the same format as returned by the + * BIOS INT 0x15 EAX=0xE820 call. + */ + GUEST_HANDLE(void) buffer; +}; +DEFINE_GUEST_HANDLE_STRUCT(xen_memory_map); + +/* + * Returns the real physical memory map. Passes the same structure as + * XENMEM_memory_map. + * arg == addr of struct xen_memory_map. + */ +#define XENMEM_machine_memory_map 10 + #endif /* __XEN_PUBLIC_MEMORY_H__ */ -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 09/16] xen: implement XENMEM_machphys_mapping
From: Ian Campbell <ian.campbell@citrix.com> Impact: add hypercall definitions This hypercall allows Xen to specify a non-default location for the machine to physical mapping. This capability is used when running a 32 bit domain 0 on a 64 bit hypervisor to shrink the hypervisor hole to exactly the size required. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/include/asm/xen/interface.h | 6 +++--- arch/x86/include/asm/xen/interface_32.h | 5 +++++ arch/x86/include/asm/xen/interface_64.h | 13 +------------ arch/x86/include/asm/xen/page.h | 7 ++++--- arch/x86/xen/enlighten.c | 7 +++++++ arch/x86/xen/mmu.c | 15 +++++++++++++++ include/xen/interface/memory.h | 13 +++++++++++++ 7 files changed, 48 insertions(+), 18 deletions(-) diff --git a/arch/x86/include/asm/xen/interface.h b/arch/x86/include/asm/xen/interface.h index e8506c1..1c10c88 100644 --- a/arch/x86/include/asm/xen/interface.h +++ b/arch/x86/include/asm/xen/interface.h @@ -61,9 +61,9 @@ DEFINE_GUEST_HANDLE(void); #define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START) #endif -#ifndef machine_to_phys_mapping -#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START) -#endif +#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START) +#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END) +#define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>__MACH2PHYS_SHIFT) /* Maximum number of virtual CPUs in multi-processor guests. */ #define MAX_VIRT_CPUS 32 diff --git a/arch/x86/include/asm/xen/interface_32.h b/arch/x86/include/asm/xen/interface_32.h index 42a7e00..8413688 100644 --- a/arch/x86/include/asm/xen/interface_32.h +++ b/arch/x86/include/asm/xen/interface_32.h @@ -32,6 +32,11 @@ /* And the trap vector is... */ #define TRAP_INSTR "int $0x82" +#define __MACH2PHYS_VIRT_START 0xF5800000 +#define __MACH2PHYS_VIRT_END 0xF6800000 + +#define __MACH2PHYS_SHIFT 2 + /* * Virtual addresses beyond this are not modifiable by guest OSes. The * machine->physical mapping table starts at this address, read-only. diff --git a/arch/x86/include/asm/xen/interface_64.h b/arch/x86/include/asm/xen/interface_64.h index 100d266..839a481 100644 --- a/arch/x86/include/asm/xen/interface_64.h +++ b/arch/x86/include/asm/xen/interface_64.h @@ -39,18 +39,7 @@ #define __HYPERVISOR_VIRT_END 0xFFFF880000000000 #define __MACH2PHYS_VIRT_START 0xFFFF800000000000 #define __MACH2PHYS_VIRT_END 0xFFFF804000000000 - -#ifndef HYPERVISOR_VIRT_START -#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START) -#define HYPERVISOR_VIRT_END mk_unsigned_long(__HYPERVISOR_VIRT_END) -#endif - -#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START) -#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END) -#define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>3) -#ifndef machine_to_phys_mapping -#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START) -#endif +#define __MACH2PHYS_SHIFT 3 /* * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base) diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h index bf5f7d3..d5fb2e8 100644 --- a/arch/x86/include/asm/xen/page.h +++ b/arch/x86/include/asm/xen/page.h @@ -5,6 +5,7 @@ #include <linux/types.h> #include <linux/spinlock.h> #include <linux/pfn.h> +#include <linux/mm.h> #include <asm/uaccess.h> #include <asm/page.h> @@ -35,6 +36,8 @@ typedef struct xpaddr { #define MAX_DOMAIN_PAGES \ ((unsigned long)((u64)CONFIG_XEN_MAX_DOMAIN_MEMORY * 1024 * 1024 * 1024 / PAGE_SIZE)) +extern unsigned long *machine_to_phys_mapping; +extern unsigned int machine_to_phys_order; extern unsigned long get_phys_to_machine(unsigned long pfn); extern void set_phys_to_machine(unsigned long pfn, unsigned long mfn); @@ -62,10 +65,8 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn) if (xen_feature(XENFEAT_auto_translated_physmap)) return mfn; -#if 0 if (unlikely((mfn >> machine_to_phys_order) != 0)) - return max_mapnr; -#endif + return ~0; pfn = 0; /* diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 72ac8a6..4b52f4c 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -63,6 +63,11 @@ DEFINE_PER_CPU(struct vcpu_info, xen_vcpu_info); enum xen_domain_type xen_domain_type = XEN_NATIVE; EXPORT_SYMBOL_GPL(xen_domain_type); +unsigned long *machine_to_phys_mapping = (void *)MACH2PHYS_VIRT_START; +EXPORT_SYMBOL(machine_to_phys_mapping); +unsigned int machine_to_phys_order; +EXPORT_SYMBOL(machine_to_phys_order); + struct start_info *xen_start_info; EXPORT_SYMBOL_GPL(xen_start_info); @@ -928,6 +933,8 @@ asmlinkage void __init xen_start_kernel(void) xen_setup_features(); + xen_setup_machphys_mapping(); + /* Install Xen paravirt ops */ pv_info = xen_info; pv_init_ops = xen_init_ops; diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index 8962bf4..b35571f 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c @@ -57,6 +57,7 @@ #include <xen/page.h> #include <xen/interface/xen.h> #include <xen/interface/version.h> +#include <xen/interface/memory.h> #include <xen/hvc-console.h> #include "multicalls.h" @@ -1729,6 +1730,20 @@ static __init void xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn) set_page_prot(pmd, PAGE_KERNEL_RO); } +void __init xen_setup_machphys_mapping(void) +{ + struct xen_machphys_mapping mapping; + unsigned long machine_to_phys_nr_ents; + + if (HYPERVISOR_memory_op(XENMEM_machphys_mapping, &mapping) == 0) { + machine_to_phys_mapping = (unsigned long *)mapping.v_start; + machine_to_phys_nr_ents = mapping.max_mfn + 1; + } else { + machine_to_phys_nr_ents = MACH2PHYS_NR_ENTRIES; + } + machine_to_phys_order = fls(machine_to_phys_nr_ents - 1); +} + #ifdef CONFIG_X86_64 static void convert_pfn_mfn(void *v) { diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h index e6c6bcb..f548f7c 100644 --- a/include/xen/interface/memory.h +++ b/include/xen/interface/memory.h @@ -97,6 +97,19 @@ struct xen_machphys_mfn_list { DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mfn_list); /* + * Returns the location in virtual address space of the machine_to_phys + * mapping table. Architectures which do not have a m2p table, or which do not + * map it by default into guest address space, do not implement this command. + * arg == addr of xen_machphys_mapping_t. + */ +#define XENMEM_machphys_mapping 12 +struct xen_machphys_mapping { + unsigned long v_start, v_end; /* Start and end virtual addresses. */ + unsigned long max_mfn; /* Maximum MFN that can be looked up. */ +}; +DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mapping_t); + +/* * Sets the GPFN at which a particular page appears in the specified guest''s * pseudophysical address space. * arg == addr of xen_add_to_physmap_t. -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 10/16] xen: clear reserved bits in l3 entries given in the initial pagetables
From: Ian Campbell <ian.campbell@citrix.com> Impact: workaround Xen bug in 32-on-64 dom0 In native PAE, the only flag that may be legitimately set in an L3 entry is Present. When Xen grafts the top-level PAE L3 pagetable entries into the L4 pagetable, it must also set the other permissions flags so that the mapped pages are actually accessible. However, due to a bug in the hypervisor, it validates update to the L3 entries as formal PAE entries, so it will refuse to validate these entries with the extra bits requires for 4-level pagetables. This patch simply masks the entries back to the bare PAE level, leaving Xen to add whatever bits it feels are necessary. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/xen/mmu.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index b35571f..55da7f9 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c @@ -1835,6 +1835,7 @@ __init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn) { pmd_t *kernel_pmd; + int i; max_pfn_mapped = PFN_DOWN(__pa(xen_start_info->pt_base) + xen_start_info->nr_pt_frames * PAGE_SIZE + @@ -1846,6 +1847,20 @@ __init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd, xen_map_identity_early(level2_kernel_pgt, max_pfn); memcpy(swapper_pg_dir, pgd, sizeof(pgd_t) * PTRS_PER_PGD); + + /* + * When running a 32 bit domain 0 on a 64 bit hypervisor a + * pinned L3 (such as the initial pgd here) contains bits + * which are reserved in the PAE layout but not in the 64 bit + * layout. Unfortunately some versions of the hypervisor + * (incorrectly) validate compat mode guests against the PAE + * layout and hence will not allow such a pagetable to be + * pinned by the guest. Therefore we mask off only the PFN and + * Present bits of the supplied L3. + */ + for (i = 0; i < PTRS_PER_PGD; i++) + swapper_pg_dir[i].pgd &= (PTE_PFN_MASK | _PAGE_PRESENT); + set_pgd(&swapper_pg_dir[KERNEL_PGD_BOUNDARY], __pgd(__pa(level2_kernel_pgt) | _PAGE_PRESENT)); -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 11/16] xen: allow enable use of VGA console on dom0
Impact: make VGA console work in dom0 Get the information about the VGA console hardware from Xen, and put it into the form the bootloader normally generates, so that the rest of the kernel can deal with VGA as usual. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/xen/Makefile | 3 +- arch/x86/xen/enlighten.c | 10 ++++++ arch/x86/xen/vga.c | 67 +++++++++++++++++++++++++++++++++++++++++++ arch/x86/xen/xen-ops.h | 11 +++++++ include/xen/interface/xen.h | 39 +++++++++++++++++++++++++ 5 files changed, 129 insertions(+), 1 deletions(-) create mode 100644 arch/x86/xen/vga.c diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile index 3b767d0..c4cda96 100644 --- a/arch/x86/xen/Makefile +++ b/arch/x86/xen/Makefile @@ -10,4 +10,5 @@ obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \ grant-table.o suspend.o obj-$(CONFIG_SMP) += smp.o spinlock.o -obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o \ No newline at end of file +obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o +obj-$(CONFIG_XEN_DOM0) += vga.o diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 4b52f4c..ece141c 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -1042,6 +1042,16 @@ asmlinkage void __init xen_start_kernel(void) add_preferred_console("xenboot", 0, NULL); add_preferred_console("tty", 0, NULL); add_preferred_console("hvc", 0, NULL); + + boot_params.screen_info.orig_video_isVGA = 0; + } else { + const struct dom0_vga_console_info *info + (void *)((char *)xen_start_info + + xen_start_info->console.dom0.info_off); + + xen_init_vga(info, xen_start_info->console.dom0.info_size); + xen_start_info->console.domU.mfn = 0; + xen_start_info->console.domU.evtchn = 0; } pat_disable("PAT disabled on Xen"); diff --git a/arch/x86/xen/vga.c b/arch/x86/xen/vga.c new file mode 100644 index 0000000..f2fca2c --- /dev/null +++ b/arch/x86/xen/vga.c @@ -0,0 +1,67 @@ +#include <linux/screen_info.h> +#include <linux/init.h> + +#include <asm/bootparam.h> +#include <asm/setup.h> + +#include <xen/interface/xen.h> + +#include "xen-ops.h" + +void __init xen_init_vga(const struct dom0_vga_console_info *info, size_t size) +{ + struct screen_info *screen_info = &boot_params.screen_info; + + /* This is drawn from a dump from vgacon:startup in + * standard Linux. */ + screen_info->orig_video_mode = 3; + screen_info->orig_video_isVGA = 1; + screen_info->orig_video_lines = 25; + screen_info->orig_video_cols = 80; + screen_info->orig_video_ega_bx = 3; + screen_info->orig_video_points = 16; + screen_info->orig_y = screen_info->orig_video_lines - 1; + + switch (info->video_type) { + case XEN_VGATYPE_TEXT_MODE_3: + if (size < offsetof(struct dom0_vga_console_info, u.text_mode_3) + + sizeof(info->u.text_mode_3)) + break; + screen_info->orig_video_lines = info->u.text_mode_3.rows; + screen_info->orig_video_cols = info->u.text_mode_3.columns; + screen_info->orig_x = info->u.text_mode_3.cursor_x; + screen_info->orig_y = info->u.text_mode_3.cursor_y; + screen_info->orig_video_points + info->u.text_mode_3.font_height; + break; + + case XEN_VGATYPE_VESA_LFB: + if (size < offsetof(struct dom0_vga_console_info, + u.vesa_lfb.gbl_caps)) + break; + screen_info->orig_video_isVGA = VIDEO_TYPE_VLFB; + screen_info->lfb_width = info->u.vesa_lfb.width; + screen_info->lfb_height = info->u.vesa_lfb.height; + screen_info->lfb_depth = info->u.vesa_lfb.bits_per_pixel; + screen_info->lfb_base = info->u.vesa_lfb.lfb_base; + screen_info->lfb_size = info->u.vesa_lfb.lfb_size; + screen_info->lfb_linelength = info->u.vesa_lfb.bytes_per_line; + screen_info->red_size = info->u.vesa_lfb.red_size; + screen_info->red_pos = info->u.vesa_lfb.red_pos; + screen_info->green_size = info->u.vesa_lfb.green_size; + screen_info->green_pos = info->u.vesa_lfb.green_pos; + screen_info->blue_size = info->u.vesa_lfb.blue_size; + screen_info->blue_pos = info->u.vesa_lfb.blue_pos; + screen_info->rsvd_size = info->u.vesa_lfb.rsvd_size; + screen_info->rsvd_pos = info->u.vesa_lfb.rsvd_pos; + if (size >= offsetof(struct dom0_vga_console_info, + u.vesa_lfb.gbl_caps) + + sizeof(info->u.vesa_lfb.gbl_caps)) + screen_info->capabilities = info->u.vesa_lfb.gbl_caps; + if (size >= offsetof(struct dom0_vga_console_info, + u.vesa_lfb.mode_attrs) + + sizeof(info->u.vesa_lfb.mode_attrs)) + screen_info->vesa_attributes = info->u.vesa_lfb.mode_attrs; + break; + } +} diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index 6ff6203..40abcef 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h @@ -72,6 +72,17 @@ static inline void xen_smp_init(void) {} #endif +struct dom0_vga_console_info; + +#ifdef CONFIG_XEN_DOM0 +void xen_init_vga(const struct dom0_vga_console_info *, size_t size); +#else +static inline void xen_init_vga(const struct dom0_vga_console_info *info, + size_t size) +{ +} +#endif + /* Declare an asm function, along with symbols needed to make it inlineable */ #define DECL_ASM(ret, name, ...) \ diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h index 18b5599..6c0af21 100644 --- a/include/xen/interface/xen.h +++ b/include/xen/interface/xen.h @@ -449,6 +449,45 @@ struct start_info { int8_t cmd_line[MAX_GUEST_CMDLINE]; }; +struct dom0_vga_console_info { + uint8_t video_type; /* DOM0_VGA_CONSOLE_??? */ +#define XEN_VGATYPE_TEXT_MODE_3 0x03 +#define XEN_VGATYPE_VESA_LFB 0x23 + + union { + struct { + /* Font height, in pixels. */ + uint16_t font_height; + /* Cursor location (column, row). */ + uint16_t cursor_x, cursor_y; + /* Number of rows and columns (dimensions in characters). */ + uint16_t rows, columns; + } text_mode_3; + + struct { + /* Width and height, in pixels. */ + uint16_t width, height; + /* Bytes per scan line. */ + uint16_t bytes_per_line; + /* Bits per pixel. */ + uint16_t bits_per_pixel; + /* LFB physical address, and size (in units of 64kB). */ + uint32_t lfb_base; + uint32_t lfb_size; + /* RGB mask offsets and sizes, as defined by VBE 1.2+ */ + uint8_t red_pos, red_size; + uint8_t green_pos, green_size; + uint8_t blue_pos, blue_size; + uint8_t rsvd_pos, rsvd_size; + + /* VESA capabilities (offset 0xa, VESA command 0x4f00). */ + uint32_t gbl_caps; + /* Mode attributes (offset 0x0, VESA command 0x4f01). */ + uint16_t mode_attrs; + } vesa_lfb; + } u; +}; + /* These flags are passed in the ''flags'' field of start_info_t. */ #define SIF_PRIVILEGED (1<<0) /* Is the domain privileged? */ #define SIF_INITDOMAIN (1<<1) /* Is this the initial control domain? */ -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 12/16] xen/dom0: add XEN_DOM0 config option
Impact: add Kconfig to enable XEN_DOM0 Allow dom0 to be configured. Requires more patches to do something useful. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/xen/Kconfig | 26 ++++++++++++++++++++++++++ arch/x86/xen/enlighten.c | 5 +++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig index b83e119..fe69286 100644 --- a/arch/x86/xen/Kconfig +++ b/arch/x86/xen/Kconfig @@ -36,3 +36,29 @@ 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_DOM0 + bool "Enable Xen privileged domain support" + depends on XEN && X86_IO_APIC && ACPI + help + The Xen hypervisor requires a privileged domain ("dom0") to + actually manage the machine, provide devices drivers, etc. + This option enables dom0 support. A dom0 kernel can also + run as an unprivileged domU kernel, or a kernel running + native on bare hardware. + +# Dummy symbol since people have come to rely on the PRIVILEGED_GUEST +# name in tools. +config XEN_PRIVILEGED_GUEST + def_bool XEN_DOM0 + +config XEN_PCI_PASSTHROUGH + bool #"Enable support for Xen PCI passthrough devices" + depends on XEN && PCI + help + Enable support for passing PCI devices through to + unprivileged domains. (COMPLETELY UNTESTED) + +config XEN_DOM0_PCI + def_bool y + depends on XEN_DOM0 && PCI diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index ece141c..507488a 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -170,9 +170,10 @@ static void __init xen_banner(void) printk(KERN_INFO "Booting paravirtualized kernel on %s\n", pv_info.name); - printk(KERN_INFO "Xen version: %d.%d%s%s\n", + printk(KERN_INFO "Xen version: %d.%d%s%s%s\n", version >> 16, version & 0xffff, extra.extraversion, - xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : ""); + xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : "", + xen_initial_domain() ? " (dom0)" : ""); } static __read_mostly unsigned int cpuid_leaf1_edx_mask = ~0; -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 13/16] x86: make /dev/mem mappings _PAGE_IOMAP
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Impact: allow hardware to be mapped via /dev/mem Use _PAGE_IOMAP on /dev/mem mappings. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/mm/pat.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index 4d2a4df..56899ae 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -504,7 +504,7 @@ int free_memtype(u64 start, u64 end) pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, unsigned long size, pgprot_t vma_prot) { - return vma_prot; + return __pgprot(pgprot_val(vma_prot) | _PAGE_IOMAP); } #ifdef CONFIG_STRICT_DEVMEM -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 14/16] paravirtualize IO permission bitmap
From: Christophe Saout <chtephan@leto.intern.saout.de> Impact: make ioperm bitmap work under Xen A PV Xen guest kernel has no TSS of its own, so the IO permission bitmap must be paravirtualized. This patch adds set_io_bitmap as a paravirt op, and defines a native version which updates the tss, and a Xen version which uses a hypercall. This is much easier now that 32 and 64-bit use the same code to manage the IO bitmap. Signed-off-by: Christophe Saout <chtephan@leto.intern.saout.de> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/include/asm/paravirt.h | 9 +++++++++ arch/x86/include/asm/processor.h | 4 ++++ arch/x86/kernel/ioport.c | 34 ++++++++++++++++++++++++++-------- arch/x86/kernel/paravirt.c | 1 + arch/x86/kernel/process.c | 27 +++++++-------------------- arch/x86/xen/enlighten.c | 16 ++++++++++++++++ 6 files changed, 63 insertions(+), 28 deletions(-) diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h index bc384be..fd2c31b 100644 --- a/arch/x86/include/asm/paravirt.h +++ b/arch/x86/include/asm/paravirt.h @@ -156,6 +156,8 @@ struct pv_cpu_ops { void (*load_sp0)(struct tss_struct *tss, struct thread_struct *t); void (*set_iopl_mask)(unsigned mask); + void (*set_io_bitmap)(struct thread_struct *thread, + int changed, unsigned long bytes_updated); void (*wbinvd)(void); void (*io_delay)(void); @@ -996,11 +998,18 @@ static inline void write_idt_entry(gate_desc *dt, int entry, const gate_desc *g) { PVOP_VCALL3(pv_cpu_ops.write_idt_entry, dt, entry, g); } + static inline void set_iopl_mask(unsigned mask) { PVOP_VCALL1(pv_cpu_ops.set_iopl_mask, mask); } +static inline void set_io_bitmap(struct thread_struct *thread, + int changed, unsigned long bytes_updated) +{ + PVOP_VCALL3(pv_cpu_ops.set_io_bitmap, thread, changed, bytes_updated); +} + /* The paravirtualized I/O functions */ static inline void slow_down_io(void) { diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 34c5237..0ed4cba 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -538,6 +538,9 @@ static inline void native_set_iopl_mask(unsigned mask) #endif } +extern void native_set_io_bitmap(struct thread_struct *thread, + int changed, unsigned long updated_bytes); + static inline void native_load_sp0(struct tss_struct *tss, struct thread_struct *thread) { @@ -579,6 +582,7 @@ static inline void load_sp0(struct tss_struct *tss, } #define set_iopl_mask native_set_iopl_mask +#define set_io_bitmap native_set_io_bitmap #endif /* CONFIG_PARAVIRT */ /* diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c index 99c4d30..5a12c9f 100644 --- a/arch/x86/kernel/ioport.c +++ b/arch/x86/kernel/ioport.c @@ -30,14 +30,31 @@ static void set_bitmap(unsigned long *bitmap, unsigned int base, } } +void native_set_io_bitmap(struct thread_struct *t, + int changed, unsigned long bytes_updated) +{ + struct tss_struct *tss; + + if (!bytes_updated) + return; + + tss = &__get_cpu_var(init_tss); + + /* Update the TSS: */ + if (t->io_bitmap_ptr) + memcpy(tss->io_bitmap, t->io_bitmap_ptr, bytes_updated); + else + memset(tss->io_bitmap, 0xff, bytes_updated); +} + /* * this changes the io permissions bitmap in the current task. */ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) { struct thread_struct *t = ¤t->thread; - struct tss_struct *tss; unsigned int i, max_long, bytes, bytes_updated; + int changed; if ((from + num <= from) || (from + num > IO_BITMAP_BITS)) return -EINVAL; @@ -58,16 +75,18 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) memset(bitmap, 0xff, IO_BITMAP_BYTES); t->io_bitmap_ptr = bitmap; set_thread_flag(TIF_IO_BITMAP); - } + changed = 1; + } else + changed = 0; /* - * do it in the per-thread copy and in the TSS ... + * do it in the per-thread copy * - * Disable preemption via get_cpu() - we must not switch away + * Disable preemption - we must not switch away * because the ->io_bitmap_max value must match the bitmap * contents: */ - tss = &per_cpu(init_tss, get_cpu()); + preempt_disable(); set_bitmap(t->io_bitmap_ptr, from, num, !turn_on); @@ -85,10 +104,9 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) t->io_bitmap_max = bytes; - /* Update the TSS: */ - memcpy(tss->io_bitmap, t->io_bitmap_ptr, bytes_updated); + set_io_bitmap(t, changed, bytes_updated); - put_cpu(); + preempt_enable(); return 0; } diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c index aa34423..1c15178 100644 --- a/arch/x86/kernel/paravirt.c +++ b/arch/x86/kernel/paravirt.c @@ -398,6 +398,7 @@ struct pv_cpu_ops pv_cpu_ops = { .swapgs = native_swapgs, .set_iopl_mask = native_set_iopl_mask, + .set_io_bitmap = native_set_io_bitmap, .io_delay = native_io_delay, .start_context_switch = paravirt_nop, diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index ca98915..a0d9544 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -71,16 +71,12 @@ void exit_thread(void) unsigned long *bp = t->io_bitmap_ptr; if (bp) { - struct tss_struct *tss = &per_cpu(init_tss, get_cpu()); - + preempt_disable(); t->io_bitmap_ptr = NULL; clear_thread_flag(TIF_IO_BITMAP); - /* - * Careful, clear this in the TSS too: - */ - memset(tss->io_bitmap, 0xff, t->io_bitmap_max); + set_io_bitmap(t, 1, t->io_bitmap_max); t->io_bitmap_max = 0; - put_cpu(); + preempt_enable(); kfree(bp); } @@ -211,19 +207,10 @@ void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p, hard_enable_TSC(); } - if (test_tsk_thread_flag(next_p, TIF_IO_BITMAP)) { - /* - * Copy the relevant range of the IO bitmap. - * Normally this is 128 bytes or less: - */ - memcpy(tss->io_bitmap, next->io_bitmap_ptr, - max(prev->io_bitmap_max, next->io_bitmap_max)); - } else if (test_tsk_thread_flag(prev_p, TIF_IO_BITMAP)) { - /* - * Clear any possible leftover bits: - */ - memset(tss->io_bitmap, 0xff, prev->io_bitmap_max); - } + if (test_tsk_thread_flag(next_p, TIF_IO_BITMAP) || + test_tsk_thread_flag(prev_p, TIF_IO_BITMAP)) + set_io_bitmap(next, 1, + max(prev->io_bitmap_max, next->io_bitmap_max)); } int sys_fork(struct pt_regs *regs) diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 507488a..0cc5a3b 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -569,6 +569,21 @@ static void xen_set_iopl_mask(unsigned mask) HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl); } +static void xen_set_io_bitmap(struct thread_struct *thread, + int changed, unsigned long bytes_updated) +{ + struct physdev_set_iobitmap set_iobitmap; + + if (!changed) + return; + + set_xen_guest_handle(set_iobitmap.bitmap, + (char *)thread->io_bitmap_ptr); + set_iobitmap.nr_ports = thread->io_bitmap_ptr ? IO_BITMAP_BITS : 0; + WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, + &set_iobitmap)); +} + static void xen_io_delay(void) { } @@ -862,6 +877,7 @@ static const struct pv_cpu_ops xen_cpu_ops __initdata = { .load_sp0 = xen_load_sp0, .set_iopl_mask = xen_set_iopl_mask, + .set_io_bitmap = xen_set_io_bitmap, .io_delay = xen_io_delay, /* Xen takes care of %gs when switching to usermode for us */ -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 15/16] x86: don''t need "changed" parameter for set_io_bitmap()
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> Impact: cleanup The "changed" parameter isn''t really used, so don''t bother passing it. (xen_set_io_bitmap can keep track of it for itself, if it wants.) Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/include/asm/paravirt.h | 6 +++--- arch/x86/include/asm/processor.h | 2 +- arch/x86/kernel/ioport.c | 9 +++------ arch/x86/kernel/process.c | 4 ++-- arch/x86/xen/enlighten.c | 5 +---- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h index fd2c31b..56acbe8 100644 --- a/arch/x86/include/asm/paravirt.h +++ b/arch/x86/include/asm/paravirt.h @@ -157,7 +157,7 @@ struct pv_cpu_ops { void (*set_iopl_mask)(unsigned mask); void (*set_io_bitmap)(struct thread_struct *thread, - int changed, unsigned long bytes_updated); + unsigned long bytes_updated); void (*wbinvd)(void); void (*io_delay)(void); @@ -1005,9 +1005,9 @@ static inline void set_iopl_mask(unsigned mask) } static inline void set_io_bitmap(struct thread_struct *thread, - int changed, unsigned long bytes_updated) + unsigned long bytes_updated) { - PVOP_VCALL3(pv_cpu_ops.set_io_bitmap, thread, changed, bytes_updated); + PVOP_VCALL2(pv_cpu_ops.set_io_bitmap, thread, bytes_updated); } /* The paravirtualized I/O functions */ diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 0ed4cba..15d0769 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -539,7 +539,7 @@ static inline void native_set_iopl_mask(unsigned mask) } extern void native_set_io_bitmap(struct thread_struct *thread, - int changed, unsigned long updated_bytes); + unsigned long updated_bytes); static inline void native_load_sp0(struct tss_struct *tss, struct thread_struct *thread) diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c index 5a12c9f..642660f 100644 --- a/arch/x86/kernel/ioport.c +++ b/arch/x86/kernel/ioport.c @@ -31,7 +31,7 @@ static void set_bitmap(unsigned long *bitmap, unsigned int base, } void native_set_io_bitmap(struct thread_struct *t, - int changed, unsigned long bytes_updated) + unsigned long bytes_updated) { struct tss_struct *tss; @@ -54,7 +54,6 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) { struct thread_struct *t = ¤t->thread; unsigned int i, max_long, bytes, bytes_updated; - int changed; if ((from + num <= from) || (from + num > IO_BITMAP_BITS)) return -EINVAL; @@ -75,9 +74,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) memset(bitmap, 0xff, IO_BITMAP_BYTES); t->io_bitmap_ptr = bitmap; set_thread_flag(TIF_IO_BITMAP); - changed = 1; - } else - changed = 0; + } /* * do it in the per-thread copy @@ -104,7 +101,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on) t->io_bitmap_max = bytes; - set_io_bitmap(t, changed, bytes_updated); + set_io_bitmap(t, bytes_updated); preempt_enable(); diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index a0d9544..ef9b919 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -74,7 +74,7 @@ void exit_thread(void) preempt_disable(); t->io_bitmap_ptr = NULL; clear_thread_flag(TIF_IO_BITMAP); - set_io_bitmap(t, 1, t->io_bitmap_max); + set_io_bitmap(t, t->io_bitmap_max); t->io_bitmap_max = 0; preempt_enable(); kfree(bp); @@ -209,7 +209,7 @@ void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p, if (test_tsk_thread_flag(next_p, TIF_IO_BITMAP) || test_tsk_thread_flag(prev_p, TIF_IO_BITMAP)) - set_io_bitmap(next, 1, + set_io_bitmap(next, max(prev->io_bitmap_max, next->io_bitmap_max)); } diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 0cc5a3b..e231cb7 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -570,13 +570,10 @@ static void xen_set_iopl_mask(unsigned mask) } static void xen_set_io_bitmap(struct thread_struct *thread, - int changed, unsigned long bytes_updated) + unsigned long bytes_updated) { struct physdev_set_iobitmap set_iobitmap; - if (!changed) - return; - set_xen_guest_handle(set_iobitmap.bitmap, (char *)thread->io_bitmap_ptr); set_iobitmap.nr_ports = thread->io_bitmap_ptr ? IO_BITMAP_BITS : 0; -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-07 21:10 UTC
[Xen-devel] [PATCH 16/16] xen: checkpatch cleanups
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> General whitespacery. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> --- arch/x86/include/asm/paravirt.h | 4 +- arch/x86/include/asm/processor.h | 2 +- arch/x86/kernel/cpu/mtrr/xen.c | 3 - arch/x86/kernel/ioport.c | 2 +- arch/x86/kernel/process.c | 4 +- arch/x86/xen/enlighten.c | 11 ++- arch/x86/xen/vga.c | 15 ++-- drivers/char/hvc_xen.c | 2 +- include/xen/interface/platform.h | 166 ++++++++++++++++++-------------------- include/xen/interface/xen.h | 66 ++++++++-------- 10 files changed, 132 insertions(+), 143 deletions(-) diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h index 56acbe8..5b74269 100644 --- a/arch/x86/include/asm/paravirt.h +++ b/arch/x86/include/asm/paravirt.h @@ -157,7 +157,7 @@ struct pv_cpu_ops { void (*set_iopl_mask)(unsigned mask); void (*set_io_bitmap)(struct thread_struct *thread, - unsigned long bytes_updated); + unsigned long bytes_updated); void (*wbinvd)(void); void (*io_delay)(void); @@ -1005,7 +1005,7 @@ static inline void set_iopl_mask(unsigned mask) } static inline void set_io_bitmap(struct thread_struct *thread, - unsigned long bytes_updated) + unsigned long bytes_updated) { PVOP_VCALL2(pv_cpu_ops.set_io_bitmap, thread, bytes_updated); } diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 15d0769..4a8d13b 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -539,7 +539,7 @@ static inline void native_set_iopl_mask(unsigned mask) } extern void native_set_io_bitmap(struct thread_struct *thread, - unsigned long updated_bytes); + unsigned long updated_bytes); static inline void native_load_sp0(struct tss_struct *tss, struct thread_struct *thread) diff --git a/arch/x86/kernel/cpu/mtrr/xen.c b/arch/x86/kernel/cpu/mtrr/xen.c index db3ef39..6760907 100644 --- a/arch/x86/kernel/cpu/mtrr/xen.c +++ b/arch/x86/kernel/cpu/mtrr/xen.c @@ -19,10 +19,7 @@ static int __init xen_num_var_ranges(void); * working userland mtrr support. */ static struct mtrr_ops xen_mtrr_ops = { .vendor = X86_VENDOR_UNKNOWN, -// .set = xen_set_mtrr, -// .get = xen_get_mtrr, .get_free_region = generic_get_free_region, -// .validate_add_page = xen_validate_add_page, .have_wrcomb = positive_have_wrcomb, .use_intel_if = 0, .num_var_ranges = xen_num_var_ranges, diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c index 642660f..0a421d3 100644 --- a/arch/x86/kernel/ioport.c +++ b/arch/x86/kernel/ioport.c @@ -31,7 +31,7 @@ static void set_bitmap(unsigned long *bitmap, unsigned int base, } void native_set_io_bitmap(struct thread_struct *t, - unsigned long bytes_updated) + unsigned long bytes_updated) { struct tss_struct *tss; diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index ef9b919..0934c09 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -209,8 +209,8 @@ void __switch_to_xtra(struct task_struct *prev_p, struct task_struct *next_p, if (test_tsk_thread_flag(next_p, TIF_IO_BITMAP) || test_tsk_thread_flag(prev_p, TIF_IO_BITMAP)) - set_io_bitmap(next, - max(prev->io_bitmap_max, next->io_bitmap_max)); + set_io_bitmap(next, max(prev->io_bitmap_max, + next->io_bitmap_max)); } int sys_fork(struct pt_regs *regs) diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index e231cb7..2d0341f 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -172,7 +172,8 @@ static void __init xen_banner(void) pv_info.name); printk(KERN_INFO "Xen version: %d.%d%s%s%s\n", version >> 16, version & 0xffff, extra.extraversion, - xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : "", + xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? + " (preserve-AD)" : "", xen_initial_domain() ? " (dom0)" : ""); } @@ -570,15 +571,15 @@ static void xen_set_iopl_mask(unsigned mask) } static void xen_set_io_bitmap(struct thread_struct *thread, - unsigned long bytes_updated) + unsigned long bytes_updated) { struct physdev_set_iobitmap set_iobitmap; set_xen_guest_handle(set_iobitmap.bitmap, - (char *)thread->io_bitmap_ptr); + (char *)thread->io_bitmap_ptr); set_iobitmap.nr_ports = thread->io_bitmap_ptr ? IO_BITMAP_BITS : 0; WARN_ON(HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, - &set_iobitmap)); + &set_iobitmap)); } static void xen_io_delay(void) @@ -1061,7 +1062,7 @@ asmlinkage void __init xen_start_kernel(void) } else { const struct dom0_vga_console_info *info (void *)((char *)xen_start_info + - xen_start_info->console.dom0.info_off); + xen_start_info->console.dom0.info_off); xen_init_vga(info, xen_start_info->console.dom0.info_size); xen_start_info->console.domU.mfn = 0; diff --git a/arch/x86/xen/vga.c b/arch/x86/xen/vga.c index f2fca2c..ab3b39e 100644 --- a/arch/x86/xen/vga.c +++ b/arch/x86/xen/vga.c @@ -25,7 +25,7 @@ void __init xen_init_vga(const struct dom0_vga_console_info *info, size_t size) switch (info->video_type) { case XEN_VGATYPE_TEXT_MODE_3: if (size < offsetof(struct dom0_vga_console_info, u.text_mode_3) - + sizeof(info->u.text_mode_3)) + + sizeof(info->u.text_mode_3)) break; screen_info->orig_video_lines = info->u.text_mode_3.rows; screen_info->orig_video_cols = info->u.text_mode_3.columns; @@ -37,7 +37,7 @@ void __init xen_init_vga(const struct dom0_vga_console_info *info, size_t size) case XEN_VGATYPE_VESA_LFB: if (size < offsetof(struct dom0_vga_console_info, - u.vesa_lfb.gbl_caps)) + u.vesa_lfb.gbl_caps)) break; screen_info->orig_video_isVGA = VIDEO_TYPE_VLFB; screen_info->lfb_width = info->u.vesa_lfb.width; @@ -55,13 +55,14 @@ void __init xen_init_vga(const struct dom0_vga_console_info *info, size_t size) screen_info->rsvd_size = info->u.vesa_lfb.rsvd_size; screen_info->rsvd_pos = info->u.vesa_lfb.rsvd_pos; if (size >= offsetof(struct dom0_vga_console_info, - u.vesa_lfb.gbl_caps) - + sizeof(info->u.vesa_lfb.gbl_caps)) + u.vesa_lfb.gbl_caps) + + sizeof(info->u.vesa_lfb.gbl_caps)) screen_info->capabilities = info->u.vesa_lfb.gbl_caps; if (size >= offsetof(struct dom0_vga_console_info, - u.vesa_lfb.mode_attrs) - + sizeof(info->u.vesa_lfb.mode_attrs)) - screen_info->vesa_attributes = info->u.vesa_lfb.mode_attrs; + u.vesa_lfb.mode_attrs) + + sizeof(info->u.vesa_lfb.mode_attrs)) + screen_info->vesa_attributes + info->u.vesa_lfb.mode_attrs; break; } } diff --git a/drivers/char/hvc_xen.c b/drivers/char/hvc_xen.c index 81d9186..11071ed 100644 --- a/drivers/char/hvc_xen.c +++ b/drivers/char/hvc_xen.c @@ -137,7 +137,7 @@ static int __init xen_hvc_init(void) struct hv_ops *ops; if (!xen_pv_domain()) - return -ENODEV; + return -ENODEV; if (xen_initial_domain()) { ops = &dom0_hvc_ops; diff --git a/include/xen/interface/platform.h b/include/xen/interface/platform.h index da548f3..2307b0f 100644 --- a/include/xen/interface/platform.h +++ b/include/xen/interface/platform.h @@ -54,13 +54,13 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_settime_t); */ #define XENPF_add_memtype 31 struct xenpf_add_memtype { - /* IN variables. */ - unsigned long mfn; - uint64_t nr_mfns; - uint32_t type; - /* OUT variables. */ - uint32_t handle; - uint32_t reg; + /* IN variables. */ + unsigned long mfn; + uint64_t nr_mfns; + uint32_t type; + /* OUT variables. */ + uint32_t handle; + uint32_t reg; }; typedef struct xenpf_add_memtype xenpf_add_memtype_t; DEFINE_GUEST_HANDLE_STRUCT(xenpf_add_memtype_t); @@ -74,9 +74,9 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_add_memtype_t); */ #define XENPF_del_memtype 32 struct xenpf_del_memtype { - /* IN variables. */ - uint32_t handle; - uint32_t reg; + /* IN variables. */ + uint32_t handle; + uint32_t reg; }; typedef struct xenpf_del_memtype xenpf_del_memtype_t; DEFINE_GUEST_HANDLE_STRUCT(xenpf_del_memtype_t); @@ -84,21 +84,21 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_del_memtype_t); /* Read current type of an MTRR (x86-specific). */ #define XENPF_read_memtype 33 struct xenpf_read_memtype { - /* IN variables. */ - uint32_t reg; - /* OUT variables. */ - unsigned long mfn; - uint64_t nr_mfns; - uint32_t type; + /* IN variables. */ + uint32_t reg; + /* OUT variables. */ + unsigned long mfn; + uint64_t nr_mfns; + uint32_t type; }; typedef struct xenpf_read_memtype xenpf_read_memtype_t; DEFINE_GUEST_HANDLE_STRUCT(xenpf_read_memtype_t); #define XENPF_microcode_update 35 struct xenpf_microcode_update { - /* IN variables. */ - GUEST_HANDLE(void) data; /* Pointer to microcode data */ - uint32_t length; /* Length of microcode data. */ + /* IN variables. */ + GUEST_HANDLE(void) data; /* Pointer to microcode data */ + uint32_t length; /* Length of microcode data. */ }; typedef struct xenpf_microcode_update xenpf_microcode_update_t; DEFINE_GUEST_HANDLE_STRUCT(xenpf_microcode_update_t); @@ -124,30 +124,30 @@ struct xenpf_firmware_info { uint32_t index; /* OUT variables. */ union { - struct { - /* Int13, Fn48: Check Extensions Present. */ - uint8_t device; /* %dl: bios device number */ - uint8_t version; /* %ah: major version */ - uint16_t interface_support; /* %cx: support bitmap */ - /* Int13, Fn08: Legacy Get Device Parameters. */ - uint16_t legacy_max_cylinder; /* %cl[7:6]:%ch: max cyl # */ - uint8_t legacy_max_head; /* %dh: max head # */ - uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector # */ - /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */ - /* NB. First uint16_t of buffer must be set to buffer size. */ - GUEST_HANDLE(void) edd_params; - } disk_info; /* XEN_FW_DISK_INFO */ - struct { - uint8_t device; /* bios device number */ - uint32_t mbr_signature; /* offset 0x1b8 in mbr */ - } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */ - struct { - /* Int10, AX=4F15: Get EDID info. */ - uint8_t capabilities; - uint8_t edid_transfer_time; - /* must refer to 128-byte buffer */ - GUEST_HANDLE(uchar) edid; - } vbeddc_info; /* XEN_FW_VBEDDC_INFO */ + struct { + /* Int13, Fn48: Check Extensions Present. */ + uint8_t device; /* %dl: bios device number */ + uint8_t version; /* %ah: major version */ + uint16_t interface_support; /* %cx: support bitmap */ + /* Int13, Fn08: Legacy Get Device Parameters. */ + uint16_t legacy_max_cylinder; /* %cl[7:6]:%ch: max cyl # */ + uint8_t legacy_max_head; /* %dh: max head # */ + uint8_t legacy_sectors_per_track; /* %cl[5:0]: max sector # */ + /* Int13, Fn41: Get Device Parameters (as filled into %ds:%esi). */ + /* NB. First uint16_t of buffer must be set to buffer size. */ + GUEST_HANDLE(void) edd_params; + } disk_info; /* XEN_FW_DISK_INFO */ + struct { + uint8_t device; /* bios device number */ + uint32_t mbr_signature; /* offset 0x1b8 in mbr */ + } disk_mbr_signature; /* XEN_FW_DISK_MBR_SIGNATURE */ + struct { + /* Int10, AX=4F15: Get EDID info. */ + uint8_t capabilities; + uint8_t edid_transfer_time; + /* must refer to 128-byte buffer */ + GUEST_HANDLE(uchar) edid; + } vbeddc_info; /* XEN_FW_VBEDDC_INFO */ } u; }; typedef struct xenpf_firmware_info xenpf_firmware_info_t; @@ -155,21 +155,21 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_firmware_info_t); #define XENPF_enter_acpi_sleep 51 struct xenpf_enter_acpi_sleep { - /* IN variables */ - uint16_t pm1a_cnt_val; /* PM1a control value. */ - uint16_t pm1b_cnt_val; /* PM1b control value. */ - uint32_t sleep_state; /* Which state to enter (Sn). */ - uint32_t flags; /* Must be zero. */ + /* IN variables */ + uint16_t pm1a_cnt_val; /* PM1a control value. */ + uint16_t pm1b_cnt_val; /* PM1b control value. */ + uint32_t sleep_state; /* Which state to enter (Sn). */ + uint32_t flags; /* Must be zero. */ }; typedef struct xenpf_enter_acpi_sleep xenpf_enter_acpi_sleep_t; DEFINE_GUEST_HANDLE_STRUCT(xenpf_enter_acpi_sleep_t); #define XENPF_change_freq 52 struct xenpf_change_freq { - /* IN variables */ - uint32_t flags; /* Must be zero. */ - uint32_t cpu; /* Physical cpu. */ - uint64_t freq; /* New frequency (Hz). */ + /* IN variables */ + uint32_t flags; /* Must be zero. */ + uint32_t cpu; /* Physical cpu. */ + uint64_t freq; /* New frequency (Hz). */ }; typedef struct xenpf_change_freq xenpf_change_freq_t; DEFINE_GUEST_HANDLE_STRUCT(xenpf_change_freq_t); @@ -184,49 +184,39 @@ DEFINE_GUEST_HANDLE_STRUCT(xenpf_change_freq_t); */ #define XENPF_getidletime 53 struct xenpf_getidletime { - /* IN/OUT variables */ - /* IN: CPUs to interrogate; OUT: subset of IN which are present */ - GUEST_HANDLE(uchar) cpumap_bitmap; - /* IN variables */ - /* Size of cpumap bitmap. */ - uint32_t cpumap_nr_cpus; - /* Must be indexable for every cpu in cpumap_bitmap. */ - GUEST_HANDLE(uint64_t) idletime; - /* OUT variables */ - /* System time when the idletime snapshots were taken. */ - uint64_t now; + /* IN/OUT variables */ + /* IN: CPUs to interrogate; OUT: subset of IN which are present */ + GUEST_HANDLE(uchar) cpumap_bitmap; + /* IN variables */ + /* Size of cpumap bitmap. */ + uint32_t cpumap_nr_cpus; + /* Must be indexable for every cpu in cpumap_bitmap. */ + GUEST_HANDLE(uint64_t) idletime; + /* OUT variables */ + /* System time when the idletime snapshots were taken. */ + uint64_t now; }; typedef struct xenpf_getidletime xenpf_getidletime_t; DEFINE_GUEST_HANDLE_STRUCT(xenpf_getidletime_t); struct xen_platform_op { - uint32_t cmd; - uint32_t interface_version; /* XENPF_INTERFACE_VERSION */ - union { - struct xenpf_settime settime; - struct xenpf_add_memtype add_memtype; - struct xenpf_del_memtype del_memtype; - struct xenpf_read_memtype read_memtype; - struct xenpf_microcode_update microcode; - struct xenpf_platform_quirk platform_quirk; - struct xenpf_firmware_info firmware_info; - struct xenpf_enter_acpi_sleep enter_acpi_sleep; - struct xenpf_change_freq change_freq; - struct xenpf_getidletime getidletime; - uint8_t pad[128]; - } u; + uint32_t cmd; + uint32_t interface_version; /* XENPF_INTERFACE_VERSION */ + union { + struct xenpf_settime settime; + struct xenpf_add_memtype add_memtype; + struct xenpf_del_memtype del_memtype; + struct xenpf_read_memtype read_memtype; + struct xenpf_microcode_update microcode; + struct xenpf_platform_quirk platform_quirk; + struct xenpf_firmware_info firmware_info; + struct xenpf_enter_acpi_sleep enter_acpi_sleep; + struct xenpf_change_freq change_freq; + struct xenpf_getidletime getidletime; + uint8_t pad[128]; + } u; }; typedef struct xen_platform_op xen_platform_op_t; DEFINE_GUEST_HANDLE_STRUCT(xen_platform_op_t); #endif /* __XEN_PUBLIC_PLATFORM_H__ */ - -/* - * Local variables: - * mode: C - * c-set-style: "BSD" - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h index 6c0af21..412326d 100644 --- a/include/xen/interface/xen.h +++ b/include/xen/interface/xen.h @@ -450,42 +450,42 @@ struct start_info { }; struct dom0_vga_console_info { - uint8_t video_type; /* DOM0_VGA_CONSOLE_??? */ + uint8_t video_type; /* DOM0_VGA_CONSOLE_??? */ #define XEN_VGATYPE_TEXT_MODE_3 0x03 #define XEN_VGATYPE_VESA_LFB 0x23 - union { - struct { - /* Font height, in pixels. */ - uint16_t font_height; - /* Cursor location (column, row). */ - uint16_t cursor_x, cursor_y; - /* Number of rows and columns (dimensions in characters). */ - uint16_t rows, columns; - } text_mode_3; - - struct { - /* Width and height, in pixels. */ - uint16_t width, height; - /* Bytes per scan line. */ - uint16_t bytes_per_line; - /* Bits per pixel. */ - uint16_t bits_per_pixel; - /* LFB physical address, and size (in units of 64kB). */ - uint32_t lfb_base; - uint32_t lfb_size; - /* RGB mask offsets and sizes, as defined by VBE 1.2+ */ - uint8_t red_pos, red_size; - uint8_t green_pos, green_size; - uint8_t blue_pos, blue_size; - uint8_t rsvd_pos, rsvd_size; - - /* VESA capabilities (offset 0xa, VESA command 0x4f00). */ - uint32_t gbl_caps; - /* Mode attributes (offset 0x0, VESA command 0x4f01). */ - uint16_t mode_attrs; - } vesa_lfb; - } u; + union { + struct { + /* Font height, in pixels. */ + uint16_t font_height; + /* Cursor location (column, row). */ + uint16_t cursor_x, cursor_y; + /* Number of rows and columns (dimensions in characters). */ + uint16_t rows, columns; + } text_mode_3; + + struct { + /* Width and height, in pixels. */ + uint16_t width, height; + /* Bytes per scan line. */ + uint16_t bytes_per_line; + /* Bits per pixel. */ + uint16_t bits_per_pixel; + /* LFB physical address, and size (in units of 64kB). */ + uint32_t lfb_base; + uint32_t lfb_size; + /* RGB mask offsets and sizes, as defined by VBE 1.2+ */ + uint8_t red_pos, red_size; + uint8_t green_pos, green_size; + uint8_t blue_pos, blue_size; + uint8_t rsvd_pos, rsvd_size; + + /* VESA capabilities (offset 0xa, VESA command 0x4f00). */ + uint32_t gbl_caps; + /* Mode attributes (offset 0x0, VESA command 0x4f01). */ + uint16_t mode_attrs; + } vesa_lfb; + } u; }; /* These flags are passed in the ''flags'' field of start_info_t. */ -- 1.6.0.6 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
* Jeremy Fitzhardinge <jeremy@goop.org> wrote:> From: Ian Campbell <ian.campbell@citrix.com> > > Impact: disable PAT under Xen > > Xen imposes a particular PAT layout on all paravirtual guests which > does not match the layout Linux would like to use. > > Force PAT to be disabled until this is resolved. > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com> > Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>hm, what will the resolution be? Every step in the direction of making Xen guests more special is a step in the wrong direction. Coupling between Xen and Linux should be reduced, not increased. Ingo _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ingo Molnar
2009-May-08 11:17 UTC
[Xen-devel] Re: [PATCH 05/16] xen mtrr: Add mtrr_ops support for Xen mtrr
* Jeremy Fitzhardinge <jeremy@goop.org> wrote:> +/* DOM0 TODO: Need to fill in the remaining mtrr methods to have full > + * working userland mtrr support. */ > +static struct mtrr_ops xen_mtrr_ops = { > + .vendor = X86_VENDOR_UNKNOWN, > +// .set = xen_set_mtrr, > +// .get = xen_get_mtrr, > + .get_free_region = generic_get_free_region, > +// .validate_add_page = xen_validate_add_page, > + .have_wrcomb = positive_have_wrcomb, > + .use_intel_if = 0, > + .num_var_ranges = xen_num_var_ranges, > +};Please dont post patches with ugly TODO items in them. Also, a more general objection is that /proc/mtrr is a legacy interface, we dont really want to extend its use. The Xen hypervisor should get proper PAT support instead ... Ingo _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On Fri, 2009-05-08 at 07:14 -0400, Ingo Molnar wrote:> * Jeremy Fitzhardinge <jeremy@goop.org> wrote: > > > From: Ian Campbell <ian.campbell@citrix.com> > > > > Impact: disable PAT under Xen > > > > Xen imposes a particular PAT layout on all paravirtual guests which > > does not match the layout Linux would like to use. > > > > Force PAT to be disabled until this is resolved. > > > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com> > > Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> > > hm, what will the resolution be?Roughly speaking the kernel needs to cope with different values written to MSR_IA32_CR_PAT than the single hard coded value it would write itself if given the chance. Essentially _PAGE_CACHE_* need to become dynamic (or I guess we could change the native layout to match Xen''s, I don''t know why native differs from the initial state, I guess just to avoid using the PAT bit for some reason). The various mappings used are: PAT PCD PWT NATIVE XEN BIOS INIT 0 0 0 WB WB WB WB 0 0 1 WC WT WT WT 0 1 0 UC- UC- UC- UC- 0 1 1 UC UC - UC 1 0 0 - WC WB WB 1 0 1 - WP WT WT 1 1 0 - - UC- UC- 1 1 1 - - - UC- (INIT is the processors initial state and BIOS is apparently commonly set by the BIOS). At the time this changeset was originally written using the actual PAT bit (required by Xen''s layout to get at WC) led to strange errors (to do with swap masking various bits IIRC) but I believe those have been fixed since by Jan Beulich. I''m not sure how _PAGE_PAT_LARGE fits in -- native cunning avoids having to worry about it by not using the PAT bit at all. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
> Roughly speaking the kernel needs to cope with different values written > to MSR_IA32_CR_PAT than the single hard coded value it would write > itself if given the chance. Essentially _PAGE_CACHE_* need to become > dynamic (or I guess we could change the native layout to match Xen''s, I > don''t know why native differs from the initial state, I guess just to > avoid using the PAT bit for some reason.Because it is required for some processor variants due to errata. This is also why the BIOS has them programmed as a mirror between 0-3 and 4-7. I don''t think changing Linux here is the right thing to do - if anything Xen probably needs to change. See Xeon errata P21. Alan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 08/05/2009 15:50, "Alan Cox" <alan@lxorguk.ukuu.org.uk> wrote:>> Roughly speaking the kernel needs to cope with different values written >> to MSR_IA32_CR_PAT than the single hard coded value it would write >> itself if given the chance. Essentially _PAGE_CACHE_* need to become >> dynamic (or I guess we could change the native layout to match Xen''s, I >> don''t know why native differs from the initial state, I guess just to >> avoid using the PAT bit for some reason. > > Because it is required for some processor variants due to errata. This is > also why the BIOS has them programmed as a mirror between 0-3 and 4-7. > > I don''t think changing Linux here is the right thing to do - if anything > Xen probably needs to change.My suggestion is that Xen changes its PAT[1] from WT to WC. AFAIK only suse''s Linux port is currently using Xen''s PAT support, and it does not actually use the WT cache attribute. Then Xen''s PAT[0-3] would match what Linux expects, and Linux apparently does not risk using PAT[4-7] because of processor errata so their values are irrelevant. Linux can check that it is running on Xen with suitable PAT setup by reading MSR_IA32_CR_PAT and checking PAT[0-3], and only enable PAT usage in case of a match. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Keir Fraser wrote:> > My suggestion is that Xen changes its PAT[1] from WT to WC. AFAIK only > suse''s Linux port is currently using Xen''s PAT support, and it does not > actually use the WT cache attribute. Then Xen''s PAT[0-3] would match what > Linux expects, and Linux apparently does not risk using PAT[4-7] because of > processor errata so their values are irrelevant. Linux can check that it is > running on Xen with suitable PAT setup by reading MSR_IA32_CR_PAT and > checking PAT[0-3], and only enable PAT usage in case of a match. >There exists at least one processor erratum where the CPU will use PAT[4-7] when the user requested PAT[0-3]. For those CPUs, it is unsafe for *any* OS to have PAT[4-7] != PAT[0-3]. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don''t speak on their behalf. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 09/05/2009 19:36, "H. Peter Anvin" <hpa@zytor.com> wrote:>> My suggestion is that Xen changes its PAT[1] from WT to WC. AFAIK only >> suse''s Linux port is currently using Xen''s PAT support, and it does not >> actually use the WT cache attribute. Then Xen''s PAT[0-3] would match what >> Linux expects, and Linux apparently does not risk using PAT[4-7] because of >> processor errata so their values are irrelevant. Linux can check that it is >> running on Xen with suitable PAT setup by reading MSR_IA32_CR_PAT and >> checking PAT[0-3], and only enable PAT usage in case of a match. > > There exists at least one processor erratum where the CPU will use > PAT[4-7] when the user requested PAT[0-3]. For those CPUs, it is unsafe > for *any* OS to have PAT[4-7] != PAT[0-3].Would it be unreasonable for us to disable PAT on such processors? An alternative would be to set up PAT according to a new elfnote in the dom0 kernel image, and then only expose the PAT feature flag to domU kernels that have matching PAT configuration. No elfnote would mean use Xen''s existing PAT setup (or if that''s very dangerous then disable PAT altogether, perhaps dependent on CPU model/stepping?). -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
> > There exists at least one processor erratum where the CPU will use > > PAT[4-7] when the user requested PAT[0-3]. For those CPUs, it is unsafe > > for *any* OS to have PAT[4-7] != PAT[0-3]. > > Would it be unreasonable for us to disable PAT on such processors?That would be a regression as far as Linux is concerned. They work perfectly well providing you stick to four PAT entries (which is enough for any Linux system). I''m not sure how Windows handles this but that might also matter for Xen I guess.> have matching PAT configuration. No elfnote would mean use Xen''s existing > PAT setup (or if that''s very dangerous then disable PAT altogether, perhaps > dependent on CPU model/stepping?).Hiding it on errata hit processors if the guest cannot support PAT safely on such processors sounds a good policy and its one being a hypervisor you can do neatly. There are quite a few different CPUs with PAT errata. I''ve no idea why there are so many errata about that specific bit. Alan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 10/05/2009 14:29, "Alan Cox" <alan@lxorguk.ukuu.org.uk> wrote:>> have matching PAT configuration. No elfnote would mean use Xen''s existing >> PAT setup (or if that''s very dangerous then disable PAT altogether, perhaps >> dependent on CPU model/stepping?). > > Hiding it on errata hit processors if the guest cannot support PAT > safely on such processors sounds a good policy and its one being a > hypervisor you can do neatly. > > There are quite a few different CPUs with PAT errata. I''ve no idea why > there are so many errata about that specific bit.Okay, this sounds like a good way to then. I can work out details with Jeremy from here, and this will then have no impact on Linux PAT logic. If we advertise PAT to Linux via CPUID, that will mean PAT is set up just as Linux requires. Thanks, Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Alan Cox wrote:> > There are quite a few different CPUs with PAT errata. I''ve no idea why > there are so many errata about that specific bit. >I suspect it is simply because: a) it moves around between the various page table formats; b) the default configuration and existing OSes don''t use it; c) it isn''t even *present* in some formats. -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don''t speak on their behalf. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
>>> Keir Fraser <keir.fraser@eu.citrix.com> 10.05.09 19:34 >>> >On 10/05/2009 14:29, "Alan Cox" <alan@lxorguk.ukuu.org.uk> wrote: > >>> have matching PAT configuration. No elfnote would mean use Xen''s existing >>> PAT setup (or if that''s very dangerous then disable PAT altogether, perhaps >>> dependent on CPU model/stepping?). >> >> Hiding it on errata hit processors if the guest cannot support PAT >> safely on such processors sounds a good policy and its one being a >> hypervisor you can do neatly. >> >> There are quite a few different CPUs with PAT errata. I''ve no idea why >> there are so many errata about that specific bit. > >Okay, this sounds like a good way to then. I can work out details with >Jeremy from here, and this will then have no impact on Linux PAT logic. If >we advertise PAT to Linux via CPUID, that will mean PAT is set up just as >Linux requires.Depending on what exact plans you have here, I would question whether having an upper layer dictate mechanisms used by a lower layer. In particular, just like with the same mistake made with kexec, - Linux''s use of PAT may change (specifically, the value it writes to the PAT MSR may not be statically determinable at some point, making the ELF note approach you indicated as a possible solution unusable) - the interface may not be suitable for non-Linux Hence I''d appreciate if working out the details here could be done in public. Thanks, Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
On 11/05/2009 10:09, "Jan Beulich" <jbeulich@novell.com> wrote:> Depending on what exact plans you have here, I would question whether > having an upper layer dictate mechanisms used by a lower layer. In > particular, just like with the same mistake made with kexec, > - Linux''s use of PAT may change (specifically, the value it writes to the PAT > MSR may not be statically determinable at some point, making the ELF note > approach you indicated as a possible solution unusable) > - the interface may not be suitable for non-Linux > Hence I''d appreciate if working out the details here could be done in public.I was going to suggest put the PAT MSR value in an elfnote, Xen picks up dom0''s note and uses it if possible (Xen relies on PAT[0]=WB,PAT[2]=UC), else disables PAT for all guest, also advertises PAT feature for any domU PV guest advertising the exact same PAT MSR value in its elfnote. Any approach involving Xen dictating to Linux has the fun job of getting past the kernel maintainers. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
* H. Peter Anvin <hpa@zytor.com> wrote:> Alan Cox wrote: > > > > There are quite a few different CPUs with PAT errata. I''ve no idea why > > there are so many errata about that specific bit. > > > > I suspect it is simply because: > > a) it moves around between the various page table formats; > b) the default configuration and existing OSes don''t use it; > c) it isn''t even *present* in some formats.I also suspect those bits is also on the TLB miss critical path so there''s probably quite a bit of extra complexity around it on the hardware side to keep the latency down. Ingo _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jeremy Fitzhardinge
2009-May-11 18:05 UTC
Re: [Xen-devel] Re: [PATCH 06/16] xen: disable PAT
Jan Beulich wrote:> Depending on what exact plans you have here, I would question whether > having an upper layer dictate mechanisms used by a lower layer. In > particular, just like with the same mistake made with kexec, > - Linux''s use of PAT may change (specifically, the value it writes to the PAT > MSR may not be statically determinable at some point, making the ELF note > approach you indicated as a possible solution unusable) >If Linux grows the ability to dynamically choose its PAT settings at runtime, then we can hook that mechanism to make sure there''s some way to work with Xen. The current problem is because both Linux and Xen current have incompatible static PAT setups.> - the interface may not be suitable for non-LinuxHow do other guests use PAT (both native and under Xen)? J _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel