QEMU With E2K User Support
Go to file
Konrad Rzeszutek Wilk 2e87512ecc xen/pt: Sync up the dev.config and data values.
For a passthrough device we maintain a state of emulated
registers value contained within d->config. We also consult
the host registers (and apply ro and write masks) whenever
the guest access the registers. This is done in xen_pt_pci_write_config
and xen_pt_pci_read_config.

Also in this picture we call pci_default_write_config which
updates the d->config and if the d->config[PCI_COMMAND] register
has PCI_COMMAND_MEMORY (or PCI_COMMAND_IO) acts on those changes.

On startup the d->config[PCI_COMMAND] are the host values, not
what the guest initial values should be, which is exactly what
we do _not_ want to do for 64-bit BARs when the guest just wants
to read the size of the BAR. Huh you say?

To get the size of 64-bit memory space BARs,  the guest has
to calculate ((BAR[x] & 0xFFFFFFF0) + ((BAR[x+1] & 0xFFFFFFFF) << 32))
which means it has to do two writes of ~0 to BARx and BARx+1.

prior to this patch and with XSA120-addendum patch (Linux kernel)
the PCI_COMMAND register is copied from the host it can have
PCI_COMMAND_MEMORY bit set which means that QEMU will try to
update the hypervisor's P2M with BARx+1 value to ~0 (0xffffffff)
(to sync the guest state to host) instead of just having
xen_pt_pci_write_config and xen_pt_bar_reg_write apply the
proper masks and return the size to the guest.

To thwart this, this patch syncs up the host values with the
guest values taking into account the emu_mask (bit set means
we emulate, PCI_COMMAND_MEMORY and PCI_COMMAND_IO are set).
That is we copy the host values - masking out any bits which
we will emulate. Then merge it with the initial emulation register
values. Lastly this value is then copied both in
dev.config _and_ XenPTReg->data field.

There is also reg->size accounting taken into consideration
that ends up being used in patch.
 xen/pt: Check if reg->init function sets the 'data' past the reg->size

This fixes errors such as these:

(XEN) memory_map:add: dom2 gfn=fffe0 mfn=fbce0 nr=20
(DEBUG) 189 pci dev 04:0 BAR16 wrote ~0.
(DEBUG) 200 pci dev 04:0 BAR16 read 0x0fffe0004.
(XEN) memory_map:remove: dom2 gfn=fffe0 mfn=fbce0 nr=20
(DEBUG) 204 pci dev 04:0 BAR16 wrote 0x0fffe0004.
(DEBUG) 217 pci dev 04:0 BAR16 read upper 0x000000000.
(XEN) memory_map:add: dom2 gfn=ffffffff00000 mfn=fbce0 nr=20
(XEN) p2m.c:883:d0v0 p2m_set_entry failed! mfn=ffffffffffffffff rc:-22
(XEN) memory_map:fail: dom2 gfn=ffffffff00000 mfn=fbce0 nr=20 ret:-22
(XEN) memory_map:remove: dom2 gfn=ffffffff00000 mfn=fbce0 nr=20
(XEN) p2m.c:920:d0v0 gfn_to_mfn failed! gfn=ffffffff00000 type:4
(XEN) p2m.c:920:d0v0 gfn_to_mfn failed! gfn=ffffffff00001 type:4
..
(XEN) memory_map: error -22 removing dom2 access to [fbce0,fbcff]
(DEBUG) 222 pci dev 04:0 BAR16 read upper 0x0ffffffff.
(XEN) memory_map:remove: dom2 gfn=ffffffff00000 mfn=fbce0 nr=20
(XEN) memory_map: error -22 removing dom2 access to [fbce0,fbcff]

[The DEBUG is to illustate what the hvmloader was doing]

Also we swap from xen_host_pci_long to using xen_host_pci_get_[byte,word,long].

Otherwise we get:

xen_pt_config_reg_init: Offset 0x0004 mismatch! Emulated=0x0000, host=0x2300017, syncing to 0x2300014.
xen_pt_config_reg_init: Error: Offset 0x0004:0x2300014 expands past register size(2)!

which is not surprising. We read the value as an 32-bit (from host),
then operate it as a 16-bit - and the remainder is left unchanged.

We end up writing the value as 16-bit (so 0014) to dev.config
(as we use proper xen_set_host_[byte,word,long] so we don't spill
to other registers) but in XenPTReg->data it is as 32-bit (0x2300014)!

It is harmless as the read/write functions end up using an size mask
and never modify the bits past 16-bit (reg->size is 2).

This patch fixes the warnings by reading the value using the
proper size.

Note that the check for size is still left in-case the developer
sets bits past the reg->size in the ->init routines. The author
tried to fiddle with QEMU_BUILD_BUG to make this work but failed.

Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2015-09-10 16:47:03 +00:00
audio ossaudio: fix memory leak 2015-07-08 13:11:01 +02:00
backends hostmem: Fix qemu_opt_get_bool() crash in host_memory_backend_init() 2015-07-22 15:09:25 -03:00
block quorum: validate vote threshold against num_children even if read-pattern is fifo 2015-09-04 21:00:32 +02:00
bsd-user linux-user: remove --enable-guest-base/--disable-guest-base 2015-08-24 11:14:17 -07:00
crypto crypto: fix built-in AES decrypt function 2015-07-27 12:22:01 +02:00
default-configs i.MX: Add SOC support for i.MX25 2015-09-07 10:39:30 +01:00
disas disas/arm-a64: Add missing compiler attribute GCC_FMT_ATTR 2015-07-21 11:18:45 +01:00
docs docs: document how to configure the qcow2 L2/refcount caches 2015-09-04 21:00:32 +02:00
dtc@65cc4d2748 dtc: Update dtc / libfdt submodule to version 1.4.0 2015-06-03 23:56:49 +02:00
fpu target-s390x: define default NaN values 2015-06-05 01:37:58 +02:00
fsdev virtfs-proxy-helper: fail gracefully if socket path is too long 2015-06-16 20:32:29 +05:30
gdb-xml s390x/gdb: support reading/writing of control registers 2015-09-07 16:10:43 +02:00
hw xen/pt: Sync up the dev.config and data values. 2015-09-10 16:47:03 +00:00
include xen: use errno instead of rc for xc_domain_add_to_physmap 2015-09-10 12:04:30 +00:00
libcacard libcacard: pkgconfig: tidy dependent libs 2015-06-23 19:57:28 +03:00
libdecnumber remove libdecnumber/dpd/decimal128Local.h 2015-06-23 19:57:27 +03:00
linux-headers linux-headers: Update to 4.2-rc1 2015-07-06 17:59:01 +02:00
linux-user target-arm: Wire up HLT 0xf000 as the A64 semihosting instruction 2015-09-07 10:39:28 +01:00
migration migration: Fix global state with Xen. 2015-08-03 16:13:23 +00:00
net net: Flush queued packets when guest resumes 2015-07-20 18:11:24 +01:00
pc-bios pc-bios/s390-ccw: rebuild image 2015-09-07 16:10:43 +02:00
pixman@87eea99e44 pixman: update internal copy to pixman-0.32.6 2014-09-15 08:14:19 +02:00
po po: fix conflict with %.mo rule in rules.mak 2014-09-26 13:35:08 +02:00
qapi qcow2: add option to clean unused cache entries after some time 2015-09-04 21:00:32 +02:00
qga qemu-ga: implement win32 guest-set-user-password 2015-09-01 13:16:26 -05:00
qobject Include qapi/qmp/qerror.h exactly where needed 2015-06-22 18:20:41 +02:00
qom exec: drop cpu_can_do_io, just read cpu->can_do_io 2015-08-14 23:40:32 +02:00
roms pseries: Update SLOF firmware image to qemu-slof-20150429 2015-07-07 17:44:49 +02:00
scripts Monitor patches 2015-09-04 17:37:50 +01:00
slirp qerror: Move #include out of qerror.h 2015-06-22 18:20:40 +02:00
stubs main-loop: introduce qemu_mutex_iothread_locked 2015-07-01 15:45:50 +02:00
target-alpha cmpbge emulation improvements 2015-09-03 12:09:41 +01:00
target-arm target-arm: Refactor CPU affinity handling 2015-09-07 10:39:31 +01:00
target-cris target-cris: Use movcond and setcond 2015-09-08 08:48:34 +02:00
target-i386 target-i386: Remove x86_cpu_compat_set_features() 2015-08-13 14:08:25 +03:00
target-lm32 cpu-exec: Purge all uses of ENV_GET_CPU() 2015-07-09 15:20:40 +02:00
target-m68k tcg: Remove tcg_gen_trunc_i64_i32 2015-08-24 11:10:54 -07:00
target-microblaze target-microblaze: Use setcond for pcmp* 2015-09-08 08:49:33 +02:00
target-mips tcg: Remove tcg_gen_trunc_i64_i32 2015-08-24 11:10:54 -07:00
target-moxie cpu-exec: Purge all uses of ENV_GET_CPU() 2015-07-09 15:20:40 +02:00
target-openrisc tcg: Remove tcg_gen_trunc_i64_i32 2015-08-24 11:10:54 -07:00
target-ppc cpu-exec: Purge all uses of ENV_GET_CPU() 2015-07-09 15:20:40 +02:00
target-s390x s390x/gdb: support reading/writing of control registers 2015-09-07 16:10:43 +02:00
target-sh4 tcg: Remove tcg_gen_trunc_i64_i32 2015-08-24 11:10:54 -07:00
target-sparc tcg: Remove tcg_gen_trunc_i64_i32 2015-08-24 11:10:54 -07:00
target-tricore tcg: Remove tcg_gen_trunc_i64_i32 2015-08-24 11:10:54 -07:00
target-unicore32 cpu-exec: Purge all uses of ENV_GET_CPU() 2015-07-09 15:20:40 +02:00
target-xtensa tcg: Remove tcg_gen_trunc_i64_i32 2015-08-24 11:10:54 -07:00
tcg tcg/i386: omit a few REXW prefixes in softmmu code 2015-09-02 14:24:10 -07:00
tests Block layer patches 2015-09-07 11:23:08 +01:00
trace Remove superfluous '\n' around error_report() 2015-03-10 08:15:33 +03:00
ui vnc: fix memory corruption (CVE-2015-5225) 2015-08-26 17:54:33 +02:00
util Make pow2ceil() and pow2floor() inline 2015-09-07 14:19:01 +01:00
.exrc qemu: add .exrc 2012-09-07 09:02:44 +03:00
.gitignore qemu-ga: Add .msi files to .gitignore 2015-09-01 11:07:08 -05:00
.gitmodules PPC: Add u-boot firmware for e500 2014-06-16 13:24:35 +02:00
.mailmap Update mailmap 2013-09-05 09:40:31 -05:00
.travis.yml .travis.yml: Add "--enable-modules" 2015-01-26 12:27:05 +01:00
accel.c accel: Create accel object when initializing machine 2014-10-09 15:36:14 +02:00
aio-posix.c AioContext: optimize clearing the EventNotifier 2015-07-22 12:41:40 +01:00
aio-win32.c AioContext: optimize clearing the EventNotifier 2015-07-22 12:41:40 +01:00
arch_init.c smbios: move smbios code into a common folder 2015-08-13 14:08:30 +03:00
async.c AioContext: force event loop iteration using BH 2015-07-29 10:02:06 +01:00
balloon.c Include monitor/monitor.h exactly where needed 2015-06-22 18:20:41 +02:00
block.c block: more check for replaced node 2015-09-02 14:56:39 +01:00
blockdev-nbd.c Include monitor/monitor.h exactly where needed 2015-06-22 18:20:41 +02:00
blockdev.c block: more check for replaced node 2015-09-02 14:56:39 +01:00
blockjob.c blockjob: add block_job_release function 2015-07-07 14:27:14 +01:00
bootdevice.c misc: fix typos in copyright declaration 2015-03-26 14:21:43 +01:00
bt-host.c sysemu: avoid proliferation of include/ subdirectories 2013-04-15 18:19:25 +02:00
bt-vhci.c sysemu: avoid proliferation of include/ subdirectories 2013-04-15 18:19:25 +02:00
Changelog Use qemu-project.org domain name 2013-10-11 09:34:56 -07:00
CODING_STYLE CODING_STYLE: Section about conditional statement 2014-08-15 18:54:06 +04:00
configure xen: use errno instead of rc for xc_domain_add_to_physmap 2015-09-10 12:04:30 +00:00
COPYING
COPYING.LIB
coroutine-gthread.c glib-compat.h: add new thread API emulation on top of pre-2.31 API 2014-06-10 07:44:01 +02:00
coroutine-sigaltstack.c coroutine-sigaltstack: Change jmp_buf to sigjmp_buf 2014-11-11 11:07:55 +03:00
coroutine-ucontext.c coroutine-ucontext: use __thread 2015-01-13 13:43:28 +00:00
coroutine-win32.c coroutine-win32.c: Add noinline attribute to work around gcc bug 2014-06-26 14:08:14 +01:00
cpu-exec.c exec: drop cpu_can_do_io, just read cpu->can_do_io 2015-08-14 23:40:32 +02:00
cpus.c exec: drop cpu_can_do_io, just read cpu->can_do_io 2015-08-14 23:40:32 +02:00
cputlb.c cputlb: Add functions for flushing TLB for a single MMU index 2015-08-25 16:18:33 +01:00
device_tree.c device_tree: Fix a typo 2015-07-27 22:44:47 +03:00
device-hotplug.c pci-hotplug-old: Has been dead for five major releases, bury 2015-03-01 12:37:54 +01:00
disas.c disas: Defeature print_target_address 2015-08-14 23:40:32 +02:00
dma-helpers.c range: remove useless inclusions 2015-04-30 16:05:48 +03:00
dump.c Include qapi/qmp/qerror.h exactly where needed 2015-06-22 18:20:41 +02:00
exec.c exec.c: Use pow2floor() rather than hand-calculation 2015-09-07 14:19:00 +01:00
gdbstub.c gdbstub: Implement gdb_do_syscallv() 2015-09-07 10:39:27 +01:00
HACKING HACKING: Document vaddr type usage 2013-07-23 02:41:31 +02:00
hmp-commands.hx hmp: add info iothreads command 2015-09-04 13:26:26 +02:00
hmp.c hmp: add info iothreads command 2015-09-04 13:26:26 +02:00
hmp.h hmp: add info iothreads command 2015-09-04 13:26:26 +02:00
iohandler.c iohandler: Change return type of qemu_set_fd_handler to "void" 2015-06-12 13:26:21 +01:00
ioport.c - miscellaneous cleanups for TCG (Emilio) and NBD (Bogdan) 2015-04-30 12:04:11 +01:00
iothread.c rcu: actually register threads that have RCU read-side critical sections 2015-07-24 13:57:45 +02:00
kvm-all.c s390x/kvm: make setting of in-kernel irq routes more efficient 2015-09-07 16:10:43 +02:00
kvm-stub.c kvm: some fixes to kvm_resamplefds_allowed 2015-07-06 12:15:14 -06:00
LICENSE vfio: move hw/misc/vfio.c to hw/vfio/pci.c Move vfio.h into include/hw/vfio 2014-12-19 15:24:06 -07:00
main-loop.c main-loop: fix qemu_notify_event for aio_notify optimization 2015-07-27 17:12:19 +01:00
MAINTAINERS First batch of s390x patches for 2.5: 2015-09-03 14:33:03 +01:00
Makefile Makefile: qemu-ga: fix msi target error message 2015-09-01 13:16:26 -05:00
Makefile.objs crypto: introduce new module for computing hash digests 2015-07-07 12:04:07 +02:00
Makefile.target migration: move savevm.c inside migration/ 2015-06-12 06:42:30 +02:00
memory_mapping.c memory_mapping: Rework cpu related includes 2015-06-26 16:00:50 +02:00
memory.c Merge memory_region_init_reservation() into memory_region_init_io() 2015-08-13 11:26:21 +01:00
module-common.c module: implement module loading 2014-02-20 13:14:18 +01:00
monitor.c hmp: add info iothreads command 2015-09-04 13:26:26 +02:00
nbd.c qemu-nbd: only send a limited number of errno codes on the wire 2015-05-08 14:45:11 +02:00
numa.c numa: Fix memory leak in numa_set_mem_node_id() 2015-07-15 16:57:50 -03:00
os-posix.c rcu: do not create thread in pthread_atfork callback 2015-04-01 10:06:38 +02:00
os-win32.c pidfile: stop making pidfile error a special case 2014-11-02 10:04:34 +03:00
page_cache.c xbzrle: rebuild the cache_is_cached function 2015-01-15 17:49:43 +05:30
qapi-schema.json s390x: Dump storage keys qmp command 2015-09-03 12:17:54 +02:00
qdev-monitor.c Include qapi/qmp/qerror.h exactly where needed 2015-06-22 18:20:41 +02:00
qdict-test-data.txt Introduce QDict test data file 2009-09-04 09:37:34 -05:00
qemu-bridge-helper.c qemu-bridge-helper: Fix fd leak in main() 2014-06-27 10:39:10 +02:00
qemu-char.c qemu-char: Fix missed data on unix socket 2015-07-23 07:37:38 +02:00
qemu-coroutine-io.c coroutine-io: Return -errno in case of error 2015-03-18 12:07:21 +01:00
qemu-coroutine-lock.c coroutine: remove unnecessary parentheses in qemu_co_queue_empty 2015-04-30 16:05:49 +03:00
qemu-coroutine-sleep.c coroutine: Drop co_sleep_ns 2014-08-29 10:46:58 +01:00
qemu-coroutine.c coroutine: Clean up qemu_coroutine_enter() 2015-03-09 11:11:59 +01:00
qemu-doc.texi qga: start a man page 2015-09-01 13:16:26 -05:00
qemu-ga.texi qga: start a man page 2015-09-01 13:16:26 -05:00
qemu-img-cmds.hx qemu-img: Add progress output for amend 2014-11-03 11:41:48 +00:00
qemu-img.c qemu-img: Fix crash in amend invocation 2015-09-04 20:59:48 +02:00
qemu-img.texi qemu-img: Add progress output for amend 2014-11-03 11:41:48 +00:00
qemu-io-cmds.c qerror: Move #include out of qerror.h 2015-06-22 18:20:40 +02:00
qemu-io.c qerror: Move #include out of qerror.h 2015-06-22 18:20:40 +02:00
qemu-log.c qemu-log: Correct help text of 'log cpu_reset' 2015-02-10 09:27:20 +03:00
qemu-nbd.c qemu-nbd: remove unnecessary qemu_notify_event() 2015-08-14 23:40:32 +02:00
qemu-nbd.texi nbd: Miscellaneous typo fixes. 2014-05-24 00:07:29 +04:00
qemu-options-wrapper.h vl.c: In qemu -h output, only print options for the arch we are running as 2011-12-19 10:27:33 -06:00
qemu-options.h
qemu-options.hx xen, gfx passthrough: basic graphics passthrough support 2015-09-10 12:04:28 +00:00
qemu-seccomp.c seccomp: add mlockall to whitelist 2015-01-23 14:07:08 +01:00
qemu-tech.texi qemu-doc: fix typos 2015-07-24 13:57:45 +02:00
qemu-timer.c qemu-timer: initialize "timers_done_ev" to set 2015-07-22 12:41:32 +01:00
qemu.nsi nsis: Improved support for parallel installation of 32 and 64 bit code 2013-11-07 07:02:44 +01:00
qemu.sasl sasl: Avoid 'Could not find keytab file' in syslog 2014-03-15 13:54:18 +04:00
qjson.c QJSON: Use OBJECT_CHECK 2015-05-11 08:59:07 -04:00
qmp-commands.hx s390x: Dump storage keys qmp command 2015-09-03 12:17:54 +02:00
qmp.c Include monitor/monitor.h exactly where needed 2015-06-22 18:20:41 +02:00
qtest.c qtest: pre-buffer hex nibs 2015-05-22 15:58:22 -04:00
README Use qemu-project.org domain name 2013-10-11 09:34:56 -07:00
rules.mak make: load only required dependency files. 2015-08-13 14:08:25 +03:00
softmmu_template.h exec: drop cpu_can_do_io, just read cpu->can_do_io 2015-08-14 23:40:32 +02:00
spice-qemu-char.c spice: fix spice_chr_add_watch() pre-condition 2015-05-29 09:56:01 +02:00
tcg-runtime.c tcg: Push tcg-runtime routines into exec/helper-* 2014-05-28 09:33:54 -07:00
tci.c tcg: implement real ext_i32_i64 and extu_i32_i64 ops 2015-08-24 11:10:54 -07:00
thread-pool.c thread-pool: clean up thread_pool_completion_bh() 2015-04-28 15:36:09 +02:00
thunk.c linux-user: Allocate thunk size dynamically 2015-06-15 11:36:58 +03:00
tpm.c Include monitor/monitor.h exactly where needed 2015-06-22 18:20:41 +02:00
trace-events xen-hvm: Add trace to ioreq 2015-09-08 15:20:20 +00:00
translate-all.c linux-user: remove --enable-guest-base/--disable-guest-base 2015-08-24 11:14:17 -07:00
translate-all.h translate-all: remove unnecessary argument to tb_invalidate_phys_range 2015-06-05 17:09:59 +02:00
user-exec.c osdep.h: Remove qemu_printf 2015-08-19 16:29:53 +01:00
VERSION Open 2.5 development tree 2015-08-11 23:15:55 +01:00
version.rc Use qemu-project.org domain name 2013-10-11 09:34:56 -07:00
vl.c xen, gfx passthrough: basic graphics passthrough support 2015-09-10 12:04:28 +00:00
xen-common-stub.c accel: Move Xen registration code to xen-common.c 2014-10-04 08:59:15 +02:00
xen-common.c migration: Fix regression for xenfv and pc,accel=xen machine. 2015-08-03 16:13:40 +00:00
xen-hvm-stub.c xen: Remove xen_cmos_set_s3_resume() 2015-03-10 08:15:33 +03:00
xen-hvm.c xen: use errno instead of rc for xc_domain_add_to_physmap 2015-09-10 12:04:30 +00:00
xen-mapcache.c xen: add a lock for the mapcache 2015-01-20 14:24:17 +00:00

Read the documentation in qemu-doc.html or on http://wiki.qemu-project.org

- QEMU team