diff options
author | Isaku Yamahata <yamahata@valinux.co.jp> | 2008-10-02 15:32:54 +0900 |
---|---|---|
committer | Isaku Yamahata <yamahata@valinux.co.jp> | 2008-10-02 15:32:54 +0900 |
commit | 8abea5a1745efde8c05c02d15bc176bd4096c796 (patch) | |
tree | b08ee881b03049fcc81e88383075298bc61b4ae6 /tools/libxc | |
parent | 45ac7f53d72d2205089e351068b21e2ecbcf0c25 (diff) | |
parent | 8fe9e65cb458e257c4515e2afe80104c0622247b (diff) | |
download | xen-8abea5a1745efde8c05c02d15bc176bd4096c796.tar.gz xen-8abea5a1745efde8c05c02d15bc176bd4096c796.tar.bz2 xen-8abea5a1745efde8c05c02d15bc176bd4096c796.zip |
merge with xen-unstable.hg
Diffstat (limited to 'tools/libxc')
-rw-r--r-- | tools/libxc/Makefile | 1 | ||||
-rw-r--r-- | tools/libxc/xc_cpu_hotplug.c | 53 | ||||
-rw-r--r-- | tools/libxc/xc_cpuid_x86.c | 51 | ||||
-rw-r--r-- | tools/libxc/xc_domain_save.c | 19 | ||||
-rw-r--r-- | tools/libxc/xc_pm.c | 1 | ||||
-rw-r--r-- | tools/libxc/xenctrl.h | 2 |
6 files changed, 114 insertions, 13 deletions
diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile index c68a0f0d9e..4ec156c1d8 100644 --- a/tools/libxc/Makefile +++ b/tools/libxc/Makefile @@ -19,6 +19,7 @@ CTRL_SRCS-y += xc_sedf.c CTRL_SRCS-y += xc_csched.c CTRL_SRCS-y += xc_tbuf.c CTRL_SRCS-y += xc_pm.c +CTRL_SRCS-y += xc_cpu_hotplug.c CTRL_SRCS-y += xc_resume.c CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c diff --git a/tools/libxc/xc_cpu_hotplug.c b/tools/libxc/xc_cpu_hotplug.c new file mode 100644 index 0000000000..4f68823974 --- /dev/null +++ b/tools/libxc/xc_cpu_hotplug.c @@ -0,0 +1,53 @@ +/****************************************************************************** + * xc_cpu_hotplug.c - Libxc API for Xen Physical CPU hotplug Management + * + * Copyright (c) 2008, Shan Haitao <haitao.shan@intel.com> + * + * 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. + * + */ + +#include "xc_private.h" + +int xc_cpu_online(int xc_handle, int cpu) +{ + DECLARE_SYSCTL; + int ret; + + sysctl.cmd = XEN_SYSCTL_cpu_hotplug; + sysctl.u.cpu_hotplug.cpu = cpu; + sysctl.u.cpu_hotplug.op = XEN_SYSCTL_CPU_HOTPLUG_ONLINE; + ret = xc_sysctl(xc_handle, &sysctl); + + return ret; +} + +int xc_cpu_offline(int xc_handle, int cpu) +{ + DECLARE_SYSCTL; + int ret; + + sysctl.cmd = XEN_SYSCTL_cpu_hotplug; + sysctl.u.cpu_hotplug.cpu = cpu; + sysctl.u.cpu_hotplug.op = XEN_SYSCTL_CPU_HOTPLUG_OFFLINE; + ret = xc_sysctl(xc_handle, &sysctl); + + return ret; +} + diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c index 2f08182bfd..6a8e7594c8 100644 --- a/tools/libxc/xc_cpuid_x86.c +++ b/tools/libxc/xc_cpuid_x86.c @@ -92,6 +92,7 @@ static void amd_xc_cpuid_policy( /* Filter all other features according to a whitelist. */ regs[2] &= ((is_64bit ? bitmaskof(X86_FEATURE_LAHF_LM) : 0) | + bitmaskof(X86_FEATURE_CMP_LEGACY) | bitmaskof(X86_FEATURE_ALTMOVCR) | bitmaskof(X86_FEATURE_ABM) | bitmaskof(X86_FEATURE_SSE4A) | @@ -108,6 +109,14 @@ static void amd_xc_cpuid_policy( bitmaskof(X86_FEATURE_3DNOWEXT)); break; } + + case 0x80000008: + /* + * ECX[15:12] is ApicIdCoreSize: ECX[7:0] is NumberOfCores (minus one). + * Update to reflect vLAPIC_ID = vCPU_ID * 2. + */ + regs[2] = ((regs[2] & 0xf000u) + 1) | ((regs[2] & 0xffu) << 1) | 1u; + break; } } @@ -123,8 +132,13 @@ static void intel_xc_cpuid_policy( break; case 0x00000004: - regs[0] &= 0x3FF; - regs[3] &= 0x3FF; + /* + * EAX[31:26] is Maximum Cores Per Package (minus one). + * Update to reflect vLAPIC_ID = vCPU_ID * 2. + */ + regs[0] = (((regs[0] & 0x7c000000u) << 1) | 0x04000000u | + (regs[0] & 0x3ffu)); + regs[3] &= 0x3ffu; break; case 0x80000001: { @@ -137,6 +151,15 @@ static void intel_xc_cpuid_policy( (is_64bit ? bitmaskof(X86_FEATURE_SYSCALL) : 0)); break; } + + case 0x80000005: + regs[0] = regs[1] = regs[2] = 0; + break; + + case 0x80000008: + /* Mask AMD Number of Cores information. */ + regs[2] = 0; + break; } } @@ -158,6 +181,12 @@ static void xc_cpuid_hvm_policy( break; case 0x00000001: + /* + * EBX[23:16] is Maximum Logical Processors Per Package. + * Update to reflect vLAPIC_ID = vCPU_ID * 2. + */ + regs[1] = (regs[1] & 0x0000ffffu) | ((regs[1] & 0x007f0000u) << 1); + regs[2] &= (bitmaskof(X86_FEATURE_XMM3) | bitmaskof(X86_FEATURE_SSSE3) | bitmaskof(X86_FEATURE_CX16) | @@ -185,7 +214,8 @@ static void xc_cpuid_hvm_policy( bitmaskof(X86_FEATURE_MMX) | bitmaskof(X86_FEATURE_FXSR) | bitmaskof(X86_FEATURE_XMM) | - bitmaskof(X86_FEATURE_XMM2)); + bitmaskof(X86_FEATURE_XMM2) | + bitmaskof(X86_FEATURE_HT)); /* We always support MTRR MSRs. */ regs[3] |= bitmaskof(X86_FEATURE_MTRR); @@ -207,15 +237,16 @@ static void xc_cpuid_hvm_policy( case 0x80000008: regs[0] &= 0x0000ffffu; - regs[1] = regs[2] = regs[3] = 0; + regs[1] = regs[3] = 0; break; - case 0x00000002: - case 0x00000004: - case 0x80000002: - case 0x80000003: - case 0x80000004: - case 0x80000006: + case 0x00000002: /* Intel cache info (dumped by AMD policy) */ + case 0x00000004: /* Intel cache info (dumped by AMD policy) */ + case 0x80000002: /* Processor name string */ + case 0x80000003: /* ... continued */ + case 0x80000004: /* ... continued */ + case 0x80000005: /* AMD L1 cache/TLB info (dumped by Intel policy) */ + case 0x80000006: /* AMD L2/3 cache/TLB info ; Intel L2 cache features */ break; default: diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c index c6e1c23c32..a910414988 100644 --- a/tools/libxc/xc_domain_save.c +++ b/tools/libxc/xc_domain_save.c @@ -727,7 +727,7 @@ static xen_pfn_t *map_and_save_p2m_table(int xc_handle, out: if ( !success && p2m ) - munmap(p2m, ROUNDUP(p2m_size * sizeof(xen_pfn_t), PAGE_SHIFT)); + munmap(p2m, P2M_FLL_ENTRIES * PAGE_SIZE); if ( live_p2m_frame_list_list ) munmap(live_p2m_frame_list_list, PAGE_SIZE); @@ -1115,7 +1115,20 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, goto out; } - if ( !hvm ) + if ( hvm ) + { + /* Look for and skip completely empty batches. */ + for ( j = 0; j < batch; j++ ) + if ( (pfn_type[j] & XEN_DOMCTL_PFINFO_LTAB_MASK) != + XEN_DOMCTL_PFINFO_XTAB ) + break; + if ( j == batch ) + { + munmap(region_base, batch*PAGE_SIZE); + continue; /* bail on this batch: no valid pages */ + } + } + else { /* Get page types */ for ( j = 0; j < batch; j++ ) @@ -1595,7 +1608,7 @@ int xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, munmap(live_shinfo, PAGE_SIZE); if ( live_p2m ) - munmap(live_p2m, ROUNDUP(p2m_size * sizeof(xen_pfn_t), PAGE_SHIFT)); + munmap(live_p2m, P2M_FLL_ENTRIES * PAGE_SIZE); if ( live_m2p ) munmap(live_m2p, M2P_SIZE(max_mfn)); diff --git a/tools/libxc/xc_pm.c b/tools/libxc/xc_pm.c index 2737cbe312..69f6b6e155 100644 --- a/tools/libxc/xc_pm.c +++ b/tools/libxc/xc_pm.c @@ -66,6 +66,7 @@ int xc_pm_get_pxstat(int xc_handle, int cpuid, struct xc_px_stat *pxpt) sysctl.cmd = XEN_SYSCTL_get_pmstat; sysctl.u.get_pmstat.type = PMSTAT_get_pxstat; sysctl.u.get_pmstat.cpuid = cpuid; + sysctl.u.get_pmstat.u.getpx.total = max_px; set_xen_guest_handle(sysctl.u.get_pmstat.u.getpx.trans_pt, pxpt->trans_pt); set_xen_guest_handle(sysctl.u.get_pmstat.u.getpx.pt, (pm_px_val_t *)pxpt->pt); diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index 7202e8171d..bdeaf2647c 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -1156,4 +1156,6 @@ int xc_pm_get_max_cx(int xc_handle, int cpuid, int *max_cx); int xc_pm_get_cxstat(int xc_handle, int cpuid, struct xc_cx_stat *cxpt); int xc_pm_reset_cxstat(int xc_handle, int cpuid); +int xc_cpu_online(int xc_handle, int cpu); +int xc_cpu_offline(int xc_handle, int cpu); #endif /* XENCTRL_H */ |