Commit Graph
24430 Commits
Author SHA1 Message Date
Ian Jackson 549ec0f73f Update QEMU_TAG 2011-11-22 16:19:11 +00:00
Keir Fraser acbd69baab debug: Add domain/vcpu pause_count info to 'd' key.
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-22 15:35:26 +00:00
Daniel De Graaf 2be4fe9b05 xsm/flask: fix resource list range checks
The FLASK security checks for resource ranges were not implemented
correctly - only the permissions on the endpoints of a range were
checked, instead of all items contained in the range. This would allow
certain resources (I/O ports, I/O memory) to be used by domains in
contravention to security policy.

This also corrects a bug where adding overlapping resource ranges did
not trigger an error.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-22 13:29:48 +00:00
Daniel De Graaf e7e7a86267 xsm/flask: Use correct flag to detect writable grant mappings
The flags passed to xsm_grant_mapref are the flags from the map
operation (GNTMAP_*), not status flags (GTF_*).

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-22 13:29:01 +00:00
Wei Wang 9c46139de8 amd iommu: Support INVALIDATE_IOMMU_ALL command.
It is one of the new architectural commands supported by iommu v2.
It instructs iommu to clear all address translation and interrupt
remapping caches for all devices and all domains.

Signed-off-by: Wei Wang <wei.wang2@amd.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-22 13:27:19 +00:00
Wei Wang 489fddfc08 amd iommu: Factor out iommu command handling functions,
and move them into a new file.

Signed-off-by: Wei Wang <wei.wang2@amd.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-22 13:26:46 +00:00
Wei Wang 550ca1beeb amd iommu: Fix incorrect definitions.
Signed-off-by: Wei Wang <wei.wang2@amd.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-22 13:26:11 +00:00
Wei Wang 7e82d0d14a amd iommu: Advertise iommu extended feature bits to xen.
Signed-off-by: Wei Wang <wei.wang2@amd.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-22 13:25:42 +00:00
Keir Fraser 28909bdbbe x86,waitqueue: Allocate whole page for shadow stack.
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-22 13:00:21 +00:00
Keir Fraser 07b6d6bea1 x86,vmx: Remove broken and unused __vmptrst().
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-22 12:53:48 +00:00
Keir Fraser 5a9a98a7a6 hvmloader: Fix memory relocation loop.
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-21 21:28:34 +00:00
Jan Beulich 7442435170 x86/vioapic: clear remote IRR when switching RTE to edge triggered mode
Xen itself (as much as Linux) relies on this behavior, so it should
also emulate it properly. Not doing so reportedly gets in the way of
kexec inside a HVM guest.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Olaf Hering <olaf@aepfle.de>
2011-11-21 09:29:31 +01:00
Keir Fraser 28e312a8b7 x86: Fix RCU locking in XENMEM_add_to_physmap.
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-19 22:13:51 +00:00
Jean Guyader cf95b2a9fd iommu: Introduce per cpu flag (iommu_dont_flush_iotlb) to avoid unnecessary iotlb flush
Add cpu flag that will be checked by the iommu low level code
to skip iotlb flushes. iommu_iotlb_flush shall be called explicitly.

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:43:26 +00:00
Jean Guyader e51e2e0e58 hvmloader: Change memory relocation loop when overlap with PCI hole
Change the way we relocate the memory page if they overlap with pci
hole.  Use new map space (XENMAPSPACE_gmfn_range) to move the loop
into xen.

This code usually get triggered when a device is pass through to a
guest and the PCI hole has to be extended to have enough room to map
the device BARs.  The PCI hole will starts lower and it might overlap
with some RAM that has been alocated for the guest. That usually
happen if the guest has more than 4G of RAM.  We have to relocate
those pages in high mem otherwise they won't be accessible.

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:42:46 +00:00
Jean Guyader a04811a315 mm: New XENMEM space, XENMAPSPACE_gmfn_range
XENMAPSPACE_gmfn_range is like XENMAPSPACE_gmfn but it runs on
a range of pages. The size of the range is defined in a new field.

This new field .size is located in the 16 bits padding between .domid
and .space in struct xen_add_to_physmap to stay compatible with older
versions.

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:42:08 +00:00
Jean Guyader 19c617a85b add_to_physmap: Move the code for XENMEM_add_to_physmap
Move the code for the XENMEM_add_to_physmap case into it's own
function (xenmem_add_to_physmap).

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:41:33 +00:00
Jean Guyader bf3292ca31 iommu: Introduce iommu_flush and iommu_flush_all.
Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:40:56 +00:00
Jean Guyader c312ccdeaf vtd: Refactor iotlb flush code
Factorize the iotlb flush code from map_page and unmap_page into
it's own function.

Signed-off-by: Jean Guyader <jean.guyader@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:40:19 +00:00
Juergen Gross f42d7a66bf sched_sedf: Avoid panic when adjusting sedf parameters
When using sedf scheduler in a cpupool the system might panic when
setting sedf scheduling parameters for a domain.  Introduces
for_each_domain_in_cpupool macro as it is usable 4 times now.  Add
appropriate locking in cpupool_unassign_cpu().

Signed-off-by: Juergen Gross <juergen.gross@ts.fujitsu.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:34:43 +00:00
Paul Durrant 95ad9f65c9 hvmloader: Add configuration options to selectively disable S3 and S4 ACPI power states.
Introduce acpi_s3 and acpi_s4 configuration options (default=1). The
S3 and S4 packages are moved into separate SSDTs and their inclusion
is controlled by the new configuration options.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:32:50 +00:00
Paul Durrant 9307335747 hvmloader: Move acpi_enabled out of hvm_info_table into xenstore
Since hvmloader has a xentore client, use a platform key in xenstore
to indicate whether ACPI is enabled or not rather than the shared
hvm_info_table structure.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-18 13:31:43 +00:00
Jan Beulich 04678eb8f3 x86/xsave: provide guests with finit-like environment
Without the use of xsave, guests get their initial floating point
environment set up with finit. At least NetWare actually depends on
this (in particular on all exceptions being masked), so to be
consistent set the same environment also when using xsave. This is
also in line with all SSE exceptions getting masked initially.

To avoid further fragile casts in xstate_alloc_save_area() the patch
also changes xsave_struct's fpu_see member to have actually usable
fields.

The patch was tested in its technically identical, but modified-file-
wise different 4.1.2 version.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Charles Arnold <carnold@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
2011-11-18 09:22:45 +01:00
Jan Beulich 8eca0db0e8 x86/IRQ: prevent vector sharing within IO-APICs
Following the prevention of vector sharing for MSIs, this change
enforces the same within IO-APICs: Pin based interrupts use the IO-APIC
as their identifying device under the AMD IOMMU (and just like for
MSIs, only the identifying device is used to remap interrupts here,
with no regard to an interrupt's destination).

Additionally, LAPIC initiated EOIs (for level triggered interrupts) too
use only the vector for identifying which interrupts to end. While this
generally causes no significant problem (at worst an interrupt would be
re-raised without a new interrupt event actually having occurred), it
still seems better to avoid the situation.

For this second aspect, a distinction is being made between the
traditional and the directed-EOI cases: In the former, vectors should
not be shared throughout all IO-APICs in the system, while in the
latter case only individual IO-APICs need to be contrained (or, if the
firmware indicates so, sub- groups of them having the same GSI appear
at multiple pins).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2011-11-18 09:21:24 +01:00
Jan Beulich f0b7583fd5 x86/IO-APIC: refine EOI-ing of migrating level interrupts
Rather than going through all IO-APICs and calling io_apic_eoi_vector()
for the vector in question, just use eoi_IO_APIC_irq().

This in turn allows to eliminate quite a bit of other code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
2011-11-18 09:18:41 +01:00
Keir Fraser 6bee8f6b86 elf: Fix Elf64 types and structs to match the specification.
The layouts were actually correct, but the type names were a bit
messed up.

Original patch by Volker Eckert <volker.eckert@citrix.com>
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-16 18:21:14 +00:00
Jan Beulich 8cf292bd24 x86/emulator: add feature checks for newer instructions
Certain instructions were introduced only after the i686 or original
x86-64 architecture, so we should not try to emulate them if the guest
is not seeing the respective feature enabled (or, worse, if the
underlying hardware doesn't support them). This affects fisttp,
movnti, and cmpxchg16b.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-16 16:04:31 +00:00
Jan Beulich 373ac54141 test_x86_emulator: add a "run" target to the test code makefile
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-16 15:50:55 +00:00
Keir Fraser b0198fc3f0 x86_emulate: Define and use BUG() and bool_t.
Original patch by Jan Beulich <jbeulich@suse.com>
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-16 15:48:49 +00:00
Keir Fraser 3e3422bb01 test_x86_emulate: Get public Xen headers via tools/include.
Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-16 15:28:55 +00:00
Jan Beulich 5d6a9065b8 x86-64/test_x86_emulate: fix blowfish test
Incorrect register usage in the _start() wrapper caused the 64-bit
execution emulation to fail.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-16 15:20:25 +00:00
Gianluca Guida 5802821430 [shadow] Disable higher level pagetables early unshadow only when the "process dying" hypercall is used.
This patch fixes a performance problem in fully virtualized guests.

Signed-off-by: Gianluca Guida <gianluca.guida@citrix.com>
Tested-by: Jan Beulich <jbeulich@suse.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-16 15:19:33 +00:00
Stefano Stabellini 6e78f81a27 hvm: introduce HVM_PARAM_BUFIOREQ_EVTCHN
Introduce an event channel for buffered io event notifications,
advertise the port number using an hvm param.  This way the device
model is not forced to check the buffered io page for data several
times a second for the entire life of the VM (buffered io is mostly
used for stdvga emulation in Xen that is switched off after the guest
goes into graphical mode).

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-16 15:17:37 +00:00
Andrew Cooper 54b1268c59 KEXEC cleanup: IA64 specific functions should not live in generic header files
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
2011-11-15 14:50:18 +01:00
Jan Beulich 525848a54b ia64: fix the build
This addresses all remaining build problems introduced over the last
several months.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
2011-11-15 14:47:41 +01:00
Ian Campbell 0d20a8e373 xen: avoid crash enabling turbo mode
On a system which has not had P-state information pushed down into the
hypervisor running "xenpm enable-turbo-mode" will reliably crash the host.

(XEN) PM OP 38 on CPU0
(XEN) ----[ Xen-4.2-unstable  x86_64  debug=y  Not tainted ]----
(XEN) CPU:    0
(XEN) RIP:    e008:[<ffff82c48013ceed>] cpufreq_enable_turbo+0x1d/0x29
(XEN) RFLAGS: 0000000000010297   CONTEXT: hypervisor
(XEN) rax: 0000000000000000   rbx: ffff82c48029fe40   rcx: 0000000000000000
(XEN) rdx: 0000000000000000   rsi: 000000000000000a   rdi: 0000000000000000
(XEN) rbp: ffff82c48029fd08   rsp: ffff82c48029fd08   r8:  0000000000000004
(XEN) r9:  0000000000000000   r10: 00000000fffffffd   r11: ffff82c480218f20
(XEN) r12: ffff830106e720b0   r13: 0000000000000000   r14: ffff82c4802bff80
(XEN) r15: ffff82c48025c0e4   cr0: 000000008005003b   cr4: 00000000000026f0
(XEN) cr3: 000000011f459000   cr2: 0000000000000051
(XEN) ds: 007b   es: 007b   fs: 00d8   gs: 0033   ss: 0000   cs: e008
(XEN) Xen stack trace from rsp=ffff82c48029fd08:
(XEN)    ffff82c48029fdb8 ffff82c48014c427 ffff82c48029fd98 ffff82c48016b2d6
(XEN)    ffff82c48029fdb8 ffff82c48029fd60 00000000001196c5 0000000116bbe025
(XEN)    0000000116bbe025 ffff8301196c5338 ffff82f6022d77c0 0000000000000000
(XEN)    ffff82f60205edf0 0000000000000000 0000000000000000 ffff8300dffba000
(XEN)    ffff82c48029fdb8 ffff82c48029ff18 0000000008050004 0000000000000000
(XEN)    ffff82c4802bff80 ffff82c48025c0e4 ffff82c48029fef8 ffff82c480124fd8
(XEN)    0000000000000000 ffff83011f48c000 0000000116bbe025 0000000000000025
(XEN)    ffff82c48029fe28 0000000080167722 ffff82c48029ff08 ffff83011f48c000
(XEN)    ffff82f60232d8a0 ffff8300dffba000 ffff83011f48c000 ffff82f60232d8a0
(XEN)    ffff82c48029fed8 ffff82c48017296a 000000080000000c 0000000000000026
(XEN)    bfb338b000000000 bfb33874bfb33868 b78988f800000000 0000008800000000
(XEN)    b787a6e0b78533a0 ffffffff00000001 080487aeb7897ff4 bfb3389000000001
(XEN)    b7898ab0b7889626 0000000100000000 0000000000000001 0804867800000001
(XEN)    000000000804e998 00000000b78533a0 bfb33e70bfb33a7c 0000000000000000
(XEN)    0000000000000000 ffff8300dffba000 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 00007d3b7fd600c7 ffff82c48021511e
(XEN)    00000000c1002467 0000000000000023 0000000000000000 0000000000000000
(XEN)    0000000000000000 0000000000000000 00000000dbf5bef8 0000000008050004
(XEN)    0000000000000000 0000000000000000 0000000000000000 0000000000000000
(XEN)    0000000000000023 00000000bfb33874 00000000bfb33868 0000000000000000
(XEN) Xen call trace:
(XEN)    [<ffff82c48013ceed>] cpufreq_enable_turbo+0x1d/0x29
(XEN)    [<ffff82c48014c427>] do_pm_op+0x884/0x8e7
(XEN)    [<ffff82c480124fd8>] do_sysctl+0x6d8/0x9f0
(XEN)    [<ffff82c48021511e>] compat_hypercall+0xae/0x107
(XEN)
(XEN) Pagetable walk from 0000000000000051:
(XEN)  L4[0x000] = 0000000116dbc027 000000000001bd22
(XEN)  L3[0x000] = 0000000119ba8027 000000000001eb36
(XEN)  L2[0x000] = 0000000000000000 ffffffffffffffff
(XEN)
(XEN) ****************************************
(XEN) Panic on CPU 0:
(XEN) FATAL PAGE FAULT
(XEN) [error_code=0000]
(XEN) Faulting linear address: 0000000000000051
(XEN) ****************************************
(XEN)

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
2011-11-15 14:24:38 +01:00
Keir Fraser 029265a33a hvmloader: Move acpi_info structure out from low memory.
This avoids a conflict with SeaBIOS's memory management. Moreover
there is no reason that acp_info must live below 1MB, and moving it
out actually simplifies our code.

Signed-off-by: Keir Fraser <keir@xen.org>
2011-11-14 20:15:35 +00:00
Roger Pau Monne 8698d6d56b tools/check: check for headers and libraries in user defined folders.
Parse EXTRA_INCLUDES, EXTRA_LIB, PREPEND_INCLUDES, PREPEND_LIB,
APPEND_INCLUDES, APPEND_LIB during checks, to search for required
files.

Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2011-11-14 18:17:44 +00:00
Roger Pau Monne 9163062a39 tools/build: Introduce {PREPEND,APPEND}_{LIB,INCLUDES}
Create two new variables called APPEND_ and PREPEND_ to add compile
flags at the beginning or at the end of the search path.

Added a new semantic for user defined compile flags, here is the list
of possible options:

PREPEND_LIB: add libraries to the search path before xen
             (before xen installation folders).
PREPEND_INCLUDES: add headers to the search path before xen
                  (before xen installation folders).
APPEND_LIB: add libraries to the search path at the end
            (after all xen installation folders have been added).
APPEND_INCLUDES: add libraries to the search path at the end
                 (after all xen installation folders have been added).

EXTRA_INCLUDES and EXTRA_LIB can still be used, and they will have the
same effect as PREPEND_INCLUDES and PREPEND_LIB.

Signed-off-by: Roger Pau Monne <roger.pau@entel.upc.edu>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2011-11-14 18:14:07 +00:00
Konrad Rzeszutek Wilk e8d40584e5 tools: xend: tolerate empty state/*.xml
Bugzilla 1680: Xend fails to start if /var/lib/xend/state/*.xml are empty
which I get often when replacing the Xen hypervisor with a newer version.

This can be easily be reproduced under Fedora Core 16 by installing
xen RPMs and then replacing the xen.gz with a newer version.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Anthony Low <shinji@pikopiko.org>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2011-11-14 17:54:54 +00:00
Ian Campbell d0de523f12 docs: report if we do not build a doc due to lack of the necessary tool
Previously only some targets did this. An alternative would be to make a hard
dependency on these tools, this might make more sense especially for markdown?

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2011-11-14 17:50:53 +00:00
Olaf Hering d2cb52cc6c xenpaging: munmap all pages after page-in
Do munmap() on all mapped pages, not just the first one.  Without this
change the gfns backing the remaining pages can not be paged out again
because the page count does not go down to 1. This change was missing
from changeset 23827:d1d6abc1db20.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2011-11-14 17:49:14 +00:00
Andrew Cooper bfbaed092e Revert c/s 23666:b96f8bdcaa15 KEXEC: disconnect all PCI devices from the PCI bus on crash
It turns out that this causes all mannor of problems on certain
motherboards (so far with no pattern I can discern)

Problems include:
* Hanging forever checking hlt instruction.
* Panics when trying to change switch root device
* Drivers hanging when trying to check for interrupts.

From: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Keir Fraser <keir@xen.org>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-11 18:14:35 +00:00
Andres Lagar-Cavilla 51032ca058 Modify naming of queries into the p2m
Callers of lookups into the p2m code are now variants of get_gfn. All
callers need to call put_gfn. The code behind it is a no-op at the
moment, but will change to proper locking in a later patch.

This patch does not change functionality. Only naming, and adds
put_gfn's.

set_p2m_entry retains its name because it is always called with
p2m_lock held.

This patch is humongous, unfortunately, given the dozens of call sites
involved.

After this patch, anyone using old style gfn_to_mfn will not succeed
in compiling their code. This is on purpose: adapt to the new API.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Keir Fraser <keir@xen.org>
2011-11-11 18:11:34 +00:00
Jan Beulich e0594d9bc1 ia64: introduce atomic_{read,write}NN()
These are required to be able to build certain portions of common code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
2011-11-11 17:46:19 +01:00
Lasse Collin e774c4ed45 Decompressors: check input size in unlzo.c
From: Lasse Collin <lasse.collin@tukaani.org>

The code assumes that the input is valid and not truncated.  Add checks to
avoid reading past the end of the input buffer.  Change the type of "skip"
from u8 to int to fix a possible integer overflow.

Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Jan Beulich <jbeulich@suse.com>
2011-11-11 14:35:51 +01:00
Lasse Collin 1fdb4c9a33 Decompressors: check for write errors in unlzo.c
From: Lasse Collin <lasse.collin@tukaani.org>

The return value of flush() is not checked in unlzo().  This means that
the decompressor won't stop even if the caller doesn't want more data.
This can happen e.g.  with a corrupt LZO-compressed initramfs image.

Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Jan Beulich <jbeulich@suse.com>
2011-11-11 14:35:05 +01:00
Lasse Collin 24bde2170d Decompressors: validate match distance in unlzma.c
From: Lasse Collin <lasse.collin@tukaani.org>

Validate the newly decoded distance (rep0) in process_bit1().  This is to
detect corrupt LZMA data quickly.  The old code can run for long time
producing garbage until it hits the end of the input.

Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Jan Beulich <jbeulich@suse.com>
2011-11-11 14:34:24 +01:00
Lasse Collin 8e8ca04c7b Decompressors: check for write errors in unlzma.c
From: Lasse Collin <lasse.collin@tukaani.org>

The return value of wr->flush() is not checked in write_byte().  This
means that the decompressor won't stop even if the caller doesn't want
more data.  This can happen e.g.  with corrupt LZMA-compressed initramfs.
Returning the error quickly allows the user to see the error message
quicker.

There is a similar missing check for wr.flush() near the end of unlzma().

Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Jan Beulich <jbeulich@suse.com>
2011-11-11 14:33:30 +01:00
Lasse Collin f4b38c6cd8 Decompressors: check for read errors in unlzma.c
From: Lasse Collin <lasse.collin@tukaani.org>

Return value of rc->fill() is checked in rc_read() and error() is called
when needed, but then the code continues as if nothing had happened.

rc_read() is a void function and it's on the top of performance critical
call stacks, so propagating the error code via return values doesn't sound
like the best fix.  It seems better to check rc->buffer_size (which holds
the return value of rc->fill()) in the main loop.  It does nothing bad
that the code runs a little with unknown data after a failed rc->fill().

This fixes an infinite loop in initramfs decompression if the
LZMA-compressed initramfs image is corrupt.

Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Jan Beulich <jbeulich@suse.com>
2011-11-11 14:32:57 +01:00