Commit Graph
8918 Commits
Author SHA1 Message Date
Keir Fraser 0b6ade9b3a Merge 2009-11-13 15:46:58 +00:00
Keir Fraser 12af847917 vtd: Make vtd faults dmesg more readable
This simple patch makes the VTd faults dmesg more readable and
helpful for debugging.

Signed-Off-By: Zhai Edwin <edwin.zhai@intel.com>
2009-11-13 15:38:57 +00:00
Keir Fraser 4da23c0c03 x86: Change the interface physdev_map_pirq to support new dom0.
It also keeps compatibility with old dom0.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
2009-11-13 15:31:45 +00:00
Keir Fraser 0ddbfec52a x86: Disable spinlock checks temporarily while bringing a CPU online.
This is safe, as described in a code comment. Also fix up another
comment in start_secondary() while we're there.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-11-12 15:34:37 +00:00
Keir Fraser 86a7522040 Don't assume vcpu_id's are contiguous in alloc_vcpu
When cpu hot-added, this assumption is broken because the hot-added
CPU may be brougt online by dom0 in arbitrary order. This patch avoids
making this assumption while still linking vcpus in ascending order of
identifier.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-11-12 13:15:40 +00:00
Keir Fraser 48fd672fee Revert 20045:db1890f07661 "Revert alloc_idle_vcpu()..."
The old implementation of alloc_idle_vcpu() is unnecessary since
arch-specific code ensures that a single idle domain supports NR_CPUS
vcpus, despite the usual limit of MAX_VIRT_CPUS for ordinary domains.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-11-12 13:02:27 +00:00
Keir Fraser daa70e9d6e x86: Remove non-CONFIG_HOTPLUG_CPU code, and general cleanup.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-11-12 11:59:18 +00:00
Keir Fraser c1100c28ed Support physical CPU hot-add in xen hypervisor
This patch add CPU hot-add in system.
a) It mark all CPU as possible when booting, if CONFIG_HOTPLUG_CPU is
set. BTW, this will increase per_cpu area.

b) When a CPU is added through hypercall, the CPU will be marked as
present and offline, and the numa information is setup if numa is
supported. The CPU will be brought to online by dom0 online explicitly.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
2009-11-12 11:43:21 +00:00
Keir Fraser f4cf0d5e88 Update pcpu_info hypercall interface
This patch change the XENPF_get_cpuinfo interface to pass only one
pcpu information each hypercall. Also, it replace
xenpf_resource_hotplug with XENPF_cpu_online/offline.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
2009-11-12 11:42:36 +00:00
Keir Fraser f8a685ad57 A few trivial cleanups
Alphabetize object files and guest config options for better
readability. Also remove svm interrupt prototypes which do not
exist.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2009-11-12 11:42:02 +00:00
Keir Fraser 2eba88c6af PoD: Handle operations properly when domain is dying
No populate-on-demand activities should happen when a domain is dying.
Especially, it is a bug for memory to be added to the PoD cache when
d->is_dying is non-zero, since if this happens after the cache has
been emptied, these pages will never be freed. This may cause "zombie
domains" to linger.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
2009-11-12 11:39:51 +00:00
Keir Fraser 24be6cfe21 Mark CPU present when it is detected
Currently a CPU is marked as present only after it has been kicked off
successfully, i.e. before the CPU is brought up, it is not
present. This patch try to mark CPU as present when it is detected
(either through MPS table or ACPI). If it can't be brought up
successfully, it will be marked as non-present again.  This change is
mainly for CPU hot-plug. As discussed, we'd take two step for physical
CPU hot-add. A CPU is firstly marked as present, and later will bring
as online.

Also, In smp_boot_cpus(), xen need only scan all present CPU, and no
need to loop from 0... NR_CPUS. With this change, the bios_cpu_apicid
is not needed anymore.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
2009-11-10 13:04:45 +00:00
Keir Fraser fee63693e0 Hypercall to expose physical CPU information.
It also make some changes to current cpu online/offline logic:
1) Firstly, cpu online/offline will trigger a vIRQ to dom0 for status
changes notification.
2) It also add an interface to platform operation to online/offline
physical CPU. Currently the cpu online/offline interface is in sysctl,
which can't be triggered in kernel. With this change, it is possible
to trigger cpu online/offline in dom0 through sysfs interface.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
2009-11-10 13:03:42 +00:00
Keir Fraser 9c2eca8f17 unlzma: Remove 'inline' decl from non-static function.
Breaks the build with some versions of gcc.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-11-09 22:30:21 +00:00
Keir Fraser abe3377eb2 x86: Fix clip_to_limit().
There are issues in updating the e820 map in the middle of a loop that
iterates over it. For example, after memmove(&e820.map[i],
&e820.map[i+1], ...), the original e820.map[i+1] become current
e820.map[i] but the next loop count is i+1, so the original
e820.map[i+1] will be skipped.

Fix and clarify the code by making a double loop.

Original bug discovery and fix by Xiao Guangrong <ericxiao.gr@gmail.com>

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-11-09 20:43:40 +00:00
Keir Fraser b6a5bfafee cmdline_parse_early: fix parse 'edd=' option
If 'edd='is default, it should decrease "opt_edd" not "opt_edid"

Signed-off-by: Xiao Guangrong <ericxiao.gr@gmail.com>
2009-11-09 20:06:48 +00:00
Keir Fraser 3f3b3ccbb3 e820: fix e820_change_range_type()
In below case, e820_change_range_type() will return success:
[s, e] is in the middle of [rs, re] and e820->nr_map+1 >=
ARRAY_SIZE(e820->map) actually, it's failed, so this patch fix it

Signed-off-by: Xiao Guangrong <ericxiao.gr@gmail.com>
2009-11-09 20:05:43 +00:00
Keir Fraser 2e6a2d4dba x86_32: Respect e820 map when populating Xen heap.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-11-09 08:19:55 +00:00
Keir Fraser cef4294cff x86, cpuid: mask TSC invariant bit for PV and HVM domains if migration
is not disabled and TSC is not emulated

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-11-09 08:03:30 +00:00
Keir Fraser ab77e81f65 x86/dom0: support bzip2 and lzma compressed bzImage payloads
This matches functionality in the tools already supporting the same
for DomU-s.

Code taken from Linux 2.6.32-rc and adjusted as little as possible to
be usable in Xen.

The question is whether, particularly for non-Linux Dom0-s, plain ELF
images compressed by bzip2 or lzma should also be supported.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
2009-11-09 07:52:27 +00:00
Keir Fraser b8a456caed x86: improve reporting through XENMEM_machine_memory_map
Since Dom0 derives machine address ranges usable for assigning PCI
device resources from the output of this sub-hypercall, Xen should
make
sure it properly reports all ranges not suitable for this (as either
reserved or unusable):
- RAM regions excluded via command line option
- memory regions used by Xen itself (LAPIC, IOAPICs)

While the latter should generally already be excluded by the BIOS
provided E820 table, this apparently isn't always the case at least
for IOAPICs, and with Linux having got changed to account for this it
seems to make sense to also do so in Xen.

Generally the HPET range should also be excluded here, but since it
isn't being reflected in Dom0's iomem_caps (and can't be, as it's a
sub-page range) I wasn't sure whether adding explicit code for doing
so would be reasonable.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
2009-11-03 12:40:28 +00:00
Keir Fraser b95beb1858 x86: Clean up APIC local timer handling.
1. Writing TMICT=0 disables the timer. Use this fact to simplify and
improve reprogram_timer(). In particular, we always write TMICT, and
write zero when we do not need a timer interrupt.

2. In HPET broadcast timer handler, set TMICT=0 when we mask the APIC
local timer. May as well do this early, before entering deep sleep.

3. In HVM-guest APIC emulation, disable the emulated local timer when
the guest sets TMICT=0. Previously we would issue an immediate
one-shot interrupt.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-11-03 09:33:22 +00:00
Keir Fraser ad1f74192a vmx: Disable vPMU feature by default
Signed-off-by: Shan Haitao <haitao.shan@intel.com>
2009-11-03 08:40:40 +00:00
Keir Fraser 18e03239ef Fixes after addition of dummy_vcpu_info.
- Clean initialisation of new vcpu_info in map_vcpu_info() if the
 vcpu was previously using the shared dummy structure.
 - Don't allow a vcpu to run with teh shared dummy info structure, as
 no good can come of it.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-11-02 09:38:34 +00:00
Keir Fraser 6785f5fef3 Extend the max vcpu number for HVM guest.
- Originally the max vcpu number for HVM guest is 32, this patch
 extend the number to 128 on x86_64 hypervisor. (For i386 hypervisor,
 the max vcpu number  is still 32).
 - This patch extends the mp-table size to fit more vcpus.
 - HVM PV driver should call VCPUOP_register_vcpu_info hypercall to
 initialize the vcpu info if the vcpu number is more than 32.

Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-10-29 14:48:28 +00:00
Keir Fraser abcac52872 AMD IOMMU: remove a BUG_ON condition, to allow boot
Signed-off-by: Wei Wang <wei.wang2@amd.com>
2009-10-29 14:05:46 +00:00
Keir Fraser dd11df9b81 Extend max vcpu number for HVM guest
Reduce size of Xen-qemu shared ioreq structure to 32 bytes. This
has two advantages:
 1. We can support up to 128 VCPUs with a single shared page
 2. If/when we want to go beyond 128 VCPUs, a whole number of ioreq_t
    structures will pack into a single shared page, so a multi-page
    array will have no ioreq_t straddling a page boundary

Also, while modifying qemu, replace a 32-entry vcpu-indexed array
with a dynamically-allocated array.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-10-29 14:03:56 +00:00
Keir Fraser bde7d0c41a Point per-vcpu vcpu_info at a dummy structure by default, avoiding
need for scattered NULL-pointer checks.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-10-29 11:14:54 +00:00
Keir Fraser a7a8dc9942 iommu: Do not initialise global vars explicitly to zero.
Unnecessary and prevents them being allocated in BSS rather than data.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-10-28 17:27:47 +00:00
Keir Fraser e99b5708b6 vtd: Simplify acpi_dmar_init().
No need to check force_iommu, as that is done later in common code.

Also no need to clear iommu_enabled as again this gets checked
later. Furthermore doing it here, from a non-Intel-specific callsite,
breaks other vendors' IOMMU support.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-10-28 17:27:09 +00:00
Keir Fraser 952ae2717b AMD IOMMU: Use global interrupt remapping table by default
Using a global interrupt remapping table shared by all devices has
better compatibility with certain old BIOSes. Per-device interrupt
remapping table can still be enabled by using a new parameter
"amd-iommu-perdev-intremap".

Signed-off-by: Wei Wang <wei.wang2@amd.com>
2009-10-28 17:08:26 +00:00
Keir Fraser fff38b68f8 x86: vioapic: fix remote irr bit setting for level triggered interrupts
Clear all entries' remote irr bits once the RTE entries' vector field
match with EOI message's vector.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
2009-10-28 10:59:14 +00:00
Keir Fraser de349fe6b0 scheduler: small csched_cpu_pick() adjustments
When csched_cpu_pick() decides to move a vCPU to a different pCPU, so
far in the vast majority of cases it selected the first core/thread of
the most idle socket/core. When there are many short executing
entities, this will generally lead to them not getting evenly
distributed (since primary cores/threads will be preferred), making
the need for subsequent migration more likely. Instead, candidate
cores/threads should get treated as symmetrically as possible, and
hence this changes the selection logic to cycle through all
candidates.

Further, since csched_cpu_pick() will never move a vCPU between
threads of the same core (and since the weights calculated for
individual threads of the same core are always identical), rather than
removing just the selected pCPU from the mask that still needs looking
at, all siblings of the chosen pCPU can be removed at once without
affecting the outcome.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
2009-10-28 10:56:39 +00:00
Keir Fraser 9119667be2 x86: deny access to the ACPI PM timer I/O port range for Dom0
Also move the declaration of pmtmr_ioport to a suitable header file.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
2009-10-28 10:55:53 +00:00
Keir Fraser 6b8d4098ca Boot parameter definition adjustments
Consolidate the various attributes into macros, and tell the compiler
not to needlessly waste spec for aligning strings used at most once.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
2009-10-28 10:55:17 +00:00
Keir Fraser a8b1845a78 Miscellaneous data placement adjustments
Make various data items const or __read_mostly where
possible/reasonable.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
2009-10-28 10:54:50 +00:00
Keir Fraser 0a7e9c30b5 irq cleanup
Make IRQ related data const or __read_mostly where possible/reasonable,
use platform_legacy_irq() where feasible, and remove the now unused
definition of vector_to_irq().

Signed-off-by: Jan Beulich <jbeulich@novell.com>
2009-10-28 10:54:20 +00:00
Keir Fraser 78942912c8 xsm: Add support for Xen device policies
Add support for Xen ocontext records to enable device polices.  The
default policy will not be changed and instructions have been added to
enable the new functionality.  Examples on how to use the new policy
language have been added but commented out.  The newest version of
checkpolicy (>= 2.0.20) and libsepol (>= 2.0.39) is needed in order to
compile it.  Devices can be labeled and enforced using the following
new commands; pirqcon, iomemcon, ioportcon and pcidevicecon.

Signed-off-by : George Coker <gscoker@alpha.ncsc.mil>
Signed-off-by : Paul Nuzzi <pjnuzzi@tycho.ncsc.mil>
2009-10-27 12:52:57 +00:00
Keir Fraser f821102450 x86: IRQ Migration logic enhancement.
To programme MSI's addr/vector safely, delay irq migration
operation before acking next interrupt. In this way, it should
avoid inconsistent interrupts generation due to non-atomic writing
addr and data registers about MSI.

Port the logic from Linux and tailor it for Xen.

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
2009-10-26 13:33:38 +00:00
Keir Fraser 9db20f3c2b x86: Small simplification to get_page_from_l1e().
No need for separate top-level check for page owner being NULL: this
can be folded into the case that page owner is not who the caller
expected (caller will never expect NULL owner).

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-10-26 13:26:43 +00:00
Keir Fraser 7a64bef908 hvm: Clean up EPT/NPT 'nested page fault' handling.
Share most of the code.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-10-26 13:19:33 +00:00
Keir Fraser 02a4e58f0b shadow dirty-VRAM: avoid multiple remove_all_mappings calls.
sh_remove_all_mappings() will walk roughly half of the shadow L1
tables for each MFN it's called with; calling it for every MFN in a
guest's framebuffer can be _very_ expensive, especially with the
shadow lock held across the whole operation.  Avoid that by just
blowing away all the shadows.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
2009-10-26 12:18:50 +00:00
Keir Fraser def87a2cbf x86: Enable TSC_RELIABLE for AMD servers
Except for a published BIOS errata on family 11h processors,
all AMD servers that have the Invariant TSC bit set have
a reliable TSC so Xen should not write to the TSC.

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
Acked-by: Mark Langsdorf <mark.langsdorf@amd.com>
2009-10-23 10:15:17 +01:00
Keir Fraser d6d3c05250 x86 ept: ignore guest writes to read only memory regions or memory
holes in EPT.

This patch prevents domain crash when running memtest86 with EPT.

Signed-off-by: Xin Li <xin.li@intel.com>
2009-10-23 10:13:52 +01:00
Keir Fraser e3d7f1dd25 vtd: interrupt remapping fix
Fix the error of translation from int remapping table entry(IRTE) to
MSI msg. This error may write wrong IRTE back to the VTd hardware, and
block physical interrupts.

Signed-Off-By: Zhai Edwin <edwin.zhai@intel.com>
2009-10-23 10:13:22 +01:00
Keir Fraser cd5cf5efb2 xsm: Corrected check in io_has_perm()
Fix the check in io_has_perm() to correctly check the start and end
of I/O Memory.

Signed-off-by : George Coker <gscoker@alpha.ncsc.mil>
Signed-off-by : Paul Nuzzi <pjnuzzi@tycho.ncsc.mil>
2009-10-23 10:12:52 +01:00
Keir Fraser 2220131142 x86: Fix RevF detection in powernow.c
The PowerNow! driver does not support RevF and earlier parts.
The current code checks for RevF processors in a function that
is not called.  Change the code path so that RevF processors
are detected and the driver fails registration.

Also fix cpufreq_add_cpu() to handle unsuccessful registration.

Signed-off-by: Mark Langsdorf <mark.langsdorf@amd.com>
2009-10-23 10:11:52 +01:00
Keir Fraser 545a227dfc passthrough/stubdom: clean up hypercall privilege checking
This patch adds securty checks for pci passthrough related hypercalls
to enforce that the current domain owns the resources that it is about
to remap. It also adds a call to xc_assign_device to xend and removes
the PRIVILEGED_STUBDOMS flags.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2009-10-23 10:04:03 +01:00
Keir Fraser 9cd9340a83 x86: Initialize the affinity field after assigning the vector.
To avoid strange output from debug-key "i", desc->affinity should
be the subset of the cfg->domain basically, so copy cfg->domain to
desc->affinity after assigning vector for the irq..

Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
2009-10-21 16:07:37 +01:00
Keir Fraser 131e05c790 Remove unused XEN_DOMINF_cpu{mask,shift} definitions.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
2009-10-21 16:05:05 +01:00