mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
* TCG 8-byte atomic accesses bugfix (Andrew) * Report disk rotation rate (Daniel) * Report invalid scsi-disk block size configuration (Mark) * KVM and memory API MemoryListener fixes (David, Maxime, Peter Xu) * x86 CPU hotplug crash fix (Igor) * Load/store API documentation (Peter Maydell) * Small fixes by myself and Thomas * qdev DEVICE_DELETED deferral (Michael) # gpg: Signature made Wed 18 Oct 2017 10:56:24 BST # gpg: using RSA key 0xBFFBD25F78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: (29 commits) scsi: reject configurations with logical block size > physical block size qdev: defer DEVICE_DEL event until instance_finalize() Revert "qdev: Free QemuOpts when the QOM path goes away" qdev: store DeviceState's canonical path to use when unparenting qemu-pr-helper: use new libmultipath API watch_mem_write: implement 8-byte accesses notdirty_mem_write: implement 8-byte accesses memory: reuse section_from_flat_range() kvm: simplify kvm_align_section() kvm: region_add and region_del is not called on updates kvm: fix error message when failing to unregister slot kvm: tolerate non-existing slot for log_start/log_stop/log_sync kvm: fix alignment of ram address memory: call log_start after region_add target/i386: trap on instructions longer than >15 bytes target/i386: introduce x86_ld*_code tco: add trace events docs/devel/loads-stores.rst: Document our various load and store APIs nios2: define tcg_env build: remove CONFIG_LIBDECNUMBER ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
@@ -102,12 +102,6 @@ obj-y += target/$(TARGET_BASE_ARCH)/
|
||||
obj-y += disas.o
|
||||
obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
|
||||
|
||||
obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decContext.o
|
||||
obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decNumber.o
|
||||
obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal32.o
|
||||
obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal64.o
|
||||
obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal128.o
|
||||
|
||||
#########################################################
|
||||
# Linux user emulator target
|
||||
|
||||
|
||||
+14
-25
@@ -197,26 +197,20 @@ static hwaddr kvm_align_section(MemoryRegionSection *section,
|
||||
hwaddr *start)
|
||||
{
|
||||
hwaddr size = int128_get64(section->size);
|
||||
hwaddr delta;
|
||||
|
||||
*start = section->offset_within_address_space;
|
||||
hwaddr delta, aligned;
|
||||
|
||||
/* kvm works in page size chunks, but the function may be called
|
||||
with sub-page size and unaligned start address. Pad the start
|
||||
address to next and truncate size to previous page boundary. */
|
||||
delta = qemu_real_host_page_size - (*start & ~qemu_real_host_page_mask);
|
||||
delta &= ~qemu_real_host_page_mask;
|
||||
*start += delta;
|
||||
aligned = ROUND_UP(section->offset_within_address_space,
|
||||
qemu_real_host_page_size);
|
||||
delta = aligned - section->offset_within_address_space;
|
||||
*start = aligned;
|
||||
if (delta > size) {
|
||||
return 0;
|
||||
}
|
||||
size -= delta;
|
||||
size &= qemu_real_host_page_mask;
|
||||
if (*start & ~qemu_real_host_page_mask) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return size;
|
||||
return (size - delta) & qemu_real_host_page_mask;
|
||||
}
|
||||
|
||||
int kvm_physical_memory_addr_from_host(KVMState *s, void *ram,
|
||||
@@ -394,8 +388,8 @@ static int kvm_section_update_flags(KVMMemoryListener *kml,
|
||||
|
||||
mem = kvm_lookup_matching_slot(kml, start_addr, size);
|
||||
if (!mem) {
|
||||
fprintf(stderr, "%s: error finding slot\n", __func__);
|
||||
abort();
|
||||
/* We don't have a slot if we want to trap every access. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return kvm_slot_update_flags(kml, mem, section->mr);
|
||||
@@ -470,8 +464,8 @@ static int kvm_physical_sync_dirty_bitmap(KVMMemoryListener *kml,
|
||||
if (size) {
|
||||
mem = kvm_lookup_matching_slot(kml, start_addr, size);
|
||||
if (!mem) {
|
||||
fprintf(stderr, "%s: error finding slot\n", __func__);
|
||||
abort();
|
||||
/* We don't have a slot if we want to trap every access. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* XXX bad kernel interface alert
|
||||
@@ -717,11 +711,12 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml,
|
||||
return;
|
||||
}
|
||||
|
||||
/* use aligned delta to align the ram address */
|
||||
ram = memory_region_get_ram_ptr(mr) + section->offset_within_region +
|
||||
(section->offset_within_address_space - start_addr);
|
||||
(start_addr - section->offset_within_address_space);
|
||||
|
||||
mem = kvm_lookup_matching_slot(kml, start_addr, size);
|
||||
if (!add) {
|
||||
mem = kvm_lookup_matching_slot(kml, start_addr, size);
|
||||
if (!mem) {
|
||||
return;
|
||||
}
|
||||
@@ -733,19 +728,13 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml,
|
||||
mem->memory_size = 0;
|
||||
err = kvm_set_user_memory_region(kml, mem);
|
||||
if (err) {
|
||||
fprintf(stderr, "%s: error unregistering overlapping slot: %s\n",
|
||||
fprintf(stderr, "%s: error unregistering slot: %s\n",
|
||||
__func__, strerror(-err));
|
||||
abort();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (mem) {
|
||||
/* update the slot */
|
||||
kvm_slot_update_flags(kml, mem, mr);
|
||||
return;
|
||||
}
|
||||
|
||||
/* register the new slot */
|
||||
mem = kvm_alloc_slot(kml);
|
||||
mem->memory_size = size;
|
||||
|
||||
+9
-10
@@ -332,10 +332,6 @@ static void tcp_chr_free_connection(Chardev *chr)
|
||||
SocketChardev *s = SOCKET_CHARDEV(chr);
|
||||
int i;
|
||||
|
||||
if (!s->connected) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (s->read_msgfds_num) {
|
||||
for (i = 0; i < s->read_msgfds_num; i++) {
|
||||
close(s->read_msgfds[i]);
|
||||
@@ -394,22 +390,25 @@ static void update_disconnected_filename(SocketChardev *s)
|
||||
s->is_listen, s->is_telnet);
|
||||
}
|
||||
|
||||
/* NB may be called even if tcp_chr_connect has not been
|
||||
* reached, due to TLS or telnet initialization failure,
|
||||
* so can *not* assume s->connected == true
|
||||
*/
|
||||
static void tcp_chr_disconnect(Chardev *chr)
|
||||
{
|
||||
SocketChardev *s = SOCKET_CHARDEV(chr);
|
||||
|
||||
if (!s->connected) {
|
||||
return;
|
||||
}
|
||||
bool emit_close = s->connected;
|
||||
|
||||
tcp_chr_free_connection(chr);
|
||||
|
||||
if (s->listen_ioc) {
|
||||
if (s->listen_ioc && s->listen_tag == 0) {
|
||||
s->listen_tag = qio_channel_add_watch(
|
||||
QIO_CHANNEL(s->listen_ioc), G_IO_IN, tcp_chr_accept, chr, NULL);
|
||||
}
|
||||
update_disconnected_filename(s);
|
||||
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
|
||||
if (emit_close) {
|
||||
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
|
||||
}
|
||||
if (s->reconnect_time) {
|
||||
qemu_chr_socket_restart_timer(chr);
|
||||
}
|
||||
|
||||
@@ -3335,9 +3335,17 @@ if test "$mpath" != "no" ; then
|
||||
#include <mpath_persist.h>
|
||||
unsigned mpath_mx_alloc_len = 1024;
|
||||
int logsink;
|
||||
static struct config *multipath_conf;
|
||||
extern struct udev *udev;
|
||||
extern struct config *get_multipath_config(void);
|
||||
extern void put_multipath_config(struct config *conf);
|
||||
struct udev *udev;
|
||||
struct config *get_multipath_config(void) { return multipath_conf; }
|
||||
void put_multipath_config(struct config *conf) { }
|
||||
|
||||
int main(void) {
|
||||
struct udev *udev = udev_new();
|
||||
mpath_lib_init(udev);
|
||||
udev = udev_new();
|
||||
multipath_conf = mpath_lib_init();
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
# Default configuration for ppc-linux-user
|
||||
CONFIG_LIBDECNUMBER=y
|
||||
|
||||
@@ -46,7 +46,6 @@ CONFIG_E500=y
|
||||
CONFIG_OPENPIC_KVM=$(call land,$(CONFIG_E500),$(CONFIG_KVM))
|
||||
CONFIG_PLATFORM_BUS=y
|
||||
CONFIG_ETSEC=y
|
||||
CONFIG_LIBDECNUMBER=y
|
||||
CONFIG_SM501=y
|
||||
# For PReP
|
||||
CONFIG_SERIAL_ISA=y
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
# Default configuration for ppc64-linux-user
|
||||
CONFIG_LIBDECNUMBER=y
|
||||
|
||||
@@ -51,7 +51,6 @@ CONFIG_E500=y
|
||||
CONFIG_OPENPIC_KVM=$(call land,$(CONFIG_E500),$(CONFIG_KVM))
|
||||
CONFIG_PLATFORM_BUS=y
|
||||
CONFIG_ETSEC=y
|
||||
CONFIG_LIBDECNUMBER=y
|
||||
CONFIG_SM501=y
|
||||
# For pSeries
|
||||
CONFIG_XICS=$(CONFIG_PSERIES)
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
# Default configuration for ppc64abi32-linux-user
|
||||
CONFIG_LIBDECNUMBER=y
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
# Default configuration for ppc64le-linux-user
|
||||
CONFIG_LIBDECNUMBER=y
|
||||
|
||||
@@ -15,5 +15,4 @@ CONFIG_PTIMER=y
|
||||
CONFIG_I8259=y
|
||||
CONFIG_XILINX=y
|
||||
CONFIG_XILINX_ETHLITE=y
|
||||
CONFIG_LIBDECNUMBER=y
|
||||
CONFIG_SM501=y
|
||||
|
||||
@@ -190,7 +190,6 @@ void target_disas(FILE *out, CPUState *cpu, target_ulong code,
|
||||
|
||||
s.cpu = cpu;
|
||||
s.info.read_memory_func = target_read_memory;
|
||||
s.info.read_memory_inner_func = NULL;
|
||||
s.info.buffer_vma = code;
|
||||
s.info.buffer_length = size;
|
||||
s.info.print_address_func = generic_print_address;
|
||||
|
||||
@@ -0,0 +1,396 @@
|
||||
..
|
||||
Copyright (c) 2017 Linaro Limited
|
||||
Written by Peter Maydell
|
||||
|
||||
===================
|
||||
Load and Store APIs
|
||||
===================
|
||||
|
||||
QEMU internally has multiple families of functions for performing
|
||||
loads and stores. This document attempts to enumerate them all
|
||||
and indicate when to use them. It does not provide detailed
|
||||
documentation of each API -- for that you should look at the
|
||||
documentation comments in the relevant header files.
|
||||
|
||||
|
||||
``ld*_p and st*_p``
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
These functions operate on a host pointer, and should be used
|
||||
when you already have a pointer into host memory (corresponding
|
||||
to guest ram or a local buffer). They deal with doing accesses
|
||||
with the desired endianness and with correctly handling
|
||||
potentially unaligned pointer values.
|
||||
|
||||
Function names follow the pattern:
|
||||
|
||||
load: ``ld{type}{sign}{size}_{endian}_p(ptr)``
|
||||
|
||||
store: ``st{type}{size}_{endian}_p(ptr, val)``
|
||||
|
||||
``type``
|
||||
- (empty) : integer access
|
||||
- ``f`` : float access
|
||||
|
||||
``sign``
|
||||
- (empty) : for 32 or 64 bit sizes (including floats and doubles)
|
||||
- ``u`` : unsigned
|
||||
- ``s`` : signed
|
||||
|
||||
``size``
|
||||
- ``b`` : 8 bits
|
||||
- ``w`` : 16 bits
|
||||
- ``l`` : 32 bits
|
||||
- ``q`` : 64 bits
|
||||
|
||||
``endian``
|
||||
- ``he`` : host endian
|
||||
- ``be`` : big endian
|
||||
- ``le`` : little endian
|
||||
|
||||
The ``_{endian}`` infix is omitted for target-endian accesses.
|
||||
|
||||
The target endian accessors are only available to source
|
||||
files which are built per-target.
|
||||
|
||||
Regexes for git grep
|
||||
- ``\<ldf\?[us]\?[bwlq]\(_[hbl]e\)\?_p\>``
|
||||
- ``\<stf\?[bwlq]\(_[hbl]e\)\?_p\>``
|
||||
|
||||
``cpu_{ld,st}_*``
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
These functions operate on a guest virtual address. Be aware
|
||||
that these functions may cause a guest CPU exception to be
|
||||
taken (e.g. for an alignment fault or MMU fault) which will
|
||||
result in guest CPU state being updated and control longjumping
|
||||
out of the function call. They should therefore only be used
|
||||
in code that is implementing emulation of the target CPU.
|
||||
|
||||
These functions may throw an exception (longjmp() back out
|
||||
to the top level TCG loop). This means they must only be used
|
||||
from helper functions where the translator has saved all
|
||||
necessary CPU state before generating the helper function call.
|
||||
It's usually better to use the ``_ra`` variants described below
|
||||
from helper functions, but these functions are the right choice
|
||||
for calls made from hooks like the CPU do_interrupt hook or
|
||||
when you know for certain that the translator had to save all
|
||||
the CPU state that ``cpu_restore_state()`` would restore anyway.
|
||||
|
||||
Function names follow the pattern:
|
||||
|
||||
load: ``cpu_ld{sign}{size}_{mmusuffix}(env, ptr)``
|
||||
|
||||
store: ``cpu_st{size}_{mmusuffix}(env, ptr, val)``
|
||||
|
||||
``sign``
|
||||
- (empty) : for 32 or 64 bit sizes
|
||||
- ``u`` : unsigned
|
||||
- ``s`` : signed
|
||||
|
||||
``size``
|
||||
- ``b`` : 8 bits
|
||||
- ``w`` : 16 bits
|
||||
- ``l`` : 32 bits
|
||||
- ``q`` : 64 bits
|
||||
|
||||
``mmusuffix`` is one of the generic suffixes ``data`` or ``code``, or
|
||||
(for softmmu configs) a target-specific MMU mode suffix as defined
|
||||
in the target's ``cpu.h``.
|
||||
|
||||
Regexes for git grep
|
||||
- ``\<cpu_ld[us]\?[bwlq]_[a-zA-Z0-9]\+\>``
|
||||
- ``\<cpu_st[bwlq]_[a-zA-Z0-9]\+\>``
|
||||
|
||||
``cpu_{ld,st}_*_ra``
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
These functions work like the ``cpu_{ld,st}_*`` functions except
|
||||
that they also take a ``retaddr`` argument. This extra argument
|
||||
allows for correct unwinding of any exception that is taken,
|
||||
and should generally be the result of GETPC() called directly
|
||||
from the top level HELPER(foo) function (i.e. the return address
|
||||
in the generated code).
|
||||
|
||||
These are generally the preferred way to do accesses by guest
|
||||
virtual address from helper functions; see the documentation
|
||||
of the non-``_ra`` variants for when those would be better.
|
||||
|
||||
Calling these functions with a ``retaddr`` argument of 0 is
|
||||
equivalent to calling the non-``_ra`` version of the function.
|
||||
|
||||
Function names follow the pattern:
|
||||
|
||||
load: ``cpu_ld{sign}{size}_{mmusuffix}_ra(env, ptr, retaddr)``
|
||||
|
||||
store: ``cpu_st{sign}{size}_{mmusuffix}_ra(env, ptr, val, retaddr)``
|
||||
|
||||
Regexes for git grep
|
||||
- ``\<cpu_ld[us]\?[bwlq]_[a-zA-Z0-9]\+_ra\>``
|
||||
- ``\<cpu_st[bwlq]_[a-zA-Z0-9]\+_ra\>``
|
||||
|
||||
``helper_*_{ld,st}*mmu``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
These functions are intended primarily to be called by the code
|
||||
generated by the TCG backend. They may also be called by target
|
||||
CPU helper function code. Like the ``cpu_{ld,st}_*_ra`` functions
|
||||
they perform accesses by guest virtual address; the difference is
|
||||
that these functions allow you to specify an ``opindex`` parameter
|
||||
which encodes (among other things) the mmu index to use for the
|
||||
access. This is necessary if your helper needs to make an access
|
||||
via a specific mmu index (for instance, an "always as non-privileged"
|
||||
access) rather than using the default mmu index for the current state
|
||||
of the guest CPU.
|
||||
|
||||
The ``opindex`` parameter should be created by calling ``make_memop_idx()``.
|
||||
|
||||
The ``retaddr`` parameter should be the result of GETPC() called directly
|
||||
from the top level HELPER(foo) function (or 0 if no guest CPU state
|
||||
unwinding is required).
|
||||
|
||||
**TODO** The names of these functions are a bit odd for historical
|
||||
reasons because they were originally expected to be called only from
|
||||
within generated code. We should rename them to bring them
|
||||
more in line with the other memory access functions.
|
||||
|
||||
load: ``helper_{endian}_ld{sign}{size}_mmu(env, addr, opindex, retaddr)``
|
||||
|
||||
load (code): ``helper_{endian}_ld{sign}{size}_cmmu(env, addr, opindex, retaddr)``
|
||||
|
||||
store: ``helper_{endian}_st{size}_mmu(env, addr, val, opindex, retaddr)``
|
||||
|
||||
``sign``
|
||||
- (empty) : for 32 or 64 bit sizes
|
||||
- ``u`` : unsigned
|
||||
- ``s`` : signed
|
||||
|
||||
``size``
|
||||
- ``b`` : 8 bits
|
||||
- ``w`` : 16 bits
|
||||
- ``l`` : 32 bits
|
||||
- ``q`` : 64 bits
|
||||
|
||||
``endian``
|
||||
- ``le`` : little endian
|
||||
- ``be`` : big endian
|
||||
- ``ret`` : target endianness
|
||||
|
||||
Regexes for git grep
|
||||
- ``\<helper_\(le\|be\|ret\)_ld[us]\?[bwlq]_c\?mmu\>``
|
||||
- ``\<helper_\(le\|be\|ret\)_st[bwlq]_mmu\>``
|
||||
|
||||
``address_space_*``
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
These functions are the primary ones to use when emulating CPU
|
||||
or device memory accesses. They take an AddressSpace, which is the
|
||||
way QEMU defines the view of memory that a device or CPU has.
|
||||
(They generally correspond to being the "master" end of a hardware bus
|
||||
or bus fabric.)
|
||||
|
||||
Each CPU has an AddressSpace. Some kinds of CPU have more than
|
||||
one AddressSpace (for instance ARM guest CPUs have an AddressSpace
|
||||
for the Secure world and one for NonSecure if they implement TrustZone).
|
||||
Devices which can do DMA-type operations should generally have an
|
||||
AddressSpace. There is also a "system address space" which typically
|
||||
has all the devices and memory that all CPUs can see. (Some older
|
||||
device models use the "system address space" rather than properly
|
||||
modelling that they have an AddressSpace of their own.)
|
||||
|
||||
Functions are provided for doing byte-buffer reads and writes,
|
||||
and also for doing one-data-item loads and stores.
|
||||
|
||||
In all cases the caller provides a MemTxAttrs to specify bus
|
||||
transaction attributes, and can check whether the memory transaction
|
||||
succeeded using a MemTxResult return code.
|
||||
|
||||
``address_space_read(address_space, addr, attrs, buf, len)``
|
||||
|
||||
``address_space_write(address_space, addr, attrs, buf, len)``
|
||||
|
||||
``address_space_rw(address_space, addr, attrs, buf, len, is_write)``
|
||||
|
||||
``address_space_ld{sign}{size}_{endian}(address_space, addr, attrs, txresult)``
|
||||
|
||||
``address_space_st{size}_{endian}(address_space, addr, val, attrs, txresult)``
|
||||
|
||||
``sign``
|
||||
- (empty) : for 32 or 64 bit sizes
|
||||
- ``u`` : unsigned
|
||||
|
||||
(No signed load operations are provided.)
|
||||
|
||||
``size``
|
||||
- ``b`` : 8 bits
|
||||
- ``w`` : 16 bits
|
||||
- ``l`` : 32 bits
|
||||
- ``q`` : 64 bits
|
||||
|
||||
``endian``
|
||||
- ``le`` : little endian
|
||||
- ``be`` : big endian
|
||||
|
||||
The ``_{endian}`` suffix is omitted for byte accesses.
|
||||
|
||||
Regexes for git grep
|
||||
- ``\<address_space_\(read\|write\|rw\)\>``
|
||||
- ``\<address_space_ldu\?[bwql]\(_[lb]e\)\?\>``
|
||||
- ``\<address_space_st[bwql]\(_[lb]e\)\?\>``
|
||||
|
||||
``{ld,st}*_phys``
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
These are functions which are identical to
|
||||
``address_space_{ld,st}*``, except that they always pass
|
||||
``MEMTXATTRS_UNSPECIFIED`` for the transaction attributes, and ignore
|
||||
whether the transaction succeeded or failed.
|
||||
|
||||
The fact that they ignore whether the transaction succeeded means
|
||||
they should not be used in new code, unless you know for certain
|
||||
that your code will only be used in a context where the CPU or
|
||||
device doing the access has no way to report such an error.
|
||||
|
||||
``load: ld{sign}{size}_{endian}_phys``
|
||||
|
||||
``store: st{size}_{endian}_phys``
|
||||
|
||||
``sign``
|
||||
- (empty) : for 32 or 64 bit sizes
|
||||
- ``u`` : unsigned
|
||||
|
||||
(No signed load operations are provided.)
|
||||
|
||||
``size``
|
||||
- ``b`` : 8 bits
|
||||
- ``w`` : 16 bits
|
||||
- ``l`` : 32 bits
|
||||
- ``q`` : 64 bits
|
||||
|
||||
``endian``
|
||||
- ``le`` : little endian
|
||||
- ``be`` : big endian
|
||||
|
||||
The ``_{endian}_`` infix is omitted for byte accesses.
|
||||
|
||||
Regexes for git grep
|
||||
- ``\<ldu\?[bwlq]\(_[bl]e\)\?_phys\>``
|
||||
- ``\<st[bwlq]\(_[bl]e\)\?_phys\>``
|
||||
|
||||
``cpu_physical_memory_*``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
These are convenience functions which are identical to
|
||||
``address_space_*`` but operate specifically on the system address space,
|
||||
always pass a ``MEMTXATTRS_UNSPECIFIED`` set of memory attributes and
|
||||
ignore whether the memory transaction succeeded or failed.
|
||||
For new code they are better avoided:
|
||||
|
||||
* there is likely to be behaviour you need to model correctly for a
|
||||
failed read or write operation
|
||||
* a device should usually perform operations on its own AddressSpace
|
||||
rather than using the system address space
|
||||
|
||||
``cpu_physical_memory_read``
|
||||
|
||||
``cpu_physical_memory_write``
|
||||
|
||||
``cpu_physical_memory_rw``
|
||||
|
||||
Regexes for git grep
|
||||
- ``\<cpu_physical_memory_\(read\|write\|rw\)\>``
|
||||
|
||||
``cpu_physical_memory_write_rom``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This function performs a write by physical address like
|
||||
``address_space_write``, except that if the write is to a ROM then
|
||||
the ROM contents will be modified, even though a write by the guest
|
||||
CPU to the ROM would be ignored.
|
||||
|
||||
Note that unlike ``cpu_physical_memory_write()`` this function takes
|
||||
an AddressSpace argument, but unlike ``address_space_write()`` this
|
||||
function does not take a ``MemTxAttrs`` or return a ``MemTxResult``.
|
||||
|
||||
**TODO**: we should probably clean up this inconsistency and
|
||||
turn the function into ``address_space_write_rom`` with an API
|
||||
matching ``address_space_write``.
|
||||
|
||||
``cpu_physical_memory_write_rom``
|
||||
|
||||
|
||||
``cpu_memory_rw_debug``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Access CPU memory by virtual address for debug purposes.
|
||||
|
||||
This function is intended for use by the GDB stub and similar code.
|
||||
It takes a virtual address, converts it to a physical address via
|
||||
an MMU lookup using the current settings of the specified CPU,
|
||||
and then performs the access (using ``address_space_rw`` for
|
||||
reads or ``cpu_physical_memory_write_rom`` for writes).
|
||||
This means that if the access is a write to a ROM then this
|
||||
function will modify the contents (whereas a normal guest CPU access
|
||||
would ignore the write attempt).
|
||||
|
||||
``cpu_memory_rw_debug``
|
||||
|
||||
``dma_memory_*``
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
These behave like ``address_space_*``, except that they perform a DMA
|
||||
barrier operation first.
|
||||
|
||||
**TODO**: We should provide guidance on when you need the DMA
|
||||
barrier operation and when it's OK to use ``address_space_*``, and
|
||||
make sure our existing code is doing things correctly.
|
||||
|
||||
``dma_memory_read``
|
||||
|
||||
``dma_memory_write``
|
||||
|
||||
``dma_memory_rw``
|
||||
|
||||
Regexes for git grep
|
||||
- ``\<dma_memory_\(read\|write\|rw\)\>``
|
||||
|
||||
``pci_dma_*`` and ``{ld,st}*_pci_dma``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
These functions are specifically for PCI device models which need to
|
||||
perform accesses where the PCI device is a bus master. You pass them a
|
||||
``PCIDevice *`` and they will do ``dma_memory_*`` operations on the
|
||||
correct address space for that device.
|
||||
|
||||
``pci_dma_read``
|
||||
|
||||
``pci_dma_write``
|
||||
|
||||
``pci_dma_rw``
|
||||
|
||||
``load: ld{sign}{size}_{endian}_pci_dma``
|
||||
|
||||
``store: st{size}_{endian}_pci_dma``
|
||||
|
||||
``sign``
|
||||
- (empty) : for 32 or 64 bit sizes
|
||||
- ``u`` : unsigned
|
||||
|
||||
(No signed load operations are provided.)
|
||||
|
||||
``size``
|
||||
- ``b`` : 8 bits
|
||||
- ``w`` : 16 bits
|
||||
- ``l`` : 32 bits
|
||||
- ``q`` : 64 bits
|
||||
|
||||
``endian``
|
||||
- ``le`` : little endian
|
||||
- ``be`` : big endian
|
||||
|
||||
The ``_{endian}_`` infix is omitted for byte accesses.
|
||||
|
||||
Regexes for git grep
|
||||
- ``\<pci_dma_\(read\|write\|rw\)\>``
|
||||
- ``\<ldu\?[bwlq]\(_[bl]e\)\?_pci_dma\>``
|
||||
- ``\<st[bwlq]\(_[bl]e\)\?_pci_dma\>``
|
||||
@@ -465,11 +465,29 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x
|
||||
return section;
|
||||
}
|
||||
|
||||
/* Called from RCU critical section */
|
||||
/**
|
||||
* flatview_do_translate - translate an address in FlatView
|
||||
*
|
||||
* @fv: the flat view that we want to translate on
|
||||
* @addr: the address to be translated in above address space
|
||||
* @xlat: the translated address offset within memory region. It
|
||||
* cannot be @NULL.
|
||||
* @plen_out: valid read/write length of the translated address. It
|
||||
* can be @NULL when we don't care about it.
|
||||
* @page_mask_out: page mask for the translated address. This
|
||||
* should only be meaningful for IOMMU translated
|
||||
* addresses, since there may be huge pages that this bit
|
||||
* would tell. It can be @NULL if we don't care about it.
|
||||
* @is_write: whether the translation operation is for write
|
||||
* @is_mmio: whether this can be MMIO, set true if it can
|
||||
*
|
||||
* This function is called from RCU critical section
|
||||
*/
|
||||
static MemoryRegionSection flatview_do_translate(FlatView *fv,
|
||||
hwaddr addr,
|
||||
hwaddr *xlat,
|
||||
hwaddr *plen,
|
||||
hwaddr *plen_out,
|
||||
hwaddr *page_mask_out,
|
||||
bool is_write,
|
||||
bool is_mmio,
|
||||
AddressSpace **target_as)
|
||||
@@ -478,11 +496,17 @@ static MemoryRegionSection flatview_do_translate(FlatView *fv,
|
||||
MemoryRegionSection *section;
|
||||
IOMMUMemoryRegion *iommu_mr;
|
||||
IOMMUMemoryRegionClass *imrc;
|
||||
hwaddr page_mask = (hwaddr)(-1);
|
||||
hwaddr plen = (hwaddr)(-1);
|
||||
|
||||
if (plen_out) {
|
||||
plen = *plen_out;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
section = address_space_translate_internal(
|
||||
flatview_to_dispatch(fv), addr, &addr,
|
||||
plen, is_mmio);
|
||||
&plen, is_mmio);
|
||||
|
||||
iommu_mr = memory_region_get_iommu(section->mr);
|
||||
if (!iommu_mr) {
|
||||
@@ -494,7 +518,8 @@ static MemoryRegionSection flatview_do_translate(FlatView *fv,
|
||||
IOMMU_WO : IOMMU_RO);
|
||||
addr = ((iotlb.translated_addr & ~iotlb.addr_mask)
|
||||
| (addr & iotlb.addr_mask));
|
||||
*plen = MIN(*plen, (addr | iotlb.addr_mask) - addr + 1);
|
||||
page_mask &= iotlb.addr_mask;
|
||||
plen = MIN(plen, (addr | iotlb.addr_mask) - addr + 1);
|
||||
if (!(iotlb.perm & (1 << is_write))) {
|
||||
goto translate_fail;
|
||||
}
|
||||
@@ -505,6 +530,19 @@ static MemoryRegionSection flatview_do_translate(FlatView *fv,
|
||||
|
||||
*xlat = addr;
|
||||
|
||||
if (page_mask == (hwaddr)(-1)) {
|
||||
/* Not behind an IOMMU, use default page size. */
|
||||
page_mask = ~TARGET_PAGE_MASK;
|
||||
}
|
||||
|
||||
if (page_mask_out) {
|
||||
*page_mask_out = page_mask;
|
||||
}
|
||||
|
||||
if (plen_out) {
|
||||
*plen_out = plen;
|
||||
}
|
||||
|
||||
return *section;
|
||||
|
||||
translate_fail:
|
||||
@@ -516,14 +554,14 @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
|
||||
bool is_write)
|
||||
{
|
||||
MemoryRegionSection section;
|
||||
hwaddr xlat, plen;
|
||||
hwaddr xlat, page_mask;
|
||||
|
||||
/* Try to get maximum page mask during translation. */
|
||||
plen = (hwaddr)-1;
|
||||
|
||||
/* This can never be MMIO. */
|
||||
section = flatview_do_translate(address_space_to_flatview(as), addr,
|
||||
&xlat, &plen, is_write, false, &as);
|
||||
/*
|
||||
* This can never be MMIO, and we don't really care about plen,
|
||||
* but page mask.
|
||||
*/
|
||||
section = flatview_do_translate(address_space_to_flatview(as), addr, &xlat,
|
||||
NULL, &page_mask, is_write, false, &as);
|
||||
|
||||
/* Illegal translation */
|
||||
if (section.mr == &io_mem_unassigned) {
|
||||
@@ -534,22 +572,11 @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr,
|
||||
xlat += section.offset_within_address_space -
|
||||
section.offset_within_region;
|
||||
|
||||
if (plen == (hwaddr)-1) {
|
||||
/*
|
||||
* We use default page size here. Logically it only happens
|
||||
* for identity mappings.
|
||||
*/
|
||||
plen = TARGET_PAGE_SIZE;
|
||||
}
|
||||
|
||||
/* Convert to address mask */
|
||||
plen -= 1;
|
||||
|
||||
return (IOMMUTLBEntry) {
|
||||
.target_as = as,
|
||||
.iova = addr & ~plen,
|
||||
.translated_addr = xlat & ~plen,
|
||||
.addr_mask = plen,
|
||||
.iova = addr & ~page_mask,
|
||||
.translated_addr = xlat & ~page_mask,
|
||||
.addr_mask = page_mask,
|
||||
/* IOTLBs are for DMAs, and DMA only allows on RAMs. */
|
||||
.perm = IOMMU_RW,
|
||||
};
|
||||
@@ -567,7 +594,8 @@ MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat,
|
||||
AddressSpace *as = NULL;
|
||||
|
||||
/* This can be MMIO, so setup MMIO bit. */
|
||||
section = flatview_do_translate(fv, addr, xlat, plen, is_write, true, &as);
|
||||
section = flatview_do_translate(fv, addr, xlat, plen, NULL,
|
||||
is_write, true, &as);
|
||||
mr = section.mr;
|
||||
|
||||
if (xen_enabled() && memory_access_is_direct(mr, is_write)) {
|
||||
@@ -2348,6 +2376,9 @@ static void notdirty_mem_write(void *opaque, hwaddr ram_addr,
|
||||
case 4:
|
||||
stl_p(qemu_map_ram_ptr(NULL, ram_addr), val);
|
||||
break;
|
||||
case 8:
|
||||
stq_p(qemu_map_ram_ptr(NULL, ram_addr), val);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
@@ -2378,6 +2409,16 @@ static const MemoryRegionOps notdirty_mem_ops = {
|
||||
.write = notdirty_mem_write,
|
||||
.valid.accepts = notdirty_mem_accepts,
|
||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 1,
|
||||
.max_access_size = 8,
|
||||
.unaligned = false,
|
||||
},
|
||||
.impl = {
|
||||
.min_access_size = 1,
|
||||
.max_access_size = 8,
|
||||
.unaligned = false,
|
||||
},
|
||||
};
|
||||
|
||||
/* Generate a debug exception if a watchpoint has been hit. */
|
||||
@@ -2462,6 +2503,9 @@ static MemTxResult watch_mem_read(void *opaque, hwaddr addr, uint64_t *pdata,
|
||||
case 4:
|
||||
data = address_space_ldl(as, addr, attrs, &res);
|
||||
break;
|
||||
case 8:
|
||||
data = address_space_ldq(as, addr, attrs, &res);
|
||||
break;
|
||||
default: abort();
|
||||
}
|
||||
*pdata = data;
|
||||
@@ -2487,6 +2531,9 @@ static MemTxResult watch_mem_write(void *opaque, hwaddr addr,
|
||||
case 4:
|
||||
address_space_stl(as, addr, val, attrs, &res);
|
||||
break;
|
||||
case 8:
|
||||
address_space_stq(as, addr, val, attrs, &res);
|
||||
break;
|
||||
default: abort();
|
||||
}
|
||||
return res;
|
||||
@@ -2496,6 +2543,16 @@ static const MemoryRegionOps watch_mem_ops = {
|
||||
.read_with_attrs = watch_mem_read,
|
||||
.write_with_attrs = watch_mem_write,
|
||||
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||
.valid = {
|
||||
.min_access_size = 1,
|
||||
.max_access_size = 8,
|
||||
.unaligned = false,
|
||||
},
|
||||
.impl = {
|
||||
.min_access_size = 1,
|
||||
.max_access_size = 8,
|
||||
.unaligned = false,
|
||||
},
|
||||
};
|
||||
|
||||
static MemTxResult flatview_write(FlatView *fv, hwaddr addr, MemTxAttrs attrs,
|
||||
|
||||
+9
-2
@@ -12,6 +12,7 @@
|
||||
#include "hw/i386/ich9.h"
|
||||
|
||||
#include "hw/acpi/tco.h"
|
||||
#include "trace.h"
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
@@ -41,8 +42,11 @@ enum {
|
||||
|
||||
static inline void tco_timer_reload(TCOIORegs *tr)
|
||||
{
|
||||
tr->expire_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
|
||||
((int64_t)(tr->tco.tmr & TCO_TMR_MASK) * TCO_TICK_NSEC);
|
||||
int ticks = tr->tco.tmr & TCO_TMR_MASK;
|
||||
int64_t nsec = (int64_t)ticks * TCO_TICK_NSEC;
|
||||
|
||||
trace_tco_timer_reload(ticks, nsec / 1000000);
|
||||
tr->expire_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + nsec;
|
||||
timer_mod(tr->tco_timer, tr->expire_time);
|
||||
}
|
||||
|
||||
@@ -59,6 +63,9 @@ static void tco_timer_expired(void *opaque)
|
||||
ICH9LPCState *lpc = container_of(pm, ICH9LPCState, pm);
|
||||
uint32_t gcs = pci_get_long(lpc->chip_config + ICH9_CC_GCS);
|
||||
|
||||
trace_tco_timer_expired(tr->timeouts_no,
|
||||
lpc->pin_strap.spkr_hi,
|
||||
!!(gcs & ICH9_CC_GCS_NO_REBOOT));
|
||||
tr->tco.rld = 0;
|
||||
tr->tco.sts1 |= TCO_TIMEOUT;
|
||||
if (++tr->timeouts_no == 2) {
|
||||
|
||||
@@ -30,3 +30,7 @@ cpuhp_acpi_ejecting_invalid_cpu(uint32_t idx) "0x%"PRIx32
|
||||
cpuhp_acpi_ejecting_cpu(uint32_t idx) "0x%"PRIx32
|
||||
cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "idx[0x%"PRIx32"] OST EVENT: 0x%"PRIx32
|
||||
cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
|
||||
|
||||
# hw/acpi/tco.c
|
||||
tco_timer_reload(int ticks, int msec) "ticks=%d (%d ms)"
|
||||
tco_timer_expired(int timeouts_no, bool strap, bool no_reboot) "timeouts_no=%d no_reboot=%d/%d"
|
||||
|
||||
+21
-11
@@ -928,6 +928,13 @@ static void device_set_realized(Object *obj, bool value, Error **errp)
|
||||
goto post_realize_fail;
|
||||
}
|
||||
|
||||
/*
|
||||
* always free/re-initialize here since the value cannot be cleaned up
|
||||
* in device_unrealize due to its usage later on in the unplug path
|
||||
*/
|
||||
g_free(dev->canonical_path);
|
||||
dev->canonical_path = object_get_canonical_path(OBJECT(dev));
|
||||
|
||||
if (qdev_get_vmsd(dev)) {
|
||||
if (vmstate_register_with_alias_id(dev, -1, qdev_get_vmsd(dev), dev,
|
||||
dev->instance_id_alias,
|
||||
@@ -984,6 +991,8 @@ child_realize_fail:
|
||||
}
|
||||
|
||||
post_realize_fail:
|
||||
g_free(dev->canonical_path);
|
||||
dev->canonical_path = NULL;
|
||||
if (dc->unrealize) {
|
||||
dc->unrealize(dev, NULL);
|
||||
}
|
||||
@@ -1070,6 +1079,18 @@ static void device_finalize(Object *obj)
|
||||
* here
|
||||
*/
|
||||
}
|
||||
|
||||
/* Only send event if the device had been completely realized */
|
||||
if (dev->pending_deleted_event) {
|
||||
g_assert(dev->canonical_path);
|
||||
|
||||
qapi_event_send_device_deleted(!!dev->id, dev->id, dev->canonical_path,
|
||||
&error_abort);
|
||||
g_free(dev->canonical_path);
|
||||
dev->canonical_path = NULL;
|
||||
}
|
||||
|
||||
qemu_opts_del(dev->opts);
|
||||
}
|
||||
|
||||
static void device_class_base_init(ObjectClass *class, void *data)
|
||||
@@ -1099,17 +1120,6 @@ static void device_unparent(Object *obj)
|
||||
object_unref(OBJECT(dev->parent_bus));
|
||||
dev->parent_bus = NULL;
|
||||
}
|
||||
|
||||
/* Only send event if the device had been completely realized */
|
||||
if (dev->pending_deleted_event) {
|
||||
gchar *path = object_get_canonical_path(OBJECT(dev));
|
||||
|
||||
qapi_event_send_device_deleted(!!dev->id, dev->id, path, &error_abort);
|
||||
g_free(path);
|
||||
}
|
||||
|
||||
qemu_opts_del(dev->opts);
|
||||
dev->opts = NULL;
|
||||
}
|
||||
|
||||
static void device_class_init(ObjectClass *class, void *data)
|
||||
|
||||
@@ -1876,8 +1876,15 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
|
||||
CPUArchId *cpu_slot;
|
||||
X86CPUTopoInfo topo;
|
||||
X86CPU *cpu = X86_CPU(dev);
|
||||
MachineState *ms = MACHINE(hotplug_dev);
|
||||
PCMachineState *pcms = PC_MACHINE(hotplug_dev);
|
||||
|
||||
if(!object_dynamic_cast(OBJECT(cpu), ms->cpu_type)) {
|
||||
error_setg(errp, "Invalid CPU type, expected cpu type: '%s'",
|
||||
ms->cpu_type);
|
||||
return;
|
||||
}
|
||||
|
||||
/* if APIC ID is not set, set it based on socket/core/thread properties */
|
||||
if (cpu->apic_id == UNASSIGNED_APIC_ID) {
|
||||
int max_socket = (max_cpus - 1) / smp_threads / smp_cores;
|
||||
|
||||
@@ -208,6 +208,7 @@ static void ide_identify(IDEState *s)
|
||||
if (dev && dev->conf.discard_granularity) {
|
||||
put_le16(p + 169, 1); /* TRIM support */
|
||||
}
|
||||
put_le16(p + 217, dev->rotation_rate); /* Nominal media rotation rate */
|
||||
|
||||
ide_identify_size(s);
|
||||
s->identify_set = 1;
|
||||
|
||||
@@ -299,6 +299,7 @@ static Property ide_hd_properties[] = {
|
||||
DEFINE_BLOCK_CHS_PROPERTIES(IDEDrive, dev.conf),
|
||||
DEFINE_PROP_BIOS_CHS_TRANS("bios-chs-trans",
|
||||
IDEDrive, dev.chs_trans, BIOS_ATA_TRANSLATION_AUTO),
|
||||
DEFINE_PROP_UINT16("rotation_rate", IDEDrive, dev.rotation_rate, 0),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user