]> xenbits.xensource.com Git - xen.git/log
xen.git
12 years agox86: don't pass negative time to gtime_to_gtsc()
Jan Beulich [Thu, 18 Apr 2013 13:25:07 +0000 (15:25 +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>
master commit: eb60be3dd870aecfa47bed1118069680389c15f7
master date: 2013-04-11 12:07:55 +0200

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>
(cherry picked from commit a5c800142cfc82159fcb85b47116cf296caebcc5)

12 years agolibxl: don't launch more than one tapdisk process for each disk
Ian Jackson [Mon, 15 Apr 2013 17:04:35 +0000 (18:04 +0100)]
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>
Backport-requested-by: Pasi Karkkainen <pasik@iki.fi>
(cherry picked from commit ec398660e89ca18bb8d061d5047d682bd383778a)
Conflicts:
tools/libxl/libxl.c
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agoupdate Xen version to 4.2.2-rc2 4.2.2-rc2
Jan Beulich [Fri, 12 Apr 2013 11:41:19 +0000 (13:41 +0200)]
update Xen version to 4.2.2-rc2

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>
(cherry picked from commit 6cffb2b469a55032a2900ccb8776c0082f346758)

12 years agolibxl: run libxl__arch_domain_create() much earlier.
Ian Jackson [Tue, 9 Apr 2013 14:44:07 +0000 (15:44 +0100)]
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>
(Cherry-picked from 650354dbc2626b643c12873275ca67782f1382c8.)

Conflicts:
tools/libxl/libxl_dom.c
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agox86/mm/shadow: spurious warning when unmapping xenheap pages.
Tim Deegan [Tue, 9 Apr 2013 14:07:23 +0000 (16:07 +0200)]
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>
master commit: cfc515dabe91e3d6c690c68c6a669d6d77fb7ac4
master date: 2013-04-04 10:14:30 +0100

12 years agoVMX: Always disable SMEP when guest is in non-paging mode
Stefan Bader [Tue, 9 Apr 2013 14:06:44 +0000 (16:06 +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>
master commit: 0d2e673a763bc7c2ddf97fed074eb691d325ecc5
master date: 2013-04-04 10:37:19 +0200

12 years agox86/S3: Restore broken vcpu affinity on resume
Ben Guthro [Tue, 9 Apr 2013 14:05:52 +0000 (16:05 +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>
master commit: 41e71c2607e036f1ac00df898b8f4acb2d4df7ee
master date: 2013-04-02 09:52:32 +0200

12 years agox86: irq_move_cleanup_interrupt() must ignore legacy vectors
Jan Beulich [Tue, 9 Apr 2013 14:04:25 +0000 (16:04 +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>
master commit: af699220ad6d111ba76fc3040342184e423cc9a1
master date: 2013-04-02 08:30:03 +0200

12 years agodefer event channel bucket pointer store until after XSM checks
Jan Beulich [Fri, 5 Apr 2013 08:02:05 +0000 (10:02 +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>
master commit: 99b9ab0b3e7f0e7e5786116773cb7b746f3fab87
master date: 2013-04-05 09:59:03 +0200

12 years agohvm: Clean up vlapic_reg_write() error propagation.
Keir Fraser [Tue, 2 Apr 2013 09:26:10 +0000 (11:26 +0200)]
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>
master changeset: 5082cc19524b6687ef1bc0a717538d75aae7cd00
master date: 2013-03-28 20:16:37 +0000

12 years agox86/EFI: permit setting variable with non-zero attributes
Jan Beulich [Tue, 2 Apr 2013 09:23:05 +0000 (11:23 +0200)]
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>
master changeset: 78380c34dfeb27da3d0222bcb7232c5d8e2f5b30
master date: 2013-03-27 08:46:28 +0100

12 years agox86: reserve pages when SandyBridge integrated graphics
Xudong Hao [Tue, 2 Apr 2013 09:21:55 +0000 (11:21 +0200)]
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>
master changeset: db537fe3023bf157b85c8246782cb72a6f989b31
master date: 2013-03-26 14:22:07 +0100

12 years agoACPI: fix APEI related table size checking
Huang Ying [Tue, 2 Apr 2013 09:02:30 +0000 (11:02 +0200)]
ACPI: fix APEI related table size checking

On Huang Ying's machine:

erst_tab->header_length == sizeof(struct acpi_table_einj)

but Yinghai reported that on his machine,

erst_tab->header_length == sizeof(struct acpi_table_einj) -
sizeof(struct acpi_table_header)

To make erst table size checking code works on all systems, both
testing are treated as PASS.

Same situation applies to einj_tab->header_length, so corresponding
table size checking is changed in similar way too.

Originally-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Huang Ying <ying.huang@intel.com>
- use switch() for better readability
- add comment explaining why a formally invalid size it also being
  accepted
- check erst_tab->header.length before even looking at
  erst_tab->header_length
- prefer sizeof(*erst_tab) over sizeof(struct acpi_table_erst)

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
master changeset: 915ef37d7cc8fcac5b37eb0b40c693754fcd12ab
master date: 2012-10-16 17:26:36 +0200

12 years agoACPI, APEI: Add apei_exec_run_optional
Huang Ying [Tue, 2 Apr 2013 09:01:40 +0000 (11:01 +0200)]
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>
master changeset: 72af01bf6f7489e54ad59270222a29d3e8c501d1
master date: 2013-03-22 12:46:25 +0100

12 years agoACPI/APEI: Unlock apei_iomaps_lock on error path
Andrew Cooper [Tue, 2 Apr 2013 09:00:22 +0000 (11:00 +0200)]
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>
master changeset: 0611689d9153227831979c7bafe594214b8505a3
master date: 2013-03-22 09:43:38 +0100

12 years agoACPI/ERST: Name table in otherwise opaque error messages
Andrew Cooper [Tue, 2 Apr 2013 08:59:34 +0000 (10:59 +0200)]
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>
master changeset: 759847e44401176401e86e7c55b644cb9f93c781
master date: 2013-03-20 10:02:52 +0100

12 years agoACPI/APEI: fix ERST MOVE_DATA instruction implementation
Huang Ying [Tue, 2 Apr 2013 08:58:31 +0000 (10:58 +0200)]
ACPI/APEI: fix ERST MOVE_DATA instruction implementation

The src_base and dst_base fields in apei_exec_context are physical
address, so they should be ioremaped before being used in ERST
MOVE_DATA instruction.

Reported-by: Javier Martinez Canillas <martinez.javier@gmail.com>
Reported-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Huang Ying <ying.huang@intel.com>
Replace use of ioremap() by __acpi_map_table()/set_fixmap(). Fix error
handling.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
master changeset: df2cf6a726b815fafa12e503c9a36707c3962f22
master date: 2012-10-17 14:12:06 +0200

12 years agoAMD IOMMU: allow disabling only interrupt remapping when certain IVRS consistency...
Jan Beulich [Tue, 2 Apr 2013 08:52:26 +0000 (10:52 +0200)]
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>
master changeset: 92b8bc03bd4b582cb524db51494d0dba7607e7ac
master date: 2013-03-25 16:55:22 +0100

12 years agoVT-d: deal with 5500/5520/X58 errata
Malcolm Crossley [Tue, 2 Apr 2013 08:51:40 +0000 (10:51 +0200)]
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>
master changeset: 6890cebc6a987d0e896f5d23a8de11a3934101cf
master date: 2013-03-25 14:31:27 +0100

12 years agoIOMMU: properly check whether interrupt remapping is enabled
Jan Beulich [Tue, 2 Apr 2013 08:50:52 +0000 (10:50 +0200)]
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 (removed from the
backport).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: "Zhang, Xiantao" <xiantao.zhang@intel.com>
master changeset: fae0372140befb88d890a30704a8ec058c902af8
master date: 2013-03-25 14:28:31 +0100

12 years agoVT-d: Enumerate IOMMUs when listing capabilities
Andrew Cooper [Tue, 2 Apr 2013 08:49:26 +0000 (10:49 +0200)]
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>
master changeset: 32861c537781ac94bf403fb778505c3679b85f67
master date: 2013-03-20 10:02:26 +0100

12 years agoAMD/IOMMU: Process softirqs while building dom0 iommu mappings
Andrew Cooper [Tue, 2 Apr 2013 08:48:36 +0000 (10:48 +0200)]
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>
master changeset: 0f7b6f91ac1bbfd33b23c291b14874b9561909d2
master date: 2013-03-20 10:00:01 +0100

12 years agox86/MCA: suppress bank clearing for certain injected events
Jan Beulich [Tue, 2 Apr 2013 08:47:26 +0000 (10:47 +0200)]
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>
master changeset: b0583c0e64cc8bb6229c95c3304fdac2051f79b3
master date: 2013-03-12 15:53:30 +0100

12 years agopowernow: add fixups for AMD P-state figures
Konrad Rzeszutek Wilk [Tue, 2 Apr 2013 08:45:30 +0000 (10:45 +0200)]
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>
master changeset: 1d80765b504b34b63a42a63aff4291e07e29f0c5
master date: 2013-03-12 15:34:22 +0100

12 years agoupdate Xen version to 4.2.2-rc1 4.2.2-rc1
Jan Beulich [Wed, 20 Mar 2013 13:01:51 +0000 (14:01 +0100)]
update Xen version to 4.2.2-rc1

12 years agox86/MSI: add mechanism to fully protect MSI-X table from PV guest accesses
Jan Beulich [Tue, 12 Mar 2013 15:19:30 +0000 (16:19 +0100)]
x86/MSI: add mechanism to fully protect MSI-X table from PV guest accesses

This adds two new physdev operations for Dom0 to invoke when resource
allocation for devices is known to be complete, so that the hypervisor
can arrange for the respective MMIO ranges to be marked read-only
before an eventual guest getting such a device assigned even gets
started, such that it won't be able to set up writable mappings for
these MMIO ranges before Xen has a chance to protect them.

This also addresses another issue with the code being modified here,
in that so far write protection for the address ranges in question got
set up only once during the lifetime of a device (i.e. until either
system shutdown or device hot removal), while teardown happened when
the last interrupt was disposed of by the guest (which at least allowed
the tables to be writable when the device got assigned to a second
guest [instance] after the first terminated).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
master changeset: 4245d331e0e75de8d1bddbbb518f3a8ce6d0bb7e
master date: 2013-03-08 14:05:34 +0100

12 years agofix domain unlocking in some xsm error paths
Matthew Daley [Tue, 12 Mar 2013 15:18:45 +0000 (16:18 +0100)]
fix domain unlocking in some xsm error paths

A couple of xsm error/access-denied code paths in hypercalls neglect to
unlock a previously locked domain. Fix by ensuring the domains are
unlocked correctly.

Signed-off-by: Matthew Daley <mattjd@gmail.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
master changeset: 9581c4f9a55372a21e759cd449cb676d0e8feddb
master date: 2013-03-06 17:10:26 +0100

12 years agoxentrace: fix off-by-one in calculate_tbuf_size
Olaf Hering [Tue, 12 Mar 2013 15:18:02 +0000 (16:18 +0100)]
xentrace: fix off-by-one in calculate_tbuf_size

Commit "xentrace: reduce trace buffer size to something mfn_offset can
reach" contains an off-by-one bug. max_mfn_offset needs to be reduced by
exactly the value of t_info_first_offset.

If the system has two cpus and the number of requested trace pages is
very large, the final number of trace pages + the offset will not fit
into a short. As a result the variable offset in alloc_trace_bufs() will
wrap while allocating buffers for the second cpu. Later
share_xen_page_with_privileged_guests() will be called with a wrong page
and the ASSERT in this function triggers. If the ASSERT is ignored by
running a non-dbg hypervisor the asserts in xentrace itself trigger
because "cons" is not aligned because the very last trace page for the
second cpu is a random mfn.

Thanks to Jan for the quick analysis.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
master changeset: d9fb28ae6d41c8201482948660e52889481830dd
master date: 2013-03-04 13:42:17 +0100

12 years agocredit1: Use atomic bit operations for the flags structure
George Dunlap [Tue, 12 Mar 2013 15:17:23 +0000 (16:17 +0100)]
credit1: Use atomic bit operations for the flags structure

The flags structure is not protected by locks (or more precisely,
it is protected using an inconsistent set of locks); we therefore need
to make sure that all accesses are atomic-safe.  This is particulary
important in the case of the PARKED flag, which if clobbered while
changing the YIELD bit will leave a vcpu wedged in an offline state.

Using the atomic bitops also requires us to change the size of the "flags"
element.

Spotted-by: Igor Pavlikevich <ipavlikevich@gmail.com>
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
master changeset: be6507509454adf3bb5a50b9406c88504e996d5a
master date: 2013-03-04 13:37:39 +0100

12 years agox86: defer processing events on the NMI exit path
Jan Beulich [Tue, 12 Mar 2013 15:16:41 +0000 (16:16 +0100)]
x86: defer processing events on the NMI exit path

Otherwise, we may end up in the scheduler, keeping NMIs masked for a
possibly unbounded period of time (until whenever the next IRET gets
executed). Enforce timely event processing by sending a self IPI.

Of course it's open for discussion whether to always use the straight
exit path from handle_ist_exception.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
master changeset: d463b005bbd6475ed930a302821efe239e1b2cf9
master date: 2013-03-04 10:19:34 +0100

12 years agoSEDF: avoid gathering vCPU-s on pCPU0
Jan Beulich [Tue, 12 Mar 2013 15:15:18 +0000 (16:15 +0100)]
SEDF: avoid gathering vCPU-s on pCPU0

The introduction of vcpu_force_reschedule() in 14320:215b799fa181 was
incompatible with the SEDF scheduler: Any vCPU using
VCPUOP_stop_periodic_timer (e.g. any vCPU of half way modern PV Linux
guests) ends up on pCPU0 after that call. Obviously, running all PV
guests' (and namely Dom0's) vCPU-s on pCPU0 causes problems for those
guests rather sooner than later.

So the main thing that was clearly wrong (and bogus from the beginning)
was the use of cpumask_first() in sedf_pick_cpu(). It is being replaced
by a construct that prefers to put back the vCPU on the pCPU that it
got launched on.

However, there's one more glitch: When reducing the affinity of a vCPU
temporarily, and then widening it again to a set that includes the pCPU
that the vCPU was last running on, the generic scheduler code would not
force a migration of that vCPU, and hence it would forever stay on the
pCPU it last ran on. Since that can again create a load imbalance, the
SEDF scheduler wants a migration to happen regardless of it being
apparently unnecessary.

Of course, an alternative to checking for SEDF explicitly in
vcpu_set_affinity() would be to introduce a flags field in struct
scheduler, and have SEDF set a "always-migrate-on-affinity-change"
flag.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
12 years agox86: make certain memory sub-ops return valid values
Jan Beulich [Tue, 12 Mar 2013 15:13:54 +0000 (16:13 +0100)]
x86: make certain memory sub-ops return valid values

When a domain's shared info field "max_pfn" is zero,
domain_get_maximum_gpfn() so far returned ULONG_MAX, which
do_memory_op() in turn converted to -1 (i.e. -EPERM). Make the former
always return a sensible number (i.e. zero if the field was zero) and
have the latter no longer truncate return values.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
master changeset: 7ffc9779aa5120c5098d938cb88f69a1dda9a0fe
master date: 2013-03-04 10:16:04 +0100

12 years agofix compat memory exchange op splitting
Jan Beulich [Tue, 12 Mar 2013 15:12:52 +0000 (16:12 +0100)]
fix compat memory exchange op splitting

A shift with a negative count was erroneously used here, yielding
undefined behavior.

Reported-by: Xi Wang <xi@mit.edu>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
master changeset: 53decd322157e922cac2988e07da6d39538c8033
master date: 2013-03-01 16:59:49 +0100

12 years agoAvoid stale pointer when moving domain to another cpupool
Juergen Gross [Tue, 12 Mar 2013 15:11:55 +0000 (16:11 +0100)]
Avoid stale pointer when moving domain to another cpupool

When a domain is moved to another cpupool the scheduler private data pointers
in vcpu and domain structures must never point to an already freed memory
area.

While at it, simplify sched_init_vcpu() by using DOM2OP instead VCPU2OP.

Signed-off-by: Juergen Gross <juergen.gross@ts.fujitsu.com>
master changeset: 482300def7d08e773ccd2a0d978bcb9469fdd810
master date: 2013-02-28 14:56:45 +0000

12 years agovmx: fix handling of NMI VMEXIT.
Tim Deegan [Tue, 12 Mar 2013 15:10:23 +0000 (16:10 +0100)]
vmx: fix handling of NMI VMEXIT.

Call do_nmi() directly and explicitly re-enable NMIs rather than
raising an NMI through the APIC. Since NMIs are disabled after the
VMEXIT, the raised NMI would be blocked until the next IRET
instruction (i.e. the next real interrupt, or after scheduling a PV
guest) and in the meantime the guest will spin taking NMI VMEXITS.

Also, handle NMIs before re-enabling interrupts, since if we handle an
interrupt (and therefore IRET) before calling do_nmi(), we may end up
running the NMI handler with NMIs enabled.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
master changeset: 7dd3b06ff031c9a8c727df16c5def2afb382101c
master date: 2013-02-28 14:00:18 +0000

12 years agoQEMU_UPSTREAM_REVISION update
Ian Jackson [Fri, 8 Mar 2013 15:27:07 +0000 (15:27 +0000)]
QEMU_UPSTREAM_REVISION update

12 years agox86/setup: don't relocate the VGA hole.
Tim Deegan [Fri, 8 Mar 2013 09:56:24 +0000 (10:56 +0100)]
x86/setup: don't relocate the VGA hole.

Copying the contents of the VGA hole is at best pointless and at worst
dangerous.  Booting Xen on Xen, it causes a very long delay as each
byte is referred to qemu.

Since we were already discarding the first 1MB of the relocated area,
just avoid copying it in the first place.

Reported-by: Jon Ludlam <jonathan.ludlam@eu.citrix.com>
Signed-off-by: Tim Deegan <tim@xen.org>
master changeset: 0b76ce20de85ad7c23c47ee3275020859b91d46b
master date: 2013-02-14 12:20:58 +0000

12 years agox86: fix CMCI injection
Jan Beulich [Thu, 7 Mar 2013 17:01:13 +0000 (18:01 +0100)]
x86: fix CMCI injection

This fixes the wrong use of literal vector 0xF7 with an "int"
instruction (invalidated by 25113:14609be41f36) and the fact that doing
the injection via a software interrupt was never valid anyway (because
cmci_interrupt() acks the LAPIC, which does the wrong thing if the
interrupt didn't get delivered though it).

In order to do latter, the patch introduces send_IPI_self(), at once
removing two opend coded uses of "genapic" in the IRQ handling code.

Reported-by: Yongjie Ren <yongjie.ren@intel.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Yongjie Ren <yongjie.ren@intel.com>
Acked-by: Keir Fraser <keir@xen.org>
master changeset: 2f8c55ccefe49bb526df0eaf5fa9b7b788422208
master date: 2013-02-26 10:15:56 +0100

12 years agoIOMMU, AMD Family15h Model10-1Fh erratum 746 Workaround
Suravee Suthikulpanit [Thu, 7 Mar 2013 17:00:23 +0000 (18:00 +0100)]
IOMMU, AMD Family15h Model10-1Fh erratum 746 Workaround

The IOMMU may stop processing page translations due to a perceived lack
of credits for writing upstream peripheral page service request (PPR)
or event logs. If the L2B miscellaneous clock gating feature is enabled
the IOMMU does not properly register credits after the log request has
completed, leading to a potential system hang.

BIOSes are supposed to disable L2B micellaneous clock gating by setting
L2_L2B_CK_GATE_CONTROL[CKGateL2BMiscDisable](D0F2xF4_x90[2]) = 1b. This
patch corrects that for those which do not enable this workaround.

Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
master changeset: 0f8adcb2a7183bea5063f6fffba7d7e1aa14fc84
master date: 2013-02-26 10:14:53 +0100

12 years agox86: fix null pointer dereference in intel_get_extended_msrs()
Xi Wang [Thu, 7 Mar 2013 16:59:21 +0000 (17:59 +0100)]
x86: fix null pointer dereference in intel_get_extended_msrs()

`memset(&mc_ext, 0, ...)' leads to a buffer overflow and a subsequent
null pointer dereference.  Replace `&mc_ext' with `mc_ext'.

Signed-off-by: Xi Wang <xi@mit.edu>
master changeset: c40e24a8ef74f9d0ee59dd9b8ca890be08b0b874
master date: 2013-02-25 12:44:25 +0100

12 years agohonor ACPI v4 FADT flags
Jan Beulich [Thu, 7 Mar 2013 16:58:19 +0000 (17:58 +0100)]
honor ACPI v4 FADT flags

- force use of physical APIC mode if indicated so (as we don't support
  xAPIC cluster mode, the respective flag is taken to force physical
  mode too)
- don't use MSI if indicated so (implies no IOMMU)

Both can be overridden on the command line, for the MSI case this at
once adds a new command line option allowing to turn off PCI MSI (IOMMU
and HPET are unaffected by this).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
master changeset: 992fdf6f46252a459c6b1b8d971b2c71f01460f8
master date: 2013-02-22 11:56:54 +0100

12 years agox86/nhvm: properly clean up after failure to set up all vCPU-s
Jan Beulich [Thu, 7 Mar 2013 16:57:02 +0000 (17:57 +0100)]
x86/nhvm: properly clean up after failure to set up all vCPU-s

Otherwise we may leak memory when setting up nHVM fails half way.

This implies that the individual destroy functions will have to remain
capable (in the VMX case they first need to be made so, following
26486:7648ef657fe7 and 26489:83a3fa9c8434) of being called for a vCPU
that the corresponding init function was never run on.

Once at it, also remove a redundant check from the corresponding
parameter validation code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
Tested-by: Olaf Hering <olaf@aepfle.de>
master changeset: 17281aea1a9a10f1ee165c6e6a2921a67b7b1df2
master date: 2013-02-22 11:21:38 +0100

12 years agox86/mm: Take the p2m lock even in shadow mode.
Tim Deegan [Thu, 7 Mar 2013 16:55:16 +0000 (17:55 +0100)]
x86/mm: Take the p2m lock even in shadow mode.

The reworking of p2m lookups to use get_gfn()/put_gfn() left the
shadow code not taking the p2m lock, even in cases where the p2m would
be updated (i.e. PoD).

In many cases, shadow code doesn't need the exclusion that
get_gfn()/put_gfn() provides, as it has its own interlocks against p2m
updates, but this is taking things too far, and can lead to crashes in
the PoD code.

Now that most shadow-code p2m lookups are done with explicitly
unlocked accessors, or with the get_page_from_gfn() accessor, which is
often lock-free, we can just turn this locking on.

The remaining locked lookups are in sh_page_fault() (in a path that's
almost always already serializing on the paging lock), and in
emulate_map_dest() (which can probably be updated to use
get_page_from_gfn()).  They're not addressed here but may be in a
follow-up patch.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
master changeset: a15d87475ed95840dba693ab0a56d0b48a215cbc
master date: 2013-02-21 15:16:20 +0000

12 years agotools/libxl: Improve videoram setting
Fabio Fantoni [Fri, 1 Mar 2013 13:22:21 +0000 (13:22 +0000)]
tools/libxl: Improve videoram setting

- If videoram setting is less than 8 mb shows error and exit.
- Added videoram setting for qemu upstream with cirrus (added in qemu 1.3).
- Updated xl.cfg man.
- Default and minimal videoram changed to 16 mb if stdvga is set and upstream
  qemu is being used. This is required by qemu 1.4 to avoid a xen memory error
  (qemu 1.3 doesn't complain about it, probably buggy).

Signed-off-by: Fabio Fantoni <fabio.fantoni@heliman.it>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
Cherry picked from xen-unstable 2e814a017155b885e4d4b5a88dc05e7367a9722a,
backport as follows:

Signed-off-by: Fabio Fantoni <fabio.fantoni@heliman.it>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agotools: Fix memset(&p,0,sizeof(p)) idiom in several places.
Michael Young [Wed, 13 Feb 2013 17:00:15 +0000 (17:00 +0000)]
tools: Fix memset(&p,0,sizeof(p)) idiom in several places.

gcc 4.8 identifies several places where code of the form memset(x, 0,
sizeof(x)); is used incorrectly, meaning that less memory is set to
zero than required.

Signed-off-by: Michael Young <m.a.young@durham.ac.uk>
Committed-by: Keir Fraser <keir@xen.org>
(cherry picked from commit d119301b5816b39b5ba722a2f8b301b37e8e34bd)

12 years agox86_32: fix acpi_dmar_init()
Jan Beulich [Mon, 25 Feb 2013 12:20:22 +0000 (13:20 +0100)]
x86_32: fix acpi_dmar_init()

map_pages_to_xen() can't be used here on x86_32, need to use up to 2
newly introduced fixmap entries for this instead.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
12 years agolibxl: fix stale timeout event callback race
Ian Jackson [Wed, 23 Jan 2013 16:53:11 +0000 (16:53 +0000)]
libxl: fix stale timeout event callback race

Because there is not necessarily any lock held at the point the
application (eg, libvirt) calls libxl_osevent_occurred_timeout, in a
multithreaded program those calls may be arbitrarily delayed in
relation to other activities within the program.

Specifically this means when ->timeout_deregister returns, libxl does
not know whether it can safely dispose of the for_libxl value or
whether it needs to retain it in case of an in-progress call to
_occurred_timeout.

The interface could be fixed by requiring the application to make a
new call into libxl to say that the deregistration was complete.

However that new call would have to be threaded through the
application's event loop; this is complicated and some application
authors are likely not to implement it properly.  Furthermore the
easiest way to implement this facility in most event loops is to queue
up a time event for "now".

Shortcut all of this by having libxl always call timeout_modify
setting abs={0,0} (ie, ASAP) instead of timeout_deregister.  This will
cause the application to call _occurred_timeout.  When processing this
calldown we see that we were no longer actually interested and simply
throw it away.

Additionally, there is a race between _occurred_timeout and
->timeout_modify.  If libxl ever adjusts the deadline for a timeout
the application may already be in the process of calling _occurred, in
which case the situation with for_app's lifetime becomes very
complicated.  Therefore abolish libxl__ev_time_modify_{abs,rel} (which
have no callers) and promise to the application only ever to call
->timeout_modify with abs=={0,0}.  The application still needs to cope
with ->timeout_modify racing with its internal function which calls
_occurred_timeout.  Document this.

This is a forwards-compatible change for applications using the libxl
API, and will hopefully eliminate these races in callback-supplying
applications (such as libvirt) without the need for corresponding
changes to the application.  (It is possible that this might expose
bugs in applications, though, as previously libxl would never call
libxl_osevent_hooks->timeout_modify and now it never calls
->timeout_deregister).

For clarity, fold the body of time_register_finite into its one
remaining call site.  This makes the semantics of ev->infinite
slightly clearer.

Cc: Bamvor Jian Zhang <bjzhang@suse.com>
Cc: Ian Campbell <Ian.Campbell@citrix.com>
Tested-by: Jim Fehlig <jfehlig@suse.com>
Acked-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agolibxl: fix stale fd event callback race
Ian Jackson [Wed, 23 Jan 2013 16:53:11 +0000 (16:53 +0000)]
libxl: fix stale fd event callback race

Because there is not necessarily any lock held at the point the
application (eg, libvirt) calls libxl_osevent_occurred_timeout and
..._fd, in a multithreaded program those calls may be arbitrarily
delayed in relation to other activities within the program.

libxl therefore needs to be prepared to receive very old event
callbacks.  Arrange for this to be the case for fd callbacks.

This requires a new layer of indirection through a "hook nexus" struct
which can outlive the libxl__ev_foo.  Allocation and deallocation of
these nexi is mostly handled in the OSEVENT macros which wrap up
the application's callbacks.

Document the problem and the solution in a comment in libxl_event.c
just before the definition of struct libxl__osevent_hook_nexus.

There is still a race relating to libxl__osevent_occurred_timeout;
this will be addressed in the following patch.

Reported-by: Bamvor Jian Zhang <bjzhang@suse.com>
Cc: Bamvor Jian Zhang <bjzhang@suse.com>
Cc: Ian Campbell <Ian.Campbell@citrix.com>
Tested-by: Jim Fehlig <jfehlig@suse.com>
Acked-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Backport-requested-by: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Backported-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agolibxl: rename "abs" variables to "absolute"
Ian Jackson [Wed, 23 Jan 2013 16:53:10 +0000 (16:53 +0000)]
libxl: rename "abs" variables to "absolute"

No functional change.

The purpose is to make it easier to backport patches from Xen 4.3's
libxl, as Xen 4.3's libxl has had this done:

    libxl: Enable -Wshadow.

    It was convenient to invent $(CFLAGS_LIBXL) to do this.

    Various renamings to avoid shadowing standard functions:
      - index(3)
      - listen(2)
      - link(2)
      - abort(3)
      - abs(3)

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
In this patch we do not change the others, and we do not enable
-Wshadow.  We're just trying to bring 4.2's libxl textually closer to
4.3's.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agoQEMU_UPSTREAM_REVISION update
Ian Jackson [Fri, 22 Feb 2013 17:57:45 +0000 (17:57 +0000)]
QEMU_UPSTREAM_REVISION update

12 years agoRevert "tools/libxc/xtl: fix logic error in stdiostream_progress"
Ian Jackson [Fri, 22 Feb 2013 17:06:51 +0000 (17:06 +0000)]
Revert "tools/libxc/xtl: fix logic error in stdiostream_progress"

This reverts commit 67ef1d1fff26ce249dacbd44b756e56953b6599f.

There is probably nothing wrong with this but I send it to 4.2 by
mistake.  Revert it for now until it has had a chance in unstable.

12 years agotools/libxc/xtl: fix logic error in stdiostream_progress
Olaf Hering [Wed, 13 Feb 2013 15:57:54 +0000 (15:57 +0000)]
tools/libxc/xtl: fix logic error in stdiostream_progress

Setting XTL_STDIOSTREAM_HIDE_PROGRESS should disable progress reporting.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
12 years agoAMD IOMMU: don't BUG() when we don't have to
Jan Beulich [Fri, 22 Feb 2013 12:45:28 +0000 (13:45 +0100)]
AMD IOMMU: don't BUG() when we don't have to

find_iommu_for_device() can easily return NULL instead, as all of its
callers are prepared for that.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
master changeset: f547d42ec0306cdceffb8f7603c7e6f8977cf398
master date: 2013-02-18 09:37:35 +0100

12 years agoxenoprof: avoid division by 0
Tim Deegan [Fri, 22 Feb 2013 12:44:53 +0000 (13:44 +0100)]
xenoprof: avoid division by 0

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
master changeset: 085f1f2d3aee1a35dfc7ca2f4423e51fa654010c
master date: 2013-02-15 09:42:02 +0100

12 years agogcc4.8 build fix: Add -Wno-unused-local-typedefs to CFLAGS.
Keir Fraser [Fri, 22 Feb 2013 12:41:09 +0000 (13:41 +0100)]
gcc4.8 build fix: Add -Wno-unused-local-typedefs to CFLAGS.

Based on a patch by M A Young <m.a.young@durham.ac.uk>

Signed-off-by: Keir Fraser <keir@xen.org>
master changeset: 511278b4e239df00de7b33f7b42d8d5d7e52221b
master date: 2013-02-13 17:03:31 +0000

12 years agolibxl: Allow migration with qemu-xen.
Alex Bligh [Tue, 19 Feb 2013 15:25:18 +0000 (15:25 +0000)]
libxl: Allow migration with qemu-xen.

Backport of xen-unstable patch:
: HG changeset patch
: User Anthony PERARD <anthony.perard@citrix.com>
: Date 1349693136 -3600
: Node ID 0995890022391682a2499a202c3c8608e1d3780a
: Parent  08fac5c2bf3dcbc493ce45091383f6ce1938f369
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
12 years agolibxl: libxl__qmp_save: Add filename as JSON parameter to xen-save-devices-state...
Alex Bligh [Tue, 19 Feb 2013 15:25:18 +0000 (15:25 +0000)]
libxl: libxl__qmp_save: Add filename as JSON parameter to xen-save-devices-state Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
12 years agolibxl_dom: Call the right switch logdirty for the right DM.
Alex Bligh [Tue, 19 Feb 2013 15:25:16 +0000 (15:25 +0000)]
libxl_dom: Call the right switch logdirty for the right DM.

This patch dispatch the switch logdirty call depending on which device model
version is running.

The call to qemu-xen right now is synchronous, not like the one to
qemu-xen-traditional.

Backport of xen-unstable patch:
: HG changeset patch
: User Anthony PERARD <anthony.perard@citrix.com>
: Date 1349693136 -3600
: Node ID 08fac5c2bf3dcbc493ce45091383f6ce1938f369
: Parent  d4aec9eff7e6d15c2805957af620c82555553b3e
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
12 years agolibxl_qmp: Introduce libxl__qmp_set_global_dirty_log.
Alex Bligh [Tue, 19 Feb 2013 15:25:16 +0000 (15:25 +0000)]
libxl_qmp: Introduce libxl__qmp_set_global_dirty_log.

This function will enable or disable the global dirty log on QEMU,
used during a migration.

Backport of xen-unstable patch:
: HG changeset patch
: User Anthony PERARD <anthony.perard@citrix.com>
: Date 1349693135 -3600
: Node ID d4aec9eff7e6d15c2805957af620c82555553b3e
: Parent  f3890916496445c97d6778d6c986b0270ff707f2
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
12 years agolibxl_qmp: Simplify run of single QMP commands.
Alex Bligh [Tue, 19 Feb 2013 15:25:15 +0000 (15:25 +0000)]
libxl_qmp: Simplify run of single QMP commands.

This new function connects to QEMU, sends the command and disconnects.

Backport of xen-unstable patch:
: HG changeset patch
: User Anthony PERARD <anthony.perard@citrix.com>
: Date 1349693134 -3600
: Node ID f3890916496445c97d6778d6c986b0270ff707f2
: Parent  be5d014f91dfbd67afacc3385c265243794a246f
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
12 years agolibxl_qmp: Use qmp_parameters_* functions for param list of a QMP command.
Alex Bligh [Tue, 19 Feb 2013 15:25:15 +0000 (15:25 +0000)]
libxl_qmp: Use qmp_parameters_* functions for param list of a QMP command.

Backported from xen-unstable patch:
: HG changeset patch
: User Anthony PERARD <anthony.perard@citrix.com>
: Date 1349693133 -3600
: Node ID be5d014f91dfbd67afacc3385c265243794a246f
: Parent  6f7847729f0f42614de516d15257ede7243f995f
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
12 years agolibxl_qmp: Introduces helpers to create an argument list.
Alex Bligh [Tue, 19 Feb 2013 15:25:14 +0000 (15:25 +0000)]
libxl_qmp: Introduces helpers to create an argument list.

Those functions will be used to create a "list" of parameters that
contain more than just strings. This list is converted by qmp_send to
a string to be sent to QEMU.

Those functions will be used in the next two patches, so right now
there are not compiled.

Backported from xen-unstable patch:
: HG changeset patch
: User Anthony PERARD <anthony.perard@citrix.com>
: Date 1349693132 -3600
: Node ID 6f7847729f0f42614de516d15257ede7243f995f
: Parent  74dee58cfc0d2d6594f388db3b4d2ce91d1bb204
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
12 years agolibxl_json: Introduce libxl__json_object_to_yajl_gen.
Alex Bligh [Tue, 19 Feb 2013 15:25:14 +0000 (15:25 +0000)]
libxl_json: Introduce libxl__json_object_to_yajl_gen.

This function converts a libxl__json_object to yajl by calling every
yajl_gen_* function on a preallocated yajl_gen hand.

This helps to integrate a json_object into an already existing
yajl_gen tree.

This function is used in a later patch.

Backported from xen-unstable patch:
: HG changeset patch
: User Anthony PERARD <anthony.perard@citrix.com>
: Date 1349693132 -3600
: Node ID 74dee58cfc0d2d6594f388db3b4d2ce91d1bb204
: Parent  3f71aab0e2774ded0c5a03436c364fb031ba9aa0
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
12 years agolibxl_json: Replace JSON_TRUE/FALSE by JSON_BOOL.
Alex Bligh [Tue, 19 Feb 2013 15:25:13 +0000 (15:25 +0000)]
libxl_json: Replace JSON_TRUE/FALSE by JSON_BOOL.

Those two JSON_TRUE and JSON_FALSE were types of node. But it's better
to have a unique JSON_BOOL type.

Backported from xen-unstable patch:
: HG changeset patch
: User Anthony PERARD <anthony.perard@citrix.com>
: Date 1349693131 -3600
: Node ID 3f71aab0e2774ded0c5a03436c364fb031ba9aa0
: Parent  4a6d5d8cba4fc44f9bbda201188885868604b8e8
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
12 years agolibxl_json: Remove JSON_ERROR from enum.
Alex Bligh [Tue, 19 Feb 2013 15:25:13 +0000 (15:25 +0000)]
libxl_json: Remove JSON_ERROR from enum.

This value from libxl__json_node_type is never used.

Backported from xen-unstable patch:
: HG changeset patch
: User Anthony PERARD <anthony.perard@citrix.com>
: Date 1349693130 -3600
: Node ID 4a6d5d8cba4fc44f9bbda201188885868604b8e8
: Parent  c9b80c7f8db1a5d26906a2298c481bf7e87fda94
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
12 years agolibxl_json: Export json_object related function.
Alex Bligh [Tue, 19 Feb 2013 15:25:11 +0000 (15:25 +0000)]
libxl_json: Export json_object related function.

Export libxl__json_object_alloc and libxl__json_object_append_to to
use them in a later patch.

Backported from xen-unstable patch:
: User Anthony PERARD <anthony.perard@citrix.com>
: Date 1349693129 -3600
: Node ID c9b80c7f8db1a5d26906a2298c481bf7e87fda94
: Parent  93e3e6a33e0a1ec9f92fc575334caa35e6dbc757
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
12 years agotools/ocaml: libxc bindings: Fix SBDF encoding
Andrew Cooper [Fri, 15 Feb 2013 15:06:18 +0000 (15:06 +0000)]
tools/ocaml: libxc bindings: Fix SBDF encoding

Changeset 23861:ec7c81fbe0de alters the SBDF encoding expected by the
DOMCTL_{de,}assign_device hypercalls.

While it updates libxl, libxc and the python bindings, the ocaml
bindings got missed.  As a result, any attempt to use PCI Passthrough
with Xen-4.2 and later will fail.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
xen-unstable changeset: 26373:56daf05bcf69
Backport-requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agoAMD IOMMU: also spot missing IO-APIC entries in IVRS table
Jan Beulich [Fri, 15 Feb 2013 14:27:44 +0000 (15:27 +0100)]
AMD IOMMU: also spot missing IO-APIC entries in IVRS table

Apart from dealing duplicate conflicting entries, we also have to
handle firmware omitting IO-APIC entries in IVRS altogether. Not doing
so has resulted in c/s 26517:601139e2b0db to crash such systems during
boot (whereas with the change here the IOMMU gets disabled just as is
being done in the other cases, i.e. unless global tables are being
used).

Debugging this issue has also pointed out that the debug log output is
pretty ugly to look at - consolidate the output, and add one extra
item for the IVHD special entries, so that future issues are easier
to analyze.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Sander Eikelenboom <linux@eikelenboom.it>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen-unstable changeset: 26531:e68f14b9e739
xen-unstable date: Thu Feb 14 08:40:52 UTC 2013

12 years agotools/ocaml: oxenstored: correctly handle a full ring.
Ian Campbell [Fri, 15 Feb 2013 11:50:22 +0000 (11:50 +0000)]
tools/ocaml: oxenstored: correctly handle a full ring.

Change 26521:2c0fd406f02c (part of XSA-38 / CVE-2013-0215) incorrectly
caused us to ignore rather than process a completely full ring. Check if
producer and consumer are equal before masking to avoid this, since prod ==
cons + PAGE_SIZE after masking becomes prod == cons.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
xen-unstable changeset: 26539:759574df84a6
Backport-requested-by: security@xen.org
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agounmodified_drivers: __devinit was removed in linux-3.8
Olaf Hering [Thu, 14 Feb 2013 13:25:21 +0000 (14:25 +0100)]
unmodified_drivers: __devinit was removed in linux-3.8

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Merge with __init handling.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen-unstable changeset: 26526:a37aa55c3cbc
xen-unstable date: Tue Feb 12 10:29:51 UTC 2013

12 years agoVMX: disable SMEP feature when guest is in non-paging mode
Dongxiao Xu [Tue, 12 Feb 2013 12:44:02 +0000 (13:44 +0100)]
VMX: disable SMEP feature when guest is in non-paging mode

SMEP is disabled if CPU is in non-paging mode in hardware.
However Xen always uses paging mode to emulate guest non-paging
mode with HAP. To emulate this behavior, SMEP needs to be manually
disabled when guest switches to non-paging mode.

We met an issue that, SMP Linux guest with recent kernel (enable
SMEP support, for example, 3.5.3) would crash with triple fault if
setting unrestricted_guest=0 in grub. This is because Xen uses an
identity mapping page table to emulate the non-paging mode, where
the page table is set with USER flag. If SMEP is still enabled in
this case, guest will meet unhandlable page fault and then crash.

Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
Signed-off-by: Xiantao Zhang <xiantao.zhang@intel.com>
xen-unstable changeset: 26502:d1bf3b21f783
xen-unstable date: Wed Jan 30 17:17:30 UTC 2013

12 years agovmx: Simplify cr0 update handling by deferring cr4 changes to the cr4 handler.
Keir Fraser [Tue, 12 Feb 2013 12:43:16 +0000 (13:43 +0100)]
vmx: Simplify cr0 update handling by deferring cr4 changes to the cr4 handler.

Signed-off-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 26501:8201b6ec3564
xen-unstable date: Wed Jan 30 17:15:39 UTC 2013

12 years agofix acpi_dmar_zap/reinstate() (fixes S3 regression)
Tomasz Wroblewski [Tue, 12 Feb 2013 12:41:37 +0000 (13:41 +0100)]
fix acpi_dmar_zap/reinstate() (fixes S3 regression)

Fix S3 regression introduced by cs 23013:65d26504e843 (ACPI: large
cleanup). The dmar virtual pointer returned from acpi_get_table cannot
be safely stored away and used later, as the underlying
acpi_os_map_memory / __acpi_map_table functions overwrite the mapping
causing it to point to different tables than dmar (last fetched table is
used). This subsequently causes acpi_dmar_reinstate() and
acpi_dmar_zap() to write data to wrong table, causing its corruption and
problems with consecutive s3 resumes.

Added a new function to fetch ACPI table physical address, and
establishing separate static mapping for dmar_table pointer instead of
using acpi_get_table().

Signed-off-by: Tomasz Wroblewski <tomasz.wroblewski@citrix.com>
Added call to acpi_tb_verify_table(). Fixed page count passed to
map_pages_to_xen(). Cosmetic changes.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen-unstable changeset: 26443:9efe4c0bf9c8
xen-unstable date: Wed Jan 23 09:31:04 UTC 2013

12 years agox86: restore (optional) forwarding of PCI SERR induced NMI to Dom0
Jan Beulich [Tue, 12 Feb 2013 12:40:36 +0000 (13:40 +0100)]
x86: restore (optional) forwarding of PCI SERR induced NMI to Dom0

c/s 22949:54fe1011f86b removed the forwarding of NMIs to Dom0 when they
were caused by PCI SERR. NMI buttons as well as BMCs (like HP's iLO)
may however want such events to be seen in Dom0 (e.g. to trigger a
dump).

Therefore restore most of the functionality which named c/s removed
(adjusted for subsequent changes, and adjusting the public interface to
use the modern term, retaining the old one for backwards
compatibility).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 26440:5af4f2ab06f3
xen-unstable date: Tue Jan 22 08:33:10 UTC 2013

12 years agox86/hvm: fix RTC setting.
Tim Deegan [Tue, 12 Feb 2013 12:39:30 +0000 (13:39 +0100)]
x86/hvm: fix RTC setting.

When the guest writes one field of the RTC time, we must bring all the
other fields up to date for the current second before calculating the
new RTC time.

Signed-off-by: Tim Deegan <tim@xen.org>
Tested-by: Phil Evans <Phil.Evans@m247.com>
xen-unstable changeset: 26428:9e8c39bdc1fe
xen-unstable date: Fri Jan 18 11:31:57 UTC 2013

12 years agox86/AMD: Enable WC+ memory type on family 10 processors
Boris Ostrovsky [Tue, 12 Feb 2013 12:38:22 +0000 (13:38 +0100)]
x86/AMD: Enable WC+ memory type on family 10 processors

In some cases BIOS may not enable WC+ memory type on family 10 processors,
instead converting what would be WC+ memory to CD type. On guests using
nested pages this could result in performance degradation. This patch
enables WC+.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@amd.com>
xen-unstable changeset: 26427:8f6dd5dc5d6c
xen-unstable date: Fri Jan 18 11:20:58 UTC 2013

12 years agox86: consistently mask floating point exceptions
Jan Beulich [Tue, 12 Feb 2013 12:37:15 +0000 (13:37 +0100)]
x86: consistently mask floating point exceptions

c/s 23142:f5e8d152a565 resulted in v->arch.fpu_ctxt to point into the
save area allocated for xsave/xrstor (when they're available). The way
vcpu_restore_fpu_lazy() works (using fpu_init() for an uninitialized
vCPU only when there's no xsave support) causes this to load whatever
arch_set_info_guest() put there, irrespective of whether the i387 state
was specified to be valid in the respective input structure.

Consequently, with a cleared (al zeroes) incoming FPU context, and with
xsave available, one gets all exceptions unmasked (as opposed to to the
legacy case, where FINIT and LDMXCSR get used, masking all exceptions).
This causes e.g. para-virtualized NetWare to crash.

The behavior of arch_set_info_guest() is thus being made more hardware-
like for the FPU portion of it: Considering it to be similar to INIT,
it will leave untouched all floating point state now. An alternative
would be to make the behavior RESET-like, forcing all state to known
values, albeit - taking into account legacy behavior - not to precisely
the values RESET would enforce (which masks only SSE exceptions, but
not x87 ones); that would come closest to mimicing FINIT behavior in
the xsave case. Another option would be to continue copying whatever
was provided, but override (at least) FCW and MXCSR if VGCF_I387_VALID
isn't set.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 26395:b4cbb83f9a1f
xen-unstable date: Wed Jan 16 12:56:55 UTC 2013

12 years agoxen: sched_credit: improve picking up the idle CPU for a VCPU
Dario Faggioli [Tue, 12 Feb 2013 12:36:07 +0000 (13:36 +0100)]
xen: sched_credit: improve picking up the idle CPU for a VCPU

In _csched_cpu_pick() we try to select the best possible CPU for
running a VCPU, considering the characteristics of the underlying
hardware (i.e., how many threads, core, sockets, and how busy they
are). What we want is "the idle execution vehicle with the most
idling neighbours in its grouping".

In order to achieve it, we select a CPU from the VCPU's affinity,
giving preference to its current processor if possible, as the basis
for the comparison with all the other CPUs. Problem is, to discount
the VCPU itself when computing this "idleness" (in an attempt to be
fair wrt its current processor), we arbitrarily and unconditionally
consider that selected CPU as idle, even when it is not the case,
for instance:
 1. If the CPU is not the one where the VCPU is running (perhaps due
    to the affinity being changed);
 2. The CPU is where the VCPU is running, but it has other VCPUs in
    its runq, so it won't go idle even if the VCPU in question goes.

This is exemplified in the trace below:

]  3.466115364 x|------|------| d10v1   22005(2:2:5) 3 [ a 1 8 ]
   ... ... ...
   3.466122856 x|------|------| d10v1 runstate_change d10v1
   running->offline
   3.466123046 x|------|------| d?v? runstate_change d32767v0
   runnable->running
   ... ... ...
]  3.466126887 x|------|------| d32767v0   28004(2:8:4) 3 [ a 1 8 ]

22005(...) line (the first line) means _csched_cpu_pick() was called
on VCPU 1 of domain 10, while it is running on CPU 0, and it choose
CPU 8, which is busy ('|'), even if there are plenty of idle
CPUs. That is because, as a consequence of changing the VCPU affinity,
CPU 8 was chosen as the basis for the comparison, and therefore
considered idle (its bit gets unconditionally set in the bitmask
representing the idle CPUs). 28004(...) line means the VCPU is woken
up and queued on CPU 8's runq, where it waits for a context switch or
a migration, in order to be able to execute.

This change fixes things by only considering the "guessed" CPU idle if
the VCPU in question is both running there and is its only runnable
VCPU.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
xen-unstable changeset: 26287:127c2c47d440
xen-unstable date: Tue Dec 18 18:10:18 UTC 2012

12 years agooxenstored: Enforce a maximum message size of 4096 bytes
Ian Jackson [Thu, 7 Feb 2013 14:24:08 +0000 (14:24 +0000)]
oxenstored: Enforce a maximum message size of 4096 bytes

The maximum size of a message is part of the protocol spec in
  xen/include/public/io/xs_wire.h

Before this patch a client which sends an overly large message can
cause a buffer read overrun.

Note if a badly-behaved client sends a very large message
then it will be difficult for them to make their connection
work again-- they will probably need to reboot.

This is a security issue, part of XSA-38 / CVE-2013-0215.

Signed-off-by: David Scott <dave.scott@eu.citrix.com>
Acked-by: Ian Campbell <Ian.Campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
xen-unstable changeset: 26522:ffd30e7388ad
Backport-requested-by: security@xen.org
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agotools/ocaml: oxenstored: Be more paranoid about ring reading
Ian Jackson [Thu, 7 Feb 2013 14:23:56 +0000 (14:23 +0000)]
tools/ocaml: oxenstored: Be more paranoid about ring reading

oxenstored makes use of the OCaml Xenbus bindings, in which the
function xs_ring_read in tools/ocaml/libs/xb/xs_ring_stubs.c is used
to read from the shared memory Xenstore ring.

This function does not correctly handle all possible (prod, cons)
states when MASK_XENSTORE_IDX(prod) > MASK_XENSTORE_IDX(cons).

The root cause is the use of the unmasked values of prod and cons to
calculate to_read.  If prod is set to an out-of-range value, the ring
peer can cause to_read to be too large or even negative.  This allows
the ring peer to force oxenstored to read and write out of range for
the buffers leading to a crash or possibly to privilege escalation.

Correct this by masking the values of cons and prod at the start, so
we only deal with masked values.  This makes the logic simpler, as
semantically inappropriate values of the upper bits of the ring
pointers are simply ignored.

The same vulnerability does not exist in the ring writer because the
only use made of the unmasked value is the check which prevents the
prod pointer overtaking the cons pointer.  A ring peer which defeats
this check will suffer only lost data.

However, additionally, precautions need to be taken to ensure that
req_cons and req_prod are only read once in each function.  Without
the use of volatile or some asm construct, the compiler can "prove"
that req_cons and req_prod do not change unexpectedly and is permitted
to "amplify" the read of (say) req_cons into two reads at different
times, giving two different values for use as cons, and then use the
two sources of cons interchangeably.  (The use of xen_mb() does not
forbid this.)

Therefore do the reads of req_cons and req_prod through a volatile
pointer in both xs_ring_read and xs_ring_write.

This is currently believed to be a theoretical vulnerability as we are
not aware of any compilers which amplify reads in this way.

This is a security issue, part of XSA-38 / CVE-2013-0215.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Tested-by: Matthew Daley <mattjd@gmail.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
xen-unstable changeset: 26521:2c0fd406f02c
Backport-requested-by: security@xen.org
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
12 years agoAMD,IOMMU: Make per-device interrupt remapping table default
Boris Ostrovsky [Tue, 5 Feb 2013 14:30:59 +0000 (15:30 +0100)]
AMD,IOMMU: Make per-device interrupt remapping table default

Using global interrupt remapping table may be insecure, as
described by XSA-36. This patch makes per-device mode default.

This is XSA-36 / CVE-2013-0153.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@amd.com>
Moved warning in amd_iov_detect() to location covering all cases.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen-unstable changeset: 26519:1af531e7bc2f
xen-unstable date: Tue Feb  5 14:22:11 UTC 2013

12 years agoAMD,IOMMU: Disable IOMMU if SATA Combined mode is on
Boris Ostrovsky [Tue, 5 Feb 2013 14:30:31 +0000 (15:30 +0100)]
AMD,IOMMU: Disable IOMMU if SATA Combined mode is on

AMD's SP5100 chipset can be placed into SATA Combined mode
that may cause prevent dom0 from booting when IOMMU is
enabled and per-device interrupt remapping table is used.
While SP5100 erratum 28 requires BIOSes to disable this mode,
some may still use it.

This patch checks whether this mode is on and, if per-device
table is in use, disables IOMMU.

This is XSA-36 / CVE-2013-0153.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@amd.com>
Flipped operands of && in amd_iommu_init() to make the message issued
by amd_sp5100_erratum28() match reality (when amd_iommu_perdev_intremap
is zero, there's really no point in calling the function).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen-unstable changeset: 26518:e379a23b0465
xen-unstable date: Tue Feb  5 14:21:25 UTC 2013

12 years agoAMD,IOMMU: Clean up old entries in remapping tables when creating new one
Jan Beulich [Tue, 5 Feb 2013 14:29:51 +0000 (15:29 +0100)]
AMD,IOMMU: Clean up old entries in remapping tables when creating new one

When changing the affinity of an IRQ associated with a passed
through PCI device, clear previous mapping.

This is XSA-36 / CVE-2013-0153.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
In addition, because some BIOSes may incorrectly program IVRS
entries for IOAPIC try to check for entry's consistency. Specifically,
if conflicting entries are found disable IOMMU if per-device
remapping table is used. If entries refer to bogus IOAPIC IDs
disable IOMMU unconditionally

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@amd.com>
xen-unstable changeset: 26517:601139e2b0db
xen-unstable date: Tue Feb  5 14:20:47 UTC 2013

12 years agoACPI: acpi_table_parse() should return handler's error code
Boris Ostrovsky [Tue, 5 Feb 2013 14:29:03 +0000 (15:29 +0100)]
ACPI: acpi_table_parse() should return handler's error code

Currently, the error code returned by acpi_table_parse()'s handler
is ignored. This patch will propagate handler's return value to
acpi_table_parse()'s caller.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@amd.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
xen-unstable changeset: 26516:32d4516a97f0
xen-unstable date: Tue Feb  5 14:18:18 UTC 2013

12 years agoxen: Do not allow guests to enable nested HVM on themselves
Ian Campbell [Wed, 23 Jan 2013 10:52:44 +0000 (11:52 +0100)]
xen: Do not allow guests to enable nested HVM on themselves

There is no reason for this and doing so exposes a memory leak to
guests. Only toolstacks need write access to this HVM param.

This is XSA-35 / CVE-2013-0152.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Jan Beulich <JBeulich@suse.com>
xen-unstable changeset: 26444:621b1a889e9b
xen-unstable date: Wed Jan 23 10:47:24 UTC 2013

12 years agox86_32: don't allow use of nested HVM
Jan Beulich [Wed, 23 Jan 2013 10:51:16 +0000 (11:51 +0100)]
x86_32: don't allow use of nested HVM

There are (indirect) uses of map_domain_page() in the nested HVM code
that are unsafe when not just using the 1:1 mapping.

This is XSA-34 / CVE-2013-0151.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
12 years agoQEMU_TAG update
Ian Jackson [Thu, 17 Jan 2013 16:00:49 +0000 (16:00 +0000)]
QEMU_TAG update

12 years agoConfig.mk: delete accidentally introduced drivel
Ian Jackson [Thu, 17 Jan 2013 12:23:12 +0000 (12:23 +0000)]
Config.mk: delete accidentally introduced drivel

12 years agoQEMU_TAG update
Ian Jackson [Thu, 17 Jan 2013 12:12:21 +0000 (12:12 +0000)]
QEMU_TAG update

12 years agoQEMU_TAG update
Ian Jackson [Wed, 16 Jan 2013 14:14:19 +0000 (14:14 +0000)]
QEMU_TAG update

12 years agoVT-d: fix interrupt remapping source validation for devices behind legacy bridges
Jan Beulich [Wed, 9 Jan 2013 16:16:00 +0000 (17:16 +0100)]
VT-d: fix interrupt remapping source validation for devices behind legacy bridges

Using SVT_VERIFY_BUS here doesn't make sense; native Linux also
uses SVT_VERIFY_SID_SQ here instead.

This is XSA-33 / CVE-2012-5634.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen-unstable changeset: 26340:19fd1237ff0d
xen-unstable date: Wed Jan  9 16:13:26 UTC 2013

12 years agox86: compat_show_guest_stack() should not truncate MFN
Jan Beulich [Wed, 9 Jan 2013 09:53:16 +0000 (10:53 +0100)]
x86: compat_show_guest_stack() should not truncate MFN

Re-using "addr" here was a mistake, as it is a 32-bit quantity.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 26332:8e942f2f3b45
xen-unstable date: Mon Jan  7 12:28:29 UTC 2013

12 years agopassthrough/domctl: use correct struct in union
Andrew Cooper [Wed, 9 Jan 2013 09:51:54 +0000 (10:51 +0100)]
passthrough/domctl: use correct struct in union

This appears to be a copy paste error from c/s 23861:ec7c81fbe0de.

It is safe, functionally speaking, as both the xen_domctl_assign_device
and xen_domctl_get_device_group structure start with a 'uint32_t
machine_sbdf'.  We should however use the correct union structure.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen-unstable changeset: 26320:8fd5635f451b
xen-unstable date: Fri Jan  4 09:06:47 UTC 2013

12 years agox86, amd: Disable way access filter on Piledriver CPUs
Andre Przywara [Wed, 9 Jan 2013 09:49:50 +0000 (10:49 +0100)]
x86, amd: Disable way access filter on Piledriver CPUs

The Way Access Filter in recent AMD CPUs may hurt the performance of
some workloads, caused by aliasing issues in the L1 cache.
This patch disables it on the affected CPUs.

The issue is similar to that one of last year:
http://lkml.indiana.edu/hypermail/linux/kernel/1107.3/00041.html
This new patch does not replace the old one, we just need another
quirk for newer CPUs.

The performance penalty without the patch depends on the
circumstances, but is a bit less than the last year's 3%.

The workloads affected would be those that access code from the same
physical page under different virtual addresses, so different
processes using the same libraries with ASLR or multiple instances of
PIE-binaries. The code needs to be accessed simultaneously from both
cores of the same compute unit.

More details can be found here:
http://developer.amd.com/Assets/SharedL1InstructionCacheonAMD15hCPU.pdf

CPUs affected are anything with the core known as Piledriver.
That includes the new parts of the AMD A-Series (aka Trinity) and the
just released new CPUs of the FX-Series (aka Vishera).
The model numbering is a bit odd here: FX CPUs have model 2,
A-Series has model 10h, with possible extensions to 1Fh. Hence the
range of model ids.

Signed-off-by: Andre Przywara <osp@andrep.de>
Add and use MSR_AMD64_IC_CFG. Update the value whenever it is found to
not have all bits set, rather than just when it's zero.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 26294:5fb0b8b838da
xen-unstable date: Wed Dec 19 10:42:09 UTC 2012

12 years agoscheduler: fix rate limit range checking
Jan Beulich [Wed, 9 Jan 2013 07:53:18 +0000 (08:53 +0100)]
scheduler: fix rate limit range checking

For one, neither of the two checks permitted for the documented value
of zero (disabling the functionality altogether).

Second, the range checking of the command line parameter was done by
the credit scheduler's initialization code, despite it being a generic
scheduler option.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 26266:8d209624ea83
xen-unstable date: Mon Dec 10 10:14:27 UTC 2012

12 years agoIOMMU: imply "verbose" from "debug"
Jan Beulich [Wed, 9 Jan 2013 07:51:27 +0000 (08:51 +0100)]
IOMMU: imply "verbose" from "debug"

I think that generally enabling debugging code without also enabling
verbose output is rather pointless; if someone really wants this, they
can always pass e.g. "iommu=debug,no-verbose".

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 26200:836697b19746
xen-unstable date: Wed Nov 28 16:00:56 UTC 2012

12 years agox86/HPET: fix FSB interrupt masking
Jan Beulich [Wed, 9 Jan 2013 07:49:56 +0000 (08:49 +0100)]
x86/HPET: fix FSB interrupt masking

HPET_TN_FSB is not really suitable for masking interrupts - it merely
switches between the two delivery methods. The right way of masking is
through the HPET_TN_ENABLE bit (which really is an interrupt enable,
not a counter enable or some such). This is even more so with certain
chip sets not even allowing HPET_TN_FSB to be cleared on some of the
channels.

Further, all the setup of the channel should happen before actually
enabling the interrupt, which requires splitting legacy and FSB logic.

Finally this also fixes an S3 resume problem (HPET_TN_FSB did not get
set in hpet_broadcast_resume(), and hpet_msi_unmask() doesn't get
called from the general resume code either afaict).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 26183:c139ca92edca
xen-unstable date: Thu Nov 22 09:03:23 UTC 2012

12 years agox86: fix assertion in get_page_type()
Jan Beulich [Mon, 7 Jan 2013 13:24:36 +0000 (14:24 +0100)]
x86: fix assertion in get_page_type()

c/s 22998:e9fab50d7b61 (and immediately following ones) made it
possible that __get_page_type() returns other than -EINVAL, in
particular -EBUSY. Consequently, the assertion in get_page_type()
should check for only the return values we absolutely don't expect to
see there.

This is XSA-37 / CVE-2013-0154.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen-unstable changeset: 26333:e1facbde56ff
xen-unstable date: Mon Jan  7 13:20:26 UTC 2013