]> xenbits.xensource.com Git - xen.git/log
xen.git
8 years agotools/livepatch: Show the correct expected state before action
Ross Lagerwall [Wed, 14 Dec 2016 07:51:53 +0000 (07:51 +0000)]
tools/livepatch: Show the correct expected state before action

Somewhat confusingly, before the action has been executed the patch is
expected to be in the "allow" state, not the "expected" state.  The
check for this was correct but the subsequent error message was not.
Fix the error message to show this state correctly.

Before:
    $ xen-livepatch unload test
    test: in wrong state (APPLIED), expected (unknown)
After:
    $ xen-livepatch unload test
    test: in wrong state (APPLIED), expected (CHECKED)

Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
8 years agox86/traps: Correct pagefault handling issues introduced in c/s d5c251c
Andrew Cooper [Wed, 14 Dec 2016 11:33:17 +0000 (11:33 +0000)]
x86/traps: Correct pagefault handling issues introduced in c/s d5c251c

There are two bugs.

Firstly, the ASSERT(paging_mode_only_log_dirty(d)) can trip when servicing a
hypervisor #PF in the context of an HVM guest, e.g. a copy_to_user() failure
in the shadow pagetable code.

Secondly, the entry conditions paging_fault() were previously guarded on
!paging_mode_external(d) which limited entry to PV contexts, but for both
guest and hypervisor faults.  Switching this to paging_mode_log_dirty() opened
it up to HVM contexts as well.

Reinstate the old !paging_mode_external(d) check, as it is actually the
relevent fact, and extend the comment to explicitly state that hypervisor
faults should follow this path.

Inside, we are now guarenteed to be in the context of a PV guest, so can
safely use the assertion about log dirty.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
8 years agox86: Use ACPI reboot method for Dell OptiPlex 9020
Ross Lagerwall [Wed, 14 Dec 2016 11:12:01 +0000 (11:12 +0000)]
x86: Use ACPI reboot method for Dell OptiPlex 9020

When EFI booting the Dell OptiPlex 9020, it sometimes GP faults in the
EFI runtime instead of rebooting. Quirk this hardware to use the ACPI
reboot method instead.

dmidecode info:

BIOS Information
    Vendor: Dell Inc.
    Version: A15
    Release Date: 11/08/2015
System Information
    Manufacturer: Dell Inc.
    Product Name: OptiPlex 9020
    Version: 00

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86/emul: Further simplify DstBitBase handling
Andrew Cooper [Wed, 14 Dec 2016 10:58:08 +0000 (10:58 +0000)]
x86/emul: Further simplify DstBitBase handling

The masking of src.val is common to both paths.  Move it later and simplify
the entry condition for adjusting the memory operand.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agoConfig.mk: update mini-os changeset
Wei Liu [Wed, 14 Dec 2016 14:44:33 +0000 (14:44 +0000)]
Config.mk: update mini-os changeset

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
8 years agostubdom: modify ioemu linkfarm only if necessary
Juergen Gross [Tue, 13 Dec 2016 15:38:06 +0000 (16:38 +0100)]
stubdom: modify ioemu linkfarm only if necessary

Several stubdom libraries are being rebuilt each time a top level make
is called as they depend on stubdom/ioemu/linkfarm.stamp which is
depending on tools/qemu-xen-traditional-dir. Unfortunately this
directory is modified by each "make tools" call.

This can be avoided by writing stubdom/ioemu/linkfarm.stamp only if
a source file beneath tools/qemu-xen-traditional-dir has been added
or removed.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
8 years agox86emul: MOVNTI does not allow REP prefixes
Jan Beulich [Wed, 14 Dec 2016 09:11:08 +0000 (10:11 +0100)]
x86emul: MOVNTI does not allow REP prefixes

Just like 66, prefixes F3 and F2 cause #UD.

Also adjust a related comment, which in its previous wording was
misleading (as in 16-bit mode there would nothing be undone when
adjusting operand size from 2 to 4).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: check for LAHF_LM availability
Jan Beulich [Wed, 14 Dec 2016 09:10:39 +0000 (10:10 +0100)]
x86emul: check for LAHF_LM availability

We can't exclude someone wanting to hide LAHF/SAHF from 64-bit guests.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: check for CLFLUSH{,OPT} availability
Jan Beulich [Wed, 14 Dec 2016 09:10:11 +0000 (10:10 +0100)]
x86emul: check for CLFLUSH{,OPT} availability

We can't exclude someone wanting to hide either of the instructions
from guests.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: check for SYSENTER/SYSEXIT availability
Jan Beulich [Wed, 14 Dec 2016 09:09:40 +0000 (10:09 +0100)]
x86emul: check for SYSENTER/SYSEXIT availability

We can't exclude someone wanting to hide the instructions from guests.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: CMPXCHG{8,16}B ignore prefixes
Jan Beulich [Wed, 14 Dec 2016 09:08:22 +0000 (10:08 +0100)]
x86emul: CMPXCHG{8,16}B ignore prefixes

This removes 0F C7 from the list of two-byte opcodes treating prefixes
66, F3, and F2 as opcode extensions. We better manually handle this in
the opcode specific code:
- CMPXCHG8B ignores all these prefixes (its handling is being adjusted
  accordingly, with a respective test case added as well, to avoid
  re-introducing the subject of XSA-200),
- RDRAND/RDSEED (support to be added subsequently) honor 66, but treat
  F3 and F2 as opcode extensions (resolving to RDPID in the RDSEED
  case, which in turn ignores 66).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86/PV: prefer pv_inject_hw_exception()
Jan Beulich [Wed, 14 Dec 2016 08:54:35 +0000 (09:54 +0100)]
x86/PV: prefer pv_inject_hw_exception()

... over editing the error code and calling do_guest_trap().

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86/PV: use generic emulator for privileged instruction handling
Jan Beulich [Wed, 14 Dec 2016 08:54:03 +0000 (09:54 +0100)]
x86/PV: use generic emulator for privileged instruction handling

There's a new emulator return code being added to allow bypassing
certain operations (see the code comment).

Another small tweak to the emulator is to single iteration handling
of INS and OUTS: Since we don't want to handle any other memory access
instructions, we want these to be handled by the rep_ins() / rep_outs()
hooks here too.

And then long-mode related bits now get hidden from the guest. This
should have been that way from the beginning, but becomes a requirement
now as the emulator's in_longmode() needs this to reflect guest view.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: make write and cmpxchg hooks optional
Jan Beulich [Wed, 14 Dec 2016 08:53:09 +0000 (09:53 +0100)]
x86emul: make write and cmpxchg hooks optional

While the read and fetch hooks are basically unavoidable, write and
cmpxchg aren't really needed by that many insns.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: generalize exception handling for rep_* hooks
Jan Beulich [Wed, 14 Dec 2016 08:52:35 +0000 (09:52 +0100)]
x86emul: generalize exception handling for rep_* hooks

If any of those hooks returns X86EMUL_EXCEPTION, some register state
should still get updated if some iterations have been performed (but
the rIP update will get suppressed if not all of them did get handled).
This updating is done by register_address_increment() and
__put_rep_prefix() (which hence must no longer be bypassed). As a
result put_rep_prefix() can then skip most of the writeback, but needs
to ensure proper completion of the executed instruction.

While on the HVM side the VA -> LA -> PA translation process ensures
that an exception would be raised on the first iteration only, doing so
would unduly complicate the PV side code about to be added.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
8 years agox86/32on64: use generic instruction decoding for call gate emulation
Jan Beulich [Wed, 14 Dec 2016 08:51:40 +0000 (09:51 +0100)]
x86/32on64: use generic instruction decoding for call gate emulation

... instead of custom handling. Note that we can't use generic
emulation, as the emulator's far branch support is rather rudimentary
at this point in time.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agolibxl: QED disks support
Cédric Bosdonnat [Tue, 13 Dec 2016 16:31:52 +0000 (17:31 +0100)]
libxl: QED disks support

Qdisk supports qcow and qcow2, extend it to also support qed disk
format.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
[ wei: regenerate libxlu_disk_l.{c,h} ]
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
8 years agofix LDRB Thumb2 decoding
Stefano Stabellini [Tue, 13 Dec 2016 19:08:39 +0000 (11:08 -0800)]
fix LDRB Thumb2 decoding

Rt is four bit at offset 12, not three. See see encoding T2 for LDRB
A8.8.70 in ARM DDI 0406C.c

Suggested-by: Julien Grall <julien.grall@arm.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Julien Grall <julien.grall@arm.com>
8 years agofirmware/rombios: fix after update to libacpi
Roger Pau Monne [Tue, 13 Dec 2016 17:15:40 +0000 (17:15 +0000)]
firmware/rombios: fix after update to libacpi

Fix a build breakage after the libacpi changes, this is due to rombios using the
libacpi headers in order to parse the ACPI tables.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reported-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agox86/traps: Adjust paged-guest handling in the PV pagefault path
Andrew Cooper [Mon, 5 Dec 2016 11:29:12 +0000 (11:29 +0000)]
x86/traps: Adjust paged-guest handling in the PV pagefault path

PV guests necessarily can't be external, as Xen must steal address space from
them.  Pagefaults for HVM guests are handled by {vmx,svm}_vmexit_handler() and
don't enter the PV fixup_page_fault() path.  Therefore, the first call to
paging_fault() is dead, and dropped.

Logdirty mode is now the only paging mode we should ever find a PV guest with,
so add a new predicate and assertion to this fact.

Drop the final reference to paging_mode_external().  It is more accurately now
only for logdirty guests.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/shadow: Drop all emulation for PV vcpus
Andrew Cooper [Mon, 5 Dec 2016 11:35:32 +0000 (11:35 +0000)]
x86/shadow: Drop all emulation for PV vcpus

Emulation is only performed for paging_mode_refcount() domains, which in
practice means HVM domains only.

Drop the PV emulation code.  As it always set addr_side and sp_size to
BITS_PER_LONG, it can't have worked correctly for PV guests running in a
different mode to Xen.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
8 years agox86/paging: Enforce PG_external == PG_translate == PG_refcounts
Andrew Cooper [Mon, 5 Dec 2016 11:28:08 +0000 (11:28 +0000)]
x86/paging: Enforce PG_external == PG_translate == PG_refcounts

Setting PG_refcounts but not PG_translate is not useful.

While adjusting this, make a few other improvements.

 * Have paging_enable() unilaterally reject any unknown modes.
 * Drop the or'ing of PG_{HAP,SH}_enable.  The underlying functions already do
   this.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/VPMU: clear the overflow status of which counter happened to overflow
Luwei Kang [Tue, 13 Dec 2016 13:21:26 +0000 (14:21 +0100)]
x86/VPMU: clear the overflow status of which counter happened to overflow

Just set the corresponding bits of counters which happened to overflow,
rather than setting all the available bits of IA32_PERF_GLOBAL_OVF_CTRL
when pmu interrupt happened.

Signed-off-by: Luwei Kang <luwei.kang@intel.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agolibacpi: announce that PVHv2 has no CMOS RTC in FADT
Roger Pau Monné [Tue, 13 Dec 2016 13:20:55 +0000 (14:20 +0100)]
libacpi: announce that PVHv2 has no CMOS RTC in FADT

At the moment this flag is unconditionally set for PVHv2 domains. Note that
using this boot flag requires that the FADT table revision is at least 5.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agolibacpi: update FADT layout to support version 5
Roger Pau Monné [Tue, 13 Dec 2016 13:20:34 +0000 (14:20 +0100)]
libacpi: update FADT layout to support version 5

Update the structure of the FADT table to version 5, and use that version for
PVHv2 guests. Note that HVM guests will continue to use FADT 4. In order to do
this, add a new field to acpi_config that contains the ACPI revision to use by
libacpi. Note that currently this only applies to the FADT.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agolibs/xenstore: set correct FreeBSD device
Roger Pau Monne [Mon, 12 Dec 2016 16:07:40 +0000 (16:07 +0000)]
libs/xenstore: set correct FreeBSD device

The path to the xenstore FreeBSD device is /dev/xen/xenstore.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agotools/fuzz: add README
Wei Liu [Thu, 8 Dec 2016 12:29:13 +0000 (12:29 +0000)]
tools/fuzz: add README

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
8 years agotools: hook up fuzz directory
Wei Liu [Thu, 8 Dec 2016 13:44:54 +0000 (13:44 +0000)]
tools: hook up fuzz directory

This will make all fuzzing targets get build every time tools directory
is built. This serves as basic regression test.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
8 years agotools/fuzz: introduce x86 instruction emulator target
Wei Liu [Thu, 8 Dec 2016 12:09:54 +0000 (12:09 +0000)]
tools/fuzz: introduce x86 instruction emulator target

Instruction emulator fuzzing code is from code previous written by
Andrew and George. Adapt it to llvm fuzzer and hook up the build system.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86emul/test: factor out emul_test_get_fpu
Wei Liu [Fri, 9 Dec 2016 16:09:41 +0000 (16:09 +0000)]
x86emul/test: factor out emul_test_get_fpu

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86emul/test: factor out emul_test_{read_cr,cpuid}
Wei Liu [Fri, 9 Dec 2016 11:45:08 +0000 (11:45 +0000)]
x86emul/test: factor out emul_test_{read_cr,cpuid}

While at it, move xgetbv, all cpu_has_* and cache_line_size macros to
x86_emulate.h.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86emul/test: factor out emul_test_make_stack_executable
Wei Liu [Fri, 9 Dec 2016 11:09:01 +0000 (11:09 +0000)]
x86emul/test: factor out emul_test_make_stack_executable

It will be used by emulator fuzzing target.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agotools/fuzz: introduce libelf target
Wei Liu [Wed, 7 Dec 2016 11:28:56 +0000 (11:28 +0000)]
tools/fuzz: introduce libelf target

Source code and Makefile to fuzz libelf in Google's oss-fuzz
infrastructure.

Introduce FUZZ_NO_LIBXC in libelf-private.h. That macro will be set when
compiling libelf fuzzer target because libxc is not required in libelf
fuzzing.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/shadow: Misc minor cleanup
Andrew Cooper [Mon, 5 Dec 2016 11:23:00 +0000 (11:23 +0000)]
x86/shadow: Misc minor cleanup

 * Move the #ifdefary inside sh_audit_gw() to avoid needing the else clause.
 * The walk_t parameter is only ever read, so make it const.
 * Use mfn_eq() rather than opencoding it.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
8 years agox86/shadow: Tweak some initialisation in sh_page_fault()
Andrew Cooper [Mon, 5 Dec 2016 11:32:59 +0000 (11:32 +0000)]
x86/shadow: Tweak some initialisation in sh_page_fault()

sh_page_fault() is a complicated function.  It aids clarity for the reader if
constant data is declared as such.

Declare struct npfec access and fetch_type_t ft as const, which requires
initialising them during declaration.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
8 years agox86/emul: Implement the STAC and CLAC instructions
Andrew Cooper [Tue, 18 Oct 2016 15:55:26 +0000 (16:55 +0100)]
x86/emul: Implement the STAC and CLAC instructions

Note that unlike most privilege restricted instructions, STAC and CLAC are
documented to raise #UD rather than #GP[0], and indeed do so.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agoxen: Fix determining when domain creation is complete
Andrew Cooper [Mon, 12 Dec 2016 18:28:40 +0000 (18:28 +0000)]
xen: Fix determining when domain creation is complete

d->creation_finished is used in several places alter behaviour depending on
whether the domain is being created, or is already running.

However, there is a latent bug if a toolstack component makes a pair of
pause/unpause calls, where creation will be considered finished prematurely.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Paul Durrant <paul.durrant@citrix.com>
8 years agox86/hvm: Fix HVMOP_get_param when skipping creating the default ioreq server
Andrew Cooper [Mon, 12 Dec 2016 18:12:54 +0000 (18:12 +0000)]
x86/hvm: Fix HVMOP_get_param when skipping creating the default ioreq server

c/s e7dabe5 "x86/hvm: don't unconditionally create a default ioreq server"
added a break statement, but the logic previously depended on falling through
into the default case to fill in the value the caller asked for.

This causes the sending migration code to put a junk PARAM into the stream,
and the receiving side to fail to zero the IOREQ pages, causing QEMU to object
when it finds stale requests while starting up.

Reorder the code so it more clearly falls through into the default case.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
8 years agofix potential pa_range_info out of bound access
Stefano Stabellini [Mon, 12 Dec 2016 19:22:39 +0000 (11:22 -0800)]
fix potential pa_range_info out of bound access

pa_range_info has only 8 elements and is accessed using pa_range as
index. pa_range is initialized to 16, potentially causing out of bound
access errors. Fix the issue by checking that pa_range is not greater
than the size of the array. Remove the now superfluous pa_range&0x8
check.

Coverity-ID: 1381865

Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Julien Grall <julien.grall@arm.com>
8 years agofix potential int overflow in efi/boot
Stefano Stabellini [Fri, 9 Dec 2016 19:52:09 +0000 (11:52 -0800)]
fix potential int overflow in efi/boot

HorizontalResolution and VerticalResolution are 32bit, while size is
64bit. As it stands multiplications are evaluated with 32bit arithmetic,
which could overflow. Cast HorizontalResolution to 64bit to avoid that.

Coverity-ID: 1381858

Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/emul: Annotate more intentional fallthrough cases
Andrew Cooper [Mon, 12 Dec 2016 10:05:04 +0000 (10:05 +0000)]
x86/emul: Annotate more intentional fallthrough cases

Some recent change in x86_emulate.c has simplified the callgraph sufficiently
for Coverity to notice these, rather than hitting its upper path limit.

All are legitimate fallthoughs.  Annotate them as such.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agoconsole: allow log level threshold adjustments
Jan Beulich [Mon, 12 Dec 2016 16:48:49 +0000 (17:48 +0100)]
console: allow log level threshold adjustments

... from serial console so that one doesn't always need to reboot to
see more / less messages.

Note that upper thresholds are sticky, i.e. while they get adjusted
upwards when the lower threshold would otherwise end up above the upper
one, they don't get adjusted when reducing the lower one. Full
flexibility is available only via a future sysctl interface.

Note further that (meaningless) large threshold values aren't being
rejected, for the sake of not adding more checks to the code than are
really necessary for safe operation.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86/time: don't omit newline in dump_softtsc()
Jan Beulich [Mon, 12 Dec 2016 16:48:19 +0000 (17:48 +0100)]
x86/time: don't omit newline in dump_softtsc()

Reported-by: Anton Samsonov <devel@zxlab.ru>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: consolidate string insn register adjustments
Jan Beulich [Mon, 12 Dec 2016 16:47:29 +0000 (17:47 +0100)]
x86emul: consolidate string insn register adjustments

Move the looking at EFLAGS.DF into the macro (being renamed to no
longer suggest a particular direction, rendering all call sites more
readable.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoAMD IOMMU: Support IOAPIC IDs larger than 128
Suravee Suthikulpanit [Mon, 12 Dec 2016 16:43:34 +0000 (17:43 +0100)]
AMD IOMMU: Support IOAPIC IDs larger than 128

Currently, the driver uses the APIC ID to index into the ioapic_sbdf array.
The current MAX_IO_APICS is 128, which causes the driver initialization
to fail on the system with IOAPIC ID >= 128.

Instead, this patch adds APIC ID in the struct ioapic_sbdf,
which is used to match the entry when searching through the array.

Also, this patch removes the use of ioapic_cmdline bit-map, which is
used to track the ivrs_ioapic options via command line.
Instead, it introduces the cmdline flag in the struct ioapic_sbdf,
to identify if the entry is created during ivrs_ioapic command-line parsing.

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86: allow the emulated APICs to be enabled for the hardware domain
Roger Pau Monné [Mon, 12 Dec 2016 16:42:40 +0000 (17:42 +0100)]
x86: allow the emulated APICs to be enabled for the hardware domain

Allow the use of both the emulated local APIC and IO APIC for the hardware
domain.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agotools: bump some library version numbers to 4.9
Wei Liu [Tue, 6 Dec 2016 12:05:46 +0000 (12:05 +0000)]
tools: bump some library version numbers to 4.9

Bump the version number for libxc, libxlu, libxl and libvchan to 4.9.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
8 years agolibxl: Add COLO replication top-id support
Zhang Chen [Wed, 30 Nov 2016 09:47:52 +0000 (17:47 +0800)]
libxl: Add COLO replication top-id support

Because of qemu colo adds the top-id parameter, so we update libxl.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agolibxl: Add Xen colo support for qemu-upstream colo code
Zhang Chen [Wed, 30 Nov 2016 09:47:51 +0000 (17:47 +0800)]
libxl: Add Xen colo support for qemu-upstream colo code

Because of qemu code has been updated, we update Xen colo block code.

Signed-off-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agolibxl: fix gentypes call in Makefile
Cédric Bosdonnat [Thu, 10 Nov 2016 16:46:00 +0000 (17:46 +0100)]
libxl: fix gentypes call in Makefile

From the make documentation:

"$* [...] If the target is `dir/a.foo.b' and the target pattern is
`a.%.b' then the stem is `dir/foo'. In a static pattern rule, the
stem is part of the file name that matched the `%' in the target
pattern."

The rule generating the c types files from the idl ones is not
a static pattern rule, but rather an implicit rule. Thus the value
of $* is preceded by the file path, instead of only what matches %.

In order to get this fixed, drop the path using a $(notdir $*).

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agolibxl: fix erroneous negation for isstubdom
Sander Eikelenboom [Sat, 10 Dec 2016 17:59:08 +0000 (18:59 +0100)]
libxl: fix erroneous negation for isstubdom

Commit 20b75251d9721d9c050a973c02baac396c794ade introduced an erroneous
negation which gave the isstubdom bool the opposite semantics, causing
the subsequent code to take the wrong code path, which breaks HVM
pci-passthrough.

Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it>
Acked-by: Cedric Bosdonnat <cbosdonnat@suse.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
8 years agoINSTALL: remove stale coverage build instruction
Wei Liu [Wed, 7 Dec 2016 15:10:01 +0000 (15:10 +0000)]
INSTALL: remove stale coverage build instruction

Now it is controlled by Kconfig.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86/hvm: don't unconditionally create a default ioreq server
Paul Durrant [Mon, 12 Dec 2016 08:49:10 +0000 (09:49 +0100)]
x86/hvm: don't unconditionally create a default ioreq server

Avoid doing so if the domain is not under construction.

If upstream QEMU is in use then it will explicitly create an ioreq server
rather than implicitly creating the default ioreq server, which is a
side-effect of reading HVM_PARAM_IOREQ_PFN, HVM_PARAM_BUFIOREQ_PFN,
or HVM_PARAM_BUFIOREQ_EVTCHN (as is done by legacy QEMUs).

However, if the domain is subsequently saved/migrated then those parameters
are read and hence the default server will be unnecessarily instantiated.

This patch adds an extra check of the 'creation_finished' flag when those
HVM params are read and will only instantiate the server if the domain is
under construction, which will always be the case when QEMU is invoked.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Zhang Chen <zhangchen.fnst@cn.fujitsu.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86emul: use SrcEax/DstEax where suitable for string insns
Jan Beulich [Mon, 12 Dec 2016 08:41:57 +0000 (09:41 +0100)]
x86emul: use SrcEax/DstEax where suitable for string insns

LODS, SCAS, and STOS all use the accumulator as one of their operands.
This avoids some open coding of things, but requires switching around
operands of SCAS.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86: add CPUID dependents of APIC and TSC
Jan Beulich [Mon, 12 Dec 2016 08:41:21 +0000 (09:41 +0100)]
x86: add CPUID dependents of APIC and TSC

TSC_DEADLINE in particular depends on both; take the opportunity to add
a few more.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: avoid numeric literals for EFLAGS values
Jan Beulich [Mon, 12 Dec 2016 08:40:40 +0000 (09:40 +0100)]
x86emul: avoid numeric literals for EFLAGS values

Make the code use EFLG_* constants instead.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: move some of the early operand adjustments
Jan Beulich [Mon, 12 Dec 2016 08:40:06 +0000 (09:40 +0100)]
x86emul: move some of the early operand adjustments

As said in the code comment being added, only adjustments affecting
further processing prior to the x86_decode_*() calls really belong into
x86_decode() itself.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: abstract gcc asm() flag output handling
Jan Beulich [Mon, 12 Dec 2016 08:39:26 +0000 (09:39 +0100)]
x86emul: abstract gcc asm() flag output handling

Let's try to limit #ifdef-ery, or else more of these would need to
appear later.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: derive vcpu_must_have() from vcpu_has()
Jan Beulich [Mon, 12 Dec 2016 08:38:50 +0000 (09:38 +0100)]
x86emul: derive vcpu_must_have() from vcpu_has()

... to avoid introducing further redundancy when adding further feature
flag checks, and to bring its use better in line with its host_and_*()
sibling.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agomake tlbflush_filter()'s first parameter a pointer
Jan Beulich [Mon, 12 Dec 2016 08:34:09 +0000 (09:34 +0100)]
make tlbflush_filter()'s first parameter a pointer

This brings it in line with most other functions dealing with CPU
masks. Convert both implementations to inline functions at once.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
8 years agoarm/irq: Reorder check in route_irq_to_guest() to avoid 4 layers of "if"
Oleksandr Tyshchenko [Tue, 6 Dec 2016 17:53:20 +0000 (19:53 +0200)]
arm/irq: Reorder check in route_irq_to_guest() to avoid 4 layers of "if"

Remove one layer of "if" by reordering the check
in route_irq_to_guest() to make code more clearer.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Julien Grall <julien.grall@arm.com>
8 years agofix out of bound access to mode_strings
Stefano Stabellini [Fri, 9 Dec 2016 01:17:04 +0000 (17:17 -0800)]
fix out of bound access to mode_strings

mode == ARRAY_SIZE(mode_strings) causes an out of bound access to
the mode_strings array.

Coverity-ID: 1381859

Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Julien Grall <julien.grall@arm.com>
8 years agomissing vgic_unlock_rank in gic_remove_irq_from_guest
Stefano Stabellini [Fri, 9 Dec 2016 00:59:28 +0000 (16:59 -0800)]
missing vgic_unlock_rank in gic_remove_irq_from_guest

Add missing vgic_unlock_rank on the error path in
gic_remove_irq_from_guest.

Coverity-ID: 1381843

Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Julien Grall <julien.grall@arm.com>
8 years agox86/hvm: Move hvm_hypervisor_cpuid_leaf() handling into cpuid_hypervisor_leaves()
Andrew Cooper [Sun, 2 Oct 2016 16:28:11 +0000 (17:28 +0100)]
x86/hvm: Move hvm_hypervisor_cpuid_leaf() handling into cpuid_hypervisor_leaves()

This reduces the net complexity of CPUID handling by having all adjustments in
the same place.  Remove the now-unused hvm_funcs.hypervisor_cpuid_leaf()
infrastructure.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/hvm: Move hvm_funcs.cpuid_intercept() handling into hvm_cpuid()
Andrew Cooper [Sun, 2 Oct 2016 16:28:11 +0000 (17:28 +0100)]
x86/hvm: Move hvm_funcs.cpuid_intercept() handling into hvm_cpuid()

This reduces the net complexity of CPUID handling by having all adjustments in
the same place.  Remove the now-unused hvm_funcs.cpuid_intercept
infrastructure.

The SYSCALL feature hiding is tweaked when moved.  In principle, an
administrator can choose to explicitly hide the SYSCALL feature from the
guest, as it has a separate feature bit.  If this is the case, the feature
shouldn't be set behind the back of the administrators wishes.  (Not that many
64bit OSes would function in this scenario.)  In reality, SYSCALL will always
be set in edx at this point.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/vpmu: Remove core2_no_vpmu_ops
Andrew Cooper [Tue, 4 Oct 2016 19:35:45 +0000 (20:35 +0100)]
x86/vpmu: Remove core2_no_vpmu_ops

core2_no_vpmu_ops exists solely to work around the default-leaking of CPUID/MSR
values in Xen.

With CPUID handling removed from arch_vpmu_ops, the RDMSR handling is the last
remaining hook.  Since core2_no_vpmu_ops's introduction in c/s 25250ed7 "vpmu
intel: Add cpuid handling when vpmu disabled", a lot of work has been done and
the nop path in vpmu_do_msr() now suffices.

vpmu_do_msr() also falls into the nop path for un-configured or unprivileged
domains, which enables the removal the duplicate logic in priv_op_read_msr().

Finally, make all arch_vpmu_ops structures const as they are never modified,
and make them static as they are not referred to externally.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
8 years agox86/vpmu: Move vpmu_do_cpuid() handling into {pv,hvm}_cpuid()
Andrew Cooper [Tue, 4 Oct 2016 19:35:45 +0000 (20:35 +0100)]
x86/vpmu: Move vpmu_do_cpuid() handling into {pv,hvm}_cpuid()

This reduces the net complexity of CPUID handling by having all adjustments in
the same place.  Remove the now-unused vpmu_do_cpuid() infrastructure.

This involves introducing a vpmu_enabled() predicate, and making the Intel
specific VPMU_CPU_HAS_* constants public.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
8 years agox86emul: correct 64-bit mode repeated string insn handling with zero count
Jan Beulich [Fri, 9 Dec 2016 14:51:57 +0000 (15:51 +0100)]
x86emul: correct 64-bit mode repeated string insn handling with zero count

When a 32-bit address override is in effect these zero-extend all
registers which would also get updated in case of non-zero repeat
count.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: consolidate loop counter handling
Jan Beulich [Fri, 9 Dec 2016 14:51:18 +0000 (15:51 +0100)]
x86emul: consolidate loop counter handling

Rename _get_rep_prefix() to make it more visibly fit other use cases
and introduce a companion "put". Use them for repeated string insn
handling as well as LOOP/J?CXZ instead of open coding the same logic a
couple of times.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul/test: don't log double % characters
Jan Beulich [Fri, 9 Dec 2016 11:08:01 +0000 (12:08 +0100)]
x86emul/test: don't log double % characters

They're useless and at best confusing.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul/test: avoid meaningless output
Jan Beulich [Fri, 9 Dec 2016 11:07:31 +0000 (12:07 +0100)]
x86emul/test: avoid meaningless output

Unconditionally reporting a skipped test in 64-bit builds is not very
useful, especially when quite a few more tests are about to be added.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: constify write_segment() register pointer
Jan Beulich [Fri, 9 Dec 2016 11:06:51 +0000 (12:06 +0100)]
x86emul: constify write_segment() register pointer

Since I stumbled across this while looking for further constification
opportunities, also correct the insn_fetch() related comment.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: support 64-bit segment descriptor types
Jan Beulich [Fri, 9 Dec 2016 11:06:20 +0000 (12:06 +0100)]
x86emul: support 64-bit segment descriptor types

This is a prereq particularly to eventually supporting UMIP emulation,
but also for LAR/LSL/VERR/VERW.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: fold SReg PUSH/POP cases
Jan Beulich [Fri, 9 Dec 2016 11:05:36 +0000 (12:05 +0100)]
x86emul: fold SReg PUSH/POP cases

Now that segment registers are numbered naturally this can be easily
done to achieve some code size reduction.

Also consistently use X86EMUL_OKAY in the code being touched.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: defer rIP-relative address calculation
Jan Beulich [Fri, 9 Dec 2016 11:04:49 +0000 (12:04 +0100)]
x86emul: defer rIP-relative address calculation

By putting it after all instruction fetching has been done, we can both
simplify the existing handling of immediate operands and take care of
any future instructions allowing rIP-relative operands and getting
additional bytes fetched in x86_decode_*() (the current cases of extra
bytes getting fetched there are only for operands without ModR/M bytes,
or with them only allowing their register forms).

Similarly the new placement of truncate_ea() will take care of any
future cases of non-standard memory operands (the one existing case -
opcodes A0...A3 - are fine with and without this, as they fetch an
ad_bytes sized unsigned address anyway).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: avoid undefined behavior when dealing with 10-byte FPU operands
Jan Beulich [Fri, 9 Dec 2016 11:04:23 +0000 (12:04 +0100)]
x86emul: avoid undefined behavior when dealing with 10-byte FPU operands

Accessing an 8-byte (or perhaps just 4-byte in the test harness when
built as 32-bit app) field to read/write 10 bytes (leveraging the
successive field) is a latent bug, as the compiler could copy things
around. Use the 32 bytes large SSE/AVX slot instead.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: reduce FPU handling code size
Jan Beulich [Fri, 9 Dec 2016 11:03:48 +0000 (12:03 +0100)]
x86emul: reduce FPU handling code size

Pulling out the {get,put}_fpu() invocations from individual emulation
paths leads to a couple of kb code size reduction in my builds. Note
that this is fine exception-wise:
- #UD and #NM have implementation defined order relative to one
  another,
- data read #GP/#SS/#PF now properly are delivered after #NM/#UD.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: simplify FPU destination operand handling
Jan Beulich [Fri, 9 Dec 2016 11:03:11 +0000 (12:03 +0100)]
x86emul: simplify FPU destination operand handling

Consolidate the copying of ea to dst: There's no need to set the type
to OP_MEM, and instead the load cases setting it to OP_NONE allows the
copying to be done just once per major opcode.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: simplify FPU source operand handling
Jan Beulich [Fri, 9 Dec 2016 11:02:45 +0000 (12:02 +0100)]
x86emul: simplify FPU source operand handling

Consistently use ea instead of src for passing the memory address to
->read(). This eliminates the need to copy ea to src, resulting in a
couple of hundred bytes smaller binary size.

In addition for opcode DE we can leverage SrcMem16 to eliminate a call
of the ->read() hook. At the same time drop the stray Mov attributes
from D8, DA, DC, and DE: They're meaningful for memory writes only.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: extend / amend supported FPU opcodes
Jan Beulich [Fri, 9 Dec 2016 11:02:12 +0000 (12:02 +0100)]
x86emul: extend / amend supported FPU opcodes

First of all there are a number of secondary encodings both Intel and
AMD support, but which aren't formally documented. See e.g.
www.sandpile.org/x86/opc_fpu.htm for inofficial documentation.

Next there are a few more no-ops - instructions which served a purpose
only on 8087 or 287.

Further switch from fail_if() to raising of #UD in a couple of places
(as the decoding of FPU opcodes should now be complete except where
explicitly marked as todo).

Also adjust a few comments.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoRevert "libelf: treat phdr and shdr similarly"
Jan Beulich [Thu, 8 Dec 2016 15:41:12 +0000 (16:41 +0100)]
Revert "libelf: treat phdr and shdr similarly"

This reverts commit a01b6d464f05dadf28bfd38612283bd1848f1350
as needing further adjustment (namely to properly avoid a
divide by zero issue spotted by Coverity and reported by
Andrew).

8 years agox86emul: simplify {,i}{mul,div} fix
Jan Beulich [Thu, 8 Dec 2016 11:22:33 +0000 (12:22 +0100)]
x86emul: simplify {,i}{mul,div} fix

Commit 75066cd4ea ("x86emul: fix {,i}mul and {,i}div") can be had with
less code: Simply do the destination register override depending on
DstEax being in effect (the four other ModRM.reg encoded operations of
these two opcodes all use DstMem).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: drop stray NULL check
Jan Beulich [Thu, 8 Dec 2016 11:21:56 +0000 (12:21 +0100)]
x86emul: drop stray NULL check

->read is required to be non-NULL, and is not being checked anywhere else.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agox86emul: drop dead code from SYSENTER handling
Jan Beulich [Thu, 8 Dec 2016 11:20:59 +0000 (12:20 +0100)]
x86emul: drop dead code from SYSENTER handling

There's no point reading CS - all of the fields get set from scratch
right afterwards. Also correct a wrong comment.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
8 years agoxen/arm: vgic-v3: Allow AArch32 guest booting with GICv3
Julien Grall [Wed, 7 Dec 2016 12:33:53 +0000 (12:33 +0000)]
xen/arm: vgic-v3: Allow AArch32 guest booting with GICv3

AArch32 guest will use co-processor registers to access the GICv3 (see
8.5 in IHI 0069C). Some of the registers have to be trapped and emulated
(e.g ICC_SGI1R), this is the purpose of this patch.

The rest of the emulation already supports access required for AArch32
so nothing has to be changed there.

Note this is only enabling 32-bit guest using GICv3 on Xen ARM64. Further
work would be required to compile GICv3 and vGICv3 for Xen ARM32.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: vgic-v3: Move the emulation of ICC_SGI1R_EL1 in a separate helper
Julien Grall [Wed, 7 Dec 2016 12:33:52 +0000 (12:33 +0000)]
xen/arm: vgic-v3: Move the emulation of ICC_SGI1R_EL1 in a separate helper

The emulation of the co-processor register ICC_SGI1R is the same as the
system register ICC_SGI1R_EL1. So move the emulation outside and use the
newly introduced helper vreg_emulate_sysreg64 to abstract the access.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: vgic: Rename emulate_sysreg callback to emulate_reg
Julien Grall [Wed, 7 Dec 2016 12:33:51 +0000 (12:33 +0000)]
xen/arm: vgic: Rename emulate_sysreg callback to emulate_reg

We will want to emulate co-processor registers access in a follow-up
patch.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: vreg: Introduce vreg_emulate_cp{32,64}
Julien Grall [Wed, 7 Dec 2016 12:33:50 +0000 (12:33 +0000)]
xen/arm: vreg: Introduce vreg_emulate_cp{32,64}

Factorize the code to emulate 32-bit and 64-bit access to a co-processor
in specific helpers.

The new helpers will be used in different components to simplify the
emulation.

Finally, the prototypes for the callbacks to emulate 32-bit and 64-bit
co-processor access are the same as the sysreg one. Rather than
introducing new ones, repurpose the existent prototypes.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: vtimer: Move emulate_sysreg* callback in a separate header
Julien Grall [Wed, 7 Dec 2016 12:33:49 +0000 (12:33 +0000)]
xen/arm: vtimer: Move emulate_sysreg* callback in a separate header

The core emulation of sysreg (reading/writing registers) is not specific
to the virtual timer. Move the helpers in a new header vreg.h.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: vgic-v3: Build vgic-v3.c when CONFIG_HAS_GICV3 is enabled.
Julien Grall [Wed, 7 Dec 2016 12:33:48 +0000 (12:33 +0000)]
xen/arm: vgic-v3: Build vgic-v3.c when CONFIG_HAS_GICV3 is enabled.

The vGICv3 depends whether Xen has a host driver for GICv3, not on the
architecture (AArch64 vs AArch32).

Note CONFIG_HAS_GICV3 is enabled only when for ARM64 build, so there is
no functional change.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: vgic: Clean-up the sysreg emulation
Julien Grall [Wed, 7 Dec 2016 12:33:47 +0000 (12:33 +0000)]
xen/arm: vgic: Clean-up the sysreg emulation

Couple of clean-up for the vgic sysreg emulation:
    - Reference the public documentation rather than a non-public one
    - Let the vgic emulation decides whether a register needs to be
    emulated
    - Drop unnecessary debug printk. They don't bring much information
    and can be misleading (vGICv2 does not support those registers)

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: vgic: Switch emulate_sysreg return from int to bool
Julien Grall [Wed, 7 Dec 2016 12:33:46 +0000 (12:33 +0000)]
xen/arm: vgic: Switch emulate_sysreg return from int to bool

emulate_sysreg callback can only return 2 values: 0 or 1. Use bool
instead to make clear only two possible values exist.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: vgic: Switch vgic_to_sgi return from int to bool and progate up to...
Julien Grall [Wed, 7 Dec 2016 12:33:45 +0000 (12:33 +0000)]
xen/arm: vgic: Switch vgic_to_sgi return from int to bool and progate up to...

vgic_v{2,3}_to_sgi.

vgic_*to_sgi functions can only return 2 values: 0 or 1. Use bool instead
to make clear only two possible values exist.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: vgic: Switch from bool_t to bool
Julien Grall [Wed, 7 Dec 2016 12:33:44 +0000 (12:33 +0000)]
xen/arm: vgic: Switch from bool_t to bool

Since commit 9202342 "xen/build: Use C99 booleans", bool_t is an alias
to bool. Going forward, therer is a preference to use bool rather than
bool_t. Also replace 0 and 1 by false and true when relevant.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: traps: Switch from bool_t to bool
Julien Grall [Wed, 7 Dec 2016 12:33:43 +0000 (12:33 +0000)]
xen/arm: traps: Switch from bool_t to bool

Since commit 9202342 "xen/build: Use C99 booleans", bool_t is an alias
to bool. Going forward, there is a preference to use bool rather than
bool_t. Also replace 0 and 1 by true and false when relevant.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: vtimer: Switch the read variable in the emulation from int to bool
Julien Grall [Wed, 7 Dec 2016 12:33:42 +0000 (12:33 +0000)]
xen/arm: vtimer: Switch the read variable in the emulation from int to bool

The read variable can only take two values: 1 => read, 0 => write. Use
bool instead to make clear the variable can only take 2 values.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: vtimer: Switch the emulation functions return from int to bool
Julien Grall [Wed, 7 Dec 2016 12:33:41 +0000 (12:33 +0000)]
xen/arm: vtimer: Switch the emulation functions return from int to bool

The emulation functions are always returning 0 or 1. Use bool instead to
make clear only two possible values exist.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
8 years agoxen/arm: fix smpboot barriers
Stefano Stabellini [Wed, 7 Dec 2016 19:13:05 +0000 (11:13 -0800)]
xen/arm: fix smpboot barriers

Remove useless smp_wmb() barrier after cpumask_set_cpu(cpuid,
&cpu_online_map), which is not synchronizing against anything.

Keep the other smp_wmb(), before the cpumask_set_cpu call, to ensure
that all writes before setting the cpu online are visible to other cpus.
For that to work properly, we need a corresponding smp_rmb() barrier,
after reading the online cpumask from other processors, which is
currently missing. Add it.

See: http://marc.info/?l=xen-devel&m=148093236307211

Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Julien Grall <julien.grall@arm.com>
8 years agoQEMU_TAG update
Ian Jackson [Wed, 7 Dec 2016 16:52:23 +0000 (16:52 +0000)]
QEMU_TAG update

8 years agomisc/release-checklist: Import from xenbits:~xen/release-checklist
Ian Jackson [Mon, 5 Dec 2016 12:28:33 +0000 (12:28 +0000)]
misc/release-checklist: Import from xenbits:~xen/release-checklist

This checklist is what we use when releasing, branching, and making
tarballs.  Right I want to commit an exact copy of the live copy kept
on xenbits outside version control.  I am fed up of maintaining this
outside version control, and probably xen.git is the best place to put
it.

I have reviewed the contents and while it contains much that might be
considered embarrassing, it doesn't contain any secrets :-).

I suggest that:

 * This file should live in misc/ rather than docs/ on the grounds
   that no-one else is likely to ever want it.

 * We maintain the copy in xen.git#staging as the master copy for all
   branches.  When things change they are more often changes to
   infrastructure organisation and so on.  So the file will continue
   to contain explicit treatment for old Xen branches.

 * We will not retain information about branches which are out of
   security support.  (So some of what is there can be deleted at our
   leisure.)

 * This file will be maintained by the release technicians (currently
   mostly that means me, although others have done some parts of the
   task) and commits will be made by release technicians without
   further review or acks.

Please argue about the filename :-).

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>
CC: George Dunlap <George.Dunlap@eu.citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Tim Deegan <tim@xen.org>
CC: Wei Liu <wei.liu2@citrix.com>