aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/xen
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-13 17:29:16 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-13 17:29:16 -0500
commit896ea17d3da5f44b2625c9cda9874d7dfe447393 (patch)
tree089f00dd300a49c81f042e9b52ef32cd1333bdbc /arch/x86/xen
parentc7708fac5a878d6e0f2de0aa19f9749cff4f707f (diff)
parent6a7ed405114b2a53ccd99631b0636aaeabf71b3e (diff)
Merge tag 'stable/for-linus-3.8-rc0-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen
Pull Xen updates from Konrad Rzeszutek Wilk: - Add necessary infrastructure to make balloon driver work under ARM. - Add /dev/xen/privcmd interfaces to work with ARM and PVH. - Improve Xen PCIBack wild-card parsing. - Add Xen ACPI PAD (Processor Aggregator) support - so can offline/ online sockets depending on the power consumption. - PVHVM + kexec = use an E820_RESV region for the shared region so we don't overwrite said region during kexec reboot. - Cleanups, compile fixes. Fix up some trivial conflicts due to the balloon driver now working on ARM, and there were changes next to the previous work-arounds that are now gone. * tag 'stable/for-linus-3.8-rc0-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen: xen/PVonHVM: fix compile warning in init_hvm_pv_info xen: arm: implement remap interfaces needed for privcmd mappings. xen: correctly use xen_pfn_t in remap_domain_mfn_range. xen: arm: enable balloon driver xen: balloon: allow PVMMU interfaces to be compiled out xen: privcmd: support autotranslated physmap guests. xen: add pages parameter to xen_remap_domain_mfn_range xen/acpi: Move the xen_running_on_version_or_later function. xen/xenbus: Remove duplicate inclusion of asm/xen/hypervisor.h xen/acpi: Fix compile error by missing decleration for xen_domain. xen/acpi: revert pad config check in xen_check_mwait xen/acpi: ACPI PAD driver xen-pciback: reject out of range inputs xen-pciback: simplify and tighten parsing of device IDs xen PVonHVM: use E820_Reserved area for shared_info
Diffstat (limited to 'arch/x86/xen')
-rw-r--r--arch/x86/xen/Kconfig1
-rw-r--r--arch/x86/xen/enlighten.c102
-rw-r--r--arch/x86/xen/mmu.c17
-rw-r--r--arch/x86/xen/suspend.c2
-rw-r--r--arch/x86/xen/xen-ops.h2
5 files changed, 95 insertions, 29 deletions
diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
index 9a6775c9ddca..131dacd2748a 100644
--- a/arch/x86/xen/Kconfig
+++ b/arch/x86/xen/Kconfig
@@ -6,6 +6,7 @@ config XEN
6 bool "Xen guest support" 6 bool "Xen guest support"
7 select PARAVIRT 7 select PARAVIRT
8 select PARAVIRT_CLOCK 8 select PARAVIRT_CLOCK
9 select XEN_HAVE_PVMMU
9 depends on X86_64 || (X86_32 && X86_PAE && !X86_VISWS) 10 depends on X86_64 || (X86_32 && X86_PAE && !X86_VISWS)
10 depends on X86_TSC 11 depends on X86_TSC
11 help 12 help
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 586d83812b67..3aeaa933b527 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -223,6 +223,21 @@ static void __init xen_banner(void)
223 version >> 16, version & 0xffff, extra.extraversion, 223 version >> 16, version & 0xffff, extra.extraversion,
224 xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : ""); 224 xen_feature(XENFEAT_mmu_pt_update_preserve_ad) ? " (preserve-AD)" : "");
225} 225}
226/* Check if running on Xen version (major, minor) or later */
227bool
228xen_running_on_version_or_later(unsigned int major, unsigned int minor)
229{
230 unsigned int version;
231
232 if (!xen_domain())
233 return false;
234
235 version = HYPERVISOR_xen_version(XENVER_version, NULL);
236 if ((((version >> 16) == major) && ((version & 0xffff) >= minor)) ||
237 ((version >> 16) > major))
238 return true;
239 return false;
240}
226 241
227#define CPUID_THERM_POWER_LEAF 6 242#define CPUID_THERM_POWER_LEAF 6
228#define APERFMPERF_PRESENT 0 243#define APERFMPERF_PRESENT 0
@@ -287,8 +302,7 @@ static void xen_cpuid(unsigned int *ax, unsigned int *bx,
287 302
288static bool __init xen_check_mwait(void) 303static bool __init xen_check_mwait(void)
289{ 304{
290#if defined(CONFIG_ACPI) && !defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR) && \ 305#ifdef CONFIG_ACPI
291 !defined(CONFIG_ACPI_PROCESSOR_AGGREGATOR_MODULE)
292 struct xen_platform_op op = { 306 struct xen_platform_op op = {
293 .cmd = XENPF_set_processor_pminfo, 307 .cmd = XENPF_set_processor_pminfo,
294 .u.set_pminfo.id = -1, 308 .u.set_pminfo.id = -1,
@@ -309,6 +323,13 @@ static bool __init xen_check_mwait(void)
309 if (!xen_initial_domain()) 323 if (!xen_initial_domain())
310 return false; 324 return false;
311 325
326 /*
327 * When running under platform earlier than Xen4.2, do not expose
328 * mwait, to avoid the risk of loading native acpi pad driver
329 */
330 if (!xen_running_on_version_or_later(4, 2))
331 return false;
332
312 ax = 1; 333 ax = 1;
313 cx = 0; 334 cx = 0;
314 335
@@ -1495,51 +1516,72 @@ asmlinkage void __init xen_start_kernel(void)
1495#endif 1516#endif
1496} 1517}
1497 1518
1498void __ref xen_hvm_init_shared_info(void) 1519#ifdef CONFIG_XEN_PVHVM
1520#define HVM_SHARED_INFO_ADDR 0xFE700000UL
1521static struct shared_info *xen_hvm_shared_info;
1522static unsigned long xen_hvm_sip_phys;
1523static int xen_major, xen_minor;
1524
1525static void xen_hvm_connect_shared_info(unsigned long pfn)
1499{ 1526{
1500 int cpu;
1501 struct xen_add_to_physmap xatp; 1527 struct xen_add_to_physmap xatp;
1502 static struct shared_info *shared_info_page = 0;
1503 1528
1504 if (!shared_info_page)
1505 shared_info_page = (struct shared_info *)
1506 extend_brk(PAGE_SIZE, PAGE_SIZE);
1507 xatp.domid = DOMID_SELF; 1529 xatp.domid = DOMID_SELF;
1508 xatp.idx = 0; 1530 xatp.idx = 0;
1509 xatp.space = XENMAPSPACE_shared_info; 1531 xatp.space = XENMAPSPACE_shared_info;
1510 xatp.gpfn = __pa(shared_info_page) >> PAGE_SHIFT; 1532 xatp.gpfn = pfn;
1511 if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp)) 1533 if (HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp))
1512 BUG(); 1534 BUG();
1513 1535
1514 HYPERVISOR_shared_info = (struct shared_info *)shared_info_page; 1536}
1537static void __init xen_hvm_set_shared_info(struct shared_info *sip)
1538{
1539 int cpu;
1540
1541 HYPERVISOR_shared_info = sip;
1515 1542
1516 /* xen_vcpu is a pointer to the vcpu_info struct in the shared_info 1543 /* xen_vcpu is a pointer to the vcpu_info struct in the shared_info
1517 * page, we use it in the event channel upcall and in some pvclock 1544 * page, we use it in the event channel upcall and in some pvclock
1518 * related functions. We don't need the vcpu_info placement 1545 * related functions. We don't need the vcpu_info placement
1519 * optimizations because we don't use any pv_mmu or pv_irq op on 1546 * optimizations because we don't use any pv_mmu or pv_irq op on
1520 * HVM. 1547 * HVM. */
1521 * When xen_hvm_init_shared_info is run at boot time only vcpu 0 is 1548 for_each_online_cpu(cpu)
1522 * online but xen_hvm_init_shared_info is run at resume time too and
1523 * in that case multiple vcpus might be online. */
1524 for_each_online_cpu(cpu) {
1525 per_cpu(xen_vcpu, cpu) = &HYPERVISOR_shared_info->vcpu_info[cpu]; 1549 per_cpu(xen_vcpu, cpu) = &HYPERVISOR_shared_info->vcpu_info[cpu];
1550}
1551
1552/* Reconnect the shared_info pfn to a (new) mfn */
1553void xen_hvm_resume_shared_info(void)
1554{
1555 xen_hvm_connect_shared_info(xen_hvm_sip_phys >> PAGE_SHIFT);
1556}
1557
1558/* Xen tools prior to Xen 4 do not provide a E820_Reserved area for guest usage.
1559 * On these old tools the shared info page will be placed in E820_Ram.
1560 * Xen 4 provides a E820_Reserved area at 0xFC000000, and this code expects
1561 * that nothing is mapped up to HVM_SHARED_INFO_ADDR.
1562 * Xen 4.3+ provides an explicit 1MB area at HVM_SHARED_INFO_ADDR which is used
1563 * here for the shared info page. */
1564static void __init xen_hvm_init_shared_info(void)
1565{
1566 if (xen_major < 4) {
1567 xen_hvm_shared_info = extend_brk(PAGE_SIZE, PAGE_SIZE);
1568 xen_hvm_sip_phys = __pa(xen_hvm_shared_info);
1569 } else {
1570 xen_hvm_sip_phys = HVM_SHARED_INFO_ADDR;
1571 set_fixmap(FIX_PARAVIRT_BOOTMAP, xen_hvm_sip_phys);
1572 xen_hvm_shared_info =
1573 (struct shared_info *)fix_to_virt(FIX_PARAVIRT_BOOTMAP);
1526 } 1574 }
1575 xen_hvm_connect_shared_info(xen_hvm_sip_phys >> PAGE_SHIFT);
1576 xen_hvm_set_shared_info(xen_hvm_shared_info);
1527} 1577}
1528 1578
1529#ifdef CONFIG_XEN_PVHVM
1530static void __init init_hvm_pv_info(void) 1579static void __init init_hvm_pv_info(void)
1531{ 1580{
1532 int major, minor; 1581 uint32_t ecx, edx, pages, msr, base;
1533 uint32_t eax, ebx, ecx, edx, pages, msr, base;
1534 u64 pfn; 1582 u64 pfn;
1535 1583
1536 base = xen_cpuid_base(); 1584 base = xen_cpuid_base();
1537 cpuid(base + 1, &eax, &ebx, &ecx, &edx);
1538
1539 major = eax >> 16;
1540 minor = eax & 0xffff;
1541 printk(KERN_INFO "Xen version %d.%d.\n", major, minor);
1542
1543 cpuid(base + 2, &pages, &msr, &ecx, &edx); 1585 cpuid(base + 2, &pages, &msr, &ecx, &edx);
1544 1586
1545 pfn = __pa(hypercall_page); 1587 pfn = __pa(hypercall_page);
@@ -1590,12 +1632,22 @@ static void __init xen_hvm_guest_init(void)
1590 1632
1591static bool __init xen_hvm_platform(void) 1633static bool __init xen_hvm_platform(void)
1592{ 1634{
1635 uint32_t eax, ebx, ecx, edx, base;
1636
1593 if (xen_pv_domain()) 1637 if (xen_pv_domain())
1594 return false; 1638 return false;
1595 1639
1596 if (!xen_cpuid_base()) 1640 base = xen_cpuid_base();
1641 if (!base)
1597 return false; 1642 return false;
1598 1643
1644 cpuid(base + 1, &eax, &ebx, &ecx, &edx);
1645
1646 xen_major = eax >> 16;
1647 xen_minor = eax & 0xffff;
1648
1649 printk(KERN_INFO "Xen version %d.%d.\n", xen_major, xen_minor);
1650
1599 return true; 1651 return true;
1600} 1652}
1601 1653
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index dcf5f2dd91ec..01de35c77221 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -2497,8 +2497,10 @@ static int remap_area_mfn_pte_fn(pte_t *ptep, pgtable_t token,
2497 2497
2498int xen_remap_domain_mfn_range(struct vm_area_struct *vma, 2498int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
2499 unsigned long addr, 2499 unsigned long addr,
2500 unsigned long mfn, int nr, 2500 xen_pfn_t mfn, int nr,
2501 pgprot_t prot, unsigned domid) 2501 pgprot_t prot, unsigned domid,
2502 struct page **pages)
2503
2502{ 2504{
2503 struct remap_data rmd; 2505 struct remap_data rmd;
2504 struct mmu_update mmu_update[REMAP_BATCH_SIZE]; 2506 struct mmu_update mmu_update[REMAP_BATCH_SIZE];
@@ -2542,3 +2544,14 @@ out:
2542 return err; 2544 return err;
2543} 2545}
2544EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range); 2546EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range);
2547
2548/* Returns: 0 success */
2549int xen_unmap_domain_mfn_range(struct vm_area_struct *vma,
2550 int numpgs, struct page **pages)
2551{
2552 if (!pages || !xen_feature(XENFEAT_auto_translated_physmap))
2553 return 0;
2554
2555 return -EINVAL;
2556}
2557EXPORT_SYMBOL_GPL(xen_unmap_domain_mfn_range);
diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c
index 45329c8c226e..ae8a00c39de4 100644
--- a/arch/x86/xen/suspend.c
+++ b/arch/x86/xen/suspend.c
@@ -30,7 +30,7 @@ void xen_arch_hvm_post_suspend(int suspend_cancelled)
30{ 30{
31#ifdef CONFIG_XEN_PVHVM 31#ifdef CONFIG_XEN_PVHVM
32 int cpu; 32 int cpu;
33 xen_hvm_init_shared_info(); 33 xen_hvm_resume_shared_info();
34 xen_callback_vector(); 34 xen_callback_vector();
35 xen_unplug_emulated_devices(); 35 xen_unplug_emulated_devices();
36 if (xen_feature(XENFEAT_hvm_safe_pvclock)) { 36 if (xen_feature(XENFEAT_hvm_safe_pvclock)) {
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index a95b41744ad0..d2e73d19d366 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -40,7 +40,7 @@ void xen_enable_syscall(void);
40void xen_vcpu_restore(void); 40void xen_vcpu_restore(void);
41 41
42void xen_callback_vector(void); 42void xen_callback_vector(void);
43void xen_hvm_init_shared_info(void); 43void xen_hvm_resume_shared_info(void);
44void xen_unplug_emulated_devices(void); 44void xen_unplug_emulated_devices(void);
45 45
46void __init xen_build_dynamic_phys_to_machine(void); 46void __init xen_build_dynamic_phys_to_machine(void);