Commit Graph

15253 Commits (cf973e469bd9d47c0460347764c1315a6180e13c)

Author SHA1 Message Date
Yang, Wei Y f79116867e kvm: Enable CPU SMEP feature
This patchset enables a new CPU feature SMEP (Supervisor Mode Execution
Protection) in QEMU-KVM. SMEP prevents kernel from executing code in application.
Updated Intel SDM describes this CPU feature. The document will be published soon.

SMEP is identified by CPUID leaf 7 EBX[7], which is 0 before. Get the right value by query KVM kernel module, so that guest can get SMEP through CPUID.

 Signed-off-by: Yang, Wei <wei.y.yang@intel.com>
 Singed-off-by: Shan, Haitao <haitao.shan@intel.com>
 Singed-off-by: Li, Xin <xin.li@intel.com>

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-06-14 09:34:35 -05:00
brillywu@viatech.com.cn b3baa152aa kvm: Add CPUID support for VIA CPU
When KVM is running on VIA CPU with host cpu's model, the
feautures of VIA CPU will be passed into kvm guest by calling
the CPUID instruction for Centaur.

Signed-off-by: BrillyWu<brillywu@viatech.com.cn>
Signed-off-by: KaryJin<karyjin@viatech.com.cn>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-06-14 09:34:35 -05:00
Markus Armbruster 6df658f55c usb-ccid: Plug memory leak on qdev exit()
ccid_initfn() allocates CCIDBus dynamically, but there is no exit
callback to free it.

Fix by getting rid of the allocation.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
2011-06-14 09:34:35 -05:00
Alon Levy 44dc0ca3d2 libcacard: add libcacard.la target
No flag to configure is required. Instead, added a libcacard.la target that
is not built by default, only when requested explicitly via:

mkdir build
cd build
../configure
make libcacard.la
make install-libcacard

Uses libtool to do actual linking of object files and shared library, and
installing. Tested only under linux, but supposed to work on other systems as
well.

If libtool isn't found you get a message complaining about that, only at build
time (since it is not a default target I did not add a message at configure
time).

New build artifacts:
 .libs subdirectories (at <buildroot> and <buildroot>/libcacard)
 *.lo files (at same locations as the respective o files)

Added %.lo : %.c rule that uses libtool.
Updated clean rule to clean up those artifacts.
Added specific rule to call dtrace with libtool wrapper (note that because of
a current upstream dtrace bug fixed by systemtap b1568fd85 commit the -fPIC flag
isn't actually passed on. still current dtrace+libtool produced object links fine).
If libtool is missing any of the following targets will complain and exit 1:
 any subdir: *.lo
 root and libcacard: libcacard.la, libcacard-instsall

Tested to link and load with all tracing backends.
2011-06-14 09:34:34 -05:00
Alon Levy 3aa5d2bee8 configure: add libdir and --libdir 2011-06-14 09:34:34 -05:00
Michael Tokarev 35f7546206 print meaningful error message in case of --disable-vhost-net
When qemu gets compiled without support of vhost-net, any attempt
to use it fails with a very clear error message:

 qemu-system-x86_64: -netdev ...,vhost=on: vhost-net requested but could not be initialized

there's absolutely no reason given _why_ it coult not be
initialized, and even strace'ing the process in question
does not reveal any errors.  So print a message telling
what's going on.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-06-14 16:48:04 +03:00
Michael S. Tsirkin b91cb44215 virtio: compat event idx support
Disable event index for compat machine types.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2011-06-14 16:48:00 +03:00
Gerd Hoffmann 94cc916a8c usb-uhci: fix expire time initialization.
expire_time must be initialited when the guest activates the
usb scheduler, not at device creation time.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:50 +02:00
Peter Maydell 9bba1eb180 hw/usb-ohci.c: Implement remote wakeup
Implement the wakeup callback in the OHCI USBPortOps, so that when
a downstream device wakes up it correctly causes the OHCI controller
to come out of suspend.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:50 +02:00
Peter Maydell 4b0315d7ed hw/usb-ohci.c: Ignore writes to HcPeriodCurrentED register
HcPeriodCurrentED is read-only, but Linux writes to it anyway; silently
ignore this rather than printing a warning message.

(Specifically, drivers/usb/host/ohci-hub.c:ohci_rh_resume() writes a
0, in at least kernels 2.6.25 through 2.6.39.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:50 +02:00
Brad Hards 4001f22ffd usb: Use defines for serial bus release number register for EHCI
Signed-off-by: Brad Hards <bradh@frogmouth.net>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:50 +02:00
Brad Hards e59d33a734 usb: Use defines for serial bus release number register for UHCI
Signed-off-by: Brad Hards <bradh@frogmouth.net>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:50 +02:00
Brad Hards 8e257816b0 usb: Add defines for USB Serial Bus Release Number register
Signed-off-by: Brad Hards <bradh@frogmouth.net>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:50 +02:00
Hans de Goede 290a5c60a3 usb-bus: Don't detach non attached devices on device exit
This causes an "Error: tried to detach unattached usb device " to be printed,
this can happen when deleting ie a usb host qdev, which did not
get attached (because a device matching the filter never got plugged in).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Hans de Goede 290d26d2e7 usb-bus: Add knowledge of USB_SPEED_SUPER to usb_speed helper
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Hans de Goede f8ddbfbcda usb-linux: Enlarge buffer for descriptors to 8192 bytes
1024 bytes is way to small, one hd UVC webcam I have over here has so
many resolutions its descriptors take op close to 4k. Hopefully 8k will
be enough for all devices.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Gerd Hoffmann e447fc6353 usb: don't call usb_host_device_open from vl.c
Not needed any more, usb-host is qdev-ified these days.
Well, at least the linux version ...

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Gerd Hoffmann 1f45a81bef usb-linux: only cleanup in host_close when host_open was successful. 2011-06-14 12:56:49 +02:00
Hans de Goede 97f8616648 usb-linux: Don't try to open the same device twice
If a user wants to redirect 2 identical usb sticks, in theory this is
possible by doing:
usb_add host🔢5678
usb_add host🔢5678

But this will lead to us trying to open the first stick twice, since we
don't break the loop after having found a match in our filter list, so the next'
filter list entry will result in us trying to open the same device again.

Fix this by adding the missing break.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Hans de Goede 130314f83d usb-linux: Ensure devep != 0
So that we don't index endp_table with a negative index.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Hans de Goede 61c1117f08 usb-linux: Don't do perror when errno is not set
Note that "op" also is not set, so before this change these error paths
would feed NULL to perror.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Hans de Goede f264cfbf4a usb-linux: Teach about super speed
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Hans de Goede 3991c35e85 usb-linux: Get speed from sysfs rather then from the connectinfo ioctl
The connectinfo ioctl only differentiates between lo speed devices, and
all other speeds, where as we would like to know the real speed. The real
speed is available in sysfs so use that when available.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Gerd Hoffmann f72e502e5f usb: documentation update
Add some more informations to docs/usb2.txt about using usb2 (also usb1)
devices.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Gerd Hoffmann 025b168ca6 usb-ehci: split trace calls to handle arg count limits
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Gerd Hoffmann e654887f38 usb-ehci: itd handling fixes.
This patch fixes a bunch of issues in the itd descriptor handling.
Most important fix is to handle transfers which cross page borders
correctly by looking up the address of the next page.  Luckily the
linux uses physically contigous memory so the data used to hits the
correct location even with this bug instead of corrupting guest
memory.  Also the transfer length updates for outgoing transfers wasn't
correct.

While being at it DPRINTFs have been replaced by tracepoints.

The isoch_pause logic has been disabled.  Not clear to me which propose
this serves and I think it is incorrect too as we just skip processing
itds.  Even when no xfer happens we have to clear the active bit.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Kevin O'Connor 69bf405b50 The USB tablet should not claim boot protocol support.
The USB tablet advertises that it supports the "boot" protocol.
However, its reports aren't "boot" protocol compatible.  So, it
shouldn't claim that.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Kevin O'Connor 46115ac4c4 Fix USB mouse Set_Protocol behavior
The QEMU USB mouse claims to support the "boot" protocol
(bInterfaceSubClass is 1).  However, the mouse rejects the
Set_Protocol command.

The qemu mouse does support the "boot" protocol specification, so a
simple fix is to enable the Set_Protocol request.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Gerd Hoffmann d05393071a usb-ehci: drop EXECUTING checks.
The state machine doesn't stop in EXECUTING state any more when async
packets are in flight, so the checks are not needed any more and can
be dropped.

Also kick out the check for the frame timer.  As we don't stop & sleep
any more on async packets this is obsolete.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Gerd Hoffmann 07771f6fce usb: cancel async packets on unplug
This patch adds USBBusOps struct with (for now) only a single callback
which is called when a device is about to be destroyed.  The USB Host
adapters are implementing this callback and use it to cancel any async
requests which might be in flight before the device actually goes away.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:49 +02:00
Hans de Goede 8e4faf3de9 ehci: fix a number of unused-but-set-variable warnings (new with gcc-4.6)
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:48 +02:00
Gerd Hoffmann d2bd525fbb usb-ehci: fix error handling.
Set the correct bits for nodev, stall and babble errors.
Raise errint irq.  Fix state transition from WRITEBACK
to the next state.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:48 +02:00
Gerd Hoffmann ba7cb5a86a usb-ehci: fix offset writeback in ehci_buffer_rw
Two bugs at once:

First the mask is backwards, so the it used to keeps the offset and
clears the page address, which is not what we need when we update the
offset.

Second the offset calculation is wrong in case head isn't page aligned.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:48 +02:00
Gerd Hoffmann 8ac6d699c4 usb-ehci: multiqueue support
This patch adds support for keeping multiple queues going at the same
time.  One slow device will not affect other devices any more.

The patch adds code to manage EHCIQueue structs.  It also does a number
of changes to the state machine:

 * The state machine will never ever stop in EXECUTING any more.
   Instead it will continue with the next queue (aka HORIZONTALQH) when
   the usb device returns USB_RET_ASYNC.
 * The state machine will stop processing when it figures it walks in
   circles (easy to figure now that we have a EHCIQueue struct for each
   QH we've processed).  The bailout logic should not be needed any
   more.  For now it is still in, but will assert() in case it triggers.
 * The state machine will just skip queues with a async USBPacket in
   flight.
 * The state machine will resume processing as soon as the async
   USBPacket is finished.

The patch also takes care to flush the QH struct back to guest memory
when needed, so we don't get stale data when (re-)loading it from guest
memory in FETCHQH state.

It also makes the writeback code to not touch the first three dwords of
the QH struct as the EHCI must not write them.  This actually fixes a
bug where QH chaining changes (next ptr) by the linux ehci driver where
overwritten by the emulated EHCI.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:56:40 +02:00
Gerd Hoffmann 0122f47279 usb-ehci: add queue data struct
Add EHCIQueue struct, move the fields needed to track the queue state
into that struct.  Pass the new struct instead of ehci state down to
functions which handle the queue state.  Lot of variable references have
changed due to that without an actual functional change.

Replace fetch_addr with two variables, one for async and one for
periodic schedule.  Add functions to get and set the fetch address.

Use EHCIQueue->usb_status (old name: EHCIState->exec_status) directly in
ehci_execute_complete instead of passing around the status using a
parameters and the return value.

ehci_state_fetchqh returns a EHCIQueue struct now.

No change in behavior.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:36:29 +02:00
Gerd Hoffmann f2c88dc10e usb-ehci: trace buffer copy
Add a trace point for buffer copies and drop the DPRINTF's.

No change in behavior.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:36:29 +02:00
Gerd Hoffmann c4f8e21165 usb-ehci: improve mmio tracing
Add a separate tracepoint to log how register values change in response
to a mmio write.  Especially useful for registers which have read-only
or clear-on-write bits in them.

No change in behavior.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:36:28 +02:00
Gerd Hoffmann dcbd0b5c0e usb-ehci: trace port state
Trace usb port operations (attach, detach, reset),
drop a few obsolete DPRINTF's.

No change in behavior.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:36:28 +02:00
Gerd Hoffmann 26d53979db usb-ehci: trace state machine changes
Add functions to get and set the current state of the state machine,
add tracepoints there to trace state transitions.  Add support for
traceing the queue heads and transfer descriptors as we look at them.

Drop a few DPRINTFs and all DPRINTF_ST lines, they are obsolete now.

No change in behavior.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:36:28 +02:00
Gerd Hoffmann 439a97ccab usb-ehci: trace mmio and usbsts
This patch starts adding trace support to ehci.  It traces
updates of the status register (USBSTS), mmio access and
controller reset.

It also adds functions to set and clear status register bits
and puts them in use everywhere.

Some DPRINTF's are dropped in favor of the new tracepoints.

No change in behavior.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:36:28 +02:00
Gerd Hoffmann 41c01ee715 usb-linux: catch ENODEV in more places.
Factor out disconnect code (called when a device disappears) to a
separate function.  Add a check for ENODEV errno to a few more places
to make sure we notice disconnects.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2011-06-14 12:36:28 +02:00
Stefan Weil 7bf4162a80 block/rbd: Remove unused local variable
Variable 'snap' is assigned a value that is never used.
Remove snap and the related code.

Cc: Christian Brunner <chb@muc.de>
Cc: Josh Durgin <josh.durgin@dreamhost.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Reviewed-by: Josh Durgin <josh.durgin@dreamhost.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-06-14 10:01:19 +02:00
Alexandre Raymond f97742d0d3 Darwin: Fix compilation warning regarding the deprecated daemon() function
Changes since v1: create a wrapper function named qemu_daemon() in oslib-posix.c
instead of putting the OS specific workaround in qemu-nbd.c directly.

On OSX >= 10.5, daemon() is deprecated, resulting in the following warning:
----8<----
qemu-nbd.c: In function ‘main’:
qemu-nbd.c:371: warning: ‘daemon’ is deprecated (declared at /usr/include/stdlib.h:289)
----8<----

The following trick, used in mDNSResponder, takes care of this warning:
http://www.opensource.apple.com/source/mDNSResponder/mDNSResponder-258.18/mDNSPosix/PosixDaemon.c

On OSX, it temporarily renames the daemon() function before including stdlib.h
and declares it manually as an extern function. This way, the compiler does not
see the declaration from stdlib.h and thus does not display the warning.

Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
2011-06-14 03:10:47 +02:00
Andreas Färber 7fee199cf9 cocoa: Avoid warning related to multiple handleEvent: definitions
Avoid compiler confusion as to which method signature to use for the
handleEvent: selector on OSX >= 10.6 by making the variable type-safe
as opposed to generic 'id' type.
Requires moving the variable definition to after the class definition.

----8<----
ui/cocoa.m: In function ‘cocoa_refresh’:
ui/cocoa.m:997: warning: multiple methods named ‘-handleEvent:’ found
/System/Library/Frameworks/AppKit.framework/Headers/NSTextInputContext.h:84: warning: using ‘-(BOOL)handleEvent:(NSEvent *)theEvent’
ui/cocoa.m:272: warning: also found ‘-(void)handleEvent:(NSEvent *)event’
----8<---

Reported-by: Alexandre Raymond <cerbere@gmail.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Tested-by: Alexandre Raymond <cerbere@gmail.com>
2011-06-14 03:08:58 +02:00
Andreas Färber e949467ba6 cocoa: Revert dependency on VNC
In 821601ea5b (Make VNC support optional)
cocoa.o was moved from ui-obj-$(CONFIG_COCOA) to vnc-obj-$(CONFIG_COCOA),
adding a dependency on $(CONFIG_VNC). That must've been unintentional.

Cc: Jes Sorensen <Jes.Sorensen@redhat.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
2011-06-14 03:08:58 +02:00
Andreas Färber 3bbbee18a4 cocoa: Provide central qemu_main() prototype
This fixes a missing prototype warning in vl.c and obsoletes
the prototype in cocoa.m. Adjust callers in cocoa.m to supply
third argument, which is currently only used on Linux/ppc.

The prototype is designed so that it could be shared with SDL
and other frontends, if desired.

Cc: Alexandre Raymond <cerbere@gmail.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
2011-06-14 03:08:58 +02:00
Andreas Färber d3922ab5fa Fix libfdt warnings on Darwin
Building with libfdt results in the following warnings on Mac OS X:

  CC    ppc-softmmu/device_tree.o
In file included from /Users/andreas/QEMU/latest64/include/libfdt.h:54,
                 from /Users/andreas/QEMU/qemu/device_tree.c:26:
/Users/andreas/QEMU/qemu/libfdt_env.h:25:20: warning: endian.h: No such file or directory
/Users/andreas/QEMU/qemu/libfdt_env.h:26:22: warning: byteswap.h: No such file or directory
/Users/andreas/QEMU/qemu/libfdt_env.h:28:5: warning: "__BYTE_ORDER" is not defined
/Users/andreas/QEMU/qemu/libfdt_env.h:28:21: warning: "__BIG_ENDIAN" is not defined

Since QEMU's copy of libfdt_env.h only uses bswap_32() and bswap_64(),
let QEMU's bswap.h take care of the headers and use its endianness define.

Cc: Hollis Blanchard <hollis@penguinppc.org>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Acked-by: Alexander Graf <agraf@suse.de>
2011-06-14 03:08:57 +02:00
Alexandre Raymond d1722a27f5 configure: Fix check for fdatasync()
Under Darwin, a symbol exists for the fdatasync() function, so that our
link test succeeds. However _POSIX_SYNCHRONIZED_IO is set to '-1'.

According to POSIX:2008, a value of -1 means the feature is not supported.
A value of 0 means supported at compilation time, and a value greater 0
means supported at both compilation and run time.

Enable fdatasync() only if _POSIX_SYNCHRONIZED_IO is '>0'.

Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
2011-06-14 03:08:57 +02:00
Alexandre Raymond dfa5294fce Remove warning in printf due to type mismatch
----8<----
qemu/target-lm32/translate.c: In function ‘gen_intermediate_code_internal’:
qemu/target-lm32/translate.c:1135: warning: format ‘%zd’ expects type ‘signed size_t’, but argument 4 has type ‘int’
----8<----

Both gen_opc_ptr and gen_opc_buf are "uint16_t *". The difference between
pointers is a ptrdiff_t so printf needs '%td'.

Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
Acked-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
2011-06-14 03:08:57 +02:00
Alexandre Raymond 9851484f3d Cocoa: avoid displaying window when command-line contains '-h' or '-help'
There was already a check in place to avoid displaying a window
in certain modes such as vnc, nographic or curses.

Add a check for '-h' and '-help' to avoid displaying a window for a split-
second before showing the usage information.

Signed-off-by: Alexandre Raymond <cerbere@gmail.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
2011-06-14 03:08:57 +02:00