]> xenbits.xensource.com Git - xen.git/log
xen.git
12 years agox86: don't pass negative time to gtime_to_gtsc()
Jan Beulich [Thu, 11 Apr 2013 10:07:55 +0000 (12:07 +0200)]
x86: don't pass negative time to gtime_to_gtsc()

scale_delta(), which is being called by that function, doesn't cope
with that.

Also print a warning message, so hopefully we can eventually figure why
occasionally a negative value results from the calculation in the first
place.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agoxen: arm: define 64-bit guest hypercall calling convention.
Ian Campbell [Tue, 12 Mar 2013 15:48:36 +0000 (15:48 +0000)]
xen: arm: define 64-bit guest hypercall calling convention.

As well as using x<N> rather than r<N> registers for passing arguments/results
as mandate the use of x16 as the hypercall number.

Add some pedantry about struct alignment layout referencing the ARM Procedure
Calling Standard to avoid confusion with the previous "OABI" convention. While
at it also mandate that hypercall argument structs are always little endian.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
12 years agoarm: tweak/improve logging for host SMP
Ian Campbell [Wed, 6 Mar 2013 08:54:36 +0000 (08:54 +0000)]
arm: tweak/improve logging for host SMP

Make the "CPU<n> booted" message fit in with the surrounding logging.

Log which CPU is taking an unexpected trap.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
12 years agoarm: gic: fix build on arm64
Ian Campbell [Wed, 6 Mar 2013 08:54:35 +0000 (08:54 +0000)]
arm: gic: fix build on arm64

lr_mask is a uint64_t and so needs to be printed with PRIx64.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
12 years agoarm: vgic: fix race between evtchn upcall and evtchnop_send
Ian Campbell [Wed, 6 Mar 2013 08:54:34 +0000 (08:54 +0000)]
arm: vgic: fix race between evtchn upcall and evtchnop_send

On ARM the evtchn upcall is done by using a local PPI interrupt. However the
guest will clear the evtchn_upcall_pending bit before it EOIs that PPI (which
happens late). This means vgic_vcpu_inject_irq (called via
vcpu_mark_events_pending) sees the PPI as in flight and ends up not reinjecting
it, if this happens after the guest has finished its event channel processing
loop but before the EOI then we have lost the upcall.

To fix this we need to check if an evtchn upcall is pending when returning to
the guest and if so reinject the PPI.

We therefore also need to call gic_restore_pending_irqs on the exit to guest
path in order to pickup any newly inject IRQ and propagate it into a free LR.
This doesn't currently support bumping a lower priority interrupt out of the
LRs in order to inject a new higher priority interrupt. We don't yet implement
interrupt prioritisation (and guests don't use it either) so this will do for
now.

Since gic_restore_pending_irqs is now called in the return to guest path it is
called with interrupts disabled and accordingly must use the
irqsave/irqrestore spinlock primitives.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
12 years agoarm: vgic: typo s/securty/security/
Ian Campbell [Wed, 6 Mar 2013 08:54:32 +0000 (08:54 +0000)]
arm: vgic: typo s/securty/security/

At least we were consistent, but lets be correct too

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
12 years agoarm: consolidate setup of hypervisor traps and second stage paging
Ian Campbell [Wed, 6 Mar 2013 08:54:29 +0000 (08:54 +0000)]
arm: consolidate setup of hypervisor traps and second stage paging

In particular be sure to initisalise HCR_EL2 on secondary processors.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
[ ijc -- adjusted due to unapplied "trap guest WFI" by s/HCR_TWI// ]

12 years agoarm: initialise VCPU SCTLR in vcpu_initialise
Ian Campbell [Wed, 6 Mar 2013 08:54:28 +0000 (08:54 +0000)]
arm: initialise VCPU SCTLR in vcpu_initialise

Ensuring a sane initial starting state for vcpus other than domain 0s.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
12 years agox86: allow AMD MSRs injected via xen-mceinj
Christoph Egger [Thu, 11 Apr 2013 08:11:44 +0000 (10:11 +0200)]
x86: allow AMD MSRs injected via xen-mceinj

Signed-off-by: Christoph Egger <chegger@amazon.de>
12 years agox86: show handler for Xen-internal interrupts
Jan Beulich [Wed, 10 Apr 2013 16:27:32 +0000 (18:27 +0200)]
x86: show handler for Xen-internal interrupts

... in 'i' debug key output.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agox86/MSI: cleanup to prepare for multi-vector MSI
Jan Beulich [Wed, 10 Apr 2013 15:30:19 +0000 (17:30 +0200)]
x86/MSI: cleanup to prepare for multi-vector MSI

The major aspect being the removal of the overload of the MSI entry's
mask_base field for MSI purposes - a proper union is being installed
instead, tracking both the config space position needed and the number
of vectors used (which is going to be 1 until the actual multi-vector
MSI patches arrive).

It also corrects misleading information from debug key 'M': When
msi_get_mask_bit() returns a negative value, there's no mask bit, and
hence output shouldn't give the impression there is.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
12 years agoxen/arm: phys_timer fixes
Stefano Stabellini [Wed, 20 Feb 2013 18:16:37 +0000 (18:16 +0000)]
xen/arm: phys_timer fixes

Do not unmask the emulated phys_timer when the related Xen timer
expires.
Do not inject the phys_timer interrupt if it is masked.

Do not let the user set CNTx_CTL_PENDING directly.

Set CNTx_CTL_PENDING when the phys_timer expires and clear it when the
phys_timer is disabled or the compare value is changed.

Define offset and cval as uint64_t given that they can't be negative and
they are used as uint64_t arguments.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoxen/arm: don't set the internal Xen timer if virt_timer is masked
Stefano Stabellini [Mon, 18 Feb 2013 16:02:29 +0000 (16:02 +0000)]
xen/arm: don't set the internal Xen timer if virt_timer is masked

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agoxen/arm: dump gic debug info from arch_dump_domain_info
Stefano Stabellini [Mon, 18 Feb 2013 16:02:28 +0000 (16:02 +0000)]
xen/arm: dump gic debug info from arch_dump_domain_info

Print some useful GIC debug information when arch_dump_domain_info is
called ('q' debug key).

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agox86: debugging code for platform timer wrap problem
Jan Beulich [Tue, 9 Apr 2013 11:33:52 +0000 (13:33 +0200)]
x86: debugging code for platform timer wrap problem

This is intentionally adding code not well formatted (so it stands out)
and expected to be reverted as soon as the problem with the timer wraps
has been spotted.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
12 years agox86: serialize page table population in map_domain_page_global()
Tim Deegan [Tue, 9 Apr 2013 08:30:33 +0000 (10:30 +0200)]
x86: serialize page table population in map_domain_page_global()

Looking at map_domain_page_global, there doesn't seem to be any locking
preventing two CPUs from populating a page of global-map l1es at the
same time.

Signed-off-by: Tim Deegan <tim@xen.org>
12 years agoxl: Accept a list for usbdevice in config file
George Dunlap [Tue, 2 Apr 2013 14:10:13 +0000 (14:10 +0000)]
xl: Accept a list for usbdevice in config file

Allow the "usbdevice" key to accept a list of USB devices, and pass
them in using the new usbdevice_list domain build element.

For backwards compatibility, still accept singleton values.

Also update the xl.cfg manpage, adding information about how to pass
through host devices.

as applied:
 - Fix trailing whitespace and wrap some lines in xl_cmdimpl.c -iwj
v2:
 - Add some verbiage to make it clear that "usb" is for emulated devices
 - Reference qemu manual for more usbdevice options

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agolibxl: Allow multiple USB devices on HVM domain creation
George Dunlap [Tue, 2 Apr 2013 14:11:33 +0000 (14:11 +0000)]
libxl: Allow multiple USB devices on HVM domain creation

This patch allows an HVM domain to be created with multiple USB
devices.

Since the previous interface only allowed the passing of a single
device, this requires us to add a new element to the hvm struct of
libxl_domain_build_info -- usbdevice_list.  For API compatibility, the
old element, usbdevice, remains.

If hvm.usbdevice_list is set, each device listed will cause an extra
"-usbdevice [foo]" to be appended to the qemu command line.

Callers may set either hvm.usbdevice or hvm.usbdevice_list, but not
both; libxl will throw an error if both are set.

In order to allow users of libxl to write software compatible with
older versions of libxl, also define LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST.
If this is defined, callers may use either hvm.usbdevice or
hvm.usbdevice_list; otherwise, only hvm.usbdevice will be available.

as applied:
 - Fix whitespace errors -iwj
v3:
 - Duplicate functionality in both "new" and "old", since we're not
   unifying the two anymore.
v2:
 - Throw an error if both usbdevice and usbdevice_list are set
 - Update and clarify definition based on feedback
 - Previous patches means this works for both traditional and upstream

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agoxl: default autoballoon option to "auto"
David Vrabel [Thu, 4 Apr 2013 17:21:12 +0000 (17:21 +0000)]
xl: default autoballoon option to "auto"

In xl.conf, autoballoon="auto" will do the right thing for most
people.  Make it the default (instead of "on").

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agoxl: extend autoballoon xl.conf option with an "auto" option
David Vrabel [Thu, 4 Apr 2013 17:21:12 +0000 (17:21 +0000)]
xl: extend autoballoon xl.conf option with an "auto" option

autoballoon=1 is not recommened if dom0_mem was used to reduce the
amount of dom0 memory.  Instead of requiring users to change xl.conf
if they do this, extend the autoballoon option with a new choice:
"auto".

With autoballoon="auto", autoballooning will be disabled if dom0_mem
was used on the Xen command line.

For consistency, accept "on" and "off" as valid autoballoon options (1
and 0 are still accepted).

The default remains "on" for now.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agotools/ocaml: Correct META for libxl bindings
Andrew Cooper [Wed, 3 Apr 2013 20:24:47 +0000 (20:24 +0000)]
tools/ocaml: Correct META for libxl bindings

This was missed by c/s 23936:cdb34816a40a which renamed xl -> xenlight

[ 23936:cdb34816a40a is 7ceaa0c7449e841d7ca7db889c3041dc3fedbb3b in git -iwj ]

Reported-by: alien@rmail.be
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
12 years agovpmu intel: Dump vpmu infos in 'q' keyhandler
Dietmar Hahn [Mon, 8 Apr 2013 15:58:16 +0000 (17:58 +0200)]
vpmu intel: Dump vpmu infos in 'q' keyhandler

This patch extends the printout of the VPCU infos of the keyhandler 'q'.
If vPMU is enabled is on the VCPU and active lines are printed like
(when running HVM openSuSE-12.3 with 'perf top');

(XEN)     vPMU running
(XEN)       general_0: 0x000000ffffff3ae1 ctrl: 0x000000000053003c
(XEN)       fixed_1:   0x000000ff90799188 ctrl: 0xb

This means general counter 0 and fixed counter 1 are running with showing
their contents and the contents of their configuration msr.

Signed-off-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Jun Nakajima <jun.nakajima@intel.com>
12 years agovpmu intel: Use PMU defines instead of numerals and bit masks
Dietmar Hahn [Mon, 8 Apr 2013 15:57:17 +0000 (17:57 +0200)]
vpmu intel: Use PMU defines instead of numerals and bit masks

This patch uses the new defines in Intel vPMU to replace existing numerals and
bit masks.

Signed-off-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Jun Nakajima <jun.nakajima@intel.com>
12 years agovpmu intel: Better names and replacing numerals with defines
Dietmar Hahn [Mon, 8 Apr 2013 15:55:49 +0000 (17:55 +0200)]
vpmu intel: Better names and replacing numerals with defines

This patch renames core2_counters to core2_fix_counters for better
understanding the code and subtitutes 2 numerals with defines in fixed counter
handling.

Signed-off-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Jun Nakajima <jun.nakajima@intel.com>
12 years agoremus: init sch_plug module based on kernel version
Shriram Rajagopalan [Fri, 5 Apr 2013 15:16:05 +0000 (15:16 +0000)]
remus: init sch_plug module based on kernel version

remus: init sch_plug module based on kernel version

sch_plug module, for network buffering, is available as part of linux
kernel (from 3.4 onwards), as opposed to an out-of-tree module.
The netlink message format to talk to the in-kernel module is different from
that of the old version.  So, before initializing the Plug Qdisc, check
the kernel version and use the appropriate message format.

Also change the names of the constants to reflect the format used by the mainline
module [CHECKPOINT -> BUFFER , RELEASE -> RELEASE_ONE ].

Signed-off-by: Shriram Rajagopalan <rshriram@cs.ubc.ca>
12 years agodefer event channel bucket pointer store until after XSM checks
Jan Beulich [Fri, 5 Apr 2013 07:59:03 +0000 (09:59 +0200)]
defer event channel bucket pointer store until after XSM checks

Otherwise a dangling pointer can be left, which would cause subsequent
memory corruption as soon as the space got re-allocated for some other
purpose.

This is CVE-2013-1920 / XSA-47.

Reported-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Tim Deegan <tim@xen.org>
12 years agox86/mm/shadow: spurious warning when unmapping xenheap pages.
Tim Deegan [Thu, 28 Mar 2013 10:32:17 +0000 (10:32 +0000)]
x86/mm/shadow: spurious warning when unmapping xenheap pages.

Xenheap pages will always have an extra typecount, taken in
share_xen_page_with_guest(), which doesn't come from a shadow PTE.
Adjust the warning in sh_remove_all_mappings() to account for it.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Tim Deegan <tim@xen.org>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
12 years agoVMX: Always disable SMEP when guest is in non-paging mode
Stefan Bader [Thu, 4 Apr 2013 08:37:19 +0000 (10:37 +0200)]
VMX: Always disable SMEP when guest is in non-paging mode

commit e7dda8ec9fc9020e4f53345cdbb18a2e82e54a65
  VMX: disable SMEP feature when guest is in non-paging mode

disabled the SMEP bit if a guest VCPU was using HAP and was not
in paging mode. However I could observe VCPUs getting stuck in
the trampoline after the following patch in the Linux kernel
changed the way CR4 gets set up:
  x86, realmode: read cr4 and EFER from kernel for 64-bit trampoline

The change will set CR4 from already set flags which includes the
SMEP bit. On bare metal this does not matter as the CPU is in non-
paging mode at that time. But Xen seems to use the emulated non-
paging mode regardless of HAP (I verified that on the guests I was
seeing the issue, HAP was not used).

Therefor it seems right to unset the SMEP bit for a VCPU that is
not in paging-mode, regardless of its HAP usage.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Keir Fraser <keir@xen.org>
Acked-by: Dongxiao Xu <dongxiao.xu@intel.com>
12 years agox86/S3: Restore broken vcpu affinity on resume
Ben Guthro [Tue, 2 Apr 2013 07:52:32 +0000 (09:52 +0200)]
x86/S3: Restore broken vcpu affinity on resume

When in SYS_STATE_suspend, and going through the cpu_disable_scheduler
path, save a copy of the current cpu affinity, and mark a flag to
restore it later.

Later, in the resume process, when enabling nonboot cpus restore these
affinities.

Signed-off-by: Ben Guthro <benjamin.guthro@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agox86: irq_move_cleanup_interrupt() must ignore legacy vectors
Jan Beulich [Tue, 2 Apr 2013 06:30:03 +0000 (08:30 +0200)]
x86: irq_move_cleanup_interrupt() must ignore legacy vectors

Since the main loop in the function includes legacy vectors, and since
vector_irq[] gets set up for legacy vectors regardless of whether those
get handled through the IO-APIC, it must not do anything on this vector
range. In fact, we should never get past the move_cleanup_count check
for IRQs not handled through the IO-APIC. Adding a respective assertion
woulkd make those iterations more expensive (due to the lock acquire).

For such an assertion to not have false positives we however ought to
suppress setting up IRQ2 as an 8259A interrupt (which wasn't correct
anyway), which is being done here despite the assertion not actually
getting added.

Furthermore, there's no point iterating over the vectors past
LAST_HIPRIORITY_VECTOR, so terminate the loop accordingly.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agox86/hvm: Centralize and simplify the RTC IRQ logic.
Tim Deegan [Thu, 28 Mar 2013 11:27:31 +0000 (11:27 +0000)]
x86/hvm: Centralize and simplify the RTC IRQ logic.

This keeps the behaviour of strobing the IRQ line every time any RTC
interrupt source is raised.  I rather suspect (based on the behaviour
of the MC146818A RTC) that we ought to be suppressing all subsequent
interrupts whenever RTC_IRQF is set, but this way avoids making
guest-visible changes.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agox86/hvm: Let the guest miss a few ticks before resetting the timer.
Tim Deegan [Thu, 28 Mar 2013 13:07:06 +0000 (13:07 +0000)]
x86/hvm: Let the guest miss a few ticks before resetting the timer.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agox86/hvm: Avoid needlessly resetting the periodic timer.
Tim Deegan [Thu, 28 Mar 2013 12:19:32 +0000 (12:19 +0000)]
x86/hvm: Avoid needlessly resetting the periodic timer.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agox86/hvm: Run the RTC periodic timer on a consistent time series.
Tim Deegan [Thu, 28 Mar 2013 12:00:46 +0000 (12:00 +0000)]
x86/hvm: Run the RTC periodic timer on a consistent time series.

When the RTC periodic timer gets restarted, align it to the VM's boot
time, not to whatever time it is now.  Otherwise every read of REG_C
will restart the current period

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Keir Fraser <keir@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
12 years agohvm: Clean up vlapic_reg_write() error propagation.
Keir Fraser [Thu, 28 Mar 2013 20:16:37 +0000 (20:16 +0000)]
hvm: Clean up vlapic_reg_write() error propagation.

In particular, correctly propagate errors through vlapic_apicv_write()
and hvm_x2apic_msr_write().

Signed-off-by: Keir Fraser <keir@xen.org>
12 years agoMerge branch 'docs.v3' of git://xenbits.xen.org/people/konradwilk/xen into staging
Ian Jackson [Thu, 28 Mar 2013 15:59:21 +0000 (15:59 +0000)]
Merge branch 'docs.v3' of git://xenbits.xen.org/people/konradwilk/xen into staging

12 years agolibxl: run libxl__arch_domain_create() much earlier.
Tim Deegan [Thu, 14 Mar 2013 12:39:39 +0000 (12:39 +0000)]
libxl: run libxl__arch_domain_create() much earlier.

Among other things, arch_domain_create() sets the shadow(/hap/p2m)
memory allocation, which must happen after vcpus are assigned (or the
shadow op will fail) but before memory is allocated (or we might run
out of p2m memory).

libxl__build_pre(), which already sets similar things like maxmem,
semes like a reasonable spot for it.  That needed a bit of plumbing to
get the right datastructure from the caller.

As a side-effect, the return code from libxl__arch_domain_create() is
no longer ignored.

This bug was analysed in:
    From: "Jan Beulich" <JBeulich@xxxxxxxx>
    "Re: [Xen-devel] [xen-unstable test] 16788: regressions - FAIL"
    Date: Mon, 04 Mar 2013 16:34:53 +0000
    http://lists.xen.org/archives/html/xen-devel/2013-03/msg00191.html

Reported-by: Jan Beulich <JBeulich@suse.com>
Signed-off-by: Tim Deegan <tim@xen.org>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
12 years agotools/blktap2: Handle read/write interrupts in blktap2 control plane.
Dr. Greg Wettstein [Thu, 28 Mar 2013 07:50:34 +0000 (07:50 +0000)]
tools/blktap2: Handle read/write interrupts in blktap2 control plane.

The following patch:

tools: Retry blktap2 tapdisk message on interrupt.

Addressed a long standing regression with the blktap2 control
plane.  An interruption of the select system call would
prematurely terminate the message sequence needed to properly
shutdown a blktap2 tapdisk instance.

Ian Jackson correctly noted that the read and write systems calls
responsible for receiving and sending the control messages could
also return EINTR resulting in similar effects.  While this
regression was not noted in field testing this patch adds support
to re-start the calls to provide a technically complete
implementation of control plane management in the presence of
signals.

Signed-off-by: Dr. Greg Wettstein <xen@wind.enjellic.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agohvm: Improve APIC INIT/SIPI emulation, fixing it for call paths other than x86_emulate().
Keir Fraser [Thu, 28 Mar 2013 11:44:11 +0000 (11:44 +0000)]
hvm: Improve APIC INIT/SIPI emulation, fixing it for call paths other than x86_emulate().

In particular, on broadcast/multicast INIT/SIPI, we handle all target
APICs at once in a single invocation of the init/sipi tasklet. This
avoids needing to return an X86EMUL_RETRY error code to the caller,
which was being ignored by all except x86_emulate().

The original bug, and the general approach in this fix, pointed out by
Intel (yang.z.zhang@intel.com).

Signed-off-by: Keir Fraser <keir@xen.org>
12 years agoACPI/APEI: revert "accept validly sized ERST on Intel systems only for now"
Jan Beulich [Thu, 28 Mar 2013 08:06:19 +0000 (09:06 +0100)]
ACPI/APEI: revert "accept validly sized ERST on Intel systems only for now"

With the recent two fixes to ERST handling, this should no longer be
necessary.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
12 years ago.gitignore: Add some flask files
Ian Jackson [Wed, 27 Mar 2013 17:13:33 +0000 (17:13 +0000)]
.gitignore: Add some flask files

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Daniel De Graaf <dgdegra@tycho.nsa.gov>
12 years agox86/EFI: permit setting variable with non-zero attributes
Jan Beulich [Wed, 27 Mar 2013 07:46:28 +0000 (08:46 +0100)]
x86/EFI: permit setting variable with non-zero attributes

This must have been a copy-and-paste mistake - get_variable uses
op->misc as output only, and wants to make sure it's zero for future
extensibility. For set_variable, this is an input though, and hence
the check is wrong.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agovpmu intel: Add cpuid handling when vpmu disabled
Dietmar Hahn [Tue, 26 Mar 2013 13:24:25 +0000 (14:24 +0100)]
vpmu intel: Add cpuid handling when vpmu disabled

Even though vpmu is disabled in the hypervisor in the HVM guest the call of
cpuid(0xa) returns informations about usable performance counters.
This may confuse guest software when trying to use the counters and nothing
happens.
This patch clears most bits in registers eax and edx of cpuid(0xa) instruction
for the guest when vpmu is disabled:
 - version ID of architectural performance counting
 - number of general pmu registers
 - width of general pmu registers
 - number of fixed pmu registers
 - width of ixed pmu registers

Signed-off-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agox86: reserve pages when SandyBridge integrated graphics
Xudong Hao [Tue, 26 Mar 2013 13:22:07 +0000 (14:22 +0100)]
x86: reserve pages when SandyBridge integrated graphics

SNB graphics devices have a bug that prevent them from accessing certain
memory ranges, namely anything below 1M and in the pages listed in the
table.

Xen does not initialize below 1MB to heap, i.e. below 1MB pages don't be
allocated, so it's unnecessary to reserve memory below the 1 MB mark
that has not already been reserved.

So reserve those pages listed in the table at xen boot if set detect a
SNB gfx device on the CPU to avoid GPU hangs.

Signed-off-by: Xudong Hao <xudong.hao@intel.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agodocs: Document the XenBus structure.
Konrad Rzeszutek Wilk [Mon, 28 Jan 2013 18:21:59 +0000 (13:21 -0500)]
docs: Document the XenBus structure.

Mark-up for inclusion of generated docs.

Acked-by: Ian Campbell <ian.campbel@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
12 years agodocs: Document start_info changes in Xen 4.2.
Konrad Rzeszutek Wilk [Mon, 28 Jan 2013 18:20:29 +0000 (13:20 -0500)]
docs: Document start_info changes in Xen 4.2.

The  25833:bb85bbccb1c9. "x86/32-on-64: adjust Dom0 initial page table layout"
fixes a bug in the reported value of pt_base versus where the page tables
actually start. This documents this in the start of the world header note.

This clarifies the implied understanding that the page table space is
pointed by pt_base. As in it is ".. implied that the range of page-tables
is the range [pt_base, pt_base + nr_pt_frames), whereas that that range
here indeed is [pt_base - 2, pt_base -2 + nr_pt_frames)" (Jan Beulich).

Also make it crystal clear that pt_base == %cr3.

Acked-by: Jan Beulich <JBeulich@suse.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
12 years agodocs: Document the dom0_vga_console_info structure.
Konrad Rzeszutek Wilk [Mon, 28 Jan 2013 18:02:04 +0000 (13:02 -0500)]
docs: Document the dom0_vga_console_info structure.

Mark-up for inclusion of generated docs.

Acked-by: Ian Campbell <ian.campbel@citrix.com>
[v2: s/dom9/dom0/]
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
12 years agodocs: Document the shared structure.
Konrad Rzeszutek Wilk [Mon, 28 Jan 2013 17:59:05 +0000 (12:59 -0500)]
docs: Document the shared structure.

Mark-up for inclusion of generated docs.

Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
12 years agodocs: Add some extra details to the ELF note.
Konrad Rzeszutek Wilk [Wed, 30 Jan 2013 17:06:23 +0000 (12:06 -0500)]
docs: Add some extra details to the ELF note.

Such as how the string values MUST be NULL terminated ASCII.

Acked-by: Ian Campbell <ian.campbel@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
12 years agodocs: Document the ELF_FEATURES entry
Konrad Rzeszutek Wilk [Mon, 28 Jan 2013 17:24:02 +0000 (12:24 -0500)]
docs: Document the ELF_FEATURES entry

Mark-up for inclusion of generated docs.

Acked-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
12 years agodocs: Document the ELF notes
Konrad Rzeszutek Wilk [Mon, 28 Jan 2013 17:10:50 +0000 (12:10 -0500)]
docs: Document the ELF notes

Mark-up for inclusion of generated docs.

Acked-by: Ian Campbell <ian.campbel@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
12 years agotrace: Add reason for NMI exit TRAP
Konrad Rzeszutek Wilk [Mon, 25 Mar 2013 15:57:31 +0000 (16:57 +0100)]
trace: Add reason for NMI exit TRAP

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
12 years agotrace: Add the other variant of do_block
Konrad Rzeszutek Wilk [Mon, 25 Mar 2013 15:57:22 +0000 (16:57 +0100)]
trace: Add the other variant of do_block

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
12 years agotrace: Add trace events for IRQ activities
Konrad Rzeszutek Wilk [Mon, 25 Mar 2013 15:57:14 +0000 (16:57 +0100)]
trace: Add trace events for IRQ activities

This expands the format to include the class of TRC_HW_IRQ.
This means that instead of:

CPU28  1753521436727 (+    3252)  unknown (0x0000000000802008)  [ 0x0000006c 0x4605709c 0x4605b682 0x00000000 0x00000000 0x00000000 0x00000000 ]

we now see:

CPU28  1753521436727 (+    3252)  do_irq [ irq = 108, began = 1174761628us, ended = 1174779522us ]

Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
12 years agotrace: Use correct trace class for power management changes
Konrad Rzeszutek Wilk [Mon, 25 Mar 2013 15:57:03 +0000 (16:57 +0100)]
trace: Use correct trace class for power management changes

Previous to this patch we would see in the trace file:

CPU28  1753503175371 (+    8496)  unknown (0x0000000000801002)  [ 0x00000004 0x4158a498 0x000003a1 0x000027e6 0x00000000 0x00000000 0x00000000 ]
CPU28  1753505321239 (+ 2145868)  unknown (0x0000000000801003)  [ 0x00000004 0x4166dca7 0x000000fa 0x00000000 0x00000000 0x00000000 0x00000000 ]
CPU28  1753505343756 (+   22517)  unknown (0x0000000000801002)  [ 0x00000004 0x41670fe5 0x00001284 0x00003766 0x00000000 0x00000000 0x00000000 ]
CPU28  1753521413711 (+16069955)  unknown (0x0000000000801003)  [ 0x00000004 0x41d1e02c 0x000000ab 0x00000000 0x00000000 0x00000000 0x00000000 ]

instead of:
CPU28  1753503175371 (+    8496)  cpu_idle_entry  [ C0 -> C4, acpi_pm_tick = 1096328344, expected = 929us, predicted = 10214us ]
CPU28  1753505321239 (+ 2145868)  cpu_idle_exit   [ C4 -> C0, acpi_pm_tick = 1097260199, irq = 250 0 0 0 ]
CPU28  1753505343756 (+   22517)  cpu_idle_entry  [ C0 -> C4, acpi_pm_tick = 1097273317, expected = 4740us, predicted = 14182us ]
CPU28  1753521413711 (+16069955)  cpu_idle_exit   [ C4 -> C0, acpi_pm_tick = 1104273452, irq = 171 0 0 0 ]

The patch that added the cpu_idle_[entry|exit] was using the
TRC_HW_IRQ class (0x00802000) instead of TRC_HW_PM (0x00801000)
as a base.

Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
12 years agoAMD IOMMU: allow disabling only interrupt remapping when certain IVRS consistency...
Jan Beulich [Mon, 25 Mar 2013 15:55:22 +0000 (16:55 +0100)]
AMD IOMMU: allow disabling only interrupt remapping when certain IVRS consistency checks fail

After some more thought on the XSA-36 and specifically the comments we
got regarding disabling the IOMMU in this situation altogether making
things worse instead of better, I came to the conclusion that we can
actually restrict the action in affected cases to just disabling
interrupt remapping. That doesn't make the situation worse than prior
to the XSA-36 fixes (where interrupt remapping didn't really protect
domains from one another), but allows at least DMA isolation to still
be utilized.

To do so, disabling of interrupt remapping must be explicitly requested
on the command line - respective checks will then be skipped.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Suravee Suthikulanit <suravee.suthikulpanit@amd.com>
12 years agoVT-d: deal with 5500/5520/X58 errata
Malcolm Crossley [Mon, 25 Mar 2013 13:31:27 +0000 (14:31 +0100)]
VT-d: deal with 5500/5520/X58 errata

http://www.intel.com/content/www/us/en/chipsets/5520-and-5500-chipset-ioh-specification-update.html

Stepping B-3 has two errata (#47 and #53) related to Interrupt
remapping, to which the workaround is for the BIOS to completely disable
interrupt remapping.  These errata are fixed in stepping C-2.

Unfortunately this chipset stepping is very common and many BIOSes are
not disabling interrupt remapping on this stepping .  We can detect this in
Xen and prevent Xen from using the problematic interrupt remapping feature.

The Intel 5500/5520/X58 chipset does not support VT-d
Extended Interrupt Mode(EIM). This means the iommu_supports_eim() check
always fails and so x2apic mode cannot be enabled in Xen before this quirk
disables the interrupt remapping feature.

Signed-off-by: Malcolm Crossley <malcolm.crossley@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Gate the function call to check the quirk on interrupt remapping being
requested to get enabled, and upon failure disable the IOMMU to be in
line with what the changes for XSA-36 (plus follow-ups) did.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: "Zhang, Xiantao" <xiantao.zhang@intel.com>
12 years agoIOMMU: properly check whether interrupt remapping is enabled
Jan Beulich [Mon, 25 Mar 2013 13:28:31 +0000 (14:28 +0100)]
IOMMU: properly check whether interrupt remapping is enabled

... rather than the IOMMU as a whole.

That in turn required to make sure iommu_intremap gets properly
cleared when the respective initialization fails (or isn't being
done at all).

Along with making sure interrupt remapping doesn't get inconsistently
enabled on some IOMMUs and not on others in the VT-d code, this in turn
allowed quite a bit of cleanup on the VT-d side (if desired, that
cleanup could of course be broken out into a separate patch).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: "Zhang, Xiantao" <xiantao.zhang@intel.com>
12 years agoxenconsoled: use array index to keep track of pollfd
Wei Liu [Tue, 19 Mar 2013 17:45:49 +0000 (17:45 +0000)]
xenconsoled: use array index to keep track of pollfd

If we use pointers to reference elements inside array, it is possible that we
get wild pointer after realloc(3) copies array and returns a new pointer.

Keep track of element indexes inside the array can solve this problem.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Marcus Granado <marcus.granado@citrix.com>
Tested-by: Marcus Granado <marcus.granado@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agolibxl: Streamline vnc argument generation code
George Dunlap [Mon, 11 Mar 2013 13:57:47 +0000 (13:57 +0000)]
libxl: Streamline vnc argument generation code

Makes the following changes to the vnc generation code:
* Simplifies and comments it, making it easier to read and grok
* Throws an error if duplicate values of display are set, rather
  than the current very un-intuitive behavior.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agotools: Retry blktap2 tapdisk message on interrupt.
Dr. Greg Wettstein [Tue, 19 Mar 2013 07:26:33 +0000 (07:26 +0000)]
tools: Retry blktap2 tapdisk message on interrupt.

Re-start blktap2 IPC select call on interrupt.

We hunted this miserable bug for a long time.

The teardown of a blktap2 tapdisk instance is being carried out
inconsistently up to and including the 4.2.1 release.  The
problem appears to be a classic 'Heisenbug' which disappears if a
single function call is added to the tapdisk shutdown path.  It
is likely this bug has been in existence for the life of the
blktap2 code.

Control messages to manipulate a tapdisk instance are sent over a
UNIX domain socket.  A select call is used on both the read and
write paths to wait on I/O and to set a timeout for the
transmission and reception of the control plane messages.

The existing code fails receipt or transmission of the control message
on any type of error return from the select call.  The xl control
process receives an interrupt while waiting in the select call which
in turn causes an error return with SIGINT as the return code.

This prematurely terminates the teardown of the tapdisk instance
leaving it in various states of shutdown.  Since multiple messages
are needed to implement a full teardown the tapdisk instance can be
left in various states ranging from fully connected to only the minor
being left allocated.

The fix is straight forward.  Check the return code from the
select call and re-try read or write of the control message if
errno is sent to EINTR.  The problem manifests itself in the read
path but there appears to be little reason to not add the fix to
the write path as well.  Both paths appear to be cut-and-paste
copies of each other.

Signed-off-by: Dr. Greg Wettstein <greg@enjellic.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agotools/firmware: Fix ovmf build with gcc version different from 4.4
fantonifabio@tiscali.it [Mon, 18 Mar 2013 10:59:53 +0000 (10:59 +0000)]
tools/firmware: Fix ovmf build with gcc version different from 4.4

Signed-off-by: Fabio Fantoni <fabio.fantoni@m2r.biz>
12 years agoACPI, APEI: Add apei_exec_run_optional
Huang Ying [Fri, 22 Mar 2013 11:46:25 +0000 (12:46 +0100)]
ACPI, APEI: Add apei_exec_run_optional

Some actions in APEI ERST and EINJ tables are optional, for example,
ACPI_EINJ_BEGIN_OPERATION action is used to do some preparation for
error injection, and firmware may choose to do nothing here.  While
some other actions are mandatory, for example, firmware must provide
ACPI_EINJ_GET_ERROR_TYPE implementation.

Original implementation treats all actions as optional (that is, can
have no instructions), that may cause issue if firmware does not
provide some mandatory actions.  To fix this, this patch adds
apei_exec_run_optional, which should be used for optional actions.
The original apei_exec_run should be used for mandatory actions.

Signed-off-by: Huang Ying <ying.huang@intel.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
12 years agoACPI/APEI: Unlock apei_iomaps_lock on error path
Andrew Cooper [Fri, 22 Mar 2013 08:43:38 +0000 (09:43 +0100)]
ACPI/APEI: Unlock apei_iomaps_lock on error path

This causes deadlocks during early boot on hardware with broken/buggy
APEI implementations, such as a Dell Poweredge 2950 with the latest
currently available BIOS.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Don't use goto or another special error path, as handling the error
case in normal flow is quite simple.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
12 years agox86/HPET: deal with event having expired while interrupt was masked
Jan Beulich [Wed, 20 Mar 2013 15:57:04 +0000 (16:57 +0100)]
x86/HPET: deal with event having expired while interrupt was masked

Commit 2d8a282 ("x86/HPET: fix FSB interrupt masking") may cause the
HPET event to occur while its interrupt is masked. In that case we need
to "manually" deliver the event.

Unfortunately this requires the locking to be changed: For one, it was
always bogus for handle_hpet_broadcast() to use spin_unlock_irq() - the
function is being called from an interrupt handler, and hence shouldn't
blindly re-enable interrupts (this should be left up to the generic
interrupt handling code). And with the event handler wanting to acquire
the lock for two of its code regions, we must not enter it with the
lock already held. Hence move the locking into
hpet_{attach,detach}_channel(), permitting the lock to be dropped by
set_channel_irq_affinity() (which is a tail call of those functions).

Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Sander Eikelenboom <linux@eikelenboom.it>
Acked-by: Keir Fraser <keir@xen.org>
12 years agoACPI/ERST: Name table in otherwise opaque error messages
Andrew Cooper [Wed, 20 Mar 2013 09:02:52 +0000 (10:02 +0100)]
ACPI/ERST: Name table in otherwise opaque error messages

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Fix spelling and lower severities.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
12 years agoVT-d: Enumerate IOMMUs when listing capabilities
Andrew Cooper [Wed, 20 Mar 2013 09:02:26 +0000 (10:02 +0100)]
VT-d: Enumerate IOMMUs when listing capabilities

This saves N identical console log lines on a multi-iommu server.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
12 years agox86: BITS_PER_LONG is now always 64
Jan Beulich [Wed, 20 Mar 2013 09:00:52 +0000 (10:00 +0100)]
x86: BITS_PER_LONG is now always 64

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agoAMD/IOMMU: Process softirqs while building dom0 iommu mappings
Andrew Cooper [Wed, 20 Mar 2013 09:00:01 +0000 (10:00 +0100)]
AMD/IOMMU: Process softirqs while building dom0 iommu mappings

Recent changes which have made their way into xen-4.2 stable have pushed the
runtime of construct_dom0() over 5 seconds, which has caused regressions in
XenServer testing because of our 5 second watchdog.

The root cause is that amd_iommu_dom0_init() does not process softirqs and in
particular the nmi_timer which causes the watchdog to decide that no useful
progress is being made.

This patch adds periodic calls to process_pending_softirqs() at the same
interval as the Intel variant of this function.  The server which was failing
with the watchdog test now boots reliably with a timeout of 1 second.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
12 years agox86/HPET: mask interrupt while changing affinity
Jan Beulich [Mon, 18 Mar 2013 16:13:32 +0000 (17:13 +0100)]
x86/HPET: mask interrupt while changing affinity

While being unable to reproduce the "No irq handler for vector ..."
messages observed on other systems, the change done by 5dc3fd2 ('x86:
extend diagnostics for "No irq handler for vector" messages') appears
to point at the lack of masking - at least I can't see what else might
be wrong with the HPET MSI code that could trigger these warnings.

While at it, also adjust the message printed by aforementioned commit
to not pointlessly insert spaces - we don't need aligned tabular output
here.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agoMAINTAINERS: Remove myself from AMD IOMMU maintainer
Wei Wang [Mon, 18 Mar 2013 10:57:54 +0000 (11:57 +0100)]
MAINTAINERS: Remove myself from AMD IOMMU maintainer

Signed-off-by: Wei Wang <wawei@amazon.com>
12 years agoQEMU_TAG update
Ian Jackson [Fri, 15 Mar 2013 18:29:36 +0000 (18:29 +0000)]
QEMU_TAG update

12 years agoxl: add vif.default.script
Roger Pau Monne [Wed, 13 Mar 2013 17:42:17 +0000 (17:42 +0000)]
xl: add vif.default.script

Replace vifscript with vif.default.script. The old config option is
kept for backwards compatibility.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: George Dunlap <george.dunlap@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agoxl: add vif.default.bridge
Roger Pau Monne [Wed, 13 Mar 2013 17:42:17 +0000 (17:42 +0000)]
xl: add vif.default.bridge

This is a replacement for defaultbridge xl.conf option. The now
deprecated defaultbridge is still supported.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agoxl: allow specifying a default gatewaydev in xl.conf
Roger Pau Monne [Wed, 13 Mar 2013 17:42:17 +0000 (17:42 +0000)]
xl: allow specifying a default gatewaydev in xl.conf

This adds a new global option in the xl configuration file called
"vif.default.gatewaydev", that is used to specify the default
gatewaydev to use when none is passed in the vif specification.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Ulf Kreutzberg <ulf.kreutzberg@hosteurope.de>
Cc: Ulf Kreutzberg <ulf.kreutzberg@hosteurope.de>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: George Dunlap <george.dunlap@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agoxl/libxl: add gatewaydev/netdev to vif specification
Roger Pau Monne [Wed, 13 Mar 2013 17:42:17 +0000 (17:42 +0000)]
xl/libxl: add gatewaydev/netdev to vif specification

This option is used by the vif-route hotplug script. A new more
descriptive name is used, "gatewaydev", but "netdev" is also supported
as a deprecated backwards compatible option.

This option was supported in the past, according to
http://wiki.xen.org/wiki/Vif-route, so we should also support it in
libxl.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Tested-by: Ulf Kreutzberg <ulf.kreutzberg@hosteurope.de>
Cc: Ulf Kreutzberg <ulf.kreutzberg@hosteurope.de>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: George Dunlap <george.dunlap@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agox86/mm: avoid undefined behavior in IS_NIL()
Xi Wang [Fri, 15 Mar 2013 09:26:17 +0000 (10:26 +0100)]
x86/mm: avoid undefined behavior in IS_NIL()

Since pointer overflow is undefined behavior in C, some compilers such
as clang optimize away the check !((ptr) + 1) in the macro IS_NIL().

This patch fixes the issue by casting the pointer type to uintptr_t,
the operations of which are well-defined.

Signed-off-by: Xi Wang <xi@mit.edu>
With that, we also need to avoid the overflow in NIL().

Note that either part of the change results in the respective macros to
become unsuitable for use with "void".

Signed-off-by: Jan Beulich <jbeulich@suse.com>
12 years agotools: libxl: unbreak build after ec41430ef6a7
Ian Campbell [Thu, 14 Mar 2013 09:45:57 +0000 (09:45 +0000)]
tools: libxl: unbreak build after ec41430ef6a7

libxl_create.c: In function ‘libxl__domain_build_info_setdefault’:
libxl_create.c:109: error: ‘info’ undeclared (first use in this function)
libxl_create.c:109: error: (Each undeclared identifier is reported only once
libxl_create.c:109: error: for each function it appears in.)
cc1: warnings being treated as errors
libxl_create.c:108: error: suggest explicit braces to avoid ambiguous ‘else’
libxl_create.c: At top level:
libxl_create.c:141: error: expected identifier or ‘(’ before ‘if’
...

Fix is to insert the missing opening brace and s/info/b_info/ in one spot.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agox86: extend diagnostics for "No irq handler for vector" messages
Jan Beulich [Thu, 14 Mar 2013 11:10:53 +0000 (12:10 +0100)]
x86: extend diagnostics for "No irq handler for vector" messages

By storing the inverted IRQ number in vector_irq[], we may be able to
spot which IRQ a vector was used for most recently, thus hopefully
permitting to understand why these messages trigger on certain systems.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agox86/mem_access: check for errors in p2m->set_entry().
Tim Deegan [Thu, 7 Mar 2013 14:23:05 +0000 (14:23 +0000)]
x86/mem_access: check for errors in p2m->set_entry().

These calls ought always to succeed.  Assert that they do rather than
ignoring the return value.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Aravindh Puthiyaparambil <aravindh@virtuata.com>
12 years agox86/mem_sharing: check for errors in p2m->set_entry().
Tim Deegan [Thu, 7 Mar 2013 14:08:24 +0000 (14:08 +0000)]
x86/mem_sharing: check for errors in p2m->set_entry().

This call ought always to succeed.  Assert that it does rather than
ignoring the return value.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
12 years agox86/ept: check for errors in a few callers of ept_set_entry.
Tim Deegan [Thu, 7 Mar 2013 13:22:32 +0000 (13:22 +0000)]
x86/ept: check for errors in a few callers of ept_set_entry.

AFAICT in all these cases we have the p2m lock and have just checked
that the p2m trie is populated so the call should succeed.  Make it
explicit with ASSERT() rather than just ignoring the result.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
12 years agox86/mm: warn if we ever run out of shadow/hap pool for p2m/lgd ops.
Tim Deegan [Thu, 7 Mar 2013 12:49:52 +0000 (12:49 +0000)]
x86/mm: warn if we ever run out of shadow/hap pool for p2m/lgd ops.

Even if the error propagates up through the p2m ops to the caller,
it'll look like ENOMEM, which won't be obviously a shadow-pool problem.

Warn on the console, once per domain.

Reported-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
12 years agox86/mm: use bool_t for flags in shadow-pagetable structs
Tim Deegan [Thu, 7 Mar 2013 12:37:12 +0000 (12:37 +0000)]
x86/mm: use bool_t for flags in shadow-pagetable structs

and reshuffle the domain struct to pack a little better.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
12 years agolibxl: use qemu-xen (upstream QEMU) as device model by default
Stefano Stabellini [Tue, 4 Dec 2012 13:06:35 +0000 (13:06 +0000)]
libxl: use qemu-xen (upstream QEMU) as device model by default

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: move check for existence of qemuu device model
Ian Jackson [Fri, 1 Mar 2013 17:17:04 +0000 (17:17 +0000)]
libxl: move check for existence of qemuu device model

The stat in libxl__domain_build_info_setdefault's default device model
logic works to fall back to qemu-xen-traditional whenever the
executable for qemu-xen is not found.

We are going to use qemu-xen-traditional in more cases, so break this
check out into its own if statement.

Also add a pair of braces to make the if() statement symmetrical.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
12 years agolibxl: move libxl_device_action to idl
Roger Pau Monne [Wed, 23 Jan 2013 17:55:39 +0000 (17:55 +0000)]
libxl: move libxl_device_action to idl

Move to idl for ease of expansion and auto-generated functions.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agolibxl: remove double check in NetBSD hotplug
Roger Pau Monne [Wed, 23 Jan 2013 17:55:44 +0000 (17:55 +0000)]
libxl: remove double check in NetBSD hotplug

Remove a duplicated check performed in libxl__get_hotplug_script_info
for NetBSD

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agolibxl: don't launch more than one tapdisk process for each disk
Roger Pau Monne [Tue, 5 Mar 2013 17:06:29 +0000 (17:06 +0000)]
libxl: don't launch more than one tapdisk process for each disk

When adding a disk don't launch multiple tapdisk instances for the
same disk, if transaction fails in device_disk_add reuse the same
tapdisk for further tries instead of creating a new instance each
time a transaction fails.

Reported-by: Darren Shepherd <darren.s.shepherd@gmail.com>
Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Tested-by: Darren Shepherd <darren.s.shepherd@gmail.com>
12 years agoxen: arm: create dom0 DTB /hypervisor/ node dynamically.
Ian Campbell [Mon, 18 Feb 2013 15:20:36 +0000 (15:20 +0000)]
xen: arm: create dom0 DTB /hypervisor/ node dynamically.

I initially added hypervisor-new and confirmed via /proc/device-model
that the content is the same before changing it to drop and replace
an existing node.

NB: There is an ambiguity in the compatibility property.
linux/arch/arm/boot/dts/xenvm-4.2.dts says "xen,xen-4.2" while
Documentation/devicetree/bindings/arm/xen.txt says "xen,xen-4.3". I have
used the actual hypervisor version as discussed in
http://marc.info/?l=xen-devel&m=135963416631423

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
12 years agoxen: strip xen, multiboot-module nodes from dom0 device tree
Ian Campbell [Mon, 18 Feb 2013 15:20:35 +0000 (15:20 +0000)]
xen: strip xen, multiboot-module nodes from dom0 device tree

These nodes are used by Xen to find the initial modules.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
12 years agoxen: arm: parse modules from DT during early boot.
Ian Campbell [Mon, 18 Feb 2013 15:20:34 +0000 (15:20 +0000)]
xen: arm: parse modules from DT during early boot.

The bootloader should populate /chosen/modules/module@<N>/ for each
module it wishes to pass to the hypervisor. The content of these nodes
is described in docs/misc/arm/device-tree/booting.txt

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
12 years agodtb: correct handling of #address-cells and #size-cells.
Ian Campbell [Mon, 18 Feb 2013 15:20:33 +0000 (15:20 +0000)]
dtb: correct handling of #address-cells and #size-cells.

If a node does not have #*-cells then the parent's value should be
used. Currently we were asssuming zero which is useless.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
12 years agoxen: correct BITS_PER_EVTCHN_WORD on arm
Ian Campbell [Wed, 27 Feb 2013 13:14:54 +0000 (13:14 +0000)]
xen: correct BITS_PER_EVTCHN_WORD on arm

This is always 64-bit on ARM, not BITS_PER_LONG

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agocoverage: fix on ARM
Ian Campbell [Fri, 22 Feb 2013 10:57:40 +0000 (10:57 +0000)]
coverage: fix on ARM

Use a list of pointers to simplify the handling of 32- vs 64-bit.

Also on ARM the section name is ".init_array" and not ".ctors".

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
[ ijc -- tweak whitespace per Frediano's comment ]

12 years agox86/MCA: suppress bank clearing for certain injected events
Jan Beulich [Tue, 12 Mar 2013 14:53:30 +0000 (15:53 +0100)]
x86/MCA: suppress bank clearing for certain injected events

As the bits indicating validity of the ADDR and MISC bank MSRs may be
injected in a way that isn't consistent with what the underlying
hardware implements (while the bank must be valid for injection to
work, the auxiliary MSRs may not be implemented - and hence cause #GP
upon access - if the hardware never sets the corresponding valid bits.

Consequently we need to do the clearing writes only if no value was
interposed for the respective MSR (which also makes sense the other way
around: there's no point in clearing a hardware register when all data
read came from software). Of course this all requires the injection
tool to do things in a consistent way (but that had been a requirement
before already).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Ren Yongjie <yongjie.ren@intel.com>
Acked-by: Liu Jinsong <jinsong.liu@intel.com>
12 years agovpmu intel: pass through cpuid bits when BTS is enabled
Dietmar Hahn [Tue, 12 Mar 2013 14:37:45 +0000 (15:37 +0100)]
vpmu intel: pass through cpuid bits when BTS is enabled

This patch passes the orginal cpuid bits for X86_FEATURE_DTES64 (64-bit
DS Area) and X86_FEATURE_DSCPL (CPL Qualified Debug Store) to the guest
when the BTS feature is switched on. I forgot this when I did this BTS
emulation.

Signed-off-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
12 years agopowernow: add fixups for AMD P-state figures
Konrad Rzeszutek Wilk [Tue, 12 Mar 2013 14:34:22 +0000 (15:34 +0100)]
powernow: add fixups for AMD P-state figures

In the Linux kernel, these two git commits:

f594065faf4f9067c2283a34619fc0714e79a98d
  ACPI: Add fixups for AMD P-state figures
9855d8ce41a7801548a05d844db2f46c3e810166
  ACPI: Check MSR valid bit before using P-state frequencies

Try to fix the the issue that "some AMD systems may round the
frequencies in ACPI tables to 100MHz boundaries. We can obtain the real
frequencies from MSRs, so add a quirk to fix these frequencies up
on AMD systems." (from f594065..)

In discussion (around 9855d8..) "it turned out that indeed real
HW/BIOSes may choose to not set the valid bit and thus mark the
P-state as invalid. So this could be considered a fix for broken
BIOSes." (from 9855d8..)

which is great for Linux. Unfortunatly the Linux kernel, when
it tries to do the RDMSR under Xen it fails to get the right
value (it gets zero) as Xen traps it and returns zero. Hence
when dom0 uploads the P-states they will be unmodified and
we should take care of updating the frequencies with the right
values.

I've tested it under Dell Inc. PowerEdge T105 /0RR825, BIOS 1.3.2
08/20/2008 where this quirk can be observed (x86 == 0x10, model == 2).
Also on other AMD (x86 == 0x12, A8-3850; x86 = 0x14, AMD E-350) to
make sure the quirk is not applied there.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: stefan.bader@canonical.com
Do the MSR access here (and while at it, also the one reading
MSR_PSTATE_CUR_LIMIT) on the target CPU, and bound the loop over
amd_fixup_frequency() by max_hw_pstate (matching the one in
powernow_cpufreq_cpu_init()).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
12 years agommu: Introduce XENMEM_claim_pages (subop of memory ops)
Dan Magenheimer [Mon, 11 Mar 2013 16:13:42 +0000 (16:13 +0000)]
mmu: Introduce XENMEM_claim_pages (subop of memory ops)

When guests memory consumption is volatile (multiple guests
ballooning up/down) we are presented with the problem of
being able to determine exactly how much memory there is
for allocation of new guests without negatively impacting
existing guests. Note that the existing models (xapi, xend)
drive the memory consumption from the tool-stack and assume
that the guest will eventually hit the memory target. Other
models, such as the dynamic memory utilized by tmem, do this
differently - the guest drivers the memory consumption (up
to the d->max_pages ceiling). With dynamic memory model, the
guest frequently can balloon up and down as it sees fit.
This presents the problem to the toolstack that it does not
know atomically how much free memory there is (as the information
gets stale the moment the d->tot_pages information is provided
to the tool-stack), and hence when starting a guest can fail
during the memory creation process. Especially if the process
is done in parallel. In a nutshell what we need is a atomic
value of all domains tot_pages during the allocation of guests.
Naturally holding a lock for such a long time is unacceptable.
Hence the goal of this hypercall is to attempt to atomically and very
quickly determine if there are sufficient pages available in the
system and, if so, "set aside" that quantity of pages for future
allocations by that domain.  Unlike an existing hypercall such as
increase_reservation or populate_physmap, specific physical
pageframes are not assigned to the domain because this
cannot be done sufficiently quickly (especially for very large
allocations in an arbitrarily fragmented system) and so the
existing mechanisms result in classic time-of-check-time-of-use
(TOCTOU) races.  One can think of claiming as similar to a
"lazy" allocation, but subsequent hypercalls are required
to do the actual physical pageframe allocation.

Note that one of effects of this hypercall is that from the
perspective of other running guests -  suddenly there is
a new guest occupying X amount of pages. This means that when
we try to balloon up they will hit the system-wide ceiling of
available free memory (if the total sum of the existing d->max_pages
>= host memory). This is OK - as that is part of the overcommit.
What we DO NOT want to do is dictate their ceiling should be
(d->max_pages) as that is risky and can lead to guests OOM-ing.
It is something the guest needs to figure out.

In order for a toolstack to "get" information about whether
a domain has a claim and, if so, how large, and also for
the toolstack to measure the total system-wide claim, a
second subop has been added and exposed through domctl
and libxl (see "xen: XENMEM_claim_pages: xc").

== Alternative solutions ==
There has been a variety of discussion whether the problem
hypercall is solving can be done in user-space, such as:
 - For all the existing guest, set their d->max_pages temporarily
   to d->tot_pages and create the domain. This forces those
   domains to stay at their current consumption level (fyi, this is what
   the tmem freeze call is doing). The disadvantage of this is
   that needlessly forces the guests to stay at the memory usage
   instead of allowing it to decide the optimal target.
 - Account only using d->max_pages of how much free memory there is.
   This ignores ballooning changes and any over-commit scenario. This
   is similar to the scenario where the sum of all d->max_pages (and
   the one to be allocated now) on the host is smaller than the available
   free memory. As such it ignores the over-commit problem.
 - Provide a ring/FIFO along with event channel to notify an userspace
   daemon of guests memory consumption. This daemon can then provide
   up-to-date information to the toolstack of how much free memory
   there is. This duplicates what the hypervisor is already doing and
   introduced latency issues and catching breath for the toolstack as there
   might be millions of these updates on heavily used machine. There might
   not be any quiescent state ever and the toolstack will heavily consume
   CPU cycles and not ever provide up-to-date information.

It has been noted that this claim mechanism solves the
underlying problem (slow failure of domain creation) for
a large class of domains but not all, specifically not
handling (but also not making the problem worse for) PV
domains that specify the "superpages" flag, and 32-bit PV
domains on large RAM systems.  These will be addressed at a
later time.

Code overview:

Though the hypercall simply does arithmetic within locks,
some of the semantics in the code may be a bit subtle.

The key variables (d->unclaimed_pages and total_unclaimed_pages)
starts at zero if no claim has yet been staked for any domain.
(Perhaps a better name is "claimed_but_not_yet_possessed" but that's
a bit unwieldy.)  If no claim hypercalls are executed, there
should be no impact on existing usage.

When a claim is successfully staked by a domain, it is like a
watermark but there is no record kept of the size of the claim.
Instead, d->unclaimed_pages is set to the difference between
d->tot_pages and the claim.  When d->tot_pages increases or decreases,
d->unclaimed_pages atomically decreases or increases.  Once
d->unclaimed_pages reaches zero, the claim is satisfied and
d->unclaimed pages stays at zero -- unless a new claim is
subsequently staked.

The systemwide variable total_unclaimed_pages is always the sum
of d->unclaimed_pages, across all domains.  A non-domain-
specific heap allocation will fail if total_unclaimed_pages
exceeds free (plus, on tmem enabled systems, freeable) pages.

Claim semantics could be modified by flags.  The initial
implementation had three flag, which discerns whether the
caller would like tmem freeable pages to be considered
in determining whether or not the claim can be successfully
staked. This in later patches was removed and there are no
flags.

A claim can be cancelled by requesting a claim with the
number of pages being zero.

A second subop returns the total outstanding claimed pages
systemwide.

Note: Save/restore/migrate may need to be modified,
else it can be documented that all claims are cancelled.

This patch of the proposed XENMEM_claim_pages hypercall/subop, takes
into account review feedback from Jan and Keir and IanC and Matthew Daley,
plus some fixes found via runtime debugging.

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: Keir Fraser <keir@xen.org>
12 years agocredit2: Reset until the front of the runqueue is positive
George Dunlap [Mon, 11 Mar 2013 08:57:11 +0000 (09:57 +0100)]
credit2: Reset until the front of the runqueue is positive

Under normal circumstances, snext->credit should never be less than
-CSCHED_MIN_TIMER.  However, under some circumstances, a vcpu with low
credits may be allowed to run long enough that its credits are
actually less than -CSCHED_CREDIT_INIT.

(Instances have been observed, for example, where a vcpu with 200us of
credit was allowed to run for 11ms, giving it -10.8ms of credit.  Thus
it was still negative even after the reset.)

If this is the case for snext, we simply want to keep moving everyone
up until it is in the black again.  This fair because none of the
other vcpus want to run at the moment.

Rather than loop, just detect how many times we want to add
CSCHED_CREDIT_INIT.  Try to avoid integer divides and multiplies in
the common case.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>