From patchwork Wed Feb 14 11:13:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898830 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CFybhM4v; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbFc1PmVz23y6 for ; Wed, 14 Feb 2024 22:15:00 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDCr-0008In-Pa; Wed, 14 Feb 2024 06:13:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDCo-0008IF-Mh for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDCe-0006gk-Qq for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909204; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w9lKsQlMmLuGyggZKeZ7XCTq8rlj+x0MjeMkyLfVkOM=; b=CFybhM4vFEL1P4MN15aLB+fENeeM/+i7XI4hnz4OXpBG63tH2t8IxIlHtghfyl1n5cREOF /awqrNB3VWRLAW4kad7PU2iHQQEXncx7HgSEC21xbS124coiY7tFCr+kLWcfinFmNeRv+0 vzx83aHP4+aVdNKRVxfF3k9gAh8O+2M= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-645-jnaXmSSAM4mkQFG5hUoRIQ-1; Wed, 14 Feb 2024 06:13:22 -0500 X-MC-Unique: jnaXmSSAM4mkQFG5hUoRIQ-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5621580fca5so886467a12.1 for ; Wed, 14 Feb 2024 03:13:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909200; x=1708514000; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=w9lKsQlMmLuGyggZKeZ7XCTq8rlj+x0MjeMkyLfVkOM=; b=h9c3HkuLT7gRXuPhqFbcdltCjQZuY7wYdUFOwGp+sRi1qJtDzP3Lfba2AOdocPNdvJ RPoqtNMe0VjzLTUKox+dujrQH65MPnFdqftf+Zf1eT82ZuC1XnMGUQ8LDi7x0FfytgTb ge7wd0CNElH0zeGkFPsicKFl5Z/uKmLbxGcX3I6/eJwwBNYGlxvDcvyOFtYtyTDxp96u Y4y5LKvE6QNbJlr+DI0viRvKiNEjigmWqS80B1wxrBb3I0QSNHnllnnsVK0ZM0FsCVzN KST1BEmvsOlJC7MtCH3QO5C64qKd7veiP86t7PLshjSKfDNaa9A1ZrKjKEva702jQULS 4bmg== X-Gm-Message-State: AOJu0Yz9U+1haA8XM+ddIRNsm9aWgaggPqa1SydNSm4Sj4rCD27o0WCu hK6tWQctZOUZXM3I45YoAAIQ0TF2cZqJn8QJBE3ugdFHEq1pgjFNcibHYkVekeKyQ3EE16LqZx9 EQPhlI2cngDkQqX4nDqIkxWDBU4w5ybyAynTl8aAUNmmv6E6efpM6o1eXVuMDGnLsA+6gOIho7D VnSMGisTD6euVujWr0OfbQmUuPXMrLYQ== X-Received: by 2002:a05:6402:5286:b0:563:8718:afa7 with SMTP id en6-20020a056402528600b005638718afa7mr921548edb.12.1707909200210; Wed, 14 Feb 2024 03:13:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/1Zd+Bb7B5gGRgQJk4ybXDzHvGWh/eHN6bf3gkT/JL6Y5mtLVSDW5pGs0nRe0D+ieZGuNHg== X-Received: by 2002:a05:6402:5286:b0:563:8718:afa7 with SMTP id en6-20020a056402528600b005638718afa7mr921503edb.12.1707909199536; Wed, 14 Feb 2024 03:13:19 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV05hAdgcT62zbbEIECYOQds5tIV7oP97MJGI/zjTrRrcLSciKZj1A7uEpi+gcyvmb5FMyF8n4yvBaiDFgmjegn3Q/Oadj3 Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id d6-20020aa7d5c6000000b00563819d224esm345016eds.21.2024.02.14.03.13.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:13:18 -0800 (PST) Date: Wed, 14 Feb 2024 06:13:16 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL 01/60] virtio: split into vhost-user-base and vhost-user-device Message-ID: <6275989647efb708f126eb4f880e593792301ed4.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Alex Bennée Lets keep a cleaner split between the base class and the derived vhost-user-device which we can use for generic vhost-user stubs. This includes an update to introduce the vq_size property so the number of entries in a virtq can be defined. Signed-off-by: Alex Bennée Message-Id: <20240104210945.1223134-2-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- ...{vhost-user-device.h => vhost-user-base.h} | 21 +- hw/virtio/vhost-user-base.c | 346 ++++++++++++++++++ hw/virtio/vhost-user-device-pci.c | 13 +- hw/virtio/vhost-user-device.c | 338 +---------------- MAINTAINERS | 6 + hw/virtio/meson.build | 1 + 6 files changed, 383 insertions(+), 342 deletions(-) rename include/hw/virtio/{vhost-user-device.h => vhost-user-base.h} (71%) create mode 100644 hw/virtio/vhost-user-base.c diff --git a/include/hw/virtio/vhost-user-device.h b/include/hw/virtio/vhost-user-base.h similarity index 71% rename from include/hw/virtio/vhost-user-device.h rename to include/hw/virtio/vhost-user-base.h index 3ddf88a146..51d0968b89 100644 --- a/include/hw/virtio/vhost-user-device.h +++ b/include/hw/virtio/vhost-user-base.h @@ -6,8 +6,8 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef QEMU_VHOST_USER_DEVICE_H -#define QEMU_VHOST_USER_DEVICE_H +#ifndef QEMU_VHOST_USER_BASE_H +#define QEMU_VHOST_USER_BASE_H #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user.h" @@ -17,11 +17,13 @@ OBJECT_DECLARE_TYPE(VHostUserBase, VHostUserBaseClass, VHOST_USER_BASE) struct VHostUserBase { - VirtIODevice parent; + VirtIODevice parent_obj; + /* Properties */ CharBackend chardev; uint16_t virtio_id; uint32_t num_vqs; + uint32_t vq_size; /* can't exceed VIRTIO_QUEUE_MAX */ uint32_t config_size; /* State tracking */ VhostUserState vhost_user; @@ -31,16 +33,17 @@ struct VHostUserBase { bool connected; }; - /* needed so we can use the base realize after specialisation - tweaks */ +/* + * Needed so we can use the base realize after specialisation + * tweaks + */ struct VHostUserBaseClass { - /*< private >*/ VirtioDeviceClass parent_class; - /*< public >*/ + DeviceRealize parent_realize; }; -/* shared for the benefit of the derived pci class */ + #define TYPE_VHOST_USER_DEVICE "vhost-user-device" -#endif /* QEMU_VHOST_USER_DEVICE_H */ +#endif /* QEMU_VHOST_USER_BASE_H */ diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c new file mode 100644 index 0000000000..620fa5cb4a --- /dev/null +++ b/hw/virtio/vhost-user-base.c @@ -0,0 +1,346 @@ +/* + * Base vhost-user-base implementation. This can be used to derive a + * more fully specified vhost-user backend either generically (see + * vhost-user-device) or via a specific stub for a device which + * encapsulates some fixed parameters. + * + * Copyright (c) 2023 Linaro Ltd + * Author: Alex Bennée + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user-base.h" +#include "qemu/error-report.h" + +static void vub_start(VirtIODevice *vdev) +{ + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + VHostUserBase *vub = VHOST_USER_BASE(vdev); + int ret, i; + + if (!k->set_guest_notifiers) { + error_report("binding does not support guest notifiers"); + return; + } + + ret = vhost_dev_enable_notifiers(&vub->vhost_dev, vdev); + if (ret < 0) { + error_report("Error enabling host notifiers: %d", -ret); + return; + } + + ret = k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, true); + if (ret < 0) { + error_report("Error binding guest notifier: %d", -ret); + goto err_host_notifiers; + } + + vub->vhost_dev.acked_features = vdev->guest_features; + + ret = vhost_dev_start(&vub->vhost_dev, vdev, true); + if (ret < 0) { + error_report("Error starting vhost-user-base: %d", -ret); + goto err_guest_notifiers; + } + + /* + * guest_notifier_mask/pending not used yet, so just unmask + * everything here. virtio-pci will do the right thing by + * enabling/disabling irqfd. + */ + for (i = 0; i < vub->vhost_dev.nvqs; i++) { + vhost_virtqueue_mask(&vub->vhost_dev, vdev, i, false); + } + + return; + +err_guest_notifiers: + k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, false); +err_host_notifiers: + vhost_dev_disable_notifiers(&vub->vhost_dev, vdev); +} + +static void vub_stop(VirtIODevice *vdev) +{ + VHostUserBase *vub = VHOST_USER_BASE(vdev); + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + int ret; + + if (!k->set_guest_notifiers) { + return; + } + + vhost_dev_stop(&vub->vhost_dev, vdev, true); + + ret = k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, false); + if (ret < 0) { + error_report("vhost guest notifier cleanup failed: %d", ret); + return; + } + + vhost_dev_disable_notifiers(&vub->vhost_dev, vdev); +} + +static void vub_set_status(VirtIODevice *vdev, uint8_t status) +{ + VHostUserBase *vub = VHOST_USER_BASE(vdev); + bool should_start = virtio_device_should_start(vdev, status); + + if (vhost_dev_is_started(&vub->vhost_dev) == should_start) { + return; + } + + if (should_start) { + vub_start(vdev); + } else { + vub_stop(vdev); + } +} + +/* + * For an implementation where everything is delegated to the backend + * we don't do anything other than return the full feature set offered + * by the daemon (module the reserved feature bit). + */ +static uint64_t vub_get_features(VirtIODevice *vdev, + uint64_t requested_features, Error **errp) +{ + VHostUserBase *vub = VHOST_USER_BASE(vdev); + /* This should be set when the vhost connection initialises */ + g_assert(vub->vhost_dev.features); + return vub->vhost_dev.features & ~(1ULL << VHOST_USER_F_PROTOCOL_FEATURES); +} + +/* + * To handle VirtIO config we need to know the size of the config + * space. We don't cache the config but re-fetch it from the guest + * every time in case something has changed. + */ +static void vub_get_config(VirtIODevice *vdev, uint8_t *config) +{ + VHostUserBase *vub = VHOST_USER_BASE(vdev); + Error *local_err = NULL; + + /* + * There will have been a warning during vhost_dev_init, but lets + * assert here as nothing will go right now. + */ + g_assert(vub->config_size && vub->vhost_user.supports_config == true); + + if (vhost_dev_get_config(&vub->vhost_dev, config, + vub->config_size, &local_err)) { + error_report_err(local_err); + } +} + +/* + * When the daemon signals an update to the config we just need to + * signal the guest as we re-read the config on demand above. + */ +static int vub_config_notifier(struct vhost_dev *dev) +{ + virtio_notify_config(dev->vdev); + return 0; +} + +const VhostDevConfigOps vub_config_ops = { + .vhost_dev_config_notifier = vub_config_notifier, +}; + +static void vub_handle_output(VirtIODevice *vdev, VirtQueue *vq) +{ + /* + * Not normally called; it's the daemon that handles the queue; + * however virtio's cleanup path can call this. + */ +} + +static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserBase *vub) +{ + vhost_user_cleanup(&vub->vhost_user); + + for (int i = 0; i < vub->num_vqs; i++) { + VirtQueue *vq = g_ptr_array_index(vub->vqs, i); + virtio_delete_queue(vq); + } + + virtio_cleanup(vdev); +} + +static int vub_connect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(vdev); + struct vhost_dev *vhost_dev = &vub->vhost_dev; + + if (vub->connected) { + return 0; + } + vub->connected = true; + + /* + * If we support VHOST_USER_GET_CONFIG we must enable the notifier + * so we can ping the guest when it updates. + */ + if (vub->vhost_user.supports_config) { + vhost_dev_set_config_notifier(vhost_dev, &vub_config_ops); + } + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vub_start(vdev); + } + + return 0; +} + +static void vub_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(vdev); + + if (!vub->connected) { + return; + } + vub->connected = false; + + if (vhost_dev_is_started(&vub->vhost_dev)) { + vub_stop(vdev); + } +} + +static void vub_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev = opaque; + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(vdev); + + switch (event) { + case CHR_EVENT_OPENED: + if (vub_connect(dev) < 0) { + qemu_chr_fe_disconnect(&vub->chardev); + return; + } + break; + case CHR_EVENT_CLOSED: + vub_disconnect(dev); + break; + case CHR_EVENT_BREAK: + case CHR_EVENT_MUX_IN: + case CHR_EVENT_MUX_OUT: + /* Ignore */ + break; + } +} + +static void vub_device_realize(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(dev); + int ret; + + if (!vub->chardev.chr) { + error_setg(errp, "vhost-user-base: missing chardev"); + return; + } + + if (!vub->virtio_id) { + error_setg(errp, "vhost-user-base: need to define device id"); + return; + } + + if (!vub->num_vqs) { + vub->num_vqs = 1; /* reasonable default? */ + } + + if (!vub->vq_size) { + vub->vq_size = 64; + } + + /* + * We can't handle config requests unless we know the size of the + * config region, specialisations of the vhost-user-base will be + * able to set this. + */ + if (vub->config_size) { + vub->vhost_user.supports_config = true; + } + + if (!vhost_user_init(&vub->vhost_user, &vub->chardev, errp)) { + return; + } + + virtio_init(vdev, vub->virtio_id, vub->config_size); + + /* + * Disable guest notifiers, by default all notifications will be via the + * asynchronous vhost-user socket. + */ + vdev->use_guest_notifier_mask = false; + + /* Allocate queues */ + vub->vqs = g_ptr_array_sized_new(vub->num_vqs); + for (int i = 0; i < vub->num_vqs; i++) { + g_ptr_array_add(vub->vqs, + virtio_add_queue(vdev, vub->vq_size, + vub_handle_output)); + } + + vub->vhost_dev.nvqs = vub->num_vqs; + vub->vhost_dev.vqs = g_new0(struct vhost_virtqueue, vub->vhost_dev.nvqs); + + /* connect to backend */ + ret = vhost_dev_init(&vub->vhost_dev, &vub->vhost_user, + VHOST_BACKEND_TYPE_USER, 0, errp); + + if (ret < 0) { + do_vhost_user_cleanup(vdev, vub); + } + + qemu_chr_fe_set_handlers(&vub->chardev, NULL, NULL, vub_event, NULL, + dev, NULL, true); +} + +static void vub_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(dev); + struct vhost_virtqueue *vhost_vqs = vub->vhost_dev.vqs; + + /* This will stop vhost backend if appropriate. */ + vub_set_status(vdev, 0); + vhost_dev_cleanup(&vub->vhost_dev); + g_free(vhost_vqs); + do_vhost_user_cleanup(vdev, vub); +} + +static void vub_class_init(ObjectClass *klass, void *data) +{ + VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + + vdc->realize = vub_device_realize; + vdc->unrealize = vub_device_unrealize; + vdc->get_features = vub_get_features; + vdc->get_config = vub_get_config; + vdc->set_status = vub_set_status; +} + +static const TypeInfo vub_types[] = { + { + .name = TYPE_VHOST_USER_BASE, + .parent = TYPE_VIRTIO_DEVICE, + .instance_size = sizeof(VHostUserBase), + .class_init = vub_class_init, + .class_size = sizeof(VHostUserBaseClass), + .abstract = true + } +}; + +DEFINE_TYPES(vub_types) diff --git a/hw/virtio/vhost-user-device-pci.c b/hw/virtio/vhost-user-device-pci.c index 41f9b7905b..efaf55d3dd 100644 --- a/hw/virtio/vhost-user-device-pci.c +++ b/hw/virtio/vhost-user-device-pci.c @@ -9,21 +9,18 @@ #include "qemu/osdep.h" #include "hw/qdev-properties.h" -#include "hw/virtio/vhost-user-device.h" +#include "hw/virtio/vhost-user-base.h" #include "hw/virtio/virtio-pci.h" struct VHostUserDevicePCI { VirtIOPCIProxy parent_obj; + VHostUserBase vub; }; -typedef struct VHostUserDevicePCI VHostUserDevicePCI; - #define TYPE_VHOST_USER_DEVICE_PCI "vhost-user-device-pci-base" -DECLARE_INSTANCE_CHECKER(VHostUserDevicePCI, - VHOST_USER_DEVICE_PCI, - TYPE_VHOST_USER_DEVICE_PCI) +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserDevicePCI, VHOST_USER_DEVICE_PCI) static void vhost_user_device_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) { @@ -39,6 +36,10 @@ static void vhost_user_device_pci_class_init(ObjectClass *klass, void *data) DeviceClass *dc = DEVICE_CLASS(klass); VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass); PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass); + + /* Reason: stop users confusing themselves */ + dc->user_creatable = false; + k->realize = vhost_user_device_pci_realize; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; diff --git a/hw/virtio/vhost-user-device.c b/hw/virtio/vhost-user-device.c index 2b028cae08..67aa934710 100644 --- a/hw/virtio/vhost-user-device.c +++ b/hw/virtio/vhost-user-device.c @@ -1,7 +1,10 @@ /* - * Generic vhost-user stub. This can be used to connect to any - * vhost-user backend. All configuration details must be handled by - * the vhost-user daemon itself + * Generic vhost-user-device implementation for any vhost-user-backend + * + * This is a concrete implementation of vhost-user-base which can be + * configured via properties. It is useful for development and + * prototyping. It expects configuration details (if any) to be + * handled by the vhost-user daemon itself. * * Copyright (c) 2023 Linaro Ltd * Author: Alex Bennée @@ -13,329 +16,9 @@ #include "qapi/error.h" #include "hw/qdev-properties.h" #include "hw/virtio/virtio-bus.h" -#include "hw/virtio/vhost-user-device.h" +#include "hw/virtio/vhost-user-base.h" #include "qemu/error-report.h" -static void vub_start(VirtIODevice *vdev) -{ - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - VHostUserBase *vub = VHOST_USER_BASE(vdev); - int ret, i; - - if (!k->set_guest_notifiers) { - error_report("binding does not support guest notifiers"); - return; - } - - ret = vhost_dev_enable_notifiers(&vub->vhost_dev, vdev); - if (ret < 0) { - error_report("Error enabling host notifiers: %d", -ret); - return; - } - - ret = k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, true); - if (ret < 0) { - error_report("Error binding guest notifier: %d", -ret); - goto err_host_notifiers; - } - - vub->vhost_dev.acked_features = vdev->guest_features; - - ret = vhost_dev_start(&vub->vhost_dev, vdev, true); - if (ret < 0) { - error_report("Error starting vhost-user-device: %d", -ret); - goto err_guest_notifiers; - } - - /* - * guest_notifier_mask/pending not used yet, so just unmask - * everything here. virtio-pci will do the right thing by - * enabling/disabling irqfd. - */ - for (i = 0; i < vub->vhost_dev.nvqs; i++) { - vhost_virtqueue_mask(&vub->vhost_dev, vdev, i, false); - } - - return; - -err_guest_notifiers: - k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, false); -err_host_notifiers: - vhost_dev_disable_notifiers(&vub->vhost_dev, vdev); -} - -static void vub_stop(VirtIODevice *vdev) -{ - VHostUserBase *vub = VHOST_USER_BASE(vdev); - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - int ret; - - if (!k->set_guest_notifiers) { - return; - } - - vhost_dev_stop(&vub->vhost_dev, vdev, true); - - ret = k->set_guest_notifiers(qbus->parent, vub->vhost_dev.nvqs, false); - if (ret < 0) { - error_report("vhost guest notifier cleanup failed: %d", ret); - return; - } - - vhost_dev_disable_notifiers(&vub->vhost_dev, vdev); -} - -static void vub_set_status(VirtIODevice *vdev, uint8_t status) -{ - VHostUserBase *vub = VHOST_USER_BASE(vdev); - bool should_start = virtio_device_should_start(vdev, status); - - if (vhost_dev_is_started(&vub->vhost_dev) == should_start) { - return; - } - - if (should_start) { - vub_start(vdev); - } else { - vub_stop(vdev); - } -} - -/* - * For an implementation where everything is delegated to the backend - * we don't do anything other than return the full feature set offered - * by the daemon (module the reserved feature bit). - */ -static uint64_t vub_get_features(VirtIODevice *vdev, - uint64_t requested_features, Error **errp) -{ - VHostUserBase *vub = VHOST_USER_BASE(vdev); - /* This should be set when the vhost connection initialises */ - g_assert(vub->vhost_dev.features); - return vub->vhost_dev.features & ~(1ULL << VHOST_USER_F_PROTOCOL_FEATURES); -} - -/* - * To handle VirtIO config we need to know the size of the config - * space. We don't cache the config but re-fetch it from the guest - * every time in case something has changed. - */ -static void vub_get_config(VirtIODevice *vdev, uint8_t *config) -{ - VHostUserBase *vub = VHOST_USER_BASE(vdev); - Error *local_err = NULL; - - /* - * There will have been a warning during vhost_dev_init, but lets - * assert here as nothing will go right now. - */ - g_assert(vub->config_size && vub->vhost_user.supports_config == true); - - if (vhost_dev_get_config(&vub->vhost_dev, config, - vub->config_size, &local_err)) { - error_report_err(local_err); - } -} - -/* - * When the daemon signals an update to the config we just need to - * signal the guest as we re-read the config on demand above. - */ -static int vub_config_notifier(struct vhost_dev *dev) -{ - virtio_notify_config(dev->vdev); - return 0; -} - -const VhostDevConfigOps vub_config_ops = { - .vhost_dev_config_notifier = vub_config_notifier, -}; - -static void vub_handle_output(VirtIODevice *vdev, VirtQueue *vq) -{ - /* - * Not normally called; it's the daemon that handles the queue; - * however virtio's cleanup path can call this. - */ -} - -static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserBase *vub) -{ - vhost_user_cleanup(&vub->vhost_user); - - for (int i = 0; i < vub->num_vqs; i++) { - VirtQueue *vq = g_ptr_array_index(vub->vqs, i); - virtio_delete_queue(vq); - } - - virtio_cleanup(vdev); -} - -static int vub_connect(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserBase *vub = VHOST_USER_BASE(vdev); - struct vhost_dev *vhost_dev = &vub->vhost_dev; - - if (vub->connected) { - return 0; - } - vub->connected = true; - - /* - * If we support VHOST_USER_GET_CONFIG we must enable the notifier - * so we can ping the guest when it updates. - */ - if (vub->vhost_user.supports_config) { - vhost_dev_set_config_notifier(vhost_dev, &vub_config_ops); - } - - /* restore vhost state */ - if (virtio_device_started(vdev, vdev->status)) { - vub_start(vdev); - } - - return 0; -} - -static void vub_disconnect(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserBase *vub = VHOST_USER_BASE(vdev); - - if (!vub->connected) { - return; - } - vub->connected = false; - - if (vhost_dev_is_started(&vub->vhost_dev)) { - vub_stop(vdev); - } -} - -static void vub_event(void *opaque, QEMUChrEvent event) -{ - DeviceState *dev = opaque; - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserBase *vub = VHOST_USER_BASE(vdev); - - switch (event) { - case CHR_EVENT_OPENED: - if (vub_connect(dev) < 0) { - qemu_chr_fe_disconnect(&vub->chardev); - return; - } - break; - case CHR_EVENT_CLOSED: - vub_disconnect(dev); - break; - case CHR_EVENT_BREAK: - case CHR_EVENT_MUX_IN: - case CHR_EVENT_MUX_OUT: - /* Ignore */ - break; - } -} - -static void vub_device_realize(DeviceState *dev, Error **errp) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserBase *vub = VHOST_USER_BASE(dev); - int ret; - - if (!vub->chardev.chr) { - error_setg(errp, "vhost-user-device: missing chardev"); - return; - } - - if (!vub->virtio_id) { - error_setg(errp, "vhost-user-device: need to define device id"); - return; - } - - if (!vub->num_vqs) { - vub->num_vqs = 1; /* reasonable default? */ - } - - /* - * We can't handle config requests unless we know the size of the - * config region, specialisations of the vhost-user-device will be - * able to set this. - */ - if (vub->config_size) { - vub->vhost_user.supports_config = true; - } - - if (!vhost_user_init(&vub->vhost_user, &vub->chardev, errp)) { - return; - } - - virtio_init(vdev, vub->virtio_id, vub->config_size); - - /* - * Disable guest notifiers, by default all notifications will be via the - * asynchronous vhost-user socket. - */ - vdev->use_guest_notifier_mask = false; - - /* Allocate queues */ - vub->vqs = g_ptr_array_sized_new(vub->num_vqs); - for (int i = 0; i < vub->num_vqs; i++) { - g_ptr_array_add(vub->vqs, - virtio_add_queue(vdev, 4, vub_handle_output)); - } - - vub->vhost_dev.nvqs = vub->num_vqs; - vub->vhost_dev.vqs = g_new0(struct vhost_virtqueue, vub->vhost_dev.nvqs); - - /* connect to backend */ - ret = vhost_dev_init(&vub->vhost_dev, &vub->vhost_user, - VHOST_BACKEND_TYPE_USER, 0, errp); - - if (ret < 0) { - do_vhost_user_cleanup(vdev, vub); - } - - qemu_chr_fe_set_handlers(&vub->chardev, NULL, NULL, vub_event, NULL, - dev, NULL, true); -} - -static void vub_device_unrealize(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserBase *vub = VHOST_USER_BASE(dev); - struct vhost_virtqueue *vhost_vqs = vub->vhost_dev.vqs; - - /* This will stop vhost backend if appropriate. */ - vub_set_status(vdev, 0); - vhost_dev_cleanup(&vub->vhost_dev); - g_free(vhost_vqs); - do_vhost_user_cleanup(vdev, vub); -} - -static void vub_class_init(ObjectClass *klass, void *data) -{ - VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); - - vdc->realize = vub_device_realize; - vdc->unrealize = vub_device_unrealize; - vdc->get_features = vub_get_features; - vdc->get_config = vub_get_config; - vdc->set_status = vub_set_status; -} - -static const TypeInfo vub_info = { - .name = TYPE_VHOST_USER_BASE, - .parent = TYPE_VIRTIO_DEVICE, - .instance_size = sizeof(VHostUserBase), - .class_init = vub_class_init, - .class_size = sizeof(VHostUserBaseClass), - .abstract = true -}; - - /* * The following is a concrete implementation of the base class which * allows the user to define the key parameters via the command line. @@ -349,6 +32,7 @@ static const VMStateDescription vud_vmstate = { static Property vud_properties[] = { DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), DEFINE_PROP_UINT16("virtio-id", VHostUserBase, virtio_id, 0), + DEFINE_PROP_UINT32("vq_size", VHostUserBase, vq_size, 64), DEFINE_PROP_UINT32("num_vqs", VHostUserBase, num_vqs, 1), DEFINE_PROP_UINT32("config_size", VHostUserBase, config_size, 0), DEFINE_PROP_END_OF_LIST(), @@ -358,6 +42,9 @@ static void vud_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + /* Reason: stop inexperienced users confusing themselves */ + dc->user_creatable = false; + device_class_set_props(dc, vud_properties); dc->vmsd = &vud_vmstate; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); @@ -366,14 +53,11 @@ static void vud_class_init(ObjectClass *klass, void *data) static const TypeInfo vud_info = { .name = TYPE_VHOST_USER_DEVICE, .parent = TYPE_VHOST_USER_BASE, - .instance_size = sizeof(VHostUserBase), .class_init = vud_class_init, - .class_size = sizeof(VHostUserBaseClass), }; static void vu_register_types(void) { - type_register_static(&vub_info); type_register_static(&vud_info); } diff --git a/MAINTAINERS b/MAINTAINERS index 2f9741b898..2426368c4d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2319,6 +2319,12 @@ F: include/sysemu/rng*.h F: backends/rng*.c F: tests/qtest/virtio-rng-test.c +vhost-user-stubs +M: Alex Bennée +S: Maintained +F: hw/virtio/vhost-user-base.c +F: hw/virtio/vhost-user-device* + vhost-user-rng M: Mathieu Poirier S: Supported diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 47baf00366..3ccddbe950 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -17,6 +17,7 @@ if have_vhost if have_vhost_user # fixme - this really should be generic specific_virtio_ss.add(files('vhost-user.c')) + system_virtio_ss.add(files('vhost-user-base.c')) system_virtio_ss.add(files('vhost-user-device.c')) system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c')) endif From patchwork Wed Feb 14 11:13:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eCjy6GWj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbDr4BD5z23j8 for ; Wed, 14 Feb 2024 22:14:20 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDCo-0008IA-UG; Wed, 14 Feb 2024 06:13:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDCm-0008Hy-60 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDCi-0006gy-8g for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909205; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YVJ2xCGDmS5//nzvgjYPTRhJxVogUUB55jW/DQR2itg=; b=eCjy6GWjb5jsOrkQvVy6iyplyw5OG6m463Gkb4ei2hEuBO+yM9QBpNc10l9lwZnKn8nhLC +D9yXk63vocD9AEfzY1UOE9KwRfd+KMIODXyA3HW/TamZeaqj0x9T++ce+MIc6e5xcnVkj sVLYAaVm9H/zoV5FJM2FP+UdG2K31fI= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-16-F6d-m2mXPTCLQd8Mmrgs7A-1; Wed, 14 Feb 2024 06:13:24 -0500 X-MC-Unique: F6d-m2mXPTCLQd8Mmrgs7A-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a2f71c83b7eso154150766b.1 for ; Wed, 14 Feb 2024 03:13:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909202; x=1708514002; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YVJ2xCGDmS5//nzvgjYPTRhJxVogUUB55jW/DQR2itg=; b=NzdtSqxgjzvFFPSO6u3X7xMtTyTDYliD6KnEouLnlzyMfSLNQuseLpFqMT6Bdm8XqL EYzJxKmYoVRTkZUmGomVrXADMmCFK47IjNVS7iVHfGzXaeYshhuDp+QaoyQYxuAl5s3p ptX8pAXr73V7NnFsNtLRFkSjTri7CVGhumMY/ZJOFBUrqx6RO4asr+Rcd3ltJr887pYg bma3UA6hJjNc5SzIFuQvqvI0uzB0lDscRX0ZZRqS5Da3OAeDG9LFsngNPkheIFZDiTuE Dns8C8muDWhgF4l1/H4baPzKKUydZvvEB+mzeULcx0Pn9NQ4ARByzcKH5648XbkvLMAB EcFw== X-Gm-Message-State: AOJu0YxpNJlv/5fGMzF3y3SVegpDlI+elwsYsRYyncYb15QK5evdHDhi 3yHxXzF7q3Gu6/N9v3uESRdbN6cqX1n6v3nVxo2IFXX4jsTH7YEcRAbOkxPmKsz0DXV6etzytsn jSCGf4484WuImzy/99HOoz/vjWMF884g+A8FTIrscBIIXbj5HB3aOqS/xczrm3yWR8TZpQ1MzpR VeRxBxZpPAId0in9Ihktb0qcKvwAbX6w== X-Received: by 2002:a17:906:134c:b0:a3c:cd77:87f9 with SMTP id x12-20020a170906134c00b00a3ccd7787f9mr1630862ejb.58.1707909202628; Wed, 14 Feb 2024 03:13:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/IvSL0WABmOl0nXkIHWAqBTJNqOkoVMQvo1899o7iw2e2j4vP7/Af7A3d+KiojeqEzcyZmg== X-Received: by 2002:a17:906:134c:b0:a3c:cd77:87f9 with SMTP id x12-20020a170906134c00b00a3ccd7787f9mr1630853ejb.58.1707909202323; Wed, 14 Feb 2024 03:13:22 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXRv6+nEZO1qiCqKKYqkkipb+MpIyOHp5HSDxMz2Wy1XloRTD3il9kxiv33PpN7+BDa3zCqIfT/VsBf6UmrYMvGMzjL9iLc Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id tb20-20020a1709078b9400b00a3cf436af4fsm1741603ejc.3.2024.02.14.03.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:13:21 -0800 (PST) Date: Wed, 14 Feb 2024 06:13:19 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL 02/60] hw/virtio: convert vhost-user-base to async shutdown Message-ID: <64a312a2737e3aab97f103b76f8e76a97770e670.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Alex Bennée We are about to convert at least one stubs which was using the async teardown so lets use it for all the cases. Signed-off-by: Alex Bennée Message-Id: <20240104210945.1223134-3-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user-base.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index 620fa5cb4a..78cfa9a5bb 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -201,6 +201,8 @@ static int vub_connect(DeviceState *dev) return 0; } +static void vub_event(void *opaque, QEMUChrEvent event); + static void vub_disconnect(DeviceState *dev) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); @@ -211,9 +213,13 @@ static void vub_disconnect(DeviceState *dev) } vub->connected = false; - if (vhost_dev_is_started(&vub->vhost_dev)) { - vub_stop(vdev); - } + vub_stop(vdev); + vhost_dev_cleanup(&vub->vhost_dev); + + /* Re-instate the event handler for new connections */ + qemu_chr_fe_set_handlers(&vub->chardev, + NULL, NULL, vub_event, + NULL, dev, NULL, true); } static void vub_event(void *opaque, QEMUChrEvent event) @@ -230,7 +236,9 @@ static void vub_event(void *opaque, QEMUChrEvent event) } break; case CHR_EVENT_CLOSED: - vub_disconnect(dev); + /* defer close until later to avoid circular close */ + vhost_user_async_close(dev, &vub->chardev, &vub->vhost_dev, + vub_disconnect, vub_event); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: From patchwork Wed Feb 14 11:13:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898825 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HKLhLGaa; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbDr4DTFz23y6 for ; Wed, 14 Feb 2024 22:14:20 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDCy-0008K4-UT; Wed, 14 Feb 2024 06:13:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDCw-0008JZ-OC for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDCj-0006hF-S5 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909209; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CcOxFnO1gTdI8lfHt5M/FhLTBAMA9QOhBRILYrhP/lQ=; b=HKLhLGaaz+LhobMgv4btVM42klsB1VSzKUzbGH0vu9S3RNN8JTli2lF3UWzUV0pg5lsVTI D5gRty1/enbXnWx8oPz1n0QoTZaj5BASnBNKv8AmtX+0N/oWkCJO3RpHNG0sbE2WZgmVDB w8xGW/ElBssYLBh683yz2dihVAmlnYY= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-120-X-7XQUEVPOuFZdiGNTWd8Q-1; Wed, 14 Feb 2024 06:13:27 -0500 X-MC-Unique: X-7XQUEVPOuFZdiGNTWd8Q-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a2bffe437b5so351894766b.1 for ; Wed, 14 Feb 2024 03:13:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909206; x=1708514006; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CcOxFnO1gTdI8lfHt5M/FhLTBAMA9QOhBRILYrhP/lQ=; b=nWPcemMBURaYkVm6sUNL38BVkId6zRS1leAPiW8XL5C9mDe6iF0/QLrZTNf18agDpK /a+82ZJOCZ3uYcjLsk2lPR4kv1aOw7eD/Zr699JfmLSPs0QeRSsuhJeI8ptLY+C5AuA8 Zz3ssSJhHBRKtsJ8Ddgo1Q0nxloBYZr0rCU2pNrsTO6QuWuH10KYXRTcfL+Gt2JhaR3p AeXGx6bCxK/4c7I19XKAhkNEaDDY6pjmRfHO0+EGIV8tjnSEWZxLp7ISnb7Qb06d+lgG FHCnqhKgU0V3SJdmstRJZ6Wfu/fyz30oPqPxCKozIe8bLSF7ZHFQJRGN3xxsGy9chAxn J+0Q== X-Gm-Message-State: AOJu0YzAdICNBxlmiDay0Rc+Wr8riP54402q93asmNtmE/25YmYVghZW A5mj2xqBgh79UpOsgo6GmQqUKsDTqVRiAFGH5oRkAcQplivx2hdNMNYnxaQarBKJp37Tu1PmptX bSMaWXPJG1V7BoNRha1/6m/8jpQBXeDCoUtHD2feATgGvhl9txYH821rDd0j4wf88E4YQBsz8lV L0iR5OXPlhuvOpREchG4HlRH8HvsLuKA== X-Received: by 2002:a17:906:4c57:b0:a3d:60da:19ce with SMTP id d23-20020a1709064c5700b00a3d60da19cemr428424ejw.75.1707909205940; Wed, 14 Feb 2024 03:13:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVhpq3EmVa8QnaTWa95febbUL/B3U2YMeDrCGJzeI63er+QW0tt+1mJfnFwccVcln8SUDk/A== X-Received: by 2002:a17:906:4c57:b0:a3d:60da:19ce with SMTP id d23-20020a1709064c5700b00a3d60da19cemr428403ejw.75.1707909205491; Wed, 14 Feb 2024 03:13:25 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUKednTXTqYBX6vp0+2+i1fOggGiJ20MuxVaijoDSPOg19W2FZL5dq4SFU87/GYTQW/huRVGuGOEE7BmBfUBzEPVvC/yJ0Z/X567ZjV8DXcqzlwAxcRIO6E1EvkTfbINDDUqq8tKajWAnfgiuD7EEebjk0j4DEUWFaz6fXnWms85QY= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id rf23-20020a1709076a1700b00a3d2ccea999sm826407ejc.35.2024.02.14.03.13.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:13:24 -0800 (PST) Date: Wed, 14 Feb 2024 06:13:22 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Mark Cave-Ayland , Mathieu Poirier Subject: [PULL 03/60] hw/virtio: derive vhost-user-rng from vhost-user-base Message-ID: <233412bf7a2b0349aa3b80ab7217e741c8acef3f.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Alex Bennée Now we can take advantage of our new base class and make vhost-user-rng a much simpler boilerplate wrapper. Also as this doesn't require any target specific hacks we only need to build the stubs once. Acked-by: Mark Cave-Ayland Signed-off-by: Alex Bennée Message-Id: <20240104210945.1223134-4-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user-rng.h | 13 +- hw/virtio/vhost-user-rng.c | 294 +++-------------------------- hw/virtio/meson.build | 9 +- 3 files changed, 31 insertions(+), 285 deletions(-) diff --git a/include/hw/virtio/vhost-user-rng.h b/include/hw/virtio/vhost-user-rng.h index ddd9f01eea..10868c7de4 100644 --- a/include/hw/virtio/vhost-user-rng.h +++ b/include/hw/virtio/vhost-user-rng.h @@ -12,22 +12,13 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user.h" -#include "chardev/char-fe.h" +#include "hw/virtio/vhost-user-base.h" #define TYPE_VHOST_USER_RNG "vhost-user-rng" OBJECT_DECLARE_SIMPLE_TYPE(VHostUserRNG, VHOST_USER_RNG) struct VHostUserRNG { - /*< private >*/ - VirtIODevice parent; - CharBackend chardev; - struct vhost_virtqueue *vhost_vq; - struct vhost_dev vhost_dev; - VhostUserState vhost_user; - VirtQueue *req_vq; - bool connected; - - /*< public >*/ + VHostUserBase parent_obj; }; #endif /* QEMU_VHOST_USER_RNG_H */ diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index 24ac1a22c8..01879c863d 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -3,7 +3,7 @@ * * Copyright (c) 2021 Mathieu Poirier * - * Implementation seriously tailored on vhost-user-i2c.c + * Simple wrapper of the generic vhost-user-device. * * SPDX-License-Identifier: GPL-2.0-or-later */ @@ -13,297 +13,47 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/vhost-user-rng.h" -#include "qemu/error-report.h" #include "standard-headers/linux/virtio_ids.h" -static const int feature_bits[] = { - VIRTIO_F_RING_RESET, - VHOST_INVALID_FEATURE_BIT -}; - -static void vu_rng_start(VirtIODevice *vdev) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - int ret; - int i; - - if (!k->set_guest_notifiers) { - error_report("binding does not support guest notifiers"); - return; - } - - ret = vhost_dev_enable_notifiers(&rng->vhost_dev, vdev); - if (ret < 0) { - error_report("Error enabling host notifiers: %d", -ret); - return; - } - - ret = k->set_guest_notifiers(qbus->parent, rng->vhost_dev.nvqs, true); - if (ret < 0) { - error_report("Error binding guest notifier: %d", -ret); - goto err_host_notifiers; - } - - rng->vhost_dev.acked_features = vdev->guest_features; - ret = vhost_dev_start(&rng->vhost_dev, vdev, true); - if (ret < 0) { - error_report("Error starting vhost-user-rng: %d", -ret); - goto err_guest_notifiers; - } - - /* - * guest_notifier_mask/pending not used yet, so just unmask - * everything here. virtio-pci will do the right thing by - * enabling/disabling irqfd. - */ - for (i = 0; i < rng->vhost_dev.nvqs; i++) { - vhost_virtqueue_mask(&rng->vhost_dev, vdev, i, false); - } - - return; - -err_guest_notifiers: - k->set_guest_notifiers(qbus->parent, rng->vhost_dev.nvqs, false); -err_host_notifiers: - vhost_dev_disable_notifiers(&rng->vhost_dev, vdev); -} - -static void vu_rng_stop(VirtIODevice *vdev) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - int ret; - - if (!k->set_guest_notifiers) { - return; - } - - vhost_dev_stop(&rng->vhost_dev, vdev, true); - - ret = k->set_guest_notifiers(qbus->parent, rng->vhost_dev.nvqs, false); - if (ret < 0) { - error_report("vhost guest notifier cleanup failed: %d", ret); - return; - } - - vhost_dev_disable_notifiers(&rng->vhost_dev, vdev); -} - -static void vu_rng_set_status(VirtIODevice *vdev, uint8_t status) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - bool should_start = virtio_device_should_start(vdev, status); - - if (vhost_dev_is_started(&rng->vhost_dev) == should_start) { - return; - } - - if (should_start) { - vu_rng_start(vdev); - } else { - vu_rng_stop(vdev); - } -} - -static uint64_t vu_rng_get_features(VirtIODevice *vdev, - uint64_t requested_features, Error **errp) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - - return vhost_get_features(&rng->vhost_dev, feature_bits, - requested_features); -} - -static void vu_rng_handle_output(VirtIODevice *vdev, VirtQueue *vq) -{ - /* - * Not normally called; it's the daemon that handles the queue; - * however virtio's cleanup path can call this. - */ -} - -static void vu_rng_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - - /* - * We don't support interrupts, return early if index is set to - * VIRTIO_CONFIG_IRQ_IDX. - */ - if (idx == VIRTIO_CONFIG_IRQ_IDX) { - return; - } - - vhost_virtqueue_mask(&rng->vhost_dev, vdev, idx, mask); -} - -static bool vu_rng_guest_notifier_pending(VirtIODevice *vdev, int idx) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - - /* - * We don't support interrupts, return early if index is set to - * VIRTIO_CONFIG_IRQ_IDX. - */ - if (idx == VIRTIO_CONFIG_IRQ_IDX) { - return false; - } - - return vhost_virtqueue_pending(&rng->vhost_dev, idx); -} - -static void vu_rng_connect(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - - if (rng->connected) { - return; - } - - rng->connected = true; - - /* restore vhost state */ - if (virtio_device_started(vdev, vdev->status)) { - vu_rng_start(vdev); - } -} - -static void vu_rng_disconnect(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - - if (!rng->connected) { - return; - } - - rng->connected = false; - - if (vhost_dev_is_started(&rng->vhost_dev)) { - vu_rng_stop(vdev); - } -} - -static void vu_rng_event(void *opaque, QEMUChrEvent event) -{ - DeviceState *dev = opaque; - - switch (event) { - case CHR_EVENT_OPENED: - vu_rng_connect(dev); - break; - case CHR_EVENT_CLOSED: - vu_rng_disconnect(dev); - break; - case CHR_EVENT_BREAK: - case CHR_EVENT_MUX_IN: - case CHR_EVENT_MUX_OUT: - /* Ignore */ - break; - } -} - -static void vu_rng_device_realize(DeviceState *dev, Error **errp) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserRNG *rng = VHOST_USER_RNG(dev); - int ret; - - if (!rng->chardev.chr) { - error_setg(errp, "missing chardev"); - return; - } - - if (!vhost_user_init(&rng->vhost_user, &rng->chardev, errp)) { - return; - } - - virtio_init(vdev, VIRTIO_ID_RNG, 0); - - rng->req_vq = virtio_add_queue(vdev, 4, vu_rng_handle_output); - if (!rng->req_vq) { - error_setg_errno(errp, -1, "virtio_add_queue() failed"); - goto virtio_add_queue_failed; - } - - rng->vhost_dev.nvqs = 1; - rng->vhost_dev.vqs = g_new0(struct vhost_virtqueue, rng->vhost_dev.nvqs); - ret = vhost_dev_init(&rng->vhost_dev, &rng->vhost_user, - VHOST_BACKEND_TYPE_USER, 0, errp); - if (ret < 0) { - error_setg_errno(errp, -ret, "vhost_dev_init() failed"); - goto vhost_dev_init_failed; - } - - qemu_chr_fe_set_handlers(&rng->chardev, NULL, NULL, vu_rng_event, NULL, - dev, NULL, true); - - return; - -vhost_dev_init_failed: - g_free(rng->vhost_dev.vqs); - virtio_delete_queue(rng->req_vq); -virtio_add_queue_failed: - virtio_cleanup(vdev); - vhost_user_cleanup(&rng->vhost_user); -} - -static void vu_rng_device_unrealize(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserRNG *rng = VHOST_USER_RNG(dev); - struct vhost_virtqueue *vhost_vqs = rng->vhost_dev.vqs; - - vu_rng_set_status(vdev, 0); - - vhost_dev_cleanup(&rng->vhost_dev); - g_free(vhost_vqs); - virtio_delete_queue(rng->req_vq); - virtio_cleanup(vdev); - vhost_user_cleanup(&rng->vhost_user); -} - -static struct vhost_dev *vu_rng_get_vhost(VirtIODevice *vdev) -{ - VHostUserRNG *rng = VHOST_USER_RNG(vdev); - return &rng->vhost_dev; -} - static const VMStateDescription vu_rng_vmstate = { .name = "vhost-user-rng", .unmigratable = 1, }; -static Property vu_rng_properties[] = { - DEFINE_PROP_CHR("chardev", VHostUserRNG, chardev), +static Property vrng_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), DEFINE_PROP_END_OF_LIST(), }; +static void vu_rng_base_realize(DeviceState *dev, Error **errp) +{ + VHostUserBase *vub = VHOST_USER_BASE(dev); + VHostUserBaseClass *vubs = VHOST_USER_BASE_GET_CLASS(dev); + + /* Fixed for RNG */ + vub->virtio_id = VIRTIO_ID_RNG; + vub->num_vqs = 1; + vub->vq_size = 4; + + vubs->parent_realize(dev, errp); +} + static void vu_rng_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass); - device_class_set_props(dc, vu_rng_properties); dc->vmsd = &vu_rng_vmstate; - set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + device_class_set_props(dc, vrng_properties); + device_class_set_parent_realize(dc, vu_rng_base_realize, + &vubc->parent_realize); - vdc->realize = vu_rng_device_realize; - vdc->unrealize = vu_rng_device_unrealize; - vdc->get_features = vu_rng_get_features; - vdc->set_status = vu_rng_set_status; - vdc->guest_notifier_mask = vu_rng_guest_notifier_mask; - vdc->guest_notifier_pending = vu_rng_guest_notifier_pending; - vdc->get_vhost = vu_rng_get_vhost; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } static const TypeInfo vu_rng_info = { .name = TYPE_VHOST_USER_RNG, - .parent = TYPE_VIRTIO_DEVICE, + .parent = TYPE_VHOST_USER_BASE, .instance_size = sizeof(VHostUserRNG), .class_init = vu_rng_class_init, }; diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 3ccddbe950..4f85e7a9ed 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -18,8 +18,15 @@ if have_vhost # fixme - this really should be generic specific_virtio_ss.add(files('vhost-user.c')) system_virtio_ss.add(files('vhost-user-base.c')) + + # MMIO Stubs system_virtio_ss.add(files('vhost-user-device.c')) + system_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) + + # PCI Stubs system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c')) + system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_RNG'], + if_true: files('vhost-user-rng-pci.c')) endif if have_vhost_vdpa system_virtio_ss.add(files('vhost-vdpa.c')) @@ -37,7 +44,6 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-us specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c')) specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c')) @@ -49,7 +55,6 @@ virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vs virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-user-input-pci.c')) -virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs-pci.c')) From patchwork Wed Feb 14 11:13:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OPoWpyF9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbL30XRQz23y6 for ; Wed, 14 Feb 2024 22:18:51 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDC-0008Tw-Td; Wed, 14 Feb 2024 06:13:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDD8-0008SU-KF for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDD6-0006kD-55 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZUXleUiq/WGOXyNYhhBaak/nwlB70apCKO5OgH1Fi9w=; b=OPoWpyF9eAWfXnNxRIV3dePufkH4ilgTSFM5mp29MdCfOjqYcVysTwg/BXoBfSDkQwYqC+ N27rAT9lTcepAaIx87kLfAU8alI+4t1iF9Zov6HES3hoA4G32oGn3fUVEO094F9GMvR4l0 5zHv4NFs/d1FqWV34itfEIxBTLweelI= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-185-BdCbYJvhPgGvSbHNMaV1vw-1; Wed, 14 Feb 2024 06:13:50 -0500 X-MC-Unique: BdCbYJvhPgGvSbHNMaV1vw-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a27eddc1c27so115405866b.3 for ; Wed, 14 Feb 2024 03:13:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909209; x=1708514009; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZUXleUiq/WGOXyNYhhBaak/nwlB70apCKO5OgH1Fi9w=; b=O+dCWNSEWM6JzrJ4QhMMa9pjfeqLLSNqgic0M3czj3pjZct2o88SSJDo+S2Ft9EYT1 8QI/eNGFxQdqR4Ln649w/BDv5NHpJwh3dADtIeaKp1aTNdVK/Gmtk2XZ6nwaXcue2tEb IVSSF13E91Lv1eEbZUXp1B93xlSYP8spv2ZtGmngCjrMquoecQgfVsUHygz7ugncf93U fZpskuzD5PA58HbCZxqr/AhPkCTXWK8RhzUVpKA21BqTadYtUdHD3FaC8YrjGfB5vwct RXBiT7hzye24RlM6wRTXE8gkaPTqya2jcHZbYJVY+iFp+Wuy0v11oWdSFLgTXB5GlZkU 9OuA== X-Gm-Message-State: AOJu0YzlrOawm2rt8eGbXhj3aCGuCkUcuQPVeCy+LWQx0auG87liHZth ItXySsKrXQYxegHy/wlGYj9bdWvP8QLh45/9E3zTiwsUcUkVH07OrITYo5kRHgCW8vyYPcC1MT5 p0xEiucXuyRVMnc3amhCpTwKa2l3xmQWye2TTckSUEPBQ5W/1WfvNnBHpHw9H97lxHWhQeOXgGe sC0D5KUEAageHTST9m8egxRzWMRlrthQ== X-Received: by 2002:a17:906:fb9b:b0:a3c:f7f3:5eed with SMTP id lr27-20020a170906fb9b00b00a3cf7f35eedmr1478431ejb.69.1707909208901; Wed, 14 Feb 2024 03:13:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEI2suI0sHhYqum81l8miCwPOUZfKLIHHryCWfGhxq5akmmt8j5UF+K2QiU9P6PkV9U7UXUIg== X-Received: by 2002:a17:906:fb9b:b0:a3c:f7f3:5eed with SMTP id lr27-20020a170906fb9b00b00a3cf7f35eedmr1478401ejb.69.1707909208417; Wed, 14 Feb 2024 03:13:28 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUJrDz+Uvjzk+XrpwQ4VZ/PiPNlPhRphovnvz3BNKrZdjeWJMpKV4ZHTgvLl/htu5yfSD+n2p9EluPODt9eekGLMzknigKKt/Q93eAa2KTrN2kDwLptWoS3+QMoqsoOorgZEjgkDVgJEPz5g21tLWOx37iKx6fdGaJXNA5JukU= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id s7-20020a17090699c700b00a3cb136aef0sm2201911ejn.224.2024.02.14.03.13.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:13:27 -0800 (PST) Date: Wed, 14 Feb 2024 06:13:25 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Mark Cave-Ayland , Viresh Kumar Subject: [PULL 04/60] hw/virtio: derive vhost-user-gpio from vhost-user-base Message-ID: <5ba587580db55bd310dc64d0eb89b4f7b19c6404.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Alex Bennée Now the new base class supports config handling we can take advantage and make vhost-user-gpio a much simpler boilerplate wrapper. Also as this doesn't require any target specific hacks we only need to build the stubs once. Acked-by: Mark Cave-Ayland Acked-by: Viresh Kumar Signed-off-by: Alex Bennée Message-Id: <20240104210945.1223134-5-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user-gpio.h | 25 +- hw/virtio/vhost-user-gpio.c | 407 ++-------------------------- hw/virtio/meson.build | 5 +- 3 files changed, 22 insertions(+), 415 deletions(-) diff --git a/include/hw/virtio/vhost-user-gpio.h b/include/hw/virtio/vhost-user-gpio.h index a9d3f9b049..5814a8400a 100644 --- a/include/hw/virtio/vhost-user-gpio.h +++ b/include/hw/virtio/vhost-user-gpio.h @@ -12,34 +12,13 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user.h" -#include "standard-headers/linux/virtio_gpio.h" -#include "chardev/char-fe.h" +#include "hw/virtio/vhost-user-base.h" #define TYPE_VHOST_USER_GPIO "vhost-user-gpio-device" OBJECT_DECLARE_SIMPLE_TYPE(VHostUserGPIO, VHOST_USER_GPIO); struct VHostUserGPIO { - /*< private >*/ - VirtIODevice parent_obj; - CharBackend chardev; - struct virtio_gpio_config config; - struct vhost_virtqueue *vhost_vqs; - struct vhost_dev vhost_dev; - VhostUserState vhost_user; - VirtQueue *command_vq; - VirtQueue *interrupt_vq; - /** - * There are at least two steps of initialization of the - * vhost-user device. The first is a "connect" step and - * second is a "start" step. Make a separation between - * those initialization phases by using two fields. - * - * @connected: see vu_gpio_connect()/vu_gpio_disconnect() - * @started_vu: see vu_gpio_start()/vu_gpio_stop() - */ - bool connected; - bool started_vu; - /*< public >*/ + VHostUserBase parent_obj; }; #endif /* _QEMU_VHOST_USER_GPIO_H */ diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index a83437a5da..9f37c25415 100644 --- a/hw/virtio/vhost-user-gpio.c +++ b/hw/virtio/vhost-user-gpio.c @@ -11,388 +11,25 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/vhost-user-gpio.h" -#include "qemu/error-report.h" #include "standard-headers/linux/virtio_ids.h" -#include "trace.h" +#include "standard-headers/linux/virtio_gpio.h" -#define VHOST_NVQS 2 - -/* Features required from VirtIO */ -static const int feature_bits[] = { - VIRTIO_F_VERSION_1, - VIRTIO_F_NOTIFY_ON_EMPTY, - VIRTIO_RING_F_INDIRECT_DESC, - VIRTIO_RING_F_EVENT_IDX, - VIRTIO_GPIO_F_IRQ, - VIRTIO_F_RING_RESET, - VHOST_INVALID_FEATURE_BIT +static Property vgpio_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), + DEFINE_PROP_END_OF_LIST(), }; -static void vu_gpio_get_config(VirtIODevice *vdev, uint8_t *config) +static void vgpio_realize(DeviceState *dev, Error **errp) { - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); + VHostUserBase *vub = VHOST_USER_BASE(dev); + VHostUserBaseClass *vubc = VHOST_USER_BASE_GET_CLASS(dev); - memcpy(config, &gpio->config, sizeof(gpio->config)); -} + /* Fixed for GPIO */ + vub->virtio_id = VIRTIO_ID_GPIO; + vub->num_vqs = 2; + vub->config_size = sizeof(struct virtio_gpio_config); -static int vu_gpio_config_notifier(struct vhost_dev *dev) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(dev->vdev); - - memcpy(dev->vdev->config, &gpio->config, sizeof(gpio->config)); - virtio_notify_config(dev->vdev); - - return 0; -} - -const VhostDevConfigOps gpio_ops = { - .vhost_dev_config_notifier = vu_gpio_config_notifier, -}; - -static int vu_gpio_start(VirtIODevice *vdev) -{ - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - struct vhost_dev *vhost_dev = &gpio->vhost_dev; - int ret, i; - - if (!k->set_guest_notifiers) { - error_report("binding does not support guest notifiers"); - return -ENOSYS; - } - - ret = vhost_dev_enable_notifiers(vhost_dev, vdev); - if (ret < 0) { - error_report("Error enabling host notifiers: %d", ret); - return ret; - } - - ret = k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, true); - if (ret < 0) { - error_report("Error binding guest notifier: %d", ret); - goto err_host_notifiers; - } - - /* - * Before we start up we need to ensure we have the final feature - * set needed for the vhost configuration. The backend may also - * apply backend_features when the feature set is sent. - */ - vhost_ack_features(&gpio->vhost_dev, feature_bits, vdev->guest_features); - - ret = vhost_dev_start(&gpio->vhost_dev, vdev, false); - if (ret < 0) { - error_report("Error starting vhost-user-gpio: %d", ret); - goto err_guest_notifiers; - } - gpio->started_vu = true; - - /* - * guest_notifier_mask/pending not used yet, so just unmask - * everything here. virtio-pci will do the right thing by - * enabling/disabling irqfd. - */ - for (i = 0; i < gpio->vhost_dev.nvqs; i++) { - vhost_virtqueue_mask(&gpio->vhost_dev, vdev, i, false); - } - - /* - * As we must have VHOST_USER_F_PROTOCOL_FEATURES (because - * VHOST_USER_GET_CONFIG requires it) we need to explicitly enable - * the vrings. - */ - g_assert(vhost_dev->vhost_ops && - vhost_dev->vhost_ops->vhost_set_vring_enable); - ret = vhost_dev->vhost_ops->vhost_set_vring_enable(vhost_dev, true); - if (ret == 0) { - return 0; - } - - error_report("Failed to start vrings for vhost-user-gpio: %d", ret); - -err_guest_notifiers: - k->set_guest_notifiers(qbus->parent, gpio->vhost_dev.nvqs, false); -err_host_notifiers: - vhost_dev_disable_notifiers(&gpio->vhost_dev, vdev); - - return ret; -} - -static void vu_gpio_stop(VirtIODevice *vdev) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - struct vhost_dev *vhost_dev = &gpio->vhost_dev; - int ret; - - if (!gpio->started_vu) { - return; - } - gpio->started_vu = false; - - if (!k->set_guest_notifiers) { - return; - } - - vhost_dev_stop(vhost_dev, vdev, false); - - ret = k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, false); - if (ret < 0) { - error_report("vhost guest notifier cleanup failed: %d", ret); - return; - } - - vhost_dev_disable_notifiers(vhost_dev, vdev); -} - -static void vu_gpio_set_status(VirtIODevice *vdev, uint8_t status) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - bool should_start = virtio_device_should_start(vdev, status); - - trace_virtio_gpio_set_status(status); - - if (!gpio->connected) { - return; - } - - if (vhost_dev_is_started(&gpio->vhost_dev) == should_start) { - return; - } - - if (should_start) { - if (vu_gpio_start(vdev)) { - qemu_chr_fe_disconnect(&gpio->chardev); - } - } else { - vu_gpio_stop(vdev); - } -} - -static uint64_t vu_gpio_get_features(VirtIODevice *vdev, uint64_t features, - Error **errp) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - - return vhost_get_features(&gpio->vhost_dev, feature_bits, features); -} - -static void vu_gpio_handle_output(VirtIODevice *vdev, VirtQueue *vq) -{ - /* - * Not normally called; it's the daemon that handles the queue; - * however virtio's cleanup path can call this. - */ -} - -static void vu_gpio_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - - /* - * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the macro of configure interrupt's IDX, If this driver does not - * support, the function will return - */ - - if (idx == VIRTIO_CONFIG_IRQ_IDX) { - return; - } - - vhost_virtqueue_mask(&gpio->vhost_dev, vdev, idx, mask); -} - -static struct vhost_dev *vu_gpio_get_vhost(VirtIODevice *vdev) -{ - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - return &gpio->vhost_dev; -} - -static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserGPIO *gpio) -{ - virtio_delete_queue(gpio->command_vq); - virtio_delete_queue(gpio->interrupt_vq); - g_free(gpio->vhost_vqs); - virtio_cleanup(vdev); - vhost_user_cleanup(&gpio->vhost_user); -} - -static int vu_gpio_connect(DeviceState *dev, Error **errp) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - struct vhost_dev *vhost_dev = &gpio->vhost_dev; - int ret; - - if (gpio->connected) { - return 0; - } - - vhost_dev_set_config_notifier(vhost_dev, &gpio_ops); - gpio->vhost_user.supports_config = true; - - gpio->vhost_dev.nvqs = VHOST_NVQS; - gpio->vhost_dev.vqs = gpio->vhost_vqs; - - ret = vhost_dev_init(vhost_dev, &gpio->vhost_user, - VHOST_BACKEND_TYPE_USER, 0, errp); - if (ret < 0) { - return ret; - } - - gpio->connected = true; - - /* restore vhost state */ - if (virtio_device_started(vdev, vdev->status)) { - vu_gpio_start(vdev); - } - - return 0; -} - -static void vu_gpio_event(void *opaque, QEMUChrEvent event); - -static void vu_gpio_disconnect(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - - if (!gpio->connected) { - return; - } - gpio->connected = false; - - vu_gpio_stop(vdev); - vhost_dev_cleanup(&gpio->vhost_dev); - - /* Re-instate the event handler for new connections */ - qemu_chr_fe_set_handlers(&gpio->chardev, - NULL, NULL, vu_gpio_event, - NULL, dev, NULL, true); -} - -static void vu_gpio_event(void *opaque, QEMUChrEvent event) -{ - DeviceState *dev = opaque; - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(vdev); - Error *local_err = NULL; - - switch (event) { - case CHR_EVENT_OPENED: - if (vu_gpio_connect(dev, &local_err) < 0) { - qemu_chr_fe_disconnect(&gpio->chardev); - return; - } - break; - case CHR_EVENT_CLOSED: - /* defer close until later to avoid circular close */ - vhost_user_async_close(dev, &gpio->chardev, &gpio->vhost_dev, - vu_gpio_disconnect, vu_gpio_event); - break; - case CHR_EVENT_BREAK: - case CHR_EVENT_MUX_IN: - case CHR_EVENT_MUX_OUT: - /* Ignore */ - break; - } -} - -static int vu_gpio_realize_connect(VHostUserGPIO *gpio, Error **errp) -{ - VirtIODevice *vdev = &gpio->parent_obj; - DeviceState *dev = &vdev->parent_obj; - struct vhost_dev *vhost_dev = &gpio->vhost_dev; - int ret; - - ret = qemu_chr_fe_wait_connected(&gpio->chardev, errp); - if (ret < 0) { - return ret; - } - - /* - * vu_gpio_connect() may have already connected (via the event - * callback) in which case it will just report success. - */ - ret = vu_gpio_connect(dev, errp); - if (ret < 0) { - qemu_chr_fe_disconnect(&gpio->chardev); - return ret; - } - g_assert(gpio->connected); - - ret = vhost_dev_get_config(vhost_dev, (uint8_t *)&gpio->config, - sizeof(gpio->config), errp); - - if (ret < 0) { - error_report("vhost-user-gpio: get config failed"); - - qemu_chr_fe_disconnect(&gpio->chardev); - vhost_dev_cleanup(vhost_dev); - return ret; - } - - return 0; -} - -static void vu_gpio_device_realize(DeviceState *dev, Error **errp) -{ - ERRP_GUARD(); - - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(dev); - int retries, ret; - - if (!gpio->chardev.chr) { - error_setg(errp, "vhost-user-gpio: chardev is mandatory"); - return; - } - - if (!vhost_user_init(&gpio->vhost_user, &gpio->chardev, errp)) { - return; - } - - virtio_init(vdev, VIRTIO_ID_GPIO, sizeof(gpio->config)); - - gpio->command_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output); - gpio->interrupt_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output); - gpio->vhost_vqs = g_new0(struct vhost_virtqueue, VHOST_NVQS); - - gpio->connected = false; - - qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, vu_gpio_event, NULL, - dev, NULL, true); - - retries = VU_REALIZE_CONN_RETRIES; - g_assert(!*errp); - do { - if (*errp) { - error_prepend(errp, "Reconnecting after error: "); - error_report_err(*errp); - *errp = NULL; - } - ret = vu_gpio_realize_connect(gpio, errp); - } while (ret < 0 && retries--); - - if (ret < 0) { - do_vhost_user_cleanup(vdev, gpio); - } - - return; -} - -static void vu_gpio_device_unrealize(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserGPIO *gpio = VHOST_USER_GPIO(dev); - - vu_gpio_set_status(vdev, 0); - qemu_chr_fe_set_handlers(&gpio->chardev, NULL, NULL, NULL, NULL, NULL, NULL, - false); - vhost_dev_cleanup(&gpio->vhost_dev); - do_vhost_user_cleanup(vdev, gpio); + vubc->parent_realize(dev, errp); } static const VMStateDescription vu_gpio_vmstate = { @@ -400,31 +37,21 @@ static const VMStateDescription vu_gpio_vmstate = { .unmigratable = 1, }; -static Property vu_gpio_properties[] = { - DEFINE_PROP_CHR("chardev", VHostUserGPIO, chardev), - DEFINE_PROP_END_OF_LIST(), -}; - static void vu_gpio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass); - device_class_set_props(dc, vu_gpio_properties); dc->vmsd = &vu_gpio_vmstate; + device_class_set_props(dc, vgpio_properties); + device_class_set_parent_realize(dc, vgpio_realize, + &vubc->parent_realize); set_bit(DEVICE_CATEGORY_INPUT, dc->categories); - vdc->realize = vu_gpio_device_realize; - vdc->unrealize = vu_gpio_device_unrealize; - vdc->get_features = vu_gpio_get_features; - vdc->get_config = vu_gpio_get_config; - vdc->set_status = vu_gpio_set_status; - vdc->guest_notifier_mask = vu_gpio_guest_notifier_mask; - vdc->get_vhost = vu_gpio_get_vhost; } static const TypeInfo vu_gpio_info = { .name = TYPE_VHOST_USER_GPIO, - .parent = TYPE_VIRTIO_DEVICE, + .parent = TYPE_VHOST_USER_BASE, .instance_size = sizeof(VHostUserGPIO), .class_init = vu_gpio_class_init, }; diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 4f85e7a9ed..374a616580 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -21,10 +21,13 @@ if have_vhost # MMIO Stubs system_virtio_ss.add(files('vhost-user-device.c')) + system_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) system_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) # PCI Stubs system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c')) + system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], + if_true: files('vhost-user-gpio-pci.c')) system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_RNG'], if_true: files('vhost-user-rng-pci.c')) endif @@ -44,8 +47,6 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-us specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c')) specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) -specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c')) specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SCMI'], if_true: files('vhost-user-scmi-pci.c')) From patchwork Wed Feb 14 11:13:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898838 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CChmhEHq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbJb1yN5z23hM for ; Wed, 14 Feb 2024 22:17:35 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDA-0008TJ-EL; Wed, 14 Feb 2024 06:13:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDD4-0008OA-Pj for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDCr-0006i0-BG for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909215; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PQq5kt6qO5rSOzwxbrrE90Nw3Hr+bwKtvbvTXLpuWM4=; b=CChmhEHqPHIqOw6c9uUlw/P+9kNLQxvYp/Jz9gDZj1v+GujqWKauP2MROTkcpJLLHP1kol Iflqb+DItaBw3TtvF5kScBy/az2DULCzlrkxDDvZSzrCi2PB0t/bS3/b3rnyTJuJvoVSrV Ug6/PC4kve/o8jzL1puxyqr1+eyZAxk= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-Sq42I2tNMb68Kdf-BEln5g-1; Wed, 14 Feb 2024 06:13:33 -0500 X-MC-Unique: Sq42I2tNMb68Kdf-BEln5g-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5597da35ebbso3828770a12.2 for ; Wed, 14 Feb 2024 03:13:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909212; x=1708514012; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PQq5kt6qO5rSOzwxbrrE90Nw3Hr+bwKtvbvTXLpuWM4=; b=nXmHF+I7e90mRaMtgEJQB3T4aFuNS1exsSHHe+KXiHo6s5v0oEaVW5s6h8ZQGAvosY POqC6mTWkZdTR6sKNu7L/zbFqBcKvo4gxQq3KVynt3Edev/GEjDJoRWN1511mb13HFJ+ JE5c9oz3PtY/EXbUDEUQ7UmhUS4IK6my4lo4UZkxHt3qVK8sdSbblf/ikVPbtt2d8qlZ HLhmCooSjlFYuVpqokeIc10JJksw4r/yj9jiMnKCoFYOVXJ8Qf8PQaGr4p4LTHuK9mhf HP5So0zMS/35lCHWWoLpQeVzSxAuP8A9ZMOilm4PXjiyztIsIG8MNykV+GMI+G6rDsZs YJGA== X-Gm-Message-State: AOJu0YzvdaQ/R8aWz/fbRqXvr0Q1vAgPIPY+UZMoCtgSpCG/FuKBZPga 4qATISPDZxwPiXI/AC1jNRCPokszdCTqd56G9fnC+U7xrqaSAyQIFlKHUzaXkNS9UD9GdebEjBU 19NSJH+0A9CN5ZoB7uTeihZmMMqH5G8Rbo2YcuqtQrhPcD6O9nZrgKxeWIDhwlLGj9i9GDljMTR ma+PmMsa4dAUG4a4CzzP5FZcHi5Y1HaA== X-Received: by 2002:aa7:d590:0:b0:560:c0da:43be with SMTP id r16-20020aa7d590000000b00560c0da43bemr1720923edq.11.1707909212179; Wed, 14 Feb 2024 03:13:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IG91hrf02Cmex6fUWr5U67mkPXMPYrGinhum8zrvrYN2KHbjcBlRiXPlRq7/jSlovjaMRpJEA== X-Received: by 2002:aa7:d590:0:b0:560:c0da:43be with SMTP id r16-20020aa7d590000000b00560c0da43bemr1720902edq.11.1707909211807; Wed, 14 Feb 2024 03:13:31 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUJaSCJ1CL+x8opzsej5NFgdGvqvdsw2Ph7P2nnzxh+EpLmSXpLGVsWHR4/jiE3lqJHMmoeJP5j4SB/5RKD/sUE5iWf0ZZKX1pI2CwMMbrp2bdLGW7i4RwZD0dvo6c47NaCCwrPeqMub6FdI3z90e/zWLSDjp+LkG/UDGJl1VQ= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id fe9-20020a056402390900b00561ffe7adb2sm1226455edb.1.2024.02.14.03.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:13:30 -0800 (PST) Date: Wed, 14 Feb 2024 06:13:28 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Mark Cave-Ayland , Viresh Kumar Subject: [PULL 05/60] hw/virtio: derive vhost-user-i2c from vhost-user-base Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Alex Bennée Now we can take advantage of the new base class and make vhost-user-i2c a much simpler boilerplate wrapper. Also as this doesn't require any target specific hacks we only need to build the stubs once. Acked-by: Mark Cave-Ayland Acked-by: Viresh Kumar Signed-off-by: Alex Bennée Message-Id: <20240104210945.1223134-6-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user-i2c.h | 14 +- hw/virtio/vhost-user-i2c.c | 272 ++--------------------------- hw/virtio/meson.build | 5 +- 3 files changed, 23 insertions(+), 268 deletions(-) diff --git a/include/hw/virtio/vhost-user-i2c.h b/include/hw/virtio/vhost-user-i2c.h index 0f7acd40e3..a9b5612ad0 100644 --- a/include/hw/virtio/vhost-user-i2c.h +++ b/include/hw/virtio/vhost-user-i2c.h @@ -9,23 +9,17 @@ #ifndef QEMU_VHOST_USER_I2C_H #define QEMU_VHOST_USER_I2C_H +#include "hw/virtio/virtio.h" #include "hw/virtio/vhost.h" #include "hw/virtio/vhost-user.h" +#include "hw/virtio/vhost-user-base.h" #define TYPE_VHOST_USER_I2C "vhost-user-i2c-device" + OBJECT_DECLARE_SIMPLE_TYPE(VHostUserI2C, VHOST_USER_I2C) struct VHostUserI2C { - VirtIODevice parent; - CharBackend chardev; - struct vhost_virtqueue *vhost_vq; - struct vhost_dev vhost_dev; - VhostUserState vhost_user; - VirtQueue *vq; - bool connected; + VHostUserBase parent_obj; }; -/* Virtio Feature bits */ -#define VIRTIO_I2C_F_ZERO_LENGTH_REQUEST 0 - #endif /* QEMU_VHOST_USER_I2C_H */ diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c index 4eef3f0633..a464f5e039 100644 --- a/hw/virtio/vhost-user-i2c.c +++ b/hw/virtio/vhost-user-i2c.c @@ -14,253 +14,22 @@ #include "qemu/error-report.h" #include "standard-headers/linux/virtio_ids.h" -static const int feature_bits[] = { - VIRTIO_I2C_F_ZERO_LENGTH_REQUEST, - VIRTIO_F_RING_RESET, - VHOST_INVALID_FEATURE_BIT +static Property vi2c_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), + DEFINE_PROP_END_OF_LIST(), }; -static void vu_i2c_start(VirtIODevice *vdev) +static void vi2c_realize(DeviceState *dev, Error **errp) { - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - int ret, i; + VHostUserBase *vub = VHOST_USER_BASE(dev); + VHostUserBaseClass *vubc = VHOST_USER_BASE_GET_CLASS(dev); - if (!k->set_guest_notifiers) { - error_report("binding does not support guest notifiers"); - return; - } + /* Fixed for I2C */ + vub->virtio_id = VIRTIO_ID_I2C_ADAPTER; + vub->num_vqs = 1; + vub->vq_size = 4; - ret = vhost_dev_enable_notifiers(&i2c->vhost_dev, vdev); - if (ret < 0) { - error_report("Error enabling host notifiers: %d", -ret); - return; - } - - ret = k->set_guest_notifiers(qbus->parent, i2c->vhost_dev.nvqs, true); - if (ret < 0) { - error_report("Error binding guest notifier: %d", -ret); - goto err_host_notifiers; - } - - i2c->vhost_dev.acked_features = vdev->guest_features; - - ret = vhost_dev_start(&i2c->vhost_dev, vdev, true); - if (ret < 0) { - error_report("Error starting vhost-user-i2c: %d", -ret); - goto err_guest_notifiers; - } - - /* - * guest_notifier_mask/pending not used yet, so just unmask - * everything here. virtio-pci will do the right thing by - * enabling/disabling irqfd. - */ - for (i = 0; i < i2c->vhost_dev.nvqs; i++) { - vhost_virtqueue_mask(&i2c->vhost_dev, vdev, i, false); - } - - return; - -err_guest_notifiers: - k->set_guest_notifiers(qbus->parent, i2c->vhost_dev.nvqs, false); -err_host_notifiers: - vhost_dev_disable_notifiers(&i2c->vhost_dev, vdev); -} - -static void vu_i2c_stop(VirtIODevice *vdev) -{ - VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); - int ret; - - if (!k->set_guest_notifiers) { - return; - } - - vhost_dev_stop(&i2c->vhost_dev, vdev, true); - - ret = k->set_guest_notifiers(qbus->parent, i2c->vhost_dev.nvqs, false); - if (ret < 0) { - error_report("vhost guest notifier cleanup failed: %d", ret); - return; - } - - vhost_dev_disable_notifiers(&i2c->vhost_dev, vdev); -} - -static void vu_i2c_set_status(VirtIODevice *vdev, uint8_t status) -{ - VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - bool should_start = virtio_device_should_start(vdev, status); - - if (vhost_dev_is_started(&i2c->vhost_dev) == should_start) { - return; - } - - if (should_start) { - vu_i2c_start(vdev); - } else { - vu_i2c_stop(vdev); - } -} - -static uint64_t vu_i2c_get_features(VirtIODevice *vdev, - uint64_t requested_features, Error **errp) -{ - VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - - virtio_add_feature(&requested_features, VIRTIO_I2C_F_ZERO_LENGTH_REQUEST); - return vhost_get_features(&i2c->vhost_dev, feature_bits, requested_features); -} - -static void vu_i2c_handle_output(VirtIODevice *vdev, VirtQueue *vq) -{ - /* - * Not normally called; it's the daemon that handles the queue; - * however virtio's cleanup path can call this. - */ -} - -static void vu_i2c_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) -{ - VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - - /* - * We don't support interrupts, return early if index is set to - * VIRTIO_CONFIG_IRQ_IDX. - */ - if (idx == VIRTIO_CONFIG_IRQ_IDX) { - return; - } - - vhost_virtqueue_mask(&i2c->vhost_dev, vdev, idx, mask); -} - -static bool vu_i2c_guest_notifier_pending(VirtIODevice *vdev, int idx) -{ - VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - - /* - * We don't support interrupts, return early if index is set to - * VIRTIO_CONFIG_IRQ_IDX. - */ - if (idx == VIRTIO_CONFIG_IRQ_IDX) { - return false; - } - - return vhost_virtqueue_pending(&i2c->vhost_dev, idx); -} - -static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserI2C *i2c) -{ - vhost_user_cleanup(&i2c->vhost_user); - virtio_delete_queue(i2c->vq); - virtio_cleanup(vdev); -} - -static int vu_i2c_connect(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - - if (i2c->connected) { - return 0; - } - i2c->connected = true; - - /* restore vhost state */ - if (virtio_device_started(vdev, vdev->status)) { - vu_i2c_start(vdev); - } - - return 0; -} - -static void vu_i2c_disconnect(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - - if (!i2c->connected) { - return; - } - i2c->connected = false; - - if (vhost_dev_is_started(&i2c->vhost_dev)) { - vu_i2c_stop(vdev); - } -} - -static void vu_i2c_event(void *opaque, QEMUChrEvent event) -{ - DeviceState *dev = opaque; - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserI2C *i2c = VHOST_USER_I2C(vdev); - - switch (event) { - case CHR_EVENT_OPENED: - if (vu_i2c_connect(dev) < 0) { - qemu_chr_fe_disconnect(&i2c->chardev); - return; - } - break; - case CHR_EVENT_CLOSED: - vu_i2c_disconnect(dev); - break; - case CHR_EVENT_BREAK: - case CHR_EVENT_MUX_IN: - case CHR_EVENT_MUX_OUT: - /* Ignore */ - break; - } -} - -static void vu_i2c_device_realize(DeviceState *dev, Error **errp) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserI2C *i2c = VHOST_USER_I2C(dev); - int ret; - - if (!i2c->chardev.chr) { - error_setg(errp, "vhost-user-i2c: missing chardev"); - return; - } - - if (!vhost_user_init(&i2c->vhost_user, &i2c->chardev, errp)) { - return; - } - - virtio_init(vdev, VIRTIO_ID_I2C_ADAPTER, 0); - - i2c->vhost_dev.nvqs = 1; - i2c->vq = virtio_add_queue(vdev, 4, vu_i2c_handle_output); - i2c->vhost_dev.vqs = g_new0(struct vhost_virtqueue, i2c->vhost_dev.nvqs); - - ret = vhost_dev_init(&i2c->vhost_dev, &i2c->vhost_user, - VHOST_BACKEND_TYPE_USER, 0, errp); - if (ret < 0) { - g_free(i2c->vhost_dev.vqs); - do_vhost_user_cleanup(vdev, i2c); - } - - qemu_chr_fe_set_handlers(&i2c->chardev, NULL, NULL, vu_i2c_event, NULL, - dev, NULL, true); -} - -static void vu_i2c_device_unrealize(DeviceState *dev) -{ - VirtIODevice *vdev = VIRTIO_DEVICE(dev); - VHostUserI2C *i2c = VHOST_USER_I2C(dev); - struct vhost_virtqueue *vhost_vqs = i2c->vhost_dev.vqs; - - /* This will stop vhost backend if appropriate. */ - vu_i2c_set_status(vdev, 0); - vhost_dev_cleanup(&i2c->vhost_dev); - g_free(vhost_vqs); - do_vhost_user_cleanup(vdev, i2c); + vubc->parent_realize(dev, errp); } static const VMStateDescription vu_i2c_vmstate = { @@ -268,30 +37,21 @@ static const VMStateDescription vu_i2c_vmstate = { .unmigratable = 1, }; -static Property vu_i2c_properties[] = { - DEFINE_PROP_CHR("chardev", VHostUserI2C, chardev), - DEFINE_PROP_END_OF_LIST(), -}; - static void vu_i2c_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); - VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass); - device_class_set_props(dc, vu_i2c_properties); dc->vmsd = &vu_i2c_vmstate; + device_class_set_props(dc, vi2c_properties); + device_class_set_parent_realize(dc, vi2c_realize, + &vubc->parent_realize); set_bit(DEVICE_CATEGORY_INPUT, dc->categories); - vdc->realize = vu_i2c_device_realize; - vdc->unrealize = vu_i2c_device_unrealize; - vdc->get_features = vu_i2c_get_features; - vdc->set_status = vu_i2c_set_status; - vdc->guest_notifier_mask = vu_i2c_guest_notifier_mask; - vdc->guest_notifier_pending = vu_i2c_guest_notifier_pending; } static const TypeInfo vu_i2c_info = { .name = TYPE_VHOST_USER_I2C, - .parent = TYPE_VIRTIO_DEVICE, + .parent = TYPE_VHOST_USER_BASE, .instance_size = sizeof(VHostUserI2C), .class_init = vu_i2c_class_init, }; diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 374a616580..685d586e69 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -22,12 +22,15 @@ if have_vhost # MMIO Stubs system_virtio_ss.add(files('vhost-user-device.c')) system_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) + system_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) system_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) # PCI Stubs system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c')) system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c')) + system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_I2C'], + if_true: files('vhost-user-i2c-pci.c')) system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_RNG'], if_true: files('vhost-user-rng-pci.c')) endif @@ -46,7 +49,6 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock.c specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock.c')) specific_virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-rng.c')) specific_virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) -specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_SCMI', if_true: files('vhost-user-scmi.c')) specific_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SCMI'], if_true: files('vhost-user-scmi-pci.c')) @@ -54,7 +56,6 @@ virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk-pci.c')) -virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-user-input-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-pci.c')) From patchwork Wed Feb 14 11:13:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898827 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RbRSNHWT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbFJ3TlWz23j8 for ; Wed, 14 Feb 2024 22:14:44 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDD7-0008R6-N6; Wed, 14 Feb 2024 06:13:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDCy-0008K5-Pk for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDCu-0006iO-5u for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909218; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B9XEZxK+Af7maEugy1zdrdEuG4od1VQ/TE0+JgjoQEw=; b=RbRSNHWTe2vJ6qjzMuSE62NRf9nM52fkU+BF5GzvMkzz/hJeX+v87rgCsG8hxzG+jU/VI+ yHXC9/ZdKLC085GbKHfxJb1bfUSxvURe9q0nucbSLtncl4ZuYBhqJ8HDaHMYSX0K/N0mC1 dcD7NqEvE2GpP8VYGeXyLo24ZaQGOSU= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-pltEzKQwNJqYWwpU_Y1O7g-1; Wed, 14 Feb 2024 06:13:36 -0500 X-MC-Unique: pltEzKQwNJqYWwpU_Y1O7g-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a3d06dd626fso90563666b.1 for ; Wed, 14 Feb 2024 03:13:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909215; x=1708514015; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=B9XEZxK+Af7maEugy1zdrdEuG4od1VQ/TE0+JgjoQEw=; b=MifBtZQ7PiB1nmSURkvr3QKlDxLwd+9Zp+77CIvCqrgdrztuTASomGtzI4jSudcGMV LO7fo8OQiwaiVITUr8Rh8YVNcKr1i6YJrF31oTbdxjB3oEnyXaJ6HiK8HAj/y16EqF1I 0nM/A9xafNqj3dS+c2u6/VcMw0YrbFyRs8Kiaybj6/ogy69pPerilxMwAOrpBjllHjXF piSLjFqKddoBKP+vw5lHQNgvaywAKdW7n9tVVAP+4oMCrAuFN4wriKFfONxweRBS/SYj UXb9oeM14Hdz7/G/LkHsC7HoH+0UeN7akYnSVibOdk+zx3mYVAWix9R05wGl+6VJaHFZ CBRQ== X-Gm-Message-State: AOJu0Ywy8Xxushem0heEwHJnE+wuQxcpoj1T5S1CE0iiYxRoverxFZ9W MPC9Y8LHp7fHuW0ST0iDJ42ghjlhoNItqN+SzJSuZ3rn5XboXeHIW73M5De+9vkygRI5OtA+NH5 rTwDAAQOz6vaQnvSeMZQK5a/10EKxZm4dDNfBP7FsePFAuDjcC1v8B5avfzwsrEDH7/cV5kizRi o8XuSqyChwwArYvmGqwIl/tewYIqSKPw== X-Received: by 2002:a17:907:105d:b0:a3d:5748:da37 with SMTP id oy29-20020a170907105d00b00a3d5748da37mr788226ejb.33.1707909215028; Wed, 14 Feb 2024 03:13:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3f3TrinlxnYJwOkBQ0+wExqjdlr9R5PdaI2uX4oonmwz9s4666L9cp5Sp06MSIvh7MULjfA== X-Received: by 2002:a17:907:105d:b0:a3d:5748:da37 with SMTP id oy29-20020a170907105d00b00a3d5748da37mr788209ejb.33.1707909214705; Wed, 14 Feb 2024 03:13:34 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXouETL9yhO/OTaW7oAa45ntjhHGxUw5nak68sdPahQ5H4khTOMvbaVKAhCEK6hYf900ZX0V9x33tv5uThQOL0p7EQKNO6Esc0y9hJbfijOxcRhwZ3LWzp0p8JCoydbhTcB4K+3fZtc+uD6Rm4+tammaKz+BZ5pkrxaJzg= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id dl7-20020a170907944700b00a3d1b41bb48sm1154170ejc.130.2024.02.14.03.13.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:13:34 -0800 (PST) Date: Wed, 14 Feb 2024 06:13:32 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Alex =?utf-8?q?Benn?= =?utf-8?q?=C3=A9e?= , Paolo Bonzini Subject: [PULL 06/60] hw/virtio: add vhost-user-snd and vhost-user-snd-pci devices Message-ID: <4ae0fc18a1dc91bfe3a494292faf3c4c1b2cc16c.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Manos Pitsidianakis Tested with rust-vmm vhost-user-sound daemon: RUST_LOG=trace cargo run --bin vhost-user-sound -- --socket /tmp/snd.sock --backend null Invocation: qemu-system-x86_64 \ -qmp unix:./qmp-sock,server,wait=off \ -m 4096 \ -numa node,memdev=mem \ -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on \ -D qemu.log \ -d guest_errors,trace:\*snd\*,trace:\*sound\*,trace:\*vhost\* \ -chardev socket,id=vsnd,path=/tmp/snd.sock \ -device vhost-user-snd-pci,chardev=vsnd,id=snd \ /path/to/disk [AJB: imported from https://github.com/epilys/qemu-virtio-snd/commit/54ae1cdd15fef2d88e9e387a175f099a38c636f4.patch] Signed-off-by: Alex Bennée Signed-off-by: Manos Pitsidianakis Message-Id: <20240104210945.1223134-7-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user-snd.h | 24 ++++++++++ hw/virtio/vhost-user-snd-pci.c | 75 ++++++++++++++++++++++++++++++ hw/virtio/vhost-user-snd.c | 67 ++++++++++++++++++++++++++ MAINTAINERS | 7 +++ hw/virtio/Kconfig | 5 ++ hw/virtio/meson.build | 3 ++ 6 files changed, 181 insertions(+) create mode 100644 include/hw/virtio/vhost-user-snd.h create mode 100644 hw/virtio/vhost-user-snd-pci.c create mode 100644 hw/virtio/vhost-user-snd.c diff --git a/include/hw/virtio/vhost-user-snd.h b/include/hw/virtio/vhost-user-snd.h new file mode 100644 index 0000000000..f9260116a7 --- /dev/null +++ b/include/hw/virtio/vhost-user-snd.h @@ -0,0 +1,24 @@ +/* + * Vhost-user Sound virtio device + * + * Copyright (c) 2021 Mathieu Poirier + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef QEMU_VHOST_USER_SND_H +#define QEMU_VHOST_USER_SND_H + +#include "hw/virtio/virtio.h" +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" +#include "hw/virtio/vhost-user-base.h" + +#define TYPE_VHOST_USER_SND "vhost-user-snd" +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserSound, VHOST_USER_SND) + +struct VHostUserSound { + VHostUserBase parent_obj; +}; + +#endif /* QEMU_VHOST_USER_SND_H */ diff --git a/hw/virtio/vhost-user-snd-pci.c b/hw/virtio/vhost-user-snd-pci.c new file mode 100644 index 0000000000..d61cfdae63 --- /dev/null +++ b/hw/virtio/vhost-user-snd-pci.c @@ -0,0 +1,75 @@ +/* + * Vhost-user Sound virtio device PCI glue + * + * Copyright (c) 2023 Manos Pitsidianakis + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/vhost-user-snd.h" +#include "hw/virtio/virtio-pci.h" + +struct VHostUserSoundPCI { + VirtIOPCIProxy parent_obj; + VHostUserSound vdev; +}; + +typedef struct VHostUserSoundPCI VHostUserSoundPCI; + +#define TYPE_VHOST_USER_SND_PCI "vhost-user-snd-pci-base" + +DECLARE_INSTANCE_CHECKER(VHostUserSoundPCI, VHOST_USER_SND_PCI, + TYPE_VHOST_USER_SND_PCI) + +static Property vhost_user_snd_pci_properties[] = { + DEFINE_PROP_END_OF_LIST(), +}; + +static void vhost_user_snd_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) +{ + VHostUserSoundPCI *dev = VHOST_USER_SND_PCI(vpci_dev); + DeviceState *vdev = DEVICE(&dev->vdev); + + vpci_dev->nvectors = 1; + + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void vhost_user_snd_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass); + k->realize = vhost_user_snd_pci_realize; + set_bit(DEVICE_CATEGORY_SOUND, dc->categories); + device_class_set_props(dc, vhost_user_snd_pci_properties); + pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id = 0; /* Set by virtio-pci based on virtio id */ + pcidev_k->revision = 0x00; + pcidev_k->class_id = PCI_CLASS_MULTIMEDIA_AUDIO; +} + +static void vhost_user_snd_pci_instance_init(Object *obj) +{ + VHostUserSoundPCI *dev = VHOST_USER_SND_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VHOST_USER_SND); +} + +static const VirtioPCIDeviceTypeInfo vhost_user_snd_pci_info = { + .base_name = TYPE_VHOST_USER_SND_PCI, + .non_transitional_name = "vhost-user-snd-pci", + .instance_size = sizeof(VHostUserSoundPCI), + .instance_init = vhost_user_snd_pci_instance_init, + .class_init = vhost_user_snd_pci_class_init, +}; + +static void vhost_user_snd_pci_register(void) +{ + virtio_pci_types_register(&vhost_user_snd_pci_info); +} + +type_init(vhost_user_snd_pci_register); diff --git a/hw/virtio/vhost-user-snd.c b/hw/virtio/vhost-user-snd.c new file mode 100644 index 0000000000..9a217543f8 --- /dev/null +++ b/hw/virtio/vhost-user-snd.c @@ -0,0 +1,67 @@ +/* + * Vhost-user snd virtio device + * + * Copyright (c) 2023 Manos Pitsidianakis + * + * Simple wrapper of the generic vhost-user-device. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user-snd.h" +#include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/virtio_snd.h" + +static const VMStateDescription vu_snd_vmstate = { + .name = "vhost-user-snd", + .unmigratable = 1, +}; + +static Property vsnd_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vu_snd_base_realize(DeviceState *dev, Error **errp) +{ + VHostUserBase *vub = VHOST_USER_BASE(dev); + VHostUserBaseClass *vubs = VHOST_USER_BASE_GET_CLASS(dev); + + vub->virtio_id = VIRTIO_ID_SOUND; + vub->num_vqs = 4; + vub->config_size = sizeof(struct virtio_snd_config); + vub->vq_size = 64; + + vubs->parent_realize(dev, errp); +} + +static void vu_snd_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass); + + dc->vmsd = &vu_snd_vmstate; + device_class_set_props(dc, vsnd_properties); + device_class_set_parent_realize(dc, vu_snd_base_realize, + &vubc->parent_realize); + + set_bit(DEVICE_CATEGORY_SOUND, dc->categories); +} + +static const TypeInfo vu_snd_info = { + .name = TYPE_VHOST_USER_SND, + .parent = TYPE_VHOST_USER_BASE, + .instance_size = sizeof(VHostUserSound), + .class_init = vu_snd_class_init, +}; + +static void vu_snd_register_types(void) +{ + type_register_static(&vu_snd_info); +} + +type_init(vu_snd_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index 2426368c4d..aff5342cb4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2342,6 +2342,13 @@ F: hw/virtio/vhost-user-gpio* F: include/hw/virtio/vhost-user-gpio.h F: tests/qtest/libqos/virtio-gpio.* +vhost-user-snd +M: Alex Bennée +R: Manos Pitsidianakis +S: Maintained +F: hw/virtio/vhost-user-snd* +F: include/hw/virtio/vhost-user-snd.h + vhost-user-scmi R: mzamazal@redhat.com S: Supported diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig index 92c9cf6c96..aa63ff7fd4 100644 --- a/hw/virtio/Kconfig +++ b/hw/virtio/Kconfig @@ -101,6 +101,11 @@ config VHOST_VDPA_DEV default y depends on VIRTIO && VHOST_VDPA && LINUX +config VHOST_USER_SND + bool + default y + depends on VIRTIO && VHOST_USER + config VHOST_USER_SCMI bool default y diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 685d586e69..af8abae020 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -24,6 +24,7 @@ if have_vhost system_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) system_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) system_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) + system_virtio_ss.add(when: 'CONFIG_VHOST_USER_SND', if_true: files('vhost-user-snd.c')) # PCI Stubs system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c')) @@ -33,6 +34,8 @@ if have_vhost if_true: files('vhost-user-i2c-pci.c')) system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_RNG'], if_true: files('vhost-user-rng-pci.c')) + system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SND'], + if_true: files('vhost-user-snd-pci.c')) endif if have_vhost_vdpa system_virtio_ss.add(files('vhost-vdpa.c')) From patchwork Wed Feb 14 11:13:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898872 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BuTkjKCA; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbNr0y0hz23j4 for ; Wed, 14 Feb 2024 22:21:16 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDD4-0008Nk-M2; Wed, 14 Feb 2024 06:13:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDCz-0008K1-AD for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDCw-0006ih-7h for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909221; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5QCQCVR6jtXXAjpCojfp7A6N/bol4CbLlxWu9xFsRU4=; b=BuTkjKCAEP5qB0I2C/GOO+iY6WsYRi59sQgaKZlPLwokns6+IcV6X0DWEN575sDrzKPPIQ 63J/adWbQJYtH7AuH9SRbbAGIxGJCf5/cBOo7J8uHIMRc/3md5voBTHtRCPU4zYw4GDdNu DhQA6Rzma57e/pAIs2n5iI/9GgOeyVA= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-355--h3i6bQXP5-1Cv83oHOtyw-1; Wed, 14 Feb 2024 06:13:39 -0500 X-MC-Unique: -h3i6bQXP5-1Cv83oHOtyw-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-51197d1fcc2so1641518e87.2 for ; Wed, 14 Feb 2024 03:13:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909218; x=1708514018; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5QCQCVR6jtXXAjpCojfp7A6N/bol4CbLlxWu9xFsRU4=; b=seb+8rNcGDcYWw5qXHxwBp3ANDNrpsf2lJ9ttUJs5GFl6bFcs+nFvhUHcSmL8lFZ3z yZCyXih9qgpFcpABR2I8WuX5Ge7NHkw+jH2pT73sHhi7j7cj51XEItChy//ZZpjmiGGg P+0v31WO73WPbYiIXlE2zs5WmOV+F8RQUCNpfZlIDOFPbxcWDg+zdCc5fW4j8nR3ULff uao2Jcu23leC4o94YtM0pkrN1q3qr9vDxbefAnSIB9EtAltdxLax5n9SohjHWpwJ7XHc jNPGceCcTE1huwW31nILmg5cMAsldTQ+NEdCaXlLDNRkNk9TOKpgr107C3nbsHz2PgLu qPag== X-Gm-Message-State: AOJu0Yx+YlNMlDxFy74p8JSD2NrCXFqbHA8wt9hkpG5gc6WfJKrGuZgi d1b6ihq9VhAC8L3iSlGmquLNGNjIwIPU/V7m8X7PmwX+yt1YUS3zdkiinK4i/OnP7OLjgfeuS0M bhsXoAErfaCQOjepyVRKsJj1YBm9qc9qlEUAQu/IyrUdtX0NAfa0JbUm1J7twvJsPlrq4HYcAsM swTG5iH1iqydtkQR6PsmteMmD11EifRQ== X-Received: by 2002:ac2:5f8a:0:b0:511:490e:b8fd with SMTP id r10-20020ac25f8a000000b00511490eb8fdmr1544597lfe.45.1707909218069; Wed, 14 Feb 2024 03:13:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQ6rqCEgjfsz8sWfs9Jz8ED5pDc0lQhQSywflvRZevy6HrAvfr7fWEOfC3rCvquH0azYgf1w== X-Received: by 2002:ac2:5f8a:0:b0:511:490e:b8fd with SMTP id r10-20020ac25f8a000000b00511490eb8fdmr1544578lfe.45.1707909217691; Wed, 14 Feb 2024 03:13:37 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVYlb7bwPA6uMGeGkuP/7gMQIYRWVuhYk2bkkMZe7m1/YaZgX7QvPMTcg8JIKF3Bq0oLe7EmMEeA8DTA0hJxwtl/0DX4CmitOeJIMXgq4rBuXp4c6qU3BkZNFxNE0OQZErjKg== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id vv3-20020a170907a68300b00a3d42c54e48sm518625ejc.153.2024.02.14.03.13.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:13:37 -0800 (PST) Date: Wed, 14 Feb 2024 06:13:35 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Mathieu Poirier Subject: [PULL 07/60] docs/system: add a basic enumeration of vhost-user devices Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Alex Bennée Make it clear the vhost-user-device is intended for expert use only. Signed-off-by: Alex Bennée Message-Id: <20240104210945.1223134-8-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/system/devices/vhost-user-rng.rst | 2 + docs/system/devices/vhost-user.rst | 70 +++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/docs/system/devices/vhost-user-rng.rst b/docs/system/devices/vhost-user-rng.rst index a145d4105c..ead1405326 100644 --- a/docs/system/devices/vhost-user-rng.rst +++ b/docs/system/devices/vhost-user-rng.rst @@ -1,3 +1,5 @@ +.. _vhost_user_rng: + QEMU vhost-user-rng - RNG emulation =================================== diff --git a/docs/system/devices/vhost-user.rst b/docs/system/devices/vhost-user.rst index a80e95a48a..c6afc4836f 100644 --- a/docs/system/devices/vhost-user.rst +++ b/docs/system/devices/vhost-user.rst @@ -8,13 +8,81 @@ outside of QEMU itself. To do this there are a number of things required. vhost-user device -=================== +================= These are simple stub devices that ensure the VirtIO device is visible to the guest. The code is mostly boilerplate although each device has a ``chardev`` option which specifies the ID of the ``--chardev`` device that connects via a socket to the vhost-user *daemon*. +Each device will have an virtio-mmio and virtio-pci variant. See your +platform details for what sort of virtio bus to use. + +.. list-table:: vhost-user devices + :widths: 20 20 60 + :header-rows: 1 + + * - Device + - Type + - Notes + * - vhost-user-blk + - Block storage + - See contrib/vhost-user-blk + * - vhost-user-fs + - File based storage driver + - See https://gitlab.com/virtio-fs/virtiofsd + * - vhost-user-gpio + - Proxy gpio pins to host + - See https://github.com/rust-vmm/vhost-device + * - vhost-user-gpu + - GPU driver + - See contrib/vhost-user-gpu + * - vhost-user-i2c + - Proxy i2c devices to host + - See https://github.com/rust-vmm/vhost-device + * - vhost-user-input + - Generic input driver + - See contrib/vhost-user-input + * - vhost-user-rng + - Entropy driver + - :ref:`vhost_user_rng` + * - vhost-user-scmi + - System Control and Management Interface + - See https://github.com/rust-vmm/vhost-device + * - vhost-user-snd + - Audio device + - See https://github.com/rust-vmm/vhost-device/staging + * - vhost-user-scsi + - SCSI based storage + - See contrib/vhost-user-scsi + * - vhost-user-vsock + - Socket based communication + - See https://github.com/rust-vmm/vhost-device + +The referenced *daemons* are not exhaustive, any conforming backend +implementing the device and using the vhost-user protocol should work. + +vhost-user-device +^^^^^^^^^^^^^^^^^ + +The vhost-user-device is a generic development device intended for +expert use while developing new backends. The user needs to specify +all the required parameters including: + + - Device ``virtio-id`` + - The ``num_vqs`` it needs and their ``vq_size`` + - The ``config_size`` if needed + +.. note:: + To prevent user confusion you cannot currently instantiate + vhost-user-device without first patching out:: + + /* Reason: stop inexperienced users confusing themselves */ + dc->user_creatable = false; + + in ``vhost-user-device.c`` and ``vhost-user-device-pci.c`` file and + rebuilding. + vhost-user daemon ================= From patchwork Wed Feb 14 11:13:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898824 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=fBDegLE/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbDr5Rzmz23yK for ; Wed, 14 Feb 2024 22:14:20 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDB-0008TL-EN; Wed, 14 Feb 2024 06:13:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDD2-0008Ku-Cw for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDCz-0006jJ-Mg for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909225; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aMCWbZMbJsUeDBMcr0PznqZivp4BA1aEeZXrL0J0rpk=; b=fBDegLE/eGV3aZ0V0cur1zXSP5/yQmDzQ90OAI7Z8J11UrtQwRfvgNsC27IKSjm/bG2owI bhxH0cHhE6Fg4B+kE9z2WEV+k87G8wT+Hn49xL6KfkxQcFVE6PX34YKnheieFl4mnNXlKM jXoZXYJ1qd1oNpsEIPdPX8z+XShbj30= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-86-t9W0Ej0UNEq64xZ6IZ859g-1; Wed, 14 Feb 2024 06:13:43 -0500 X-MC-Unique: t9W0Ej0UNEq64xZ6IZ859g-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-51151b8de86so5087003e87.1 for ; Wed, 14 Feb 2024 03:13:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909220; x=1708514020; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aMCWbZMbJsUeDBMcr0PznqZivp4BA1aEeZXrL0J0rpk=; b=AePr8Z2BdROTfXxjen227ItDp/xskZZUdbzPVmJih4kID9gY7McbaSeockjPwuEKB1 qlMNXjBu/3JQvsarWHPPKb4AzWZuRV7zMFQy0FEfiUgzaZQHa16Fmb/VCGr9fGYYf7j+ n+3O+lfE/Y7P92ubAqLOt2w9c9PRcXj0MnkHVTB4O78leXbC8tN/iWgG4WefMGSv90Y4 1EwogK/2pdavgFv7dJc2rvUaTuCIuwRkjIEFiPk4VnL0jYdwMd+T2FWnXhGP86B3mU0U xeM0JCKSsrQ7Uhz84isyXEXXeYC7L8f4Bxg1ksmO9jbbAw0FFbSQo+yyvrjC73ThAHp/ JP0A== X-Gm-Message-State: AOJu0YwLKo457HPbLNWncad4Hh2/EqJLfVglWcO81ukYqp0EuPlfXEtQ xnGBVfy6oXH52yJ+DXUTGsXulUfTmXp+k3PG6psXnPLgcPr35uUPGbZFp3+JgvFyOyDJUtZGymL hdWsa1RSkmGLISDvDy/cZIGkAIH5hRswS1wV5GJ4dodU8s8foDe9Hx1J5kXLWn7pcMu3JTEjGfd 2+/Al8RzjqJRNVSUVF6pC8/i8+TBuB0g== X-Received: by 2002:ac2:4c81:0:b0:511:8d37:4b60 with SMTP id d1-20020ac24c81000000b005118d374b60mr1591085lfl.6.1707909220703; Wed, 14 Feb 2024 03:13:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcOoL9frDXTu3cZC84nECDCMtgnu8Wt+YvatVp4G7jnVQAfH/np6ZxHTMHajMMDE7K9yKHBw== X-Received: by 2002:ac2:4c81:0:b0:511:8d37:4b60 with SMTP id d1-20020ac24c81000000b005118d374b60mr1591071lfl.6.1707909220438; Wed, 14 Feb 2024 03:13:40 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV5gMbGpldpCBiTkSEZMuJhDuOPsH0HWn0WWLfmTrIDv7zIfo6NQA9MCwvbYvGB7JneBEcVMYqvQSDz6GExaTDtotnNWDuCN1T0s4vAylyzt26YLyIUngJJyDKlNkN9ukEV8W7DvgQ+9gUj7w2nfngTEaksIRdxxQ== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id y21-20020a170906559500b00a34d0a865ecsm2169280ejp.163.2024.02.14.03.13.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:13:39 -0800 (PST) Date: Wed, 14 Feb 2024 06:13:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Leo Yan , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL 08/60] hw/virtio: Support set_config() callback in vhost-user-base Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Leo Yan The Virtio input device invokes set_config() callback for retrieving the event configuration info, but the callback is not supported in vhost-user-base. This patch adds support set_config() callback in vhost-user-base. Signed-off-by: Leo Yan Reviewed-by: Marc-André Lureau Message-Id: <20231120043721.50555-2-leo.yan@linaro.org> Signed-off-by: Alex Bennée Message-Id: <20240104210945.1223134-9-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user-base.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index 78cfa9a5bb..a83167191e 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -140,6 +140,22 @@ static void vub_get_config(VirtIODevice *vdev, uint8_t *config) } } +static void vub_set_config(VirtIODevice *vdev, const uint8_t *config_data) +{ + VHostUserBase *vub = VHOST_USER_BASE(vdev); + int ret; + + g_assert(vub->config_size && vub->vhost_user.supports_config == true); + + ret = vhost_dev_set_config(&vub->vhost_dev, config_data, + 0, vub->config_size, + VHOST_SET_CONFIG_TYPE_FRONTEND); + if (ret) { + error_report("vhost guest set device config space failed: %d", ret); + return; + } +} + /* * When the daemon signals an update to the config we just need to * signal the guest as we re-read the config on demand above. @@ -337,6 +353,7 @@ static void vub_class_init(ObjectClass *klass, void *data) vdc->unrealize = vub_device_unrealize; vdc->get_features = vub_get_features; vdc->get_config = vub_get_config; + vdc->set_config = vub_set_config; vdc->set_status = vub_set_status; } From patchwork Wed Feb 14 11:13:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898829 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NsJNnWiO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbFc0KKHz23j8 for ; Wed, 14 Feb 2024 22:15:00 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDD7-0008Q1-Ly; Wed, 14 Feb 2024 06:13:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDD3-0008NF-VN for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDD2-0006jb-5h for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909227; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gPFXPFy/mnGFMSxq5GRTraSFwMu/Y3VYl/4w4KYs38Y=; b=NsJNnWiOWEd8Cmfv08R0FbFwhbB/371p7NQjfsfdwBvnIWO3DONL+8I/4QybyV7n/6MuHh atLNrh+Gy6sGCcHAUGvy0YnptgD1yp1jK22471Z9lbt7x+OGMmgWUnGnHWtawjoqkfTkhM l/JrarxfhEOb/8sVvTofOua/sV/vYqA= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-182-q7oERDwdOE65AIFbH8GNGg-1; Wed, 14 Feb 2024 06:13:46 -0500 X-MC-Unique: q7oERDwdOE65AIFbH8GNGg-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-51151b8de86so5087045e87.1 for ; Wed, 14 Feb 2024 03:13:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909224; x=1708514024; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gPFXPFy/mnGFMSxq5GRTraSFwMu/Y3VYl/4w4KYs38Y=; b=lfVDmd25k0kHlNi/274sNLXGPp8IGfWYJKOgJCSLQPTeFPaqQyLLfeHsfRqmu1llv+ MGIF2CnvR59onp3i5X3bVKZSN+YChfBvon5EdjlnH7cZCll3ivoQxXqYq/I1GG/G+UKF xUsm7zFug2JNJOciuo3eo5AMTRDx2dvkPksGQt99oAP/5CtyMF3oueE63taps5v1ZZDV U11K6wgHC4y4SnTFP4hAQkkrd+An/LdybtRQTsGb+w4Vgtx+2qmb22BmbQZCs/mWFvka U6FG3CfU/1M4Dauw9Vhs5/QKrokFYm+R9HaDo/jLI5TygUJt3dlEFj9rDNOAD+gZNYO0 95KA== X-Gm-Message-State: AOJu0YzAB65KEgvwNFtM+p/wBlW139CADRlrSSWyxbHv1rxkzXn8eaYc xpSRqWwC8QvmdOPgo9HvR/ektRZJxpehHBNVtQ437DnkgVKG2aRjqDAgcGjp5O6OqZm6wRQgfkL BDca9xa6HVaZ37ZCIu1P6zYg94prFu/kAtUWSjKHC+1jQSz54j4TdWM7J1zcZfN/iyKINjXUjHO MVbBkYPrFhxFtzlhRZzpzNmqeJxjEBBQ== X-Received: by 2002:ac2:4c02:0:b0:511:5314:1762 with SMTP id t2-20020ac24c02000000b0051153141762mr1509677lfq.44.1707909223850; Wed, 14 Feb 2024 03:13:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQwsL9VzwPPQNpQdcQwvWYthUtJDDzJLDJD1r4h5fUxNFVRgCoPTY3ZUFMxjLQphf8oKB0qQ== X-Received: by 2002:ac2:4c02:0:b0:511:5314:1762 with SMTP id t2-20020ac24c02000000b0051153141762mr1509664lfq.44.1707909223438; Wed, 14 Feb 2024 03:13:43 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVWG68j22UBZyG3Y/MP8+57fE7YZ+QNtYcHKP4qw+AxkSR2QtastNpGVzm/6FYvihicsok3tTl9Djvrqz9/iOZ8MJLERukfez6JnLuSLuxKVsHTKZfYSYkqvRlyvDASixLekff1VRWGsXchUonc Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id en14-20020a056402528e00b0055fef53460bsm4592878edb.0.2024.02.14.03.13.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:13:42 -0800 (PST) Date: Wed, 14 Feb 2024 06:13:40 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Leo Yan , Alex =?utf-8?q?Benn=C3=A9e?= , Gerd Hoffmann Subject: [PULL 09/60] docs/system: Add vhost-user-input documentation Message-ID: <887d5775863b8804bacba6fe1a860ed3ea5cfdd9.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Leo Yan This adds basic documentation for vhost-user-input. Signed-off-by: Leo Yan Message-Id: <20231120043721.50555-3-leo.yan@linaro.org> Signed-off-by: Alex Bennée Message-Id: <20240104210945.1223134-10-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- MAINTAINERS | 1 + docs/system/device-emulation.rst | 1 + docs/system/devices/vhost-user-input.rst | 45 ++++++++++++++++++++++++ docs/system/devices/vhost-user.rst | 4 ++- 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 docs/system/devices/vhost-user-input.rst diff --git a/MAINTAINERS b/MAINTAINERS index aff5342cb4..66c9e81c55 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2289,6 +2289,7 @@ L: virtio-fs@lists.linux.dev virtio-input M: Gerd Hoffmann S: Odd Fixes +F: docs/system/devices/vhost-user-input.rst F: hw/input/vhost-user-input.c F: hw/input/virtio-input*.c F: include/hw/virtio/virtio-input.h diff --git a/docs/system/device-emulation.rst b/docs/system/device-emulation.rst index d1f3277cb0..f19777411c 100644 --- a/docs/system/device-emulation.rst +++ b/docs/system/device-emulation.rst @@ -94,6 +94,7 @@ Emulated Devices devices/virtio-gpu.rst devices/virtio-pmem.rst devices/virtio-snd.rst + devices/vhost-user-input.rst devices/vhost-user-rng.rst devices/canokey.rst devices/usb-u2f.rst diff --git a/docs/system/devices/vhost-user-input.rst b/docs/system/devices/vhost-user-input.rst new file mode 100644 index 0000000000..118eb78101 --- /dev/null +++ b/docs/system/devices/vhost-user-input.rst @@ -0,0 +1,45 @@ +.. _vhost_user_input: + +QEMU vhost-user-input - Input emulation +======================================= + +This document describes the setup and usage of the Virtio input device. +The Virtio input device is a paravirtualized device for input events. + +Description +----------- + +The vhost-user-input device implementation was designed to work with a daemon +polling on input devices and passes input events to the guest. + +QEMU provides a backend implementation in contrib/vhost-user-input. + +Linux kernel support +-------------------- + +Virtio input requires a guest Linux kernel built with the +``CONFIG_VIRTIO_INPUT`` option. + +Examples +-------- + +The backend daemon should be started first: + +:: + + host# vhost-user-input --socket-path=input.sock \ + --evdev-path=/dev/input/event17 + +The QEMU invocation needs to create a chardev socket to communicate with the +backend daemon and access the VirtIO queues with the guest over the +:ref:`shared memory `. + +:: + + host# qemu-system \ + -chardev socket,path=/tmp/input.sock,id=mouse0 \ + -device vhost-user-input-pci,chardev=mouse0 \ + -m 4096 \ + -object memory-backend-file,id=mem,size=4G,mem-path=/dev/shm,share=on \ + -numa node,memdev=mem \ + ... diff --git a/docs/system/devices/vhost-user.rst b/docs/system/devices/vhost-user.rst index c6afc4836f..9b2da106ce 100644 --- a/docs/system/devices/vhost-user.rst +++ b/docs/system/devices/vhost-user.rst @@ -42,7 +42,7 @@ platform details for what sort of virtio bus to use. - See https://github.com/rust-vmm/vhost-device * - vhost-user-input - Generic input driver - - See contrib/vhost-user-input + - :ref:`vhost_user_input` * - vhost-user-rng - Entropy driver - :ref:`vhost_user_rng` @@ -91,6 +91,8 @@ following the :ref:`vhost_user_proto`. There are a number of daemons that can be built when enabled by the project although any daemon that meets the specification for a given device can be used. +.. _shared_memory_object: + Shared memory object ==================== From patchwork Wed Feb 14 11:13:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898848 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cxaMXjEz; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbKw544Wz23hM for ; Wed, 14 Feb 2024 22:18:44 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDC-0008Ts-8y; Wed, 14 Feb 2024 06:13:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDD7-0008QF-Aj for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDD5-0006k7-LF for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:13:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t2Py5K1KV4TIQcdeM+IKUI8vM0Fvjo561iUpW9cAFpE=; b=cxaMXjEzAxLA77d99dwbMyy3XyHUuLSeZvrqeBd4Rkg4uIQ/dMALLkbiYw+XXqht1MNLbT bqisnD5FpJLgU7yOHsVjP9wC/D7C03q1q7gMkZBSYGi8gKIowzChptRYzJxpdzrScro3l4 JncksV4o4uFT0Jx0mTUNGzUCfiL6L7A= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-HNCCbDiwNi-ps32gxoOApQ-1; Wed, 14 Feb 2024 06:13:49 -0500 X-MC-Unique: HNCCbDiwNi-ps32gxoOApQ-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-560f41972easo3123162a12.0 for ; Wed, 14 Feb 2024 03:13:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909228; x=1708514028; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=t2Py5K1KV4TIQcdeM+IKUI8vM0Fvjo561iUpW9cAFpE=; b=JgydlApXVxuiatOTCy5t1WQhjVvkH875k7h4Biz2yMvMFSB9tWNjwct/A+kOsM+jpU 1hXieic9kmQEk2twkWUY6+HAjsykNtUriWSKbpn3ZECk2ybuo3HqlwX/MSu4/rb6pKwj lVcuxismwnGsIrkYTwIDCJAyDLIlH44ZkieThKgfGzlft2JQIt4kVyMrPcFDpbtCJn/8 alN6X+nO/MRyBd4gunKa2AkgBMjaoYEAZ7XLHNMplXO6MQuovmCEjDDGjtY9Q5tIfxu3 26XPKJ16LPD3fUTLYxa7b61PgzDcbZ3tMhDJPixc2nFk0K+YE1854QxeP98cTKkxWuwC E1tw== X-Gm-Message-State: AOJu0Yyq1+dEVg0SlAiCsG2DXlu8tLQr8+feoxWBWFrC8A4zHxtwWdxY +SZBAw/lqVIRQfnvdpAPHET7LWP3Xx9Scdri9zJjH/ECJYrKdv6j9Bcp5o722H/RAW3S7f493n8 cn5MLw2eJgCxG+d7hGGODCqEuSrJO0PCGtFXlzzjPUaXaqs3l3ZqBRPDwOq9pdrnJ5M4VcXlPKl YNq+y0zKyukhV4+1YB8gh7+XW+poOHPQ== X-Received: by 2002:aa7:c901:0:b0:561:aed9:37e8 with SMTP id b1-20020aa7c901000000b00561aed937e8mr1823343edt.3.1707909228118; Wed, 14 Feb 2024 03:13:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfKFfhlFDN8YbVpAlvmtN/QzRARAVj3rFSkTefBbyEu7xrJEuDVyBUq9BBKzb69vKJnh8guw== X-Received: by 2002:aa7:c901:0:b0:561:aed9:37e8 with SMTP id b1-20020aa7c901000000b00561aed937e8mr1823289edt.3.1707909226850; Wed, 14 Feb 2024 03:13:46 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVyzTL8BmDkFj6R8/MA9LIsDVFmI5VE4YjiqZTYPzhroHU094AfhLPdQgg5DKfFNTWceqfePe/HE09zAxTndq6G82s3g0p5THox7AHX9KHfdYGq3jOMNVPjvjTY9GHDupJU1Gft9/8Q2CHU7GyI8BY+HkhPwDhhTFlUjZdskr+qp37xmZKxmhdmr7V9botVD3LFjNlV0jO8bTd5SiXyAAprPUElu40cS0shyqLh2Q3Q7nN19mM+h1YsRubIHsUGduFBBjvFqSZU5GUUr9XWOchgCD+ARnSqJeZ94UJ+pAuRXHki+HYWo09RsKE= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id cq9-20020a056402220900b0055ffe74e39dsm4549878edb.85.2024.02.14.03.13.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:13:46 -0800 (PST) Date: Wed, 14 Feb 2024 06:13:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Leo Yan , Manos Pitsidianakis , Alex =?utf-8?q?Benn?= =?utf-8?q?=C3=A9e?= , Philippe =?utf-8?q?Mathieu-Da?= =?utf-8?q?ud=C3=A9?= , Thomas Huth , =?utf-8?q?C=C3=A9dric?= Le Goater , Richard Henderson , Mark Cave-Ayland Subject: [PULL 10/60] hw/virtio: Move vhost-user-input into virtio folder Message-ID: <87c7fb7819962e052a69046167949fe266611abf.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Leo Yan vhost-user-input is in the input folder. On the other hand, the folder 'hw/virtio' maintains other virtio stubs (e.g. I2C, RNG, GPIO, etc). This patch moves vhost-user-input into the virtio folder for better code organization. No functionality change. Signed-off-by: Leo Yan Reviewed-by: Manos Pitsidianakis Message-Id: <20231120043721.50555-4-leo.yan@linaro.org> Signed-off-by: Alex Bennée Message-Id: <20240104210945.1223134-11-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/{input => virtio}/vhost-user-input.c | 0 MAINTAINERS | 2 +- hw/input/meson.build | 1 - hw/virtio/meson.build | 4 +++- 4 files changed, 4 insertions(+), 3 deletions(-) rename hw/{input => virtio}/vhost-user-input.c (100%) diff --git a/hw/input/vhost-user-input.c b/hw/virtio/vhost-user-input.c similarity index 100% rename from hw/input/vhost-user-input.c rename to hw/virtio/vhost-user-input.c diff --git a/MAINTAINERS b/MAINTAINERS index 66c9e81c55..89f2d31f70 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2290,8 +2290,8 @@ virtio-input M: Gerd Hoffmann S: Odd Fixes F: docs/system/devices/vhost-user-input.rst -F: hw/input/vhost-user-input.c F: hw/input/virtio-input*.c +F: hw/virtio/vhost-user-input.c F: include/hw/virtio/virtio-input.h F: contrib/vhost-user-input/* diff --git a/hw/input/meson.build b/hw/input/meson.build index 640556bbbc..3cc8ab85f0 100644 --- a/hw/input/meson.build +++ b/hw/input/meson.build @@ -11,7 +11,6 @@ system_ss.add(when: 'CONFIG_TSC2005', if_true: files('tsc2005.c')) system_ss.add(when: 'CONFIG_VIRTIO_INPUT', if_true: files('virtio-input.c')) system_ss.add(when: 'CONFIG_VIRTIO_INPUT', if_true: files('virtio-input-hid.c')) system_ss.add(when: 'CONFIG_VIRTIO_INPUT_HOST', if_true: files('virtio-input-host.c')) -system_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-user-input.c')) system_ss.add(when: 'CONFIG_PXA2XX', if_true: files('pxa2xx_keypad.c')) system_ss.add(when: 'CONFIG_TSC210X', if_true: files('tsc210x.c')) diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index af8abae020..d7f18c96e6 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -25,6 +25,7 @@ if have_vhost system_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) system_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) system_virtio_ss.add(when: 'CONFIG_VHOST_USER_SND', if_true: files('vhost-user-snd.c')) + system_virtio_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-user-input.c')) # PCI Stubs system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c')) @@ -36,6 +37,8 @@ if have_vhost if_true: files('vhost-user-rng-pci.c')) system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_SND'], if_true: files('vhost-user-snd-pci.c')) + system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_INPUT'], + if_true: files('vhost-user-input-pci.c')) endif if have_vhost_vdpa system_virtio_ss.add(files('vhost-vdpa.c')) @@ -59,7 +62,6 @@ virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_VSOCK', if_true: files('vhost-user-vsock-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_BLK', if_true: files('vhost-user-blk-pci.c')) -virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('vhost-user-input-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_SCSI', if_true: files('vhost-user-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_SCSI', if_true: files('vhost-scsi-pci.c')) virtio_pci_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs-pci.c')) From patchwork Wed Feb 14 11:13:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898861 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KzExtXAV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbLz0zDRz23hM for ; Wed, 14 Feb 2024 22:19:39 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDb-0000jC-DP; Wed, 14 Feb 2024 06:14:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDQ-0000E4-Id for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDA-0006m5-Ns for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909234; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CjRo4fIPTfHOrRBaGJPDLNZ8uI+Q6cMsNY8ttQOPSos=; b=KzExtXAVoRQepG9VSqD0/1HLAluiB4POKTxfXEgkKNKms0aoZTw9EAs8YcYyfPhnF8O1BB ATHR7Zc9R4KtN4yMQuHu81AeDMr8B6zXbrtwkB44CDdjBHWEaMfVoHN5M7J0GstZgaw2yV CYuZ7Ag0Le+vOu/Ny/HfcmliqEukP7s= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-329-vScGgLX9OLqG54Ra7JKCdQ-1; Wed, 14 Feb 2024 06:13:53 -0500 X-MC-Unique: vScGgLX9OLqG54Ra7JKCdQ-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a3d38947c35so39110066b.3 for ; Wed, 14 Feb 2024 03:13:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909231; x=1708514031; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CjRo4fIPTfHOrRBaGJPDLNZ8uI+Q6cMsNY8ttQOPSos=; b=i8edT1TLm6K7EG83xZb1DaF+D0Dl5OtMXy8+aSZQlpDZTHq5PtMnPImi3mbmoB4zCr oqttw0TKJ81QJYw/CUpQytxODv42kOQ5w6TkF0uRfLd4gH+QnuEizAeiT6vc8PSeJjxw nDXPHwMM2C9UaS1meWw31MXPnhwiRNV97NMvLPs0/LLTIXvvnYEDMn0nXTU/t2c4VTyG 2v3v/nMGnirW7HAAVXpXz66DecgmZNUMHiH/taeKkef3HA3w/znkKxBGlpmao+COttU0 Kn+iY2Z+Y1d41WfzI185MzQVfUOPy1+kP9NMfAUJEIRG2YzjouGMnMKZ0oaP3o7WTRfJ xVhw== X-Gm-Message-State: AOJu0YwwyjJ6R4puz+STDOSVEgJFC9paSYYekwKW2T9PO6b+89Hzt57i CndsITmPpg74irKo1IW3BXq8mzv9l6Yuiwz0iWIKzbLexQ2H4eOq/VjYqS+RESgCExI9bgh/fpE +OX4wdgllY4D8ECvQTwz03IWIclkgMVr9vXQr01AbeTg+XhUHK1Uzhw6Xe8TEmZMafil4UVsrdy dLKxsq6zq8sjVGyBWLwKqykHweR2gwNQ== X-Received: by 2002:a17:906:495:b0:a3d:1a89:7054 with SMTP id f21-20020a170906049500b00a3d1a897054mr1658783eja.39.1707909231350; Wed, 14 Feb 2024 03:13:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHoT6C3Mm5gxupyXuYSncNRUGtqkZuZjVzeO/mpb99YEvPkG3UBltpCyf+nqXWbbECXeia8mA== X-Received: by 2002:a17:906:495:b0:a3d:1a89:7054 with SMTP id f21-20020a170906049500b00a3d1a897054mr1658767eja.39.1707909231010; Wed, 14 Feb 2024 03:13:51 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXlGC/LtYf/uBYgXMnS3iNHh3O6U/wbqPmc/UWX+AW9oJD7DM3lMySCmtF+sG+brY205s9GSoB2KSeaqKlXLxzR0LRIykaHi2I+46XMtEYQopzc66H39cvutazhfokwgYXVPg2Z3OOgtHAhwrdYMafi3GQDUrSDz3/rZ1k6l7ciw97R8GfZVq777X4BtUY= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id vo9-20020a170907a80900b00a3ce268c015sm2037811ejc.48.2024.02.14.03.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:13:50 -0800 (PST) Date: Wed, 14 Feb 2024 06:13:48 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Leo Yan , Manos Pitsidianakis , Alex =?utf-8?q?Benn?= =?utf-8?q?=C3=A9e?= , Gerd Hoffmann Subject: [PULL 11/60] hw/virtio: derive vhost-user-input from vhost-user-base Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Leo Yan This patch derives vhost-user-input from vhost-user-base class, so make the input stub as a simpler boilerplate wrapper. With the refactoring, vhost-user-input adds the property 'chardev', this leads to conflict with the vhost-user-input-pci adds the same property. To resolve the error, remove the duplicate property from vhost-user-input-pci. Signed-off-by: Leo Yan Reviewed-by: Manos Pitsidianakis Message-Id: <20231120043721.50555-5-leo.yan@linaro.org> Signed-off-by: Alex Bennée Message-Id: <20240104210945.1223134-12-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-input.h | 6 +- hw/virtio/vhost-user-input-pci.c | 3 - hw/virtio/vhost-user-input.c | 114 +++++-------------------------- 3 files changed, 21 insertions(+), 102 deletions(-) diff --git a/include/hw/virtio/virtio-input.h b/include/hw/virtio/virtio-input.h index a6c9703644..e69c0aeca3 100644 --- a/include/hw/virtio/virtio-input.h +++ b/include/hw/virtio/virtio-input.h @@ -1,6 +1,8 @@ #ifndef QEMU_VIRTIO_INPUT_H #define QEMU_VIRTIO_INPUT_H +#include "hw/virtio/vhost-user.h" +#include "hw/virtio/vhost-user-base.h" #include "ui/input.h" #include "sysemu/vhost-user-backend.h" @@ -97,9 +99,7 @@ struct VirtIOInputHost { }; struct VHostUserInput { - VirtIOInput parent_obj; - - VhostUserBackend *vhost; + VHostUserBase parent_obj; }; void virtio_input_send(VirtIOInput *vinput, virtio_input_event *event); diff --git a/hw/virtio/vhost-user-input-pci.c b/hw/virtio/vhost-user-input-pci.c index b858898a36..3f4761ce88 100644 --- a/hw/virtio/vhost-user-input-pci.c +++ b/hw/virtio/vhost-user-input-pci.c @@ -30,9 +30,6 @@ static void vhost_user_input_pci_instance_init(Object *obj) virtio_instance_init_common(obj, &dev->vhi, sizeof(dev->vhi), TYPE_VHOST_USER_INPUT); - - object_property_add_alias(obj, "chardev", - OBJECT(&dev->vhi), "chardev"); } static const VirtioPCIDeviceTypeInfo vhost_user_input_pci_info = { diff --git a/hw/virtio/vhost-user-input.c b/hw/virtio/vhost-user-input.c index 4ee3542106..bedec0468c 100644 --- a/hw/virtio/vhost-user-input.c +++ b/hw/virtio/vhost-user-input.c @@ -5,83 +5,25 @@ */ #include "qemu/osdep.h" -#include "qemu/error-report.h" -#include "qapi/error.h" - #include "hw/virtio/virtio-input.h" -static int vhost_input_config_change(struct vhost_dev *dev) -{ - error_report("vhost-user-input: unhandled backend config change"); - return -1; -} - -static const VhostDevConfigOps config_ops = { - .vhost_dev_config_notifier = vhost_input_config_change, +static Property vinput_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), + DEFINE_PROP_END_OF_LIST(), }; -static void vhost_input_realize(DeviceState *dev, Error **errp) +static void vinput_realize(DeviceState *dev, Error **errp) { - VHostUserInput *vhi = VHOST_USER_INPUT(dev); - VirtIOInput *vinput = VIRTIO_INPUT(dev); - VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserBase *vub = VHOST_USER_BASE(dev); + VHostUserBaseClass *vubc = VHOST_USER_BASE_GET_CLASS(dev); - vhost_dev_set_config_notifier(&vhi->vhost->dev, &config_ops); - vinput->cfg_size = sizeof_field(virtio_input_config, u); - if (vhost_user_backend_dev_init(vhi->vhost, vdev, 2, errp) == -1) { - return; - } -} + /* Fixed for input device */ + vub->virtio_id = VIRTIO_ID_INPUT; + vub->num_vqs = 2; + vub->vq_size = 4; + vub->config_size = sizeof(virtio_input_config); -static void vhost_input_change_active(VirtIOInput *vinput) -{ - VHostUserInput *vhi = VHOST_USER_INPUT(vinput); - - if (vinput->active) { - vhost_user_backend_start(vhi->vhost); - } else { - vhost_user_backend_stop(vhi->vhost); - } -} - -static void vhost_input_get_config(VirtIODevice *vdev, uint8_t *config_data) -{ - VirtIOInput *vinput = VIRTIO_INPUT(vdev); - VHostUserInput *vhi = VHOST_USER_INPUT(vdev); - Error *local_err = NULL; - int ret; - - memset(config_data, 0, vinput->cfg_size); - - ret = vhost_dev_get_config(&vhi->vhost->dev, config_data, vinput->cfg_size, - &local_err); - if (ret) { - error_report_err(local_err); - return; - } -} - -static void vhost_input_set_config(VirtIODevice *vdev, - const uint8_t *config_data) -{ - VHostUserInput *vhi = VHOST_USER_INPUT(vdev); - int ret; - - ret = vhost_dev_set_config(&vhi->vhost->dev, config_data, - 0, sizeof(virtio_input_config), - VHOST_SET_CONFIG_TYPE_FRONTEND); - if (ret) { - error_report("vhost-user-input: set device config space failed"); - return; - } - - virtio_notify_config(vdev); -} - -static struct vhost_dev *vhost_input_get_vhost(VirtIODevice *vdev) -{ - VHostUserInput *vhi = VHOST_USER_INPUT(vdev); - return &vhi->vhost->dev; + vubc->parent_realize(dev, errp); } static const VMStateDescription vmstate_vhost_input = { @@ -91,40 +33,20 @@ static const VMStateDescription vmstate_vhost_input = { static void vhost_input_class_init(ObjectClass *klass, void *data) { - VirtIOInputClass *vic = VIRTIO_INPUT_CLASS(klass); - VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass); dc->vmsd = &vmstate_vhost_input; - vdc->get_config = vhost_input_get_config; - vdc->set_config = vhost_input_set_config; - vdc->get_vhost = vhost_input_get_vhost; - vic->realize = vhost_input_realize; - vic->change_active = vhost_input_change_active; -} - -static void vhost_input_init(Object *obj) -{ - VHostUserInput *vhi = VHOST_USER_INPUT(obj); - - vhi->vhost = VHOST_USER_BACKEND(object_new(TYPE_VHOST_USER_BACKEND)); - object_property_add_alias(obj, "chardev", - OBJECT(vhi->vhost), "chardev"); -} - -static void vhost_input_finalize(Object *obj) -{ - VHostUserInput *vhi = VHOST_USER_INPUT(obj); - - object_unref(OBJECT(vhi->vhost)); + device_class_set_props(dc, vinput_properties); + device_class_set_parent_realize(dc, vinput_realize, + &vubc->parent_realize); + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } static const TypeInfo vhost_input_info = { .name = TYPE_VHOST_USER_INPUT, - .parent = TYPE_VIRTIO_INPUT, + .parent = TYPE_VHOST_USER_BASE, .instance_size = sizeof(VHostUserInput), - .instance_init = vhost_input_init, - .instance_finalize = vhost_input_finalize, .class_init = vhost_input_class_init, }; From patchwork Wed Feb 14 11:13:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898826 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LIza2Ozc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbFG1VKbz23j8 for ; Wed, 14 Feb 2024 22:14:42 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDS-0000IP-It; Wed, 14 Feb 2024 06:14:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDM-0000Ax-3N for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDD-0006mR-7y for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pNWPNdaeH/gm2+Fuc6t0CFL+yHMh3buRTqg9OHqLxYg=; b=LIza2OzcMqIPC4lL1k0LgdnZ+EepkGNFs/dhR6EUvlIIT/ETu41K/QU3RIKirTRzZZG5sj 1Z91VLWyu0RQZXgYOyvzmyJ8ZIWvSX5gKmNnQ2k11x6WrhaPJ4uk2AjeXVxaVkdLASHqR3 6u2Div7+xMae5hNDQMeph1s9S123jrE= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-321-VX0J20qoMLmm4FTcaIUzPg-1; Wed, 14 Feb 2024 06:13:57 -0500 X-MC-Unique: VX0J20qoMLmm4FTcaIUzPg-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-5114f2a1e81so1843829e87.1 for ; Wed, 14 Feb 2024 03:13:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909235; x=1708514035; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=pNWPNdaeH/gm2+Fuc6t0CFL+yHMh3buRTqg9OHqLxYg=; b=JNQIPUrOHKwfhINv48NBjTlrG5kfeUoAuHDsg2hqZiyghSiq8yg/x5k2/NtuAJNJRo N96LfawRc8D7KZBPgbicajYDq1l9CyIsWz6hRnTwQBvOCFAhHqAQjt0B9DAmAe2OovUT 8SW6biJ4UE3w+YAPGc2lxVRer/RtK3pMCG7IZ7DoftD2dB5JlqsBkAKN1zYH17qb5u/d qCtlU/esI90DnfAg38B8lYb4coxrKORjofxQrh0AmonjbTNMhKZJu0tLEYpF6cKF+eoR Kmn4VQV29fqOqR0Q+Bgk2O3uYPQ6CzNaSIrqY4H8MLodaOC5E4cZXJuFbUjiEyH9ekov 9KTg== X-Gm-Message-State: AOJu0YxMw4Wd3etzzTERR+567rtF4BoQGv9PzNG7UGm9+wxtSsAey0vx UUQh4KUE7sExp6F4Tw0F4ir8iUybvvelgSUWo2sVnNIIrna6GxFQECWi3ean49jPXohOdZfLd0S VNRnUMBNpx8Ze2wiRyrw+X3QUfdaF41iyJwQD045mghgFYczKm/vmJnzsa7SsV65/ipV/pbxzfG GvqhrKYWQAey0SYLk6jJFCc6dMiRiyRQ== X-Received: by 2002:ac2:483c:0:b0:511:8b33:6c72 with SMTP id 28-20020ac2483c000000b005118b336c72mr1559614lft.47.1707909234979; Wed, 14 Feb 2024 03:13:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHi3EkOzzfe+qbA14LdRGgIHwn+PpD7zGPn8bFLmlyMv/AYtKcMbYZ8mCcEEsrVg7GNH42bAA== X-Received: by 2002:ac2:483c:0:b0:511:8b33:6c72 with SMTP id 28-20020ac2483c000000b005118b336c72mr1559603lft.47.1707909234598; Wed, 14 Feb 2024 03:13:54 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUlfO48icVbYx/2bL46+VoxP/+vh/tCWiXAjqg88ei4dKkXm1N3Eur0KSCSQ7CIzALMkZpOPPNJhvE+7S7vCyMJFLmejnqdXmuly07TRPzPUiSU8ksmp/d8rSzk1ye0/WTD8Au+6B6wB/rcM24761Enxr+cWfl3TmmvIgmKsRSmw/dCgxl7dkMxYuRb8mLyphOvJ7vLRGo8TNQTNKvMt4AdRkypav9TmcZUpsVS Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id fi27-20020a056402551b00b0055edfb81384sm4496217edb.60.2024.02.14.03.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:13:53 -0800 (PST) Date: Wed, 14 Feb 2024 06:13:51 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bui Quang Minh , Paolo Bonzini , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost Subject: [PULL 12/60] i386/tcg: implement x2APIC registers MSR access Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bui Quang Minh This commit creates apic_register_read/write which are used by both apic_mem_read/write for MMIO access and apic_msr_read/write for MSR access. The apic_msr_read/write returns -1 on error, accelerator can use this to raise the appropriate exception. Signed-off-by: Bui Quang Minh Message-Id: <20240111154404.5333-2-minhquangbui99@gmail.com> Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/apic.h | 3 + target/i386/cpu.h | 3 + hw/intc/apic.c | 122 ++++++++++++++++++++------- target/i386/tcg/sysemu/misc_helper.c | 27 ++++++ hw/intc/trace-events | 4 +- 5 files changed, 127 insertions(+), 32 deletions(-) diff --git a/include/hw/i386/apic.h b/include/hw/i386/apic.h index bdc15a7a73..ddea4213db 100644 --- a/include/hw/i386/apic.h +++ b/include/hw/i386/apic.h @@ -18,6 +18,9 @@ void apic_sipi(DeviceState *s); void apic_poll_irq(DeviceState *d); void apic_designate_bsp(DeviceState *d, bool bsp); int apic_get_highest_priority_irr(DeviceState *dev); +int apic_msr_read(int index, uint64_t *val); +int apic_msr_write(int index, uint64_t val); +bool is_x2apic_mode(DeviceState *d); /* pc.c */ DeviceState *cpu_get_current_apic(void); diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 6a5b180ccb..afabdeab75 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -545,6 +545,9 @@ typedef enum X86Seg { #define MSR_IA32_VMX_TRUE_ENTRY_CTLS 0x00000490 #define MSR_IA32_VMX_VMFUNC 0x00000491 +#define MSR_APIC_START 0x00000800 +#define MSR_APIC_END 0x000008ff + #define XSTATE_FP_BIT 0 #define XSTATE_SSE_BIT 1 #define XSTATE_YMM_BIT 2 diff --git a/hw/intc/apic.c b/hw/intc/apic.c index ac3d47d231..7a349c0723 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -288,6 +288,13 @@ void apic_deliver_irq(uint8_t dest, uint8_t dest_mode, uint8_t delivery_mode, apic_bus_deliver(deliver_bitmask, delivery_mode, vector_num, trigger_mode); } +bool is_x2apic_mode(DeviceState *dev) +{ + APICCommonState *s = APIC(dev); + + return s->apicbase & MSR_IA32_APICBASE_EXTD; +} + static void apic_set_base(APICCommonState *s, uint64_t val) { s->apicbase = (val & 0xfffff000) | @@ -636,24 +643,19 @@ static void apic_timer(void *opaque) apic_timer_update(s, s->next_time); } -static uint64_t apic_mem_read(void *opaque, hwaddr addr, unsigned size) +static int apic_register_read(int index, uint64_t *value) { DeviceState *dev; APICCommonState *s; uint32_t val; - int index; - - if (size < 4) { - return 0; - } + int ret = 0; dev = cpu_get_current_apic(); if (!dev) { - return 0; + return -1; } s = APIC(dev); - index = (addr >> 4) & 0xff; switch(index) { case 0x02: /* id */ val = s->id << 24; @@ -718,12 +720,46 @@ static uint64_t apic_mem_read(void *opaque, hwaddr addr, unsigned size) default: s->esr |= APIC_ESR_ILLEGAL_ADDRESS; val = 0; + ret = -1; break; } - trace_apic_mem_readl(addr, val); + + trace_apic_register_read(index, val); + *value = val; + return ret; +} + +static uint64_t apic_mem_read(void *opaque, hwaddr addr, unsigned size) +{ + uint64_t val; + int index; + + if (size < 4) { + return 0; + } + + index = (addr >> 4) & 0xff; + apic_register_read(index, &val); + return val; } +int apic_msr_read(int index, uint64_t *val) +{ + DeviceState *dev; + + dev = cpu_get_current_apic(); + if (!dev) { + return -1; + } + + if (!is_x2apic_mode(dev)) { + return -1; + } + + return apic_register_read(index, val); +} + static void apic_send_msi(MSIMessage *msi) { uint64_t addr = msi->address; @@ -737,35 +773,18 @@ static void apic_send_msi(MSIMessage *msi) apic_deliver_irq(dest, dest_mode, delivery, vector, trigger_mode); } -static void apic_mem_write(void *opaque, hwaddr addr, uint64_t val, - unsigned size) +static int apic_register_write(int index, uint64_t val) { DeviceState *dev; APICCommonState *s; - int index = (addr >> 4) & 0xff; - - if (size < 4) { - return; - } - - if (addr > 0xfff || !index) { - /* MSI and MMIO APIC are at the same memory location, - * but actually not on the global bus: MSI is on PCI bus - * APIC is connected directly to the CPU. - * Mapping them on the global bus happens to work because - * MSI registers are reserved in APIC MMIO and vice versa. */ - MSIMessage msi = { .address = addr, .data = val }; - apic_send_msi(&msi); - return; - } dev = cpu_get_current_apic(); if (!dev) { - return; + return -1; } s = APIC(dev); - trace_apic_mem_writel(addr, val); + trace_apic_register_write(index, val); switch(index) { case 0x02: @@ -839,8 +858,51 @@ static void apic_mem_write(void *opaque, hwaddr addr, uint64_t val, break; default: s->esr |= APIC_ESR_ILLEGAL_ADDRESS; - break; + return -1; } + + return 0; +} + +static void apic_mem_write(void *opaque, hwaddr addr, uint64_t val, + unsigned size) +{ + int index = (addr >> 4) & 0xff; + + if (size < 4) { + return; + } + + if (addr > 0xfff || !index) { + /* + * MSI and MMIO APIC are at the same memory location, + * but actually not on the global bus: MSI is on PCI bus + * APIC is connected directly to the CPU. + * Mapping them on the global bus happens to work because + * MSI registers are reserved in APIC MMIO and vice versa. + */ + MSIMessage msi = { .address = addr, .data = val }; + apic_send_msi(&msi); + return; + } + + apic_register_write(index, val); +} + +int apic_msr_write(int index, uint64_t val) +{ + DeviceState *dev; + + dev = cpu_get_current_apic(); + if (!dev) { + return -1; + } + + if (!is_x2apic_mode(dev)) { + return -1; + } + + return apic_register_write(index, val); } static void apic_pre_save(APICCommonState *s) diff --git a/target/i386/tcg/sysemu/misc_helper.c b/target/i386/tcg/sysemu/misc_helper.c index 1ddfc9fe09..1c43a9f4f7 100644 --- a/target/i386/tcg/sysemu/misc_helper.c +++ b/target/i386/tcg/sysemu/misc_helper.c @@ -25,6 +25,7 @@ #include "exec/address-spaces.h" #include "exec/exec-all.h" #include "tcg/helper-tcg.h" +#include "hw/i386/apic.h" void helper_outb(CPUX86State *env, uint32_t port, uint32_t data) { @@ -289,6 +290,19 @@ void helper_wrmsr(CPUX86State *env) env->msr_bndcfgs = val; cpu_sync_bndcs_hflags(env); break; + case MSR_APIC_START ... MSR_APIC_END: { + int ret; + int index = (uint32_t)env->regs[R_ECX] - MSR_APIC_START; + + bql_lock(); + ret = apic_msr_write(index, val); + bql_unlock(); + if (ret < 0) { + goto error; + } + + break; + } default: if ((uint32_t)env->regs[R_ECX] >= MSR_MC0_CTL && (uint32_t)env->regs[R_ECX] < MSR_MC0_CTL + @@ -455,6 +469,19 @@ void helper_rdmsr(CPUX86State *env) val = (cs->nr_threads * cs->nr_cores) | (cs->nr_cores << 16); break; } + case MSR_APIC_START ... MSR_APIC_END: { + int ret; + int index = (uint32_t)env->regs[R_ECX] - MSR_APIC_START; + + bql_lock(); + ret = apic_msr_read(index, &val); + bql_unlock(); + if (ret < 0) { + raise_exception_err_ra(env, EXCP0D_GPF, 0, GETPC()); + } + + break; + } default: if ((uint32_t)env->regs[R_ECX] >= MSR_MC0_CTL && (uint32_t)env->regs[R_ECX] < MSR_MC0_CTL + diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 36ff71f947..1ef29d0256 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -14,8 +14,8 @@ cpu_get_apic_base(uint64_t val) "0x%016"PRIx64 # apic.c apic_local_deliver(int vector, uint32_t lvt) "vector %d delivery mode %d" apic_deliver_irq(uint8_t dest, uint8_t dest_mode, uint8_t delivery_mode, uint8_t vector_num, uint8_t trigger_mode) "dest %d dest_mode %d delivery_mode %d vector %d trigger_mode %d" -apic_mem_readl(uint64_t addr, uint32_t val) "0x%"PRIx64" = 0x%08x" -apic_mem_writel(uint64_t addr, uint32_t val) "0x%"PRIx64" = 0x%08x" +apic_register_read(uint8_t reg, uint64_t val) "register 0x%02x = 0x%"PRIx64 +apic_register_write(uint8_t reg, uint64_t val) "register 0x%02x = 0x%"PRIx64 # ioapic.c ioapic_set_remote_irr(int n) "set remote irr for pin %d" From patchwork Wed Feb 14 11:13:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eBhY7IZw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbKf4cWkz23hM for ; Wed, 14 Feb 2024 22:18:30 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDU-0000TP-Da; Wed, 14 Feb 2024 06:14:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDQ-0000Dt-Iv for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDL-0006n4-RH for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kuMPa6Sdwt4odkOM9VRUJLd71CBRiHTHNkqSTHJLh8o=; b=eBhY7IZwYKlyQUjBxv8EYJ5MFTTteM6rETdWQAEQzjcIzTt7ZaRM1Rr3g+gmPzKhnTOAnZ UrV+FLvnPg9xuaNLl/slgj2yrQU6bPqZYtPgA37rSZoK1eQmk4pUzmtfy03OyIwJ5d/4p3 GkASvYUnfW50V9xaZFmVCEKHLpRFVLk= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-282-lVeGVbiRMzazLymJ-nUytA-1; Wed, 14 Feb 2024 06:14:01 -0500 X-MC-Unique: lVeGVbiRMzazLymJ-nUytA-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5621c809a3bso451100a12.2 for ; Wed, 14 Feb 2024 03:14:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909238; x=1708514038; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=kuMPa6Sdwt4odkOM9VRUJLd71CBRiHTHNkqSTHJLh8o=; b=gSgwxAaJoaRYg5DQnerFIkwZDnsoWolHyXNBJnqxPOnkN1sL0BYj2U3p8QABbOv6BY 6uUtIph/E+NZypIoiRxodCR62astTXv1Ah5GD9242CGOkP2knaFuYYxRrGAbgaf6570r LlmnbpIIE+/RA1WsJag6+MTCjre5QeDj4bWzUdy7t1dcDi7JYIHH+BirHBNsjs9tX40r wZpWUSwExpW0dRuSOH7penx4e2r4qkDvi1f1mforFh+W6nJoYi89qHiaWRNEPEbEnaDS 4pJST5Mi9hvfeymSxutPWo38nf0P95ff5zT8naZu1V41LfTrzMLWddU9RCrK9aG8Ry2w eBHw== X-Gm-Message-State: AOJu0YwyTltB/Ujg+SNzXJBHwwjDDtAVjEItDs48AMEEqHfILqHpPRDs YRpewHYu+FrnWxKBDjA1LvS1BMPJ0HVnaqEYLmhUSgo+cXpoxmmP6AmOCtImMteF25T85LbkJdq LnCESYEqfh9K4qNDM2zNDszXG5yO4XH6shwqYZ8o/yZv94v4dMnL2IFajgi8NrUoHRer6ZF26Sf 9tCYF8UZMnxw2pskDrJrI/WbDHFV9fDQ== X-Received: by 2002:a05:6402:1501:b0:561:1b5e:14f0 with SMTP id f1-20020a056402150100b005611b5e14f0mr1799269edw.8.1707909238181; Wed, 14 Feb 2024 03:13:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IEQfP4NNHIBe2MSbizJBAXSAyxzZqDIo1wps/ANvV/Xk2uQZeCoNbyiCEK2tyZNHWCaH0g9PQ== X-Received: by 2002:a05:6402:1501:b0:561:1b5e:14f0 with SMTP id f1-20020a056402150100b005611b5e14f0mr1799248edw.8.1707909237712; Wed, 14 Feb 2024 03:13:57 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUYU+8eBjaj5a1xNVHyu5KFkGrEb3WzOkD8bpMVpQByN4c+EHKTJ/KzSc99nD3Dhyg47G10GzypQ4rKuw3ZStOQO+YO5/BTkQ7somrQp6TiVqjC/Sux7jmSw8MPysU+xW9AgoR6fRoQW0BVHwR6C3+oGNSLHhlM3ZmwVmalBss5+GZTIwtdXUC4N/eUkp8DQoie/AfHoywKOaBP8CFYCSB5LjkpJxf7H64A7l// Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id g14-20020a056402428e00b0055fba4996d9sm4571428edc.71.2024.02.14.03.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:13:57 -0800 (PST) Date: Wed, 14 Feb 2024 06:13:54 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bui Quang Minh , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 13/60] apic: add support for x2APIC mode Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bui Quang Minh This commit extends the APIC ID to 32-bit long and remove the 255 max APIC ID limit in userspace APIC. The array that manages local APICs is now dynamically allocated based on the max APIC ID of created x86 machine. Also, new x2APIC IPI destination determination scheme, self IPI and x2APIC mode register access are supported. Signed-off-by: Bui Quang Minh Message-Id: <20240111154404.5333-3-minhquangbui99@gmail.com> Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/apic.h | 3 +- include/hw/i386/apic_internal.h | 7 +- target/i386/cpu.h | 2 + hw/i386/x86.c | 6 +- hw/intc/apic.c | 287 ++++++++++++++++++++++++-------- hw/intc/apic_common.c | 9 + target/i386/cpu-sysemu.c | 18 +- 7 files changed, 258 insertions(+), 74 deletions(-) diff --git a/include/hw/i386/apic.h b/include/hw/i386/apic.h index ddea4213db..c8ca41ab44 100644 --- a/include/hw/i386/apic.h +++ b/include/hw/i386/apic.h @@ -3,8 +3,7 @@ /* apic.c */ -void apic_deliver_irq(uint8_t dest, uint8_t dest_mode, uint8_t delivery_mode, - uint8_t vector_num, uint8_t trigger_mode); +void apic_set_max_apic_id(uint32_t max_apic_id); int apic_accept_pic_intr(DeviceState *s); void apic_deliver_pic_intr(DeviceState *s, int level); void apic_deliver_nmi(DeviceState *d); diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_internal.h index 5f2ba24bfc..e796e6cae3 100644 --- a/include/hw/i386/apic_internal.h +++ b/include/hw/i386/apic_internal.h @@ -46,8 +46,10 @@ #define APIC_DM_EXTINT 7 /* APIC destination mode */ -#define APIC_DESTMODE_FLAT 0xf -#define APIC_DESTMODE_CLUSTER 1 +#define APIC_DESTMODE_PHYSICAL 0 +#define APIC_DESTMODE_LOGICAL 1 +#define APIC_DESTMODE_LOGICAL_FLAT 0xf +#define APIC_DESTMODE_LOGICAL_CLUSTER 0 #define APIC_TRIGGER_EDGE 0 #define APIC_TRIGGER_LEVEL 1 @@ -187,6 +189,7 @@ struct APICCommonState { DeviceState *vapic; hwaddr vapic_paddr; /* note: persistence via kvmvapic */ bool legacy_instance_id; + uint32_t extended_log_dest; }; typedef struct VAPICState { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index afabdeab75..08eaa61c56 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2239,8 +2239,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx); void cpu_clear_apic_feature(CPUX86State *env); +void cpu_set_apic_feature(CPUX86State *env); void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx); +bool cpu_has_x2apic_feature(CPUX86State *env); /* helper.c */ void x86_cpu_set_a20(X86CPU *cpu, int a20_state); diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 2b6291ad8d..3d1bdd334e 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -137,7 +137,7 @@ void x86_cpus_init(X86MachineState *x86ms, int default_cpu_version) * a literal `0` in configurations where kvm_* aren't defined) */ if (kvm_enabled() && x86ms->apic_id_limit > 255 && - (!kvm_irqchip_in_kernel() || !kvm_enable_x2apic())) { + kvm_irqchip_in_kernel() && !kvm_enable_x2apic()) { error_report("current -smp configuration requires kernel " "irqchip and X2APIC API support."); exit(EXIT_FAILURE); @@ -147,6 +147,10 @@ void x86_cpus_init(X86MachineState *x86ms, int default_cpu_version) kvm_set_max_apic_id(x86ms->apic_id_limit); } + if (!kvm_irqchip_in_kernel()) { + apic_set_max_apic_id(x86ms->apic_id_limit); + } + possible_cpus = mc->possible_cpu_arch_ids(ms); for (i = 0; i < ms->smp.cpus; i++) { x86_cpu_new(x86ms, possible_cpus->cpus[i].arch_id, &error_fatal); diff --git a/hw/intc/apic.c b/hw/intc/apic.c index 7a349c0723..178fb26b47 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -32,14 +32,13 @@ #include "qapi/error.h" #include "qom/object.h" -#define MAX_APICS 255 -#define MAX_APIC_WORDS 8 - #define SYNC_FROM_VAPIC 0x1 #define SYNC_TO_VAPIC 0x2 #define SYNC_ISR_IRR_TO_VAPIC 0x4 -static APICCommonState *local_apics[MAX_APICS + 1]; +static APICCommonState **local_apics; +static uint32_t max_apics; +static uint32_t max_apic_words; #define TYPE_APIC "apic" /*This is reusing the APICCommonState typedef from APIC_COMMON */ @@ -49,7 +48,19 @@ DECLARE_INSTANCE_CHECKER(APICCommonState, APIC, static void apic_set_irq(APICCommonState *s, int vector_num, int trigger_mode); static void apic_update_irq(APICCommonState *s); static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask, - uint8_t dest, uint8_t dest_mode); + uint32_t dest, uint8_t dest_mode); + +void apic_set_max_apic_id(uint32_t max_apic_id) +{ + int word_size = 32; + + /* round up the max apic id to next multiple of words */ + max_apics = (max_apic_id + word_size - 1) & ~(word_size - 1); + + local_apics = g_malloc0(sizeof(*local_apics) * max_apics); + max_apic_words = max_apics >> 5; +} + /* Find first bit starting from msb */ static int apic_fls_bit(uint32_t value) @@ -199,10 +210,10 @@ static void apic_external_nmi(APICCommonState *s) #define foreach_apic(apic, deliver_bitmask, code) \ {\ int __i, __j;\ - for(__i = 0; __i < MAX_APIC_WORDS; __i++) {\ + for (__i = 0; __i < max_apic_words; __i++) {\ uint32_t __mask = deliver_bitmask[__i];\ if (__mask) {\ - for(__j = 0; __j < 32; __j++) {\ + for (__j = 0; __j < 32; __j++) {\ if (__mask & (1U << __j)) {\ apic = local_apics[__i * 32 + __j];\ if (apic) {\ @@ -226,7 +237,7 @@ static void apic_bus_deliver(const uint32_t *deliver_bitmask, { int i, d; d = -1; - for(i = 0; i < MAX_APIC_WORDS; i++) { + for (i = 0; i < max_apic_words; i++) { if (deliver_bitmask[i]) { d = i * 32 + apic_ffs_bit(deliver_bitmask[i]); break; @@ -276,16 +287,18 @@ static void apic_bus_deliver(const uint32_t *deliver_bitmask, apic_set_irq(apic_iter, vector_num, trigger_mode) ); } -void apic_deliver_irq(uint8_t dest, uint8_t dest_mode, uint8_t delivery_mode, - uint8_t vector_num, uint8_t trigger_mode) +static void apic_deliver_irq(uint32_t dest, uint8_t dest_mode, + uint8_t delivery_mode, uint8_t vector_num, + uint8_t trigger_mode) { - uint32_t deliver_bitmask[MAX_APIC_WORDS]; + uint32_t *deliver_bitmask = g_malloc(max_apic_words * sizeof(uint32_t)); trace_apic_deliver_irq(dest, dest_mode, delivery_mode, vector_num, trigger_mode); apic_get_delivery_bitmask(deliver_bitmask, dest, dest_mode); apic_bus_deliver(deliver_bitmask, delivery_mode, vector_num, trigger_mode); + g_free(deliver_bitmask); } bool is_x2apic_mode(DeviceState *dev) @@ -442,57 +455,123 @@ static void apic_eoi(APICCommonState *s) apic_update_irq(s); } -static int apic_find_dest(uint8_t dest) +static bool apic_match_dest(APICCommonState *apic, uint32_t dest) { - APICCommonState *apic = local_apics[dest]; + if (is_x2apic_mode(&apic->parent_obj)) { + return apic->initial_apic_id == dest; + } else { + return apic->id == (uint8_t)dest; + } +} + +static void apic_find_dest(uint32_t *deliver_bitmask, uint32_t dest) +{ + APICCommonState *apic = NULL; int i; - if (apic && apic->id == dest) - return dest; /* shortcut in case apic->id == local_apics[dest]->id */ - - for (i = 0; i < MAX_APICS; i++) { + for (i = 0; i < max_apics; i++) { apic = local_apics[i]; - if (apic && apic->id == dest) - return i; - if (!apic) - break; + if (apic && apic_match_dest(apic, dest)) { + apic_set_bit(deliver_bitmask, i); + } } +} - return -1; +/* + * Deliver interrupt to x2APIC CPUs if it is x2APIC broadcast. + * Otherwise, deliver interrupt to xAPIC CPUs if it is xAPIC + * broadcast. + */ +static void apic_get_broadcast_bitmask(uint32_t *deliver_bitmask, + bool is_x2apic_broadcast) +{ + int i; + APICCommonState *apic_iter; + + for (i = 0; i < max_apics; i++) { + apic_iter = local_apics[i]; + if (apic_iter) { + bool apic_in_x2apic = is_x2apic_mode(&apic_iter->parent_obj); + + if (is_x2apic_broadcast && apic_in_x2apic) { + apic_set_bit(deliver_bitmask, i); + } else if (!is_x2apic_broadcast && !apic_in_x2apic) { + apic_set_bit(deliver_bitmask, i); + } + } + } } static void apic_get_delivery_bitmask(uint32_t *deliver_bitmask, - uint8_t dest, uint8_t dest_mode) + uint32_t dest, uint8_t dest_mode) { - APICCommonState *apic_iter; + APICCommonState *apic; int i; - if (dest_mode == 0) { - if (dest == 0xff) { - memset(deliver_bitmask, 0xff, MAX_APIC_WORDS * sizeof(uint32_t)); + memset(deliver_bitmask, 0x00, max_apic_words * sizeof(uint32_t)); + + /* + * x2APIC broadcast is delivered to all x2APIC CPUs regardless of + * destination mode. In case the destination mode is physical, it is + * broadcasted to all xAPIC CPUs too. Otherwise, if the destination + * mode is logical, we need to continue checking if xAPIC CPUs accepts + * the interrupt. + */ + if (dest == 0xffffffff) { + if (dest_mode == APIC_DESTMODE_PHYSICAL) { + memset(deliver_bitmask, 0xff, max_apic_words * sizeof(uint32_t)); + return; } else { - int idx = apic_find_dest(dest); - memset(deliver_bitmask, 0x00, MAX_APIC_WORDS * sizeof(uint32_t)); - if (idx >= 0) - apic_set_bit(deliver_bitmask, idx); + apic_get_broadcast_bitmask(deliver_bitmask, true); + } + } + + if (dest_mode == APIC_DESTMODE_PHYSICAL) { + apic_find_dest(deliver_bitmask, dest); + /* Any APIC in xAPIC mode will interpret 0xFF as broadcast */ + if (dest == 0xff) { + apic_get_broadcast_bitmask(deliver_bitmask, false); } } else { - /* XXX: cluster mode */ - memset(deliver_bitmask, 0x00, MAX_APIC_WORDS * sizeof(uint32_t)); - for(i = 0; i < MAX_APICS; i++) { - apic_iter = local_apics[i]; - if (apic_iter) { - if (apic_iter->dest_mode == 0xf) { - if (dest & apic_iter->log_dest) - apic_set_bit(deliver_bitmask, i); - } else if (apic_iter->dest_mode == 0x0) { - if ((dest & 0xf0) == (apic_iter->log_dest & 0xf0) && - (dest & apic_iter->log_dest & 0x0f)) { + /* XXX: logical mode */ + for (i = 0; i < max_apics; i++) { + apic = local_apics[i]; + if (apic) { + /* x2APIC logical mode */ + if (apic->apicbase & MSR_IA32_APICBASE_EXTD) { + if ((dest >> 16) == (apic->extended_log_dest >> 16) && + (dest & apic->extended_log_dest & 0xffff)) { apic_set_bit(deliver_bitmask, i); } + continue; } - } else { - break; + + /* xAPIC logical mode */ + dest = (uint8_t)dest; + if (apic->dest_mode == APIC_DESTMODE_LOGICAL_FLAT) { + if (dest & apic->log_dest) { + apic_set_bit(deliver_bitmask, i); + } + } else if (apic->dest_mode == APIC_DESTMODE_LOGICAL_CLUSTER) { + /* + * In cluster model of xAPIC logical mode IPI, 4 higher + * bits are used as cluster address, 4 lower bits are + * the bitmask for local APICs in the cluster. The IPI + * is delivered to an APIC if the cluster address + * matches and the APIC's address bit in the cluster is + * set in bitmask of destination ID in IPI. + * + * The cluster address ranges from 0 - 14, the cluster + * address 15 (0xf) is the broadcast address to all + * clusters. + */ + if ((dest & 0xf0) == 0xf0 || + (dest & 0xf0) == (apic->log_dest & 0xf0)) { + if (dest & apic->log_dest & 0x0f) { + apic_set_bit(deliver_bitmask, i); + } + } + } } } } @@ -516,29 +595,36 @@ void apic_sipi(DeviceState *dev) s->wait_for_sipi = 0; } -static void apic_deliver(DeviceState *dev, uint8_t dest, uint8_t dest_mode, +static void apic_deliver(DeviceState *dev, uint32_t dest, uint8_t dest_mode, uint8_t delivery_mode, uint8_t vector_num, - uint8_t trigger_mode) + uint8_t trigger_mode, uint8_t dest_shorthand) { APICCommonState *s = APIC(dev); - uint32_t deliver_bitmask[MAX_APIC_WORDS]; - int dest_shorthand = (s->icr[0] >> 18) & 3; APICCommonState *apic_iter; + uint32_t deliver_bitmask_size = max_apic_words * sizeof(uint32_t); + uint32_t *deliver_bitmask = g_malloc(deliver_bitmask_size); + uint32_t current_apic_id; + + if (is_x2apic_mode(dev)) { + current_apic_id = s->initial_apic_id; + } else { + current_apic_id = s->id; + } switch (dest_shorthand) { case 0: apic_get_delivery_bitmask(deliver_bitmask, dest, dest_mode); break; case 1: - memset(deliver_bitmask, 0x00, sizeof(deliver_bitmask)); - apic_set_bit(deliver_bitmask, s->id); + memset(deliver_bitmask, 0x00, deliver_bitmask_size); + apic_set_bit(deliver_bitmask, current_apic_id); break; case 2: - memset(deliver_bitmask, 0xff, sizeof(deliver_bitmask)); + memset(deliver_bitmask, 0xff, deliver_bitmask_size); break; case 3: - memset(deliver_bitmask, 0xff, sizeof(deliver_bitmask)); - apic_reset_bit(deliver_bitmask, s->id); + memset(deliver_bitmask, 0xff, deliver_bitmask_size); + apic_reset_bit(deliver_bitmask, current_apic_id); break; } @@ -562,6 +648,7 @@ static void apic_deliver(DeviceState *dev, uint8_t dest, uint8_t dest_mode, } apic_bus_deliver(deliver_bitmask, delivery_mode, vector_num, trigger_mode); + g_free(deliver_bitmask); } static bool apic_check_pic(APICCommonState *s) @@ -658,7 +745,11 @@ static int apic_register_read(int index, uint64_t *value) switch(index) { case 0x02: /* id */ - val = s->id << 24; + if (is_x2apic_mode(dev)) { + val = s->initial_apic_id; + } else { + val = s->id << 24; + } break; case 0x03: /* version */ val = s->version | ((APIC_LVT_NB - 1) << 16); @@ -681,10 +772,19 @@ static int apic_register_read(int index, uint64_t *value) val = 0; break; case 0x0d: - val = s->log_dest << 24; + if (is_x2apic_mode(dev)) { + val = s->extended_log_dest; + } else { + val = s->log_dest << 24; + } break; case 0x0e: - val = (s->dest_mode << 28) | 0xfffffff; + if (is_x2apic_mode(dev)) { + val = 0; + ret = -1; + } else { + val = (s->dest_mode << 28) | 0xfffffff; + } break; case 0x0f: val = s->spurious_vec; @@ -764,7 +864,12 @@ static void apic_send_msi(MSIMessage *msi) { uint64_t addr = msi->address; uint32_t data = msi->data; - uint8_t dest = (addr & MSI_ADDR_DEST_ID_MASK) >> MSI_ADDR_DEST_ID_SHIFT; + uint32_t dest = (addr & MSI_ADDR_DEST_ID_MASK) >> MSI_ADDR_DEST_ID_SHIFT; + /* + * The higher 3 bytes of destination id is stored in higher word of + * msi address. See x86_iommu_irq_to_msi_message() + */ + dest = dest | (addr >> 32); uint8_t vector = (data & MSI_DATA_VECTOR_MASK) >> MSI_DATA_VECTOR_SHIFT; uint8_t dest_mode = (addr >> MSI_ADDR_DEST_MODE_SHIFT) & 0x1; uint8_t trigger_mode = (data >> MSI_DATA_TRIGGER_SHIFT) & 0x1; @@ -788,6 +893,10 @@ static int apic_register_write(int index, uint64_t val) switch(index) { case 0x02: + if (is_x2apic_mode(dev)) { + return -1; + } + s->id = (val >> 24); break; case 0x03: @@ -807,9 +916,17 @@ static int apic_register_write(int index, uint64_t val) apic_eoi(s); break; case 0x0d: + if (is_x2apic_mode(dev)) { + return -1; + } + s->log_dest = val >> 24; break; case 0x0e: + if (is_x2apic_mode(dev)) { + return -1; + } + s->dest_mode = val >> 28; break; case 0x0f: @@ -821,13 +938,27 @@ static int apic_register_write(int index, uint64_t val) case 0x20 ... 0x27: case 0x28: break; - case 0x30: + case 0x30: { + uint32_t dest; + s->icr[0] = val; - apic_deliver(dev, (s->icr[1] >> 24) & 0xff, (s->icr[0] >> 11) & 1, + if (is_x2apic_mode(dev)) { + s->icr[1] = val >> 32; + dest = s->icr[1]; + } else { + dest = (s->icr[1] >> 24) & 0xff; + } + + apic_deliver(dev, dest, (s->icr[0] >> 11) & 1, (s->icr[0] >> 8) & 7, (s->icr[0] & 0xff), - (s->icr[0] >> 15) & 1); + (s->icr[0] >> 15) & 1, (s->icr[0] >> 18) & 3); break; + } case 0x31: + if (is_x2apic_mode(dev)) { + return -1; + } + s->icr[1] = val; break; case 0x32 ... 0x37: @@ -856,6 +987,23 @@ static int apic_register_write(int index, uint64_t val) s->count_shift = (v + 1) & 7; } break; + case 0x3f: { + int vector = val & 0xff; + + if (!is_x2apic_mode(dev)) { + return -1; + } + + /* + * Self IPI is identical to IPI with + * - Destination shorthand: 1 (Self) + * - Trigger mode: 0 (Edge) + * - Delivery mode: 0 (Fixed) + */ + apic_deliver(dev, 0, 0, APIC_DM_FIXED, vector, 0, 1); + + break; + } default: s->esr |= APIC_ESR_ILLEGAL_ADDRESS; return -1; @@ -933,12 +1081,6 @@ static void apic_realize(DeviceState *dev, Error **errp) { APICCommonState *s = APIC(dev); - if (s->id >= MAX_APICS) { - error_setg(errp, "%s initialization failed. APIC ID %d is invalid", - object_get_typename(OBJECT(dev)), s->id); - return; - } - if (kvm_enabled()) { warn_report("Userspace local APIC is deprecated for KVM."); warn_report("Do not use kernel-irqchip except for the -M isapc machine type."); @@ -955,7 +1097,16 @@ static void apic_realize(DeviceState *dev, Error **errp) s->io_memory.disable_reentrancy_guard = true; s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, apic_timer, s); - local_apics[s->id] = s; + + /* + * The --machine none does not call apic_set_max_apic_id before creating + * apic, so we need to call it here and set it to 1 which is the max cpus + * in machine none. + */ + if (!local_apics) { + apic_set_max_apic_id(1); + } + local_apics[s->initial_apic_id] = s; msi_nonbroken = true; } @@ -965,7 +1116,7 @@ static void apic_unrealize(DeviceState *dev) APICCommonState *s = APIC(dev); timer_free(s->timer); - local_apics[s->id] = NULL; + local_apics[s->initial_apic_id] = NULL; } static void apic_class_init(ObjectClass *klass, void *data) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index 6c100b48d6..3c43ac9a1d 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -287,6 +287,10 @@ static void apic_common_realize(DeviceState *dev, Error **errp) } vmstate_register_with_alias_id(NULL, instance_id, &vmstate_apic_common, s, -1, 0, NULL); + + /* APIC LDR in x2APIC mode */ + s->extended_log_dest = ((s->initial_apic_id >> 4) << 16) | + (1 << (s->initial_apic_id & 0xf)); } static void apic_common_unrealize(DeviceState *dev) @@ -427,6 +431,11 @@ static void apic_common_set_id(Object *obj, Visitor *v, const char *name, return; } + if (value >= 255 && !cpu_has_x2apic_feature(&s->cpu->env)) { + error_setg(errp, "APIC ID %d requires x2APIC feature in CPU", value); + return; + } + s->initial_apic_id = value; s->id = (uint8_t)value; } diff --git a/target/i386/cpu-sysemu.c b/target/i386/cpu-sysemu.c index 2375e48178..7422096737 100644 --- a/target/i386/cpu-sysemu.c +++ b/target/i386/cpu-sysemu.c @@ -235,6 +235,16 @@ void cpu_clear_apic_feature(CPUX86State *env) env->features[FEAT_1_EDX] &= ~CPUID_APIC; } +void cpu_set_apic_feature(CPUX86State *env) +{ + env->features[FEAT_1_EDX] |= CPUID_APIC; +} + +bool cpu_has_x2apic_feature(CPUX86State *env) +{ + return env->features[FEAT_1_ECX] & CPUID_EXT_X2APIC; +} + bool cpu_is_bsp(X86CPU *cpu) { return cpu_get_apic_base(cpu->apic_state) & MSR_IA32_APICBASE_BSP; @@ -281,11 +291,17 @@ void x86_cpu_apic_create(X86CPU *cpu, Error **errp) OBJECT(cpu->apic_state)); object_unref(OBJECT(cpu->apic_state)); - qdev_prop_set_uint32(cpu->apic_state, "id", cpu->apic_id); /* TODO: convert to link<> */ apic = APIC_COMMON(cpu->apic_state); apic->cpu = cpu; apic->apicbase = APIC_DEFAULT_ADDRESS | MSR_IA32_APICBASE_ENABLE; + + /* + * apic_common_set_id needs to check if the CPU has x2APIC + * feature in case APIC ID >= 255, so we need to set apic->cpu + * before setting APIC ID + */ + qdev_prop_set_uint32(cpu->apic_state, "id", cpu->apic_id); } void x86_cpu_apic_realize(X86CPU *cpu, Error **errp) From patchwork Wed Feb 14 11:13:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898843 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Z0S/q/Hk; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbK448Mxz23y6 for ; Wed, 14 Feb 2024 22:18:00 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDU-0000Uu-P7; Wed, 14 Feb 2024 06:14:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDQ-0000DP-HD for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDL-0006nO-S5 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909246; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=c1T4mZW1Lt2fEcvTpJpGMJKvoac/0r1T6DraMR3Q2iM=; b=Z0S/q/Hkq2hpqo+Ygzs19Z1NaYy7ISdPxio7KCmGppHj8+qybZ0NFYXH2aKKxRa629oTxC XZnUDCukMDBA4QXy2gtYPFonultbGhHPGpI8SI789gTm/PVqMUdAT42aJEYWoIQeGoQm5J VPwxSorK6tvFSRqplKOr4YTafjolMAc= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-227-20oApC2QO0CIxgHAOR4oSg-1; Wed, 14 Feb 2024 06:14:05 -0500 X-MC-Unique: 20oApC2QO0CIxgHAOR4oSg-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a3bdd99a243so68558766b.0 for ; Wed, 14 Feb 2024 03:14:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909243; x=1708514043; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=c1T4mZW1Lt2fEcvTpJpGMJKvoac/0r1T6DraMR3Q2iM=; b=LuCvKQWhA0bHQg/KPntW96TxkQLQOYgOeX72iOZ2ZR9WgNhOUBa5k+len2YHuQxj2/ L1XBHsHZvy3Deo73q4yBXLzzAMW6k/prwxaW7EFrHFiYnRZslQXEaSOc2qFyL789//Xf QnFu9PHMxsmLcB2us1rquFcaCLbWfUgvAKUFqsRPSXz7K5rKhIds+NwQQaDHOpcclDJF hX0sJGGY1E42K7aIyopGOspp3MsIylZnP5XtPtkeMo/dDU86ZvhcdKAqd7vgzIwefo/N BfOhmQ354U0jJ0wd+aylc+Z46f+68qValpIMOECWbu2/Fu6zfNSpNmRyhN56sV182eNn 4Ojg== X-Gm-Message-State: AOJu0Yx9N6MpYHlDhvjQvUITkYEvalyr3lSwFoRHydn6rnWSE+vZnrtZ V7824wZ/6cQK0xrqoKj2cGSAGKEaKJb7R8l2FNaywLOuZl14q4ILRTYt70mlLPDqZtPiSh0YJPF Niz9ZRnv3QgHKNWUTkTO/Ekvaa4VEb88KfhxJRS14MtOy2xJWiTyLcA536xkRA4hjQM4K2AqNJk VYtOjwMMOaArNfZRb6LQTq3NuY/iUuHg== X-Received: by 2002:a17:906:aacb:b0:a3c:d0d0:4602 with SMTP id kt11-20020a170906aacb00b00a3cd0d04602mr1474615ejb.6.1707909243514; Wed, 14 Feb 2024 03:14:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IH8PGa8fe+YzlQNsaQxLZwEWdxHc893kIKDULDI4XVDmy08H/IvVqWGbByMSYsf44RIBF6RxQ== X-Received: by 2002:a17:906:aacb:b0:a3c:d0d0:4602 with SMTP id kt11-20020a170906aacb00b00a3cd0d04602mr1474559ejb.6.1707909242253; Wed, 14 Feb 2024 03:14:02 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXzRh2VKZgo8A+woJ9nPu2okdk+XErDylKqAwVKf+sraUsUJAczLmragZ3ncuj+Z6gPCv/6xLKry8uh0vcpB7oLoDWlHlKxDV1VU2kqdG7uW+KLSabxeWUYT0SJzIB8y5XTgOIhWIJoZyEJWTP7pIVzIPL9arbFi8oUEQJWNIwMy37kApC/rRlAPXUHbU75UO8npXBekk5cXAm+Zo7QQfoKktb99+icWJ8zFp6+HqJcuTP6Z95etyaO2pW2Hlji3fBUmakvB0UwdaD9NzPFIOknAMjRD/w9UM2GtuI+bD0a+H3DWT3O9EuqWWeL9phyZZ4edKF2UUA2k46f1aQhrj08zjpcdxPAXKMBomkkOgSwmAl40S95V6ImclLcuJ6meqzuR+YL2w== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id gv24-20020a170906f11800b00a3bd8a34b1bsm2212432ejb.164.2024.02.14.03.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:00 -0800 (PST) Date: Wed, 14 Feb 2024 06:13:57 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bui Quang Minh , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Stefano Stabellini , Anthony Perard , Paul Durrant , Sunil Muthuswamy , xen-devel@lists.xenproject.org Subject: [PULL 14/60] apic, i386/tcg: add x2apic transitions Message-ID: <774204cf9874e58dc7fc13394a505452357750ad.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bui Quang Minh This commit adds support for x2APIC transitions when writing to MSR_IA32_APICBASE register and finally adds CPUID_EXT_X2APIC to TCG_EXT_FEATURES. The set_base in APICCommonClass now returns an integer to indicate error in execution. apic_set_base return -1 on invalid APIC state transition, accelerator can use this to raise appropriate exception. Signed-off-by: Bui Quang Minh Message-Id: <20240111154404.5333-4-minhquangbui99@gmail.com> Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/apic.h | 2 +- include/hw/i386/apic_internal.h | 2 +- target/i386/cpu.h | 4 ++ hw/i386/kvm/apic.c | 3 +- hw/i386/xen/xen_apic.c | 3 +- hw/intc/apic.c | 62 +++++++++++++++++++++++++++- hw/intc/apic_common.c | 13 +++--- target/i386/cpu.c | 9 ++-- target/i386/tcg/sysemu/misc_helper.c | 14 ++++++- target/i386/whpx/whpx-apic.c | 3 +- 10 files changed, 96 insertions(+), 19 deletions(-) diff --git a/include/hw/i386/apic.h b/include/hw/i386/apic.h index c8ca41ab44..f6e7489f2d 100644 --- a/include/hw/i386/apic.h +++ b/include/hw/i386/apic.h @@ -8,7 +8,7 @@ int apic_accept_pic_intr(DeviceState *s); void apic_deliver_pic_intr(DeviceState *s, int level); void apic_deliver_nmi(DeviceState *d); int apic_get_interrupt(DeviceState *s); -void cpu_set_apic_base(DeviceState *s, uint64_t val); +int cpu_set_apic_base(DeviceState *s, uint64_t val); uint64_t cpu_get_apic_base(DeviceState *s); void cpu_set_apic_tpr(DeviceState *s, uint8_t val); uint8_t cpu_get_apic_tpr(DeviceState *s); diff --git a/include/hw/i386/apic_internal.h b/include/hw/i386/apic_internal.h index e796e6cae3..d6e85833da 100644 --- a/include/hw/i386/apic_internal.h +++ b/include/hw/i386/apic_internal.h @@ -137,7 +137,7 @@ struct APICCommonClass { DeviceRealize realize; DeviceUnrealize unrealize; - void (*set_base)(APICCommonState *s, uint64_t val); + int (*set_base)(APICCommonState *s, uint64_t val); void (*set_tpr)(APICCommonState *s, uint8_t val); uint8_t (*get_tpr)(APICCommonState *s); void (*enable_tpr_reporting)(APICCommonState *s, bool enable); diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 08eaa61c56..dfe43b8204 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -379,6 +379,10 @@ typedef enum X86Seg { #define MSR_IA32_APICBASE_ENABLE (1<<11) #define MSR_IA32_APICBASE_EXTD (1 << 10) #define MSR_IA32_APICBASE_BASE (0xfffffU<<12) +#define MSR_IA32_APICBASE_RESERVED \ + (~(uint64_t)(MSR_IA32_APICBASE_BSP | MSR_IA32_APICBASE_ENABLE \ + | MSR_IA32_APICBASE_EXTD | MSR_IA32_APICBASE_BASE)) + #define MSR_IA32_FEATURE_CONTROL 0x0000003a #define MSR_TSC_ADJUST 0x0000003b #define MSR_IA32_SPEC_CTRL 0x48 diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c index 1e89ca0899..a72c28e8a7 100644 --- a/hw/i386/kvm/apic.c +++ b/hw/i386/kvm/apic.c @@ -95,9 +95,10 @@ void kvm_get_apic_state(DeviceState *dev, struct kvm_lapic_state *kapic) apic_next_timer(s, s->initial_count_load_time); } -static void kvm_apic_set_base(APICCommonState *s, uint64_t val) +static int kvm_apic_set_base(APICCommonState *s, uint64_t val) { s->apicbase = val; + return 0; } static void kvm_apic_set_tpr(APICCommonState *s, uint8_t val) diff --git a/hw/i386/xen/xen_apic.c b/hw/i386/xen/xen_apic.c index 7c7a60b166..101e16a766 100644 --- a/hw/i386/xen/xen_apic.c +++ b/hw/i386/xen/xen_apic.c @@ -49,8 +49,9 @@ static void xen_apic_realize(DeviceState *dev, Error **errp) msi_nonbroken = true; } -static void xen_apic_set_base(APICCommonState *s, uint64_t val) +static int xen_apic_set_base(APICCommonState *s, uint64_t val) { + return 0; } static void xen_apic_set_tpr(APICCommonState *s, uint8_t val) diff --git a/hw/intc/apic.c b/hw/intc/apic.c index 178fb26b47..1d887d66b8 100644 --- a/hw/intc/apic.c +++ b/hw/intc/apic.c @@ -308,8 +308,49 @@ bool is_x2apic_mode(DeviceState *dev) return s->apicbase & MSR_IA32_APICBASE_EXTD; } -static void apic_set_base(APICCommonState *s, uint64_t val) +static int apic_set_base_check(APICCommonState *s, uint64_t val) { + /* Enable x2apic when x2apic is not supported by CPU */ + if (!cpu_has_x2apic_feature(&s->cpu->env) && + val & MSR_IA32_APICBASE_EXTD) { + return -1; + } + + /* + * Transition into invalid state + * (s->apicbase & MSR_IA32_APICBASE_ENABLE == 0) && + * (s->apicbase & MSR_IA32_APICBASE_EXTD) == 1 + */ + if (!(val & MSR_IA32_APICBASE_ENABLE) && + (val & MSR_IA32_APICBASE_EXTD)) { + return -1; + } + + /* Invalid transition from disabled mode to x2APIC */ + if (!(s->apicbase & MSR_IA32_APICBASE_ENABLE) && + !(s->apicbase & MSR_IA32_APICBASE_EXTD) && + (val & MSR_IA32_APICBASE_ENABLE) && + (val & MSR_IA32_APICBASE_EXTD)) { + return -1; + } + + /* Invalid transition from x2APIC to xAPIC */ + if ((s->apicbase & MSR_IA32_APICBASE_ENABLE) && + (s->apicbase & MSR_IA32_APICBASE_EXTD) && + (val & MSR_IA32_APICBASE_ENABLE) && + !(val & MSR_IA32_APICBASE_EXTD)) { + return -1; + } + + return 0; +} + +static int apic_set_base(APICCommonState *s, uint64_t val) +{ + if (apic_set_base_check(s, val) < 0) { + return -1; + } + s->apicbase = (val & 0xfffff000) | (s->apicbase & (MSR_IA32_APICBASE_BSP | MSR_IA32_APICBASE_ENABLE)); /* if disabled, cannot be enabled again */ @@ -318,6 +359,25 @@ static void apic_set_base(APICCommonState *s, uint64_t val) cpu_clear_apic_feature(&s->cpu->env); s->spurious_vec &= ~APIC_SV_ENABLE; } + + /* Transition from disabled mode to xAPIC */ + if (!(s->apicbase & MSR_IA32_APICBASE_ENABLE) && + (val & MSR_IA32_APICBASE_ENABLE)) { + s->apicbase |= MSR_IA32_APICBASE_ENABLE; + cpu_set_apic_feature(&s->cpu->env); + } + + /* Transition from xAPIC to x2APIC */ + if (cpu_has_x2apic_feature(&s->cpu->env) && + !(s->apicbase & MSR_IA32_APICBASE_EXTD) && + (val & MSR_IA32_APICBASE_EXTD)) { + s->apicbase |= MSR_IA32_APICBASE_EXTD; + + s->log_dest = ((s->initial_apic_id & 0xffff0) << 16) | + (1 << (s->initial_apic_id & 0xf)); + } + + return 0; } static void apic_set_tpr(APICCommonState *s, uint8_t val) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index 3c43ac9a1d..16ab40a35f 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -35,20 +35,19 @@ bool apic_report_tpr_access; -void cpu_set_apic_base(DeviceState *dev, uint64_t val) +int cpu_set_apic_base(DeviceState *dev, uint64_t val) { trace_cpu_set_apic_base(val); if (dev) { APICCommonState *s = APIC_COMMON(dev); APICCommonClass *info = APIC_COMMON_GET_CLASS(s); - /* switching to x2APIC, reset possibly modified xAPIC ID */ - if (!(s->apicbase & MSR_IA32_APICBASE_EXTD) && - (val & MSR_IA32_APICBASE_EXTD)) { - s->id = s->initial_apic_id; - } - info->set_base(s, val); + /* Reset possibly modified xAPIC ID */ + s->id = s->initial_apic_id; + return info->set_base(s, val); } + + return 0; } uint64_t cpu_get_apic_base(DeviceState *dev) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ef46755a50..2126b0e589 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -631,8 +631,8 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, * in CPL=3; remove them if they are ever implemented for system emulation. */ #if defined CONFIG_USER_ONLY -#define CPUID_EXT_KERNEL_FEATURES (CPUID_EXT_PCID | CPUID_EXT_TSC_DEADLINE_TIMER | \ - CPUID_EXT_X2APIC) +#define CPUID_EXT_KERNEL_FEATURES \ + (CPUID_EXT_PCID | CPUID_EXT_TSC_DEADLINE_TIMER) #else #define CPUID_EXT_KERNEL_FEATURES 0 #endif @@ -642,12 +642,13 @@ void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, CPUID_EXT_XSAVE | /* CPUID_EXT_OSXSAVE is dynamic */ \ CPUID_EXT_MOVBE | CPUID_EXT_AES | CPUID_EXT_HYPERVISOR | \ CPUID_EXT_RDRAND | CPUID_EXT_AVX | CPUID_EXT_F16C | \ - CPUID_EXT_FMA | CPUID_EXT_KERNEL_FEATURES) + CPUID_EXT_FMA | CPUID_EXT_X2APIC | CPUID_EXT_KERNEL_FEATURES) /* missing: CPUID_EXT_DTES64, CPUID_EXT_DSCPL, CPUID_EXT_VMX, CPUID_EXT_SMX, CPUID_EXT_EST, CPUID_EXT_TM2, CPUID_EXT_CID, CPUID_EXT_XTPR, CPUID_EXT_PDCM, CPUID_EXT_PCID, CPUID_EXT_DCA, - CPUID_EXT_X2APIC, CPUID_EXT_TSC_DEADLINE_TIMER */ + CPUID_EXT_TSC_DEADLINE_TIMER + */ #ifdef TARGET_X86_64 #define TCG_EXT2_X86_64_FEATURES CPUID_EXT2_LM diff --git a/target/i386/tcg/sysemu/misc_helper.c b/target/i386/tcg/sysemu/misc_helper.c index 1c43a9f4f7..7de0a6e866 100644 --- a/target/i386/tcg/sysemu/misc_helper.c +++ b/target/i386/tcg/sysemu/misc_helper.c @@ -158,9 +158,19 @@ void helper_wrmsr(CPUX86State *env) case MSR_IA32_SYSENTER_EIP: env->sysenter_eip = val; break; - case MSR_IA32_APICBASE: - cpu_set_apic_base(env_archcpu(env)->apic_state, val); + case MSR_IA32_APICBASE: { + int ret; + + if (val & MSR_IA32_APICBASE_RESERVED) { + goto error; + } + + ret = cpu_set_apic_base(env_archcpu(env)->apic_state, val); + if (ret < 0) { + goto error; + } break; + } case MSR_EFER: { uint64_t update_mask; diff --git a/target/i386/whpx/whpx-apic.c b/target/i386/whpx/whpx-apic.c index 8710e37567..7e14ded978 100644 --- a/target/i386/whpx/whpx-apic.c +++ b/target/i386/whpx/whpx-apic.c @@ -90,9 +90,10 @@ static void whpx_get_apic_state(APICCommonState *s, apic_next_timer(s, s->initial_count_load_time); } -static void whpx_apic_set_base(APICCommonState *s, uint64_t val) +static int whpx_apic_set_base(APICCommonState *s, uint64_t val) { s->apicbase = val; + return 0; } static void whpx_put_apic_base(CPUState *cpu, uint64_t val) From patchwork Wed Feb 14 11:14:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898828 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=SoCNhsN0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbFQ4mKRz23j8 for ; Wed, 14 Feb 2024 22:14:50 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDZ-0000f2-GQ; Wed, 14 Feb 2024 06:14:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDU-0000VI-P1 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDQ-0006o9-9Q for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909250; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9iax4fGkbgDG496GWyJLMKtIlIETz7WAUyf3pMF1uss=; b=SoCNhsN0aVoGQ31saM03LTxvc6RpqXRAgaTqX8a4cQL2/ORVSW4vnC939Z6Gyc23Rk2Drd DwE3kp51PCWf0uNq2peSp2a3U6h4RLvbTyD8Zx3hiMXL/YTcKD573JMnfj9USUWTmgCecx XeHiURYmhWARMTxhFXbhn8M/IJcmASY= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-539-1j-73DFKOMaZKZf_5Dpjfg-1; Wed, 14 Feb 2024 06:14:08 -0500 X-MC-Unique: 1j-73DFKOMaZKZf_5Dpjfg-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a3d06dd626fso90592966b.1 for ; Wed, 14 Feb 2024 03:14:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909247; x=1708514047; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9iax4fGkbgDG496GWyJLMKtIlIETz7WAUyf3pMF1uss=; b=EbKMWR+WmhPaE+RWDSKcWzRR8wWjDGmaLb4CkgE5ujuX2ZBUeNb49XL/n66aoZQDEv M+bmdZ3iUBzaRYC+o9vSFeYL/PSwhW/kvyViFb9a9aV+fyg/OK5e5cMZDNZvdFHdSPaK tYras3+FA9QU4g97hD6910vH+AMcU7FbJWbGjzf6iW6icsnHNVDYdsCXIWDsO2Q1H1bB 5qOep0eGFEZe668Itzox7fiVv+naRPQWezBDTgR9k+1fp3AnBzA5wraadvZuG+AFqZrU bnLuuAfZiuBLgj2db8/1PYTzMUcVrKDJNRp/0fMSuaQOlrK3y67wo/JxwYQklealZAsX 61jg== X-Gm-Message-State: AOJu0YxgYSk7t6lNocx7Os32/DznBSELHJiKntjQacs/wRdIEu/htL2o eSZ+GumzvlNCmh6x/7bHWqbo8WwtjmsZMbs/W6ESX/oEJC5fP2lup8jRDIYiBi4NViKXl4kpoJV cDaSXIpKOPHLDWs28C6EuZYxHnFt31fieB8LYuIcSUBUEyYfAc4WzCJec08fSnE5bs+Ig41TwKZ fZtYb3aU6k6/KxEtTZgwX8bj+roaIX0A== X-Received: by 2002:a17:907:170d:b0:a3d:1170:e6e3 with SMTP id le13-20020a170907170d00b00a3d1170e6e3mr1527439ejc.14.1707909246801; Wed, 14 Feb 2024 03:14:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGI49NcLQyhOXFsT4Md53NHs0c+SdAhAFi2eKpc8vzrHhHQLFmXDzJAS+L37Rh07ecp476ZiA== X-Received: by 2002:a17:907:170d:b0:a3d:1170:e6e3 with SMTP id le13-20020a170907170d00b00a3d1170e6e3mr1527417ejc.14.1707909246526; Wed, 14 Feb 2024 03:14:06 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU67ULHZKtEAw62/YAPtzCrjtvIDaXgeWg3SK7op60uqHWpe/E0cY99jjrG6+5gvY72coW60A/pb0Tfc00twzDj3OFLJWarLTA8RBqO3k6hUxgvmC7L2ku3QI4XykXMNbzYn8EWE9PkjN93/0BWJ1kuIbJ3k6XZgvbIW8JxAN6raBkKz7IqnEeFcEwtmDh4nWFcKQdP4CkNtPJyFBL1tGlkx/Qpmbaf2kcD9h7K4QtT1GGkyTXnei3g6VegLDkJpWmyBr8T0OxNaCrcnL9nQcVOpXPC+cNiYT+/MHOpQK+DU+8LSYy429CrWXOmDGuaXg== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id i24-20020a170906115800b00a3d303f0981sm767429eja.92.2024.02.14.03.14.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:05 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:03 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bui Quang Minh , Joao Martins , Peter Xu , Jason Wang , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 15/60] intel_iommu: allow Extended Interrupt Mode when using userspace APIC Message-ID: <2cf16205290bdb6d92bade3590adec6e08fd26c9.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bui Quang Minh As userspace APIC now supports x2APIC, intel interrupt remapping hardware can be set to EIM mode when userspace local APIC is used. Suggested-by: Joao Martins Acked-by: Peter Xu Signed-off-by: Bui Quang Minh Message-Id: <20240111154404.5333-5-minhquangbui99@gmail.com> Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 1a07faddb4..cf933189d3 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -4124,11 +4124,7 @@ static bool vtd_decide_config(IntelIOMMUState *s, Error **errp) ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF; } if (s->intr_eim == ON_OFF_AUTO_ON && !s->buggy_eim) { - if (!kvm_irqchip_is_split()) { - error_setg(errp, "eim=on requires accel=kvm,kernel-irqchip=split"); - return false; - } - if (kvm_enabled() && !kvm_enable_x2apic()) { + if (kvm_irqchip_is_split() && !kvm_enable_x2apic()) { error_setg(errp, "eim=on requires support on the KVM side" "(X2APIC_API, first shipped in v4.7)"); return false; From patchwork Wed Feb 14 11:14:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898836 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Gfu6pyRK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbJJ1kKYz23hM for ; Wed, 14 Feb 2024 22:17:20 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDa-0000iv-KB; Wed, 14 Feb 2024 06:14:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDU-0000VL-Pz for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDR-0006oo-9o for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909252; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=BNWmEEc1AFwNYSkngLIcbrXY7t57G8tK4w2tVPlRoEk=; b=Gfu6pyRK2Uh5TUROp3NIvXlhzafjvcoBL/AafcIVZ7W8o5qJgoLKK3LKWzlKIGiRk1fY8k j86GGW3M0+cKTtITKGE/9vOvVgDM7ypZcKZRRldHJLZGbBHfjVtF/cXb5v7ckpNZZ/TZTj x2/N7aCWwJxicU52PDqoU+nhOey/olI= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-31-MRMpxzFPOdu8est3MnBadw-1; Wed, 14 Feb 2024 06:14:11 -0500 X-MC-Unique: MRMpxzFPOdu8est3MnBadw-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a2bc65005feso378365566b.0 for ; Wed, 14 Feb 2024 03:14:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909249; x=1708514049; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=BNWmEEc1AFwNYSkngLIcbrXY7t57G8tK4w2tVPlRoEk=; b=hDDMS7zxJzHBTe1zAxNhJztu3wmjt2O5Xc1v44cVl4+YKnMmMQxfbQibtjYv3LcGH7 JKu8O/Xv8fTphqe2BFN8uy40Smhau3Gyj5QnGT+gEJpefQ29Fl2MyCWq+Vyl1TfWwK9J c6TzQN0AU9zCu9I+dRvX5utY37YokpPsB+2RMpAczDOke9YVkhE9jJNtLcThTEDKHPQs CwJFJyLd9qcSVnwVJg7tu9y3WBfH+e2F8+MaGik3C3BEif7UAtbPB4g3r32x+aYpZiZX Kn1dKR5QShENTQkmg2ZCxhFXI3biKVVdevKL/UWG3johhTeWZ2hRcjPqjJaKIjZYpsTp 0V9Q== X-Gm-Message-State: AOJu0YzxWLqVqD6OT4DszStnQZdNSYAhNpj4VCFvv7Ccn8cXxHGSOykd xJBN8TZQ6l9Y4TfuilvWVmu2zDUzEd6xbXCtqzF1qhUIAT4LtDP7kvlQ1EI+VoQAdzraKZJUDbN kSZl9o9BrEAKd1bAUoY8BRFv6IavzGj2xSZF0aQu8ReUUz2bFtNBLWFzTaM0TACJLIab64UvPp+ oIBatGq5fP8eS92ho15wg5gS6V8LrRFA== X-Received: by 2002:a17:906:6bcd:b0:a38:7171:e832 with SMTP id t13-20020a1709066bcd00b00a387171e832mr1494960ejs.32.1707909249560; Wed, 14 Feb 2024 03:14:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IFcJcIqC2Rx3Amk4km7PEH/Cc9S3s4kSzJDAyLO2TNhWkc9ZBHrpKBncETIiYFtU0eEQT5Zmw== X-Received: by 2002:a17:906:6bcd:b0:a38:7171:e832 with SMTP id t13-20020a1709066bcd00b00a387171e832mr1494942ejs.32.1707909249331; Wed, 14 Feb 2024 03:14:09 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW94K8mG1H3qnLzA4JpVm+kEWSUzDLv41ZTHTu2qGtxvblA7C62zwc2sFXkrjbVT/hCdfvIA7XpUknG/NoTImE5gr6XCIta3yVZuMs2naxM4DKBRcQ/QuAHZthICSIG5lZIDCaXI8TxzFq+36i9QP3u/Mw= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id vo10-20020a170907a80a00b00a3cfd838f32sm1620231ejc.178.2024.02.14.03.14.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:08 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:06 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bui Quang Minh , Igor Mammedov , Ani Sinha Subject: [PULL 16/60] test: bios-tables-test: prepare IVRS change in ACPI table Message-ID: <595cd6fd9dffe51ef3fdb3077979a87ff2947b1f.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bui Quang Minh Following the instructions in bios-tables-test, this lists that IVRS.ivrs in ACPI table will be changed to add new IVHD type 0x11. Signed-off-by: Bui Quang Minh Message-Id: <20240111154404.5333-6-minhquangbui99@gmail.com> Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index dfb8523c8b..ac420db6b7 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,2 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/IVRS.ivrs", From patchwork Wed Feb 14 11:14:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898839 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ErMRqQYC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbJc02Wyz23y6 for ; Wed, 14 Feb 2024 22:17:36 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDa-0000iH-AA; Wed, 14 Feb 2024 06:14:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDX-0000ca-Lc for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDV-0006pJ-1a for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909256; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=PCy0wrcxC/Qiqh6j1e5fGl2NS38D3wIzgFH+/GE5gVw=; b=ErMRqQYC3qLLyVNU7wtXvkHEf+04CBH2VsiRwG0w2N97pPh/QULbdgztRSHtPAmjGViAoT dmyzkSlSbef+uJKGIdMngajGI/f/gA3FvncrUnu9kNwF/SISDntGV1a72nS/dWvUeHLZRZ N7xvhQe/5xvzmidKyLOn6KWyd/bCJSs= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-551-vMP8AvtvMK6ZCu61ZI8tdA-1; Wed, 14 Feb 2024 06:14:14 -0500 X-MC-Unique: vMP8AvtvMK6ZCu61ZI8tdA-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a381d3277a9so255398266b.0 for ; Wed, 14 Feb 2024 03:14:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909253; x=1708514053; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PCy0wrcxC/Qiqh6j1e5fGl2NS38D3wIzgFH+/GE5gVw=; b=nb1fLbycGX1MHG/Dhufa7rY/ulRgbPTzyxILxWsAe0kbKICU5s6Qx/f9sJdrsecGrs Z8LVeHCLA55M6O4FtZbpnEw8Lc1GZc1VVbMA3lTyS4q0Y+XKLSW4PNe/ZavyycMEM3gI l4urUh8g8iDUfgkmmTzgx/T6tFTK/mO+ZeGyZezeuLd/TFZDLI3qAYIdB82ypl/mh3bf jpAUk2+eHVpmZFEILMBcyAqbmGbZ+4upW/OCFtuooHto3YoVp7QLETjrRiDSbDfL5NKU 94D4jWixKjJjuW6eE2fu2MXEKB1H/7F87tLkg+egSPTOMiMXx8fmPLSdoSwe2OUZfWy2 Bpwg== X-Gm-Message-State: AOJu0YzDgoqXLaiOlanOYfl813UJ1t1fWmviTA7zzfNi1ZHpu9DgA1v6 ObSm7ycr1IU9Xtws/nHaBUjEjNX7/zFysHFcx6zi1GYh2kmoVPs2WIZ4mNzRdXvHjaR+4FL6Wq2 My6R482auG3vmqugWsZwB3Ca4z+hZpdTr5Tib8cGJyiE8nSBxMvnuCbjwFqbEDy9E0zb5qOAa0z lKg1ErHlG2QY2+DxWnWX+jeLHjl8B8QA== X-Received: by 2002:aa7:c49a:0:b0:560:9256:3cf5 with SMTP id m26-20020aa7c49a000000b0056092563cf5mr1890654edq.34.1707909252945; Wed, 14 Feb 2024 03:14:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFh1RTDJ84lLdez3EY/Qoyes9TARI1jmLOmMIr4z1EU0r//Nr1IKFwzJp9X0M7rgaAbN810AQ== X-Received: by 2002:aa7:c49a:0:b0:560:9256:3cf5 with SMTP id m26-20020aa7c49a000000b0056092563cf5mr1890629edq.34.1707909252555; Wed, 14 Feb 2024 03:14:12 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVygjJLWNb7j6HKh9GLpZJJyJLYBWn31ggXolhI7PQSH0YH9zAma5ptKPKiayoaGfyfb74UhJt+Q9oE3x8XMMdYr6evQyxbp56iHotdZPhzotez+xr2WdNxD9kOoXyq1iS5LLVse32XXjenj+vP98mxM2L0iddaNksOkBMh+S8rmtWRTIG35LOZ+hT3rtYLIt2Fl0oGXiBv2xqoc58zQeQXSfmXTmWQkGqs/0x/bSEv7uD91vFCOO/9OHesY3CELW5z0REc38l02MvP5GCQ16b6K8AWLip8 Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id cq9-20020a056402220900b0055ffe74e39dsm4550191edb.85.2024.02.14.03.14.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:11 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:09 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bui Quang Minh , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 17/60] amd_iommu: report x2APIC support to the operating system Message-ID: <328a11a08a70ca9e565cee807eb74e1e59e1b5d9.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bui Quang Minh This commit adds XTSup configuration to let user choose to whether enable this feature or not. When XTSup is enabled, additional bytes in IRTE with enabled guest virtual VAPIC are used to support 32-bit destination id. Additionally, this commit exports IVHD type 0x11 besides the old IVHD type 0x10 in ACPI table. IVHD type 0x10 does not report full set of IOMMU features only the legacy ones, so operating system (e.g. Linux) may only detects x2APIC support if IVHD type 0x11 is available. The IVHD type 0x10 is kept so that old operating system that only parses type 0x10 can detect the IOMMU device. Besides, an amd_iommu-stub.c file is created to provide the definition for amdvi_extended_feature_register when CONFIG_AMD_IOMMU=n. This function is used by acpi-build.c to get the extended feature register value for building the ACPI table. When CONFIG_AMD_IOMMU=y, this function is defined in amd_iommu.c. Signed-off-by: Bui Quang Minh Message-Id: <20240111154404.5333-7-minhquangbui99@gmail.com> Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.h | 16 ++++-- hw/i386/acpi-build.c | 107 +++++++++++++++++++++++++-------------- hw/i386/amd_iommu-stub.c | 26 ++++++++++ hw/i386/amd_iommu.c | 29 +++++++++-- hw/i386/meson.build | 3 +- 5 files changed, 134 insertions(+), 47 deletions(-) create mode 100644 hw/i386/amd_iommu-stub.c diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index c5065a3e27..73619fe9ea 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -154,6 +154,7 @@ #define AMDVI_FEATURE_PREFETCH (1ULL << 0) /* page prefetch */ #define AMDVI_FEATURE_PPR (1ULL << 1) /* PPR Support */ +#define AMDVI_FEATURE_XT (1ULL << 2) /* x2APIC Support */ #define AMDVI_FEATURE_GT (1ULL << 4) /* Guest Translation */ #define AMDVI_FEATURE_IA (1ULL << 6) /* inval all support */ #define AMDVI_FEATURE_GA (1ULL << 7) /* guest VAPIC support */ @@ -173,8 +174,9 @@ #define AMDVI_IOTLB_MAX_SIZE 1024 #define AMDVI_DEVID_SHIFT 36 -/* extended feature support */ -#define AMDVI_EXT_FEATURES (AMDVI_FEATURE_PREFETCH | AMDVI_FEATURE_PPR | \ +/* default extended feature */ +#define AMDVI_DEFAULT_EXT_FEATURES \ + (AMDVI_FEATURE_PREFETCH | AMDVI_FEATURE_PPR | \ AMDVI_FEATURE_IA | AMDVI_FEATURE_GT | AMDVI_FEATURE_HE | \ AMDVI_GATS_MODE | AMDVI_HATS_MODE | AMDVI_FEATURE_GA) @@ -276,8 +278,8 @@ union irte_ga_lo { dm:1, /* ------ */ guest_mode:1, - destination:8, - rsvd_1:48; + destination:24, + rsvd_1:32; } fields_remap; }; @@ -285,7 +287,8 @@ union irte_ga_hi { uint64_t val; struct { uint64_t vector:8, - rsvd_2:56; + rsvd_2:48, + destination_hi:8; } fields; }; @@ -364,6 +367,9 @@ struct AMDVIState { /* Interrupt remapping */ bool ga_enabled; + bool xtsup; }; +uint64_t amdvi_extended_feature_register(AMDVIState *s); + #endif diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index e990b0ae92..d5c6c94474 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2333,30 +2333,23 @@ static void build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) { - int ivhd_table_len = 24; AMDVIState *s = AMD_IOMMU_DEVICE(x86_iommu_get_default()); GArray *ivhd_blob = g_array_new(false, true, 1); AcpiTable table = { .sig = "IVRS", .rev = 1, .oem_id = oem_id, .oem_table_id = oem_table_id }; + uint64_t feature_report; acpi_table_begin(&table, table_data); /* IVinfo - IO virtualization information common to all * IOMMU units in a system */ - build_append_int_noprefix(table_data, 40UL << 8/* PASize */, 4); + build_append_int_noprefix(table_data, + (1UL << 0) | /* EFRSup */ + (40UL << 8), /* PASize */ + 4); /* reserved */ build_append_int_noprefix(table_data, 0, 8); - /* IVHD definition - type 10h */ - build_append_int_noprefix(table_data, 0x10, 1); - /* virtualization flags */ - build_append_int_noprefix(table_data, - (1UL << 0) | /* HtTunEn */ - (1UL << 4) | /* iotblSup */ - (1UL << 6) | /* PrefSup */ - (1UL << 7), /* PPRSup */ - 1); - /* * A PCI bus walk, for each PCI host bridge, is necessary to create a * complete set of IVHD entries. Do this into a separate blob so that we @@ -2376,18 +2369,34 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id, build_append_int_noprefix(ivhd_blob, 0x0000001, 4); } - ivhd_table_len += ivhd_blob->len; - /* * When interrupt remapping is supported, we add a special IVHD device - * for type IO-APIC. + * for type IO-APIC + * Refer to spec - Table 95: IVHD device entry type codes + * + * Linux IOMMU driver checks for the special IVHD device (type IO-APIC). + * See Linux kernel commit 'c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059' */ if (x86_iommu_ir_supported(x86_iommu_get_default())) { - ivhd_table_len += 8; + build_append_int_noprefix(ivhd_blob, + (0x1ull << 56) | /* type IOAPIC */ + (IOAPIC_SB_DEVID << 40) | /* IOAPIC devid */ + 0x48, /* special device */ + 8); } + /* IVHD definition - type 10h */ + build_append_int_noprefix(table_data, 0x10, 1); + /* virtualization flags */ + build_append_int_noprefix(table_data, + (1UL << 0) | /* HtTunEn */ + (1UL << 4) | /* iotblSup */ + (1UL << 6) | /* PrefSup */ + (1UL << 7), /* PPRSup */ + 1); + /* IVHD length */ - build_append_int_noprefix(table_data, ivhd_table_len, 2); + build_append_int_noprefix(table_data, ivhd_blob->len + 24, 2); /* DeviceID */ build_append_int_noprefix(table_data, object_property_get_int(OBJECT(&s->pci), "addr", @@ -2401,31 +2410,53 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker, const char *oem_id, /* IOMMU info */ build_append_int_noprefix(table_data, 0, 2); /* IOMMU Feature Reporting */ - build_append_int_noprefix(table_data, - (48UL << 30) | /* HATS */ - (48UL << 28) | /* GATS */ - (1UL << 2) | /* GTSup */ - (1UL << 6), /* GASup */ - 4); + feature_report = (48UL << 30) | /* HATS */ + (48UL << 28) | /* GATS */ + (1UL << 2) | /* GTSup */ + (1UL << 6); /* GASup */ + if (s->xtsup) { + feature_report |= (1UL << 0); /* XTSup */ + } + build_append_int_noprefix(table_data, feature_report, 4); /* IVHD entries as found above */ g_array_append_vals(table_data, ivhd_blob->data, ivhd_blob->len); - g_array_free(ivhd_blob, TRUE); - /* - * Add a special IVHD device type. - * Refer to spec - Table 95: IVHD device entry type codes - * - * Linux IOMMU driver checks for the special IVHD device (type IO-APIC). - * See Linux kernel commit 'c2ff5cf5294bcbd7fa50f7d860e90a66db7e5059' - */ - if (x86_iommu_ir_supported(x86_iommu_get_default())) { - build_append_int_noprefix(table_data, - (0x1ull << 56) | /* type IOAPIC */ - (IOAPIC_SB_DEVID << 40) | /* IOAPIC devid */ - 0x48, /* special device */ - 8); - } + /* IVHD definition - type 11h */ + build_append_int_noprefix(table_data, 0x11, 1); + /* virtualization flags */ + build_append_int_noprefix(table_data, + (1UL << 0) | /* HtTunEn */ + (1UL << 4), /* iotblSup */ + 1); + + /* IVHD length */ + build_append_int_noprefix(table_data, ivhd_blob->len + 40, 2); + /* DeviceID */ + build_append_int_noprefix(table_data, + object_property_get_int(OBJECT(&s->pci), "addr", + &error_abort), 2); + /* Capability offset */ + build_append_int_noprefix(table_data, s->pci.capab_offset, 2); + /* IOMMU base address */ + build_append_int_noprefix(table_data, s->mmio.addr, 8); + /* PCI Segment Group */ + build_append_int_noprefix(table_data, 0, 2); + /* IOMMU info */ + build_append_int_noprefix(table_data, 0, 2); + /* IOMMU Attributes */ + build_append_int_noprefix(table_data, 0, 4); + /* EFR Register Image */ + build_append_int_noprefix(table_data, + amdvi_extended_feature_register(s), + 8); + /* EFR Register Image 2 */ + build_append_int_noprefix(table_data, 0, 8); + + /* IVHD entries as found above */ + g_array_append_vals(table_data, ivhd_blob->data, ivhd_blob->len); + + g_array_free(ivhd_blob, TRUE); acpi_table_end(linker, &table); } diff --git a/hw/i386/amd_iommu-stub.c b/hw/i386/amd_iommu-stub.c new file mode 100644 index 0000000000..d62a3732e6 --- /dev/null +++ b/hw/i386/amd_iommu-stub.c @@ -0,0 +1,26 @@ +/* + * Stubs for AMD IOMMU emulation + * + * Copyright (C) 2023 Bui Quang Minh + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "qemu/osdep.h" +#include "amd_iommu.h" + +uint64_t amdvi_extended_feature_register(AMDVIState *s) +{ + return AMDVI_DEFAULT_EXT_FEATURES; +} diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 4203144da9..7329553ad3 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -31,6 +31,7 @@ #include "hw/i386/apic_internal.h" #include "trace.h" #include "hw/i386/apic-msidef.h" +#include "hw/qdev-properties.h" /* used AMD-Vi MMIO registers */ const char *amdvi_mmio_low[] = { @@ -74,6 +75,16 @@ typedef struct AMDVIIOTLBEntry { uint64_t page_mask; /* physical page size */ } AMDVIIOTLBEntry; +uint64_t amdvi_extended_feature_register(AMDVIState *s) +{ + uint64_t feature = AMDVI_DEFAULT_EXT_FEATURES; + if (s->xtsup) { + feature |= AMDVI_FEATURE_XT; + } + + return feature; +} + /* configure MMIO registers at startup/reset */ static void amdvi_set_quad(AMDVIState *s, hwaddr addr, uint64_t val, uint64_t romask, uint64_t w1cmask) @@ -1155,7 +1166,12 @@ static int amdvi_int_remap_ga(AMDVIState *iommu, irq->vector = irte.hi.fields.vector; irq->dest_mode = irte.lo.fields_remap.dm; irq->redir_hint = irte.lo.fields_remap.rq_eoi; - irq->dest = irte.lo.fields_remap.destination; + if (iommu->xtsup) { + irq->dest = irte.lo.fields_remap.destination | + (irte.hi.fields.destination_hi << 24); + } else { + irq->dest = irte.lo.fields_remap.destination & 0xff; + } return 0; } @@ -1505,8 +1521,9 @@ static void amdvi_init(AMDVIState *s) /* reset MMIO */ memset(s->mmior, 0, AMDVI_MMIO_SIZE); - amdvi_set_quad(s, AMDVI_MMIO_EXT_FEATURES, AMDVI_EXT_FEATURES, - 0xffffffffffffffef, 0); + amdvi_set_quad(s, AMDVI_MMIO_EXT_FEATURES, + amdvi_extended_feature_register(s), + 0xffffffffffffffef, 0); amdvi_set_quad(s, AMDVI_MMIO_STATUS, 0, 0x98, 0x67); } @@ -1589,6 +1606,11 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp) amdvi_init(s); } +static Property amdvi_properties[] = { + DEFINE_PROP_BOOL("xtsup", AMDVIState, xtsup, false), + DEFINE_PROP_END_OF_LIST(), +}; + static const VMStateDescription vmstate_amdvi_sysbus = { .name = "amd-iommu", .unmigratable = 1 @@ -1615,6 +1637,7 @@ static void amdvi_sysbus_class_init(ObjectClass *klass, void *data) dc->user_creatable = true; set_bit(DEVICE_CATEGORY_MISC, dc->categories); dc->desc = "AMD IOMMU (AMD-Vi) DMA Remapping device"; + device_class_set_props(dc, amdvi_properties); } static const TypeInfo amdvi_sysbus = { diff --git a/hw/i386/meson.build b/hw/i386/meson.build index 369c6bf823..b9c1ca39cb 100644 --- a/hw/i386/meson.build +++ b/hw/i386/meson.build @@ -9,7 +9,8 @@ i386_ss.add(files( i386_ss.add(when: 'CONFIG_X86_IOMMU', if_true: files('x86-iommu.c'), if_false: files('x86-iommu-stub.c')) -i386_ss.add(when: 'CONFIG_AMD_IOMMU', if_true: files('amd_iommu.c')) +i386_ss.add(when: 'CONFIG_AMD_IOMMU', if_true: files('amd_iommu.c'), + if_false: files('amd_iommu-stub.c')) i386_ss.add(when: 'CONFIG_I440FX', if_true: files('pc_piix.c')) i386_ss.add(when: 'CONFIG_MICROVM', if_true: files('microvm.c', 'acpi-microvm.c', 'microvm-dt.c')) i386_ss.add(when: 'CONFIG_Q35', if_true: files('pc_q35.c')) From patchwork Wed Feb 14 11:14:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898837 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QSXN9982; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbJQ1Vl9z23hM for ; Wed, 14 Feb 2024 22:17:26 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDc-0000jO-0C; Wed, 14 Feb 2024 06:14:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDa-0000iP-B8 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDX-0006pr-Ch for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909258; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=K7Ls7uqSEpQ5boWF/LDBroh1T2tN1l+pN+CXJNHb3ag=; b=QSXN9982Dgsr8/wI+BQdDc7MDPAMFcmyF4sbofxq1rJBw8qfOyHePwMDhEuCy8obBoPOX9 phVRBcbDYtD4iN4Au79GYgqOcr/evTqghynpSxcZNZtfkVHTJVyiDelwTAuRudVZRDgpEo Q1HqWG/OrU9bD6Yu2KAeM5dk+zWyKyA= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-0ZmcHcfcOfKImUz2NcWXAQ-1; Wed, 14 Feb 2024 06:14:17 -0500 X-MC-Unique: 0ZmcHcfcOfKImUz2NcWXAQ-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a357c92f241so317422066b.0 for ; Wed, 14 Feb 2024 03:14:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909255; x=1708514055; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=K7Ls7uqSEpQ5boWF/LDBroh1T2tN1l+pN+CXJNHb3ag=; b=k8Ijms7xTWn0za2UIhm9ZrtB56/oJVk7B4GhT1shjyEdMR0UIRjxG6g95mOcK9wWUH foKwP2sC25Q6+NRjPyKc0MkWkYhgvBXtyjDjToN80KU7VqzkrBrMnKUBdhRiiRD0oYCG 0cT6XtR/uM7NFJob8wbcT4ieNhDIuzWCCMkb5IkpYZvnE56EnlDbPPRa7tKpHnAPcYpH LfYm9sSDIaR+iPRRoH8xNuLEGj8lH+PDBhed8QOoPURwtg00b94YvG4HCRmrCp7dCOs5 vWm9EnZNs6tw+Xls/HjVQRV6BltCkTYRmhEMecZPZr6Sacv0HLhuWx/S3fA5C7bFCFZJ iA9w== X-Gm-Message-State: AOJu0YxeUyTAlotNaAVcYuv4Qo3eCKVXznzDWdeLwwy/JDe1R3oM+YUo Wlkr4op2uiNmp7n41nJ9vw6EJs6zRhJ25HE8i+laUQV/9IJvP5nK/OxqC11zWQJXsAeeGtCPl1v KkNnPg6KkP/P13vVP5R06ilz74R20TMHH1xCxnMrkioQM+z/ESGTn1bdPSAHE8QzjMXxhAKYeiH xaESoMgEGTjLGAehVAxwiv4wvKHHjd9Q== X-Received: by 2002:a17:906:f296:b0:a3d:22bf:38f2 with SMTP id gu22-20020a170906f29600b00a3d22bf38f2mr1361131ejb.74.1707909255614; Wed, 14 Feb 2024 03:14:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFR1NFPQUEoHPiht1HLUE2CwOTlfELq5I9aa20YUAw3YB1FYDwmksa+1vFOrOHcvr7NO12XcA== X-Received: by 2002:a17:906:f296:b0:a3d:22bf:38f2 with SMTP id gu22-20020a170906f29600b00a3d22bf38f2mr1361108ejb.74.1707909255270; Wed, 14 Feb 2024 03:14:15 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXNy+daEVEzH3m+Zc2jBIlfOYy3WTecnhu0VaX+FVqO9XHk6iV0rCW3G2IDaaXp5SbjYXoUa05H8Z7upGXzvt3hiTz9RHzN0uOPgeM4dLgZl+O8TYde9R0paSwud5fSYQ1dN6YcBicFI3VwviCLcZQE0R4= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id cx7-20020a170907168700b00a3cdccd7e41sm2180051ejd.98.2024.02.14.03.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:14 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:12 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bui Quang Minh , Igor Mammedov , Ani Sinha Subject: [PULL 18/60] test: bios-tables-test: add IVRS changed binary Message-ID: <7618fffdf16e03377390e51c033f0b14d772333a.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bui Quang Minh Following the instructions in bios-tables-test, this adds the changed IVRS.ivrs binary. New IVRS differs in length, checksum, it enables EFRSup in Virtualization Info and adds IVHD type 0x11 with the same device entries as in IVHD type 0x10. ASL diff: /* * Intel ACPI Component Architecture * AML/ASL+ Disassembler version 20230628 (64-bit version) * Copyright (c) 2000 - 2023 Intel Corporation * - * Disassembly of tests/data/acpi/q35/IVRS.ivrs, Wed Nov 8 21:39:58 2023 + * Disassembly of /tmp/aml-2ODND2, Wed Nov 8 21:39:58 2023 * * ACPI Data Table [IVRS] * * Format: [HexOffset DecimalOffset ByteLength] FieldName : FieldValue (in hex) */ [000h 0000 004h] Signature : "IVRS" [I/O Virtualization Reporting Structure] -[004h 0004 004h] Table Length : 00000068 +[004h 0004 004h] Table Length : 000000B0 [008h 0008 001h] Revision : 01 -[009h 0009 001h] Checksum : 43 +[009h 0009 001h] Checksum : 74 [00Ah 0010 006h] Oem ID : "BOCHS " [010h 0016 008h] Oem Table ID : "BXPC " [018h 0024 004h] Oem Revision : 00000001 [01Ch 0028 004h] Asl Compiler ID : "BXPC" [020h 0032 004h] Asl Compiler Revision : 00000001 -[024h 0036 004h] Virtualization Info : 00002800 +[024h 0036 004h] Virtualization Info : 00002801 [028h 0040 008h] Reserved : 0000000000000000 [030h 0048 001h] Subtable Type : 10 [Hardware Definition Block (IVHD)] [031h 0049 001h] Flags (decoded below) : D1 HtTunEn : 1 PassPW : 0 ResPassPW : 0 Isoc Control : 0 Iotlb Support : 1 Coherent : 0 Prefetch Support : 1 PPR Support : 1 [032h 0050 002h] Length : 0038 [034h 0052 002h] DeviceId : 0010 [036h 0054 002h] Capability Offset : 0040 [038h 0056 008h] Base Address : 00000000FED80000 @@ -108,25 +108,129 @@ LINT1 Pass : 0 [060h 0096 001h] Subtable Type : 48 [Device Entry: Special Device] [061h 0097 002h] Device ID : 0000 [063h 0099 001h] Data Setting (decoded below) : 00 INITPass : 0 EIntPass : 0 NMIPass : 0 Reserved : 0 System MGMT : 0 LINT0 Pass : 0 LINT1 Pass : 0 [064h 0100 001h] Handle : 00 [065h 0101 002h] Source Used Device ID : 00A0 [067h 0103 001h] Variety : 01 -Raw Table Data: Length 104 (0x68) +[068h 0104 001h] Subtable Type : 11 [Hardware Definition Block (IVHD)] +[069h 0105 001h] Flags (decoded below) : 11 + HtTunEn : 1 + PassPW : 0 + ResPassPW : 0 + Isoc Control : 0 + Iotlb Support : 1 + Coherent : 0 + Prefetch Support : 0 + PPR Support : 0 +[06Ah 0106 002h] Length : 0048 +[06Ch 0108 002h] DeviceId : 0010 +[06Eh 0110 002h] Capability Offset : 0040 +[070h 0112 008h] Base Address : 00000000FED80000 +[078h 0120 002h] PCI Segment Group : 0000 +[07Ah 0122 002h] Virtualization Info : 0000 +[07Ch 0124 004h] Attributes : 00000000 +[080h 0128 008h] EFR Image : 00000000000029D3 +[088h 0136 008h] Reserved : 0000000000000000 + +[090h 0144 001h] Subtable Type : 02 [Device Entry: Select One Device] +[091h 0145 002h] Device ID : 0000 +[093h 0147 001h] Data Setting (decoded below) : 00 + INITPass : 0 + EIntPass : 0 + NMIPass : 0 + Reserved : 0 + System MGMT : 0 + LINT0 Pass : 0 + LINT1 Pass : 0 + +[094h 0148 001h] Subtable Type : 02 [Device Entry: Select One Device] +[095h 0149 002h] Device ID : 0008 +[097h 0151 001h] Data Setting (decoded below) : 00 + INITPass : 0 + EIntPass : 0 + NMIPass : 0 + Reserved : 0 + System MGMT : 0 + LINT0 Pass : 0 + LINT1 Pass : 0 + +[098h 0152 001h] Subtable Type : 02 [Device Entry: Select One Device] +[099h 0153 002h] Device ID : 0010 +[09Bh 0155 001h] Data Setting (decoded below) : 00 + INITPass : 0 + EIntPass : 0 + NMIPass : 0 + Reserved : 0 + System MGMT : 0 + LINT0 Pass : 0 + LINT1 Pass : 0 + +[09Ch 0156 001h] Subtable Type : 02 [Device Entry: Select One Device] +[09Dh 0157 002h] Device ID : 00F8 +[09Fh 0159 001h] Data Setting (decoded below) : 00 + INITPass : 0 + EIntPass : 0 + NMIPass : 0 + Reserved : 0 + System MGMT : 0 + LINT0 Pass : 0 + LINT1 Pass : 0 + +[0A0h 0160 001h] Subtable Type : 02 [Device Entry: Select One Device] +[0A1h 0161 002h] Device ID : 00FA +[0A3h 0163 001h] Data Setting (decoded below) : 00 + INITPass : 0 + EIntPass : 0 + NMIPass : 0 + Reserved : 0 + System MGMT : 0 + LINT0 Pass : 0 + LINT1 Pass : 0 + +[0A4h 0164 001h] Subtable Type : 02 [Device Entry: Select One Device] +[0A5h 0165 002h] Device ID : 00FB +[0A7h 0167 001h] Data Setting (decoded below) : 00 + INITPass : 0 + EIntPass : 0 + NMIPass : 0 + Reserved : 0 + System MGMT : 0 + LINT0 Pass : 0 + LINT1 Pass : 0 + +[0A8h 0168 001h] Subtable Type : 48 [Device Entry: Special Device] +[0A9h 0169 002h] Device ID : 0000 +[0ABh 0171 001h] Data Setting (decoded below) : 00 + INITPass : 0 + EIntPass : 0 + NMIPass : 0 + Reserved : 0 + System MGMT : 0 + LINT0 Pass : 0 + LINT1 Pass : 0 +[0ACh 0172 001h] Handle : 00 +[0ADh 0173 002h] Source Used Device ID : 00A0 +[0AFh 0175 001h] Variety : 01 + +Raw Table Data: Length 176 (0xB0) - 0000: 49 56 52 53 68 00 00 00 01 43 42 4F 43 48 53 20 // IVRSh....CBOCHS + 0000: 49 56 52 53 B0 00 00 00 01 74 42 4F 43 48 53 20 // IVRS.....tBOCHS 0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC ....BXPC - 0020: 01 00 00 00 00 28 00 00 00 00 00 00 00 00 00 00 // .....(.......... + 0020: 01 00 00 00 01 28 00 00 00 00 00 00 00 00 00 00 // .....(.......... 0030: 10 D1 38 00 10 00 40 00 00 00 D8 FE 00 00 00 00 // ..8...@......... 0040: 00 00 00 00 44 00 00 00 02 00 00 00 02 08 00 00 // ....D........... 0050: 02 10 00 00 02 F8 00 00 02 FA 00 00 02 FB 00 00 // ................ - 0060: 48 00 00 00 00 A0 00 01 // H....... + 0060: 48 00 00 00 00 A0 00 01 11 11 48 00 10 00 40 00 // H.........H...@. + 0070: 00 00 D8 FE 00 00 00 00 00 00 00 00 00 00 00 00 // ................ + 0080: D3 29 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // .).............. + 0090: 02 00 00 00 02 08 00 00 02 10 00 00 02 F8 00 00 // ................ + 00A0: 02 FA 00 00 02 FB 00 00 48 00 00 00 00 A0 00 01 // ........H....... Signed-off-by: Bui Quang Minh Message-Id: <20240111154404.5333-8-minhquangbui99@gmail.com> Acked-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 1 - tests/data/acpi/q35/IVRS.ivrs | Bin 104 -> 176 bytes 2 files changed, 1 deletion(-) diff --git a/tests/data/acpi/q35/IVRS.ivrs b/tests/data/acpi/q35/IVRS.ivrs index 17611202e53a32f7da8e4925d6955b384670b8b1..7f9e91aabc0b7777a7efc9f219587a4f91f0edb1 100644 GIT binary patch delta 63 zcmd1Uz{uqp78JaJfq{XsWFnUoBjZF>XH`K#4+a4S2cY1Me?S5bE^ES>3=9)pl>vea B3FiO+ delta 22 dcmdnMn8D>478IPpz`(%hJdsO^kzt~$GXOlo1j7IT diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index ac420db6b7..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,2 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/IVRS.ivrs", From patchwork Wed Feb 14 11:14:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898840 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=W0RHdvjy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbJc1qR8z23yK for ; Wed, 14 Feb 2024 22:17:36 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDe-0000ki-0u; Wed, 14 Feb 2024 06:14:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDc-0000jl-J4 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDb-0006qU-7X for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909262; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+7/1YIgENNn6T5ST2SQ++m3V36j5nIhY7SM7UOSEqks=; b=W0RHdvjy6E+xaFVfZ7ovjnGzYA+qCCuQ/pe+F21CURcFGPl5aZX9GuacE8WMd7IBLPrHDc uKloMnPaVVkFJB80jx78j8hjqAaUjijlWOwRjfqi7FA91xwbEfAP1u+J1Xgi7vBTEzT4lM Vysx4MMr+F+sxFPVMll3maSmYbfEGdM= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-427-1ojCe2fGNKqBt0ZrSfiIug-1; Wed, 14 Feb 2024 06:14:20 -0500 X-MC-Unique: 1ojCe2fGNKqBt0ZrSfiIug-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a3d3e8f1635so32560766b.2 for ; Wed, 14 Feb 2024 03:14:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909258; x=1708514058; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+7/1YIgENNn6T5ST2SQ++m3V36j5nIhY7SM7UOSEqks=; b=bgE/Pcqtg8qiBqEP8CbwMsFY22h/Oia11OVZ0R0NS92rL1L/VwaaZV0eQf/imCm7uH HxgWCL1HHIVLE2djTapz6+5Eq3/5efgFRhx+Aq93jW4KGhemtjwM9NnnZG0AUL1MUo3F sAyi1ayH/+I9N18aDOzzfay4WHhl/T25CtjSGg8oo+E15ZU9BXVQDezox5LGm4Ml1xxY S1s4dgAC2CV8fJDk9Vv16TCKHVUzC2Y6QEx5xScMszAe4B3mebwnV+L5CZpylhlD8/eP h8ovkci6sGlwAGxhB/C/6TyIo6HPVHqWGJ6sJhqd3WPr9XMFhfbE2UO0I071FEpMWHbv ybTQ== X-Gm-Message-State: AOJu0Yzq/qydUNZONY7Jucv1GP/ISRJ0518RHLlSU51cqYERXSpO+o2f DEZys6ypYV0zhUuTP/0nGyresmGgemLvp3rtzaIVW80aGkaTcbz2croGHV6nbtc3dozmJGewLUF X4nbs3uK+IhorlcA1BCXKUJ5mCqbO3Y2gWxhBJzcw60MZ6Z3Hrscqq9nGLwrLYC0bJuQLeMOGU/ 6OprDBCVTMlSdxPJRnGXY7fCZeAI5a4w== X-Received: by 2002:a17:906:4f0b:b0:a3c:7651:209e with SMTP id t11-20020a1709064f0b00b00a3c7651209emr1569141eju.19.1707909258776; Wed, 14 Feb 2024 03:14:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFlUivMwdUfkNOyrB5mJPxZRRZyG5wyqR9v0ySHCB/7gj15CNTVQDJcoglSlDT6Sgn8Yt9bTg== X-Received: by 2002:a17:906:4f0b:b0:a3c:7651:209e with SMTP id t11-20020a1709064f0b00b00a3c7651209emr1569119eju.19.1707909258415; Wed, 14 Feb 2024 03:14:18 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUBdWKDM7AE3wIqXkW7Xv5fgLZWtnrmO8/iuLtFveztewupLJv6jyYXWfW8OakQbEjqz0R0huLv1Oh2TW12E6FzkyxEIX8oZRwOPR4lj3wk/uGbGbGQt+Kts1Z7wZw0tY2EU/DmCxLBg6ZE/D3eNVgUckJOXC7pz8ZF4LTCzulZWr8eeJyhF/LYeqEO87LubcDq1W43f6uSa685Jnrf5yWwHfJpcCU= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id xa7-20020a170907b9c700b00a3d2490799fsm964986ejc.20.2024.02.14.03.14.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:17 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:15 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 19/60] hw/i386/x86: Reverse if statement Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Beschow The if statement currently uses double negation when executing the else branch. So swap the branches and simplify the condition to make the code more comprehensible. Signed-off-by: Bernhard Beschow Message-Id: <20240106132546.21248-2-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/x86.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 3d1bdd334e..505f64f89c 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -520,10 +520,10 @@ static void x86_nmi(NMIState *n, int cpu_index, Error **errp) CPU_FOREACH(cs) { X86CPU *cpu = X86_CPU(cs); - if (!cpu->apic_state) { - cpu_interrupt(cs, CPU_INTERRUPT_NMI); - } else { + if (cpu->apic_state) { apic_deliver_nmi(cpu->apic_state); + } else { + cpu_interrupt(cs, CPU_INTERRUPT_NMI); } } } From patchwork Wed Feb 14 11:14:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898845 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NUWSpy9R; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbKH2JnHz23hM for ; Wed, 14 Feb 2024 22:18:11 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDl-0000uH-IC; Wed, 14 Feb 2024 06:14:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDj-0000rg-TX for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:32 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDd-0006qo-QN for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909265; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OxMN2l27ZlNrqzqAChublXV5BVT305BpADMb7E/hjJc=; b=NUWSpy9RD7b6OBKnHhstY0JFklUIAn8MsU9SF9jnmlUXnwcOaUaHPijne9FoD6Zh9sB7by xSqUa8QbxeU/X4wL9grP/DQ7CNrfVX0D03wmLvZFCu7vDWT2pHQwKvKs2PamZPiQXsEyoo kfqmok2vNwL8Px0lj2AvGCjjUnRxhaE= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-592-WmrEfYtgPvKMVSbVe93-Bg-1; Wed, 14 Feb 2024 06:14:23 -0500 X-MC-Unique: WmrEfYtgPvKMVSbVe93-Bg-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-558aafe9bf2so4618068a12.1 for ; Wed, 14 Feb 2024 03:14:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909262; x=1708514062; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=OxMN2l27ZlNrqzqAChublXV5BVT305BpADMb7E/hjJc=; b=VGY9hOnPttvGtIzg/qo0Iwfn5H7AS+qYDUSDOCkUsWMnqDsFCLMmMmAmhhuPL6A1gO Z2vSk0Gt+pHbWQ/Ikt10dKMuNbW39r/6yRRjlUTOIHuyMwrn6VVWPzNbzh/l8/lsjXz/ CLOsHW+UIh+7Y54S+Rsfqh8wLjC7ltwireuK9yW2tf7KhwjUJyNS8U44ZFW9yfubCyyi ih3mCEfpJu6VRUpNaouLf1lKw+rngrtlrLxu+HUCCwaITFeiY8JipD9OPJbOd1B0iN1i fUSv+uGWPJR2jqqODJO6HmpespzG5HgryHYLhFWkRFRbFzdjvBhg0aWo26xJFLLGibvv hlLg== X-Gm-Message-State: AOJu0YylbaSwpiAQGaYO9LT/SAR60/0GPYSM8ChkPAGZTuLXMDT8pdGy wmmkU7k1p/2wVOk6qgFNffzyjp/t68FGPDg+P4GeGxttQ5CU1EU4rRxOQp1PmkcjP6YZuy8Z7dS p0itDjoZ68+siIFXTUUr5z4A1rLH9aAN6JKWFl0fzOQU+14GydcB73WLQP4pc3bE44C0ShkMpBx FxGkgxC1APeQS2J8/us1iZVccQ3DUG3w== X-Received: by 2002:aa7:da0e:0:b0:560:d9d5:7af7 with SMTP id r14-20020aa7da0e000000b00560d9d57af7mr1647753eds.10.1707909261942; Wed, 14 Feb 2024 03:14:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvy8bydbyLBiI7ND00c508SS6NxGZxgMTCL8GQaPbuYIBeKvXYhznHlA/3HnX0rB7B+ZDY/w== X-Received: by 2002:aa7:da0e:0:b0:560:d9d5:7af7 with SMTP id r14-20020aa7da0e000000b00560d9d57af7mr1647729eds.10.1707909261625; Wed, 14 Feb 2024 03:14:21 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVb6JaBbLgJiw0H6Eh7E7ZQxXPj2vRtYO+DIIJMDAi643t1PQLlK8T/Eykkk3LI2qBFHkWMJ3OmaTlJQXh2+8lqC8sj8RFe5XQSo29+9wNBW6PvDekDblkXiXzcW7ewgyNFIZC/YP30j2lAjlRK06cKexbVJAqgYKn5auZkfwLTBLPj9bXQ+2J5FinQawsVZFaFsJhTpaOTEeTXFwYHXAO8XxgQ8UM= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id i23-20020a50d757000000b005621e66c8ddsm708911edj.17.2024.02.14.03.14.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:20 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:18 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 20/60] hw/i386/x86: Fix PIC interrupt handling if APIC is globally disabled Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Beschow QEMU populates the apic_state attribute of x86 CPUs if supported by real hardware or if SMP is active. When handling interrupts, it just checks whether apic_state is populated to route the interrupt to the PIC or to the APIC. However, chapter 10.4.3 of [1] requires that: When IA32_APIC_BASE[11] is 0, the processor is functionally equivalent to an IA-32 processor without an on-chip APIC. This means that when apic_state is populated, QEMU needs to check for the MSR_IA32_APICBASE_ENABLE flag in addition. Implement this which fixes some real-world BIOSes. [1] Intel 64 and IA-32 Architectures Software Developer's Manual, Vol. 3A: System Programming Guide, Part 1 Signed-off-by: Bernhard Beschow Message-Id: <20240106132546.21248-3-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/apic.h | 1 + hw/i386/x86.c | 4 ++-- hw/intc/apic_common.c | 13 +++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/include/hw/i386/apic.h b/include/hw/i386/apic.h index f6e7489f2d..eb606d6076 100644 --- a/include/hw/i386/apic.h +++ b/include/hw/i386/apic.h @@ -10,6 +10,7 @@ void apic_deliver_nmi(DeviceState *d); int apic_get_interrupt(DeviceState *s); int cpu_set_apic_base(DeviceState *s, uint64_t val); uint64_t cpu_get_apic_base(DeviceState *s); +bool cpu_is_apic_enabled(DeviceState *s); void cpu_set_apic_tpr(DeviceState *s, uint8_t val); uint8_t cpu_get_apic_tpr(DeviceState *s); void apic_init_reset(DeviceState *s); diff --git a/hw/i386/x86.c b/hw/i386/x86.c index 505f64f89c..684dce90e9 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -520,7 +520,7 @@ static void x86_nmi(NMIState *n, int cpu_index, Error **errp) CPU_FOREACH(cs) { X86CPU *cpu = X86_CPU(cs); - if (cpu->apic_state) { + if (cpu_is_apic_enabled(cpu->apic_state)) { apic_deliver_nmi(cpu->apic_state); } else { cpu_interrupt(cs, CPU_INTERRUPT_NMI); @@ -555,7 +555,7 @@ static void pic_irq_request(void *opaque, int irq, int level) X86CPU *cpu = X86_CPU(cs); trace_x86_pic_interrupt(irq, level); - if (cpu->apic_state && !kvm_irqchip_in_kernel() && + if (cpu_is_apic_enabled(cpu->apic_state) && !kvm_irqchip_in_kernel() && !whpx_apic_in_platform()) { CPU_FOREACH(cs) { cpu = X86_CPU(cs); diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index 16ab40a35f..d8fc1e2815 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -62,6 +62,19 @@ uint64_t cpu_get_apic_base(DeviceState *dev) } } +bool cpu_is_apic_enabled(DeviceState *dev) +{ + APICCommonState *s; + + if (!dev) { + return false; + } + + s = APIC_COMMON(dev); + + return s->apicbase & MSR_IA32_APICBASE_ENABLE; +} + void cpu_set_apic_tpr(DeviceState *dev, uint8_t val) { APICCommonState *s; From patchwork Wed Feb 14 11:14:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898850 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Pkr/mu42; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbL302hYz23hM for ; Wed, 14 Feb 2024 22:18:51 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDm-00013W-LB; Wed, 14 Feb 2024 06:14:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDl-0000tz-11 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDi-0006r5-Ug for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909267; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IFQEyso13LWrBynJ1cCVjL6Hf/e/37ToPaPEgRO7pkw=; b=Pkr/mu42Q5Cx3gsJNIWpSujZOv9aWJ5IIiZskHZ5TC8MaW21bgZMOREeygxm9I5LU8bdaA //MW9z8zt0BNKKc2kUSYBWVhOm24MXgOq6aRy9o4V02XjHqEa8RUN4Xu9TnYUlEaX5iudZ QUMqZqhG1+27cWYhQcX98vsSu91AqV0= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-w1ovtsMUOm6X3L-NoVDC0g-1; Wed, 14 Feb 2024 06:14:26 -0500 X-MC-Unique: w1ovtsMUOm6X3L-NoVDC0g-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-558aafe9bf2so4618082a12.1 for ; Wed, 14 Feb 2024 03:14:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909264; x=1708514064; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IFQEyso13LWrBynJ1cCVjL6Hf/e/37ToPaPEgRO7pkw=; b=CG6F5bd8Wr4gc1Xxe9fT+n+ur9F2TBPNvkMP6RmfiVHZ8Bzw/ThrgRUmOF/pYey6KR t+xPDpHCAKnrTAoE1IdQfveMfSU+TrxRqpXY7GpjpKXxB9Ef1N4J5SQyaqBCcz6RbVdL 32+Uaqa/WSWESzcz8tOEfIuCo6LCYd+CETpd0T+b9xe2YUQ+8lPY/YCVlVV9q+MB4ITG 5sHWMSe3cPu8fLQCvn62A2JtEi3mCxa/TNXyOY2cKDGgLSWi3yrpqaga3atcVIm+dgD0 N+rvdh4PLmOJg7urSPd117HdLDeN3Rt3Gbtt6YGKRAbDq4Jj+pEOMXYsjK9L8rsnIAY4 Eu4g== X-Gm-Message-State: AOJu0Yw0nRuWCrI6pTt5sgmvkqXJ0uv8mtneidwg/hwI3sevwl9eU726 wul3Ir/MGhApHTSkvRoHqImtLtypRDJZ5Bz3bVJFCmr+QHW8qRqLwBQZGaoFuVXBUYXRKor0M+y Er6W8XN1/R+q5j4sIot5B5Ikt6eWpJCSnA+roWX6IBsn+n3CvM63FpjDkXbG0PITkGTRcIsD1Lh SInkm2NWMRPdMRsXkxjIfs/p3SpkuJmw== X-Received: by 2002:a05:6402:2033:b0:561:f210:d554 with SMTP id ay19-20020a056402203300b00561f210d554mr1746402edb.13.1707909264741; Wed, 14 Feb 2024 03:14:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHQASElPsopC+mWIEzciTQXR11ucVCBFKDWvpt8wwlfJzAKPSZyr7nKOeSTaRtYkqGm9Ur96A== X-Received: by 2002:a05:6402:2033:b0:561:f210:d554 with SMTP id ay19-20020a056402203300b00561f210d554mr1746385edb.13.1707909264451; Wed, 14 Feb 2024 03:14:24 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUDisr4sOr/iP5asScZ8RxIFXIXVv2oX4Vd3d6hLiO9sinqRdb0HR+cITYXIqxbUDm13lw+M588wuPtDtkg+/Jt6RGQsshfpvQTWQTXE9HNwO2HcDYLoLEg2CE0Yy0mkZ4UAaVV3qwZdiaNqPksBw== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id dc11-20020a056402310b00b005613cbbdb81sm4592125edb.80.2024.02.14.03.14.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:23 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:21 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Alex =?utf-8?q?Benn=C3=A9e?= , Paolo Bonzini Subject: [PULL 21/60] target/i386/cpu: Fix typo in comment Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Beschow Signed-off-by: Bernhard Beschow Reviewed-by: Alex Bennée Message-Id: <20240106132546.21248-4-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- target/i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 2126b0e589..0cd32a6fce 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2179,7 +2179,7 @@ static const CPUCaches epyc_genoa_cache_info = { * Conceal VM entries from PT * Enable ENCLS exiting * Mode-based execute control (XS/XU) - s TSC scaling (Skylake Server and newer) + * TSC scaling (Skylake Server and newer) * GPA translation for PT (IceLake and newer) * User wait and pause * ENCLV exiting From patchwork Wed Feb 14 11:14:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898876 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ktrqfe9q; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbP82kThz23j4 for ; Wed, 14 Feb 2024 22:21:32 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDIh-0002sX-2F; Wed, 14 Feb 2024 06:19:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDIe-0002Pz-W9 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:19:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDId-00085T-CK for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:19:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6LsM8D7u878nz29/5qgyEFYwVL8xOaz5pqW5FXboxXM=; b=Ktrqfe9qZZGdnLc7kgnSN1tnzRD25A38Ap0obYCrNAUAGv2wjJ5sF8FyHaFhYY7+ccr+qL yswwbtwC+Iybuzbmj8MWSp1ocNnANLDfRbDo0TVHmkY1Nshdh/LRsgiHPOcdtvJiF+QUXn yOpoeQTusaFvpqPAp0j91bKcGD4obf0= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-554-CHzqgG5BM_yWN2RUguzeUA-1; Wed, 14 Feb 2024 06:19:32 -0500 X-MC-Unique: CHzqgG5BM_yWN2RUguzeUA-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a27eddc1c27so115450866b.3 for ; Wed, 14 Feb 2024 03:19:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909268; x=1708514068; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6LsM8D7u878nz29/5qgyEFYwVL8xOaz5pqW5FXboxXM=; b=N1oMK2bA6io++JJ7nI7RPzkxFS4mYWfHHxzRYDMua7V4sFxIa+xkwQ/1SuT20uwVhz X4S9ev//dG4o2Dx6TKGyS9Tg8JQTAaH253QPLpkecuxYeatu+8VW+xXs9XueyTmlB2C2 2JTymCaK/fa8rHOHufaRHLzGu9bfBrmNdyXZ18HrBKYqcYBa/q3wK9dy5Z0fiKxb1+QL PgnXhSxhPg5JS7UPxLhtRB8FM+PSVKh3FOP5PkHtazKtZH7J2tkW5B6fnvHyMASWrvUk d1T4wgpHRbW3RWlrHrBtnO15ldZbiKk20WrudcgJqSib9lR/h2TAFbYgSi53jGTt8GbC e6wQ== X-Gm-Message-State: AOJu0Yw9ie260NojFyk4+1yoccSD9S7qcE0stmuXqYh3dVKaqZ57tBwe ZQIN6U3iS8Jwc7FYa3u3wEa8CMnUUFlBUSN/ffYOprPdHfCGh3b7e1zFctpelDMIjhpU8G/xBnE /rgGwNEV5RZfnDu0RXRk7gjyj+Z8E4/X8fZEVyvvR/oGL9bSl7omCdSnMqHotefjuoc7W/vPksc SFrKiiUGVsqqmDfDBUfhZkFyUVaTAZ2A== X-Received: by 2002:a17:906:ae09:b0:a3b:7216:3091 with SMTP id le9-20020a170906ae0900b00a3b72163091mr1424060ejb.20.1707909267917; Wed, 14 Feb 2024 03:14:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWzxIveWeX6h8076CJoQaqcXY6Vt6chTMkNlDW/mtgaWKVryZy/PnFAp7sNQVQZC1bJl8P9w== X-Received: by 2002:a17:906:ae09:b0:a3b:7216:3091 with SMTP id le9-20020a170906ae0900b00a3b72163091mr1424040ejb.20.1707909267642; Wed, 14 Feb 2024 03:14:27 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXtEz5+bFRwbiGs+0QLbtvQTBsbhklKzO1xNKGN7UMWJxnu5MP3hesH/CjRva1FiwCeHCk/T/W47DP8y0ZMZSvHAD+tBEccLEEZDF7wxQtzw6DLbP83zQ3CRq/XDQvP75eVYmJhWngdo/NOgJPxxxnmCQyukhpArgrWfGPUX9pVchX/qjKYpm1+TE5BFRRm9MS1I0QOacWTCy0wNVBCdLApdDXR Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id mm19-20020a1709077a9300b00a3d4d78a769sm404454ejc.1.2024.02.14.03.14.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:27 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:24 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , BALATON Zoltan , John Snow , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PULL 22/60] hw/block/fdc-isa: Move portio_list from FDCtrl to FDCtrlISABus Message-ID: <271c5bb3780773008a936f424cccf181a11b592c.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Beschow FDCtrl::portio_list isn't used inside FDCtrl context but only inside FDCtrlISABus context, so move it there. Signed-off-by: Bernhard Beschow Reviewed-by: BALATON Zoltan Message-Id: <20240114123911.4877-2-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/block/fdc-internal.h | 2 -- hw/block/fdc-isa.c | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/block/fdc-internal.h b/hw/block/fdc-internal.h index 036392e9fc..fef2bfbbf5 100644 --- a/hw/block/fdc-internal.h +++ b/hw/block/fdc-internal.h @@ -26,7 +26,6 @@ #define HW_BLOCK_FDC_INTERNAL_H #include "exec/memory.h" -#include "exec/ioport.h" #include "hw/block/block.h" #include "hw/block/fdc.h" #include "qapi/qapi-types-block.h" @@ -140,7 +139,6 @@ struct FDCtrl { /* Timers state */ uint8_t timer0; uint8_t timer1; - PortioList portio_list; }; extern const FDFormat fd_formats[]; diff --git a/hw/block/fdc-isa.c b/hw/block/fdc-isa.c index ad0921c7d3..2d8a98ce7d 100644 --- a/hw/block/fdc-isa.c +++ b/hw/block/fdc-isa.c @@ -42,6 +42,7 @@ #include "sysemu/block-backend.h" #include "sysemu/blockdev.h" #include "sysemu/sysemu.h" +#include "exec/ioport.h" #include "qemu/log.h" #include "qemu/main-loop.h" #include "qemu/module.h" @@ -60,6 +61,7 @@ struct FDCtrlISABus { uint32_t irq; uint32_t dma; struct FDCtrl state; + PortioList portio_list; int32_t bootindexA; int32_t bootindexB; }; @@ -91,7 +93,7 @@ static void isabus_fdc_realize(DeviceState *dev, Error **errp) FDCtrl *fdctrl = &isa->state; Error *err = NULL; - isa_register_portio_list(isadev, &fdctrl->portio_list, + isa_register_portio_list(isadev, &isa->portio_list, isa->iobase, fdc_portio_list, fdctrl, "fdc"); From patchwork Wed Feb 14 11:14:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898863 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=g7cfhMni; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbMQ64ZKz23j8 for ; Wed, 14 Feb 2024 22:20:02 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDq-0001S9-7q; Wed, 14 Feb 2024 06:14:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDo-0001CB-81 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDm-0006ry-Hu for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909273; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=e2FiAPUSNm6DWhdD5+bHFGCA/e/qpo+4q1OUy9Pvg0M=; b=g7cfhMni6oAIsl4sgok68dnByIIl4raLDiOqZLhBdQnANanvefnD7Iqf8/rEf3eb6fs4Tu lTywWm1FqYEHk9zyf1Ck5/VvW0Eh5OJzB2zzVuC/CBZysSwVWUGmMG8IAkGTjGChf6LJma M/NnahmAvTlNwQmXuzB/2OKwvV9NSLw= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-271-g2g9orhQPMK0qgNDuo2NWg-1; Wed, 14 Feb 2024 06:14:32 -0500 X-MC-Unique: g2g9orhQPMK0qgNDuo2NWg-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a3d24680e06so62355066b.3 for ; Wed, 14 Feb 2024 03:14:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909271; x=1708514071; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=e2FiAPUSNm6DWhdD5+bHFGCA/e/qpo+4q1OUy9Pvg0M=; b=HH7vCKtVZAU2e90XYX/tbYngw0F/jCHwsKv/KIHm/XD0imykj8A1gRxtVNuSvZoqAS rTy7v3eA845RoEBHoLdzhPplcqT1vhtX0ayG5rg6qG2up5HoPZmEUSPBn8jnOSGYyWcG g7ZiD3dTwe2b6i6/BKQNiay1fVRoA6BOjJuoS5LjOXV8CIbBR5AjVoX82ilK/qjRziEm 4QJgbVTw16hyugAdCQEepnlNO9hDYeHLwWzmNtZ9iALlpM+G53gKFiEnWfmv4mUGS/vH JUtJu9m254BSRVIZR44Bj/GXm5YnoY4blEZB8eibHRCn3d9xp/piqcdUK1guKeuDF5nS Mpow== X-Gm-Message-State: AOJu0YxL1SdblKK7KA6aiAh26nSZf2fWhbSjxCZdmyjzoXV2m/dUEgn0 0eW7W2Y7QSEy+vRUx1LZelpoyF8v8ISmyiG3nMF0vbw0IpOu3v4pvvmebRyfzW8BD+y3RuAM8AC v0LjNG8+SjG+tBqBV3oueFd9oyvHhoQ7Zw27yrtLpSQ3BbrQsPH1UFAMkPWXROzxrmfHnFMchZt XSHSzqgwU7V+XvMZOSyByljBW9c3yq2Q== X-Received: by 2002:a17:906:5a8a:b0:a3d:2222:bb81 with SMTP id l10-20020a1709065a8a00b00a3d2222bb81mr1603027ejq.10.1707909271097; Wed, 14 Feb 2024 03:14:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IElhCPqFZUH/6PTMwJj24ddmlHWdLqtHld0xgkHi/q5sMKHUSZ0Pp2cbtfRTQlKtKrH05WE/w== X-Received: by 2002:a17:906:5a8a:b0:a3d:2222:bb81 with SMTP id l10-20020a1709065a8a00b00a3d2222bb81mr1603010ejq.10.1707909270816; Wed, 14 Feb 2024 03:14:30 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUB2TSlLcRjQXkffGcmVQdPgRZRA31ZZlLw44cS6KcDIsuSl6XWK+R1bsAJoVbbsxolu7Hf9ILgWb2Ay9ajAaLnvJB6lhh7VarsXfGM3bAqXpYtUKZHos2PWZneTh0RJ6Z+Bxn2oef5ZAq94HJaEruoYkHntaSzGkyOhUIKnknfoAySrMLn6qCNA7dsmzeOVMKKqBjUkjGOfaH+Oal/OetaKmjP Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id gs20-20020a170906f19400b00a3d64b37a35sm90817ejb.137.2024.02.14.03.14.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:30 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:27 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , BALATON Zoltan , John Snow , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PULL 23/60] hw/block/fdc-sysbus: Move iomem from FDCtrl to FDCtrlSysBus Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Beschow FDCtrl::iomem isn't used inside FDCtrl context but only inside FDCtrlSysBus context, so move it there. Signed-off-by: Bernhard Beschow Reviewed-by: BALATON Zoltan Message-Id: <20240114123911.4877-3-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/block/fdc-internal.h | 2 -- hw/block/fdc-sysbus.c | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/block/fdc-internal.h b/hw/block/fdc-internal.h index fef2bfbbf5..e219623dc7 100644 --- a/hw/block/fdc-internal.h +++ b/hw/block/fdc-internal.h @@ -25,7 +25,6 @@ #ifndef HW_BLOCK_FDC_INTERNAL_H #define HW_BLOCK_FDC_INTERNAL_H -#include "exec/memory.h" #include "hw/block/block.h" #include "hw/block/fdc.h" #include "qapi/qapi-types-block.h" @@ -91,7 +90,6 @@ typedef struct FDrive { } FDrive; struct FDCtrl { - MemoryRegion iomem; qemu_irq irq; /* Controller state */ QEMUTimer *result_timer; diff --git a/hw/block/fdc-sysbus.c b/hw/block/fdc-sysbus.c index 266bc4d145..035bc08975 100644 --- a/hw/block/fdc-sysbus.c +++ b/hw/block/fdc-sysbus.c @@ -26,6 +26,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qom/object.h" +#include "exec/memory.h" #include "hw/sysbus.h" #include "hw/block/fdc.h" #include "migration/vmstate.h" @@ -52,6 +53,7 @@ struct FDCtrlSysBus { /*< public >*/ struct FDCtrl state; + MemoryRegion iomem; }; static uint64_t fdctrl_read_mem(void *opaque, hwaddr reg, unsigned ize) @@ -146,11 +148,11 @@ static void sysbus_fdc_common_instance_init(Object *obj) qdev_set_legacy_instance_id(dev, 0 /* io */, 2); /* FIXME */ - memory_region_init_io(&fdctrl->iomem, obj, + memory_region_init_io(&sys->iomem, obj, sbdc->use_strict_io ? &fdctrl_mem_strict_ops : &fdctrl_mem_ops, fdctrl, "fdc", 0x08); - sysbus_init_mmio(sbd, &fdctrl->iomem); + sysbus_init_mmio(sbd, &sys->iomem); sysbus_init_irq(sbd, &fdctrl->irq); qdev_init_gpio_in(dev, fdctrl_handle_tc, 1); From patchwork Wed Feb 14 11:14:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898880 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XtDlVgm+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbQ235Kmz23j4 for ; Wed, 14 Feb 2024 22:22:18 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDu-0001uj-1S; Wed, 14 Feb 2024 06:14:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDr-0001dV-Pf for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDq-0006sQ-5w for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909277; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=rCVOMcJiLddQAE98l74rVjecbrg61kvWL8401omA3iY=; b=XtDlVgm+zHN8yyA+Ruk7tOOTq2ye/cvWChKX7G+1N7k+5PKGogMopg/N3vvbE95Bder/03 401Y0j3SeByRRszP5Fuklj7MoaaiuNNbkbD6f6lZnhh1MJoceu1UtDpSdYNa0GzcPzXuUQ pA6AYuYeNb5nIvIPRzS92bzEVbTMFiY= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-453-Q6KHLJMvPEqErtCEHzmXUA-1; Wed, 14 Feb 2024 06:14:35 -0500 X-MC-Unique: Q6KHLJMvPEqErtCEHzmXUA-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5621c809accso455896a12.1 for ; Wed, 14 Feb 2024 03:14:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909274; x=1708514074; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rCVOMcJiLddQAE98l74rVjecbrg61kvWL8401omA3iY=; b=ih1bLW+ebXBKUwFuJDwY8Ny62pyPNNwQVk8leOHKl5zHsYvnJyEozboUCSX4B9t94E JfvfV6cWwRyIbZNTcDpHqJ+I8k2VGyqUdq/Q8zS85YVe3MbxKxI2Da0qd2kLKVBFL2Og OYQtFhAouJXwd29lPGWw/Rr/zrn218pCKgb0P0oqnEtde7HpGGiZLKd/iYAAmgGsQxEH gSMfJtej0/Yww6HGbgfsExJawcFvzRcznzs+zUm+KHWBJx023U7pRykibfb+6CCOFDfI 36+STdRQfn13HLgFeSoqn0AvW1R+8mXHQFreC1jMy+HMgIX2vqiL0uUyLBI1biJpKzkf 1rlA== X-Gm-Message-State: AOJu0YxliwcajIzt0dZtB8npJNLP3vyrDDT6aelr5vr+eXE6S+LDeuu6 Gt5+g6GCRuJH0mZKmQYLNBiSq9jj275R9hAOiyNl+h0Uf8Bf60aA7LsE+QQZV3nmV0E3BXby7p4 RbBKNcuJAgLaZ2pnsEQ1S5zAnXtTzdoMYKbf/mGCp3jAk7n4HnxDswqr5wg8q4WOYYhtjvkEj3u u+Wj3ndZwW2PUL1myC7dvFxkLN+EzCZQ== X-Received: by 2002:a05:6402:26c9:b0:563:42c:5420 with SMTP id x9-20020a05640226c900b00563042c5420mr1330639edd.30.1707909274274; Wed, 14 Feb 2024 03:14:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWvdfndwfDABzjfAvQs+a5JHcNzIgtBC8udj/EzP+91gBxbyIeX1/DOMT67EIhYlnSgAUlXg== X-Received: by 2002:a05:6402:26c9:b0:563:42c:5420 with SMTP id x9-20020a05640226c900b00563042c5420mr1330615edd.30.1707909273925; Wed, 14 Feb 2024 03:14:33 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUz+tl5wWQGa00DQGgpo93NJVvuJgXAmGOxDSEWYou6BVp3sEZyN5sL5SEbf1Ong3KXskEJxv/xFOHIP7/2QYuW8OCoaSxshCS6m3qfoFZUwOQzMHhJ+2IFLopHioKMBTEyXuwyl10nFZc4J8cb6XeRiHojRc2vPOsn4QvgXhATohuGmE5FNIA= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id da23-20020a056402177700b00561a0dc7934sm3217986edb.7.2024.02.14.03.14.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:33 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:31 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , BALATON Zoltan , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9?= Lureau Subject: [PULL 24/60] hw/char/parallel: Move portio_list from ParallelState to ISAParallelState Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Beschow ParallelState::portio_list isn't used inside ParallelState context but only inside ISAParallelState context, so move it there. Signed-off-by: Bernhard Beschow Reviewed-by: BALATON Zoltan Message-Id: <20240114123911.4877-4-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/char/parallel-isa.h | 2 ++ include/hw/char/parallel.h | 2 -- hw/char/parallel.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/hw/char/parallel-isa.h b/include/hw/char/parallel-isa.h index d24ccecf05..3b783bd08d 100644 --- a/include/hw/char/parallel-isa.h +++ b/include/hw/char/parallel-isa.h @@ -12,6 +12,7 @@ #include "parallel.h" +#include "exec/ioport.h" #include "hw/isa/isa.h" #include "qom/object.h" @@ -25,6 +26,7 @@ struct ISAParallelState { uint32_t iobase; uint32_t isairq; ParallelState state; + PortioList portio_list; }; #endif /* HW_PARALLEL_ISA_H */ diff --git a/include/hw/char/parallel.h b/include/hw/char/parallel.h index 7b5a309a03..cfb97cc7cc 100644 --- a/include/hw/char/parallel.h +++ b/include/hw/char/parallel.h @@ -1,7 +1,6 @@ #ifndef HW_PARALLEL_H #define HW_PARALLEL_H -#include "exec/ioport.h" #include "exec/memory.h" #include "hw/isa/isa.h" #include "hw/irq.h" @@ -22,7 +21,6 @@ typedef struct ParallelState { uint32_t last_read_offset; /* For debugging */ /* Memory-mapped interface */ int it_shift; - PortioList portio_list; } ParallelState; void parallel_hds_isa_init(ISABus *bus, int n); diff --git a/hw/char/parallel.c b/hw/char/parallel.c index bd488cd7f9..c394635ada 100644 --- a/hw/char/parallel.c +++ b/hw/char/parallel.c @@ -532,7 +532,7 @@ static void parallel_isa_realizefn(DeviceState *dev, Error **errp) s->status = dummy; } - isa_register_portio_list(isadev, &s->portio_list, base, + isa_register_portio_list(isadev, &isa->portio_list, base, (s->hw_driver ? &isa_parallel_portio_hw_list[0] : &isa_parallel_portio_sw_list[0]), From patchwork Wed Feb 14 11:14:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898841 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Y6ioUhoK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbJc5HGCz23hM for ; Wed, 14 Feb 2024 22:17:36 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDDw-0002Cy-AR; Wed, 14 Feb 2024 06:14:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDu-00023J-VP for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDt-0006tE-3f for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vU/FdZML6DqnPVTmQt+IGMJCQ6FBN1LoDWvbCySz6NY=; b=Y6ioUhoKeQnylojVzZPfAru+lgoRH691ojeDwhtLNKTAxjpduUjgSHxE83z8kfT5TY4o6I gQFrDrEjxWZTERCVJM5cP9DtQuQZrtb/3Tt/DCKIrckcmT3xFsoWXff/r/OqpdHw8tT75e eTKx8ak9mhvVmPsv5tIsY186MwpZlK0= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-505-A4d6Ix4JOVGZpYwsRkUo9g-1; Wed, 14 Feb 2024 06:14:39 -0500 X-MC-Unique: A4d6Ix4JOVGZpYwsRkUo9g-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a3d4881bcf5so30795166b.1 for ; Wed, 14 Feb 2024 03:14:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909277; x=1708514077; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vU/FdZML6DqnPVTmQt+IGMJCQ6FBN1LoDWvbCySz6NY=; b=GHiUl/3rE2bswuMgZ64/3T8TFvx+MGXXr+YSB+vnpLTqE4R5voFtDihphBhk+d274H YgTpSaX6qF+ysyuPzPWsu9P5XZmr6IYq4/ZkaIbqJsOYvE0wINeyfo+nZ9yZStV4+h1D oFwSxmih0hDJSY75elGzrLWSHnuodJGfKKNldKuo9B2R49FKzdd7lG7eVCpmzmkOTu1v FGbBAgOxR0WppCUHX94wUFzjlubY9+3VYB01DJ9WYiSN+OvWcn/3Ynnvrh+8GSR1K2C7 aMGsH33X4c5GiY6t7Wxtdib8zxKc0luy8hED/80LZpDprDMt68BoPMzOlnFR4n5+ICA9 v2Wg== X-Gm-Message-State: AOJu0YwXAu+dB/k+qEVRaDp3qhbfDsEP8GLhXeOU8t1QFOKzQoSXaJqe DHOop3eQAQsSY2hO55Wwmb8sPhH7T5W6yRU6Y5DIzFdkqG1dk0xm3MHlv5z98+imLTFESUPT/sZ NjZ7GS4EMgLKHrFGWXjo0gd4YSXb9T7m8h1zXC3R4eaWgwWgUQSqNLbu6+yCWkZ12kdWA50vKCo RCBSflbi/v+eU0EKAQbxzs6TeSbbth2Q== X-Received: by 2002:a17:906:f10a:b0:a38:1e54:91d7 with SMTP id gv10-20020a170906f10a00b00a381e5491d7mr1526239ejb.56.1707909277451; Wed, 14 Feb 2024 03:14:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFtPhGzWEUddikie8HWtYEMTgNxvRUm4eZsC0Q1VLwVE43uufPxpTdoyZ2gbOKOj+b70EMOw== X-Received: by 2002:a17:906:f10a:b0:a38:1e54:91d7 with SMTP id gv10-20020a170906f10a00b00a381e5491d7mr1526218ejb.56.1707909277058; Wed, 14 Feb 2024 03:14:37 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXXjXx0XyAXLEFe0Zh5fb9GSpChGhIPxYmW7UY6Ed6F4WS4tidh5vIt2zvTYnmQ1dp/b4XZCHNTxUyZX+U5pvUHlrVXa1xxDpbPYaVPpvxS8KgG38Mi11xoaT5UIGqTtt8Nz1V+g7CdRMDAiFjK7eUcIWvONbkRV3wG8K+BABKodryxNoehyDyjyI5bvEbv Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id ss3-20020a170907c00300b00a3d11908bbcsm1320430ejc.203.2024.02.14.03.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:36 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:34 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Paolo Bonzini , Peter Xu , David Hildenbrand , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PULL 25/60] exec/ioport: Resolve redundant .base attribute in struct MemoryRegionPortio Message-ID: <4edee342f81397e8938ba7a80d1908c5103b66c8.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Beschow portio_list_add_1() creates a MemoryRegionPortioList instance which holds a MemoryRegion `mr` and an array of MemoryRegionPortio elements named `ports`. Each element in the array gets assigned the same value for its .base attribute. The same value also ends up as the .addr attribute of `mr` due to the memory_region_add_subregion() call. This means that all .base attributes are the same as `mr.addr`. The only usages of MemoryRegionPortio::base were in portio_read() and portio_write(). Both functions get above MemoryRegionPortioList as their opaque parameter. In both cases find_portio() can only return one of the MemoryRegionPortio elements of the `ports` array. Due to above observation any element will have the same .base value equal to `mr.addr` which is also accessible. Hence, `mrpio->mr.addr` is equivalent to `mrp->base` and MemoryRegionPortio::base is redundant and can be removed. Signed-off-by: Bernhard Beschow Message-Id: <20240114123911.4877-5-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/exec/ioport.h | 1 - system/ioport.c | 13 ++++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/exec/ioport.h b/include/exec/ioport.h index e34f668998..95f1dc30d0 100644 --- a/include/exec/ioport.h +++ b/include/exec/ioport.h @@ -35,7 +35,6 @@ typedef struct MemoryRegionPortio { unsigned size; uint32_t (*read)(void *opaque, uint32_t address); void (*write)(void *opaque, uint32_t address, uint32_t data); - uint32_t base; /* private field */ } MemoryRegionPortio; #define PORTIO_END_OF_LIST() { } diff --git a/system/ioport.c b/system/ioport.c index 1824aa808c..a59e58b716 100644 --- a/system/ioport.c +++ b/system/ioport.c @@ -181,13 +181,13 @@ static uint64_t portio_read(void *opaque, hwaddr addr, unsigned size) data = ((uint64_t)1 << (size * 8)) - 1; if (mrp) { - data = mrp->read(mrpio->portio_opaque, mrp->base + addr); + data = mrp->read(mrpio->portio_opaque, mrpio->mr.addr + addr); } else if (size == 2) { mrp = find_portio(mrpio, addr, 1, false); if (mrp) { - data = mrp->read(mrpio->portio_opaque, mrp->base + addr); + data = mrp->read(mrpio->portio_opaque, mrpio->mr.addr + addr); if (addr + 1 < mrp->offset + mrp->len) { - data |= mrp->read(mrpio->portio_opaque, mrp->base + addr + 1) << 8; + data |= mrp->read(mrpio->portio_opaque, mrpio->mr.addr + addr + 1) << 8; } else { data |= 0xff00; } @@ -203,13 +203,13 @@ static void portio_write(void *opaque, hwaddr addr, uint64_t data, const MemoryRegionPortio *mrp = find_portio(mrpio, addr, size, true); if (mrp) { - mrp->write(mrpio->portio_opaque, mrp->base + addr, data); + mrp->write(mrpio->portio_opaque, mrpio->mr.addr + addr, data); } else if (size == 2) { mrp = find_portio(mrpio, addr, 1, true); if (mrp) { - mrp->write(mrpio->portio_opaque, mrp->base + addr, data & 0xff); + mrp->write(mrpio->portio_opaque, mrpio->mr.addr + addr, data & 0xff); if (addr + 1 < mrp->offset + mrp->len) { - mrp->write(mrpio->portio_opaque, mrp->base + addr + 1, data >> 8); + mrp->write(mrpio->portio_opaque, mrpio->mr.addr + addr + 1, data >> 8); } } } @@ -244,7 +244,6 @@ static void portio_list_add_1(PortioList *piolist, /* Adjust the offsets to all be zero-based for the region. */ for (i = 0; i < count; ++i) { mrpio->ports[i].offset -= off_low; - mrpio->ports[i].base = start + off_low; } /* From patchwork Wed Feb 14 11:14:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898884 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LkRJGF//; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbRQ0GGHz23j4 for ; Wed, 14 Feb 2024 22:23:30 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDE0-0002np-5Z; Wed, 14 Feb 2024 06:14:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDx-0002OS-TL for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDw-0006tr-1U for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909283; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=smiDBzm8jjockK0zGaO+moTUtAPPy/TrghQrFfeHPcQ=; b=LkRJGF//g278S5E2UIu4bDdcsy0BsuV/4XnBm90KFzjY849+819q5FXzy/df0T+md/uZum 46aNik42fxXzX4326jn6zIQK48kYS6JBkRA7MWC0mlNl+P4OGy8xVJdp6+4rsqYsb8PAOf 1+WYED8TsYPq28tVGhvfbOX7OGhv700= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-412-13pTl0a-PhaJpbtcXOvQZw-1; Wed, 14 Feb 2024 06:14:41 -0500 X-MC-Unique: 13pTl0a-PhaJpbtcXOvQZw-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a2bc664528fso403710166b.3 for ; Wed, 14 Feb 2024 03:14:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909280; x=1708514080; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=smiDBzm8jjockK0zGaO+moTUtAPPy/TrghQrFfeHPcQ=; b=XSeXYFu5xQkob/sERN6faHhKHwQqKqWf2Z1K1cF6dF4BCUZ3uHuBzMERIi2MTPn0Oz ee8i6pjBCP5xMS1yOyBCRsgA/PDj0MpL321Lt2zLJbNYut/Z5PP2z6fk1X/rgFueAGbC pjW2e85wOWuTWvpU4OBG08+x8MiZGFROiYidQBLcJYHVWZg+35KDBKQlaJAj6QQjnFsw mb5bMputZeT5OmZBBCjkxEz5LbWRlXr1hmNwumb0icU1soxfFGIX3npwh7vgkbOM+oTR zqly+Uh4YK4yRWLhItaep069zLkGCpoZPpl5FbCLuX7UkWB7EzJloMJrGVvRyV9699cf dXFw== X-Gm-Message-State: AOJu0Yy06N1RpQ5KIPm2qURhgNe/uAFZ+wKVgehRVe80hEwkFItKHbC6 bJgq+lnxbwWDeThlwcuUHii7TqLSbaKmTNKTIZC1PE3TckckTBtkbhf23ykVlftiyIjw+Opqt0q lNkrKPmAYDpA2AMIDV5avpO+y4NoHT056qlk0Gw1Xc0rSSlvNIVSWSzmYOCQTKNg66pa3+wCHSA SDZp63Yors8cr/nrhaEkk+p+7hBnSzCg== X-Received: by 2002:a17:906:6809:b0:a3d:6160:fcca with SMTP id k9-20020a170906680900b00a3d6160fccamr463631ejr.69.1707909280212; Wed, 14 Feb 2024 03:14:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZjsSdR+l4A/AMEj2g0dxGAt+tfDD2oxNPbfCTsR93ojeJ4kt5Ig95/isB/NwkQ7W8CWZU/g== X-Received: by 2002:a17:906:6809:b0:a3d:6160:fcca with SMTP id k9-20020a170906680900b00a3d6160fccamr463612ejr.69.1707909279962; Wed, 14 Feb 2024 03:14:39 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVCcIux88zS8EZnjkSw4acOkpebnVTw0Tj1c2ALNA6K7LQXu4YZMmsMvHVsxcQOFK9PqHMc9PFk64IYNLdrXvxN7IrTCcrcVHw+xZybfhiZdpL4luJyy77i+CLdCwY8zGdL3DUO5R2EMG5ZQNKIpL1vBLgjVOS5XZhBTMWWqiIjuKPyZEd+WzIyn+EAc+63 Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id x16-20020a170906441000b00a3d44571dd9sm504245ejo.136.2024.02.14.03.14.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:39 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:37 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Paolo Bonzini , Peter Xu , David Hildenbrand , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PULL 26/60] exec/ioport: Add portio_list_set_address() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Beschow Some SuperI/O devices such as the VIA south bridges or the PC87312 controller are able to relocate their SuperI/O functions. Add a convenience function for implementing this in the VIA south bridges. This convenience function relies on previous simplifications in exec/ioport which avoids some duplicate synchronization of I/O port base addresses. The naming of the function is inspired by its memory_region_set_address() pendant. Signed-off-by: Bernhard Beschow Message-Id: <20240114123911.4877-6-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/exec/ioport.h | 2 ++ system/ioport.c | 19 +++++++++++++++++++ docs/devel/migration/main.rst | 5 +++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/include/exec/ioport.h b/include/exec/ioport.h index 95f1dc30d0..96858e5ac3 100644 --- a/include/exec/ioport.h +++ b/include/exec/ioport.h @@ -54,6 +54,7 @@ typedef struct PortioList { const struct MemoryRegionPortio *ports; Object *owner; struct MemoryRegion *address_space; + uint32_t addr; unsigned nr; struct MemoryRegion **regions; void *opaque; @@ -70,5 +71,6 @@ void portio_list_add(PortioList *piolist, struct MemoryRegion *address_space, uint32_t addr); void portio_list_del(PortioList *piolist); +void portio_list_set_address(PortioList *piolist, uint32_t addr); #endif /* IOPORT_H */ diff --git a/system/ioport.c b/system/ioport.c index a59e58b716..000e0ee1af 100644 --- a/system/ioport.c +++ b/system/ioport.c @@ -133,6 +133,7 @@ void portio_list_init(PortioList *piolist, piolist->nr = 0; piolist->regions = g_new0(MemoryRegion *, n); piolist->address_space = NULL; + piolist->addr = 0; piolist->opaque = opaque; piolist->owner = owner; piolist->name = name; @@ -282,6 +283,7 @@ void portio_list_add(PortioList *piolist, unsigned int off_low, off_high, off_last, count; piolist->address_space = address_space; + piolist->addr = start; /* Handle the first entry specially. */ off_last = off_low = pio_start->offset; @@ -322,6 +324,23 @@ void portio_list_del(PortioList *piolist) } } +void portio_list_set_address(PortioList *piolist, uint32_t addr) +{ + MemoryRegionPortioList *mrpio; + unsigned i, j; + + for (i = 0; i < piolist->nr; ++i) { + mrpio = container_of(piolist->regions[i], MemoryRegionPortioList, mr); + memory_region_set_address(&mrpio->mr, + mrpio->mr.addr - piolist->addr + addr); + for (j = 0; mrpio->ports[j].size; ++j) { + mrpio->ports[j].offset += addr - piolist->addr; + } + } + + piolist->addr = addr; +} + static void memory_region_portio_list_finalize(Object *obj) { MemoryRegionPortioList *mrpio = MEMORY_REGION_PORTIO_LIST(obj); diff --git a/docs/devel/migration/main.rst b/docs/devel/migration/main.rst index 00b9c3d32f..9439adcf66 100644 --- a/docs/devel/migration/main.rst +++ b/docs/devel/migration/main.rst @@ -431,10 +431,10 @@ data doesn't match the stored device data well; it allows an intermediate temporary structure to be populated with migration data and then transferred to the main structure. -If you use memory API functions that update memory layout outside +If you use memory or portio_list API functions that update memory layout outside initialization (i.e., in response to a guest action), this is a strong indication that you need to call these functions in a ``post_load`` callback. -Examples of such memory API functions are: +Examples of such API functions are: - memory_region_add_subregion() - memory_region_del_subregion() @@ -443,6 +443,7 @@ Examples of such memory API functions are: - memory_region_set_enabled() - memory_region_set_address() - memory_region_set_alias_offset() + - portio_list_set_address() Iterative device migration -------------------------- From patchwork Wed Feb 14 11:14:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898856 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KEwR46jZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbLQ3XkRz23hM for ; Wed, 14 Feb 2024 22:19:10 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDE3-0002sY-AP; Wed, 14 Feb 2024 06:14:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDE1-0002qM-E1 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDDz-0006uS-Ua for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XM132RQQIUZpLEj5Uac/xI2M4i5v/RWBhoUWLeS7lSc=; b=KEwR46jZosdN4W2qUWK/HVuNssT4VWc4zQuk6EQ6+mCiiybeLy0EbMgXHKWwoJ9UKZpjew o/D3l6pAl1yfS7IxJ1lazoa27/VNUZi7uOoHKloRFWxctyfLcY8FppsW8vgDJAuvldfEZP qPJuhiOnQpJEvKnMAScQh1bN4jowwa0= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-wZ5T-nstNVi4ShS86OcfEA-1; Wed, 14 Feb 2024 06:14:44 -0500 X-MC-Unique: wZ5T-nstNVi4ShS86OcfEA-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-55fee28d93dso3093239a12.2 for ; Wed, 14 Feb 2024 03:14:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909283; x=1708514083; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=XM132RQQIUZpLEj5Uac/xI2M4i5v/RWBhoUWLeS7lSc=; b=jSuREEAeEV4WY3Zdm82SoKa3abl0Q+lJEj0yI3kpo7RY+4q3l6ISrnsYM9GoVnMlqw 6GglZbNVwL/0gpnxEz/AzdqUiFDrGi/ThyLMRZJ7esEzNNz37d0wuhoTFH2xOlOfYaA/ pSpaH1pQjwQH+TSSbU5SzrBRZ26op/wGfRrOjbovHcysUD0Hbp/QlUkm0DKa683e8c7h 08ONY1R/b+HFEy7TTNZkwyKaAtyGhxW5BryVTQmVuIg8e1IRRuUpRBszSFjH+m7TUfwd sGktIF0MCF5fxQLD5wzCH+6kOILWoNt6DkIF6GAKJAXXMAHCaM26LCEJPOfkRnGSYw4u X5YA== X-Gm-Message-State: AOJu0YzWrR+N1UVqafFxDTERNvBte3PE5L/PCWAp5CeZCzzbwMjDlSKg 58zqVaIiiGIM7Y9HuxlzoH/xA+GFUTeqajTrtTU14Q2AZNyJfD/bArpRofveSV5vZxauwDlVTiY JrJyh05iQ+gjuOH2++uhQyD8ElTx0UDXiQl7ExXf3T9LEkTaZaoOdKF/zP6nsn1mDtTRzv0UDmC E0Hime2HP374wGnMqhtnn5NHnnNWG2YA== X-Received: by 2002:a05:6402:8c2:b0:560:5c58:dfc4 with SMTP id d2-20020a05640208c200b005605c58dfc4mr1841048edz.1.1707909283265; Wed, 14 Feb 2024 03:14:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGa1Q7mLxSy9uqtgQwswxcRerHydiHG9HnmpCMP0DQJqn13jEByxEVRfTeRv+Qd5XvJyydm+Q== X-Received: by 2002:a05:6402:8c2:b0:560:5c58:dfc4 with SMTP id d2-20020a05640208c200b005605c58dfc4mr1841029edz.1.1707909282958; Wed, 14 Feb 2024 03:14:42 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVCRUdDL7iWpdLfAd55S/UEUgY4N0w2WkNRxMRJwHwPZCXFGU/NXCO/fuwWWZzg7ZSMf++BcBkUi46Wr22xUOoTeosRO7hWW/CjEowTECN9/KJPllD08r/YHHPCk7MSAUu81tI85W1eECCdxLLS6em4bmoIboobhf/M+ElqiZQvrFlqVVeu4HTxm7ExJbjc Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id l20-20020aa7cad4000000b005638a4f935dsm183952edt.4.2024.02.14.03.14.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:42 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:40 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Paolo Bonzini , Peter Xu , David Hildenbrand , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PULL 27/60] exec/ioport: Add portio_list_set_enabled() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Beschow Some SuperI/O devices such as the VIA south bridges or the PC87312 controller allow to enable or disable their SuperI/O functions. Add a convenience function for implementing this in the VIA south bridges. The naming of the functions is inspired by its memory_region_set_enabled() pendant. Signed-off-by: Bernhard Beschow Message-Id: <20240114123911.4877-7-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/exec/ioport.h | 1 + system/ioport.c | 9 +++++++++ docs/devel/migration/main.rst | 1 + 3 files changed, 11 insertions(+) diff --git a/include/exec/ioport.h b/include/exec/ioport.h index 96858e5ac3..4397f12f93 100644 --- a/include/exec/ioport.h +++ b/include/exec/ioport.h @@ -71,6 +71,7 @@ void portio_list_add(PortioList *piolist, struct MemoryRegion *address_space, uint32_t addr); void portio_list_del(PortioList *piolist); +void portio_list_set_enabled(PortioList *piolist, bool enabled); void portio_list_set_address(PortioList *piolist, uint32_t addr); #endif /* IOPORT_H */ diff --git a/system/ioport.c b/system/ioport.c index 000e0ee1af..fd551d0375 100644 --- a/system/ioport.c +++ b/system/ioport.c @@ -324,6 +324,15 @@ void portio_list_del(PortioList *piolist) } } +void portio_list_set_enabled(PortioList *piolist, bool enabled) +{ + unsigned i; + + for (i = 0; i < piolist->nr; ++i) { + memory_region_set_enabled(piolist->regions[i], enabled); + } +} + void portio_list_set_address(PortioList *piolist, uint32_t addr) { MemoryRegionPortioList *mrpio; diff --git a/docs/devel/migration/main.rst b/docs/devel/migration/main.rst index 9439adcf66..331252a92c 100644 --- a/docs/devel/migration/main.rst +++ b/docs/devel/migration/main.rst @@ -444,6 +444,7 @@ Examples of such API functions are: - memory_region_set_address() - memory_region_set_alias_offset() - portio_list_set_address() + - portio_list_set_enabled() Iterative device migration -------------------------- From patchwork Wed Feb 14 11:14:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898842 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BL0sjsmO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbK41t2tz23hM for ; Wed, 14 Feb 2024 22:18:00 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDE6-00033V-6T; Wed, 14 Feb 2024 06:14:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDE4-0002yC-JA for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDE3-0006vH-6g for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909290; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=NQPq2eB8YlzFRo2yi/9ewINIVLnGxrTHAgWJxfM/5SU=; b=BL0sjsmOxNUbLtuNqJZuXFZtaa+qIQmIEEZjENug5V0XRLy0HdEoh4MQJ/gR1zElgGcItD 4BsZSJKZwblCLeDCkny1MJTwh6JgPGJVCEcZADNdIqZtgOcHQDnFPz+mSefwAZCE9Gn3B/ YXHdN2Mz+RcIkFVkX0MqpRPX8szS0/I= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-232-youdLG_DOUOfkxdvJJ-OpA-1; Wed, 14 Feb 2024 06:14:48 -0500 X-MC-Unique: youdLG_DOUOfkxdvJJ-OpA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a3cdd79d960so114091566b.0 for ; Wed, 14 Feb 2024 03:14:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909286; x=1708514086; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NQPq2eB8YlzFRo2yi/9ewINIVLnGxrTHAgWJxfM/5SU=; b=kjvkN0/vncArA7FBmILzGyKW8Gg3kFNcQkytIZNBuZLB2nhyPDRiDBb/TAqXItG/OD Kb3hF+NtjUpLhNtRSqvgalADrk7/qmTbfI4KY+xXQjvTYTmeQjl82CZXtpbjY4/Av3ag EleqwsyYfePvCeSNTtfv20j/248KviyzM3nH2PppshsyThzWOU6hCfeHtw7JS+bJiVuY u2FdGfWz1bHQNejbp4ZeRKTqSNNbDl5q9pKQ5jqxeGLln9EFYO8Ip9Eaic9ct59FTtxa Keew0krryBFLtwbLR1MFKNeFn+VY+FphuHUAQSLguhdpNV5F7H0qfL+Xx9NrDXW/zOHQ x/8Q== X-Gm-Message-State: AOJu0Yz2lWNjdhiZPyAGGgk7Me3KfiHANmKDhCQSRADVPdY8VYxuX0ru KqGk0bITwDNAl/mlKRIa8quwJUpskul94AZ8xx+uhvC2bzZqEXvbCvcLaSKoHx/si/uBonq1onO JfkIoaPMH8XaAsjn+923vBOh0sw6hvV1/UZo3rybXkweQSTmrJNp4qpM5CpnGrpBXUsQYjpGV8+ JqrPDw7tilrXN7VgkgyBLq0HASErhr8g== X-Received: by 2002:a17:906:6043:b0:a3c:edc4:4abd with SMTP id p3-20020a170906604300b00a3cedc44abdmr1622496ejj.33.1707909286359; Wed, 14 Feb 2024 03:14:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IFlE5zsOtDbDpmO+I+yuR2yY/6loGor3xrXhWAZTODGea6RjOPtaXWwiR2yMkgWSveo7a0EUA== X-Received: by 2002:a17:906:6043:b0:a3c:edc4:4abd with SMTP id p3-20020a170906604300b00a3cedc44abdmr1622482ejj.33.1707909286104; Wed, 14 Feb 2024 03:14:46 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUu1DkKbb3j81+ckBkqyZZl1dUz1gIXrWEqHXS4B16cQpF7w9daVhYssxqEnIai19UNv5kLZU8VMxEJqYiHWJzKmRYfANL3OwSmR5Xi0fZNqnK+KZKd1H7rBBQhb3Q2mwBBBESfoPn7biyCaq0QmDuKp34fX1sxeSmCDQJmZAzq5qeC9j3yibcrT51OEp1SHw== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id m10-20020a1709060d8a00b00a3cd0c09a05sm2194400eji.180.2024.02.14.03.14.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:45 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , John Snow , Kevin Wolf , Hanna Reitz , qemu-block@nongnu.org Subject: [PULL 28/60] hw/block/fdc-isa: Implement relocation and enabling/disabling for TYPE_ISA_FDC Message-ID: <8c4d239139e93268884f9d385a0966ef40db422f.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Beschow The real SuperI/O chips emulated by QEMU allow for relocating and enabling or disabling their SuperI/O functions via software. So far this is not implemented. Prepare for that by adding isa_fdc_set_{enabled,iobase}. Signed-off-by: Bernhard Beschow Message-Id: <20240114123911.4877-8-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/block/fdc.h | 3 +++ hw/block/fdc-isa.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/hw/block/fdc.h b/include/hw/block/fdc.h index 35248c0837..c367c5efea 100644 --- a/include/hw/block/fdc.h +++ b/include/hw/block/fdc.h @@ -14,6 +14,9 @@ void fdctrl_init_sysbus(qemu_irq irq, hwaddr mmio_base, DriveInfo **fds); void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base, DriveInfo **fds, qemu_irq *fdc_tc); +void isa_fdc_set_iobase(ISADevice *fdc, hwaddr iobase); +void isa_fdc_set_enabled(ISADevice *fdc, bool enabled); + FloppyDriveType isa_fdc_get_drive_type(ISADevice *fdc, int i); int cmos_get_fd_drive_type(FloppyDriveType fd0); diff --git a/hw/block/fdc-isa.c b/hw/block/fdc-isa.c index 2d8a98ce7d..e43dc532af 100644 --- a/hw/block/fdc-isa.c +++ b/hw/block/fdc-isa.c @@ -192,6 +192,20 @@ static Aml *build_fdinfo_aml(int idx, FloppyDriveType type) return dev; } +void isa_fdc_set_iobase(ISADevice *fdc, hwaddr iobase) +{ + FDCtrlISABus *isa = ISA_FDC(fdc); + + fdc->ioport_id = iobase; + isa->iobase = iobase; + portio_list_set_address(&isa->portio_list, isa->iobase); +} + +void isa_fdc_set_enabled(ISADevice *fdc, bool enabled) +{ + portio_list_set_enabled(&ISA_FDC(fdc)->portio_list, enabled); +} + int cmos_get_fd_drive_type(FloppyDriveType fd0) { int val; From patchwork Wed Feb 14 11:14:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898832 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MrffwFmi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbGS6fkxz23hM for ; Wed, 14 Feb 2024 22:15:44 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDE8-0003Fn-S5; Wed, 14 Feb 2024 06:14:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDE6-00033l-NV for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:54 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDE5-0006vu-8x for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MRWTVErun+rCrNj/knFfh+bLyvrCH3Pht/W9/VrpypY=; b=MrffwFmip9RcdKKgHB+QKdW3jq7Z2kNZQNsw4ePo9Z46m23K4VmJ4XB3cfwGaNwn7rtb+m l9wPrq+61/sRDVFNcSrhDJudjg/qncWDx5jHbGNwfGQEcChtIQLYl7zM2YlScSKCB3NpSY 0e5M80jq0HQMuztJ8fPFsAALqdSZ5mY= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-489-Qi6APLYqOv6X0vS4UyPzMA-1; Wed, 14 Feb 2024 06:14:51 -0500 X-MC-Unique: Qi6APLYqOv6X0vS4UyPzMA-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a2c4e9cb449so364357366b.1 for ; Wed, 14 Feb 2024 03:14:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909289; x=1708514089; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MRWTVErun+rCrNj/knFfh+bLyvrCH3Pht/W9/VrpypY=; b=FBaLpfvXdCHfvlCSu5sKCgMk9pTfeh07JIUHHOPJIbUg0Rqz313smHTdIizp0wnW+6 vakfTLMQ9ePJFBN8l2y9aFxqBIzonhQXmKKzl83MU07IlTd387sMD7ukn/W0xYwA94WS YuxGqPVsE9G8QvFZbM/roe2OjyEoDUpS7NazjdijK+IuVUm+RAV5b+C62Yz0k616n5Iv 6noO8Ca4FN27LBtKW0+8QTwL8YDWVakRZa4yHb1itbdNAHaHHJ6+Dopl8oSkuO2AcrS4 C92TN1LwFQ5jOcSlQNPpyrlBHkwaTlTqdG428eO7YH/yfzHuqk+pU6r67NbpoRDrT2qY 1mrw== X-Gm-Message-State: AOJu0YzvfNcSBLqu75ffIlUCh46Jht7MG6KY7ZwMG4uAd04CqG5xSwI+ 3+RQ7nCw82ejsmcRHw1wL1o1BB4UrudkF7f63fpBPLnaymzKIAfGGPEeU5OMDTISrVHO/xWYiBJ HWAZ/6v0M1gGDpKsai8/v58sm6lVZzItLbv0YOUgksdpW9lcVzf6xjouL5q33e5oWWiUhyF0PmD VvjvDgyLIC7lVe0BKVsjAWespEBCzJBQ== X-Received: by 2002:a17:906:3591:b0:a3c:ed94:7672 with SMTP id o17-20020a170906359100b00a3ced947672mr1643146ejb.64.1707909289428; Wed, 14 Feb 2024 03:14:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfbWgdbIr7LA7h+6ZHBrUSSCOOU2nCxfE29VU3mbL40DK9LPkbmZ6R4HMBOgWV9uJSZcel2w== X-Received: by 2002:a17:906:3591:b0:a3c:ed94:7672 with SMTP id o17-20020a170906359100b00a3ced947672mr1643128ejb.64.1707909289101; Wed, 14 Feb 2024 03:14:49 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCX2XO0sv708t8NJXtk5CCWXGRYHfOjjvQx41rLKPpYbPqkmg8Tu/t+55vQKErgkOTJVnSCB6PScPjTpqIN7iv922spauKlL4fHtLI69Iu1XuaxmFvQk9xkf/seQ83fc9SATL7/l4YpKTKSPtw2TydKimiUU Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id qo12-20020a170907874c00b00a3d061514a6sm1489319ejc.201.2024.02.14.03.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:48 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:46 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9?= Lureau Subject: [PULL 29/60] hw/char/serial-isa: Implement relocation and enabling/disabling for TYPE_ISA_SERIAL Message-ID: <7812dbc54c72f71df2644d0cec52a1e8d6b19584.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Beschow The real SuperI/O chips emulated by QEMU allow for relocating and enabling or disabling their SuperI/O functions via software. So far this is not implemented. Prepare for that by adding isa_serial_set_{enabled,iobase}. Signed-off-by: Bernhard Beschow Message-Id: <20240114123911.4877-9-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/char/serial.h | 2 ++ hw/char/serial-isa.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h index 8ba7eca3d6..6e14099ee7 100644 --- a/include/hw/char/serial.h +++ b/include/hw/char/serial.h @@ -112,5 +112,7 @@ SerialMM *serial_mm_init(MemoryRegion *address_space, #define TYPE_ISA_SERIAL "isa-serial" void serial_hds_isa_init(ISABus *bus, int from, int to); +void isa_serial_set_iobase(ISADevice *serial, hwaddr iobase); +void isa_serial_set_enabled(ISADevice *serial, bool enabled); #endif diff --git a/hw/char/serial-isa.c b/hw/char/serial-isa.c index 1c793b20f7..329b352b9a 100644 --- a/hw/char/serial-isa.c +++ b/hw/char/serial-isa.c @@ -184,3 +184,17 @@ void serial_hds_isa_init(ISABus *bus, int from, int to) } } } + +void isa_serial_set_iobase(ISADevice *serial, hwaddr iobase) +{ + ISASerialState *s = ISA_SERIAL(serial); + + serial->ioport_id = iobase; + s->iobase = iobase; + memory_region_set_address(&s->state.io, s->iobase); +} + +void isa_serial_set_enabled(ISADevice *serial, bool enabled) +{ + memory_region_set_enabled(&ISA_SERIAL(serial)->state.io, enabled); +} From patchwork Wed Feb 14 11:14:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898834 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Vkz5Hb5j; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbHd3q8pz23hM for ; Wed, 14 Feb 2024 22:16:45 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDEC-0003fb-Md; Wed, 14 Feb 2024 06:15:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEA-0003XM-RH for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDE9-0006xy-7V for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:14:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909295; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FeqQbjEcpCbjayR7Mh9VjABD+SO9Cb44x6hEWH/bfvY=; b=Vkz5Hb5j31yTbAw1f8/oTcg4qN3j+0J3zi8bBVgCpcTj8KZBVw+r0n5FlG2qqhz5sofcfy L/fg6rVRz9T92XqhvmJbaeXu7RaQvr58joCHBPKz5LeO2foDiqTzKnff/lN0RZmMSqtgK1 Fk+lKIQDh9hm44da3yrZDWKr584dpdk= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-414-qX0cVYV0MYucatKqI55plg-1; Wed, 14 Feb 2024 06:14:54 -0500 X-MC-Unique: qX0cVYV0MYucatKqI55plg-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a2f71c9f5d2so388469666b.2 for ; Wed, 14 Feb 2024 03:14:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909292; x=1708514092; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=FeqQbjEcpCbjayR7Mh9VjABD+SO9Cb44x6hEWH/bfvY=; b=Ofwd/osKIdS9dScK8ACV0cq1QYSY1pSriGQBV9qAkYko3oT+JFL6gGj9pKb15xrkkO 3fZkhXUNpIh5t90yMXNmXcjlYhyQg8vAPd7BT/uOcFuMC0JcThQMDfrDGlACVL2TjqxV siVxDZN6fTEBwQ+4X+WTO4fmoTj20xWOYOgoaxk4dsFbcKYZcsedOTJa7rWaX+ix7Sgl 7daEdC6mxlX1zwySygVdCRVCTjOjCxQzojqeFPMsW6gdFIs4+nP6bjsCOG9nIO4kT00u Sqh5m7SPkvutPmZ9dEWR4tI7kq1XcxDQt3yiucC/fEg0bg/9dix7FpNhRZRomaBgoJcQ QazQ== X-Gm-Message-State: AOJu0Yxrla/cgt/wmBWET0AObJw3v5vJvse9LbJoc7GcSI3spvWvawdP pA76m6oyUzj3+l8OyT5HL84jkzDfN2S1YUJvLpLg3qUSlkFC8D9NAtxjSB2NnyVV1sHbOkkzfa4 w57rKWVa6/0SkzN5vVogkTDuZA1BCujoZXSHFUNVYlA5kxQ2if03Y+3iO6g5x2dd/G/cIhsx+kF 3MpCI2ygLQe/HkTlGrL9nMJexusDf43g== X-Received: by 2002:a17:906:35c6:b0:a3d:232f:a4f6 with SMTP id p6-20020a17090635c600b00a3d232fa4f6mr1776018ejb.11.1707909292307; Wed, 14 Feb 2024 03:14:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IFhb2V8CS78PyQAJ31vjUL9bYYGJFoRBw3QNnIEbXlTSxHvZhxulMGXEl0gBUC38UL7k6/ZKA== X-Received: by 2002:a17:906:35c6:b0:a3d:232f:a4f6 with SMTP id p6-20020a17090635c600b00a3d232fa4f6mr1775998ejb.11.1707909291994; Wed, 14 Feb 2024 03:14:51 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV2hKf72jdrAErus6+SZojSJlW8IYLH6VFNk5ZaP7bvWcBOLJqZEtiTpGvG0nTFpYefp2ED+sI3HqQpdsv8YS5D2aD8HFWyyBxgu1ptrmeFoQUChQbOh9Z/eJ2oj8NC/psG0ZOE9mjT8D4bllk193zPqZJy Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id qo12-20020a170907874c00b00a3d061514a6sm1489363ejc.201.2024.02.14.03.14.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:51 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:49 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9?= Lureau Subject: [PULL 30/60] hw/char/parallel-isa: Implement relocation and enabling/disabling for TYPE_ISA_PARALLEL Message-ID: <1d1afd9ff7264c7ed35f3ca25cc4bf9dd82a6b06.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Beschow The real SuperI/O chips emulated by QEMU allow for relocating and enabling or disabling their SuperI/O functions via software. So far this is not implemented. Prepare for that by adding isa_parallel_set_{enabled,iobase}. Signed-off-by: Bernhard Beschow Message-Id: <20240114123911.4877-10-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/char/parallel-isa.h | 3 +++ hw/char/parallel-isa.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/hw/char/parallel-isa.h b/include/hw/char/parallel-isa.h index 3b783bd08d..5284b2ffec 100644 --- a/include/hw/char/parallel-isa.h +++ b/include/hw/char/parallel-isa.h @@ -29,4 +29,7 @@ struct ISAParallelState { PortioList portio_list; }; +void isa_parallel_set_iobase(ISADevice *parallel, hwaddr iobase); +void isa_parallel_set_enabled(ISADevice *parallel, bool enabled); + #endif /* HW_PARALLEL_ISA_H */ diff --git a/hw/char/parallel-isa.c b/hw/char/parallel-isa.c index ab0f879998..a5ce6ee13a 100644 --- a/hw/char/parallel-isa.c +++ b/hw/char/parallel-isa.c @@ -41,3 +41,17 @@ void parallel_hds_isa_init(ISABus *bus, int n) } } } + +void isa_parallel_set_iobase(ISADevice *parallel, hwaddr iobase) +{ + ISAParallelState *s = ISA_PARALLEL(parallel); + + parallel->ioport_id = iobase; + s->iobase = iobase; + portio_list_set_address(&s->portio_list, s->iobase); +} + +void isa_parallel_set_enabled(ISADevice *parallel, bool enabled) +{ + portio_list_set_enabled(&ISA_PARALLEL(parallel)->portio_list, enabled); +} From patchwork Wed Feb 14 11:14:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898847 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VE44sy85; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbKf62QSz23y6 for ; Wed, 14 Feb 2024 22:18:30 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDEE-0003iS-Dc; Wed, 14 Feb 2024 06:15:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEC-0003fQ-Ht for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEB-0006yR-4j for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909298; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=s/uvRz6NqAtcw4NfACRR0TvuyVvMvzlS8V+gAdYV2LQ=; b=VE44sy85Dx+gKRi6+KWV5veh9aY3QCWYO4s/HcBeKELWVh+RswkWPMhCqAvDFIm8hZT/5d cA574G4aVnhhUZe7gGN+KX0iYF6y6moiKfblLHW6+oNkLnNftw5CtLyXPGT0wTo2tr+4VB Uq/PtTb9ziqGY4l7+hiD2sJzOYElLPI= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-112-JPytBuucNI68ZQx80FsLMw-1; Wed, 14 Feb 2024 06:14:57 -0500 X-MC-Unique: JPytBuucNI68ZQx80FsLMw-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a27eddc1c27so115463666b.3 for ; Wed, 14 Feb 2024 03:14:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909295; x=1708514095; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=s/uvRz6NqAtcw4NfACRR0TvuyVvMvzlS8V+gAdYV2LQ=; b=Oz/as7I14AxMV2+KXtKDhSPzFCc95JeuoL0JCwAzF+eLsUaBhRIHJ+HusrzMZLmc7q /WdqNK7rYoeZ9Usm6UlWVPSAdT3TVzB9WTQvqOAwoitpWn+fIZkGBABUZ5jaJQ2Z8FH1 0sLGRVeaGlR8dTfvb8mOTbaOPnYV2EemggJUUMOwlkyeXbOMflvcUoyKEm4ostsQ2s5n HRebonc5xlLz6AAI8uuRAI6hAEmH5PnEtA9leRZ6WlXsdYYknP/SXZAC8IBuwYxztmlI DPPv45kwcYfZYOtC8CXDNfs6CjdSRYCesetl/WNx5cTqQzPSgwoUpLklgS9RvQ6t0iBm zirA== X-Gm-Message-State: AOJu0YwGk2ng1Hq8q4ybNBIA4cB2UebO7s97y8ox+7c1M8kH0pWden7w Ljzd2jzkB2AFs0aFTYiN9CroRoRZ03688t5rdbtwjRZH8vUfyxTb8BGIiq0HXmtEc/I9/DUOeT2 1E5JdxWqoYJw1rB0Pci3ySWu9TydCqpJvWdFwyMKlR7zIIeK8YcsgwH1CErsxmNk7qNvUCamJfj fM/8LaxoIKINCsg+WxM3UGtUhbQfsyeQ== X-Received: by 2002:a17:906:c13:b0:a3c:ffbb:b47c with SMTP id s19-20020a1709060c1300b00a3cffbbb47cmr1458258ejf.72.1707909295256; Wed, 14 Feb 2024 03:14:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbMT8fA2YEV9bk+O+Ln3/XbRME1NygdGCkdkvS5mwmdQHeYLIt/V8BE6DQifwPSVugixtJHQ== X-Received: by 2002:a17:906:c13:b0:a3c:ffbb:b47c with SMTP id s19-20020a1709060c1300b00a3cffbbb47cmr1458241ejf.72.1707909294940; Wed, 14 Feb 2024 03:14:54 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXQQkuBtSu5oB2RP3FEfHM3PdnpW3n6dvFMQ2xo4nV2c2GujC878mOleSuKgQs4CqCpuz5l/eJfOhlFoE+jhQP337xuPb+Tc5w1YP4DPbsrAcrA+vmIl1YwdtzHqZdlo9su0LsSRHkYgjds Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id u15-20020a170906408f00b00a3bc368ca7esm2219174ejj.53.2024.02.14.03.14.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:54 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:52 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , BALATON Zoltan , qemu-ppc@nongnu.org Subject: [PULL 31/60] hw/ppc/pegasos2: Let pegasos2 machine configure SuperI/O functions Message-ID: <79a7f53065abea95b33e2212dcfb58e1de4be479.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Beschow This is a preparation for implementing relocation and toggling of SuperI/O functions in the VT8231 device model. Upon reset, all SuperI/O functions will be deactivated, so in case if no -bios is given, let the machine configure those functions the same way Pegasos II firmware would do. Signed-off-by: Bernhard Beschow Reviewed-by: BALATON Zoltan Message-Id: <20240114123911.4877-11-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/ppc/pegasos2.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index d84f3f977d..04d6decb2b 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -285,6 +285,12 @@ static void pegasos2_pci_config_write(Pegasos2MachineState *pm, int bus, pegasos2_mv_reg_write(pm, pcicfg + 4, len, val); } +static void pegasos2_superio_write(uint8_t addr, uint8_t val) +{ + cpu_physical_memory_write(PCI1_IO_BASE + 0x3f0, &addr, 1); + cpu_physical_memory_write(PCI1_IO_BASE + 0x3f1, &val, 1); +} + static void pegasos2_machine_reset(MachineState *machine, ShutdownCause reason) { Pegasos2MachineState *pm = PEGASOS2_MACHINE(machine); @@ -310,6 +316,12 @@ static void pegasos2_machine_reset(MachineState *machine, ShutdownCause reason) pegasos2_pci_config_write(pm, 1, (PCI_DEVFN(12, 0) << 8) | PCI_INTERRUPT_LINE, 2, 0x9); + pegasos2_pci_config_write(pm, 1, (PCI_DEVFN(12, 0) << 8) | + 0x50, 1, 0x6); + pegasos2_superio_write(0xf4, 0xbe); + pegasos2_superio_write(0xf6, 0xef); + pegasos2_superio_write(0xf7, 0xfc); + pegasos2_superio_write(0xf2, 0x14); pegasos2_pci_config_write(pm, 1, (PCI_DEVFN(12, 0) << 8) | 0x50, 1, 0x2); pegasos2_pci_config_write(pm, 1, (PCI_DEVFN(12, 0) << 8) | From patchwork Wed Feb 14 11:14:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898835 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KQ0OTjqw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbHd6rrRz23y6 for ; Wed, 14 Feb 2024 22:16:45 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDEH-0003l3-UU; Wed, 14 Feb 2024 06:15:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEF-0003jo-Uy for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEE-0006zL-5q for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yp293q1k7EwGS1/MtUhndzXz8BO3g1U19jHZpbrZKu0=; b=KQ0OTjqwCPaHTkBkAOIps/mxBQdlmCBoXQKQeXtZnVrMP3FrRHUckDMySYVo7QA5+l+KVL mSoqb1usmFuMJGpzaYIbfBcbbltoosyn1NuqjlvJhmlfSbX3TxZjK91GNGHohhSMWZ+zm3 lOQQQWu2VVHYQNV6+9mfSYxunakgLLo= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-410-l-cR1vU4PrCnCmRDyjNDDw-1; Wed, 14 Feb 2024 06:15:00 -0500 X-MC-Unique: l-cR1vU4PrCnCmRDyjNDDw-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a3ccb68f284so149575566b.1 for ; Wed, 14 Feb 2024 03:15:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909298; x=1708514098; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yp293q1k7EwGS1/MtUhndzXz8BO3g1U19jHZpbrZKu0=; b=blOe3gNkEaCQraUkWY47kGujgkADCObC9UxftSLljdbLs2JiiKLbTgN11SVeFGczLV X8pIBAQKd1P3TpN9jgAXn7c/4RhfBwqfgoETwJj/w8ejRX/WX/jRcequswTW6KfkwNDZ exfXI6gFI+ReZ6hXaduchpV0tdSwUsRBaKr19sVTVuopU1h6WHCqkrdon7Ufscd0xfyV XCZfz5lJub3P16WMdNzGCiaFgFkxVlInAJ6ViX5+9xw92iU9VlcBBUyJUortZyzqoUfP ZNkrG4FIZpiMfWIPNLhNw8/+SQVqxXBUjzGHnNXN4o/9il32aT7DablAdGNR2WI/Wai9 zv7A== X-Gm-Message-State: AOJu0Yz6/wp4vow2Tqv10fnZeCs8TVjhmcN9lhDN6EzY8xc19SoILfSl 5TBIZESSTJOk/eMNFPt1EDr5SC3qLo1dE7HF0eHCWtyAnASnxTbgI2pWK8JLsPQ4OZF3lG8OJkW HIcbmRVAShDhPyW7ZLTALgKTMTR2O1W+99t0Luano0y2ZZDnjrp9xUk1DGXUoNtzj5Co49TYQyK 1KYoy2ZfIsueEzwchsLjEvwP6J5w6OeQ== X-Received: by 2002:a17:906:aad6:b0:a3c:a655:3a3c with SMTP id kt22-20020a170906aad600b00a3ca6553a3cmr1383214ejb.16.1707909298465; Wed, 14 Feb 2024 03:14:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGZ1nWWXcLhhi9eMYz/sfekc+bCed9WsdeAryIGsfCIiw9HVRh5P7YXnnh6vXbGlwYxB2rBXg== X-Received: by 2002:a17:906:aad6:b0:a3c:a655:3a3c with SMTP id kt22-20020a170906aad600b00a3ca6553a3cmr1383191ejb.16.1707909298096; Wed, 14 Feb 2024 03:14:58 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW+P8qx6GekVbYdyaGPBPviA4m64AxuHE/c6dMCIOfU6ngZvzYuKpy425ABYNVzwYepgCcTjPVawSxYQ5pEv4Q0fMptOqLxuDzELyDEPI6qo1+MsUQUquHSFiWd4fUVsTYzGaAkbQIpwKRakrap7apu37YUmnxaXXiyUKeJiJ4ia4I= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id vg9-20020a170907d30900b00a3cf4e8fdf5sm1756740ejc.150.2024.02.14.03.14.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:14:57 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:55 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , BALATON Zoltan , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 32/60] hw/isa/vt82c686: Implement relocation and toggling of SuperI/O functions Message-ID: <35a6380b4ed27f8355330b1fb0918b20c728d30e.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Bernhard Beschow The VIA south bridges are able to relocate and toggle (enable or disable) their SuperI/O functions. So far this is hardcoded such that all functions are always enabled and are located at fixed addresses. Some PC BIOSes seem to probe for I/O occupancy before activating such a function and issue an error in case of a conflict. Since the functions are currently enabled on reset, conflicts are always detected. Prevent that by implementing relocation and toggling of the SuperI/O functions. Note that all SuperI/O functions are now deactivated upon reset (except for VT82C686B's serial ports where Fuloong 2e's rescue-yl seems to expect them to be enabled by default). Rely on firmware to configure the functions accordingly. Signed-off-by: Bernhard Beschow Reviewed-by: BALATON Zoltan Message-Id: <20240114123911.4877-12-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/isa/vt82c686.c | 65 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 10 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index d3e0f6d01f..485bb685b7 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -15,6 +15,9 @@ #include "qemu/osdep.h" #include "hw/isa/vt82c686.h" +#include "hw/block/fdc.h" +#include "hw/char/parallel-isa.h" +#include "hw/char/serial.h" #include "hw/pci/pci.h" #include "hw/qdev-properties.h" #include "hw/ide/pci.h" @@ -323,6 +326,17 @@ static uint64_t via_superio_cfg_read(void *opaque, hwaddr addr, unsigned size) return val; } +static void via_superio_devices_enable(ViaSuperIOState *s, uint8_t data) +{ + ISASuperIOClass *ic = ISA_SUPERIO_GET_CLASS(s); + + isa_parallel_set_enabled(s->superio.parallel[0], (data & 0x3) != 3); + for (int i = 0; i < ic->serial.count; i++) { + isa_serial_set_enabled(s->superio.serial[i], data & BIT(i + 2)); + } + isa_fdc_set_enabled(s->superio.floppy, data & BIT(4)); +} + static void via_superio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -368,7 +382,25 @@ static void vt82c686b_superio_cfg_write(void *opaque, hwaddr addr, case 0xfd ... 0xff: /* ignore write to read only registers */ return; - /* case 0xe6 ... 0xe8: Should set base port of parallel and serial */ + case 0xe2: + data &= 0x1f; + via_superio_devices_enable(sc, data); + break; + case 0xe3: + data &= 0xfc; + isa_fdc_set_iobase(sc->superio.floppy, data << 2); + break; + case 0xe6: + isa_parallel_set_iobase(sc->superio.parallel[0], data << 2); + break; + case 0xe7: + data &= 0xfe; + isa_serial_set_iobase(sc->superio.serial[0], data << 2); + break; + case 0xe8: + data &= 0xfe; + isa_serial_set_iobase(sc->superio.serial[1], data << 2); + break; default: qemu_log_mask(LOG_UNIMP, "via_superio_cfg: unimplemented register 0x%x\n", idx); @@ -395,9 +427,14 @@ static void vt82c686b_superio_reset(DeviceState *dev) /* Device ID */ vt82c686b_superio_cfg_write(s, 0, 0xe0, 1); vt82c686b_superio_cfg_write(s, 1, 0x3c, 1); - /* Function select - all disabled */ + /* + * Function select - only serial enabled + * Fuloong 2e's rescue-yl prints to the serial console w/o enabling it. This + * suggests that the serial ports are enabled by default, so override the + * datasheet. + */ vt82c686b_superio_cfg_write(s, 0, 0xe2, 1); - vt82c686b_superio_cfg_write(s, 1, 0x03, 1); + vt82c686b_superio_cfg_write(s, 1, 0x0f, 1); /* Floppy ctrl base addr 0x3f0-7 */ vt82c686b_superio_cfg_write(s, 0, 0xe3, 1); vt82c686b_superio_cfg_write(s, 1, 0xfc, 1); @@ -465,6 +502,21 @@ static void vt8231_superio_cfg_write(void *opaque, hwaddr addr, case 0xfd: /* ignore write to read only registers */ return; + case 0xf2: + data &= 0x17; + via_superio_devices_enable(sc, data); + break; + case 0xf4: + data &= 0xfe; + isa_serial_set_iobase(sc->superio.serial[0], data << 2); + break; + case 0xf6: + isa_parallel_set_iobase(sc->superio.parallel[0], data << 2); + break; + case 0xf7: + data &= 0xfc; + isa_fdc_set_iobase(sc->superio.floppy, data << 2); + break; default: qemu_log_mask(LOG_UNIMP, "via_superio_cfg: unimplemented register 0x%x\n", idx); @@ -513,12 +565,6 @@ static void vt8231_superio_init(Object *obj) VIA_SUPERIO(obj)->io_ops = &vt8231_superio_cfg_ops; } -static uint16_t vt8231_superio_serial_iobase(ISASuperIODevice *sio, - uint8_t index) -{ - return 0x2f8; /* FIXME: This should be settable via registers f2-f4 */ -} - static void vt8231_superio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -526,7 +572,6 @@ static void vt8231_superio_class_init(ObjectClass *klass, void *data) dc->reset = vt8231_superio_reset; sc->serial.count = 1; - sc->serial.get_iobase = vt8231_superio_serial_iobase; sc->parallel.count = 1; sc->ide.count = 0; /* emulated by via-ide */ sc->floppy.count = 1; From patchwork Wed Feb 14 11:14:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=aAjL9OEt; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbP72FVGz23j4 for ; Wed, 14 Feb 2024 22:21:31 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDEV-000416-OC; Wed, 14 Feb 2024 06:15:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEJ-0003u8-OA for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEH-00070A-MX for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909304; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HDW4Dr83WauGt3rYUkraVtb8t0sfCwscB4horrSQHwE=; b=aAjL9OEtGD96ys8rxt8W+qAYxLOk50BxgNKKWSXrt0sOd5qUqC84fHJu/9ALgUxEzDHJ3b kP/SfJJF8f9vwQmMKOzOaLkIpIceyZCWo9TQZcZ8LF66uNyiDxgZ0xUvwA5AMiHpmLOq1F o95+bhvzu5qA4QZVqZCImi6tdY7ciKU= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-Yj6JoeTpOya9_LNkJPZdQw-1; Wed, 14 Feb 2024 06:15:03 -0500 X-MC-Unique: Yj6JoeTpOya9_LNkJPZdQw-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a2bc664528fso403728366b.3 for ; Wed, 14 Feb 2024 03:15:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909301; x=1708514101; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HDW4Dr83WauGt3rYUkraVtb8t0sfCwscB4horrSQHwE=; b=PC+0LoCnsBe/2Kvwi9XUWFAq2GBJlBQa9CPfuxcNOG9LK55vxxf1P55cNzvj7TPVzb 1z99jewMvmoQ+SvKeb12vI0GsCjtbvnk20bXjkswiQ7c+RbhkIUYBm/mlz95f3UfDAWq CHcpaQ2WFEywFlmtSNgWgbjz1HK/vBAdBdXNeAhl8eI/zbDyRVpSv71pZn/1LGueFOlA Vm6lkPdyZH7oWpvUJODVWqUc86ICGpcNoD/lE3ilrpNbcRqIMp2y1s3ZDua5OYGIEZJ3 qqNTOSr5U/rAD5MCBG9vwA0oU+1fHEw3ZpyvzCY8YCVt4sWRvX667l7LC3ECy2ZFjXMO MXeA== X-Gm-Message-State: AOJu0YxM7x2SpSC1pgtiWyZL5do6j3+sQvP08bGickds+i1ROc3r7Dg7 4n6c8+ekvuainQgCFOn8o5/ubtvrC5dsbKXd0Y5iTr9Gh5b9N8wZ/jpdmxf2cw9VfURspPPkZkU PXLVCT+zSAVyEG5WM/Y4Svu6cwZ6EcgfqZ6fp3wBHaA/KTPwrdOw2xlRw/tinYU75Q8qPHJyWZw oHFTVRg4ciUGPvKpnAI2Z1oTVfkC1Yfg== X-Received: by 2002:a17:906:68ce:b0:a3d:6637:9d6a with SMTP id y14-20020a17090668ce00b00a3d66379d6amr184459ejr.61.1707909300911; Wed, 14 Feb 2024 03:15:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHm7LO85kM6cZMNR0zVI4MLPyYpafFGqBA+FRtvUnFacf/wJCVrDF2nJsXd66rP2JhnRjL/ew== X-Received: by 2002:a17:906:68ce:b0:a3d:6637:9d6a with SMTP id y14-20020a17090668ce00b00a3d66379d6amr184435ejr.61.1707909300595; Wed, 14 Feb 2024 03:15:00 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUxEk+/+EfvzJRi35A6MXS4f7MMkBpe0dSCdtFOZyAxO1CP03ndlPI/ju4yBpoU4XVGqKdSujiN7v91C2A6Dg== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id ci18-20020a170906c35200b00a3d32341280sm730301ejb.181.2024.02.14.03.14.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:00 -0800 (PST) Date: Wed, 14 Feb 2024 06:14:58 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Andrey Ignatov Subject: [PULL 33/60] vhost-user.rst: Fix vring address description Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Andrey Ignatov There is no "size" field in vring address structure. Remove it. Fixes: 5fc0e00291 ("Add vhost-user protocol documentation") Signed-off-by: Andrey Ignatov Message-Id: <20240112004555.64900-1-rdna@apple.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/interop/vhost-user.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 9f1103f85a..ad6e142f23 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -148,9 +148,9 @@ Vring descriptor indices for packed virtqueues A vring address description ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -+-------+-------+------+------------+------+-----------+-----+ -| index | flags | size | descriptor | used | available | log | -+-------+-------+------+------------+------+-----------+-----+ ++-------+-------+------------+------+-----------+-----+ +| index | flags | descriptor | used | available | log | ++-------+-------+------------+------+-----------+-----+ :index: a 32-bit vring index From patchwork Wed Feb 14 11:15:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898869 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cSMiMTNL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbNX05RFz23j4 for ; Wed, 14 Feb 2024 22:21:00 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDEp-0004Pj-Ip; Wed, 14 Feb 2024 06:15:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEb-00049B-KZ for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEM-000714-Fb for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909308; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l/GevgLgj9voaDnNnKRlj9zSBAyk98vBx5fEOilPhZE=; b=cSMiMTNLv6PBnfOmoWwJ6OQQb4oMnQvteB/l7oN0M9kunPu8IUdXw6irWvax/d0WsG6gHB PqnWgkpXUkqyCdfEeHrtMlEu8EE1wENva7PXe/MkTlJpRrmpwIpoCfM3/RufR5ufRJRHYM vrxtvID76ngfLg1BSaPsNwlZD9wDihE= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-568-FXBcN5RgMUqEVZLNi2AXLA-1; Wed, 14 Feb 2024 06:15:06 -0500 X-MC-Unique: FXBcN5RgMUqEVZLNi2AXLA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a3cdd79d960so114110466b.0 for ; Wed, 14 Feb 2024 03:15:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909304; x=1708514104; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=l/GevgLgj9voaDnNnKRlj9zSBAyk98vBx5fEOilPhZE=; b=gd+99YZ4PFigqqgn8pOGC6wIfauibDM76aKPkTg9zHGoxjXkCpUU4TfAF0MWmrOaX/ m3v1+joR8r+Xciu7WjdE2/L8MVm499xoFOBjQY4bK6TtOrUHu9uGA9+W9pUTnmp848tH LZ33Kng8LqJy7p/J/jhDR4TJHmrxEpsBUMbIX3mx58MVxUfPIPBeErECjV+tJVCBOTai QsgKSKv4QUKOWdjBteeQkfeshxbqt+ntauipCnppCImjxoZ+7xLZwz/e/WKxqiAUZ27j lOzuKpjw6bH9KmkoTLfJh5APiBz1RcS8tpQWjYLMjqyRpzekB2TjLMbPJXiqbxEebRY0 r3fg== X-Gm-Message-State: AOJu0Ywo65g9Quj8ZTsbuFa0lbcR6HjANfioCz9yK7fTkHmRPF9a7YpZ NpFLai/1oPK9kehm9YAsbUrmmf/WfsDbfRTUUrr7KAZ5Q6UWbDtWs3kC/xuHQqRKyCEDz7xvuJH yt88fuQMG5YIC6DxciKrJsewvHcNUJB6qvizfkPP6rFrIMsTA5zmx7XqwXzVFoSatA8kePPZP4P /D3Qfa4RM3V5cmM9+/D03hC99k+Ue6XQ== X-Received: by 2002:a17:907:104a:b0:a38:8ed4:fc82 with SMTP id oy10-20020a170907104a00b00a388ed4fc82mr1396621ejb.15.1707909304478; Wed, 14 Feb 2024 03:15:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGnhcqC8taT79QS6qLJuk+vLqToWhB/bIZ4y45pBYTwyb5z5c8753J+Z/LOlK1ZbAxjMsWunQ== X-Received: by 2002:a17:907:104a:b0:a38:8ed4:fc82 with SMTP id oy10-20020a170907104a00b00a388ed4fc82mr1396598ejb.15.1707909304005; Wed, 14 Feb 2024 03:15:04 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWr2E1LeWwcIDTJquGh0IR7JfFSYxQ7zC1c/rzMOciSHMkdbtblhrGMgLkOpQCuwPh0+/rUrTZvUOo2puNvavQjY6zNcFhsDdLa3fhisyUguCwAfVkUCJ8pZMzMg1q2e6+hS1ITWG4dY2LWac7c2vJFc5pS94UcJzbuekf/dHY4feipLwp6b1y9T8kG528AEpisM1sbtLGhzdCwPaUBwtD7nA== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id mm19-20020a1709077a9300b00a3d4d78a769sm404919ejc.1.2024.02.14.03.15.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:03 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:00 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Peter Xu , Jason Wang , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Thomas Huth , =?utf-8?q?C=C3=A9dric?= Le Goater , Alex =?utf-8?q?Benn=C3=A9?= =?utf-8?q?e?= Subject: [PULL 34/60] MAINTAINERS: Drop myself as VT-d maintainers Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Xu Due to my own limitation on bandwidth, I noticed that unfortunately I won't have time to review VT-d patches at least in the near future. Meanwhile I expect a lot of possibilities could actually happen in this area in the near future. To reflect that reality, I decided to drop myself from the VT-d role. It shouldn't affect much since we still have Jason around like usual, and Michael on top. But I assume it'll always be good if anyone would like to fill this role up. I'll still work on QEMU. So I suppose anyone can still copy me if one thinks essential. Cc: Michael S. Tsirkin Cc: Jason Wang Signed-off-by: Peter Xu Message-Id: <20240118091035.48178-1-peterx@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Acked-by: Jason Wang --- MAINTAINERS | 1 - 1 file changed, 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 89f2d31f70..7a1afb40ac 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3630,7 +3630,6 @@ F: tests/uefi-test-tools/ VT-d Emulation M: Michael S. Tsirkin -M: Peter Xu R: Jason Wang S: Supported F: hw/i386/intel_iommu.c From patchwork Wed Feb 14 11:15:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898833 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ten86G9u; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbGm0YFDz23hM for ; Wed, 14 Feb 2024 22:16:00 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDEl-0004I9-Mb; Wed, 14 Feb 2024 06:15:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDET-000424-FX for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEN-0007BF-T2 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909310; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=V4zjwwSJtTmpywd9ngatCTbsjan0GSdeS1bW++CNE5c=; b=Ten86G9uQyJJWl+qSWsgZly9mUOSMTRpjaPw0uih5D7T6e2SPryK22VcClCGWzoJdWuS8O v4b4hv/Zu73riE2wiM9XfXgh3/QpOha+VQJg6r8TIZYER4u3DSoiZQ3wc9pUpRZarWLLFg MYBKbSYNAqdW7IHIAa8L4P+00hexrdU= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-214-aMhTW5HAMz-c5XFm5mradA-1; Wed, 14 Feb 2024 06:15:09 -0500 X-MC-Unique: aMhTW5HAMz-c5XFm5mradA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a2f71c9f5d2so388493466b.2 for ; Wed, 14 Feb 2024 03:15:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909307; x=1708514107; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=V4zjwwSJtTmpywd9ngatCTbsjan0GSdeS1bW++CNE5c=; b=FQVVC873SrCNR+lVLyz4x381AiAbG/sByY2UbrdFFk8yiKy61WAtxOBREp7ALH7dsM loLRGg03gFXrEQCIdKBAItG9iMp28MC8zjG1P/69qWN41IpkEpXmIiUNgk53pT9FCDY9 N+Y89QXykbmoOHCuHY41KRfhGLLjgZDa3oo5rwgDyCc65DSZreJVVzVvOxKULN19scio 89b6DHs71Zb/Oqe9lN45jI6cwdB4i6P3tOXRjemIOXdeiJHPuPMiQgHCwS7ngGbElHRk qLJVNyGqwJWpwxNuNawgL1eoTev6StRthrabajNc3VaIcf/7j3PzM4L4ODhpU3uWJiCi Srxg== X-Gm-Message-State: AOJu0YweGL5PRm6yH9kKpd563+VNOBS0Is9k/3ZTwEN20stWQrdibE/O aJVEH5o0FunCExETBzIILgQVP34dGX2+7TxkucuCrebw90y6/H6pgQI7zo17CwPSj2WHqSc6Jfn A1I5kR/hx8Twuv/NOTxasHjiPpDdedc/bMyoIAs4mpwWoTmhpy4IWB+m+gbL5ZukZaJxIaqXNeG ERAt13gig9orYOIUV5aOT2gX5q+39Saw== X-Received: by 2002:a17:906:b7c4:b0:a3d:1df3:4a55 with SMTP id fy4-20020a170906b7c400b00a3d1df34a55mr1657573ejb.9.1707909307364; Wed, 14 Feb 2024 03:15:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdajZjxZDO0KZl9LnRp/+jR0soc2A0a+dtsNhxSadlg4yfXqj9h4e62j+ydLWisJYUmQQ7Eg== X-Received: by 2002:a17:906:b7c4:b0:a3d:1df3:4a55 with SMTP id fy4-20020a170906b7c400b00a3d1df34a55mr1657553ejb.9.1707909307029; Wed, 14 Feb 2024 03:15:07 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUfGDiMmsd17kQpRV0SD6bRTu6Qn49KjQQNRIIcnAaRvVZI8OOw7RY911ySteoYLh8TNnIU3pE+l/UjUfvO/ieh8mFqMgVG6+ycH2R4Htyozt40OzcPCkW5GGLmPSTUAg== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id s8-20020a1709066c8800b00a3be8b717dasm2199419ejr.58.2024.02.14.03.15.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:06 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:04 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhenzhong Duan , Eric Auger Subject: [PULL 35/60] virtio_iommu: Clear IOMMUPciBus pointer cache when system reset Message-ID: <9a457383ce9d309d4679b079fafb51f0a2d949aa.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Zhenzhong Duan s->iommu_pcibus_by_bus_num is a IOMMUPciBus pointer cache indexed by bus number, bus number may not always be a fixed value, i.e., guest reboot to different kernel which set bus number with different algorithm. This could lead to endpoint binding to wrong iommu MR in virtio_iommu_get_endpoint(), then vfio device setup wrong mapping from other device. Remove the memset in virtio_iommu_device_realize() to avoid redundancy with memset in system reset. Signed-off-by: Zhenzhong Duan Message-Id: <20240125073706.339369-2-zhenzhong.duan@intel.com> Reviewed-by: Eric Auger Tested-by: Eric Auger Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 8a4bd933c6..86623d55a5 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -1264,6 +1264,8 @@ static void virtio_iommu_system_reset(void *opaque) trace_virtio_iommu_system_reset(); + memset(s->iommu_pcibus_by_bus_num, 0, sizeof(s->iommu_pcibus_by_bus_num)); + /* * config.bypass is sticky across device reset, but should be restored on * system reset @@ -1302,8 +1304,6 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) virtio_init(vdev, VIRTIO_ID_IOMMU, sizeof(struct virtio_iommu_config)); - memset(s->iommu_pcibus_by_bus_num, 0, sizeof(s->iommu_pcibus_by_bus_num)); - s->req_vq = virtio_add_queue(vdev, VIOMMU_DEFAULT_QUEUE_SIZE, virtio_iommu_handle_command); s->event_vq = virtio_add_queue(vdev, VIOMMU_DEFAULT_QUEUE_SIZE, NULL); From patchwork Wed Feb 14 11:15:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898868 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=X1K6p7wD; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbNW00ypz23j4 for ; Wed, 14 Feb 2024 22:20:58 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFD-0005FZ-9n; Wed, 14 Feb 2024 06:16:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDET-000425-Go for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEP-0007CU-Us for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909313; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ZoIzxN4wtVZC8VE/mIbpxC6DW0nDJt+pWpq7gnJFkLU=; b=X1K6p7wDT1w7oG7t3AJIBd2eA6UQWeD3y1lgkIOESSVxlZY+IZ8Ju4B/KQznhyQm0+qIOi Zp1BvEJGpZA85ivMkFt/d4DZ5gK9IUzwsx4bPcEUK8GRAhkUV0RojIB+EvCTr//dLcPrtW JcAU7j3HmrlPfaSG2rrtdF8g6fDMv+I= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-185-FgGQase3MjqXVq8ItnoeJQ-1; Wed, 14 Feb 2024 06:15:11 -0500 X-MC-Unique: FgGQase3MjqXVq8ItnoeJQ-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5611e1da4c6so3589060a12.1 for ; Wed, 14 Feb 2024 03:15:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909310; x=1708514110; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZoIzxN4wtVZC8VE/mIbpxC6DW0nDJt+pWpq7gnJFkLU=; b=OfAa4fvbo8uM7Lv5DbmtAV51J+wIBxwhIT0DmdaPyyaUoTeYQTahIPCroN/iwpVvIA wH9W2GECnO16gGVI7jUsvZwPIt2+wPUGwxDtQGf7SWYuZ9LuRK634km1d4x/9956Hb04 CvHP8jpMq7FghWubGSeehbTHofEUq315iX+YE5rEcjEHGKdiEho7nliqdfbXPCjV9DHD xJrnGnGAcUF0q1+cnm4pdd92oX1ASZibkuPyKeInJLTDd5CJ/oARZwEL4te+2E7aHntL WHR1R7X7UR2Z3xnGI2UrG2YNRhvRIy7bGjlTPNXZuSyT7meHca/IjoMfTPkFWpMMkj6E 41dQ== X-Gm-Message-State: AOJu0Yzkfmbm4CEoBVEQRWp48cmk1hKqDrQbfvfZlkvG9hTXbFgs9Kzi ehHOSj7oOlpa/OYnqIU1LThAADKgHJpOXrct1s5CLyi4IrNKeyPQQYlNGJQNhWclAGLgE3p2+1t EU4Ve1AWuerzrwORuOG4J3DAgFU4dLsGEgpCN2SoMV+sRgjef0BM481GRipQ1MFQ2EbJ8EG/qOk ko4+WSIkGRCDuj9Qk04VZMynxNqqjlGQ== X-Received: by 2002:aa7:da0a:0:b0:55f:fba9:de8c with SMTP id r10-20020aa7da0a000000b0055ffba9de8cmr1705434eds.21.1707909310099; Wed, 14 Feb 2024 03:15:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJK7n/YA0Gl2lZvV7a0zOZa7QGHzAXexi2mUK7V7/n5DJxtbKMvfS9GTZKGWE8QX9Bj8DZjA== X-Received: by 2002:aa7:da0a:0:b0:55f:fba9:de8c with SMTP id r10-20020aa7da0a000000b0055ffba9de8cmr1705417eds.21.1707909309829; Wed, 14 Feb 2024 03:15:09 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCU1Fc1dZC9nuJ3DOptBHrZF/BOPp2m65fqkjj9dDxnAFgLD49vdYbYqBeQ7NPghzf/G62ZSSJPw7Ux+a4RNb7PUGWDgXmjyPCKb7fiF8Mjx6cy+ecqr5bwoxmHu0KFPr8JSzWBKJlz9bMGHhUWXjJeCSEC3xg== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id ca13-20020aa7cd6d000000b005638af177aesm171512edb.53.2024.02.14.03.15.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:09 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:07 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhenzhong Duan , Eric Auger , qemu-arm@nongnu.org Subject: [PULL 36/60] smmu: Clear SMMUPciBus pointer cache when system reset Message-ID: <8a6b3f4dc95a064e88adaca86374108da0ecb38d.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Zhenzhong Duan s->smmu_pcibus_by_bus_num is a SMMUPciBus pointer cache indexed by bus number, bus number may not always be a fixed value, i.e., guest reboot to different kernel which set bus number with different algorithm. This could lead to smmu_iommu_mr() providing the wrong iommu MR. Suggested-by: Eric Auger Signed-off-by: Zhenzhong Duan Message-Id: <20240125073706.339369-3-zhenzhong.duan@intel.com> Reviewed-by: Eric Auger Tested-by: Eric Auger Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/arm/smmu-common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index 9a8ac45431..f58261bb81 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -675,6 +675,8 @@ static void smmu_base_reset_hold(Object *obj) { SMMUState *s = ARM_SMMU(obj); + memset(s->smmu_pcibus_by_bus_num, 0, sizeof(s->smmu_pcibus_by_bus_num)); + g_hash_table_remove_all(s->configs); g_hash_table_remove_all(s->iotlb); } From patchwork Wed Feb 14 11:15:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898866 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JJKLqEH7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbN43GyGz23yK for ; Wed, 14 Feb 2024 22:20:36 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFH-0005Oe-TH; Wed, 14 Feb 2024 06:16:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEV-00045B-DR for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDET-0007Ct-8V for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=s0q+66FHFgz+QEw9GXtnbF95xt1ZFxqJmwC/w0RAaIs=; b=JJKLqEH7SzhDzkHqqMwMs89/meTiK6iguHSOIPYTi2Mg2EqpUpzNvmVU7RcN+pqco0AaPQ 5SUYf6z91T49Lj2eRJVAzs1U2snAa0MHtO7A5dewz1zgk2Nnyxkyk7efyaL9Wc/RriXKJ3 +QTTh+ClU/BFxEbe+29aj08x0+XwU9I= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-70-UgnnJRSPMeyfEa5qzf8fjw-1; Wed, 14 Feb 2024 06:15:14 -0500 X-MC-Unique: UgnnJRSPMeyfEa5qzf8fjw-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5628953d2d8so381928a12.0 for ; Wed, 14 Feb 2024 03:15:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909313; x=1708514113; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=s0q+66FHFgz+QEw9GXtnbF95xt1ZFxqJmwC/w0RAaIs=; b=kYIXfBWuOEz7vqdZ2DazJnUjhiZ+0Zub9hW1wD8egxlxVMDR8+Qc0RYH8E3ZWvrxXJ wdx+iJ9IAnJNmKl2LYlTm/PIKqYjrgRScUyLd5thCupsLVPRy2FF51iwSqEgaIkBoPH+ 07uTWJoKcQGAI989HFVZHTbJ2DzyxE7oJtP2MfkEO5GAxy5Q1g362YweGH/gseELnGO5 wkA4vSuubfhCJ+E+F8Sh5i9jb4xYCxr4sX4mC86V66Z+jpJgfxAJ/JLShroTgC6dStLl Htdhr9mP+PO3ngq54fhsaHeslQSh3mrb9VgkVh8z0DSm6mJqHf2kXqkh8Njje+GAH1Wb D7vA== X-Gm-Message-State: AOJu0YyZa8P3zaN9RTSCQqyFpKl8TSLttA4rS/03N4tKyBYZUYsYyibR +NdOyglA5cl00n/ddz0o/pJ5RIJEy7GSG3Uj9yi31+kugNmBPKT7M3lrHNkLQxtmv8KE3DmXDp4 iqjXMl0MpPTs9ATolXxUGc1ZdNi5XtRXpB1poP+Cc4io0mXaYy1SDDHa0om5r+HBZ8haidZy7Eh YoJNwCzOop8QTpTHTYZI8o7VRcrDQsiQ== X-Received: by 2002:aa7:c58f:0:b0:561:b28:e61 with SMTP id g15-20020aa7c58f000000b005610b280e61mr1786042edq.31.1707909313095; Wed, 14 Feb 2024 03:15:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqzxXCXR241gJUj2BY4RTnBbjI5s921dqL7Tz8OSN10EFdJ6l6JCmDYFxoVRUQnkD5adtryA== X-Received: by 2002:aa7:c58f:0:b0:561:b28:e61 with SMTP id g15-20020aa7c58f000000b005610b280e61mr1786029edq.31.1707909312884; Wed, 14 Feb 2024 03:15:12 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXfzL+TzVONdYLKSlGm4tQCq6dNIMqdaljQjLdP5YSdeMoclRZQ7K2l98+htbRpyykZmLFxO0rPzRMgW6VFrECC1i94r4DRnzEPy/HNAH1IE7I+/88b4d4vOuZE1Kof69ZAPygFsL4ofElsJ4P/jJDMLR6VkHGZrnEqoawsEB+CCZWjsQ/Kp8FPSLUUtLBzTKmHdlFBL/GmNuzulX4UafrjrUXrv38y Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id d6-20020aa7d5c6000000b00563819d224esm346330eds.21.2024.02.14.03.15.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:12 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:09 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ira Weiny , Huai-Cheng Kuo , Dave Jiang , Fan Ni , Jonathan Cameron Subject: [PULL 37/60] cxl/cdat: Handle cdat table build errors Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Ira Weiny The callback for building CDAT tables may return negative error codes. This was previously unhandled and will result in potentially huge allocations later on in ct3_build_cdat() Detect the negative error code and defer cdat building. Fixes: f5ee7413d592 ("hw/mem/cxl-type3: Add CXL CDAT Data Object Exchange") Cc: Huai-Cheng Kuo Reviewed-by: Dave Jiang Reviewed-by: Fan Ni Signed-off-by: Ira Weiny Signed-off-by: Jonathan Cameron Message-Id: <20240126120132.24248-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-cdat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/cxl/cxl-cdat.c b/hw/cxl/cxl-cdat.c index 639a2db3e1..24829cf242 100644 --- a/hw/cxl/cxl-cdat.c +++ b/hw/cxl/cxl-cdat.c @@ -63,7 +63,7 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp) cdat->built_buf_len = cdat->build_cdat_table(&cdat->built_buf, cdat->private); - if (!cdat->built_buf_len) { + if (cdat->built_buf_len <= 0) { /* Build later as not all data available yet */ cdat->to_update = true; return; From patchwork Wed Feb 14 11:15:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DX1g3RD2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbMZ6RQzz23j4 for ; Wed, 14 Feb 2024 22:20:10 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFL-0005Y6-Jg; Wed, 14 Feb 2024 06:16:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEZ-00045y-7i for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEX-0007Dc-3n for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909319; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0BqA9eVzG1Xkbf5+yaBkWiX1PEZkTb1figaBuHZ4bdw=; b=DX1g3RD274lCMog3k0Rn59cqrgFo54lofITPZof8xT0D92jT829dyvOttz1YCkPFCDyLeb z6/tn4tCUTgDfwsQuWdTXcsmU1QY5b1ieQNCBhkZjt2+y2BCrLhl9cqt1O+tae7GjoSPGF 9rSAiGigbsxR0a5a2rWxodNIhVT+Y50= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-385-As1qIUyQO_yArAJM5GL5bQ-1; Wed, 14 Feb 2024 06:15:18 -0500 X-MC-Unique: As1qIUyQO_yArAJM5GL5bQ-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a3c3f477eb7so186335466b.0 for ; Wed, 14 Feb 2024 03:15:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909316; x=1708514116; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0BqA9eVzG1Xkbf5+yaBkWiX1PEZkTb1figaBuHZ4bdw=; b=PEAzAWIunbKynyLHgIfTWGTKR9yDIUh4s7SyWt+libFQkGG4PfN2K11cRs2OK2vjdh h2Wb699fUK9l5sUuIZTBwb4Brk2yxcSpYDels7+HHZTFZ92qV56znphnhlyF/Z9/F2N2 7bgI2ivoS9YbHt9BZjAx/Gpi4zZ/BDw+M8iJrcQBPG03K6GC+0D0Gfziv0ZhI+C5tub4 DAARB1XL65MTYS/VC5Gx/g2MFKHvswaecqmDwH6MDKM4xEwqwJCswKWNucCEc6qugzHH /M03A0b2nel97cM6CK6w9ZfcNkUIgEm5CsOfiXZW8xqKNlkakEfsonZGmSiXgypSDB7M yzUg== X-Gm-Message-State: AOJu0Yx7moXpQcjtR8xkBo2BjGfujOlkoDZRNJSiQQoo2KhtTUdDH/AP k0YQwxbao+hBDNVB0eggMtG5N+2PcDdu1rQ3HRmGi3Ve3CEXWRfU9RN3ZWAAyDIYxwoWiKplDKv sGwjqTUH8xAmKC8IKhS4aokkFm+6QlR5i/XFJsycf91+7CV5BrgeKfhWUyEntVk73D+CSyOI0Nj IWOXys+mlJ1OfVgxfgzDB5GKGNj+NVBQ== X-Received: by 2002:a17:906:374a:b0:a3d:2637:b713 with SMTP id e10-20020a170906374a00b00a3d2637b713mr1776481ejc.54.1707909316224; Wed, 14 Feb 2024 03:15:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IEg06sXqD5nwQvc3dSZ5KvqlW8ZAzu7nOBsNTYs+thJjIcP8XoFHlQhyGB5iiEJARiz3DUKSg== X-Received: by 2002:a17:906:374a:b0:a3d:2637:b713 with SMTP id e10-20020a170906374a00b00a3d2637b713mr1776465ejc.54.1707909315943; Wed, 14 Feb 2024 03:15:15 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWBE1DUo6l7tRnad2agKVEalLFoCR/WAO8+miM9Eth4zslkepjY7bsAmGGHOYRoZp+NJqGddC0i3dOWnLhOfrDyXwgo0q9xlOSJjAS6TGaKO/NaGDw0PoM82wbiYJTYqQ== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id vh2-20020a170907d38200b00a3d08f3283fsm1468213ejc.104.2024.02.14.03.15.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:15 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:13 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 38/60] hw/mem/cxl_type3: Drop handling of failure of g_malloc0() and g_malloc() Message-ID: <0dbcc0ce2f7b7a98a11224add69b2f2f2b8125da.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jonathan Cameron As g_malloc0/g_malloc() will just exit QEMU on failure there is no point in checking for it failing. Reviewed-by: Fan Ni Signed-off-by: Jonathan Cameron Message-Id: <20240126120132.24248-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/cxl_type3.c | 52 +++++++--------------------------------------- 1 file changed, 7 insertions(+), 45 deletions(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 52647b4ac7..1b92a065a3 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -42,9 +42,9 @@ enum { CT3_CDAT_NUM_ENTRIES }; -static int ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, - int dsmad_handle, MemoryRegion *mr, - bool is_pmem, uint64_t dpa_base) +static void ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, + int dsmad_handle, MemoryRegion *mr, + bool is_pmem, uint64_t dpa_base) { g_autofree CDATDsmas *dsmas = NULL; g_autofree CDATDslbis *dslbis0 = NULL; @@ -54,9 +54,6 @@ static int ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, g_autofree CDATDsemts *dsemts = NULL; dsmas = g_malloc(sizeof(*dsmas)); - if (!dsmas) { - return -ENOMEM; - } *dsmas = (CDATDsmas) { .header = { .type = CDAT_TYPE_DSMAS, @@ -70,9 +67,6 @@ static int ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, /* For now, no memory side cache, plausiblish numbers */ dslbis0 = g_malloc(sizeof(*dslbis0)); - if (!dslbis0) { - return -ENOMEM; - } *dslbis0 = (CDATDslbis) { .header = { .type = CDAT_TYPE_DSLBIS, @@ -86,9 +80,6 @@ static int ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, }; dslbis1 = g_malloc(sizeof(*dslbis1)); - if (!dslbis1) { - return -ENOMEM; - } *dslbis1 = (CDATDslbis) { .header = { .type = CDAT_TYPE_DSLBIS, @@ -102,9 +93,6 @@ static int ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, }; dslbis2 = g_malloc(sizeof(*dslbis2)); - if (!dslbis2) { - return -ENOMEM; - } *dslbis2 = (CDATDslbis) { .header = { .type = CDAT_TYPE_DSLBIS, @@ -118,9 +106,6 @@ static int ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, }; dslbis3 = g_malloc(sizeof(*dslbis3)); - if (!dslbis3) { - return -ENOMEM; - } *dslbis3 = (CDATDslbis) { .header = { .type = CDAT_TYPE_DSLBIS, @@ -134,9 +119,6 @@ static int ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, }; dsemts = g_malloc(sizeof(*dsemts)); - if (!dsemts) { - return -ENOMEM; - } *dsemts = (CDATDsemts) { .header = { .type = CDAT_TYPE_DSEMTS, @@ -159,8 +141,6 @@ static int ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, cdat_table[CT3_CDAT_DSLBIS2] = g_steal_pointer(&dslbis2); cdat_table[CT3_CDAT_DSLBIS3] = g_steal_pointer(&dslbis3); cdat_table[CT3_CDAT_DSEMTS] = g_steal_pointer(&dsemts); - - return 0; } static int ct3_build_cdat_table(CDATSubHeader ***cdat_table, void *priv) @@ -171,7 +151,6 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_table, void *priv) int dsmad_handle = 0; int cur_ent = 0; int len = 0; - int rc, i; if (!ct3d->hostpmem && !ct3d->hostvmem) { return 0; @@ -194,27 +173,18 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_table, void *priv) } table = g_malloc0(len * sizeof(*table)); - if (!table) { - return -ENOMEM; - } /* Now fill them in */ if (volatile_mr) { - rc = ct3_build_cdat_entries_for_mr(table, dsmad_handle++, volatile_mr, - false, 0); - if (rc < 0) { - return rc; - } + ct3_build_cdat_entries_for_mr(table, dsmad_handle++, volatile_mr, + false, 0); cur_ent = CT3_CDAT_NUM_ENTRIES; } if (nonvolatile_mr) { uint64_t base = volatile_mr ? memory_region_size(volatile_mr) : 0; - rc = ct3_build_cdat_entries_for_mr(&(table[cur_ent]), dsmad_handle++, - nonvolatile_mr, true, base); - if (rc < 0) { - goto error_cleanup; - } + ct3_build_cdat_entries_for_mr(&(table[cur_ent]), dsmad_handle++, + nonvolatile_mr, true, base); cur_ent += CT3_CDAT_NUM_ENTRIES; } assert(len == cur_ent); @@ -222,11 +192,6 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_table, void *priv) *cdat_table = g_steal_pointer(&table); return len; -error_cleanup: - for (i = 0; i < cur_ent; i++) { - g_free(table[i]); - } - return rc; } static void ct3_free_cdat_table(CDATSubHeader **cdat_table, int num, void *priv) @@ -1168,9 +1133,6 @@ void qmp_cxl_inject_uncorrectable_errors(const char *path, } cxl_err = g_malloc0(sizeof(*cxl_err)); - if (!cxl_err) { - return; - } cxl_err->type = cxl_err_code; while (header && header_count < 32) { From patchwork Wed Feb 14 11:15:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Uaf8CzI3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbPv6YpGz23j4 for ; Wed, 14 Feb 2024 22:22:11 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFO-0005bo-2B; Wed, 14 Feb 2024 06:16:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEc-00049d-Dh for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEZ-0007E9-Dt for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Bo/qBucH+tKMVpBd3eDGN9ZyJTB3hA1wV1N4MxHrb0U=; b=Uaf8CzI3fx63uQnVtxGzRPqqsYFrgtx2CLMcAqVyf3y3A4w8VfTWwLLp93F9Ajqsf00LH0 tX5J2K3UrpnN4Qf8To/yIfkkbclM4iKpuQSgt4pkJDFRHOFnYkW7sxUoe7UghlLjLzx9lf UxoOQg+42Vkahw3t3FEapmCE7cwDKBk= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-215-1WJnv3OeOauyXkflv8LEVA-1; Wed, 14 Feb 2024 06:15:21 -0500 X-MC-Unique: 1WJnv3OeOauyXkflv8LEVA-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a27eddc1c27so115480366b.3 for ; Wed, 14 Feb 2024 03:15:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909320; x=1708514120; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Bo/qBucH+tKMVpBd3eDGN9ZyJTB3hA1wV1N4MxHrb0U=; b=LbCMcVg32PSEO39tT4KRSmmu76AFUvXLcIOzIVstypgveVHmuMhbt5+nGZqV/hIyz4 Wfs/dasQcs0TW+jZHAOss4lX7nl29WLVUXYVlGo7y5SLnCE8QGVjmDORYbLeQOs/N7sx V5wkgIXGdViwgFv5nyNkUtT8+1p7iDS5y1CcwOWYxQAivRhzit0GYv/O/wLs3D5ie0De aKusPKIIf88WpZp61Z282SGHb9mu0iHwEDUq4n5Fi4QOzy4pCNUnc81A/DJXI4fT8/BC bwPzrqfCiCG7GouOP459bzu0cS7r/LaWQXKDQwI8SE2gDWwlptt7/rIqF2FSjzNphmty x28g== X-Gm-Message-State: AOJu0Yx7VxNskBiXff05AYw7nHFj07c0oyHxFUxoKz2jbHV9DRXOOevD bkMwlvZznP5c958TCGs4CabJSrhig2lWLTztHJ91kdyg6Rf3fpEuglsHsgSclcUzo/nUOk3TpiX nWJCdS9dUS2bj6uxYX1MD6yTJ8Ovnl/UNfkbpzdIG7+JtCs9m4N+c2Ph4Or2aJfaixlYvIM3dz3 LbdTSkjsEzPyyxQ4Jnot1k80WgbxCThw== X-Received: by 2002:a17:906:af10:b0:a3c:9470:219a with SMTP id lx16-20020a170906af1000b00a3c9470219amr1421956ejb.4.1707909320086; Wed, 14 Feb 2024 03:15:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIItT0vSBnI/VNaQMQ8THnGTciax+ed9AyIyfD/+yMHA+42lf955ymmlXXo/xOZsZvkmNgZQ== X-Received: by 2002:a17:906:af10:b0:a3c:9470:219a with SMTP id lx16-20020a170906af1000b00a3c9470219amr1421942ejb.4.1707909319759; Wed, 14 Feb 2024 03:15:19 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWlgJGayyRIh7l1OIdr3ZYPw/U7Jgsn0yX1d9gT9AzGiAUDWG2UZUTlMxKsB4tXDtxwoYIRPSYqRBrxKLAGn0rv58StVet5zmaPEptnnUR8xTj4RQab26uVS3sQfcGfxxmsdOzDmBQv Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id vx1-20020a170907a78100b00a3d014fa12esm1546223ejc.196.2024.02.14.03.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:19 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:16 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Marcel Apfelbaum Subject: [PULL 39/60] hw/pci-bridge/cxl_upstream: Drop g_malloc() failure handling Message-ID: <99747b71baf278068b5938ccdc66d6c906ed437e.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jonathan Cameron As a failure of g_malloc() will result in QEMU exiting, it won't return a NULL to check. As such, drop the incorrect handling of such NULL returns in the cdat table building code. Signed-off-by: Jonathan Cameron Message-Id: <20240126120132.24248-4-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-bridge/cxl_upstream.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/hw/pci-bridge/cxl_upstream.c b/hw/pci-bridge/cxl_upstream.c index 36737189c6..d5341b530f 100644 --- a/hw/pci-bridge/cxl_upstream.c +++ b/hw/pci-bridge/cxl_upstream.c @@ -228,9 +228,6 @@ static int build_cdat_table(CDATSubHeader ***cdat_table, void *priv) sslbis_size = sizeof(CDATSslbis) + sizeof(*sslbis_latency->sslbe) * count; sslbis_latency = g_malloc(sslbis_size); - if (!sslbis_latency) { - return -ENOMEM; - } *sslbis_latency = (CDATSslbis) { .sslbis_header = { .header = { @@ -251,9 +248,6 @@ static int build_cdat_table(CDATSubHeader ***cdat_table, void *priv) } sslbis_bandwidth = g_malloc(sslbis_size); - if (!sslbis_bandwidth) { - return 0; - } *sslbis_bandwidth = (CDATSslbis) { .sslbis_header = { .header = { From patchwork Wed Feb 14 11:15:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898870 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Oab3fYzC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbNn2CgVz23j4 for ; Wed, 14 Feb 2024 22:21:13 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFD-0005GP-Py; Wed, 14 Feb 2024 06:16:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEg-0004BF-An for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEe-0007Et-MV for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909328; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/2s6lqYMeUV26bl5P/Tb03gTeEl6FUUCG2Fkw3zLptU=; b=Oab3fYzCqQnYKh4EtL5CQJEpharT/DRwwkjiCAogS7l7hlztTLmAi+f0V9vsRilEpoLHgy SYg2l1OcOcSxp4C3lVpdvHu6aDb0cSfGBke84f0OUFafsthSYff0Wu4K6rGZms6/Bk/Z7X VMAlUVG5vhbAQv9k2/TXNo3yvCdIHfs= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-327-k1Ih44GXOB-bYZ2UjcLdYQ-1; Wed, 14 Feb 2024 06:15:26 -0500 X-MC-Unique: k1Ih44GXOB-bYZ2UjcLdYQ-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a3d4cfc543fso24535566b.2 for ; Wed, 14 Feb 2024 03:15:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909325; x=1708514125; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/2s6lqYMeUV26bl5P/Tb03gTeEl6FUUCG2Fkw3zLptU=; b=srgHPzSDbgSLOSuLaPLqpiCJIMsNqXjozQitVlQkZiuRFoKsw77jrKaDo3cJowXynd QUTBFh7fHhKXyLgrqmmJNsSxFdo7rX7eEhiwwY+oQKtaULMOx3PNO5DbxqIwlqCvhaRh uX9RErzWT/GSyHL5gOGq0da/yqOiZvaV2CdTIEgJt5Nx2rqAIOECpWEoV0I06ssLckMq Jb3GjByirsNEdLSg98Df1pPCOT/EP/tTwSjgKp21UbTdK1oG37qz6So0CWFn8nBGHHIk pNX0wQGZy2uy6Kiq5P4csOUZ2ZW09YLA3afWlyM21fM8eWmgCbrA01wnKRTnDWxPfuOR C+ZQ== X-Gm-Message-State: AOJu0Yw5vt+kjrUa9k3BXSFQcIq7vfVFuA+fByuhLmjTTMyjbEbMy2vQ rYmpB+v2G9Ly2cwEuOQlVprh3qBuUI0YJrEdQqBf7Pm6qQkdtOmTbzLCa0izRv/g6bxkgczciu0 xbEnn0gxhi1qV7KFVbOHPvKI8+llqjAXgaYlOIsC02Ui/zsY8CEZ1FQmBKoSPGRb/+V/9vdczzO 5hX9GY8TTUNH6eoAQzdnbZ9ZO2rgQO4w== X-Received: by 2002:a17:906:395:b0:a3d:6a0b:5bf0 with SMTP id b21-20020a170906039500b00a3d6a0b5bf0mr21769eja.63.1707909324990; Wed, 14 Feb 2024 03:15:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEHiSpQ4mN/0FBoiB+JLxMHGoDiBgllu+o+cXzcDQ2WFpm11bWh7Vi843TAF3hGxz08Y3Egfg== X-Received: by 2002:a17:906:395:b0:a3d:6a0b:5bf0 with SMTP id b21-20020a170906039500b00a3d6a0b5bf0mr21748eja.63.1707909324709; Wed, 14 Feb 2024 03:15:24 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXCzDaXBDA5RBi4ZChqZjr8oY05sR7JSAaUPHISUk+BH2cnub0GJ9rz4OYDdNwcW3OPM0QBqBRCVjGoka09boS+BfLVvkoRbrbiJGjVUAZ5Z7O1dG3BjQA+pUuuZcp/nsrr+zVpLRPdgIoj+5S6sQk3e8+fUhy3wd0WjwHy++aALl5FtGq0SigzAh+USs/UOJjYFBaxUmJ1xMWDsUqcxvUgWHuKrl7A Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id d20-20020a1709064c5400b00a3c598d6b74sm2212621ejw.54.2024.02.14.03.15.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:24 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:20 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ira Weiny , Huai-Cheng Kuo , Dave Jiang , Fan Ni , Jonathan Cameron Subject: [PULL 40/60] cxl/cdat: Fix header sum value in CDAT checksum Message-ID: <64fdad5e67587e88c2f1d8f294e89403856a4a31.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Ira Weiny The addition of the DCD support for CXL type-3 devices extended the CDAT table large enough that the checksum being returned was incorrect.[1] This was because the checksum value was using the header length field rather than each of the 4 bytes of the length field. This was previously not seen because the length of the CDAT data was less than 256 thus resulting in an equivalent checksum value. Properly calculate the checksum for the CDAT header. [1] https://lore.kernel.org/all/20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com/ Fixes: aba578bdace5 ("hw/cxl/cdat: CXL CDAT Data Object Exchange implementation") Cc: Huai-Cheng Kuo Signed-off-by: Ira Weiny Reviewed-by: Dave Jiang Reviewed-by: Fan Ni Signed-off-by: Jonathan Cameron Message-Id: <20240126120132.24248-5-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-cdat.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/cxl/cxl-cdat.c b/hw/cxl/cxl-cdat.c index 24829cf242..2fea975671 100644 --- a/hw/cxl/cxl-cdat.c +++ b/hw/cxl/cxl-cdat.c @@ -49,6 +49,7 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp) g_autofree CDATTableHeader *cdat_header = NULL; g_autofree CDATEntry *cdat_st = NULL; uint8_t sum = 0; + uint8_t *hdr_buf; int ent, i; /* Use default table if fopen == NULL */ @@ -95,8 +96,12 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp) /* For now, no runtime updates */ cdat_header->sequence = 0; cdat_header->length += sizeof(CDATTableHeader); - sum += cdat_header->revision + cdat_header->sequence + - cdat_header->length; + + hdr_buf = (uint8_t *)cdat_header; + for (i = 0; i < sizeof(*cdat_header); i++) { + sum += hdr_buf[i]; + } + /* Sum of all bytes including checksum must be 0 */ cdat_header->checksum = ~sum + 1; From patchwork Wed Feb 14 11:15:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898844 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GAj8Yx7i; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbKD5QwGz23hM for ; Wed, 14 Feb 2024 22:18:08 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFQ-0005gz-OG; Wed, 14 Feb 2024 06:16:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEl-0004JE-8J for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEj-0007FY-Cm for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ny9ujC/q8Uoo9V1VXsX5vJYsw7EaDLr3xTeRBTEHjis=; b=GAj8Yx7i2rOBXX8LrhA6zcmw4aLKSqCngindw/HAw7/zxK3VtfryOuIoX+KPN+6D3LqGm6 zHxxRHwG077GxMw1eR1+UHvVRpBYlCwQnQlWTDJyrhW3JtMaantpDhqhEdxBqTr/c/FyKj QvRz+9kqCxdImGh6dp9nDk1q71cmB50= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-433-NdPGabwQN2uSuwmIDfQ60Q-1; Wed, 14 Feb 2024 06:15:31 -0500 X-MC-Unique: NdPGabwQN2uSuwmIDfQ60Q-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a2bc664528fso403759766b.3 for ; Wed, 14 Feb 2024 03:15:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909329; x=1708514129; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ny9ujC/q8Uoo9V1VXsX5vJYsw7EaDLr3xTeRBTEHjis=; b=WpFxN63NTneTiYZ6u70pUZffslnkjwYrDA4cWKtcIb7DZGBoH4s6lsSsXrqGaO6Zko JiBBE3ZvbAf3zV6KtBY8YoPe/6SbJS6qsu2sYq5RjJX2bbr7BquLmSTDkTtcA3lsh8Nq EAJfHO0+8PSdw4Mw0BSpsi7YS+Y6mF0KA6lpacC4N6W/+QPAdRZekKYGcXJN7y/g1Fvf aPixpAZsJHaB5jkRsm7SmWdMvHyUbdAwo7bWcDj3jLFYskM2d1Zt2Fvk8XPKfKC7HNvc SfQNgR6GG0Gg9Ib5CK7NAf2TgXNY38jpj8Q4yhig7FlbcAmDnpfleDwusXbnxb+b1u6l 2hSg== X-Gm-Message-State: AOJu0YwG07rkJCiXlDaBjIYkxE2q/vFOxvsla3G+YyMWh89IXDBoDYM9 9ypjg+1wiB8+t92OWnwQeooB8ZmEd9K6D3oQroFSmmQKseKJ2kKOf0hjWQtN3tOkUxie08zupUv ObcIc+LIK266+4EdEZvcgcj8vDZO00gPGiEqoDuJJeFL9hhoV00J3LueXQd/l47BwL8057DO9I2 B1RPIGiFNN4/DJnl+r8ZcFFKHfHiqySw== X-Received: by 2002:a17:906:b7c4:b0:a3c:11a0:8d10 with SMTP id fy4-20020a170906b7c400b00a3c11a08d10mr1682393ejb.3.1707909329399; Wed, 14 Feb 2024 03:15:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbHOQkf1nKWKnALpSek5ac4lF2Ksm3qtzz7OVRyTMTV94rSMtOpkxPhaPMdCN0wP9mnm0T0Q== X-Received: by 2002:a17:906:b7c4:b0:a3c:11a0:8d10 with SMTP id fy4-20020a170906b7c400b00a3c11a08d10mr1682378ejb.3.1707909329060; Wed, 14 Feb 2024 03:15:29 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVuI4MvfH9478Gs+zR4LA/EvNdOYlJiH2pVjomgC419sSLx4kvBa9Dq3Xho4e+Bcg2VCr11ehLVHbbxgPRpUMdWWB9671RqzXkAPgQE+WDpy3dO0/VLF4N5+PX09D94Vhx166InFtbQLdWz/3y97M+ARrc= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id ca23-20020a170906a3d700b00a3caccb8f66sm2209113ejb.44.2024.02.14.03.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:28 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:24 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Davidlohr Bueso , Fan Ni , Jonathan Cameron Subject: [PULL 41/60] hw/cxl/mbox: Remove dead code Message-ID: <7031ee540b7e25a8f38d7b855ed99c7c5f68200d.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Davidlohr Bueso Two functions were reported to have dead code, remove the bogus branches altogether, as well as a misplaced qemu_log call. Reported-by: Peter Maydell Reviewed-by: Fan Ni Signed-off-by: Davidlohr Bueso Signed-off-by: Jonathan Cameron Message-Id: <20240126120132.24248-6-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 43 +++++++++++++------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 6eff56fb1b..dc42850767 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1001,15 +1001,8 @@ static CXLRetCode cmd_sanitize_overwrite(const struct cxl_cmd *cmd, cxl_dev_disable_media(&ct3d->cxl_dstate); - if (secs > 2) { - /* sanitize when done */ - return CXL_MBOX_BG_STARTED; - } else { - __do_sanitization(ct3d); - cxl_dev_enable_media(&ct3d->cxl_dstate); - - return CXL_MBOX_SUCCESS; - } + /* sanitize when done */ + return CXL_MBOX_BG_STARTED; } static CXLRetCode cmd_get_security_state(const struct cxl_cmd *cmd, @@ -1387,27 +1380,21 @@ static void bg_timercb(void *opaque) cci->bg.complete_pct = 100; cci->bg.ret_code = ret; - if (ret == CXL_MBOX_SUCCESS) { - switch (cci->bg.opcode) { - case 0x4400: /* sanitize */ - { - CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + switch (cci->bg.opcode) { + case 0x4400: /* sanitize */ + { + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); - __do_sanitization(ct3d); - cxl_dev_enable_media(&ct3d->cxl_dstate); - } - break; - case 0x4304: /* TODO: scan media */ - break; - default: - __builtin_unreachable(); - break; - } + __do_sanitization(ct3d); + cxl_dev_enable_media(&ct3d->cxl_dstate); + } + break; + case 0x4304: /* TODO: scan media */ + break; + default: + __builtin_unreachable(); + break; } - - qemu_log("Background command %04xh finished: %s\n", - cci->bg.opcode, - ret == CXL_MBOX_SUCCESS ? "success" : "aborted"); } else { /* estimate only */ cci->bg.complete_pct = 100 * now / total_time; From patchwork Wed Feb 14 11:15:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898882 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Q+F7SFFq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbQB5ws6z23j4 for ; Wed, 14 Feb 2024 22:22:26 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFT-0005jY-3o; Wed, 14 Feb 2024 06:16:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEo-0004bF-Gr for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEm-0007G8-T3 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909336; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=eTezAdoG0+PsCPdXqD/75aTZ1DfSUbN39Tdfu99ToIE=; b=Q+F7SFFq81RpXTU67l96czZ/gCsg/FDZ+UE6/g2MuRrNwAOn5u4hjS1zSg2g71Haz6blMe ComQW/OU0H578pZ4sJ38ooBlzdNnOfAPAavV4m6liLsJ7fEewFNo0al32gLu19YfX/DQsb 8xmKl/BiJXS2V5krf0/9F9YfOFVQrhA= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-390-o4yM7GrPPIuGTtkcpR9dvQ-1; Wed, 14 Feb 2024 06:15:34 -0500 X-MC-Unique: o4yM7GrPPIuGTtkcpR9dvQ-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a3d4cfc543fso24541566b.2 for ; Wed, 14 Feb 2024 03:15:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909333; x=1708514133; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=eTezAdoG0+PsCPdXqD/75aTZ1DfSUbN39Tdfu99ToIE=; b=u7xRn71KDva0J6eOaPLU99tPCHb93EXW8MI8L2YZc8YS3rtT/3VdRydYI3Pgymgh20 XDemNSnspJqeqTj5e0qV+N8Cn/Q8x6iSe6uXAtWslEwU/yZYcWuP7GyJXzfU98133fWI /r93pKgIBxWsDlcOXRaQPN9/LfepkIZiow23okX30S4wR5bD64ZGsWn/n+GvHPMnCvla /hbDmJgqPQYudgBGD9T8DO7VxaWTywJQqAsAvM7mjfqLsTIn27CJj4pu+BTNGIHNEbEr vW62z+Zi6OnC/5eY6yO4yeRu+WJ6ol2fJbH85S6csR8kQP26SBD42UTbZOGnORiHf3ME BNbA== X-Gm-Message-State: AOJu0YzcYn4aFNRveT5VXaKBnSnJPTKzGVJ6KB5fgnOGhlr64G3xKUhc IS7kEy+9NTfBOi8gLuuk45V+4Vw/jk/xfVN7QsMiHwvucvFKOM4ffq3r1oUJyZmJ2gfm52WJmpq OzKYVqdcJi3RlFz1KdWph5FctV3iwhwH3b9GxB+xVUCXd5ya6RL0GpVOyU0X1QAWoYNDiAuvhEZ JtfEHkLU/mUm+IGsJjrtLZMwFlxl44Kg== X-Received: by 2002:a17:906:4e91:b0:a3d:47dc:e3a8 with SMTP id v17-20020a1709064e9100b00a3d47dce3a8mr1108685eju.3.1707909332863; Wed, 14 Feb 2024 03:15:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IEuvX5JrJhja8Hb5a675iXcwVT+jyUm6OpRJzI4Rdd5MYNqgiFjbB4jFanVZBDLA7JluPAgXw== X-Received: by 2002:a17:906:4e91:b0:a3d:47dc:e3a8 with SMTP id v17-20020a1709064e9100b00a3d47dce3a8mr1108670eju.3.1707909332541; Wed, 14 Feb 2024 03:15:32 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUMOZFH9/cRncfd9zJ5+f+XcqGy7xhbzIrYnnXaeZMSoC546466i3v4BCo17ZJs3S2hAwGC9wMRrnUZEh5pMnONETpNaeG5NqHjG/QoE0b/CWP2A0Ko1FNjnbXlGwQiBsUOf8HSdGjwauY/l2aKmI3IAXsjkA== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id y8-20020a170906558800b00a3d409ebe5fsm549997ejp.119.2024.02.14.03.15.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:32 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:29 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Fan Ni , Jonathan Cameron Subject: [PULL 42/60] hw/cxl/device: read from register values in mdev_reg_read() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Hyeonggon Yoo <42.hyeyoo@gmail.com> In the current mdev_reg_read() implementation, it consistently returns that the Media Status is Ready (01b). This was fine until commit 25a52959f99d ("hw/cxl: Add support for device sanitation") because the media was presumed to be ready. However, as per the CXL 3.0 spec "8.2.9.8.5.1 Sanitize (Opcode 4400h)", during sanitation, the Media State should be set to Disabled (11b). The mentioned commit correctly sets it to Disabled, but mdev_reg_read() still returns Media Status as Ready. To address this, update mdev_reg_read() to read register values instead of returning dummy values. Note that __toggle_media() managed to not only write something that no one read, it did it to the wrong register storage and so changed the reported mailbox size which was definitely not the intent. That gets fixed as a side effect of allocating separate state storage for this register. Fixes: commit 25a52959f99d ("hw/cxl: Add support for device sanitation") Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Reviewed-by: Fan Ni Signed-off-by: Jonathan Cameron Message-Id: <20240126120132.24248-7-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 9 +++++++-- hw/cxl/cxl-device-utils.c | 17 +++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index befb5f884b..31d2afcd3d 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -202,6 +202,9 @@ typedef struct cxl_device_state { }; }; + /* Stash the memory device status value */ + uint64_t memdev_status; + struct { bool set; uint64_t last_set; @@ -353,8 +356,10 @@ static inline void __toggle_media(CXLDeviceState *cxl_dstate, int val) { uint64_t dev_status_reg; - dev_status_reg = FIELD_DP64(0, CXL_MEM_DEV_STS, MEDIA_STATUS, val); - cxl_dstate->mbox_reg_state64[R_CXL_MEM_DEV_STS] = dev_status_reg; + dev_status_reg = cxl_dstate->memdev_status; + dev_status_reg = FIELD_DP64(dev_status_reg, CXL_MEM_DEV_STS, MEDIA_STATUS, + val); + cxl_dstate->memdev_status = dev_status_reg; } #define cxl_dev_disable_media(cxlds) \ do { __toggle_media((cxlds), 0x3); } while (0) diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c index 61a3c4dc2e..40b619ffd9 100644 --- a/hw/cxl/cxl-device-utils.c +++ b/hw/cxl/cxl-device-utils.c @@ -229,12 +229,9 @@ static void mailbox_reg_write(void *opaque, hwaddr offset, uint64_t value, static uint64_t mdev_reg_read(void *opaque, hwaddr offset, unsigned size) { - uint64_t retval = 0; + CXLDeviceState *cxl_dstate = opaque; - retval = FIELD_DP64(retval, CXL_MEM_DEV_STS, MEDIA_STATUS, 1); - retval = FIELD_DP64(retval, CXL_MEM_DEV_STS, MBOX_READY, 1); - - return retval; + return cxl_dstate->memdev_status; } static void ro_reg_write(void *opaque, hwaddr offset, uint64_t value, @@ -371,7 +368,15 @@ static void mailbox_reg_init_common(CXLDeviceState *cxl_dstate) cxl_dstate->mbox_msi_n = msi_n; } -static void memdev_reg_init_common(CXLDeviceState *cxl_dstate) { } +static void memdev_reg_init_common(CXLDeviceState *cxl_dstate) +{ + uint64_t memdev_status_reg; + + memdev_status_reg = FIELD_DP64(0, CXL_MEM_DEV_STS, MEDIA_STATUS, 1); + memdev_status_reg = FIELD_DP64(memdev_status_reg, CXL_MEM_DEV_STS, + MBOX_READY, 1); + cxl_dstate->memdev_status = memdev_status_reg; +} void cxl_device_register_init_t3(CXLType3Dev *ct3d) { From patchwork Wed Feb 14 11:15:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898857 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VuQnS6sf; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbLW4BXlz23hM for ; Wed, 14 Feb 2024 22:19:15 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFI-0005Qd-Ez; Wed, 14 Feb 2024 06:16:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEq-0004pw-W8 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEp-0007Gw-Br for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909338; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qucpWaRpKGw+aISNv+x3UhQU62lbgVkDGnj9pzduH7o=; b=VuQnS6sfOVjP60FhF884l0uUkf//vU2EOL1to927x25QuqTv7RpQn068DUx8yCZEyi4GGI NoDAhcFuwlgDjuJMfGEZpT5HBR3P85rR//v7RnYgO2/NpwVaFh76sxfT51RSOXh7c0/lUE j3LzKMdygO2JVkvnIwjss+V0qCqPVNI= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-67-3IMhYaHgMQWPeKH9WrdUpw-1; Wed, 14 Feb 2024 06:15:37 -0500 X-MC-Unique: 3IMhYaHgMQWPeKH9WrdUpw-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-560127ce17fso2751782a12.0 for ; Wed, 14 Feb 2024 03:15:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909336; x=1708514136; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qucpWaRpKGw+aISNv+x3UhQU62lbgVkDGnj9pzduH7o=; b=lhfqsjfD4CHb3wuasx2K6UhiaT6jB3uzgLZkuyA+mOm0WVDP2K0xVQHf4nXmeIpG7j t66TgfRmOqexPmRt2kLR4JOTdi9EEf1zvlY4UzAGyzdIqKcwyQGDUDFXQkhFp4N05o5Y yrn1Rze68Kntnxh8vCZHp+3UgtvSfU7hIZXTnmzHKyLXRSznY1PO+5oH7WZ3LxurlwiQ xmZ9UxCVMrOe7Z+YWWYjuUWUQvH4+Z6Je2DNOCaoqfZuVecImyIt6v4mxZL0+iR18ZQM e00wZAWYT1qjyMGrR0UIEzFBb/eYqTsmNqgljxzLbq1KfE3upXh0Q1MQ2eW8HBqxvF8h HVoA== X-Gm-Message-State: AOJu0Yxs7VeiENWFafhyrUEaEMngrSoGbwcUyXcy8uxnhHj3E/9Knwuf 6EyYhUiK1jxXALPlhwdpWTiYzSYQNnhM5z0uX2um5JhK5y5oJK0pQbv0SKXFOjG2yi3fyl3w5iQ cUDAFFV5PlCg7iTnysDnSypeHBfwlQ+1NPsfulSiJhEYuEWEugnILaysJLoLY0DogjEMJ/Kh9Cw s4e+DbXjVWA1JkvjP2oVZUhMZ77ztq9g== X-Received: by 2002:aa7:d8d7:0:b0:55f:6a35:b541 with SMTP id k23-20020aa7d8d7000000b0055f6a35b541mr1960135eds.14.1707909335786; Wed, 14 Feb 2024 03:15:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGR26JdICMobyiH7k7PziaOg3yh9jHZQxoX7Fr+dnGQDLn6sgk9oREmpK3gdBrNLJ94LJhbvg== X-Received: by 2002:aa7:d8d7:0:b0:55f:6a35:b541 with SMTP id k23-20020aa7d8d7000000b0055f6a35b541mr1960118eds.14.1707909335487; Wed, 14 Feb 2024 03:15:35 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVCEo9Okp/nS/XZGupRXP/lR0KSDFKGrKCzsQTzj57gSV9aKsMLT0oSLw+fKfTBIPA7SExD8Lue3MGjO0c/359dYWuk64Tn675ONuqEL2XYJY9hrIDs5WKTBeaYg8/8mOAwmx6xfR3CRnCtLinRTQ3cUa3P6l7y Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id g34-20020a056402322200b0056384b26771sm307550eda.91.2024.02.14.03.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:34 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:32 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Li Zhijian , Fan Ni , Jonathan Cameron Subject: [PULL 43/60] hw/cxl: Pass CXLComponentState to cache_mem_ops Message-ID: <729d45a6af06753d3e330f589c248fe9687c5cd5.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Li Zhijian cache_mem_ops.{read,write}() interprets opaque as CXLComponentState(cxl_cstate) instead of ComponentRegisters(cregs). Fortunately, cregs is the first member of cxl_cstate, so their values are the same. Fixes: 9e58f52d3f8 ("hw/cxl/component: Introduce CXL components (8.1.x, 8.2.5)") Reviewed-by: Fan Ni Signed-off-by: Li Zhijian Signed-off-by: Jonathan Cameron Message-Id: <20240126120132.24248-8-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-component-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c index 29d477492b..9dfde6c0b3 100644 --- a/hw/cxl/cxl-component-utils.c +++ b/hw/cxl/cxl-component-utils.c @@ -199,7 +199,7 @@ void cxl_component_register_block_init(Object *obj, /* io registers controls link which we don't care about in QEMU */ memory_region_init_io(&cregs->io, obj, NULL, cregs, ".io", CXL2_COMPONENT_IO_REGION_SIZE); - memory_region_init_io(&cregs->cache_mem, obj, &cache_mem_ops, cregs, + memory_region_init_io(&cregs->cache_mem, obj, &cache_mem_ops, cxl_cstate, ".cache_mem", CXL2_COMPONENT_CM_REGION_SIZE); memory_region_add_subregion(&cregs->component_registers, 0, &cregs->io); From patchwork Wed Feb 14 11:15:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898881 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dajjsAKu; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbQ80lxxz23j4 for ; Wed, 14 Feb 2024 22:22:24 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFM-0005Yu-6E; Wed, 14 Feb 2024 06:16:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEu-0004zP-Fw for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEr-0007HN-Nv for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909341; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7L7U5a8D5EylkKppdsLWG+1xzPDLzJY36FKng3qebqs=; b=dajjsAKuhVwOt30fz7sRRr1xdANmS+3YHDDj1GfVgR392Kk2jOPKGSeUMw1SfaqnUVMmJh LvVqkb4Qo8omsuKsN9JozCmEdaYPBnh8wwpPV/VSWGmafM0GaWvPrCMnOqy/FWFNwmNIpw 4XmVqSo+SdhxeMvuHmfPJaXNS6fGPoo= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-648-LVeiuTSxNV6LtCAYtyGhgA-1; Wed, 14 Feb 2024 06:15:40 -0500 X-MC-Unique: LVeiuTSxNV6LtCAYtyGhgA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a2bc664528fso403766966b.3 for ; Wed, 14 Feb 2024 03:15:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909338; x=1708514138; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7L7U5a8D5EylkKppdsLWG+1xzPDLzJY36FKng3qebqs=; b=PIDfwtaDtg0jn3VXs9S9kVYjj11N8eWO7F2inHMUC+QLNZEcjaxVTX6RZrlMQsCov+ 2ECR6+GCAPeHxncuY+USXF7mRFPb5m3bXSiCw/TWkVhvFSaNu649Fo2dlvEvcuUEDpPk x38NVVVZ85Pj5L0UY0TrdZs9xG5oekVor5DGSMR6qqNh6pNADcHOO5YDJ4D5iUc0l0rH 0oxksmNd8kt47/PcQU+BW9y+vUk5BAwd+9LYISYzCgbkrbNdyjHgnt92i3bUChBUuxnq hwmDPKscTnSMSJqPMrubca7mFJtmQiex01gPpYxHiah9gcRHAZoitcyXNuK79P8sGzGZ 2TeQ== X-Gm-Message-State: AOJu0Yyg/qbSfpPLMKjHukWkjZAeOyjs71oQcxftDSbj/ZxxkhK+DUfO bzkp1cMDLryCxNSJ+JCVk4hZ78ZVlWVYItGRe68HHSAbmE/mQnoDewY0DFe9Ai4RqIbqPctC3Bq nVnQ5Q0nuUXwTzsmvykxIcGjnD4o+M1Ejf/ltaZl846/NYIs2jabmy6qf9MqssiKCGPiYODvbBg pf1Wf/A9T0jNoSkMyadmuXbSdJF0dcIA== X-Received: by 2002:a17:906:a451:b0:a3c:930b:2d14 with SMTP id cb17-20020a170906a45100b00a3c930b2d14mr1598430ejb.9.1707909338390; Wed, 14 Feb 2024 03:15:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2gx/PdD/d0yhvlIvbutYnhRfhxQvKnKfgCGu9ZamHq8OmbwH7vXrFgMl/OA2Zzs6SGewVMA== X-Received: by 2002:a17:906:a451:b0:a3c:930b:2d14 with SMTP id cb17-20020a170906a45100b00a3c930b2d14mr1598414ejb.9.1707909338155; Wed, 14 Feb 2024 03:15:38 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVjjwE5ZaDM8VgzWJx6EBQPGzPgT77eJRz+HjaEgFu+O8++l4x/TQ7faHj1clE45TGcgE2GX56ehxr+U5Ee/8ls+onZSYV/d3QNjum4ahl9JtE/SJpsPw/AtneYgVPLPRoZg7XvFkX9GVJjfHbY7qOP67xhWIcd Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id ss6-20020a170907c00600b00a3d17841204sm1232227ejc.94.2024.02.14.03.15.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:37 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:35 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Li Zhijian , Fan Ni , Jonathan Cameron Subject: [PULL 44/60] hw/cxl: Pass NULL for a NULL MemoryRegionOps Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Li Zhijian a NULL parameter is enough for a NULL MemoryRegionOps Reviewed-by: Fan Ni Signed-off-by: Li Zhijian Signed-off-by: Jonathan Cameron Message-Id: <20240126120132.24248-9-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-component-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c index 9dfde6c0b3..5ddd47ed8d 100644 --- a/hw/cxl/cxl-component-utils.c +++ b/hw/cxl/cxl-component-utils.c @@ -197,7 +197,7 @@ void cxl_component_register_block_init(Object *obj, CXL2_COMPONENT_BLOCK_SIZE); /* io registers controls link which we don't care about in QEMU */ - memory_region_init_io(&cregs->io, obj, NULL, cregs, ".io", + memory_region_init_io(&cregs->io, obj, NULL, NULL, ".io", CXL2_COMPONENT_IO_REGION_SIZE); memory_region_init_io(&cregs->cache_mem, obj, &cache_mem_ops, cxl_cstate, ".cache_mem", CXL2_COMPONENT_CM_REGION_SIZE); From patchwork Wed Feb 14 11:15:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898883 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VEwUcy8M; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbRH693Jz23j4 for ; Wed, 14 Feb 2024 22:23:23 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFZ-0005vh-Gf; Wed, 14 Feb 2024 06:16:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEw-00050O-5T for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEu-0007Ho-Lw for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909344; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=uf4Q9wGfIlQGBzOLWZQCxpB+JmyuulvBhB/9UEzfO+A=; b=VEwUcy8McP5SFM3WubDM/vKGiMy/gjaj/Bzip+V/l2CJFDVgVmdLu4vMeS+GOu2LtWHLLl wKwm5pE7CWGmExO0mMZRCc2AoKy2lUFkMmBnKbGxeXxU3/K8lHiHqzuosDUKcGvXGRAffh y9c+eEAu/E3NPdPLGvJKnfo+xozH5r8= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-427-jOvTgSc6PjqmnAlFIVAwnQ-1; Wed, 14 Feb 2024 06:15:42 -0500 X-MC-Unique: jOvTgSc6PjqmnAlFIVAwnQ-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a3d201e60f2so71831466b.3 for ; Wed, 14 Feb 2024 03:15:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909341; x=1708514141; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uf4Q9wGfIlQGBzOLWZQCxpB+JmyuulvBhB/9UEzfO+A=; b=iHVIpQ8gjon7WciopQ2Az6q3LEZ/BNTZq2uY9/CuXF7OMAPpOvuGP12QdXCLWEcNum qx5P0TkoakT+h99vDRubiPjNJOkVqL7dFPZeVHNKTawKrrCtkhAeLyEctyCjAWJc0cUp 1GeaD82a2EvTHK0F56uyy7z9s0f4ZhI5ueDXoQjqi0jIQRjcNyiJ6Qb5ojSXlWuPALQv LTakKxV9U4KxWjxIFzoyU1TaZSEpUEgreIImmmcC3BrQ7gO2w4t+hOjsuWeRTZ/LBwcG V/ra/amQ0ePH9ptsgPuBgQnj1pJrUGsDSqwDpao3xb7uNpmm3tHDk8o1f0Wj2Jd+iOwt P8mA== X-Gm-Message-State: AOJu0YxTdUVDtCuq9jUWXQhzM9t6+8zrYHcp7Z/mfhxN0GZoHu8FkUEu MAV3e3GJjF5gFvOZrkjcE/CDGP89CrwjL1kt5SqRhtY8YtKmvwQWD4lF2ZPAYF4o/O28uW8CsVU 3IhsEgV/ImpYwqr8lIkTKRRf3hWYSqKYCoJmoKWETOH9kFsLAxe0Go+sFEpSkaswTxACXYutE3C CSyDewgQmSaROFBdWA9NhVwt+b/uirDA== X-Received: by 2002:a17:906:f6d4:b0:a3c:a3eb:4c10 with SMTP id jo20-20020a170906f6d400b00a3ca3eb4c10mr1628533ejb.63.1707909341154; Wed, 14 Feb 2024 03:15:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFkA372y6SW6ww4IR24mwEOdcitcIbp9DkhnB5BKYBCCmiLYACOWFnC1lsgJDd3lZWrofTPpQ== X-Received: by 2002:a17:906:f6d4:b0:a3c:a3eb:4c10 with SMTP id jo20-20020a170906f6d400b00a3ca3eb4c10mr1628516ejb.63.1707909340871; Wed, 14 Feb 2024 03:15:40 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUFHPnSOA9eEWNPlYGqqJRpglthtcivzody29rPJAAxY5rjd6sJE947n6u2Mv435cCg4jXBxnawZwQlObMdSZcGFX03yAuRUrRXRM3iLN36wC6JaFPH5nNpX6RiHLiuok7nGNR4A4bnZtIM2xpylORn1Lcu Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id ty8-20020a170907c70800b00a3d09d09e90sm1443404ejc.59.2024.02.14.03.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:40 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:38 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Stefan Hajnoczi , Fan Ni Subject: [PULL 45/60] hw/mem/cxl_type3: Fix potential divide by zero reported by coverity Message-ID: <48461825af1bdc68cfa25fa0b698c958b65f7368.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jonathan Cameron Fixes Coverity ID 1522368. Currently error_fatal is set if interleave_ways_dec() is going to return 0 but we should handle that zero return explicitly. Reported-by: Stefan Hajnoczi Reviewed-by: Fan Ni Signed-off-by: Jonathan Cameron Message-Id: <20240126120132.24248-10-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/cxl_type3.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 1b92a065a3..71fcb44613 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -794,8 +794,13 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa) } if (((uint64_t)host_addr < decoder_base) || (hpa_offset >= decoder_size)) { - dpa_base += decoder_size / - cxl_interleave_ways_dec(iw, &error_fatal); + int decoded_iw = cxl_interleave_ways_dec(iw, &error_fatal); + + if (decoded_iw == 0) { + return false; + } + + dpa_base += decoder_size / decoded_iw; continue; } From patchwork Wed Feb 14 11:15:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898873 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=H48/Ae0K; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbNr1CLjz23y6 for ; Wed, 14 Feb 2024 22:21:16 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFV-0005pp-RR; Wed, 14 Feb 2024 06:16:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEz-00052h-Is for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEy-0007IW-7E for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909347; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1m40RG3DO787zSHU7BGwg57JlBK36kVvrbc9G+uzCdk=; b=H48/Ae0K5foajI+am2/QrQa3l5bX0ueAqlTwWJCmFDdJHSsnKizfWeFvtb6ps0LjTYj+Aa ABBrCOtVn3772r8guBZJ/A8eOvIlknp6r5zGI9+Rgj3ISUJg4wWx2TExbiJXg8vXIRcHQy TSXC+BzuzhyAJRjVsH8Jk4BHTDCWyc0= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-fmBEoVjXPBOazzUpEaXn5g-1; Wed, 14 Feb 2024 06:15:46 -0500 X-MC-Unique: fmBEoVjXPBOazzUpEaXn5g-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-51162d43c64so3207155e87.1 for ; Wed, 14 Feb 2024 03:15:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909344; x=1708514144; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=1m40RG3DO787zSHU7BGwg57JlBK36kVvrbc9G+uzCdk=; b=SyO0WUhkDNiynPU/pjwvUSfC9BX1tSqHIVSLkvCOwU9OIwbzdO+7ABaExXTGzhR1HL xan3lyWxu6DC7TaiugROLe/AN3TO7gAYvvOOzvAwx1LD1vRi3hWqm0TjmXakt4k9iCF3 upanAxqTDZIxOpbd/mxa7tf1EK1U/YLgLJmfk+tj7fQo2lREJPw1F5fGIYrUFf/OjjD0 dLvbI7LbcLKNe2KAoVb5osd0wgxnVlg38kG1bQWYuvPivLMa5FevG7Q1s/Xgg5vGEghT EUP7aYC2gTJgVKIkqlCf7SaH+fHqBfBe68ZS/MQtpnsVYlKsblGPSHe0jdaj4qk85eXb 7TCw== X-Gm-Message-State: AOJu0YymCtUf6QwLyOjl8Tl4DnWnO1QESRhWVmwvBTa2lLI6rIfjkjhe z+8gDFifgwAZ8MEgsNhTV0qn4O9ljobBtNKVUGR3PA8NJhY/G3JOkMx+J2v4deO2pGVDcaIQGG9 JHp0iMRjCWSSKROdwXKQeHoHo8RQJopKGmXL+RzhNEJAqm9BxBpaElcDKX9h2ftN3h2a2veb2iE JOuYWdK80jM53jkkdI3QqCDS3HtpJFzg== X-Received: by 2002:a05:6512:53a:b0:511:5994:2c92 with SMTP id o26-20020a056512053a00b0051159942c92mr1715926lfc.7.1707909343798; Wed, 14 Feb 2024 03:15:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/8T8mvx1Dva0phBPblUBGPpA2jeM8+UNPxggMoqmKVWjJ9IBz7rOWTBU2Ixy3KcUmOzwERA== X-Received: by 2002:a05:6512:53a:b0:511:5994:2c92 with SMTP id o26-20020a056512053a00b0051159942c92mr1715905lfc.7.1707909343474; Wed, 14 Feb 2024 03:15:43 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXgJd5COh7in68drsPi5VP5OsuXCjzLsBN/hztAZgJB6opXEqfWYsLLl1Yx723f6HU/hT2EQPe+kISo6IOhT6GvBD3sckLL0ArPBUxBM2GqNqq1mkVsBGwlcOiglm13aTyKG35I0kugWCXHyASvBIls+PJZx+U= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id er13-20020a056402448d00b005607825b11bsm4536532edb.12.2024.02.14.03.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:43 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:41 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , Ani Sinha Subject: [PULL 46/60] tests/acpi: Allow update of DSDT.cxl Message-ID: <14ec4ff3e4293635240ba5a7afe7a0f3ba447d31.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jonathan Cameron The _STA value returned currently indicates the ACPI0017 device is not enabled. Whilst this isn't a real device, setting _STA like this may prevent an OS from enumerating it correctly and hence from parsing the CEDT table. Signed-off-by: Jonathan Cameron Message-Id: <20240126120132.24248-11-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index dfb8523c8b..9ce0f596cc 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,2 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DSDT.cxl", From patchwork Wed Feb 14 11:15:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UqN0QEHU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbLl5khlz23hM for ; Wed, 14 Feb 2024 22:19:27 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFc-00060q-MX; Wed, 14 Feb 2024 06:16:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDF2-00058n-Db for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDF0-0007Iz-Ae for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fN72J8WFo/Zhfl2CffZ0fQwcDGfJHksFH3RcOtTuZe8=; b=UqN0QEHUOTDIVq3+XsGQ/5P2qXNzRquUPdqcKBvB7QKUyGWGCBa52NGWM6nRsilpTjuGdB FNS45o6NU9168d28aogvkfDf8eJWoTkIhcxAFmWlBpGM32uFYpH6Rr1tSG2lHd17nhTbZX BPljTqKa8dEEWlZuMavOpdiTwgmxUYc= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-414-D0D05RZFPVWLauXp_ikMYg-1; Wed, 14 Feb 2024 06:15:48 -0500 X-MC-Unique: D0D05RZFPVWLauXp_ikMYg-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5621c809a3bso452539a12.2 for ; Wed, 14 Feb 2024 03:15:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909347; x=1708514147; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fN72J8WFo/Zhfl2CffZ0fQwcDGfJHksFH3RcOtTuZe8=; b=uQKTRiuu7tcsVhnOvwYux30w+78Q6+LkawNpaZkQQxIHrBGBItKyXnfUpS8C1xnFyf bJEe3rLyxZLxnphvdSd+5iLCcLALOYx2eBHA6eNby8RtxJL9iHcfbNXV+RDtY4hPaDGN LI/y7/2tvD3jgcjh6byQX//ug743UHm2Qc41tpSJ2fP+U52vmilORA1rW1uW+nVoQpwj wuSrhR+9zOH6GBjMb2mshwFZTIItHLwfU7sxOWEUxABA6V0ieG/ZpeNB7XsaoDYs1cYC /ajrfBs/SuxfyFBxPa0MZHhJrrxEhqkvEUQCljvYxrCqpuF4zmngn2f05WZCKnelJyzA GjNQ== X-Gm-Message-State: AOJu0YyB5M4l2XeZhVyVx17rFVRTdMdZNG3t8jR9YFiMoZawjoVW6kjF 0PzF9NAKbQS5a5r0ml9cowhT+hnQfAKixgt2Rp6kdXp7hDj2HSg8u80s3wGQT5FlBusem23qxuo cGuCIuvJiEIWH4xYqraEZFmNfj+NIDEEUy3LzWRw/sdypEHAFUtgTe+IhIV1EDy0b3J4Lxu520p 3lj5rGjIJwOTHPwUOx9IweIGiriq+1Sw== X-Received: by 2002:a05:6402:6d7:b0:563:906f:4171 with SMTP id n23-20020a05640206d700b00563906f4171mr48809edy.18.1707909346985; Wed, 14 Feb 2024 03:15:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2inKnnQZXSTc38j06fXNv/Qm5ehexs4T0dLjIipcBJlyOy4+oa0xYf608qMCASnFXkw+DQA== X-Received: by 2002:a05:6402:6d7:b0:563:906f:4171 with SMTP id n23-20020a05640206d700b00563906f4171mr48788edy.18.1707909346640; Wed, 14 Feb 2024 03:15:46 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWLqZBjidmXq5/6GbRdJN3FwsNBUZBvo+5WavW6BjtG2mn8jO5BpcZ+0HeMxLZAVJ0myX8bCA+D1mg1ni4a7cZC79wTOi4EKeK0Oc+umUmEfAhshXZsg29kES4qOWsUKVynnCc34josebIC5Z6G1iJmHCfnL/mYQ7IKL0VPwa/n0op1LR4zK9LVitudZcqZFqWFcC2PhJs7gcgUygil1Yj9DdqfZnaG33BcrZ1GZ3xlzRpYNNDDnIvgq+HpmbBzDW+u0pdAQ+VqCXky2XthKvWrCeCFjpOUDC6z Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id p5-20020a056402074500b005638caeff4bsm121063edy.22.2024.02.14.03.15.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:46 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:43 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 47/60] hw/i386: Fix _STA return value for ACPI0017 Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jonathan Cameron Found whilst testing a series for the linux kernel that actually bothers to check if enabled is set. 0xB is the option used for vast majority of DSDT entries in QEMU. It is a little odd for a device that doesn't really exist and is simply a hook to tell the OS there is a CEDT table but 0xB seems a reasonable choice and avoids need to special case this device in the OS. Means: * Device present. * Device enabled and decoding it's resources. * Not shown in UI * Functioning properly * No battery (on this device!) Signed-off-by: Jonathan Cameron Message-Id: <20240126120132.24248-12-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index d5c6c94474..d3ce96dd9f 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1415,7 +1415,7 @@ static void build_acpi0017(Aml *table) aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0017"))); method = aml_method("_STA", 0, AML_NOTSERIALIZED); - aml_append(method, aml_return(aml_int(0x01))); + aml_append(method, aml_return(aml_int(0x0B))); aml_append(dev, method); build_cxl_dsm_method(dev); From patchwork Wed Feb 14 11:15:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898867 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YVx+55WJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbNT6s3Wz23j4 for ; Wed, 14 Feb 2024 22:20:57 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFP-0005e4-6a; Wed, 14 Feb 2024 06:16:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDF4-0005A2-T8 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDF3-0007Jh-IV for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909353; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=K17K/uN0886Kn47U734ewDBEWNLSENKFpu38B+iNS80=; b=YVx+55WJWmrRsvt8TXZZikCC7XyvetD9aQxaVPv1wFBpQt1rLlwm9Mi9rWZFQVEyCtwQBB 2lOVzBg/xlMsaVOvcrE7dDDszB8lkLfZqB4CPjOG+pbTrC9nR6E/oTb1CKMuVQ67DVPLhl mf8QrBTita1bcg3Fk/f+wi/q5AzK+lU= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-508-nycbCbexNlOHydhJBBFjhA-1; Wed, 14 Feb 2024 06:15:51 -0500 X-MC-Unique: nycbCbexNlOHydhJBBFjhA-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a2cb0d70d6cso340244066b.2 for ; Wed, 14 Feb 2024 03:15:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909350; x=1708514150; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=K17K/uN0886Kn47U734ewDBEWNLSENKFpu38B+iNS80=; b=H3f+SHIvWeCcYIuL4dh493qrNz84M6kC8sVXXQXbCTUtzohWpDK8BRzqifRhJzmvIH FMVxTS1MqAKPQjn/qzvWoF1n2YHcog/blhhs5TMNNvF7lmdBNo6eewut5Fa8p6+iXFg2 xFt7wl2Erd1W/0agrIZiFspnCLslwv45eotuKbmY+/qhcHsBGOIpT6hOZytvhwR9zdDA Lk7mLzcu442Z7oDiawFihWMpvqEMNohwFv9BbDi+30NdHfED7SGyc55FtLQVj3cYk43g rSQhW44GzZMyNCR1bVIB14/k7US7pzlrtsJ2NVyjIIU25Be/eMxALM3fj/B5Yd89aEcy 53Gw== X-Gm-Message-State: AOJu0YxWZQAmVUydBeKKr1339VPpbR1/PJM3b3oqeUi0Nb9pIo+ysxfb BO1Ef/mHshcjczmvIR0DcMqyHe0ou1JWZPc4LL3joYubSFT9yeNI2pKzMGE5IyU9AQ2HBFN9WmG EGCCJkPn0Yt45F2zBIansKeSA7el1/S9lnttlcDUVnY25/mE3tmXGBNzHliO69hh9LOHy55rwEu avbRXTX5Kt81NFDCgMntVsva5yQ2O0fg== X-Received: by 2002:a17:906:a2c9:b0:a3c:8299:9c5f with SMTP id by9-20020a170906a2c900b00a3c82999c5fmr1524904ejb.75.1707909350167; Wed, 14 Feb 2024 03:15:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9ro8RzYCRQT3ChPXndgElsvWkD4U4e0zmV+QarAOpok0ZrKscCzCutBzJNvgO0dc7TqTYFQ== X-Received: by 2002:a17:906:a2c9:b0:a3c:8299:9c5f with SMTP id by9-20020a170906a2c900b00a3c82999c5fmr1524882ejb.75.1707909349757; Wed, 14 Feb 2024 03:15:49 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWcX+cy8xzEBOYB9PvKS3QeNB7mqfN3Jy1g9t23D6ICCt4iHIS88MR+WnmWv/H4jDkapfoDTvz8NE7YZcnjvgxgQ2qP5V2agaYw9jClKL027arCX9E0CJM5XCygInKgi50gROFtHLROwG2/aZ6ke3DqJ7voIHo= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id ll5-20020a170907190500b00a3d120e311asm1316390ejc.117.2024.02.14.03.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:49 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:47 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Igor Mammedov , Ani Sinha Subject: [PULL 48/60] tests/acpi: Update DSDT.cxl to reflect change _STA return value. Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jonathan Cameron _STA will now return 0xB (in common with most other devices) rather than not setting the bits to indicate this fake device has not been enabled, and self tests haven't passed. Signed-off-by: Jonathan Cameron Message-Id: <20240126120132.24248-13-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 1 - tests/data/acpi/q35/DSDT.cxl | Bin 9713 -> 9714 bytes 2 files changed, 1 deletion(-) diff --git a/tests/data/acpi/q35/DSDT.cxl b/tests/data/acpi/q35/DSDT.cxl index 145301c52af9a17242bb306c210f8a7e0f01b827..afcdc0d0ba8e41bb70ac20a78dcc8562ca0cb74b 100644 GIT binary patch delta 64 zcmez9{mGllCDuD9;-j0~S)C(%d^zGhJY9GlodY}#3=GW~ UL^$JvLmU~FaB*)wsA#|f0Fwq1RsaA1 delta 63 zcmez5{n4AtCD X-Patchwork-Id: 1898871 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=TTQeaM2V; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbNp2n07z23j4 for ; Wed, 14 Feb 2024 22:21:14 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFW-0005rV-Mb; Wed, 14 Feb 2024 06:16:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDF9-0005DW-IE for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDF8-0007Lq-0X for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909356; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/ggdbY/LPAEpu4bQnWL4QSYX6TO+5Q3+mttO5tostwE=; b=TTQeaM2V+B0NsPn9GYY/Yz+P0SMtjoijn0Cy9BbeUo3RKo1ZX2VJHMnOgUSZgFD23FrbmA VJ0ekf9vq5Mt6wiQnd0+tfh5/GWPz6O0tTENiZDP/yEPDm7O5TNlJSuyBlfyvudo3XQesS G6joYvDQ0ZEAqVO59+AFRZ9q8+nrEz4= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-18-3h9edssKPGmvznQtXsHYIA-1; Wed, 14 Feb 2024 06:15:54 -0500 X-MC-Unique: 3h9edssKPGmvznQtXsHYIA-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a3d481c7d8cso27693366b.1 for ; Wed, 14 Feb 2024 03:15:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909353; x=1708514153; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/ggdbY/LPAEpu4bQnWL4QSYX6TO+5Q3+mttO5tostwE=; b=j+VEyasWnrBVupl9oDFliFQYCYElwOiUbAdL1j277ZI665D/8kjxhaBdjcIOvWvy8r HBuicnisGyu0AC9fLgHr7hSWbir96YAmY02BRmtAUC91ODoZJFKOlW2ENS01ki1ob3JM icD3HIEYHgLeXwQXribYTi4yb7xvRh3UwjIaGXWuCVe5ZHG/GbmDEBpv7WjDxPDE/24S XEysGusLXeMxz3RG6jZcewMbQ9KujFRRpMRQiKQPBheJnEwp3Sdu9mxpevjzuOAsKGSR qCB4jBb7rFtC/J4r3gy+UmNQxVjb37aWN4EcPPzvpXu2qKVW/Nc69IPhQrCJzU2nYdZD VV1g== X-Gm-Message-State: AOJu0YyaZj+mdVaeTqyrKc1BIbV8BPzM3+5mqWzhvQ+9Maw5KTkPSxeN fzHDlT+5OwnTTkVk6eMARKWohQ/8txnwbaDCd3hKUN2SNcztKmfbL9/8wyVoMxr1cKgSBmzInSW u8fcrFcmo8xWwF/KwHM3TVfW5d0yfKz2Rt8WOdn1XLwMmQx6GIAS9C4bVySBGQSULMXetQ95Ibl +PymU2rbhzmjw9KsQuZT9F3BFWANfsTA== X-Received: by 2002:a17:906:bc59:b0:a38:916e:a4fe with SMTP id s25-20020a170906bc5900b00a38916ea4femr1588437ejv.39.1707909352960; Wed, 14 Feb 2024 03:15:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBmqSqXj6AOCkWo4acFUHX1+O3Rkj5lOUDH2bVtG17TnOg1qkrOKN/t3AYiKdcX7Nbo/Y2/g== X-Received: by 2002:a17:906:bc59:b0:a38:916e:a4fe with SMTP id s25-20020a170906bc5900b00a38916ea4femr1588424ejv.39.1707909352540; Wed, 14 Feb 2024 03:15:52 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXStH8YTHn0bmCotcCK7lny7JbxAa/yARMP94HDxG5eHJIciRZJp6IlytLC4L6Pws+GQjGPfUOhwG9v7jauvDhGClJyMLuBNcPiDMCB7QI+vVbvOPt2e+wgCZRI0s3uUA== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id lj8-20020a170907188800b00a3d2e685ff2sm805230ejc.78.2024.02.14.03.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:52 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:50 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 49/60] hw/cxl: Update HDM Decoder capability to version 3 Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UPPERCASE_50_75=0.008 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jonathan Cameron Part of standardizing the QEMU code on CXL r3.1. No fuctional changes as everything added is optional and it is set as not implemented. Reviewed-by: Fan Ni Signed-off-by: Jonathan Cameron Message-Id: <20240126121636.24611-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_component.h | 16 ++++++++++++++-- hw/cxl/cxl-component-utils.c | 10 +++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/include/hw/cxl/cxl_component.h b/include/hw/cxl/cxl_component.h index 5227a8e833..7d3edef1bf 100644 --- a/include/hw/cxl/cxl_component.h +++ b/include/hw/cxl/cxl_component.h @@ -109,8 +109,9 @@ REG32(CXL_RAS_ERR_HEADER0, CXL_RAS_REGISTERS_OFFSET + 0x18) (CXL_SEC_REGISTERS_OFFSET + CXL_SEC_REGISTERS_SIZE) #define CXL_LINK_REGISTERS_SIZE 0x38 -/* 8.2.5.12 - CXL HDM Decoder Capability Structure */ -#define HDM_DECODE_MAX 10 /* 8.2.5.12.1 */ +/* CXL r3.1 Section 8.2.4.20: CXL HDM Decoder Capability Structure */ +#define HDM_DECODE_MAX 10 /* Maximum decoders for Devices */ +#define CXL_HDM_CAPABILITY_VERSION 3 #define CXL_HDM_REGISTERS_OFFSET \ (CXL_LINK_REGISTERS_OFFSET + CXL_LINK_REGISTERS_SIZE) #define CXL_HDM_REGISTERS_SIZE (0x10 + 0x20 * HDM_DECODE_MAX) @@ -133,6 +134,11 @@ REG32(CXL_RAS_ERR_HEADER0, CXL_RAS_REGISTERS_OFFSET + 0x18) FIELD(CXL_HDM_DECODER##n##_CTRL, COMMITTED, 10, 1) \ FIELD(CXL_HDM_DECODER##n##_CTRL, ERR, 11, 1) \ FIELD(CXL_HDM_DECODER##n##_CTRL, TYPE, 12, 1) \ + FIELD(CXL_HDM_DECODER##n##_CTRL, BI, 13, 1) \ + FIELD(CXL_HDM_DECODER##n##_CTRL, UIO, 14, 1) \ + FIELD(CXL_HDM_DECODER##n##_CTRL, UIG, 16, 4) \ + FIELD(CXL_HDM_DECODER##n##_CTRL, UIW, 20, 4) \ + FIELD(CXL_HDM_DECODER##n##_CTRL, ISP, 24, 4) \ REG32(CXL_HDM_DECODER##n##_TARGET_LIST_LO, \ CXL_HDM_REGISTERS_OFFSET + (0x20 * n) + 0x24) \ REG32(CXL_HDM_DECODER##n##_TARGET_LIST_HI, \ @@ -148,6 +154,12 @@ REG32(CXL_HDM_DECODER_CAPABILITY, CXL_HDM_REGISTERS_OFFSET) FIELD(CXL_HDM_DECODER_CAPABILITY, INTERLEAVE_256B, 8, 1) FIELD(CXL_HDM_DECODER_CAPABILITY, INTERLEAVE_4K, 9, 1) FIELD(CXL_HDM_DECODER_CAPABILITY, POISON_ON_ERR_CAP, 10, 1) + FIELD(CXL_HDM_DECODER_CAPABILITY, 3_6_12_WAY, 11, 1) + FIELD(CXL_HDM_DECODER_CAPABILITY, 16_WAY, 12, 1) + FIELD(CXL_HDM_DECODER_CAPABILITY, UIO, 13, 1) + FIELD(CXL_HDM_DECODER_CAPABILITY, UIO_DECODER_COUNT, 16, 4) + FIELD(CXL_HDM_DECODER_CAPABILITY, MEMDATA_NXM_CAP, 20, 1) + FIELD(CXL_HDM_DECODER_CAPABILITY, SUPPORTED_COHERENCY_MODEL, 21, 2) REG32(CXL_HDM_DECODER_GLOBAL_CONTROL, CXL_HDM_REGISTERS_OFFSET + 4) FIELD(CXL_HDM_DECODER_GLOBAL_CONTROL, POISON_ON_ERR_EN, 0, 1) FIELD(CXL_HDM_DECODER_GLOBAL_CONTROL, HDM_DECODER_ENABLE, 1, 1) diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c index 5ddd47ed8d..a55cf5a036 100644 --- a/hw/cxl/cxl-component-utils.c +++ b/hw/cxl/cxl-component-utils.c @@ -243,6 +243,14 @@ static void hdm_init_common(uint32_t *reg_state, uint32_t *write_msk, ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, INTERLEAVE_4K, 1); ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, POISON_ON_ERR_CAP, 0); + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, 3_6_12_WAY, 0); + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, 16_WAY, 0); + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, UIO, 0); + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, + UIO_DECODER_COUNT, 0); + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, MEMDATA_NXM_CAP, 0); + ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_CAPABILITY, + SUPPORTED_COHERENCY_MODEL, 0); /* Unknown */ ARRAY_FIELD_DP32(reg_state, CXL_HDM_DECODER_GLOBAL_CONTROL, HDM_DECODER_ENABLE, 0); write_msk[R_CXL_HDM_DECODER_GLOBAL_CONTROL] = 0x3; @@ -326,7 +334,7 @@ void cxl_component_register_init_common(uint32_t *reg_state, return; } - init_cap_reg(HDM, 5, 1); + init_cap_reg(HDM, 5, CXL_HDM_CAPABILITY_VERSION); hdm_init_common(reg_state, write_msk, type); if (caps < 5) { From patchwork Wed Feb 14 11:15:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898858 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=XucYV0lb; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbLg50vLz23hM for ; Wed, 14 Feb 2024 22:19:23 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFe-00063W-I4; Wed, 14 Feb 2024 06:16:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFA-0005Dn-QL for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDF9-0007MJ-7c for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909358; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=jXLu0fCpWfnRtLL6HbFiblf7I9UT0za8sM7v/5jTM+w=; b=XucYV0lbnaYTJeTdWOgZZRNWqJ3G0aUmvypUwFXrBBlYHD2ULukL44VgWtYXOpwkpB1KMi qoG6NrO3Hur/S8cCIzVr76s9KwDGmdLJDt2//EYJsITviTkzd3GQlXUEUQ8QZW1mnltMtP QzOpYAUD8rnJ45kkVsT0+f7FrhKxQcM= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-378-Gk_A__JQO_udcFjFuh-f_g-1; Wed, 14 Feb 2024 06:15:57 -0500 X-MC-Unique: Gk_A__JQO_udcFjFuh-f_g-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a3d130eb757so78351566b.2 for ; Wed, 14 Feb 2024 03:15:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909355; x=1708514155; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jXLu0fCpWfnRtLL6HbFiblf7I9UT0za8sM7v/5jTM+w=; b=AH1sRf06jyXB77weEi5BD/ZoB50z6MhydfJxYytk8UD0ifL4BfeiX1FYye9YRDq6hM mkpdyLR0wJbT0SZCIpbHon8+1JUeM3wphyfMJt1jarRwycC6QrOO5fedrPFQMP6T5/xs JpDPaIBR1o3MVkGhxWwJksA/aBnCC1ypJlLfBmgQtcwj0CQtBZJC2tScqGr/P01Sr8q5 2mb4Is9btu8zIR73jT3cR9nGm0IXGfPV/FSnsNe7bTV4qtrPAcHGZBWDyRjmMt13ToVQ /29z6G1G9I1L1L407vG47jWnPW5VVIOHdrbSHIcVkaWa/sMEYoq+ZvOlnM9lhUyyWeIF zW9Q== X-Gm-Message-State: AOJu0YxtGWG+d816ITWTD9SAbJDcQsEodXfezKayVVHJYx4i0FbytOxz /ITptMp3GmbKjkTp//ilO6SklSFQuM7Y7KO+rX7oicmQP9nw9XpHFDsIPtMVsFnlllKp0NADKWD RUxtiyKhImSiBRqxA117gdHfAqNwDS2D/gVBCXXFxA1teIIW+5BsZjNPNCWV8+HoAYqSBAnzKpc 49H06RL/P+INd0tkZ3Bc3ahsS+J9uNDQ== X-Received: by 2002:a17:907:11dd:b0:a3d:14ce:9559 with SMTP id va29-20020a17090711dd00b00a3d14ce9559mr1731954ejb.47.1707909355657; Wed, 14 Feb 2024 03:15:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IEMk3fGggdN7rV6DGx0uZNRADkZLIrHTBB0mcmPVTl2mUAj/ZHVdfPG8MkB+FIjZvHeqHWe7g== X-Received: by 2002:a17:907:11dd:b0:a3d:14ce:9559 with SMTP id va29-20020a17090711dd00b00a3d14ce9559mr1731937ejb.47.1707909355377; Wed, 14 Feb 2024 03:15:55 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWqF2qsjT5X+q6kX2hlufXVFjpV0Cy1G7bDvCZgUkXTfdvHobILCFv6pcLSwet0uEGw8QGnyOWdeYpsYTrTIVsXiJ1rtB7v24YA40nPJORS5JULWQXBfNYH6VXerzMLOQ== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id qb35-20020a1709077ea300b00a3840fbeef9sm2203879ejc.70.2024.02.14.03.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:54 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:52 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 50/60] hw/cxl: Update link register definitions. Message-ID: <40ecac10c03aa74deada32a1ee7af1ad9750d483.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jonathan Cameron Not actually implemented, but we need to reserve more space for the larger version of the structure in CXL r3.1. Reviewed-by: Fan Ni Signed-off-by: Jonathan Cameron Message-Id: <20240126121636.24611-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_component.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/hw/cxl/cxl_component.h b/include/hw/cxl/cxl_component.h index 7d3edef1bf..2c7631bd1e 100644 --- a/include/hw/cxl/cxl_component.h +++ b/include/hw/cxl/cxl_component.h @@ -104,10 +104,10 @@ REG32(CXL_RAS_ERR_HEADER0, CXL_RAS_REGISTERS_OFFSET + 0x18) (CXL_RAS_REGISTERS_OFFSET + CXL_RAS_REGISTERS_SIZE) #define CXL_SEC_REGISTERS_SIZE 0 /* We don't implement 1.1 downstream ports */ -/* 8.2.5.11 - CXL Link Capability Structure */ +/* CXL r3.1 Section 8.2.4.19: CXL Link Capability Structure */ #define CXL_LINK_REGISTERS_OFFSET \ (CXL_SEC_REGISTERS_OFFSET + CXL_SEC_REGISTERS_SIZE) -#define CXL_LINK_REGISTERS_SIZE 0x38 +#define CXL_LINK_REGISTERS_SIZE 0x50 /* CXL r3.1 Section 8.2.4.20: CXL HDM Decoder Capability Structure */ #define HDM_DECODE_MAX 10 /* Maximum decoders for Devices */ From patchwork Wed Feb 14 11:15:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898862 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=SwMW7SAg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbML1hPzz23hM for ; Wed, 14 Feb 2024 22:19:58 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFL-0005YI-Ob; Wed, 14 Feb 2024 06:16:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFF-0005Le-5x for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFD-0007NM-Ea for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909362; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=mVxvuEjSCC48+PeMNO+t/y9XPe1f/wxKbS6YfzXmdhM=; b=SwMW7SAgiPjNJUCCKZCUsFKdsOIFEt9dVb3QoknHTUAp1avUI1ps/crcP6JY/aj3ALlUgD bHrISJs8GsQWd6F95JrZv4n1mQ0VCjhzdyMIbsEKBhDrZIV8DZwc8FxXUpELrmVU22I1k4 qv1MPwPWAPl1+RUi8beXHVXmBennr54= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-522-h1TZkV9JP5-N4nslXvJPQg-1; Wed, 14 Feb 2024 06:16:01 -0500 X-MC-Unique: h1TZkV9JP5-N4nslXvJPQg-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a26f2da3c7bso283534666b.0 for ; Wed, 14 Feb 2024 03:16:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909359; x=1708514159; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mVxvuEjSCC48+PeMNO+t/y9XPe1f/wxKbS6YfzXmdhM=; b=eEdY+SvCbXF1dVE8Oli7XbIUXYykXZUZV31PFSjIJucReDhs0IgDZEWO0vgJOpKiBI QQyGwQgDJ65blETL0HeOArf9fE1qy1fpAeyXnmNmFbdvFIs/6yaWpxjvXyB3DozeTahW ddlW3cylBBHaKIDbgFZ8kfvMP38LZAJadLD/+olDeuwT9kPpTjC0P0oKVX8p0fHpDzWB /RUcg0tMczzYZtctFrFLPKyhYFs9xbaL2KkfLo9yqRu80GJFtuNs20QoNKLXN5xNZMFy gex8IKu9YsSpn9gK1URNYey48yIICW1Wy8By2GXV/2YOwRENVIey60/yvPu1oZ4p39oS 3S5g== X-Gm-Message-State: AOJu0YxpI0Vc8TeNOBnwTJkmDtAX1H9RDDqf45sDVuQFh3G/eQsTkcRz p8yuixGeh4LSCFizM3vVk0bGqXfgDz/XVe6dRHf1M7QD3EQyuszmwjfLEIVzgWP0KGhBCP2iWCt YRR7vkHND+TRLl4mxRPuWG/cKZb88YCbeMEbkQKLQTC8gb8tHahUcbQXb1vHS1VRGaPZuNl7eKB QEIzuSLkHvsdreZDeweEgljhrxgcGodw== X-Received: by 2002:a05:6402:74b:b0:561:f04:17c1 with SMTP id p11-20020a056402074b00b005610f0417c1mr1683759edy.28.1707909359205; Wed, 14 Feb 2024 03:15:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEHkeiY4F+ZnhN03AxsvQX/3ukVFXdjjOeeqgCGlqQUPnrlNAgGdNVeEQvRhcmUhrC7Gnz+A== X-Received: by 2002:a05:6402:74b:b0:561:f04:17c1 with SMTP id p11-20020a056402074b00b005610f0417c1mr1683723edy.28.1707909357987; Wed, 14 Feb 2024 03:15:57 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWYerUJw18bp9ng4f9fk+kjEuxaWmcx7CaQRr+7IOZIufrDGsh94cVvBRS/ewL2vTYBjMxGiLNvJzR4TKjs002RQ9DLU2ADqoAf6sxSx9v9ArWRhImeuS8slRDDOPZRHw== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id h2-20020a0564020e8200b00560c6ff443esm4518808eda.66.2024.02.14.03.15.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:57 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:55 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 51/60] hw/cxl: Update RAS Capability Definitions for version 3. Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jonathan Cameron Part of bringing all of CXL emulation inline with CXL r3.1. No functional changes. Reviewed-by: Fan Ni Signed-off-by: Jonathan Cameron Message-Id: <20240126121636.24611-4-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_component.h | 5 ++++- hw/cxl/cxl-component-utils.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/hw/cxl/cxl_component.h b/include/hw/cxl/cxl_component.h index 2c7631bd1e..b5da72b789 100644 --- a/include/hw/cxl/cxl_component.h +++ b/include/hw/cxl/cxl_component.h @@ -60,8 +60,9 @@ CXLx_CAPABILITY_HEADER(SNOOP, 0x14) * implements. Some of these are specific to certain types of components, but * this implementation leaves enough space regardless. */ -/* 8.2.5.9 - CXL RAS Capability Structure */ +/* CXL r3.1 Section 8.2.4.17: CXL RAS Capability Structure */ +#define CXL_RAS_CAPABILITY_VERSION 3 /* Give ample space for caps before this */ #define CXL_RAS_REGISTERS_OFFSET 0x80 #define CXL_RAS_REGISTERS_SIZE 0x58 @@ -95,6 +96,8 @@ REG32(CXL_RAS_COR_ERR_STATUS, CXL_RAS_REGISTERS_OFFSET + 0xc) REG32(CXL_RAS_COR_ERR_MASK, CXL_RAS_REGISTERS_OFFSET + 0x10) REG32(CXL_RAS_ERR_CAP_CTRL, CXL_RAS_REGISTERS_OFFSET + 0x14) FIELD(CXL_RAS_ERR_CAP_CTRL, FIRST_ERROR_POINTER, 0, 6) + FIELD(CXL_RAS_ERR_CAP_CTRL, MULTIPLE_HEADER_RECORDING_CAP, 9, 1) + FIELD(CXL_RAS_ERR_POISON_ENABLED, POISON_ENABLED, 13, 1) REG32(CXL_RAS_ERR_HEADER0, CXL_RAS_REGISTERS_OFFSET + 0x18) #define CXL_RAS_ERR_HEADER_NUM 32 /* Offset 0x18 - 0x58 reserved for RAS logs */ diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c index a55cf5a036..848bfa20f1 100644 --- a/hw/cxl/cxl-component-utils.c +++ b/hw/cxl/cxl-component-utils.c @@ -325,7 +325,7 @@ void cxl_component_register_init_common(uint32_t *reg_state, CXL_##reg##_REGISTERS_OFFSET); \ } while (0) - init_cap_reg(RAS, 2, 2); + init_cap_reg(RAS, 2, CXL_RAS_CAPABILITY_VERSION); ras_init_common(reg_state, write_msk); init_cap_reg(LINK, 4, 2); From patchwork Wed Feb 14 11:15:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898877 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UEpJTA1g; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbPT4JgQz23j4 for ; Wed, 14 Feb 2024 22:21:49 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFh-00067c-AX; Wed, 14 Feb 2024 06:16:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFH-0005PO-Fj for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFF-0007Np-Il for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909364; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ylEcLLQelxgTT5SRTb3yQG3L55Bz8TDs5AeDEz2G4ss=; b=UEpJTA1gsI9ZVRUnh6zfSXv0qJewIh4aNsdjVLUHskn9IVpssZBWs0PyChepyei8jnxT6Y MSuhX8ETSxeNp+TGGBSJdxpL3XxV5j2O/Sm4qcqE/kJUZe4kVIXJjp6pBEt6rePCfuGYKm 0X8kE3y47DAY0g48ru1kq1CuJ9xynAk= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-655-jugRfqSBMeCanekjl0Bcng-1; Wed, 14 Feb 2024 06:16:03 -0500 X-MC-Unique: jugRfqSBMeCanekjl0Bcng-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5620e5747acso669440a12.0 for ; Wed, 14 Feb 2024 03:16:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909362; x=1708514162; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ylEcLLQelxgTT5SRTb3yQG3L55Bz8TDs5AeDEz2G4ss=; b=IMZsXPbgt4Tu1dT1MKGk1l82tiH9wDJot1mUTEOcfSnpAGltARkmS/OFvqZTUeRkqV O9wfe5EkZkz/24h2dWS1qTZbSur74gi7nxfNQBEeOBlIKxi9k9pgh0S0ArHVNNlzE9V+ e7rDp7CnOq+9wHNAdWoy8Vw6jEtsYQovVupc7hbBqI9Y/fT03UGPEyF4fWtJ9AuMmIFp pRqbttbSD4w6mojiig6RaCxdUHg7YpYKdjAjY9TanL4w3XfBrVpvfQLL6ucFW88+wz99 mwZJH0jqR/9Tb7mia3l+xWFuunqgDNOTsECI3TlGbszlBz0+I5M1LVYYwnDJ70f/y1FS /Zyw== X-Gm-Message-State: AOJu0YzF6a975+joXY+HuKhmWwR9YLnGdT/vvToa7VrUwttW+phOiiAo Ci8Hn+Nf06N4rIhVyFFmN8/DkRcW1LKzabG5amKp4LGvf9yUd8visGh/rPY4nUb0STx5YYbIg13 efMkSFK4DYpRe7kUE5KsMCQ7bp+Hp+rYtkepUPQJGBBSAnNDqKE/zfX3R7eMunn5pqfoc8FhJ58 8gVvNwtYYEVCMzsoocuYxWcqyuDpS7EA== X-Received: by 2002:a05:6402:5410:b0:561:5e21:8b89 with SMTP id ev16-20020a056402541000b005615e218b89mr1669576edb.13.1707909362094; Wed, 14 Feb 2024 03:16:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGnUwzQAgZoc9Y5U/DZp5GdynU0j6oJbT2Ym7gFOc/uY0hNc2e0ipL7dvWlG5LDXc6G8RoaMQ== X-Received: by 2002:a05:6402:5410:b0:561:5e21:8b89 with SMTP id ev16-20020a056402541000b005615e218b89mr1669562edb.13.1707909361788; Wed, 14 Feb 2024 03:16:01 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVtSe5S3zQApolxxgTdW5XYX+GyKydWvcWMijuVQ+AQwhvLgtrBWh8eK6uauhNWG1vV6W0zWfI+AuH8iU+XT4PD4z5qd6fEIAh7c0t7BvPovVBz7zcvuBXelKvGSjyn+Q== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id i23-20020a50d757000000b005621e66c8ddsm710069edj.17.2024.02.14.03.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:16:01 -0800 (PST) Date: Wed, 14 Feb 2024 06:15:59 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni Subject: [PULL 52/60] hw/cxl: Update mailbox status registers. Message-ID: <202f651469b7a6440577cb6a985cf1eb538ea899.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jonathan Cameron Whilst the reported version was 1 so there should be no changes, a couple of fields (where the value 0 was valid) were not defined. Make those explicit and update references to be based on CXL r3.1. Reviewed-by: Fan Ni Signed-off-by: Jonathan Cameron Message-Id: <20240126121636.24611-5-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 17 ++++++++++------- hw/cxl/cxl-device-utils.c | 6 +++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 31d2afcd3d..9f51c586d7 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -189,7 +189,7 @@ typedef struct cxl_device_state { }; }; - /* mmio for the mailbox registers 8.2.8.4 */ + /* CXL r3.1 Section 8.2.8.4: Mailbox Registers */ struct { MemoryRegion mailbox; uint16_t payload_size; @@ -310,39 +310,42 @@ void cxl_initialize_t3_ld_cci(CXLCCI *cci, DeviceState *d, REG64(CXL_DEV_EVENT_STATUS, 0) FIELD(CXL_DEV_EVENT_STATUS, EVENT_STATUS, 0, 32) -/* CXL 2.0 8.2.8.4.3 Mailbox Capabilities Register */ +#define CXL_DEV_MAILBOX_VERSION 1 +/* CXL r3.1 Section 8.2.8.4.3: Mailbox Capabilities Register */ REG32(CXL_DEV_MAILBOX_CAP, 0) FIELD(CXL_DEV_MAILBOX_CAP, PAYLOAD_SIZE, 0, 5) FIELD(CXL_DEV_MAILBOX_CAP, INT_CAP, 5, 1) FIELD(CXL_DEV_MAILBOX_CAP, BG_INT_CAP, 6, 1) FIELD(CXL_DEV_MAILBOX_CAP, MSI_N, 7, 4) + FIELD(CXL_DEV_MAILBOX_CAP, MBOX_READY_TIME, 11, 8) + FIELD(CXL_DEV_MAILBOX_CAP, TYPE, 19, 4) -/* CXL 2.0 8.2.8.4.4 Mailbox Control Register */ +/* CXL r3.1 Section 8.2.8.4.4: Mailbox Control Register */ REG32(CXL_DEV_MAILBOX_CTRL, 4) FIELD(CXL_DEV_MAILBOX_CTRL, DOORBELL, 0, 1) FIELD(CXL_DEV_MAILBOX_CTRL, INT_EN, 1, 1) FIELD(CXL_DEV_MAILBOX_CTRL, BG_INT_EN, 2, 1) -/* CXL 2.0 8.2.8.4.5 Command Register */ +/* CXL r3.1 Section 8.2.8.4.5: Command Register */ REG64(CXL_DEV_MAILBOX_CMD, 8) FIELD(CXL_DEV_MAILBOX_CMD, COMMAND, 0, 8) FIELD(CXL_DEV_MAILBOX_CMD, COMMAND_SET, 8, 8) FIELD(CXL_DEV_MAILBOX_CMD, LENGTH, 16, 20) -/* CXL 2.0 8.2.8.4.6 Mailbox Status Register */ +/* CXL r3.1 Section 8.2.8.4.6: Mailbox Status Register */ REG64(CXL_DEV_MAILBOX_STS, 0x10) FIELD(CXL_DEV_MAILBOX_STS, BG_OP, 0, 1) FIELD(CXL_DEV_MAILBOX_STS, ERRNO, 32, 16) FIELD(CXL_DEV_MAILBOX_STS, VENDOR_ERRNO, 48, 16) -/* CXL 2.0 8.2.8.4.7 Background Command Status Register */ +/* CXL r3.1 Section 8.2.8.4.7: Background Command Status Register */ REG64(CXL_DEV_BG_CMD_STS, 0x18) FIELD(CXL_DEV_BG_CMD_STS, OP, 0, 16) FIELD(CXL_DEV_BG_CMD_STS, PERCENTAGE_COMP, 16, 7) FIELD(CXL_DEV_BG_CMD_STS, RET_CODE, 32, 16) FIELD(CXL_DEV_BG_CMD_STS, VENDOR_RET_CODE, 48, 16) -/* CXL 2.0 8.2.8.4.8 Command Payload Registers */ +/* CXL r3.1 Section 8.2.8.4.8: Command Payload Registers */ REG32(CXL_DEV_CMD_PAYLOAD, 0x20) REG64(CXL_MEM_DEV_STS, 0) diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c index 40b619ffd9..9df8738f86 100644 --- a/hw/cxl/cxl-device-utils.c +++ b/hw/cxl/cxl-device-utils.c @@ -366,6 +366,10 @@ static void mailbox_reg_init_common(CXLDeviceState *cxl_dstate) ARRAY_FIELD_DP32(cxl_dstate->mbox_reg_state32, CXL_DEV_MAILBOX_CAP, MSI_N, msi_n); cxl_dstate->mbox_msi_n = msi_n; + ARRAY_FIELD_DP32(cxl_dstate->mbox_reg_state32, CXL_DEV_MAILBOX_CAP, + MBOX_READY_TIME, 0); /* Not reported */ + ARRAY_FIELD_DP32(cxl_dstate->mbox_reg_state32, CXL_DEV_MAILBOX_CAP, + TYPE, 0); /* Inferred from class code */ } static void memdev_reg_init_common(CXLDeviceState *cxl_dstate) @@ -392,7 +396,7 @@ void cxl_device_register_init_t3(CXLType3Dev *ct3d) cxl_device_cap_init(cxl_dstate, DEVICE_STATUS, 1, 2); device_reg_init_common(cxl_dstate); - cxl_device_cap_init(cxl_dstate, MAILBOX, 2, 1); + cxl_device_cap_init(cxl_dstate, MAILBOX, 2, CXL_DEV_MAILBOX_VERSION); mailbox_reg_init_common(cxl_dstate); cxl_device_cap_init(cxl_dstate, MEMORY_DEVICE, 0x4000, 1); From patchwork Wed Feb 14 11:16:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Bqwkcc6t; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbPw5Kzvz23y6 for ; Wed, 14 Feb 2024 22:22:12 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFT-0005ld-Kj; Wed, 14 Feb 2024 06:16:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFO-0005cc-41 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFJ-0007Oi-U4 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=N2Fy7C90mQ0ERPj+zUleNb8jOASiAWlxxZfrJZwybPk=; b=Bqwkcc6tS71xdWOee6KjYRcYRfj3xc9hSrSOdOigINqSrB+2/tsSzGA+orCIsVGoBmRCWO 5DRaAXxyq7d5TyoysWDDZNejA+c8hB68MYViRpYFCb1ECT7Hg8NxnI1Ln9VnzsGkg3672r S72my6m7AuOX4yTL060I6Zwo7sel1/A= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-284-gXU18v20Onq8ifCT-wqY9Q-1; Wed, 14 Feb 2024 06:16:07 -0500 X-MC-Unique: gXU18v20Onq8ifCT-wqY9Q-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-5621455776fso941546a12.0 for ; Wed, 14 Feb 2024 03:16:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909366; x=1708514166; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=N2Fy7C90mQ0ERPj+zUleNb8jOASiAWlxxZfrJZwybPk=; b=VKM+kDEESdUF/E/V0fljsDzKR7FFvYgMa7iywIpjsuQP11U6MQQV7nCX1EInHyXdt2 zTP6D2x9fyf2NmGIcUq1Jzara7Mz6/TRbD4fA/Foc9MGoYVJMRUP+6N3dSua0NafykYe ZABKVaq5avRkOZlkTlmPYF4np6qPxMCwApyJjiAMe0J42fetB/1MwsF4d/u28oH9E22b FDV6kgIsJk3euxgFVVuuw3knduIxGvRV6VoJHEeRiPsjuqTx7uzTaTz2Py2uuZjuyoIo URlFt+Pzx9nmLdNkg3iYF8lTfV8tpFm1blalYG2TrSpiF1cOL38ttQXqNM9CleSr1ZZ6 Itvw== X-Gm-Message-State: AOJu0YzmmyEIf7xfn32dquCLETaO5h6OnXca27UGEFKGNHFRlOcRXPwx L+vTd+e/6m3hPzAMnr+iWegJ82GizJOD3tU9wVbu/jeyefart2KjHgj7Ww0IYzLjBLbC6X2b320 NWQYCzQQpQvxvA8dMDJZ5NM/Pc2mO8ye9VhhTitHoXJ9KbbiIvSAYNBmLdsJnWDqNo33XV10bMO n4SXc0OfQiVw6iCyXZkC98EBDJF1oZdg== X-Received: by 2002:a05:6402:22ca:b0:562:9e4f:6bd1 with SMTP id dm10-20020a05640222ca00b005629e4f6bd1mr1067624edb.9.1707909365644; Wed, 14 Feb 2024 03:16:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFt6oiEKAwiv5l5VAXXM5lKgT5yG3ZH/VZmxaBeO1PRIa7N2fmC93eAx1rJ17PlX4ZThGT1fQ== X-Received: by 2002:a05:6402:22ca:b0:562:9e4f:6bd1 with SMTP id dm10-20020a05640222ca00b005629e4f6bd1mr1067598edb.9.1707909364903; Wed, 14 Feb 2024 03:16:04 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWaaKcJVOQm0NzdnZnElOBi1WFsBu5bpfG4PIT+CLRybRCY6fHxnM8MmRtLSLeQio9JLkTaA0LaUayS+O+zSWz9hzzbhPzdqBhRI7Afo0uG0ppPBXmJBZAn+xrBV7g9HbCkrlU2ZzUgRZXqZjXhEd7giURyznnQWWmFwUM= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id c3-20020a50d643000000b0056022d78141sm4884035edj.56.2024.02.14.03.16.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:16:04 -0800 (PST) Date: Wed, 14 Feb 2024 06:16:01 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Fan Ni , Marcel Apfelbaum Subject: [PULL 53/60] hw/cxl: Standardize all references on CXL r3.1 and minor updates Message-ID: <8700ee15de465a55e5c7281f87618ca4b4827441.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jonathan Cameron Previously not all references mentioned any spec version at all. Given r3.1 is the current specification available for evaluation at www.computeexpresslink.org update references to refer to that. Hopefully this won't become a never ending job. A few structure definitions have been updated to add new fields. Defaults of 0 and read only are valid choices for these new DVSEC registers so go with that for now. There are additional error codes and some of the 'questions' in the comments are resolved now. Update documentation reference to point to the CXL r3.1 specification with naming closer to what is on the cover. For cases where there are structure version numbers, add defines so they can be found next to the register definitions. Signed-off-by: Jonathan Cameron Message-Id: <20240126121636.24611-6-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_cdat.h | 10 ++--- include/hw/cxl/cxl_component.h | 26 ++++++++----- include/hw/cxl/cxl_device.h | 60 +++++++++++++++++++++--------- include/hw/cxl/cxl_events.h | 18 ++++----- include/hw/cxl/cxl_pci.h | 67 ++++++++++++++++++++++++---------- hw/cxl/cxl-component-utils.c | 17 +++++---- hw/cxl/cxl-device-utils.c | 8 ++-- hw/cxl/cxl-events.c | 2 +- hw/cxl/cxl-mailbox-utils.c | 49 ++++++++++++++----------- hw/mem/cxl_type3.c | 6 +-- hw/pci-bridge/cxl_downstream.c | 4 +- hw/pci-bridge/cxl_root_port.c | 4 +- hw/pci-bridge/cxl_upstream.c | 4 +- docs/system/devices/cxl.rst | 3 +- 14 files changed, 174 insertions(+), 104 deletions(-) diff --git a/include/hw/cxl/cxl_cdat.h b/include/hw/cxl/cxl_cdat.h index 7f67638685..8e3d094608 100644 --- a/include/hw/cxl/cxl_cdat.h +++ b/include/hw/cxl/cxl_cdat.h @@ -16,17 +16,17 @@ /* * Reference: * Coherent Device Attribute Table (CDAT) Specification, Rev. 1.03, July. 2022 - * Compute Express Link (CXL) Specification, Rev. 3.0, Aug. 2022 + * Compute Express Link (CXL) Specification, Rev. 3.1, Aug. 2023 */ -/* Table Access DOE - CXL r3.0 8.1.11 */ +/* Table Access DOE - CXL r3.1 8.1.11 */ #define CXL_DOE_TABLE_ACCESS 2 #define CXL_DOE_PROTOCOL_CDAT ((CXL_DOE_TABLE_ACCESS << 16) | CXL_VENDOR_ID) -/* Read Entry - CXL r3.0 8.1.11.1 */ +/* Read Entry - CXL r3.1 8.1.11.1 */ #define CXL_DOE_TAB_TYPE_CDAT 0 #define CXL_DOE_TAB_ENT_MAX 0xFFFF -/* Read Entry Request - CXL r3.0 8.1.11.1 Table 8-13 */ +/* Read Entry Request - CXL r3.1 8.1.11.1 Table 8-13 */ #define CXL_DOE_TAB_REQ 0 typedef struct CDATReq { DOEHeader header; @@ -35,7 +35,7 @@ typedef struct CDATReq { uint16_t entry_handle; } QEMU_PACKED CDATReq; -/* Read Entry Response - CXL r3.0 8.1.11.1 Table 8-14 */ +/* Read Entry Response - CXL r3.1 8.1.11.1 Table 8-14 */ #define CXL_DOE_TAB_RSP 0 typedef struct CDATRsp { DOEHeader header; diff --git a/include/hw/cxl/cxl_component.h b/include/hw/cxl/cxl_component.h index b5da72b789..0e5d35c263 100644 --- a/include/hw/cxl/cxl_component.h +++ b/include/hw/cxl/cxl_component.h @@ -10,7 +10,7 @@ #ifndef CXL_COMPONENT_H #define CXL_COMPONENT_H -/* CXL 2.0 - 8.2.4 */ +/* CXL r3.1 Section 8.2.4: CXL.cache and CXL.mem Registers */ #define CXL2_COMPONENT_IO_REGION_SIZE 0x1000 #define CXL2_COMPONENT_CM_REGION_SIZE 0x1000 #define CXL2_COMPONENT_BLOCK_SIZE 0x10000 @@ -34,10 +34,11 @@ enum reg_type { * Capability registers are defined at the top of the CXL.cache/mem region and * are packed. For our purposes we will always define the caps in the same * order. - * CXL 2.0 - 8.2.5 Table 142 for details. + * CXL r3.1 Table 8-22: CXL_CAPABILITY_ID Assignment for details. */ -/* CXL 2.0 - 8.2.5.1 */ +/* CXL r3.1 Section 8.2.4.1: CXL Capability Header Register */ +#define CXL_CAPABILITY_VERSION 1 REG32(CXL_CAPABILITY_HEADER, 0) FIELD(CXL_CAPABILITY_HEADER, ID, 0, 16) FIELD(CXL_CAPABILITY_HEADER, VERSION, 16, 4) @@ -102,12 +103,13 @@ REG32(CXL_RAS_ERR_HEADER0, CXL_RAS_REGISTERS_OFFSET + 0x18) #define CXL_RAS_ERR_HEADER_NUM 32 /* Offset 0x18 - 0x58 reserved for RAS logs */ -/* 8.2.5.10 - CXL Security Capability Structure */ +/* CXL r3.1 Section 8.2.4.18: CXL Security Capability Structure */ #define CXL_SEC_REGISTERS_OFFSET \ (CXL_RAS_REGISTERS_OFFSET + CXL_RAS_REGISTERS_SIZE) #define CXL_SEC_REGISTERS_SIZE 0 /* We don't implement 1.1 downstream ports */ /* CXL r3.1 Section 8.2.4.19: CXL Link Capability Structure */ +#define CXL_LINK_CAPABILITY_VERSION 2 #define CXL_LINK_REGISTERS_OFFSET \ (CXL_SEC_REGISTERS_OFFSET + CXL_SEC_REGISTERS_SIZE) #define CXL_LINK_REGISTERS_SIZE 0x50 @@ -175,18 +177,24 @@ HDM_DECODER_INIT(1); HDM_DECODER_INIT(2); HDM_DECODER_INIT(3); -/* 8.2.5.13 - CXL Extended Security Capability Structure (Root complex only) */ +/* + * CXL r3.1 Section 8.2.4.21: CXL Extended Security Capability Structure + * (Root complex only) + */ #define EXTSEC_ENTRY_MAX 256 +#define CXL_EXTSEC_CAP_VERSION 2 #define CXL_EXTSEC_REGISTERS_OFFSET \ (CXL_HDM_REGISTERS_OFFSET + CXL_HDM_REGISTERS_SIZE) #define CXL_EXTSEC_REGISTERS_SIZE (8 * EXTSEC_ENTRY_MAX + 4) -/* 8.2.5.14 - CXL IDE Capability Structure */ +/* CXL r3.1 Section 8.2.4.22: CXL IDE Capability Structure */ +#define CXL_IDE_CAP_VERSION 2 #define CXL_IDE_REGISTERS_OFFSET \ (CXL_EXTSEC_REGISTERS_OFFSET + CXL_EXTSEC_REGISTERS_SIZE) -#define CXL_IDE_REGISTERS_SIZE 0x20 +#define CXL_IDE_REGISTERS_SIZE 0x24 -/* 8.2.5.15 - CXL Snoop Filter Capability Structure */ +/* CXL r3.1 Section 8.2.4.23 - CXL Snoop Filter Capability Structure */ +#define CXL_SNOOP_CAP_VERSION 1 #define CXL_SNOOP_REGISTERS_OFFSET \ (CXL_IDE_REGISTERS_OFFSET + CXL_IDE_REGISTERS_SIZE) #define CXL_SNOOP_REGISTERS_SIZE 0x8 @@ -202,7 +210,7 @@ typedef struct component_registers { MemoryRegion component_registers; /* - * 8.2.4 Table 141: + * CXL r3.1 Table 8-21: CXL Subsystem Component Register Ranges * 0x0000 - 0x0fff CXL.io registers * 0x1000 - 0x1fff CXL.cache and CXL.mem * 0x2000 - 0xdfff Implementation specific diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 9f51c586d7..d8e184c4ba 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -58,18 +58,30 @@ * */ -#define CXL_DEVICE_CAP_HDR1_OFFSET 0x10 /* Figure 138 */ -#define CXL_DEVICE_CAP_REG_SIZE 0x10 /* 8.2.8.2 */ -#define CXL_DEVICE_CAPS_MAX 4 /* 8.2.8.2.1 + 8.2.8.5 */ +/* CXL r3.1 Figure 8-12: CXL Device Registers */ +#define CXL_DEVICE_CAP_HDR1_OFFSET 0x10 +/* CXL r3.1 Section 8.2.8.2: CXL Device Capability Header Register */ +#define CXL_DEVICE_CAP_REG_SIZE 0x10 + +/* + * CXL r3.1 Section 8.2.8.2.1: CXL Device Capabilities + + * CXL r3.1 Section 8.2.8.5: Memory Device Capabilities + */ +#define CXL_DEVICE_CAPS_MAX 4 #define CXL_CAPS_SIZE \ (CXL_DEVICE_CAP_REG_SIZE * (CXL_DEVICE_CAPS_MAX + 1)) /* +1 for header */ #define CXL_DEVICE_STATUS_REGISTERS_OFFSET 0x80 /* Read comment above */ -#define CXL_DEVICE_STATUS_REGISTERS_LENGTH 0x8 /* 8.2.8.3.1 */ +/* + * CXL r3.1 Section 8.2.8.3: Device Status Registers + * As it is the only Device Status Register in CXL r3.1 + */ +#define CXL_DEVICE_STATUS_REGISTERS_LENGTH 0x8 #define CXL_MAILBOX_REGISTERS_OFFSET \ (CXL_DEVICE_STATUS_REGISTERS_OFFSET + CXL_DEVICE_STATUS_REGISTERS_LENGTH) -#define CXL_MAILBOX_REGISTERS_SIZE 0x20 /* 8.2.8.4, Figure 139 */ +/* CXL r3.1 Figure 8-13: Mailbox Registers */ +#define CXL_MAILBOX_REGISTERS_SIZE 0x20 #define CXL_MAILBOX_PAYLOAD_SHIFT 11 #define CXL_MAILBOX_MAX_PAYLOAD_SIZE (1 << CXL_MAILBOX_PAYLOAD_SHIFT) #define CXL_MAILBOX_REGISTERS_LENGTH \ @@ -83,7 +95,7 @@ (CXL_DEVICE_CAP_REG_SIZE + CXL_DEVICE_STATUS_REGISTERS_LENGTH + \ CXL_MAILBOX_REGISTERS_LENGTH + CXL_MEMORY_DEVICE_REGISTERS_LENGTH) -/* 8.2.8.4.5.1 Command Return Codes */ +/* CXL r3.1 Table 8-34: Command Return Codes */ typedef enum { CXL_MBOX_SUCCESS = 0x0, CXL_MBOX_BG_STARTED = 0x1, @@ -108,7 +120,17 @@ typedef enum { CXL_MBOX_INCORRECT_PASSPHRASE = 0x14, CXL_MBOX_UNSUPPORTED_MAILBOX = 0x15, CXL_MBOX_INVALID_PAYLOAD_LENGTH = 0x16, - CXL_MBOX_MAX = 0x17 + CXL_MBOX_INVALID_LOG = 0x17, + CXL_MBOX_INTERRUPTED = 0x18, + CXL_MBOX_UNSUPPORTED_FEATURE_VERSION = 0x19, + CXL_MBOX_UNSUPPORTED_FEATURE_SELECTION_VALUE = 0x1a, + CXL_MBOX_FEATURE_TRANSFER_IN_PROGRESS = 0x1b, + CXL_MBOX_FEATURE_TRANSFER_OUT_OF_ORDER = 0x1c, + CXL_MBOX_RESOURCES_EXHAUSTED = 0x1d, + CXL_MBOX_INVALID_EXTENT_LIST = 0x1e, + CXL_MBOX_TRANSFER_OUT_OF_ORDER = 0x1f, + CXL_MBOX_REQUEST_ABORT_NOTSUP = 0x20, + CXL_MBOX_MAX = 0x20 } CXLRetCode; typedef struct CXLCCI CXLCCI; @@ -169,7 +191,7 @@ typedef struct CXLCCI { typedef struct cxl_device_state { MemoryRegion device_registers; - /* mmio for device capabilities array - 8.2.8.2 */ + /* CXL r3.1 Section 8.2.8.3: Device Status Registers */ struct { MemoryRegion device; union { @@ -231,7 +253,7 @@ void cxl_device_register_init_t3(CXLType3Dev *ct3d); void cxl_device_register_init_swcci(CSWMBCCIDev *sw); /* - * CXL 2.0 - 8.2.8.1 including errata F4 + * CXL r3.1 Section 8.2.8.1: CXL Device Capabilities Array Register * Documented as a 128 bit register, but 64 bit accesses and the second * 64 bits are currently reserved. */ @@ -246,17 +268,18 @@ void cxl_event_set_status(CXLDeviceState *cxl_dstate, CXLEventLogType log_type, /* * Helper macro to initialize capability headers for CXL devices. * - * In the 8.2.8.2, this is listed as a 128b register, but in 8.2.8, it says: + * In CXL r3.1 Section 8.2.8.2: CXL Device Capablity Header Register, this is + * listed as a 128b register, but in CXL r3.1 Section 8.2.8: CXL Device Register + * Interface, it says: * > No registers defined in Section 8.2.8 are larger than 64-bits wide so that * > is the maximum access size allowed for these registers. If this rule is not - * > followed, the behavior is undefined + * > followed, the behavior is undefined. * - * CXL 2.0 Errata F4 states further that the layouts in the specification are - * shown as greater than 128 bits, but implementations are expected to - * use any size of access up to 64 bits. + * > To illustrate how the fields fit together, the layouts ... are shown as + * > wider than a 64 bit register. Implemenations are expected to use any size + * > accesses for this information up to 64 bits without lost of functionality * - * Here we've chosen to make it 4 dwords. The spec allows any pow2 multiple - * access to be used for a register up to 64 bits. + * Here we've chosen to make it 4 dwords. */ #define CXL_DEVICE_CAPABILITY_HEADER_REGISTER(n, offset) \ REG32(CXL_DEV_##n##_CAP_HDR0, offset) \ @@ -306,7 +329,8 @@ void cxl_initialize_t3_ld_cci(CXLCCI *cci, DeviceState *d, CAP_LENGTH, CXL_##reg##_REGISTERS_LENGTH); \ } while (0) -/* CXL 3.0 8.2.8.3.1 Event Status Register */ +/* CXL r3.2 Section 8.2.8.3.1: Event Status Register */ +#define CXL_DEVICE_STATUS_VERSION 2 REG64(CXL_DEV_EVENT_STATUS, 0) FIELD(CXL_DEV_EVENT_STATUS, EVENT_STATUS, 0, 32) @@ -348,6 +372,8 @@ REG64(CXL_DEV_BG_CMD_STS, 0x18) /* CXL r3.1 Section 8.2.8.4.8: Command Payload Registers */ REG32(CXL_DEV_CMD_PAYLOAD, 0x20) +/* CXL r3.1 Section 8.2.8.4.1: Memory Device Status Registers */ +#define CXL_MEM_DEV_STATUS_VERSION 1 REG64(CXL_MEM_DEV_STS, 0) FIELD(CXL_MEM_DEV_STS, FATAL, 0, 1) FIELD(CXL_MEM_DEV_STS, FW_HALT, 1, 1) diff --git a/include/hw/cxl/cxl_events.h b/include/hw/cxl/cxl_events.h index d778487b7e..5170b8dbf8 100644 --- a/include/hw/cxl/cxl_events.h +++ b/include/hw/cxl/cxl_events.h @@ -13,7 +13,7 @@ #include "qemu/uuid.h" /* - * CXL rev 3.0 section 8.2.9.2.2; Table 8-49 + * CXL r3.1 section 8.2.9.2.2: Get Event Records (Opcode 0100h); Table 8-52 * * Define these as the bit position for the event status register for ease of * setting the status. @@ -29,7 +29,7 @@ typedef enum CXLEventLogType { /* * Common Event Record Format - * CXL rev 3.0 section 8.2.9.2.1; Table 8-42 + * CXL r3.1 section 8.2.9.2.1: Event Records; Table 8-43 */ #define CXL_EVENT_REC_HDR_RES_LEN 0xf typedef struct CXLEventRecordHdr { @@ -52,7 +52,7 @@ typedef struct CXLEventRecordRaw { /* * Get Event Records output payload - * CXL rev 3.0 section 8.2.9.2.2; Table 8-50 + * CXL r3.1 section 8.2.9.2.2; Table 8-53 */ #define CXL_GET_EVENT_FLAG_OVERFLOW BIT(0) #define CXL_GET_EVENT_FLAG_MORE_RECORDS BIT(1) @@ -70,7 +70,7 @@ typedef struct CXLGetEventPayload { /* * Clear Event Records input payload - * CXL rev 3.0 section 8.2.9.2.3; Table 8-51 + * CXL r3.1 section 8.2.9.2.3; Table 8-54 */ typedef struct CXLClearEventPayload { uint8_t event_log; /* CXLEventLogType */ @@ -80,10 +80,10 @@ typedef struct CXLClearEventPayload { uint16_t handle[]; } CXLClearEventPayload; -/** +/* * Event Interrupt Policy * - * CXL rev 3.0 section 8.2.9.2.4; Table 8-52 + * CXL r3.1 section 8.2.9.2.4; Table 8-55 */ typedef enum CXLEventIntMode { CXL_INT_NONE = 0x00, @@ -106,7 +106,7 @@ typedef struct CXLEventInterruptPolicy { /* * General Media Event Record - * CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43 + * CXL r3.1 Section 8.2.9.2.1.1; Table 8-45 */ #define CXL_EVENT_GEN_MED_COMP_ID_SIZE 0x10 #define CXL_EVENT_GEN_MED_RES_SIZE 0x2e @@ -126,7 +126,7 @@ typedef struct CXLEventGenMedia { /* * DRAM Event Record - * CXL Rev 3.0 Section 8.2.9.2.1.2: Table 8-44 + * CXL r3.1 Section 8.2.9.2.1.2: Table 8-46 * All fields little endian. */ typedef struct CXLEventDram { @@ -149,7 +149,7 @@ typedef struct CXLEventDram { /* * Memory Module Event Record - * CXL Rev 3.0 Section 8.2.9.2.1.3: Table 8-45 + * CXL r3.1 Section 8.2.9.2.1.3: Table 8-47 * All fields little endian. */ typedef struct CXLEventMemoryModule { diff --git a/include/hw/cxl/cxl_pci.h b/include/hw/cxl/cxl_pci.h index ddf01a543b..265db6c407 100644 --- a/include/hw/cxl/cxl_pci.h +++ b/include/hw/cxl/cxl_pci.h @@ -16,9 +16,8 @@ #define PCIE_DVSEC_HEADER1_OFFSET 0x4 /* Offset from start of extend cap */ #define PCIE_DVSEC_ID_OFFSET 0x8 -#define PCIE_CXL_DEVICE_DVSEC_LENGTH 0x38 -#define PCIE_CXL1_DEVICE_DVSEC_REVID 0 -#define PCIE_CXL2_DEVICE_DVSEC_REVID 1 +#define PCIE_CXL_DEVICE_DVSEC_LENGTH 0x3C +#define PCIE_CXL31_DEVICE_DVSEC_REVID 3 #define EXTENSIONS_PORT_DVSEC_LENGTH 0x28 #define EXTENSIONS_PORT_DVSEC_REVID 0 @@ -29,8 +28,8 @@ #define GPF_DEVICE_DVSEC_LENGTH 0x10 #define GPF_DEVICE_DVSEC_REVID 0 -#define PCIE_FLEXBUS_PORT_DVSEC_LENGTH_2_0 0x14 -#define PCIE_FLEXBUS_PORT_DVSEC_REVID_2_0 1 +#define PCIE_CXL3_FLEXBUS_PORT_DVSEC_LENGTH 0x20 +#define PCIE_CXL3_FLEXBUS_PORT_DVSEC_REVID 2 #define REG_LOC_DVSEC_LENGTH 0x24 #define REG_LOC_DVSEC_REVID 0 @@ -55,16 +54,26 @@ typedef struct DVSECHeader { QEMU_BUILD_BUG_ON(sizeof(DVSECHeader) != 10); /* - * CXL 2.0 devices must implement certain DVSEC IDs, and can [optionally] + * CXL r3.1 Table 8-2: CXL DVSEC ID Assignment + * Devices must implement certain DVSEC IDs, and can [optionally] * implement others. + * (x) - IDs in Table 8-2. * - * CXL 2.0 Device: 0, [2], 5, 8 - * CXL 2.0 RP: 3, 4, 7, 8 - * CXL 2.0 Upstream Port: [2], 7, 8 - * CXL 2.0 Downstream Port: 3, 4, 7, 8 + * CXL RCD (D1): 0, [2], [5], 7, [8], A - Not emulated yet + * CXL RCD USP (UP1): 7, [8] - Not emulated yet + * CXL RCH DSP (DP1): 7, [8] + * CXL SLD (D2): 0, [2], 5, 7, 8, [A] + * CXL LD (LD): 0, [2], 5, 7, 8 + * CXL RP (R): 3, 4, 7, 8 + * CXL Switch USP (USP): [2], 7, 8 + * CXL Switch DSP (DSP): 3, 4, 7, 8 + * FM-Owned LD (FMLD): 0, [2], 7, 8, 9 */ -/* CXL 2.0 - 8.1.3 (ID 0001) */ +/* + * CXL r3.1 Section 8.1.3: PCIe DVSEC for Devices + * DVSEC ID: 0, Revision: 3 + */ typedef struct CXLDVSECDevice { DVSECHeader hdr; uint16_t cap; @@ -82,10 +91,14 @@ typedef struct CXLDVSECDevice { uint32_t range2_size_lo; uint32_t range2_base_hi; uint32_t range2_base_lo; -} CXLDVSECDevice; -QEMU_BUILD_BUG_ON(sizeof(CXLDVSECDevice) != 0x38); + uint16_t cap3; +} QEMU_PACKED CXLDVSECDevice; +QEMU_BUILD_BUG_ON(sizeof(CXLDVSECDevice) != 0x3A); -/* CXL 2.0 - 8.1.5 (ID 0003) */ +/* + * CXL r3.1 Section 8.1.5: CXL Extensions DVSEC for Ports + * DVSEC ID: 3, Revision: 0 + */ typedef struct CXLDVSECPortExt { DVSECHeader hdr; uint16_t status; @@ -107,7 +120,10 @@ QEMU_BUILD_BUG_ON(sizeof(CXLDVSECPortExt) != 0x28); #define PORT_CONTROL_UNMASK_SBR 1 #define PORT_CONTROL_ALT_MEMID_EN 4 -/* CXL 2.0 - 8.1.6 GPF DVSEC (ID 0004) */ +/* + * CXL r3.1 Section 8.1.6: GPF DVSEC for CXL Port + * DVSEC ID: 4, Revision: 0 + */ typedef struct CXLDVSECPortGPF { DVSECHeader hdr; uint16_t rsvd; @@ -116,7 +132,10 @@ typedef struct CXLDVSECPortGPF { } CXLDVSECPortGPF; QEMU_BUILD_BUG_ON(sizeof(CXLDVSECPortGPF) != 0x10); -/* CXL 2.0 - 8.1.7 GPF DVSEC for CXL Device */ +/* + * CXL r3.1 Section 8.1.7: GPF DVSEC for CXL Device + * DVSEC ID: 5, Revision 0 + */ typedef struct CXLDVSECDeviceGPF { DVSECHeader hdr; uint16_t phase2_duration; @@ -124,17 +143,27 @@ typedef struct CXLDVSECDeviceGPF { } CXLDVSECDeviceGPF; QEMU_BUILD_BUG_ON(sizeof(CXLDVSECDeviceGPF) != 0x10); -/* CXL 2.0 - 8.1.8/8.2.1.3 Flex Bus DVSEC (ID 0007) */ +/* + * CXL r3.1 Section 8.1.8: PCIe DVSEC for Flex Bus Port + * CXL r3.1 Section 8.2.1.3: Flex Bus Port DVSEC + * DVSEC ID: 7, Revision 2 + */ typedef struct CXLDVSECPortFlexBus { DVSECHeader hdr; uint16_t cap; uint16_t ctrl; uint16_t status; uint32_t rcvd_mod_ts_data_phase1; + uint32_t cap2; + uint32_t ctrl2; + uint32_t status2; } CXLDVSECPortFlexBus; -QEMU_BUILD_BUG_ON(sizeof(CXLDVSECPortFlexBus) != 0x14); +QEMU_BUILD_BUG_ON(sizeof(CXLDVSECPortFlexBus) != 0x20); -/* CXL 2.0 - 8.1.9 Register Locator DVSEC (ID 0008) */ +/* + * CXL r3.1 Section 8.1.9: Register Locator DVSEC + * DVSEC ID: 8, Revision 0 + */ typedef struct CXLDVSECRegisterLocator { DVSECHeader hdr; uint16_t rsvd; diff --git a/hw/cxl/cxl-component-utils.c b/hw/cxl/cxl-component-utils.c index 848bfa20f1..84ab503325 100644 --- a/hw/cxl/cxl-component-utils.c +++ b/hw/cxl/cxl-component-utils.c @@ -13,7 +13,7 @@ #include "hw/pci/pci.h" #include "hw/cxl/cxl.h" -/* CXL r3.0 Section 8.2.4.19.1 CXL HDM Decoder Capability Register */ +/* CXL r3.1 Section 8.2.4.20.1 CXL HDM Decoder Capability Register */ int cxl_decoder_count_enc(int count) { switch (count) { @@ -160,11 +160,11 @@ static void cxl_cache_mem_write_reg(void *opaque, hwaddr offset, uint64_t value, } /* - * 8.2.3 + * CXL r3.1 Section 8.2.3: Component Register Layout and Definition * The access restrictions specified in Section 8.2.2 also apply to CXL 2.0 * Component Registers. * - * 8.2.2 + * CXL r3.1 Section 8.2.2: Accessing Component Registers * . A 32 bit register shall be accessed as a 4 Bytes quantity. Partial * reads are not permitted. * . A 64 bit register shall be accessed as a 8 Bytes quantity. Partial @@ -308,7 +308,8 @@ void cxl_component_register_init_common(uint32_t *reg_state, /* CXL Capability Header Register */ ARRAY_FIELD_DP32(reg_state, CXL_CAPABILITY_HEADER, ID, 1); - ARRAY_FIELD_DP32(reg_state, CXL_CAPABILITY_HEADER, VERSION, 1); + ARRAY_FIELD_DP32(reg_state, CXL_CAPABILITY_HEADER, VERSION, + CXL_CAPABILITY_VERSION); ARRAY_FIELD_DP32(reg_state, CXL_CAPABILITY_HEADER, CACHE_MEM_VERSION, 1); ARRAY_FIELD_DP32(reg_state, CXL_CAPABILITY_HEADER, ARRAY_SIZE, caps); @@ -328,7 +329,7 @@ void cxl_component_register_init_common(uint32_t *reg_state, init_cap_reg(RAS, 2, CXL_RAS_CAPABILITY_VERSION); ras_init_common(reg_state, write_msk); - init_cap_reg(LINK, 4, 2); + init_cap_reg(LINK, 4, CXL_LINK_CAPABILITY_VERSION); if (caps < 3) { return; @@ -341,8 +342,8 @@ void cxl_component_register_init_common(uint32_t *reg_state, return; } - init_cap_reg(EXTSEC, 6, 1); - init_cap_reg(SNOOP, 8, 1); + init_cap_reg(EXTSEC, 6, CXL_EXTSEC_CAP_VERSION); + init_cap_reg(SNOOP, 8, CXL_SNOOP_CAP_VERSION); #undef init_cap_reg } @@ -467,7 +468,7 @@ void cxl_component_create_dvsec(CXLComponentState *cxl, cxl->dvsec_offset += length; } -/* CXL r3.0 Section 8.2.4.19.7 CXL HDM Decoder n Control Register */ +/* CXL r3.1 Section 8.2.4.20.7 CXL HDM Decoder n Control Register */ uint8_t cxl_interleave_ways_enc(int iw, Error **errp) { switch (iw) { diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c index 9df8738f86..035d034f6d 100644 --- a/hw/cxl/cxl-device-utils.c +++ b/hw/cxl/cxl-device-utils.c @@ -13,7 +13,7 @@ /* * Device registers have no restrictions per the spec, and so fall back to the - * default memory mapped register rules in 8.2: + * default memory mapped register rules in CXL r3.1 Section 8.2: * Software shall use CXL.io Memory Read and Write to access memory mapped * register defined in this section. Unless otherwise specified, software * shall restrict the accesses width based on the following: @@ -393,13 +393,15 @@ void cxl_device_register_init_t3(CXLType3Dev *ct3d) ARRAY_FIELD_DP64(cap_h, CXL_DEV_CAP_ARRAY, CAP_VERSION, 1); ARRAY_FIELD_DP64(cap_h, CXL_DEV_CAP_ARRAY, CAP_COUNT, cap_count); - cxl_device_cap_init(cxl_dstate, DEVICE_STATUS, 1, 2); + cxl_device_cap_init(cxl_dstate, DEVICE_STATUS, 1, + CXL_DEVICE_STATUS_VERSION); device_reg_init_common(cxl_dstate); cxl_device_cap_init(cxl_dstate, MAILBOX, 2, CXL_DEV_MAILBOX_VERSION); mailbox_reg_init_common(cxl_dstate); - cxl_device_cap_init(cxl_dstate, MEMORY_DEVICE, 0x4000, 1); + cxl_device_cap_init(cxl_dstate, MEMORY_DEVICE, 0x4000, + CXL_MEM_DEV_STATUS_VERSION); memdev_reg_init_common(cxl_dstate); cxl_initialize_mailbox_t3(&ct3d->cci, DEVICE(ct3d), diff --git a/hw/cxl/cxl-events.c b/hw/cxl/cxl-events.c index affcf8a34d..d397718b1b 100644 --- a/hw/cxl/cxl-events.c +++ b/hw/cxl/cxl-events.c @@ -204,7 +204,7 @@ CXLRetCode cxl_event_clear_records(CXLDeviceState *cxlds, * record that will not be cleared when Clear Event Records is executed, * the device shall return the Invalid Handle return code and shall not * clear any of the specified event records." - * -- CXL 3.0 8.2.9.2.3 + * -- CXL r3.1 Section 8.2.9.2.3: Clear Event Records (0101h) */ entry = cxl_event_get_head(log); for (nr = 0; entry && nr < pl->nr_recs; nr++) { diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index dc42850767..e5eb97cb91 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -86,7 +86,7 @@ enum { #define MANAGEMENT_COMMAND 0x0 }; -/* CCI Message Format CXL r3.0 Figure 7-19 */ +/* CCI Message Format CXL r3.1 Figure 7-19 */ typedef struct CXLCCIMessage { uint8_t category; #define CXL_CCI_CAT_REQ 0 @@ -342,7 +342,7 @@ static CXLRetCode cmd_events_set_interrupt_policy(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } -/* CXL r3.0 section 8.2.9.1.1: Identify (Opcode 0001h) */ +/* CXL r3.1 section 8.2.9.1.1: Identify (Opcode 0001h) */ static CXLRetCode cmd_infostat_identify(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, @@ -403,7 +403,7 @@ static void cxl_set_dsp_active_bm(PCIBus *b, PCIDevice *d, } } -/* CXL r3 8.2.9.1.1 */ +/* CXL r3.1 Section 7.6.7.1.1: Identify Switch Device (Opcode 5100h) */ static CXLRetCode cmd_identify_switch_device(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, @@ -455,7 +455,7 @@ static CXLRetCode cmd_identify_switch_device(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } -/* CXL r3.0 Section 7.6.7.1.2: Get Physical Port State (Opcode 5101h) */ +/* CXL r3.1 Section 7.6.7.1.2: Get Physical Port State (Opcode 5101h) */ static CXLRetCode cmd_get_physical_port_state(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, @@ -463,14 +463,14 @@ static CXLRetCode cmd_get_physical_port_state(const struct cxl_cmd *cmd, size_t *len_out, CXLCCI *cci) { - /* CXL r3.0 Table 7-18: Get Physical Port State Request Payload */ + /* CXL r3.1 Table 7-17: Get Physical Port State Request Payload */ struct cxl_fmapi_get_phys_port_state_req_pl { uint8_t num_ports; uint8_t ports[]; } QEMU_PACKED *in; /* - * CXL r3.0 Table 7-20: Get Physical Port State Port Information Block + * CXL r3.1 Table 7-19: Get Physical Port State Port Information Block * Format */ struct cxl_fmapi_port_state_info_block { @@ -491,7 +491,7 @@ static CXLRetCode cmd_get_physical_port_state(const struct cxl_cmd *cmd, uint8_t supported_ld_count; } QEMU_PACKED; - /* CXL r3.0 Table 7-19: Get Physical Port State Response Payload */ + /* CXL r3.1 Table 7-18: Get Physical Port State Response Payload */ struct cxl_fmapi_get_phys_port_state_resp_pl { uint8_t num_ports; uint8_t rsv1[3]; @@ -579,7 +579,7 @@ static CXLRetCode cmd_get_physical_port_state(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } -/* CXL r3.0 8.2.9.1.2 */ +/* CXL r3.1 Section 8.2.9.1.2: Background Operation Status (Opcode 0002h) */ static CXLRetCode cmd_infostat_bg_op_sts(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, @@ -609,7 +609,7 @@ static CXLRetCode cmd_infostat_bg_op_sts(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } -/* 8.2.9.2.1 */ +/* CXL r3.1 Section 8.2.9.3.1: Get FW Info (Opcode 0200h) */ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len, @@ -647,7 +647,7 @@ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } -/* 8.2.9.3.1 */ +/* CXL r3.1 Section 8.2.9.4.1: Get Timestamp (Opcode 0300h) */ static CXLRetCode cmd_timestamp_get(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, @@ -664,7 +664,7 @@ static CXLRetCode cmd_timestamp_get(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } -/* 8.2.9.3.2 */ +/* CXL r3.1 Section 8.2.9.4.2: Set Timestamp (Opcode 0301h) */ static CXLRetCode cmd_timestamp_set(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, @@ -683,13 +683,13 @@ static CXLRetCode cmd_timestamp_set(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } -/* CXL 3.0 8.2.9.5.2.1 Command Effects Log (CEL) */ +/* CXL r3.1 Section 8.2.9.5.2.1: Command Effects Log (CEL) */ static const QemuUUID cel_uuid = { .data = UUID(0x0da9c0b5, 0xbf41, 0x4b78, 0x8f, 0x79, 0x96, 0xb1, 0x62, 0x3b, 0x3f, 0x17) }; -/* 8.2.9.4.1 */ +/* CXL r3.1 Section 8.2.9.5.1: Get Supported Logs (Opcode 0400h) */ static CXLRetCode cmd_logs_get_supported(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, @@ -715,7 +715,7 @@ static CXLRetCode cmd_logs_get_supported(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } -/* 8.2.9.4.2 */ +/* CXL r3.1 Section 8.2.9.5.2: Get Log (Opcode 0401h) */ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, @@ -732,14 +732,11 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd *cmd, get_log = (void *)payload_in; /* - * 8.2.9.4.2 - * The device shall return Invalid Parameter if the Offset or Length + * CXL r3.1 Section 8.2.9.5.2: Get Log (Opcode 0401h) + * The device shall return Invalid Input if the Offset or Length * fields attempt to access beyond the size of the log as reported by Get * Supported Logs. * - * XXX: Spec is wrong, "Invalid Parameter" isn't a thing. - * XXX: Spec doesn't address incorrect UUID incorrectness. - * * The CEL buffer is large enough to fit all commands in the emulation, so * the only possible failure would be if the mailbox itself isn't big * enough. @@ -749,7 +746,7 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd *cmd, } if (!qemu_uuid_is_equal(&get_log->uuid, &cel_uuid)) { - return CXL_MBOX_UNSUPPORTED; + return CXL_MBOX_INVALID_LOG; } /* Store off everything to local variables so we can wipe out the payload */ @@ -760,7 +757,7 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } -/* 8.2.9.5.1.1 */ +/* CXL r3.1 Section 8.2.9.9.1.1: Identify Memory Device (Opcode 4000h) */ static CXLRetCode cmd_identify_memory_device(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, @@ -815,6 +812,7 @@ static CXLRetCode cmd_identify_memory_device(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } +/* CXL r3.1 Section 8.2.9.9.2.1: Get Partition Info (Opcode 4100h) */ static CXLRetCode cmd_ccls_get_partition_info(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, @@ -851,6 +849,7 @@ static CXLRetCode cmd_ccls_get_partition_info(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } +/* CXL r3.1 Section 8.2.9.9.2.3: Get LSA (Opcode 4102h) */ static CXLRetCode cmd_ccls_get_lsa(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, @@ -879,6 +878,7 @@ static CXLRetCode cmd_ccls_get_lsa(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } +/* CXL r3.1 Section 8.2.9.9.2.4: Set LSA (Opcode 4103h) */ static CXLRetCode cmd_ccls_set_lsa(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, @@ -940,7 +940,7 @@ static void __do_sanitization(CXLType3Dev *ct3d) } /* - * CXL 3.0 spec section 8.2.9.8.5.1 - Sanitize. + * CXL r3.1 Section 8.2.9.9.5.1: Sanitize (Opcode 4400h) * * Once the Sanitize command has started successfully, the device shall be * placed in the media disabled state. If the command fails or is interrupted @@ -1018,7 +1018,10 @@ static CXLRetCode cmd_get_security_state(const struct cxl_cmd *cmd, *len_out = 4; return CXL_MBOX_SUCCESS; } + /* + * CXL r3.1 Section 8.2.9.9.4.1: Get Poison List (Opcode 4300h) + * * This is very inefficient, but good enough for now! * Also the payload will always fit, so no need to handle the MORE flag and * make this stateful. We may want to allow longer poison lists to aid @@ -1103,6 +1106,7 @@ static CXLRetCode cmd_media_get_poison_list(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } +/* CXL r3.1 Section 8.2.9.9.4.2: Inject Poison (Opcode 4301h) */ static CXLRetCode cmd_media_inject_poison(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, @@ -1146,6 +1150,7 @@ static CXLRetCode cmd_media_inject_poison(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } +/* CXL r3.1 Section 8.2.9.9.4.3: Clear Poison (Opcode 4302h */ static CXLRetCode cmd_media_clear_poison(const struct cxl_cmd *cmd, uint8_t *payload_in, size_t len_in, diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 71fcb44613..e8801805b9 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -319,7 +319,7 @@ static void build_dvsecs(CXLType3Dev *ct3d) cxl_component_create_dvsec(cxl_cstate, CXL2_TYPE3_DEVICE, PCIE_CXL_DEVICE_DVSEC_LENGTH, PCIE_CXL_DEVICE_DVSEC, - PCIE_CXL2_DEVICE_DVSEC_REVID, dvsec); + PCIE_CXL31_DEVICE_DVSEC_REVID, dvsec); dvsec = (uint8_t *)&(CXLDVSECRegisterLocator){ .rsvd = 0, @@ -346,9 +346,9 @@ static void build_dvsecs(CXLType3Dev *ct3d) .rcvd_mod_ts_data_phase1 = 0xef, /* WTF? */ }; cxl_component_create_dvsec(cxl_cstate, CXL2_TYPE3_DEVICE, - PCIE_FLEXBUS_PORT_DVSEC_LENGTH_2_0, + PCIE_CXL3_FLEXBUS_PORT_DVSEC_LENGTH, PCIE_FLEXBUS_PORT_DVSEC, - PCIE_FLEXBUS_PORT_DVSEC_REVID_2_0, dvsec); + PCIE_CXL3_FLEXBUS_PORT_DVSEC_REVID, dvsec); } static void hdm_decoder_commit(CXLType3Dev *ct3d, int which) diff --git a/hw/pci-bridge/cxl_downstream.c b/hw/pci-bridge/cxl_downstream.c index 405a133eef..742da07a01 100644 --- a/hw/pci-bridge/cxl_downstream.c +++ b/hw/pci-bridge/cxl_downstream.c @@ -109,9 +109,9 @@ static void build_dvsecs(CXLComponentState *cxl) .rcvd_mod_ts_data_phase1 = 0xef, /* WTF? */ }; cxl_component_create_dvsec(cxl, CXL2_DOWNSTREAM_PORT, - PCIE_FLEXBUS_PORT_DVSEC_LENGTH_2_0, + PCIE_CXL3_FLEXBUS_PORT_DVSEC_LENGTH, PCIE_FLEXBUS_PORT_DVSEC, - PCIE_FLEXBUS_PORT_DVSEC_REVID_2_0, dvsec); + PCIE_CXL3_FLEXBUS_PORT_DVSEC_REVID, dvsec); dvsec = (uint8_t *)&(CXLDVSECPortGPF){ .rsvd = 0, diff --git a/hw/pci-bridge/cxl_root_port.c b/hw/pci-bridge/cxl_root_port.c index 8f97697631..62f96994eb 100644 --- a/hw/pci-bridge/cxl_root_port.c +++ b/hw/pci-bridge/cxl_root_port.c @@ -129,9 +129,9 @@ static void build_dvsecs(CXLComponentState *cxl) .rcvd_mod_ts_data_phase1 = 0xef, }; cxl_component_create_dvsec(cxl, CXL2_ROOT_PORT, - PCIE_FLEXBUS_PORT_DVSEC_LENGTH_2_0, + PCIE_CXL3_FLEXBUS_PORT_DVSEC_LENGTH, PCIE_FLEXBUS_PORT_DVSEC, - PCIE_FLEXBUS_PORT_DVSEC_REVID_2_0, dvsec); + PCIE_CXL3_FLEXBUS_PORT_DVSEC_REVID, dvsec); dvsec = (uint8_t *)&(CXLDVSECRegisterLocator){ .rsvd = 0, diff --git a/hw/pci-bridge/cxl_upstream.c b/hw/pci-bridge/cxl_upstream.c index d5341b530f..e87eb40177 100644 --- a/hw/pci-bridge/cxl_upstream.c +++ b/hw/pci-bridge/cxl_upstream.c @@ -121,9 +121,9 @@ static void build_dvsecs(CXLComponentState *cxl) .rcvd_mod_ts_data_phase1 = 0xef, /* WTF? */ }; cxl_component_create_dvsec(cxl, CXL2_UPSTREAM_PORT, - PCIE_FLEXBUS_PORT_DVSEC_LENGTH_2_0, + PCIE_CXL3_FLEXBUS_PORT_DVSEC_LENGTH, PCIE_FLEXBUS_PORT_DVSEC, - PCIE_FLEXBUS_PORT_DVSEC_REVID_2_0, dvsec); + PCIE_CXL3_FLEXBUS_PORT_DVSEC_REVID, dvsec); dvsec = (uint8_t *)&(CXLDVSECRegisterLocator){ .rsvd = 0, diff --git a/docs/system/devices/cxl.rst b/docs/system/devices/cxl.rst index 6ab5f72473..10a0e9bc9f 100644 --- a/docs/system/devices/cxl.rst +++ b/docs/system/devices/cxl.rst @@ -411,5 +411,4 @@ References - Consortium website for specifications etc: http://www.computeexpresslink.org - - Compute Express link Revision 2 specification, October 2020 - - CEDT CFMWS & QTG _DSM ECN May 2021 + - Compute Express Link (CXL) Specification, Revision 3.1, August 2023 From patchwork Wed Feb 14 11:16:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898852 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=e32kLoJh; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbLL7424z23hM for ; Wed, 14 Feb 2024 22:19:06 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFq-0006EE-IQ; Wed, 14 Feb 2024 06:16:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFN-0005bx-Mu for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFL-0007Ox-Uu for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909371; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YXqr7ST6Ul9FSSoAU3o419J9SGTE+jd0wE02/JUaNUI=; b=e32kLoJhCLYhcLABgfsqkcqTE1FWkOQxtHSOXFXHXHv+O2SbYhObTkN0LBlocL3DmJ32A5 nOu5KBXumBkExEDBzPhL/UJTnidWPEoYqK73RH3uMndh1VJySxp+Z/AFruuRi2od0tTTix qfJTwMHM6BqK4KWRTtv71YNFer7NC+M= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-683-F0fLAng-OcecVMHWt4HvIg-1; Wed, 14 Feb 2024 06:16:09 -0500 X-MC-Unique: F0fLAng-OcecVMHWt4HvIg-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a3d3e8f1635so32640766b.2 for ; Wed, 14 Feb 2024 03:16:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909368; x=1708514168; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YXqr7ST6Ul9FSSoAU3o419J9SGTE+jd0wE02/JUaNUI=; b=B9RUTub47WX6tOYslZo9yS6D1eFAh5EnUP7js9A3KvcI+EIwmNQ1d9AbHf3ftfgfzA 2j/TwVYZc9G5hcxN1wTXzyyHkWn9Vkwjjq5wimMpAccTd5vlsnZ88w1BF4+femnV75iN zjCStrE/vmZU2lIQTLxzwnrATLE+HIB9rSA7wtpXZKoG3Au5RIf0c5U0NiAY+mUp8RgK 5VvrQSjeOjAv77c0Y2kgUYVk2tILPAB+n2krrassdf9CBKqobJ8A17si8iYZwAvWVZeP zGdtwr6t08SOhUZibsXYFb/ICpWtHUShBKYrUKeDrIdh0TEPt03eJFQnX9MLxYKThybu nqzw== X-Gm-Message-State: AOJu0YwjcIP9a5mtfohCIB47eVwB77xsqy5Udh3R+obKjbOVuVCltBV6 Cg0bohRraQm3bl28Uh4lfVc6kKvmPJNRkqXg+RDPZK/z0DsIp2gmlpMty1VsGJSzoCGaIRQiuGy Hg6Wnfh3jKt9GmudkBy0VGQnEsE0ZXJZIpzyl7CQ36PqUMNUFkKACsRHyhzT6WN4SUlMgD7SF0l J6JvxOS46O9oyqDaE++oyGrfkDPZY1pg== X-Received: by 2002:a17:907:378:b0:a3c:a6de:a132 with SMTP id rs24-20020a170907037800b00a3ca6dea132mr1434715ejb.57.1707909368165; Wed, 14 Feb 2024 03:16:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/YdiwdOS7wLor/YnjKGgPNT3Qi9IfRkVD3oYLpQ5RWW1QNSqmc0GNgMidFatApXgA5Dt5ng== X-Received: by 2002:a17:907:378:b0:a3c:a6de:a132 with SMTP id rs24-20020a170907037800b00a3ca6dea132mr1434699ejb.57.1707909367867; Wed, 14 Feb 2024 03:16:07 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUVLx8F6LS+1vzdgVzPvmurqPddMV49N1GxsoZawCpSQtaCIQlAtemogFT0KUXH4HtjyaNa5hNSUIH974t9aYGJwRbH9l2Y39fvcKfLOUacRyMmgSNmie/zArNYFLbILD2d9y6a/PI9sqaIuKpTSA8xq6/hVyWW270vhagbWPBEAkXVYGGtAxoToh4hPBMkvr7b/QAp2g== Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id cu3-20020a170906ba8300b00a3ce8093f6esm1981759ejd.179.2024.02.14.03.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:16:07 -0800 (PST) Date: Wed, 14 Feb 2024 06:16:05 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Dmitry Osipenko , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , qemu-stable@nongnu.org, Gerd Hoffmann Subject: [PULL 54/60] virtio-gpu: Correct virgl_renderer_resource_get_info() error check Message-ID: <574b64aa6754ba491f51024c5a823a674d48a658.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Dmitry Osipenko virgl_renderer_resource_get_info() returns errno and not -1 on error. Correct the return-value check. Reviewed-by: Marc-André Lureau Signed-off-by: Dmitry Osipenko Message-Id: <20240129073921.446869-1-dmitry.osipenko@collabora.com> Cc: qemu-stable@nongnu.org Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/vhost-user-gpu/virgl.c | 6 +++--- hw/display/virtio-gpu-virgl.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c index d1ccdf7d06..51da0e3667 100644 --- a/contrib/vhost-user-gpu/virgl.c +++ b/contrib/vhost-user-gpu/virgl.c @@ -327,7 +327,7 @@ virgl_get_resource_info_modifiers(uint32_t resource_id, #ifdef VIRGL_RENDERER_RESOURCE_INFO_EXT_VERSION struct virgl_renderer_resource_info_ext info_ext; ret = virgl_renderer_resource_get_info_ext(resource_id, &info_ext); - if (ret < 0) { + if (ret) { return ret; } @@ -335,7 +335,7 @@ virgl_get_resource_info_modifiers(uint32_t resource_id, *modifiers = info_ext.modifiers; #else ret = virgl_renderer_resource_get_info(resource_id, info); - if (ret < 0) { + if (ret) { return ret; } @@ -372,7 +372,7 @@ virgl_cmd_set_scanout(VuGpu *g, uint64_t modifiers = 0; ret = virgl_get_resource_info_modifiers(ss.resource_id, &info, &modifiers); - if (ret == -1) { + if (ret) { g_critical("%s: illegal resource specified %d\n", __func__, ss.resource_id); cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 8bb7a2c21f..9f34d0e661 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -181,7 +181,7 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, memset(&info, 0, sizeof(info)); ret = virgl_renderer_resource_get_info(ss.resource_id, &info); #endif - if (ret == -1) { + if (ret) { qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal resource specified %d\n", __func__, ss.resource_id); From patchwork Wed Feb 14 11:16:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898853 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GQiml0jO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbLM3n0Hz23y6 for ; Wed, 14 Feb 2024 22:19:07 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDG1-0006bo-IF; Wed, 14 Feb 2024 06:16:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFQ-0005gZ-Fx for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFO-0007PV-Ot for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TmDYJ4T8Bz+NoOI3p2PmjP8oPOJZM9WBKm2EH3ooem4=; b=GQiml0jOQNnKsC1IJBDG8lZ/UnC7aq4eTO7L/oux8QuNYYwfIO0LFZ4M+Gy+gZjGdIJKeD j5agX0CXdsE3T9UWv2xdnukaC27HResP5e4z3iGlT9/ue01JKi8WoQle7hdS5ssIDcL0VU uObjSzcARxr2Tm3HzdNEQTUaUl43Rws= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-581-KrpTwIqNNvKaxNxvuKPPcQ-1; Wed, 14 Feb 2024 06:16:12 -0500 X-MC-Unique: KrpTwIqNNvKaxNxvuKPPcQ-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-55fee28d93dso3093902a12.2 for ; Wed, 14 Feb 2024 03:16:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909371; x=1708514171; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TmDYJ4T8Bz+NoOI3p2PmjP8oPOJZM9WBKm2EH3ooem4=; b=IbAB4dcu4P/e+dX+ZiNRsI7yQtV6nI7CMmniBInvvy3pqtgwOECfHqbUg2zohlR5jM SY8GuMNiGsC6R5sM2dBYaZMduUudkXnOVdy9bKXGj67yhiFEKVLVWDJ9NmF+HC1XmEg/ u+CIWsSDOhpM+rDcv/VZE94QltkEp864UrS4iQWiyBfVNahLyE5fXGEW9nhAKP+FiuoC ow5EkkK1euZdY92CHxKjPynTmMzZ7huuXBH/7iMYS2t5Tcw3C0A2FoaQ31n4CP3As6ca V4ujC5B+HkRQ2WjVglcOuUABFZrOGojefPL0fXqsTg5VzVwQObzhwoVXL3Lu5yV4neZy E6Mw== X-Gm-Message-State: AOJu0YzqtDs24iX75dmeeE8AxeeUgwxZ+WLaI3JbAWjepCb9uHt/ssTj xHv92GzXyaCF5Ei7n/aRwOrtH+HyNu5FfiiVU6m8A/tr81JVsZcd+wiTq5nCBtfh4QX8BDmGVXp gjaO8NBOEoUKFiHxYoXmRiz9T2X7DxW8W6mI3pe3EtxwIcYdeU1kQOjworhzjGA4LwwNAFTAcUp cWCBp9ttP6S1qt5hOZBObr1GzAhgiAjQ== X-Received: by 2002:a17:906:6812:b0:a3d:967:eab6 with SMTP id k18-20020a170906681200b00a3d0967eab6mr1541431ejr.41.1707909371202; Wed, 14 Feb 2024 03:16:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfSfux0Ajn4HD//6r9kG0i49vcP75ZK0Rox31i0IvPwZ3FGH0d26JuBlCKSkCKmXfiAa9L4A== X-Received: by 2002:a17:906:6812:b0:a3d:967:eab6 with SMTP id k18-20020a170906681200b00a3d0967eab6mr1541413ejr.41.1707909370987; Wed, 14 Feb 2024 03:16:10 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUyAWQoEhiNWMaOP08T7ia0XHrwBo5JKfQZA/Te/QGeyuDOBBv7RQ95OKItvlsFoAjaIhj/8jcMF/W+fExPeaiIAw8rmmomX88Nd2FJAMCau0h2hUKhUnu82hZHidDBWk8jsLM7cUStYEJRZzubUWgY/5rfBuRs/ZJra+FWINHc9bzLBtBv5AHJMPvt/FP3g/Bgsn4zNwyJFrLB Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id sa9-20020a1709076d0900b00a379be71a84sm2201854ejc.219.2024.02.14.03.16.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:16:10 -0800 (PST) Date: Wed, 14 Feb 2024 06:16:08 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , qemu-stable@nongnu.org, Michael Tokarev , Ani Sinha , Igor Mammedov Subject: [PULL 55/60] hw/smbios: Fix OEM strings table option validation Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Akihiko Odaki qemu_smbios_type11_opts did not have the list terminator and that resulted in out-of-bound memory access. It also needs to have an element for the type option. Cc: qemu-stable@nongnu.org Fixes: 2d6dcbf93fb0 ("smbios: support setting OEM strings table") Signed-off-by: Akihiko Odaki Reviewed-by: Michael Tokarev Message-Id: <20240129-smbios-v2-1-9ee6fede0d10@daynix.com> Reviewed-by: Ani Sinha Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/smbios/smbios.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index c0c5a81e66..a9048c1342 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -375,6 +375,11 @@ static const QemuOptDesc qemu_smbios_type8_opts[] = { }; static const QemuOptDesc qemu_smbios_type11_opts[] = { + { + .name = "type", + .type = QEMU_OPT_NUMBER, + .help = "SMBIOS element type", + }, { .name = "value", .type = QEMU_OPT_STRING, @@ -385,6 +390,7 @@ static const QemuOptDesc qemu_smbios_type11_opts[] = { .type = QEMU_OPT_STRING, .help = "OEM string data from file", }, + { /* end of list */ } }; static const QemuOptDesc qemu_smbios_type17_opts[] = { From patchwork Wed Feb 14 11:16:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898860 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iJ5oVn8z; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbLv6b5pz23hM for ; Wed, 14 Feb 2024 22:19:35 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDG3-0006gP-FY; Wed, 14 Feb 2024 06:16:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFU-0005ns-Ij for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFS-0007Sr-9B for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909377; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=w4ENYhUgFnCI8zatThJ4D45wdZB8M6CEIKjVTDexlIE=; b=iJ5oVn8znMhZK/lB+I9H6toAS6aPVAxjepVs+InkNu/hmqBE6S8Tom1iemuoBSo6s3mZeN Ohmvx0kkCffZP4KjITqglWpCeUV1pqQpXTj9pknuNotoFL8qNy9KSqHbmr4WOA/jeYrjvR paI582enO/WJR60pCPp15ROyr4FTmmw= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-1WSgttgHPmaL8Nhgw1dbFw-1; Wed, 14 Feb 2024 06:16:16 -0500 X-MC-Unique: 1WSgttgHPmaL8Nhgw1dbFw-1 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2d0908edbd0so48678491fa.2 for ; Wed, 14 Feb 2024 03:16:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909374; x=1708514174; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=w4ENYhUgFnCI8zatThJ4D45wdZB8M6CEIKjVTDexlIE=; b=JzWlhWFXQAc4EZjGDSSljVNcJq157RObjdOm5uGs/FG8lprTmyqgUXlqXzu7U5EEOz z04KUwR9U66ABs51eJFVW0EOvHrcdCptIlXJPBmmTZcR5TNbkiToMcK0JxWEdeL4ajB3 yRF4u9223+OdgT03e3h14aCPaVtHdoEh923Ov/tQJ2s61kxCyzq4LfIGxZOFsJc2OmRC 06PVwQzW+1dH9A27SjDIJD1Ka0fuwiftm0bDU94uHSFcNtTmeYLUykdA83DM+JRBgex3 XxE0Zcl7/ty8C1YoWrZxYWuYGz/DNN3d15PhRKooip4E7c0J9sXV9w8NOw7DDHWYyMnk Y/Bw== X-Gm-Message-State: AOJu0YzcO+/TpMZSj5WqGsgJ4yAw13o982Rwietf3pvUMMXatnO989qv iu4Cec553r+67Ems9ZTWwcsrPDhy9W1nn4MQSA5YfasT5tr5Pv+IzsFDUxY+2/65s2gTcNoakIu +wQNi0Vo0hzXyFH20AxXZns1ujsJK6k6C3aBstxoozLDGbo3tsxmsn5390XnBC++I3Ol5o/HYGZ ITMJuzeNAo7rbNZ/3CRFJDJgTMPraEog== X-Received: by 2002:a05:6512:3b9e:b0:511:a4bd:bfef with SMTP id g30-20020a0565123b9e00b00511a4bdbfefmr1957636lfv.4.1707909374455; Wed, 14 Feb 2024 03:16:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFF+OqKZCMfufDjJtx8otkLsPpsc9I1uzpC0KIbXQDoj+mcraCvf7AvXISr3Z187fRjrjceSg== X-Received: by 2002:a05:6512:3b9e:b0:511:a4bd:bfef with SMTP id g30-20020a0565123b9e00b00511a4bdbfefmr1957614lfv.4.1707909374146; Wed, 14 Feb 2024 03:16:14 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWL1bHQDdLCPwalsrug/6tMZWvvKtH+kiycUoW4UEHDfzuYt8tPKZEJ4VjQH1cK3YERq5i7W1zL+x+dVMKaj8eDLbqdyhTQxcBEf592TezjC2+M6MowNd9eqZw8Hpm7PViYCLlOCzub6fRV6qo5/AI+/MMUuhudElKEmVLMX+AIj+BKLc7EB2F8XdFQUVu196WwUjx1rEWDVcdz Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id c8-20020a0564021f8800b0055d312732dbsm4619551edc.5.2024.02.14.03.16.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:16:13 -0800 (PST) Date: Wed, 14 Feb 2024 06:16:11 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , qemu-stable@nongnu.org, Michael Tokarev , Ani Sinha , Igor Mammedov Subject: [PULL 56/60] hw/smbios: Fix port connector option validation Message-ID: <33b081e2947db6117b27f8c76544a756053f5514.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Akihiko Odaki qemu_smbios_type8_opts did not have the list terminator and that resulted in out-of-bound memory access. It also needs to have an element for the type option. Cc: qemu-stable@nongnu.org Fixes: fd8caa253c56 ("hw/smbios: support for type 8 (port connector)") Signed-off-by: Akihiko Odaki Reviewed-by: Michael Tokarev Message-Id: <20240129-smbios-v2-2-9ee6fede0d10@daynix.com> Reviewed-by: Ani Sinha Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/smbios/smbios.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index a9048c1342..a3c4e52ce9 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -352,6 +352,11 @@ static const QemuOptDesc qemu_smbios_type4_opts[] = { }; static const QemuOptDesc qemu_smbios_type8_opts[] = { + { + .name = "type", + .type = QEMU_OPT_NUMBER, + .help = "SMBIOS element type", + }, { .name = "internal_reference", .type = QEMU_OPT_STRING, @@ -372,6 +377,7 @@ static const QemuOptDesc qemu_smbios_type8_opts[] = { .type = QEMU_OPT_NUMBER, .help = "port type", }, + { /* end of list */ } }; static const QemuOptDesc qemu_smbios_type11_opts[] = { From patchwork Wed Feb 14 11:16:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898865 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hnlJ5pTa; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbN35dcTz23y6 for ; Wed, 14 Feb 2024 22:20:35 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFd-00062Q-Mh; Wed, 14 Feb 2024 06:16:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFW-0005qz-8V for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFU-0007Uo-Om for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909380; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5PjSQ+n8yhW/Y6dlynPh+22i7hOBitqudNQgzkqsiGE=; b=hnlJ5pTalTQB7THnVo0bFPbos2XsrmbPuIOMahBavhya/PuOu4mCJHrns9a48ccLNGQRoQ O6xOwwjvwGP6DMw+2u2fLvZ29G/7Xye0zu5268jooB4AHPrEVXgiD5dYP5TN7Y4+MaQjXM XMONx0TTZiFSVFsn/wtikz89jQmeSxM= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-494-G5mHQel8NBOUz6mPhlzpsg-1; Wed, 14 Feb 2024 06:16:19 -0500 X-MC-Unique: G5mHQel8NBOUz6mPhlzpsg-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-56217800333so625174a12.1 for ; Wed, 14 Feb 2024 03:16:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909377; x=1708514177; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5PjSQ+n8yhW/Y6dlynPh+22i7hOBitqudNQgzkqsiGE=; b=DB5vdC1byxUY41MYRi2cvSlH8FAEcLaelT6dddEUpe9+TzV2etiaHPBZW/1QsMFCoZ +orNRkpcMbG+m0qFurzaR/T9kCQNNECGi+9ZFHPYulI4rbZdxmX82DCza9YRJ7+iYIzp K6q+zoMMG0YrijZ//MoFlpRG3+kCCrj7ITH3uargpI+huogKVAeGfNkPTuIwvQdfv1Lw ByIgy0vxb541graw0t4HQ9E4kSjqRmQLCgef6TZLti3n9oaGAiBTzk1H6cP31ZwO2xrc lbg4kyfDi5INFM8bCbvSkFitzMorgPUjN4w19BlZruKtMeAavsrIrzSQRzETUlIrFQju iaCw== X-Gm-Message-State: AOJu0YytXqD2IUzu+9tFz3uEbGlBk5Wa8GcEvVK7ZUqa0YFwu2aeJjob EK/Q4WlhwIbnQGeJdbI0Y6MER+thGpPQyksRu+0odLu6RsXFcF2adMhbXCE13mZnfYCPBE3f4sI kbIOjdHHUuSwq0NG2Q6KYjKxC/pf3CEVU6NjYRbAqybGp47N2aonscb3XsgfYr4K94BfUqHXJje kvby/PcisAIRIHjuzwuXTwE1GV+vL03w== X-Received: by 2002:a05:6402:68b:b0:560:311c:4fcb with SMTP id f11-20020a056402068b00b00560311c4fcbmr1682773edy.33.1707909377282; Wed, 14 Feb 2024 03:16:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfJn3MC6LytzZA3b2es6L56pSoo1IY8/mVm8732O+26FD8TZbPtycS7snAdBw/Rv/WroqOPQ== X-Received: by 2002:a05:6402:68b:b0:560:311c:4fcb with SMTP id f11-20020a056402068b00b00560311c4fcbmr1682760edy.33.1707909377002; Wed, 14 Feb 2024 03:16:17 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWAWVJEnDAscxTX86fOco2JV5YDdKm1tc+ScnftSABHqGLj3bXQdUIShsNIsuzIHODRIrnzpD+zYwoGLsHHAWyvBn5Mth5d4LzjtFLawr68ZhYcL/uUpYWLlHTSsXMu9IxmqYYSR3piHBbOnjy18l0s4ec/EaGJvQlRVfnjUEg= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id i32-20020a0564020f2000b005617e079110sm4141059eda.81.2024.02.14.03.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:16:16 -0800 (PST) Date: Wed, 14 Feb 2024 06:16:14 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9?= Lureau , Gerd Hoffmann Subject: [PULL 57/60] hw/display/virtio-gpu.c: use reset_bh class method Message-ID: <8b162082cb2d495f8661b7ee3239a36936dab2ee.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Manos Pitsidianakis While the VirtioGPU type has a reset_bh field to specify a reset callback, it's never used. virtio_gpu_reset() calls the general virtio_gpu_reset_bh() function for all devices that inherit from VirtioGPU. While no devices override reset_bh at the moment, a device reset might require special logic for implementations in the future. Reviewed-by: Marc-André Lureau Signed-off-by: Manos Pitsidianakis Message-Id: <87fb4fa72ce5b341a6f957513a00dcb79fd5997f.1706626470.git.manos.pitsidianakis@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/display/virtio-gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index f8a675eb30..2b73ae585b 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1515,7 +1515,7 @@ void virtio_gpu_reset(VirtIODevice *vdev) qemu_cond_wait_bql(&g->reset_cond); } } else { - virtio_gpu_reset_bh(g); + aio_bh_call(g->reset_bh); } while (!QTAILQ_EMPTY(&g->cmdq)) { From patchwork Wed Feb 14 11:16:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898849 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=G5BKpfU+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbKz4YJ3z23hM for ; Wed, 14 Feb 2024 22:18:47 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFc-00060p-M5; Wed, 14 Feb 2024 06:16:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFZ-0005wY-Pd for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFY-0007WQ-2c for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909383; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uWvXvbaJCJDx3gylChFMzTBYNmFWTG/2A3hUdEuwE2s=; b=G5BKpfU+bzfFRHvIL7m2XN1fCvx9k9r2K+K134olAe+6afYc9q9b9s2D5HZKVKdjHLMB2n ssxJ+tSZBRinpZ7XtfdWO4XYM7atdNgS2TogQgFp5mZukvhxHxm1xz5JdAhEF40o/HcjRL Wr9yE/ILZgQRvOt+47HP9a1VNr6KzNY= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-550-L6p72Ht8MIa7GdG-gYEKoA-1; Wed, 14 Feb 2024 06:16:22 -0500 X-MC-Unique: L6p72Ht8MIa7GdG-gYEKoA-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a3c3f477eb7so186417066b.0 for ; Wed, 14 Feb 2024 03:16:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909380; x=1708514180; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uWvXvbaJCJDx3gylChFMzTBYNmFWTG/2A3hUdEuwE2s=; b=p3TZC7x6GaHUQkd5sC8d0rIsSMoKsVFiHJRV48RtgsNvGyuSldIZAnVtojo5jJbU4o fUa3IBqpEIQKRVz8F1qjg5deB2DgTNipUy0jBVHCo12ZhQfhTWhi2+CoepRrGJh7dL3g GUYIy9O0yWRAZOC0jx+MREPOKEjovuEQoO6IcsXjz3Mx44Qp9G1RaUEpBVmt5EPhG0xO RB+74v7JtyOKiuTw1f0vvUDw8xpKuUXBafqcudDjFohtMSdTRd6LNwia5jo+F/YjGfVs fARueVkgbtsD2mJNj3mXrgYG2IKPb36ka9RuRGDMrcg7vQ7tWQm8Vc1eZR4HhLGyvr9w mU1A== X-Gm-Message-State: AOJu0YzPnQAHIl57H4+r2np5FEw4FVPlJMKfCsTFXEzQ1I7r4K4zEI7n 59eWzkzwSNlq1WxBFAdXjfGTQH1wFML0eV1RT0pEUcVhTFFdlWBUzujMjYbbQoHvi+50EVbTAAb 5dRGQovaVu+q+hKXQuP+JNkG8X+0PMfhxo+ZF4Ngv1zRTTf1fkhcswsrwGUy7ax9Ld0XG3ZI2Zy OcU/mSBUxsKWFjxzZ/fAqm686lxtuD2Q== X-Received: by 2002:a17:906:d14f:b0:a3d:1edf:f9c6 with SMTP id br15-20020a170906d14f00b00a3d1edff9c6mr1525267ejb.33.1707909380405; Wed, 14 Feb 2024 03:16:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGGCOhcF574L1dv+7lkgQaW6VX6fPFKzac6lvta0OO8ZsLFiv/7ZJOyvUvaDBbYC1oLK1573w== X-Received: by 2002:a17:906:d14f:b0:a3d:1edf:f9c6 with SMTP id br15-20020a170906d14f00b00a3d1edff9c6mr1525246ejb.33.1707909380001; Wed, 14 Feb 2024 03:16:20 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVaHudQaTlihTqrNJfllMBJi68j/BTCrgUJ3HRnpOykh6VzemLlSw1rPU38uubMELGSwYwyOqr9+lxvm8IF6t1rcdtWnQO2a1an7oZh91j9sE07F6/KlNnpu4Kozo4JYj0vWAJ9bBupmH5hDfSz59yrm30+/kGjafy2MO6E3NM= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id y8-20020a170906558800b00a3d409ebe5fsm550631ejp.119.2024.02.14.03.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:16:19 -0800 (PST) Date: Wed, 14 Feb 2024 06:16:17 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9?= Lureau , Gerd Hoffmann Subject: [PULL 58/60] virtio-gpu.c: add resource_destroy class method Message-ID: <330399bd8935c9c2100c40e168781f405545d05a.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Manos Pitsidianakis When destroying/unrefing resources, devices such as virtio-gpu-rutabaga need to do their own bookkeeping (free rutabaga resources that are associated with the virtio_gpu_simple_resource). This commit adds a class method so that virtio-gpu-rutabaga can override it in the next commit. Reviewed-by: Marc-André Lureau Signed-off-by: Manos Pitsidianakis Message-Id: Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-gpu.h | 3 +++ hw/display/virtio-gpu.c | 25 ++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 584ba2ed73..b28e7ef0d2 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -219,6 +219,9 @@ struct VirtIOGPUClass { void (*update_cursor_data)(VirtIOGPU *g, struct virtio_gpu_scanout *s, uint32_t resource_id); + void (*resource_destroy)(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res, + Error **errp); }; struct VirtIOGPUGL { diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 2b73ae585b..1c1ee230b3 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -402,7 +402,8 @@ static void virtio_gpu_disable_scanout(VirtIOGPU *g, int scanout_id) } static void virtio_gpu_resource_destroy(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res) + struct virtio_gpu_simple_resource *res, + Error **errp) { int i; @@ -438,7 +439,11 @@ static void virtio_gpu_resource_unref(VirtIOGPU *g, cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; return; } - virtio_gpu_resource_destroy(g, res); + /* + * virtio_gpu_resource_destroy does not set any errors, so pass a NULL errp + * to ignore them. + */ + virtio_gpu_resource_destroy(g, res, NULL); } static void virtio_gpu_transfer_to_host_2d(VirtIOGPU *g, @@ -1488,11 +1493,24 @@ static void virtio_gpu_device_unrealize(DeviceState *qdev) static void virtio_gpu_reset_bh(void *opaque) { VirtIOGPU *g = VIRTIO_GPU(opaque); + VirtIOGPUClass *vgc = VIRTIO_GPU_GET_CLASS(g); struct virtio_gpu_simple_resource *res, *tmp; + uint32_t resource_id; + Error *local_err = NULL; int i = 0; QTAILQ_FOREACH_SAFE(res, &g->reslist, next, tmp) { - virtio_gpu_resource_destroy(g, res); + resource_id = res->resource_id; + vgc->resource_destroy(g, res, &local_err); + if (local_err) { + error_append_hint(&local_err, "%s: %s resource_destroy" + "for resource_id = %"PRIu32" failed.\n", + __func__, object_get_typename(OBJECT(g)), + resource_id); + /* error_report_err frees the error object for us */ + error_report_err(local_err); + local_err = NULL; + } } for (i = 0; i < g->parent_obj.conf.max_outputs; i++) { @@ -1632,6 +1650,7 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data) vgc->handle_ctrl = virtio_gpu_handle_ctrl; vgc->process_cmd = virtio_gpu_simple_process_cmd; vgc->update_cursor_data = virtio_gpu_update_cursor_data; + vgc->resource_destroy = virtio_gpu_resource_destroy; vgbc->gl_flushed = virtio_gpu_handle_gl_flushed; vdc->realize = virtio_gpu_device_realize; From patchwork Wed Feb 14 11:16:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898854 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=fCX4nTZy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbLN3hr2z23hM for ; Wed, 14 Feb 2024 22:19:08 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFe-00063r-PH; Wed, 14 Feb 2024 06:16:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFc-00060Z-AX for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFa-0007Wu-Kc for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=I30j7lVXoI5R21ou36fHAIQFrRuJEAkbfijdJs+XjD8=; b=fCX4nTZyCsVoL4GoVmKMPFnHtCNZ2I7XntFjfrfjiuDX6zySC0Sj6rHg3K1Py5F9rrQ4Bt viWhBPg8K1cbVwzLMAEbothxmtnMELEjP7t78UHCqwh7qttBUZ9KK2A82R8tf3dBjUqp9q w5tH3fazj33qjDhbNfkS3f85rEtcs9Q= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-509-C1u8OgJ0MAOpO0SIFah6Ow-1; Wed, 14 Feb 2024 06:16:24 -0500 X-MC-Unique: C1u8OgJ0MAOpO0SIFah6Ow-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-511535180b4so4261555e87.2 for ; Wed, 14 Feb 2024 03:16:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909383; x=1708514183; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=I30j7lVXoI5R21ou36fHAIQFrRuJEAkbfijdJs+XjD8=; b=wOaLvGltpJZhT+RZ/+x/3KZQB9cIaNt9Zvl3BwFEl75lmATYBhVAA8NLwVnLXx/hA1 Zq+Xp/pbozindnKScdOkgbhEqSVvix3QPvIcQDLw85w09cCcUkiIS7bKW+B3tt0a6FV3 ZxVhGNjgjH9eFy1jQy571loQIvfLe4wHpWcyM6r8qkvnbSUIT9W6i2UIv7kE1GdrLhDG x0yHHp7Ao0v32mh+8gCvC2oFwEJsyvRohgQ2i2H+JBIVvhyt7Mxc+FD/HoIYV0G8WAlE K+R5OZd1KFYjgmVKO2TiND/n360ijVWI1JESHqdxQmk7Giiri6ackEKgLQxN4T5YHBxQ 7TvA== X-Gm-Message-State: AOJu0Yzbea2+qKSUsFzA3XZcpWI7I6fPYDpBMAhOdTpep4YwSWNoLMyQ /s5TAmkmALnUHcZyaUvC4N1yQ6uKkptTLkazz7uaiUbee57qfWlpC+bKH/JA/Q9PIKhT0faQl12 cRRP06B+IVXhjVGKRIA7X/YfXMru7R4vMyjd6UiJieGCrohKMycii6nUFfwccwJAUVpZlffnYx7 gkLQcLnNQTaCid8Nk9i2uJGA2Kwn89cg== X-Received: by 2002:a05:6512:1287:b0:511:acd9:c10d with SMTP id u7-20020a056512128700b00511acd9c10dmr546764lfs.40.1707909383135; Wed, 14 Feb 2024 03:16:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IFopikCh4jJnR2UIzWfLdhF3HSFZxY+K97pd1SYMQTZbGQwpWG+0Zn/NObii+NynNh3Mf0I7g== X-Received: by 2002:a05:6512:1287:b0:511:acd9:c10d with SMTP id u7-20020a056512128700b00511acd9c10dmr546739lfs.40.1707909382777; Wed, 14 Feb 2024 03:16:22 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWMxzjOMceSY6eaK6U5U9SXP6EnQF6qPF/7f2PwekTbS0td1Zjasd2r9cqQ4oDruONcItmYhz2sdbVzPxaRb9YBAkc+liv4Pfvp21bC/mDJ293SPM66ocP7JDVmHG3ZZXmK4J6RmK5OXH3C8sP9JXseSfru9LzlUe+9SCsAUsw= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id lj8-20020a170907188800b00a3d2e685ff2sm805646ejc.78.2024.02.14.03.16.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:16:22 -0800 (PST) Date: Wed, 14 Feb 2024 06:16:20 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Gurchetan Singh , Gerd Hoffmann Subject: [PULL 59/60] virtio-gpu-rutabaga.c: override resource_destroy method Message-ID: <148d114933ea0cab43a3f575cf7516c362c74d2a.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Manos Pitsidianakis When the Rutabaga GPU device frees resources, it calls rutabaga_resource_unref for that resource_id. However, when the generic VirtIOGPU functions destroys resources, it only removes the virtio_gpu_simple_resource from the device's VirtIOGPU->reslist list. The rutabaga resource associated with that resource_id is then leaked. This commit overrides the resource_destroy class method introduced in the previous commit to fix this. Signed-off-by: Manos Pitsidianakis Message-Id: Reviewed-by: Gurchetan Singh Signed-off-by: Manos Pitsidianakis Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/display/virtio-gpu-rutabaga.c | 47 ++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/hw/display/virtio-gpu-rutabaga.c b/hw/display/virtio-gpu-rutabaga.c index 9e67f9bd51..17bf701a21 100644 --- a/hw/display/virtio-gpu-rutabaga.c +++ b/hw/display/virtio-gpu-rutabaga.c @@ -147,15 +147,39 @@ rutabaga_cmd_create_resource_3d(VirtIOGPU *g, QTAILQ_INSERT_HEAD(&g->reslist, res, next); } +static void +virtio_gpu_rutabaga_resource_unref(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res, + Error **errp) +{ + int32_t result; + VirtIOGPURutabaga *vr = VIRTIO_GPU_RUTABAGA(g); + + result = rutabaga_resource_unref(vr->rutabaga, res->resource_id); + if (result) { + error_setg_errno(errp, + (int)result, + "%s: rutabaga_resource_unref returned %"PRIi32 + " for resource_id = %"PRIu32, __func__, result, + res->resource_id); + } + + if (res->image) { + pixman_image_unref(res->image); + } + + QTAILQ_REMOVE(&g->reslist, res, next); + g_free(res); +} + static void rutabaga_cmd_resource_unref(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { - int32_t result; + int32_t result = 0; struct virtio_gpu_simple_resource *res; struct virtio_gpu_resource_unref unref; - - VirtIOGPURutabaga *vr = VIRTIO_GPU_RUTABAGA(g); + Error *local_err = NULL; VIRTIO_GPU_FILL_CMD(unref); @@ -164,15 +188,14 @@ rutabaga_cmd_resource_unref(VirtIOGPU *g, res = virtio_gpu_find_resource(g, unref.resource_id); CHECK(res, cmd); - result = rutabaga_resource_unref(vr->rutabaga, unref.resource_id); - CHECK(!result, cmd); - - if (res->image) { - pixman_image_unref(res->image); + virtio_gpu_rutabaga_resource_unref(g, res, &local_err); + if (local_err) { + error_report_err(local_err); + /* local_err was freed, do not reuse it. */ + local_err = NULL; + result = 1; } - - QTAILQ_REMOVE(&g->reslist, res, next); - g_free(res); + CHECK(!result, cmd); } static void @@ -1099,7 +1122,7 @@ static void virtio_gpu_rutabaga_class_init(ObjectClass *klass, void *data) vgc->handle_ctrl = virtio_gpu_rutabaga_handle_ctrl; vgc->process_cmd = virtio_gpu_rutabaga_process_cmd; vgc->update_cursor_data = virtio_gpu_rutabaga_update_cursor; - + vgc->resource_destroy = virtio_gpu_rutabaga_resource_unref; vdc->realize = virtio_gpu_rutabaga_realize; device_class_set_props(dc, virtio_gpu_rutabaga_properties); } From patchwork Wed Feb 14 11:16:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1898855 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=RK0eX771; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TZbLP1MBZz23y6 for ; Wed, 14 Feb 2024 22:19:09 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDG7-0006oC-PN; Wed, 14 Feb 2024 06:16:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFf-00064y-1f for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDFd-0007XS-F9 for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:16:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+IqUlUd43QVp4JPzLFMlq1/YZ7NboCWEvvXOOtxwXww=; b=RK0eX771DcUtYqgTu7rV7p36Q46aaw9CDT30qCloO0tIOssUDJwKjlsYW0m/onWFVSckE1 +YUmbdB8bEqWNz8RaZmLck84CpOVs0IS0XeRHAfoR463p2R0j3yB/3Uj2hvWhYTfRPS14+ sROirhrxmqeN9X6hNAhB9Ez2gyxHu+g= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-576-t4CFZwWwP7eusGV3-VSm7w-1; Wed, 14 Feb 2024 06:16:27 -0500 X-MC-Unique: t4CFZwWwP7eusGV3-VSm7w-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-56217800333so625268a12.1 for ; Wed, 14 Feb 2024 03:16:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909386; x=1708514186; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+IqUlUd43QVp4JPzLFMlq1/YZ7NboCWEvvXOOtxwXww=; b=vYSnUe0MMx/i9qB4rCcxwKGQjGj2u8A9MgvN91VmJD+3c/qlwsAkJviTUa7FyMPFvi nkwUihp0E3izSRS3nyuMsxTIKWXVYni/8qdAtfYaF6xwZjVD6snIVnS5HxrbKyvrDwkD L2SlpqfVw+N503EnMs3QCKAQkj9xeqD53sUqVwzx09cewNDLgC+Bmpld42WW/UNdxTyb Pg4C4hZg/b7cOk77/FPAFE3E0eSNshCQfiuNclrHnX223zmj3ElW6LoDMlzjobJjox46 8a7GmEcq68ERzf8vLjgSUqk1rXzBGjg6pska0qkT5caRgd0ED/SnABM0KgC0z0RjMpJD SySg== X-Gm-Message-State: AOJu0YyYg18MfRXT65UbC4oWSBjqClnh/5nwSc0jnbDXuzwN0KGPoWfm xkH1rWgDn6Ym88PRYiOLWjvg85nIjZV6OAMCUWaAaSqWK4Abqpy/NWW08RdqUD4sst0ZGeRllrZ IEV06eUqewFm6TktB3P5qdRTQAPhKNiBl8Ms3zNehxPBV9rT6K1jxZU4sRgnGIzFtMkmzth5wIp Exd/Ju0C6J7/J7WwHcdhoi+8qvHbIWcg== X-Received: by 2002:a17:906:6684:b0:a3d:37a4:a7e6 with SMTP id z4-20020a170906668400b00a3d37a4a7e6mr1202313ejo.21.1707909386239; Wed, 14 Feb 2024 03:16:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHtTYOR+WwAEd7eYcpklZOVxSG77n8Z/0mY7z46JYv9XeviV1Gq6ioL818hxkUr4Kvyaxe9OA== X-Received: by 2002:a17:906:6684:b0:a3d:37a4:a7e6 with SMTP id z4-20020a170906668400b00a3d37a4a7e6mr1202294ejo.21.1707909385909; Wed, 14 Feb 2024 03:16:25 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVD9AbnjEEVvkKJthBTPV1jAphMxJ7UiTG0awezkIl+ExBKxGW2pcWPOv42aWpPTCnS+RbffAFRALpEQ7Dq6wWB5Ih5SeaKX0t+H7vKSkkh4d8ZZQWe9SXJ7RgBzmUvDvTc+9TLtCYZTmxuU2eWTm3K62+e7f7TryZjXDjY+gNEiLEoPOgwTsJTZ3lpblPrfaHJjq5LXtA= Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id tl14-20020a170907c30e00b00a3beacb1666sm2196228ejc.157.2024.02.14.03.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:16:25 -0800 (PST) Date: Wed, 14 Feb 2024 06:16:22 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Raphael Norwitz , Alex =?utf-8?q?Benn=C3=A9e?= , Philippe =?utf-8?q?M?= =?utf-8?q?athieu-Daud=C3=A9?= , Thomas Huth , =?utf-8?q?C=C3=A9dric?= Le Goater Subject: [PULL 60/60] MAINTAINERS: Switch to my Enfabrica email Message-ID: <3afdb6d18e9ccd6470be30f151a562cf4537d13f.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Raphael Norwitz I'd prefer to use my new work email so this change updates MAINTAINERS with it. Signed-off-by: Raphael Norwitz Message-Id: <20240204023758.83191-1-raphael.s.norwitz@gmail.com> Reviewed-by: Alex Bennée Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 7a1afb40ac..0bf716db6a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2570,7 +2570,7 @@ F: include/hw/virtio/virtio-gpu.h F: docs/system/devices/virtio-gpu.rst vhost-user-blk -M: Raphael Norwitz +M: Raphael Norwitz S: Maintained F: contrib/vhost-user-blk/ F: contrib/vhost-user-scsi/