[PATCH v5 1/6] libvhost-user: implement VHOST_USER_PROTOCOL_F_REPLY_ACK
From: Johannes Berg This is really simple, since we know whether a response is already requested or not, so we can just send a (successful) response when there isn't one already. Given that, it's not all _that_ useful but the master can at least be sure the message was processed, and we can exercise more code paths using the example code. Reviewed-by: Stefan Hajnoczi Signed-off-by: Johannes Berg --- contrib/libvhost-user/libvhost-user.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c index ec27b78ff108..8cc3054fd510 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -1168,7 +1168,8 @@ vu_get_protocol_features_exec(VuDev *dev, VhostUserMsg *vmsg) 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD | 1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ | 1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER | -1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD; +1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD | +1ULL << VHOST_USER_PROTOCOL_F_REPLY_ACK; if (have_userfault()) { features |= 1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT; @@ -1550,13 +1551,20 @@ vu_dispatch(VuDev *dev) { VhostUserMsg vmsg = { 0, }; int reply_requested; -bool success = false; +bool need_reply, success = false; if (!vu_message_read(dev, dev->sock, &vmsg)) { goto end; } +need_reply = vmsg.flags & VHOST_USER_NEED_REPLY_MASK; + reply_requested = vu_process_message(dev, &vmsg); +if (!reply_requested && need_reply) { +vmsg_set_reply_u64(&vmsg, 0); +reply_requested = 1; +} + if (!reply_requested) { success = true; goto end; -- 2.24.1
[PATCH v5 2/6] libvhost-user-glib: fix VugDev main fd cleanup
From: Johannes Berg If you try to make a device implementation that can handle multiple connections and allow disconnections (which requires overriding the VHOST_USER_NONE handling), then glib will warn that we remove a src while it's still on the mainloop, and will poll() an FD that doesn't exist anymore. Fix this by making vug_source_new() require pairing with the new vug_source_destroy() so we can keep the GSource referenced in the meantime. Note that this requires calling the new API in vhost-user-input. vhost-user-gpu also uses vug_source_new(), but never seems to free the result at all, so I haven't changed anything there. Fixes: 8bb7ddb78a1c ("libvhost-user: add glib source helper") Reviewed-by: Marc-André Lureau Signed-off-by: Johannes Berg --- contrib/libvhost-user/libvhost-user-glib.c | 15 --- contrib/libvhost-user/libvhost-user-glib.h | 1 + contrib/vhost-user-input/main.c| 6 ++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user-glib.c b/contrib/libvhost-user/libvhost-user-glib.c index 99edd2f3de45..824c7780de61 100644 --- a/contrib/libvhost-user/libvhost-user-glib.c +++ b/contrib/libvhost-user/libvhost-user-glib.c @@ -91,7 +91,6 @@ vug_source_new(VugDev *gdev, int fd, GIOCondition cond, g_source_add_poll(gsrc, &src->gfd); id = g_source_attach(gsrc, NULL); g_assert(id); -g_source_unref(gsrc); return gsrc; } @@ -131,6 +130,16 @@ static void vug_watch(VuDev *dev, int condition, void *data) } } +void vug_source_destroy(GSource *src) +{ +if (!src) { +return; +} + +g_source_destroy(src); +g_source_unref(src); +} + bool vug_init(VugDev *dev, uint16_t max_queues, int socket, vu_panic_cb panic, const VuDevIface *iface) @@ -144,7 +153,7 @@ vug_init(VugDev *dev, uint16_t max_queues, int socket, } dev->fdmap = g_hash_table_new_full(NULL, NULL, NULL, - (GDestroyNotify) g_source_destroy); + (GDestroyNotify) vug_source_destroy); dev->src = vug_source_new(dev, socket, G_IO_IN, vug_watch, NULL); @@ -157,5 +166,5 @@ vug_deinit(VugDev *dev) g_assert(dev); g_hash_table_unref(dev->fdmap); -g_source_unref(dev->src); +vug_source_destroy(dev->src); } diff --git a/contrib/libvhost-user/libvhost-user-glib.h b/contrib/libvhost-user/libvhost-user-glib.h index 64d539d93aba..1a79a4916ef2 100644 --- a/contrib/libvhost-user/libvhost-user-glib.h +++ b/contrib/libvhost-user/libvhost-user-glib.h @@ -31,5 +31,6 @@ void vug_deinit(VugDev *dev); GSource *vug_source_new(VugDev *dev, int fd, GIOCondition cond, vu_watch_cb vu_cb, gpointer data); +void vug_source_destroy(GSource *src); #endif /* LIBVHOST_USER_GLIB_H */ diff --git a/contrib/vhost-user-input/main.c b/contrib/vhost-user-input/main.c index ef4b7769f285..6020c6f33a46 100644 --- a/contrib/vhost-user-input/main.c +++ b/contrib/vhost-user-input/main.c @@ -187,7 +187,7 @@ vi_queue_set_started(VuDev *dev, int qidx, bool started) } if (!started && vi->evsrc) { -g_source_destroy(vi->evsrc); +vug_source_destroy(vi->evsrc); vi->evsrc = NULL; } } @@ -401,9 +401,7 @@ main(int argc, char *argv[]) vug_deinit(&vi.dev); -if (vi.evsrc) { -g_source_unref(vi.evsrc); -} +vug_source_destroy(vi.evsrc); g_array_free(vi.config, TRUE); g_free(vi.queue); return 0; -- 2.24.1
[PATCH v5 3/6] libvhost-user-glib: use g_main_context_get_thread_default()
From: Johannes Berg If we use NULL, we just get the main program default mainloop here. Using g_main_context_get_thread_default() has basically the same effect, but it lets us start different devices in different threads with different mainloops, which can be useful. Reviewed-by: Stefan Hajnoczi Reviewed-by: Marc-André Lureau Signed-off-by: Johannes Berg --- contrib/libvhost-user/libvhost-user-glib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/libvhost-user/libvhost-user-glib.c b/contrib/libvhost-user/libvhost-user-glib.c index 824c7780de61..53f1ca4cdd73 100644 --- a/contrib/libvhost-user/libvhost-user-glib.c +++ b/contrib/libvhost-user/libvhost-user-glib.c @@ -89,7 +89,7 @@ vug_source_new(VugDev *gdev, int fd, GIOCondition cond, src->gfd.events = cond; g_source_add_poll(gsrc, &src->gfd); -id = g_source_attach(gsrc, NULL); +id = g_source_attach(gsrc, g_main_context_get_thread_default()); g_assert(id); return gsrc; -- 2.24.1
[PATCH v5 0/6] small vhost changes and in-band notifications
Hi, Here's a repost of all the patches I sent back in August, with the in-band notifications rebased over the reset patch, so IDs have now changed a bit. I've marked this all as v5 even if it really wasn't for all of them, just the VugDev main fd cleanup patch was at v4 before. I've also collected reviewed-by's from the previous patches here. Let me know if I should make any further edits here or in follow-up patches. Thanks, johannes
[PATCH v5 6/6] libvhost-user: implement in-band notifications
From: Johannes Berg Add support for VHOST_USER_PROTOCOL_F_IN_BAND_NOTIFICATIONS, but as it's not desired by default, don't enable it unless the device implementation opts in by returning it from its protocol features callback. Note that I updated vu_set_vring_err_exec(), but didn't add any sending of the VHOST_USER_SLAVE_VRING_ERR message as there's no write to the err_fd today either. This also adds vu_queue_notify_sync() which can be used to force a synchronous notification if inband notifications are supported. Previously, I had left out the slave->master direction handling of F_REPLY_ACK, this now adds some code to support it as well. Signed-off-by: Johannes Berg --- contrib/libvhost-user/libvhost-user.c | 103 +- contrib/libvhost-user/libvhost-user.h | 14 2 files changed, 114 insertions(+), 3 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c index 34d08e2fc4be..5cb8e6e32158 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -136,6 +136,7 @@ vu_request_to_string(unsigned int req) REQ(VHOST_USER_GET_INFLIGHT_FD), REQ(VHOST_USER_SET_INFLIGHT_FD), REQ(VHOST_USER_GPU_SET_SOCKET), +REQ(VHOST_USER_VRING_KICK), REQ(VHOST_USER_MAX), }; #undef REQ @@ -163,7 +164,10 @@ vu_panic(VuDev *dev, const char *msg, ...) dev->panic(dev, buf); free(buf); -/* FIXME: find a way to call virtio_error? */ +/* + * FIXME: + * find a way to call virtio_error, or perhaps close the connection? + */ } /* Translate guest physical address to our virtual address. */ @@ -1172,6 +1176,14 @@ vu_set_vring_err_exec(VuDev *dev, VhostUserMsg *vmsg) static bool vu_get_protocol_features_exec(VuDev *dev, VhostUserMsg *vmsg) { +/* + * Note that we support, but intentionally do not set, + * VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS. This means that + * a device implementation can return it in its callback + * (get_protocol_features) if it wants to use this for + * simulation, but it is otherwise not desirable (if even + * implemented by the master.) + */ uint64_t features = 1ULL << VHOST_USER_PROTOCOL_F_MQ | 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD | 1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ | @@ -1204,6 +1216,25 @@ vu_set_protocol_features_exec(VuDev *dev, VhostUserMsg *vmsg) dev->protocol_features = vmsg->payload.u64; +if (vu_has_protocol_feature(dev, +VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS) && +(!vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_SLAVE_REQ) || + !vu_has_protocol_feature(dev, VHOST_USER_PROTOCOL_F_REPLY_ACK))) { +/* + * The use case for using messages for kick/call is simulation, to make + * the kick and call synchronous. To actually get that behaviour, both + * of the other features are required. + * Theoretically, one could use only kick messages, or do them without + * having F_REPLY_ACK, but too many (possibly pending) messages on the + * socket will eventually cause the master to hang, to avoid this in + * scenarios where not desired enforce that the settings are in a way + * that actually enables the simulation case. + */ +vu_panic(dev, + "F_IN_BAND_NOTIFICATIONS requires F_SLAVE_REQ && F_REPLY_ACK"); +return false; +} + if (dev->iface->set_protocol_features) { dev->iface->set_protocol_features(dev, features); } @@ -1464,6 +1495,34 @@ vu_set_inflight_fd(VuDev *dev, VhostUserMsg *vmsg) return false; } +static bool +vu_handle_vring_kick(VuDev *dev, VhostUserMsg *vmsg) +{ +unsigned int index = vmsg->payload.state.index; + +if (index >= dev->max_queues) { +vu_panic(dev, "Invalid queue index: %u", index); +return false; +} + +DPRINT("Got kick message: handler:%p idx:%d\n", + dev->vq[index].handler, index); + +if (!dev->vq[index].started) { +dev->vq[index].started = true; + +if (dev->iface->queue_set_started) { +dev->iface->queue_set_started(dev, index, true); +} +} + +if (dev->vq[index].handler) { +dev->vq[index].handler(dev, index); +} + +return false; +} + static bool vu_process_message(VuDev *dev, VhostUserMsg *vmsg) { @@ -1546,6 +1605,8 @@ vu_process_message(VuDev *dev, VhostUserMsg *vmsg) return vu_get_inflight_fd(dev, vmsg); case VHOST_USER_SET_INFLIGHT_FD: return vu_set_inflight_fd(dev, vmsg); +case VHOST_USER_VRING_KICK: +return vu_handle_vring_kick(dev, vmsg); default: vmsg_close_fds(vmsg); vu_panic(dev, "Unhandled request: %d", vmsg->request); @@ -2005,8 +2066,7 @@ vring_notify(VuDev *dev, VuVirtq *vq) return !v || vring_need_event(vr
[PATCH v5 5/6] docs: vhost-user: add in-band kick/call messages
From: Johannes Berg For good reason, vhost-user is currently built asynchronously, that way better performance can be obtained. However, for certain use cases such as simulation, this is problematic. Consider an event-based simulation in which both the device and CPU have scheduled according to a simulation "calendar". Now, consider the CPU sending I/O to the device, over a vring in the vhost-user protocol. In this case, the CPU must wait for the vring interrupt to have been processed by the device, so that the device is able to put an entry onto the simulation calendar to obtain time to handle the interrupt. Note that this doesn't mean the I/O is actually done at this time, it just means that the handling of it is scheduled before the CPU can continue running. This cannot be done with the asynchronous eventfd based vring kick and call design. Extend the protocol slightly, so that a message can be used for kick and call instead, if VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS is negotiated. This in itself doesn't guarantee synchronisation, but both sides can also negotiate VHOST_USER_PROTOCOL_F_REPLY_ACK and thus get a reply to this message by setting the need_reply flag, and ensure synchronisation this way. To really use it in both directions, VHOST_USER_PROTOCOL_F_SLAVE_REQ is also needed. Since it is used for simulation purposes and too many messages on the socket can lock up the virtual machine, document that this should only be used together with the mentioned features. Signed-off-by: Johannes Berg --- docs/interop/vhost-user.rst | 122 ++-- 1 file changed, 104 insertions(+), 18 deletions(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 5f8b3a456b5e..401652397cac 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -2,6 +2,7 @@ Vhost-user Protocol === :Copyright: 2014 Virtual Open Systems Sarl. +:Copyright: 2019 Intel Corporation :Licence: This work is licensed under the terms of the GNU GPL, version 2 or later. See the COPYING file in the top-level directory. @@ -279,6 +280,9 @@ If *master* is unable to send the full message or receives a wrong reply it will close the connection. An optional reconnection mechanism can be implemented. +If *slave* detects some error such as incompatible features, it may also +close the connection. This should only happen in exceptional circumstances. + Any protocol extensions are gated by protocol feature bits, which allows full backwards compatibility on both master and slave. As older slaves don't support negotiating protocol features, a feature @@ -315,7 +319,8 @@ it until ring is started, or after it has been stopped. Client must start ring upon receiving a kick (that is, detecting that file descriptor is readable) on the descriptor specified by -``VHOST_USER_SET_VRING_KICK``, and stop ring upon receiving +``VHOST_USER_SET_VRING_KICK`` or receiving the in-band message +``VHOST_USER_VRING_KICK`` if negotiated, and stop ring upon receiving ``VHOST_USER_GET_VRING_BASE``. While processing the rings (whether they are enabled or not), client @@ -767,25 +772,49 @@ When reconnecting: #. Resubmit inflight ``DescStatePacked`` entries in order of their counter value +In-band notifications +- + +In some limited situations (e.g. for simulation) it is desirable to +have the kick, call and error (if used) signals done via in-band +messages instead of asynchronous eventfd notifications. This can be +done by negotiating the ``VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS`` +protocol feature. + +Note that due to the fact that too many messages on the sockets can +cause the sending application(s) to block, it is not advised to use +this feature unless absolutely necessary. It is also considered an +error to negotiate this feature without also negotiating +``VHOST_USER_PROTOCOL_F_SLAVE_REQ`` and ``VHOST_USER_PROTOCOL_F_REPLY_ACK``, +the former is necessary for getting a message channel from the slave +to the master, while the latter needs to be used with the in-band +notification messages to block until they are processed, both to avoid +blocking later and for proper processing (at least in the simulation +use case.) As it has no other way of signalling this error, the slave +should close the connection as a response to a +``VHOST_USER_SET_PROTOCOL_FEATURES`` message that sets the in-band +notifications feature flag without the other two. + Protocol features - .. code:: c - #define VHOST_USER_PROTOCOL_F_MQ 0 - #define VHOST_USER_PROTOCOL_F_LOG_SHMFD 1 - #define VHOST_USER_PROTOCOL_F_RARP 2 - #define VHOST_USER_PROTOCOL_F_REPLY_ACK 3 - #define VHOST_USER_PROTOCOL_F_MTU4 - #define VHOST_USER_PROTOCOL_F_SLAVE_REQ 5 - #define VHOST_USER_PROTOCOL_F_CROSS_ENDIAN 6 - #define VHOST_USER_PROTOCOL_F_CRYPTO_SESSION 7 - #define VHOST_USER
[PATCH v5 4/6] libvhost-user: handle NOFD flag in call/kick/err better
From: Johannes Berg The code here is odd, for example will it print out invalid file descriptor numbers that were never sent in the message. Clean that up a bit so it's actually possible to implement a device that uses polling. Signed-off-by: Johannes Berg --- contrib/libvhost-user/libvhost-user.c | 24 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c index 8cc3054fd510..34d08e2fc4be 100644 --- a/contrib/libvhost-user/libvhost-user.c +++ b/contrib/libvhost-user/libvhost-user.c @@ -920,6 +920,7 @@ static bool vu_check_queue_msg_file(VuDev *dev, VhostUserMsg *vmsg) { int index = vmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK; +bool nofd = vmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK; if (index >= dev->max_queues) { vmsg_close_fds(vmsg); @@ -927,8 +928,12 @@ vu_check_queue_msg_file(VuDev *dev, VhostUserMsg *vmsg) return false; } -if (vmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK || -vmsg->fd_num != 1) { +if (nofd) { +vmsg_close_fds(vmsg); +return true; +} + +if (vmsg->fd_num != 1) { vmsg_close_fds(vmsg); vu_panic(dev, "Invalid fds in request: %d", vmsg->request); return false; @@ -1025,6 +1030,7 @@ static bool vu_set_vring_kick_exec(VuDev *dev, VhostUserMsg *vmsg) { int index = vmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK; +bool nofd = vmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK; DPRINT("u64: 0x%016"PRIx64"\n", vmsg->payload.u64); @@ -1038,8 +1044,8 @@ vu_set_vring_kick_exec(VuDev *dev, VhostUserMsg *vmsg) dev->vq[index].kick_fd = -1; } -dev->vq[index].kick_fd = vmsg->fds[0]; -DPRINT("Got kick_fd: %d for vq: %d\n", vmsg->fds[0], index); +dev->vq[index].kick_fd = nofd ? -1 : vmsg->fds[0]; +DPRINT("Got kick_fd: %d for vq: %d\n", dev->vq[index].kick_fd, index); dev->vq[index].started = true; if (dev->iface->queue_set_started) { @@ -1116,6 +1122,7 @@ static bool vu_set_vring_call_exec(VuDev *dev, VhostUserMsg *vmsg) { int index = vmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK; +bool nofd = vmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK; DPRINT("u64: 0x%016"PRIx64"\n", vmsg->payload.u64); @@ -1128,14 +1135,14 @@ vu_set_vring_call_exec(VuDev *dev, VhostUserMsg *vmsg) dev->vq[index].call_fd = -1; } -dev->vq[index].call_fd = vmsg->fds[0]; +dev->vq[index].call_fd = nofd ? -1 : vmsg->fds[0]; /* in case of I/O hang after reconnecting */ -if (eventfd_write(vmsg->fds[0], 1)) { +if (dev->vq[index].call_fd != -1 && eventfd_write(vmsg->fds[0], 1)) { return -1; } -DPRINT("Got call_fd: %d for vq: %d\n", vmsg->fds[0], index); +DPRINT("Got call_fd: %d for vq: %d\n", dev->vq[index].call_fd, index); return false; } @@ -1144,6 +1151,7 @@ static bool vu_set_vring_err_exec(VuDev *dev, VhostUserMsg *vmsg) { int index = vmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK; +bool nofd = vmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK; DPRINT("u64: 0x%016"PRIx64"\n", vmsg->payload.u64); @@ -1156,7 +1164,7 @@ vu_set_vring_err_exec(VuDev *dev, VhostUserMsg *vmsg) dev->vq[index].err_fd = -1; } -dev->vq[index].err_fd = vmsg->fds[0]; +dev->vq[index].err_fd = nofd ? -1 : vmsg->fds[0]; return false; } -- 2.24.1
Re: [RFC PATCH] qapi: Incorrect attempt to fix building with MC146818RTC=n
Paolo Bonzini writes: > On 22/01/20 06:41, Markus Armbruster wrote: >> Paolo Bonzini writes: >> >>> Il mar 21 gen 2020, 15:22 Markus Armbruster ha scritto: >>> > To see it a different way, these are the "C bindings" to QMP, just that > the implementation is an in-process call rather than RPC. If the QAPI > code generator was also able to generate Python bindings and the like, > they would have to be the same for all QEMU binaries, wouldn't they? Ommitting the kind of #if we've been discussing is relatively harmless but what about this one, in qapi-types-block-core.h: typedef enum BlockdevDriver { BLOCKDEV_DRIVER_BLKDEBUG, [...] #if defined(CONFIG_REPLICATION) BLOCKDEV_DRIVER_REPLICATION, #endif /* defined(CONFIG_REPLICATION) */ [...] BLOCKDEV_DRIVER__MAX, } BlockdevDriver; >>> >>> Well, I don't think this should be conditional at all. Introspection is a >>> tool to detect unsupported features, not working features. >> >> Isn't this what it does? To detect "replication" is unsupported, check >> whether it's absent, and "supported" does not imply "works". > > Indeed... > >>>KVM will be >>> present in introspection data even if /dev/kvm doesn't exist on your >>> machine or you don't have permission to access it. >> >> Yes. >> >> QAPI/QMP introspection is compile-time static by design. It can't tell >> you more than "this QEMU build supports X". > > ... and I think it would be fine even if it told you less: "this QEMU > will not give a parse error if X appears in QMP syntax". For example, > QEMU could accept "replication" even if CONFIG_REPLICATION is not > defined and therefore using it would always fail. This would allow > limiting even more use of conditional compilation. This is effectively how things worked before we added 'if' to the QAPI schema language. A feature F may (1) not exist in this version of QEMU (2) exist, but configured off for this build of QEMU (3) be present in this build of QEMU When the management application sees (1) or (2), it knows that using F cannot possibly work no matter what you do to the host short of using another build of QEMU. The management application can then reject attempts to use F with a useful error message, or make such attempts impossible (think graying out menu entries). When the management application sees (3), it still needs to be prepared for actual use to fail. Possible failures depend on the feature. Identifying the various kinds of failures can be awkward and/or brittle. Useful error reporting is often hard. A management application doesn't care for the difference between (1) and (2). We added 'if' to the QAPI schema language in part to make the difference disappear. Without it, introspection munges together (2) and (3) instead. The management application's information degrades from "the QEMU I have does not provide F" to "something went wrong". Perhaps the management application can figure out what went wrong, perhaps it can't. Perhaps it doesn't need to know. My point is: we trade away information at the external interface for the benefit of "limiting even more use of conditional compilation". I doubt that's a good trade, not least because I can't quite see how exactly the benefit is, well, beneficial[*]. Anyway, we've had introspection reflect compile time configuration since v3.0.0. I don't think we can break that now. [*] It saves us including headers we really should be including. Anything else?
[PULL 05/17] linux-user: Add support for FS_IOC32_VERSION ioctls
From: Aleksandar Markovic These FS_IOC32_VERSION ioctls are identical to FS_IOC_VERSION ioctls, but without the anomaly of their number defined as if their third argument is of type long, while it is treated internally in kernel as is of type int. Reviewed-by: Laurent Vivier Signed-off-by: Aleksandar Markovic Message-Id: <1579214991-19602-4-git-send-email-aleksandar.marko...@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 4fd693984e6a..3affd8814a86 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -142,6 +142,8 @@ IOCTL(FS_IOC_SETVERSION, IOC_W, MK_PTR(TYPE_INT)) IOCTL(FS_IOC32_GETFLAGS, IOC_R, MK_PTR(TYPE_INT)) IOCTL(FS_IOC32_SETFLAGS, IOC_W, MK_PTR(TYPE_INT)) + IOCTL(FS_IOC32_GETVERSION, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(FS_IOC32_SETVERSION, IOC_W, MK_PTR(TYPE_INT)) #ifdef CONFIG_USBFS /* USB ioctls */ diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 964b2b458dd5..a73cc3d06790 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -922,6 +922,8 @@ struct target_pollfd { #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap) #define TARGET_FS_IOC32_GETFLAGS TARGET_IOR('f', 1, int) #define TARGET_FS_IOC32_SETFLAGS TARGET_IOW('f', 2, int) +#define TARGET_FS_IOC32_GETVERSION TARGET_IOR('v', 1, int) +#define TARGET_FS_IOC32_SETVERSION TARGET_IOW('v', 2, int) /* usb ioctls */ #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0) -- 2.24.1
[PULL 04/17] linux-user: Add support for FS_IOC32_FLAGS ioctls
From: Aleksandar Markovic These FS_IOC32_FLAGS ioctls are identical to FS_IOC_FLAGS ioctls, but without the anomaly of their number defined as if their third argument is of type long, while it is treated internally in kernel as is of type int. Reviewed-by: Laurent Vivier Signed-off-by: Aleksandar Markovic Message-Id: <1579214991-19602-3-git-send-email-aleksandar.marko...@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index c44f42eaf4e7..4fd693984e6a 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -140,6 +140,8 @@ IOCTL(FS_IOC_SETFLAGS, IOC_W, MK_PTR(TYPE_INT)) IOCTL(FS_IOC_GETVERSION, IOC_R, MK_PTR(TYPE_INT)) IOCTL(FS_IOC_SETVERSION, IOC_W, MK_PTR(TYPE_INT)) + IOCTL(FS_IOC32_GETFLAGS, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(FS_IOC32_SETFLAGS, IOC_W, MK_PTR(TYPE_INT)) #ifdef CONFIG_USBFS /* USB ioctls */ diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index f68a8b6e8e18..964b2b458dd5 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -920,6 +920,8 @@ struct target_pollfd { #define TARGET_FS_IOC_GETVERSION TARGET_IOR('v', 1, abi_long) #define TARGET_FS_IOC_SETVERSION TARGET_IOW('v', 2, abi_long) #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap) +#define TARGET_FS_IOC32_GETFLAGS TARGET_IOR('f', 1, int) +#define TARGET_FS_IOC32_SETFLAGS TARGET_IOW('f', 2, int) /* usb ioctls */ #define TARGET_USBDEVFS_CONTROL TARGET_IOWRU('U', 0) -- 2.24.1
[PULL 08/17] configure: Detect kcov support and introduce CONFIG_KCOV
From: Aleksandar Markovic kcov is kernel code coverage tracing tool. It requires kernel 4.4+ compiled with certain kernel options. This patch checks if kcov header "sys/kcov.h" is present on build machine, and stores the result in variable CONFIG_KCOV, meant to be used in linux-user code related to the support for three ioctls that were introduced at the same time as the mentioned header (their definition was a part of the first version of that header). Signed-off-by: Aleksandar Markovic Reviewed-by: Laurent Vivier Message-Id: <1579214991-19602-11-git-send-email-aleksandar.marko...@rt-rk.com> Signed-off-by: Laurent Vivier --- configure | 9 + 1 file changed, 9 insertions(+) diff --git a/configure b/configure index 557e4382ea87..d91eab4d65c4 100755 --- a/configure +++ b/configure @@ -4761,6 +4761,12 @@ if compile_prog "" "" ; then syncfs=yes fi +# check for kcov support (kernel must be 4.4+, compiled with certain options) +kcov=no +if check_include sys/kcov.h ; then +kcov=yes +fi + # Check we have a new enough version of sphinx-build has_sphinx_build() { # This is a bit awkward but works: create a trivial document and @@ -6874,6 +6880,9 @@ fi if test "$syncfs" = "yes" ; then echo "CONFIG_SYNCFS=y" >> $config_host_mak fi +if test "$kcov" = "yes" ; then + echo "CONFIG_KCOV=y" >> $config_host_mak +fi if test "$inotify" = "yes" ; then echo "CONFIG_INOTIFY=y" >> $config_host_mak fi -- 2.24.1
[PULL 00/17] Linux user for 5.0 patches
The following changes since commit 3e08b2b9cb64bff2b73fa9128c0e49bfcde0dd40: Merge remote-tracking branch 'remotes/philmd-gitlab/tags/edk2-next-20200121' into staging (2020-01-21 15:29:25 +) are available in the Git repository at: git://github.com/vivier/qemu.git tags/linux-user-for-5.0-pull-request for you to fetch changes up to a7b09746679c1815115249ec69197e454efdfb15: linux-user: Add support for read/clear RTC voltage low detector using ioctls (2020-01-22 15:21:37 +0100) Fix mmap guest space and brk Add FS/FD/RTC/KCOV ioctls Aleksandar Markovic (8): linux-user: Add support for FS_IOC_VERSION ioctls linux-user: Add support for FS_IOC32_FLAGS ioctls linux-user: Add support for FS_IOC32_VERSION ioctls linux-user: Add support for FD ioctls linux-user: Add support for FDFMT ioctls configure: Detect kcov support and introduce CONFIG_KCOV linux-user: Add support for KCOV_ ioctls linux-user: Add support for KCOV_INIT_TRACE ioctl Filip Bozuta (7): linux-user: Add support for TYPE_LONG and TYPE_ULONG in do_ioctl() linux-user: Add support for enabling/disabling RTC features using ioctls linux-user: Add support for getting/setting RTC time and alarm using ioctls linux-user: Add support for getting/setting RTC periodic interrupt and epoch using ioctls linux-user: Add support for getting/setting RTC wakeup alarm using ioctls linux-user: Add support for getting/setting RTC PLL correction using ioctls linux-user: Add support for read/clear RTC voltage low detector using ioctls Richard Henderson (1): linux-user: Reserve space for brk Xinyu Li (1): linux-user:Fix align mistake when mmap guest space configure | 9 + linux-user/elfload.c | 75 +- linux-user/ioctls.h| 41 + linux-user/qemu.h | 1 + linux-user/syscall.c | 6 +++ linux-user/syscall_defs.h | 59 -- linux-user/syscall_types.h | 37 +++ 7 files changed, 207 insertions(+), 21 deletions(-) -- 2.24.1
[PULL 01/17] linux-user:Fix align mistake when mmap guest space
From: Xinyu Li In init_guest_space, we need to mmap guest space. If the return address of first mmap is not aligned with align, which was set to MAX(SHMLBA, qemu_host_page_size), we need unmap and a new mmap(space is larger than first size). The new size is named real_size, which is aligned_size + qemu_host_page_size. alugned_size is the guest space size. And add a qemu_host_page_size to avoid memory error when we align real_start manually (ROUND_UP(real_start, align)). But when SHMLBA > qemu_host_page_size, the added size will smaller than the size to align, which can make a mistake(in a mips machine, it appears). So change real_size from aligned_size +qemu_host_page_size to aligned_size + align will solve it. Signed-off-by: Xinyu Li Reviewed-by: Richard Henderson Message-Id: <20191213022919.5934-1-preci...@mail.ustc.edu.cn> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 07b16cc0f470..511e4500788b 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -2191,7 +2191,7 @@ unsigned long init_guest_space(unsigned long host_start, * to where we need to put the commpage. */ munmap((void *)real_start, host_size); -real_size = aligned_size + qemu_host_page_size; +real_size = aligned_size + align; real_start = (unsigned long) mmap((void *)real_start, real_size, PROT_NONE, flags, -1, 0); if (real_start == (unsigned long)-1) { -- 2.24.1
[PULL 09/17] linux-user: Add support for KCOV_ ioctls
From: Aleksandar Markovic KCOV_ENABLE and KCOV_DISABLE play the role in kernel coverage tracing. These ioctls do not use the third argument of ioctl() system call and are straightforward to implement in QEMU. Reviewed-by: Laurent Vivier Signed-off-by: Aleksandar Markovic Message-Id: <1579214991-19602-12-git-send-email-aleksandar.marko...@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 5 + linux-user/syscall.c | 3 +++ linux-user/syscall_defs.h | 4 3 files changed, 12 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 29969e2f2f27..6220dd8cf791 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -534,3 +534,8 @@ IOCTL_IGNORE(TIOCSTART) IOCTL_IGNORE(TIOCSTOP) #endif + +#ifdef CONFIG_KCOV + IOCTL(KCOV_ENABLE, 0, TYPE_NULL) + IOCTL(KCOV_DISABLE, 0, TYPE_NULL) +#endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 249e4b95fc9f..c5bda60b45de 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -73,6 +73,9 @@ #ifdef CONFIG_SENDFILE #include #endif +#ifdef CONFIG_KCOV +#include +#endif #define termios host_termios #define winsize host_winsize diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index b3acf85a6b23..7b0b60d253d9 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2434,6 +2434,10 @@ struct target_mtpos { #define TARGET_MTIOCGETTARGET_IOR('m', 2, struct target_mtget) #define TARGET_MTIOCPOSTARGET_IOR('m', 3, struct target_mtpos) +/* kcov ioctls */ +#define TARGET_KCOV_ENABLE TARGET_IO('c', 100) +#define TARGET_KCOV_DISABLETARGET_IO('c', 101) + struct target_sysinfo { abi_long uptime;/* Seconds since boot */ abi_ulong loads[3]; /* 1, 5, and 15 minute load averages */ -- 2.24.1
[PULL 14/17] linux-user: Add support for getting/setting RTC periodic interrupt and epoch using ioctls
From: Filip Bozuta This patch implements functionalities of following ioctls: RTC_IRQP_READ, RTC_IRQP_SET - Getting/Setting IRQ rate Read and set the frequency for periodic interrupts, for RTCs that support periodic interrupts. The periodic interrupt must be separately enabled or disabled using the RTC_PIE_ON, RTC_PIE_OFF requests. The third ioctl's argument is an unsigned long * or an unsigned long, respectively. The value is the frequency in interrupts per second. The set of allow‐ able frequencies is the multiples of two in the range 2 to 8192. Only a privileged process (i.e., one having the CAP_SYS_RESOURCE capability) can set frequencies above the value specified in /proc/sys/dev/rtc/max-user-freq. (This file contains the value 64 by default.) RTC_EPOCH_READ, RTC_EPOCH_SET - Getting/Setting epoch Many RTCs encode the year in an 8-bit register which is either interpreted as an 8-bit binary number or as a BCD number. In both cases, the number is interpreted relative to this RTC's Epoch. The RTC's Epoch is initialized to 1900 on most systems but on Alpha and MIPS it might also be initialized to 1952, 1980, or 2000, depending on the value of an RTC register for the year. With some RTCs, these operations can be used to read or to set the RTC's Epoch, respectively. The third ioctl's argument is an unsigned long * or an unsigned long, respectively, and the value returned (or assigned) is the Epoch. To set the RTC's Epoch the process must be privileged (i.e., have the CAP_SYS_TIME capability). Implementation notes: All ioctls in this patch have a pointer to 'ulong' as their third argument. That is the reason why corresponding parts of added code in linux-user/syscall_defs.h contain special handling related to 'ulong' type: they use 'abi_ulong' type to make sure that ioctl's code is calculated correctly for both 32-bit and 64-bit targets. Also, 'MK_PTR(TYPE_ULONG)' is used for the similar reason in linux-user/ioctls.h. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta Message-Id: <1579117007-7565-4-git-send-email-filip.boz...@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 4 linux-user/syscall_defs.h | 4 2 files changed, 8 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index c39dd0128a60..9e91eaae7705 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -81,6 +81,10 @@ IOCTL(RTC_ALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) IOCTL(RTC_RD_TIME, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) IOCTL(RTC_SET_TIME, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) + IOCTL(RTC_IRQP_READ, IOC_R, MK_PTR(TYPE_ULONG)) + IOCTL(RTC_IRQP_SET, IOC_W, TYPE_ULONG) + IOCTL(RTC_EPOCH_READ, IOC_R, MK_PTR(TYPE_ULONG)) + IOCTL(RTC_EPOCH_SET, IOC_W, TYPE_ULONG) IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT)) IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index dc36dd475112..fcbb2ee9a387 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -776,6 +776,10 @@ struct target_pollfd { #define TARGET_RTC_ALM_SET TARGET_IOW('p', 0x07, struct rtc_time) #define TARGET_RTC_RD_TIME TARGET_IOR('p', 0x09, struct rtc_time) #define TARGET_RTC_SET_TIME TARGET_IOW('p', 0x0a, struct rtc_time) +#define TARGET_RTC_IRQP_READTARGET_IOR('p', 0x0b, abi_ulong) +#define TARGET_RTC_IRQP_SET TARGET_IOW('p', 0x0c, abi_ulong) +#define TARGET_RTC_EPOCH_READ TARGET_IOR('p', 0x0d, abi_ulong) +#define TARGET_RTC_EPOCH_SETTARGET_IOW('p', 0x0e, abi_ulong) #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) -- 2.24.1
[PULL 03/17] linux-user: Add support for FS_IOC_VERSION ioctls
From: Aleksandar Markovic A very specific thing for these two ioctls is that their code implies that their third argument is of type 'long', but the kernel uses that argument as if it is of type 'int'. This anomaly is recognized also in commit 6080723 (linux-user: Implement FS_IOC_GETFLAGS and FS_IOC_SETFLAGS ioctls). Reviewed-by: Laurent Vivier Signed-off-by: Aleksandar Markovic Message-Id: <1579214991-19602-2-git-send-email-aleksandar.marko...@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 8 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index c6b9d6ad6653..c44f42eaf4e7 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -138,6 +138,8 @@ IOCTL(FS_IOC_GETFLAGS, IOC_R, MK_PTR(TYPE_INT)) IOCTL(FS_IOC_SETFLAGS, IOC_W, MK_PTR(TYPE_INT)) + IOCTL(FS_IOC_GETVERSION, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(FS_IOC_SETVERSION, IOC_W, MK_PTR(TYPE_INT)) #ifdef CONFIG_USBFS /* USB ioctls */ diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 98c2119de9c1..f68a8b6e8e18 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -911,12 +911,14 @@ struct target_pollfd { #define TARGET_FICLONETARGET_IOW(0x94, 9, int) #define TARGET_FICLONERANGE TARGET_IOW(0x94, 13, struct file_clone_range) -/* Note that the ioctl numbers claim type "long" but the actual type - * used by the kernel is "int". +/* + * Note that the ioctl numbers for FS_IOC_ + * claim type "long" but the actual type used by the kernel is "int". */ #define TARGET_FS_IOC_GETFLAGS TARGET_IOR('f', 1, abi_long) #define TARGET_FS_IOC_SETFLAGS TARGET_IOW('f', 2, abi_long) - +#define TARGET_FS_IOC_GETVERSION TARGET_IOR('v', 1, abi_long) +#define TARGET_FS_IOC_SETVERSION TARGET_IOW('v', 2, abi_long) #define TARGET_FS_IOC_FIEMAP TARGET_IOWR('f',11,struct fiemap) /* usb ioctls */ -- 2.24.1
[PULL 10/17] linux-user: Add support for KCOV_INIT_TRACE ioctl
From: Aleksandar Markovic KCOV_INIT_TRACE ioctl plays the role in kernel coverage tracing. This ioctl's third argument is of type 'unsigned long', and the implementation in QEMU is straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Aleksandar Markovic Message-Id: <1579214991-19602-13-git-send-email-aleksandar.marko...@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 1 + linux-user/syscall_defs.h | 1 + 2 files changed, 2 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 6220dd8cf791..23f6d3feb5db 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -538,4 +538,5 @@ #ifdef CONFIG_KCOV IOCTL(KCOV_ENABLE, 0, TYPE_NULL) IOCTL(KCOV_DISABLE, 0, TYPE_NULL) + IOCTL(KCOV_INIT_TRACE, IOC_R, TYPE_ULONG) #endif diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 7b0b60d253d9..fb8318d12185 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2437,6 +2437,7 @@ struct target_mtpos { /* kcov ioctls */ #define TARGET_KCOV_ENABLE TARGET_IO('c', 100) #define TARGET_KCOV_DISABLETARGET_IO('c', 101) +#define TARGET_KCOV_INIT_TRACE TARGET_IOR('c', 1, abi_ulong) struct target_sysinfo { abi_long uptime;/* Seconds since boot */ -- 2.24.1
[PULL 16/17] linux-user: Add support for getting/setting RTC PLL correction using ioctls
From: Filip Bozuta This patch implements functionalities of following ioctls: RTC_PLL_GET - Getting PLL correction Read the PLL correction for RTCs that support PLL. The PLL correction is returned in the following structure: struct rtc_pll_info { int pll_ctrl;/* placeholder for fancier control */ int pll_value; /* get/set correction value */ int pll_max; /* max +ve (faster) adjustment value */ int pll_min; /* max -ve (slower) adjustment value */ int pll_posmult; /* factor for +ve correction */ int pll_negmult; /* factor for -ve correction */ long pll_clock; /* base PLL frequency */ }; A pointer to this structure should be passed as the third ioctl's argument. RTC_PLL_SET - Setting PLL correction Sets the PLL correction for RTCs that support PLL. The PLL correction that is set is specified by the rtc_pll_info structure pointed to by the third ioctl's' argument. Implementation notes: All ioctls in this patch have a pointer to a structure rtc_pll_info as their third argument. All elements of this structure are of type 'int', except the last one that is of type 'long'. That is the reason why a separate target structure (target_rtc_pll_info) is defined in linux-user/syscall_defs. The rest of the implementation is straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta Message-Id: <1579117007-7565-6-git-send-email-filip.boz...@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h| 2 ++ linux-user/syscall_defs.h | 14 ++ linux-user/syscall_types.h | 9 + 3 files changed, 25 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index e4c1fbf52b1b..789764d11314 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -87,6 +87,8 @@ IOCTL(RTC_EPOCH_SET, IOC_W, TYPE_ULONG) IOCTL(RTC_WKALM_RD, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm))) IOCTL(RTC_WKALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm))) + IOCTL(RTC_PLL_GET, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info))) + IOCTL(RTC_PLL_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info))) IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT)) IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index c33432a374e5..9f7aad49c683 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -763,6 +763,16 @@ struct target_pollfd { #define TARGET_KDSETLED0x4B32 /* set led state [lights, not flags] */ #define TARGET_KDSIGACCEPT 0x4B4E +struct target_rtc_pll_info { +int pll_ctrl; +int pll_value; +int pll_max; +int pll_min; +int pll_posmult; +int pll_negmult; +abi_long pll_clock; +}; + /* real time clock ioctls */ #define TARGET_RTC_AIE_ON TARGET_IO('p', 0x01) #define TARGET_RTC_AIE_OFF TARGET_IO('p', 0x02) @@ -782,6 +792,10 @@ struct target_pollfd { #define TARGET_RTC_EPOCH_SETTARGET_IOW('p', 0x0e, abi_ulong) #define TARGET_RTC_WKALM_RD TARGET_IOR('p', 0x10, struct rtc_wkalrm) #define TARGET_RTC_WKALM_SETTARGET_IOW('p', 0x0f, struct rtc_wkalrm) +#define TARGET_RTC_PLL_GET TARGET_IOR('p', 0x11, \ + struct target_rtc_pll_info) +#define TARGET_RTC_PLL_SET TARGET_IOW('p', 0x12, \ + struct target_rtc_pll_info) #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 3efa9536ccfa..5ba4155047ba 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -271,6 +271,15 @@ STRUCT(rtc_wkalrm, TYPE_CHAR, /* pending */ MK_STRUCT(STRUCT_rtc_time)) /* time */ +STRUCT(rtc_pll_info, + TYPE_INT, /* pll_ctrl */ + TYPE_INT, /* pll_value */ + TYPE_INT, /* pll_max */ + TYPE_INT, /* pll_min */ + TYPE_INT, /* pll_posmult */ + TYPE_INT, /* pll_negmult */ + TYPE_LONG) /* pll_clock */ + STRUCT(blkpg_ioctl_arg, TYPE_INT, /* op */ TYPE_INT, /* flags */ -- 2.24.1
[PULL 11/17] linux-user: Add support for TYPE_LONG and TYPE_ULONG in do_ioctl()
From: Filip Bozuta Function "do_ioctl()" located in file "syscall.c" was missing an option for TYPE_LONG and TYPE_ULONG. This caused some ioctls to not be recognised because they had the third argument that was of type 'long' or 'unsigned long'. For example: Since implemented ioctls RTC_IRQP_SET and RTC_EPOCH_SET are of type IOW(writing type) that have unsigned long as their third argument, they were not recognised in QEMU before the changes of this patch. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier Message-Id: <1579117007-7565-14-git-send-email-filip.boz...@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c5bda60b45de..bd2436b31007 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5178,6 +5178,8 @@ static abi_long do_ioctl(int fd, int cmd, abi_long arg) break; case TYPE_PTRVOID: case TYPE_INT: +case TYPE_LONG: +case TYPE_ULONG: ret = get_errno(safe_ioctl(fd, ie->host_cmd, arg)); break; case TYPE_PTR: -- 2.24.1
[PULL 07/17] linux-user: Add support for FDFMT ioctls
From: Aleksandar Markovic FDFMTBEG, FDFMTTRK, and FDFMTEND ioctls provide means for controlling formatting of a floppy drive. FDFMTTRK's third agrument is a pointer to the structure: struct format_descr { unsigned int device,head,track; }; defined in Linux kernel header . Since all fields of the structure are of type 'unsigned int', there is no need to define "target_format_descr". FDFMTBEG and FDFMTEND ioctls do not use the third argument. Reviewed-by: Laurent Vivier Signed-off-by: Aleksandar Markovic Message-Id: <1579214991-19602-9-git-send-email-aleksandar.marko...@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h| 3 +++ linux-user/syscall_defs.h | 3 +++ linux-user/syscall_types.h | 5 + 3 files changed, 11 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 2c3d798842e4..29969e2f2f27 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -115,6 +115,9 @@ IOCTL(FDMSGON, 0, TYPE_NULL) IOCTL(FDMSGOFF, 0, TYPE_NULL) IOCTL(FDSETEMSGTRESH, 0, TYPE_NULL) + IOCTL(FDFMTBEG, 0, TYPE_NULL) + IOCTL(FDFMTTRK, IOC_W, MK_PTR(MK_STRUCT(STRUCT_format_descr))) + IOCTL(FDFMTEND, 0, TYPE_NULL) IOCTL(FDFLUSH, 0, TYPE_NULL) IOCTL(FDSETMAXERRS, IOC_W, MK_PTR(MK_STRUCT(STRUCT_floppy_max_errors))) IOCTL(FDGETMAXERRS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_floppy_max_errors))) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 48de76145f0c..b3acf85a6b23 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -899,6 +899,9 @@ struct target_pollfd { #define TARGET_FDMSGONTARGET_IO(2, 0x45) #define TARGET_FDMSGOFF TARGET_IO(2, 0x46) +#define TARGET_FDFMTBEG TARGET_IO(2, 0x47) +#define TARGET_FDFMTTRK TARGET_IOW(2, 0x48, struct format_descr) +#define TARGET_FDFMTEND TARGET_IO(2, 0x49) #define TARGET_FDSETEMSGTRESH TARGET_IO(2, 0x4a) #define TARGET_FDFLUSHTARGET_IO(2, 0x4b) #define TARGET_FDSETMAXERRS TARGET_IOW(2, 0x4c, struct floppy_max_errors) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index e4e0429637c5..8ff78a625ace 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -261,6 +261,11 @@ STRUCT(blkpg_ioctl_arg, TYPE_INT, /* datalen */ TYPE_PTRVOID) /* data */ +STRUCT(format_descr, + TYPE_INT, /* device */ + TYPE_INT, /* head */ + TYPE_INT) /* track */ + STRUCT(floppy_max_errors, TYPE_INT, /* abort */ TYPE_INT, /* read_track */ -- 2.24.1
Re: Maintainers, please add Message-Id: when merging patches
Alex Bennée writes: > Stefan Hajnoczi writes: > >> Around 66% of qemu.git commits since v4.1.0 include a Message-Id: tag. >> Hooray! >> >> Message-Id: references the patch email that a commit was merged from. >> This information is helpful to anyone wishing to refer back to email >> discussions and patch series. > > So I guess the ones that don't are maintainer originated patches unless > you actively rebuild your trees from a posted series? I recommend using the exact same workflow for constructing pull requests whether you wrote the patches yourself or not.
[PULL 06/17] linux-user: Add support for FD ioctls
From: Aleksandar Markovic FDSETEMSGTRESH, FDSETMAXERRS, and FDGETMAXERRS ioctls are commands for controlling error reporting of a floppy drive. FDSETEMSGTRESH's third agrument is a pointer to the structure: struct floppy_max_errors { unsigned int abort, /* number of errors to be reached before aborting */ read_track, /* maximal number of errors permitted to read an * entire track at once */ reset, /* maximal number of errors before a reset is tried */ recal, /* maximal number of errors before a recalibrate is * tried */ /* * Threshold for reporting FDC errors to the console. * Setting this to zero may flood your screen when using * ultra cheap floppies ;-) */ reporting; }; defined in Linux kernel header . Since all fields of the structure are of type 'unsigned int', there is no need to define "target_floppy_max_errors". FDSETMAXERRS and FDGETMAXERRS ioctls do not use the third argument. Reviewed-by: Laurent Vivier Signed-off-by: Aleksandar Markovic Message-Id: <1579214991-19602-8-git-send-email-aleksandar.marko...@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h| 3 +++ linux-user/syscall_defs.h | 3 +++ linux-user/syscall_types.h | 7 +++ 3 files changed, 13 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 3affd8814a86..2c3d798842e4 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -114,7 +114,10 @@ IOCTL(FDMSGON, 0, TYPE_NULL) IOCTL(FDMSGOFF, 0, TYPE_NULL) + IOCTL(FDSETEMSGTRESH, 0, TYPE_NULL) IOCTL(FDFLUSH, 0, TYPE_NULL) + IOCTL(FDSETMAXERRS, IOC_W, MK_PTR(MK_STRUCT(STRUCT_floppy_max_errors))) + IOCTL(FDGETMAXERRS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_floppy_max_errors))) IOCTL(FDRESET, 0, TYPE_NULL) IOCTL(FDRAWCMD, 0, TYPE_NULL) IOCTL(FDTWADDLE, 0, TYPE_NULL) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index a73cc3d06790..48de76145f0c 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -899,7 +899,10 @@ struct target_pollfd { #define TARGET_FDMSGONTARGET_IO(2, 0x45) #define TARGET_FDMSGOFF TARGET_IO(2, 0x46) +#define TARGET_FDSETEMSGTRESH TARGET_IO(2, 0x4a) #define TARGET_FDFLUSHTARGET_IO(2, 0x4b) +#define TARGET_FDSETMAXERRS TARGET_IOW(2, 0x4c, struct floppy_max_errors) +#define TARGET_FDGETMAXERRS TARGET_IOR(2, 0x0e, struct floppy_max_errors) #define TARGET_FDRESETTARGET_IO(2, 0x54) #define TARGET_FDRAWCMD TARGET_IO(2, 0x58) #define TARGET_FDTWADDLE TARGET_IO(2, 0x59) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 4e3698382629..e4e0429637c5 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -261,6 +261,13 @@ STRUCT(blkpg_ioctl_arg, TYPE_INT, /* datalen */ TYPE_PTRVOID) /* data */ +STRUCT(floppy_max_errors, + TYPE_INT, /* abort */ + TYPE_INT, /* read_track */ + TYPE_INT, /* reset */ + TYPE_INT, /* recal */ + TYPE_INT) /* reporting */ + #if defined(CONFIG_USBFS) /* usb device ioctls */ STRUCT(usbdevfs_ctrltransfer, -- 2.24.1
[PULL 15/17] linux-user: Add support for getting/setting RTC wakeup alarm using ioctls
From: Filip Bozuta This patch implements functionalities of following ioctls: RTC_WKALM_SET, RTC_WKALM_GET - Getting/Setting wakeup alarm Some RTCs support a more powerful alarm interface, using these ioctls to read or write the RTC's alarm time (respectively) with this structure: struct rtc_wkalrm { unsigned char enabled; unsigned char pending; struct rtc_time time; }; The enabled flag is used to enable or disable the alarm interrupt, or to read its current status; when using these calls, RTC_AIE_ON and RTC_AIE_OFF are not used. The pending flag is used by RTC_WKALM_RD to report a pending interrupt (so it's mostly useless on Linux, except when talking to the RTC managed by EFI firmware). The time field is as used with RTC_ALM_READ and RTC_ALM_SET except that the tm_mday, tm_mon, and tm_year fields are also valid. A pointer to this structure should be passed as the third ioctl's argument. Implementation notes: All ioctls in this patch have a pointer to a structure rtc_wkalrm as their third argument. That is the reason why corresponding definition is added in linux-user/syscall_types.h. Since all elements of this structure are either of type 'unsigned char' or 'struct rtc_time' (that was covered in one of previous patches), the rest of the implementation is straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta Message-Id: <1579117007-7565-5-git-send-email-filip.boz...@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h| 2 ++ linux-user/syscall_defs.h | 2 ++ linux-user/syscall_types.h | 5 + 3 files changed, 9 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 9e91eaae7705..e4c1fbf52b1b 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -85,6 +85,8 @@ IOCTL(RTC_IRQP_SET, IOC_W, TYPE_ULONG) IOCTL(RTC_EPOCH_READ, IOC_R, MK_PTR(TYPE_ULONG)) IOCTL(RTC_EPOCH_SET, IOC_W, TYPE_ULONG) + IOCTL(RTC_WKALM_RD, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm))) + IOCTL(RTC_WKALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm))) IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT)) IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index fcbb2ee9a387..c33432a374e5 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -780,6 +780,8 @@ struct target_pollfd { #define TARGET_RTC_IRQP_SET TARGET_IOW('p', 0x0c, abi_ulong) #define TARGET_RTC_EPOCH_READ TARGET_IOR('p', 0x0d, abi_ulong) #define TARGET_RTC_EPOCH_SETTARGET_IOW('p', 0x0e, abi_ulong) +#define TARGET_RTC_WKALM_RD TARGET_IOR('p', 0x10, struct rtc_wkalrm) +#define TARGET_RTC_WKALM_SETTARGET_IOW('p', 0x0f, struct rtc_wkalrm) #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index bddc89a6641b..3efa9536ccfa 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -266,6 +266,11 @@ STRUCT(rtc_time, TYPE_INT, /* tm_yday */ TYPE_INT) /* tm_isdst */ +STRUCT(rtc_wkalrm, + TYPE_CHAR, /* enabled */ + TYPE_CHAR, /* pending */ + MK_STRUCT(STRUCT_rtc_time)) /* time */ + STRUCT(blkpg_ioctl_arg, TYPE_INT, /* op */ TYPE_INT, /* flags */ -- 2.24.1
[PULL 17/17] linux-user: Add support for read/clear RTC voltage low detector using ioctls
From: Filip Bozuta This patch implements functionalities of following ioctls: RTC_VL_READ - Read voltage low detection information Read the voltage low for RTCs that support voltage low. The third ioctl's' argument points to an int in which the voltage low is returned. RTC_VL_CLR - Clear voltage low information Clear the information about voltage low for RTCs that support voltage low. The third ioctl(2) argument is ignored. Implementation notes: Since one ioctl has a pointer to 'int' as its third agrument, and another ioctl has NULL as its third argument, their implementation was straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta Message-Id: <1579117007-7565-7-git-send-email-filip.boz...@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 789764d11314..73dcc761e642 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -89,6 +89,8 @@ IOCTL(RTC_WKALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm))) IOCTL(RTC_PLL_GET, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info))) IOCTL(RTC_PLL_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info))) + IOCTL(RTC_VL_READ, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(RTC_VL_CLR, 0, TYPE_NULL) IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT)) IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 9f7aad49c683..9b61ae8547dd 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -796,6 +796,8 @@ struct target_rtc_pll_info { struct target_rtc_pll_info) #define TARGET_RTC_PLL_SET TARGET_IOW('p', 0x12, \ struct target_rtc_pll_info) +#define TARGET_RTC_VL_READ TARGET_IOR('p', 0x13, int) +#define TARGET_RTC_VL_CLR TARGET_IO('p', 0x14) #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) -- 2.24.1
[PULL 12/17] linux-user: Add support for enabling/disabling RTC features using ioctls
From: Filip Bozuta This patch implements functionalities of following ioctls: RTC_AIE_ON, RTC_AIE_OFF - Alarm interrupt enabling on/off Enable or disable the alarm interrupt, for RTCs that support alarms. The third ioctl's argument is ignored. RTC_UIE_ON, RTC_UIE_OFF - Update interrupt enabling on/off Enable or disable the interrupt on every clock update, for RTCs that support this once-per-second interrupt. The third ioctl's argument is ignored. RTC_PIE_ON, RTC_PIE_OFF - Periodic interrupt enabling on/off Enable or disable the periodic interrupt, for RTCs that sup‐ port these periodic interrupts. The third ioctl's argument is ignored. Only a privileged process (i.e., one having the CAP_SYS_RESOURCE capability) can enable the periodic interrupt if the frequency is currently set above the value specified in /proc/sys/dev/rtc/max-user-freq. RTC_WIE_ON, RTC_WIE_OFF - Watchdog interrupt enabling on/off Enable or disable the Watchdog interrupt, for RTCs that sup- port this Watchdog interrupt. The third ioctl's argument is ignored. Implementation notes: Since all of involved ioctls have NULL as their third argument, their implementation was straightforward. The line '#include ' was added to recognize preprocessor definitions for these ioctls. This needs to be done only once in this series of commits. Also, the content of this file (with respect to ioctl definitions) remained unchanged for a long time, therefore there is no need to worry about supporting older Linux kernel version. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta Message-Id: <1579117007-7565-2-git-send-email-filip.boz...@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h | 9 + linux-user/syscall.c | 1 + linux-user/syscall_defs.h | 10 ++ 3 files changed, 20 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 23f6d3feb5db..55ad47186dc0 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -69,6 +69,15 @@ IOCTL(KDSETLED, 0, TYPE_INT) IOCTL_SPECIAL(KDSIGACCEPT, 0, do_ioctl_kdsigaccept, TYPE_INT) + IOCTL(RTC_AIE_ON, 0, TYPE_NULL) + IOCTL(RTC_AIE_OFF, 0, TYPE_NULL) + IOCTL(RTC_UIE_ON, 0, TYPE_NULL) + IOCTL(RTC_UIE_OFF, 0, TYPE_NULL) + IOCTL(RTC_PIE_ON, 0, TYPE_NULL) + IOCTL(RTC_PIE_OFF, 0, TYPE_NULL) + IOCTL(RTC_WIE_ON, 0, TYPE_NULL) + IOCTL(RTC_WIE_OFF, 0, TYPE_NULL) + IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT)) IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) IOCTL(BLKRRPART, 0, TYPE_NULL) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index bd2436b31007..d60142f0691c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -110,6 +110,7 @@ #include #include #include +#include #include "linux_loop.h" #include "uname.h" diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index fb8318d12185..fc3d79ab9762 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -763,6 +763,16 @@ struct target_pollfd { #define TARGET_KDSETLED0x4B32 /* set led state [lights, not flags] */ #define TARGET_KDSIGACCEPT 0x4B4E +/* real time clock ioctls */ +#define TARGET_RTC_AIE_ON TARGET_IO('p', 0x01) +#define TARGET_RTC_AIE_OFF TARGET_IO('p', 0x02) +#define TARGET_RTC_UIE_ON TARGET_IO('p', 0x03) +#define TARGET_RTC_UIE_OFF TARGET_IO('p', 0x04) +#define TARGET_RTC_PIE_ON TARGET_IO('p', 0x05) +#define TARGET_RTC_PIE_OFF TARGET_IO('p', 0x06) +#define TARGET_RTC_WIE_ON TARGET_IO('p', 0x0f) +#define TARGET_RTC_WIE_OFF TARGET_IO('p', 0x10) + #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) #define TARGET_FIOGETOWN TARGET_IOR('f', 123, int) -- 2.24.1
[PULL 02/17] linux-user: Reserve space for brk
From: Richard Henderson With bad luck, we can wind up with no space at all for brk, which will generally cause the guest malloc to fail. This bad luck is easier to come by with ET_DYN (PIE) binaries, where either the stack or the interpreter (ld.so) gets placed immediately after the main executable. But there's nothing preventing this same thing from happening with ET_EXEC (normal) binaries, during probe_guest_base(). In both cases, reserve some extra space via mmap and release it back to the system after loading the interpreter and allocating the stack. The choice of 16MB is somewhat arbitrary. It's enough for libc to get going, but without being so large that 32-bit guests or 32-bit hosts are in danger of running out of virtual address space. It is expected that libc will be able to fall back to mmap arenas after the limited brk space is exhausted. Launchpad: https://bugs.launchpad.net/qemu/+bug/1749393 Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée Tested-by: Alex Bennée Message-Id: <20200117230245.5040-1-richard.hender...@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/elfload.c | 73 +--- linux-user/qemu.h| 1 + 2 files changed, 57 insertions(+), 17 deletions(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 511e4500788b..f3080a16358c 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -10,6 +10,7 @@ #include "qemu/path.h" #include "qemu/queue.h" #include "qemu/guest-random.h" +#include "qemu/units.h" #ifdef _ARCH_PPC64 #undef ARCH_DLINFO @@ -2364,24 +2365,51 @@ static void load_elf_image(const char *image_name, int image_fd, } } -load_addr = loaddr; -if (ehdr->e_type == ET_DYN) { -/* The image indicates that it can be loaded anywhere. Find a - location that can hold the memory space required. If the - image is pre-linked, LOADDR will be non-zero. Since we do - not supply MAP_FIXED here we'll use that address if and - only if it remains available. */ -load_addr = target_mmap(loaddr, hiaddr - loaddr, PROT_NONE, -MAP_PRIVATE | MAP_ANON | MAP_NORESERVE, --1, 0); -if (load_addr == -1) { -goto exit_perror; +if (pinterp_name != NULL) { +/* + * This is the main executable. + * + * Reserve extra space for brk. + * We hold on to this space while placing the interpreter + * and the stack, lest they be placed immediately after + * the data segment and block allocation from the brk. + * + * 16MB is chosen as "large enough" without being so large + * as to allow the result to not fit with a 32-bit guest on + * a 32-bit host. + */ +info->reserve_brk = 16 * MiB; +hiaddr += info->reserve_brk; + +if (ehdr->e_type == ET_EXEC) { +/* + * Make sure that the low address does not conflict with + * MMAP_MIN_ADDR or the QEMU application itself. + */ +probe_guest_base(image_name, loaddr, hiaddr); } -} else if (pinterp_name != NULL) { -/* This is the main executable. Make sure that the low - address does not conflict with MMAP_MIN_ADDR or the - QEMU application itself. */ -probe_guest_base(image_name, loaddr, hiaddr); +} + +/* + * Reserve address space for all of this. + * + * In the case of ET_EXEC, we supply MAP_FIXED so that we get + * exactly the address range that is required. + * + * Otherwise this is ET_DYN, and we are searching for a location + * that can hold the memory space required. If the image is + * pre-linked, LOADDR will be non-zero, and the kernel should + * honor that address if it happens to be free. + * + * In both cases, we will overwrite pages in this range with mappings + * from the executable. + */ +load_addr = target_mmap(loaddr, hiaddr - loaddr, PROT_NONE, +MAP_PRIVATE | MAP_ANON | MAP_NORESERVE | +(ehdr->e_type == ET_EXEC ? MAP_FIXED : 0), +-1, 0); +if (load_addr == -1) { +goto exit_perror; } load_bias = load_addr - loaddr; @@ -2860,6 +2888,17 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) bprm->core_dump = &elf_core_dump; #endif +/* + * If we reserved extra space for brk, release it now. + * The implementation of do_brk in syscalls.c expects to be able + * to mmap pages in this space. + */ +if (info->reserve_brk) { +abi_ulong start_brk = HOST_PAGE_ALIGN(info->brk); +abi_ulong end_brk = HOST_PAGE_ALIGN(info->brk + info->reserve_brk); +target_munmap(start_brk, end_brk - start_brk); +} + return 0; } diff --git a/linux-user/qemu.h
[PULL 13/17] linux-user: Add support for getting/setting RTC time and alarm using ioctls
From: Filip Bozuta This patch implements functionalities of following ioctls: RTC_RD_TIME - Getting RTC time Returns this RTC's time in the following structure: struct rtc_time { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; /* unused */ int tm_yday; /* unused */ int tm_isdst;/* unused */ }; The fields in this structure have the same meaning and ranges as the tm structure described in gmtime man page. A pointer to this structure should be passed as the third ioctl's argument. RTC_SET_TIME - Setting RTC time Sets this RTC's time to the time specified by the rtc_time structure pointed to by the third ioctl's argument. To set the RTC's time the process must be privileged (i.e., have the CAP_SYS_TIME capability). RTC_ALM_READ, RTC_ALM_SET - Getting/Setting alarm time Read and set the alarm time, for RTCs that support alarms. The alarm interrupt must be separately enabled or disabled using the RTC_AIE_ON, RTC_AIE_OFF requests. The third ioctl's argument is a pointer to a rtc_time structure. Only the tm_sec, tm_min, and tm_hour fields of this structure are used. Implementation notes: All ioctls in this patch have pointer to a structure rtc_time as their third argument. That is the reason why corresponding definition is added in linux-user/syscall_types.h. Since all elements of this structure are of type 'int', the rest of the implementation is straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta Message-Id: <1579117007-7565-3-git-send-email-filip.boz...@rt-rk.com> Signed-off-by: Laurent Vivier --- linux-user/ioctls.h| 4 linux-user/syscall_defs.h | 4 linux-user/syscall_types.h | 11 +++ 3 files changed, 19 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 55ad47186dc0..c39dd0128a60 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -77,6 +77,10 @@ IOCTL(RTC_PIE_OFF, 0, TYPE_NULL) IOCTL(RTC_WIE_ON, 0, TYPE_NULL) IOCTL(RTC_WIE_OFF, 0, TYPE_NULL) + IOCTL(RTC_ALM_READ, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) + IOCTL(RTC_ALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) + IOCTL(RTC_RD_TIME, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) + IOCTL(RTC_SET_TIME, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT)) IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index fc3d79ab9762..dc36dd475112 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -772,6 +772,10 @@ struct target_pollfd { #define TARGET_RTC_PIE_OFF TARGET_IO('p', 0x06) #define TARGET_RTC_WIE_ON TARGET_IO('p', 0x0f) #define TARGET_RTC_WIE_OFF TARGET_IO('p', 0x10) +#define TARGET_RTC_ALM_READ TARGET_IOR('p', 0x08, struct rtc_time) +#define TARGET_RTC_ALM_SET TARGET_IOW('p', 0x07, struct rtc_time) +#define TARGET_RTC_RD_TIME TARGET_IOR('p', 0x09, struct rtc_time) +#define TARGET_RTC_SET_TIME TARGET_IOW('p', 0x0a, struct rtc_time) #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 8ff78a625ace..bddc89a6641b 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -255,6 +255,17 @@ STRUCT(blkpg_partition, MK_ARRAY(TYPE_CHAR, BLKPG_DEVNAMELTH), /* devname */ MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */ +STRUCT(rtc_time, + TYPE_INT, /* tm_sec */ + TYPE_INT, /* tm_min */ + TYPE_INT, /* tm_hour */ + TYPE_INT, /* tm_mday */ + TYPE_INT, /* tm_mon */ + TYPE_INT, /* tm_year */ + TYPE_INT, /* tm_wday */ + TYPE_INT, /* tm_yday */ + TYPE_INT) /* tm_isdst */ + STRUCT(blkpg_ioctl_arg, TYPE_INT, /* op */ TYPE_INT, /* flags */ -- 2.24.1
Re: [PATCH v9 4/6] tpm_spapr: Support suspend and resume
On Tue, Jan 21, 2020 at 7:30 PM Stefan Berger wrote: > > From: Stefan Berger > > Extend the tpm_spapr frontend with VM suspend and resume support. > > Signed-off-by: Stefan Berger Reviewed-by: Marc-André Lureau > --- > hw/tpm/tpm_spapr.c | 52 - > hw/tpm/trace-events | 2 ++ > 2 files changed, 53 insertions(+), 1 deletion(-) > > diff --git a/hw/tpm/tpm_spapr.c b/hw/tpm/tpm_spapr.c > index 1db9696ae0..8ba561f41c 100644 > --- a/hw/tpm/tpm_spapr.c > +++ b/hw/tpm/tpm_spapr.c > @@ -76,6 +76,8 @@ typedef struct { > > unsigned char *buffer; > > +uint32_t numbytes; /* number of bytes to deliver on resume */ > + > TPMBackendCmd cmd; > > TPMBackend *be_driver; > @@ -240,6 +242,14 @@ static void tpm_spapr_request_completed(TPMIf *ti, int > ret) > > /* a max. of be_buffer_size bytes can be transported */ > len = MIN(tpm_cmd_get_size(s->buffer), s->be_buffer_size); > + > +if (runstate_check(RUN_STATE_FINISH_MIGRATE)) { > +trace_tpm_spapr_caught_response(len); > +/* defer delivery of response until .post_load */ > +s->numbytes = len; > +return; > +} > + > rc = spapr_vio_dma_write(&s->vdev, be32_to_cpu(crq->data), > s->buffer, len); > > @@ -288,6 +298,7 @@ static void tpm_spapr_reset(SpaprVioDevice *dev) > SpaprTpmState *s = VIO_SPAPR_VTPM(dev); > > s->state = SPAPR_VTPM_STATE_NONE; > +s->numbytes = 0; > > s->be_tpm_version = tpm_backend_get_tpm_version(s->be_driver); > > @@ -309,9 +320,48 @@ static enum TPMVersion tpm_spapr_get_version(TPMIf *ti) > return tpm_backend_get_tpm_version(s->be_driver); > } > > +/* persistent state handling */ > + > +static int tpm_spapr_pre_save(void *opaque) > +{ > +SpaprTpmState *s = opaque; > + > +tpm_backend_finish_sync(s->be_driver); > +/* > + * we cannot deliver the results to the VM since DMA would touch VM > memory > + */ > + > +return 0; > +} > + > +static int tpm_spapr_post_load(void *opaque, int version_id) > +{ > +SpaprTpmState *s = opaque; > + > +if (s->numbytes) { > +trace_tpm_spapr_post_load(); > +/* deliver the results to the VM via DMA */ > +tpm_spapr_request_completed(TPM_IF(s), 0); > +s->numbytes = 0; > +} > + > +return 0; > +} > + > static const VMStateDescription vmstate_spapr_vtpm = { > .name = "tpm-spapr", > -.unmigratable = 1, > +.pre_save = tpm_spapr_pre_save, > +.post_load = tpm_spapr_post_load, > +.fields = (VMStateField[]) { > +VMSTATE_SPAPR_VIO(vdev, SpaprTpmState), > + > +VMSTATE_UINT8(state, SpaprTpmState), > +VMSTATE_UINT32(numbytes, SpaprTpmState), > +VMSTATE_VBUFFER_UINT32(buffer, SpaprTpmState, 0, NULL, numbytes), > +/* remember DMA address */ > +VMSTATE_UINT32(crq.data, SpaprTpmState), > +VMSTATE_END_OF_LIST(), > +} > }; > > static Property tpm_spapr_properties[] = { > diff --git a/hw/tpm/trace-events b/hw/tpm/trace-events > index 9143a8eaa3..439e514787 100644 > --- a/hw/tpm/trace-events > +++ b/hw/tpm/trace-events > @@ -67,3 +67,5 @@ tpm_spapr_do_crq_get_version(uint32_t version) "response: > version %u" > tpm_spapr_do_crq_prepare_to_suspend(void) "response: preparing to suspend" > tpm_spapr_do_crq_unknown_msg_type(uint8_t type) "Unknown message type 0x%02x" > tpm_spapr_do_crq_unknown_crq(uint8_t raw1, uint8_t raw2) "unknown CRQ 0x%02x > 0x%02x ..." > +tpm_spapr_post_load(void) "Delivering TPM response after resume" > +tpm_spapr_caught_response(uint32_t v) "Caught response to deliver after > resume: %u bytes" > -- > 2.24.1 > > -- Marc-André Lureau
Re: [PATCH qemu v5] spapr: Kill SLOF
On 23/01/2020 16:11, David Gibson wrote: > On Wed, Jan 22, 2020 at 06:14:37PM +1100, Alexey Kardashevskiy wrote: >> >> >> On 22/01/2020 17:32, David Gibson wrote: >>> On Tue, Jan 21, 2020 at 06:25:36PM +1100, Alexey Kardashevskiy wrote: On 21/01/2020 16:11, David Gibson wrote: > On Fri, Jan 10, 2020 at 01:09:25PM +1100, Alexey Kardashevskiy wrote: >> The Petitboot bootloader is way more advanced than SLOF is ever going to >> be as Petitboot comes with the full-featured Linux kernel with all >> the drivers, and initramdisk with quite user friendly interface. >> The problem with ditching SLOF is that an unmodified pseries kernel can >> either start via: >> 1. kexec, this requires presence of RTAS and skips >> ibm,client-architecture-support entirely; >> 2. normal boot, this heavily relies on the OF1275 client interface to >> fetch the device tree and do early setup (claim memory). >> >> This adds a new bios-less mode to the pseries machine: "bios=on|off". >> When enabled, QEMU does not load SLOF and jumps to the kernel from >> "-kernel". > > I don't love the name "bios" for this flag, since BIOS tends to refer > to old-school x86 firmware. Given the various plans we're considering > the future, I'd suggest "firmware=slof" for the current in-guest SLOF > mode, and say "firmware=vof" (Virtual Open Firmware) for the new > model. We can consider firmware=petitboot or firmware=none (for > direct kexec-style boot into -kernel) or whatever in the future Ok. We could also enforce default loading addresses for SLOF/kernel/grub and drop "kernel-addr", although it is going to be confusing if it changes in not so obvious way... >>> >>> Yes, I think that would be confusing, so I think adding the >>> kernel-addr override is a good idea, I'd just like it split out for >>> clarity. >>> In fact, I will ideally need 3 flags: -bios: on|off to stop loading SLOF; -kernel-addr: 0x0 for slof/kernel; 0x2 for grub; >>> >>> I'm happy for that one to be separate from the "firmware style" >>> option. >>> -kernel-translate-hack: on|off - as grub is linked to run from 0x2 and it only works when placed there, the hack breaks it. >>> >>> Hrm. I don't really understand what this one is about. That doesn't >>> really seem like something the user would ever want to fiddle with >>> directly. >> >> This allows loading grub, or actually any elf (not that I have anything >> else in mind that just grub but still) which is not capable of >> relocating itself. > > Ok, why would we ever not want that? Typical vmlinux is: [fstn1-p1 kernel]$ readelf --sections ~/pbuild/kernel-le-guest/vmlinux | head -n 100 There are 54 section headers, starting at offset 0x1027d0b8: Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0 0 0 [ 1] .head.textPROGBITS c000 0001 8000 AX 0 0 128 [ 2] .text PROGBITS c0008000 00018000 00ea2c50 AX 0 0 256 [ 3] .rodata PROGBITS c0eb 00ec 002f4b58 WA 0 0 128 [ 4] .gnu.hash GNU_HASH c11a4b58 011b4b58 001c A 27 0 8 [ 5] .pci_fixupPROGBITS c11a4b78 011b4b78 3438 A 0 0 8 [ 6] __param PROGBITS c11a7fb0 011b7fb0 3fe8 WA 0 0 8 [ 7] __modver PROGBITS c11abf98 011bbf98 0118 WA 0 0 8 This - c0xx - is where QEMU will try loading the kernel if we did not have that translate_kernel_address. > Or we can pass grub via -bios and not via -kernel but strictly speaking there is still a firmware - that new 20 bytes blob so it would not be accurate. We can put this all into a single -firmware slof|vof|grub|linux. Not sure. >>> >>> I'm not thinking of "grub" as a separate option - that would be the >>> same as "vof". Using vof + no -kernel we'd need to scan the disks in >>> the same way SLOF does, and look for a boot partition, which will >>> probably contain a GRUB image. >> >> I was hoping we can avoid that by allowing >> "-kernel grub" and let grub do filesystems and MBR/GPT. > > I don't want that to be the only way, because I want the GRUB > installed by the OS installer to be the GRUB we use. Then it means implementing filesystems in the OF client i
[PATCH] target/i386: Add the 'model-id' for Skylake -v3 CPU models
This fixes a confusion in the help output. (Although, if you squint long enough at the '-cpu help' output, you _do_ notice that "Skylake-Client-noTSX-IBRS" is an alias of "Skylake-Client-v3"; similarly for Skylake-Server-v3.) Without this patch: $ qemu-system-x86 -cpu help ... x86 Skylake-Client-v1 Intel Core Processor (Skylake) x86 Skylake-Client-v2 Intel Core Processor (Skylake, IBRS) x86 Skylake-Client-v3 Intel Core Processor (Skylake, IBRS) ... x86 Skylake-Server-v1 Intel Xeon Processor (Skylake) x86 Skylake-Server-v2 Intel Xeon Processor (Skylake, IBRS) x86 Skylake-Server-v3 Intel Xeon Processor (Skylake, IBRS) ... With this patch: $ ./qemu-system-x86 -cpu help ... x86 Skylake-Client-v1 Intel Core Processor (Skylake) x86 Skylake-Client-v2 Intel Core Processor (Skylake, IBRS) x86 Skylake-Client-v3 Intel Core Processor (Skylake, IBRS, no TSX) ... x86 Skylake-Server-v1 Intel Xeon Processor (Skylake) x86 Skylake-Server-v2 Intel Xeon Processor (Skylake, IBRS) x86 Skylake-Server-v3 Intel Xeon Processor (Skylake, IBRS, no TSX) ... Signed-off-by: Kashyap Chamarthy --- target/i386/cpu.c | 4 1 file changed, 4 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 41f28cebf946c7dd77a066eac55623a7370730d5..821cab7f2a4eda43631359a95f7b3bb301b9788f 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2905,6 +2905,8 @@ static X86CPUDefinition builtin_x86_defs[] = { .props = (PropValue[]) { { "hle", "off" }, { "rtm", "off" }, +{ "model-id", + "Intel Core Processor (Skylake, IBRS, no TSX)" }, { /* end of list */ } } }, @@ -3028,6 +3030,8 @@ static X86CPUDefinition builtin_x86_defs[] = { .props = (PropValue[]) { { "hle", "off" }, { "rtm", "off" }, +{ "model-id", + "Intel Xeon Processor (Skylake, IBRS, no TSX)" }, { /* end of list */ } } }, -- 2.21.0
Re: [PATCH] target/i386: Add the 'model-id' for Skylake -v3 CPU models
On 23/01/20 10:01, Kashyap Chamarthy wrote: > This fixes a confusion in the help output. (Although, if you squint > long enough at the '-cpu help' output, you _do_ notice that > "Skylake-Client-noTSX-IBRS" is an alias of "Skylake-Client-v3"; > similarly for Skylake-Server-v3.) > > Without this patch: > > $ qemu-system-x86 -cpu help > ... > x86 Skylake-Client-v1 Intel Core Processor (Skylake) > x86 Skylake-Client-v2 Intel Core Processor (Skylake, IBRS) > x86 Skylake-Client-v3 Intel Core Processor (Skylake, IBRS) > ... > x86 Skylake-Server-v1 Intel Xeon Processor (Skylake) > x86 Skylake-Server-v2 Intel Xeon Processor (Skylake, IBRS) > x86 Skylake-Server-v3 Intel Xeon Processor (Skylake, IBRS) > ... > > With this patch: > > $ ./qemu-system-x86 -cpu help > ... > x86 Skylake-Client-v1 Intel Core Processor (Skylake) > x86 Skylake-Client-v2 Intel Core Processor (Skylake, IBRS) > x86 Skylake-Client-v3 Intel Core Processor (Skylake, IBRS, no TSX) > ... > x86 Skylake-Server-v1 Intel Xeon Processor (Skylake) > x86 Skylake-Server-v2 Intel Xeon Processor (Skylake, IBRS) > x86 Skylake-Server-v3 Intel Xeon Processor (Skylake, IBRS, no TSX) > ... > > Signed-off-by: Kashyap Chamarthy > --- > target/i386/cpu.c | 4 > 1 file changed, 4 insertions(+) > > diff --git a/target/i386/cpu.c b/target/i386/cpu.c > index > 41f28cebf946c7dd77a066eac55623a7370730d5..821cab7f2a4eda43631359a95f7b3bb301b9788f > 100644 > --- a/target/i386/cpu.c > +++ b/target/i386/cpu.c > @@ -2905,6 +2905,8 @@ static X86CPUDefinition builtin_x86_defs[] = { > .props = (PropValue[]) { > { "hle", "off" }, > { "rtm", "off" }, > +{ "model-id", > + "Intel Core Processor (Skylake, IBRS, no TSX)" }, > { /* end of list */ } > } > }, > @@ -3028,6 +3030,8 @@ static X86CPUDefinition builtin_x86_defs[] = { > .props = (PropValue[]) { > { "hle", "off" }, > { "rtm", "off" }, > +{ "model-id", > + "Intel Xeon Processor (Skylake, IBRS, no TSX)" }, > { /* end of list */ } > } > }, > Queued, thanks. Paolo
Re: Maintainers, please add Message-Id: when merging patches
On 01/22/20 20:07, Cornelia Huck wrote: > On Wed, 22 Jan 2020 18:56:47 + > Alex Bennée wrote: > >> Laszlo Ersek writes: >> >>> On 01/22/20 13:30, Alex Bennée wrote: Stefan Hajnoczi writes: > Around 66% of qemu.git commits since v4.1.0 include a Message-Id: tag. > Hooray! > > Message-Id: references the patch email that a commit was merged from. > This information is helpful to anyone wishing to refer back to email > discussions and patch series. So I guess the ones that don't are maintainer originated patches unless you actively rebuild your trees from a posted series? >>> >>> I *think* this should not be a huge problem process wise: >>> >>> Assuming that a maintainer does not include their own patches in a PULL >>> request for Peter until the same patches receive R-b/A-b/T-b feedback >>> from other list subscribers, the maintainer will want to rebase the >>> patches at least once anyway, in order to pick up those lines. >> >> Oh I always do a re-base as I apply the r-b/t-b tags. But that is >> working off my tree and a bunch of references to the emails with the >> appropriate tags in them. >> >> So which Message-Id should I use. The first time the patch was posted to >> the list or the last time it was? > > From the last one? I mean, I'll pick the last incarnation if I apply > someone else's patches, as well? I think so as well -- pick the IDs from those messages of yours that another maintainer would apply with git-am. (BTW I've had another thought -- git-send-email prints the message IDs it generates while sending the emails, so one could pick those up with a git-rebase/reword right after posting, too.) Thanks, Laszlo > > [I just add the id right before I send my 'queued' email.] >
[Bug 1859656] Re: [2.6] Unable to reboot s390x KVM machine after initial deploy
TBH I'd really want to see how this worked as we didn't push anything to Bionic that would have changed this recently. I checked and the only change in that regard is really old. It was for bug 1790901 which was a prereq for real IPXE on s390x. So I doubt that MAAS could have worked before that. Never the less to be sure I was trying the old verson (which needed an odd bundle of kernel+initrd to build into what you reply on netboot). But even that - if netboot is failing - it does not fall through (as I'd expected, but I wanted to be sure). root@testkvm-bionic-from:~# virsh start netboot --console Domain netboot started Connected to domain netboot Escape character is ^] done Using IPv4 address: 192.168.122.33 Requesting file "" via TFTP from 192.168.122.1 Receiving data: 0 KBytesICMP ERROR "port unreachable" Failed to load OS from network -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1859656 Title: [2.6] Unable to reboot s390x KVM machine after initial deploy Status in MAAS: New Status in QEMU: Incomplete Status in Ubuntu on IBM z Systems: Triaged Bug description: MAAS version: 2.6.1 (7832-g17912cdc9-0ubuntu1~18.04.1) Arch: S390x Appears that MAAS can not find the s390x bootloader to boot from the disk, not sure how maas determines this. However this was working in the past. I had originally thought that if the maas machine was deployed then it defaulted to boot from disk. If I force the VM to book from disk, the VM starts up as expected. Reproduce: - Deploy Disco on S390x KVM instance - Reboot it on the KVM console... Connected to domain s2lp6g001 Escape character is ^] done Using IPv4 address: 10.246.75.160 Using TFTP server: 10.246.72.3 Bootfile name: 'boots390x.bin' Receiving data: 0 KBytes TFTP error: file not found: boots390x.bin Trying pxelinux.cfg files... Receiving data: 0 KBytes Receiving data: 0 KBytes Failed to load OS from network ==> /var/log/maas/rackd.log <== 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] boots390x.bin requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/65a9ca43-9541-49be-b315-e2ca85936ea2 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/01-52-54-00-e5-d7-bb requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF64BA0 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF64BA requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF64B requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF64 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF6 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0A requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/default requested by 10.246.75.160 To manage notifications about this bug go to: https://bugs.launchpad.net/maas/+bug/1859656/+subscriptions
[Bug 1859656] Re: [2.6] Unable to reboot s390x KVM machine after initial deploy
First check - as assumed - the old style config always failed. It went into netboot, netboot fails and then it bails out. root@testkvm-bionic-from:~# virsh start netboot --console Domain netboot started Connected to domain netboot Escape character is ^] done Using IPv4 address: 192.168.122.33 Using TFTP server: 192.168.122.1 Trying pxelinux.cfg files... TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" Receiving data: 0 KBytes Repeating TFTP read request... TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" Receiving data: 0 KBytes Repeating TFTP read request... TFTP error: ICMP ERROR "port unreachable" Failed to load OS from network root@testkvm-bionic-from:~# root@testkvm-bionic-from:~# virsh list --all IdName State - netbootshut off -- -- -- -- The suggested config with bootindex (lets see if that would work on s390x) root@testkvm-bionic-from:~# virsh start netboot --console Domain netboot started Connected to domain netboot Escape character is ^] done Using IPv4 address: 192.168.122.33 Using TFTP server: 192.168.122.1 Trying pxelinux.cfg files... TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" Receiving data: 0 KBytes Repeating TFTP read request... TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" TFTP error: ICMP ERROR "port unreachable" Receiving data: 0 KBytes Repeating TFTP read request... TFTP error: ICMP ERROR "port unreachable" Failed to load OS from network by that confirming SFeole again (comment #9 this time). So no easy workarounds present. -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1859656 Title: [2.6] Unable to reboot s390x KVM machine after initial deploy Status in MAAS: New Status in QEMU: Incomplete Status in Ubuntu on IBM z Systems: Triaged Bug description: MAAS version: 2.6.1 (7832-g17912cdc9-0ubuntu1~18.04.1) Arch: S390x Appears that MAAS can not find the s390x bootloader to boot from the disk, not sure how maas determines this. However this was working in the past. I had originally thought that if the maas machine was deployed then it defaulted to boot from disk. If I force the VM to book from disk, the VM starts up as expected. Reproduce: - Deploy Disco on S390x KVM instance - Reboot it on the KVM console... Connected to domain s2lp6g001 Escape character is ^] done Using IPv4 address: 10.246.75.160 Using TFTP server: 10.246.72.3 Bootfile name: 'boots390x.bin' Receiving data: 0 KBytes TFTP error: file not found: boots390x.bin Trying pxelinux.cfg files... Receiving data: 0 KBytes Receiving data: 0 KBytes Failed to load OS from network ==> /var/log/maas/rackd.log <== 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] boots390x.bin requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/65a9ca43-9541-49be-b315-e2ca85936ea2 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/01-52-54-00-e5-d7-bb requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF64BA0 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF64BA requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF64B requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF64 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF6 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0A requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/default requested by 10.246.75.160 To manage notifications about this bug go to: https://bugs.launchpad.net/maas/+bug/1859656/+subscriptions
Re: [PATCH] target/s390x/translate: Do not leak stack address in translate_one()
On Thu, 23 Jan 2020 08:05:33 +0100 Thomas Huth wrote: > The code in translate_one() leaks a stack address via "s->field" parameter: > > static DisasJumpType translate_one(CPUS390XState *env, DisasContext *s) > { > DisasJumpType ret = DISAS_NEXT; > DisasFields f; > [...] > s->fields = &f; > [...] > return ret; > } > > It's currently harmless since the caller does not seem to use "fields" > anymore, but let's better play safe (and please static code analyzers) > by setting the fields back to NULL before returning. > > Buglink: https://bugs.launchpad.net/qemu/+bug/1661815 > Signed-off-by: Thomas Huth > --- > target/s390x/translate.c | 2 ++ > 1 file changed, 2 insertions(+) Thanks, applied.
Re: Making QEMU easier for management tools and applications
On Wed, Jan 22, 2020 at 05:42:10PM -0500, John Snow wrote: > > > On 12/24/19 8:00 AM, Daniel P. Berrangé wrote: > > Based on experiance in libvirt, this is an even larger job than (4), > > as the feature set here is huge. Much of it directly ties into the > > config problem, as to deal with SELinux / namespace setup the code > > needs to understand what resources to provide access to. This > > requires a way to express 100% coverage of all QEMU configuration > > in use & analyse it to determine what resources it implies. So this > > ties strongly into QAPI-ification completion. > > Is it totally bonkers to suggest that QEMU provide a method of digesting > a given configuration and returning a configuration object that a > standalone jailer can use? > > So we have a QEMU manager, the generic jailer, and QEMU. QEMU and the > manager cooperate to produce the jailing configuration, and the jailer > does what we ask it to. It isn't clear what you mean by "QEMU" here. If this QEMU, the system emulator process, then this is the untrustworthy part of the stack, so the jailer must not use any data that QEMU is providing. In fact during startup the jailer does its work before QEMU even exists. There are aspects to the confinement that use / rely on knowledge that QEMU doesn't normally have, or are expressed in a different way that which QEMU uses, or needs to take a different imlpementation approach to that which QEMU normally has. For networking, for example, from QEMU's config POV, there's just a TAP file descriptor. There are then a huge number of ways in which that TAP FD has been connected to the network in the host that are invisible to QEMU. Plain bridge, openvswitch bridge, macvtap device all with varying configs. Knowledge of this is relevant to the manager process and the jailer but irrelevant to QEMU. When configuring disks we have technical issues. For example we need to identify the full backing chain and grant the appropriate permissions on this. Even if there was a libqemublock.so, libvirt would not use this because the QEMU storage code design is not reliable & minimal enough. For example to just query the backing file, QEMU opens the qcow2 and parses all the data about it, building up L1/L2 tables, and other data structures involved. It is trivial to create qcow2 files which result in both memory and CPU denial of service merely from opening the file. Libvirt's approach to this is minimalist just having a data table of offsets to the key fields in each file format. So we can extract the backing file & its format without reading anything else from the disk. When configuring chardevs there is a choice of how to do it - we could just pass the UNIX socket path in, or we could create the UNIX socket ourselves & pass in the pre-opened FD. Both are equally functional from QEMU's POV and the end user's POV, but passing a pre-opened FD is more convenient for libvirt's needs as it allowed for race-free startups sychronization between libvirt & QEMU, or rather QMP. The different options here though, have different needs on the jailer, because extra steps are needed when passing pre-opened FD to get the SELinux labelling right. QEMU doesn't know which approach the mgmt app will want to take, so we can't ask QEMU how the jailer should be configured - the mgmt app needs to make that decision. Essentially we have 2 configuration formats - the high level one that the mgmt app layer uses & the low level one that QEMU uses. The component in the stack which maps between the two config formats, is that one that has the knowledge to configure the jailer. This isn't QEMU. It is whatever is immediately above QEMU, currently libvirt, but something conceptually equivalent to the role libvirt's QEMU driver impl fills. Regards, Daniel -- |: https://berrange.com -o-https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o-https://fstop138.berrange.com :| |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
Re: [PATCH v4 06/11] tests/virtio-9p: added splitted readdir test
On Wed, 22 Jan 2020 23:36:22 +0100 Christian Schoenebeck wrote: > On Mittwoch, 22. Januar 2020 22:19:05 CET Greg Kurz wrote: > > On Tue, 21 Jan 2020 01:16:21 +0100 > > > > Christian Schoenebeck wrote: > > > The previous, already existing readdir test simply used a 'count' > > > parameter big enough to retrieve all directory entries with a > > > single Treaddir request. > > > > > > In this new 'splitted' readdir test, directory entries are > > > retrieved, splitted over several Treaddir requests by picking small > > > 'count' parameters which force the server to truncate the response. > > > So the test client sends as many Treaddir requests as necessary to > > > get all directory entries. Currently this test covers actually two > > > tests: a sequence of Treaddir requests with count=512 and then a > > > subsequent test with a sequence of Treaddir requests with count=256. > > > > > > Signed-off-by: Christian Schoenebeck > > > --- > > > > Not sure it is really needed to check with multiple values for 'count', > > but it doesn't eat too many cycles so I guess it doesn't hurt. > > Yes, it is a cheap test, nobody will feel the difference. One could argue > about the precise 'count' values being used ... > > > > > Applied as well. > > > > > tests/qtest/virtio-9p-test.c | 91 > > > 1 file changed, 91 insertions(+) > > > > > > diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c > > > index 2167322985..8b0d94546e 100644 > > > --- a/tests/qtest/virtio-9p-test.c > > > +++ b/tests/qtest/virtio-9p-test.c > > > @@ -578,6 +578,7 @@ static bool fs_dirents_contain_name(struct V9fsDirent > > > *e, const char* name)> > > > return false; > > > > > > } > > > > > > +/* basic readdir test where reply fits into a single response message */ > > > > > > static void fs_readdir(void *obj, void *data, QGuestAllocator *t_alloc) > > > { > > > > > > QVirtio9P *v9p = obj; > > > > > > @@ -631,6 +632,95 @@ static void fs_readdir(void *obj, void *data, > > > QGuestAllocator *t_alloc)> > > > g_free(wnames[0]); > > > > > > } > > > > > > +/* readdir test where overall request is splitted over several messages > > > */ > > > +static void fs_readdir_split(void *obj, void *data, QGuestAllocator > > > *t_alloc) +{ > > > +QVirtio9P *v9p = obj; > > > +alloc = t_alloc; > > > +char *const wnames[] = { g_strdup(QTEST_V9FS_SYNTH_READDIR_DIR) }; > > > +uint16_t nqid; > > > +v9fs_qid qid; > > > +uint32_t count, nentries, npartialentries; > > > +struct V9fsDirent *entries, *tail, *partialentries; > > > +P9Req *req; > > > +int subtest; > > > +int fid; > > > +uint64_t offset; > > > +/* the Treaddir 'count' parameter values to be tested */ > > > +const uint32_t vcount[] = { 512, 256 }; > > ... here. But IMO it does make sense preserving the function's overall > structure to allow testing with different 'count' values if necessary. > Because > that way this test could e.g. guard potential bugs when server's Treaddir > handler is rolling back (or not) the dir offset for instance, which server > has > to do (or not) according to this 'count' value and the precise file name > length of the individual directory entries. > I still agree it is useful to be able to check different values but I now realize that it shouldn't be done like this because adding new values to vcount[] doesn't scale well with the MAX_REQ limitation I mentioned in another mail. More values, especially small ones, are likely to trigger "Failed to decode VirtFS request type 40" at some point. I now think that fs_readdir_split() should rather get count as an argument and only do one run. By default we would only call this with an appropriate value, ideally derived from the test environment (number of files, size of filenames... etc...). If someone needs to test a specific value, it is easy as adding a new qos_add_test() line. This would ensure at least that each run starts with the same fixed number of possible requests, ie. MAX_REQ minus the cost of fs_attach(). So I'll revert this patch for now. > Whatever precise 'count' tests are desired, it would only mean a one line > change here. > > Best regards, > Christian Schoenebeck > >
Re: [PATCH v4 08/11] 9pfs: readdir benchmark
On Tue, 21 Jan 2020 01:23:55 +0100 Christian Schoenebeck wrote: > This patch is not intended to be merged. It just provides a Well I like the idea of having such a benchmark available. It could probably be merged after a few changes... > temporary benchmark foundation for coneniently A/B comparison > of the subsequent 9p readdir optimization patches: > > * hw/9pfs/9p-synth: increase amount of simulated files for > readdir test to 2000 files. > ... the 9p-synth backend could maybe always create this number of files ? > * tests/virtio-9p: measure wall time that elapsed between > sending T_readdir request and arrival of R_readdir response > and print out that measured duration, as well as amount of > directory entries received, and the amount of bytes of the > response message. > ... maybe we should make the printing optional and off by default so that it doesn't pollute CI logs. > * tests/virtio-9p: increased msize to 256kiB to allow > retrieving all 2000 files (simulated by 9pfs synth driver) > with only one T_readdir request. > ... always use 256k for both the basic test and a revisited split test ? > Running this benchmark is fairly quick & simple and does not > require any guest OS installation or other prerequisites: > > cd build > make && make tests/qtest/qos-test > export QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 > tests/qtest/qos-test -p $(tests/qtest/qos-test -l | grep readdir/basic) > > Since this benchmark uses the 9pfs synth driver, the host > machine's I/O hardware (SSDs/HDDs) is not relevant for the > benchmark result, because the synth backend's readdir > implementation returns immediately (without any blocking I/O > that would incur with a real-life fs driver) and just returns > already prepared, simulated directory entries directly from RAM. > So this benchmark focuses on the efficiency of the 9pfs > controller code (or top half) for readdir request handling. > > Signed-off-by: Christian Schoenebeck > --- > hw/9pfs/9p-synth.h | 2 +- > tests/qtest/virtio-9p-test.c | 37 +++- > 2 files changed, 37 insertions(+), 2 deletions(-) > > diff --git a/hw/9pfs/9p-synth.h b/hw/9pfs/9p-synth.h > index 036d7e4a5b..7d6cedcdac 100644 > --- a/hw/9pfs/9p-synth.h > +++ b/hw/9pfs/9p-synth.h > @@ -58,7 +58,7 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int > mode, > /* for READDIR test */ > #define QTEST_V9FS_SYNTH_READDIR_DIR "ReadDirDir" > #define QTEST_V9FS_SYNTH_READDIR_FILE "ReadDirFile%d" > -#define QTEST_V9FS_SYNTH_READDIR_NFILES 100 > +#define QTEST_V9FS_SYNTH_READDIR_NFILES 2000 > > /* Any write to the "FLUSH" file is handled one byte at a time by the > * backend. If the byte is zero, the backend returns success (ie, 1), > diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c > index e47b286340..d71b37aa6c 100644 > --- a/tests/qtest/virtio-9p-test.c > +++ b/tests/qtest/virtio-9p-test.c > @@ -15,6 +15,18 @@ > #include "libqos/virtio-9p.h" > #include "libqos/qgraph.h" > > +/* > + * to benchmark the real time (not CPU time) that elapsed between start of > + * a request and arrival of its response > + */ > +static double wall_time(void) > +{ > +struct timeval t; > +struct timezone tz; > +gettimeofday(&t, &tz); > +return t.tv_sec + t.tv_usec * 0.01; > +} > + > #define QVIRTIO_9P_TIMEOUT_US (10 * 1000 * 1000) > static QGuestAllocator *alloc; > > @@ -36,7 +48,7 @@ static void pci_config(void *obj, void *data, > QGuestAllocator *t_alloc) > g_free(tag); > } > > -#define P9_MAX_SIZE 4096 /* Max size of a T-message or R-message */ > +#define P9_MAX_SIZE (256 * 1024) /* Max size of a T-message or R-message */ > > typedef struct { > QTestState *qts; > @@ -600,12 +612,35 @@ static void fs_readdir(void *obj, void *data, > QGuestAllocator *t_alloc) > v9fs_req_wait_for_reply(req, NULL); > v9fs_rlopen(req, &qid, NULL); > > +const double start = wall_time(); > + > /* > * submit count = msize - 11, because 11 is the header size of Rreaddir > */ > req = v9fs_treaddir(v9p, 1, 0, P9_MAX_SIZE - 11, 0); > +const double treaddir = wall_time(); > v9fs_req_wait_for_reply(req, NULL); > +const double waitforreply = wall_time(); > v9fs_rreaddir(req, &count, &nentries, &entries); > +const double end = wall_time(); > + > +printf("\nTime client spent on sending T_readdir: %fs\n\n", > + treaddir - start); > + > +printf("Time client spent for waiting for reply from server: %fs " > + "[MOST IMPORTANT]\n", waitforreply - start); > +printf("(This is the most important value, because it reflects the > time\n" > + "the 9p server required to process and return the result of the\n" > + "T_readdir request.)\n\n"); > + > +printf("Total client time: %fs\n", end - start); > +printf("(NOTE: this time is not relevant; this huge time comes from\n" > + "in
Re: [PATCH v3 0/2] ide: Fix incorrect handling of some PRDTs and add the corresponding unit-test
On 23.01.2020 02:14, John Snow wrote: > On 12/23/19 12:51 PM, Alexander Popov wrote: >> Fuzzing the Linux kernel with syzkaller allowed to find how to crash qemu >> using a special SCSI_IOCTL_SEND_COMMAND. It hits the assertion in >> ide_dma_cb() introduced in the commit a718978ed58a in July 2015. >> >> This patch series fixes incorrect handling of some PRDTs in ide_dma_cb() >> and improves the ide-test to cover more PRDT cases (including one >> that causes that particular qemu crash). >> >> Changes from v2 (thanks to Kevin Wolf for the feedback): >> - the assertion about prepare_buf() return value is improved; >> - the patch order is reversed to keep the tree bisectable; >> - the unit-test performance is improved -- now it runs 8 seconds >>instead of 3 minutes on my laptop. >> >> Alexander Popov (2): >> ide: Fix incorrect handling of some PRDTs in ide_dma_cb() >> tests/ide-test: Create a single unit-test covering more PRDT cases >> >> hw/ide/core.c| 30 +--- >> tests/ide-test.c | 174 --- >> 2 files changed, 96 insertions(+), 108 deletions(-) >> > > Thanks, applied to my IDE tree: > > https://github.com/jnsnow/qemu/commits/ide > https://github.com/jnsnow/qemu.git Happy end! Thanks a lot! Best regards, Alexander
[PATCH v3 01/80] numa: remove deprecated -mem-path fallback to anonymous RAM
it has been deprecated since 4.0 by commit cb79224b7 (deprecate -mem-path fallback to anonymous RAM) Deprecation period ran out and it's time to remove it so it won't get in a way of switching to using hostmem backend for RAM. Signed-off-by: Igor Mammedov --- CC:libvir-l...@redhat.com CC: ehabk...@redhat.com --- hw/core/numa.c | 18 +- qemu-deprecated.texi | 9 - 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/hw/core/numa.c b/hw/core/numa.c index 0d1b4be..840e685 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -784,24 +784,8 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, { if (mem_path) { #ifdef __linux__ -Error *err = NULL; memory_region_init_ram_from_file(mr, owner, name, ram_size, 0, 0, - mem_path, &err); -if (err) { -error_report_err(err); -if (mem_prealloc) { -exit(1); -} -warn_report("falling back to regular RAM allocation"); -error_printf("This is deprecated. Make sure that -mem-path " - " specified path has sufficient resources to allocate" - " -m specified RAM amount\n"); -/* Legacy behavior: if allocation failed, fall back to - * regular RAM allocation. - */ -mem_path = NULL; -memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error_fatal); -} + mem_path, &error_fatal); #else fprintf(stderr, "-mem-path not supported on this host\n"); exit(1); diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index 0968d37..982af95 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -113,15 +113,6 @@ QEMU using implicit generic or board specific splitting rule. Use @option{memdev} with @var{memory-backend-ram} backend or @option{mem} (if it's supported by used machine type) to define mapping explictly instead. -@subsection -mem-path fallback to RAM (since 4.1) -Currently if guest RAM allocation from file pointed by @option{mem-path} -fails, QEMU falls back to allocating from RAM, which might result -in unpredictable behavior since the backing file specified by the user -is ignored. In the future, users will be responsible for making sure -the backing storage specified with @option{-mem-path} can actually provide -the guest RAM configured with @option{-m} and QEMU will fail to start up if -RAM allocation is unsuccessful. - @subsection RISC-V -bios (since 4.1) QEMU 4.1 introduced support for the -bios option in QEMU for RISC-V for the -- 2.7.4
[PATCH v3 02/80] machine: introduce memory-backend property
Property will contain link to memory backend that will be used for backing initial RAM. Follow up commit will alias -mem-path and -mem-prealloc CLI options into memory backend options to make memory handling consistent (using only hostmem backend family for guest RAM allocation). Signed-off-by: Igor Mammedov --- v3: * rename property name from ram-memdev to memory-backend (Paolo Bonzini ) CC: ehabk...@redhat.com CC: pbonz...@redhat.com --- include/hw/boards.h | 2 ++ hw/core/machine.c | 9 + 2 files changed, 11 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index fb1b43d..6aa01b8 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -4,6 +4,7 @@ #define HW_BOARDS_H #include "exec/memory.h" +#include "sysemu/hostmem.h" #include "sysemu/blockdev.h" #include "sysemu/accel.h" #include "qapi/qapi-types-machine.h" @@ -285,6 +286,7 @@ struct MachineState { bool enforce_config_section; bool enable_graphics; char *memory_encryption; +HostMemoryBackend *ram_memdev; DeviceMemoryState *device_memory; ram_addr_t ram_size; diff --git a/hw/core/machine.c b/hw/core/machine.c index 3e288bf..bf30183 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -886,6 +886,15 @@ static void machine_initfn(Object *obj) "Table (HMAT)", NULL); } +object_property_add_link(obj, "memory-backend", TYPE_MEMORY_BACKEND, + (Object **)&ms->ram_memdev, + object_property_allow_set_link, + OBJ_PROP_LINK_STRONG, &error_abort); +object_property_set_description(obj, "memory-backend", +"Set RAM backend" +"Valid value is ID of hostmem based backend", + &error_abort); + /* Register notifier when init is done for sysbus sanity checks */ ms->sysbus_notifier.notify = machine_init_notify; qemu_add_machine_init_done_notifier(&ms->sysbus_notifier); -- 2.7.4
[PATCH v3 00/80] refactor main RAM allocation to use hostmem backend
v3: - due to libvirt not being ready, postpone till 5.1 * [PATCH v2 82/86] numa: forbid '-numa node, mem' for 5.0 and newer machine types and depended [PATCH v2 86/86] numa: remove deprecated implicit RAM distribution between nodes - drop as not related "[PATCH v2 85/86] numa: make exit() usage consistent" - drop "[PATCH v2 76/86] post conversion default_ram_id cleanup" so that default memory-backedend won't be created for boards that do not care about -m. Which makes -m optin feature. We should decide what do in case board doesn't use -m (but that's out of scope of this series) - use object_register_sugar_prop() instead of hacking compat props directly - simplified/reworked aspeed patches - s/RAM_ADDR_FMT/size_to_str()/ - rename 'ram-memdev' property to 'memory-backend' - minor fixes to numa-test - fixes for issues noticed during review of [PATCH v2 66/86] ppc/{ppc440_bamboo,sam460x}: drop RAM size fixup v2: - fix compile errors on mingw32 host by introducing RAM_ADDR_UFMT [11/86] - replace "[PATCH 43/86] hppa: drop RAM size fixup" with alternative patches made by Philippe (which effectively do the same thing but other way around) - ppc440: fix crash and add suggested valid RAM size in error output. s/ppc4xx_sdram_adjust/ppc4xx_sdram_prep/ and simplify it by removing not necessary nested loop - rebase on current master due to new conflicts Series removes ad hoc RAM allocation API (memory_region_allocate_system_memory) and consolidates it around hostmem backend. It allows to * resolve conflicts between global -mem-prealloc and hostmem's "policy" option fixing premature allocation before binding policy is applied * simplify complicated memory allocation routines which had to deal with 2 ways to allocate RAM. * it allows to reuse hostmem backends of a choice for main RAM without adding extra CLI options to duplicate hostmem features. Recent case was -mem-shared, to enable vhost-user on targets that don't support hostmem backends [1] (ex: s390) * move RAM allocation from individual boards into generic machine code and provide them with prepared MemoryRegion. * clean up deprecated NUMA features which were tied to the old API (see patches) - "numa: remove deprecated -mem-path fallback to anonymous RAM" - (POSTPONED, waiting on libvirt side) "forbid '-numa node,mem' for 5.0 and newer machine types" - (POSTPONED) "numa: remove deprecated implicit RAM distribution between nodes" Conversion introduces a new machine.memory-backend property and wrapper code that aliases global -mem-path and -mem-alloc into automatically created hostmem backend properties (provided memory-backend was not set explicitly given by user). And then follows bulk of trivial patches that incrementally convert individual boards to using machine.memory-backend provided MemoryRegion. Board conversion typically involves: * providing MachineClass::default_ram_size and MachineClass::default_ram_id so generic code could create default backend if user didn't explicitly provide memory-backend or -m options * dropping memory_region_allocate_system_memory() call * using convenience MachineState::ram MemoryRegion, which points to MemoryRegion allocated by ram-memdev On top of that for some boards: * added missing ram_size checks (typically it were boards with fixed ram size) * ram_size fixups were replaced by checks and hard errors, forcing user to provide correct "-m" values instead of ignoring it and continuing running. After all boards are converted the old API is removed and memory allocation routines are cleaned up. git tree for testing: https://github.com/imammedo/qemu convert_main_ram_to_memdev_v3 previous rev: https://github.com/imammedo/qemu convert_main_ram_to_memdev_v2 https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg02960.html Igor Mammedov (77): numa: remove deprecated -mem-path fallback to anonymous RAM machine: introduce memory-backend property machine: alias -mem-path and -mem-prealloc into memory-foo backend machine: introduce convenience MachineState::ram initialize MachineState::ram in NUMA case alpha:dp264: use memdev for RAM arm/aspeed: actually check RAM size arm/aspeed: use memdev for RAM arm/collie: use memdev for RAM arm/cubieboard: use memdev for RAM arm/digic_boards: use memdev for RAM arm/highbank: use memdev for RAM arm/imx25_pdk: drop RAM size fixup arm/imx25_pdk: use memdev for RAM arm/integratorcp: use memdev for RAM arm/kzm: drop RAM size fixup arm/kzm: use memdev for RAM arm/mcimx6ul-evk: use memdev for RAM arm/mcimx7d-sabre: use memdev for RAM arm/mps2-tz: use memdev for RAM arm/mps2: use memdev for RAM arm/musicpal: use memdev for RAM arm/nseries: use memdev for RAM arm/omap_sx1: use memdev for RAM arm/palm: use memdev for RAM arm/raspi: use memdev for RAM arm/sabrelite: use memdev for RAM arm/sbs
Re: [PATCH 19/26] qdev: set properties with device_class_set_props()
On 10/01/20 16:30, Marc-André Lureau wrote: > The following patch will need to handle properties registration during > class_init time. Let's use a device_class_set_props() setter. If you don't mind, I'll also rename "props" to "props_" so that we can more easily catch conflicts (which will be syntax errors and not just bugs) in the future. Paolo
Re: [PATCH 19/26] qdev: set properties with device_class_set_props()
Hi On Thu, Jan 23, 2020 at 3:09 PM Paolo Bonzini wrote: > > On 10/01/20 16:30, Marc-André Lureau wrote: > > The following patch will need to handle properties registration during > > class_init time. Let's use a device_class_set_props() setter. > > If you don't mind, I'll also rename "props" to "props_" so that we can > more easily catch conflicts (which will be syntax errors and not just > bugs) in the future. Yes, I wanted to do something like that too. thanks -- Marc-André Lureau
Re: [PATCH v5 2/2] tests: add virtio-scsi and virtio-blk seg_max_adjust test
On Wed, 22 Jan 2020 22:47:42 +0100 Philippe Mathieu-Daudé wrote: > > This test is failing on OSX: > > > > TestFail: machine type pc-i440fx-2.0: > > > > Looking at my job-results/job-2020-01-22T17.54-92b7fae/job.log: > > > > Unexpected error in object_property_find() at qom/object.c:1201: > > qemu-system-x86_64: -device virtio-blk-pci,id=scsi0,drive=drive0: can't > > apply global virtio-blk-device.scsi=true: Property '.scsi' not found > > > > Which makes sense looking at hw/block/virtio-blk.c: > > > > 1261 static Property virtio_blk_properties[] = { > > 1262 DEFINE_BLOCK_PROPERTIES(VirtIOBlock, conf.conf), > > ... > > 1268 #ifdef __linux__ > > 1269 DEFINE_PROP_BIT64("scsi", VirtIOBlock, host_features, > > 1270 VIRTIO_BLK_F_SCSI, false), > > 1271 #endif > > > > Except code moved around, origin is: > > > > $ git show 1063b8b15 > > commit 1063b8b15fb49fcf88ffa282b19aaaf7ca9c678c > > Author: Christoph Hellwig > > Date: Mon Apr 27 10:29:14 2009 +0200 > > > > virtio-blk: add SGI_IO passthru support > > > > Add support for SG_IO passthru (packet commands) to the virtio-blk > > backend. Conceptually based on an older patch from Hannes Reinecke > > but largely rewritten to match the code structure and layering in > > virtio-blk. > > > > Note that currently we issue the hose SG_IO synchronously. We could > > easily switch to async I/O, but that would required either bloating > > the VirtIOBlockReq by the size of struct sg_io_hdr or an additional > > memory allocation for each SG_IO request. > > > > I'm not sure what is the correct way to fix this. > > ... because of: > > $ git show ed65fd1a27 > commit ed65fd1a2750d24290354cc7ea49caec7c13e30b > Author: Cornelia Huck > Date: Fri Oct 16 12:25:54 2015 +0200 > > virtio-blk: switch off scsi-passthrough by default > > Devices that are compliant with virtio-1 do not support scsi > passthrough any more (and it has not been a recommended setup > anyway for quite some time). To avoid having to switch it off > explicitly in newer qemus that turn on virtio-1 by default, let's > switch the default to scsi=false for 2.5. > > Signed-off-by: Cornelia Huck > Message-id: 1444991154-79217-4-git-send-email-cornelia.h...@de.ibm.com > Signed-off-by: Stefan Hajnoczi > > diff --git a/include/hw/compat.h b/include/hw/compat.h > index 095de5d12f..93e71afb4a 100644 > --- a/include/hw/compat.h > +++ b/include/hw/compat.h > @@ -2,7 +2,11 @@ > #define HW_COMPAT_H > > #define HW_COMPAT_2_4 \ > -/* empty */ > +{\ > +.driver = "virtio-blk-device",\ > +.property = "scsi",\ > +.value= "true",\ > +}, This code has changed a lot in the meantime... > > #define HW_COMPAT_2_3 \ > {\ > diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c > index 3e230debb8..45a24e4fa6 100644 > --- a/hw/block/virtio-blk.c > +++ b/hw/block/virtio-blk.c > @@ -972,7 +972,7 @@ static Property virtio_blk_properties[] = { > DEFINE_PROP_STRING("serial", VirtIOBlock, conf.serial), > DEFINE_PROP_BIT("config-wce", VirtIOBlock, conf.config_wce, 0, true), > #ifdef __linux__ > -DEFINE_PROP_BIT("scsi", VirtIOBlock, conf.scsi, 0, true), > +DEFINE_PROP_BIT("scsi", VirtIOBlock, conf.scsi, 0, false), > #endif > DEFINE_PROP_BIT("request-merging", VirtIOBlock, > conf.request_merging, 0, > true), > > Should this HW_COMPAT_2_4 entry be guarded with ifdef __linux__? ... so something like the following might do the trick: diff --git a/hw/core/machine.c b/hw/core/machine.c index 3e288bfceb7f..d8e30e4895d8 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -148,7 +148,8 @@ GlobalProperty hw_compat_2_5[] = { const size_t hw_compat_2_5_len = G_N_ELEMENTS(hw_compat_2_5); GlobalProperty hw_compat_2_4[] = { -{ "virtio-blk-device", "scsi", "true" }, +/* Optional because the 'scsi' property is Linux-only */ +{ "virtio-blk-device", "scsi", "true", .optional = true }, { "e1000", "extra_mac_registers", "off" }, { "virtio-pci", "x-disable-pcie", "on" }, { "virtio-pci", "migrate-extra", "off" }, > > Probably nobody ran a pre-2.4 machine out of Linux =) > Yeah. I'm wondering if there's more compat stuff in there that should be optional. Devices that simply do not exist are not a problem, but properties that not always exist are.
Re: [PATCH v4 09/11] hw/9pfs/9p-synth: avoid n-square issue in synth_readdir()
On Tue, 21 Jan 2020 01:26:15 +0100 Christian Schoenebeck wrote: > This patch is just a temporary benchmark hack, not intended > to be merged! > > 9pfs synth driver's readdir() implementation has a severe > n-square performance problem. This patch is a quick and dirty > hack to prevent that performance problem from tainting the > readdir() benchmark results. In its current form, this patch > is not useful for anything else than for an isolated readdir > benchmark. > > NOTE: This patch would break the new readdir/split test, > because it would alter the behaviour of seekdir() required > for retrieving directory entries splitted over several > requests. > > Signed-off-by: Christian Schoenebeck > --- Honestly it doesn't seem to change anything significant for me. Mean time calculated over 100 runs: Without this patch: [greg@bahia qemu-9p]$ (cd .mbuild-$(stg branch)/obj ; export QTEST_QEMU_BINARY='x86_64-softmmu/qemu-system-x86_64'; make all tests/qtest/qos-test && for i in {1..100}; do tests/qtest/qos-test -p $(tests/qtest/qos-test -l | grep readdir/basic); done) |& awk '/IMPORTANT/ { print $10 }' | sed -e 's/s//' -e 's/^/n+=1;x+=/;$ascale=6;x/n' | bc .055654 With this patch: [greg@bahia qemu-9p]$ (cd .mbuild-$(stg branch)/obj ; export QTEST_QEMU_BINARY='x86_64-softmmu/qemu-system-x86_64'; make all tests/qtest/qos-test && for i in {1..100}; do tests/qtest/qos-test -p $(tests/qtest/qos-test -l | grep readdir/basic); done) |& awk '/IMPORTANT/ { print $10 }' | sed -e 's/s//' -e 's/^/n+=1;x+=/;$ascale=6;x/n' | bc .058786 > hw/9pfs/9p-synth.c | 29 ++--- > 1 file changed, 26 insertions(+), 3 deletions(-) > > diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c > index 7eb210ffa8..54dc30f37b 100644 > --- a/hw/9pfs/9p-synth.c > +++ b/hw/9pfs/9p-synth.c > @@ -225,7 +225,8 @@ static void synth_direntry(V9fsSynthNode *node, > } > > static struct dirent *synth_get_dentry(V9fsSynthNode *dir, > -struct dirent *entry, off_t off) > + struct dirent *entry, off_t off, > + V9fsSynthNode **hack) > { > int i = 0; > V9fsSynthNode *node; > @@ -243,16 +244,38 @@ static struct dirent *synth_get_dentry(V9fsSynthNode > *dir, > /* end of directory */ > return NULL; > } > +*hack = node; > synth_direntry(node, entry, off); > return entry; > } > > static struct dirent *synth_readdir(FsContext *ctx, V9fsFidOpenState *fs) > { > -struct dirent *entry; > +struct dirent *entry = NULL; > V9fsSynthOpenState *synth_open = fs->private; > V9fsSynthNode *node = synth_open->node; > -entry = synth_get_dentry(node, &synth_open->dent, synth_open->offset); > + > +/* > + * HACK: This is just intended for benchmark, to avoid severe n-square > + * performance problem of synth driver's readdir implementation here > which > + * would otherwise unncessarily taint the benchmark results. By simply > + * caching (globally) the previous node (of the previous synth_readdir() > + * call) we can simply proceed to next node in chained list efficiently. > + * > + * not a good idea for any production code ;-) > + */ > +static struct V9fsSynthNode *cachedNode; > + > +if (!cachedNode) { > +entry = synth_get_dentry(node, &synth_open->dent, synth_open->offset, > + &cachedNode); > +} else { > +cachedNode = cachedNode->sibling.le_next; > +if (cachedNode) { > +entry = &synth_open->dent; > +synth_direntry(cachedNode, entry, synth_open->offset + 1); > +} > +} > if (entry) { > synth_open->offset++; > }
Re: Maintainers, please add Message-Id: when merging patches
On Thu, Jan 23, 2020 at 09:27:54AM +0100, Markus Armbruster wrote: > Alex Bennée writes: > > > Stefan Hajnoczi writes: > > > >> Around 66% of qemu.git commits since v4.1.0 include a Message-Id: tag. > >> Hooray! > >> > >> Message-Id: references the patch email that a commit was merged from. > >> This information is helpful to anyone wishing to refer back to email > >> discussions and patch series. > > > > So I guess the ones that don't are maintainer originated patches unless > > you actively rebuild your trees from a posted series? > > I recommend using the exact same workflow for constructing pull requests > whether you wrote the patches yourself or not. Yes, that's the approach I follow too. I use the 'patches' tool to apply patch series, including my own. It's necessary to get the Revewied-by:, Tested-by:, etc tags squashed in automatically anyway. Stefan signature.asc Description: PGP signature
Re: [PATCH 1/6] tests/acceptance/virtio_seg_max_adjust: Only remove listed machines
On Wed, 22 Jan 2020 23:32:42 +0100 Philippe Mathieu-Daudé wrote: > Do not remove unavailable machines, this fixes: > > VirtioMaxSegSettingsCheck.test_machine_types: ERROR: list.remove(x): x not > in list (0.12 s) > > Signed-off-by: Philippe Mathieu-Daudé > --- > tests/acceptance/virtio_seg_max_adjust.py | 9 + > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/tests/acceptance/virtio_seg_max_adjust.py > b/tests/acceptance/virtio_seg_max_adjust.py > index 5458573138..4a417b8ef5 100755 > --- a/tests/acceptance/virtio_seg_max_adjust.py > +++ b/tests/acceptance/virtio_seg_max_adjust.py > @@ -109,14 +109,15 @@ class VirtioMaxSegSettingsCheck(Test): > return False > > def test_machine_types(self): > -# collect all machine types except 'none', 'isapc', 'microvm' > +EXCLUDED_MACHINES = ['none', 'isapc', 'microvm'] That one seems more flexible as well. > +# collect all machine types except the ones in EXCLUDED_MACHINES > with QEMUMachine(self.qemu_bin) as vm: > vm.launch() > machines = [m['name'] for m in vm.command('query-machines')] > vm.shutdown() > -machines.remove('none') > -machines.remove('isapc') > -machines.remove('microvm') > +for m in EXCLUDED_MACHINES: > +if m in machines: > +machines.remove(m) > > for dev_type in DEV_TYPES: > # create the list of machine types and their parameters. Reviewed-by: Cornelia Huck
[Bug 1661815] Re: Stack address is returned from function translate_one
I've finally posted a patch for this: https://lists.gnu.org/archive/html/qemu-devel/2020-01/msg05204.html -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1661815 Title: Stack address is returned from function translate_one Status in QEMU: New Bug description: The vulnerable version is qemu-2.8.0, and the vulnerable function is in "target-s390x/translate.c". The code snippet is as following. static ExitStatus translate_one(CPUS390XState *env, DisasContext *s) { const DisasInsn *insn; ExitStatus ret = NO_EXIT; DisasFields f; ... s->fields = &f; ... s->pc = s->next_pc; return ret; } A stack address, i.e. the address of local variable "f" is returned from current function through the output parameter "s->fields" as a side effect. This issue is one kind of undefined behaviors, according the C Standard, 6.2.4 [ISO/IEC 9899:2011] (https://www.securecoding.cert.org/confluence/display/c/DCL30-C.+Declare+objects+with+appropriate+storage+durations) This dangerous defect may lead to an exploitable vulnerability. We suggest sanitizing "s->fields" as null before return. Note that this issue is reported by shqking and Zhenwei Zou together. To manage notifications about this bug go to: https://bugs.launchpad.net/qemu/+bug/1661815/+subscriptions
Re: [PATCH 10/26] object: add object_property_set_defaut_{bool, str, int, uint}()
This patch caught my attention because of the typo in the function, but I also noticed that get_default is never set to anything but object_property_get_defval. What do you think about removing the method and just relying on defval? In practice there would be a new patch that squashes 7, 10 and the thing after my signature. Paolo diff --git a/include/qom/object.h b/include/qom/object.h index 1ea5c8c..035e41c 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -367,13 +367,6 @@ typedef void (ObjectPropertyRelease)(Object *obj, */ typedef void (ObjectPropertyInit)(Object *obj, ObjectProperty *prop); -/** - * ObjectPropertyGetDefault: - * - * Get an allocated string representation of the default value. - */ -typedef char *(ObjectPropertyGetDefault)(ObjectProperty *prop); - struct ObjectProperty { gchar *name; @@ -384,7 +377,6 @@ struct ObjectProperty ObjectPropertyResolve *resolve; ObjectPropertyRelease *release; ObjectPropertyInit *init; -ObjectPropertyGetDefault *get_default; void *opaque; QObject *defval; }; diff --git a/qom/object.c b/qom/object.c index 2464a9f..aa6cf19 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1444,15 +1444,6 @@ int64_t object_property_get_int(Object *obj, const char *name, return retval; } -char *object_property_get_default(ObjectProperty *prop) -{ -if (!prop->get_default) { -return NULL; -} - -return prop->get_default(prop); -} - static void object_property_init_defval(Object *obj, ObjectProperty *prop) { Visitor *v = qobject_input_visitor_new(prop->defval); @@ -1463,8 +1454,12 @@ static void object_property_init_defval(Object *obj, ObjectProperty *prop) visit_free(v); } -static char *object_property_get_defval(ObjectProperty *prop) +char *object_property_get_default(ObjectProperty *prop) { +if (!prop->defval) { +return NULL; +} + return qstring_free(qobject_to_json(prop->defval), TRUE); } @@ -1472,11 +1467,9 @@ static void object_property_set_default(ObjectProperty *prop, QObject *defval) { assert(!prop->defval); assert(!prop->init); -assert(!prop->get_default); prop->defval = defval; prop->init = object_property_init_defval; -prop->get_default = object_property_get_defval; } void object_property_set_default_bool(ObjectProperty *prop, bool value) @@ -2610,8 +2603,7 @@ void object_property_add_alias(Object *obj, const char *name, goto out; } op->resolve = property_resolve_alias; -if (target_prop->get_default) { -op->get_default = target_prop->get_default; +if (target_prop->defval) { op->defval = qobject_ref(target_prop->defval); }
Re: [PATCH 0/6] Fix more GCC9 -O3 warnings
Philippe Mathieu-Daudé writes: > On 12/17/19 6:32 PM, Philippe Mathieu-Daudé wrote: >> Fix some trivial warnings when building with -O3. >> Philippe Mathieu-Daudé (6): >>audio/audio: Add missing fall through comment >>hw/display/tcx: Add missing fall through comments >>hw/net/imx_fec: Rewrite fall through comments >>hw/timer/aspeed_timer: Add a fall through comment >>hw/scsi/megasas: Silent GCC9 duplicated-cond warning >>qemu-io-cmds: Silent GCC9 format-overflow warning > > Sorry, this series failed because I used this tag in the first patch: > > Cc: Kővágó, Zoltán > > Then git-send-email was happy with --dry-run, but then failed: > (body) Adding cc: Kővágó, Zoltán from line > 'Cc: Kővágó, Zoltán ' > 5.1.1 : Recipient address rejected: User unknown in local > recipient table > > Note to self, enclose utf-8 names, as: > Cc: "Kővágó, Zoltán" I never have to with my tags: Cc: Alex Bennée Is it possible to be more even utf-8? Sounds like a bug in the git tools to me. -- Alex Bennée
Re: [PATCH 4/6] tests/acceptance/virtio_seg_max_adjust: Only test Xen as superuser
On Wed, 22 Jan 2020 23:32:45 +0100 Philippe Mathieu-Daudé wrote: $SUBJECT: s/Only test Xen as superuser/Test Xen only as superuser/ ? > When running the test unprivileged, we get: > > $ avocado --show=app,machine run tests/acceptance/virtio_seg_max_adjust.py > JOB ID : b631d5d692e49b791b211d33b80730315d561d45 > JOB LOG: job-results/job-2020-01-22T17.56-b631d5d/job.log >(1/1) > tests/acceptance/virtio_seg_max_adjust.py:VirtioMaxSegSettingsCheck.test_machine_types: > machine: {'name': 'pc-i440fx-2.12', 'seg_max_adjust': 'false', 'device': > 'virtio-scsi-pci'} > machine: {'name': 'pc-i440fx-2.0', 'seg_max_adjust': 'false', 'device': > 'virtio-scsi-pci'} > machine: {'name': 'xenpv', 'seg_max_adjust': 'false', 'device': > 'virtio-scsi-pci'} > FAIL: machine type xenpv: (0.40 s) > > Looking at the job.log file we find: > > xencall: error: Could not obtain handle on privileged command interface: No > such file or directory > xen be core: xen be core: can't open xen interface > > Do not run this test on Xen machines if not superuser. > > Signed-off-by: Philippe Mathieu-Daudé > --- > tests/acceptance/virtio_seg_max_adjust.py | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tests/acceptance/virtio_seg_max_adjust.py > b/tests/acceptance/virtio_seg_max_adjust.py > index f679b0eec7..ad736bcda3 100755 > --- a/tests/acceptance/virtio_seg_max_adjust.py > +++ b/tests/acceptance/virtio_seg_max_adjust.py > @@ -118,6 +118,8 @@ class VirtioMaxSegSettingsCheck(Test): > > def test_machine_types(self): > EXCLUDED_MACHINES = ['none', 'isapc', 'microvm'] > +if os.geteuid() != 0: > +EXCLUDED_MACHINES += ['xenfv', 'xenpv'] > # collect all machine types except the ones in EXCLUDED_MACHINES > with QEMUMachine(self.qemu_bin) as vm: > vm.launch() Acked-by: Cornelia Huck
Re: [PATCH] qemu_set_log_filename: filename argument may be NULL
On Wed, Jan 22, 2020 at 10:08:12PM +0100, salva...@qindel.com wrote: Existing callers like vl.c:main() do: if (log_file) { qemu_set_log_filename(log_file, &error_fatal); } Please fix up existing callers. They won't need to check for NULL anymore before calling qemu_set_log_filename(). > +/* else, let logfilename be NULL indicating we want to use stderr */ Please update the doc comment instead. That way callers know that passing NULL is allowed without reading the implementation. signature.asc Description: PGP signature
Re: [PATCH v4 10/11] 9pfs: T_readdir latency optimization
On Tue, 21 Jan 2020 01:30:10 +0100 Christian Schoenebeck wrote: > Make top half really top half and bottom half really bottom half: > > Each T_readdir request handling is hopping between threads (main > I/O thread and background I/O driver threads) several times for > every individual directory entry, which sums up to huge latencies > for handling just a single T_readdir request. > > Instead of doing that, collect now all required directory entries > (including all potentially required stat buffers for each entry) in > one rush on a background I/O thread from fs driver, then assemble > the entire resulting network response message for the readdir > request on main I/O thread. The fs driver is still aborting the > directory entry retrieval loop (on the background I/O thread) as > soon as it would exceed the client's requested maximum R_readdir > response size. So we should not have any performance penalty by > doing this. > > Signed-off-by: Christian Schoenebeck > --- Ok so this is it. Not reviewed this huge patch yet but I could at least give a try. The gain is impressive indeed: [greg@bahia qemu-9p]$ (cd .mbuild-$(stg branch)/obj ; export QTEST_QEMU_BINARY='x86_64-softmmu/qemu-system-x86_64'; make all tests/qtest/qos-test && for i in {1..100}; do tests/qtest/qos-test -p $(tests/qtest/qos-test -l | grep readdir/basic); done) |& awk '/IMPORTANT/ { print $10 }' | sed -e 's/s//' -e 's/^/n+=1;x+=/;$ascale=6;x/n' | bc .009806 instead of .055654, i.e. nearly 6 times faster ! This sounds promising :) Now I need to find time to do a decent review... :-\ > hw/9pfs/9p.c| 124 +++- > hw/9pfs/9p.h| 23 ++ > hw/9pfs/codir.c | 183 +--- > hw/9pfs/coth.h | 3 + > 4 files changed, 254 insertions(+), 79 deletions(-) > > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c > index 18370183c4..e0ca45d46b 100644 > --- a/hw/9pfs/9p.c > +++ b/hw/9pfs/9p.c > @@ -971,30 +971,6 @@ static int coroutine_fn fid_to_qid(V9fsPDU *pdu, > V9fsFidState *fidp, > return 0; > } > > -static int coroutine_fn dirent_to_qid(V9fsPDU *pdu, V9fsFidState *fidp, > - struct dirent *dent, V9fsQID *qidp) > -{ > -struct stat stbuf; > -V9fsPath path; > -int err; > - > -v9fs_path_init(&path); > - > -err = v9fs_co_name_to_path(pdu, &fidp->path, dent->d_name, &path); > -if (err < 0) { > -goto out; > -} > -err = v9fs_co_lstat(pdu, &path, &stbuf); > -if (err < 0) { > -goto out; > -} > -err = stat_to_qid(pdu, &stbuf, qidp); > - > -out: > -v9fs_path_free(&path); > -return err; > -} > - > V9fsPDU *pdu_alloc(V9fsState *s) > { > V9fsPDU *pdu = NULL; > @@ -2314,7 +2290,7 @@ out_nofid: > pdu_complete(pdu, err); > } > > -static size_t v9fs_readdir_data_size(V9fsString *name) > +size_t v9fs_readdir_response_size(V9fsString *name) > { > /* > * Size of each dirent on the wire: size of qid (13) + size of offset (8) > @@ -2323,6 +2299,18 @@ static size_t v9fs_readdir_data_size(V9fsString *name) > return 24 + v9fs_string_size(name); > } > > +static void v9fs_free_dirents(struct V9fsDirEnt *e) > +{ > +struct V9fsDirEnt *next = NULL; > + > +for (; e; e = next) { > +next = e->next; > +g_free(e->dent); > +g_free(e->st); > +g_free(e); > +} > +} > + > static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, V9fsFidState *fidp, > int32_t max_count) > { > @@ -2331,54 +2319,53 @@ static int coroutine_fn v9fs_do_readdir(V9fsPDU *pdu, > V9fsFidState *fidp, > V9fsString name; > int len, err = 0; > int32_t count = 0; > -off_t saved_dir_pos; > struct dirent *dent; > +struct stat *st; > +struct V9fsDirEnt *entries = NULL; > > -/* save the directory position */ > -saved_dir_pos = v9fs_co_telldir(pdu, fidp); > -if (saved_dir_pos < 0) { > -return saved_dir_pos; > -} > - > -while (1) { > -v9fs_readdir_lock(&fidp->fs.dir); > +/* > + * inode remapping requires the device id, which in turn might be > + * different for different directory entries, so if inode remapping is > + * enabled we have to make a full stat for each directory entry > + */ > +const bool dostat = pdu->s->ctx.export_flags & V9FS_REMAP_INODES; > > -err = v9fs_co_readdir(pdu, fidp, &dent); > -if (err || !dent) { > -break; > -} > -v9fs_string_init(&name); > -v9fs_string_sprintf(&name, "%s", dent->d_name); > -if ((count + v9fs_readdir_data_size(&name)) > max_count) { > -v9fs_readdir_unlock(&fidp->fs.dir); > +/* > + * Fetch all required directory entries altogether on a background IO > + * thread from fs driver. We don't want to do that for each entry > + * individually, because hopping between threads (this main IO thread > +
Re: [PATCH v4 07/11] tests/virtio-9p: failing splitted readdir test
On Mittwoch, 22. Januar 2020 23:59:54 CET Greg Kurz wrote: > On Tue, 21 Jan 2020 01:17:35 +0100 > > Christian Schoenebeck wrote: > > This patch is not intended to be merged. It resembles > > an issue (with debug messages) where the splitted > > readdir test fails because server is interrupted with > > transport error "Failed to decode VirtFS request type 40", > > Ok. When we send a new request, we call: > > uint32_t qvirtqueue_add(QTestState *qts, QVirtQueue *vq, uint64_t data, > uint32_t len, bool write, bool next) > { > uint16_t flags = 0; > vq->num_free--; > > [...] > > return vq->free_head++; /* Return and increase, in this order */ > } Ah, I see! > where vq->num_free is the number of available buffers (aka. requests) in > the vq and vq->free_head the index of the next available buffer. The size > of the vq of the virtio-9p device is MAX_REQ (128) buffers. The driver > is very simple and doesn't care to handle the scenario of a full vq, > ie, num_free == 0 and free_head is past the vq->desc[] array. It seems > that count=128 generates enough extra requests to reach the end of the > vq. Hence the "decode" error you get. Maybe an assert(vq->num_free) in > qvirtqueue_add() would make that more clear ? So just that I get it right; currently the 9pfs test suite writes to a ringbuffer with every request (decreasing the free space in the ringbuffer), but it never frees up that space in the ringbuffer? > Not sure it is worth to address this limitation though. Especially since > count=128 isn't really a recommended choice in the first place. Well, if that's what happens with the ringbuffer, it would need to be addressed somehow anyway, otherwise it would be impossible to add more 9pfs tests, since they would hit the ringbuffer limit as well at a certain point, no matter how simple the requests are. Wouldn't it make sense to reset the ringbuffer after every succesful, individual 9pfs test? > It has > more chances to cause a disconnect if the server needs to return a longer > file name (which is expected since most fs have 255 character long file > names). Well, this test is dependent on what's provided exactly by the synth driver anyway. So I don't see the value 128 as a problem here. The readdir/split test could even determine the max. length of a file provided by synth driver if you are concerned about that, because the file name template macro QTEST_V9FS_SYNTH_READDIR_FILE used by synth driver is public. And BTW it is not really this specific 'count' value (128) that triggers this issue, if you just run the readdir/split test with i.e.: const uint32_t vcount[] = { 128 }; then you won't trigger this test environment issue. Best regards, Christian Schoenebeck
Re: [PATCH 10/26] object: add object_property_set_defaut_{bool, str, int, uint}()
Hi On Thu, Jan 23, 2020 at 3:29 PM Paolo Bonzini wrote: > > This patch caught my attention because of the typo in the function, but Ah! a french "défaut". > I also noticed that get_default is never set to anything but > object_property_get_defval. > > What do you think about removing the method and just relying on defval? > In practice there would be a new patch that squashes 7, 10 and the thing > after my signature. Indeed, we could remove the get_default callback. I can't find the reason I added it now. Are you resending the series then? > > Paolo > > diff --git a/include/qom/object.h b/include/qom/object.h > index 1ea5c8c..035e41c 100644 > --- a/include/qom/object.h > +++ b/include/qom/object.h > @@ -367,13 +367,6 @@ typedef void (ObjectPropertyRelease)(Object *obj, > */ > typedef void (ObjectPropertyInit)(Object *obj, ObjectProperty *prop); > > -/** > - * ObjectPropertyGetDefault: > - * > - * Get an allocated string representation of the default value. > - */ > -typedef char *(ObjectPropertyGetDefault)(ObjectProperty *prop); > - > struct ObjectProperty > { > gchar *name; > @@ -384,7 +377,6 @@ struct ObjectProperty > ObjectPropertyResolve *resolve; > ObjectPropertyRelease *release; > ObjectPropertyInit *init; > -ObjectPropertyGetDefault *get_default; > void *opaque; > QObject *defval; > }; > diff --git a/qom/object.c b/qom/object.c > index 2464a9f..aa6cf19 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -1444,15 +1444,6 @@ int64_t object_property_get_int(Object *obj, const > char *name, > return retval; > } > > -char *object_property_get_default(ObjectProperty *prop) > -{ > -if (!prop->get_default) { > -return NULL; > -} > - > -return prop->get_default(prop); > -} > - > static void object_property_init_defval(Object *obj, ObjectProperty *prop) > { > Visitor *v = qobject_input_visitor_new(prop->defval); > @@ -1463,8 +1454,12 @@ static void object_property_init_defval(Object *obj, > ObjectProperty *prop) > visit_free(v); > } > > -static char *object_property_get_defval(ObjectProperty *prop) > +char *object_property_get_default(ObjectProperty *prop) > { > +if (!prop->defval) { > +return NULL; > +} > + > return qstring_free(qobject_to_json(prop->defval), TRUE); > } > > @@ -1472,11 +1467,9 @@ static void object_property_set_default(ObjectProperty > *prop, QObject *defval) > { > assert(!prop->defval); > assert(!prop->init); > -assert(!prop->get_default); > > prop->defval = defval; > prop->init = object_property_init_defval; > -prop->get_default = object_property_get_defval; > } > > void object_property_set_default_bool(ObjectProperty *prop, bool value) > @@ -2610,8 +2603,7 @@ void object_property_add_alias(Object *obj, const char > *name, > goto out; > } > op->resolve = property_resolve_alias; > -if (target_prop->get_default) { > -op->get_default = target_prop->get_default; > +if (target_prop->defval) { > op->defval = qobject_ref(target_prop->defval); > } > > > -- Marc-André Lureau
[Bug 1859656] Re: [2.6] Unable to reboot s390x KVM machine after initial deploy
I took the time and recreated a MAAS setup (latest stable 2.2) on s390x and it looks like this: - I could start a deployment and ran through the states: - Power On, Commissioning (Performing PXE boot) - Power On, Commissioning (Gathering Information) - Power On, Ready - Power Off, Ready (I may have have missed some states in between.) - Power Off, Ready is the final state at that point and on the console it's: $ virsh list --all IdName State - vm1shut off - xml VM definition is: $ virsh dumpxml vm1 vm1 0f7d1d61-9368-4bfe-8c65-c709e90e8780 1048576 1048576 1 hvm destroy restart destroy /usr/bin/kvm 6addbfeb-ff2c-4350-b34d-11a56ea34f1d So it largely looks like assumed (after initially reading the bug), PXE itself seems to work, but the boot issue it due to: That confirms the situation (on s390x and MAAS 2.6.2)m but it still raises the question why it seem to have worked with 2.6.0? -- You received this bug notification because you are a member of qemu- devel-ml, which is subscribed to QEMU. https://bugs.launchpad.net/bugs/1859656 Title: [2.6] Unable to reboot s390x KVM machine after initial deploy Status in MAAS: New Status in QEMU: Incomplete Status in Ubuntu on IBM z Systems: Triaged Bug description: MAAS version: 2.6.1 (7832-g17912cdc9-0ubuntu1~18.04.1) Arch: S390x Appears that MAAS can not find the s390x bootloader to boot from the disk, not sure how maas determines this. However this was working in the past. I had originally thought that if the maas machine was deployed then it defaulted to boot from disk. If I force the VM to book from disk, the VM starts up as expected. Reproduce: - Deploy Disco on S390x KVM instance - Reboot it on the KVM console... Connected to domain s2lp6g001 Escape character is ^] done Using IPv4 address: 10.246.75.160 Using TFTP server: 10.246.72.3 Bootfile name: 'boots390x.bin' Receiving data: 0 KBytes TFTP error: file not found: boots390x.bin Trying pxelinux.cfg files... Receiving data: 0 KBytes Receiving data: 0 KBytes Failed to load OS from network ==> /var/log/maas/rackd.log <== 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] boots390x.bin requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/65a9ca43-9541-49be-b315-e2ca85936ea2 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/01-52-54-00-e5-d7-bb requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF64BA0 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF64BA requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF64B requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF64 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF6 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0AF requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0A requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/0 requested by 10.246.75.160 2020-01-14 18:21:24 provisioningserver.rackdservices.tftp: [info] s390x/default requested by 10.246.75.160 To manage notifications about this bug go to: https://bugs.launchpad.net/maas/+bug/1859656/+subscriptions
[PATCH REPOST v3 02/80] machine: introduce memory-backend property
Property will contain link to memory backend that will be used for backing initial RAM. Follow up commit will alias -mem-path and -mem-prealloc CLI options into memory backend options to make memory handling consistent (using only hostmem backend family for guest RAM allocation). Signed-off-by: Igor Mammedov --- v3: * rename property name from ram-memdev to memory-backend (Paolo Bonzini ) CC: ehabk...@redhat.com CC: pbonz...@redhat.com --- include/hw/boards.h | 2 ++ hw/core/machine.c | 9 + 2 files changed, 11 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index fb1b43d..6aa01b8 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -4,6 +4,7 @@ #define HW_BOARDS_H #include "exec/memory.h" +#include "sysemu/hostmem.h" #include "sysemu/blockdev.h" #include "sysemu/accel.h" #include "qapi/qapi-types-machine.h" @@ -285,6 +286,7 @@ struct MachineState { bool enforce_config_section; bool enable_graphics; char *memory_encryption; +HostMemoryBackend *ram_memdev; DeviceMemoryState *device_memory; ram_addr_t ram_size; diff --git a/hw/core/machine.c b/hw/core/machine.c index 3e288bf..bf30183 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -886,6 +886,15 @@ static void machine_initfn(Object *obj) "Table (HMAT)", NULL); } +object_property_add_link(obj, "memory-backend", TYPE_MEMORY_BACKEND, + (Object **)&ms->ram_memdev, + object_property_allow_set_link, + OBJ_PROP_LINK_STRONG, &error_abort); +object_property_set_description(obj, "memory-backend", +"Set RAM backend" +"Valid value is ID of hostmem based backend", + &error_abort); + /* Register notifier when init is done for sysbus sanity checks */ ms->sysbus_notifier.notify = machine_init_notify; qemu_add_machine_init_done_notifier(&ms->sysbus_notifier); -- 2.7.4
[PATCH REPOST v3 00/80] refactor main RAM allocation to use hostmem backend
v3: - due to libvirt not being ready, postpone till 5.1 * [PATCH v2 82/86] numa: forbid '-numa node, mem' for 5.0 and newer machine types and depended [PATCH v2 86/86] numa: remove deprecated implicit RAM distribution between nodes - drop as not related "[PATCH v2 85/86] numa: make exit() usage consistent" - drop "[PATCH v2 76/86] post conversion default_ram_id cleanup" so that default memory-backedend won't be created for boards that do not care about -m. Which makes -m optin feature. We should decide what do in case board doesn't use -m (but that's out of scope of this series) - use object_register_sugar_prop() instead of hacking compat props directly - simplified/reworked aspeed patches - s/RAM_ADDR_FMT/size_to_str()/ - rename 'ram-memdev' property to 'memory-backend' - minor fixes to numa-test - fixes for issues noticed during review of [PATCH v2 66/86] ppc/{ppc440_bamboo,sam460x}: drop RAM size fixup v2: - fix compile errors on mingw32 host by introducing RAM_ADDR_UFMT [11/86] - replace "[PATCH 43/86] hppa: drop RAM size fixup" with alternative patches made by Philippe (which effectively do the same thing but other way around) - ppc440: fix crash and add suggested valid RAM size in error output. s/ppc4xx_sdram_adjust/ppc4xx_sdram_prep/ and simplify it by removing not necessary nested loop - rebase on current master due to new conflicts Series removes ad hoc RAM allocation API (memory_region_allocate_system_memory) and consolidates it around hostmem backend. It allows to * resolve conflicts between global -mem-prealloc and hostmem's "policy" option fixing premature allocation before binding policy is applied * simplify complicated memory allocation routines which had to deal with 2 ways to allocate RAM. * it allows to reuse hostmem backends of a choice for main RAM without adding extra CLI options to duplicate hostmem features. Recent case was -mem-shared, to enable vhost-user on targets that don't support hostmem backends [1] (ex: s390) * move RAM allocation from individual boards into generic machine code and provide them with prepared MemoryRegion. * clean up deprecated NUMA features which were tied to the old API (see patches) - "numa: remove deprecated -mem-path fallback to anonymous RAM" - (POSTPONED, waiting on libvirt side) "forbid '-numa node,mem' for 5.0 and newer machine types" - (POSTPONED) "numa: remove deprecated implicit RAM distribution between nodes" Conversion introduces a new machine.memory-backend property and wrapper code that aliases global -mem-path and -mem-alloc into automatically created hostmem backend properties (provided memory-backend was not set explicitly given by user). And then follows bulk of trivial patches that incrementally convert individual boards to using machine.memory-backend provided MemoryRegion. Board conversion typically involves: * providing MachineClass::default_ram_size and MachineClass::default_ram_id so generic code could create default backend if user didn't explicitly provide memory-backend or -m options * dropping memory_region_allocate_system_memory() call * using convenience MachineState::ram MemoryRegion, which points to MemoryRegion allocated by ram-memdev On top of that for some boards: * added missing ram_size checks (typically it were boards with fixed ram size) * ram_size fixups were replaced by checks and hard errors, forcing user to provide correct "-m" values instead of ignoring it and continuing running. After all boards are converted the old API is removed and memory allocation routines are cleaned up. git tree for testing: https://github.com/imammedo/qemu convert_main_ram_to_memdev_v3 previous rev: https://github.com/imammedo/qemu convert_main_ram_to_memdev_v2 https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg02960.html Igor Mammedov (77): numa: remove deprecated -mem-path fallback to anonymous RAM machine: introduce memory-backend property machine: alias -mem-path and -mem-prealloc into memory-foo backend machine: introduce convenience MachineState::ram initialize MachineState::ram in NUMA case alpha:dp264: use memdev for RAM arm/aspeed: actually check RAM size arm/aspeed: use memdev for RAM arm/collie: use memdev for RAM arm/cubieboard: use memdev for RAM arm/digic_boards: use memdev for RAM arm/highbank: use memdev for RAM arm/imx25_pdk: drop RAM size fixup arm/imx25_pdk: use memdev for RAM arm/integratorcp: use memdev for RAM arm/kzm: drop RAM size fixup arm/kzm: use memdev for RAM arm/mcimx6ul-evk: use memdev for RAM arm/mcimx7d-sabre: use memdev for RAM arm/mps2-tz: use memdev for RAM arm/mps2: use memdev for RAM arm/musicpal: use memdev for RAM arm/nseries: use memdev for RAM arm/omap_sx1: use memdev for RAM arm/palm: use memdev for RAM arm/raspi: use memdev for RAM arm/sabrelite: use memdev for RAM arm/
[PATCH REPOST v3 10/80] arm/cubieboard: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: While at it, get rid of no longer needed CubieBoardState wrapper. Signed-off-by: Igor Mammedov --- CC: drjo...@redhat.com CC: b.galv...@gmail.com CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/cubieboard.c | 25 - 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c index 6dc2f1d..089f9a3 100644 --- a/hw/arm/cubieboard.c +++ b/hw/arm/cubieboard.c @@ -28,52 +28,42 @@ static struct arm_boot_info cubieboard_binfo = { .board_id = 0x1008, }; -typedef struct CubieBoardState { -AwA10State *a10; -MemoryRegion sdram; -} CubieBoardState; - static void cubieboard_init(MachineState *machine) { -CubieBoardState *s = g_new(CubieBoardState, 1); +AwA10State *a10 = AW_A10(object_new(TYPE_AW_A10)); Error *err = NULL; -s->a10 = AW_A10(object_new(TYPE_AW_A10)); - -object_property_set_int(OBJECT(&s->a10->emac), 1, "phy-addr", &err); +object_property_set_int(OBJECT(&a10->emac), 1, "phy-addr", &err); if (err != NULL) { error_reportf_err(err, "Couldn't set phy address: "); exit(1); } -object_property_set_int(OBJECT(&s->a10->timer), 32768, "clk0-freq", &err); +object_property_set_int(OBJECT(&a10->timer), 32768, "clk0-freq", &err); if (err != NULL) { error_reportf_err(err, "Couldn't set clk0 frequency: "); exit(1); } -object_property_set_int(OBJECT(&s->a10->timer), 2400, "clk1-freq", -&err); +object_property_set_int(OBJECT(&a10->timer), 2400, "clk1-freq", &err); if (err != NULL) { error_reportf_err(err, "Couldn't set clk1 frequency: "); exit(1); } -object_property_set_bool(OBJECT(s->a10), true, "realized", &err); +object_property_set_bool(OBJECT(a10), true, "realized", &err); if (err != NULL) { error_reportf_err(err, "Couldn't realize Allwinner A10: "); exit(1); } -memory_region_allocate_system_memory(&s->sdram, NULL, "cubieboard.ram", - machine->ram_size); memory_region_add_subregion(get_system_memory(), AW_A10_SDRAM_BASE, -&s->sdram); +machine->ram); /* TODO create and connect IDE devices for ide_drive_get() */ cubieboard_binfo.ram_size = machine->ram_size; -arm_load_kernel(&s->a10->cpu, machine, &cubieboard_binfo); +arm_load_kernel(&a10->cpu, machine, &cubieboard_binfo); } static void cubieboard_machine_init(MachineClass *mc) @@ -84,6 +74,7 @@ static void cubieboard_machine_init(MachineClass *mc) mc->block_default_type = IF_IDE; mc->units_per_default_bus = 1; mc->ignore_memory_transaction_failures = true; +mc->default_ram_id = "cubieboard.ram"; } DEFINE_MACHINE("cubieboard", cubieboard_machine_init) -- 2.7.4
[PATCH REPOST v3 01/80] numa: remove deprecated -mem-path fallback to anonymous RAM
it has been deprecated since 4.0 by commit cb79224b7 (deprecate -mem-path fallback to anonymous RAM) Deprecation period ran out and it's time to remove it so it won't get in a way of switching to using hostmem backend for RAM. Signed-off-by: Igor Mammedov --- CC:libvir-l...@redhat.com CC: ehabk...@redhat.com --- hw/core/numa.c | 18 +- qemu-deprecated.texi | 9 - 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/hw/core/numa.c b/hw/core/numa.c index 0d1b4be..840e685 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -784,24 +784,8 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner, { if (mem_path) { #ifdef __linux__ -Error *err = NULL; memory_region_init_ram_from_file(mr, owner, name, ram_size, 0, 0, - mem_path, &err); -if (err) { -error_report_err(err); -if (mem_prealloc) { -exit(1); -} -warn_report("falling back to regular RAM allocation"); -error_printf("This is deprecated. Make sure that -mem-path " - " specified path has sufficient resources to allocate" - " -m specified RAM amount\n"); -/* Legacy behavior: if allocation failed, fall back to - * regular RAM allocation. - */ -mem_path = NULL; -memory_region_init_ram_nomigrate(mr, owner, name, ram_size, &error_fatal); -} + mem_path, &error_fatal); #else fprintf(stderr, "-mem-path not supported on this host\n"); exit(1); diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index 0968d37..982af95 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -113,15 +113,6 @@ QEMU using implicit generic or board specific splitting rule. Use @option{memdev} with @var{memory-backend-ram} backend or @option{mem} (if it's supported by used machine type) to define mapping explictly instead. -@subsection -mem-path fallback to RAM (since 4.1) -Currently if guest RAM allocation from file pointed by @option{mem-path} -fails, QEMU falls back to allocating from RAM, which might result -in unpredictable behavior since the backing file specified by the user -is ignored. In the future, users will be responsible for making sure -the backing storage specified with @option{-mem-path} can actually provide -the guest RAM configured with @option{-m} and QEMU will fail to start up if -RAM allocation is unsuccessful. - @subsection RISC-V -bios (since 4.1) QEMU 4.1 introduced support for the -bios option in QEMU for RISC-V for the -- 2.7.4
[PATCH REPOST v3 05/80] initialize MachineState::ram in NUMA case
In case of NUMA there are 2 cases to consider: 1. '-numa node,memdev', the only one that will be available for 5.0 and newer machine types. In this case reuse current behavior, with only difference memdevs are put into MachineState::ram container + a temporary glue to keep memory_region_allocate_system_memory() working until all boards converted. 2. fake NUMA ("-numa node mem" and default RAM splitting) the later has been deprecated and will be removed but the former is going to stay available for compat reasons for 5.0 and older machine types it takes allocate_system_memory_nonnuma() path, like non-NUMA case and falls under conversion to memdev. So extend non-NUMA MachineState::ram initialization introduced in previous patch to take care of fake NUMA case. Signed-off-by: Igor Mammedov --- CC: ehabk...@redhat.com CC: pbonz...@redhat.com --- include/sysemu/numa.h | 1 + hw/core/numa.c| 43 ++- vl.c | 7 --- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/include/sysemu/numa.h b/include/sysemu/numa.h index ba693cc..ad58ee8 100644 --- a/include/sysemu/numa.h +++ b/include/sysemu/numa.h @@ -112,5 +112,6 @@ void numa_default_auto_assign_ram(MachineClass *mc, NodeInfo *nodes, int nb_nodes, ram_addr_t size); void numa_cpu_pre_plug(const struct CPUArchId *slot, DeviceState *dev, Error **errp); +bool numa_uses_legacy_mem(void); #endif diff --git a/hw/core/numa.c b/hw/core/numa.c index 8264336..e6baf2c 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -52,6 +52,11 @@ QemuOptsList qemu_numa_opts = { }; static int have_memdevs; +bool numa_uses_legacy_mem(void) +{ +return !have_memdevs; +} + static int have_mem; static int max_numa_nodeid; /* Highest specified NUMA node ID, plus one. * For all nodes, nodeid < max_numa_nodeid @@ -652,6 +657,23 @@ void numa_default_auto_assign_ram(MachineClass *mc, NodeInfo *nodes, nodes[i].node_mem = size - usedmem; } +static void numa_init_memdev_container(MachineState *ms, MemoryRegion *ram) +{ +int i; +uint64_t addr = 0; + +for (i = 0; i < ms->numa_state->num_nodes; i++) { +uint64_t size = ms->numa_state->nodes[i].node_mem; +HostMemoryBackend *backend = ms->numa_state->nodes[i].node_memdev; +if (!backend) { +continue; +} +MemoryRegion *seg = machine_consume_memdev(ms, backend); +memory_region_add_subregion(ram, addr, seg); +addr += size; +} +} + void numa_complete_configuration(MachineState *ms) { int i; @@ -734,6 +756,12 @@ void numa_complete_configuration(MachineState *ms) exit(1); } +if (!numa_uses_legacy_mem() && mc->default_ram_id) { +ms->ram = g_new(MemoryRegion, 1); +memory_region_init(ms->ram, OBJECT(ms), mc->default_ram_id, + ram_size); +numa_init_memdev_container(ms, ms->ram); +} /* QEMU needs at least all unique node pair distances to build * the whole NUMA distance table. QEMU treats the distance table * as symmetric by default, i.e. distance A->B == distance B->A. @@ -800,27 +828,16 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, const char *name, uint64_t ram_size) { -uint64_t addr = 0; -int i; MachineState *ms = MACHINE(qdev_get_machine()); if (ms->numa_state == NULL || -ms->numa_state->num_nodes == 0 || !have_memdevs) { +ms->numa_state->num_nodes == 0 || numa_uses_legacy_mem()) { allocate_system_memory_nonnuma(mr, owner, name, ram_size); return; } memory_region_init(mr, owner, name, ram_size); -for (i = 0; i < ms->numa_state->num_nodes; i++) { -uint64_t size = ms->numa_state->nodes[i].node_mem; -HostMemoryBackend *backend = ms->numa_state->nodes[i].node_memdev; -if (!backend) { -continue; -} -MemoryRegion *seg = machine_consume_memdev(ms, backend); -memory_region_add_subregion(mr, addr, seg); -addr += size; -} +numa_init_memdev_container(ms, mr); } static void numa_stat_memory_devices(NumaNodeMem node_mem[]) diff --git a/vl.c b/vl.c index 9f97cb6..3536451 100644 --- a/vl.c +++ b/vl.c @@ -4305,9 +4305,10 @@ int main(int argc, char **argv, char **envp) } parse_numa_opts(current_machine); -if (!current_machine->ram_memdev && - machine_class->default_ram_size && - machine_class->default_ram_id) { +if (numa_uses_legacy_mem() && +machine_class->default_ram_size && +machine_class->default_ram_id && +!current_machine->ram_memdev) { create_default_memdev(current_machine
[PATCH REPOST v3 07/80] arm/aspeed: actually check RAM size
It's supposed that SOC will check if "-m" provided RAM size is valid by setting "ram-size" property and then board would read back valid (possibly corrected value) to map RAM MemoryReging with valid size. It isn't doing so, since check is called only indirectly from aspeed_sdmc_reset()->asc->compute_conf() or much later when guest writes to configuration register. So depending on "-m" value QEMU end-ups with a warning and an invalid MemoryRegion size allocated and mapped. (examples: -M ast2500-evb -m 1M 8000-00017ffe (prio 0, i/o): aspeed-ram-container 8000-800f (prio 0, ram): ram 8010-bfff (prio 0, i/o): max_ram -M ast2500-evb -m 3G 8000-00017ffe (prio 0, i/o): aspeed-ram-container 8000-00013fff (prio 0, ram): ram [DETECTED OVERFLOW!] 00014000-bfff (prio 0, i/o): max_ram ) On top of that sdmc falls back and reports to guest "default" size, it thinks machine should have. This patch makes ram-size check actually work and changes behavior from a warning later on during machine reset to error_fatal at the moment SOC.ram-size is set so user will have to fix RAM size on CLI to start machine. It also gets out of the way mutable ram-size logic, so we could consolidate RAM allocation logic around pre-allocated hostmem backend (supplied by user or auto created by generic machine code depending on supplied -m/mem-path/mem-prealloc options. Signed-off-by: Igor Mammedov Reviewed-by: Cédric Le Goater --- v3: * replace [PATCH v2 07/86] arm:aspeed: convert valid RAM sizes to data [PATCH v2 08/86] arm:aspeed: actually check RAM size with a simplified variant that adds ram_size check to sdmc.ram-size property * use g_assert_not_reached() in default branch (Cédric Le Goater ) CC: c...@kaod.org CC: peter.mayd...@linaro.org CC: and...@aj.id.au CC: j...@jms.id.au CC: qemu-...@nongnu.org Signed-off-by: Igor Mammedov --- include/hw/misc/aspeed_sdmc.h | 1 + hw/arm/aspeed.c | 13 +++ hw/misc/aspeed_sdmc.c | 83 +-- 3 files changed, 70 insertions(+), 27 deletions(-) diff --git a/include/hw/misc/aspeed_sdmc.h b/include/hw/misc/aspeed_sdmc.h index 5dbde59..cea1e67 100644 --- a/include/hw/misc/aspeed_sdmc.h +++ b/include/hw/misc/aspeed_sdmc.h @@ -40,6 +40,7 @@ typedef struct AspeedSDMCClass { SysBusDeviceClass parent_class; uint64_t max_ram_size; +const uint64_t *valid_ram_sizes; uint32_t (*compute_conf)(AspeedSDMCState *s, uint32_t data); void (*write)(AspeedSDMCState *s, uint32_t reg, uint32_t data); } AspeedSDMCClass; diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index cc06af4..c8573e5 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -191,8 +191,12 @@ static void aspeed_machine_init(MachineState *machine) sc = ASPEED_SOC_GET_CLASS(&bmc->soc); +/* + * This will error out if isize is not supported by memory controller. + */ object_property_set_uint(OBJECT(&bmc->soc), ram_size, "ram-size", - &error_abort); + &error_fatal); + object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap1, "hw-strap1", &error_abort); object_property_set_int(OBJECT(&bmc->soc), amc->hw_strap2, "hw-strap2", @@ -215,13 +219,6 @@ static void aspeed_machine_init(MachineState *machine) object_property_set_bool(OBJECT(&bmc->soc), true, "realized", &error_abort); -/* - * Allocate RAM after the memory controller has checked the size - * was valid. If not, a default value is used. - */ -ram_size = object_property_get_uint(OBJECT(&bmc->soc), "ram-size", -&error_abort); - memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); memory_region_add_subregion(&bmc->ram_container, 0, &bmc->ram); memory_region_add_subregion(get_system_memory(), diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c index 2df3244..fc289a3 100644 --- a/hw/misc/aspeed_sdmc.c +++ b/hw/misc/aspeed_sdmc.c @@ -17,6 +17,9 @@ #include "migration/vmstate.h" #include "qapi/error.h" #include "trace.h" +#include "qemu/units.h" +#include "qemu/cutils.h" +#include "qapi/visitor.h" /* Protection Key Register */ #define R_PROT(0x00 / 4) @@ -160,14 +163,9 @@ static int ast2400_rambits(AspeedSDMCState *s) case 512: return ASPEED_SDMC_DRAM_512MB; default: +g_assert_not_reached(); break; } - -/* use a common default */ -warn_report("Invalid RAM size 0x%" PRIx64 ". Using default 256M", -s->ram_size); -s->ram_size = 256 << 20; -return ASPEED_SDMC_DRAM_256MB; } static int ast2500_rambits(AspeedSDMCState *s) @@ -182,14 +180,9 @@ static int ast2500_rambits(AspeedSDMCState *s)
[PATCH REPOST v3 04/80] machine: introduce convenience MachineState::ram
the new field will be used by boards to get access to main RAM memory region and will help to save boiler plate in boards which often introduce a field or variable just for this purpose. Memory region will be equivalent to what currently used memory_region_allocate_system_memory() is returning apart from that it will come from hostmem backend. Followup patches will incrementally switch boards to using RAM from MachineState::ram. Patch takes care of non-NUMA case and follow up patch will initialize MachineState::ram for NUMA case. Signed-off-by: Igor Mammedov --- CC: ehabk...@redhat.com CC: pbonz...@redhat.com --- include/hw/boards.h | 9 - hw/core/machine.c | 21 + hw/core/numa.c | 14 +- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 2a4e804..351479d 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -73,7 +73,12 @@ void machine_set_cpu_numa_node(MachineState *machine, Error **errp); void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type); - +/* + * Checks that backend isn't used, preps it for exclusive usage and + * returns migratable MemoryRegion provided by backend. + */ +MemoryRegion *machine_consume_memdev(MachineState *machine, + HostMemoryBackend *backend); /** * CPUArchId: @@ -292,6 +297,8 @@ struct MachineState { bool enable_graphics; char *memory_encryption; HostMemoryBackend *ram_memdev; +/* convenience alias to ram_memdev memory region or numa container */ +MemoryRegion *ram; DeviceMemoryState *device_memory; ram_addr_t ram_size; diff --git a/hw/core/machine.c b/hw/core/machine.c index bf30183..81791a0 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -26,6 +26,7 @@ #include "sysemu/qtest.h" #include "hw/pci/pci.h" #include "hw/mem/nvdimm.h" +#include "migration/vmstate.h" GlobalProperty hw_compat_4_2[] = { { "virtio-blk-device", "x-enable-wce-if-config-wce", "off" }, @@ -1041,10 +1042,30 @@ static void machine_numa_finish_cpu_init(MachineState *machine) g_string_free(s, true); } +MemoryRegion *machine_consume_memdev(MachineState *machine, + HostMemoryBackend *backend) +{ +MemoryRegion *ret = host_memory_backend_get_memory(backend); + +if (memory_region_is_mapped(ret)) { +char *path = object_get_canonical_path_component(OBJECT(backend)); +error_report("memory backend %s can't be used multiple times.", path); +g_free(path); +exit(EXIT_FAILURE); +} +host_memory_backend_set_mapped(backend, true); +vmstate_register_ram_global(ret); +return ret; +} + void machine_run_board_init(MachineState *machine) { MachineClass *machine_class = MACHINE_GET_CLASS(machine); +if (machine->ram_memdev) { +machine->ram = machine_consume_memdev(machine, machine->ram_memdev); +} + if (machine->numa_state) { numa_complete_configuration(machine); if (machine->numa_state->num_nodes) { diff --git a/hw/core/numa.c b/hw/core/numa.c index 840e685..8264336 100644 --- a/hw/core/numa.c +++ b/hw/core/numa.c @@ -817,20 +817,8 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner, if (!backend) { continue; } -MemoryRegion *seg = host_memory_backend_get_memory(backend); - -if (memory_region_is_mapped(seg)) { -char *path = object_get_canonical_path_component(OBJECT(backend)); -error_report("memory backend %s is used multiple times. Each " - "-numa option must use a different memdev value.", - path); -g_free(path); -exit(1); -} - -host_memory_backend_set_mapped(backend, true); +MemoryRegion *seg = machine_consume_memdev(ms, backend); memory_region_add_subregion(mr, addr, seg); -vmstate_register_ram_global(seg); addr += size; } } -- 2.7.4
[PATCH REPOST v3 03/80] machine: alias -mem-path and -mem-prealloc into memory-foo backend
Allow machine to opt in for hostmem backend based initial RAM even if user uses old -mem-path/prealloc options by providing MachineClass::default_ram_id Follow up patches will incrementally convert machines to new API, by dropping memory_region_allocate_system_memory() and setting default_ram_id that board used to use before conversion to keep migration stream the same. Signed-off-by: Igor Mammedov --- v3: * rename "ram-memdev" property to "memory-backend" (Paolo Bonzini ) CC: ehabk...@redhat.com CC: pbonz...@redhat.com CC: phi...@redhat.com --- include/hw/boards.h | 5 + include/sysemu/hostmem.h | 16 backends/hostmem-file.c | 7 --- backends/hostmem-ram.c | 2 -- vl.c | 25 + 5 files changed, 46 insertions(+), 9 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 6aa01b8..2a4e804 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -170,6 +170,10 @@ typedef struct { *false is returned, an error must be set to show the reason of *the rejection. If the hook is not provided, all hotplug will be *allowed. + * @default_ram_id: + *Specifies inital RAM MemoryRegion name to be used for default backend + *creation if user explicitly hasn't specified backend with "memory-backend" + *property. */ struct MachineClass { /*< private >*/ @@ -226,6 +230,7 @@ struct MachineClass { bool nvdimm_supported; bool numa_mem_supported; bool auto_enable_numa; +const char *default_ram_id; HotplugHandler *(*get_hotplug_handler)(MachineState *machine, DeviceState *dev); diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h index 4dbdadd..5db0d66 100644 --- a/include/sysemu/hostmem.h +++ b/include/sysemu/hostmem.h @@ -27,6 +27,22 @@ #define MEMORY_BACKEND_CLASS(klass) \ OBJECT_CLASS_CHECK(HostMemoryBackendClass, (klass), TYPE_MEMORY_BACKEND) +/* hostmem-ram.c */ +/** + * @TYPE_MEMORY_BACKEND_RAM: + * name of backend that uses mmap on the anonymous RAM + */ + +#define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram" + +/* hostmem-file.c */ +/** + * @TYPE_MEMORY_BACKEND_FILE: + * name of backend that uses mmap on a file descriptor + */ +#define TYPE_MEMORY_BACKEND_FILE "memory-backend-file" + +typedef struct HostMemoryBackend HostMemoryBackend; typedef struct HostMemoryBackendClass HostMemoryBackendClass; /** diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c index be64020..cb319a9 100644 --- a/backends/hostmem-file.c +++ b/backends/hostmem-file.c @@ -18,13 +18,6 @@ #include "sysemu/sysemu.h" #include "qom/object_interfaces.h" -/* hostmem-file.c */ -/** - * @TYPE_MEMORY_BACKEND_FILE: - * name of backend that uses mmap on a file descriptor - */ -#define TYPE_MEMORY_BACKEND_FILE "memory-backend-file" - #define MEMORY_BACKEND_FILE(obj) \ OBJECT_CHECK(HostMemoryBackendFile, (obj), TYPE_MEMORY_BACKEND_FILE) diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c index 6aab8d3..5cc53e7 100644 --- a/backends/hostmem-ram.c +++ b/backends/hostmem-ram.c @@ -16,8 +16,6 @@ #include "qemu/module.h" #include "qom/object_interfaces.h" -#define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram" - static void ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { diff --git a/vl.c b/vl.c index 71d3e7e..9f97cb6 100644 --- a/vl.c +++ b/vl.c @@ -75,6 +75,7 @@ int main(int argc, char **argv) #include "ui/input.h" #include "sysemu/sysemu.h" #include "sysemu/numa.h" +#include "sysemu/hostmem.h" #include "exec/gdbstub.h" #include "qemu/timer.h" #include "chardev/char.h" @@ -2822,6 +2823,25 @@ static void configure_accelerators(const char *progname) } } +static void create_default_memdev(MachineState *ms, const char *path, + bool prealloc) +{ +Object *obj; +MachineClass *mc = MACHINE_GET_CLASS(ms); + +obj = object_new(path ? TYPE_MEMORY_BACKEND_FILE : TYPE_MEMORY_BACKEND_RAM); +if (path) { +object_property_set_str(obj, path, "mem-path", &error_fatal); +} +object_property_set_bool(obj, prealloc, "prealloc", &error_fatal); +object_property_set_int(obj, ms->ram_size, "size", &error_fatal); +object_property_add_child(object_get_objects_root(), mc->default_ram_id, + obj, &error_fatal); +user_creatable_complete(USER_CREATABLE(obj), &error_fatal); +object_unref(obj); +object_property_set_link(OBJECT(ms), obj, "memory-backend", &error_fatal); +} + int main(int argc, char **argv, char **envp) { int i; @@ -4285,6 +4305,11 @@ int main(int argc, char **argv, char **envp) } parse_numa_opts(current_machine); +if (!current_machine->ram_memdev && + machine_class->default_ram_size && + machine_class->default_ram_id) { +create_default_memdev(current_machine, mem_path, mem_prealloc); +} /* do monitor/qmp
[PATCH REPOST v3 11/80] arm/digic_boards: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: remove no longer needed DigicBoardState PS2: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov --- v3: * move 'DigicState *s' declaration to the top of digic4_board_init() v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daudé ) CC: drjo...@redhat.com CC: antonynpav...@gmail.com CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/digic_boards.c | 40 +--- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c index ef3fc2b..518a63e 100644 --- a/hw/arm/digic_boards.c +++ b/hw/arm/digic_boards.c @@ -35,39 +35,40 @@ #include "hw/loader.h" #include "sysemu/sysemu.h" #include "sysemu/qtest.h" +#include "qemu/units.h" +#include "qemu/cutils.h" #define DIGIC4_ROM0_BASE 0xf000 #define DIGIC4_ROM1_BASE 0xf800 #define DIGIC4_ROM_MAX_SIZE 0x0800 -typedef struct DigicBoardState { -DigicState *digic; -MemoryRegion ram; -} DigicBoardState; - typedef struct DigicBoard { -hwaddr ram_size; -void (*add_rom0)(DigicBoardState *, hwaddr, const char *); +void (*add_rom0)(DigicState *, hwaddr, const char *); const char *rom0_def_filename; -void (*add_rom1)(DigicBoardState *, hwaddr, const char *); +void (*add_rom1)(DigicState *, hwaddr, const char *); const char *rom1_def_filename; } DigicBoard; -static void digic4_board_init(DigicBoard *board) +static void digic4_board_init(MachineState *machine, DigicBoard *board) { Error *err = NULL; +DigicState *s = DIGIC(object_new(TYPE_DIGIC)); +MachineClass *mc = MACHINE_GET_CLASS(machine); + +if (machine->ram_size != mc->default_ram_size) { +char *sz = size_to_str(mc->default_ram_size); +error_report("Invalid RAM size, should be %s", sz); +g_free(sz); +exit(EXIT_FAILURE); +} -DigicBoardState *s = g_new(DigicBoardState, 1); - -s->digic = DIGIC(object_new(TYPE_DIGIC)); -object_property_set_bool(OBJECT(s->digic), true, "realized", &err); +object_property_set_bool(OBJECT(s), true, "realized", &err); if (err != NULL) { error_reportf_err(err, "Couldn't realize DIGIC SoC: "); exit(1); } -memory_region_allocate_system_memory(&s->ram, NULL, "ram", board->ram_size); -memory_region_add_subregion(get_system_memory(), 0, &s->ram); +memory_region_add_subregion(get_system_memory(), 0, machine->ram); if (board->add_rom0) { board->add_rom0(s, DIGIC4_ROM0_BASE, board->rom0_def_filename); @@ -78,7 +79,7 @@ static void digic4_board_init(DigicBoard *board) } } -static void digic_load_rom(DigicBoardState *s, hwaddr addr, +static void digic_load_rom(DigicState *s, hwaddr addr, hwaddr max_size, const char *def_filename) { target_long rom_size; @@ -118,7 +119,7 @@ static void digic_load_rom(DigicBoardState *s, hwaddr addr, * Samsung K8P3215UQB * 64M Bit (4Mx16) Page Mode / Multi-Bank NOR Flash Memory */ -static void digic4_add_k8p3215uqb_rom(DigicBoardState *s, hwaddr addr, +static void digic4_add_k8p3215uqb_rom(DigicState *s, hwaddr addr, const char *def_filename) { #define FLASH_K8P3215UQB_SIZE (4 * 1024 * 1024) @@ -135,14 +136,13 @@ static void digic4_add_k8p3215uqb_rom(DigicBoardState *s, hwaddr addr, } static DigicBoard digic4_board_canon_a1100 = { -.ram_size = 64 * 1024 * 1024, .add_rom1 = digic4_add_k8p3215uqb_rom, .rom1_def_filename = "canon-a1100-rom1.bin", }; static void canon_a1100_init(MachineState *machine) { -digic4_board_init(&digic4_board_canon_a1100); +digic4_board_init(machine, &digic4_board_canon_a1100); } static void canon_a1100_machine_init(MachineClass *mc) @@ -150,6 +150,8 @@ static void canon_a1100_machine_init(MachineClass *mc) mc->desc = "Canon PowerShot A1100 IS"; mc->init = &canon_a1100_init; mc->ignore_memory_transaction_failures = true; +mc->default_ram_size = 64 * MiB; +mc->default_ram_id = "ram"; } DEFINE_MACHINE("canon-a1100", canon_a1100_machine_init) -- 2.7.4
[PATCH REPOST v3 17/80] arm/kzm: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Peter Chubb --- CC: peter.ch...@nicta.com.au CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/kzm.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c index 94cbac1..34f6bcb 100644 --- a/hw/arm/kzm.c +++ b/hw/arm/kzm.c @@ -52,7 +52,6 @@ typedef struct IMX31KZM { FslIMX31State soc; -MemoryRegion ram; MemoryRegion ram_alias; } IMX31KZM; @@ -85,10 +84,8 @@ static void kzm_init(MachineState *machine) exit(EXIT_FAILURE); } -memory_region_allocate_system_memory(&s->ram, NULL, "kzm.ram", - machine->ram_size); memory_region_add_subregion(get_system_memory(), FSL_IMX31_SDRAM0_ADDR, -&s->ram); +machine->ram); /* initialize the alias memory if any */ for (i = 0, ram_size = machine->ram_size, alias_offset = 0; @@ -108,7 +105,8 @@ static void kzm_init(MachineState *machine) if (size < ram[i].size) { memory_region_init_alias(&s->ram_alias, NULL, "ram.alias", - &s->ram, alias_offset, ram[i].size - size); + machine->ram, + alias_offset, ram[i].size - size); memory_region_add_subregion(get_system_memory(), ram[i].addr + size, &s->ram_alias); } @@ -140,6 +138,7 @@ static void kzm_machine_init(MachineClass *mc) mc->desc = "ARM KZM Emulation Baseboard (ARM1136)"; mc->init = kzm_init; mc->ignore_memory_transaction_failures = true; +mc->default_ram_id = "kzm.ram"; } DEFINE_MACHINE("kzm", kzm_machine_init) -- 2.7.4
[PATCH REPOST v3 09/80] arm/collie: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: - while at it add check for user supplied RAM size and error out if it mismatches board expected value. - introduce RAM_ADDR_UFMT to avoid build errors on 32-bit hosts when specifying format string for ram_addr_t type Signed-off-by: Igor Mammedov --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daudé ) v3: * instead of RAM_ADDR_UFMT adding use size_to_str() Philippe Mathieu-Daudé CC: drjo...@redhat.com CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/collie.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/arm/collie.c b/hw/arm/collie.c index 970a440..024893f 100644 --- a/hw/arm/collie.c +++ b/hw/arm/collie.c @@ -10,6 +10,7 @@ */ #include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/cutils.h" #include "hw/sysbus.h" #include "hw/boards.h" #include "strongarm.h" @@ -20,20 +21,24 @@ static struct arm_boot_info collie_binfo = { .loader_start = SA_SDCS0, -.ram_size = 0x2000, }; static void collie_init(MachineState *machine) { StrongARMState *s; DriveInfo *dinfo; -MemoryRegion *sdram = g_new(MemoryRegion, 1); +MachineClass *mc = MACHINE_GET_CLASS(machine); + +if (machine->ram_size != mc->default_ram_size) { +char *sz = size_to_str(mc->default_ram_size); +error_report("Invalid RAM size, should be %s", sz); +g_free(sz); +exit(EXIT_FAILURE); +} s = sa1110_init(machine->cpu_type); -memory_region_allocate_system_memory(sdram, NULL, "strongarm.sdram", - collie_binfo.ram_size); -memory_region_add_subregion(get_system_memory(), SA_SDCS0, sdram); +memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ram); dinfo = drive_get(IF_PFLASH, 0, 0); pflash_cfi01_register(SA_CS0, "collie.fl1", 0x0200, @@ -57,6 +62,8 @@ static void collie_machine_init(MachineClass *mc) mc->init = collie_init; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type = ARM_CPU_TYPE_NAME("sa1110"); +mc->default_ram_size = 0x2000; +mc->default_ram_id = "strongarm.sdram"; } DEFINE_MACHINE("collie", collie_machine_init) -- 2.7.4
[PATCH REPOST v3 06/80] alpha:dp264: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Acked-by: Richard Henderson --- hw/alpha/alpha_sys.h | 2 +- hw/alpha/dp264.c | 3 ++- hw/alpha/typhoon.c | 8 ++-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/hw/alpha/alpha_sys.h b/hw/alpha/alpha_sys.h index 95033d7..bc0a286 100644 --- a/hw/alpha/alpha_sys.h +++ b/hw/alpha/alpha_sys.h @@ -11,7 +11,7 @@ #include "hw/intc/i8259.h" -PCIBus *typhoon_init(ram_addr_t, ISABus **, qemu_irq *, AlphaCPU *[4], +PCIBus *typhoon_init(MemoryRegion *, ISABus **, qemu_irq *, AlphaCPU *[4], pci_map_irq_fn); /* alpha_pci.c. */ diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c index f2026fd..29439c7 100644 --- a/hw/alpha/dp264.c +++ b/hw/alpha/dp264.c @@ -75,7 +75,7 @@ static void clipper_init(MachineState *machine) cpus[0]->env.trap_arg2 = smp_cpus; /* Init the chipset. */ -pci_bus = typhoon_init(ram_size, &isa_bus, &rtc_irq, cpus, +pci_bus = typhoon_init(machine->ram, &isa_bus, &rtc_irq, cpus, clipper_pci_map_irq); /* Since we have an SRM-compatible PALcode, use the SRM epoch. */ @@ -183,6 +183,7 @@ static void clipper_machine_init(MachineClass *mc) mc->max_cpus = 4; mc->is_default = 1; mc->default_cpu_type = ALPHA_CPU_TYPE_NAME("ev67"); +mc->default_ram_id = "ram"; } DEFINE_MACHINE("clipper", clipper_machine_init) diff --git a/hw/alpha/typhoon.c b/hw/alpha/typhoon.c index 179e1f7..1795e2f 100644 --- a/hw/alpha/typhoon.c +++ b/hw/alpha/typhoon.c @@ -58,7 +58,6 @@ typedef struct TyphoonState { TyphoonCchip cchip; TyphoonPchip pchip; MemoryRegion dchip_region; -MemoryRegion ram_region; } TyphoonState; /* Called when one of DRIR or DIM changes. */ @@ -817,8 +816,7 @@ static void typhoon_alarm_timer(void *opaque) cpu_interrupt(CPU(s->cchip.cpu[cpu]), CPU_INTERRUPT_TIMER); } -PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus, - qemu_irq *p_rtc_irq, +PCIBus *typhoon_init(MemoryRegion *ram, ISABus **isa_bus, qemu_irq *p_rtc_irq, AlphaCPU *cpus[4], pci_map_irq_fn sys_map_irq) { MemoryRegion *addr_space = get_system_memory(); @@ -851,9 +849,7 @@ PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus, /* Main memory region, 0x00... Real hardware supports 32GB, but the address space hole reserved at this point is 8TB. */ -memory_region_allocate_system_memory(&s->ram_region, OBJECT(s), "ram", - ram_size); -memory_region_add_subregion(addr_space, 0, &s->ram_region); +memory_region_add_subregion(addr_space, 0, ram); /* TIGbus, 0x801.., 1GB. */ /* ??? The TIGbus is used for delivering interrupts, and access to -- 2.7.4
[PATCH REPOST v3 13/80] arm/imx25_pdk: drop RAM size fixup
If user provided non-sense RAM size, board will complain and continue running with max RAM size supported. Also RAM is going to be allocated by generic code, so it won't be possible for board to fix things up for user. Make it error message and exit to force user fix CLI, instead of accepting non-sense CLI values. Signed-off-by: Igor Mammedov --- CC: drjo...@redhat.com CC: j...@tribudubois.net CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/imx25_pdk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c index c76fc2b..a2b7b35 100644 --- a/hw/arm/imx25_pdk.c +++ b/hw/arm/imx25_pdk.c @@ -78,10 +78,10 @@ static void imx25_pdk_init(MachineState *machine) /* We need to initialize our memory */ if (machine->ram_size > (FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE)) { -warn_report("RAM size " RAM_ADDR_FMT " above max supported, " +error_report("RAM size " RAM_ADDR_FMT " above max supported, " "reduced to %x", machine->ram_size, FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE); -machine->ram_size = FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE; +exit(EXIT_FAILURE); } memory_region_allocate_system_memory(&s->ram, NULL, "imx25.ram", -- 2.7.4
[PATCH REPOST v3 08/80] arm/aspeed: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Cédric Le Goater --- CC: c...@kaod.org CC: peter.mayd...@linaro.org CC: and...@aj.id.au CC: j...@jms.id.au CC: qemu-...@nongnu.org --- hw/arm/aspeed.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index c8573e5..7b956f9 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -35,7 +35,6 @@ static struct arm_boot_info aspeed_board_binfo = { struct AspeedBoardState { AspeedSoCState soc; MemoryRegion ram_container; -MemoryRegion ram; MemoryRegion max_ram; }; @@ -184,6 +183,7 @@ static void aspeed_machine_init(MachineState *machine) memory_region_init(&bmc->ram_container, NULL, "aspeed-ram-container", UINT32_MAX); +memory_region_add_subregion(&bmc->ram_container, 0, machine->ram); object_initialize_child(OBJECT(machine), "soc", &bmc->soc, (sizeof(bmc->soc)), amc->soc_name, &error_abort, @@ -219,8 +219,6 @@ static void aspeed_machine_init(MachineState *machine) object_property_set_bool(OBJECT(&bmc->soc), true, "realized", &error_abort); -memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); -memory_region_add_subregion(&bmc->ram_container, 0, &bmc->ram); memory_region_add_subregion(get_system_memory(), sc->memmap[ASPEED_SDRAM], &bmc->ram_container); @@ -397,6 +395,7 @@ static void aspeed_machine_class_init(ObjectClass *oc, void *data) mc->no_floppy = 1; mc->no_cdrom = 1; mc->no_parallel = 1; +mc->default_ram_id = "ram"; } static void aspeed_machine_palmetto_class_init(ObjectClass *oc, void *data) -- 2.7.4
[PATCH REPOST v3 18/80] arm/mcimx6ul-evk: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: remove no longer needed MCIMX6ULEVK Signed-off-by: Igor Mammedov --- CC: drjo...@redhat.com CC: j...@tribudubois.net CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/mcimx6ul-evk.c | 25 + 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/hw/arm/mcimx6ul-evk.c b/hw/arm/mcimx6ul-evk.c index e90b393..23a71ed 100644 --- a/hw/arm/mcimx6ul-evk.c +++ b/hw/arm/mcimx6ul-evk.c @@ -19,15 +19,10 @@ #include "qemu/error-report.h" #include "sysemu/qtest.h" -typedef struct { -FslIMX6ULState soc; -MemoryRegion ram; -} MCIMX6ULEVK; - static void mcimx6ul_evk_init(MachineState *machine) { static struct arm_boot_info boot_info; -MCIMX6ULEVK *s = g_new0(MCIMX6ULEVK, 1); +FslIMX6ULState *s; int i; if (machine->ram_size > FSL_IMX6UL_MMDC_SIZE) { @@ -43,15 +38,12 @@ static void mcimx6ul_evk_init(MachineState *machine) .nb_cpus = machine->smp.cpus, }; -object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc), -TYPE_FSL_IMX6UL, &error_fatal, NULL); - -object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fatal); +s = FSL_IMX6UL(object_new(TYPE_FSL_IMX6UL)); +object_property_add_child(OBJECT(machine), "soc", OBJECT(s), &error_fatal); +object_property_set_bool(OBJECT(s), true, "realized", &error_fatal); -memory_region_allocate_system_memory(&s->ram, NULL, "mcimx6ul-evk.ram", - machine->ram_size); -memory_region_add_subregion(get_system_memory(), -FSL_IMX6UL_MMDC_ADDR, &s->ram); +memory_region_add_subregion(get_system_memory(), FSL_IMX6UL_MMDC_ADDR, +machine->ram); for (i = 0; i < FSL_IMX6UL_NUM_USDHCS; i++) { BusState *bus; @@ -61,7 +53,7 @@ static void mcimx6ul_evk_init(MachineState *machine) di = drive_get_next(IF_SD); blk = di ? blk_by_legacy_dinfo(di) : NULL; -bus = qdev_get_child_bus(DEVICE(&s->soc.usdhc[i]), "sd-bus"); +bus = qdev_get_child_bus(DEVICE(&s->usdhc[i]), "sd-bus"); carddev = qdev_create(bus, TYPE_SD_CARD); qdev_prop_set_drive(carddev, "drive", blk, &error_fatal); object_property_set_bool(OBJECT(carddev), true, @@ -69,7 +61,7 @@ static void mcimx6ul_evk_init(MachineState *machine) } if (!qtest_enabled()) { -arm_load_kernel(&s->soc.cpu, machine, &boot_info); +arm_load_kernel(&s->cpu, machine, &boot_info); } } @@ -78,5 +70,6 @@ static void mcimx6ul_evk_machine_init(MachineClass *mc) mc->desc = "Freescale i.MX6UL Evaluation Kit (Cortex A7)"; mc->init = mcimx6ul_evk_init; mc->max_cpus = FSL_IMX6UL_NUM_CPUS; +mc->default_ram_id = "mcimx6ul-evk.ram"; } DEFINE_MACHINE("mcimx6ul-evk", mcimx6ul_evk_machine_init) -- 2.7.4
[PATCH REPOST v3 12/80] arm/highbank: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé --- CC: r...@kernel.org CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/highbank.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c index 518d935..ac9de94 100644 --- a/hw/arm/highbank.c +++ b/hw/arm/highbank.c @@ -236,7 +236,6 @@ enum cxmachines { */ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) { -ram_addr_t ram_size = machine->ram_size; DeviceState *dev = NULL; SysBusDevice *busdev; qemu_irq pic[128]; @@ -247,7 +246,6 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) qemu_irq cpu_virq[4]; qemu_irq cpu_vfiq[4]; MemoryRegion *sysram; -MemoryRegion *dram; MemoryRegion *sysmem; char *sysboot_filename; @@ -290,10 +288,8 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) } sysmem = get_system_memory(); -dram = g_new(MemoryRegion, 1); -memory_region_allocate_system_memory(dram, NULL, "highbank.dram", ram_size); /* SDRAM at address zero. */ -memory_region_add_subregion(sysmem, 0, dram); +memory_region_add_subregion(sysmem, 0, machine->ram); sysram = g_new(MemoryRegion, 1); memory_region_init_ram(sysram, NULL, "highbank.sysram", 0x8000, @@ -387,7 +383,7 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id) /* TODO create and connect IDE devices for ide_drive_get() */ -highbank_binfo.ram_size = ram_size; +highbank_binfo.ram_size = machine->ram_size; /* highbank requires a dtb in order to boot, and the dtb will override * the board ID. The following value is ignored, so set it to -1 to be * clear that the value is meaningless. @@ -430,6 +426,7 @@ static void highbank_class_init(ObjectClass *oc, void *data) mc->units_per_default_bus = 1; mc->max_cpus = 4; mc->ignore_memory_transaction_failures = true; +mc->default_ram_id = "highbank.dram"; } static const TypeInfo highbank_type = { @@ -448,6 +445,7 @@ static void midway_class_init(ObjectClass *oc, void *data) mc->units_per_default_bus = 1; mc->max_cpus = 4; mc->ignore_memory_transaction_failures = true; +mc->default_ram_id = "highbank.dram"; } static const TypeInfo midway_type = { -- 2.7.4
[PATCH REPOST v3 15/80] arm/integratorcp: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov --- CC: drjo...@redhat.com CC: peter.ch...@nicta.com.au CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/integratorcp.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c index 5249708..89c223b 100644 --- a/hw/arm/integratorcp.c +++ b/hw/arm/integratorcp.c @@ -585,7 +585,6 @@ static void integratorcp_init(MachineState *machine) Object *cpuobj; ARMCPU *cpu; MemoryRegion *address_space_mem = get_system_memory(); -MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *ram_alias = g_new(MemoryRegion, 1); qemu_irq pic[32]; DeviceState *dev, *sic, *icp; @@ -605,14 +604,13 @@ static void integratorcp_init(MachineState *machine) cpu = ARM_CPU(cpuobj); -memory_region_allocate_system_memory(ram, NULL, "integrator.ram", - ram_size); /* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash. */ /* ??? RAM should repeat to fill physical memory space. */ /* SDRAM at address zero*/ -memory_region_add_subregion(address_space_mem, 0, ram); +memory_region_add_subregion(address_space_mem, 0, machine->ram); /* And again at address 0x8000 */ -memory_region_init_alias(ram_alias, NULL, "ram.alias", ram, 0, ram_size); +memory_region_init_alias(ram_alias, NULL, "ram.alias", machine->ram, + 0, ram_size); memory_region_add_subregion(address_space_mem, 0x8000, ram_alias); dev = qdev_create(NULL, TYPE_INTEGRATOR_CM); @@ -660,6 +658,7 @@ static void integratorcp_machine_init(MachineClass *mc) mc->init = integratorcp_init; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm926"); +mc->default_ram_id = "integrator.ram"; } DEFINE_MACHINE("integratorcp", integratorcp_machine_init) -- 2.7.4
[PATCH REPOST v3 24/80] arm/omap_sx1: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daudé ) CC: drjo...@redhat.com CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/omap_sx1.c | 20 +++- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c index be24571..2bebab4 100644 --- a/hw/arm/omap_sx1.c +++ b/hw/arm/omap_sx1.c @@ -35,6 +35,7 @@ #include "sysemu/qtest.h" #include "exec/address-spaces.h" #include "cpu.h" +#include "qemu/cutils.h" /*/ /* Siemens SX1 Cellphone V1 */ @@ -102,8 +103,8 @@ static struct arm_boot_info sx1_binfo = { static void sx1_init(MachineState *machine, const int version) { struct omap_mpu_state_s *mpu; +MachineClass *mc = MACHINE_GET_CLASS(machine); MemoryRegion *address_space = get_system_memory(); -MemoryRegion *dram = g_new(MemoryRegion, 1); MemoryRegion *flash = g_new(MemoryRegion, 1); MemoryRegion *cs = g_new(MemoryRegion, 4); static uint32_t cs0val = 0x00213090; @@ -115,15 +116,20 @@ static void sx1_init(MachineState *machine, const int version) uint32_t flash_size = flash0_size; int be; +if (machine->ram_size != mc->default_ram_size) { +char *sz = size_to_str(mc->default_ram_size); +error_report("Invalid RAM size, should be %s", sz); +g_free(sz); +exit(EXIT_FAILURE); +} + if (version == 2) { flash_size = flash2_size; } -memory_region_allocate_system_memory(dram, NULL, "omap1.dram", - sx1_binfo.ram_size); -memory_region_add_subregion(address_space, OMAP_EMIFF_BASE, dram); +memory_region_add_subregion(address_space, OMAP_EMIFF_BASE, machine->ram); -mpu = omap310_mpu_init(dram, machine->cpu_type); +mpu = omap310_mpu_init(machine->ram, machine->cpu_type); /* External Flash (EMIFS) */ memory_region_init_ram(flash, NULL, "omap_sx1.flash0-0", flash_size, @@ -223,6 +229,8 @@ static void sx1_machine_v2_class_init(ObjectClass *oc, void *data) mc->init = sx1_init_v2; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type = ARM_CPU_TYPE_NAME("ti925t"); +mc->default_ram_size = sdram_size; +mc->default_ram_id = "omap1.dram"; } static const TypeInfo sx1_machine_v2_type = { @@ -239,6 +247,8 @@ static void sx1_machine_v1_class_init(ObjectClass *oc, void *data) mc->init = sx1_init_v1; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type = ARM_CPU_TYPE_NAME("ti925t"); +mc->default_ram_size = sdram_size; +mc->default_ram_id = "omap1.dram"; } static const TypeInfo sx1_machine_v1_type = { -- 2.7.4
[PATCH REPOST v3 14/80] arm/imx25_pdk: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé --- CC: j...@tribudubois.net CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/imx25_pdk.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/arm/imx25_pdk.c b/hw/arm/imx25_pdk.c index a2b7b35..9087fcb 100644 --- a/hw/arm/imx25_pdk.c +++ b/hw/arm/imx25_pdk.c @@ -58,7 +58,6 @@ typedef struct IMX25PDK { FslIMX25State soc; -MemoryRegion ram; MemoryRegion ram_alias; } IMX25PDK; @@ -84,10 +83,8 @@ static void imx25_pdk_init(MachineState *machine) exit(EXIT_FAILURE); } -memory_region_allocate_system_memory(&s->ram, NULL, "imx25.ram", - machine->ram_size); memory_region_add_subregion(get_system_memory(), FSL_IMX25_SDRAM0_ADDR, -&s->ram); +machine->ram); /* initialize the alias memory if any */ for (i = 0, ram_size = machine->ram_size, alias_offset = 0; @@ -107,7 +104,8 @@ static void imx25_pdk_init(MachineState *machine) if (size < ram[i].size) { memory_region_init_alias(&s->ram_alias, NULL, "ram.alias", - &s->ram, alias_offset, ram[i].size - size); + machine->ram, + alias_offset, ram[i].size - size); memory_region_add_subregion(get_system_memory(), ram[i].addr + size, &s->ram_alias); } @@ -135,6 +133,7 @@ static void imx25_pdk_machine_init(MachineClass *mc) mc->desc = "ARM i.MX25 PDK board (ARM926)"; mc->init = imx25_pdk_init; mc->ignore_memory_transaction_failures = true; +mc->default_ram_id = "imx25.ram"; } DEFINE_MACHINE("imx25-pdk", imx25_pdk_machine_init) -- 2.7.4
[PATCH REPOST v3 16/80] arm/kzm: drop RAM size fixup
If the user provided too large a RAM size, the code used to complain and trim it to the max size. Now tht RAM is allocated by generic code, that's no longer possible, so generate an error and exit instead. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé --- v3: * rephrase commit message in nicer way ("Chubb, Peter (Data61, Kensington NSW)" ) * reword error message and use size_to_str() to pretty print suggested size ("Chubb, Peter (Data61, Kensington NSW)" ) CC: peter.ch...@nicta.com.au CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/kzm.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c index 1d5ef28..94cbac1 100644 --- a/hw/arm/kzm.c +++ b/hw/arm/kzm.c @@ -25,6 +25,7 @@ #include "hw/char/serial.h" #include "sysemu/qtest.h" #include "sysemu/sysemu.h" +#include "qemu/cutils.h" /* Memory map for Kzm Emulation Baseboard: * 0x-0x7fff See i.MX31 SOC for support @@ -78,10 +79,10 @@ static void kzm_init(MachineState *machine) /* Check the amount of memory is compatible with the SOC */ if (machine->ram_size > (FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE)) { -warn_report("RAM size " RAM_ADDR_FMT " above max supported, " -"reduced to %x", machine->ram_size, -FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE); -machine->ram_size = FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE; +char *sz = size_to_str(FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE); +error_report("RAM size more than %s is not supported", sz); +g_free(sz); +exit(EXIT_FAILURE); } memory_region_allocate_system_memory(&s->ram, NULL, "kzm.ram", -- 2.7.4
[PATCH REPOST v3 22/80] arm/musicpal: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daudé ) CC: drjo...@redhat.com CC: jan.kis...@web.de CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/musicpal.c | 18 +- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index f68a399..c6418b0 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -32,6 +32,7 @@ #include "sysemu/runstate.h" #include "exec/address-spaces.h" #include "ui/pixel_ops.h" +#include "qemu/cutils.h" #define MP_MISC_BASE0x80002000 #define MP_MISC_SIZE0x1000 @@ -1589,16 +1590,21 @@ static void musicpal_init(MachineState *machine) int i; unsigned long flash_size; DriveInfo *dinfo; +MachineClass *mc = MACHINE_GET_CLASS(machine); MemoryRegion *address_space_mem = get_system_memory(); -MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *sram = g_new(MemoryRegion, 1); +/* For now we use a fixed - the original - RAM size */ +if (machine->ram_size != mc->default_ram_size) { +char *sz = size_to_str(mc->default_ram_size); +error_report("Invalid RAM size, should be %s", sz); +g_free(sz); +exit(EXIT_FAILURE); +} + cpu = ARM_CPU(cpu_create(machine->cpu_type)); -/* For now we use a fixed - the original - RAM size */ -memory_region_allocate_system_memory(ram, NULL, "musicpal.ram", - MP_RAM_DEFAULT_SIZE); -memory_region_add_subregion(address_space_mem, 0, ram); +memory_region_add_subregion(address_space_mem, 0, machine->ram); memory_region_init_ram(sram, NULL, "musicpal.sram", MP_SRAM_SIZE, &error_fatal); @@ -1714,6 +1720,8 @@ static void musicpal_machine_init(MachineClass *mc) mc->init = musicpal_init; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm926"); +mc->default_ram_size = MP_RAM_DEFAULT_SIZE; +mc->default_ram_id = "musicpal.ram"; } DEFINE_MACHINE("musicpal", musicpal_machine_init) -- 2.7.4
[PATCH REPOST v3 25/80] arm/palm: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daudé ) CC: drjo...@redhat.com CC: balr...@gmail.com CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/palm.c | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/hw/arm/palm.c b/hw/arm/palm.c index 72eca8c..388b262 100644 --- a/hw/arm/palm.c +++ b/hw/arm/palm.c @@ -31,6 +31,7 @@ #include "hw/loader.h" #include "exec/address-spaces.h" #include "cpu.h" +#include "qemu/cutils.h" static uint64_t static_read(void *opaque, hwaddr offset, unsigned size) { @@ -181,7 +182,6 @@ static void palmte_gpio_setup(struct omap_mpu_state_s *cpu) static struct arm_boot_info palmte_binfo = { .loader_start = OMAP_EMIFF_BASE, -.ram_size = 0x0200, .board_id = 0x331, }; @@ -195,15 +195,21 @@ static void palmte_init(MachineState *machine) static uint32_t cs2val = 0xe1a0; static uint32_t cs3val = 0xe1a0e1a0; int rom_size, rom_loaded = 0; -MemoryRegion *dram = g_new(MemoryRegion, 1); +MachineClass *mc = MACHINE_GET_CLASS(machine); MemoryRegion *flash = g_new(MemoryRegion, 1); MemoryRegion *cs = g_new(MemoryRegion, 4); -memory_region_allocate_system_memory(dram, NULL, "omap1.dram", - palmte_binfo.ram_size); -memory_region_add_subregion(address_space_mem, OMAP_EMIFF_BASE, dram); +if (machine->ram_size != mc->default_ram_size) { +char *sz = size_to_str(mc->default_ram_size); +error_report("Invalid RAM size, should be %s", sz); +g_free(sz); +exit(EXIT_FAILURE); +} + +memory_region_add_subregion(address_space_mem, OMAP_EMIFF_BASE, +machine->ram); -mpu = omap310_mpu_init(dram, machine->cpu_type); +mpu = omap310_mpu_init(machine->ram, machine->cpu_type); /* External Flash (EMIFS) */ memory_region_init_ram(flash, NULL, "palmte.flash", flash_size, @@ -265,6 +271,8 @@ static void palmte_machine_init(MachineClass *mc) mc->init = palmte_init; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type = ARM_CPU_TYPE_NAME("ti925t"); +mc->default_ram_size = 0x0200; +mc->default_ram_id = "omap1.dram"; } DEFINE_MACHINE("cheetah", palmte_machine_init) -- 2.7.4
[PATCH REPOST v3 20/80] arm/mps2-tz: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daudé ) CC: drjo...@redhat.com CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/mps2-tz.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/arm/mps2-tz.c b/hw/arm/mps2-tz.c index f8b620b..06dacf6 100644 --- a/hw/arm/mps2-tz.c +++ b/hw/arm/mps2-tz.c @@ -39,6 +39,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/cutils.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/arm/boot.h" @@ -79,7 +80,6 @@ typedef struct { MachineState parent; ARMSSE iotkit; -MemoryRegion psram; MemoryRegion ssram[3]; MemoryRegion ssram1_m; MPS2SCC scc; @@ -388,6 +388,13 @@ static void mps2tz_common_init(MachineState *machine) exit(1); } +if (machine->ram_size != mc->default_ram_size) { +char *sz = size_to_str(mc->default_ram_size); +error_report("Invalid RAM size, should be %s", sz); +g_free(sz); +exit(EXIT_FAILURE); +} + sysbus_init_child_obj(OBJECT(machine), "iotkit", &mms->iotkit, sizeof(mms->iotkit), mmc->armsse_type); iotkitdev = DEVICE(&mms->iotkit); @@ -458,9 +465,7 @@ static void mps2tz_common_init(MachineState *machine) * tradeoffs. For QEMU they're all just RAM, though. We arbitrarily * call the 16MB our "system memory", as it's the largest lump. */ -memory_region_allocate_system_memory(&mms->psram, - NULL, "mps.ram", 16 * MiB); -memory_region_add_subregion(system_memory, 0x8000, &mms->psram); +memory_region_add_subregion(system_memory, 0x8000, machine->ram); /* The overflow IRQs for all UARTs are ORed together. * Tx, Rx and "combined" IRQs are sent to the NVIC separately. @@ -642,6 +647,7 @@ static void mps2tz_class_init(ObjectClass *oc, void *data) mc->init = mps2tz_common_init; iic->check = mps2_tz_idau_check; +mc->default_ram_id = "mps.ram"; } static void mps2tz_an505_class_init(ObjectClass *oc, void *data) @@ -657,6 +663,7 @@ static void mps2tz_an505_class_init(ObjectClass *oc, void *data) mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m33"); mmc->scc_id = 0x41045050; mmc->armsse_type = TYPE_IOTKIT; +mc->default_ram_size = 16 * MiB; } static void mps2tz_an521_class_init(ObjectClass *oc, void *data) -- 2.7.4
[PATCH REPOST v3 19/80] arm/mcimx7d-sabre: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: remove no longer needed MCIMX7Sabre Signed-off-by: Igor Mammedov --- CC: drjo...@redhat.com CC: andrew.smir...@gmail.com CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/mcimx7d-sabre.c | 25 + 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/hw/arm/mcimx7d-sabre.c b/hw/arm/mcimx7d-sabre.c index 0d1f62d..de1e264 100644 --- a/hw/arm/mcimx7d-sabre.c +++ b/hw/arm/mcimx7d-sabre.c @@ -21,15 +21,10 @@ #include "qemu/error-report.h" #include "sysemu/qtest.h" -typedef struct { -FslIMX7State soc; -MemoryRegion ram; -} MCIMX7Sabre; - static void mcimx7d_sabre_init(MachineState *machine) { static struct arm_boot_info boot_info; -MCIMX7Sabre *s = g_new0(MCIMX7Sabre, 1); +FslIMX7State *s; int i; if (machine->ram_size > FSL_IMX7_MMDC_SIZE) { @@ -45,15 +40,12 @@ static void mcimx7d_sabre_init(MachineState *machine) .nb_cpus = machine->smp.cpus, }; -object_initialize_child(OBJECT(machine), "soc", -&s->soc, sizeof(s->soc), -TYPE_FSL_IMX7, &error_fatal, NULL); -object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fatal); +s = FSL_IMX7(object_new(TYPE_FSL_IMX7)); +object_property_add_child(OBJECT(machine), "soc", OBJECT(s), &error_fatal); +object_property_set_bool(OBJECT(s), true, "realized", &error_fatal); -memory_region_allocate_system_memory(&s->ram, NULL, "mcimx7d-sabre.ram", - machine->ram_size); -memory_region_add_subregion(get_system_memory(), -FSL_IMX7_MMDC_ADDR, &s->ram); +memory_region_add_subregion(get_system_memory(), FSL_IMX7_MMDC_ADDR, +machine->ram); for (i = 0; i < FSL_IMX7_NUM_USDHCS; i++) { BusState *bus; @@ -63,7 +55,7 @@ static void mcimx7d_sabre_init(MachineState *machine) di = drive_get_next(IF_SD); blk = di ? blk_by_legacy_dinfo(di) : NULL; -bus = qdev_get_child_bus(DEVICE(&s->soc.usdhc[i]), "sd-bus"); +bus = qdev_get_child_bus(DEVICE(&s->usdhc[i]), "sd-bus"); carddev = qdev_create(bus, TYPE_SD_CARD); qdev_prop_set_drive(carddev, "drive", blk, &error_fatal); object_property_set_bool(OBJECT(carddev), true, @@ -71,7 +63,7 @@ static void mcimx7d_sabre_init(MachineState *machine) } if (!qtest_enabled()) { -arm_load_kernel(&s->soc.cpu[0], machine, &boot_info); +arm_load_kernel(&s->cpu[0], machine, &boot_info); } } @@ -80,5 +72,6 @@ static void mcimx7d_sabre_machine_init(MachineClass *mc) mc->desc = "Freescale i.MX7 DUAL SABRE (Cortex A7)"; mc->init = mcimx7d_sabre_init; mc->max_cpus = FSL_IMX7_NUM_CPUS; +mc->default_ram_id = "mcimx7d-sabre.ram"; } DEFINE_MACHINE("mcimx7d-sabre", mcimx7d_sabre_machine_init) -- 2.7.4
[PATCH REPOST v3 23/80] arm/nseries: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daudé ) CC: drjo...@redhat.com CC: balr...@gmail.com CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/nseries.c | 32 +++- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c index 3fd196f..eae800b 100644 --- a/hw/arm/nseries.c +++ b/hw/arm/nseries.c @@ -47,7 +47,6 @@ /* Nokia N8x0 support */ struct n800_s { -MemoryRegion sdram; struct omap_mpu_state_s *mpu; struct rfbi_chip_s blizzard; @@ -1311,13 +1310,19 @@ static void n8x0_init(MachineState *machine, struct arm_boot_info *binfo, int model) { struct n800_s *s = (struct n800_s *) g_malloc0(sizeof(*s)); -uint64_t sdram_size = binfo->ram_size; +MachineClass *mc = MACHINE_GET_CLASS(machine); -memory_region_allocate_system_memory(&s->sdram, NULL, "omap2.dram", - sdram_size); -memory_region_add_subregion(get_system_memory(), OMAP2_Q2_BASE, &s->sdram); +if (machine->ram_size != mc->default_ram_size) { +char *sz = size_to_str(mc->default_ram_size); +error_report("Invalid RAM size, should be %s", sz); +g_free(sz); +exit(EXIT_FAILURE); +} + +memory_region_add_subregion(get_system_memory(), OMAP2_Q2_BASE, +machine->ram); -s->mpu = omap2420_mpu_init(&s->sdram, machine->cpu_type); +s->mpu = omap2420_mpu_init(machine->ram, machine->cpu_type); /* Setup peripherals * @@ -1383,9 +1388,8 @@ static void n8x0_init(MachineState *machine, * * The code above is for loading the `zImage' file from Nokia * images. */ -load_image_targphys(option_rom[0].name, -OMAP2_Q2_BASE + 0x40, -sdram_size - 0x40); +load_image_targphys(option_rom[0].name, OMAP2_Q2_BASE + 0x40, +machine->ram_size - 0x40); n800_setup_nolo_tags(nolo_tags); cpu_physical_memory_write(OMAP2_SRAM_BASE, nolo_tags, 0x1); @@ -1395,16 +1399,12 @@ static void n8x0_init(MachineState *machine, static struct arm_boot_info n800_binfo = { .loader_start = OMAP2_Q2_BASE, -/* Actually two chips of 0x400 bytes each */ -.ram_size = 0x0800, .board_id = 0x4f7, .atag_board = n800_atag_setup, }; static struct arm_boot_info n810_binfo = { .loader_start = OMAP2_Q2_BASE, -/* Actually two chips of 0x400 bytes each */ -.ram_size = 0x0800, /* 0x60c and 0x6bf (WiMAX Edition) have been assigned but are not * used by some older versions of the bootloader and is used * instead (including versions that shipped with many devices). */ @@ -1431,6 +1431,9 @@ static void n800_class_init(ObjectClass *oc, void *data) mc->default_boot_order = ""; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm1136-r2"); +/* Actually two chips of 0x400 bytes each */ +mc->default_ram_size = 0x0800; +mc->default_ram_id = "omap2.dram"; } static const TypeInfo n800_type = { @@ -1448,6 +1451,9 @@ static void n810_class_init(ObjectClass *oc, void *data) mc->default_boot_order = ""; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm1136-r2"); +/* Actually two chips of 0x400 bytes each */ +mc->default_ram_size = 0x0800; +mc->default_ram_id = "omap2.dram"; } static const TypeInfo n810_type = { -- 2.7.4
[PATCH REPOST v3 30/80] arm/vexpress: use memdev for RAM
replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé --- CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/vexpress.c | 14 +- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 4673a88..ed683ee 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -273,7 +273,6 @@ static void a9_daughterboard_init(const VexpressMachineState *vms, { MachineState *machine = MACHINE(vms); MemoryRegion *sysmem = get_system_memory(); -MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *lowram = g_new(MemoryRegion, 1); ram_addr_t low_ram_size; @@ -283,8 +282,6 @@ static void a9_daughterboard_init(const VexpressMachineState *vms, exit(1); } -memory_region_allocate_system_memory(ram, NULL, "vexpress.highmem", - ram_size); low_ram_size = ram_size; if (low_ram_size > 0x400) { low_ram_size = 0x400; @@ -293,9 +290,10 @@ static void a9_daughterboard_init(const VexpressMachineState *vms, * address space should in theory be remappable to various * things including ROM or RAM; we always map the RAM there. */ -memory_region_init_alias(lowram, NULL, "vexpress.lowmem", ram, 0, low_ram_size); +memory_region_init_alias(lowram, NULL, "vexpress.lowmem", machine->ram, + 0, low_ram_size); memory_region_add_subregion(sysmem, 0x0, lowram); -memory_region_add_subregion(sysmem, 0x6000, ram); +memory_region_add_subregion(sysmem, 0x6000, machine->ram); /* 0x1e00 A9MPCore (SCU) private memory region */ init_cpus(machine, cpu_type, TYPE_A9MPCORE_PRIV, 0x1e00, pic, @@ -360,7 +358,6 @@ static void a15_daughterboard_init(const VexpressMachineState *vms, { MachineState *machine = MACHINE(vms); MemoryRegion *sysmem = get_system_memory(); -MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *sram = g_new(MemoryRegion, 1); { @@ -375,10 +372,8 @@ static void a15_daughterboard_init(const VexpressMachineState *vms, } } -memory_region_allocate_system_memory(ram, NULL, "vexpress.highmem", - ram_size); /* RAM is from 0x8000 upwards; there is no low-memory alias for it. */ -memory_region_add_subregion(sysmem, 0x8000, ram); +memory_region_add_subregion(sysmem, 0x8000, machine->ram); /* 0x2c00 A15MPCore private memory region (GIC) */ init_cpus(machine, cpu_type, TYPE_A15MPCORE_PRIV, @@ -795,6 +790,7 @@ static void vexpress_class_init(ObjectClass *oc, void *data) mc->init = vexpress_common_init; mc->max_cpus = 4; mc->ignore_memory_transaction_failures = true; +mc->default_ram_id = "vexpress.highmem"; } static void vexpress_a9_class_init(ObjectClass *oc, void *data) -- 2.7.4
[PATCH REPOST v3 21/80] arm/mps2: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daudé ) CC: drjo...@redhat.com CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/mps2.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c index d002b12..f246213 100644 --- a/hw/arm/mps2.c +++ b/hw/arm/mps2.c @@ -24,6 +24,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/cutils.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "hw/arm/boot.h" @@ -55,7 +56,6 @@ typedef struct { MachineState parent; ARMv7MState armv7m; -MemoryRegion psram; MemoryRegion ssram1; MemoryRegion ssram1_m; MemoryRegion ssram23; @@ -118,6 +118,13 @@ static void mps2_common_init(MachineState *machine) exit(1); } +if (machine->ram_size != mc->default_ram_size) { +char *sz = size_to_str(mc->default_ram_size); +error_report("Invalid RAM size, should be %s", sz); +g_free(sz); +exit(EXIT_FAILURE); +} + /* The FPGA images have an odd combination of different RAMs, * because in hardware they are different implementations and * connected to different buses, giving varying performance/size @@ -146,9 +153,7 @@ static void mps2_common_init(MachineState *machine) * This is of no use for QEMU so we don't implement it (as if * zbt_boot_ctrl is always zero). */ -memory_region_allocate_system_memory(&mms->psram, - NULL, "mps.ram", 16 * MiB); -memory_region_add_subregion(system_memory, 0x2100, &mms->psram); +memory_region_add_subregion(system_memory, 0x2100, machine->ram); switch (mmc->fpga_type) { case FPGA_AN385: @@ -338,6 +343,8 @@ static void mps2_class_init(ObjectClass *oc, void *data) mc->init = mps2_common_init; mc->max_cpus = 1; +mc->default_ram_size = 16 * MiB; +mc->default_ram_id = "mps.ram"; } static void mps2_an385_class_init(ObjectClass *oc, void *data) -- 2.7.4
[PATCH REPOST v3 34/80] arm/xlnx-versal-virt: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé --- hw/arm/xlnx-versal-virt.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c index 462493c..c137ff4 100644 --- a/hw/arm/xlnx-versal-virt.c +++ b/hw/arm/xlnx-versal-virt.c @@ -30,7 +30,6 @@ typedef struct VersalVirt { MachineState parent_obj; Versal soc; -MemoryRegion mr_ddr; void *fdt; int fdt_size; @@ -414,12 +413,9 @@ static void versal_virt_init(MachineState *machine) psci_conduit = QEMU_PSCI_CONDUIT_SMC; } -memory_region_allocate_system_memory(&s->mr_ddr, NULL, "ddr", - machine->ram_size); - sysbus_init_child_obj(OBJECT(machine), "xlnx-ve", &s->soc, sizeof(s->soc), TYPE_XLNX_VERSAL); -object_property_set_link(OBJECT(&s->soc), OBJECT(&s->mr_ddr), +object_property_set_link(OBJECT(&s->soc), OBJECT(machine->ram), "ddr", &error_abort); object_property_set_int(OBJECT(&s->soc), psci_conduit, "psci-conduit", &error_abort); @@ -473,6 +469,7 @@ static void versal_virt_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus = XLNX_VERSAL_NR_ACPUS; mc->default_cpus = XLNX_VERSAL_NR_ACPUS; mc->no_cdrom = true; +mc->default_ram_id = "ddr"; } static const TypeInfo versal_virt_machine_init_typeinfo = { -- 2.7.4
[PATCH REPOST v3 28/80] arm/sbsa-ref: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé --- CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org CC: radoslaw.bierna...@linaro.org CC: leif.lindh...@linaro.org --- hw/arm/sbsa-ref.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index 9b5bcb5..1cba9fc 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -593,7 +593,6 @@ static void sbsa_ref_init(MachineState *machine) MachineClass *mc = MACHINE_GET_CLASS(machine); MemoryRegion *sysmem = get_system_memory(); MemoryRegion *secure_sysmem = g_new(MemoryRegion, 1); -MemoryRegion *ram = g_new(MemoryRegion, 1); bool firmware_loaded; const CPUArchIdList *possible_cpus; int n, sbsa_max_cpus; @@ -685,9 +684,8 @@ static void sbsa_ref_init(MachineState *machine) object_unref(cpuobj); } -memory_region_allocate_system_memory(ram, NULL, "sbsa-ref.ram", - machine->ram_size); -memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, ram); +memory_region_add_subregion(sysmem, sbsa_ref_memmap[SBSA_MEM].base, +machine->ram); create_fdt(sms); @@ -785,6 +783,7 @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data) mc->block_default_type = IF_IDE; mc->no_cdrom = 1; mc->default_ram_size = 1 * GiB; +mc->default_ram_id = "sbsa-ref.ram"; mc->default_cpus = 4; mc->possible_cpu_arch_ids = sbsa_ref_possible_cpu_arch_ids; mc->cpu_index_to_instance_props = sbsa_ref_cpu_index_to_props; -- 2.7.4
[PATCH REPOST v3 26/80] arm/raspi: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: remove no longer needed RasPiState Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé --- CC: andrew.baum...@microsoft.com CC: phi...@redhat.com CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/raspi.c | 34 +- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 6a510aa..33ace66 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -32,11 +32,6 @@ /* Table of Linux board IDs for different Pi versions */ static const int raspi_boardid[] = {[1] = 0xc42, [2] = 0xc43, [3] = 0xc44}; -typedef struct RasPiState { -BCM283XState soc; -MemoryRegion ram; -} RasPiState; - static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info) { static const uint32_t smpboot[] = { @@ -166,7 +161,7 @@ static void setup_boot(MachineState *machine, int version, size_t ram_size) static void raspi_init(MachineState *machine, int version) { -RasPiState *s = g_new0(RasPiState, 1); +Object *soc; uint32_t vcram_size; DriveInfo *di; BlockBackend *blk; @@ -179,30 +174,26 @@ static void raspi_init(MachineState *machine, int version) exit(1); } -object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc), -version == 3 ? TYPE_BCM2837 : TYPE_BCM2836, -&error_abort, NULL); +soc = object_new(version == 3 ? TYPE_BCM2837 : TYPE_BCM2836); +object_property_add_child(OBJECT(machine), "soc", soc, &error_fatal); -/* Allocate and map RAM */ -memory_region_allocate_system_memory(&s->ram, OBJECT(machine), "ram", - machine->ram_size); /* FIXME: Remove when we have custom CPU address space support */ -memory_region_add_subregion_overlap(get_system_memory(), 0, &s->ram, 0); +memory_region_add_subregion_overlap(get_system_memory(), 0, +machine->ram, 0); /* Setup the SOC */ -object_property_add_const_link(OBJECT(&s->soc), "ram", OBJECT(&s->ram), +object_property_add_const_link(soc, "ram", OBJECT(machine->ram), &error_abort); -object_property_set_int(OBJECT(&s->soc), machine->smp.cpus, "enabled-cpus", +object_property_set_int(soc, machine->smp.cpus, "enabled-cpus", &error_abort); int board_rev = version == 3 ? 0xa02082 : 0xa21041; -object_property_set_int(OBJECT(&s->soc), board_rev, "board-rev", -&error_abort); -object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_abort); +object_property_set_int(soc, board_rev, "board-rev", &error_abort); +object_property_set_bool(soc, true, "realized", &error_abort); /* Create and plug in the SD cards */ di = drive_get_next(IF_SD); blk = di ? blk_by_legacy_dinfo(di) : NULL; -bus = qdev_get_child_bus(DEVICE(&s->soc), "sd-bus"); +bus = qdev_get_child_bus(DEVICE(soc), "sd-bus"); if (bus == NULL) { error_report("No SD bus found in SOC object"); exit(1); @@ -211,8 +202,7 @@ static void raspi_init(MachineState *machine, int version) qdev_prop_set_drive(carddev, "drive", blk, &error_fatal); object_property_set_bool(OBJECT(carddev), true, "realized", &error_fatal); -vcram_size = object_property_get_uint(OBJECT(&s->soc), "vcram-size", - &error_abort); +vcram_size = object_property_get_uint(soc, "vcram-size", &error_abort); setup_boot(machine, version, machine->ram_size - vcram_size); } @@ -233,6 +223,7 @@ static void raspi2_machine_init(MachineClass *mc) mc->min_cpus = BCM283X_NCPUS; mc->default_cpus = BCM283X_NCPUS; mc->default_ram_size = 1 * GiB; +mc->default_ram_id = "ram"; mc->ignore_memory_transaction_failures = true; }; DEFINE_MACHINE("raspi2", raspi2_machine_init) @@ -255,6 +246,7 @@ static void raspi3_machine_init(MachineClass *mc) mc->min_cpus = BCM283X_NCPUS; mc->default_cpus = BCM283X_NCPUS; mc->default_ram_size = 1 * GiB; +mc->default_ram_id = "ram"; } DEFINE_MACHINE("raspi3", raspi3_machine_init) #endif -- 2.7.4
[PATCH REPOST v3 37/80] null-machine: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé --- hw/core/null-machine.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/core/null-machine.c b/hw/core/null-machine.c index 1aa0a9a..cb47d9d 100644 --- a/hw/core/null-machine.c +++ b/hw/core/null-machine.c @@ -32,11 +32,8 @@ static void machine_none_init(MachineState *mch) } /* RAM at address zero */ -if (mch->ram_size) { -MemoryRegion *ram = g_new(MemoryRegion, 1); - -memory_region_allocate_system_memory(ram, NULL, "ram", mch->ram_size); -memory_region_add_subregion(get_system_memory(), 0, ram); +if (mch->ram) { +memory_region_add_subregion(get_system_memory(), 0, mch->ram); } if (mch->kernel_filename) { @@ -52,6 +49,7 @@ static void machine_none_machine_init(MachineClass *mc) mc->init = machine_none_init; mc->max_cpus = 1; mc->default_ram_size = 0; +mc->default_ram_id = "ram"; } DEFINE_MACHINE("none", machine_none_machine_init) -- 2.7.4
[PATCH REPOST v3 27/80] arm/sabrelite: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: remove no longer needed IMX6Sabrelite Signed-off-by: Igor Mammedov --- CC: drjo...@redhat.com CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org CC: j...@tribudubois.net --- hw/arm/sabrelite.c | 23 --- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c index 96cc455..e31694b 100644 --- a/hw/arm/sabrelite.c +++ b/hw/arm/sabrelite.c @@ -19,11 +19,6 @@ #include "qemu/error-report.h" #include "sysemu/qtest.h" -typedef struct IMX6Sabrelite { -FslIMX6State soc; -MemoryRegion ram; -} IMX6Sabrelite; - static struct arm_boot_info sabrelite_binfo = { /* DDR memory start */ .loader_start = FSL_IMX6_MMDC_ADDR, @@ -45,7 +40,7 @@ static void sabrelite_reset_secondary(ARMCPU *cpu, static void sabrelite_init(MachineState *machine) { -IMX6Sabrelite *s = g_new0(IMX6Sabrelite, 1); +FslIMX6State *s; Error *err = NULL; /* Check the amount of memory is compatible with the SOC */ @@ -55,19 +50,16 @@ static void sabrelite_init(MachineState *machine) exit(1); } -object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc), -TYPE_FSL_IMX6, &error_abort, NULL); - -object_property_set_bool(OBJECT(&s->soc), true, "realized", &err); +s = FSL_IMX6(object_new(TYPE_FSL_IMX6)); +object_property_add_child(OBJECT(machine), "soc", OBJECT(s), &error_fatal); +object_property_set_bool(OBJECT(s), true, "realized", &err); if (err != NULL) { error_report("%s", error_get_pretty(err)); exit(1); } -memory_region_allocate_system_memory(&s->ram, NULL, "sabrelite.ram", - machine->ram_size); memory_region_add_subregion(get_system_memory(), FSL_IMX6_MMDC_ADDR, -&s->ram); +machine->ram); { /* @@ -78,7 +70,7 @@ static void sabrelite_init(MachineState *machine) /* Add the sst25vf016b NOR FLASH memory to first SPI */ Object *spi_dev; -spi_dev = object_resolve_path_component(OBJECT(&s->soc), "spi1"); +spi_dev = object_resolve_path_component(OBJECT(s), "spi1"); if (spi_dev) { SSIBus *spi_bus; @@ -109,7 +101,7 @@ static void sabrelite_init(MachineState *machine) sabrelite_binfo.secondary_cpu_reset_hook = sabrelite_reset_secondary; if (!qtest_enabled()) { -arm_load_kernel(&s->soc.cpu[0], machine, &sabrelite_binfo); +arm_load_kernel(&s->cpu[0], machine, &sabrelite_binfo); } } @@ -119,6 +111,7 @@ static void sabrelite_machine_init(MachineClass *mc) mc->init = sabrelite_init; mc->max_cpus = FSL_IMX6_NUM_CPUS; mc->ignore_memory_transaction_failures = true; +mc->default_ram_id = "sabrelite.ram"; } DEFINE_MACHINE("sabrelite", sabrelite_machine_init) -- 2.7.4
[PATCH REPOST v3 32/80] arm/xilinx_zynq: drop RAM size fixup
If user provided non-sense RAM size, board will complain and continue running with max RAM size supported. Also RAM is going to be allocated by generic code, so it won't be possible for board to fix things up for user. Make it error message and exit to force user fix CLI, instead of accepting non-sense CLI values. Signed-off-by: Igor Mammedov Reviewed-by: Alistair Francis --- CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org CC: edgar.igles...@gmail.com CC: alist...@alistair23.me --- hw/arm/xilinx_zynq.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c index 3a0fa5b..df950fc 100644 --- a/hw/arm/xilinx_zynq.c +++ b/hw/arm/xilinx_zynq.c @@ -158,7 +158,6 @@ static inline void zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq, static void zynq_init(MachineState *machine) { -ram_addr_t ram_size = machine->ram_size; ARMCPU *cpu; MemoryRegion *address_space_mem = get_system_memory(); MemoryRegion *ext_ram = g_new(MemoryRegion, 1); @@ -168,6 +167,12 @@ static void zynq_init(MachineState *machine) qemu_irq pic[64]; int n; +/* max 2GB ram */ +if (machine->ram_size > 0x8000) { +error_report("RAM size more than %d is not supported", 0x8000); +exit(EXIT_FAILURE); +} + cpu = ARM_CPU(object_new(machine->cpu_type)); /* By default A9 CPUs have EL3 enabled. This board does not @@ -184,14 +189,9 @@ static void zynq_init(MachineState *machine) &error_fatal); object_property_set_bool(OBJECT(cpu), true, "realized", &error_fatal); -/* max 2GB ram */ -if (ram_size > 0x8000) { -ram_size = 0x8000; -} - /* DDR remapped to address zero. */ memory_region_allocate_system_memory(ext_ram, NULL, "zynq.ext_ram", - ram_size); + machine->ram_size); memory_region_add_subregion(address_space_mem, 0, ext_ram); /* 256K of on-chip memory */ @@ -300,7 +300,7 @@ static void zynq_init(MachineState *machine) sysbus_connect_irq(busdev, 0, pic[40 - IRQ_OFFSET]); sysbus_mmio_map(busdev, 0, 0xF8007000); -zynq_binfo.ram_size = ram_size; +zynq_binfo.ram_size = machine->ram_size; zynq_binfo.nb_cpus = 1; zynq_binfo.board_id = 0xd32; zynq_binfo.loader_start = 0; -- 2.7.4
[PATCH REPOST v3 29/80] arm/versatilepb: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé --- CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/versatilepb.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c index e86af01..f3c4a50 100644 --- a/hw/arm/versatilepb.c +++ b/hw/arm/versatilepb.c @@ -184,7 +184,6 @@ static void versatile_init(MachineState *machine, int board_id) Object *cpuobj; ARMCPU *cpu; MemoryRegion *sysmem = get_system_memory(); -MemoryRegion *ram = g_new(MemoryRegion, 1); qemu_irq pic[32]; qemu_irq sic[32]; DeviceState *dev, *sysctl; @@ -220,11 +219,9 @@ static void versatile_init(MachineState *machine, int board_id) cpu = ARM_CPU(cpuobj); -memory_region_allocate_system_memory(ram, NULL, "versatile.ram", - machine->ram_size); /* ??? RAM should repeat to fill physical memory space. */ /* SDRAM at address zero. */ -memory_region_add_subregion(sysmem, 0, ram); +memory_region_add_subregion(sysmem, 0, machine->ram); sysctl = qdev_create(NULL, "realview_sysctl"); qdev_prop_set_uint32(sysctl, "sys_id", 0x41007004); @@ -398,6 +395,7 @@ static void versatilepb_class_init(ObjectClass *oc, void *data) mc->block_default_type = IF_SCSI; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm926"); +mc->default_ram_id = "versatile.ram"; } static const TypeInfo versatilepb_type = { @@ -415,6 +413,7 @@ static void versatileab_class_init(ObjectClass *oc, void *data) mc->block_default_type = IF_SCSI; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type = ARM_CPU_TYPE_NAME("arm926"); +mc->default_ram_id = "versatile.ram"; } static const TypeInfo versatileab_type = { -- 2.7.4
[PATCH REPOST v3 31/80] arm/virt: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and then map memory region provided by MachineState::ram_memdev Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé --- CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org CC: drjo...@redhat.com --- hw/arm/virt.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 39ab5f4..e2fbca3 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1512,7 +1512,6 @@ static void machvirt_init(MachineState *machine) MemoryRegion *sysmem = get_system_memory(); MemoryRegion *secure_sysmem = NULL; int n, virt_max_cpus; -MemoryRegion *ram = g_new(MemoryRegion, 1); bool firmware_loaded; bool aarch64 = true; bool has_ged = !vmc->no_ged; @@ -1701,9 +1700,8 @@ static void machvirt_init(MachineState *machine) } } -memory_region_allocate_system_memory(ram, NULL, "mach-virt.ram", - machine->ram_size); -memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram); +memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, +machine->ram); if (machine->device_memory) { memory_region_add_subregion(sysmem, machine->device_memory->base, &machine->device_memory->mr); @@ -2053,6 +2051,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) hc->unplug_request = virt_machine_device_unplug_request_cb; mc->numa_mem_supported = true; mc->auto_enable_numa_with_memhp = true; +mc->default_ram_id = "mach-virt.ram"; } static void virt_instance_init(Object *obj) -- 2.7.4
[PATCH REPOST v3 45/80] lm32/lm32_boards: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. PS: while at it add check for user supplied RAM size and error out if it mismatches board expected value. Signed-off-by: Igor Mammedov --- v2: * fix format string causing build failure on 32-bit host (Philippe Mathieu-Daudé ) CC: mich...@walle.cc --- hw/lm32/lm32_boards.c | 39 ++- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/hw/lm32/lm32_boards.c b/hw/lm32/lm32_boards.c index 5ae308b..cffb777 100644 --- a/hw/lm32/lm32_boards.c +++ b/hw/lm32/lm32_boards.c @@ -19,6 +19,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" +#include "qemu/cutils.h" #include "qemu/error-report.h" #include "cpu.h" #include "hw/sysbus.h" @@ -75,22 +76,28 @@ static void main_cpu_reset(void *opaque) static void lm32_evr_init(MachineState *machine) { +MachineClass *mc = MACHINE_GET_CLASS(machine); const char *kernel_filename = machine->kernel_filename; LM32CPU *cpu; CPULM32State *env; DriveInfo *dinfo; MemoryRegion *address_space_mem = get_system_memory(); -MemoryRegion *phys_ram = g_new(MemoryRegion, 1); qemu_irq irq[32]; ResetInfo *reset_info; int i; +if (machine->ram_size != mc->default_ram_size) { +char *sz = size_to_str(mc->default_ram_size); +error_report("Invalid RAM size, should be %s", sz); +g_free(sz); +exit(EXIT_FAILURE); +} + /* memory map */ hwaddr flash_base = 0x0400; size_t flash_sector_size = 256 * KiB; size_t flash_size = 32 * MiB; hwaddr ram_base= 0x0800; -size_t ram_size= 64 * MiB; hwaddr timer0_base = 0x80002000; hwaddr uart0_base = 0x80006000; hwaddr timer1_base = 0x8000a000; @@ -107,9 +114,7 @@ static void lm32_evr_init(MachineState *machine) reset_info->flash_base = flash_base; -memory_region_allocate_system_memory(phys_ram, NULL, "lm32_evr.sdram", - ram_size); -memory_region_add_subregion(address_space_mem, ram_base, phys_ram); +memory_region_add_subregion(address_space_mem, ram_base, machine->ram); dinfo = drive_get(IF_PFLASH, 0, 0); /* Spansion S29NS128P */ @@ -144,7 +149,7 @@ static void lm32_evr_init(MachineState *machine) if (kernel_size < 0) { kernel_size = load_image_targphys(kernel_filename, ram_base, - ram_size); + machine->ram_size); reset_info->bootstrap_pc = ram_base; } @@ -159,6 +164,7 @@ static void lm32_evr_init(MachineState *machine) static void lm32_uclinux_init(MachineState *machine) { +MachineClass *mc = MACHINE_GET_CLASS(machine); const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; @@ -166,18 +172,23 @@ static void lm32_uclinux_init(MachineState *machine) CPULM32State *env; DriveInfo *dinfo; MemoryRegion *address_space_mem = get_system_memory(); -MemoryRegion *phys_ram = g_new(MemoryRegion, 1); qemu_irq irq[32]; HWSetup *hw; ResetInfo *reset_info; int i; +if (machine->ram_size != mc->default_ram_size) { +char *sz = size_to_str(mc->default_ram_size); +error_report("Invalid RAM size, should be %s", sz); +g_free(sz); +exit(EXIT_FAILURE); +} + /* memory map */ hwaddr flash_base = 0x0400; size_t flash_sector_size= 256 * KiB; size_t flash_size = 32 * MiB; hwaddr ram_base = 0x0800; -size_t ram_size = 64 * MiB; hwaddr uart0_base = 0x8000; hwaddr timer0_base = 0x80002000; hwaddr timer1_base = 0x8001; @@ -200,9 +211,7 @@ static void lm32_uclinux_init(MachineState *machine) reset_info->flash_base = flash_base; -memory_region_allocate_system_memory(phys_ram, NULL, - "lm32_uclinux.sdram", ram_size); -memory_region_add_subregion(address_space_mem, ram_base, phys_ram); +memory_region_add_subregion(address_space_mem, ram_base, machine->ram); dinfo = drive_get(IF_PFLASH, 0, 0); /* Spansion S29NS128P */ @@ -238,7 +247,7 @@ static void lm32_uclinux_init(MachineState *machine) if (kernel_size < 0) { kernel_size = load_image_targphys(kernel_filename, ram_base, - ram_size); + machine->ram_size); reset_info->bootst
[PATCH REPOST v3 35/80] arm/xlnx-zcu102: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis --- CC: alist...@alistair23.me CC: edgar.igles...@gmail.com CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org --- hw/arm/xlnx-zcu102.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/arm/xlnx-zcu102.c b/hw/arm/xlnx-zcu102.c index 53cfe7c..bd645ad 100644 --- a/hw/arm/xlnx-zcu102.c +++ b/hw/arm/xlnx-zcu102.c @@ -28,7 +28,6 @@ typedef struct XlnxZCU102 { MachineState parent_obj; XlnxZynqMPState soc; -MemoryRegion ddr_ram; bool secure; bool virt; @@ -87,13 +86,10 @@ static void xlnx_zcu102_init(MachineState *machine) ram_size); } -memory_region_allocate_system_memory(&s->ddr_ram, NULL, "ddr-ram", - ram_size); - object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc), TYPE_XLNX_ZYNQMP, &error_abort, NULL); -object_property_set_link(OBJECT(&s->soc), OBJECT(&s->ddr_ram), +object_property_set_link(OBJECT(&s->soc), OBJECT(machine->ram), "ddr-ram", &error_abort); object_property_set_bool(OBJECT(&s->soc), s->secure, "secure", &error_fatal); @@ -211,6 +207,7 @@ static void xlnx_zcu102_machine_class_init(ObjectClass *oc, void *data) mc->ignore_memory_transaction_failures = true; mc->max_cpus = XLNX_ZYNQMP_NUM_APU_CPUS + XLNX_ZYNQMP_NUM_RPU_CPUS; mc->default_cpus = XLNX_ZYNQMP_NUM_APU_CPUS; +mc->default_ram_id = "ddr-ram"; } static const TypeInfo xlnx_zcu102_machine_init_typeinfo = { -- 2.7.4
[PATCH REPOST v3 36/80] s390x/s390-virtio-ccw: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: David Hildenbrand --- CC: r...@twiddle.net CC: da...@redhat.com CC: coh...@redhat.com CC: pa...@linux.ibm.com CC: borntrae...@de.ibm.com CC: qemu-s3...@nongnu.org --- hw/s390x/s390-virtio-ccw.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index e0e2813..cbdd4ba 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -154,14 +154,12 @@ static void virtio_ccw_register_hcalls(void) virtio_ccw_hcall_early_printk); } -static void s390_memory_init(ram_addr_t mem_size) +static void s390_memory_init(MemoryRegion *ram) { MemoryRegion *sysmem = get_system_memory(); -MemoryRegion *ram = g_new(MemoryRegion, 1); Error *local_err = NULL; /* allocate RAM for core */ -memory_region_allocate_system_memory(ram, NULL, "s390.ram", mem_size); memory_region_add_subregion(sysmem, 0, ram); /* @@ -245,7 +243,7 @@ static void ccw_init(MachineState *machine) s390_sclp_init(); /* init memory + setup max page size. Required for the CPU model */ -s390_memory_init(machine->ram_size); +s390_memory_init(machine->ram); /* init CPUs (incl. CPU model) early so s390_has_feature() works */ s390_init_cpus(machine); @@ -471,6 +469,7 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data) hc->plug = s390_machine_device_plug; hc->unplug_request = s390_machine_device_unplug_request; nc->nmi_monitor_handler = s390_nmi; +mc->default_ram_id = "s390.ram"; } static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp) -- 2.7.4
[PATCH REPOST v3 51/80] mips/mips_fulong2e: drop RAM size fixup
If user provided non-sense RAM size, board will complain and continue running with max RAM size supported. Also RAM is going to be allocated by generic code, so it won't be possible for board to fix things up for user. Make it error message and exit to force user fix CLI, instead of accepting non-sense CLI values. Signed-off-by: Igor Mammedov --- v2: * fix format string cousing build failure on 32-bit host (Philippe Mathieu-Daudé ) v3: * since size is ifxed, just hardcode 256Mb value as text in error message (BALATON Zoltan ) CC: phi...@redhat.com CC: amarko...@wavecomp.com CC: aurel...@aurel32.net CC: aleksandar.rik...@rt-rk.com CC: bala...@eik.bme.hu --- hw/mips/mips_fulong2e.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c index 9eaa6e2..e4fba88 100644 --- a/hw/mips/mips_fulong2e.c +++ b/hw/mips/mips_fulong2e.c @@ -296,7 +296,6 @@ static void mips_fulong2e_init(MachineState *machine) MemoryRegion *address_space_mem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *bios = g_new(MemoryRegion, 1); -ram_addr_t ram_size = machine->ram_size; long bios_size; uint8_t *spd_data; Error *err = NULL; @@ -315,10 +314,14 @@ static void mips_fulong2e_init(MachineState *machine) qemu_register_reset(main_cpu_reset, cpu); /* TODO: support more than 256M RAM as highmem */ -ram_size = 256 * MiB; +if (machine->ram_size != 256 * MiB) { +error_report("Invalid RAM size, should be 256MB"); +exit(EXIT_FAILURE); +} /* allocate RAM */ -memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram", ram_size); +memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram", + machine->ram_size); memory_region_init_ram(bios, NULL, "fulong2e.bios", BIOS_SIZE, &error_fatal); memory_region_set_readonly(bios, true); @@ -332,7 +335,7 @@ static void mips_fulong2e_init(MachineState *machine) */ if (kernel_filename) { -loaderparams.ram_size = ram_size; +loaderparams.ram_size = machine->ram_size; loaderparams.kernel_filename = kernel_filename; loaderparams.kernel_cmdline = kernel_cmdline; loaderparams.initrd_filename = initrd_filename; @@ -378,7 +381,7 @@ static void mips_fulong2e_init(MachineState *machine) } /* Populate SPD eeprom data */ -spd_data = spd_data_generate(DDR, ram_size, &err); +spd_data = spd_data_generate(DDR, machine->ram_size, &err); if (err) { warn_report_err(err); } -- 2.7.4
[PATCH REPOST v3 38/80] cris/axis_dev88: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé --- CC: edgar.igles...@gmail.com --- hw/cris/axis_dev88.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/hw/cris/axis_dev88.c b/hw/cris/axis_dev88.c index be77604..cf6790f 100644 --- a/hw/cris/axis_dev88.c +++ b/hw/cris/axis_dev88.c @@ -249,7 +249,6 @@ static struct cris_load_info li; static void axisdev88_init(MachineState *machine) { -ram_addr_t ram_size = machine->ram_size; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; CRISCPU *cpu; @@ -261,16 +260,12 @@ void axisdev88_init(MachineState *machine) struct etraxfs_dma_client *dma_eth; int i; MemoryRegion *address_space_mem = get_system_memory(); -MemoryRegion *phys_ram = g_new(MemoryRegion, 1); MemoryRegion *phys_intmem = g_new(MemoryRegion, 1); /* init CPUs */ cpu = CRIS_CPU(cpu_create(machine->cpu_type)); -/* allocate RAM */ -memory_region_allocate_system_memory(phys_ram, NULL, "axisdev88.ram", - ram_size); -memory_region_add_subregion(address_space_mem, 0x4000, phys_ram); +memory_region_add_subregion(address_space_mem, 0x4000, machine->ram); /* The ETRAX-FS has 128Kb on chip ram, the docs refer to it as the internal memory. */ @@ -351,6 +346,7 @@ static void axisdev88_machine_init(MachineClass *mc) mc->init = axisdev88_init; mc->is_default = 1; mc->default_cpu_type = CRIS_CPU_TYPE_NAME("crisv32"); +mc->default_ram_id = "axisdev88.ram"; } DEFINE_MACHINE("axis-dev88", axisdev88_machine_init) -- 2.7.4
[PATCH REPOST v3 33/80] arm/xilinx_zynq: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Alistair Francis --- CC: peter.mayd...@linaro.org CC: qemu-...@nongnu.org CC: edgar.igles...@gmail.com CC: alist...@alistair23.me --- hw/arm/xilinx_zynq.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c index df950fc..0ef9688 100644 --- a/hw/arm/xilinx_zynq.c +++ b/hw/arm/xilinx_zynq.c @@ -160,7 +160,6 @@ static void zynq_init(MachineState *machine) { ARMCPU *cpu; MemoryRegion *address_space_mem = get_system_memory(); -MemoryRegion *ext_ram = g_new(MemoryRegion, 1); MemoryRegion *ocm_ram = g_new(MemoryRegion, 1); DeviceState *dev; SysBusDevice *busdev; @@ -190,9 +189,7 @@ static void zynq_init(MachineState *machine) object_property_set_bool(OBJECT(cpu), true, "realized", &error_fatal); /* DDR remapped to address zero. */ -memory_region_allocate_system_memory(ext_ram, NULL, "zynq.ext_ram", - machine->ram_size); -memory_region_add_subregion(address_space_mem, 0, ext_ram); +memory_region_add_subregion(address_space_mem, 0, machine->ram); /* 256K of on-chip memory */ memory_region_init_ram(ocm_ram, NULL, "zynq.ocm_ram", 256 * KiB, @@ -318,6 +315,7 @@ static void zynq_machine_init(MachineClass *mc) mc->no_sdcard = 1; mc->ignore_memory_transaction_failures = true; mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a9"); +mc->default_ram_id = "zynq.ext_ram"; } DEFINE_MACHINE("xilinx-zynq-a9", zynq_machine_init) -- 2.7.4
[PATCH REPOST v3 53/80] mips/mips_jazz: use memdev for RAM
memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé --- hw/mips/mips_jazz.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c index 66fd4d8..85d49cf 100644 --- a/hw/mips/mips_jazz.c +++ b/hw/mips/mips_jazz.c @@ -159,7 +159,6 @@ static void mips_jazz_init(MachineState *machine, ISABus *isa_bus; ISADevice *pit; DriveInfo *fds[MAX_FD]; -MemoryRegion *ram = g_new(MemoryRegion, 1); MemoryRegion *bios = g_new(MemoryRegion, 1); MemoryRegion *bios2 = g_new(MemoryRegion, 1); SysBusESPState *sysbus_esp; @@ -191,9 +190,7 @@ static void mips_jazz_init(MachineState *machine, cc->do_transaction_failed = mips_jazz_do_transaction_failed; /* allocate RAM */ -memory_region_allocate_system_memory(ram, NULL, "mips_jazz.ram", - machine->ram_size); -memory_region_add_subregion(address_space, 0, ram); +memory_region_add_subregion(address_space, 0, machine->ram); memory_region_init_ram(bios, NULL, "mips_jazz.bios", MAGNUM_BIOS_SIZE, &error_fatal); @@ -393,6 +390,7 @@ static void mips_magnum_class_init(ObjectClass *oc, void *data) mc->init = mips_magnum_init; mc->block_default_type = IF_SCSI; mc->default_cpu_type = MIPS_CPU_TYPE_NAME("R4000"); +mc->default_ram_id = "mips_jazz.ram"; } static const TypeInfo mips_magnum_type = { @@ -409,6 +407,7 @@ static void mips_pica61_class_init(ObjectClass *oc, void *data) mc->init = mips_pica61_init; mc->block_default_type = IF_SCSI; mc->default_cpu_type = MIPS_CPU_TYPE_NAME("R4000"); +mc->default_ram_id = "mips_jazz.ram"; } static const TypeInfo mips_pica61_type = { -- 2.7.4
[PATCH REPOST v3 40/80] hw/hppa/machine: Restrict the total memory size to 3GB
From: Philippe Mathieu-Daudé The hardware expects DIMM slots of 1 or 2 GB, allowing up to 4 GB of memory. We want to accept the same amount of memory the hardware can deal with. DIMMs of 768MB are not available. However we have to deal with a firmware limitation: currently SeaBIOS only supports 32-bit, and expects the RAM size in a 32-bit register. When using a 4GB configuration, the 32-bit register get truncated and we report a size of 0MB to SeaBIOS, which ends halting the machine: $ qemu-system-hppa -m 4g -serial stdio SeaBIOS: Machine configured with too little memory (0 MB), minimum is 16 MB. SeaBIOS wants SYSTEM HALT. The easiest way is to restrict the machine to 3GB of memory. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Acked-by: Helge Deller Signed-off-by: Igor Mammedov --- hw/hppa/machine.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 6775d87..119ae4d 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -90,12 +90,11 @@ static void machine_hppa_init(MachineState *machine) g_free(name); } -/* Limit main memory. */ -if (ram_size > FIRMWARE_START) { -machine->ram_size = ram_size = FIRMWARE_START; -} - /* Main memory region. */ +if (machine->ram_size > 3 * GiB) { +error_report("RAM size is currently restricted to 3GB"); +exit(EXIT_FAILURE); +} ram_region = g_new(MemoryRegion, 1); memory_region_allocate_system_memory(ram_region, OBJECT(machine), "ram", ram_size); -- 2.7.4