]> xenbits.xensource.com Git - xen.git/log
xen.git
11 years agox86: Improve information from domain_crash_synchronous
Andrew Cooper [Fri, 4 Oct 2013 10:58:20 +0000 (12:58 +0200)]
x86: Improve information from domain_crash_synchronous

As it currently stands, the string "domain_crash_sync called from entry.S" is
not helpful at identifying why the domain was crashed, and a debug build of
Xen doesn't help the matter

This patch improves the information printed, by pointing to where the crash
decision was made.

Specific improvements include:
 * Moving the ascii string "domain_crash_sync called from entry.S\n" away from
   some semi-hot code cache lines.
 * Moving the printk into C code (especially as this_cpu() is miserable to use
   in assembly code)
 * Undo the previous confusing situation of having the
   domain_crash_synchronous() as a macro in C code, yet a global symbol in
   assembly code.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agox86/traps: Record last extable faulting address
Andrew Cooper [Fri, 4 Oct 2013 10:57:43 +0000 (12:57 +0200)]
x86/traps: Record last extable faulting address

... so the following patch can identify the location of faults leading to a
decision to crash a domain.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agox86: allow HVM guests to make console_io hypercall
Konrad Rzeszutek Wilk [Fri, 4 Oct 2013 10:54:38 +0000 (12:54 +0200)]
x86: allow HVM guests to make console_io hypercall

The console_io hypercall is provided for PV guests and for HVM
guests it is done via the 0xe9 port. However the PV hypercall
is more efficient as it takes a string rather than one character
per write.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
11 years agoxsm: clean up unneeded current references
Daniel De Graaf [Fri, 4 Oct 2013 10:52:56 +0000 (12:52 +0200)]
xsm: clean up unneeded current references

Some XSM hooks in dummy.h used current->domain when this was also passed
as a parameter; use the parameter in these cases. There are two hooks
where this does not apply and which are not immediately obvious:
xsm_set_target's parameters are the device model and HVM domains, and
xsm_mem_sharing_op's first parameter is the source of the shared page,
not the domain making the hypercall.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
11 years agoxsm: forbid PV guest console reads
Daniel De Graaf [Fri, 4 Oct 2013 10:51:44 +0000 (12:51 +0200)]
xsm: forbid PV guest console reads

The CONSOLEIO_read operation was incorrectly allowed to PV guests if the
hypervisor was compiled in debug mode (with VERBOSE defined).

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
11 years agox86: make hvm_cpuid() tolerate NULL pointers
Jan Beulich [Fri, 4 Oct 2013 10:32:25 +0000 (12:32 +0200)]
x86: make hvm_cpuid() tolerate NULL pointers

Now that other HVM code started making more extensive use of
hvm_cpuid(), let's not force every caller to declare dummy variables
for output not cared about.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Jun Nakajima <jun.nakajima@intel.com>
11 years agoNested VMX: fix IA32_VMX_CR4_FIXED1 msr emulation
Yang Zhang [Fri, 4 Oct 2013 10:30:09 +0000 (12:30 +0200)]
Nested VMX: fix IA32_VMX_CR4_FIXED1 msr emulation

Currently, it use hardcode value for IA32_VMX_CR4_FIXED1. This is wrong.
We should check guest's cpuid to know which bits are writeable in CR4 by guest
and allow the guest to set the corresponding bit only when guest has the feature.

Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
Cleanup.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Jun Nakajima <jun.nakajima@intel.com>
11 years agoVMX: clean up capability checks
Jan Beulich [Fri, 4 Oct 2013 10:29:08 +0000 (12:29 +0200)]
VMX: clean up capability checks

VMCS size validation on APs should check against BP's size.

No need for a separate cpu_has_vmx_ins_outs_instr_info variable
anymore.

Use proper symbolics.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Jun Nakajima <jun.nakajima@intel.com>
11 years agoNested VMX: check VMX capability before read VMX related MSRs
Yang Zhang [Fri, 4 Oct 2013 10:28:14 +0000 (12:28 +0200)]
Nested VMX: check VMX capability before read VMX related MSRs

VMX MSRs only available when the CPU support the VMX feature. In addition,
VMX_TRUE* MSRs only available when bit 55 of VMX_BASIC MSR is set.

Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
Cleanup.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Jun Nakajima <jun.nakajima@intel.com>
11 years agox86/percpu: Force INVALID_PERCPU_AREA into the non-canonical address region
Andrew Cooper [Fri, 4 Oct 2013 10:24:34 +0000 (12:24 +0200)]
x86/percpu: Force INVALID_PERCPU_AREA into the non-canonical address region

This causes accidental uses of per_cpu() on a pcpu with an INVALID_PERCPU_AREA
to result in a #GF for attempting to access the middle of the non-canonical
virtual address region.

This is preferable to the current behaviour, where incorrect use of per_cpu()
will result in an effective NULL structure dereference which has security
implication in the context of PV guests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agox86/idle: Fix get_cpu_idle_time()'s interaction with offline pcpus
Andrew Cooper [Fri, 4 Oct 2013 10:23:23 +0000 (12:23 +0200)]
x86/idle: Fix get_cpu_idle_time()'s interaction with offline pcpus

Checking for "idle_vcpu[cpu] != NULL" is insufficient protection against
offline pcpus.  From a hypercall, vcpu_runstate_get() will determine "v !=
current", and try to take the vcpu_schedule_lock().  This will try to look up
per_cpu(schedule_data, v->processor) and promptly suffer a NULL structure
deference as v->processors' __per_cpu_offset is INVALID_PERCPU_AREA.

One example might look like this:

...
Xen call trace:
   [<ffff82c4c0126ddb>] vcpu_runstate_get+0x50/0x113
   [<ffff82c4c0126ec6>] get_cpu_idle_time+0x28/0x2e
   [<ffff82c4c012b5cb>] do_sysctl+0x3db/0xeb8
   [<ffff82c4c023280d>] compat_hypercall+0xbd/0x116

Pagetable walk from 0000000000000040:
 L4[0x000] = 0000000186df8027 0000000000028207
 L3[0x000] = 0000000188e36027 00000000000261c9
 L2[0x000] = 0000000000000000 ffffffffffffffff

****************************************
Panic on CPU 11:
...

get_cpu_idle_time() has been updated to correctly deal with offline pcpus
itself by returning 0, in the same way as it would if it was missing the
idle_vcpu[] pointer.

In doing so, XENPF_getidletime needed updating to correctly retain its
described behaviour of clearing bits in the cpumap for offline pcpus.

As this crash can only be triggered with toolstack hypercalls, it is not a
security issue and just a simple bug.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agolibxl: correctly handle libxl_get_cpu_topology failure in libxl_{cpu, node}map_to_...
Matthew Daley [Sun, 29 Sep 2013 05:47:37 +0000 (18:47 +1300)]
libxl: correctly handle libxl_get_cpu_topology failure in libxl_{cpu, node}map_to_{node, cpu}map

Initialize nr_cpus to 0 so that if it is unchanged by a failing
libxl_get_cpu_topology, libxl_cputopology_list_free still works OK
afterward.

Coverity-ID: 1055294
Coverity-ID: 1055295
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Dario Faggioli <dario.faggioli@citrix.com>
11 years agoxen/arm: map_domain_page: reuse slots with avail == 0
Stefano Stabellini [Mon, 30 Sep 2013 12:06:12 +0000 (13:06 +0100)]
xen/arm: map_domain_page: reuse slots with avail == 0

If a slot has avail == 0 but still points to the right mfn, reuse it.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: only put poller if already gotten in libxl_event_wait
Matthew Daley [Sun, 29 Sep 2013 05:24:36 +0000 (18:24 +1300)]
libxl: only put poller if already gotten in libxl_event_wait

Coverity-ID: 1055292
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxc: only munmap when something has actually been mapped in change_pte
Matthew Daley [Sun, 29 Sep 2013 01:35:02 +0000 (14:35 +1300)]
libxc: only munmap when something has actually been mapped in change_pte

Coverity-ID: 1055269
signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxm-test: fix the ip allocation function
Zhu Yanhai [Mon, 30 Sep 2013 08:12:10 +0000 (16:12 +0800)]
xm-test: fix the ip allocation function

__findFirstOctetIP() is expecting min and max available octets according to
its code, however the caller getFreeIP() gives it the min octet and (max -
min + 1), which is the length instead.

Signed-off-by: Zhu Yanhai <gaoyang.zyh@taobao.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm32: don't export v7_init
Julien Grall [Fri, 27 Sep 2013 16:49:52 +0000 (17:49 +0100)]
xen/arm32: don't export v7_init

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxl: fork before execing vncviewer
Ian Campbell [Fri, 27 Sep 2013 10:16:22 +0000 (11:16 +0100)]
xl: fork before execing vncviewer

Otherwise we don't daemonize to monitor the domain.

Heavily cargo-culted from autoconnect-console and only compile tested.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Olaf Hering <olaf@aepfle.de>
11 years agolibxl: handle null lists in libxl_string_list_length
Matthew Daley [Fri, 27 Sep 2013 11:29:10 +0000 (23:29 +1200)]
libxl: handle null lists in libxl_string_list_length

After commit b0be2b12 ("libxl: fix libxl_string_list_length and its only
caller") libxl_string_list_length no longer handles null (empty) lists. Fix
so they are handled, returning length 0.

While at it, remove the unneccessary undereferenced null pointer check
and tidy the layout of the function.

Reported-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agox86: don't blindly create L3 tables for the direct map
Jan Beulich [Mon, 30 Sep 2013 13:28:12 +0000 (15:28 +0200)]
x86: don't blindly create L3 tables for the direct map

Now that the direct map area can extend all the way up to almost the
end of address space, this is wasteful.

Also fold two almost redundant messages in SRAT parsing into one.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Malcolm Crossley <malcolm.crossley@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agox86: properly set up fbld emulation operand address
Jan Beulich [Mon, 30 Sep 2013 12:18:58 +0000 (14:18 +0200)]
x86: properly set up fbld emulation operand address

This is CVE-2013-4361 / XSA-66.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
11 years agox86/mm/shadow: Fix initialization of PV shadow L4 tables.
Tim Deegan [Mon, 30 Sep 2013 12:18:25 +0000 (14:18 +0200)]
x86/mm/shadow: Fix initialization of PV shadow L4 tables.

Shadowed PV L4 tables must have the same Xen mappings as their
unshadowed equivalent.  This is done by copying the Xen entries
verbatim from the idle pagetable, and then using guest_l4_slot()
in the SHADOW_FOREACH_L4E() iterator to avoid touching those entries.

adc5afbf1c70ef55c260fb93e4b8ce5ccb918706 (x86: support up to 16Tb)
changed the definition of ROOT_PAGETABLE_XEN_SLOTS to extend right to
the top of the address space, which causes the shadow code to
copy Xen mappings into guest-kernel-address slots too.

In the common case, all those slots are zero in the idle pagetable,
and no harm is done.  But if any slot above #271 is non-zero, Xen will
crash when that slot is later cleared (it attempts to drop
shadow-pagetable refcounts on its own L4 pagetables).

Fix by using the new ROOT_PAGETABLE_PV_XEN_SLOTS when appropriate.
Monitor pagetables need the full Xen mappings, so they keep using the
old name (with its new semantics).

This is CVE-2013-4356 / XSA-64.

Signed-off-by: Tim Deegan <tim@xen.org>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
11 years agox86: properly handle hvm_copy_from_guest_{phys,virt}() errors
Jan Beulich [Mon, 30 Sep 2013 12:17:46 +0000 (14:17 +0200)]
x86: properly handle hvm_copy_from_guest_{phys,virt}() errors

Ignoring them generally implies using uninitialized data and, in all
but two of the cases dealt with here, potentially leaking hypervisor
stack contents to guests.

This is CVE-2013-4355 / XSA-63.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
11 years agox86/AMD-Vi: Fix IVRS HPET special->handle override
Suravee Suthikulpanit [Mon, 30 Sep 2013 12:00:44 +0000 (14:00 +0200)]
x86/AMD-Vi: Fix IVRS HPET special->handle override

The current logic does not handle the case when HPET special->handle
is invalid in IVRS. On such system, the following message is shown:

(XEN) AMD-Vi: Failed to setup HPET MSI remapping: Wrong HPET

This patch will allow the ivrs_hpet[<handle>]=<sbdf> to override the
IVRS.  Also, it removes struct hpet_sbdf.iommu since it is not
used anywhere in the code.

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
11 years agocpupools: update domU's node-affinity on the cpupool_unassign_cpu() path
Dario Faggioli [Mon, 30 Sep 2013 11:59:47 +0000 (13:59 +0200)]
cpupools: update domU's node-affinity on the cpupool_unassign_cpu() path

that is, when a cpu is remove from a pool, as it is happening already
on the cpupool_assign_cpu_*() path (i.e., when a cpu is added to a
pool).

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Juergen Gross <juergen.gross@ts.fujitsu.com>
11 years agoNested VMX: Expose unrestricted guest feature to guest
Yang Zhang [Mon, 30 Sep 2013 11:58:48 +0000 (13:58 +0200)]
Nested VMX: Expose unrestricted guest feature to guest

With virtual unrestricted guest feature, L2 guest is allowed to run
with PG cleared. Also, allow PAE not set during virtual vmexit emulation.

Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
Acked-by: Eddie.Dong@intel.com
11 years agoxen: arm: move smp_init_cpus to smpboot.c
Ian Campbell [Fri, 27 Sep 2013 09:30:29 +0000 (10:30 +0100)]
xen: arm: move smp_init_cpus to smpboot.c

Seems like a better home.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: split cpu0's domheap mapping PTs out from xen_second
Ian Campbell [Mon, 16 Sep 2013 20:26:48 +0000 (21:26 +0100)]
xen: arm: split cpu0's domheap mapping PTs out from xen_second

Now that bringup has been rewritten we don't need these 4 contiguous pages for
the 1:1 map. So split them out and only allocate them for 32 bit

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm: configure TCR_EL2 for 40 bit physical address space
Ian Campbell [Mon, 16 Sep 2013 20:39:22 +0000 (21:39 +0100)]
xen: arm: configure TCR_EL2 for 40 bit physical address space

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm: use symbolic names for MPIDR bits.
Ian Campbell [Fri, 20 Sep 2013 16:51:20 +0000 (17:51 +0100)]
xen: arm: use symbolic names for MPIDR bits.

arm32 already uses MPIDR_HWID_MASK, use it on arm64 too. Add MPIDR_{SMP,UP}
(and bitwise equivalents) and use them.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm: rewrite start of day page table and cpu bring up
Ian Campbell [Thu, 29 Aug 2013 15:25:00 +0000 (16:25 +0100)]
xen: arm: rewrite start of day page table and cpu bring up

This is unfortunately a rather large monolithic patch.

Rather than bringing up all CPUs in lockstep as we setup paging and relocate
Xen instead create a simplified set of dedicated boot time pagetables.

This allows secondary CPUs to remain powered down or in the firmware until we
actually want to enable them. The bringup is now done later on in C and can be
driven by DT etc. I have included code for the vexpress platform, but other
platforms will need to be added.

The mechanism for deciding how to bring up a CPU differs between arm32 and
arm64. On arm32 it is essentially a per-platform property, with the exception
of PSCI which can be implemented globally (but isn't here). On arm64 there is a
per-cpu property in the device tree.

Secondary CPUs are brought up directly into the relocated Xen image, instead of
relying on being able to launch on the unrelocated Xen and hoping that it
hasn't been clobbered.

As part of this change drop support for switching from secure mode to NS HYP as
well as the early CPU kick. Xen now requires that it is launched in NS HYP
mode and that firmware configure things such that secondary CPUs can be woken
up by a primarly CPU in HYP mode. This may require fixes to bootloaders or the
use of a boot wrapper.

The changes done here (re)exposed an issue with relocating Xen and the compiler
spilling values to the stack between the copy and the actual switch to the
relocaed copy of Xen in setup_pagetables. Therefore switch to doing the copy
and switch in a single asm function where we can control precisely what gets
spilled to the stack etc.

Since we now have a separate set of boot pagetables it is much easier to build
the real Xen pagetables inplace before relocating rather than the more complex
approach of rewriting the pagetables in the relocated copy before switching.

This will also enable Xen to be loaded above the 4GB boundary on 64-bit.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: implement smp initialisation callbacks for exynos5
Ian Campbell [Fri, 27 Sep 2013 09:38:21 +0000 (10:38 +0100)]
xen: arm: implement smp initialisation callbacks for exynos5

These were removed in "xen: arm: rewrite start of day page table and cpu
bring up".

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: implement arch/platform SMP and CPU initialisation framework
Ian Campbell [Fri, 20 Sep 2013 22:29:44 +0000 (23:29 +0100)]
xen: arm: implement arch/platform SMP and CPU initialisation framework

Includes an implementation for vexpress using the sysflags interface and
support for the ARMv8 "spin-table" method.

Unused until "rewrite start of day page table and cpu bring up", split out to
simplify review.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: add two new device tree helpers
Ian Campbell [Tue, 17 Sep 2013 01:27:49 +0000 (02:27 +0100)]
xen: arm: add two new device tree helpers

 - dt_property_read_u64
 - dt_find_node_by_type

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: make sure we stay within the memory bank during mm setup
Ian Campbell [Mon, 16 Sep 2013 16:57:08 +0000 (17:57 +0100)]
xen: arm: make sure we stay within the memory bank during mm setup

Otherwise if there is a module in another bank we can run off the end.

Rename *n to *end to make it clearer what is happening.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: Log the raw MIDR on boot.
Ian Campbell [Mon, 16 Sep 2013 14:47:05 +0000 (15:47 +0100)]
xen: arm: Log the raw MIDR on boot.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm: build platform support only on the relevant arch
Ian Campbell [Fri, 27 Sep 2013 09:35:47 +0000 (10:35 +0100)]
xen: arm: build platform support only on the relevant arch

midway, omap5 and exynos are all 32-bit only platforms. This avoids needing
CONFIG_ARM_32 ifdefs around the SMP callbacks on such platforms.

Vexpress is both.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
11 years agoxen: arm: Load xen under 4GB on 32-bit
Ian Campbell [Wed, 5 Jun 2013 09:08:35 +0000 (10:08 +0100)]
xen: arm: Load xen under 4GB on 32-bit

We need to be able to use a 1:1 mapping during bring up.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agox86/microcode: Check whether the microcode is correct
Konrad Rzeszutek Wilk [Fri, 27 Sep 2013 08:25:08 +0000 (10:25 +0200)]
x86/microcode: Check whether the microcode is correct

We do the microcode code update in two steps - the presmp:
'microcode_presmp_init' and when CPUs are brought up: 'microcode_init'.
The earlier performs the microcode update on the BSP - but
unfortunately it does not check whether the update failed. Which means
that we might try later to update a incorrect payload on the rest of
CPUs.

This patch handles this odd situation.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agox86/microcode: Scan the initramfs payload for microcode blob
Konrad Rzeszutek Wilk [Fri, 27 Sep 2013 08:22:55 +0000 (10:22 +0200)]
x86/microcode: Scan the initramfs payload for microcode blob

The Linux kernel is able to update the microcode during early bootup
via inspection of the initramfs blob to see if there is an cpio image
with certain microcode files. Linux is able to function with two (or
more) cpio archives in the initrd b/c it unpacks all of the cpio
archives.

The format of the early initramfs is nicely documented in Linux's
Documentation/x86/early-microcode.txt:

Early load microcode
====================
By Fenghua Yu <fenghua.yu@intel.com>

Kernel can update microcode in early phase of boot time. Loading microcode early
can fix CPU issues before they are observed during kernel boot time.

Microcode is stored in an initrd file. The microcode is read from the initrd
file and loaded to CPUs during boot time.

The format of the combined initrd image is microcode in cpio format followed by
the initrd image (maybe compressed). Kernel parses the combined initrd image
during boot time. The microcode file in cpio name space is:
kernel/x86/microcode/GenuineIntel.bin

During BSP boot (before SMP starts), if the kernel finds the microcode file in
the initrd file, it parses the microcode and saves matching microcode in memory.
If matching microcode is found, it will be uploaded in BSP and later on in all
APs.

The cached microcode patch is applied when CPUs resume from a sleep state.

There are two legacy user space interfaces to load microcode, either through
/dev/cpu/microcode or through /sys/devices/system/cpu/microcode/reload file
in sysfs.

In addition to these two legacy methods, the early loading method described
here is the third method with which microcode can be uploaded to a system's
CPUs.

The following example script shows how to generate a new combined initrd file in
/boot/initrd-3.5.0.ucode.img with original microcode microcode.bin and
original initrd image /boot/initrd-3.5.0.img.

mkdir initrd
cd initrd
mkdir kernel
mkdir kernel/x86
mkdir kernel/x86/microcode
cp ../microcode.bin kernel/x86/microcode/GenuineIntel.bin
find .|cpio -oc >../ucode.cpio
cd ..
cat ucode.cpio /boot/initrd-3.5.0.img >/boot/initrd-3.5.0.ucode.img

As such this code inspects the initrd to see if the microcode
signatures are present and if so updates the hypervisor.

The option to turn this scan on/off is gated by the 'ucode'
parameter. The options are now:
 'scan'      Scan for the microcode in any multiboot payload.
 <index>     Attempt to load microcode blob (not the cpio archive
             format) from the multiboot payload number.

This option alters slightly the 'ucode' parameter by only allowing
either parameter:
  ucode=[<index>|scan]

Implementation wise the ucode_blob is defined as __initdata.
That is OK from the viewpoint of suspend/resume as the the underlaying
architecture microcode (microcode_intel or microcode_amd) end up saving
the blob in 'struct ucode_cpu_info' which is a per-cpu data
structure (see ucode_cpu_info). They end up saving it when doing the
pre-SMP (for CPU0) and SMP (for the rest) microcode loading.

Naturally if one does a hypercall to update the microcode and it is
newer, then the old per-cpu data is replaced.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agounmodified_drivers: enable build of usbfront driver
Olaf Hering [Fri, 27 Sep 2013 08:18:03 +0000 (10:18 +0200)]
unmodified_drivers: enable build of usbfront driver

Signed-off-by: Olaf Hering <olaf@aepfle.de>
11 years agohvmloader/smbios: Change strncpy to memcpy for anchor strings
Andrew Cooper [Fri, 27 Sep 2013 08:15:28 +0000 (10:15 +0200)]
hvmloader/smbios: Change strncpy to memcpy for anchor strings

Coverity complains about the use of strncpy() to completely fill the anchor
strings, resulting in an unterminated string.

Although the strncpy result is correct, the anchor strings are not strings in
the C sense, and use of memcpy is the prevaling style elsewhere in hvmloader
anyway.

While tidying up the style in this function, also remove some trailing
whitespace and gratuitous cast.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agoAMD IOMMU: fix Dom0 device setup failure for host bridges
Suravee Suthikulpanit [Fri, 27 Sep 2013 08:11:49 +0000 (10:11 +0200)]
AMD IOMMU: fix Dom0 device setup failure for host bridges

The host bridge device (i.e. 0x18 for AMD) does not require IOMMU, and
therefore is not included in the IVRS. The current logic tries to map
all PCI devices to an IOMMU. In this case, "xl dmesg" shows the
following message on AMD sytem.

(XEN) setup 0000:00:18.0 for d0 failed (-19)
(XEN) setup 0000:00:18.1 for d0 failed (-19)
(XEN) setup 0000:00:18.2 for d0 failed (-19)
(XEN) setup 0000:00:18.3 for d0 failed (-19)
(XEN) setup 0000:00:18.4 for d0 failed (-19)
(XEN) setup 0000:00:18.5 for d0 failed (-19)

This patch adds a new device type (i.e. DEV_TYPE_PCI_HOST_BRIDGE) which
corresponds to PCI class code 0x06 and sub-class 0x00. Then, it uses
this new type to filter when trying to map device to IOMMU.

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Reported-by: Stefan Bader <stefan.bader@canonical.com>
On VT-d refuse (un)mapping host bridges for other than the hardware
domain.

Coding style cleanup.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Xiantao Zhang <xiantao.zhang@intel.com>
11 years agoxen: support RAM at addresses 0 and 4096
Ian Campbell [Thu, 26 Sep 2013 11:35:42 +0000 (12:35 +0100)]
xen: support RAM at addresses 0 and 4096

Currently the mapping from pages to zones causes the page at zero to go into
zone -1 and the page at 4096 to go into zone 0, which is the Xen zone
(confusing various assertions).

Arrange instead for the mapping to be such that zone 0 is always reserved for
Xen and all other pages map to a zone >= 1.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Cc: jbeulich@suse.com
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen/arm: print the location of the Xen heap on 32 bit
Ian Campbell [Thu, 26 Sep 2013 11:35:41 +0000 (12:35 +0100)]
xen/arm: print the location of the Xen heap on 32 bit

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen/arm: rename boot misc region to boot reloc now it has a single purpose
Ian Campbell [Thu, 26 Sep 2013 11:35:40 +0000 (12:35 +0100)]
xen/arm: rename boot misc region to boot reloc now it has a single purpose

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen/arm: Support dtb /memreserve/ regions
Ian Campbell [Thu, 26 Sep 2013 11:35:39 +0000 (12:35 +0100)]
xen/arm: Support dtb /memreserve/ regions

This requires a mapping of the DTB during setup_mm. Previously this was in
the BOOT_MISC slot, which is clobbered by setup_pagetables. Split it out
into its own slot which can be preserved.

Also handle these regions as part of consider_modules() and when adding pages
to the heaps to ensure we do not locate any part of Xen or the heaps over
them.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen/arm: cope with modules outside of "visible" RAM
Ian Campbell [Thu, 26 Sep 2013 11:35:38 +0000 (12:35 +0100)]
xen/arm: cope with modules outside of "visible" RAM

This can happen if modules are in a bank which we can't cope with e.g. due to
being non-contiguous.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen/arm: do not relocate Xen outside of visible RAM
Ian Campbell [Thu, 26 Sep 2013 11:35:37 +0000 (12:35 +0100)]
xen/arm: do not relocate Xen outside of visible RAM

Since we do not handle non-contiguous banks of memory lets avoid relocating
Xen into such a bank. Avoids issues such as free_init_memory releasing pages
which are outside of the frametable.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen/arm: Reserve FDT via early module mechanism
Ian Campbell [Thu, 26 Sep 2013 11:35:36 +0000 (12:35 +0100)]
xen/arm: Reserve FDT via early module mechanism

This will stop us putting any heaps or relocating Xen itself over the FDT.

The devicetree will be copied to allocated memory in setup_mm and the
original copy will be freed by discard_initial_modules.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen/arm: DOMHEAP_SECOND_PAGES is arm32 specific
Ian Campbell [Thu, 26 Sep 2013 11:35:35 +0000 (12:35 +0100)]
xen/arm: DOMHEAP_SECOND_PAGES is arm32 specific

since 5263507b1b4a "xen: arm: Use a direct mapping of RAM on arm64"

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen/arm: ensure the xenheap is 32MB aligned
Ian Campbell [Thu, 26 Sep 2013 11:35:34 +0000 (12:35 +0100)]
xen/arm: ensure the xenheap is 32MB aligned

My patch 08693f5948d8 "xen: arm: reduce the size of the xen heap to max 1/8
RAM size" unintentionally violated the constraint that the xenheap must be
32MB aligned, since we only explicitly align the end of the heap and
xenheap_pages was not a multiple of 32 pages.

Round xenheap pages up to a 32MB boundary.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen/arm: Don't dump stack when the VCPU is offline
Julien Grall [Wed, 25 Sep 2013 12:12:47 +0000 (13:12 +0100)]
xen/arm: Don't dump stack when the VCPU is offline

When a VCPU is not yet online, the registers contain garbagge. This will
result to call randomly BUG() in show_guest_stack.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen: arm: use new 64-bit zImage magic numbers for Xen binary
Ian Campbell [Wed, 25 Sep 2013 11:21:51 +0000 (12:21 +0100)]
xen: arm: use new 64-bit zImage magic numbers for Xen binary

Upstream commit 4370eec05a88 "arm64: Expand arm64 image header" ended up
changing the zImage magic (which was actually the initial branch instructio
encoding!). The new header has a proper magic number at a fixed location.

Switch Xen itself to using this format. Neither the bootwrapper nor the
models care about this header themselves and real bootloaders are not widely
used, so now is as good a time as any to switch (as upstream have proven)

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agoxen: arm: handle new 64-bit zImage magic numbers
Ian Campbell [Wed, 25 Sep 2013 11:21:35 +0000 (12:21 +0100)]
xen: arm: handle new 64-bit zImage magic numbers

Upstream commit 4370eec05a88 "arm64: Expand arm64 image header" ended up
changing the zImage magic (which was actually the initial branch instruction
encoding!). The new header has a proper magic number at a fixed location. Support that as well as the original magic.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agodocs: fix syntax error in xl.cfg.pod
Olaf Hering [Wed, 25 Sep 2013 21:10:09 +0000 (23:10 +0200)]
docs: fix syntax error in xl.cfg.pod

man/xl.cfg.pod.5 around line 1193: '=item' outside of any '=over'
POD document had syntax errors at /usr/bin/pod2man line 71.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: Use the hardware ID to boot correctly secondary cpus
Julien Grall [Thu, 26 Sep 2013 11:09:41 +0000 (12:09 +0100)]
xen/arm: Use the hardware ID to boot correctly secondary cpus

Secondary CPUs will spin in head.S until their MPIDR[23:0] correspond to
the smp_up_cpu. Actually Xen will set the value with the logical CPU ID
which is wrong. Use the cpu_logical_map to get the correct CPU ID.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: Dissociate logical and hardware CPU ID
Julien Grall [Thu, 26 Sep 2013 11:09:40 +0000 (12:09 +0100)]
xen/arm: Dissociate logical and hardware CPU ID

Introduce cpu_logical_map to associate a logical CPU ID to an hardware CPU ID.
This map will be filled during Xen boot via the device tree. Each CPU node
contains a "reg" property which contains the hardware ID (ie MPIDR[0:23]).

Also move /cpus parsing later so we can use the dt_* API.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: Fix assert in send_SGI_one
Julien Grall [Thu, 26 Sep 2013 11:09:39 +0000 (12:09 +0100)]
xen/arm: Fix assert in send_SGI_one

The GIC can handle maximum 8 cpus (0...7). The CPU id 7 is still valid.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: gic: Use the correct CPU ID
Julien Grall [Thu, 26 Sep 2013 11:09:38 +0000 (12:09 +0100)]
xen/arm: gic: Use the correct CPU ID

The GIC mapping of CPU interfaces does not necessarily match the logical
CPU numbering.

When Xen wants to send an SGI to specific CPU, it needs to use the GIC CPU
ID.  It can be retrieved from ITARGETSR0, in fact when this field is read,
the GIC will return a value that corresponds only to the processor reading
the register.  So Xen can use the PPI 0 to initialize the mapping.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: Initialize correctly IRQ routing
Julien Grall [Thu, 26 Sep 2013 11:09:37 +0000 (12:09 +0100)]
xen/arm: Initialize correctly IRQ routing

When Xen initialize the GIC distributor, we need to route all the IRQs to
the boot CPU. The CPU ID can differ between Xen and the GIC.

When ITARGETSR0 is read, each field will return a value that corresponds
only to the processor reading the register. So Xen can use the PPI 0 to
initialize correctly the routing.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: use cpumask_t to describe cpu mask in gic_route_dt_irq
Julien Grall [Thu, 26 Sep 2013 11:09:36 +0000 (12:09 +0100)]
xen/arm: use cpumask_t to describe cpu mask in gic_route_dt_irq

Replace by cpumask_t to take advantage of cpumask_* helpers.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxen/arm: Introduce init_info structure
Julien Grall [Thu, 26 Sep 2013 11:09:35 +0000 (12:09 +0100)]
xen/arm: Introduce init_info structure

This structure will gather all information to boot a secondary cpus.
For now it just contains the initial stack.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agox86: fix compat guest handling of XENPF_enter_acpi_sleep
Jan Beulich [Thu, 26 Sep 2013 08:23:39 +0000 (10:23 +0200)]
x86: fix compat guest handling of XENPF_enter_acpi_sleep

Rather than blindly defining the native name to the compat one, when
we want to pass the compat structure to a native function we ought to
verify that their layouts match. With a respective xlat.lst entry
there's then also no need anymore to do such aliasing.

While cleaaning up that file I also noticed that the Cx and Px
interface handling here has quite a few unnecessary #define-s - delete
them.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
11 years agofix DOMID_IO mapping permission checks (try 2)
Daniel De Graaf [Thu, 26 Sep 2013 08:15:47 +0000 (10:15 +0200)]
fix DOMID_IO mapping permission checks (try 2)

When the permission checks for memory mapping were moved from
get_pg_owner to xsm_mmu_update in aaba7a677, the exception for DOMID_IO
was not taken into account. This will cause IO memory mappings by PV
domains (mini-os in particular) to fail when XSM/FLASK is not being
used. This patch reintroduces the exception for DOMID_IO; the actual
restrictions on IO memory mappings have always been checked separately
using iomem_access_permitted, so this change should not break existing
access control.

Reported-by: Eduardo Peixoto Macedo <epm@cin.ufpe.br>
Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
11 years agox86/crash: Indicate how well nmi_shootdown_cpus() managed to do
Andrew Cooper [Thu, 26 Sep 2013 08:14:51 +0000 (10:14 +0200)]
x86/crash: Indicate how well nmi_shootdown_cpus() managed to do

Having nmi_shootdown_cpus() report which pcpus failed to be shot down is a
useful debugging hint as to what possibly went wrong (especially when the
crash logs seem to indicate that an NMI timeout occurred while waiting for one
of the problematic pcpus to perform an action).

This is achieved by swapping an atomic_t count of unreported pcpus with a
cpumask.  In the case that the 1 second timeout occurs, use the cpumask to
identify the problematic pcpus.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agox86: fix rdrand asm()
Jan Beulich [Thu, 26 Sep 2013 08:11:00 +0000 (10:11 +0200)]
x86: fix rdrand asm()

Just learned the hard way that at least for non-volatile asm()s gcc
indeed does what the documentation says: It may move it across jumps
(i.e. ahead of the cpu_has() check). While the documentation claims
that this can also happen for volatile asm()s, if that was the case
we'd have many more problems in our code (and e,g, Linux would too).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agoRevert "fix DOMID_IO mapping permission checks"
Jan Beulich [Wed, 25 Sep 2013 16:13:06 +0000 (18:13 +0200)]
Revert "fix DOMID_IO mapping permission checks"

This reverts commit 145ae98bfab8280744ad5e800cc036e1c84c0486.

11 years agoxm-test: add a missing %s
Zhu Yanhai [Mon, 23 Sep 2013 10:02:33 +0000 (18:02 +0800)]
xm-test: add a missing %s

Obviously we need a %s here.

Signed-off-by: Zhu Yanhai <gaoyang.zyh@taobao.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenstore: check socket path length before copying it
Matthew Daley [Wed, 18 Sep 2013 03:37:56 +0000 (15:37 +1200)]
xenstore: check socket path length before copying it

Coverity-ID: 1055997
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenstored: fix faulty check for bad handle in domain_init
Matthew Daley [Wed, 18 Sep 2013 03:37:55 +0000 (15:37 +1200)]
xenstored: fix faulty check for bad handle in domain_init

Coverity-ID: 1054975
Coverity-ID: 1055196
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agoxenstored: handle unlikely failure better in ask_parents
Matthew Daley [Wed, 18 Sep 2013 03:37:54 +0000 (15:37 +1200)]
xenstored: handle unlikely failure better in ask_parents

Coverity-ID: 1055277
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: fix file open failure check in libxl__file_reference_map
Matthew Daley [Wed, 18 Sep 2013 03:37:52 +0000 (15:37 +1200)]
libxl: fix file open failure check in libxl__file_reference_map

Coverity-ID: 1055567
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: fix typo in libxl__hotplug_nic error checking
Matthew Daley [Wed, 18 Sep 2013 03:37:51 +0000 (15:37 +1200)]
libxl: fix typo in libxl__hotplug_nic error checking

Coverity-ID: 1055945
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: only free console reader if it was allocated in main_dmesg
Matthew Daley [Wed, 18 Sep 2013 03:37:50 +0000 (15:37 +1200)]
libxl: only free console reader if it was allocated in main_dmesg

Coverity-ID: 1055304
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: fix out-of-memory check in parse_global_config
Matthew Daley [Wed, 18 Sep 2013 03:37:45 +0000 (15:37 +1200)]
libxl: fix out-of-memory check in parse_global_config

Coverity-ID: 1055174
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: fix leak of rune in main_remus
Matthew Daley [Wed, 18 Sep 2013 03:37:44 +0000 (15:37 +1200)]
libxl: fix leak of rune in main_remus

Coverity-ID: 1087194
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: fix leak of config_data in main_cpupoolcreate
Matthew Daley [Wed, 18 Sep 2013 03:37:43 +0000 (15:37 +1200)]
libxl: fix leak of config_data in main_cpupoolcreate

Coverity-ID: 1087193
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: fix leak of corename in handle_domain_death
Matthew Daley [Wed, 18 Sep 2013 03:37:42 +0000 (15:37 +1200)]
libxl: fix leak of corename in handle_domain_death

Coverity-ID: 1087192
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: fix dispose without init of disk in cd_insert
Matthew Daley [Wed, 18 Sep 2013 03:37:41 +0000 (15:37 +1200)]
libxl: fix dispose without init of disk in cd_insert

Coverity-ID: 1056078
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxl: fix libxl_string_list_length and its only caller
Matthew Daley [Wed, 18 Sep 2013 03:37:40 +0000 (15:37 +1200)]
libxl: fix libxl_string_list_length and its only caller

The wrong amount of indirections were being taken in
libxl_string_list_length, and its only caller was miscounting the amount
of initial non-list arguments, seemingly since the initial commit
(599c784).

This has been seen and reported in the wild (##xen):
< Trixboxer> Hi, any idea why would I get
< Trixboxer> xl: libxl_bootloader.c:42: bootloader_arg: Assertion `bl->nargs < bl->argsspace' failed.
< Trixboxer> 4.2.2-23.el6

Coverity-ID: 1054954
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agolibxc: fix memory leak in load_p2m_frame_list error handling
Matthew Daley [Wed, 18 Sep 2013 03:37:38 +0000 (15:37 +1200)]
libxc: fix memory leak in load_p2m_frame_list error handling

Coverity-ID: 1055885
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agofix DOMID_IO mapping permission checks
Daniel De Graaf [Wed, 25 Sep 2013 08:48:20 +0000 (10:48 +0200)]
fix DOMID_IO mapping permission checks

When the permission checks for memory mapping were moved from
get_pg_owner to xsm_mmu_update in aaba7a677, the exception for DOMID_IO
was not taken into account. This will cause IO memory mappings by PV
domains (mini-os in particular) to fail when XSM/FLASK is not being
used. This patch reintroduces the exception for DOMID_IO; the actual
restrictions on IO memory mappings have always been checked separately
using iomem_access_permitted, so this change should not break existing
access control.

Reported-by: Eduardo Peixoto Macedo <epm@cin.ufpe.br>
Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
11 years agox86/hap: Remove bogus assertion in hap_free_p2m_page()
Andrew Cooper [Wed, 25 Sep 2013 08:45:53 +0000 (10:45 +0200)]
x86/hap: Remove bogus assertion in hap_free_p2m_page()

Coverity ID: 1055622

Coverity correctly points out that this ASSERT() is unconditionally true as an
unsigned integer is always >= 0.

Judging from the shadow counterpart and p2m callsites, there is nothing
invalid about freeing the final p2m page.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
11 years agons16550: Use correct #define symbol for HAS_IOPORTS
Andrew Cooper [Wed, 25 Sep 2013 08:44:21 +0000 (10:44 +0200)]
ns16550: Use correct #define symbol for HAS_IOPORTS

CID 1091471, Regression caused by 7c1de0038895cbc75ebd0caffc5b0f3f03c5ad51

This appears to be a typo which causes check_existence() to unconditionally
return 1 in all cases.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agox86/xsave: initialize extended register state when guests enable it
Jan Beulich [Wed, 25 Sep 2013 08:41:25 +0000 (10:41 +0200)]
x86/xsave: initialize extended register state when guests enable it

Till now, when setting previously unset bits in XCR0 we wouldn't touch
the active register state, thus leaving in the newly enabled registers
whatever a prior user of it left there, i.e. potentially leaking
information between guests.

This is CVE-2013-1442 / XSA-62.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
11 years agoVMX: drop memory clobbers from vmread/vmwrite wrappers
Jan Beulich [Mon, 23 Sep 2013 15:37:50 +0000 (17:37 +0200)]
VMX: drop memory clobbers from vmread/vmwrite wrappers

All effects are properly being described by the asm() constraints.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jun Nakajima <jun.nakajima@intel.com>
11 years agoVMX: also use proper instruction mnemonic for VMREAD
Jan Beulich [Mon, 23 Sep 2013 15:37:00 +0000 (17:37 +0200)]
VMX: also use proper instruction mnemonic for VMREAD

... when assembler supports it, following commit cfd54835 ("VMX: use
proper instruction mnemonics if assembler supports them"). This merely
got split off from the earlier change becase of the significant number
of call sites needing to be changed.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jun Nakajima <jun.nakajima@intel.com>
11 years agox86/HVM: refuse doing string operations in certain situations
Jan Beulich [Mon, 23 Sep 2013 07:55:14 +0000 (09:55 +0200)]
x86/HVM: refuse doing string operations in certain situations

We shouldn't do any acceleration for
- "rep movs" when either side is passed through MMIO or when both sides
  are handled by qemu
- "rep ins" and "rep outs" when the memory operand is any kind of MMIO

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agox86/HVM: linear address must be canonical for the whole accessed range
Jan Beulich [Mon, 23 Sep 2013 07:53:55 +0000 (09:53 +0200)]
x86/HVM: linear address must be canonical for the whole accessed range

... rather than just for the first byte.

While at it, also
- make the real mode case at least dpo a wrap around check
- drop the mis-named "gpf" label (we're not generating faults here)
  and use in-place returns instead

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agox86_emulate: fix wrap around handling for repeated string instructions
Jan Beulich [Mon, 23 Sep 2013 07:52:29 +0000 (09:52 +0200)]
x86_emulate: fix wrap around handling for repeated string instructions

For one, repeat count clipping for MOVS must be done taking into
consideration both source and destination addresses.

And then we should allow a wrap on the final iteration only if either
the wrap is a precise one (i.e. the access itself doesn't wrap, just
the resulting index register value would) or if there is just one
iteration. In all other cases we should do a bulk operation first
without hitting the wrap, and then issue an individual iteration. If
we don't do it that way,
- the last iteration not completing successfully will cause the whole
  operation to fail (i.e. registers not get updated to the failure
  point)
- hvmemul_virtual_to_linear() may needlessly enforce non-repeated
  operation

Additionally with the prior implementation there was a case
(df=1, ea=~0, reps=~0, bytes_per_rep=1) where we'd end up passing zero
reps back to the caller, yet various places assume that there's at
least on iteration.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
11 years agogdbsx: clear sockaddr before using it
Matthew Daley [Wed, 18 Sep 2013 03:38:04 +0000 (15:38 +1200)]
gdbsx: clear sockaddr before using it

...so that sin_zero is actually zero.

Coverity-ID: 1056070
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
11 years agomini-os: fix various memory leaks in various locations
Matthew Daley [Wed, 18 Sep 2013 03:38:03 +0000 (15:38 +1200)]
mini-os: fix various memory leaks in various locations

Coverity-ID: 1055827
Coverity-ID: 1055828
Coverity-ID: 1055829
Coverity-ID: 1055830
Coverity-ID: 1055831
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
11 years agomini-os: fix various memory leaks in consfront
Matthew Daley [Wed, 18 Sep 2013 03:38:02 +0000 (15:38 +1200)]
mini-os: fix various memory leaks in consfront

Coverity-ID: 1055816
Coverity-ID: 1055817
Coverity-ID: 1055818
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
11 years agomini-os: fix various memory leaks in pcifront
Matthew Daley [Wed, 18 Sep 2013 03:38:01 +0000 (15:38 +1200)]
mini-os: fix various memory leaks in pcifront

Coverity-ID: 1055834-1055840
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
11 years agomini-os: fix various memory leaks in netfront
Matthew Daley [Wed, 18 Sep 2013 03:38:00 +0000 (15:38 +1200)]
mini-os: fix various memory leaks in netfront

Coverity-ID: 1055832
Coverity-ID: 1055833
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
11 years agomini-os: fix various memory leaks in {fb, kbd}front
Matthew Daley [Wed, 18 Sep 2013 03:37:59 +0000 (15:37 +1200)]
mini-os: fix various memory leaks in {fb, kbd}front

Coverity-ID: 1055819-1055826
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
11 years agomini-os: fix various memory leaks in blkfront
Matthew Daley [Wed, 18 Sep 2013 03:37:58 +0000 (15:37 +1200)]
mini-os: fix various memory leaks in blkfront

Coverity-ID: 1055814
Coverity-ID: 1055815
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
11 years agomini-os: fix nodename generation in init_netfront
Matthew Daley [Wed, 18 Sep 2013 03:37:57 +0000 (15:37 +1200)]
mini-os: fix nodename generation in init_netfront

Using strlen here makes no sense.

Coverity-ID: 1056053
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
11 years agoxen/arm: Support Cortex-A7 GIC
Ian Campbell [Fri, 20 Sep 2013 16:18:36 +0000 (17:18 +0100)]
xen/arm: Support Cortex-A7 GIC

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>