]> xenbits.xensource.com Git - xen.git/log
xen.git
10 years agoxen: arm: enable sync console in machine_reboot.
Ian Campbell [Thu, 15 Jan 2015 11:22:27 +0000 (11:22 +0000)]
xen: arm: enable sync console in machine_reboot.

Otherwise the last thing printed is "(XE" or something.

In line with x86 also disable the watchdog and spin debugging.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
10 years agolibxl: Prevent qemu closing QMP socket on shutdown before libxl is done with it.
Sander Eikelenboom [Thu, 22 Jan 2015 17:21:40 +0000 (18:21 +0100)]
libxl: Prevent qemu closing QMP socket on shutdown before libxl is done with it.

At present on shutdown when using pci-passthrough with qemu-xen, qemu
closes the QMP socket before libxl is done with it causing these
errors to be logged by libxl:

    Waiting for domain test (domid 1) to die [pid 11568]
    Domain 1 has shut down, reason code 0 0x0
    Action for shutdown reason code 0 is destroy
    Domain 1 needs to be cleaned up: destroying the domain
    libxl: error: libxl_qmp.c:443:qmp_next: Socket read error: Connection reset by peer
    libxl: error: libxl_qmp.c:701:libxl__qmp_initialize: Failed to connect to QMP
    libxl: error: libxl_qmp.c:686:libxl__qmp_initialize: Connection error: Connection refused
    libxl: error: libxl_dm.c:1588:kill_device_model: Device Model already exited
    Done. Exiting now

Prevent this by using the qemu '-no-shutdown' parameter which is
described as doing:

    "Don’t exit QEMU on guest shutdown, but instead only stop the emulation.
     This allows for instance switching to monitor to commit changes to the disk image."

So Qemu will stop emulating, but keeps the QMP socket open and waits
for libxl to kill the qemu process when it is done, preventing the
race and resulting in this to be logged by libxl:

    Waiting for domain test (domid 1) to die [pid 10859]
    Domain 1 has shut down, reason code 0 0x0
    Action for shutdown reason code 0 is destroy
    Domain 1 needs to be cleaned up: destroying the domain
    Done. Exiting now

Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
10 years agolibxl: Spice streaming video setting support for upstream qemu
Fabio Fantoni [Tue, 20 Jan 2015 10:33:17 +0000 (11:33 +0100)]
libxl: Spice streaming video setting support for upstream qemu

Usage:
spice_streaming_video=[filter|all|off]

Specifies what streaming video setting is to be used by spice (if
given),
otherwise the qemu default will be used.

Signed-off-by: Fabio Fantoni <fabio.fantoni@m2r.biz>
Acked-by: Wei Liu <wei.liu2@citrix.com>
10 years agolibxl: Spice image compression setting support for upstream qemu
Fabio Fantoni [Tue, 20 Jan 2015 10:26:30 +0000 (11:26 +0100)]
libxl: Spice image compression setting support for upstream qemu

Usage:
spice_image_compression=[auto_glz|auto_lz|quic|glz|lz|off]

Specifies what image compression is to be used by spice (if given),
otherwise the qemu default will be used.

Signed-off-by: Fabio Fantoni <fabio.fantoni@m2r.biz>
Acked-by: Wei Liu <wei.liu2@citrix.com>
10 years agotools/Makefile: fix qemu-xen-traditional build
Wei Liu [Sun, 25 Jan 2015 15:38:59 +0000 (15:38 +0000)]
tools/Makefile: fix qemu-xen-traditional build

In d9740237a ("tools: unhook blktap1 from the build and remove all
references to it"), one spot was left unchanged, which leads to failure
in building qemu-xen-traditional.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agotools: generate systemd service files only when systemd is available
Wei Liu [Tue, 20 Jan 2015 11:47:46 +0000 (11:47 +0000)]
tools: generate systemd service files only when systemd is available

Though that's not in any way harmful but it is on the other hand not
very useful.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
[ ijc -- rerun autogen.sh ]
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agotools: fix "make distclean"
Wei Liu [Tue, 20 Jan 2015 13:31:12 +0000 (13:31 +0000)]
tools: fix "make distclean"

The original rule to target "distclean" in tools/Rules.mk was in effect
"make clean". It should be "make distclean".

However not all Makefiles in subdirectories have distclean target
defined. So this patch also adds a bunch of distclean targets to various
Makefiles. They only depend on clean target and don't have any actions
in most cases.

With the patch applied, following command outputs 0 results:

  find tools -name 'Makefile*' -exec grep -L 'distclean' {} \+ \
     | grep -v ocaml | grep -v libfsimage

Ocaml and libfsimage are known to have distclean defined in a dedicated
rules file.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agolibxl: provide xlutil.pc
Wei Liu [Tue, 20 Jan 2015 12:22:50 +0000 (12:22 +0000)]
libxl: provide xlutil.pc

Please rerun autogen.sh after applying this patch.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agolibxl: delete xenlight.pc.in in distclean
Wei Liu [Tue, 20 Jan 2015 12:22:49 +0000 (12:22 +0000)]
libxl: delete xenlight.pc.in in distclean

That file is generated by configure. Deleting it in "make clean" leads
to rerun configure. Move it under distclean target.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agolibxc: introduce a per architecture scratch pfn for temporary grant mapping
Julien Grall [Wed, 21 Jan 2015 13:25:44 +0000 (13:25 +0000)]
libxc: introduce a per architecture scratch pfn for temporary grant mapping

The code to initialize the grant table in libxc uses
xc_domain_maximum_gpfn() + 1 to get a guest pfn for mapping the grant
frame and to initialize it.

This solution has two major issues:
    - The check of the return of xc_domain_maximum_gpfn is buggy because
    xen_pfn_t is unsigned and in case of an error -ERRNO is returned.
    Which is never catch with ( pfn <= 0 ).
    - The guest memory layout maybe filled up to the end, i.e
    xc_domain_maximum_gpfn() + 1 gives either 0 or an invalid PFN due to
    hardware limitation.

Futhermore, on ARM, xc_domain_maximum_gpfn() is not implemented and
return -ENOSYS. This will make libxc to use always the same PFN which
may colapse with an already mapped region (see xen/include/public/arch-arm.h
for the layout).

This patch only address the problem for ARM, the x86 version use the same
behavior (ie xc_domain_maximum_gpfn() + 1), as I'm not familiar with Xen x86.

A new function xc_core_arch_get_scratch_gpfn is introduced to be able to
choose the gpfn per architecture.

For the ARM version, we use the GUEST_GNTTAB_GUEST which is the base of
the region by the guest to map the grant table. At the build time,
nothing is mapped there.

At the same time correctly check the return of xc_domain_maximum_gpfn
for x86.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Roger Pau Monné <roger.pau@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agox86: vcpu_destroy_pagetables() must not return -EINTR
Konrad Rzeszutek Wilk [Mon, 26 Jan 2015 11:51:09 +0000 (12:51 +0100)]
x86: vcpu_destroy_pagetables() must not return -EINTR

.. otherwise it has the side effect that: domain_relinquish_resources
will stop and will return to user-space with -EINTR which it is not
equipped to deal with that error code; or vcpu_reset - which will
ignore it and convert the error to -ENOMEM..

The preemption mechanism we have for domain destruction is to return
-EAGAIN (and then user-space calls the hypercall again) and as such we need
to catch the case of:

domain_relinquish_resources
  ->vcpu_destroy_pagetables
    -> put_page_and_type_preemptible
       -> __put_page_type
           returns -EINTR

and convert it to the proper type. For:

XEN_DOMCTL_setvcpucontext
 -> vcpu_reset
   -> vcpu_destroy_pagetables

we need to return -ERESTART otherwise we end up returning -ENOMEM.

There are also other callers of vcpu_destroy_pagetables: arch_vcpu_reset
(vcpu_reset) are:
 - hvm_s3_suspend (asserts on any return code),
 - vlapic_init_sipi_one (asserts on any return code),

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
10 years agox86: use tzcnt instead of bsf
Jan Beulich [Mon, 26 Jan 2015 11:50:21 +0000 (12:50 +0100)]
x86: use tzcnt instead of bsf

Following a compiler change done in 2012, make use of the fact that for
non-zero input BSF and TZCNT produce the same numeric result (EFLAGS
setting differs), and that CPUs not knowing of TZCNT will treat the
instruction as BSF (i.e. ignore what looks like a REP prefix to them).
The assumption here is that TZCNT would never have worse performance
than BSF.

Also extend the asm() input in find_first_set_bit() to allow memory
operands.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86/HVM: improve EFER validation error messages
Andrew Cooper [Mon, 26 Jan 2015 11:48:38 +0000 (12:48 +0100)]
x86/HVM: improve EFER validation error messages

The previous error message was very little use in identifying the actual
problem after the fact.  Now, hvm_efer_valid() will indicate the issue which
it objects to, which is far more useful for diagnosing issues from logs.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agoRevert "x86/VPMU: handle APIC_LVTPC accesses"
Jan Beulich [Mon, 26 Jan 2015 11:47:30 +0000 (12:47 +0100)]
Revert "x86/VPMU: handle APIC_LVTPC accesses"

This reverts commit 8097616fbdda2d214b305dc41f2468f9fb88d500, most
likely reponsible for regressions found by osstest.

10 years agointel/VPMU: MSR_CORE_PERF_GLOBAL_CTRL should be initialized to zero
Boris Ostrovsky [Fri, 23 Jan 2015 16:54:23 +0000 (17:54 +0100)]
intel/VPMU: MSR_CORE_PERF_GLOBAL_CTRL should be initialized to zero

MSR_CORE_PERF_GLOBAL_CTRL register should be set zero initially. It is up to
the guest to set it so that counters are enabled.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
Tested-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
10 years agox86/VPMU: handle APIC_LVTPC accesses
Boris Ostrovsky [Fri, 23 Jan 2015 16:53:49 +0000 (17:53 +0100)]
x86/VPMU: handle APIC_LVTPC accesses

Don't have the hypervisor update APIC_LVTPC when _it_ thinks the vector should
be updated. Instead, handle guest's APIC_LVTPC accesses and write what the guest
explicitly wanted.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
Tested-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
10 years agovmx: merge MSR management routines
Boris Ostrovsky [Fri, 23 Jan 2015 16:53:01 +0000 (17:53 +0100)]
vmx: merge MSR management routines

vmx_add_host_load_msr() and vmx_add_guest_msr() share fair amount of code. Merge
them to simplify code maintenance.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
Tested-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
10 years agox86/VPMU: clean up Intel VPMU code
Boris Ostrovsky [Fri, 23 Jan 2015 16:52:23 +0000 (17:52 +0100)]
x86/VPMU: clean up Intel VPMU code

Remove struct pmumsr and core2_pmu_enable. Replace static MSR structures with
fields in core2_vpmu_context.

Call core2_get_pmc_count() once, during initialization.

Properly clean up when core2_vpmu_alloc_resource() fails.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
Tested-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
10 years agox86/VPMU: make vpmu macros a bit more efficient
Boris Ostrovsky [Fri, 23 Jan 2015 16:51:43 +0000 (17:51 +0100)]
x86/VPMU: make vpmu macros a bit more efficient

Introduce vpmu_are_all_set that allows testing multiple bits at once. Convert macros
into inlines for better compiler checking.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
Tested-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
10 years agox86/VPMU: set MSR bitmaps only for HVM/PVH guests
Boris Ostrovsky [Fri, 23 Jan 2015 16:51:15 +0000 (17:51 +0100)]
x86/VPMU: set MSR bitmaps only for HVM/PVH guests

In preparation for making VPMU code shared with PV make sure that we we update
MSR bitmaps only for HVM/PVH guests

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
Tested-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
10 years agox86/VPMU: manage VPMU_CONTEXT_SAVE flag in vpmu_save_force()
Boris Ostrovsky [Fri, 23 Jan 2015 16:50:53 +0000 (17:50 +0100)]
x86/VPMU: manage VPMU_CONTEXT_SAVE flag in vpmu_save_force()

There is a possibility that we set VPMU_CONTEXT_SAVE on VPMU context in
vpmu_load() and never clear it (because vpmu_save_force() will see
VPMU_CONTEXT_LOADED bit clear, which is possible on AMD processors)

The problem is that amd_vpmu_save() assumes that if VPMU_CONTEXT_SAVE is set
then (1) we need to save counters and (2) we don't need to "stop" control
registers since they must have been stopped earlier. The latter may cause all
sorts of problem (like counters still running in a wrong guest and hypervisor
sending to that guest unexpected PMU interrupts).

Since setting this flag is currently always done prior to calling
vpmu_save_force() let's both set and clear it there.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
Tested-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
10 years agox86/VPMU: don't globally disable VPMU if initialization fails
Boris Ostrovsky [Fri, 23 Jan 2015 16:49:50 +0000 (17:49 +0100)]
x86/VPMU: don't globally disable VPMU if initialization fails

The failure to initialize VPMU may be temporary so we shouldn'd disable VMPU
forever.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
10 years agox86: prevent access to HPET from Dom0
Roger Pau Monné [Fri, 23 Jan 2015 14:16:18 +0000 (15:16 +0100)]
x86: prevent access to HPET from Dom0

Prevent Dom0 from accessing HPET MMIO region by adding the HPET mfn to the
list of forbiden memory regions (if ACPI_HPET_PAGE_PROTECT4 or
ACPI_HPET_PAGE_PROTECT64 flag is set) or to the list of read-only regions.

Also provide an option that prevents adding the HPET to the read-only memory
regions called ro-hpet, in case there are systems that put other stuff in
the HPET page.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Don't loop over iomem_deny_access() for consecutive MFNs.

Put new command line option's doc entry in right spot.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
10 years agox86/pvh: check permissions when adding MMIO regions
Roger Pau Monné [Fri, 23 Jan 2015 14:15:30 +0000 (15:15 +0100)]
x86/pvh: check permissions when adding MMIO regions

Check that MMIO regions added to PVH Dom0 are allowed. Previously a PVH Dom0
would have access to the full MMIO range.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
10 years agox86: allow set_mmio_p2m_entry to specify access type
Roger Pau Monné [Fri, 23 Jan 2015 14:14:56 +0000 (15:14 +0100)]
x86: allow set_mmio_p2m_entry to specify access type

Preparatory change that allows setting the access type to
set_mmio_p2m_entry.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
10 years agox86/HVM: replace plain numbers
Jan Beulich [Fri, 23 Jan 2015 14:13:39 +0000 (15:13 +0100)]
x86/HVM: replace plain numbers

... making the code better document itself. No functional change
intended.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86/HVM: make hvm_efer_valid() honor guest features
Jan Beulich [Fri, 23 Jan 2015 14:13:05 +0000 (15:13 +0100)]
x86/HVM: make hvm_efer_valid() honor guest features

Following the earlier similar change validating CR4 modifications.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agohandle XENMEM_get_vnumainfo in compat_memory_op
Wei Liu [Fri, 23 Jan 2015 14:06:26 +0000 (15:06 +0100)]
handle XENMEM_get_vnumainfo in compat_memory_op

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
10 years agogrant-table: use uint16_t consistently for grant copy offset and length
David Vrabel [Fri, 23 Jan 2015 14:05:48 +0000 (15:05 +0100)]
grant-table: use uint16_t consistently for grant copy offset and length

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
10 years agoVMX: replace plain numbers
Jan Beulich [Fri, 23 Jan 2015 14:05:08 +0000 (15:05 +0100)]
VMX: replace plain numbers

... making the code better document itself. No functional change
intended.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
10 years agox86/traps: replace plain numbers
Jan Beulich [Fri, 23 Jan 2015 14:04:26 +0000 (15:04 +0100)]
x86/traps: replace plain numbers

... making the code better document itself. No functional change
intended.

Note that for now (as we don't support RTM yet) DR_STATUS_RESERVED_ONE
and its users don't take DR_NOT_RTM into consideration yet.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86/HVM: replace plain number in hvm_combine_hw_exceptions()
Jan Beulich [Fri, 23 Jan 2015 14:03:28 +0000 (15:03 +0100)]
x86/HVM: replace plain number in hvm_combine_hw_exceptions()

While doing so also take care of #VE here (even if we don't make use of
it yet). Note that contributory_exceptions, other than the original
0x7c01 constant, doesn't include #PF anymore, but the check where the
variable is used is after one that already filtered out #PF.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: TIm Deegan <tim@xen.org>
10 years agoarm64: fix fls()
Jan Beulich [Fri, 23 Jan 2015 14:02:39 +0000 (15:02 +0100)]
arm64: fix fls()

It using CLZ on a 64-bit register while specifying the input operand as
only 32 bits wide is wrong: An operand intentionally shrunk down to 32
bits at the source level doesn't imply respective zero extension also
happens at the machine instruction level, and hence the wrong result
could get returned.

Add suitable inline assembly abstraction so that the function can
remain shared between arm32 and arm64. The need to include asm_defns.h
in bitops.h makes it necessary to adjust processor.h though - it is
generally wrong to include public headers without making sure that
integer types are properly defined. (I didn't innvestigate or try
whether the possible alternative of moving the public/arch-arm.h
inclusion down in the file would also work.)

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agomake fls() and ffs() consistent across architectures
Jan Beulich [Fri, 23 Jan 2015 13:59:37 +0000 (14:59 +0100)]
make fls() and ffs() consistent across architectures

Their parameter types differed between ARM and x86.

Along with generalizing the functions this fixes
- x86's non-long functions having long parameter types
- ARM's ffs() using a long intermediate variable
- generic_fls64() being broken when the upper half of the input is
  non-zero
- common (and in one case also ARM) code using fls() when flsl() was
  meant

Also drop ARM's constant_fls() in favor of the identical generic_fls().

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agox86/vlapic: express x2apic msr readability with a bitmap
Andrew Cooper [Thu, 22 Jan 2015 11:59:14 +0000 (12:59 +0100)]
x86/vlapic: express x2apic msr readability with a bitmap

The x2apic MSR space is currently defined between 0x800 and 0x83f, which
conveniently fits in a 64 bit wide bitmap.  This is far more efficient than
the cascade comparisons generated by the switch statement, which can't be
optimised because of the case ranges used for the ISR, TMR and IRR blocks.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Convert 0xffUL to ((1UL << (NR_VECTORS / 32)) - 1) and drop a couple of
clearly superfluous parentheses.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
10 years agox86/domain: improvements to switch_native() and switch_compat()
Andrew Cooper [Thu, 22 Jan 2015 11:58:47 +0000 (12:58 +0100)]
x86/domain: improvements to switch_native() and switch_compat()

Both are called with known-good domains, making the NULL check redundant.
Both also have open-coded forms of for_each_vcpu() which are replaced.

switch_compat() is updated to propagate the error from set_compat_l4(), rather
than automatically overriding with -ENOMEM.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agoVMX: use cached "current" where available
Jan Beulich [Thu, 22 Jan 2015 11:58:06 +0000 (12:58 +0100)]
VMX: use cached "current" where available

..., yielding better code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
10 years agoVMX: drop VMCS *_HIGH enumerators
Jan Beulich [Thu, 22 Jan 2015 11:57:27 +0000 (12:57 +0100)]
VMX: drop VMCS *_HIGH enumerators

Most of them have been unused since the dropping of 32-bit support, and
the few remaining cases are more efficiently dealt with using a generic
macro (and probably things should have been done that way from the
beginning).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
10 years agoVMX: dump further control state
Jan Beulich [Thu, 22 Jan 2015 11:56:33 +0000 (12:56 +0100)]
VMX: dump further control state

A few relevant control state fields did not get dumped so far; in
particular, VM_ENTRY_INSTRUCTION_LEN got printed twice (instead of also
printing VM_EXIT_INSTRUCTION_LEN). Where suitable (to reduce the amount
of output) make some of the dumping conditional upon guest settings
(this isn't required for correctness as vmr() already uses
__vmread_safe(), i.e. it is fine to access non-existing fields).

Also drop casts.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
10 years agoVMX: dump full host state
Jan Beulich [Thu, 22 Jan 2015 11:55:56 +0000 (12:55 +0100)]
VMX: dump full host state

A few host state fields did not get dumped so far. Where suitable (to
reduce the amount of output) make some of the dumping conditional upon
guest settings (this isn't required for correctness as vmr() already
uses __vmread_safe(), i.e. it is fine to access non-existing fields).

Also drop casts - many of them haven't been needed anymore since the
dropping of 32-bit support.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
10 years agoVMX: dump full guest state
Jan Beulich [Thu, 22 Jan 2015 11:54:49 +0000 (12:54 +0100)]
VMX: dump full guest state

Several guest state fields did not get dumped so far. Where suitable
(to reduce the amount of output) make some of the dumping conditional
upon guest settings (this isn't required for correctness as vmr()
already uses __vmread_safe(), i.e. it is fine to access non-existing
fields).

Move CR3_TARGET_* and TSC_OFFSET processing into the control state
section, at once making the upper bound of CR3_TARGET_VALUEn printed
depend on CR3_TARGET_COUNT (which architecturally can be higher than
4).

Also rename GUEST_PDPTRn to GUEST_PDPTEn (matching the SDM naming) and
group them as well as CR3_TARGET_VALUEn similar to EOI_EXIT_BITMAP.

Finally, drop casts - they haven't been needed anymore since the
dropping of 32-bit support (and some of them were not really needed in
the first place). Introduce vmr16() and vmr32() helper macros to avoid
the "l" printk format modifier and at the same time validate that only
16-/32-bit fields get accessed this way.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
10 years agox86: don't open-code cpuid_count() in pv_cpuid()
Jan Beulich [Thu, 22 Jan 2015 11:49:04 +0000 (12:49 +0100)]
x86: don't open-code cpuid_count() in pv_cpuid()

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86: correctly check for sub-leaf zero of leaf 7 in pv_cpuid()
Jan Beulich [Thu, 22 Jan 2015 11:48:40 +0000 (12:48 +0100)]
x86: correctly check for sub-leaf zero of leaf 7 in pv_cpuid()

Only the low 32 bits are relevant.

For consistency also change a cast on regs->eax to regs->_eax.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86: don't expose XSAVES capability to PV guests
Jan Beulich [Thu, 22 Jan 2015 11:47:56 +0000 (12:47 +0100)]
x86: don't expose XSAVES capability to PV guests

As done by the recent Linux commit b65d6e17fe ("kvm: x86: mask out
XSAVES") for KVM, we should also mask out XSAVES from what PV guests
get to see as long as we don't emulate accesses to MSR_IA32_XSS.

Actually, go beyond that: Just like for leaf 7, switch from
blacklisting to whitelisting, i.e. only allow XSAVEOPT and XSAVEC for
the time being. And do these overrides consistently for both Dom0 and
DomU-s.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agodrop redundant MAX_VIRT_CPUS bounds checks
Andrew Cooper [Thu, 22 Jan 2015 11:46:43 +0000 (12:46 +0100)]
drop redundant MAX_VIRT_CPUS bounds checks

In all 4 cases, visible in the context are bounds check against d->max_vcpus.
Domain building will ensure that d->max_vcpus never exceeds an appropriate
bound.  In the x86 case, different types of domains have different maxima for
vcpus, making the checks wrong as opposed to simply redundant.

For vpsci in ARM, 'vcpuid' is an unsigned type so could never be less than 0.

For the common changes to do_{,compat}_vcpu_op(), these changes do result in a
guest visible change, but only in so far as certain invalid vcpu ids will now
fail with -ENOENT rather than -EINVAL.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agosched/arinc653: remove MAX_VIRT_CPUS bounds check
Andrew Cooper [Thu, 22 Jan 2015 11:46:10 +0000 (12:46 +0100)]
sched/arinc653: remove MAX_VIRT_CPUS bounds check

The arinc653 interface is capable of specifying a domain in the schedule (from
the toolstack) before the domain itself exists, or is present in the cpupool
(The domain is identified by UUID rather than domid). As a result, the
schedule can't be validated at this point.

The vcpu_id from userspace is only ever used to compare against a list of real
vcpus available to the scheduler, which prevents ill-specified vcpus from
actually being scheduled.

Remove the MAX_VIRT_CPUS test, as it is not an appropriate bound for vcpu_id.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by Robert VanVossen <robert.vanvossen@dornerworks.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
10 years agoevtchn: reduce the size of the poll_mask where possible
Andrew Cooper [Thu, 22 Jan 2015 11:45:13 +0000 (12:45 +0100)]
evtchn: reduce the size of the poll_mask where possible

Use domain_max_vcpus(d) in preference to MAX_VIRT_CPUS when allocating the
poll mask.  This allows x86 HVM guests to have a poll mask of 128 bits rather
than 8k bits.

While changing this, use xzalloc_array() in preference to xmalloc_array() to
avoid needing the subsequent call to bitmap_zero().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
10 years agointroduce domain_max_vcpus() helper and implement per arch
Andrew Cooper [Thu, 22 Jan 2015 11:44:03 +0000 (12:44 +0100)]
introduce domain_max_vcpus() helper and implement per arch

This allows the common XEN_DOMCTL_max_vcpus handler to lose some x86-specific
architecture knowledge.

It turns out that Xen had the same magic number twice in-tree with different
names (HVM_MAX_VCPUS and MAX_HVM_VCPUS).  This removes all use of
MAX_HVM_VCPUS, and x86 uses HVM_MAX_VCPUS from the public headers.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
10 years agomake error codes a formal part of the ABI
Jan Beulich [Thu, 22 Jan 2015 11:41:50 +0000 (12:41 +0100)]
make error codes a formal part of the ABI

Now that we have two cases where patches against hvmloader got
submitted needing to include the hypervisor's errno.h (for the host's
system header not necessarily reflecting the correct numbers), take
this as a strong sign that we need to make the error return values part
of the hypervisor ABI (which de-fact they've always been).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agore-order struct domain fields
Jan Beulich [Tue, 20 Jan 2015 09:47:21 +0000 (10:47 +0100)]
re-order struct domain fields

... to reduce padding holes.

I also wonder whether having independent spin locks side by side is
really a good thing cache-line-bouncing-wise.

Also change suspend_evtchn's type to evtchn_port_t.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
10 years agox86: latch current->domain in do_physdev_op()
Jan Beulich [Tue, 20 Jan 2015 09:46:19 +0000 (10:46 +0100)]
x86: latch current->domain in do_physdev_op()

... and drop global latching of current, as being needed more than once
only in PHYSDEVOP_set_iopl and PHYSDEVOP_set_iobitmap, and not at all
in all other cases.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86: slightly simplify PHYSDEVOP_pirq_eoi_gmfn_v* handling
Jan Beulich [Tue, 20 Jan 2015 09:45:01 +0000 (10:45 +0100)]
x86: slightly simplify PHYSDEVOP_pirq_eoi_gmfn_v* handling

We don't really need the MFN in more than one place (after dropping
mfn_to_page() translations where we know the result already), so no
need to have a local variable for it.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agophysdev: hide compatibility definitions for new enough interface version
Jan Beulich [Tue, 20 Jan 2015 09:43:52 +0000 (10:43 +0100)]
physdev: hide compatibility definitions for new enough interface version

There's no point in continuing to expose those.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxsm/evtchn: never pretend to have successfully created a Xen event channel
Andrew Cooper [Tue, 20 Jan 2015 09:42:26 +0000 (10:42 +0100)]
xsm/evtchn: never pretend to have successfully created a Xen event channel

Xen event channels are not internal resources.  They still have one end in a
domain, and are created at the request of privileged domains.  This logic
which "successfully" creates a Xen event channel opens up undesirable failure
cases with ill-specified XSM policies.

If a domain is permitted to create ioreq servers or memevent listeners, but
not to create event channels, the ioreq/memevent creation will succeed but
attempting to bind the returned event channel will fail without any indication
of a permission error.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
10 years agox86/cpuid: correct parameter types for cpuid_count()
Andrew Cooper [Tue, 20 Jan 2015 09:41:18 +0000 (10:41 +0100)]
x86/cpuid: correct parameter types for cpuid_count()

About half of the cpuid space has the top bit of op set, and op it always
specified with unsigned integers.  There are no problematic uses in tree at
the moment.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agoxfree() can tolerate NULL pointers
Andrew Cooper [Tue, 20 Jan 2015 09:40:32 +0000 (10:40 +0100)]
xfree() can tolerate NULL pointers

Replace instances of "if ( p ) xfree(p)" with just "xfree(p)"

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
10 years agolibxl: Avoid returning empty path from libxl_console_get_tty
Anthony PERARD [Thu, 15 Jan 2015 17:55:56 +0000 (17:55 +0000)]
libxl: Avoid returning empty path from libxl_console_get_tty

This could happen if xenconsoled have not populate the xenstore key yet.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agolibxl: check HVM direct boot parameters
Wei Liu [Mon, 19 Jan 2015 16:13:59 +0000 (16:13 +0000)]
libxl: check HVM direct boot parameters

We should honour -initrd and -append iff -kernel is specified, because
that's how QEMU works.

Check direct boot parameters in libxl__domain_build_info_setdefault.
Return failure if kernel is missing while ramdisk (-initrd) and / or
cmdline (-append) is present.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Chunyan Liu <cyliu@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agotools/configure: Check if pixman is present on the system when building QEMU
Julien Grall [Thu, 15 Jan 2015 21:06:18 +0000 (21:06 +0000)]
tools/configure: Check if pixman is present on the system when building QEMU

QEMU upstream requires the use of pixman. When pixman is not present the
system, the configure of QEMU will fail with:

ERROR: pixman not present. Your options:
         (1) Preferred: Install the pixman devel package (any recent
             distro should have packages as Xorg needs pixman too).
         (2) Fetch the pixman submodule, using:
             git submodule update --init pixman

I think we can use by default the version on the system. So check it
a Xen configuration time to avoid a build issue later.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
[ ijc -- reran autogen.sh, adjusted comment ]

10 years agotools/configure: Check if Glib is present only when building QEMU
Julien Grall [Thu, 15 Jan 2015 21:06:17 +0000 (21:06 +0000)]
tools/configure: Check if Glib is present only when building QEMU

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
[ ijc -- reran autogen.sh ]

10 years agoxen/arm: vgic: Rename nr_lines into nr_spis
Julien Grall [Thu, 15 Jan 2015 20:23:40 +0000 (20:23 +0000)]
xen/arm: vgic: Rename nr_lines into nr_spis

The field nr_lines in the arch_domain vgic structure contains the number of
SPIs for the emulated GIC. Using the nr_lines make confusion with the GIC
code, where it means the number of IRQs. This can lead to coding error.

Also introduce vgic_num_irqs to get the number of IRQ handled by the emulated
GIC.

Finally drop the initialization of nr_spis in both gicv2v_init and gicv3_init
as it's already initialized in vgic common code.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agolibxl: provide xenlight.pc
Wei Liu [Fri, 9 Jan 2015 14:32:18 +0000 (14:32 +0000)]
libxl: provide xenlight.pc

A pkg-config file for libxl. It also contains two variables
(xenfirmwaredir and libexec_bin) so that tools that are very keen on
knowing the locations of Xen binaries (say, libvirt) can use them to
determine the location of the binaries.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- ran autogen.sh ]

10 years agoInstall libxlutil.h
Jim Fehlig [Thu, 8 Jan 2015 21:43:28 +0000 (14:43 -0700)]
Install libxlutil.h

libxlutil.{a,so} are installed, but not the corresponding header
file.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Dario Faggioli <dario.faggioli@citrix.com>
10 years agocorrect hypervisor version
Jan Beulich [Mon, 19 Jan 2015 15:08:41 +0000 (16:08 +0100)]
correct hypervisor version

-unstable doesn't use the .0 part added by commit 0082626f35.

10 years agohypercall: update vcpu_op to take an unsigned vcpuid
Andrew Cooper [Mon, 19 Jan 2015 11:19:11 +0000 (12:19 +0100)]
hypercall: update vcpu_op to take an unsigned vcpuid

This has no guest-visible change, but makes the Hypervisor side bounds
checking more simple.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
10 years agox86/hvm: add per-vcpu evtchn upcalls
Paul Durrant [Mon, 19 Jan 2015 11:18:03 +0000 (12:18 +0100)]
x86/hvm: add per-vcpu evtchn upcalls

HVM guests have always been confined to using the domain callback
via (see HVM_PARAM_CALLBACK_IRQ) to receive event notifications.
This is usually an IOAPIC vector and is only used if the event
channel is bound to vcpu 0.

PVHVM Linux uses a pre-defined interrupt vector for the event
channel upcall, set using HVM_PARAM_CALLBACK_IRQ by ORing in a
special bit (bit 57) into the value (see params.h). However, it
does not assert the interrupt via the emulated local APIC.

This mechanism is not suitable in the general case since Windows
(and potentially other OSes) because they:

- cannot guarantee the same vector for all VCPUs
- do require the upcall to be asserted via the local APIC

This patch adds a new HVM op allowing a guest to specify a local
APIC vector to use as an upcall notification for a specific vcpu
therefore coping with the case of differing vector numbers.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agox86/minios: remove more vestigial remnants of SUPERVISOR_MODE_KERNEL
Andrew Cooper [Mon, 19 Jan 2015 11:17:24 +0000 (12:17 +0100)]
x86/minios: remove more vestigial remnants of SUPERVISOR_MODE_KERNEL

MiniOS has never advertised support for supervisor_mode_kernel, and the
feature was only ever implemented for 32bit Xen.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
10 years agohvm/hpet: correctly gate the virtual HPET on HVM_PARAM_HPET_ENABLE
Andrew Cooper [Mon, 19 Jan 2015 11:16:44 +0000 (12:16 +0100)]
hvm/hpet: correctly gate the virtual HPET on HVM_PARAM_HPET_ENABLE

c/s 3f8e22de7 "x86 hvm: Allow HPET to be configured as a per-domain config
option" introduced the parameter to conditionally enable the HPET.

However, having the check in hpet_range() does not have the intended effect.
As currently implemented, when the HPET is disabled, the range is not claimed
and an ioreq is forwarded to qemu, which implements an HPET itself.

Properly disable the HPET by always claiming the range, dropping writes and
reading ~0.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
10 years agokexec: fix some types
Jan Beulich [Mon, 19 Jan 2015 11:01:18 +0000 (12:01 +0100)]
kexec: fix some types

crashinfo_maxaddr can/will be a 64-bit type, hence passing it to fls()
is wrong.

crashinfo_maxaddr_bits, otoh, doesn't need to be a paddr_t, and can
additionally be __initdata.

struct xen_kexec_reserve's start field - representing a physical
address - ought to have respective type.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
10 years agoevtchn: simplify sending of notifications
Jan Beulich [Mon, 19 Jan 2015 11:00:08 +0000 (12:00 +0100)]
evtchn: simplify sending of notifications

The trivial wrapper evtchn_set_pending() is pretty pointless, as it
only serves to invoke another wrapper evtchn_port_set_pending(). In
turn, the latter is kind of inconsistent with its siblings in that is
takes a struct vcpu * rather than a struct domain * - adjusting this
allows for more efficient code in the majority of cases.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
10 years agocommon/memory: fix an XSM error path
Jan Beulich [Mon, 19 Jan 2015 10:59:05 +0000 (11:59 +0100)]
common/memory: fix an XSM error path

XENMEM_{in,de}crease_reservation as well as XENMEM_populate_physmap
return the extent at which failure was detected, not error indicators.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Tim Deegan <tim@xen.org>
10 years agox86/mm: reunite nestedp2m_lock with its comment.
Tim Deegan [Thu, 15 Jan 2015 17:49:48 +0000 (17:49 +0000)]
x86/mm: reunite nestedp2m_lock with its comment.

Signed-off-by: Tim Deegan <tim@xen.org>
10 years agox86/viridian: do not leak page refs and mappings if the host tsc is unstable
Andrew Cooper [Thu, 15 Jan 2015 16:56:25 +0000 (17:56 +0100)]
x86/viridian: do not leak page refs and mappings if the host tsc is unstable

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Coverity-ID: 1264360
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
10 years agoxen/arm: Update documentation in the public header arch-arm.h
Julien Grall [Wed, 14 Jan 2015 12:53:49 +0000 (12:53 +0000)]
xen/arm: Update documentation in the public header arch-arm.h

Minor updates to the documentation in xen/include/public/arch-arm.h:
    - Comments coding style fix
    - Typoes
    - Update the list of supported hypercalls by ARM
    - Remove unnecessary comment about 64bit.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Keir Fraser <keir@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- fixed spelling of unnecessary, corrected aarch into aarch32 ]

10 years agotools: remove blktap1
Ian Campbell [Tue, 4 Nov 2014 10:41:25 +0000 (10:41 +0000)]
tools: remove blktap1

Now that it is unhooked we can just remove it.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
10 years agotools: unhook blktap1 from the build and remove all references to it
Ian Campbell [Fri, 9 Jan 2015 13:37:03 +0000 (13:37 +0000)]
tools: unhook blktap1 from the build and remove all references to it

This was disabled by default in Xen 4.4. Since xend has now been
removed from the tree I don't believe anything is using it.

We need to pass an explicit CONFIG_BLKTAP1=n to qemu-xen-traditional
otherwise it defaults to y and doesn't build.

This patch does all the ground work, the tools/blktap directory will
be removed in the next (*huge*) patch.

Note that this has no impact on blktap2, which is what libxl supports.
blktap1 was only usable via xend which has already been removed.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
10 years agoxen: arm: wait 1000ms for a CPU to come up, instead of forever
Ian Campbell [Wed, 14 Jan 2015 15:47:36 +0000 (15:47 +0000)]
xen: arm: wait 1000ms for a CPU to come up, instead of forever

Otherwise continue without it, which is preferable to the current
infinite hang.

Slightly tweak the grammar of a comment in the same function.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
10 years agoxen: arm: enable perf counters
Ian Campbell [Wed, 14 Jan 2015 16:16:50 +0000 (16:16 +0000)]
xen: arm: enable perf counters

As well as the existing common perf counters add a bunch of ARM
specifics, including the various trap types, vuart/vgic/vtimer
accesses and different types of interrupt.

Adjust the common code so that the columns line up again, not sure
when/where this went wrong.

This is mostly the set of stuff I happened to be interested in, it can
be made more (or less) fine grained as the need arises.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
10 years agoxen/arm: Blacklist the memory mapped timer (armv7-timer-mem)
Julien Grall [Wed, 14 Jan 2015 18:00:43 +0000 (18:00 +0000)]
xen/arm: Blacklist the memory mapped timer (armv7-timer-mem)

Some platform (such as the VFP Base AEMv8 model) has a memory mapped
timer. We don't want DOM0 use this timer rather than the generic ARM
timer. So blacklist it for all platforms.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen/arm: grant-table: Increased the initial number of grant frame to 4
Julien Grall [Tue, 13 Jan 2015 18:17:21 +0000 (18:17 +0000)]
xen/arm: grant-table: Increased the initial number of grant frame to 4

When a domain is created on ARM, the grant table code initialized one
grant frame. With a basic load (i.e disk usage), Xen is quickly trying
to expand the number of frames:

(XEN) grant_table.c:1305:d2v0 Expanding dom (2) grant table from (1) to (2) frames.
(XEN) grant_table.c:1305:d2v0 Expanding dom (2) grant table from (2) to (3) frames.
(XEN) grant_table.c:311:d0v0 Increased maptrack size to 2 frames
(XEN) grant_table.c:311:d0v0 Increased maptrack size to 3 frames

The x86 code is initialied 4 frames (I didn't find the exact reason). I
think we could use the same default value.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoxen/arm: Remove the define INVALID_GFN from arch-arm/grant_table.h
Julien Grall [Tue, 13 Jan 2015 18:17:20 +0000 (18:17 +0000)]
xen/arm: Remove the define INVALID_GFN from arch-arm/grant_table.h

The define INVALID_GFN is misplaced in arch-arm/grant_table.h and is
never used in neither in ARM nor in the common code.

Therefore we can safely remove it.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoRevert "x86/HVM: make hvm_efer_valid() honor guest features"
Jan Beulich [Wed, 14 Jan 2015 10:53:28 +0000 (11:53 +0100)]
Revert "x86/HVM: make hvm_efer_valid() honor guest features"

This reverts commit 07a6aa869bae0699d2f7e1b75d188229eb70c9e4. Some HVM
guests don't survive the new checking (EFER=0x901 reported invalid).

10 years agoMini-OS: netfront: Fix rx ring starvation in network_rx
Martin Lucina [Thu, 4 Dec 2014 13:33:53 +0000 (14:33 +0100)]
Mini-OS: netfront: Fix rx ring starvation in network_rx

In network_rx() we must push the same amount of requests back onto the
ring in the second loop that we consumed in the first loop. Otherwise
the ring will eventually starve itself of free request slots and no
packets will be delivered.

Further, we make the HAVE_LIBC codepath clearer to follow by removing
the "some" variable from the for loop initialisation and conditions.

Signed-off-by: Martin Lucina <martin@lucina.net>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
10 years agotools: xl: refactor code to parse network device options
Alexandra Sandulescu [Tue, 21 Oct 2014 21:36:21 +0000 (00:36 +0300)]
tools: xl: refactor code to parse network device options

This patch removes duplicate code in /tools/libxl/xl_cmdimpl.c by
adding parse_nic_config function. This function parses configuration
data and adds the information into libxl_device_nic struct. It is
called in both main_networkattach and parse_config_data functions
to replace duplicate code.

Signed-off-by: Alexandra Sandulescu <alecsandra.sandulescu@gmail.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
10 years agotools/xl: Call init function for libxl_bitmap
Uma Sharma [Mon, 20 Oct 2014 21:45:10 +0000 (03:15 +0530)]
tools/xl: Call init function for libxl_bitmap

This patch calls init function for libxl_bitmap in
main_cpupoolnumasplit() and vcpuset()
tools/libxl/xl_cmdimpl.c
IDL generated libxl types should be used only after calling the init
function even if the variable is simply being passed by reference as
an output parameter to a libxl function

Signed-off-by: Uma Sharma <uma.sharma523@gmail.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
--

10 years agotools/xl: Call init function for libxl_domain_sched_params
Uma Sharma [Mon, 20 Oct 2014 21:42:11 +0000 (03:12 +0530)]
tools/xl: Call init function for libxl_domain_sched_params

This patch calls init function for libxl_domain_sched_params before
passing it as reference to sched_domain_get() function in
tools/libxl/xl_cmdimpl.c
IDL generated libxl types should be used only after calling the init
function even if the variable is simply being passed by reference as
an output parameter to a libxl function

Signed-off-by: Uma Sharma <uma.sharma523@gmail.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
--

10 years agolibxl: add emacs local variables in libxl_{x86, arm}.c
Wei Liu [Mon, 1 Dec 2014 15:33:28 +0000 (15:33 +0000)]
libxl: add emacs local variables in libxl_{x86, arm}.c

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Dario Faggioli <dario.faggioli@citrix.com>
Cc: Elena Ufimtseva <ufimtseva@gmail.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agotools/misc: Cleanup makefile
Andrew Cooper [Thu, 8 Jan 2015 13:34:22 +0000 (13:34 +0000)]
tools/misc: Cleanup makefile

The existing makefile was awkward with needing to express conditional
inclusion for both the build and install rules, and contained both split and
unsplit long lines.

The INSTALL_* rules now contain the conditional inclusion information, while
the TARGET_* rules generate the build list from the complete install list,
less the minority of scripts which simply need copying into place.  Comments
are introduces to aid clarity.

In addition, collect the CFLAGS expressions, remove the unreferenced and empty
HDRS list, and restrict the libxc internals build fix to the offending
binaries.

No functional change as a result of this patch, but it is rather more simple
to add or remove utilities.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
10 years agotools/Rules.mk: Don't optimize debug builds; add macro debugging information
Euan Harris [Mon, 1 Dec 2014 14:21:05 +0000 (14:21 +0000)]
tools/Rules.mk: Don't optimize debug builds; add macro debugging information

Tools debug builds are built with optimization level -O1, inherited from
the CFLAGS definition in StdGNU.mk.   Optimizations confuse the debugger,
and the comment justifying -O1 in StdGNU.mk should not apply for a
userspace library.   Disable optimization by appending -O0 to CFLAGS,
which overrides the -O1 flag specified earlier.

Also specify -g3, to add macro debugging information which allows
gdb to expand macro invocations.   This is useful as libxl uses many
non-trivial macros.

Signed-off-by: Euan Harris <euan.harris@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- inserted a clarifying "enable" into comment ]

10 years agolibxl: Don't ignore error when we fail to give access to ioport/irq/iomem
Julien Grall [Fri, 9 Jan 2015 15:56:45 +0000 (15:56 +0000)]
libxl: Don't ignore error when we fail to give access to ioport/irq/iomem

If we fail to give the access, the domain will unlikely work correctly.
So we should bail out at the first error.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
10 years agolibxl/arm: Correctly spelled FDT_ERR_* in a comment
Julien Grall [Fri, 9 Jan 2015 16:13:02 +0000 (16:13 +0000)]
libxl/arm: Correctly spelled FDT_ERR_* in a comment

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agolibxl, hotplug/Linux: default to phy backend for raw format file, take 2
Wei Liu [Thu, 8 Jan 2015 13:46:53 +0000 (13:46 +0000)]
libxl, hotplug/Linux: default to phy backend for raw format file, take 2

This patch resurrects 11a63a166. The previous patch had a bug that
wrong "physical-device" was written to xenstore causing block script
execution fail. This patch fixes that problem.

Following configurations have been tested:

1. Raw file and PV
2. Raw file and HVM
3. Block device and PV
4. Block device and HVM

Creation / destruction / local migration all worked.

Original commit message from 11a63a166:

Modify libxl and hotplug script to allow raw format file to use phy
backend.

The block script now tests the path and determine the actual type of
file (block device or regular file) then use the actual type to
determine which branch to run.

With these changes, plus the current ordering of backend preference (phy
> qdisk > tap), we will use phy backend for raw format file by default.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agodt-uart: support /chosen/stdout-path property.
Ian Campbell [Thu, 8 Jan 2015 11:53:56 +0000 (11:53 +0000)]
dt-uart: support /chosen/stdout-path property.

ePAPR v1.1 section 3.5 defines the /chosen/stdout-path property to
refer to the device to be used for boot console output, so if no
dtuart property is given try to use that instead. This will make Xen
find a suitable console by default on DT platforms which include this
property.

As it happens the dtuart option has the exact same syntax as
stdout-path, so we can just copy the value into that buffer if it is
empty. If the string is too large for the buffer we truncate and warn
but continue in the hopes that enough of the path survived (i.e. only
the options part was dropped) to get something out.

FWIW support for this was added to Linux in v3.19-rc1 (7914a7c5651a
"of: support passing console options with stdout-path") and a fairly
large number of the dts files shipped with Linux have already included
a stdout-path property for quite a while now.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
10 years agodt-uart: use ':' as separator between path and options
Ian Campbell [Thu, 8 Jan 2015 11:53:55 +0000 (11:53 +0000)]
dt-uart: use ':' as separator between path and options

',' is a valid character in a device-tree path (see ePAPR v1.1 Table
2-1), in fact ',' is actually pretty common in node names.

Using ',' as a separator breaks for example on fast models. If you use
the full path (/smb/motherboard/iofpga@3,00000000/uart@090000) rather
than the alias then earlyprintk gives:

(XEN) Looking for UART console /smb/motherboard/iofpga@3
(XEN) Unable to find device "/smb/motherboard/iofpga@3"
(XEN) Bad console= option 'dtuart'

I actually noticed this on Jetson where the uart is
"/serial@0,70006300" and there happened to be no alias defined.

Instead use ':' as the separator, it is defined to terminate the path
in the context of /chosen/stdout-path (Table 3-4) which is pretty
closely analogous to the dtuart= option and so makes a pretty good
choice (especially since the next patch adds support for stdout-path).

Since no DT aware driver current supports any options there is no
point in retaining support for ',' for backwards compatibility.

Additionally, expand the buffer for the dtuart option, a path can be
far longer than 30 characters (in fact the maximum size of a single
node name is 31, so it's not even necessarily enough for an alias).
128 is completely arbitrary and allows for paths at least 8 deep even
with worst case node names.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
10 years agodt-uart: Clarify log messages at init time.
Ian Campbell [Thu, 8 Jan 2015 11:53:54 +0000 (11:53 +0000)]
dt-uart: Clarify log messages at init time.

- Don't log at all if console=dtuart (the default) was not present, in
  that case the user has asked for something else, no need for every
  other driver to tell them this.
- Use "dtuart" in all other messages, rather than just "console" or
  "uart".
- Be more explicit if we are exiting because dtuart= wasn't given.
- Log the options which we've parsed.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
10 years agodt-uart: add an emacs magic block
Ian Campbell [Thu, 8 Jan 2015 11:53:53 +0000 (11:53 +0000)]
dt-uart: add an emacs magic block

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
10 years agoxenstored: log tdb message via xenstored's logging mechanisms
Ian Campbell [Mon, 12 Jan 2015 15:18:02 +0000 (15:18 +0000)]
xenstored: log tdb message via xenstored's logging mechanisms

TDB provides us with a callback for this purpose. Use it in both
xenstored and xs_tdb_dump.

While at it make the existing log() macro tollerate memory failures.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
10 years agotools: libxl: directly initialise saved_* in _libxl_types.c
Ian Campbell [Thu, 8 Jan 2015 10:57:47 +0000 (10:57 +0000)]
tools: libxl: directly initialise saved_* in _libxl_types.c

Coverity complains:
> /tools/libxl/_libxl_types.c: 9194 in libxl__device_channel_parse_json()
> 9188             }
> 9189             x = libxl__json_map_get("connection.socket", o, JSON_MAP);
> 9190             if (x) {
> 9191                 libxl_device_channel_init_connection(p, LIBXL_CHANNEL_CONNECTION_SOCKET);
> 9192                 {
> 9193                     const libxl__json_object *saved_path = NULL;
> >>>     CID 1261758:  Unused value  (UNUSED_VALUE)
> >>>     Value from "x" is assigned to "saved_path" here, but that
> >>>     stored value is not used before it is overwritten.
> 9194                     saved_path = x;
> 9195                     x = libxl__json_map_get("path", x, JSON_STRING | JSON_NULL);
> 9196                     if (x) {
> 9197                         rc = libxl__string_parse_json(gc, x, &p->u.socket.path);
> 9198                         if (rc)
> 9199                             goto out;

Which we can avoid by initialising saved_%s as we define it. Resulting
in numerous instances of the generated code changing like this:
         if (x) {
             libxl_channelinfo_init_connection(p, LIBXL_CHANNEL_CONNECTION_PTY);
             {
-                const libxl__json_object *saved_path = NULL;
-                saved_path = x;
+                const libxl__json_object *saved_path = x;
                 x = libxl__json_map_get("path", x, JSON_STRING | JSON_NULL);
                 if (x) {
                     rc = libxl__string_parse_json(gc, x, &p->u.pty.path);

CID: 12617581261759 (and I would have expected others, but not
seeing them for some reason).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
10 years agoextend list of sections convertible to .init.* ones in init-only objects
Jan Beulich [Mon, 12 Jan 2015 14:44:06 +0000 (15:44 +0100)]
extend list of sections convertible to .init.* ones in init-only objects

In particular the .rodata.str2 case is relevant for the EFI boot code
(moving around 3k from permanent to init-time sections).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
10 years agoarm64/EFI: minor corrections
Jan Beulich [Mon, 12 Jan 2015 14:42:53 +0000 (15:42 +0100)]
arm64/EFI: minor corrections

- don't bail when using the last slot of bootinfo.mem.bank[] (due to
  premature incrementing of the array index)
- GUIDs should be static const (and placed into .init.* whenever
  possible)
- PrintErrMsg() issues a CR/LF pair itself - no need to explicitly
  append one to the message passed to the function

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>