From patchwork Mon Jul 10 23:02:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806114 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=YW7CHQXd; dkim-atps=neutral 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 4R0KV01Vd6z20bx for ; Tue, 11 Jul 2023 09:10:16 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIztv-0002oz-HO; Mon, 10 Jul 2023 19:02:39 -0400 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 1qIztt-0002oS-TU for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:37 -0400 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 1qIzts-00046P-4r for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030155; 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=b0MXB3jbql5WvQ/habq6pavth8cn2+kv1+mjQ4aH340=; b=YW7CHQXd/I0ujglgAyZjwmnIcKbS7TqzwdAMKjyg0W8e20eM2MfXbOauvFU8PfT3H7q9nD dtTKmwrQe2dWe/Dcu2lCfECdZkajzccChv2TUK976umnX8SJoPaetvzkRBWUEMWotMcN+P WQjgK9fR7AMCOo3GOzOC9oZ6DzqxKIo= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-395-t0wIWPGpOkaWKi6wIO3ucw-1; Mon, 10 Jul 2023 19:02:34 -0400 X-MC-Unique: t0wIWPGpOkaWKi6wIO3ucw-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3113da8b778so2712642f8f.3 for ; Mon, 10 Jul 2023 16:02:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030152; x=1691622152; 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=b0MXB3jbql5WvQ/habq6pavth8cn2+kv1+mjQ4aH340=; b=jugBMHkYTaMJDk0OdvDgsvW3p0mGv9FckErtuhkiRwWMhOzNQA7eIrMM53GiWjtCyy Cg4JAHm2SLFTOBW/dNs/8Vbx/q5taM0boZx/z7aqB/xUMI+j0LCWzQLEZ+l6dlTnMXyO TqBXozyICXHrnAlPJpsER9aYbtv/OzXgRfngy3MnGUWiPTpKhXtiEt2EBMclhzxNvOgA NtkoWxXB8XXu8M/YjqlBf/HQqab5RPehlCe8LFgdIhncea1VWGRKhowBJ/H7okja1w7F I/nc2HJK3llzi+70HsZIhuVwMYxThGZby/Zs9ZfS0iK/lNQznlFeuHsmCmCao+B6a5xQ KQwQ== X-Gm-Message-State: ABy/qLYsGSDIWfbKu0vBWrrQOo0O7aXL63QWDqOIr27L9FH7wVCPQv3c CyoE7lMk5BPasEwwiHgXLOukF9nuP7cxH5Mo7yPCyQJblL6UXG9iXmFPQ4INBV/Rwd6HshsLAPP 7ofkSZLr4s+2Ks4OcP0ukdoKg7HZ8+rkQ9ACIKoODGOTbTk5x6lgCX5SsleaWCn0Dffhz X-Received: by 2002:adf:f008:0:b0:314:13e7:b8b with SMTP id j8-20020adff008000000b0031413e70b8bmr12949153wro.18.1689030151901; Mon, 10 Jul 2023 16:02:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlG7UBTBcDbb7a89vED4u/KGi721kr3T1LpEeDsuoMLK01dlstLC3TGpsLGRGGIepUkr06HAng== X-Received: by 2002:adf:f008:0:b0:314:13e7:b8b with SMTP id j8-20020adff008000000b0031413e70b8bmr12949135wro.18.1689030151604; Mon, 10 Jul 2023 16:02:31 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id m15-20020adfdc4f000000b003142ea7a661sm595472wrj.21.2023.07.10.16.02.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:02:31 -0700 (PDT) Date: Mon, 10 Jul 2023 19:02:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Eugenio =?utf-8?b?UMOpcmV6?= , Stefano Garzarella , Jason Wang Subject: [PULL 01/66] vdpa: Remove status in reset tracing Message-ID: <2b5de4d7dff457d34b57fcf3f985a41ddc0db062.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Eugenio Pérez It is always 0 and it is not useful to route call through file descriptor. Reviewed-by: Stefano Garzarella Acked-by: Jason Wang Signed-off-by: Eugenio Pérez Message-Id: <20230526153736.472443-1-eperezma@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vdpa.c | 2 +- hw/virtio/trace-events | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 3c575a9a6e..6246e5b9bf 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -859,7 +859,7 @@ static int vhost_vdpa_reset_device(struct vhost_dev *dev) uint8_t status = 0; ret = vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &status); - trace_vhost_vdpa_reset_device(dev, status); + trace_vhost_vdpa_reset_device(dev); v->suspended = false; return ret; } diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 8f8d05cf9b..6265231683 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -44,7 +44,7 @@ vhost_vdpa_set_mem_table(void *dev, uint32_t nregions, uint32_t padding) "dev: % vhost_vdpa_dump_regions(void *dev, int i, uint64_t guest_phys_addr, uint64_t memory_size, uint64_t userspace_addr, uint64_t flags_padding) "dev: %p %d: guest_phys_addr: 0x%"PRIx64" memory_size: 0x%"PRIx64" userspace_addr: 0x%"PRIx64" flags_padding: 0x%"PRIx64 vhost_vdpa_set_features(void *dev, uint64_t features) "dev: %p features: 0x%"PRIx64 vhost_vdpa_get_device_id(void *dev, uint32_t device_id) "dev: %p device_id %"PRIu32 -vhost_vdpa_reset_device(void *dev, uint8_t status) "dev: %p status: 0x%"PRIx8 +vhost_vdpa_reset_device(void *dev) "dev: %p" vhost_vdpa_get_vq_index(void *dev, int idx, int vq_idx) "dev: %p idx: %d vq idx: %d" vhost_vdpa_set_vring_ready(void *dev) "dev: %p" vhost_vdpa_dump_config(void *dev, const char *line) "dev: %p %s" From patchwork Mon Jul 10 23:02:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=DMZl99fa; dkim-atps=neutral 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 4R0KPX3nDpz20ZZ for ; Tue, 11 Jul 2023 09:06:24 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzty-0002pf-51; Mon, 10 Jul 2023 19:02:42 -0400 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 1qIztw-0002pH-EB for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:40 -0400 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 1qIztu-00046k-Q4 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030157; 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=HBXk/tr6uvd4qdoz2s4YWQLgUA//BbIN1kbLdfETPAE=; b=DMZl99fa2slFn8mUz9M9MoWc27vjWnAfUVR4O8x/Nn1P8lIz4c2Yobe3/lNt7yy1+bYjZp DxdCUCXMV7EBYISaex9A98OH6tJX1RZrWZLeWGBQMj51oqxZOnDZvBLq+ogrUcs0x8xoVh vxsx+sWGfqBx3OpP3hJqnYFjk5fFDcU= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-260-dWdqLP08O7-tlm3qm_0chA-1; Mon, 10 Jul 2023 19:02:36 -0400 X-MC-Unique: dWdqLP08O7-tlm3qm_0chA-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3fbb0fdd060so31128435e9.0 for ; Mon, 10 Jul 2023 16:02:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030155; x=1691622155; 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=HBXk/tr6uvd4qdoz2s4YWQLgUA//BbIN1kbLdfETPAE=; b=kDuEn7JZGQ9GgovWbn1L/yrNQjpjnUBaMx6bW1bDrdQJj/KdXNgxJPpJisbMUXcf/T DxYxLJi9gYtlesQtal4icE1/RyGDWKuvnoBaAyO5EfSbxxBQ5S/M5SzF/9YeqdnU4GKO zLGC54VjRl16aqZQcq6IwLJPZCYFhvKusl8x/tLPkP22mSwjhntd23Fj7CVbb1Clfwo1 2Mi5ShgQw/sFYTGDbZ7cjv/5QNDkfFs63d/iaD+bmORaQ0KAsAqjmkRpHy82fAJnxZHz gORe9rGKB0TMkvEk4wmva6vKdm85SrvBXS24uN/NusBRjpOK1aTCE0nltHuHfOP/ssuF mo0Q== X-Gm-Message-State: ABy/qLZSI2wt1DddDcJsv5SoJW+6mjFYrHmdn31QhxqM7/2QYPIjw1bQ kwrS91Z+L6yXtllG4+5u/Afqr4o0QomeXM8nEykuHRuUk3Yz3+3LWU21l0ztUbvjmzmA5CiKIDG Rd7LlN9QUuvGVVPSk6ZNbYJho3CE4LY2zil0CrpJ4u8/XSEwhzCq67XspF5Z3KQ5mXxO8 X-Received: by 2002:a1c:f713:0:b0:3f8:f4f3:82ec with SMTP id v19-20020a1cf713000000b003f8f4f382ecmr13687793wmh.8.1689030154752; Mon, 10 Jul 2023 16:02:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlGNpx1nNcAnLSa6CB6YiiKBzg+S2tvs2Fpdz8H6LR+3H+iCAh9ZvzCh/A6L8Gi4B/lFeYR0nQ== X-Received: by 2002:a1c:f713:0:b0:3f8:f4f3:82ec with SMTP id v19-20020a1cf713000000b003f8f4f382ecmr13687773wmh.8.1689030154420; Mon, 10 Jul 2023 16:02:34 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id v15-20020a1cf70f000000b003fa8158135esm11397594wmh.11.2023.07.10.16.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:02:33 -0700 (PDT) Date: Mon, 10 Jul 2023 19:02:31 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Viktor Prutyanov , Jason Wang Subject: [PULL 02/66] vhost: register and change IOMMU flag depending on Device-TLB state 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Viktor Prutyanov The guest can disable or never enable Device-TLB. In these cases, it can't be used even if enabled in QEMU. So, check Device-TLB state before registering IOMMU notifier and select unmap flag depending on that. Also, implement a way to change IOMMU notifier flag if Device-TLB state is changed. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2001312 Signed-off-by: Viktor Prutyanov Acked-by: Jason Wang Message-Id: <20230626091258.24453-2-viktor@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost.h | 1 + hw/virtio/vhost-stub.c | 4 ++++ hw/virtio/vhost.c | 38 ++++++++++++++++++++++++++------------ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index f7f10c8fb7..6a173cb9fa 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -320,6 +320,7 @@ bool vhost_has_free_slot(void); int vhost_net_set_backend(struct vhost_dev *hdev, struct vhost_vring_file *file); +void vhost_toggle_device_iotlb(VirtIODevice *vdev); int vhost_device_iotlb_miss(struct vhost_dev *dev, uint64_t iova, int write); int vhost_virtqueue_start(struct vhost_dev *dev, struct VirtIODevice *vdev, diff --git a/hw/virtio/vhost-stub.c b/hw/virtio/vhost-stub.c index c175148fce..aa858ef3fb 100644 --- a/hw/virtio/vhost-stub.c +++ b/hw/virtio/vhost-stub.c @@ -15,3 +15,7 @@ bool vhost_user_init(VhostUserState *user, CharBackend *chr, Error **errp) void vhost_user_cleanup(VhostUserState *user) { } + +void vhost_toggle_device_iotlb(VirtIODevice *vdev) +{ +} diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 82394331bf..abf0d03c8d 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -780,7 +780,6 @@ static void vhost_iommu_region_add(MemoryListener *listener, Int128 end; int iommu_idx; IOMMUMemoryRegion *iommu_mr; - int ret; if (!memory_region_is_iommu(section->mr)) { return; @@ -795,7 +794,9 @@ static void vhost_iommu_region_add(MemoryListener *listener, iommu_idx = memory_region_iommu_attrs_to_index(iommu_mr, MEMTXATTRS_UNSPECIFIED); iommu_notifier_init(&iommu->n, vhost_iommu_unmap_notify, - IOMMU_NOTIFIER_DEVIOTLB_UNMAP, + dev->vdev->device_iotlb_enabled ? + IOMMU_NOTIFIER_DEVIOTLB_UNMAP : + IOMMU_NOTIFIER_UNMAP, section->offset_within_region, int128_get64(end), iommu_idx); @@ -803,16 +804,8 @@ static void vhost_iommu_region_add(MemoryListener *listener, iommu->iommu_offset = section->offset_within_address_space - section->offset_within_region; iommu->hdev = dev; - ret = memory_region_register_iommu_notifier(section->mr, &iommu->n, NULL); - if (ret) { - /* - * Some vIOMMUs do not support dev-iotlb yet. If so, try to use the - * UNMAP legacy message - */ - iommu->n.notifier_flags = IOMMU_NOTIFIER_UNMAP; - memory_region_register_iommu_notifier(section->mr, &iommu->n, - &error_fatal); - } + memory_region_register_iommu_notifier(section->mr, &iommu->n, + &error_fatal); QLIST_INSERT_HEAD(&dev->iommu_list, iommu, iommu_next); /* TODO: can replay help performance here? */ } @@ -840,6 +833,27 @@ static void vhost_iommu_region_del(MemoryListener *listener, } } +void vhost_toggle_device_iotlb(VirtIODevice *vdev) +{ + VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); + struct vhost_dev *dev; + struct vhost_iommu *iommu; + + if (vdev->vhost_started) { + dev = vdc->get_vhost(vdev); + } else { + return; + } + + QLIST_FOREACH(iommu, &dev->iommu_list, iommu_next) { + memory_region_unregister_iommu_notifier(iommu->mr, &iommu->n); + iommu->n.notifier_flags = vdev->device_iotlb_enabled ? + IOMMU_NOTIFIER_DEVIOTLB_UNMAP : IOMMU_NOTIFIER_UNMAP; + memory_region_register_iommu_notifier(iommu->mr, &iommu->n, + &error_fatal); + } +} + static int vhost_virtqueue_set_addr(struct vhost_dev *dev, struct vhost_virtqueue *vq, unsigned idx, bool enable_log) From patchwork Mon Jul 10 23:02:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=DJEomSBF; dkim-atps=neutral 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 4R0KKZ1Dr7z20Ph for ; Tue, 11 Jul 2023 09:02:58 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIztz-0002q1-QL; Mon, 10 Jul 2023 19:02:43 -0400 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 1qIzty-0002pZ-1q for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:42 -0400 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 1qIztw-000478-MT for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030160; 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=jZcq1DYmpi4vNgb1KecH/E6OuJO5OkwSaIFJsUnElEQ=; b=DJEomSBFV3Nd5+Tvxl2snBAW7YaM6tKi4H9ZY/q2ej/ypTNFOsavkMWyTREoJc3CETm476 dvEKyUk0T67qluHz04T23JHz9HN3jzmEGUNvMU7gfQoSZo3T+xUemKnjdPzF9XTT84Svw2 4OlHSOLBpUyuHRQrojJO3FPwb1JahMo= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-137--YE-EWcVMdm4yPVaa40PSA-1; Mon, 10 Jul 2023 19:02:38 -0400 X-MC-Unique: -YE-EWcVMdm4yPVaa40PSA-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-313c930ee0eso2725106f8f.0 for ; Mon, 10 Jul 2023 16:02:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030157; x=1691622157; 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=jZcq1DYmpi4vNgb1KecH/E6OuJO5OkwSaIFJsUnElEQ=; b=H600q21LA/f1tyR5JQ382LQbcqzEASZUjJUcC0x5VCaXA+8aQSlIwKdCT1HkUQhf/3 5yCpGKyHZQXwz9fTf8fheTAfYOVJEQgtMUV8BF7+ZrUMtVnbhkZ0tOQaH6+2pWHnuWq9 hSbvmHhRbALXR3gGyuSX5dj2ExnXGViZHhrt2iSu6BWqSKsKO7fJc1CBoVcBQkYx6bI0 4Dxd3Yz/p9URSmCHxwvfxVZihTmiRCd4v4b2yMensZsvIUEf1RYWmmJbPIQHANAPU+ET zbT2J7Fy+h9fv9II05nvXyr0vC9LmCDhMbNf7A1iscxO2kSpU6DnPcZ+7gPoR1dpUfdg g2ug== X-Gm-Message-State: ABy/qLYArrM6hHTr1P4cqYZzf/r4lU32FZkBMn08LbOFedHttDaQtlRL Hb11hx9xm+nRfc9QU+4yoWJI8XgGVH6nXpqP7b3zKLn8WPM8zmC12EjlDsQ1FrD04FX/IqyNVOJ 79B8amttWlH0fwFLG9y7/7cUPzlbew9JSOw6TfDy51ssfvr5IzQOkFYQ/5+EsO38jXuZo X-Received: by 2002:a5d:428c:0:b0:311:db0:8aff with SMTP id k12-20020a5d428c000000b003110db08affmr10914590wrq.70.1689030157084; Mon, 10 Jul 2023 16:02:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlECt2IhUizJKTo9wXXS7xdGmHGqTODkkBnz/UTzcEJNFDoxmEdtuJ0V3bmZQMhTIYQcILEY4g== X-Received: by 2002:a5d:428c:0:b0:311:db0:8aff with SMTP id k12-20020a5d428c000000b003110db08affmr10914575wrq.70.1689030156867; Mon, 10 Jul 2023 16:02:36 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id z8-20020adff1c8000000b003141e86e751sm611531wro.5.2023.07.10.16.02.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:02:36 -0700 (PDT) Date: Mon, 10 Jul 2023 19:02:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Viktor Prutyanov , Jason Wang Subject: [PULL 03/66] virtio-net: pass Device-TLB enable/disable events to vhost 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Viktor Prutyanov If vhost is enabled for virtio-net, Device-TLB enable/disable events must be passed to vhost for proper IOMMU unmap flag selection. Signed-off-by: Viktor Prutyanov Acked-by: Jason Wang Message-Id: <20230626091258.24453-3-viktor@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 04783f5b94..d51067123b 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3951,6 +3951,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data) vdc->vmsd = &vmstate_virtio_net_device; vdc->primary_unplug_pending = primary_unplug_pending; vdc->get_vhost = virtio_net_get_vhost; + vdc->toggle_device_iotlb = vhost_toggle_device_iotlb; } static const TypeInfo virtio_net_info = { From patchwork Mon Jul 10 23:02:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=DjfL1Thv; dkim-atps=neutral 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 4R0KKq40Qvz20Ph for ; Tue, 11 Jul 2023 09:03:11 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzu3-0002qR-29; Mon, 10 Jul 2023 19:02:47 -0400 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 1qIzu1-0002qE-7s for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:45 -0400 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 1qIztz-00047f-Nd for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030163; 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=cm7m/d6NYZfBBMZKPgelKWyXoTCCqKJswESWtJrljJw=; b=DjfL1ThvNuLzEMPIbi9jE+jVdcsziSI/VGRp70ITP6qf3YzpEf362pygY8XuO46ejjjk/L LZpA34z7cwKOszTQqznssMPn36Ov7KRZ8PLzhuycJDRde7ak3giRh8uqLOEEqlEiMzHSsq 4kviRaPck5JwhM2BlLIJx6n4bV5uy3I= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-494-fvHJp3PkMJiXcbL7vAB0Tw-1; Mon, 10 Jul 2023 19:02:41 -0400 X-MC-Unique: fvHJp3PkMJiXcbL7vAB0Tw-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-314275b653eso2720543f8f.1 for ; Mon, 10 Jul 2023 16:02:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030160; x=1691622160; 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=cm7m/d6NYZfBBMZKPgelKWyXoTCCqKJswESWtJrljJw=; b=JmWhIE4w/1ou7K05ICJAHnfwlzU2glaYBxCfIcbT7aqo6ZbDu4wAx5tZTBITE4iWCq UvJ2wuKmh5b46ttawxGBXLTdpk1MkEv9A4YwHejNtN1d4KnXiT2YfrJd1PRL/aIzzhcp kJEH8yhx7rY27gUQGy0F5sIidYgUgKUvc/FAnmd1+IV5Sm2fCJkfVsETPsh/f8I3pelr Dd+Quy7mn/GJaseG0GHarlPXowoica906oRaXHNeOq8BFAenQC530XNvuIfZLnP4DuxF 26BDdNZRLBgh69f9gBGm2lZiQf8ynF12aBciRqfkB8d9PgAYK5j2EF86XsB7onWbJrW2 zIhw== X-Gm-Message-State: ABy/qLa2N2fyGPdJqv0QllYQkl2KWTiBNsGlYvj3A8r8tqiTDLndWO9H FgwtU4kg4uSPk3CjQzec3m/15w+AjuzUG0x/Zxg0zScyJF7RG5OF080Hvwx8fTbeNMULYAxSlqt OGIMJ9CFapjtXZRW+oRGTzOuNnprfV5n+9oFTa0MF53NA4icYZD9xZsIAtxDK+Xz+41vb X-Received: by 2002:a5d:6649:0:b0:314:1443:7fbe with SMTP id f9-20020a5d6649000000b0031414437fbemr12713143wrw.36.1689030159899; Mon, 10 Jul 2023 16:02:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlGcKqnx2Ds9IOMRCPKdqxz9y183syGJ3LprG5Eqfs0zJMjHDWksESeQXRXJGx1qPsHS2Jf3Gw== X-Received: by 2002:a5d:6649:0:b0:314:1443:7fbe with SMTP id f9-20020a5d6649000000b0031414437fbemr12713122wrw.36.1689030159598; Mon, 10 Jul 2023 16:02:39 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id f14-20020adfe90e000000b0030647449730sm578463wrm.74.2023.07.10.16.02.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:02:38 -0700 (PDT) Date: Mon, 10 Jul 2023 19:02:37 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Erico Nunes , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , Gerd Hoffmann Subject: [PULL 04/66] virtio-gpu: refactor generate_edid function to virtio_gpu_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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Erico Nunes This functionality can be shared with upcoming use in vhost-user-gpu, so move it to the shared file to avoid duplicating it. Signed-off-by: Erico Nunes Reviewed-by: Marc-André Lureau Message-Id: <20230626164708.1163239-2-ernunes@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-gpu.h | 2 ++ hw/display/virtio-gpu-base.c | 17 +++++++++++++++++ hw/display/virtio-gpu.c | 20 +------------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 7a5f8056ea..7ea8ae2bee 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -242,6 +242,8 @@ void virtio_gpu_base_reset(VirtIOGPUBase *g); void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, struct virtio_gpu_resp_display_info *dpy_info); +void virtio_gpu_base_generate_edid(VirtIOGPUBase *g, int scanout, + struct virtio_gpu_resp_edid *edid); /* virtio-gpu.c */ void virtio_gpu_ctrl_response(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd, diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index a29f191aa8..7ab7d08d0a 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -17,6 +17,7 @@ #include "migration/blocker.h" #include "qapi/error.h" #include "qemu/error-report.h" +#include "hw/display/edid.h" #include "trace.h" void @@ -51,6 +52,22 @@ virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, } } +void +virtio_gpu_base_generate_edid(VirtIOGPUBase *g, int scanout, + struct virtio_gpu_resp_edid *edid) +{ + qemu_edid_info info = { + .width_mm = g->req_state[scanout].width_mm, + .height_mm = g->req_state[scanout].height_mm, + .prefx = g->req_state[scanout].width, + .prefy = g->req_state[scanout].height, + .refresh_rate = g->req_state[scanout].refresh_rate, + }; + + edid->size = cpu_to_le32(sizeof(edid->edid)); + qemu_edid_generate(edid->edid, sizeof(edid->edid), &info); +} + static void virtio_gpu_invalidate_display(void *opaque) { } diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 347e17d490..befa7d6d78 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -24,7 +24,6 @@ #include "hw/virtio/virtio-gpu-bswap.h" #include "hw/virtio/virtio-gpu-pixman.h" #include "hw/virtio/virtio-bus.h" -#include "hw/display/edid.h" #include "hw/qdev-properties.h" #include "qemu/log.h" #include "qemu/module.h" @@ -207,23 +206,6 @@ void virtio_gpu_get_display_info(VirtIOGPU *g, sizeof(display_info)); } -static void -virtio_gpu_generate_edid(VirtIOGPU *g, int scanout, - struct virtio_gpu_resp_edid *edid) -{ - VirtIOGPUBase *b = VIRTIO_GPU_BASE(g); - qemu_edid_info info = { - .width_mm = b->req_state[scanout].width_mm, - .height_mm = b->req_state[scanout].height_mm, - .prefx = b->req_state[scanout].width, - .prefy = b->req_state[scanout].height, - .refresh_rate = b->req_state[scanout].refresh_rate, - }; - - edid->size = cpu_to_le32(sizeof(edid->edid)); - qemu_edid_generate(edid->edid, sizeof(edid->edid), &info); -} - void virtio_gpu_get_edid(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { @@ -242,7 +224,7 @@ void virtio_gpu_get_edid(VirtIOGPU *g, trace_virtio_gpu_cmd_get_edid(get_edid.scanout); memset(&edid, 0, sizeof(edid)); edid.hdr.type = VIRTIO_GPU_RESP_OK_EDID; - virtio_gpu_generate_edid(g, get_edid.scanout, &edid); + virtio_gpu_base_generate_edid(VIRTIO_GPU_BASE(g), get_edid.scanout, &edid); virtio_gpu_ctrl_response(g, cmd, &edid.hdr, sizeof(edid)); } From patchwork Mon Jul 10 23:02:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806079 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=GoIY1Gdy; dkim-atps=neutral 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 4R0KRR5XHrz20ZZ for ; Tue, 11 Jul 2023 09:08:03 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzu5-0002rA-JA; Mon, 10 Jul 2023 19:02:49 -0400 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 1qIzu3-0002qd-P4 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:47 -0400 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 1qIzu2-00047w-A1 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030165; 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=jiHSJhGfrExMCfEGSl3IWf42A4x66124Sakgqtwn2N8=; b=GoIY1Gdy28qCltqzLAdYJvWxLT5y/PHaRgVej8pevnGVtrYkBhaP70Cn3Ea10UM5N1P3gb my/OM6hZO30GZBBjR5d7NpPC4w+dMwNRTZbUImFlnqS2CgY+L4h70hk7S6EcMve4RVCg7f fdq3JrVeMC4ezURISep0lfpeNhHnytM= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-505-W0bHCzI7M4W_8ClL_5TS_Q-1; Mon, 10 Jul 2023 19:02:44 -0400 X-MC-Unique: W0bHCzI7M4W_8ClL_5TS_Q-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fa8cd898e0so34200385e9.3 for ; Mon, 10 Jul 2023 16:02:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030162; x=1691622162; 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=jiHSJhGfrExMCfEGSl3IWf42A4x66124Sakgqtwn2N8=; b=GorEQtIXSMK4pFYkCN0y3ko7ehKnENI2bEYHB75alqhmHAONQRoH0MDrO6QWIGIQ2n k3s/z5z7HdBRlhOy9YRpr6Hu8GC8J0U8rHC2AHBXI6bV939wIDLAd7gP8sus9A3y+6C3 8ynRYdFtw8m2naoTPz/7oFCLtawDKmoL7ShwZ25vQk3ic4rPggoEfPs5pJ0lM/c+8mlo 7erjvfx3Itkse3M9HPngvrE5FUbdeLYt/OR6hrDg7yQk48Bprv1pu0L+QvKzq0rMHyXR zRmsheJ6uvtRJVaw19TVW1s6hTb9rEbFwX/9HokOv1lbHwVRkW01w9MGO1MQj2Ib+2Lh IULA== X-Gm-Message-State: ABy/qLbN220DEIIvm6hAv7su5AOGTRtjpaMP1px6hDIHKP93rJbQy1sy SY49Lho9bfL+Yu/4GuIMZZ7iEnbQAkIcedxuQM6YLBclafpfcGJUWBBFa9ZWsbgGgrYsvYaWv9D l5u6DZtfwjuNCK4xwSpdr7upRjKnmRgxV6Q/ba9o4TN6CYnUYQBjIVPxt76Z4R6I3jFwa X-Received: by 2002:a1c:4b17:0:b0:3fb:b008:2003 with SMTP id y23-20020a1c4b17000000b003fbb0082003mr14360472wma.38.1689030162573; Mon, 10 Jul 2023 16:02:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlFlYaWrizfsxLZe+Zx/hxlf0IhPkrQdk2DeqS/Cp7SLjpv8dXnNsEi/KDKe5Tu6TMxmn0MSZw== X-Received: by 2002:a1c:4b17:0:b0:3fb:b008:2003 with SMTP id y23-20020a1c4b17000000b003fbb0082003mr14360449wma.38.1689030162279; Mon, 10 Jul 2023 16:02:42 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id l4-20020a1ced04000000b003fbe561f6a3sm11446797wmh.37.2023.07.10.16.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:02:41 -0700 (PDT) Date: Mon, 10 Jul 2023 19:02:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Erico Nunes , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , Gerd Hoffmann Subject: [PULL 05/66] docs: vhost-user-gpu: add protocol changes for EDID Message-ID: <50cbd5b4b37de3f474495c5fd6a66d5c0e8e49c2.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Erico Nunes VHOST_USER_GPU_GET_EDID is defined as a message from the backend to the frontend to retrieve the EDID data for a given scanout. The VHOST_USER_GPU_PROTOCOL_F_EDID protocol feature is defined as a way to check whether this new message is supported or not. Signed-off-by: Erico Nunes Reviewed-by: Marc-André Lureau Message-Id: <20230626164708.1163239-3-ernunes@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/interop/vhost-user-gpu.rst | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/interop/vhost-user-gpu.rst b/docs/interop/vhost-user-gpu.rst index 1640553729..b78806892d 100644 --- a/docs/interop/vhost-user-gpu.rst +++ b/docs/interop/vhost-user-gpu.rst @@ -124,6 +124,16 @@ VhostUserGpuDMABUFScanout :fourcc: ``i32``, the DMABUF fourcc +VhostUserGpuEdidRequest +^^^^^^^^^^^^^^^^^^^^^^^ + ++------------+ +| scanout-id | ++------------+ + +:scanout-id: ``u32``, the scanout to get edid from + + C structure ----------- @@ -141,6 +151,8 @@ In QEMU the vhost-user-gpu message is implemented with the following struct: VhostUserGpuScanout scanout; VhostUserGpuUpdate update; VhostUserGpuDMABUFScanout dmabuf_scanout; + VhostUserGpuEdidRequest edid_req; + struct virtio_gpu_resp_edid resp_edid; struct virtio_gpu_resp_display_info display_info; uint64_t u64; } payload; @@ -149,10 +161,11 @@ In QEMU the vhost-user-gpu message is implemented with the following struct: Protocol features ----------------- -None yet. +.. code:: c -As the protocol may need to evolve, new messages and communication -changes are negotiated thanks to preliminary + #define VHOST_USER_GPU_PROTOCOL_F_EDID 0 + +New messages and communication changes are negotiated thanks to the ``VHOST_USER_GPU_GET_PROTOCOL_FEATURES`` and ``VHOST_USER_GPU_SET_PROTOCOL_FEATURES`` requests. @@ -241,3 +254,12 @@ Message types Note: there is no data payload, since the scanout is shared thanks to DMABUF, that must have been set previously with ``VHOST_USER_GPU_DMABUF_SCANOUT``. + +``VHOST_USER_GPU_GET_EDID`` + :id: 11 + :request payload: ``struct VhostUserGpuEdidRequest`` + :reply payload: ``struct virtio_gpu_resp_edid`` (from virtio specification) + + Retrieve the EDID data for a given scanout. + This message requires the ``VHOST_USER_GPU_PROTOCOL_F_EDID`` protocol + feature to be supported. From patchwork Mon Jul 10 23:02:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806058 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=TI5VWdd3; dkim-atps=neutral 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 4R0KLs4Pypz20Ph for ; Tue, 11 Jul 2023 09:04:05 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzuD-0003GX-4f; Mon, 10 Jul 2023 19:02:57 -0400 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 1qIzuB-00037S-JN for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:55 -0400 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 1qIzu5-00048F-Oz for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030168; 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=91ehsKt74UQJMB5yd1wqn/5XX3vDbWuqDYEZyK7Ivzc=; b=TI5VWdd3G/v5kRen3sQJEdM3K0WPooOEkYzw3SJRdSeao1d4TCvhC2XPVE2ry8ObFsJ9th MBEhmiRe/3xUXG+VcFHTNiOfGfafPPx0YkxBJoWuTXIoq6qlQ7cTD/Iy1YCqcj9BH5Uenp U0Y34MI+sKCMGe0tQ/XDqVezAcHvBbw= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-460-1KCLqDgqNOiMx2fX7EqEhA-1; Mon, 10 Jul 2023 19:02:47 -0400 X-MC-Unique: 1KCLqDgqNOiMx2fX7EqEhA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fbcae05906so33511395e9.3 for ; Mon, 10 Jul 2023 16:02:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030165; x=1691622165; 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=91ehsKt74UQJMB5yd1wqn/5XX3vDbWuqDYEZyK7Ivzc=; b=hjAdsI4zCOEqyDeWjB82O9aDQzERzKts4xEIq5QoGgfq7JVJeFlOx1Kx6BBxwJz2oL LOOjsNaXP1GuwCh6HaC6DCu6Kyck2umzw73Nbs0vOQdPNrHhZJw8R70/Nx8qwvlo2evT Nsgr5ECTqkBqTwMP+3UPa5zEoywArkQDH277Ss1Z5DsTacTZJN4+XCTo6bwZ/u4Dj71r 7yip8HjNAo9xYa4RKh8Mvg49mVVgHJe7s6ZkvVfejWxGN5+5CEXmaqizIMcHyWpR8C6F P/FbB6iL4CN7XvyTBRF/3wjr7jGBWpBTBwFdRkh9TQ6qJdeSDpBDI+XZ0N28+xcnv2Vh 2znw== X-Gm-Message-State: ABy/qLZzkunZWF79Qz4kY7561kAv2Qz3+cOmFsxw7ZzRl+wIBfBIafkW MfwaAkJAc9rjmvd1T1PJ4hlPysLFv5lhbv1unQ86MASqSDBf/vZVo4n8VKqFsAYh1BEk+f4/Php f+6GjtAZFGCBJxo1G2hTDX9SdGuxxdp1GKHmXmsqict1800iijOgaZ09IhkQelgoL/wEN X-Received: by 2002:a05:600c:20b:b0:3fb:415a:d07 with SMTP id 11-20020a05600c020b00b003fb415a0d07mr13841334wmi.36.1689030165614; Mon, 10 Jul 2023 16:02:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlG+j3t90UvZgPhJiAOJl2z740F9kWilaCqy99V4KlnBnrKuJj4liILNUR/wJmX/7Zf04Iqe8A== X-Received: by 2002:a05:600c:20b:b0:3fb:415a:d07 with SMTP id 11-20020a05600c020b00b003fb415a0d07mr13841302wmi.36.1689030165185; Mon, 10 Jul 2023 16:02:45 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id v21-20020a7bcb55000000b003fba9db141esm11435823wmj.38.2023.07.10.16.02.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:02:44 -0700 (PDT) Date: Mon, 10 Jul 2023 19:02:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Erico Nunes , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , Gerd Hoffmann Subject: [PULL 06/66] contrib/vhost-user-gpu: implement get_edid feature 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: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=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=no 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: Erico Nunes Implement the virtio-gpu feature in contrib/vhost-user-gpu, which was unsupported until now. In this implementation, the feature is enabled inconditionally to avoid creating another optional config argument. Similarly to get_display_info, vhost-user-gpu sends a message back to the frontend to have access to all the display information. In the case of get_edid, it also needs to pass which scanout we should retrieve the edid for. The VHOST_USER_GPU_PROTOCOL_F_EDID protocol feature is required if the frontend sets the VIRTIO_GPU_F_EDID virtio-gpu feature. If the frontend sets the virtio-gpu feature but does not support the protocol feature, the backend will abort with an error. Signed-off-by: Erico Nunes Reviewed-by: Marc-André Lureau Message-Id: <20230626164708.1163239-4-ernunes@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/vhost-user-gpu/vugpu.h | 11 ++++ contrib/vhost-user-gpu/vhost-user-gpu.c | 73 +++++++++++++++++++++++-- contrib/vhost-user-gpu/virgl.c | 3 + 3 files changed, 81 insertions(+), 6 deletions(-) diff --git a/contrib/vhost-user-gpu/vugpu.h b/contrib/vhost-user-gpu/vugpu.h index e2864bba68..f0f2069c47 100644 --- a/contrib/vhost-user-gpu/vugpu.h +++ b/contrib/vhost-user-gpu/vugpu.h @@ -36,6 +36,7 @@ typedef enum VhostUserGpuRequest { VHOST_USER_GPU_UPDATE, VHOST_USER_GPU_DMABUF_SCANOUT, VHOST_USER_GPU_DMABUF_UPDATE, + VHOST_USER_GPU_GET_EDID, } VhostUserGpuRequest; typedef struct VhostUserGpuDisplayInfoReply { @@ -83,6 +84,10 @@ typedef struct VhostUserGpuDMABUFScanout { int fd_drm_fourcc; } QEMU_PACKED VhostUserGpuDMABUFScanout; +typedef struct VhostUserGpuEdidRequest { + uint32_t scanout_id; +} QEMU_PACKED VhostUserGpuEdidRequest; + typedef struct VhostUserGpuMsg { uint32_t request; /* VhostUserGpuRequest */ uint32_t flags; @@ -93,6 +98,8 @@ typedef struct VhostUserGpuMsg { VhostUserGpuScanout scanout; VhostUserGpuUpdate update; VhostUserGpuDMABUFScanout dmabuf_scanout; + VhostUserGpuEdidRequest edid_req; + struct virtio_gpu_resp_edid resp_edid; struct virtio_gpu_resp_display_info display_info; uint64_t u64; } payload; @@ -104,6 +111,8 @@ static VhostUserGpuMsg m __attribute__ ((unused)); #define VHOST_USER_GPU_MSG_FLAG_REPLY 0x4 +#define VHOST_USER_GPU_PROTOCOL_F_EDID 0 + struct virtio_gpu_scanout { uint32_t width, height; int x, y; @@ -122,6 +131,7 @@ typedef struct VuGpu { bool virgl; bool virgl_inited; + bool edid_inited; uint32_t inflight; struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS]; @@ -171,6 +181,7 @@ int vg_create_mapping_iov(VuGpu *g, struct iovec **iov); void vg_cleanup_mapping_iov(VuGpu *g, struct iovec *iov, uint32_t count); void vg_get_display_info(VuGpu *vg, struct virtio_gpu_ctrl_command *cmd); +void vg_get_edid(VuGpu *vg, struct virtio_gpu_ctrl_command *cmd); void vg_wait_ok(VuGpu *g); diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-gpu/vhost-user-gpu.c index bfb8d93cf8..2e7815a7a3 100644 --- a/contrib/vhost-user-gpu/vhost-user-gpu.c +++ b/contrib/vhost-user-gpu/vhost-user-gpu.c @@ -303,6 +303,53 @@ vg_get_display_info(VuGpu *vg, struct virtio_gpu_ctrl_command *cmd) cmd->state = VG_CMD_STATE_PENDING; } +static gboolean +get_edid_cb(gint fd, GIOCondition condition, gpointer user_data) +{ + struct virtio_gpu_resp_edid resp_edid; + VuGpu *vg = user_data; + struct virtio_gpu_ctrl_command *cmd = QTAILQ_LAST(&vg->fenceq); + + g_debug("get edid cb"); + assert(cmd->cmd_hdr.type == VIRTIO_GPU_CMD_GET_EDID); + if (!vg_recv_msg(vg, VHOST_USER_GPU_GET_EDID, + sizeof(resp_edid), &resp_edid)) { + return G_SOURCE_CONTINUE; + } + + QTAILQ_REMOVE(&vg->fenceq, cmd, next); + vg_ctrl_response(vg, cmd, &resp_edid.hdr, sizeof(resp_edid)); + + vg->wait_in = 0; + vg_handle_ctrl(&vg->dev.parent, 0); + + return G_SOURCE_REMOVE; +} + +void +vg_get_edid(VuGpu *vg, struct virtio_gpu_ctrl_command *cmd) +{ + struct virtio_gpu_cmd_get_edid get_edid; + + VUGPU_FILL_CMD(get_edid); + virtio_gpu_bswap_32(&get_edid, sizeof(get_edid)); + + VhostUserGpuMsg msg = { + .request = VHOST_USER_GPU_GET_EDID, + .size = sizeof(VhostUserGpuEdidRequest), + .payload.edid_req = { + .scanout_id = get_edid.scanout, + }, + }; + + assert(vg->wait_in == 0); + + vg_send_msg(vg, &msg, -1); + vg->wait_in = g_unix_fd_add(vg->sock_fd, G_IO_IN | G_IO_HUP, + get_edid_cb, vg); + cmd->state = VG_CMD_STATE_PENDING; +} + static void vg_resource_create_2d(VuGpu *g, struct virtio_gpu_ctrl_command *cmd) @@ -837,8 +884,9 @@ vg_process_cmd(VuGpu *vg, struct virtio_gpu_ctrl_command *cmd) case VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING: vg_resource_detach_backing(vg, cmd); break; - /* case VIRTIO_GPU_CMD_GET_EDID: */ - /* break */ + case VIRTIO_GPU_CMD_GET_EDID: + vg_get_edid(vg, cmd); + break; default: g_warning("TODO handle ctrl %x\n", cmd->cmd_hdr.type); cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; @@ -1022,26 +1070,36 @@ vg_queue_set_started(VuDev *dev, int qidx, bool started) static gboolean protocol_features_cb(gint fd, GIOCondition condition, gpointer user_data) { + const uint64_t protocol_edid = (1 << VHOST_USER_GPU_PROTOCOL_F_EDID); VuGpu *g = user_data; - uint64_t u64; + uint64_t protocol_features; VhostUserGpuMsg msg = { .request = VHOST_USER_GPU_GET_PROTOCOL_FEATURES }; - if (!vg_recv_msg(g, msg.request, sizeof(u64), &u64)) { + if (!vg_recv_msg(g, msg.request, + sizeof(protocol_features), &protocol_features)) { return G_SOURCE_CONTINUE; } + protocol_features &= protocol_edid; + msg = (VhostUserGpuMsg) { .request = VHOST_USER_GPU_SET_PROTOCOL_FEATURES, .size = sizeof(uint64_t), - .payload.u64 = 0 + .payload.u64 = protocol_features, }; vg_send_msg(g, &msg, -1); g->wait_in = 0; vg_handle_ctrl(&g->dev.parent, 0); + if (g->edid_inited && !(protocol_features & protocol_edid)) { + g_printerr("EDID feature set by the frontend but it does not support " + "the EDID vhost-user-gpu protocol.\n"); + exit(EXIT_FAILURE); + } + return G_SOURCE_REMOVE; } @@ -1049,7 +1107,7 @@ static void set_gpu_protocol_features(VuGpu *g) { VhostUserGpuMsg msg = { - .request = VHOST_USER_GPU_GET_PROTOCOL_FEATURES + .request = VHOST_USER_GPU_GET_PROTOCOL_FEATURES, }; vg_send_msg(g, &msg, -1); @@ -1086,6 +1144,7 @@ vg_get_features(VuDev *dev) if (opt_virgl) { features |= 1 << VIRTIO_GPU_F_VIRGL; } + features |= 1 << VIRTIO_GPU_F_EDID; return features; } @@ -1103,6 +1162,8 @@ vg_set_features(VuDev *dev, uint64_t features) g->virgl_inited = true; } + g->edid_inited = !!(features & (1 << VIRTIO_GPU_F_EDID)); + g->virgl = virgl; } diff --git a/contrib/vhost-user-gpu/virgl.c b/contrib/vhost-user-gpu/virgl.c index 3e45e1bd33..211aa110a9 100644 --- a/contrib/vhost-user-gpu/virgl.c +++ b/contrib/vhost-user-gpu/virgl.c @@ -495,6 +495,9 @@ void vg_virgl_process_cmd(VuGpu *g, struct virtio_gpu_ctrl_command *cmd) case VIRTIO_GPU_CMD_GET_DISPLAY_INFO: vg_get_display_info(g, cmd); break; + case VIRTIO_GPU_CMD_GET_EDID: + vg_get_edid(g, cmd); + break; default: g_debug("TODO handle ctrl %x\n", cmd->cmd_hdr.type); cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; From patchwork Mon Jul 10 23:02:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806059 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=IlKY+9kc; dkim-atps=neutral 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 4R0KM01hYXz20Ph for ; Tue, 11 Jul 2023 09:04:12 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzuE-0003Ih-4N; Mon, 10 Jul 2023 19:02:58 -0400 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 1qIzuC-0003EJ-Hb for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:56 -0400 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 1qIzu8-00048V-Ix for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030171; 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=nb6A6Tfn52akOK7CEow1SEE448JU/iA9KQYIu4Ch9Y4=; b=IlKY+9kch5Ux6lhyll47OOI2JvWg4651qomYnqOkltdr7w4+9eHjOgHOjaxgbCoreRaBe6 xvtyweI8pGlkvdjcP0IlyXMnesxJyhzitPvIp3DtTd9Dq38ZlUWzVrFLEeT/llz86sYEep 4Q8rQHoXnlcq0Vlgqnl1JUYyvN/WxMA= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-580-mKfRZHl3PSGtLqM12i8iEw-1; Mon, 10 Jul 2023 19:02:50 -0400 X-MC-Unique: mKfRZHl3PSGtLqM12i8iEw-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-315926005c9so1351001f8f.0 for ; Mon, 10 Jul 2023 16:02:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030168; x=1691622168; 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=nb6A6Tfn52akOK7CEow1SEE448JU/iA9KQYIu4Ch9Y4=; b=Ezpqlqtho6ZIatS/QaeGS3PNwoqei98IjGjtOGwoxgRYuGGA+uVmXkzqNjhgt4QD/D npuHrwSHPEYFS8KJnH66sb2DmANiKecROinE1EKYT8AUPBU+onAXNUiGmS7auTsbz/l8 dNsxLxJcQswZezftYPWQytoFWNO8SSZwZTXLROq6vFhkcyo9lvt+eOdfPW15lgHvC1ri lDndZhG/YXCYwk2SQMmb+93Q05T+bajN7C4uMbdMhly8vOtdiN8xnWO6sxgypDiPCg9i 7m1Ei+9C84MQwO3bbDHUClcIY+cDZBwdrjDepdaupq/Jiya951lENDvCx+DGKE/uYJOK 6k/g== X-Gm-Message-State: ABy/qLZEicfQYdlVbKXad+Jxrg3z1fuMHe/59XOqR++9Dme4C45508gx /UPJZQ7rAOloLHUoW2zKWCuTmNOkm88qh2LN/EGm2FNP79f04nYpBGuqMMtPfbekjOAZZBNjwf7 o4Y/PxctoGNSIsKnsclsL3eEpBHFlYSEk8ZEpW5SInScJsEtLDpueMTV2wvplZH1IKqNN X-Received: by 2002:a05:6000:1106:b0:315:a1f9:8667 with SMTP id z6-20020a056000110600b00315a1f98667mr1629369wrw.23.1689030168535; Mon, 10 Jul 2023 16:02:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlF69jdgfhfU9drK42HR4CwHmai1MM71ZceVhNsAGcuYmn+cPRuLH9q21+DXyp3VagyFNdpUbw== X-Received: by 2002:a05:6000:1106:b0:315:a1f9:8667 with SMTP id z6-20020a056000110600b00315a1f98667mr1629353wrw.23.1689030168239; Mon, 10 Jul 2023 16:02:48 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id o7-20020a5d6707000000b002c70ce264bfsm576055wru.76.2023.07.10.16.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:02:47 -0700 (PDT) Date: Mon, 10 Jul 2023 19:02:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Erico Nunes , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , Gerd Hoffmann Subject: [PULL 07/66] vhost-user-gpu: implement get_edid frontend feature Message-ID: <31f137e3d6c596883ecd572ff3c53eb03b0e87c7.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Erico Nunes Implement the frontend side of the get_edid feature in the qemu vhost-user-gpu frontend device. Signed-off-by: Erico Nunes Reviewed-by: Marc-André Lureau Message-Id: <20230626164708.1163239-5-ernunes@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/display/vhost-user-gpu.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 15f9d99d09..543ea92721 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -31,6 +31,7 @@ typedef enum VhostUserGpuRequest { VHOST_USER_GPU_UPDATE, VHOST_USER_GPU_DMABUF_SCANOUT, VHOST_USER_GPU_DMABUF_UPDATE, + VHOST_USER_GPU_GET_EDID, } VhostUserGpuRequest; typedef struct VhostUserGpuDisplayInfoReply { @@ -78,6 +79,10 @@ typedef struct VhostUserGpuDMABUFScanout { int fd_drm_fourcc; } QEMU_PACKED VhostUserGpuDMABUFScanout; +typedef struct VhostUserGpuEdidRequest { + uint32_t scanout_id; +} QEMU_PACKED VhostUserGpuEdidRequest; + typedef struct VhostUserGpuMsg { uint32_t request; /* VhostUserGpuRequest */ uint32_t flags; @@ -88,6 +93,8 @@ typedef struct VhostUserGpuMsg { VhostUserGpuScanout scanout; VhostUserGpuUpdate update; VhostUserGpuDMABUFScanout dmabuf_scanout; + VhostUserGpuEdidRequest edid_req; + struct virtio_gpu_resp_edid resp_edid; struct virtio_gpu_resp_display_info display_info; uint64_t u64; } payload; @@ -99,6 +106,8 @@ static VhostUserGpuMsg m __attribute__ ((unused)); #define VHOST_USER_GPU_MSG_FLAG_REPLY 0x4 +#define VHOST_USER_GPU_PROTOCOL_F_EDID 0 + static void vhost_user_gpu_update_blocked(VhostUserGPU *g, bool blocked); static void @@ -161,6 +170,9 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg) .request = msg->request, .flags = VHOST_USER_GPU_MSG_FLAG_REPLY, .size = sizeof(uint64_t), + .payload = { + .u64 = (1 << VHOST_USER_GPU_PROTOCOL_F_EDID) + } }; vhost_user_gpu_send_msg(g, &reply); @@ -184,6 +196,26 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg) vhost_user_gpu_send_msg(g, &reply); break; } + case VHOST_USER_GPU_GET_EDID: { + VhostUserGpuEdidRequest *m = &msg->payload.edid_req; + struct virtio_gpu_resp_edid resp = { {} }; + VhostUserGpuMsg reply = { + .request = msg->request, + .flags = VHOST_USER_GPU_MSG_FLAG_REPLY, + .size = sizeof(reply.payload.resp_edid), + }; + + if (m->scanout_id >= g->parent_obj.conf.max_outputs) { + error_report("invalid scanout: %d", m->scanout_id); + break; + } + + resp.hdr.type = VIRTIO_GPU_RESP_OK_EDID; + virtio_gpu_base_generate_edid(VIRTIO_GPU_BASE(g), m->scanout_id, &resp); + memcpy(&reply.payload.resp_edid, &resp, sizeof(resp)); + vhost_user_gpu_send_msg(g, &reply); + break; + } case VHOST_USER_GPU_SCANOUT: { VhostUserGpuScanout *m = &msg->payload.scanout; From patchwork Mon Jul 10 23:02:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806104 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=JAPbkF4B; dkim-atps=neutral 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 4R0KT82R6bz20ZZ for ; Tue, 11 Jul 2023 09:09:32 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzuK-0003ZD-1Y; Mon, 10 Jul 2023 19:03:04 -0400 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 1qIzuI-0003RX-6V for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:02 -0400 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 1qIzuA-000498-Rd for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030174; 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=MzgY2YQ6D5tMY/mE621QwwjCaplHfEWxVWzGlVYyn5w=; b=JAPbkF4BcujVgJWz+agyrhGJk9R8Fe7OaQP/mqey4wCyX8FARmnXmbNAiSENc4BO3w1KEV q4VKhvkMkqvFY2u0wlJYhlUUB2Qy01brrZRDxxPgt5tB/4D9IE4jPLAiNwjEWF7DgOUQrn bTi3BeNFHKKeCkdbhjgDyaK+nip9Gg0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-607-lXFfgUZLNvus971uwOsxUA-1; Mon, 10 Jul 2023 19:02:53 -0400 X-MC-Unique: lXFfgUZLNvus971uwOsxUA-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fa8cd898e0so34200825e9.3 for ; Mon, 10 Jul 2023 16:02:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030171; x=1691622171; 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=MzgY2YQ6D5tMY/mE621QwwjCaplHfEWxVWzGlVYyn5w=; b=YRGOgMDoRS3G1+7SS+aOmgdOcEQQqfRQTWEN+0hoZtIeyfY4WOID9tlleph0GQwKlj 6H28WjqGqJmDh8y5IBxDMFfe8oKuUFjrGaxSb02Z/bGBwx6IcmeKELXKC5ARRMIeDPYY 1RsHm4C0P6gtPm+Oz6DuSKVVT2cgkr1OTE0i09AbekwAHBgP148rz8DLKeITDnNsqhtn UjuiGwScHH3WxpuUvWfSf5ARR1trLJWaeXdRGWSzQxgmAj0NeFW+UBMSQGGIj7Am7K5R rH3Zq/TcHj7EHH05x601Cb+ZsSGCVsD1K/V7FltFmwaXCUZCEEKccjGj+Q9aga1tU5x+ 6KbA== X-Gm-Message-State: ABy/qLbfroIGMK28AIM7y2xlZ45IdZTjvEHyEHHZuwdMZSwX66YqMGdF 1YVnx6hlcQKh928AnuSmyOF8aXJC9C72DTNiUSNqbu8xej4NbsOKO8dvbT0bSIGuRyDh5dCJ3wl Ngl2Jii37xM9uk67N3B4V3BR/oc9Nqwhjs/MAwZQukHwINXiZR6KCttxn1ddUx+7uoFJe X-Received: by 2002:a1c:7505:0:b0:3f9:846:d892 with SMTP id o5-20020a1c7505000000b003f90846d892mr13357815wmc.9.1689030171251; Mon, 10 Jul 2023 16:02:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGo98k6FF772kTLtyapMoRsF8Nl2piqOg9JSgEXH3ipBU9CaOgU9w47nNDpdRkcdG9Om0XxRA== X-Received: by 2002:a1c:7505:0:b0:3f9:846:d892 with SMTP id o5-20020a1c7505000000b003f90846d892mr13357800wmc.9.1689030170917; Mon, 10 Jul 2023 16:02:50 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id o6-20020adfeac6000000b00314145e6d61sm612554wrn.6.2023.07.10.16.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:02:50 -0700 (PDT) Date: Mon, 10 Jul 2023 19:02:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Milan Zamazal , Paolo Bonzini Subject: [PULL 08/66] hw/virtio: Add boilerplate for vhost-user-scmi device 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Milan Zamazal This creates the QEMU side of the vhost-user-scmi device which connects to the remote daemon. It is based on code of similar vhost-user devices. Signed-off-by: Milan Zamazal Message-Id: <20230628100524.342666-2-mzamazal@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user-scmi.h | 30 +++ hw/virtio/vhost-user-scmi.c | 306 ++++++++++++++++++++++++++++ MAINTAINERS | 6 + hw/virtio/Kconfig | 5 + hw/virtio/meson.build | 1 + 5 files changed, 348 insertions(+) create mode 100644 include/hw/virtio/vhost-user-scmi.h create mode 100644 hw/virtio/vhost-user-scmi.c diff --git a/include/hw/virtio/vhost-user-scmi.h b/include/hw/virtio/vhost-user-scmi.h new file mode 100644 index 0000000000..6175a74ebd --- /dev/null +++ b/include/hw/virtio/vhost-user-scmi.h @@ -0,0 +1,30 @@ +/* + * Vhost-user SCMI virtio device + * + * Copyright (c) 2023 Red Hat, Inc. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _QEMU_VHOST_USER_SCMI_H +#define _QEMU_VHOST_USER_SCMI_H + +#include "hw/virtio/virtio.h" +#include "hw/virtio/vhost.h" +#include "hw/virtio/vhost-user.h" + +#define TYPE_VHOST_USER_SCMI "vhost-user-scmi" +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserSCMI, VHOST_USER_SCMI); + +struct VHostUserSCMI { + VirtIODevice parent; + CharBackend chardev; + struct vhost_virtqueue *vhost_vqs; + struct vhost_dev vhost_dev; + VhostUserState vhost_user; + VirtQueue *cmd_vq; + VirtQueue *event_vq; + bool connected; +}; + +#endif /* _QEMU_VHOST_USER_SCMI_H */ diff --git a/hw/virtio/vhost-user-scmi.c b/hw/virtio/vhost-user-scmi.c new file mode 100644 index 0000000000..d386fb2df9 --- /dev/null +++ b/hw/virtio/vhost-user-scmi.c @@ -0,0 +1,306 @@ +/* + * Vhost-user SCMI virtio device + * + * SPDX-FileCopyrightText: Red Hat, Inc. + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Implementation based on other vhost-user devices in QEMU. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "hw/virtio/virtio-bus.h" +#include "hw/virtio/vhost-user-scmi.h" +#include "standard-headers/linux/virtio_ids.h" +#include "standard-headers/linux/virtio_scmi.h" +#include "trace.h" + +/* + * In this version, we don't support VIRTIO_SCMI_F_SHARED_MEMORY. + * Note that VIRTIO_SCMI_F_SHARED_MEMORY is currently not supported in + * Linux VirtIO SCMI guest driver. + */ +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_F_RING_RESET, + VIRTIO_SCMI_F_P2A_CHANNELS, + VHOST_INVALID_FEATURE_BIT +}; + +static int vu_scmi_start(VirtIODevice *vdev) +{ + VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev); + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + struct vhost_dev *vhost_dev = &scmi->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; + } + + vhost_ack_features(&scmi->vhost_dev, feature_bits, vdev->guest_features); + + ret = vhost_dev_start(&scmi->vhost_dev, vdev, true); + if (ret < 0) { + error_report("Error starting vhost-user-scmi: %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 < scmi->vhost_dev.nvqs; i++) { + vhost_virtqueue_mask(&scmi->vhost_dev, vdev, i, false); + } + return 0; + +err_guest_notifiers: + k->set_guest_notifiers(qbus->parent, vhost_dev->nvqs, false); +err_host_notifiers: + vhost_dev_disable_notifiers(vhost_dev, vdev); + + return ret; +} + +static void vu_scmi_stop(VirtIODevice *vdev) +{ + VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev); + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + struct vhost_dev *vhost_dev = &scmi->vhost_dev; + int ret; + + if (!k->set_guest_notifiers) { + return; + } + + vhost_dev_stop(vhost_dev, vdev, true); + + 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_scmi_set_status(VirtIODevice *vdev, uint8_t status) +{ + VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev); + bool should_start = virtio_device_should_start(vdev, status); + + if (!scmi->connected) { + return; + } + if (vhost_dev_is_started(&scmi->vhost_dev) == should_start) { + return; + } + + if (should_start) { + vu_scmi_start(vdev); + } else { + vu_scmi_stop(vdev); + } +} + +static uint64_t vu_scmi_get_features(VirtIODevice *vdev, uint64_t features, + Error **errp) +{ + VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev); + + return vhost_get_features(&scmi->vhost_dev, feature_bits, features); +} + +static void vu_scmi_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_scmi_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) +{ + VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev); + + if (idx == VIRTIO_CONFIG_IRQ_IDX) { + return; + } + + vhost_virtqueue_mask(&scmi->vhost_dev, vdev, idx, mask); +} + +static bool vu_scmi_guest_notifier_pending(VirtIODevice *vdev, int idx) +{ + VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev); + + return vhost_virtqueue_pending(&scmi->vhost_dev, idx); +} + +static void vu_scmi_connect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev); + + if (scmi->connected) { + return; + } + scmi->connected = true; + + /* restore vhost state */ + if (virtio_device_started(vdev, vdev->status)) { + vu_scmi_start(vdev); + } +} + +static void vu_scmi_disconnect(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserSCMI *scmi = VHOST_USER_SCMI(vdev); + + if (!scmi->connected) { + return; + } + scmi->connected = false; + + if (vhost_dev_is_started(&scmi->vhost_dev)) { + vu_scmi_stop(vdev); + } +} + +static void vu_scmi_event(void *opaque, QEMUChrEvent event) +{ + DeviceState *dev = opaque; + + switch (event) { + case CHR_EVENT_OPENED: + vu_scmi_connect(dev); + break; + case CHR_EVENT_CLOSED: + vu_scmi_disconnect(dev); + break; + case CHR_EVENT_BREAK: + case CHR_EVENT_MUX_IN: + case CHR_EVENT_MUX_OUT: + /* Ignore */ + break; + } +} + +static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserSCMI *scmi) +{ + virtio_delete_queue(scmi->cmd_vq); + virtio_delete_queue(scmi->event_vq); + g_free(scmi->vhost_dev.vqs); + virtio_cleanup(vdev); + vhost_user_cleanup(&scmi->vhost_user); +} + +static void vu_scmi_device_realize(DeviceState *dev, Error **errp) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserSCMI *scmi = VHOST_USER_SCMI(dev); + int ret; + + if (!scmi->chardev.chr) { + error_setg(errp, "vhost-user-scmi: chardev is mandatory"); + return; + } + + vdev->host_features |= (1ULL << VIRTIO_SCMI_F_P2A_CHANNELS); + + if (!vhost_user_init(&scmi->vhost_user, &scmi->chardev, errp)) { + return; + } + + virtio_init(vdev, VIRTIO_ID_SCMI, 0); + + scmi->cmd_vq = virtio_add_queue(vdev, 256, vu_scmi_handle_output); + scmi->event_vq = virtio_add_queue(vdev, 256, vu_scmi_handle_output); + scmi->vhost_dev.nvqs = 2; + scmi->vhost_dev.vqs = g_new0(struct vhost_virtqueue, scmi->vhost_dev.nvqs); + + ret = vhost_dev_init(&scmi->vhost_dev, &scmi->vhost_user, + VHOST_BACKEND_TYPE_USER, 0, errp); + if (ret < 0) { + error_setg_errno(errp, -ret, + "vhost-user-scmi: vhost_dev_init() failed"); + do_vhost_user_cleanup(vdev, scmi); + return; + } + + qemu_chr_fe_set_handlers(&scmi->chardev, NULL, NULL, vu_scmi_event, NULL, + dev, NULL, true); + + return; +} + +static void vu_scmi_device_unrealize(DeviceState *dev) +{ + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + VHostUserSCMI *scmi = VHOST_USER_SCMI(dev); + + vu_scmi_set_status(vdev, 0); + vhost_dev_cleanup(&scmi->vhost_dev); + do_vhost_user_cleanup(vdev, scmi); +} + +static const VMStateDescription vu_scmi_vmstate = { + .name = "vhost-user-scmi", + .unmigratable = 1, +}; + +static Property vu_scmi_properties[] = { + DEFINE_PROP_CHR("chardev", VHostUserSCMI, chardev), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vu_scmi_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + + device_class_set_props(dc, vu_scmi_properties); + dc->vmsd = &vu_scmi_vmstate; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + vdc->realize = vu_scmi_device_realize; + vdc->unrealize = vu_scmi_device_unrealize; + vdc->get_features = vu_scmi_get_features; + vdc->set_status = vu_scmi_set_status; + vdc->guest_notifier_mask = vu_scmi_guest_notifier_mask; + vdc->guest_notifier_pending = vu_scmi_guest_notifier_pending; +} + +static const TypeInfo vu_scmi_info = { + .name = TYPE_VHOST_USER_SCMI, + .parent = TYPE_VIRTIO_DEVICE, + .instance_size = sizeof(VHostUserSCMI), + .class_init = vu_scmi_class_init, +}; + +static void vu_scmi_register_types(void) +{ + type_register_static(&vu_scmi_info); +} + +type_init(vu_scmi_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index 1817cfc62f..504dddb7dd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2217,6 +2217,12 @@ F: hw/virtio/vhost-user-gpio* F: include/hw/virtio/vhost-user-gpio.h F: tests/qtest/libqos/virtio-gpio.* +vhost-user-scmi +R: mzamazal@redhat.com +S: Supported +F: hw/virtio/vhost-user-scmi* +F: include/hw/virtio/vhost-user-scmi.h + virtio-crypto M: Gonglei S: Supported diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig index de7a35429a..a9ee09062f 100644 --- a/hw/virtio/Kconfig +++ b/hw/virtio/Kconfig @@ -96,3 +96,8 @@ config VHOST_VDPA_DEV bool default y depends on VIRTIO && VHOST_VDPA && LINUX + +config VHOST_USER_SCMI + bool + default y + depends on VIRTIO && VHOST_USER diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index f32b22f61b..4a4d7e1c27 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -35,6 +35,7 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user 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')) virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c')) From patchwork Mon Jul 10 23:02:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=LHqWz4Vn; dkim-atps=neutral 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 4R0KLK5Lgpz20ZZ for ; Tue, 11 Jul 2023 09:03:37 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzuG-0003Jy-C9; Mon, 10 Jul 2023 19:03:00 -0400 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 1qIzuE-0003JE-Lw for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:58 -0400 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 1qIzuD-00049f-4M for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:02:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030176; 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=ZkQdbFHoz6KUjwAnffgufnSjDWO7ahW1tpRCAX7lWrg=; b=LHqWz4VnT672KmE9pHn8MMiKomonJxekbbv2+j7ojhaBTeselzMAqOXpzxKOBbK+zNvTSe wFq32UIRHiqXD2J2v77tGpmpsj2ZbPoWxyhVnhECfQ2A64tKdWzyOb8iOAzdDGJGjucCjg EhjZRNsjJxpStgXLuLtxok/4teYIskg= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-194-_RNvyqTfPfSbFSsETxTh6g-1; Mon, 10 Jul 2023 19:02:55 -0400 X-MC-Unique: _RNvyqTfPfSbFSsETxTh6g-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fb40ec952bso29651055e9.0 for ; Mon, 10 Jul 2023 16:02:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030173; x=1691622173; 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=ZkQdbFHoz6KUjwAnffgufnSjDWO7ahW1tpRCAX7lWrg=; b=CXkjnFjanAHpFObgSfUUc+gw8tjOR3vx+sE25epj47UDh6j0Az5flUwEfkwyzyZUWo Yep8hx8RnP8EflgC4yVcBXGSgeW0WrYI8+wFtLGZySTuInwp+HsIs0vozNCedFmFI3Wz pzjK98xpk6F2OP+/X0ZiW81V8yYil90sqXQL0hrIIODzKtc3D2nk5nUOgyv71brCPKK9 SsusQ0G7xeERj5/YcVMy2PwuuxBj+ev3Ul9hhlgUbbckQRMt3PEgQUsg8+3yvTpSfBsv VUT9PIIHd8/0ZqL/33jghbqe8KbBjRT2gla6yK5A4U4OtSVCDCgxMOPAaCd0w/XDuDl3 fyZQ== X-Gm-Message-State: ABy/qLbQNwXOANxWdJ7hsZ4XFiasP9Xi/4DMHKUUjoYk4EqnEizi+sOv ULbpeJumKa/HQ6Z+cgEyHqghUy5eO4o3txIxKM1mzJaOgFrQzkihVunFomVxQ7lNsKttTxdN6O7 FgxJuYEGf+EOzyIwxoBoH1rQrditYaYTqiQs/pUn9c5sFjSyi0e5oGjllgrekh+MsXJug X-Received: by 2002:a7b:c050:0:b0:3fc:10:b25b with SMTP id u16-20020a7bc050000000b003fc0010b25bmr11219426wmc.21.1689030173663; Mon, 10 Jul 2023 16:02:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlH3/azalc04vxyMD8YY7HUwguMIFWHiZC7zaZVNU/HvhgKwKbcLC5vS5VfBSmhV1zWmL02MiQ== X-Received: by 2002:a7b:c050:0:b0:3fc:10:b25b with SMTP id u16-20020a7bc050000000b003fc0010b25bmr11219414wmc.21.1689030173404; Mon, 10 Jul 2023 16:02:53 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id 13-20020a05600c228d00b003fbe4cecc3bsm11371169wmf.16.2023.07.10.16.02.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:02:53 -0700 (PDT) Date: Mon, 10 Jul 2023 19:02:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Milan Zamazal Subject: [PULL 09/66] hw/virtio: Add vhost-user-scmi-pci boilerplate 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Milan Zamazal This allows is to instantiate a vhost-user-scmi device as part of a PCI bus. It is mostly boilerplate similar to the other vhost-user-*-pci boilerplates of similar devices. Signed-off-by: Milan Zamazal Message-Id: <20230628100524.342666-3-mzamazal@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user-scmi-pci.c | 68 +++++++++++++++++++++++++++++++++ hw/virtio/meson.build | 1 + 2 files changed, 69 insertions(+) create mode 100644 hw/virtio/vhost-user-scmi-pci.c diff --git a/hw/virtio/vhost-user-scmi-pci.c b/hw/virtio/vhost-user-scmi-pci.c new file mode 100644 index 0000000000..7f53af7fce --- /dev/null +++ b/hw/virtio/vhost-user-scmi-pci.c @@ -0,0 +1,68 @@ +/* + * Vhost-user SCMI virtio device PCI glue + * + * SPDX-FileCopyrightText: Red Hat, Inc. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/vhost-user-scmi.h" +#include "hw/virtio/virtio-pci.h" + +struct VHostUserSCMIPCI { + VirtIOPCIProxy parent_obj; + VHostUserSCMI vdev; +}; + +typedef struct VHostUserSCMIPCI VHostUserSCMIPCI; + +#define TYPE_VHOST_USER_SCMI_PCI "vhost-user-scmi-pci-base" + +DECLARE_INSTANCE_CHECKER(VHostUserSCMIPCI, VHOST_USER_SCMI_PCI, + TYPE_VHOST_USER_SCMI_PCI) + +static void vhost_user_scmi_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) +{ + VHostUserSCMIPCI *dev = VHOST_USER_SCMI_PCI(vpci_dev); + DeviceState *vdev = DEVICE(&dev->vdev); + + vpci_dev->nvectors = 1; + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void vhost_user_scmi_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_scmi_pci_realize; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + 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_COMMUNICATION_OTHER; +} + +static void vhost_user_scmi_pci_instance_init(Object *obj) +{ + VHostUserSCMIPCI *dev = VHOST_USER_SCMI_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VHOST_USER_SCMI); +} + +static const VirtioPCIDeviceTypeInfo vhost_user_scmi_pci_info = { + .base_name = TYPE_VHOST_USER_SCMI_PCI, + .non_transitional_name = "vhost-user-scmi-pci", + .instance_size = sizeof(VHostUserSCMIPCI), + .instance_init = vhost_user_scmi_pci_instance_init, + .class_init = vhost_user_scmi_pci_class_init, +}; + +static void vhost_user_scmi_pci_register(void) +{ + virtio_pci_types_register(&vhost_user_scmi_pci_info); +} + +type_init(vhost_user_scmi_pci_register); diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 4a4d7e1c27..c4f4fe05fa 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -36,6 +36,7 @@ specific_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user 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')) virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c')) From patchwork Mon Jul 10 23:02:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806052 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=EUZMjUw8; dkim-atps=neutral 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 4R0KLK16rSz20Ph for ; Tue, 11 Jul 2023 09:03:37 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzuJ-0003YI-PG; Mon, 10 Jul 2023 19:03:03 -0400 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 1qIzuI-0003Re-84 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:02 -0400 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 1qIzuG-0004A0-6P for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030179; 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=nqd/Fy8W0/ZAKxo97suoRR5PKde+OrdOQHeLimuza+w=; b=EUZMjUw8XiOReZIC296qN/Y/QQaBjVmqpYejvQm3RsGxhczClLVs714+VeokUxWt1vdSyu UtrRO/j40Tbo3yxx7h2SNAMTZdkBEsSjYUOGvGmYhkOiJ3Ma0Jyd7pPM4O+yF/4hqgT6cu CxGteB1MqbW1ZUgoHyvylRT4TN4o60o= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-527-AWO9IX7PNq-oyR6LpGCJSw-1; Mon, 10 Jul 2023 19:02:58 -0400 X-MC-Unique: AWO9IX7PNq-oyR6LpGCJSw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3f5fa06debcso34382805e9.0 for ; Mon, 10 Jul 2023 16:02:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030176; x=1691622176; 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=nqd/Fy8W0/ZAKxo97suoRR5PKde+OrdOQHeLimuza+w=; b=EkZnQKyRlqZ9TmSaBg4971fQgyG0OVusLLMesLdue5LcT///DJLhxxS07wFGzKP2Fp BTlSVBN0UJvosCB9twkqTzJHKW2VxLhHXpddgZI0jw3CyEKTnN++pC8CF7X7aaagafdX Jgadwoa06jcJ5aor94R/vp0K9mGi+W41tgrh8scEC9SU+OsJQiPdNwskXhtG4XP+8KrU vUQxVRakG3XtBz6s5l0knviSfxLeMXDBYgbIaZUDJsFAJcc5g7dVuSNG1uvKQM+kb5bL d1R69kad2o3ninA9tuilq7LwMNd/RHek9ZnjC94GLcLUdNocPxjIrS0o/ZypKTI9xHFT Ttig== X-Gm-Message-State: ABy/qLbkyqLoqLRzs8/Rxv6dhaQhE5gyyfv0pW0AK+rrxGWeWc+vn5OK TgXg2aj6NQ9nvzRwZwy9dMxZ0wAIQIqRFmcy4Sz5xleN0ikGapCDIoIFJ2jG22OSYy4QXX3kQk4 z2LP4hW9DTDjwdpRnKBn42eRh413qRwbDuagGksJVqU7ItF8el2ebjllq+1/9MZiV2Goq X-Received: by 2002:a1c:ed14:0:b0:3fb:cf8e:c934 with SMTP id l20-20020a1ced14000000b003fbcf8ec934mr13961604wmh.27.1689030176704; Mon, 10 Jul 2023 16:02:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlHEC4j3aFf9friRFInab0Cw4b6VVlb2bNSP4JAQNOapiNOsZAzyJ1sz/fz4EZvngeb+P3TL8A== X-Received: by 2002:a1c:ed14:0:b0:3fb:cf8e:c934 with SMTP id l20-20020a1ced14000000b003fbcf8ec934mr13961590wmh.27.1689030176397; Mon, 10 Jul 2023 16:02:56 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id hn32-20020a05600ca3a000b003fbdd5d0758sm939466wmb.22.2023.07.10.16.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:02:55 -0700 (PDT) Date: Mon, 10 Jul 2023 19:02:53 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Milan Zamazal , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL 10/66] tests/qtest: enable tests for virtio-scmi 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Milan Zamazal We don't have a virtio-scmi implementation in QEMU and only support a vhost-user backend. This is very similar to virtio-gpio and we add the same set of tests, just passing some vhost-user messages over the control socket. Signed-off-by: Milan Zamazal Acked-by: Thomas Huth Message-Id: <20230628100524.342666-4-mzamazal@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/libqos/virtio-scmi.h | 34 ++++++ tests/qtest/libqos/virtio-scmi.c | 174 +++++++++++++++++++++++++++++++ tests/qtest/vhost-user-test.c | 44 ++++++++ MAINTAINERS | 1 + tests/qtest/libqos/meson.build | 1 + 5 files changed, 254 insertions(+) create mode 100644 tests/qtest/libqos/virtio-scmi.h create mode 100644 tests/qtest/libqos/virtio-scmi.c diff --git a/tests/qtest/libqos/virtio-scmi.h b/tests/qtest/libqos/virtio-scmi.h new file mode 100644 index 0000000000..cb5670da6e --- /dev/null +++ b/tests/qtest/libqos/virtio-scmi.h @@ -0,0 +1,34 @@ +/* + * virtio-scmi structures + * + * SPDX-FileCopyrightText: Red Hat, Inc. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef TESTS_LIBQOS_VIRTIO_SCMI_H +#define TESTS_LIBQOS_VIRTIO_SCMI_H + +#include "qgraph.h" +#include "virtio.h" +#include "virtio-pci.h" + +typedef struct QVhostUserSCMI QVhostUserSCMI; +typedef struct QVhostUserSCMIPCI QVhostUserSCMIPCI; +typedef struct QVhostUserSCMIDevice QVhostUserSCMIDevice; + +struct QVhostUserSCMI { + QVirtioDevice *vdev; + QVirtQueue **queues; +}; + +struct QVhostUserSCMIPCI { + QVirtioPCIDevice pci_vdev; + QVhostUserSCMI scmi; +}; + +struct QVhostUserSCMIDevice { + QOSGraphObject obj; + QVhostUserSCMI scmi; +}; + +#endif diff --git a/tests/qtest/libqos/virtio-scmi.c b/tests/qtest/libqos/virtio-scmi.c new file mode 100644 index 0000000000..ce8f4d5c06 --- /dev/null +++ b/tests/qtest/libqos/virtio-scmi.c @@ -0,0 +1,174 @@ +/* + * virtio-scmi nodes for testing + * + * SPDX-FileCopyrightText: Linaro Ltd + * SPDX-FileCopyrightText: Red Hat, Inc. + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Based on virtio-gpio.c, doing basically the same thing. + */ + +#include "qemu/osdep.h" +#include "standard-headers/linux/virtio_config.h" +#include "../libqtest.h" +#include "qemu/module.h" +#include "qgraph.h" +#include "virtio-scmi.h" + +static QGuestAllocator *alloc; + +static void virtio_scmi_cleanup(QVhostUserSCMI *scmi) +{ + QVirtioDevice *vdev = scmi->vdev; + int i; + + for (i = 0; i < 2; i++) { + qvirtqueue_cleanup(vdev->bus, scmi->queues[i], alloc); + } + g_free(scmi->queues); +} + +/* + * This handles the VirtIO setup from the point of view of the driver + * frontend and therefore doesn't present any vhost specific features + * and in fact masks of the re-used bit. + */ +static void virtio_scmi_setup(QVhostUserSCMI *scmi) +{ + QVirtioDevice *vdev = scmi->vdev; + uint64_t features; + int i; + + features = qvirtio_get_features(vdev); + features &= ~QVIRTIO_F_BAD_FEATURE; + qvirtio_set_features(vdev, features); + + scmi->queues = g_new(QVirtQueue *, 2); + for (i = 0; i < 2; i++) { + scmi->queues[i] = qvirtqueue_setup(vdev, alloc, i); + } + qvirtio_set_driver_ok(vdev); +} + +static void *qvirtio_scmi_get_driver(QVhostUserSCMI *v_scmi, + const char *interface) +{ + if (!g_strcmp0(interface, "vhost-user-scmi")) { + return v_scmi; + } + if (!g_strcmp0(interface, "virtio")) { + return v_scmi->vdev; + } + + g_assert_not_reached(); +} + +static void *qvirtio_scmi_device_get_driver(void *object, + const char *interface) +{ + QVhostUserSCMIDevice *v_scmi = object; + return qvirtio_scmi_get_driver(&v_scmi->scmi, interface); +} + +/* virtio-scmi (mmio) */ +static void qvirtio_scmi_device_destructor(QOSGraphObject *obj) +{ + QVhostUserSCMIDevice *scmi_dev = (QVhostUserSCMIDevice *) obj; + virtio_scmi_cleanup(&scmi_dev->scmi); +} + +static void qvirtio_scmi_device_start_hw(QOSGraphObject *obj) +{ + QVhostUserSCMIDevice *scmi_dev = (QVhostUserSCMIDevice *) obj; + virtio_scmi_setup(&scmi_dev->scmi); +} + +static void *virtio_scmi_device_create(void *virtio_dev, + QGuestAllocator *t_alloc, + void *addr) +{ + QVhostUserSCMIDevice *virtio_device = g_new0(QVhostUserSCMIDevice, 1); + QVhostUserSCMI *interface = &virtio_device->scmi; + + interface->vdev = virtio_dev; + alloc = t_alloc; + + virtio_device->obj.get_driver = qvirtio_scmi_device_get_driver; + virtio_device->obj.start_hw = qvirtio_scmi_device_start_hw; + virtio_device->obj.destructor = qvirtio_scmi_device_destructor; + + return &virtio_device->obj; +} + +/* virtio-scmi-pci */ +static void qvirtio_scmi_pci_destructor(QOSGraphObject *obj) +{ + QVhostUserSCMIPCI *scmi_pci = (QVhostUserSCMIPCI *) obj; + QOSGraphObject *pci_vobj = &scmi_pci->pci_vdev.obj; + + virtio_scmi_cleanup(&scmi_pci->scmi); + qvirtio_pci_destructor(pci_vobj); +} + +static void qvirtio_scmi_pci_start_hw(QOSGraphObject *obj) +{ + QVhostUserSCMIPCI *scmi_pci = (QVhostUserSCMIPCI *) obj; + QOSGraphObject *pci_vobj = &scmi_pci->pci_vdev.obj; + + qvirtio_pci_start_hw(pci_vobj); + virtio_scmi_setup(&scmi_pci->scmi); +} + +static void *qvirtio_scmi_pci_get_driver(void *object, const char *interface) +{ + QVhostUserSCMIPCI *v_scmi = object; + + if (!g_strcmp0(interface, "pci-device")) { + return v_scmi->pci_vdev.pdev; + } + return qvirtio_scmi_get_driver(&v_scmi->scmi, interface); +} + +static void *virtio_scmi_pci_create(void *pci_bus, QGuestAllocator *t_alloc, + void *addr) +{ + QVhostUserSCMIPCI *virtio_spci = g_new0(QVhostUserSCMIPCI, 1); + QVhostUserSCMI *interface = &virtio_spci->scmi; + QOSGraphObject *obj = &virtio_spci->pci_vdev.obj; + + virtio_pci_init(&virtio_spci->pci_vdev, pci_bus, addr); + interface->vdev = &virtio_spci->pci_vdev.vdev; + alloc = t_alloc; + + obj->get_driver = qvirtio_scmi_pci_get_driver; + obj->start_hw = qvirtio_scmi_pci_start_hw; + obj->destructor = qvirtio_scmi_pci_destructor; + + return obj; +} + +static void virtio_scmi_register_nodes(void) +{ + QPCIAddress addr = { + .devfn = QPCI_DEVFN(4, 0), + }; + + QOSGraphEdgeOptions edge_opts = { }; + + /* vhost-user-scmi-device */ + edge_opts.extra_device_opts = "id=scmi,chardev=chr-vhost-user-test " + "-global virtio-mmio.force-legacy=false"; + qos_node_create_driver("vhost-user-scmi-device", + virtio_scmi_device_create); + qos_node_consumes("vhost-user-scmi-device", "virtio-bus", &edge_opts); + qos_node_produces("vhost-user-scmi-device", "vhost-user-scmi"); + + /* virtio-scmi-pci */ + edge_opts.extra_device_opts = "id=scmi,addr=04.0,chardev=chr-vhost-user-test"; + add_qpci_address(&edge_opts, &addr); + qos_node_create_driver("vhost-user-scmi-pci", virtio_scmi_pci_create); + qos_node_consumes("vhost-user-scmi-pci", "pci-bus", &edge_opts); + qos_node_produces("vhost-user-scmi-pci", "vhost-user-scmi"); +} + +libqos_init(virtio_scmi_register_nodes); diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index dfb8003597..d4e437265f 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -33,6 +33,7 @@ #include "standard-headers/linux/virtio_ids.h" #include "standard-headers/linux/virtio_net.h" #include "standard-headers/linux/virtio_gpio.h" +#include "standard-headers/linux/virtio_scmi.h" #ifdef CONFIG_LINUX #include @@ -145,6 +146,7 @@ enum { enum { VHOST_USER_NET, VHOST_USER_GPIO, + VHOST_USER_SCMI, }; typedef struct TestServer { @@ -1157,3 +1159,45 @@ static void register_vhost_gpio_test(void) "vhost-user-gpio", test_read_guest_mem, &opts); } libqos_init(register_vhost_gpio_test); + +static uint64_t vu_scmi_get_features(TestServer *s) +{ + return 0x1ULL << VIRTIO_F_VERSION_1 | + 0x1ULL << VIRTIO_SCMI_F_P2A_CHANNELS | + 0x1ULL << VHOST_USER_F_PROTOCOL_FEATURES; +} + +static void vu_scmi_get_protocol_features(TestServer *s, CharBackend *chr, + VhostUserMsg *msg) +{ + msg->flags |= VHOST_USER_REPLY_MASK; + msg->size = sizeof(m.payload.u64); + msg->payload.u64 = 1ULL << VHOST_USER_PROTOCOL_F_MQ; + + qemu_chr_fe_write_all(chr, (uint8_t *)msg, VHOST_USER_HDR_SIZE + msg->size); +} + +static struct vhost_user_ops g_vu_scmi_ops = { + .type = VHOST_USER_SCMI, + + .append_opts = append_vhost_gpio_opts, + + .get_features = vu_scmi_get_features, + .set_features = vu_net_set_features, + .get_protocol_features = vu_scmi_get_protocol_features, +}; + +static void register_vhost_scmi_test(void) +{ + QOSGraphTestOptions opts = { + .before = vhost_user_test_setup, + .subprocess = true, + .arg = &g_vu_scmi_ops, + }; + + qemu_add_opts(&qemu_chardev_opts); + + qos_add_test("scmi/read-guest-mem/memfile", + "vhost-user-scmi", test_read_guest_mem, &opts); +} +libqos_init(register_vhost_scmi_test); diff --git a/MAINTAINERS b/MAINTAINERS index 504dddb7dd..8f642141d0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2222,6 +2222,7 @@ R: mzamazal@redhat.com S: Supported F: hw/virtio/vhost-user-scmi* F: include/hw/virtio/vhost-user-scmi.h +F: tests/qtest/libqos/virtio-scmi.* virtio-crypto M: Gonglei diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build index cc209a8de5..90aae42a22 100644 --- a/tests/qtest/libqos/meson.build +++ b/tests/qtest/libqos/meson.build @@ -46,6 +46,7 @@ libqos_srcs = files( 'virtio-serial.c', 'virtio-iommu.c', 'virtio-gpio.c', + 'virtio-scmi.c', 'generic-pcihost.c', # qgraph machines: From patchwork Mon Jul 10 23:02:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806075 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=i6UIcr4D; dkim-atps=neutral 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 4R0KQr5TKgz20ZZ for ; Tue, 11 Jul 2023 09:07:32 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzuL-0003fS-V9; Mon, 10 Jul 2023 19:03:05 -0400 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 1qIzuK-0003aY-81 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:04 -0400 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 1qIzuI-0004AL-PF for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030182; 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=is4JU1X/3OUSKq/URlPYqO+soLMMDT1XVm32TNN7udw=; b=i6UIcr4DGEvmfTPlSGGrrh/hamUA6RTquqMNh9MP1ncwpfZVWguH06AdQRcfAC4zOSzf7/ cE6r5FRw7v7ytMn5ayKZrG5srLK//wdTJYaO2uFlK7v/TxJkhLb2bvt0v8RHKX8uYpE7Ek UDGA335p/gexb7vPRHy9/IhGfbU1fTw= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-573-DMRD-kjgOz2UCqXvjxF_6A-1; Mon, 10 Jul 2023 19:03:00 -0400 X-MC-Unique: DMRD-kjgOz2UCqXvjxF_6A-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fbfc766a78so24382005e9.3 for ; Mon, 10 Jul 2023 16:03:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030179; x=1691622179; 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=is4JU1X/3OUSKq/URlPYqO+soLMMDT1XVm32TNN7udw=; b=VlqoHgBr6n9WK4tWFinA2k46QiClik1LB5SfIpoJ+4tyQBS+KjAZOrqNYebBeXnIU5 l3Jwh21kZiQiA34uKPmCBjpjL3y8ZbzI9xDOI70Vboxkmikx/Pr4yhE8+tkioPQXWCs/ ByX0YiuXhrWo5srXpsLmAQq3br9Ls8JSEXthhRewp9++cH8IKvWXVsNWcCbt5zU3godD szrkUlVF6TWX0UBzjt75DdYGsRt6sbWE0+ETaIkUAZU97RdJYQoJ2+BYAkJ+YFXBGzDz hQ+hC8YeLv5wPr+N5odZpkGhK1Vxk5vVGbX2NmVrzYEtoQoHhPVA1e0g8HNJRIPIPv7s pv4w== X-Gm-Message-State: ABy/qLYB53LMtJPg7WJb+Cxvdh8eZjAYEfCXEemBCCtC+uC7radcLOas eWIclRaiUIVIGpdWcV+aovzjk8tWJAxlnGJqFdWv0H191SrvYApkS54MZ9LMutCo0iZvRUD9HW6 JFLycZw8aC87678ZD4O1wPa9Ad6yDdOD88ycuDpypEFYfJNGrztUo25JgxaYC2ZjxaYvh X-Received: by 2002:a7b:c8ca:0:b0:3fa:77ed:9894 with SMTP id f10-20020a7bc8ca000000b003fa77ed9894mr11222059wml.7.1689030179427; Mon, 10 Jul 2023 16:02:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlHxBB6CRPrxq10uB1kszRkoOc3U0Ccm3507ayOVkvU1V3FCsIHRwX4LJfQBnmGeeAfEluqYRA== X-Received: by 2002:a7b:c8ca:0:b0:3fa:77ed:9894 with SMTP id f10-20020a7bc8ca000000b003fa77ed9894mr11222045wml.7.1689030179192; Mon, 10 Jul 2023 16:02:59 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id 13-20020a05600c228d00b003fbe4cecc3bsm11371299wmf.16.2023.07.10.16.02.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:02:58 -0700 (PDT) Date: Mon, 10 Jul 2023 19:02:56 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Eduardo Habkost , Marcel Apfelbaum , Philippe =?utf-8?q?Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang Subject: [PULL 11/66] machine: Add helpers to get cores/threads per socket 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Zhao Liu The number of cores/threads per socket are needed for smbios, and are also useful for other modules. Provide the helpers to wrap the calculation of cores/threads per socket so that we can avoid calculation errors caused by other modules miss topology changes. Suggested-by: Igor Mammedov Signed-off-by: Zhao Liu Message-Id: <20230628135437.1145805-2-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/boards.h | 2 ++ hw/core/machine-smp.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/hw/boards.h b/include/hw/boards.h index 6b267c21ce..12d9e9d17c 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -35,6 +35,8 @@ void machine_set_cpu_numa_node(MachineState *machine, Error **errp); void machine_parse_smp_config(MachineState *ms, const SMPConfiguration *config, Error **errp); +unsigned int machine_topo_get_cores_per_socket(const MachineState *ms); +unsigned int machine_topo_get_threads_per_socket(const MachineState *ms); /** * machine_class_allow_dynamic_sysbus_dev: Add type to list of valid devices diff --git a/hw/core/machine-smp.c b/hw/core/machine-smp.c index 89fe0cda42..0f4d9b6f7a 100644 --- a/hw/core/machine-smp.c +++ b/hw/core/machine-smp.c @@ -197,3 +197,13 @@ void machine_parse_smp_config(MachineState *ms, return; } } + +unsigned int machine_topo_get_cores_per_socket(const MachineState *ms) +{ + return ms->smp.cores * ms->smp.clusters * ms->smp.dies; +} + +unsigned int machine_topo_get_threads_per_socket(const MachineState *ms) +{ + return ms->smp.threads * machine_topo_get_cores_per_socket(ms); +} From patchwork Mon Jul 10 23:02:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806106 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=NahldwUv; dkim-atps=neutral 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 4R0KTB0GHyz20ZZ for ; Tue, 11 Jul 2023 09:09:34 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzuN-0003hl-W5; Mon, 10 Jul 2023 19:03:08 -0400 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 1qIzuM-0003gN-PH for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:06 -0400 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 1qIzuL-0004Av-DH for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030184; 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=SM6HtXV56hI3gJZn0vAaGg3ztZLfzZhW3nxUKN5CA6E=; b=NahldwUvRd+BrBI44oSAWkekvhBKDw7VzfscllZdD4GyfGbyFOKWrpQ/X/4iMuFkkcU9Qu sCwDg50N6jneO15HV64Bl8QyrksZEVR7UT7sgGuxx0RMv/u6vVc4s8c7WsTM2rwsnE3B07 hp8RJnGe58Nvb2+QH86V0bm9No4uBQQ= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-592-5SCDiTFZOPevRmUsihpSAA-1; Mon, 10 Jul 2023 19:03:03 -0400 X-MC-Unique: 5SCDiTFZOPevRmUsihpSAA-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-315998d6e7fso1080196f8f.3 for ; Mon, 10 Jul 2023 16:03:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030182; x=1691622182; 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=SM6HtXV56hI3gJZn0vAaGg3ztZLfzZhW3nxUKN5CA6E=; b=M6QEEv7+kO/S57tcSb3YS57jvQP4XhuMPCrrbPPojPFNdqCFyC5819ixHtRdka2+FK ZQmWXICyxg4BwNfw11jZnkC7K32Fe0EHLMYcCw+2XPJ0a3MJCu5KUftgSYsIPpnSkbl7 7ClKhJ20oK5BBZmxSuFdKoo+RqVZaDQik5L6JHPh5ABhsrz6zgQx49PwIjSvBDZvTfJ9 KXmFivw/lLmmqCU9xHkbYpwMFGtzMAarsOb+61qfK9Elj5RzNyP19dv9q7fTIBH/UhGq XvZ6ZiIJTXhNx0lku5N6pcs1W4+zibdTIpCmnL+vL8U+jZvKGaNU7d0GfP0o1TiINiOQ 4dmw== X-Gm-Message-State: ABy/qLaP1AiQ3cr4OyxeVjNbGPghNR3VX/y6oSSYevdn1aoBG+ScN8OS 78pCuS4xMeHTMrBD3VBJCEJFsdGbgXe59PqFyCekMcpitIOu6w2wZAprhNqV5ilMvfEgjR8Lb2H 5GeSp0ymHzlCYplpxN8uV2/G/vxB6wFNV38s5g9WuajMJeFJLjsYpLQF9XErJy6X2zPAs X-Received: by 2002:a5d:5444:0:b0:314:8d:7eb1 with SMTP id w4-20020a5d5444000000b00314008d7eb1mr11284795wrv.55.1689030182045; Mon, 10 Jul 2023 16:03:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlEvualZyW5BnHDmgPlPuIhijkNWtMlnL85ocKyJFBMVf8svlhNSVyRYm+Wwkyi/95s1pCPm1A== X-Received: by 2002:a5d:5444:0:b0:314:8d:7eb1 with SMTP id w4-20020a5d5444000000b00314008d7eb1mr11284779wrv.55.1689030181795; Mon, 10 Jul 2023 16:03:01 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id q4-20020adfcd84000000b0031134bcdacdsm594256wrj.42.2023.07.10.16.03.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:01 -0700 (PDT) Date: Mon, 10 Jul 2023 19:02:59 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 12/66] hw/smbios: Fix smbios_smp_sockets caculation 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Zhao Liu smp.sockets is the number of sockets which is configured by "-smp" ( otherwise, the default is 1). Trying to recalculate it here with another rules leads to errors, such as: 1. 003f230e37d7 ("machine: Tweak the order of topology members in struct CpuTopology") changes the meaning of smp.cores but doesn't fix original smp.cores uses. With the introduction of cluster, now smp.cores means the number of cores in one cluster. So smp.cores * smp.threads just means the threads in a cluster not in a socket. 2. On the other hand, we shouldn't use smp.cpus here because it indicates the initial number of online CPUs at the boot time, and is not mathematically related to smp.sockets. So stop reinventing the another wheel and use the topo values that has been calculated. Fixes: 003f230e37d7 ("machine: Tweak the order of topology members in struct CpuTopology") Signed-off-by: Zhao Liu Message-Id: <20230628135437.1145805-3-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/smbios/smbios.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index d2007e70fb..d67415d44d 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -1088,8 +1088,7 @@ void smbios_get_tables(MachineState *ms, smbios_build_type_2_table(); smbios_build_type_3_table(); - smbios_smp_sockets = DIV_ROUND_UP(ms->smp.cpus, - ms->smp.cores * ms->smp.threads); + smbios_smp_sockets = ms->smp.sockets; assert(smbios_smp_sockets >= 1); for (i = 0; i < smbios_smp_sockets; i++) { From patchwork Mon Jul 10 23:03:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806061 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=Gkz9GGFt; dkim-atps=neutral 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 4R0KMf1hy7z20Ph for ; Tue, 11 Jul 2023 09:04:46 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzuW-0003za-EB; Mon, 10 Jul 2023 19:03:16 -0400 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 1qIzuS-0003tB-VS for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:14 -0400 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 1qIzuR-0004Bn-Hc for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030190; 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=Ankrdrqe8uBDyZbVrO/a93nDhI3+nBuaqJDTmGENhZA=; b=Gkz9GGFtYSgPquxboJPwMZvgnTo/TCRPbP/gTkaanA9VwDxCeykeIaqg+hO3+Cf1uBTgvU gXNtW3j98W8qp0QtWFwHVzG52XGFq0yVO5pEdBveUv4gwGnOTE1U39FQuaSSDat8Nc+jvU r0sHKIjhzVeCMNEVJgDJnKfRrXgR1u8= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-Uza6_PwZOmyQw2oZu5y8oA-1; Mon, 10 Jul 2023 19:03:06 -0400 X-MC-Unique: Uza6_PwZOmyQw2oZu5y8oA-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fbab56aac7so29564835e9.1 for ; Mon, 10 Jul 2023 16:03:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030184; x=1691622184; 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=Ankrdrqe8uBDyZbVrO/a93nDhI3+nBuaqJDTmGENhZA=; b=d+wRK2AQAYFdCcSsRdicwYLPbhNx9VkFDT2Ug6dnhIdCV8qU7cKuJoy+l1W7JL4Hfx Y1LAi2lXPqrtooI/SMhgGpX8K4Zu7o5xZETJBsFW2cDrAkh+6Cb4XJIqJIUO0GGR4aVk pbamlsUvbpc4INxcKvUCsp6Dhfs/2H7wZBzakSDBwi5ZFYyRveO3izTOexHb2jutyFIF CqQoeKiqODw4mWLXgJhgUY9yZdsZV2dXJxIRDESTFN+oR7w/udYRFnNn1b/yiU6ht1pc gGEsIYzHYnZeCgJprUG0rX8I72JYahQtuhQmAvj5aND5LOV8CraEudZIOA2US70UKhEy TGZQ== X-Gm-Message-State: ABy/qLZtVW9yrAOQp/E0iHo2p+Daz5aEFrGqjaUNoUzEriM10wWlwQQp hUQqZpFJt+UlQ5wpOgl9wTXwsM8H4VWpu/B9kBRtSmhQBr7MbEdx08L1JuUCqfotkn+HpCtiTXm 9E5QheukbbmemrZFE0qCbl9x4YmbFNnlmsQ+GOYcCtCZPGIy4O7PsoH1l2jgcsJNrM//H X-Received: by 2002:a1c:7204:0:b0:3fa:9767:c816 with SMTP id n4-20020a1c7204000000b003fa9767c816mr13024287wmc.39.1689030184726; Mon, 10 Jul 2023 16:03:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlHRwitSvNph3vvNBOvYBTEbH/FIplESB2PS4lWC0aygi2kprZsvRs79NHlHAG7hjBb9SEOnlg== X-Received: by 2002:a1c:7204:0:b0:3fa:9767:c816 with SMTP id n4-20020a1c7204000000b003fa9767c816mr13024274wmc.39.1689030184407; Mon, 10 Jul 2023 16:03:04 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id 18-20020a05600c025200b003fbca942499sm11337838wmj.14.2023.07.10.16.03.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:03 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 13/66] hw/smbios: Fix thread count in type4 Message-ID: <7298fd7de5551c4501f54381228458e3c21cab4b.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Zhao Liu >From SMBIOS 3.0 specification, thread count field means: Thread Count is the total number of threads detected by the BIOS for this processor socket. It is a processor-wide count, not a thread-per-core count. [1] So here we should use threads per socket other than threads per core. [1] SMBIOS 3.0.0, section 7.5.8, Processor Information - Thread Count Fixes: c97294ec1b9e ("SMBIOS: Build aggregate smbios tables and entry point") Signed-off-by: Zhao Liu Message-Id: <20230628135437.1145805-4-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/smbios/smbios.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index d67415d44d..3aae9328c0 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -713,6 +713,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance) { char sock_str[128]; size_t tbl_len = SMBIOS_TYPE_4_LEN_V28; + unsigned threads_per_socket; if (smbios_ep_type == SMBIOS_ENTRY_POINT_TYPE_64) { tbl_len = SMBIOS_TYPE_4_LEN_V30; @@ -747,17 +748,19 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance) SMBIOS_TABLE_SET_STR(4, asset_tag_number_str, type4.asset); SMBIOS_TABLE_SET_STR(4, part_number_str, type4.part); + threads_per_socket = machine_topo_get_threads_per_socket(ms); + t->core_count = (ms->smp.cores > 255) ? 0xFF : ms->smp.cores; t->core_enabled = t->core_count; - t->thread_count = (ms->smp.threads > 255) ? 0xFF : ms->smp.threads; + t->thread_count = (threads_per_socket > 255) ? 0xFF : threads_per_socket; t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */ t->processor_family2 = cpu_to_le16(0x01); /* Other */ if (tbl_len == SMBIOS_TYPE_4_LEN_V30) { t->core_count2 = t->core_enabled2 = cpu_to_le16(ms->smp.cores); - t->thread_count2 = cpu_to_le16(ms->smp.threads); + t->thread_count2 = cpu_to_le16(threads_per_socket); } SMBIOS_BUILD_TABLE_POST; From patchwork Mon Jul 10 23:03:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806088 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=hZGO1gyV; dkim-atps=neutral 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 4R0KRt6Tlcz20bx for ; Tue, 11 Jul 2023 09:08:26 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzuU-0003uW-Mo; Mon, 10 Jul 2023 19:03:14 -0400 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 1qIzuS-0003sj-C5 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:12 -0400 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 1qIzuQ-0004Bc-QN for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030190; 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=8By2ZmyapkS1ozV1Uy5Uvrkjg6+zILSxVQCNLRXQ83o=; b=hZGO1gyVCAcMCNmPbnZSRMG2z7Kp2KJLyIqWKQxTKYm+VTzq3SEb9/GgvRACDcQ4M2aKKG 4BecShyNTiPtV2XST8olFBZDef4Pvhp3gVVap7JZ08wBs0O1ZfV7qpKqOwc3YhW/hKzCU9 7LXcWGOioH6Kfs8DVLuJIKOKutJoYtQ= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-352--SyFSNwAMrKNKnDLl4RwBA-1; Mon, 10 Jul 2023 19:03:09 -0400 X-MC-Unique: -SyFSNwAMrKNKnDLl4RwBA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fa9a282fffso29956065e9.1 for ; Mon, 10 Jul 2023 16:03:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030187; x=1691622187; 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=8By2ZmyapkS1ozV1Uy5Uvrkjg6+zILSxVQCNLRXQ83o=; b=agQ2f8jalMuAFaZ4JjmQFDix1qcJAc6uPVO2DPZE0oCeeRzAEqHZqrIvGzzmqnTsEt +GJYZBzdS9FasT7/0adrihA/Ssolqc6x8FlCGy/52ayhgt3woI9BDYTgZoM9MFi1zKbS g9bo7rkbyOZZtmDIIndxsTYnZ9hDeW+eMdzlyDMCv/pQ71ONED7W0fgEFhmVuUa+bNfj I/JEjFaLbjijk8bznuKyZp0s6+tQPq6G/AWquApT40ICweLJu4hLa6HrcvobNtwfv2b8 C1dWaLnpy6nZN4zlcA0LmfZx2qT4mZ+mxtKXcxaCkqbkHi7bPEmqJSl+SW39eCeSmtLX AAxQ== X-Gm-Message-State: ABy/qLYBL3hZEc6BCLDfRmTV4+FiDaxfUl6JmotgvZG8jw5L+ug+gdW8 LyqRXa/85Pt7Rqe/2daIfLeQZ+NTMORXgBFi9zf7oYx4I2V4Zl3RqjoW2N7hlIuHbP+EBfIxC11 P9bsq6/JPayT11wanVlI2Sl16vQAFSvKcZqUbDkHPKW35yeNEBh2ako69+fdlOTTezkWT X-Received: by 2002:a7b:ce8e:0:b0:3fb:40ec:9483 with SMTP id q14-20020a7bce8e000000b003fb40ec9483mr12296991wmj.16.1689030187370; Mon, 10 Jul 2023 16:03:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlH0xLtqHoIU2smbyj5RjpSC2IK5XLLgd3Z4Hx91R4i5OXuAXZqgzdHOWPAu9S2K+A+4Z4n8MA== X-Received: by 2002:a7b:ce8e:0:b0:3fb:40ec:9483 with SMTP id q14-20020a7bce8e000000b003fb40ec9483mr12296977wmj.16.1689030187034; Mon, 10 Jul 2023 16:03:07 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id 24-20020a05600c22d800b003fbaade072dsm938719wmg.23.2023.07.10.16.03.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:06 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Igor Mammedov , Ani Sinha Subject: [PULL 14/66] hw/smbios: Fix core count in type4 Message-ID: <196ea60a734c346d7d75f1d89aa37703d4d854e7.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Zhao Liu >From SMBIOS 3.0 specification, core count field means: Core Count is the number of cores detected by the BIOS for this processor socket. [1] Before 003f230e37d7 ("machine: Tweak the order of topology members in struct CpuTopology"), MachineState.smp.cores means "the number of cores in one package", and it's correct to use smp.cores for core count. But 003f230e37d7 changes the smp.cores' meaning to "the number of cores in one die" and doesn't change the original smp.cores' use in smbios as well, which makes core count in type4 go wrong. Fix this issue with the correct "cores per socket" caculation. [1] SMBIOS 3.0.0, section 7.5.6, Processor Information - Core Count Fixes: 003f230e37d7 ("machine: Tweak the order of topology members in struct CpuTopology") Signed-off-by: Zhao Liu Message-Id: <20230628135437.1145805-5-zhao1.liu@linux.intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/smbios/smbios.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 3aae9328c0..10cd22f610 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -714,6 +714,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance) char sock_str[128]; size_t tbl_len = SMBIOS_TYPE_4_LEN_V28; unsigned threads_per_socket; + unsigned cores_per_socket; if (smbios_ep_type == SMBIOS_ENTRY_POINT_TYPE_64) { tbl_len = SMBIOS_TYPE_4_LEN_V30; @@ -749,8 +750,9 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance) SMBIOS_TABLE_SET_STR(4, part_number_str, type4.part); threads_per_socket = machine_topo_get_threads_per_socket(ms); + cores_per_socket = machine_topo_get_cores_per_socket(ms); - t->core_count = (ms->smp.cores > 255) ? 0xFF : ms->smp.cores; + t->core_count = (cores_per_socket > 255) ? 0xFF : cores_per_socket; t->core_enabled = t->core_count; t->thread_count = (threads_per_socket > 255) ? 0xFF : threads_per_socket; @@ -759,7 +761,7 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance) t->processor_family2 = cpu_to_le16(0x01); /* Other */ if (tbl_len == SMBIOS_TYPE_4_LEN_V30) { - t->core_count2 = t->core_enabled2 = cpu_to_le16(ms->smp.cores); + t->core_count2 = t->core_enabled2 = cpu_to_le16(cores_per_socket); t->thread_count2 = cpu_to_le16(threads_per_socket); } From patchwork Mon Jul 10 23:03:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=ToNod03m; dkim-atps=neutral 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 4R0KQ02y76z20ZZ for ; Tue, 11 Jul 2023 09:06:48 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzuW-0003zj-EN; Mon, 10 Jul 2023 19:03:16 -0400 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 1qIzuU-0003un-Mw for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:14 -0400 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 1qIzuT-0004C8-3Q for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030192; 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=lAfUlLDrPcMNUXKJIJA1rQ6sYWvHzs/EbqL1gvZxI9U=; b=ToNod03mOSQ4J9hnoj+hJTK+jrrf5dFVvXiIYQXQEx87Z0hl2TZNvIBS3sRAbLaM/YxR7+ NLLRlyU1kG2mEK02hMdI97A4dMgQ/cJw3LuoH+arjsF4BDbgnSJeb/x1inah/wP7C7sDwv SHkGGB0IMF5w4dp7qezLQprwqBXRW8s= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-_B2wq78UMHWFOpOncB1_JA-1; Mon, 10 Jul 2023 19:03:11 -0400 X-MC-Unique: _B2wq78UMHWFOpOncB1_JA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fa976b8b6fso31040095e9.3 for ; Mon, 10 Jul 2023 16:03:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030189; x=1691622189; 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=lAfUlLDrPcMNUXKJIJA1rQ6sYWvHzs/EbqL1gvZxI9U=; b=j2GwdSfOo7z6ZNme9zXI1VC31gunb6LGPDa4rXbJ+TVtg6jlNbrAIgtwzrQIj0N8Be yfHorKWTHWRvoGfU42jfRToUpcwAalbIH3eFTZCsrF27ZZ/7ENYdhI1egW1IzUPCBpj+ 1m441i+eArlUblVZs53bhctVq8QA8ynYaSSyR6VSRp6vNJE4tWia7TlWU03gwXjDI/BT UMs+y1SqGZM47pBlaIwzmwkmyn9Nute5hEIVr2+GzH9LqeGPhSAeLK1UHllavzmAZmjG LxOl6ASmJ2ZiPQQQ7jXD6AWi/S/vxDML8cdNqakqTFPX4qL0C+3f5eh9Wl12hZA9SybH fyVw== X-Gm-Message-State: ABy/qLZqsvKRCd9dessMPxs4TNxj6AR0+30XYBLGFR8XUtir8Brz96AR BUadqtWSDhgbOgfD8/x46iD6Lzz4HhQZCBEz/Eeh2HUscJGmRvlamKmVx2A+sschdUa6RV+TPgv S9/adfsgmoV4jWuGcPua7r8RabHr1Bf6uNOkjvumLvcapYtZqhYNaHIdvsMFJWZ9RNMVX X-Received: by 2002:a7b:c5d6:0:b0:3f7:3991:e12e with SMTP id n22-20020a7bc5d6000000b003f73991e12emr13508761wmk.1.1689030189728; Mon, 10 Jul 2023 16:03:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlE4IMtpgeHShLyDcFZgkhT+O7sDPlCFe4jqo27T7Vi2eu3JLymUZLOsJlXcjia+zvli/PHhZw== X-Received: by 2002:a7b:c5d6:0:b0:3f7:3991:e12e with SMTP id n22-20020a7bc5d6000000b003f73991e12emr13508744wmk.1.1689030189481; Mon, 10 Jul 2023 16:03:09 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id v10-20020a05600c470a00b003f9b3829269sm21826965wmo.2.2023.07.10.16.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:09 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:07 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Tom Lonergan , Raphael Norwitz Subject: [PULL 15/66] vhost-user: Change one_time to per_device request Message-ID: <0dcb4172f2cecdfae113239ff931718eefdeb2d2.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Tom Lonergan Some devices, like virtio-scsi, consist of one vhost_dev, while others, like virtio-net, contain multiple vhost_devs. The QEMU vhost-user code has a concept of one-time messages which is misleading. One-time messages are sent once per operation on the device, not once for the lifetime of the device. Therefore, as discussed in [1], vhost_user_one_time_request should be renamed to vhost_user_per_device_request and the relevant comments updated to match the real functionality. [1] https://lore.kernel.org/qemu-devel/20230127083027-mutt-send-email-mst@kernel.org/ Signed-off-by: Tom Lonergan Message-Id: <20230628163927.108171-2-tom.lonergan@nutanix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Raphael Norwitz --- hw/virtio/vhost-user.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index c4e0cbd702..65d6299343 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -367,7 +367,7 @@ static int process_message_reply(struct vhost_dev *dev, return msg_reply.payload.u64 ? -EIO : 0; } -static bool vhost_user_one_time_request(VhostUserRequest request) +static bool vhost_user_per_device_request(VhostUserRequest request) { switch (request) { case VHOST_USER_SET_OWNER: @@ -392,11 +392,17 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg, int ret, size = VHOST_USER_HDR_SIZE + msg->hdr.size; /* - * For non-vring specific requests, like VHOST_USER_SET_MEM_TABLE, - * we just need send it once in the first time. For later such - * request, we just ignore it. + * Some devices, like virtio-scsi, are implemented as a single vhost_dev, + * while others, like virtio-net, contain multiple vhost_devs. For + * operations such as configuring device memory mappings or issuing device + * resets, which affect the whole device instead of individual VQs, + * vhost-user messages should only be sent once. + * + * Devices with multiple vhost_devs are given an associated dev->vq_index + * so per_device requests are only sent if vq_index is 0. */ - if (vhost_user_one_time_request(msg->hdr.request) && dev->vq_index != 0) { + if (vhost_user_per_device_request(msg->hdr.request) + && dev->vq_index != 0) { msg->hdr.flags &= ~VHOST_USER_NEED_REPLY_MASK; return 0; } @@ -1256,7 +1262,7 @@ static int vhost_user_get_u64(struct vhost_dev *dev, int request, uint64_t *u64) .hdr.flags = VHOST_USER_VERSION, }; - if (vhost_user_one_time_request(request) && dev->vq_index != 0) { + if (vhost_user_per_device_request(request) && dev->vq_index != 0) { return 0; } From patchwork Mon Jul 10 23:03:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806054 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=Bsd5arX3; dkim-atps=neutral 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 4R0KLR3QH6z20Ph for ; Tue, 11 Jul 2023 09:03:43 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzuY-0004GS-Pw; Mon, 10 Jul 2023 19:03:18 -0400 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 1qIzuX-00047F-9o for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:17 -0400 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 1qIzuV-0004CV-Px for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030194; 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=4eiO06RfyYnB8FTG9kZaEZOiNvCWbZsGWdYJarnqlvs=; b=Bsd5arX3eu7gMx62XtS6Q7VNt2Xn5RSDgIEg1bzGL4QW2H+v8LK1UhuAKlb3MiB0TLLMVi d6hTxCS+JqAv7OmwkEX7rn8lU2q51/xhCHsNXrzndCaOHkdwjIwZEhaAgIzS+Rz09JjQ1J ePhubYYzXi08dJg6e2SfuUp5brL9tyg= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-114-9pEP3WGbPNuh9aBJIKc-zA-1; Mon, 10 Jul 2023 19:03:13 -0400 X-MC-Unique: 9pEP3WGbPNuh9aBJIKc-zA-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fbb0c01e71so30005525e9.0 for ; Mon, 10 Jul 2023 16:03:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030192; x=1691622192; 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=4eiO06RfyYnB8FTG9kZaEZOiNvCWbZsGWdYJarnqlvs=; b=JC6oJlf2cZWq4GTiR1+Yj1+nGYK1uhGKO/TG1wm6FTUHNTJp3EnbT8NYfwF7m5le9j gthIFSCdlkK+Zr6QGmMowgjGF9UYgK5ubMzTLhnhijNOwUa2ZX+O9QO5JjVP0aCiVtw6 WaKNmckl2FmO+XmqQarO6/C6ljXdbFREdB+dip0R35Spo82ORniLwTZ5xuMMcldB2CbK w+E7LrUp6K3gkkrwn4qD9b2NsKvD2fi0jjpNRZFuGkWCPoS/MosnhoSWHq0gyapM22D1 UXlFIG5Kw1xLdAGkM6QJJ6/kqVbmzOCHOazfE9AfCgZaordXMTKUMGk2TcwVa+oOItXm leag== X-Gm-Message-State: ABy/qLaDds1grltJwK6RDmyQR8rGyTlV0BtPY86cnnYCwVSVpgBhnh4T cE6RkbgBkab9aYGJe6cqYi2hIBSunMIqYtB9yxF9ecyc+oOk/t5/fD0JBkuAzTGm3vWiGSfmUQg HVyLoIM+tWuZCE3KYGZBFO4+RHjUWxftWjVofyvOfUcZJDEo80gOimIblUKraiocr8lhA X-Received: by 2002:a05:600c:452:b0:3fc:7d2:e0c0 with SMTP id s18-20020a05600c045200b003fc07d2e0c0mr6867296wmb.27.1689030192304; Mon, 10 Jul 2023 16:03:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlG2lATBC1MNJUQb+P49RSfZUPLzk9CPD30+j7zl+//O5rQlOeS+v5ECppwe0azjKNCoDdgoSw== X-Received: by 2002:a05:600c:452:b0:3fc:7d2:e0c0 with SMTP id s18-20020a05600c045200b003fc07d2e0c0mr6867282wmb.27.1689030192084; Mon, 10 Jul 2023 16:03:12 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id q5-20020a1ce905000000b003fc07e1908csm899629wmc.43.2023.07.10.16.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:11 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:09 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Tom Lonergan , Raphael Norwitz Subject: [PULL 16/66] vhost-user: Make RESET_DEVICE a per device message Message-ID: <667e58aef1aa7a0294f635ef070c591efebf75c1.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Tom Lonergan A device reset is issued per device, not per VQ. The legacy device reset message, VHOST_USER_RESET_OWNER, is already a per device message. Therefore, this change adds the proper message, VHOST_USER_RESET_DEVICE, to per device messages. Signed-off-by: Tom Lonergan Message-Id: <20230628163927.108171-3-tom.lonergan@nutanix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Raphael Norwitz --- hw/virtio/vhost-user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 65d6299343..8dcf049d42 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -375,6 +375,7 @@ static bool vhost_user_per_device_request(VhostUserRequest request) case VHOST_USER_SET_MEM_TABLE: case VHOST_USER_GET_QUEUE_NUM: case VHOST_USER_NET_SET_MTU: + case VHOST_USER_RESET_DEVICE: case VHOST_USER_ADD_MEM_REG: case VHOST_USER_REM_MEM_REG: return true; From patchwork Mon Jul 10 23:03:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=bMBg+m8v; dkim-atps=neutral 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 4R0KMx1jLNz20ZZ for ; Tue, 11 Jul 2023 09:05:00 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzud-0004N2-6x; Mon, 10 Jul 2023 19:03:23 -0400 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 1qIzuc-0004Mg-La for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:22 -0400 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 1qIzub-0004DQ-7D for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030200; 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=XqJdx6u6jXF5O2Iy5NnoNS2DM0M40RdaAyjvqgM48CU=; b=bMBg+m8vzy43ux5reJUb82hPDl8nAV/qQZQboaSd4M8xa65U7YVYqQ/1Wnl2BavWTmLdEA 7eMK8Bj4FxoODLBRdnLctyHK1TLunofD61vqyiv5IK4chorNnZgGYQ8a7MLJEfndyGwcTU ZiVrY2tuKsXfX6pgWYkbodS0wgpvRpY= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-182-0VuYW9NrMCegFhAyv90Szw-1; Mon, 10 Jul 2023 19:03:18 -0400 X-MC-Unique: 0VuYW9NrMCegFhAyv90Szw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fc0627eafbso12520945e9.0 for ; Mon, 10 Jul 2023 16:03:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030195; x=1691622195; 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=XqJdx6u6jXF5O2Iy5NnoNS2DM0M40RdaAyjvqgM48CU=; b=ieKu5nNfbaHdNR/MzBCVuZcCKYcHOBhKiUeys4kq5jI/bDQk5tBWZyrUB3NkvRCwbK VvQljewMutCbD4qucUUvuyVY9e6t7NxT07oQm0/J5JCSyDs8OQidfEj6+Qw+Z62iWqkC rkJHTsgxWGT3XZ/9gasUZQSjFe2u1ILAUPSWYu1QFEC6o+tx0iWMK5GHLDLoelHm4Czq ZRHHCwZMDZ2oPaVN2B9vCTZAuN9T4CtaUnJwNuOjMGbMhvZi4RkrPoAx0hiQIf4pPIGb Ej7y6Vn0WITvT2iRFzXbJZRnrDZYtorMQRY85z+/hegyQIo478mw6TYDXa2HonS4cMLu mNdQ== X-Gm-Message-State: ABy/qLakM14EPGhEjVX+fkitogJbqjklP2+fNy3oAko9zXGFARtR+1h4 GTuRX2k73S/E9ml7GFzj2/SLjSh09KSWaCK3Mp5pDFneVcGdvMdQo5S0soz1lNi4IzXaFKNrHJT tlJNASs8UqqH1bl0qNgdlrpdtLSC90rdfmBudUMIoUx9wcLq0tBPoqY1AQubDkll26S7+ X-Received: by 2002:a05:600c:b52:b0:3fb:c060:9698 with SMTP id k18-20020a05600c0b5200b003fbc0609698mr13782172wmr.5.1689030195596; Mon, 10 Jul 2023 16:03:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlHMxBAf5tcKimAL4BFUDvcU0x9keWIcARX9+UrPGi5NEqNKvP31zy0rqJ58PIty5Cg+p1CuCA== X-Received: by 2002:a05:600c:b52:b0:3fb:c060:9698 with SMTP id k18-20020a05600c0b5200b003fbc0609698mr13782154wmr.5.1689030195214; Mon, 10 Jul 2023 16:03:15 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id m8-20020a7bca48000000b003fbdd9c72aasm939153wml.21.2023.07.10.16.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:14 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:12 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Thomas Huth , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 17/66] hw/i386/pc_q35: Resolve redundant q35_host variable Message-ID: <00f52e77d742c788ade7d713a7bf558481a89eec.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 variable is redundant to "phb" and is never used by its real type. Signed-off-by: Bernhard Beschow Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230630073720.21297-2-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc_q35.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 11a7084ea1..d9f3764184 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -120,8 +120,7 @@ static void pc_q35_init(MachineState *machine) PCMachineState *pcms = PC_MACHINE(machine); PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); X86MachineState *x86ms = X86_MACHINE(machine); - Q35PCIHost *q35_host; - PCIHostState *phb; + Object *phb; PCIBus *host_bus; PCIDevice *lpc; DeviceState *lpc_dev; @@ -207,10 +206,10 @@ static void pc_q35_init(MachineState *machine) } /* create pci host bus */ - q35_host = Q35_HOST_DEVICE(qdev_new(TYPE_Q35_HOST_DEVICE)); + phb = OBJECT(qdev_new(TYPE_Q35_HOST_DEVICE)); if (pcmc->pci_enabled) { - pci_hole64_size = object_property_get_uint(OBJECT(q35_host), + pci_hole64_size = object_property_get_uint(phb, PCI_HOST_PROP_PCI_HOLE64_SIZE, &error_abort); } @@ -218,23 +217,23 @@ static void pc_q35_init(MachineState *machine) /* allocate ram and load rom/bios */ pc_memory_init(pcms, system_memory, rom_memory, pci_hole64_size); - object_property_add_child(OBJECT(machine), "q35", OBJECT(q35_host)); - object_property_set_link(OBJECT(q35_host), MCH_HOST_PROP_RAM_MEM, + object_property_add_child(OBJECT(machine), "q35", phb); + object_property_set_link(phb, MCH_HOST_PROP_RAM_MEM, OBJECT(machine->ram), NULL); - object_property_set_link(OBJECT(q35_host), MCH_HOST_PROP_PCI_MEM, + object_property_set_link(phb, MCH_HOST_PROP_PCI_MEM, OBJECT(pci_memory), NULL); - object_property_set_link(OBJECT(q35_host), MCH_HOST_PROP_SYSTEM_MEM, + object_property_set_link(phb, MCH_HOST_PROP_SYSTEM_MEM, OBJECT(system_memory), NULL); - object_property_set_link(OBJECT(q35_host), MCH_HOST_PROP_IO_MEM, + object_property_set_link(phb, MCH_HOST_PROP_IO_MEM, OBJECT(system_io), NULL); - object_property_set_int(OBJECT(q35_host), PCI_HOST_BELOW_4G_MEM_SIZE, + object_property_set_int(phb, PCI_HOST_BELOW_4G_MEM_SIZE, x86ms->below_4g_mem_size, NULL); - object_property_set_int(OBJECT(q35_host), PCI_HOST_ABOVE_4G_MEM_SIZE, + object_property_set_int(phb, PCI_HOST_ABOVE_4G_MEM_SIZE, x86ms->above_4g_mem_size, NULL); + /* pci */ - sysbus_realize_and_unref(SYS_BUS_DEVICE(q35_host), &error_fatal); - phb = PCI_HOST_BRIDGE(q35_host); - host_bus = phb->bus; + sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal); + host_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pcie.0")); /* create ISA bus */ lpc = pci_new_multifunction(PCI_DEVFN(ICH9_LPC_DEV, ICH9_LPC_FUNC), true, TYPE_ICH9_LPC_DEVICE); From patchwork Mon Jul 10 23:03:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806095 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=E1mHWq6N; dkim-atps=neutral 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 4R0KSX3mqGz242X for ; Tue, 11 Jul 2023 09:09:00 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzuf-0004Rx-3k; Mon, 10 Jul 2023 19:03:25 -0400 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 1qIzud-0004Mx-2C for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:23 -0400 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 1qIzub-0004Da-NZ for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030201; 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=zw2umn06AtI1S+/Gxf3HhoyuNucsi0r5jYKqy/7dleU=; b=E1mHWq6NZv9hvh0AVJqmo/7t0YqBIZq1nL+dJPVi/2eHWorzO/4Y58YvbBfLCptmZd3z6h 43qYC1G0JOl1eCyCAeVfYTTYasn9dd7bCMhPYxB5C/QsUAPG0BossIDneC2rgcsbDhqe+a OKSelAONfZFkIAcv0rwvOCL/9yVbTMA= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-iIR8NbpNNKGRmoJN2qiplA-1; Mon, 10 Jul 2023 19:03:19 -0400 X-MC-Unique: iIR8NbpNNKGRmoJN2qiplA-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3143b999f6eso2883531f8f.3 for ; Mon, 10 Jul 2023 16:03:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030198; x=1691622198; 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=zw2umn06AtI1S+/Gxf3HhoyuNucsi0r5jYKqy/7dleU=; b=SzKiEC239Gh2/gAGxnLy8rGD5bA0vEEkfLYRGwH0Tz0cyn32FFgSuQaSKWJJdqtCGu bFM7XaN8zeW3EHvn5QzRAI/QP3zk+v5qCNNwQhtqHl1ThEgfWuVfO6PN3bARhemc22qX 0XMCivkZ6sQHcTION7X0g8um+mBcXpzlSdx+TJCO4pLYc0nJZF5gE5OUUqZM/60A2wNo dx3G8oH7dTmul2q+tkhSzs/hWVWyldKP/Sfc5QDJq+MOEq6jSCOjuS52Sl7phhw6DlQf VW8qpUO3pkZmuYlYr5c09Q04r45ShNcddiLx41fCZ8fHWDEi3iIQMrkuaw7ys/bWiids uYHw== X-Gm-Message-State: ABy/qLZ896xh6MsQ1Z/cDbAzOWmEXTBijG6YuWNkA+obh3IZUTQxRWID jKZDRmyUzKjcXFPBpD6cXXCFrUgg/JvuR0wJ+mlD9lS16eOuz7JEmZeKrgULHvh8k2QhgmGT5Ur RruyebxcaJ1HVuu7ErH84aSaO42Uy9/XqwKhjZTYetHdlSo6VEv78xK6dY2SlUFhDQIzy X-Received: by 2002:a5d:670e:0:b0:314:172b:a7d5 with SMTP id o14-20020a5d670e000000b00314172ba7d5mr12887297wru.27.1689030198214; Mon, 10 Jul 2023 16:03:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlE9CYtlRdsp0AnU+APOSHfjA6NJrKEa9ztnKJLJah7sjms3Edpph6hB4xBOVusj/TP1vEhAvw== X-Received: by 2002:a5d:670e:0:b0:314:172b:a7d5 with SMTP id o14-20020a5d670e000000b00314172ba7d5mr12887273wru.27.1689030197914; Mon, 10 Jul 2023 16:03:17 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id c7-20020a5d4147000000b003141a3c4353sm601517wrq.30.2023.07.10.16.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:17 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:15 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Marcel Apfelbaum Subject: [PULL 18/66] hw/pci-host/q35: Fix double, contradicting .endianness assignment Message-ID: <8cf08065b1b19cea1958a43187755cec6546a5d0.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 Fixes the following clangd warning (-Winitializer-overrides): q35.c:297:19: Initializer overrides prior initialization of this subobject q35.c:292:19: previous initialization is here Settle on little endian which is consistent with using pci_host_conf_le_ops. Fixes: bafc90bdc594 ("q35: implement TSEG") Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230630073720.21297-3-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-host/q35.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index fd18920e7f..84137b9ad9 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -285,7 +285,6 @@ static void blackhole_write(void *opaque, hwaddr addr, uint64_t val, static const MemoryRegionOps blackhole_ops = { .read = blackhole_read, .write = blackhole_write, - .endianness = DEVICE_NATIVE_ENDIAN, .valid.min_access_size = 1, .valid.max_access_size = 4, .impl.min_access_size = 4, From patchwork Mon Jul 10 23:03:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806068 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=ECIA+H3I; dkim-atps=neutral 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 4R0KNb33YBz20ZZ for ; Tue, 11 Jul 2023 09:05:35 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzui-0004nK-De; Mon, 10 Jul 2023 19:03:28 -0400 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 1qIzug-0004cG-GA for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:26 -0400 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 1qIzue-0004Dy-VE for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030204; 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=QkHlkRkwRqr2wnXNmLOmWdy8/xXSowfTeKJm6zvZ4CA=; b=ECIA+H3IxQuY2D7ymHc7/ISGAY//hBCWss+UMEl0FO2t1MDG5BOBTF0DlvErCq7lYdgn0m IbAeY3fWSZkw5gOP8ItDQBmWkYht1nbtVo1wuwuLZVPyyyNYbElPGLLV2gMJV2v+YdeKep zUN5x5sY2u/VKlc484RYDHJg3AyD7rA= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-qZbaidDJPEWj1uUG9REEPQ-1; Mon, 10 Jul 2023 19:03:23 -0400 X-MC-Unique: qZbaidDJPEWj1uUG9REEPQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fbe356b8deso31117235e9.0 for ; Mon, 10 Jul 2023 16:03:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030201; x=1691622201; 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=QkHlkRkwRqr2wnXNmLOmWdy8/xXSowfTeKJm6zvZ4CA=; b=PVGrDeq14Gv7jR4VtZts4kSWom6J53UZ+ltbgs9ph2G1la7f6I8MmflxpeerYIvxsy XGNDn0CjZe86Ore/nZ1YAFb5bTOkdkh7nHiSGSjEzMLichsNzv5+G6+DD53MYLyuVxNB W+jdvptj+Irk78d4TT4wpMPSOX1oXZ53m6xckSHHQ+mhVuE9xdHJDulI8m9mgg0LjgwW n9LdFjCmn4A8YagS/b5iSwtZ9p6kRKE4LnJSC+MDh4PVKLkPbS1ewCe+n1xrunSo+TVg iwmOHqlD4hMLcrdb+OKsvVq2kq39BLTrCODBAaxyOIW+yJVHIzAbUTI9CAzOvNuoNfqW Zd9w== X-Gm-Message-State: ABy/qLY7NhfW5JHp4t0SOqcvb3yelAgY6c8q4dSlGOvJ4vMys4LYrV0z F6yVjR65Yc1d26PQIP0xdfhbsMC3v1hrKlk+Hm43Wa9oiTlvlMhR3T40m1zpZNDgb22VzNCh+fD hHaBC3+kNcsS6yBrvM6U6QGlGjwtymEZHs5aeHlcfDRuxh9/3e+ycs7OIjyMuSklmdClx X-Received: by 2002:a7b:c392:0:b0:3fb:d1db:5454 with SMTP id s18-20020a7bc392000000b003fbd1db5454mr14426808wmj.35.1689030201325; Mon, 10 Jul 2023 16:03:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlEQfJrtJnQU7jlKYAFHIpb3sB2nekHEWYNXSfjpS/0g4fE8THSpEib9nSaYehgHtfyVuFE9CA== X-Received: by 2002:a7b:c392:0:b0:3fb:d1db:5454 with SMTP id s18-20020a7bc392000000b003fbd1db5454mr14426792wmj.35.1689030201095; Mon, 10 Jul 2023 16:03:21 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id c18-20020a7bc012000000b003fbd2a9e94asm927921wmb.31.2023.07.10.16.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:20 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:18 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Igor Mammedov , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 19/66] hw/pci-host/q35: Initialize PCMachineState::bus in board code Message-ID: <06a492bd2b75653970e30c3ae0ea79ab1ed4ae31.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 Q35 PCI host currently sets the PC machine's PCI bus attribute through global state, thereby assuming the machine to be a PC machine. The Q35 machine code already holds on to Q35's pci bus attribute, so can easily set its own property while preserving encapsulation. Signed-off-by: Bernhard Beschow Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230630073720.21297-4-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc_q35.c | 4 +++- hw/pci-host/q35.c | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index d9f3764184..4edc0b35f4 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -230,10 +230,12 @@ static void pc_q35_init(MachineState *machine) x86ms->below_4g_mem_size, NULL); object_property_set_int(phb, PCI_HOST_ABOVE_4G_MEM_SIZE, x86ms->above_4g_mem_size, NULL); + sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal); /* pci */ - sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal); host_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pcie.0")); + pcms->bus = host_bus; + /* create ISA bus */ lpc = pci_new_multifunction(PCI_DEVFN(ICH9_LPC_DEV, ICH9_LPC_FUNC), true, TYPE_ICH9_LPC_DEVICE); diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 84137b9ad9..0604464074 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -66,7 +66,6 @@ static void q35_host_realize(DeviceState *dev, Error **errp) s->mch.pci_address_space, s->mch.address_space_io, 0, TYPE_PCIE_BUS); - PC_MACHINE(qdev_get_machine())->bus = pci->bus; pci->bypass_iommu = PC_MACHINE(qdev_get_machine())->default_bus_bypass_iommu; qdev_realize(DEVICE(&s->mch), BUS(pci->bus), &error_fatal); From patchwork Mon Jul 10 23:03:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806116 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=HOvfSAl1; dkim-atps=neutral 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 4R0KV81BHHz20bm for ; Tue, 11 Jul 2023 09:10:24 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzuv-0005CZ-AM; Mon, 10 Jul 2023 19:03:41 -0400 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 1qIzus-0005BH-M7 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:38 -0400 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 1qIzuh-0004Fb-NG for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030207; 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=shxGVXAL5KDbHnl/hVylYQFlgdwxks2fBEctaqulL2A=; b=HOvfSAl1qetXjJAc12t83vG0dZrZ/TrMSWeo5oxBq+n7p2fAsK3qZwEY6E5AFPKen1FLLE j6oJAyCBiGqzbOdyFyLygfJRZxszKN+2q5fQcKybvXKOsyEzsafpfH4FoB5i3An8dTB3ww ygpa8719aZOQ76t0bHDtXQJR7qsiGIo= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-QcTZZAkqMByEtjQubdwmWA-1; Mon, 10 Jul 2023 19:03:25 -0400 X-MC-Unique: QcTZZAkqMByEtjQubdwmWA-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-315935c808bso908617f8f.1 for ; Mon, 10 Jul 2023 16:03:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030204; x=1691622204; 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=shxGVXAL5KDbHnl/hVylYQFlgdwxks2fBEctaqulL2A=; b=JEQLLeZ+YPuOFe7QWjQ/VxWKD+6gOr2PWypcSV+VxMKiNl/5aDHAG5lKXObGWId3pm X/11Z8J1q74Itd8dasbq8eWnjG9LVIT39xKqSWQKy4xueCImSyVvBryMTSM+apgcgZWi 7Ikj4BvWdkPkKG7Vu/LvMD9zif+P5U3mFrrlloPJSxX3Pw5aTsL5YPAXmq0bDG0QlFEx ModB+iWeQr0aR0aGBlioGkeOEmExWS+/x0LeZgW6I14BcWhQWY2qaJdiQ3y4amJh+8gN P1/osyaoV+xIqO8Zw6KZHOliANgU85EPUaahMBAS/SSIanCKmM/RLib32rbbRGhWmFFd Xbtw== X-Gm-Message-State: ABy/qLY2iJTYkNG/xMC8HiEkmz88mhMGwmLyd60qhv+fm2Xb1MKuSi4f KdcnthOrx3PF6LEyr8psPiAOh+Jd0+7LjA839sr3tbdN5FX1dqmeYtASeEqN2K4ACpfoy9oLW00 V4RuKlwDwf8lqCHmNg1qOZdzMSToyPERUl+tRtIqQEwZtlf+ieQZ6BvQalnvC+esixZ4Y X-Received: by 2002:a05:6000:104d:b0:312:849d:acc8 with SMTP id c13-20020a056000104d00b00312849dacc8mr12624209wrx.9.1689030204178; Mon, 10 Jul 2023 16:03:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlHNx7UVKOZ90QkQPHHufjUTCikO1BER8KIApEK5O55lqCYI7Tx1iyDXJNS3ELlsVhXzxH7/AA== X-Received: by 2002:a05:6000:104d:b0:312:849d:acc8 with SMTP id c13-20020a056000104d00b00312849dacc8mr12624198wrx.9.1689030203975; Mon, 10 Jul 2023 16:03:23 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id o6-20020adfeac6000000b00314145e6d61sm613437wrn.6.2023.07.10.16.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:23 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Igor Mammedov , Marcel Apfelbaum Subject: [PULL 20/66] hw/pci/pci_host: Introduce PCI_HOST_BYPASS_IOMMU macro Message-ID: <3b20f4ca59b53f10240d94cdb3f482c116640437.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 Introduce a macro to avoid copy and pasting strings which can easily cause typos. Suggested-by: Michael S. Tsirkin Signed-off-by: Bernhard Beschow Reviewed-by: Igor Mammedov Message-Id: <20230630073720.21297-5-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci_host.h | 2 ++ hw/pci/pci_host.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/hw/pci/pci_host.h b/include/hw/pci/pci_host.h index c6f4eb4585..e52d8ec2cd 100644 --- a/include/hw/pci/pci_host.h +++ b/include/hw/pci/pci_host.h @@ -31,6 +31,8 @@ #include "hw/sysbus.h" #include "qom/object.h" +#define PCI_HOST_BYPASS_IOMMU "bypass-iommu" + #define TYPE_PCI_HOST_BRIDGE "pci-host-bridge" OBJECT_DECLARE_TYPE(PCIHostState, PCIHostBridgeClass, PCI_HOST_BRIDGE) diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index dfd185bbb4..7af8afdcbe 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -232,7 +232,7 @@ const VMStateDescription vmstate_pcihost = { static Property pci_host_properties_common[] = { DEFINE_PROP_BOOL("x-config-reg-migration-enabled", PCIHostState, mig_enabled, true), - DEFINE_PROP_BOOL("bypass-iommu", PCIHostState, bypass_iommu, false), + DEFINE_PROP_BOOL(PCI_HOST_BYPASS_IOMMU, PCIHostState, bypass_iommu, false), DEFINE_PROP_END_OF_LIST(), }; From patchwork Mon Jul 10 23:03:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806055 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=Wd+Chmwg; dkim-atps=neutral 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 4R0KLb14kYz20Ph for ; Tue, 11 Jul 2023 09:03:51 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzuo-00053R-72; Mon, 10 Jul 2023 19:03:34 -0400 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 1qIzum-00052e-42 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:32 -0400 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 1qIzuk-0004Fp-NF for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030210; 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=V3AeU+luiCA/Y1UCFMNDdCAt3vJKdjvI6VF3GLVTy8g=; b=Wd+Chmwg7rG4SIja9EkAHIXWtimji9pB6EPb5esv/8x/5EmHNKm6sm43lzaA/DlCiv2j0e eCaaoyxh5kAtlqpQdTYsCljI6dzR6QCQ3dzt3jNO+ArOLFnAhRaMBbp23NJk6Eu01isBjR nAyZknH4qCvfI/NFvLDnuq1aoo25914= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-86-qeOKJFXjP7ey81czSoM3CA-1; Mon, 10 Jul 2023 19:03:28 -0400 X-MC-Unique: qeOKJFXjP7ey81czSoM3CA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fbdde92299so29497815e9.3 for ; Mon, 10 Jul 2023 16:03:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030207; x=1691622207; 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=V3AeU+luiCA/Y1UCFMNDdCAt3vJKdjvI6VF3GLVTy8g=; b=At0WALhQPHLW5efW7+MsKnSWc9lwpgJ+YRBZpPQxvQlSrVLXocSjaWsfHH8IVuhscL h3WbpVZvqDJtCX3ScJtfWOkOO/OO+VlhlKC3s/k2MkZ10vSG6UL8rsw95L92hRwW3tDu XFBaWG7C0q6yBAKB13SHynCa1VxMF3J5925pRHsPEmsY4ITQdFE3k50jEzkP1yrGC7qt TO6Rxaf1LWE0PMAd6iyYnlQFyz0Ys59q9lmbxlG2PA4OHycijY2WqU0FkX7Lgr5033NT 519PCiIfRFh/iHdcr8CqQQ2IvispoUFac9YNImvxVK7ubcZ4hRjd5tFVeqe6GmC0IlrM SI9A== X-Gm-Message-State: ABy/qLY6BpjeT2RqFoViDwPf4yoIZaBenfkU2Lgt/58I6ssD2YRD7B6q JDLyg01wm85OiiuvS7rts/tdFyLs+dqaJwLSmcxtAMyWC/df2ZlQZP/yJCO88z9C6tcoh3f41gB uo6iYJNIQN/GVTO8z7+boA4cj0g0wP62nnHWDGEDLfSL34L2Vn/V9HtcOR9lCjB1Cl0YT X-Received: by 2002:a05:600c:acc:b0:3f9:b30f:a013 with SMTP id c12-20020a05600c0acc00b003f9b30fa013mr14576219wmr.6.1689030207309; Mon, 10 Jul 2023 16:03:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlG7Yw1rm9oEEyjyQeGC3r3I3bsau8MgE9cFxgiocQAJ45u87z6+7en26CK8/UTvk0kkLdkOlw== X-Received: by 2002:a05:600c:acc:b0:3f9:b30f:a013 with SMTP id c12-20020a05600c0acc00b003f9b30fa013mr14576197wmr.6.1689030207039; Mon, 10 Jul 2023 16:03:27 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id l16-20020a1c7910000000b003fb40ec9475sm948212wme.11.2023.07.10.16.03.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:26 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Igor Mammedov , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 21/66] hw/pci-host/q35: Initialize PCI_HOST_BYPASS_IOMMU property from board code 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 Q35 PCI host already has a PCI_HOST_BYPASS_IOMMU property. However, the host initializes this property itself by accessing global machine state, thereby assuming it to be a PC machine. Avoid this by having board code set this property. Signed-off-by: Bernhard Beschow Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230630073720.21297-6-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc_q35.c | 2 ++ hw/pci-host/q35.c | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 4edc0b35f4..852250e8cb 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -230,6 +230,8 @@ static void pc_q35_init(MachineState *machine) x86ms->below_4g_mem_size, NULL); object_property_set_int(phb, PCI_HOST_ABOVE_4G_MEM_SIZE, x86ms->above_4g_mem_size, NULL); + object_property_set_bool(phb, PCI_HOST_BYPASS_IOMMU, + pcms->default_bus_bypass_iommu, NULL); sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal); /* pci */ diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index 0604464074..d2830cee34 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -66,8 +66,7 @@ static void q35_host_realize(DeviceState *dev, Error **errp) s->mch.pci_address_space, s->mch.address_space_io, 0, TYPE_PCIE_BUS); - pci->bypass_iommu = - PC_MACHINE(qdev_get_machine())->default_bus_bypass_iommu; + qdev_realize(DEVICE(&s->mch), BUS(pci->bus), &error_fatal); } From patchwork Mon Jul 10 23:03:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806115 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=ZI/xQhNJ; dkim-atps=neutral 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 4R0KV00r9Kz20Ph for ; Tue, 11 Jul 2023 09:10:16 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzus-0005Ak-A6; Mon, 10 Jul 2023 19:03:38 -0400 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 1qIzuq-00058N-7U for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:36 -0400 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 1qIzuo-0004GN-KZ for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030213; 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=kEjEJwICeQiKCSVVw3Xvi2viKbcFg/KX0TNGLrPqfQ0=; b=ZI/xQhNJg8GILTrukW1cO7X2FjtOiVvN88zCT21ifNrhkiNhMVTIRfWhjD5yXdPMTn0CFg Wkrg5GGkl1aBHPwh8BgL/u2rGOjlXWVYfUByRM6eLn2DvTCucPr6NF5+6DyCI7E6gYdk75 bkShLXowspmChO4toaoeFIkUfJ3A70c= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-580-7iO72CKvNseVS6CrrJSxXQ-1; Mon, 10 Jul 2023 19:03:31 -0400 X-MC-Unique: 7iO72CKvNseVS6CrrJSxXQ-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-314326f6e23so2583646f8f.2 for ; Mon, 10 Jul 2023 16:03:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030210; x=1691622210; 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=kEjEJwICeQiKCSVVw3Xvi2viKbcFg/KX0TNGLrPqfQ0=; b=cUDQbdTBEAkzQy7AbNspQo3SvCbsSDOIpLIhn8HaPRdodbf7og4vO4A677RT2lcG7D QPhvUh4+ILiwaBhNfjtybafbxqZWpkSJSJbd55A7FiZq6NqtNy2Xh5U4LprpkGhNMQ1n wJ22VYjKntdM1dW960HibxbpKnDkuNUbkXOBKVNJchMrYMNx8+pwA6dYoUzxUtqVrHzc ABABSERs1J9SPZA+MsDcjS/l50LIin7cGYTZmse1T2AE2+swJTbQBuJCMEkq35G08tZb Mx9cNPf/xrdK87QYx3np+21i8lq6SZdqxKAbiWoCTSECcVQgicnOnDOX4d/ebDPUFPXe F54w== X-Gm-Message-State: ABy/qLbk3+p9muyfxvsSq/BgbtJfSsASgRONG1yCu78P72bfzpkh5/L3 apjOSFfWl0HnNI/M3ylEOftGGfymXTCCmmqISlqKWhI8GQNIQPAaj5WGpHvGrkoVKYxtnPsrLNj LdWoFSmJElszMsDmPUAlWui0UZGv2D3FnI4gPK3LfN+FRdWQdDeiiihlIh8DPUrzYCtzc X-Received: by 2002:adf:da4e:0:b0:314:315a:93b5 with SMTP id r14-20020adfda4e000000b00314315a93b5mr381020wrl.54.1689030210101; Mon, 10 Jul 2023 16:03:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlFkXFysj3Oo/BALje+GL6qVXc7h231LgtO42YvI9NLy4BvvdoMoGEFXc1Kl6jXdRl26JfDLZQ== X-Received: by 2002:adf:da4e:0:b0:314:315a:93b5 with SMTP id r14-20020adfda4e000000b00314315a93b5mr381001wrl.54.1689030209811; Mon, 10 Jul 2023 16:03:29 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id l10-20020adffe8a000000b00315995837aesm590819wrr.36.2023.07.10.16.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:29 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 22/66] hw/pci-host/q35: Make some property name macros reusable by i440fx Message-ID: <3d664a9a386dd5968962b038d056caf182ef29a1.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 Signed-off-by: Bernhard Beschow Message-Id: <20230630073720.21297-7-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/i386/pc.h | 4 ++++ include/hw/pci-host/q35.h | 5 ----- hw/i386/pc_q35.c | 8 ++++---- hw/pci-host/q35.c | 8 ++++---- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 6eec0fc51d..c34c698cdd 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -146,6 +146,10 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level); void pc_guest_info_init(PCMachineState *pcms); +#define PCI_HOST_PROP_RAM_MEM "ram-mem" +#define PCI_HOST_PROP_PCI_MEM "pci-mem" +#define PCI_HOST_PROP_SYSTEM_MEM "system-mem" +#define PCI_HOST_PROP_IO_MEM "io-mem" #define PCI_HOST_PROP_PCI_HOLE_START "pci-hole-start" #define PCI_HOST_PROP_PCI_HOLE_END "pci-hole-end" #define PCI_HOST_PROP_PCI_HOLE64_START "pci-hole64-start" diff --git a/include/hw/pci-host/q35.h b/include/hw/pci-host/q35.h index e89329c51e..1d98bbfe0d 100644 --- a/include/hw/pci-host/q35.h +++ b/include/hw/pci-host/q35.h @@ -74,11 +74,6 @@ struct Q35PCIHost { * gmch part */ -#define MCH_HOST_PROP_RAM_MEM "ram-mem" -#define MCH_HOST_PROP_PCI_MEM "pci-mem" -#define MCH_HOST_PROP_SYSTEM_MEM "system-mem" -#define MCH_HOST_PROP_IO_MEM "io-mem" - /* PCI configuration */ #define MCH_HOST_BRIDGE "MCH" diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 852250e8cb..02dd274276 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -218,13 +218,13 @@ static void pc_q35_init(MachineState *machine) pc_memory_init(pcms, system_memory, rom_memory, pci_hole64_size); object_property_add_child(OBJECT(machine), "q35", phb); - object_property_set_link(phb, MCH_HOST_PROP_RAM_MEM, + object_property_set_link(phb, PCI_HOST_PROP_RAM_MEM, OBJECT(machine->ram), NULL); - object_property_set_link(phb, MCH_HOST_PROP_PCI_MEM, + object_property_set_link(phb, PCI_HOST_PROP_PCI_MEM, OBJECT(pci_memory), NULL); - object_property_set_link(phb, MCH_HOST_PROP_SYSTEM_MEM, + object_property_set_link(phb, PCI_HOST_PROP_SYSTEM_MEM, OBJECT(system_memory), NULL); - object_property_set_link(phb, MCH_HOST_PROP_IO_MEM, + object_property_set_link(phb, PCI_HOST_PROP_IO_MEM, OBJECT(system_io), NULL); object_property_set_int(phb, PCI_HOST_BELOW_4G_MEM_SIZE, x86ms->below_4g_mem_size, NULL); diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index d2830cee34..91c46df9ae 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -240,19 +240,19 @@ static void q35_host_initfn(Object *obj) object_property_add_uint64_ptr(obj, PCIE_HOST_MCFG_SIZE, &pehb->size, OBJ_PROP_FLAG_READ); - object_property_add_link(obj, MCH_HOST_PROP_RAM_MEM, TYPE_MEMORY_REGION, + object_property_add_link(obj, PCI_HOST_PROP_RAM_MEM, TYPE_MEMORY_REGION, (Object **) &s->mch.ram_memory, qdev_prop_allow_set_link_before_realize, 0); - object_property_add_link(obj, MCH_HOST_PROP_PCI_MEM, TYPE_MEMORY_REGION, + object_property_add_link(obj, PCI_HOST_PROP_PCI_MEM, TYPE_MEMORY_REGION, (Object **) &s->mch.pci_address_space, qdev_prop_allow_set_link_before_realize, 0); - object_property_add_link(obj, MCH_HOST_PROP_SYSTEM_MEM, TYPE_MEMORY_REGION, + object_property_add_link(obj, PCI_HOST_PROP_SYSTEM_MEM, TYPE_MEMORY_REGION, (Object **) &s->mch.system_memory, qdev_prop_allow_set_link_before_realize, 0); - object_property_add_link(obj, MCH_HOST_PROP_IO_MEM, TYPE_MEMORY_REGION, + object_property_add_link(obj, PCI_HOST_PROP_IO_MEM, TYPE_MEMORY_REGION, (Object **) &s->mch.address_space_io, qdev_prop_allow_set_link_before_realize, 0); } From patchwork Mon Jul 10 23:03:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806070 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=aPEIqPCA; dkim-atps=neutral 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 4R0KPF0scdz20ZZ for ; Tue, 11 Jul 2023 09:06:09 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzut-0005Bq-QR; Mon, 10 Jul 2023 19:03:40 -0400 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 1qIzus-0005BB-Fm for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:38 -0400 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 1qIzur-0004H9-0n for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030216; 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=YMNZW+4NKvO7+vAb7cE4MQSCw+g7Z2FKLuxYz0OIZhE=; b=aPEIqPCA+vsuODnPuB+GlKTlPuGIjFmmvRIydkM8TzXwxtDJPtrA8zKy3jQFpP2yb0qCy2 bshaek3bW0MeKRUxT5J6p7gO+uwz6MHTEMQ5Q6x1PT0B3dSONpW094SFLTS+soCUekyd+X T+z/jwyo5FiDsWkq0plHDxD/qxts8d0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-227-E-WrnLCaNbeu380CeUXVOw-1; Mon, 10 Jul 2023 19:03:34 -0400 X-MC-Unique: E-WrnLCaNbeu380CeUXVOw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fc0855dcc5so15718115e9.2 for ; Mon, 10 Jul 2023 16:03:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030213; x=1691622213; 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=YMNZW+4NKvO7+vAb7cE4MQSCw+g7Z2FKLuxYz0OIZhE=; b=LXKB9QKK1OOzND8F7bvrW1X7OuF2KfPLxpsJuNDR0cwBkV10y0AnGBdpP/qZgJx4lj OdUe9k/4zbk/BkX2a5izoBVZCGEEeFFU+Qq6KGnh+0SgdpFFgCWekabFOOJFs2cBv8zZ bJHo/HYzJy/D2K9ebPXrOr1mF8gaEeffQZUhRGmxdrg2pjWve1o3corG/jRl0UGyvEjk Ul4rb2BwtLOB7m+nlkISA9u42Yc+emnLfrUqzBBt+CtOM4zau8qm6RsGn0DzA5Y4OnBP g+M1jgmS2cEWqm9zfnKUjYgsc+L3A27bj/by/4FZ+6escuz20HmxGo7X1gqCLQ9S9BcF WH/A== X-Gm-Message-State: ABy/qLbHtQ8Ct1U9u48GKNYNs/g0twA+EpOlXLih7LEWWyUFtXaD9TzV Y6GDX22s6ReUFXoDXb099+laNuxiom5F29SwHm6f97QDNeKEi/aKmJJrBxpVIbM+vMCMW44oUma 6gKouN6V0AxSK1fBrz/lPOaC1pDYRHPJXeImb9uwwNQpsDkAMpfoZd8dePHuYyHcz0ite X-Received: by 2002:a7b:c451:0:b0:3fb:b4fc:be62 with SMTP id l17-20020a7bc451000000b003fbb4fcbe62mr12489315wmi.17.1689030213549; Mon, 10 Jul 2023 16:03:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlEVNZ+BnLLxkBMCEZ9uDGv6zO7afQKFOT3DSF0pzGCLb2JpIJp/zWEzmnkJITDcfZifDBzhCQ== X-Received: by 2002:a7b:c451:0:b0:3fb:b4fc:be62 with SMTP id l17-20020a7bc451000000b003fbb4fcbe62mr12489295wmi.17.1689030213271; Mon, 10 Jul 2023 16:03:33 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id v3-20020a1cf703000000b003fbb5506e54sm935317wmh.29.2023.07.10.16.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:32 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Igor Mammedov , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 23/66] hw/i386/pc_piix: Turn some local variables into initializers 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 Eliminates an else branch. Suggested-by: Igor Mammedov Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230630073720.21297-8-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc_piix.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index f9947fbc10..6a5b6dad2f 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -122,11 +122,11 @@ static void pc_init1(MachineState *machine, BusState *idebus[MAX_IDE_BUS]; ISADevice *rtc_state; MemoryRegion *ram_memory; - MemoryRegion *pci_memory; - MemoryRegion *rom_memory; + MemoryRegion *pci_memory = NULL; + MemoryRegion *rom_memory = system_memory; ram_addr_t lowmem; - uint64_t hole64_size; - DeviceState *i440fx_host; + uint64_t hole64_size = 0; + DeviceState *i440fx_host = NULL; /* * Calculate ram split, for memory below and above 4G. It's a bit @@ -205,11 +205,6 @@ static void pc_init1(MachineState *machine, hole64_size = object_property_get_uint(OBJECT(i440fx_host), PCI_HOST_PROP_PCI_HOLE64_SIZE, &error_abort); - } else { - pci_memory = NULL; - rom_memory = system_memory; - i440fx_host = NULL; - hole64_size = 0; } pc_guest_info_init(pcms); From patchwork Mon Jul 10 23:03:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=BjbQYZi+; dkim-atps=neutral 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 4R0KLn32xnz20ZZ for ; Tue, 11 Jul 2023 09:04:01 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzux-0005Wj-VJ; Mon, 10 Jul 2023 19:03:43 -0400 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 1qIzuw-0005Lk-K3 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:42 -0400 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 1qIzuu-0004Hk-1J for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030219; 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=elYMoXg9QVwhRNFpbJN9zA3o30arH0LQPiAaoIJj+RU=; b=BjbQYZi+H1EH0O5m94QIVxpUE7mmrxR2zddcXbnO8wDuiJTK1Q6yvluiqzwdGyN5A6kQ3j N5r/mViKG+rcnRxksPgM+iF2n+Q3gpFecKqzYCvh1T1i5ZrmRwGQrrxp1f9qIh1h5EIFTJ VsOGUv5kkbhsPpcreJKW6hUwKzo95HY= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-376-PN2x-NT3Nhyewapxr0s0lg-1; Mon, 10 Jul 2023 19:03:38 -0400 X-MC-Unique: PN2x-NT3Nhyewapxr0s0lg-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-31400956ce8so2831701f8f.3 for ; Mon, 10 Jul 2023 16:03:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030216; x=1691622216; 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=elYMoXg9QVwhRNFpbJN9zA3o30arH0LQPiAaoIJj+RU=; b=jixDnGbjb49E3W4FFzn61AmNVvLDFDX0/YmDAJpDBCYz8J8uXNkG8/g96SutOTEQI9 5Ppy8nzJu7TFSO7XGhN3x2CjzmpcJCt/CSjVdfqSHumQBl/h0sJa54shiEpq3/sivr6X JZ7rdqI7mPOV/ep74HOOiZBC0WKE+h8xa7TzsMa2g9u4LbZpUypf8vHjf+Wx1YpGmIbO jMpZdUJ5OZJY9KF/Ea32kWBh6sI2JFFadI+B35HmCgW+IOf9Nh9UI/vPrMuLblB23wbe 4apWnc/2MqBexcOypv065alhsEw8MYh/qiRI86aehy3x2o5/r5WrW7WCaypY9P75JiMK suDA== X-Gm-Message-State: ABy/qLYH+WGN2h/gYCuM7mWWZ3F8YzwjS6u0hVR3Ql3D8UjjbCG2PEZM RjgfdOUt1r4FD1LSJYWz/enTIp2JQuwmjq+fCsbSXO9/D8XEm2is8BZftolH8k4t2K7xMXTBhKN VghzJGYgLWef05F/PWkSRmuHtAuOoj4tPjxaWHfc52SHAxZnEFipcxJvWmpwb99/EGCL/ X-Received: by 2002:adf:ee4a:0:b0:30f:af19:81f3 with SMTP id w10-20020adfee4a000000b0030faf1981f3mr12565222wro.41.1689030216414; Mon, 10 Jul 2023 16:03:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlFelC4me9mv1dP6Ygmt2SzeoiSwkGn6CHefoVqsfb2sKglCfEs1JDWvEguBbVtgXx4qqwzk8A== X-Received: by 2002:adf:ee4a:0:b0:30f:af19:81f3 with SMTP id w10-20020adfee4a000000b0030faf1981f3mr12565196wro.41.1689030216067; Mon, 10 Jul 2023 16:03:36 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id d6-20020adfe846000000b0030fd03e3d25sm580551wrn.75.2023.07.10.16.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:35 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:33 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 24/66] hw/pci-host/i440fx: Add "i440fx" child property in board code 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 parent-child relation is usually established near a child's qdev_new(). For i440fx this allows for reusing the machine parameter, thus avoiding qdev_get_machine() which relies on a global variable. Suggested-by: Philippe Mathieu-Daudé Signed-off-by: Bernhard Beschow Message-Id: <20230630073720.21297-9-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc_piix.c | 2 ++ hw/pci-host/i440fx.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 6a5b6dad2f..26e8473a4d 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -202,6 +202,8 @@ static void pc_init1(MachineState *machine, memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); rom_memory = pci_memory; i440fx_host = qdev_new(host_type); + object_property_add_child(OBJECT(machine), "i440fx", + OBJECT(i440fx_host)); hole64_size = object_property_get_uint(OBJECT(i440fx_host), PCI_HOST_PROP_PCI_HOLE64_SIZE, &error_abort); diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c index 61e7b97ff4..d95d9229d3 100644 --- a/hw/pci-host/i440fx.c +++ b/hw/pci-host/i440fx.c @@ -259,7 +259,6 @@ PCIBus *i440fx_init(const char *pci_type, b = pci_root_bus_new(dev, NULL, pci_address_space, address_space_io, 0, TYPE_PCI_BUS); s->bus = b; - object_property_add_child(qdev_get_machine(), "i440fx", OBJECT(dev)); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); d = pci_create_simple(b, 0, pci_type); From patchwork Mon Jul 10 23:03:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806069 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=SNKvXMna; dkim-atps=neutral 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 4R0KNr6gs4z20ZZ for ; Tue, 11 Jul 2023 09:05:48 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzv1-0005tk-0C; Mon, 10 Jul 2023 19:03:47 -0400 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 1qIzuy-0005cM-Fo for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:44 -0400 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 1qIzuw-0004JU-RH for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030222; 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=dbUuQwrEGr4xi2bvWM77xOceCJpPOzjb+5zsk5++7pk=; b=SNKvXMnav4SXsiuRKjUSIjsyvhKfSuElhodeXlf9D0qsjaFweM1KtFqcHFewEQcJvJ9FFL F9Wt0TZzirExJBJ3QFH9TlYbJ4//d1YVoSABql3rpSX1BxK9g9zfFrx6TQjrC18OTRYjsF whvqFe+Jui23JM2zIgrBU4W6RxbqB3g= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-128-kHRfZt9jMj26DSX6YDzAMA-1; Mon, 10 Jul 2023 19:03:41 -0400 X-MC-Unique: kHRfZt9jMj26DSX6YDzAMA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fa9a282fffso29957805e9.1 for ; Mon, 10 Jul 2023 16:03:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030219; x=1691622219; 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=dbUuQwrEGr4xi2bvWM77xOceCJpPOzjb+5zsk5++7pk=; b=MT/2ud36+dy2fnzQ5uBDRssxxXwjjAEK/yH64FwXPgU8Nlkcs/HccpZFYClTOQYyAF e4x7wejyGZULYNj4uNLsPjIQzoc3J0UuFypyEn8b518svAdPI4KmiC4yxTCLMGNc0/cj 9GiJhKsP3J5Wii1b1ztPWOS39cm00Xya9jTPgzAl8GVzb4937YGpP3+CL3zCM+srPnmQ 2RR3bivx+EMwZVAfEcngH+dQIUCYzx+28bt0nWYorB/UzLFhjs49mVmqWZtCJerS2g9f HDi9KeUbvZrc3Nbe9iEk5uf8lhwjV+hRzbkbhxMG1cRYkAiA9TnhTtmWRLy4x6uqss5I 07vw== X-Gm-Message-State: ABy/qLYejH00xf6Sl2hKBC98mDiflEHHg5WAfYyjrzcXfCYzoC6NY2C9 JPwvleRu2pvIDtiJh0aNiXUQfTMzPhvIV9CTjQUrwlpHq8EnqSTGsX74zRhvYFY0PWoi510sRVi 3TSBk2oip2En63bZVCqVT483jfFDMEye4YPuH+fAv+0jfv1DiTLN1jf9ZkiKjdXi9LZ4b X-Received: by 2002:a05:600c:ad8:b0:3fb:fa61:a4ed with SMTP id c24-20020a05600c0ad800b003fbfa61a4edmr9451245wmr.26.1689030219514; Mon, 10 Jul 2023 16:03:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlGvihms63n2ABlA862hXbtpDhmK9ZIE7P1sSctfVX+/QUkuFip4xLI4LrZy8pQliMqLeU9V0A== X-Received: by 2002:a05:600c:ad8:b0:3fb:fa61:a4ed with SMTP id c24-20020a05600c0ad800b003fbfa61a4edmr9451229wmr.26.1689030219151; Mon, 10 Jul 2023 16:03:39 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id v15-20020a1cf70f000000b003fa8158135esm11398974wmh.11.2023.07.10.16.03.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:38 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:36 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Igor Mammedov , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Marcel Apfelbaum Subject: [PULL 25/66] hw/pci-host/i440fx: Replace magic values by existing constants 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 Signed-off-by: Bernhard Beschow Reviewed-by: Igor Mammedov Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230630073720.21297-10-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-host/i440fx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c index d95d9229d3..b7c24a4e1d 100644 --- a/hw/pci-host/i440fx.c +++ b/hw/pci-host/i440fx.c @@ -276,8 +276,8 @@ PCIBus *i440fx_init(const char *pci_type, /* if *disabled* show SMRAM to all CPUs */ memory_region_init_alias(&f->smram_region, OBJECT(d), "smram-region", - f->pci_address_space, 0xa0000, 0x20000); - memory_region_add_subregion_overlap(f->system_memory, 0xa0000, + f->pci_address_space, SMRAM_C_BASE, SMRAM_C_SIZE); + memory_region_add_subregion_overlap(f->system_memory, SMRAM_C_BASE, &f->smram_region, 1); memory_region_set_enabled(&f->smram_region, true); @@ -285,9 +285,9 @@ PCIBus *i440fx_init(const char *pci_type, memory_region_init(&f->smram, OBJECT(d), "smram", 4 * GiB); memory_region_set_enabled(&f->smram, true); memory_region_init_alias(&f->low_smram, OBJECT(d), "smram-low", - f->ram_memory, 0xa0000, 0x20000); + f->ram_memory, SMRAM_C_BASE, SMRAM_C_SIZE); memory_region_set_enabled(&f->low_smram, true); - memory_region_add_subregion(&f->smram, 0xa0000, &f->low_smram); + memory_region_add_subregion(&f->smram, SMRAM_C_BASE, &f->low_smram); object_property_add_const_link(qdev_get_machine(), "smram", OBJECT(&f->smram)); From patchwork Mon Jul 10 23:03:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806056 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=GdNrpWnN; dkim-atps=neutral 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 4R0KLm6pGvz20Ph for ; Tue, 11 Jul 2023 09:04:00 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzv3-0006KK-Rb; Mon, 10 Jul 2023 19:03:49 -0400 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 1qIzv2-000665-94 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:48 -0400 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 1qIzv0-0004OB-Ko for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030226; 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=h9s9LINlofROMqq3QpUKiPP8dWTQZ4BuJJSE2ob0izQ=; b=GdNrpWnNt5Z1PJyaFgUCSvVBRjwjaHrjNr4HEf0gn1/NzmFNrAgtObD888RnAFoWdQPUYO lgCpRj3sfR1K9bdiMEhptJQ0+ijGUZDn/WbOov5omf/eJBcNSfnKxpuYMctAIe34zmNPGL vbUnmTsPUCPUWtzluuFGU6kEQpbfvT0= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-474-ImHNmX6NNmS7ot3CF40_Kg-1; Mon, 10 Jul 2023 19:03:43 -0400 X-MC-Unique: ImHNmX6NNmS7ot3CF40_Kg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-31444df0fafso2937149f8f.2 for ; Mon, 10 Jul 2023 16:03:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030222; x=1691622222; 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=h9s9LINlofROMqq3QpUKiPP8dWTQZ4BuJJSE2ob0izQ=; b=LsDjtwpmM7mmaTx0Ntc5D3ThKFk0kpgdTij4PSLJ9Z0vqHcvGwDAwvlv1OyEcwdyYg sY+Lkyi8KFfE4AdPunIC9piXLfOdBaHtGmFJ0lXW8WJf1RNJE35/0aOMZ8gPR4w82Dw0 Gj618SrdbXkRQfcLFsMS7SL+mbVXbR3SCS3Ru+bWUIWRzWe+F75uEhjudPoDv2jRLJ+S 5Dp0jEWnXccmAEmhQ1xLoYI1kcmrjd0Vsi1PgmLh2R790JvdTt7gt6fb3RsakgUq0ym1 2BVr/fX/tYf2Mgv+homkFtAjjH1Bz8VtKZNWj/cXVGI8Ub44U5FXwN8ZgdHO18b+YNfD aOCQ== X-Gm-Message-State: ABy/qLbuZIwKAtwdcoXUGml/yXq+v1NlRvm/QvqIbcisT3eDK/WTpUzZ 4jIzII7mKGcjwemHS5gNLOxG54gxr2giQW40yRK9aTECjeK3qsBl2pzR6eewunElsIP1qTq9tgo vQW9MrWaSzGMY1RQs7txefMXbRd0XVE2rmsIJSu/StCHvyJKF36ieHgFnUgcOmgE8kMMn X-Received: by 2002:a5d:5391:0:b0:315:9d08:9d3b with SMTP id d17-20020a5d5391000000b003159d089d3bmr4951915wrv.32.1689030222004; Mon, 10 Jul 2023 16:03:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlHwItxCu6dIxbKWYunGmQdaE/4uNN5/Pth9lufiDU95AVrjyAjunL0kUIE5g7aYp2qGSqbf5Q== X-Received: by 2002:a5d:5391:0:b0:315:9d08:9d3b with SMTP id d17-20020a5d5391000000b003159d089d3bmr4951894wrv.32.1689030221766; Mon, 10 Jul 2023 16:03:41 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id l10-20020adffe8a000000b00315995837aesm591126wrr.36.2023.07.10.16.03.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:41 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Marcel Apfelbaum Subject: [PULL 26/66] hw/pci-host/i440fx: Have common names for some local variables 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 `PCIHostState` is often referred to as `phb`, own device state usually as `s`. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230630073720.21297-11-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-host/i440fx.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c index b7c24a4e1d..0b76fe71af 100644 --- a/hw/pci-host/i440fx.c +++ b/hw/pci-host/i440fx.c @@ -205,28 +205,28 @@ static void i440fx_pcihost_get_pci_hole64_end(Object *obj, Visitor *v, static void i440fx_pcihost_initfn(Object *obj) { - PCIHostState *s = PCI_HOST_BRIDGE(obj); + PCIHostState *phb = PCI_HOST_BRIDGE(obj); - memory_region_init_io(&s->conf_mem, obj, &pci_host_conf_le_ops, s, + memory_region_init_io(&phb->conf_mem, obj, &pci_host_conf_le_ops, phb, "pci-conf-idx", 4); - memory_region_init_io(&s->data_mem, obj, &pci_host_data_le_ops, s, + memory_region_init_io(&phb->data_mem, obj, &pci_host_data_le_ops, phb, "pci-conf-data", 4); } static void i440fx_pcihost_realize(DeviceState *dev, Error **errp) { - PCIHostState *s = PCI_HOST_BRIDGE(dev); + PCIHostState *phb = PCI_HOST_BRIDGE(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); - memory_region_add_subregion(s->bus->address_space_io, 0xcf8, &s->conf_mem); + memory_region_add_subregion(phb->bus->address_space_io, 0xcf8, &phb->conf_mem); sysbus_init_ioports(sbd, 0xcf8, 4); - memory_region_add_subregion(s->bus->address_space_io, 0xcfc, &s->data_mem); + memory_region_add_subregion(phb->bus->address_space_io, 0xcfc, &phb->data_mem); sysbus_init_ioports(sbd, 0xcfc, 4); /* register i440fx 0xcf8 port as coalesced pio */ - memory_region_set_flush_coalesced(&s->data_mem); - memory_region_add_coalescing(&s->conf_mem, 0, 4); + memory_region_set_flush_coalesced(&phb->data_mem); + memory_region_add_coalescing(&phb->conf_mem, 0, 4); } static void i440fx_realize(PCIDevice *dev, Error **errp) @@ -248,17 +248,16 @@ PCIBus *i440fx_init(const char *pci_type, MemoryRegion *pci_address_space, MemoryRegion *ram_memory) { + I440FXState *s = I440FX_PCI_HOST_BRIDGE(dev); + PCIHostState *phb = PCI_HOST_BRIDGE(dev); PCIBus *b; PCIDevice *d; - PCIHostState *s; PCII440FXState *f; unsigned i; - I440FXState *i440fx; - s = PCI_HOST_BRIDGE(dev); b = pci_root_bus_new(dev, NULL, pci_address_space, address_space_io, 0, TYPE_PCI_BUS); - s->bus = b; + phb->bus = b; sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); d = pci_create_simple(b, 0, pci_type); @@ -267,8 +266,7 @@ PCIBus *i440fx_init(const char *pci_type, f->pci_address_space = pci_address_space; f->ram_memory = ram_memory; - i440fx = I440FX_PCI_HOST_BRIDGE(dev); - range_set_bounds(&i440fx->pci_hole, below_4g_mem_size, + range_set_bounds(&s->pci_hole, below_4g_mem_size, IO_APIC_DEFAULT_ADDRESS - 1); /* setup pci memory mapping */ From patchwork Mon Jul 10 23:03:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806083 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=RZZquMPX; dkim-atps=neutral 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 4R0KRj4jCjz20bx for ; Tue, 11 Jul 2023 09:08:17 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzv5-0006V9-8Z; Mon, 10 Jul 2023 19:03:51 -0400 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 1qIzv3-0006K2-Mi for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:49 -0400 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 1qIzv2-0004Os-5q for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030227; 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=Muy8inKfvBPASO7rYLT1LevUdIo8+kfo/7lFDLCwAW8=; b=RZZquMPXGO/FTH2HIZ7/8CMwBmnlWSbZAdTy4A2FO4laRGxnSd0RrjqVoKZm5/xsHrUSWW LzuYtnXb+g8N3o4w5VY29MI5cF/wOiEhExxaS9oDNx8aYSjdB+z2Dz24VSHoD67MxTyYw7 FHmblSeNzEVSoBz7U7I8EapiyycOGjI= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-385-W4dBKDuDPVeHZ1JnJXfrTw-1; Mon, 10 Jul 2023 19:03:46 -0400 X-MC-Unique: W4dBKDuDPVeHZ1JnJXfrTw-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-315998d6e7fso1080471f8f.3 for ; Mon, 10 Jul 2023 16:03:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030224; x=1691622224; 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=Muy8inKfvBPASO7rYLT1LevUdIo8+kfo/7lFDLCwAW8=; b=WExKSNaEirQslc5IsokviqDn27scP0zEMvzZfb+5QNo9VyS+14p9iFqD8munNu6hNM 6ZCN3nysvGjrBCOB7OnCCiIowOP6TsuBuNvG/6LBcJoaDPPVMLnY4BES7ix+2L5yOAuP FBvXNygU3LMz4zk0gbDS3g2Jw5zGf//qg0rZFEdIAOiP8e6gsjrrzRnW2zxjdQzzcHAB GBAjlZ8g4XQwQkhjkZUQFjcdEn/7PUtmKp2gN5sB5UUkxRlPFAwsF1b/GoW4qEBYWc88 sEKIRxS92949+aJOFpZIuBk5NLtYdaV+F3GQWG+uEb0mw3W0gUDTQqa06wvScYmYxFfB vI4Q== X-Gm-Message-State: ABy/qLY4L5dA6qZ8Ui9Hcez4ZAa/NpZQELIoHMRRAgH5zwEkHJhV2Auf Xi1YAxBexXhaDJmAFUAjJp+ZGY2VDoZgV+viO/k/oPaBqkCNLcS6lIcyccjBgvPytZ9yMPivDX9 Cr+P0j7uv7B2B/25A16yg4QnVovMqwcJiIy9wu4FduucXfhOXDLViCdmZQ2G92aDn3A/B X-Received: by 2002:adf:fe43:0:b0:314:1a98:ebc0 with SMTP id m3-20020adffe43000000b003141a98ebc0mr11566161wrs.26.1689030224838; Mon, 10 Jul 2023 16:03:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlEmqj1QcSRR7qS0RclbDFTdZLcy4TAcmg785TslHOSqY+JERxjUiA3AkPjVxMJqveaI9M04tA== X-Received: by 2002:adf:fe43:0:b0:314:1a98:ebc0 with SMTP id m3-20020adffe43000000b003141a98ebc0mr11566151wrs.26.1689030224638; Mon, 10 Jul 2023 16:03:44 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id f4-20020a5d4dc4000000b0031424f4ef1dsm600772wru.19.2023.07.10.16.03.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:44 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Marcel Apfelbaum Subject: [PULL 27/66] hw/pci-host/i440fx: Move i440fx_realize() into PCII440FXState section Message-ID: <44df0552a020efd6191714da44edede5ded37ec8.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 i440fx_realize() realizes the PCI device inside the host bridge (PCII440FXState), but is implemented between i440fx_pcihost_realize() and i440fx_init() which deal with the host bridge itself (I440FXState). Since we want to append i440fx_init() to i440fx_pcihost_realize() later let's move i440fx_realize() out of the way. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230630073720.21297-12-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-host/i440fx.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c index 0b76fe71af..e84fcd50b6 100644 --- a/hw/pci-host/i440fx.c +++ b/hw/pci-host/i440fx.c @@ -65,6 +65,15 @@ struct I440FXState { */ #define I440FX_COREBOOT_RAM_SIZE 0x57 +static void i440fx_realize(PCIDevice *dev, Error **errp) +{ + dev->config[I440FX_SMRAM] = 0x02; + + if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) { + warn_report("i440fx doesn't support emulated iommu"); + } +} + static void i440fx_update_memory_mappings(PCII440FXState *d) { int i; @@ -229,15 +238,6 @@ static void i440fx_pcihost_realize(DeviceState *dev, Error **errp) memory_region_add_coalescing(&phb->conf_mem, 0, 4); } -static void i440fx_realize(PCIDevice *dev, Error **errp) -{ - dev->config[I440FX_SMRAM] = 0x02; - - if (object_property_get_bool(qdev_get_machine(), "iommu", NULL)) { - warn_report("i440fx doesn't support emulated iommu"); - } -} - PCIBus *i440fx_init(const char *pci_type, DeviceState *dev, MemoryRegion *address_space_mem, From patchwork Mon Jul 10 23:03:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806060 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=BC5x5/k1; dkim-atps=neutral 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 4R0KMT2Wtwz20Ph for ; Tue, 11 Jul 2023 09:04:37 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzv8-0006hX-Qc; Mon, 10 Jul 2023 19:03:54 -0400 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 1qIzv7-0006b0-81 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:53 -0400 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 1qIzv5-0004Ps-KG for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030231; 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=4FNn+sY/o3drXdYQoMsrAHjkktUYUW6+/Foc/eC1Pfo=; b=BC5x5/k1lSb//z/MqWeYD2mt1LGc44GHWextXilnolc4B+PUnlKbm7nGyG/YoAQS6WlIpZ 97aP2eUD6irKWYPQH5qS/rKXs8u5cDxVQu+/W6TTkNsqylrb3oCi0RYdoYo0bSI6n7Eypv FRI0r8jtjOWPxn2ZpfcE70usDnoz8wE= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-310-pzLI1etPOaGOOozZeCOHdQ-1; Mon, 10 Jul 2023 19:03:49 -0400 X-MC-Unique: pzLI1etPOaGOOozZeCOHdQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fbdd5d09b8so34278645e9.1 for ; Mon, 10 Jul 2023 16:03:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030228; x=1691622228; 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=4FNn+sY/o3drXdYQoMsrAHjkktUYUW6+/Foc/eC1Pfo=; b=HBQVvOq8DvNuAysDK6qgVK1YRdad92ceBJ82yY/8BQinVo09xtNTFcRso86sdKik+v psyWPCPhZ02e4NBvlpEJvcj5isyWoGXyl5Ac7VrdBdGt5hlA4tXB7TWnXpYKyP6o2Nku KYm51N8DrbwZ6+p06cVl8SRYH9mj03UJbkayYHK7BwxhCFpw/a8DMyeO/sbMXEDMb3gD +WNdjulNg09NQ6MS4dr9f8/hwq/D0hsWxGzzqowCaOFsW4A2F2r8B0sg0LgOo33UgE0b QpL4IJmeRylAtqmVv23wdfxUzkd9XStD5OE7j6b3A4X0zVywRFSn5QDAhiC6yw1ku21T Xlig== X-Gm-Message-State: ABy/qLaP9EikTau91K1Kj6P+/wIQvsIsCj2/155qAYP0GLJW85lhD/wI gqldyTWIDqXlG2TaU1qCZytKO5hFNaKynibrj7PXHXBBdBZ0mxXcmGmxmPNsqlOiQ+Bw/nrzkI4 SwYNtX3oLgdW7x79/asC4T1yQZKBz64aIYEZ6/9MDRajLK+WMKLqMKzZCr3CIV+TCP9hY X-Received: by 2002:a1c:7417:0:b0:3fb:e573:4172 with SMTP id p23-20020a1c7417000000b003fbe5734172mr13818774wmc.31.1689030228178; Mon, 10 Jul 2023 16:03:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlEVI0Ov4/Ie3hKz6ek9CmRuNwBuGqGt3iR73qpSRRaxjuseycC28nFjJJ9g6sQjE9wPI48AyA== X-Received: by 2002:a1c:7417:0:b0:3fb:e573:4172 with SMTP id p23-20020a1c7417000000b003fbe5734172mr13818756wmc.31.1689030227789; Mon, 10 Jul 2023 16:03:47 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id f19-20020a7bcc13000000b003fa973e6612sm11484343wmh.44.2023.07.10.16.03.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:47 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Marcel Apfelbaum Subject: [PULL 28/66] hw/pci-host/i440fx: Make MemoryRegion pointers accessible as properties Message-ID: <09f85b7b93a05f1551509b245be99529a9e278f9.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 goal is to eliminate i440fx_init() which is a legacy init function. This neccessitates the memory regions to be properties, like in Q35, which will be assigned in board code. Since i440fx needs different PCI devices in Xen mode, and since i440fx shall be self-contained, the PCI device will be created during realization of the host. Thus the pointers need to be moved to the host structure to be usable as properties. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230630073720.21297-13-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci-host/i440fx.h | 3 --- hw/pci-host/i440fx.c | 42 +++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/include/hw/pci-host/i440fx.h b/include/hw/pci-host/i440fx.h index bf57216c78..e3a550021e 100644 --- a/include/hw/pci-host/i440fx.h +++ b/include/hw/pci-host/i440fx.h @@ -25,9 +25,6 @@ struct PCII440FXState { PCIDevice parent_obj; /*< public >*/ - MemoryRegion *system_memory; - MemoryRegion *pci_address_space; - MemoryRegion *ram_memory; PAMMemoryRegion pam_regions[PAM_REGIONS_COUNT]; MemoryRegion smram_region; MemoryRegion smram, low_smram; diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c index e84fcd50b6..b9530fc3a0 100644 --- a/hw/pci-host/i440fx.c +++ b/hw/pci-host/i440fx.c @@ -47,6 +47,10 @@ OBJECT_DECLARE_SIMPLE_TYPE(I440FXState, I440FX_PCI_HOST_BRIDGE) struct I440FXState { PCIHostState parent_obj; + + MemoryRegion *system_memory; + MemoryRegion *pci_address_space; + MemoryRegion *ram_memory; Range pci_hole; uint64_t pci_hole64_size; bool pci_hole64_fix; @@ -214,12 +218,25 @@ static void i440fx_pcihost_get_pci_hole64_end(Object *obj, Visitor *v, static void i440fx_pcihost_initfn(Object *obj) { + I440FXState *s = I440FX_PCI_HOST_BRIDGE(obj); PCIHostState *phb = PCI_HOST_BRIDGE(obj); memory_region_init_io(&phb->conf_mem, obj, &pci_host_conf_le_ops, phb, "pci-conf-idx", 4); memory_region_init_io(&phb->data_mem, obj, &pci_host_data_le_ops, phb, "pci-conf-data", 4); + + object_property_add_link(obj, PCI_HOST_PROP_RAM_MEM, TYPE_MEMORY_REGION, + (Object **) &s->ram_memory, + qdev_prop_allow_set_link_before_realize, 0); + + object_property_add_link(obj, PCI_HOST_PROP_PCI_MEM, TYPE_MEMORY_REGION, + (Object **) &s->pci_address_space, + qdev_prop_allow_set_link_before_realize, 0); + + object_property_add_link(obj, PCI_HOST_PROP_SYSTEM_MEM, TYPE_MEMORY_REGION, + (Object **) &s->system_memory, + qdev_prop_allow_set_link_before_realize, 0); } static void i440fx_pcihost_realize(DeviceState *dev, Error **errp) @@ -255,27 +272,28 @@ PCIBus *i440fx_init(const char *pci_type, PCII440FXState *f; unsigned i; - b = pci_root_bus_new(dev, NULL, pci_address_space, + s->system_memory = address_space_mem; + s->pci_address_space = pci_address_space; + s->ram_memory = ram_memory; + + b = pci_root_bus_new(dev, NULL, s->pci_address_space, address_space_io, 0, TYPE_PCI_BUS); phb->bus = b; sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); d = pci_create_simple(b, 0, pci_type); f = I440FX_PCI_DEVICE(d); - f->system_memory = address_space_mem; - f->pci_address_space = pci_address_space; - f->ram_memory = ram_memory; range_set_bounds(&s->pci_hole, below_4g_mem_size, IO_APIC_DEFAULT_ADDRESS - 1); /* setup pci memory mapping */ - pc_pci_as_mapping_init(f->system_memory, f->pci_address_space); + pc_pci_as_mapping_init(s->system_memory, s->pci_address_space); /* if *disabled* show SMRAM to all CPUs */ memory_region_init_alias(&f->smram_region, OBJECT(d), "smram-region", - f->pci_address_space, SMRAM_C_BASE, SMRAM_C_SIZE); - memory_region_add_subregion_overlap(f->system_memory, SMRAM_C_BASE, + s->pci_address_space, SMRAM_C_BASE, SMRAM_C_SIZE); + memory_region_add_subregion_overlap(s->system_memory, SMRAM_C_BASE, &f->smram_region, 1); memory_region_set_enabled(&f->smram_region, true); @@ -283,17 +301,17 @@ PCIBus *i440fx_init(const char *pci_type, memory_region_init(&f->smram, OBJECT(d), "smram", 4 * GiB); memory_region_set_enabled(&f->smram, true); memory_region_init_alias(&f->low_smram, OBJECT(d), "smram-low", - f->ram_memory, SMRAM_C_BASE, SMRAM_C_SIZE); + s->ram_memory, SMRAM_C_BASE, SMRAM_C_SIZE); memory_region_set_enabled(&f->low_smram, true); memory_region_add_subregion(&f->smram, SMRAM_C_BASE, &f->low_smram); object_property_add_const_link(qdev_get_machine(), "smram", OBJECT(&f->smram)); - init_pam(&f->pam_regions[0], OBJECT(d), f->ram_memory, f->system_memory, - f->pci_address_space, PAM_BIOS_BASE, PAM_BIOS_SIZE); + init_pam(&f->pam_regions[0], OBJECT(d), s->ram_memory, s->system_memory, + s->pci_address_space, PAM_BIOS_BASE, PAM_BIOS_SIZE); for (i = 0; i < ARRAY_SIZE(f->pam_regions) - 1; ++i) { - init_pam(&f->pam_regions[i + 1], OBJECT(d), f->ram_memory, - f->system_memory, f->pci_address_space, + init_pam(&f->pam_regions[i + 1], OBJECT(d), s->ram_memory, + s->system_memory, s->pci_address_space, PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); } From patchwork Mon Jul 10 23:03:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806078 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=LVmGj3qg; dkim-atps=neutral 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 4R0KRK6Rcyz20ZZ for ; Tue, 11 Jul 2023 09:07:57 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzvC-0007AC-Mj; Mon, 10 Jul 2023 19:03:58 -0400 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 1qIzvA-0006v4-SR for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:56 -0400 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 1qIzv9-0004Q8-8j for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030233; 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=rCz2MZwVWTLA7GKiawzVQqAFmBnEDXSLl1/166ddiFk=; b=LVmGj3qgnfMVchIdz27I+NQH/dIk9z9hzTmf9ttH/1pzEOZpAf+FbnAvL/WZt5lNr07b68 FDRCSssz3x8poj56xmorbPPKfVD0Asd1whVwm+86Awy2KJJNtzQ+BUzq9H6+87ppNLRLWI SyTv6Cs2FtonGZDTwzb/nzVlybEUicY= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-336-I2VSets6NfKGgPi4NFXAZQ-1; Mon, 10 Jul 2023 19:03:52 -0400 X-MC-Unique: I2VSets6NfKGgPi4NFXAZQ-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-315926005c9so1351452f8f.0 for ; Mon, 10 Jul 2023 16:03:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030230; x=1691622230; 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=rCz2MZwVWTLA7GKiawzVQqAFmBnEDXSLl1/166ddiFk=; b=ENQEkQnDV2mIQNc7bXVZYRssWJOWzahRYusaa3ockjQY+6/Nw3E3M60qqOqQg7ml+o Dgd9KON2soZtCK1q7KFCFN18TiiWiXFg/Nur92ismC+EdMwmQNF/fAqKnroKFynGvNCB rLdHxIppVZHTVEGSdSsxEFSv6iStKvfVClqDyEQj07GHHrkQ7plbAEwzf/H7cxnlzLfz 6R2u2akgxTFB1s5yWtMsPyW+F5r8jKD2n1xFpqvcPVhG/rmw7OwQ2HOroU7mmaGaZcPP CtaGekqNQERP7U4C2hqQuptGP+zAfKUNJJFLyPmWpuy7/1RhIWniUbBdE8dxySMg34ck bOqQ== X-Gm-Message-State: ABy/qLbZzc5Xa/5KsvNhH+qMd7JzcTm1SHDk6t8w4I0zfQLjXDPEsglI r7od7lEz3280Y6rq7ehV2NxXu3P4ygRvOiyfkJ5Kn7vq1Lpowcbaq+q94F7qtZiVeVsZEChHuGD NvNvwBYhfxAFxzNSpdt5LOw8qEpT/NpgETRym4/G/khr+0vTk3SvJu59GCUJ7hH3Pq5Yk X-Received: by 2002:a05:6000:1290:b0:314:55cd:ec6b with SMTP id f16-20020a056000129000b0031455cdec6bmr1583609wrx.71.1689030230745; Mon, 10 Jul 2023 16:03:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlEvrNBWHreRBukB5O8nYulChbRKy5/+52nkB0G+HYS0zbVRbd1U89dECw//jw+vlUV99DCKSQ== X-Received: by 2002:a05:6000:1290:b0:314:55cd:ec6b with SMTP id f16-20020a056000129000b0031455cdec6bmr1583598wrx.71.1689030230539; Mon, 10 Jul 2023 16:03:50 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id r7-20020a5d6947000000b00313fd294d6csm614942wrw.7.2023.07.10.16.03.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:50 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Marcel Apfelbaum Subject: [PULL 29/66] hw/pci-host/i440fx: Add PCI_HOST_PROP_IO_MEM property 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 Introduce the property in anticipation of QOM'ification; Q35 has the same property. Signed-off-by: Bernhard Beschow Message-Id: <20230630073720.21297-14-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci-host/i440fx.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c index b9530fc3a0..de14c75e95 100644 --- a/hw/pci-host/i440fx.c +++ b/hw/pci-host/i440fx.c @@ -27,7 +27,6 @@ #include "qemu/range.h" #include "hw/i386/pc.h" #include "hw/pci/pci.h" -#include "hw/pci/pci_bus.h" #include "hw/pci/pci_host.h" #include "hw/pci-host/i440fx.h" #include "hw/qdev-properties.h" @@ -49,6 +48,7 @@ struct I440FXState { PCIHostState parent_obj; MemoryRegion *system_memory; + MemoryRegion *io_memory; MemoryRegion *pci_address_space; MemoryRegion *ram_memory; Range pci_hole; @@ -237,17 +237,22 @@ static void i440fx_pcihost_initfn(Object *obj) object_property_add_link(obj, PCI_HOST_PROP_SYSTEM_MEM, TYPE_MEMORY_REGION, (Object **) &s->system_memory, qdev_prop_allow_set_link_before_realize, 0); + + object_property_add_link(obj, PCI_HOST_PROP_IO_MEM, TYPE_MEMORY_REGION, + (Object **) &s->io_memory, + qdev_prop_allow_set_link_before_realize, 0); } static void i440fx_pcihost_realize(DeviceState *dev, Error **errp) { + I440FXState *s = I440FX_PCI_HOST_BRIDGE(dev); PCIHostState *phb = PCI_HOST_BRIDGE(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); - memory_region_add_subregion(phb->bus->address_space_io, 0xcf8, &phb->conf_mem); + memory_region_add_subregion(s->io_memory, 0xcf8, &phb->conf_mem); sysbus_init_ioports(sbd, 0xcf8, 4); - memory_region_add_subregion(phb->bus->address_space_io, 0xcfc, &phb->data_mem); + memory_region_add_subregion(s->io_memory, 0xcfc, &phb->data_mem); sysbus_init_ioports(sbd, 0xcfc, 4); /* register i440fx 0xcf8 port as coalesced pio */ @@ -273,11 +278,12 @@ PCIBus *i440fx_init(const char *pci_type, unsigned i; s->system_memory = address_space_mem; + s->io_memory = address_space_io; s->pci_address_space = pci_address_space; s->ram_memory = ram_memory; b = pci_root_bus_new(dev, NULL, s->pci_address_space, - address_space_io, 0, TYPE_PCI_BUS); + s->io_memory, 0, TYPE_PCI_BUS); phb->bus = b; sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); From patchwork Mon Jul 10 23:03:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806094 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=IDQzMDFf; dkim-atps=neutral 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 4R0KSX0KYQz20bx for ; Tue, 11 Jul 2023 09:09:00 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzvE-0007Oy-Dm; Mon, 10 Jul 2023 19:04:00 -0400 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 1qIzvC-0007Ds-T9 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:58 -0400 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 1qIzvB-0004QI-0L for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:03:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030236; 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=hddxwq1XHSF6riRXSBNidFCr4o8X89eTT2U5op/sFq0=; b=IDQzMDFfY9ewiHvbHoqKnC5dpnmRFs7uM/Zs5HGxVJKJb9jpG7RRMEHNTxXoRHWJx5z9pq JwsT0cUAha7oFqsN81WHsNLfszgrCTPW0tMVCQBBFFvoF/8Ep1CFoP1cKir8PSL/KV+TA/ 1dVy0kb8l0/9JD+kiTbQtlgjdeyJr/Q= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-204-d6JW5XcxNuuv8qvvjAfdQg-1; Mon, 10 Jul 2023 19:03:55 -0400 X-MC-Unique: d6JW5XcxNuuv8qvvjAfdQg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-315a03cae87so488609f8f.0 for ; Mon, 10 Jul 2023 16:03:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030233; x=1691622233; 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=hddxwq1XHSF6riRXSBNidFCr4o8X89eTT2U5op/sFq0=; b=f8OfCzER5slYwFAQjc/fswmY+KCgf46+yyW5RNG0dGnNxXYXoy7ipI5n7kvpJwG2us RVgrIhxNtVrzo706RV2wpSSV7+9u276rgmLxRMyjmrQmZW1VOKeu/wtfNHF16oK78Kni rDlfduHWyP5pHSMsQb62M9g33I9CHnlFQoHLnQjNwnaBAYZtgF5zfN+30Z2XUzqdQiFC b77tGo0iFZjQk1Svvr459PYuhC1bhHm+ez/jvUZvz1REd162+n5uWulL+gLhI+OHANwq HOFoJokOAuaHezJaGwhx8nfolWc2t4RJZXq2CU3oXFvRD9tEei8NphGKOAp/dE9NxMBV 7MYQ== X-Gm-Message-State: ABy/qLZYLmBsDMXpwcLwORPG8ZBKWFhfoW+GpvZo41dosl5k6yFKLLeh U2U9IJkJLtZ1hbiZPizwtjQlNES90A2FGk1Cr2KP6nm5qLiOYXQ6lw8m4YC5ziMIybKlFCRNihQ /pxQ6b7ErAGm505aJ5/HbnFQwXrVcOA825GCABIEk8QAIFAVm31bFiAtPMtR8LQ9RUAPy X-Received: by 2002:a5d:65c8:0:b0:313:f0a7:133a with SMTP id e8-20020a5d65c8000000b00313f0a7133amr15801249wrw.13.1689030233693; Mon, 10 Jul 2023 16:03:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlGcY0b6/kVCw3nDJVbJ7Jpo5eENdwDD2x6sdH11NSpj2DQ1Myps0V6u8gzB8wKIbtKqkInmAQ== X-Received: by 2002:a5d:65c8:0:b0:313:f0a7:133a with SMTP id e8-20020a5d65c8000000b00313f0a7133amr15801234wrw.13.1689030233473; Mon, 10 Jul 2023 16:03:53 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id m15-20020adfdc4f000000b003142ea7a661sm597465wrj.21.2023.07.10.16.03.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:53 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:50 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 30/66] hw/pci-host/i440fx: Add PCI_HOST_{ABOVE, BELOW}_4G_MEM_SIZE properties Message-ID: <82feef45f42db607b9439411d4aad7c21bdf3047.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 Introduce the properties in anticipation of QOM'ification; Q35 has the same properties. Note that we want to avoid a "ram size" property in the QOM interface since it seems redundant to both properties introduced in this change. Thus the removal of the ram_size parameter. We assume the invariant of both properties to sum up to "ram size" which is already asserted in pc_memory_init(). Under Xen the invariant seems to hold as well, so we now also check it there. Signed-off-by: Bernhard Beschow Message-Id: <20230630073720.21297-15-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci-host/i440fx.h | 1 - hw/i386/pc_piix.c | 5 ++++- hw/pci-host/i440fx.c | 12 ++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/hw/pci-host/i440fx.h b/include/hw/pci-host/i440fx.h index e3a550021e..7e38456ebb 100644 --- a/include/hw/pci-host/i440fx.h +++ b/include/hw/pci-host/i440fx.h @@ -36,7 +36,6 @@ PCIBus *i440fx_init(const char *pci_type, DeviceState *dev, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, - ram_addr_t ram_size, ram_addr_t below_4g_mem_size, ram_addr_t above_4g_mem_size, MemoryRegion *pci_memory, diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 26e8473a4d..c36783809f 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -224,6 +224,9 @@ static void pc_init1(MachineState *machine, if (!xen_enabled()) { pc_memory_init(pcms, system_memory, rom_memory, hole64_size); } else { + assert(machine->ram_size == x86ms->below_4g_mem_size + + x86ms->above_4g_mem_size); + pc_system_flash_cleanup_unused(pcms); if (machine->kernel_filename != NULL) { /* For xen HVM direct kernel boot, load linux here */ @@ -239,7 +242,7 @@ static void pc_init1(MachineState *machine, pci_bus = i440fx_init(pci_type, i440fx_host, - system_memory, system_io, machine->ram_size, + system_memory, system_io, x86ms->below_4g_mem_size, x86ms->above_4g_mem_size, pci_memory, ram_memory); diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c index de14c75e95..8731740a1b 100644 --- a/hw/pci-host/i440fx.c +++ b/hw/pci-host/i440fx.c @@ -52,6 +52,8 @@ struct I440FXState { MemoryRegion *pci_address_space; MemoryRegion *ram_memory; Range pci_hole; + uint64_t below_4g_mem_size; + uint64_t above_4g_mem_size; uint64_t pci_hole64_size; bool pci_hole64_fix; uint32_t short_root_bus; @@ -264,7 +266,6 @@ PCIBus *i440fx_init(const char *pci_type, DeviceState *dev, MemoryRegion *address_space_mem, MemoryRegion *address_space_io, - ram_addr_t ram_size, ram_addr_t below_4g_mem_size, ram_addr_t above_4g_mem_size, MemoryRegion *pci_address_space, @@ -281,6 +282,8 @@ PCIBus *i440fx_init(const char *pci_type, s->io_memory = address_space_io; s->pci_address_space = pci_address_space; s->ram_memory = ram_memory; + s->below_4g_mem_size = below_4g_mem_size; + s->above_4g_mem_size = above_4g_mem_size; b = pci_root_bus_new(dev, NULL, s->pci_address_space, s->io_memory, 0, TYPE_PCI_BUS); @@ -290,7 +293,7 @@ PCIBus *i440fx_init(const char *pci_type, d = pci_create_simple(b, 0, pci_type); f = I440FX_PCI_DEVICE(d); - range_set_bounds(&s->pci_hole, below_4g_mem_size, + range_set_bounds(&s->pci_hole, s->below_4g_mem_size, IO_APIC_DEFAULT_ADDRESS - 1); /* setup pci memory mapping */ @@ -321,6 +324,7 @@ PCIBus *i440fx_init(const char *pci_type, PAM_EXPAN_BASE + i * PAM_EXPAN_SIZE, PAM_EXPAN_SIZE); } + ram_addr_t ram_size = s->below_4g_mem_size + s->above_4g_mem_size; ram_size = ram_size / 8 / 1024 / 1024; if (ram_size > 255) { ram_size = 255; @@ -380,6 +384,10 @@ static Property i440fx_props[] = { DEFINE_PROP_SIZE(PCI_HOST_PROP_PCI_HOLE64_SIZE, I440FXState, pci_hole64_size, I440FX_PCI_HOST_HOLE64_SIZE_DEFAULT), DEFINE_PROP_UINT32("short_root_bus", I440FXState, short_root_bus, 0), + DEFINE_PROP_SIZE(PCI_HOST_BELOW_4G_MEM_SIZE, I440FXState, + below_4g_mem_size, 0), + DEFINE_PROP_SIZE(PCI_HOST_ABOVE_4G_MEM_SIZE, I440FXState, + above_4g_mem_size, 0), DEFINE_PROP_BOOL("x-pci-hole64-fix", I440FXState, pci_hole64_fix, true), DEFINE_PROP_END_OF_LIST(), }; From patchwork Mon Jul 10 23:03:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806074 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=fihJ0ULE; dkim-atps=neutral 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 4R0KQC1fFPz20ZZ for ; Tue, 11 Jul 2023 09:06:59 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzvL-0007Yb-JN; Mon, 10 Jul 2023 19:04:07 -0400 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 1qIzvG-0007SY-KI for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:03 -0400 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 1qIzvF-0004R9-13 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030240; 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=llOwBCxIvdLIU1f6GwL+jt15mYCqzEo8OOqYTIZkV4k=; b=fihJ0ULEvYFhPt+uy18chmmqpxCE5D3g/zbQs/bTmR+Jg1G7SJzZtz3ysPNwPiPD+fClRL 0c/9iSmq6xczp3cEdj8RPPfkvr5EIszqFnqrTbNQKyDFkxk5m5EhKZ2m/NGz8+8c+DKrpW /04qS/X0q0S2eqSOmT5g3QnzAAI4HDI= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-517-RHr0tKztOUKAUV2f7KFEDQ-1; Mon, 10 Jul 2023 19:03:58 -0400 X-MC-Unique: RHr0tKztOUKAUV2f7KFEDQ-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-313e6020882so2727178f8f.1 for ; Mon, 10 Jul 2023 16:03:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030236; x=1691622236; 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=llOwBCxIvdLIU1f6GwL+jt15mYCqzEo8OOqYTIZkV4k=; b=RHSOUch0gXCKHHdt+xRh2Qp6c/EpVKgVdtPzdCDErL3am48n7eggw/bCm3PNCxkI9+ 8Hd4ZSwhUNLYdpy7wxcDg5iW/c1YXr4zpk6VZnu5UTjtAy3XzKXnh+Xdl+SRpRvZThqk 6FY9ftuYiiSOGI8wQryL2VXPnsn4Dwy3BrRAYx7Jg1FanbJ+I/O2GYuA8PwO04vJGJq1 ELZfzHMdKcpOXgqXnKtKtSP71DZWI63pQt/1ZKHkpXSmgU35Mf+zTJ2wk2EPA/B+8m60 nSPfuRGcFxZEfVLsosUK5RgHJSXUFzcCP5VZk+vubIZ4+Q9HROXx9+IVswzUJ7+hoL7A z6rA== X-Gm-Message-State: ABy/qLZRwdZ2tqwrZCZ1TIIesG981hWuJhvMInx9yVsMH1bm6drqru3M sohxIM5co5+D7sp/Yi9h0RWa95fsuZVQDvkMhdMquXzhlzYLB1C1RiwjkKbmveRgbFIQeynkLOT V4Wpw4swy5ynD6WSlKV8/CxQz2c1KgSST43waTXEbSn18WFqokt90yqEgKZvNrNY4LyOp X-Received: by 2002:a5d:44cb:0:b0:311:b18:9ca4 with SMTP id z11-20020a5d44cb000000b003110b189ca4mr15167514wrr.17.1689030236537; Mon, 10 Jul 2023 16:03:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlHcIbFyf3ujImlDEA/oXkkjyMD0YxHOwR3xLLJ5toedmK+iSoOpXz1gbPqSURbPoa5+46b+4A== X-Received: by 2002:a5d:44cb:0:b0:311:b18:9ca4 with SMTP id z11-20020a5d44cb000000b003110b189ca4mr15167503wrr.17.1689030236321; Mon, 10 Jul 2023 16:03:56 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id o6-20020adfeac6000000b00314145e6d61sm614240wrn.6.2023.07.10.16.03.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:55 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Marcel Apfelbaum Subject: [PULL 31/66] hw/pci-host/i440fx: Add I440FX_HOST_PROP_PCI_TYPE property 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 I440FX needs a different PCI device model if the "igd-passthru" property is enabled. The type name is currently passed as a parameter to i440fx_init(). This parameter will be replaced by a property assignment once i440fx_init() gets resolved. Signed-off-by: Bernhard Beschow Message-Id: <20230630073720.21297-16-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci-host/i440fx.h | 2 ++ hw/pci-host/i440fx.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/hw/pci-host/i440fx.h b/include/hw/pci-host/i440fx.h index 7e38456ebb..2d7bae5a45 100644 --- a/include/hw/pci-host/i440fx.h +++ b/include/hw/pci-host/i440fx.h @@ -15,6 +15,8 @@ #include "hw/pci-host/pam.h" #include "qom/object.h" +#define I440FX_HOST_PROP_PCI_TYPE "pci-type" + #define TYPE_I440FX_PCI_HOST_BRIDGE "i440FX-pcihost" #define TYPE_I440FX_PCI_DEVICE "i440FX" diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c index 8731740a1b..c458987405 100644 --- a/hw/pci-host/i440fx.c +++ b/hw/pci-host/i440fx.c @@ -57,6 +57,8 @@ struct I440FXState { uint64_t pci_hole64_size; bool pci_hole64_fix; uint32_t short_root_bus; + + char *pci_type; }; #define I440FX_PAM 0x59 @@ -284,13 +286,14 @@ PCIBus *i440fx_init(const char *pci_type, s->ram_memory = ram_memory; s->below_4g_mem_size = below_4g_mem_size; s->above_4g_mem_size = above_4g_mem_size; + s->pci_type = (char *)pci_type; b = pci_root_bus_new(dev, NULL, s->pci_address_space, s->io_memory, 0, TYPE_PCI_BUS); phb->bus = b; sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - d = pci_create_simple(b, 0, pci_type); + d = pci_create_simple(b, 0, s->pci_type); f = I440FX_PCI_DEVICE(d); range_set_bounds(&s->pci_hole, s->below_4g_mem_size, @@ -389,6 +392,7 @@ static Property i440fx_props[] = { DEFINE_PROP_SIZE(PCI_HOST_ABOVE_4G_MEM_SIZE, I440FXState, above_4g_mem_size, 0), DEFINE_PROP_BOOL("x-pci-hole64-fix", I440FXState, pci_hole64_fix, true), + DEFINE_PROP_STRING(I440FX_HOST_PROP_PCI_TYPE, I440FXState, pci_type), DEFINE_PROP_END_OF_LIST(), }; From patchwork Mon Jul 10 23:03:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806080 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=OvKdYC2w; dkim-atps=neutral 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 4R0KRX6sVyz20ZZ for ; Tue, 11 Jul 2023 09:08:08 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzvR-0007gI-Nz; Mon, 10 Jul 2023 19:04:15 -0400 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 1qIzvK-0007ZD-Mc for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:07 -0400 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 1qIzvI-0004Rr-Hz for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030244; 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=zBihUDmGB6uFtH/AkcYIicM5fh04EulaKYLbdQ/QMSU=; b=OvKdYC2wsf9M78Ou00YBqkL8fDZkYr2G75lbWqnzsajUBTU+QSRpG/sxVnreTqBhqbkMT1 ledVWKW1Iywwd55nYvwFon7MGjwK6+2CDABKxw0/YPDCHJcAQoR+PT13JoXbPU8m4vLMWm 9hiLwq2WQTJNi5fzMHzSLU0XNWQex8c= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-528-d7LU3e7PNs6zqPjbiB52ug-1; Mon, 10 Jul 2023 19:04:01 -0400 X-MC-Unique: d7LU3e7PNs6zqPjbiB52ug-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fbb0fdd060so31133165e9.0 for ; Mon, 10 Jul 2023 16:04:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030239; x=1691622239; 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=zBihUDmGB6uFtH/AkcYIicM5fh04EulaKYLbdQ/QMSU=; b=kAzoZOlfV0njUTGO0iJCOBG00AgF1i/Iz5l8D/VfWKxMJB0IuYTzn/aVLbshDLjAMB vjDx8SWr2fzbsIQi3/hwbuCfDcPdTMjIP4n6C4muV3jtiI98DtMlsB+0//M0fitj/aAO fn6z8JmOuSa3zchLC9X8HkMTHK0kDIeOkBf0b1YTwi44nSw2/MwE1rEAcCzelayHhijT 9UunPqDV92QjAMn2rOIwpky/QBTl5WTmx3wqfpVqPhzGBHxGQT5jAZaI7faEZ8H/SaCg PzmX9pQKh9kbw96qY0Z7bDVarqG7RNbKm5XmLbvfRXpglO6U7j3/WjUNpnKbX9cYLICT TjTA== X-Gm-Message-State: ABy/qLa/nZY6k7HOBEDY63pfkZBaUlCwvFNLkyQiz19tHjUCFtbwXN5g vpdsNuZ/AfaP8TSSCNHVd97CZLNH35QPF3ZMGW75I/Ou7ITMXEG8o5T77OeI3XgRWOxTJytROs2 5JCLbZTcey2wNuj5tXSNOxSU0GSIdHjw1Xpan2f8RSsR7e7oUUbBMIYdjKTQHoPn+Y0Z4 X-Received: by 2002:a5d:410e:0:b0:315:902b:7913 with SMTP id l14-20020a5d410e000000b00315902b7913mr8570111wrp.31.1689030239489; Mon, 10 Jul 2023 16:03:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlElvc1J+xlRdlRyjYLiJgR2dAGxWK2KEPCb6Q8YoCskjj8F/t0YHQRC7R/MPt10UdfwRJBRew== X-Received: by 2002:a5d:410e:0:b0:315:902b:7913 with SMTP id l14-20020a5d410e000000b00315902b7913mr8570090wrp.31.1689030239206; Mon, 10 Jul 2023 16:03:59 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id f4-20020a5d4dc4000000b0031424f4ef1dsm601118wru.19.2023.07.10.16.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:58 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:56 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 32/66] hw/pci-host/i440fx: Resolve i440fx_init() 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 i440fx_init() is a legacy init function. The previous patches worked towards TYPE_I440FX_PCI_HOST_BRIDGE to be instantiated the QOM way. Do this now by transforming the parameters passed to i440fx_init() into property assignments. Signed-off-by: Bernhard Beschow Message-Id: <20230630073720.21297-17-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daudé --- include/hw/pci-host/i440fx.h | 10 ---------- hw/i386/pc_piix.c | 32 +++++++++++++++++++++----------- hw/pci-host/i440fx.c | 33 +++++---------------------------- 3 files changed, 26 insertions(+), 49 deletions(-) diff --git a/include/hw/pci-host/i440fx.h b/include/hw/pci-host/i440fx.h index 2d7bae5a45..c988f70890 100644 --- a/include/hw/pci-host/i440fx.h +++ b/include/hw/pci-host/i440fx.h @@ -34,14 +34,4 @@ struct PCII440FXState { #define TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE "igd-passthrough-i440FX" -PCIBus *i440fx_init(const char *pci_type, - DeviceState *dev, - MemoryRegion *address_space_mem, - MemoryRegion *address_space_io, - ram_addr_t below_4g_mem_size, - ram_addr_t above_4g_mem_size, - MemoryRegion *pci_memory, - MemoryRegion *ram_memory); - - #endif diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index c36783809f..62148d7636 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -126,7 +126,7 @@ static void pc_init1(MachineState *machine, MemoryRegion *rom_memory = system_memory; ram_addr_t lowmem; uint64_t hole64_size = 0; - DeviceState *i440fx_host = NULL; + Object *phb = NULL; /* * Calculate ram split, for memory below and above 4G. It's a bit @@ -201,10 +201,9 @@ static void pc_init1(MachineState *machine, pci_memory = g_new(MemoryRegion, 1); memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); rom_memory = pci_memory; - i440fx_host = qdev_new(host_type); - object_property_add_child(OBJECT(machine), "i440fx", - OBJECT(i440fx_host)); - hole64_size = object_property_get_uint(OBJECT(i440fx_host), + phb = OBJECT(qdev_new(host_type)); + object_property_add_child(OBJECT(machine), "i440fx", phb); + hole64_size = object_property_get_uint(phb, PCI_HOST_PROP_PCI_HOLE64_SIZE, &error_abort); } @@ -240,12 +239,23 @@ static void pc_init1(MachineState *machine, PIIX3State *piix3; PCIDevice *pci_dev; - pci_bus = i440fx_init(pci_type, - i440fx_host, - system_memory, system_io, - x86ms->below_4g_mem_size, - x86ms->above_4g_mem_size, - pci_memory, ram_memory); + object_property_set_link(phb, PCI_HOST_PROP_RAM_MEM, + OBJECT(ram_memory), &error_fatal); + object_property_set_link(phb, PCI_HOST_PROP_PCI_MEM, + OBJECT(pci_memory), &error_fatal); + object_property_set_link(phb, PCI_HOST_PROP_SYSTEM_MEM, + OBJECT(system_memory), &error_fatal); + object_property_set_link(phb, PCI_HOST_PROP_IO_MEM, + OBJECT(system_io), &error_fatal); + object_property_set_uint(phb, PCI_HOST_BELOW_4G_MEM_SIZE, + x86ms->below_4g_mem_size, &error_fatal); + object_property_set_uint(phb, PCI_HOST_ABOVE_4G_MEM_SIZE, + x86ms->above_4g_mem_size, &error_fatal); + object_property_set_str(phb, I440FX_HOST_PROP_PCI_TYPE, + pci_type, &error_fatal); + sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal); + + pci_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pci.0")); pci_bus_map_irqs(pci_bus, xen_enabled() ? xen_pci_slot_get_pirq : pc_pci_slot_get_pirq); diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c index c458987405..62d6287681 100644 --- a/hw/pci-host/i440fx.c +++ b/hw/pci-host/i440fx.c @@ -249,9 +249,14 @@ static void i440fx_pcihost_initfn(Object *obj) static void i440fx_pcihost_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); I440FXState *s = I440FX_PCI_HOST_BRIDGE(dev); PCIHostState *phb = PCI_HOST_BRIDGE(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); + PCIBus *b; + PCIDevice *d; + PCII440FXState *f; + unsigned i; memory_region_add_subregion(s->io_memory, 0xcf8, &phb->conf_mem); sysbus_init_ioports(sbd, 0xcf8, 4); @@ -262,36 +267,10 @@ static void i440fx_pcihost_realize(DeviceState *dev, Error **errp) /* register i440fx 0xcf8 port as coalesced pio */ memory_region_set_flush_coalesced(&phb->data_mem); memory_region_add_coalescing(&phb->conf_mem, 0, 4); -} - -PCIBus *i440fx_init(const char *pci_type, - DeviceState *dev, - MemoryRegion *address_space_mem, - MemoryRegion *address_space_io, - ram_addr_t below_4g_mem_size, - ram_addr_t above_4g_mem_size, - MemoryRegion *pci_address_space, - MemoryRegion *ram_memory) -{ - I440FXState *s = I440FX_PCI_HOST_BRIDGE(dev); - PCIHostState *phb = PCI_HOST_BRIDGE(dev); - PCIBus *b; - PCIDevice *d; - PCII440FXState *f; - unsigned i; - - s->system_memory = address_space_mem; - s->io_memory = address_space_io; - s->pci_address_space = pci_address_space; - s->ram_memory = ram_memory; - s->below_4g_mem_size = below_4g_mem_size; - s->above_4g_mem_size = above_4g_mem_size; - s->pci_type = (char *)pci_type; b = pci_root_bus_new(dev, NULL, s->pci_address_space, s->io_memory, 0, TYPE_PCI_BUS); phb->bus = b; - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); d = pci_create_simple(b, 0, s->pci_type); f = I440FX_PCI_DEVICE(d); @@ -335,8 +314,6 @@ PCIBus *i440fx_init(const char *pci_type, d->config[I440FX_COREBOOT_RAM_SIZE] = ram_size; i440fx_update_memory_mappings(f); - - return b; } static void i440fx_class_init(ObjectClass *klass, void *data) From patchwork Mon Jul 10 23:03:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=L84CLY1u; dkim-atps=neutral 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 4R0KMr2mJ5z20Ph for ; Tue, 11 Jul 2023 09:04:56 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzvV-0007wM-Nt; Mon, 10 Jul 2023 19:04:19 -0400 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 1qIzvM-0007bb-Be for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:09 -0400 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 1qIzvK-0004S5-JR for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030245; 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=YDsngXzPd9VZYax82YGMdxQV4ZtCon0fLLMZ+kNSXk4=; b=L84CLY1uHm9G7yLNJ0YcFUJPWUHjyOpD9V5oTsaSGSg4Uo1sdx923aNbY7lwdYdJ6AGeJ3 GI7NpL9aT+K5RBUKjyoEtshM5JuJ6TS8bRXZrkD+2/8XQy/Z4YKlaykcWDVRuhqugHalDp 946djv1Mr+toMQblIO+8BbMjScGvag4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-K6Ud5p4IO2ODyLtPZlJ8OA-1; Mon, 10 Jul 2023 19:04:04 -0400 X-MC-Unique: K6Ud5p4IO2ODyLtPZlJ8OA-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-31400956ce8so2831826f8f.3 for ; Mon, 10 Jul 2023 16:04:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030243; x=1691622243; 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=YDsngXzPd9VZYax82YGMdxQV4ZtCon0fLLMZ+kNSXk4=; b=FaPgS7e2JkmDr+29XWY/bjxHTZuSsBox8JwLa7iqTvf+hayq0eLzRDOWLx6lnHy6pP kGKs11zAocaRZgvtValM6duu2PGWxtsTWKR4IFYATX5hiHEW/5v05DR1m2YK0sZ9ywrn fa1DW4b4sqZahCn1HuhqFTLL/uy1yIAeisrX3GSMMtqbNY2atnSRBd70zL7D17BWpqNn WGYli8WHBvq+cqgZDTIUtUZ8pjgu3HA67HC3rL1kZCxiWwMPwihpNAah0uwp4rQ/ZKD/ p9zW9/kejShv/SqoWUuBY1BQNvU58Xz8nlA4wuvxcP5WPCGn5YXug/amFAzkoB7cL3ag kWVg== X-Gm-Message-State: ABy/qLYflx6bLDjWcYVad6p7Vl5YDbLIAAz886Okr2XAWPqpJpGX5ek5 litj+kcqjOltusAoS1mWGq+C9hS7vArs2zAyYJ3eg1o5ECSNfQhQ46i0GcjIrqDUHDbVm1nfOEI 47BfeKCXFfG4P3QSbmoojdmhY298jIr/LQvE7g0a0+FpdPNUXE2c/ZQECeERkSqVPrFBn X-Received: by 2002:a05:6000:90c:b0:313:f7f1:e34c with SMTP id cw12-20020a056000090c00b00313f7f1e34cmr12258393wrb.60.1689030242803; Mon, 10 Jul 2023 16:04:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlE81g+A0MkRNx36mzwke2+8jPDXlL+at2ea1JqO+zxMQ3KuwXAutVNZ+NolOGgxV+BJ+qUiZw== X-Received: by 2002:a05:6000:90c:b0:313:f7f1:e34c with SMTP id cw12-20020a056000090c00b00313f7f1e34cmr12258371wrb.60.1689030242536; Mon, 10 Jul 2023 16:04:02 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id z13-20020adfe54d000000b003143ac73fd0sm617119wrm.1.2023.07.10.16.04.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:02 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:59 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 33/66] hw/i386/pc_piix: Move i440fx' realize near its qdev_new() 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 I440FX realization is currently mixed with PIIX3 creation. Furthermore, it is common practice to only set properties between a device's qdev_new() and qdev_realize(). Clean up to resolve both issues. Since I440FX spawns a PCI bus let's also move the pci_bus initialization there. Note that when running `qemu-system-x86_64 -M pc -S` before and after this patch, `info mtree` in the QEMU console doesn't show any differences except that the ordering is different. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230630073720.21297-18-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/pc_piix.c | 51 ++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 62148d7636..b18443d3df 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -114,7 +114,7 @@ static void pc_init1(MachineState *machine, X86MachineState *x86ms = X86_MACHINE(machine); MemoryRegion *system_memory = get_system_memory(); MemoryRegion *system_io = get_system_io(); - PCIBus *pci_bus; + PCIBus *pci_bus = NULL; ISABus *isa_bus; int piix3_devfn = -1; qemu_irq smi_irq; @@ -126,7 +126,6 @@ static void pc_init1(MachineState *machine, MemoryRegion *rom_memory = system_memory; ram_addr_t lowmem; uint64_t hole64_size = 0; - Object *phb = NULL; /* * Calculate ram split, for memory below and above 4G. It's a bit @@ -198,11 +197,36 @@ static void pc_init1(MachineState *machine, } if (pcmc->pci_enabled) { + Object *phb; + pci_memory = g_new(MemoryRegion, 1); memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); rom_memory = pci_memory; + phb = OBJECT(qdev_new(host_type)); object_property_add_child(OBJECT(machine), "i440fx", phb); + object_property_set_link(phb, PCI_HOST_PROP_RAM_MEM, + OBJECT(ram_memory), &error_fatal); + object_property_set_link(phb, PCI_HOST_PROP_PCI_MEM, + OBJECT(pci_memory), &error_fatal); + object_property_set_link(phb, PCI_HOST_PROP_SYSTEM_MEM, + OBJECT(system_memory), &error_fatal); + object_property_set_link(phb, PCI_HOST_PROP_IO_MEM, + OBJECT(system_io), &error_fatal); + object_property_set_uint(phb, PCI_HOST_BELOW_4G_MEM_SIZE, + x86ms->below_4g_mem_size, &error_fatal); + object_property_set_uint(phb, PCI_HOST_ABOVE_4G_MEM_SIZE, + x86ms->above_4g_mem_size, &error_fatal); + object_property_set_str(phb, I440FX_HOST_PROP_PCI_TYPE, pci_type, + &error_fatal); + sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal); + + pci_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pci.0")); + pci_bus_map_irqs(pci_bus, + xen_enabled() ? xen_pci_slot_get_pirq + : pc_pci_slot_get_pirq); + pcms->bus = pci_bus; + hole64_size = object_property_get_uint(phb, PCI_HOST_PROP_PCI_HOLE64_SIZE, &error_abort); @@ -239,28 +263,6 @@ static void pc_init1(MachineState *machine, PIIX3State *piix3; PCIDevice *pci_dev; - object_property_set_link(phb, PCI_HOST_PROP_RAM_MEM, - OBJECT(ram_memory), &error_fatal); - object_property_set_link(phb, PCI_HOST_PROP_PCI_MEM, - OBJECT(pci_memory), &error_fatal); - object_property_set_link(phb, PCI_HOST_PROP_SYSTEM_MEM, - OBJECT(system_memory), &error_fatal); - object_property_set_link(phb, PCI_HOST_PROP_IO_MEM, - OBJECT(system_io), &error_fatal); - object_property_set_uint(phb, PCI_HOST_BELOW_4G_MEM_SIZE, - x86ms->below_4g_mem_size, &error_fatal); - object_property_set_uint(phb, PCI_HOST_ABOVE_4G_MEM_SIZE, - x86ms->above_4g_mem_size, &error_fatal); - object_property_set_str(phb, I440FX_HOST_PROP_PCI_TYPE, - pci_type, &error_fatal); - sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal); - - pci_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pci.0")); - pci_bus_map_irqs(pci_bus, - xen_enabled() ? xen_pci_slot_get_pirq - : pc_pci_slot_get_pirq); - pcms->bus = pci_bus; - pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, TYPE_PIIX3_DEVICE); @@ -285,7 +287,6 @@ static void pc_init1(MachineState *machine, rtc_state = ISA_DEVICE(object_resolve_path_component(OBJECT(pci_dev), "rtc")); } else { - pci_bus = NULL; isa_bus = isa_bus_new(NULL, system_memory, system_io, &error_abort); From patchwork Mon Jul 10 23:04:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806066 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=C8O0hpS3; dkim-atps=neutral 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 4R0KNJ14tZz20ZZ for ; Tue, 11 Jul 2023 09:05:20 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzvc-000886-1l; Mon, 10 Jul 2023 19:04:24 -0400 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 1qIzvQ-0007gV-Hh for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:13 -0400 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 1qIzvO-0004Sd-O8 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030250; 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=LemduFqhY2MXG8M8oqW3BXS0GMz2e3CJYcqD9/6gSoI=; b=C8O0hpS3xq5BIbqili8yusIQLKJKlXplIfLnfRD7vt/N6LGQHw7iIcbO1D9rh3a4a5yitQ 4i7eGm5x1ICKIBNKB/5DmpFMWWCsINjOwvmFZceUXKcX2wGWnEQzcmFaZap0AR7gllGexk thYmnCTFeKMsSoUEwCSQNcdp/8iFMFc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-471-RmrG_VaFPy-tGAlxH3ZxeA-1; Mon, 10 Jul 2023 19:04:08 -0400 X-MC-Unique: RmrG_VaFPy-tGAlxH3ZxeA-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-31400956ce8so2831853f8f.3 for ; Mon, 10 Jul 2023 16:04:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030246; x=1691622246; 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=LemduFqhY2MXG8M8oqW3BXS0GMz2e3CJYcqD9/6gSoI=; b=STz6MC/i50XbGvaJycy4t52GmdBpo1lEPSc3ZM6jsJ8gQVXnwrb+I4gGvqab/NtozW C4LYhD/8CFkMwd7R2PH+FnuGEcoGuD/zCAGJdnU1qI69GVqVs1foxwnF09hym80SAr/l lNUdpmnRGZ09fC+fJa+IBLrOgBPSr6ghltXAymqrTyxkLIJR22vx1l8mJsSeulTPkvIW 7v93FCPV1MxCaYrHRAIqwIAnikLJgZCqjHMFt4B1+8ThpHvWxSM0bHczvMKUF3WR5VpS 2YG9C2GSrDdwWcNezN4p/z7p4BOT6IQuv4RAdVC2iBdMJyfGckQpH3iXlgIEVL0zkP0f u+1A== X-Gm-Message-State: ABy/qLacg6iNoaY0R3kUlZEJn3IthtuWtM7rD5ot7fmZvM4IocNF+ptG ozIVamO1mLk9oU55UvZ7k7VrD57V9fb5QvP56iMY7Fn/8bEazUvZ+lcsDiQXMG40hHWHLOiTzfl vRhoC/4q1VMBl/0o1kcucmETho0nBO8NDuHaUdRsj5OMoF8M6vx8zf8lai8ieNf7yEbX8 X-Received: by 2002:a05:6000:1103:b0:315:83d4:7dd6 with SMTP id z3-20020a056000110300b0031583d47dd6mr9621462wrw.5.1689030246676; Mon, 10 Jul 2023 16:04:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlHYwZmkQO8D3LXX0CcdAd2ab6kzgYtYH+OdS57kxOcneZpMNK1nii2I8kzT0yqfr7yUkIG0Aw== X-Received: by 2002:a05:6000:1103:b0:315:83d4:7dd6 with SMTP id z3-20020a056000110300b0031583d47dd6mr9621439wrw.5.1689030246402; Mon, 10 Jul 2023 16:04:06 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id d2-20020adfe842000000b003143c06135bsm587526wrn.50.2023.07.10.16.04.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:05 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:02 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Paul Burton , Aleksandar Rikalo , Philippe =?utf-8?q?Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Huacai Chen , Jiaxun Yang , Aurelien Jarno , BALATON Zoltan , qemu-ppc@nongnu.org Subject: [PULL 34/66] hw/pci/pci: Remove multifunction parameter from pci_create_simple_multifunction() 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 There is also pci_create_simple() which creates non-multifunction PCI devices. Accordingly the parameter is always set to true when a multi function PCI device is to be created. The reason for the parameter's existence seems to be that it is used in the internal PCI code as well which is the only location where it gets set to false. This one usage can be replaced by trivial code. Remove this redundant, error-prone parameter. Signed-off-by: Bernhard Beschow Message-Id: <20230304114043.121024-5-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 1 - hw/i386/pc_piix.c | 3 +-- hw/i386/pc_q35.c | 4 ++-- hw/mips/boston.c | 3 +-- hw/mips/fuloong2e.c | 2 +- hw/mips/malta.c | 2 +- hw/pci/pci.c | 7 ++++--- hw/ppc/pegasos2.c | 2 +- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index e6d0574a29..18c35b64db 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -583,7 +583,6 @@ PCIDevice *pci_new(int devfn, const char *name); bool pci_realize_and_unref(PCIDevice *dev, PCIBus *bus, Error **errp); PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn, - bool multifunction, const char *name); PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name); diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index b18443d3df..ac72e8f5be 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -263,8 +263,7 @@ static void pc_init1(MachineState *machine, PIIX3State *piix3; PCIDevice *pci_dev; - pci_dev = pci_create_simple_multifunction(pci_bus, -1, true, - TYPE_PIIX3_DEVICE); + pci_dev = pci_create_simple_multifunction(pci_bus, -1, TYPE_PIIX3_DEVICE); if (xen_enabled()) { pci_device_set_intx_routing_notifier( diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 02dd274276..fdab1f6a56 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -304,7 +304,7 @@ static void pc_q35_init(MachineState *machine) ahci = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_SATA1_DEV, ICH9_SATA1_FUNC), - true, "ich9-ahci"); + "ich9-ahci"); idebus[0] = qdev_get_child_bus(&ahci->qdev, "ide.0"); idebus[1] = qdev_get_child_bus(&ahci->qdev, "ide.1"); g_assert(MAX_SATA_PORTS == ahci_get_num_ports(ahci)); @@ -326,7 +326,7 @@ static void pc_q35_init(MachineState *machine) smb = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_SMB_DEV, ICH9_SMB_FUNC), - true, TYPE_ICH9_SMB_DEVICE); + TYPE_ICH9_SMB_DEVICE); pcms->smbus = I2C_BUS(qdev_get_child_bus(DEVICE(smb), "i2c")); smbus_eeprom_init(pcms->smbus, 8, NULL, 0); diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 21ad844519..4e11ff6cd6 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -770,8 +770,7 @@ static void boston_mach_init(MachineState *machine) boston_lcd_event, NULL, s, NULL, true); ahci = pci_create_simple_multifunction(&PCI_BRIDGE(&pcie2->root)->sec_bus, - PCI_DEVFN(0, 0), - true, TYPE_ICH9_AHCI); + PCI_DEVFN(0, 0), TYPE_ICH9_AHCI); g_assert(ARRAY_SIZE(hd) == ahci_get_num_ports(ahci)); ide_drive_get(hd, ahci_get_num_ports(ahci)); ahci_ide_create_devs(ahci, hd); diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c index cfc8ca6ae4..c827f615f3 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -297,7 +297,7 @@ static void mips_fuloong2e_init(MachineState *machine) /* South bridge -> IP5 */ pci_dev = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(FULOONG2E_VIA_SLOT, 0), - true, TYPE_VT82C686B_ISA); + TYPE_VT82C686B_ISA); object_property_add_alias(OBJECT(machine), "rtc-time", object_resolve_path_component(OBJECT(pci_dev), "rtc"), diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 47cb49f691..f9618fa5f5 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -1251,7 +1251,7 @@ void mips_malta_init(MachineState *machine) pci_bus_map_irqs(pci_bus, malta_pci_slot_get_pirq); /* Southbridge */ - piix4 = pci_create_simple_multifunction(pci_bus, PIIX4_PCI_DEVFN, true, + piix4 = pci_create_simple_multifunction(pci_bus, PIIX4_PCI_DEVFN, TYPE_PIIX4_PCI_DEVICE); isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(piix4), "isa.0")); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e2eb4c3b4a..5152989c10 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2186,17 +2186,18 @@ bool pci_realize_and_unref(PCIDevice *dev, PCIBus *bus, Error **errp) } PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn, - bool multifunction, const char *name) { - PCIDevice *dev = pci_new_multifunction(devfn, multifunction, name); + PCIDevice *dev = pci_new_multifunction(devfn, true, name); pci_realize_and_unref(dev, bus, &error_fatal); return dev; } PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name) { - return pci_create_simple_multifunction(bus, devfn, false, name); + PCIDevice *dev = pci_new(devfn, name); + pci_realize_and_unref(dev, bus, &error_fatal); + return dev; } static uint8_t pci_find_space(PCIDevice *pdev, uint8_t size) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 9c9944188b..4447bbe8ec 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -180,7 +180,7 @@ static void pegasos2_init(MachineState *machine) /* VIA VT8231 South Bridge (multifunction PCI device) */ via = OBJECT(pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0), - true, TYPE_VT8231_ISA)); + TYPE_VT8231_ISA)); for (i = 0; i < PCI_NUM_PINS; i++) { pm->via_pirq[i] = qdev_get_gpio_in_named(DEVICE(via), "pirq", i); } From patchwork Mon Jul 10 23:04:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806077 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=WraeWiyg; dkim-atps=neutral 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 4R0KRG2G6Lz20ZZ for ; Tue, 11 Jul 2023 09:07:54 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzvc-00089l-8P; Mon, 10 Jul 2023 19:04:24 -0400 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 1qIzvS-0007ss-Q6 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:15 -0400 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 1qIzvR-0004TN-38 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030252; 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=wwQkhUqHzYSpel71j/LGGzZNtrjeD2cCb2B//2mq/TI=; b=WraeWiygY61Qmq+m9QtBWhutJ65pSeTKpIbYXlnvsuhQDBEvfPFligwDBRAdMrU2qk49pY CyLmb/ykrA03bejV1q44C8aI7IzpHH+ffotLAy3y0qUx6L27T7TCUi4J8vFX4Slj7Gt8zT hF1rg0T1U7xHoAxcmeBVJAs4u5HK+jc= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-444-5sTFlm12NAGM5PXzsXEPTA-1; Mon, 10 Jul 2023 19:04:11 -0400 X-MC-Unique: 5sTFlm12NAGM5PXzsXEPTA-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-315935c808bso908793f8f.1 for ; Mon, 10 Jul 2023 16:04:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030249; x=1691622249; 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=wwQkhUqHzYSpel71j/LGGzZNtrjeD2cCb2B//2mq/TI=; b=j/9HMh+UunQqShOoYBf6Qilqxdj4QDuKKcNT/iuMXG85G5TxqjDlBIQD17qYuvoCCM 12mEQ9FGboJvM9VMeNkpm6nBLkFt04JydTwsZucXekNPm4ggse2/gMlufl9vs64AccPM aiTU0yQIsKwvzllmcpArwxsrPVbYfT3KizbZZlAQLAtCJEK8TJ9y28hStroOba45mvz6 U4EdRx0qBLTtD/us13hRLvnoqBHvdJuPHlmINRvcarw/g8NxOdRDgJOifj8pvZT0ysZ7 J/biJdR6cXzAE8rixTQq2HwgcFRVm88brJc0x0bZFaWqn75KfKhemEksBXeF8TcaSiw5 mRhw== X-Gm-Message-State: ABy/qLYrUl7yOHAqLJ+G4BBgQ2eAB1e5RgsVpRu59oONeqttvWjNRpGe 9mUozQGKKtkZFRiu5ZxWfoXbpGHGamd8918zc1D2M4lfeOHOVzdCzCu+lfPr+9paoRWUJePk+YL LKbq+HhFHec7ufq67B59Iot8mP9s3lWNxwu7e38XXxEbcJlvAWZFLbmj0+91W2tvESO/m X-Received: by 2002:a05:6000:8b:b0:30e:56b3:60fe with SMTP id m11-20020a056000008b00b0030e56b360femr12726724wrx.4.1689030249704; Mon, 10 Jul 2023 16:04:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlFiNC7qCnAlYOsBpNl23wH8J9eape0FBhDM0sdixtMJjVLzW1f4iv3sUvKkUgt1KiSNfVJZmg== X-Received: by 2002:a05:6000:8b:b0:30e:56b3:60fe with SMTP id m11-20020a056000008b00b0030e56b360femr12726706wrx.4.1689030249415; Mon, 10 Jul 2023 16:04:09 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id g15-20020a5d554f000000b0031411e46af3sm566764wrw.97.2023.07.10.16.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:09 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:06 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum , Mark Cave-Ayland , Artyom Tarasenko Subject: [PULL 35/66] hw/pci/pci: Remove multifunction parameter from pci_new_multifunction() 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 There is also pci_new() which creates non-multifunction PCI devices. Accordingly the parameter is always set to true when a multi function PCI device is to be created. The reason for the parameter's existence seems to be that it is used in the internal PCI code as well which is the only location where it gets set to false. This one usage can be resolved by factoring out an internal helper function. Remove this redundant, error-prone parameter. Signed-off-by: Bernhard Beschow Message-Id: <20230304114043.121024-6-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 3 +-- hw/i386/pc_q35.c | 6 +++--- hw/pci-host/sabre.c | 6 ++---- hw/pci/pci.c | 13 +++++++++---- hw/sparc64/sun4u.c | 5 ++--- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 18c35b64db..ab2bd65a3a 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -577,8 +577,7 @@ pci_set_quad_by_mask(uint8_t *config, uint64_t mask, uint64_t reg) pci_set_quad(config, (~mask & val) | (mask & rval)); } -PCIDevice *pci_new_multifunction(int devfn, bool multifunction, - const char *name); +PCIDevice *pci_new_multifunction(int devfn, const char *name); PCIDevice *pci_new(int devfn, const char *name); bool pci_realize_and_unref(PCIDevice *dev, PCIBus *bus, Error **errp); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index fdab1f6a56..dc27a9e223 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -100,12 +100,12 @@ static int ehci_create_ich9_with_companions(PCIBus *bus, int slot) return -1; } - ehci = pci_new_multifunction(PCI_DEVFN(slot, 7), true, name); + ehci = pci_new_multifunction(PCI_DEVFN(slot, 7), name); pci_realize_and_unref(ehci, bus, &error_fatal); usbbus = QLIST_FIRST(&ehci->qdev.child_bus); for (i = 0; i < 3; i++) { - uhci = pci_new_multifunction(PCI_DEVFN(slot, comp[i].func), true, + uhci = pci_new_multifunction(PCI_DEVFN(slot, comp[i].func), comp[i].name); qdev_prop_set_string(&uhci->qdev, "masterbus", usbbus->name); qdev_prop_set_uint32(&uhci->qdev, "firstport", comp[i].port); @@ -239,7 +239,7 @@ static void pc_q35_init(MachineState *machine) pcms->bus = host_bus; /* create ISA bus */ - lpc = pci_new_multifunction(PCI_DEVFN(ICH9_LPC_DEV, ICH9_LPC_FUNC), true, + lpc = pci_new_multifunction(PCI_DEVFN(ICH9_LPC_DEV, ICH9_LPC_FUNC), TYPE_ICH9_LPC_DEVICE); qdev_prop_set_bit(DEVICE(lpc), "smm-enabled", x86_machine_is_smm_enabled(x86ms)); diff --git a/hw/pci-host/sabre.c b/hw/pci-host/sabre.c index 949ecc21f2..dcb2e230b6 100644 --- a/hw/pci-host/sabre.c +++ b/hw/pci-host/sabre.c @@ -387,14 +387,12 @@ static void sabre_realize(DeviceState *dev, Error **errp) pci_setup_iommu(phb->bus, sabre_pci_dma_iommu, s->iommu); /* APB secondary busses */ - pci_dev = pci_new_multifunction(PCI_DEVFN(1, 0), true, - TYPE_SIMBA_PCI_BRIDGE); + pci_dev = pci_new_multifunction(PCI_DEVFN(1, 0), TYPE_SIMBA_PCI_BRIDGE); s->bridgeB = PCI_BRIDGE(pci_dev); pci_bridge_map_irq(s->bridgeB, "pciB", pci_simbaB_map_irq); pci_realize_and_unref(pci_dev, phb->bus, &error_fatal); - pci_dev = pci_new_multifunction(PCI_DEVFN(1, 1), true, - TYPE_SIMBA_PCI_BRIDGE); + pci_dev = pci_new_multifunction(PCI_DEVFN(1, 1), TYPE_SIMBA_PCI_BRIDGE); s->bridgeA = PCI_BRIDGE(pci_dev); pci_bridge_map_irq(s->bridgeA, "pciA", pci_simbaA_map_irq); pci_realize_and_unref(pci_dev, phb->bus, &error_fatal); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 5152989c10..fb17138f7d 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2164,8 +2164,8 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp) pci_dev->msi_trigger = pci_msi_trigger; } -PCIDevice *pci_new_multifunction(int devfn, bool multifunction, - const char *name) +static PCIDevice *pci_new_internal(int devfn, bool multifunction, + const char *name) { DeviceState *dev; @@ -2175,9 +2175,14 @@ PCIDevice *pci_new_multifunction(int devfn, bool multifunction, return PCI_DEVICE(dev); } +PCIDevice *pci_new_multifunction(int devfn, const char *name) +{ + return pci_new_internal(devfn, true, name); +} + PCIDevice *pci_new(int devfn, const char *name) { - return pci_new_multifunction(devfn, false, name); + return pci_new_internal(devfn, false, name); } bool pci_realize_and_unref(PCIDevice *dev, PCIBus *bus, Error **errp) @@ -2188,7 +2193,7 @@ bool pci_realize_and_unref(PCIDevice *dev, PCIBus *bus, Error **errp) PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn, const char *name) { - PCIDevice *dev = pci_new_multifunction(devfn, true, name); + PCIDevice *dev = pci_new_multifunction(devfn, name); pci_realize_and_unref(dev, bus, &error_fatal); return dev; } diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index 29e9b6cc26..d908a38f73 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -612,7 +612,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, pci_bus_set_slot_reserved_mask(pci_busA, 0xfffffff1); pci_bus_set_slot_reserved_mask(pci_busB, 0xfffffff0); - ebus = pci_new_multifunction(PCI_DEVFN(1, 0), true, TYPE_EBUS); + ebus = pci_new_multifunction(PCI_DEVFN(1, 0), TYPE_EBUS); qdev_prop_set_uint64(DEVICE(ebus), "console-serial-base", hwdef->console_serial_base); pci_realize_and_unref(ebus, pci_busA, &error_fatal); @@ -648,8 +648,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, if (!nd->model || strcmp(nd->model, mc->default_nic) == 0) { if (!onboard_nic) { - pci_dev = pci_new_multifunction(PCI_DEVFN(1, 1), - true, mc->default_nic); + pci_dev = pci_new_multifunction(PCI_DEVFN(1, 1), mc->default_nic); bus = pci_busA; memcpy(&macaddr, &nd->macaddr.a, sizeof(MACAddr)); onboard_nic = true; From patchwork Mon Jul 10 23:04:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806090 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=Tf0d8m6s; dkim-atps=neutral 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 4R0KS40sbCz20ZZ for ; Tue, 11 Jul 2023 09:08:36 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzvd-0008H0-2d; Mon, 10 Jul 2023 19:04:25 -0400 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 1qIzvV-0007wO-3P for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:17 -0400 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 1qIzvT-0004Tf-Js for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030254; 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=DsnG6X5s9gl0JGqrN3ljzYWE2z5sJ0pUx0PXwD0gJHI=; b=Tf0d8m6s6kXv6gWx7xzFv7SAgwpiYKhVdUyr/G3+nrPMwjemoW/N2a7kXmkcbOWINuTn1A DfoK3GDvrOeY4BSu8EyDprclvw1NkPB6Tu5Hky21vtUXaJldKmOB1AfJaGHET/YJHEq/0S i5vhkzvtx5xm5Sieftcw0fBtFVjwtxo= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-417-0lRwuUoWMv2eRDRWZyNIpw-1; Mon, 10 Jul 2023 19:04:13 -0400 X-MC-Unique: 0lRwuUoWMv2eRDRWZyNIpw-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-314291caa91so2830055f8f.2 for ; Mon, 10 Jul 2023 16:04:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030252; x=1691622252; 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=DsnG6X5s9gl0JGqrN3ljzYWE2z5sJ0pUx0PXwD0gJHI=; b=DQs9B6TCtIMq37E/OGZaATguMyjqWaWN0mUkwwWYrE+2dXC4lUzJV3BsxmVSXzzzkg 5w2WBiQGt0XVN8rm6gGL4Jfu9PbjtDNBCfA9o0PEhsX5G1Ay0Lbw/uxaS2YcRWr11vi9 i40yw8sbD9oAf9WsGLQ3Ttq8gZ0PbC+adRKr2PjhjHjvVR2QZGmPG8Hpw5daXkn5+EQj JDiQ+s8MI0jvRuUB5yrz7A7HYjOY3OIWh7QE9gO7tx5WHjl8UttOwlWnBV1OJu2w1MrR 3CKDIGoN/OYzEXy+lxu+kuoi18ERtg7ArLYv39WiinyLMaKoMaYTJH3Pe9MnE1pNdEY6 3Eqw== X-Gm-Message-State: ABy/qLaL+EswmGkTMEWhOqSz+HJrLnbVDLjYTCOlkN6Rs0rv2kkILRRp flWR6+JhhDQebt7z/hSt5+fZt3T5YRsPjFJpGJa2ivsOfDvQlH9q0lyXCelPruz5zUrpktKeEH2 N1LRT3/fpJVpykVQyzRRxjqYRdv+XiMuoJXIiPJv26ku5X98ujD4LcINpALJXx8m7KLnb X-Received: by 2002:a05:6000:1b86:b0:314:34dd:aaec with SMTP id r6-20020a0560001b8600b0031434ddaaecmr13486286wru.8.1689030252275; Mon, 10 Jul 2023 16:04:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlGYMv9RdHe2vGbh2EP7bm8yf+2GKK3I6ZmwMeoiVOYWEUri7/dHpLViUI8VDKgLllGIu089cw== X-Received: by 2002:a05:6000:1b86:b0:314:34dd:aaec with SMTP id r6-20020a0560001b8600b0031434ddaaecmr13486265wru.8.1689030251961; Mon, 10 Jul 2023 16:04:11 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id x6-20020a5d6506000000b003143b14848dsm562689wru.102.2023.07.10.16.04.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:11 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:09 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , =?utf-8?q?C=C3=A9dric?= Le Goater , Marcel Apfelbaum Subject: [PULL 36/66] pcie: Release references of virtual functions Message-ID: <08f632848008544b7e1ab8a8aa50df02c39a26a1.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Akihiko Odaki pci_new() automatically retains a reference to a virtual function when registering it so we need to release the reference when unregistering. Fixes: 7c0fa8dff8 ("pcie: Add support for Single Root I/O Virtualization (SR/IOV)") Signed-off-by: Akihiko Odaki Message-Id: <20230411090408.48366-1-akihiko.odaki@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Cédric Le Goater --- hw/pci/pcie_sriov.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index aa5a757b11..76a3b6917e 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -211,6 +211,7 @@ static void unregister_vfs(PCIDevice *dev) error_free(local_err); } object_unparent(OBJECT(vf)); + object_unref(OBJECT(vf)); } g_free(dev->exp.sriov_pf.vf); dev->exp.sriov_pf.vf = NULL; From patchwork Mon Jul 10 23:04:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806087 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=TrzF7LhV; dkim-atps=neutral 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 4R0KRt6938z20ZZ for ; Tue, 11 Jul 2023 09:08:26 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzvd-0008NZ-Qf; Mon, 10 Jul 2023 19:04:25 -0400 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 1qIzvX-00080b-Ox for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:22 -0400 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 1qIzvW-0004U3-BT for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030257; 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=O9A8NXPUZ1UAaZ4xg8XGvm2vrnKputB+kT4Xm8amg28=; b=TrzF7LhVmjtXnNJZiCrVWRz2d9byVwiX+XwZ87OVSqFQP4mCKdL+KDvQnH7X8oLxr2bNBp v+jBFwmenPwXKINz6VOJgm7yCn0jKlclvvdKyazmnHqVaxafiE25pPavh4Inkxeb2dCy9+ FWbNUgcPfj9qIIMLN7wwxLC1lULklyM= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-556-nJRoKJvVO9yOSBYDPQ5oyg-1; Mon, 10 Jul 2023 19:04:16 -0400 X-MC-Unique: nJRoKJvVO9yOSBYDPQ5oyg-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fc0855dcc5so15721055e9.2 for ; Mon, 10 Jul 2023 16:04:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030255; x=1691622255; 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=O9A8NXPUZ1UAaZ4xg8XGvm2vrnKputB+kT4Xm8amg28=; b=U7f3+MbDYnKcC9y/+TKdb2fgifS/9nPITIDANwvMWvMF7SavGOt2yUHDS4yr6ane+/ u4lejdla5PZRbINWyH4tIYrwayzcoAFiKe9ZHZc6GaG30f3dQiAdY5fcgKXOuzK7aNer sWNuFDMd50HQr06BJo8BlQOxmK5WydmcHbCrMlJaPNmYgpRm2iV++YjyD6WeDJUIZ2O6 Bo2FyAtqQuv9xcJB5N0qWXYLuHRxLVtISSqA4Nbnpr+vCEvm9hcUOKLwKChMjh8XBSNA YJOvOvfcqpouKIo/psRGtJjuYyxoEMcrmqjnyvzWt7SMF2lMsOx3aLF7CapLNLV6xra0 c1ng== X-Gm-Message-State: ABy/qLa1nZf3Y1zAHuG3tHKRMJDTCdK3EuxtkukxBO5TNrZc6QvmayE5 RHBNGb5WuIR9+1QoQCKmgupnASGJBTjjNu/6NvhWcL80fcjTRF25+7Kz0KLj8kNKARyGanMpqOw p1OlJ36OM08NL7D6wpVUG9RFuqho7ljuwOcc9T2P6KC3E9uP35sH0kK2HbNWO5KIGluM7 X-Received: by 2002:a05:600c:21cb:b0:3fb:b8a6:33f9 with SMTP id x11-20020a05600c21cb00b003fbb8a633f9mr12950878wmj.0.1689030255143; Mon, 10 Jul 2023 16:04:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlFo/aWJF/1VvEjOsT/dEI91F2r40j5IpMrKg+g/g9PyUU67tkD0G7OXABBETbz2CpIxWUvxPg== X-Received: by 2002:a05:600c:21cb:b0:3fb:b8a6:33f9 with SMTP id x11-20020a05600c21cb00b003fbb8a633f9mr12950849wmj.0.1689030254754; Mon, 10 Jul 2023 16:04:14 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id w18-20020a5d6812000000b0031416362e23sm610529wru.3.2023.07.10.16.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:14 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:12 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Jason Wang , Eugenio =?utf-8?b?UMOpcmV6?= , Lei Yang Subject: [PULL 37/66] vdpa: Return -EIO if device ack is VIRTIO_NET_ERR in _load_mac() 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Hawkins Jiawei According to VirtIO standard, "The class, command and command-specific-data are set by the driver, and the device sets the ack byte. There is little it can do except issue a diagnostic if ack is not VIRTIO_NET_OK." Therefore, QEMU should stop sending the queued SVQ commands and cancel the device startup if the device's ack is not VIRTIO_NET_OK. Yet the problem is that, vhost_vdpa_net_load_mac() returns 1 based on `*s->status != VIRTIO_NET_OK` when the device's ack is VIRTIO_NET_ERR. As a result, net->nc->info->load() also returns 1, this makes vhost_net_start_one() incorrectly assume the device state is successfully loaded by vhost_vdpa_net_load() and return 0, instead of goto `fail` label to cancel the device startup, as vhost_net_start_one() only cancels the device startup when net->nc->info->load() returns a negative value. This patch fixes this problem by returning -EIO when the device's ack is not VIRTIO_NET_OK. Fixes: f73c0c43ac ("vdpa: extract vhost_vdpa_net_load_mac from vhost_vdpa_net_load") Signed-off-by: Hawkins Jiawei Acked-by: Jason Wang Acked-by: Eugenio Pérez Message-Id: Tested-by: Lei Yang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index c0e93ce568..345a301d62 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -652,8 +652,9 @@ static int vhost_vdpa_net_load_mac(VhostVDPAState *s, const VirtIONet *n) if (unlikely(dev_written < 0)) { return dev_written; } - - return *s->status != VIRTIO_NET_OK; + if (*s->status != VIRTIO_NET_OK) { + return -EIO; + } } return 0; From patchwork Mon Jul 10 23:04:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806085 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=Ku5xUJ+m; dkim-atps=neutral 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 4R0KRs5HRyz20bx for ; Tue, 11 Jul 2023 09:08:25 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzve-0008P2-0Z; Mon, 10 Jul 2023 19:04:26 -0400 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 1qIzva-000843-SE for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:23 -0400 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 1qIzvZ-0004UN-9n for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030260; 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=fHmhGhTSD6X74P22Q0DAjxHl108XBojNde1QZNnDoCw=; b=Ku5xUJ+m7c/QB0ttv0JccmGd0tpA0j3JPkbiUcBvRtOd2rSUZxbK+sui0fjrz1Z6EQ3Fbg ye/W12VDXJ44742VN5Zg8XnFhl2RguMlBeNTOM0gNSD4MtpdQRBn2hbBpWrZq3W7rRzL6r IlF4wwt4oQPOVTrI46KiwIDQBL7V20Y= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-601-9sC7DBvZMw6xkIvuwR1MgQ-1; Mon, 10 Jul 2023 19:04:19 -0400 X-MC-Unique: 9sC7DBvZMw6xkIvuwR1MgQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fa8db49267so31649285e9.3 for ; Mon, 10 Jul 2023 16:04:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030257; x=1691622257; 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=fHmhGhTSD6X74P22Q0DAjxHl108XBojNde1QZNnDoCw=; b=ds47wJF2TvIFHznB9tL5mE3TuPvpWPQg/5h9vYShRB3fdzOH8iw6MnSvr0GI8Ga8Rz KTs1/r6f6BA/vGTYCgi5AFcKgLZH7+2sAHF4Q2OtoEWKZRmAq1nOr6JhpuLPISkq+tR9 o+MEBk69EKEycuNR79hYFQJSv8x0HZAC0Q9teFqjidwO4XsUSxHvzX++mma+82/vr6UF U+l6qcE36E3B2sQJmyTEs8010ELvM9nuOueXrU/384QamQbyaIFf3C1/gEoiKZwselgH t+sy+F9jhxmO7DQmW0FxB00Y/siZus9VYz43D4cI3yu2stKZvt2f3E4D9gtIHCXh9uXZ JUdg== X-Gm-Message-State: ABy/qLZtnelU3mEcYSEHS4UHkJoBDNR1tacM7327O/RgyKEM5BNozsnt UWs/qOgVSoVzGx+gYXuaC9MeF7npxDlFh26DAJJprhXeJuCkbi3UeV+9VI7wH2rsrKOYKlw7NHt sDi+Iuae+x4Ghxll18il68E3sMPPaq8ZwPS2rUBeQ4ATqNlJgPBOedJ2NOcpjKEvWKj4l X-Received: by 2002:a1c:6a0c:0:b0:3f7:e3dd:8a47 with SMTP id f12-20020a1c6a0c000000b003f7e3dd8a47mr12333313wmc.11.1689030257798; Mon, 10 Jul 2023 16:04:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlHZGRlZ9eTrTscuHnI0NJMB37SWi28REPbq4btp7AF9RH5NQg2TcmWntxhbIzp3bZZ7KUGm5A== X-Received: by 2002:a1c:6a0c:0:b0:3f7:e3dd:8a47 with SMTP id f12-20020a1c6a0c000000b003f7e3dd8a47mr12333294wmc.11.1689030257528; Mon, 10 Jul 2023 16:04:17 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id m4-20020a05600c280400b003fc07e17d4esm7623082wmb.2.2023.07.10.16.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:17 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:15 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Jason Wang , Eugenio =?utf-8?b?UMOpcmV6?= , Lei Yang Subject: [PULL 38/66] vdpa: Return -EIO if device ack is VIRTIO_NET_ERR in _load_mq() 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Hawkins Jiawei According to VirtIO standard, "The class, command and command-specific-data are set by the driver, and the device sets the ack byte. There is little it can do except issue a diagnostic if ack is not VIRTIO_NET_OK." Therefore, QEMU should stop sending the queued SVQ commands and cancel the device startup if the device's ack is not VIRTIO_NET_OK. Yet the problem is that, vhost_vdpa_net_load_mq() returns 1 based on `*s->status != VIRTIO_NET_OK` when the device's ack is VIRTIO_NET_ERR. As a result, net->nc->info->load() also returns 1, this makes vhost_net_start_one() incorrectly assume the device state is successfully loaded by vhost_vdpa_net_load() and return 0, instead of goto `fail` label to cancel the device startup, as vhost_net_start_one() only cancels the device startup when net->nc->info->load() returns a negative value. This patch fixes this problem by returning -EIO when the device's ack is not VIRTIO_NET_OK. Fixes: f64c7cda69 ("vdpa: Add vhost_vdpa_net_load_mq") Signed-off-by: Hawkins Jiawei Acked-by: Jason Wang Acked-by: Eugenio Pérez Message-Id: Tested-by: Lei Yang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 345a301d62..8477ed2579 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -677,8 +677,11 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s, if (unlikely(dev_written < 0)) { return dev_written; } + if (*s->status != VIRTIO_NET_OK) { + return -EIO; + } - return *s->status != VIRTIO_NET_OK; + return 0; } static int vhost_vdpa_net_load_offloads(VhostVDPAState *s, From patchwork Mon Jul 10 23:04:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806098 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=AAV+xptV; dkim-atps=neutral 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 4R0KSl5xLkz20ZZ for ; Tue, 11 Jul 2023 09:09:11 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzvg-0000Uh-Us; Mon, 10 Jul 2023 19:04:28 -0400 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 1qIzvd-0008LW-GV for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:25 -0400 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 1qIzvb-0004Ud-Re for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030263; 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=amZrO0aYgcy6UzcFRq/TV5jwcN2L/fT0tqTPTXjBW+0=; b=AAV+xptVfsaF9DrgdbnhBBN4HTq4gM0cA/63OI/eFLv2foZQFZHNhfSs2clyBYnvvFRG8R Teb9XrT1jrV1bo5yYKwDRxwYzJa5s1se/C5/Zx6sAUdLLi5uIrt9C62gZ+YYSupkySbARi t5Phr1F9y6JzGy+O+NhsBAz+61aA3oc= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-450-6A4W91V0OziBGZtuthQe-A-1; Mon, 10 Jul 2023 19:04:22 -0400 X-MC-Unique: 6A4W91V0OziBGZtuthQe-A-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-30793c16c78so3534871f8f.3 for ; Mon, 10 Jul 2023 16:04:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030260; x=1691622260; 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=amZrO0aYgcy6UzcFRq/TV5jwcN2L/fT0tqTPTXjBW+0=; b=lWqr0rteKWe4GrO9sZ7rL13dwNBsQAsNBf/nyyPyJPC9lFgSEFY1wr9VXirUm6SkIC GgNVe+JfpjlmzzVS9fhHsDUyUhgSj5GpD2i0++4UHnD8sXaJ3VfaYmSHC1ICpGkpSgof m0vAetUiMq1P73nbRaNaRJRpE48k5D6Q2OiXfo1inbzMtvgJRBpERQjQl0E4WPWgRpgC b1hNqUF8R7fMkRD4yY6jRbIFMjfkT71vaj81LbtylPVgC8v9W1fHMaF8qQeCnuiJI/GR JerfLxWGIEkS2DzczV10wyBv8uWewkXIaL8osptS1yGcAn/gs+y93KSQtXtO0zGu5/sl Lgfg== X-Gm-Message-State: ABy/qLYzbEj3pwNHaivBY3A/DMqu6xVhv6OxomcLEB7ggSIWZYrxv07S rG3gfBUi73ISVsiiVLBsqraGkSGbOD2IVRlJljgf6clbkIPXwKB+0oKA8dQsIvi4qjKfFULrw6W Eh6h1TuZly65NcFND5SgPYegyPCYtc3Zsm/YEtOHUFSiq8AkqrZe/buHrevxPDzNPXr8r X-Received: by 2002:a1c:7404:0:b0:3fb:424b:ef6e with SMTP id p4-20020a1c7404000000b003fb424bef6emr15884721wmc.23.1689030260695; Mon, 10 Jul 2023 16:04:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlF04OsIwVl2dIzNSwADap5A3fr8nFshIz260IRu3+lgBklurChPRnaWnx/CBKGdUdUawokPlQ== X-Received: by 2002:a1c:7404:0:b0:3fb:424b:ef6e with SMTP id p4-20020a1c7404000000b003fb424bef6emr15884707wmc.23.1689030260422; Mon, 10 Jul 2023 16:04:20 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id j8-20020adfe508000000b0031424950a99sm574625wrm.81.2023.07.10.16.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:19 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:17 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Jason Wang , Eugenio =?utf-8?b?UMOpcmV6?= , Lei Yang Subject: [PULL 39/66] vdpa: Return -EIO if device ack is VIRTIO_NET_ERR in _load_offloads() Message-ID: <6f34807116ffef7c449a656dbe2091d4f4da89c8.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Hawkins Jiawei According to VirtIO standard, "The class, command and command-specific-data are set by the driver, and the device sets the ack byte. There is little it can do except issue a diagnostic if ack is not VIRTIO_NET_OK." Therefore, QEMU should stop sending the queued SVQ commands and cancel the device startup if the device's ack is not VIRTIO_NET_OK. Yet the problem is that, vhost_vdpa_net_load_offloads() returns 1 based on `*s->status != VIRTIO_NET_OK` when the device's ack is VIRTIO_NET_ERR. As a result, net->nc->info->load() also returns 1, this makes vhost_net_start_one() incorrectly assume the device state is successfully loaded by vhost_vdpa_net_load() and return 0, instead of goto `fail` label to cancel the device startup, as vhost_net_start_one() only cancels the device startup when net->nc->info->load() returns a negative value. This patch fixes this problem by returning -EIO when the device's ack is not VIRTIO_NET_OK. Fixes: 0b58d3686a ("vdpa: Add vhost_vdpa_net_load_offloads()") Signed-off-by: Hawkins Jiawei Acked-by: Jason Wang Acked-by: Eugenio Pérez Message-Id: Tested-by: Lei Yang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 8477ed2579..679ef4bed0 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -718,8 +718,11 @@ static int vhost_vdpa_net_load_offloads(VhostVDPAState *s, if (unlikely(dev_written < 0)) { return dev_written; } + if (*s->status != VIRTIO_NET_OK) { + return -EIO; + } - return *s->status != VIRTIO_NET_OK; + return 0; } static int vhost_vdpa_net_load(NetClientState *nc) From patchwork Mon Jul 10 23:04:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806063 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=IIRQMQ55; dkim-atps=neutral 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 4R0KMv1K4nz20Ph for ; Tue, 11 Jul 2023 09:04:58 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzvi-0000Zu-LU; Mon, 10 Jul 2023 19:04:30 -0400 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 1qIzvg-0000WS-VH for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:28 -0400 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 1qIzvf-0004WC-A6 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030266; 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=WlMuDt1UzJVVupSGICrVYy9F98jUJydJxkhHG86yxjs=; b=IIRQMQ55HYUcwq+ji/w36Hq+FxxJDPbU0xJV4oBuE6oV5sLg/DfsxLRO8FW7PIoG1HyhJ/ 07PyHU2OehmNl7eWTRGTUIay1o2ZMMAREHaZ9gXNP8jmQAm3gOdy5sHkBg5q/545hqujx7 8c5mZjnsKLLMrDgK4ulDgGEGNuh5ky0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-639-ca-WBvGfOcy0v4u1r9Xwog-1; Mon, 10 Jul 2023 19:04:25 -0400 X-MC-Unique: ca-WBvGfOcy0v4u1r9Xwog-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fbdd5d09b8so34284225e9.1 for ; Mon, 10 Jul 2023 16:04:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030263; x=1691622263; 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=WlMuDt1UzJVVupSGICrVYy9F98jUJydJxkhHG86yxjs=; b=MRtru5qiUYECAQp+kAFGzA/dzOHoPAiHrapt5pJCTtgJOIIWB5XK7n558zDb34a6Rl S6gqol1UKcayIY6wfct9gMLKcXgzs1LGyf3O+ADcdMO2j0H+W6mUn8IouT4n/BqApZQP dQDVeXPYYTpN24DPTjvq1LRMicbUpIa9tVNo6i35SThFo3FtWyleBk2wlAElQ3FD0m/a QtsnnMnd5Ul9btrc86+se1OSkfhgl4jQx83lHm9zJ7Qfq0udiPkVL1+SAZDRr7i1cl7x I/+Qx8u3OyZZTRF67WibWfeybmuziHq+Lel3S/K1Z56S4ku9A/8GAUmHd0XFcYm6YiLS fiUQ== X-Gm-Message-State: ABy/qLbVsocrNH+YP6Pcw7In2E6gHM8sGdlzzMoka0DnSX4luJPVfT28 T3PpwLOQdoP3JEIUswz53vA0qOvaBcgyXB51pyO/SvO6l0DBnA7cyDtqKQRaKbXKNvBOSDnFskg 8tq4bwCyssyNg0A0htnY6+xEj6+A6xKLXnlekbsZAu3O798wmBdNohDEbyqKTg36FGrzL X-Received: by 2002:a7b:c019:0:b0:3fb:b2c0:fcec with SMTP id c25-20020a7bc019000000b003fbb2c0fcecmr13116297wmb.24.1689030263358; Mon, 10 Jul 2023 16:04:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlHOzKrdn1qXH7uBvRC8Ir3P4H9t9VZqzEpChA9PQiOQgWllevscHn7x3tAmf/PGJUWhr+YZ9g== X-Received: by 2002:a7b:c019:0:b0:3fb:b2c0:fcec with SMTP id c25-20020a7bc019000000b003fbb2c0fcecmr13116283wmb.24.1689030263095; Mon, 10 Jul 2023 16:04:23 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id f18-20020a7bcd12000000b003fa999cefc0sm919011wmj.36.2023.07.10.16.04.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:22 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:20 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Laurent Vivier , David Hildenbrand , Jason Wang Subject: [PULL 40/66] vhost-vdpa: mute unaligned memory error report Message-ID: <77812aa7b1fdf8f547c35a7f9a4eb1cbf3a073db.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Laurent Vivier With TPM CRM device, vhost-vdpa reports an error when it tries to register a listener for a non aligned memory region: qemu-system-x86_64: vhost_vdpa_listener_region_add received unaligned region qemu-system-x86_64: vhost_vdpa_listener_region_del received unaligned region This error can be confusing for the user whereas we only need to skip the region (as it's already done after the error_report()) Rather than introducing a special case for TPM CRB memory section to not display the message in this case, simply replace the error_report() by a trace function (with more information, like the memory region name). Signed-off-by: Laurent Vivier Message-Id: <20230704071931.575888-2-lvivier@redhat.com> Reviewed-by: David Hildenbrand Acked-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vdpa.c | 8 ++++++-- hw/virtio/trace-events | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 6246e5b9bf..42f2a4bae9 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -323,7 +323,9 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener, if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK) != (section->offset_within_region & ~TARGET_PAGE_MASK))) { - error_report("%s received unaligned region", __func__); + trace_vhost_vdpa_listener_region_add_unaligned(v, section->mr->name, + section->offset_within_address_space & ~TARGET_PAGE_MASK, + section->offset_within_region & ~TARGET_PAGE_MASK); return; } @@ -405,7 +407,9 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener, if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK) != (section->offset_within_region & ~TARGET_PAGE_MASK))) { - error_report("%s received unaligned region", __func__); + trace_vhost_vdpa_listener_region_del_unaligned(v, section->mr->name, + section->offset_within_address_space & ~TARGET_PAGE_MASK, + section->offset_within_region & ~TARGET_PAGE_MASK); return; } diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 6265231683..4e39ed8a95 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -34,7 +34,9 @@ vhost_vdpa_dma_map(void *vdpa, int fd, uint32_t msg_type, uint32_t asid, uint64_ vhost_vdpa_dma_unmap(void *vdpa, int fd, uint32_t msg_type, uint32_t asid, uint64_t iova, uint64_t size, uint8_t type) "vdpa:%p fd: %d msg_type: %"PRIu32" asid: %"PRIu32" iova: 0x%"PRIx64" size: 0x%"PRIx64" type: %"PRIu8 vhost_vdpa_listener_begin_batch(void *v, int fd, uint32_t msg_type, uint8_t type) "vdpa:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8 vhost_vdpa_listener_commit(void *v, int fd, uint32_t msg_type, uint8_t type) "vdpa:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8 +vhost_vdpa_listener_region_add_unaligned(void *v, const char *name, uint64_t offset_as, uint64_t offset_page) "vdpa: %p region %s offset_within_address_space %"PRIu64" offset_within_region %"PRIu64 vhost_vdpa_listener_region_add(void *vdpa, uint64_t iova, uint64_t llend, void *vaddr, bool readonly) "vdpa: %p iova 0x%"PRIx64" llend 0x%"PRIx64" vaddr: %p read-only: %d" +vhost_vdpa_listener_region_del_unaligned(void *v, const char *name, uint64_t offset_as, uint64_t offset_page) "vdpa: %p region %s offset_within_address_space %"PRIu64" offset_within_region %"PRIu64 vhost_vdpa_listener_region_del(void *vdpa, uint64_t iova, uint64_t llend) "vdpa: %p iova 0x%"PRIx64" llend 0x%"PRIx64 vhost_vdpa_add_status(void *dev, uint8_t status) "dev: %p status: 0x%"PRIx8 vhost_vdpa_init(void *dev, void *vdpa) "dev: %p vdpa: %p" From patchwork Mon Jul 10 23:04:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806067 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=bvuaOsAV; dkim-atps=neutral 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 4R0KNb3Fmdz20bx for ; Tue, 11 Jul 2023 09:05:35 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzvk-0000pa-Ny; Mon, 10 Jul 2023 19:04:32 -0400 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 1qIzvi-0000en-Ta for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:30 -0400 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 1qIzvh-0004X0-I2 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030269; 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=zofxrfRWOPA7vCxeFJ2sQZ2pbcHa86xzs6DzLNXbfH8=; b=bvuaOsAVIP3c1JKmUxkFVs2cgssalzccFB0Gz9hZhE2JHDL1AFcZ/Gllpd0r9Q2NBq0q2A nXAHjWWKmF1mgAy+iGi6BXa9UfJh1sbxRWOogdWIR9KZ039g0ahU/T45RJ5z//aH/lfeQY uA0s4hwpr/JywK9RgfAdaYGaM6YmgHo= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-205-18V-fx-2OmO0M413xUYitg-1; Mon, 10 Jul 2023 19:04:27 -0400 X-MC-Unique: 18V-fx-2OmO0M413xUYitg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fbdf34184eso31733275e9.1 for ; Mon, 10 Jul 2023 16:04:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030266; x=1691622266; 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=zofxrfRWOPA7vCxeFJ2sQZ2pbcHa86xzs6DzLNXbfH8=; b=GVdc/DyvXrtADRmwyRmzO4ic/rCrbN65SbnxG6Fd0m+2naEZK5uE5fSCZszrYrbztO +qtA8FB6HhS30FRmGKu23jesrQ/e9AxYz/CNoQtpylKx/MryC1S+IS4+1ZHBRcuByr01 dgSPeE+Wl1hZrfribQsCj60rY2rwnz/YtSOKiMqYlnS8RhopEXJUSbEzD1s2yoCNJ3Fh 26qE9Vg72m4K/YrSOzXrpzWwauE4nX8cltRMXj5I0vvQOr/pbknnL0dBmIOkVKw6cFNi 96QOpRI1G6OLN2fjidISdgirbcgz1oyYCD77EEsG1SkWY4PmpOmKVLFth7bdsQuzZssT Q/TQ== X-Gm-Message-State: ABy/qLbfAEe3M5iEZRzjI0YIAfbmkNBLNwgWfG3xEqECWiQF8P2AUzuu 3KJEnKbs4zzhTIdkbh+6toWPcjtO+FI0JJfnNXyE5O7mtmi/hwi4vqt27qph+OW34J0hFsQbRw1 znc/3gxVzQ18vOyFUDtUimpeVsolSrWPWjTIiJxj210IgY5AO/n9jwo+vZyhJmOlAYfuZ X-Received: by 2002:a05:600c:220b:b0:3fc:85c:5ef7 with SMTP id z11-20020a05600c220b00b003fc085c5ef7mr7126499wml.22.1689030266153; Mon, 10 Jul 2023 16:04:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlFCTwWDRW7TJtOfeNwXrm9xRKXdXTgUJ7N763zQj4YcdpVR+Odwc1br5W+8Z+VQWTF0p5fi6w== X-Received: by 2002:a05:600c:220b:b0:3fc:85c:5ef7 with SMTP id z11-20020a05600c220b00b003fc085c5ef7mr7126476wml.22.1689030265808; Mon, 10 Jul 2023 16:04:25 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id z14-20020a05600c220e00b003fbacc853ccsm939643wml.18.2023.07.10.16.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:25 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:23 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ani Sinha , Igor Mammedov Subject: [PULL 41/66] tests/acpi: allow changes in DSDT.noacpihp table blob Message-ID: <8d60105a5973320ffd72a48f208cfd2b041d6c0b.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Ani Sinha We are going to fix bio-tables-test in the next patch and hence need to make sure the acpi tests continue to pass. Signed-off-by: Ani Sinha Acked-by: Igor Mammedov Message-Id: <20230705115925.5339-2-anisinha@redhat.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..31df9c6187 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.noacpihp", From patchwork Mon Jul 10 23:04:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=R8+FxZXV; dkim-atps=neutral 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 4R0KRj1bF7z20ZZ for ; Tue, 11 Jul 2023 09:08:17 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzvn-0001H9-IH; Mon, 10 Jul 2023 19:04:35 -0400 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 1qIzvl-00012i-VC for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:33 -0400 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 1qIzvk-0004XZ-ET for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030271; 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=CIQfU3WFFO/+csV0ypsEiMeMOH7tqtHxkacd12WBjno=; b=R8+FxZXVyKEdz7h0Qv9IjTdPsOMAnShV2nDuBgyGjDZR4Lk2EPkxSYmGuX/bc+N93l5Ws7 AV9EKjCOCdVzo5X7Cw7PI4WQA4VipqsIlmO3UEzoCQnW6Mhvp6Fsi02TP9+JTo09tPjTLa YViNt+jGoUDQVdm75yJ2ep+YZGyKwLc= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-208-321VpTNYMuKrgvXW2aB9aQ-1; Mon, 10 Jul 2023 19:04:30 -0400 X-MC-Unique: 321VpTNYMuKrgvXW2aB9aQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fa979d0c32so31021325e9.2 for ; Mon, 10 Jul 2023 16:04:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030269; x=1691622269; 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=CIQfU3WFFO/+csV0ypsEiMeMOH7tqtHxkacd12WBjno=; b=d+oWABRsAMDW3WPlyn63nLzaNyZkojHp6N+PiSGwwVhP1aeIFUvrM6UTPaOSA/aNIR uB4c+IBVjoRdkm2f/DmMxEqueOCViJ88t/phuKwcpbX8XiBkLKBN9U5CzrCJku91sszt QKIKzEHF0knIq+qR8oy8TlzfVKGGNILnYlrxRhfxGO1RxW7Ze2d5zHZzhJqqxhFP/9B/ 8Ln7cbLJemWY/E4JRjNwPkZ+ambzitUKSLXXREJGLddLSqW4Wuj3cQ8AwfbkVjGZSGTF w9txzep/ZVacFl6XvONUQrt3LiE9U4JrMsYAjI9lJUPB6l2OxOh1WvVJfDsYodZdDfKT Iz+w== X-Gm-Message-State: ABy/qLZvuLIlzYRVi/oGELYFCo7kxWU0JtxIhzfqX4tQw2zbakNX7OY7 Cfc+4I1EL/NgHxIQoWo++1XwZFee9JzAEDooxd7WVbqHD6RsN+Tp65zcYRzZEdoCNyU6lrtnUzt tg2Jx4FyuyqDEMVQbr8M5LemKFSpbLRcqZDXv7xW3MFmCF7IzccSkgF/g7i+vTkyRXBvf X-Received: by 2002:a1c:6a09:0:b0:3fc:586:ccb4 with SMTP id f9-20020a1c6a09000000b003fc0586ccb4mr7471185wmc.36.1689030269152; Mon, 10 Jul 2023 16:04:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlEtd8psith3Q/JFLB7Gmf04jVUIDcMl+Na99LBUqCvrAwxSeCsbtqLakfrUvvSkhcoPQa2csg== X-Received: by 2002:a1c:6a09:0:b0:3fc:586:ccb4 with SMTP id f9-20020a1c6a09000000b003fc0586ccb4mr7471171wmc.36.1689030268862; Mon, 10 Jul 2023 16:04:28 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id r13-20020a05600c458d00b003fa9a00d74csm20008487wmo.3.2023.07.10.16.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:28 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:26 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ani Sinha , Igor Mammedov Subject: [PULL 42/66] tests/acpi/bios-tables-test: use the correct slot on the pcie-root-port Message-ID: <7b0ba7b1c8b362a83bfb30170dae6035a71192c2.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Ani Sinha PCIE ports only have one slot, slot 0. Hence, non-zero slots are not available for PCIE devices on PCIE root ports. Fix test_acpi_q35_tcg_no_acpi_hotplug() so that the test does not use them. Signed-off-by: Ani Sinha Reviewed-by: Igor Mammedov Message-Id: <20230705115925.5339-3-anisinha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index ed1c69cf01..47ba20b957 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -1020,9 +1020,9 @@ static void test_acpi_q35_tcg_no_acpi_hotplug(void) " -device pci-testdev,bus=nohprp,acpi-index=501" " -device pcie-root-port,id=nohprpint,port=0x0,chassis=3,hotplug=off," "multifunction=on,addr=8.0" - " -device pci-testdev,bus=nohprpint,acpi-index=601,addr=8.1" + " -device pci-testdev,bus=nohprpint,acpi-index=601,addr=0.1" " -device pcie-root-port,id=hprp2,port=0x0,chassis=4,bus=nohprpint," - "addr=9.0" + "addr=0.2" " -device pci-testdev,bus=hprp2,acpi-index=602" , &data); free_test_data(&data); From patchwork Mon Jul 10 23:04:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806096 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=At4Fuimg; dkim-atps=neutral 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 4R0KSX2YbVz20cZ for ; Tue, 11 Jul 2023 09:09:00 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwK-000238-3l; Mon, 10 Jul 2023 19:05:08 -0400 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 1qIzvq-0001Xy-6v for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:49 -0400 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 1qIzvo-0004Y3-FE for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030275; 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=aBRCyVMXtwE/vLnlZhU8V6LGVN3Foijz8hViuua/bjw=; b=At4FuimgIBDpR2F5Y4lIoYbreyK3WQ4sIxQLtPpelKpJZAoLgfIV+KBF+kipqd2OgG8Ikd kee5qIujys+viZFcY5zmAhJgYA2/izIZY5omRHLDtSaZNw50oSQ6hC/T8BrKtVVxNhWka7 sElrYK9s1SOzeFtz8RhMDgStuakoVcs= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-480-P1QvxD6sOD-nPmO4dB9sCw-1; Mon, 10 Jul 2023 19:04:34 -0400 X-MC-Unique: P1QvxD6sOD-nPmO4dB9sCw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fc0094c1bdso24645065e9.2 for ; Mon, 10 Jul 2023 16:04:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030272; x=1691622272; 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=aBRCyVMXtwE/vLnlZhU8V6LGVN3Foijz8hViuua/bjw=; b=cru/dtHrNk9+BQSsgYB2bUFAhCdKthPVbFNBjh8MnO9k3oxVTrabZabARPHFms/xZr DDArTOQXQ9iwkj70iGeo+tfGfHYKFu0NdKqJ2Vsa/4fxdvIMxE0iVS+F6YnEvNi0hUxd Y3qZLKgkrxehW6TctmNGRp5mr9sY4T+D2a7bQP1ZYtyRfdZmO91ysGrPKHJycB5yaWdv Tsxs8qxBycjPu1LIOWs3bWh+iA7PVf1zpZnWyi2KlO51CUUTW+/6PBMfLF8su7v814xc gotnanBkrvuTXii8s8B2TQlbSzqp6fRSO5FkqbJx4n+1hzhI+PtIDXxgE3Pou5X/Cf5s W11g== X-Gm-Message-State: ABy/qLaO4OeAlNBi6ArwKZHgUV+UHVJerPdQwi1xlzBxbSQU9ceGwtrc n6SDI6VN2O1fJSm6KQOO/Bc3e63O0VcDKljdMSLLMz5S3H+zGcN6+bm5ka776LqoZ7gfrHiOy0S /92VkpBcanIhfAw3DP79qiWeq6H8Pj+dXTvZJ58dji0HyPTS6YjGaAeKdsqCYgnsVfVnT X-Received: by 2002:a1c:6a1a:0:b0:3f8:c70e:7ed1 with SMTP id f26-20020a1c6a1a000000b003f8c70e7ed1mr13627816wmc.20.1689030271861; Mon, 10 Jul 2023 16:04:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlG+QSZUKvpxpkcuTBo1GJ58lfKbe0gtmq3ok6gidV1TRZ4gGct0Y9wZHYEZeA/bGJy17xr/MQ== X-Received: by 2002:a1c:6a1a:0:b0:3f8:c70e:7ed1 with SMTP id f26-20020a1c6a1a000000b003f8c70e7ed1mr13627795wmc.20.1689030271559; Mon, 10 Jul 2023 16:04:31 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id f11-20020a7bc8cb000000b003fa98908014sm11534848wml.8.2023.07.10.16.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:31 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ani Sinha , Igor Mammedov Subject: [PULL 43/66] tests/acpi/bios-tables-test: update acpi blob q35/DSDT.noacpihp 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Ani Sinha Some fixes were committed in bios-tables-test in the previous commit. Update the acpi blob and clear bios-tables-test-allowed-diff.h so that the test continues to pass with the changes in the bios-tables-test. Following is the asl diff between the old and the newly updated blob: @@ -1,30 +1,30 @@ /* * Intel ACPI Component Architecture * AML/ASL+ Disassembler version 20210604 (64-bit version) * Copyright (c) 2000 - 2021 Intel Corporation * * Disassembling to symbolic ASL+ operators * - * Disassembly of tests/data/acpi/q35/DSDT.noacpihp, Wed Jun 21 18:26:52 2023 + * Disassembly of /tmp/aml-O8SU61, Wed Jun 21 18:26:52 2023 * * Original Table Header: * Signature "DSDT" - * Length 0x00002038 (8248) + * Length 0x00002031 (8241) * Revision 0x01 **** 32-bit table (V1), no 64-bit math support - * Checksum 0x4A + * Checksum 0x89 * OEM ID "BOCHS " * OEM Table ID "BXPC " * OEM Revision 0x00000001 (1) * Compiler ID "BXPC" * Compiler Version 0x00000001 (1) */ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPC ", 0x00000001) { Scope (\) { OperationRegion (DBG, SystemIO, 0x0402, One) Field (DBG, ByteAcc, NoLock, Preserve) { DBGB, 8 } @@ -3148,48 +3148,48 @@ { Name (_ADR, Zero) // _ADR: Address Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { Local0 = Package (0x01) { 0x01F5 } Return (EDSM (Arg0, Arg1, Arg2, Arg3, Local0)) } } } Device (S40) { Name (_ADR, 0x00080000) // _ADR: Address - Device (S41) + Device (S01) { - Name (_ADR, 0x00080001) // _ADR: Address + Name (_ADR, One) // _ADR: Address Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { Local0 = Package (0x01) { 0x0259 } Return (EDSM (Arg0, Arg1, Arg2, Arg3, Local0)) } } - Device (S48) + Device (S02) { - Name (_ADR, 0x00090000) // _ADR: Address + Name (_ADR, 0x02) // _ADR: Address Device (S00) { Name (_ADR, Zero) // _ADR: Address } } } Device (SF8) { Name (_ADR, 0x001F0000) // _ADR: Address OperationRegion (PIRQ, PCI_Config, 0x60, 0x0C) Scope (\_SB) { Field (PCI0.SF8.PIRQ, ByteAcc, NoLock, Preserve) { PRQA, 8, Signed-off-by: Ani Sinha Acked-by: Igor Mammedov Message-Id: <20230705115925.5339-4-anisinha@redhat.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.noacpihp | Bin 8248 -> 8241 bytes 2 files changed, 1 deletion(-) diff --git a/tests/data/acpi/q35/DSDT.noacpihp b/tests/data/acpi/q35/DSDT.noacpihp index 6ab1f0e52543fcb7f84a7fd1327fe5aa42010565..8cab2f8eb9ae94e0165f3f17857ec7d080fb0e13 100644 GIT binary patch delta 109 zcmdntu+f3bCDi)r&-xoSoL DyqFtK delta 94 zcmdn!u)~4NCD X-Patchwork-Id: 1806091 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=O2POnCp8; dkim-atps=neutral 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 4R0KS95pnbz20ZZ for ; Tue, 11 Jul 2023 09:08:41 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwL-0002M3-Mt; Mon, 10 Jul 2023 19:05:09 -0400 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 1qIzwI-0001y5-DS for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:06 -0400 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 1qIzvq-0004YI-85 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030277; 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=NyBILryif2hXI0ZSClC5i65ujuUNrZfJQjKYOUdCsOo=; b=O2POnCp8AN1OYk3aYyEO2XqXhCHi9vQPNs6wr06J+vMnAOkasDjKMf/Iqy/hGdCtADphUc nfZ55drVaPH3HJOxrcUf5PaoYBWlAnnEyonYr1tCgoTvALlHk9C4sPwfNLGU6l6ieGsGNy IKpE6bk+Oj22brVY6dC8LgG9BULmS24= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-425-XvFvdDbZMXSwH_6mQPOXgw-1; Mon, 10 Jul 2023 19:04:36 -0400 X-MC-Unique: XvFvdDbZMXSwH_6mQPOXgw-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-315935c808bso908869f8f.1 for ; Mon, 10 Jul 2023 16:04:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030275; x=1691622275; 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=NyBILryif2hXI0ZSClC5i65ujuUNrZfJQjKYOUdCsOo=; b=LBjFkEpCohn7AkY381YEV6J6iQNK63+6n3TViFZ2jgI2kq7nkq9kfnArfIIzgrC2il 7PDpJHbUYqVhCPXAteBM6ozbrMrHUSoWwombxzv3RSiHVUKCDN3tWdFq7VVUX/JJhGqV I1XOGJzSK2fUd4c+AQv0rQU6eZdrDL0p/s1eEWRbaUlgvKNI6XuvQ0YediHjF/zaZEEM tUUKyKrYTE95+KX11WnGV6nJZJbkAG7MSMu/veYbH3Ws3XdF2yNo04u68NFY6GUpYq8a uuFk0GK71j/deQ8bNZUlMdnRkPZh1N8mG1/wT1kd7hYYciI2Cg2mZ75AUZnTffEi3mDa FFcw== X-Gm-Message-State: ABy/qLbFJyzcJGRG3YnEXLN+rgTCIsCYkv5095aejFZdr+UpfHZbwDKE 1Qes6jTg/RWeVqSGZeVtaoeU11YrEuWa4Ye/qh291Ls541+34lx4QYMSl+PT61wceNK4/vTRjXC bRLDS0oPYu08z7Q/jWxXiAqoK/Tau8wIorlEL+lPdpIvt9b5hFpGEB6z6Dvwj5kXw4oft X-Received: by 2002:adf:f286:0:b0:313:e20c:b90b with SMTP id k6-20020adff286000000b00313e20cb90bmr12949840wro.26.1689030274910; Mon, 10 Jul 2023 16:04:34 -0700 (PDT) X-Google-Smtp-Source: APBJJlEYEFC+NQtx6RB8R6RLT0G5GcVubi64HOJJsuQPCx7Nz43nh7gjDcrIwq++nfytdFVA3ClxBA== X-Received: by 2002:adf:f286:0:b0:313:e20c:b90b with SMTP id k6-20020adff286000000b00313e20cb90bmr12949821wro.26.1689030274581; Mon, 10 Jul 2023 16:04:34 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id p7-20020a5d6387000000b003143801f8d8sm569259wru.103.2023.07.10.16.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:34 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:31 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ani Sinha , mst@redhat.com, imammedo@redhat.com, Michael Labiuk , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL 44/66] tests/qtest/hd-geo-test: fix incorrect pcie-root-port usage and simplify test Message-ID: <579edbd459a53beb7929ee1169dc9675cc329865.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Ani Sinha The test attaches a SCSI controller to a non-zero slot and a pcie-to-pci bridge on slot 0 on the same pcie-root-port. Since a downstream device can be attached to a pcie-root-port only on slot 0, the above test configuration is not allowed. Additionally using pcie.0 as id for pcie-to-pci bridge is incorrect as that id is reserved only for the root bus. In the test scenario, there is no need to attach a pcie-root-port to the root complex. A SCSI controller can be attached to a pcie-to-pci bridge which can then be directly attached to the root bus (pcie.0). Fix the test and simplify it. CC: mst@redhat.com CC: imammedo@redhat.com CC: Michael Labiuk Acked-by: Thomas Huth Reviewed-by: Igor Mammedov Signed-off-by: Ani Sinha Message-Id: <20230705115925.5339-5-anisinha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/hd-geo-test.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/qtest/hd-geo-test.c b/tests/qtest/hd-geo-test.c index 5aa258a2b3..d08bffad91 100644 --- a/tests/qtest/hd-geo-test.c +++ b/tests/qtest/hd-geo-test.c @@ -784,14 +784,12 @@ static void test_override_scsi(void) test_override(args, "pc", expected); } -static void setup_pci_bridge(TestArgs *args, const char *id, const char *rootid) +static void setup_pci_bridge(TestArgs *args, const char *id) { - char *root, *br; - root = g_strdup_printf("-device pcie-root-port,id=%s", rootid); - br = g_strdup_printf("-device pcie-pci-bridge,bus=%s,id=%s", rootid, id); + char *br; + br = g_strdup_printf("-device pcie-pci-bridge,bus=pcie.0,id=%s", id); - args->argc = append_arg(args->argc, args->argv, ARGV_SIZE, root); args->argc = append_arg(args->argc, args->argv, ARGV_SIZE, br); } @@ -811,8 +809,8 @@ static void test_override_scsi_q35(void) add_drive_with_mbr(args, empty_mbr, 1); add_drive_with_mbr(args, empty_mbr, 1); add_drive_with_mbr(args, empty_mbr, 1); - setup_pci_bridge(args, "pcie.0", "br"); - add_scsi_controller(args, "lsi53c895a", "br", 3); + setup_pci_bridge(args, "pcie-pci-br"); + add_scsi_controller(args, "lsi53c895a", "pcie-pci-br", 3); add_scsi_disk(args, 0, 0, 0, 0, 0, 10000, 120, 30); add_scsi_disk(args, 1, 0, 0, 1, 0, 9000, 120, 30); add_scsi_disk(args, 2, 0, 0, 2, 0, 1, 0, 0); @@ -868,9 +866,9 @@ static void test_override_virtio_blk_q35(void) }; add_drive_with_mbr(args, empty_mbr, 1); add_drive_with_mbr(args, empty_mbr, 1); - setup_pci_bridge(args, "pcie.0", "br"); - add_virtio_disk(args, 0, "br", 3, 10000, 120, 30); - add_virtio_disk(args, 1, "br", 4, 9000, 120, 30); + setup_pci_bridge(args, "pcie-pci-br"); + add_virtio_disk(args, 0, "pcie-pci-br", 3, 10000, 120, 30); + add_virtio_disk(args, 1, "pcie-pci-br", 4, 9000, 120, 30); test_override(args, "q35", expected); } From patchwork Mon Jul 10 23:04:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806107 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=O9pCfLuN; dkim-atps=neutral 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 4R0KTF16Bvz20ZZ for ; Tue, 11 Jul 2023 09:09:37 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwh-000422-8J; Mon, 10 Jul 2023 19:05:31 -0400 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 1qIzwW-0003Cf-PI for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:22 -0400 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 1qIzwB-0004Yc-JZ for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030280; 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=NKbPO8ARdLVSrsrJJis4atM4y0FvySweZZUS4AyFig8=; b=O9pCfLuNnHbDk6pJN2gIh/ZStWv3X8X5EArON5R17WqvBXfeyjnVoGWW+SU8+rc3o4iC0m bxDgvY6pP81kamxZKE0T6fbDEJTz2j+MbELtlBAjHnsgCWu8egFNRRETe3E3NhoWM6cAvy SX/RNWfAZTti7gNlSzjfvxpy72WrIjs= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-524-D8Xgo10aOEKZhxZGBX5sGA-1; Mon, 10 Jul 2023 19:04:39 -0400 X-MC-Unique: D8Xgo10aOEKZhxZGBX5sGA-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3f5df65f9f4so31647815e9.2 for ; Mon, 10 Jul 2023 16:04:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030278; x=1691622278; 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=NKbPO8ARdLVSrsrJJis4atM4y0FvySweZZUS4AyFig8=; b=DFh2JO4AX00GhlXfg4tZID/Qt3S+6Jt2tw1m875ch7EBLZAoLIemFaafq5ZDHoiAb1 rZw8XnjadvOuMv3UC2etMzuP0Yez95mbfL5o8c2gotZkvWEqf+Vf6jqi4B3FEk82Vau0 5WDJNIaFM1Ki+loL30kL7WA4tfemeTYPkLx651hHLOUvLNkSc5yfCopvIla6uo4ND574 wkuXZMNV/7s5eY9d9HxdDOXZPjU4LUKghS/Eq9Q/N8D1JjUHQ1/NBpZ9IO5oR79lv7RL ROxntBJ2XeVPpCrMnlKDwYpemvFuMcLR/NVy+DEC3UemY0pY5iXZsBStadQvZFgkQscD hfDw== X-Gm-Message-State: ABy/qLashtRADTTe4/rxwIeWsnF9XwpyMhir0HK/za0X9jT6FNkW4mzR oGBxWkPfyEVcVWAcxpB6HpQclfvu1uaOQ92SdOT/rO8QD9KTsaNCcbX2TsYddcpY6vaK16JgXK/ w/RLr4kHduXDHtD11CnS1YfwWxqV/IjptiaaO7PH/Yl9yH1ES5gFjHfILfzbSeFuqWtoi X-Received: by 2002:a05:600c:29a:b0:3fb:abd0:2b52 with SMTP id 26-20020a05600c029a00b003fbabd02b52mr12272649wmk.13.1689030277924; Mon, 10 Jul 2023 16:04:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlHmC7+r8jaVZKZnEDjDLpMd4kpEnoUezHAA5PFHCM7ND6IOO3aXgghxU7e2LmjQtMh+RFEACg== X-Received: by 2002:a05:600c:29a:b0:3fb:abd0:2b52 with SMTP id 26-20020a05600c029a00b003fbabd02b52mr12272630wmk.13.1689030277606; Mon, 10 Jul 2023 16:04:37 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id b7-20020a05600c11c700b003fc015ae1e1sm981387wmi.3.2023.07.10.16.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:37 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:35 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ani Sinha , jusual@redhat.com, imammedo@redhat.com, mst@redhat.com, akihiko.odaki@daynix.com, Marcel Apfelbaum Subject: [PULL 45/66] hw/pci: warn when PCIe device is plugged into non-zero slot of downstream port 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: Ani Sinha PCIe downstream ports only have a single device 0, so PCI Express devices can only be plugged into slot 0 on a PCIe port. Add a warning to let users know when the invalid configuration is used. We may enforce this more strongly later once we get more clarity on whether we are introducing a bad regression for users currently using the wrong configuration. The change has been tested to not break or alter behaviors of ARI capable devices by instantiating seven vfs on an emulated igb device (the maximum number of vfs the igb device supports). The vfs are instantiated correctly and are seen to have non-zero device/slot numbers in the conventional PCI BDF representation. CC: jusual@redhat.com CC: imammedo@redhat.com CC: mst@redhat.com CC: akihiko.odaki@daynix.com Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2128929 Signed-off-by: Ani Sinha Reviewed-by: Julia Suvorova Message-Id: <20230705115925.5339-6-anisinha@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Akihiko Odaki --- hw/pci/pci.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index fb17138f7d..4b14f31859 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -65,6 +65,7 @@ bool pci_available = true; static char *pcibus_get_dev_path(DeviceState *dev); static char *pcibus_get_fw_dev_path(DeviceState *dev); static void pcibus_reset(BusState *qbus); +static bool pcie_has_upstream_port(PCIDevice *dev); static Property pci_props[] = { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), @@ -2121,6 +2122,25 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp) } } + /* + * A PCIe Downstream Port that do not have ARI Forwarding enabled must + * associate only Device 0 with the device attached to the bus + * representing the Link from the Port (PCIe base spec rev 4.0 ver 0.3, + * sec 7.3.1). + * With ARI, PCI_SLOT() can return non-zero value as the traditional + * 5-bit Device Number and 3-bit Function Number fields in its associated + * Routing IDs, Requester IDs and Completer IDs are interpreted as a + * single 8-bit Function Number. Hence, ignore ARI capable devices. + */ + if (pci_is_express(pci_dev) && + !pcie_find_capability(pci_dev, PCI_EXT_CAP_ID_ARI) && + pcie_has_upstream_port(pci_dev) && + PCI_SLOT(pci_dev->devfn)) { + warn_report("PCI: slot %d is not valid for %s," + " parent device only allows plugging into slot 0.", + PCI_SLOT(pci_dev->devfn), pci_dev->name); + } + if (pci_dev->failover_pair_id) { if (!pci_bus_is_express(pci_get_bus(pci_dev))) { error_setg(errp, "failover primary device must be on " From patchwork Mon Jul 10 23:04:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806101 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=ZbBtui5L; dkim-atps=neutral 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 4R0KSr6dNKz20bx for ; Tue, 11 Jul 2023 09:09:16 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwf-0003jt-UZ; Mon, 10 Jul 2023 19:05:30 -0400 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 1qIzwM-0002W8-UB for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:10 -0400 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 1qIzwI-0004Z8-0X for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030284; 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=A/513T7kroKOQx8pSM4wAJX3w8Juwbgshwbra6tnmIM=; b=ZbBtui5LGvNhP+4A/8FsrFMICr0PKg//+51uis7+yFAEeNqZ/Wr183GGBHKRHXNo8WhsUo bVc8J700F2O5ysi+Sojdwcp7Nz3jzCTL31KwcjYS8j4HEHQAn3tzCl85hoTzIM5plifr11 I1BGL+ZtSpn1mvbidSVkmjRfIS5P46Q= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-399-Rw4wXgWUN1OAiBMIHoa6Sw-1; Mon, 10 Jul 2023 19:04:42 -0400 X-MC-Unique: Rw4wXgWUN1OAiBMIHoa6Sw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3fbdf341934so37078835e9.3 for ; Mon, 10 Jul 2023 16:04:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030281; x=1691622281; 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=A/513T7kroKOQx8pSM4wAJX3w8Juwbgshwbra6tnmIM=; b=KnwtwqIFu0LBHYVL1A5yNOSKvc5NK/wCrTsO4XdeC8/X+EL62szY389xJcKatjgMkc 97r1U7Ov3eeAuEKwyVzRpP7zIoRgQKmbF6MuApcUYGw+c1f1CBAQtiLBWNAVVxSERjxn MgVNyGirocsB6xQlPuuq6yafvDVmMeiijxiL9XaEl2Ikj/WkqbiPSeevisycpPUNGr/c cusji13yu9NU9PFa5F6e5QW/EXaBBypf8UDhpsjZP9FAv58WmQkDJBBekWPFoTnD2QNH r0YgeJkLzCuWswoqFLvBEdX+TiIT+BINsebOFrrKgx6plA8YQsWrqXxy/xHDsCseLdnY RecA== X-Gm-Message-State: ABy/qLaOGc3fu68iLzJN7l+COBIG40YtKXUbwMC+qyfw54ND1eaVdRje HUIbg8a8L8lWanG9ycm2eUCbTDJZwYAzj3IN3dFUYbq5PVd19cqXJJCr783FwD5uUWLijdlYTOM TWLfqj7PXyTe7vz990aajNgCoA2nXdCTBGu7/Q49OGGCQ7BVhEoPvQNEHjVaOqIPoC/yZ X-Received: by 2002:a05:600c:247:b0:3fc:65:8dff with SMTP id 7-20020a05600c024700b003fc00658dffmr14667211wmj.4.1689030280919; Mon, 10 Jul 2023 16:04:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlGTCl+MuxiHIqO0lV6NA8mf6j6Mfq+K1TsP0Uq/4M6xPdAKi6R8ZMgPLFWnd9/AB+WDS3UvZw== X-Received: by 2002:a05:600c:247:b0:3fc:65:8dff with SMTP id 7-20020a05600c024700b003fc00658dffmr14667185wmj.4.1689030280572; Mon, 10 Jul 2023 16:04:40 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id b16-20020a5d5510000000b0031417b0d338sm574460wrv.87.2023.07.10.16.04.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:40 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Eric Auger , Jean-Philippe Brucker , Zhenzhong Duan Subject: [PULL 46/66] virtio-iommu: Fix 64kB host page size VFIO device assignment Message-ID: <94df5b2180d61fb2ee2b04cc007981e58b6479a9.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Eric Auger When running on a 64kB page size host and protecting a VFIO device with the virtio-iommu, qemu crashes with this kind of message: qemu-kvm: virtio-iommu page mask 0xfffffffffffff000 is incompatible with mask 0x20010000 qemu: hardware error: vfio: DMA mapping failed, unable to continue This is due to the fact the IOMMU MR corresponding to the VFIO device is enabled very late on domain attach, after the machine init. The device reports a minimal 64kB page size but it is too late to be applied. virtio_iommu_set_page_size_mask() fails and this causes vfio_listener_region_add() to end up with hw_error(); To work around this issue, we transiently enable the IOMMU MR on machine init to collect the page size requirements and then restore the bypass state. Fixes: 90519b9053 ("virtio-iommu: Add bypass mode support to assigned device") Signed-off-by: Eric Auger Message-Id: <20230705165118.28194-2-eric.auger@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Jean-Philippe Brucker Tested-by: Jean-Philippe Brucker Reviewed-by: Zhenzhong Duan --- include/hw/virtio/virtio-iommu.h | 2 ++ hw/virtio/virtio-iommu.c | 31 +++++++++++++++++++++++++++++-- hw/virtio/trace-events | 1 + 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/include/hw/virtio/virtio-iommu.h b/include/hw/virtio/virtio-iommu.h index 2ad5ee320b..a93fc5383e 100644 --- a/include/hw/virtio/virtio-iommu.h +++ b/include/hw/virtio/virtio-iommu.h @@ -61,6 +61,8 @@ struct VirtIOIOMMU { QemuRecMutex mutex; GTree *endpoints; bool boot_bypass; + Notifier machine_done; + bool granule_frozen; }; #endif diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 1bbad23f4a..8d0c5e3f32 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -25,6 +25,7 @@ #include "hw/virtio/virtio.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" +#include "sysemu/sysemu.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "trace.h" @@ -1106,12 +1107,12 @@ static int virtio_iommu_set_page_size_mask(IOMMUMemoryRegion *mr, } /* - * After the machine is finalized, we can't change the mask anymore. If by + * Once the granule is frozen we can't change the mask anymore. If by * chance the hotplugged device supports the same granule, we can still * accept it. Having a different masks is possible but the guest will use * sub-optimal block sizes, so warn about it. */ - if (phase_check(PHASE_MACHINE_READY)) { + if (s->granule_frozen) { int new_granule = ctz64(new_mask); int cur_granule = ctz64(cur_mask); @@ -1146,6 +1147,28 @@ static void virtio_iommu_system_reset(void *opaque) } +static void virtio_iommu_freeze_granule(Notifier *notifier, void *data) +{ + VirtIOIOMMU *s = container_of(notifier, VirtIOIOMMU, machine_done); + int granule; + + if (likely(s->config.bypass)) { + /* + * Transient IOMMU MR enable to collect page_size_mask requirements + * through memory_region_iommu_set_page_size_mask() called by + * VFIO region_add() callback + */ + s->config.bypass = false; + virtio_iommu_switch_address_space_all(s); + /* restore default */ + s->config.bypass = true; + virtio_iommu_switch_address_space_all(s); + } + s->granule_frozen = true; + granule = ctz64(s->config.page_size_mask); + trace_virtio_iommu_freeze_granule(BIT(granule)); +} + static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); @@ -1189,6 +1212,9 @@ static void virtio_iommu_device_realize(DeviceState *dev, Error **errp) error_setg(errp, "VIRTIO-IOMMU is not attached to any PCI bus!"); } + s->machine_done.notify = virtio_iommu_freeze_granule; + qemu_add_machine_init_done_notifier(&s->machine_done); + qemu_register_reset(virtio_iommu_system_reset, s); } @@ -1198,6 +1224,7 @@ static void virtio_iommu_device_unrealize(DeviceState *dev) VirtIOIOMMU *s = VIRTIO_IOMMU(dev); qemu_unregister_reset(virtio_iommu_system_reset, s); + qemu_remove_machine_init_done_notifier(&s->machine_done); g_hash_table_destroy(s->as_by_busptr); if (s->domains) { diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 4e39ed8a95..7109cf1a3b 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -133,6 +133,7 @@ virtio_iommu_set_page_size_mask(const char *name, uint64_t old, uint64_t new) "m virtio_iommu_notify_flag_add(const char *name) "add notifier to mr %s" virtio_iommu_notify_flag_del(const char *name) "del notifier from mr %s" virtio_iommu_switch_address_space(uint8_t bus, uint8_t slot, uint8_t fn, bool on) "Device %02x:%02x.%x switching address space (iommu enabled=%d)" +virtio_iommu_freeze_granule(uint64_t page_size_mask) "granule set to 0x%"PRIx64 # virtio-mem.c virtio_mem_send_response(uint16_t type) "type=%" PRIu16 From patchwork Mon Jul 10 23:04:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806111 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=UWEWoX/5; dkim-atps=neutral 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 4R0KTK1XtSz20cZ for ; Tue, 11 Jul 2023 09:09:41 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwN-0002WZ-49; Mon, 10 Jul 2023 19:05:11 -0400 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 1qIzwJ-00028D-SG for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:08 -0400 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 1qIzwI-0004ZQ-3d for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030286; 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=e96k/kxAhOznziHvCn8/Sqiu/LbtoiFGXi8Abmjs3vo=; b=UWEWoX/5Wr25a6k6kUroE3Kyv6PYkcmrfp17Tvx0p6MKOg4++3hssNyDdyU9arv4aSnOyM 3AX5tzm2KH7mjARBqLHlKv70b+kvq0qhcKiHzvVcpA3n3Fy6eFUwbqK4jI6E4n8Zbjhrai jUmaBi+gLEIXpT533noG1GrP+RlAN/4= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-634-YwbQb7NUPFq_DKPfoc0_Vg-1; Mon, 10 Jul 2023 19:04:45 -0400 X-MC-Unique: YwbQb7NUPFq_DKPfoc0_Vg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fc0094c1bdso24648925e9.2 for ; Mon, 10 Jul 2023 16:04:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030283; x=1691622283; 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=e96k/kxAhOznziHvCn8/Sqiu/LbtoiFGXi8Abmjs3vo=; b=ON/ibZB9QQH1jjyNrQzCCJcr42ptnL7Ac0P41kPnb0ZUv+wpS9Bz/KBPgCjCV223Lp aFAlp3svSA7e0g2g1rDuKGkhu3S5JWmETXnrpnHb8HBQkF32q6u/ehKE+XmUj62uTUVJ NHs6xwtJp2/M80YPZyZbmmAwKvke75mJ7l4BJf6DpqJmZYJ+LdQcvMV748D+nUMP7mUC X7a6w8jpc8SWxvrP5jMs74e3rqZ36H5CTk4GkiFyDkI5Tm7aXb8TvkdwB6N0FsYZ1c6N T+Q88MQW1FUVTYlzA4iVIX5b0aBFAQ5Of5sCV3rDkPia0zX10PPSTqLFJ76WICx3FHpc M4AA== X-Gm-Message-State: ABy/qLbFpf3vExs429oMtOwHpEL34cR8TjOfGW+kohjdc99OzgHPkAtD Xo49xA0Q2WPJ86SeGOaWoJRaH3QppLB7y4DcpW2i6Amsy/MmoLg8XkK4Tg1cNpTAgVonUZreBY7 5nWzaU0jMRqgjFGGSDmLX/g0kn9IFBpHUIpSSKI9hKfFeGBmimhB2B8O/WW55O2UaNO6V X-Received: by 2002:a7b:c389:0:b0:3fc:9f:e75c with SMTP id s9-20020a7bc389000000b003fc009fe75cmr10669096wmj.11.1689030283589; Mon, 10 Jul 2023 16:04:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlHp/2/TOjUyWiaBJxW3lCs74cD2f3zMrKSwa2zGBp+RcRwKa/QcBxYd7/6Prrlqer69OOVgFg== X-Received: by 2002:a7b:c389:0:b0:3fc:9f:e75c with SMTP id s9-20020a7bc389000000b003fc009fe75cmr10669074wmj.11.1689030283188; Mon, 10 Jul 2023 16:04:43 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id z9-20020a1c4c09000000b003fa74bff02asm932968wmf.26.2023.07.10.16.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:42 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:40 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Eric Auger , Zhenzhong Duan , Jean-Philippe Brucker Subject: [PULL 47/66] virtio-iommu: Rework the traces in virtio_iommu_set_page_size_mask() Message-ID: <587a7641d53055054d68d67d94c9408ef808f127.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Eric Auger The current error messages in virtio_iommu_set_page_size_mask() sound quite similar for different situations and miss the IOMMU memory region that causes the issue. Clarify them and rework the comment. Also remove the trace when the new page_size_mask is not applied as the current frozen granule is kept. This message is rather confusing for the end user and anyway the current granule would have been used by the driver. Signed-off-by: Eric Auger Reviewed-by: Zhenzhong Duan Message-Id: <20230705165118.28194-3-eric.auger@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Jean-Philippe Brucker Tested-by: Jean-Philippe Brucker --- hw/virtio/virtio-iommu.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 8d0c5e3f32..201127c488 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -1101,29 +1101,24 @@ static int virtio_iommu_set_page_size_mask(IOMMUMemoryRegion *mr, new_mask); if ((cur_mask & new_mask) == 0) { - error_setg(errp, "virtio-iommu page mask 0x%"PRIx64 - " is incompatible with mask 0x%"PRIx64, cur_mask, new_mask); + error_setg(errp, "virtio-iommu %s reports a page size mask 0x%"PRIx64 + " incompatible with currently supported mask 0x%"PRIx64, + mr->parent_obj.name, new_mask, cur_mask); return -1; } /* * Once the granule is frozen we can't change the mask anymore. If by * chance the hotplugged device supports the same granule, we can still - * accept it. Having a different masks is possible but the guest will use - * sub-optimal block sizes, so warn about it. + * accept it. */ if (s->granule_frozen) { - int new_granule = ctz64(new_mask); int cur_granule = ctz64(cur_mask); - if (new_granule != cur_granule) { - error_setg(errp, "virtio-iommu page mask 0x%"PRIx64 - " is incompatible with mask 0x%"PRIx64, cur_mask, - new_mask); + if (!(BIT(cur_granule) & new_mask)) { + error_setg(errp, "virtio-iommu %s does not support frozen granule 0x%llx", + mr->parent_obj.name, BIT_ULL(cur_granule)); return -1; - } else if (new_mask != cur_mask) { - warn_report("virtio-iommu page mask 0x%"PRIx64 - " does not match 0x%"PRIx64, cur_mask, new_mask); } return 0; } From patchwork Mon Jul 10 23:04:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806100 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=T6VqkFsN; dkim-atps=neutral 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 4R0KSq5Kv6z20ZZ for ; Tue, 11 Jul 2023 09:09:15 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwa-0003Ci-HF; Mon, 10 Jul 2023 19:05:24 -0400 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 1qIzwM-0002Vv-TD for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:10 -0400 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 1qIzwI-0004Zc-Dn for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030289; 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=xD1AkY/txf5N+3ZJ0BJ1Fs74CaRBbtaK9Vb5NSU/lq4=; b=T6VqkFsNJjKK9UoUYpRyXks/43BUdwT1WXIoNPb7ksrcBE1RCOUjooIW7Nv8/HJwDfvHwv mutSxiVTvjEiFvcYFku/KC9Y829aB07A+BAvVsZ6w4MRYIc68QZjLuTTy+vO24XeEmCzkV nMcWk2d2jK3/LaN8UapqC8Y4SteuwSs= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-Q3K-hMeMNkSrygRNgFchAw-1; Mon, 10 Jul 2023 19:04:48 -0400 X-MC-Unique: Q3K-hMeMNkSrygRNgFchAw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3fc07d4c63eso10374685e9.1 for ; Mon, 10 Jul 2023 16:04:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030286; x=1691622286; 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=xD1AkY/txf5N+3ZJ0BJ1Fs74CaRBbtaK9Vb5NSU/lq4=; b=S+jiRAQ8pxxPhvW18NQnmYl1nDrEcvDMd+qXni8tz2OLfc/LT7YfmdWqKcGgYO952k DICRMLUiaalWygQWuIn5QxXXjOvinxVsrB7GqN9lQw5yfbUlgCYHWBDBAgQME2Rsj2AL iRkkeAOmgCa3qX8arf3Hi7PeAEizjXPTR3cZQsjJ4m3clyQ2Gn9Z6xwOctFALAzGvjfZ QXG6vM8IhpzpwEOZnKS/b27F+qbqajJpEqKHAyFhvI22jf47pnLzafB2vFr3w16memQY UpjEeY4cQYy1wzpRjhbSxPI2SGozyUTATvH+3R+2SMkCQaDDJ8ErqSKbk5eEPFsB51SL FI7g== X-Gm-Message-State: ABy/qLYkmHP/YsJD69h1t9WbLy702GG/VR11Xqxa+8bb8/zgsWG72Emu Nr36o2A0T5B7ZH9eXnGGdBvnbyBvScLpeyqVVIfgRQjKLSqmOpTCIuUunVK6iHGD2TSUWbN3SKf e+UATxgLAJIQKDFjlORrYjO9BHpA7Yxk+36me1a1uWSpCAwA7+469To74OjorZ4C++cSD X-Received: by 2002:a05:6000:8b:b0:30e:56b3:60fe with SMTP id m11-20020a056000008b00b0030e56b360femr12727790wrx.4.1689030286387; Mon, 10 Jul 2023 16:04:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlGhQMsYv7zygab3dCzUEdaW/nT6fijvgaEMfYTmFF4ZiehJ9ZFiUsrLK6LtQ5YpJRpQtlBP8g== X-Received: by 2002:a05:6000:8b:b0:30e:56b3:60fe with SMTP id m11-20020a056000008b00b0030e56b360femr12727773wrx.4.1689030286101; Mon, 10 Jul 2023 16:04:46 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id b16-20020a5d5510000000b0031417b0d338sm574620wrv.87.2023.07.10.16.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:45 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Leonardo Bras , Juan Quintela , Marcel Apfelbaum Subject: [PULL 48/66] pcie: Add hotplug detect state register to cmask Message-ID: <625b370c45f4acd155ee625d61c0057d770a5b5e.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Leonardo Bras When trying to migrate a machine type pc-q35-6.0 or lower, with this cmdline options, -device driver=pcie-root-port,port=18,chassis=19,id=pcie-root-port18,bus=pcie.0,addr=0x12 \ -device driver=nec-usb-xhci,p2=4,p3=4,id=nex-usb-xhci0,bus=pcie-root-port18,addr=0x12.0x1 the following bug happens after all ram pages were sent: qemu-kvm: get_pci_config_device: Bad config data: i=0x6e read: 0 device: 40 cmask: ff wmask: 0 w1cmask:19 qemu-kvm: Failed to load PCIDevice:config qemu-kvm: Failed to load pcie-root-port:parent_obj.parent_obj.parent_obj qemu-kvm: error while loading state for instance 0x0 of device '0000:00:12.0/pcie-root-port' qemu-kvm: load of migration failed: Invalid argument This happens on pc-q35-6.0 or lower because of: { "ICH9-LPC", ACPI_PM_PROP_ACPI_PCIHP_BRIDGE, "off" } In this scenario, hotplug_handler_plug() calls pcie_cap_slot_plug_cb(), which sets dev->config byte 0x6e with bit PCI_EXP_SLTSTA_PDS to signal PCI hotplug for the guest. After a while the guest will deal with this hotplug and qemu will clear the above bit. Then, during migration, get_pci_config_device() will compare the configs of both the freshly created device and the one that is being received via migration, which will differ due to the PCI_EXP_SLTSTA_PDS bit and cause the bug to reproduce. To avoid this fake incompatibility, there are tree fields in PCIDevice that can help: - wmask: Used to implement R/W bytes, and - w1cmask: Used to implement RW1C(Write 1 to Clear) bytes - cmask: Used to enable config checks on load. According to PCI Express® Base Specification Revision 5.0 Version 1.0, table 7-27 (Slot Status Register) bit 6, the "Presence Detect State" is listed as RO (read-only), so it only makes sense to make use of the cmask field. So, clear PCI_EXP_SLTSTA_PDS bit on cmask, so the fake incompatibility on get_pci_config_device() does not abort the migration. Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=2215819 Signed-off-by: Leonardo Bras Message-Id: <20230706045546.593605-3-leobras@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Juan Quintela --- hw/pci/pcie.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index b7f107ed8d..763f65c528 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -666,6 +666,10 @@ void pcie_cap_slot_init(PCIDevice *dev, PCIESlot *s) pci_word_test_and_set_mask(dev->w1cmask + pos + PCI_EXP_SLTSTA, PCI_EXP_HP_EV_SUPPORTED); + /* Avoid migration abortion when this device hot-removed by guest */ + pci_word_test_and_clear_mask(dev->cmask + pos + PCI_EXP_SLTSTA, + PCI_EXP_SLTSTA_PDS); + dev->exp.hpev_notified = false; qbus_set_hotplug_handler(BUS(pci_bridge_get_sec_bus(PCI_BRIDGE(dev))), From patchwork Mon Jul 10 23:04:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806081 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=b9H9wE5G; dkim-atps=neutral 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 4R0KRd40PNz20ZZ for ; Tue, 11 Jul 2023 09:08:13 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwe-0003aQ-W1; Mon, 10 Jul 2023 19:05:29 -0400 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 1qIzwM-0002Vr-T1 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:10 -0400 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 1qIzwI-0004Zn-E2 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030292; 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=prlM+cemIKIm3D7j/eroL0Z9oyt7v5VUTSaZUNi0Drw=; b=b9H9wE5GLw7VqI6BoVuhOnVC+1C22/bqt7zfBrFq4Eg2o+bwiwOOkoJgOP0iCpMRx8nYY+ StWbEB21lEcRvl7VNlUzcXxCU5rJ1wxYUxWsZ6UpT1h1pJcaiRinyn8aWbFENkA+ayJVVR YY+36Y7pzXRZYN2HK+VQXroTFGYpSbo= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-341-vgrldHLJORiGWaWblacVQw-1; Mon, 10 Jul 2023 19:04:50 -0400 X-MC-Unique: vgrldHLJORiGWaWblacVQw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fa9a282fffso29962645e9.1 for ; Mon, 10 Jul 2023 16:04:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030289; x=1691622289; 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=prlM+cemIKIm3D7j/eroL0Z9oyt7v5VUTSaZUNi0Drw=; b=BirTxgP8bq+ChTFgWCRZyPsBRTg4TUvJdgowyRK34beD5KylBMbY7TuSHAAx/1dtB9 m+QQwANmGYxaRLwBlS8okMjSU3Jaberx/QCvLW6lL7y/GihXf22sMiI2v1Ic6Knh1NGV zO2MItFlPGwIvOfuFHrcA2JtILwhy4wHBHL7iMIzERm0zJSX4CyAwCrP0JmE5GZX1ENc SgqFxIBhZTSAdZMlal/M1kKOfgtUga+HDsLvo/LIRZOrQdeIbSvjT5yA3/RN2dcSytWE ShOrB7IuLnioLP6HZpB/rwNBGBfg1hDRAMCTHcb0MHp5pxiAmDdEA/MehazEjRVHQgPU fA8A== X-Gm-Message-State: ABy/qLZOB1uZC68KQfNNvFVGU/d+L0zwfKRA0a+Rxld5L/0LIkIZTq4X 16r/+/TNHVpWOe5wavmUvAYG2swGSPJaGWYsIXeHUAbtfdd50NcHpaH2PGRsb6UNKT41cakteH9 lpUzeyO0Oos6JJDZzM8tasUWSmvEQHloAtxaor9psSCe7Xxln5JJJZvdJ9oIHxjxsIm99 X-Received: by 2002:a1c:4b19:0:b0:3f8:f382:8e1f with SMTP id y25-20020a1c4b19000000b003f8f3828e1fmr11101428wma.24.1689030289070; Mon, 10 Jul 2023 16:04:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlE7pK4HwH9VcQUu7MupZ4/y7peVFwUDpvI5MeoZC7IYAiempWv1Ic9CAW53V0vg0+WzUTb5GA== X-Received: by 2002:a1c:4b19:0:b0:3f8:f382:8e1f with SMTP id y25-20020a1c4b19000000b003f8f3828e1fmr11101412wma.24.1689030288837; Mon, 10 Jul 2023 16:04:48 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id l4-20020a1ced04000000b003fbe561f6a3sm11449505wmh.37.2023.07.10.16.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:48 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:46 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Eugenio =?utf-8?b?UMOpcmV6?= , Jason Wang Subject: [PULL 49/66] vdpa: Fix possible use-after-free for VirtQueueElement Message-ID: <031b1abacbdb3f4e016b6b926f7e7876c05339bb.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Hawkins Jiawei QEMU uses vhost_handle_guest_kick() to forward guest's available buffers to the vdpa device in SVQ avail ring. In vhost_handle_guest_kick(), a `g_autofree` `elem` is used to iterate through the available VirtQueueElements. This `elem` is then passed to `svq->ops->avail_handler`, specifically to the vhost_vdpa_net_handle_ctrl_avail(). If this handler fails to process the CVQ command, vhost_handle_guest_kick() regains ownership of the `elem`, and either frees it or requeues it. Yet the problem is that, vhost_vdpa_net_handle_ctrl_avail() mistakenly frees the `elem`, even if it fails to forward the CVQ command to vdpa device. This can result in a use-after-free for the `elem` in vhost_handle_guest_kick(). This patch solves this problem by refactoring vhost_vdpa_net_handle_ctrl_avail() to only freeing the `elem` if it owns it. Fixes: bd907ae4b0 ("vdpa: manual forward CVQ buffers") Signed-off-by: Hawkins Jiawei Message-Id: Reviewed-by: Eugenio Pérez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 679ef4bed0..5542b47a8f 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -831,7 +831,16 @@ out: error_report("Bad device CVQ written length"); } vhost_svq_push_elem(svq, elem, MIN(in_len, sizeof(status))); - g_free(elem); + /* + * `elem` belongs to vhost_vdpa_net_handle_ctrl_avail() only when + * the function successfully forwards the CVQ command, indicated + * by a non-negative value of `dev_written`. Otherwise, it still + * belongs to SVQ. + * This function should only free the `elem` when it owns. + */ + if (dev_written >= 0) { + g_free(elem); + } return dev_written < 0 ? dev_written : 0; } From patchwork Mon Jul 10 23:04:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806073 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=gmP8WiT4; dkim-atps=neutral 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 4R0KQ76J5zz20ZZ for ; Tue, 11 Jul 2023 09:06:55 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwQ-0002lR-B9; Mon, 10 Jul 2023 19:05:15 -0400 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 1qIzwM-0002WF-Uw for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:10 -0400 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 1qIzwI-0004a0-Di for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030294; 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=b1yF9+I+eRXG7++9iT7lOKTZwoXP1PUCE8vxaJW/z4w=; b=gmP8WiT4E1fgozuNfqZ+3FbtbRSA22bOfVVMAOx3i4X5YVa7q7IlN+a5ZnM1Zv+rr4fW1d 1SeTm1V+2U+vppt9KiRqm61NmVNqKwSeBv+qS+w23CsJ5H+i3MRoMRgY7+GZu67cnczt28 2PTPhblHVViGyqaqpCH1IGt3v/DIZUY= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-435-I8xdiB1iPoeAMqEPn6qD5Q-1; Mon, 10 Jul 2023 19:04:53 -0400 X-MC-Unique: I8xdiB1iPoeAMqEPn6qD5Q-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fbfc766a78so24389415e9.3 for ; Mon, 10 Jul 2023 16:04:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030292; x=1691622292; 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=b1yF9+I+eRXG7++9iT7lOKTZwoXP1PUCE8vxaJW/z4w=; b=lIGsQjXRSJI8JrmPh9h3CN5HhnifiF+0OMKLf0T2mtvjRcVVglluXIpUDzSPYdssqY BraP0VthjOjK8NNRTWLq2Ta9L/MSC26yE4vqnfCvv3stkx5qmsaqtLAioZGuNB4PFSoZ X5ehRKmqf0onc3Ft6NTISB9Am8i1eM3fgWcqpuOMYl8ngIJavZleEUTRZy86PodwwWRo KJwc9g46bY9DiqkphirXhMwcj4K9ZbSq6cuti2GVjHQdK/s34SpxWjq9l2IJqP1rnA+L jy3KpFqoPxSB5P4AyeLXxa2yj0YGJvX9v2L4uqtoeoMGCV8sb/yt4iwUhRchXVGTcUMi rdcg== X-Gm-Message-State: ABy/qLYyUVt4oNyn5GEKse3qYk4VXFqlk4eIrbHulhk0/hqinTwAfp5Y LR0haCyhQI90JuTRYpOj1gSAVj5E6Ge2ZIevtWp4KgDY9fNGUPTLOoMURHugP8RBB6uMNXDKA2Y hBZYW8DAm1Z23xypnfIBMnefpwm7AQVI/vrlxDMLOgvsYffttitekPJbQwrzod3kZUT11 X-Received: by 2002:a1c:e915:0:b0:3fb:b5dc:dab1 with SMTP id q21-20020a1ce915000000b003fbb5dcdab1mr11486440wmc.39.1689030291890; Mon, 10 Jul 2023 16:04:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlHcsOQcBI8OYETib//Ak0I4t52L+vCBxsvExkrcBMFu4ukf+sVc30LL7gnHgJPlFF9oSy83nQ== X-Received: by 2002:a1c:e915:0:b0:3fb:b5dc:dab1 with SMTP id q21-20020a1ce915000000b003fbb5dcdab1mr11486421wmc.39.1689030291518; Mon, 10 Jul 2023 16:04:51 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id f18-20020a7bcd12000000b003fa999cefc0sm919598wmj.36.2023.07.10.16.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:51 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:49 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Paolo Bonzini , Daniel =?utf-8?b?UC4gQmVycmFuZ8Op?= , Eduardo Habkost Subject: [PULL 50/66] include: attempt to document device_class_set_props 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 I'm still not sure how I achieve by use case of the parent class defining the following properties: static Property vud_properties[] = { DEFINE_PROP_CHR("chardev", VHostUserDevice, chardev), DEFINE_PROP_UINT16("id", VHostUserDevice, id, 0), DEFINE_PROP_UINT32("num_vqs", VHostUserDevice, num_vqs, 1), DEFINE_PROP_END_OF_LIST(), }; But for the specialisation of the class I want the id to default to the actual device id, e.g.: static Property vu_rng_properties[] = { DEFINE_PROP_UINT16("id", VHostUserDevice, id, VIRTIO_ID_RNG), DEFINE_PROP_UINT32("num_vqs", VHostUserDevice, num_vqs, 1), DEFINE_PROP_END_OF_LIST(), }; And so far the API for doing that isn't super clear. Signed-off-by: Alex Bennée Message-Id: <20230710153522.3469097-2-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/qdev-core.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 06cadfc492..196ebf6d91 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -926,6 +926,15 @@ BusState *sysbus_get_default(void); char *qdev_get_fw_dev_path(DeviceState *dev); char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev); +/** + * device_class_set_props(): add a set of properties to an device + * @dc: the parent DeviceClass all devices inherit + * @props: an array of properties, terminate by DEFINE_PROP_END_OF_LIST() + * + * This will add a set of properties to the object. It will fault if + * you attempt to add an existing property defined by a parent class. + * To modify an inherited property you need to use???? + */ void device_class_set_props(DeviceClass *dc, Property *props); /** From patchwork Mon Jul 10 23:04:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806099 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=G2mU1m/X; dkim-atps=neutral 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 4R0KSn54f7z20ZZ for ; Tue, 11 Jul 2023 09:09:13 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwO-0002eo-9c; Mon, 10 Jul 2023 19:05:12 -0400 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 1qIzwN-0002Wc-0O for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:11 -0400 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 1qIzwJ-0004aQ-HR for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030297; 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=gchxlBA+cB22tJPCzqHzEwVhVGuwa/sdVVkoeiXPLUI=; b=G2mU1m/X4XbvivAUIsXsvsYRY+yX0mxuj6Jzu7OUBkkVWyv9pdR4e0EIOwsYAnVd3q9/d9 YpaNPtgveE2SXMzGclktkq9d9JfyMSDCqD4wjfBRSv++9SDBuI5ZTienby34kWlIcfKYEd DHqNUU+7Cycy/DLRBtOYttoVrknCHtg= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-418-7o4Kbhw3Mta-FYhKux5faw-1; Mon, 10 Jul 2023 19:04:56 -0400 X-MC-Unique: 7o4Kbhw3Mta-FYhKux5faw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3fbfc766a78so24389635e9.3 for ; Mon, 10 Jul 2023 16:04:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030295; x=1691622295; 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=gchxlBA+cB22tJPCzqHzEwVhVGuwa/sdVVkoeiXPLUI=; b=aGP38018cSoUpKTXNn1rIQ38JFuzRgy/NuqPV5ahUZrA+aWGUCIWi2m/mele0U2hPk qIh/ql+UUiWVRziE2eAcBQwUj3UY++8keHEXNlwACP9iVp3I7wg/UJKUemHPkvxLvuTl 6lKMrDQkO1Wplc8tUhV2MUrUsNaslQwL+SPj/UPxU06/JPDPRSsqankkDiXq8NZiM7bP eZrm2S4kAVLQVgZyl8Jae84XqcsqQhpaBpnSMSTuIm1pOCu3J6qlrKu9cWULrGiAcFyE 23y2erg73bxsWAGZC3/l8EjyeCJCHYpHH8tON4SHX3qMXojvjw7KYx4tMeHd41DqSXGE XWGQ== X-Gm-Message-State: ABy/qLZD2CzGctMhNWBX+Y8LKdhQ3okJ5qOoZqySHl1XjV8gPUKTlAlJ 8SDxZUeCI9VKyjC3iaklr43gT8FLSaYe3jFWh6aBINi5h2+68R9AhrXdZdr2WFPah+ShHLdxzD/ 5LdVt2WfXhATjxESPGUauE3BGTYrQIKGqqNbYZmy8Y4MrS0jM1Pm7AN+FT/SxFtRYpwXH X-Received: by 2002:a7b:cbd8:0:b0:3f9:9a93:217f with SMTP id n24-20020a7bcbd8000000b003f99a93217fmr11257220wmi.3.1689030294797; Mon, 10 Jul 2023 16:04:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlG70jLAfa+GG4erWaNxXLwkJxPxnpjRU9bN9vKPimsTGOTtuhz46IXtj7L3bD+4f/43d0Y1eA== X-Received: by 2002:a7b:cbd8:0:b0:3f9:9a93:217f with SMTP id n24-20020a7bcbd8000000b003f99a93217fmr11257202wmi.3.1689030294415; Mon, 10 Jul 2023 16:04:54 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id a25-20020a1cf019000000b003fbb346279dsm919922wmb.38.2023.07.10.16.04.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:53 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , Paolo Bonzini , Daniel =?utf-8?b?UC4gQmVycmFuZ8Op?= , Eduardo Habkost Subject: [PULL 51/66] include/hw: document the device_class_set_parent_* fns 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 These are useful functions for when you want proper inheritance of functionality across realize/unrealize calls. Signed-off-by: Alex Bennée Message-Id: <20230710153522.3469097-3-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/qdev-core.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 196ebf6d91..884c726a87 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -952,9 +952,36 @@ void device_class_set_props(DeviceClass *dc, Property *props); void device_class_set_parent_reset(DeviceClass *dc, DeviceReset dev_reset, DeviceReset *parent_reset); + +/** + * device_class_set_parent_realize() - set up for chaining realize fns + * @dc: The device class + * @dev_realize: the device realize function + * @parent_realize: somewhere to save the parents realize function + * + * This is intended to be used when the new realize function will + * eventually call its parent realization function during creation. + * This requires storing the function call somewhere (usually in the + * instance structure) so you can eventually call + * dc->parent_realize(dev, errp) + */ void device_class_set_parent_realize(DeviceClass *dc, DeviceRealize dev_realize, DeviceRealize *parent_realize); + + +/** + * device_class_set_parent_unrealize() - set up for chaining unrealize fns + * @dc: The device class + * @dev_unrealize: the device realize function + * @parent_unrealize: somewhere to save the parents unrealize function + * + * This is intended to be used when the new unrealize function will + * eventually call its parent unrealization function during the + * unrealize phase. This requires storing the function call somewhere + * (usually in the instance structure) so you can eventually call + * dc->parent_unrealize(dev); + */ void device_class_set_parent_unrealize(DeviceClass *dc, DeviceUnrealize dev_unrealize, DeviceUnrealize *parent_unrealize); From patchwork Mon Jul 10 23:04:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806093 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=LSQLJjku; dkim-atps=neutral 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 4R0KSW4CMXz20ZZ for ; Tue, 11 Jul 2023 09:08:59 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwO-0002gl-GM; Mon, 10 Jul 2023 19:05:12 -0400 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 1qIzwM-0002W1-TX for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:10 -0400 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 1qIzwJ-0004b7-HR for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030303; 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=8aPiUq53zYt0kY/8LueF30ebx/Uzyl1lsl0vCB8gSxM=; b=LSQLJjku7VmvSrifoSWry2+ggQSIceHmlEGgdThNG0VeV72fX0zCUvdrjgAkwu/K8A1Wep sMnl+XwL8ZISXPa2RDiWXPjwxYjLlyxVdgcm+4CnmWQVxgZ4kJ7pSzvsXHqtZmO0BZt6Uo Xgsr4InQuuJXp4AuPyZRvU+Zz8La5rk= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-423-nkfSFsBBPBW9bu2aNwGY9Q-1; Mon, 10 Jul 2023 19:04:59 -0400 X-MC-Unique: nkfSFsBBPBW9bu2aNwGY9Q-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3fbdf34184eso31734845e9.1 for ; Mon, 10 Jul 2023 16:04:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030298; x=1691622298; 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=8aPiUq53zYt0kY/8LueF30ebx/Uzyl1lsl0vCB8gSxM=; b=d+i77AyXPZw+it7Red+UqlrbPtSJJd7BxwNYEqvNuPixBtjbPDDvI3ExakXpBSHjlE NVS1G36IUfh/umeVa/pIq1hfQEAtuX1x+xxViaKtJfIKNTD1XwJ20cZ3zK+YAlTQ/jjq Be2iIpywYPXhON/DMaydxdWJaBTxt9OqqDlqcgidFQF/6qiy6wkH3e09kOKD81gDcuJz KAxDfhHDmSgc4ym5y7J+PTcd7GExCPQIShzx2hMgsYBI/rgweYokPHYGlfToJwF9p+3m DOz68CPVk+RNLs2UfWjXb2nzq0ACwmQDUA1kMmqpAxb5Sv2tOj9LDoTdjQHoM5SNY5Hk y5vA== X-Gm-Message-State: ABy/qLZeXWRHbNVWePsfRziSjxVff/4YUpId309zlrlwNMfHFt+cH3gT qHqcr0plWyri5y3TPci9yZAua9X777O//hpD+sbFp65Ej0UMT8oglDPbmaybXsn0fgpA70W1ZrC qFLjSrOGq/ZO5FUXdYnQogNUjC7VkuNOVKuSGt216tI9c0V2gryNgQuueaeK5A87HvYwB X-Received: by 2002:a1c:6a0c:0:b0:3f7:e3dd:8a47 with SMTP id f12-20020a1c6a0c000000b003f7e3dd8a47mr12334816wmc.11.1689030298060; Mon, 10 Jul 2023 16:04:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlFVvGOuEqODhMN1Tl9/PR0I5Eat3/XSZwrW4j8sbEckGFeMDhP2sMi0n24BPdIioJEuA459Rw== X-Received: by 2002:a1c:6a0c:0:b0:3f7:e3dd:8a47 with SMTP id f12-20020a1c6a0c000000b003f7e3dd8a47mr12334790wmc.11.1689030297762; Mon, 10 Jul 2023 16:04:57 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id s21-20020a7bc395000000b003fbc89af035sm946671wmj.17.2023.07.10.16.04.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:57 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9?= Lureau , Gerd Hoffmann , Jason Wang , Stefan Hajnoczi , Viresh Kumar , "Gonglei (Arei)" , virtio-fs@redhat.com Subject: [PULL 52/66] hw/virtio: fix typo in VIRTIO_CONFIG_IRQ_IDX comments Message-ID: <7e8094f0dfd04d4772b65dc92dd087dc86783dc4.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 Fixes: 544f0278af (virtio: introduce macro VIRTIO_CONFIG_IRQ_IDX) Signed-off-by: Alex Bennée Message-Id: <20230710153522.3469097-4-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/display/vhost-user-gpu.c | 4 ++-- hw/net/virtio-net.c | 4 ++-- hw/virtio/vhost-user-fs.c | 4 ++-- hw/virtio/vhost-user-gpio.c | 2 +- hw/virtio/vhost-vsock-common.c | 4 ++-- hw/virtio/virtio-crypto.c | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 543ea92721..e8ee03094e 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -521,7 +521,7 @@ vhost_user_gpu_guest_notifier_pending(VirtIODevice *vdev, int idx) /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ @@ -538,7 +538,7 @@ vhost_user_gpu_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index d51067123b..7102ec4817 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3362,7 +3362,7 @@ static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx) } /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return false */ @@ -3394,7 +3394,7 @@ static void virtio_net_guest_notifier_mask(VirtIODevice *vdev, int idx, } /* *Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index 83fc20e49e..49d699ffc2 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -161,7 +161,7 @@ static void vuf_guest_notifier_mask(VirtIODevice *vdev, int idx, /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ @@ -177,7 +177,7 @@ static bool vuf_guest_notifier_pending(VirtIODevice *vdev, int idx) /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c index d6927b610a..3b013f2d0f 100644 --- a/hw/virtio/vhost-user-gpio.c +++ b/hw/virtio/vhost-user-gpio.c @@ -194,7 +194,7 @@ static void vu_gpio_guest_notifier_mask(VirtIODevice *vdev, int idx, bool mask) /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 321262f6b3..12ea87d7a7 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -129,7 +129,7 @@ static void vhost_vsock_common_guest_notifier_mask(VirtIODevice *vdev, int idx, /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ @@ -146,7 +146,7 @@ static bool vhost_vsock_common_guest_notifier_pending(VirtIODevice *vdev, /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index a6d7e1e8ec..44faf5a522 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -1210,7 +1210,7 @@ static void virtio_crypto_guest_notifier_mask(VirtIODevice *vdev, int idx, /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ @@ -1229,7 +1229,7 @@ static bool virtio_crypto_guest_notifier_pending(VirtIODevice *vdev, int idx) /* * Add the check for configure interrupt, Use VIRTIO_CONFIG_IRQ_IDX -1 - * as the Marco of configure interrupt's IDX, If this driver does not + * as the macro of configure interrupt's IDX, If this driver does not * support, the function will return */ From patchwork Mon Jul 10 23:04:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806092 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=OGoH6s7n; dkim-atps=neutral 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 4R0KSK0k1Sz20ZZ for ; Tue, 11 Jul 2023 09:08:49 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwU-000393-QF; Mon, 10 Jul 2023 19:05:20 -0400 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 1qIzwO-0002jW-Rg for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:12 -0400 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 1qIzwI-0004b4-45 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030303; 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=kvUl4/drtgXBRU9CPKwk/PRPx+0o4aik4MUaSEpTsWY=; b=OGoH6s7nZoIoRySJsq9ijNwdg10El6/UvJg04JXN1NG3++wf/9WaSHNIK/DeF4tCjMDZFF Ht/9EC5TwWzU3cIobhuoR3tmXWf8LrkkcXv+DoexfU2i908wStkygFqTIwsvRm3UPvesLg JJJsoXNAiQOQtfdJ0GkItKU9UrpYumk= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-395-MdwVQz74M_izAgPUrrNMfg-1; Mon, 10 Jul 2023 19:05:02 -0400 X-MC-Unique: MdwVQz74M_izAgPUrrNMfg-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3fbb34f7224so33549135e9.2 for ; Mon, 10 Jul 2023 16:05:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030300; x=1691622300; 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=kvUl4/drtgXBRU9CPKwk/PRPx+0o4aik4MUaSEpTsWY=; b=IQKkT9DgYvWGD3c9CJgR3PkVk8yy4JKUrkV2sfz+m7xaRdhtUWOEzI5auGmCXUYvdU 2GbMbaXK9aZHbi058MpqtIb95GssEBV+EFHo9W24GY5159lvRhvhG+w3q9f4p+wvFThR clz/m7DiSgmyOT6r9HwNhrSaZSdpDNckzXR1HbTpiNW0k/9jdLEbH4ETbDlIlzpJG2Sg w1CUkSEA5osaoV596mlTEBc0KPoiqUnRnWgX2ChiZMuPJwRDIP9i6B2SCDL+bKnYSno0 ZXB63fkjm+8iuhWVIXQXWPCYkR4h3ob2AiW40tm8VqPu66/oQC0VIJ5JqBYVk8sGdKJ9 YV1g== X-Gm-Message-State: ABy/qLZ+lDEOr9LIRqjsVDUmqyjKEhQykh3b9BqMJIn2RpXlWo9FFGAd HN2SNy9SZdH2POQRfSSl5ABWgwAdSZmbfGT+E2pL4WZbCTvOZOVI1NWTgukGtbUqJgTbJOI0rv/ MY5e9ycnkVamRSC6tLoIRYOpnUhpWNzFFxbT1X3zMq3oRPHGF4uVsq9aDbqWPKNEithHv X-Received: by 2002:a1c:f712:0:b0:3fb:e643:1225 with SMTP id v18-20020a1cf712000000b003fbe6431225mr14193474wmh.13.1689030300437; Mon, 10 Jul 2023 16:05:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlEbs3QvCHtKoskpiYyQaZ9EwuExgtcstTr9yKZXW1SzYsFCu5KnwvdAGGAZDMKdn0VmfcBQ+A== X-Received: by 2002:a1c:f712:0:b0:3fb:e643:1225 with SMTP id v18-20020a1cf712000000b003fbe6431225mr14193448wmh.13.1689030300141; Mon, 10 Jul 2023 16:05:00 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id l15-20020a1c790f000000b003fc01f7b415sm9206642wme.39.2023.07.10.16.04.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:04:59 -0700 (PDT) Date: Mon, 10 Jul 2023 19:04:58 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL 53/66] include/hw/virtio: document virtio_notify_config 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 Signed-off-by: Alex Bennée Message-Id: <20230710153522.3469097-5-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 0492d26900..0671989383 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -276,6 +276,13 @@ extern const VMStateInfo virtio_vmstate_info; int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id); +/** + * virtio_notify_config() - signal a change to device config + * @vdev: the virtio device + * + * Assuming the virtio device is up (VIRTIO_CONFIG_S_DRIVER_OK) this + * will trigger a guest interrupt and update the config version. + */ void virtio_notify_config(VirtIODevice *vdev); bool virtio_queue_get_notification(VirtQueue *vq); From patchwork Mon Jul 10 23:05:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806097 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=e5smPRA2; dkim-atps=neutral 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 4R0KSj5t5fz20ZZ for ; Tue, 11 Jul 2023 09:09:09 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwf-0003jf-Ql; Mon, 10 Jul 2023 19:05:30 -0400 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 1qIzwR-000306-OA for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:17 -0400 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 1qIzwJ-0004mQ-II for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030306; 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=Lr23N/kbsARVVr5iF+Jste9DzcTEbZfcy58ahS6NDeE=; b=e5smPRA2/l96QhTLog8h9OPyArZMjwsbfW5DN5S8o0k/xuwfd+6WlhLBRD9L6jyqDso2j6 dLnzlMXqYJ44tQLprzFB1jAZfM/ZCYEOVIHe3peoUWyvSa4A5WPkGd+Cd0onSXFirGUHNs F2thQUcsdEfV0RCC6+t5S260UIFEpC8= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-lG3QSu20NqCodVKUi7eNGA-1; Mon, 10 Jul 2023 19:05:05 -0400 X-MC-Unique: lG3QSu20NqCodVKUi7eNGA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fa9a282fffso29964105e9.1 for ; Mon, 10 Jul 2023 16:05:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030303; x=1691622303; 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=Lr23N/kbsARVVr5iF+Jste9DzcTEbZfcy58ahS6NDeE=; b=eb5pF/Qwhmt4gJ3TCbBSkk2GjjIj468pJ7X3RuBgz/kAYSzELSxOXtI6lx+JSnPq3i ZwKYCrZjKgqKdakLizRmWSRDe+Cqj2s/REzVyjAsclnHgbZIYFS2nSt1pcbreOh+GOg+ +gJZRyjY4NdeIMrXVY4EgKahdXk1HPAN6T2zNrg9KzunKgKK+je582bqAErou4qQthHA /cMgJnWVviYbjDrQhFoOuj191Ya44cQ1BHK7rzODYNhsTVi/NiPoxxMTkonJnZPgVeUe RKdzw0d4+PjRZBtAS7/EFmHR12fyV3crfz3wm5p0rE62ZysuPlWkHif/plRN0lkiEGUG Mmpw== X-Gm-Message-State: ABy/qLaVj1EjZ4126OJalhzKpbUHfnWEGGOdKZnuUCWwQ85Xm+QU4CZO Pl9X76GGN+8z6xddVbhfWzP5rf8xUkVV3ezOYRz9eRq18npRqtLN9wvT5chlxMHyqzu464CdWem T2r6mLFySuRdPW2mDRd06m2ZpFuGyAirTtvcm2N46eBW1je/g517+dIGq30jy3HRPUzl0 X-Received: by 2002:a5d:4d4d:0:b0:313:ed1d:39d5 with SMTP id a13-20020a5d4d4d000000b00313ed1d39d5mr11259275wru.35.1689030303517; Mon, 10 Jul 2023 16:05:03 -0700 (PDT) X-Google-Smtp-Source: APBJJlFDJU2buaWcSt8ZU/tuCkUzqbYAWhnEiATIyHNBl4kgNTqJEjaYitvNy1JjG7XCLsoaToF63w== X-Received: by 2002:a5d:4d4d:0:b0:313:ed1d:39d5 with SMTP id a13-20020a5d4d4d000000b00313ed1d39d5mr11259264wru.35.1689030303312; Mon, 10 Jul 2023 16:05:03 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id q10-20020adfdfca000000b003144b95e1ecsm565441wrn.93.2023.07.10.16.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:05:02 -0700 (PDT) Date: Mon, 10 Jul 2023 19:05:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL 54/66] include/hw/virtio: add kerneldoc for virtio_init Message-ID: <3b6256c2c57061c365cfad7857e12fd8d15ca3c8.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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 Signed-off-by: Alex Bennée Message-Id: <20230710153522.3469097-6-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 0671989383..631490bda4 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -219,6 +219,12 @@ struct VirtioDeviceClass { void virtio_instance_init_common(Object *proxy_obj, void *data, size_t vdev_size, const char *vdev_name); +/** + * virtio_init() - initialise the common VirtIODevice structure + * @vdev: pointer to VirtIODevice + * @device_id: the VirtIO device ID (see virtio_ids.h) + * @config_size: size of the config space + */ void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_size); void virtio_cleanup(VirtIODevice *vdev); From patchwork Mon Jul 10 23:05:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806110 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=HVD60UHH; dkim-atps=neutral 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 4R0KTJ56MFz20ZZ for ; Tue, 11 Jul 2023 09:09:40 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwi-00049C-3v; Mon, 10 Jul 2023 19:05:32 -0400 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 1qIzwe-0003ZA-Ed for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:28 -0400 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 1qIzwP-0004oi-Re for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030312; 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=6owJwf2FkV6CUX/2hjmF+Amv1PF8cnNyFJlq3/wOoXQ=; b=HVD60UHH9nAcwMaoqc0sX0nl22LcovFePQrzwuaoZsUsnh2N135mFJQ5nyMQuEHNbQ3i82 kGFN3/41LugFkwXoix1VzHeXZWAmq+NbfoUbouAalNXNlAelsjsxA1EiWYf2ELMuPTN/G1 4qV5hEgsIKfc8kOcamU/bqLAp/ExOCk= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-153-OedXWG-nMO6ol65hFNEDpg-1; Mon, 10 Jul 2023 19:05:08 -0400 X-MC-Unique: OedXWG-nMO6ol65hFNEDpg-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3141c6f4173so2720879f8f.1 for ; Mon, 10 Jul 2023 16:05:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030306; x=1691622306; 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=6owJwf2FkV6CUX/2hjmF+Amv1PF8cnNyFJlq3/wOoXQ=; b=fmC8WpDUgGbNz9JZl2Zmo6/kXbY51TgsIVIfBnH6/18FBudEki7YGh6OCzR8G7WfSf jN2B9d33XRrD2Iek0qyEswbDK/lsdacwvvRxAYDQbqOVwOQaMF++JwTsRIpB16WWEll9 f4e1h+V2Mple7a95lpjmn0MqbTw3aCEFwhEyPRX1WByvShcRI1P2fgVFFgVH7chmwGF7 pWLP8TWAP5EOGBcS1626Fo4at9gW/lWm7lkOWOUv0s9FFJg2oIsmJiaSHroVIIKjq+JT uGloPlVzjqXHOXm+0PQs8FtLSkTjVniNPtUojtAJEod0tFO2o7PTrwzHww7C1QNnU81j qEIA== X-Gm-Message-State: ABy/qLY8gEdbEJyUdnaiDKWmqB+ThlzVXCYr59RVi3s/JV+GFPuiqL+V Dj70mk/HzIJ/wnfVDCBD53cEDLPgq7E6BbS1bZNxCMUvMfpst9ef6hhC3BFBztues0ceL6jgB3D o/y0E1A0uCWPjxzth7AdvrYKRWU9sAIdJ9CwunoYQGub4/zA4WcDfQBQ5yEl3kgdSq/HB X-Received: by 2002:adf:ec0e:0:b0:313:e57b:e96d with SMTP id x14-20020adfec0e000000b00313e57be96dmr11872738wrn.36.1689030305907; Mon, 10 Jul 2023 16:05:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlFt5rvvgvkeRDAg22sUJmuXzlGhQ2HP2/ZnZYrWG1YNLWdE7ak+ZMIX2kIpW8x8iOnIhiH0Aw== X-Received: by 2002:adf:ec0e:0:b0:313:e57b:e96d with SMTP id x14-20020adfec0e000000b00313e57be96dmr11872727wrn.36.1689030305703; Mon, 10 Jul 2023 16:05:05 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id c3-20020a5d4cc3000000b00311299df211sm578797wrt.77.2023.07.10.16.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:05:05 -0700 (PDT) Date: Mon, 10 Jul 2023 19:05:03 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL 55/66] include/hw/virtio: document some more usage of notifiers Message-ID: <661dee7bd08dd93d15b898d43821bb46b2aa422c.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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 document some more of the core VirtIODevice structure. Signed-off-by: Alex Bennée Message-Id: <20230710153522.3469097-7-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 631490bda4..c8f72850bc 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -150,10 +150,18 @@ struct VirtIODevice VMChangeStateEntry *vmstate; char *bus_name; uint8_t device_endian; + /** + * @user_guest_notifier_mask: gate usage of ->guest_notifier_mask() callback. + * This is used to suppress the masking of guest updates for + * vhost-user devices which are asynchronous by design. + */ bool use_guest_notifier_mask; AddressSpace *dma_as; QLIST_HEAD(, VirtQueue) *vector_queues; QTAILQ_ENTRY(VirtIODevice) next; + /** + * @config_notifier: the event notifier that handles config events + */ EventNotifier config_notifier; bool device_iotlb_enabled; }; From patchwork Mon Jul 10 23:05:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806105 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=A6n4A6jQ; dkim-atps=neutral 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 4R0KT93B8jz20bx for ; Tue, 11 Jul 2023 09:09:33 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwi-0004Fe-TL; Mon, 10 Jul 2023 19:05:32 -0400 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 1qIzwU-0003Bk-Gl for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:18 -0400 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 1qIzwP-0004od-9W for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030312; 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=U2PQIgfh7c5FIKJQdtrKt4BlDrgB/tEbncYB4sm69iQ=; b=A6n4A6jQJjs2YqQj57/wm2/kXwCBf4Sxpev4rnXy2Nc7JoVYk6UwGfK2MFAYAbHVPt+8qF 1bTaUL8AXf+IFIZDVTnuUpiJU+VdJdnVepyYKvcPJMV9vtaimy37tqo2z/DlQRHYvgFzoM ius8+bf/XEMd7JorEjcu/29rkaUs3sI= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-84-BVjsuUgNOgirOgo02dnVCg-1; Mon, 10 Jul 2023 19:05:11 -0400 X-MC-Unique: BVjsuUgNOgirOgo02dnVCg-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fc07d4c2f4so18892175e9.1 for ; Mon, 10 Jul 2023 16:05:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030309; x=1691622309; 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=U2PQIgfh7c5FIKJQdtrKt4BlDrgB/tEbncYB4sm69iQ=; b=OLNidRdROyfIRtWO8Jvgv2Fqt0bbqszG36IyzHFd2RtnsU2yzacWUTpLe3kxbB7vgT GHR4/nwqBQFz1QrCpjMyc/3scu7NqBuLXQwWksy9Q9o0AelTr1Jku5jZ+KQAeEmNzczq T3UPJ8w2+2RDkF/YF54WnQ8/xnMdjFfB+k6460XwZinTmcih8bLzPn8idYKzRdP4L0QL mm9+7EuCMOb2CPIwtadsQC0igRc09B150ka+8bdNWOYLzGR+lKWUXyPk1wRaFJ3fpK7Z j4vtJq/SVsU8VCnyzLUeQ5jf0+TIj+GukUoPozaRQ60vxyKWmCTbA+VWXaD/VYRWtmnL eeYg== X-Gm-Message-State: ABy/qLYjvD9ru+B327vEeJ0ykunLFxSpt8TX+Uzk/3928SENdGhuRY78 Tow9EUJQWnDPZsMnSWx4hlqkeKBqE5H/XIhw9ZILxtt8xrgGmsPBlYvcqzer32zGzwc8PtPe7cx bAKfgYoCpP3IKDhXiCZ7Jx4ndN4S7KKKNXfXR8hiK7httVI4DOZ+CpnSKhzjfNmHQNjos X-Received: by 2002:a1c:6a03:0:b0:3fb:a576:3212 with SMTP id f3-20020a1c6a03000000b003fba5763212mr13842120wmc.39.1689030309257; Mon, 10 Jul 2023 16:05:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlFJ9JAYYk0p9XumFVmMAXeFRhko6eGEblXKiHMmjOKTpxyxY83XbOcN9+Y0A17ZCM1D86e2kg== X-Received: by 2002:a1c:6a03:0:b0:3fb:a576:3212 with SMTP id f3-20020a1c6a03000000b003fba5763212mr13842093wmc.39.1689030308913; Mon, 10 Jul 2023 16:05:08 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id t25-20020a1c7719000000b003fbfef555d2sm10655077wmi.23.2023.07.10.16.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:05:08 -0700 (PDT) Date: Mon, 10 Jul 2023 19:05:06 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Ani Sinha , Marcel Apfelbaum , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , qemu-block@nongnu.org Subject: [PULL 56/66] pcie: Use common ARI next function number Message-ID: <445416e3010a2525c577d692921979a64d88a998.1689030052.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: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=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=no 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 Currently the only implementers of ARI is SR-IOV devices, and they behave similar. Share the ARI next function number. Signed-off-by: Akihiko Odaki Reviewed-by: Ani Sinha Message-Id: <20230710153838.33917-2-akihiko.odaki@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/pcie_sriov.txt | 4 ++-- include/hw/pci/pcie.h | 2 +- hw/net/igb.c | 2 +- hw/net/igbvf.c | 2 +- hw/nvme/ctrl.c | 2 +- hw/pci/pcie.c | 4 +++- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/pcie_sriov.txt b/docs/pcie_sriov.txt index 7eff7f2703..a47aad0bfa 100644 --- a/docs/pcie_sriov.txt +++ b/docs/pcie_sriov.txt @@ -48,7 +48,7 @@ setting up a BAR for a VF. ... int ret = pcie_endpoint_cap_init(d, 0x70); ... - pcie_ari_init(d, 0x100, 1); + pcie_ari_init(d, 0x100); ... /* Add and initialize the SR/IOV capability */ @@ -78,7 +78,7 @@ setting up a BAR for a VF. ... int ret = pcie_endpoint_cap_init(d, 0x60); ... - pcie_ari_init(d, 0x100, 1); + pcie_ari_init(d, 0x100); ... memory_region_init(mr, ... ) pcie_sriov_vf_register_bar(d, bar_nr, mr); diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 51ab57bc3c..11f5a91bbb 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -135,7 +135,7 @@ void pcie_sync_bridge_lnk(PCIDevice *dev); void pcie_acs_init(PCIDevice *dev, uint16_t offset); void pcie_acs_reset(PCIDevice *dev); -void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn); +void pcie_ari_init(PCIDevice *dev, uint16_t offset); void pcie_dev_ser_num_init(PCIDevice *dev, uint16_t offset, uint64_t ser_num); void pcie_ats_init(PCIDevice *dev, uint16_t offset, bool aligned); diff --git a/hw/net/igb.c b/hw/net/igb.c index 1c989d7677..8ff832acfc 100644 --- a/hw/net/igb.c +++ b/hw/net/igb.c @@ -431,7 +431,7 @@ static void igb_pci_realize(PCIDevice *pci_dev, Error **errp) hw_error("Failed to initialize AER capability"); } - pcie_ari_init(pci_dev, 0x150, 1); + pcie_ari_init(pci_dev, 0x150); pcie_sriov_pf_init(pci_dev, IGB_CAP_SRIOV_OFFSET, TYPE_IGBVF, IGB_82576_VF_DEV_ID, IGB_MAX_VF_FUNCTIONS, IGB_MAX_VF_FUNCTIONS, diff --git a/hw/net/igbvf.c b/hw/net/igbvf.c index 284ea61184..d55e1e8a6a 100644 --- a/hw/net/igbvf.c +++ b/hw/net/igbvf.c @@ -270,7 +270,7 @@ static void igbvf_pci_realize(PCIDevice *dev, Error **errp) hw_error("Failed to initialize AER capability"); } - pcie_ari_init(dev, 0x150, 1); + pcie_ari_init(dev, 0x150); } static void igbvf_pci_uninit(PCIDevice *dev) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 355668bdf8..8e8e870b9a 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8120,7 +8120,7 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pci_dev, Error **errp) pcie_endpoint_cap_init(pci_dev, 0x80); pcie_cap_flr_init(pci_dev); if (n->params.sriov_max_vfs) { - pcie_ari_init(pci_dev, 0x100, 1); + pcie_ari_init(pci_dev, 0x100); } /* add one to max_ioqpairs to account for the admin queue pair */ diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 763f65c528..6075ff5556 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1039,8 +1039,10 @@ void pcie_sync_bridge_lnk(PCIDevice *bridge_dev) */ /* ARI */ -void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn) +void pcie_ari_init(PCIDevice *dev, uint16_t offset) { + uint16_t nextfn = 1; + pcie_add_capability(dev, PCI_EXT_CAP_ID_ARI, PCI_ARI_VER, offset, PCI_ARI_SIZEOF); pci_set_long(dev->config + offset + PCI_ARI_CAP, (nextfn & 0xff) << 8); From patchwork Mon Jul 10 23:05:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806086 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=NjVpQO4A; dkim-atps=neutral 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 4R0KRs2TrMz20ZZ for ; Tue, 11 Jul 2023 09:08:25 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwe-0003YZ-J9; Mon, 10 Jul 2023 19:05:28 -0400 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 1qIzwU-0003Bl-HH for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:18 -0400 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 1qIzwS-0004pO-T7 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030316; 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=epa7wwkAgwMEyNmrkfxcZV2wLqeDQswBEeLehQ/hP44=; b=NjVpQO4ArYtOGZbsbw1uIACboxw7X9OE/tmzrljckP9NmQ8cQTozJ4cfooQVzjL+JNJ+El +T6j4fXbHpXHNJqb2Z9X5u7pA/qK7jNIWKUteKWB4g5BcQL+brdddR7vj4kRcdoJt++Nqr oEJd4nhEl9jKOO0t2r/Qb4Ik2/K/KLU= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-180-oqsZ6bI8PUCt0SJP-_obtQ-1; Mon, 10 Jul 2023 19:05:14 -0400 X-MC-Unique: oqsZ6bI8PUCt0SJP-_obtQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fc00d7d62cso21843865e9.2 for ; Mon, 10 Jul 2023 16:05:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030312; x=1691622312; 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=epa7wwkAgwMEyNmrkfxcZV2wLqeDQswBEeLehQ/hP44=; b=fPZ0RLgRWwxcwTVW4HFeOI8xzLPkkDp5zKRwCfh9wPeugwTBSu0JhFJRq/lKtgfs7z 0lReIhIEjwqwpcM3yVW7/Mi8kPj3Fhwma7bKuUEf+ODaS0tO6HGdzO4t0aCNLGq3Tr20 uvn8fH28KCg8M3n1SUtLsxKayPbXXSeWgwgaxQKUag5UwMfXubaP3vmYzWqDrHfgGIN9 /ZxiA3ltyhkieFhrvgjKZJ4TzP9y7ENGZfQH8L08kPE17B1yMiDOT3Eopb6MaxLPhJMY pRI4f0dEqlMJxXJzQivB45VQEoUoT86SxAVn8hAR5UzpXH70hULLmSYHd7o5luTHVT71 TjtA== X-Gm-Message-State: ABy/qLauYp3SDmnFUzmP9+yJ1XAnpN1mwzuVybPnlU88U2dLuYl4moSA 5SaJr/78YXjFgovbwO1DYbvNTkNjFXAV/G0klMGD4j+K2rivO5/C4eKcrhZl53KAX/rQPk0PdtC 3jxXIxrgLLhfqjSjfRme56Cljf/5UAMPXoYFzhrRTTmeJZDbJ3qMd2fyi8Az1O54ZDX5l X-Received: by 2002:a7b:c7d9:0:b0:3f5:146a:c79d with SMTP id z25-20020a7bc7d9000000b003f5146ac79dmr12859754wmk.15.1689030312203; Mon, 10 Jul 2023 16:05:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlFxMBKJXilRpzMNn6lh3y5L0zn+yCSFEnhOgpIz4IUJcqtOQyqAl5Jkv+0ifeqDymjR3jKkGA== X-Received: by 2002:a7b:c7d9:0:b0:3f5:146a:c79d with SMTP id z25-20020a7bc7d9000000b003f5146ac79dmr12859732wmk.15.1689030311889; Mon, 10 Jul 2023 16:05:11 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id v10-20020a05600c470a00b003f9b3829269sm21830452wmo.2.2023.07.10.16.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:05:11 -0700 (PDT) Date: Mon, 10 Jul 2023 19:05:09 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Ani Sinha , Eduardo Habkost , Marcel Apfelbaum , Philippe =?utf-8?q?Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang Subject: [PULL 57/66] pcie: Specify 0 for ARI next function numbers Message-ID: <7c228c5f3301113ffd7cfee7f982e7ae04c8ffda.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Akihiko Odaki The current implementers of ARI are all SR-IOV devices. The ARI next function number field is undefined for VF according to PCI Express Base Specification Revision 5.0 Version 1.0 section 9.3.7.7. The PF still requires some defined value so end the linked list formed with the field by specifying 0 as required for any ARI implementation according to section 7.8.7.2. For migration, the field will keep having 1 as its value on the old QEMU machine versions. Fixes: 2503461691 ("pcie: Add some SR/IOV API documentation in docs/pcie_sriov.txt") Fixes: 44c2c09488 ("hw/nvme: Add support for SR-IOV") Fixes: 3a977deebe ("Intrdocue igb device emulation") Signed-off-by: Akihiko Odaki Reviewed-by: Ani Sinha Message-Id: <20230710153838.33917-3-akihiko.odaki@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 2 ++ hw/core/machine.c | 1 + hw/pci/pci.c | 2 ++ hw/pci/pcie.c | 2 +- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index ab2bd65a3a..abdc1ef103 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -209,6 +209,8 @@ enum { QEMU_PCIE_CAP_CXL = (1 << QEMU_PCIE_CXL_BITNR), #define QEMU_PCIE_ERR_UNC_MASK_BITNR 11 QEMU_PCIE_ERR_UNC_MASK = (1 << QEMU_PCIE_ERR_UNC_MASK_BITNR), +#define QEMU_PCIE_ARI_NEXTFN_1_BITNR 12 + QEMU_PCIE_ARI_NEXTFN_1 = (1 << QEMU_PCIE_ARI_NEXTFN_1_BITNR), }; typedef struct PCIINTxRoute { diff --git a/hw/core/machine.c b/hw/core/machine.c index 46f8f9a2b0..f0d35c6401 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -41,6 +41,7 @@ GlobalProperty hw_compat_8_0[] = { { "migration", "multifd-flush-after-each-section", "on"}, + { TYPE_PCI_DEVICE, "x-pcie-ari-nextfn-1", "on" }, }; const size_t hw_compat_8_0_len = G_N_ELEMENTS(hw_compat_8_0); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 4b14f31859..784c02a182 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -83,6 +83,8 @@ static Property pci_props[] = { DEFINE_PROP_UINT32("acpi-index", PCIDevice, acpi_index, 0), DEFINE_PROP_BIT("x-pcie-err-unc-mask", PCIDevice, cap_present, QEMU_PCIE_ERR_UNC_MASK_BITNR, true), + DEFINE_PROP_BIT("x-pcie-ari-nextfn-1", PCIDevice, cap_present, + QEMU_PCIE_ARI_NEXTFN_1_BITNR, false), DEFINE_PROP_END_OF_LIST() }; diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 6075ff5556..6db0cf69cd 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1041,7 +1041,7 @@ void pcie_sync_bridge_lnk(PCIDevice *bridge_dev) /* ARI */ void pcie_ari_init(PCIDevice *dev, uint16_t offset) { - uint16_t nextfn = 1; + uint16_t nextfn = dev->cap_present & QEMU_PCIE_ARI_NEXTFN_1 ? 1 : 0; pcie_add_capability(dev, PCI_EXT_CAP_ID_ARI, PCI_ARI_VER, offset, PCI_ARI_SIZEOF); From patchwork Mon Jul 10 23:05:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=EZZXErj7; dkim-atps=neutral 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 4R0KTJ0Syrz20bx for ; Tue, 11 Jul 2023 09:09:40 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwi-0004Fm-Tn; Mon, 10 Jul 2023 19:05:32 -0400 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 1qIzwW-0003Ce-P9 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:22 -0400 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 1qIzwT-0004q3-Ve for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030317; 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=iZ/Pm5db16b2YRddidlqV+DPQbQWoo36WZiyW4cPnzI=; b=EZZXErj7G54yluCUOUxs9XqW9zc9siD60PRAVzn09NjCh/5umnuGBLlkpLs28Q9IyjArcX 211J0Y/bgxnSsUiav/AHtdiOuCvzY0gnQwNrptnus1Nlfpxx5cvvZ0IR24COMeoPgiqeIb jaX89IAXV7ahWkYHmlUsW8Tm8/X1kQQ= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-13-DXJDY6boMHCZAH6faCv92A-1; Mon, 10 Jul 2023 19:05:16 -0400 X-MC-Unique: DXJDY6boMHCZAH6faCv92A-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fbcae05906so33522485e9.3 for ; Mon, 10 Jul 2023 16:05:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030315; x=1691622315; 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=iZ/Pm5db16b2YRddidlqV+DPQbQWoo36WZiyW4cPnzI=; b=LQMpI7AB9zRxiVOZuJoLDEJxdyc+pJJkUPB1K7r3QvIq8PWXJyWPehx2EyUcHvwy1s ekfsTzLWVQQ9QFIhiKd156parE86KeAVWx34IrcqW3pTQGer+f4sJn0v2JjfIXQQ3vmT bPngD2dfv/j54AY2DLyA7cmy9v8gkzot2JHRuzZ0fRvpvKQ+QaXkfSAsphRFOpf8Y2Wt 8vMlcrraf1oT9xYP/ELhdYZs+UikkDg6DBoSvWpARsE6BdFqujxuuIFOv/ku41R3GRUU agxq+iE3nDN+5KWC2DTw082r2JbJFrltC0I2wXVS4c6v3ko16FeKnfEYgo+d9YVzG42n gxkg== X-Gm-Message-State: ABy/qLa0wEAFx/aoFWRNH7u3YV2hMUc3To90S+djNXAdZXa1upwYEcWy bgMM/vAaXK8dIFYrSkUmogSXDf5iikSxLa10wGTqi0hQg7rkEsfBVtqc9xLzUsx4y1G9erPUuYM 8SEriSj/XqtCoW28ppCEeJhWhSNMH2/XyGrTLxE8euEs955+aD14eDe5oOMJOWdJwqAmr X-Received: by 2002:a1c:7502:0:b0:3f8:fc96:6bfd with SMTP id o2-20020a1c7502000000b003f8fc966bfdmr13196649wmc.17.1689030314936; Mon, 10 Jul 2023 16:05:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlFBe2TYTQ72ocKMNMmaT0+ogCql+XXA1vhn6e/WELtDntcREPGdnDknKzWc8PeYTAN4Ybr4iw== X-Received: by 2002:a1c:7502:0:b0:3f8:fc96:6bfd with SMTP id o2-20020a1c7502000000b003f8fc966bfdmr13196628wmc.17.1689030314576; Mon, 10 Jul 2023 16:05:14 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id f19-20020a7bcc13000000b003fa973e6612sm11486226wmh.44.2023.07.10.16.05.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:05:14 -0700 (PDT) Date: Mon, 10 Jul 2023 19:05:12 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Jason Wang Subject: [PULL 58/66] vdpa: Use iovec for vhost_vdpa_net_load_cmd() Message-ID: <2848c6aa7536fb48a57f38dabed1dce97fb45c6f.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Hawkins Jiawei According to VirtIO standard, "The driver MUST follow the VIRTIO_NET_CTRL_MAC_TABLE_SET command by a le32 number, followed by that number of non-multicast MAC addresses, followed by another le32 number, followed by that number of multicast addresses." Considering that these data is not stored in contiguous memory, this patch refactors vhost_vdpa_net_load_cmd() to accept scattered data, eliminating the need for an addtional data copy or packing the data into s->cvq_cmd_out_buffer outside of vhost_vdpa_net_load_cmd(). Signed-off-by: Hawkins Jiawei Message-Id: <3482cc50eebd13db4140b8b5dec9d0cc25b20b1b.1688743107.git.yin31149@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 5542b47a8f..e192217a96 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -626,29 +626,38 @@ static ssize_t vhost_vdpa_net_cvq_add(VhostVDPAState *s, size_t out_len, } static ssize_t vhost_vdpa_net_load_cmd(VhostVDPAState *s, uint8_t class, - uint8_t cmd, const void *data, - size_t data_size) + uint8_t cmd, const struct iovec *data_sg, + size_t data_num) { const struct virtio_net_ctrl_hdr ctrl = { .class = class, .cmd = cmd, }; + size_t data_size = iov_size(data_sg, data_num); assert(data_size < vhost_vdpa_net_cvq_cmd_page_len() - sizeof(ctrl)); + /* pack the CVQ command header */ memcpy(s->cvq_cmd_out_buffer, &ctrl, sizeof(ctrl)); - memcpy(s->cvq_cmd_out_buffer + sizeof(ctrl), data, data_size); - return vhost_vdpa_net_cvq_add(s, sizeof(ctrl) + data_size, + /* pack the CVQ command command-specific-data */ + iov_to_buf(data_sg, data_num, 0, + s->cvq_cmd_out_buffer + sizeof(ctrl), data_size); + + return vhost_vdpa_net_cvq_add(s, data_size + sizeof(ctrl), sizeof(virtio_net_ctrl_ack)); } static int vhost_vdpa_net_load_mac(VhostVDPAState *s, const VirtIONet *n) { if (virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_CTRL_MAC_ADDR)) { + const struct iovec data = { + .iov_base = (void *)n->mac, + .iov_len = sizeof(n->mac), + }; ssize_t dev_written = vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_MAC, VIRTIO_NET_CTRL_MAC_ADDR_SET, - n->mac, sizeof(n->mac)); + &data, 1); if (unlikely(dev_written < 0)) { return dev_written; } @@ -671,9 +680,13 @@ static int vhost_vdpa_net_load_mq(VhostVDPAState *s, } mq.virtqueue_pairs = cpu_to_le16(n->curr_queue_pairs); + const struct iovec data = { + .iov_base = &mq, + .iov_len = sizeof(mq), + }; dev_written = vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_MQ, - VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET, &mq, - sizeof(mq)); + VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET, + &data, 1); if (unlikely(dev_written < 0)) { return dev_written; } @@ -712,9 +725,13 @@ static int vhost_vdpa_net_load_offloads(VhostVDPAState *s, } offloads = cpu_to_le64(n->curr_guest_offloads); + const struct iovec data = { + .iov_base = &offloads, + .iov_len = sizeof(offloads), + }; dev_written = vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_GUEST_OFFLOADS, VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET, - &offloads, sizeof(offloads)); + &data, 1); if (unlikely(dev_written < 0)) { return dev_written; } From patchwork Mon Jul 10 23:05:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806084 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=G8InDX2I; dkim-atps=neutral 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 4R0KRp2x28z20ZZ for ; Tue, 11 Jul 2023 09:08:22 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwf-0003h0-IG; Mon, 10 Jul 2023 19:05:29 -0400 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 1qIzwY-0003Cr-2A for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:23 -0400 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 1qIzwW-0004qg-K5 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030320; 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=9kWFuRvPt5D6YBoQYP7DIO/LugHsQbLIi6mRC8bw7F8=; b=G8InDX2Ik1gSkZEgn+tEwCiDQAynzyqqbAcI9UDcS5OsIhl0BKkocyGjmb3V1Pa31J32ZA H6dvp52vbYebO5bTi3RIaKoUdraVCHltj3S2Ne70jA/z566PkHK40XMzMOLQjmBbbvpymv Q7uI9ms8Q4yAkIoFP8/upmm9VwdeJRk= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-0vyH7E1uO-yVrluR34qvKA-1; Mon, 10 Jul 2023 19:05:18 -0400 X-MC-Unique: 0vyH7E1uO-yVrluR34qvKA-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3141325af78so3112140f8f.3 for ; Mon, 10 Jul 2023 16:05:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030317; x=1691622317; 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=9kWFuRvPt5D6YBoQYP7DIO/LugHsQbLIi6mRC8bw7F8=; b=EIhiSU2/w0cJNUFkmUVejn5YK6LWtiOe68ew7PSvWE7/wezqmPvS1GtUd+UUf2/k8H 6DVVmNjOpj6JUeyMRoNmCRdqq4ID31qyQUYkjKF1YH5JoTpNvFoNFbqaYZyT7wAc1nAX eN2KMvLiJjayYLIW/NMJ3Cwm4eUoZk02OdnUN/3DujM0K3OSLwsuDow4TsNWIkGgmG6w NSX9QmtBOWMRKivE9bQrcMv7zVSLM3uqySJtSfxW2xvuyAjXzenCg7Kk7LCKCWR4H0oD AL40PcwSXYiSpViVTADK/H4ZpCH7jvo44jjYE6QzCDLp27irb0GKSYnE8bgOyAdXyNWy fEFw== X-Gm-Message-State: ABy/qLZtd4MmKKq2uf+Y+dXrMSPGPQQ8hbkc33W3jTWL+TW1NdvgBZrF VPZmLr1iE4ZUd9QKDzlyE0PMzAae7ys1wYa6tBaurpWyiLKxN5TiYQ3TZuhdY143JM8PaupYnvk rsHBXITxF18XLrTJVAINM/dy39NLJ5x4kRWkv6LTs95CCTAVnIBt3YpvCq+0d6JJYpHao X-Received: by 2002:a5d:540c:0:b0:315:8f4f:81b8 with SMTP id g12-20020a5d540c000000b003158f4f81b8mr6805398wrv.50.1689030317166; Mon, 10 Jul 2023 16:05:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlE0kkayp1aiYW5byVitcUXZE0fUC8zhW6605czqEoKzdx8UVBo77zwf6P+7BuMK2vB49D3dew== X-Received: by 2002:a5d:540c:0:b0:315:8f4f:81b8 with SMTP id g12-20020a5d540c000000b003158f4f81b8mr6805382wrv.50.1689030316927; Mon, 10 Jul 2023 16:05:16 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id i10-20020a5d558a000000b0030fb828511csm563401wrv.100.2023.07.10.16.05.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:05:16 -0700 (PDT) Date: Mon, 10 Jul 2023 19:05:14 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Jason Wang Subject: [PULL 59/66] vdpa: Restore MAC address filtering state Message-ID: <0ddcecb8f2e14b5aa6781ae3403ffa2ac4b25197.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Hawkins Jiawei This patch refactors vhost_vdpa_net_load_mac() to restore the MAC address filtering state at device's startup. Signed-off-by: Hawkins Jiawei Message-Id: <4b9550c14bc8c98c8f48e04dbf3d3ac41489d3fd.1688743107.git.yin31149@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index e192217a96..126afbc7a5 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -666,6 +666,58 @@ static int vhost_vdpa_net_load_mac(VhostVDPAState *s, const VirtIONet *n) } } + /* + * According to VirtIO standard, "The device MUST have an + * empty MAC filtering table on reset.". + * + * Therefore, there is no need to send this CVQ command if the + * driver also sets an empty MAC filter table, which aligns with + * the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + if (!virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_CTRL_RX) || + n->mac_table.in_use == 0) { + return 0; + } + + uint32_t uni_entries = n->mac_table.first_multi, + uni_macs_size = uni_entries * ETH_ALEN, + mul_entries = n->mac_table.in_use - uni_entries, + mul_macs_size = mul_entries * ETH_ALEN; + struct virtio_net_ctrl_mac uni = { + .entries = cpu_to_le32(uni_entries), + }; + struct virtio_net_ctrl_mac mul = { + .entries = cpu_to_le32(mul_entries), + }; + const struct iovec data[] = { + { + .iov_base = &uni, + .iov_len = sizeof(uni), + }, { + .iov_base = n->mac_table.macs, + .iov_len = uni_macs_size, + }, { + .iov_base = &mul, + .iov_len = sizeof(mul), + }, { + .iov_base = &n->mac_table.macs[uni_macs_size], + .iov_len = mul_macs_size, + }, + }; + ssize_t dev_written = vhost_vdpa_net_load_cmd(s, + VIRTIO_NET_CTRL_MAC, + VIRTIO_NET_CTRL_MAC_TABLE_SET, + data, ARRAY_SIZE(data)); + if (unlikely(dev_written < 0)) { + return dev_written; + } + if (*s->status != VIRTIO_NET_OK) { + return -EIO; + } + return 0; } From patchwork Mon Jul 10 23:05:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806113 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=Iju3N0gz; dkim-atps=neutral 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 4R0KTQ2X3Tz20ZZ for ; Tue, 11 Jul 2023 09:09:46 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwh-00048o-Vw; Mon, 10 Jul 2023 19:05:32 -0400 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 1qIzwc-0003Q8-8d for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:26 -0400 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 1qIzwZ-0004rQ-Gt for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030322; 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=0+kiq79YBkXbXg7G5M89/OfLyf3rOZ0UzS1jeywjCIc=; b=Iju3N0gzl9xxb5iIu3Le/378KXSvrG7/GQqaTxm+s3tVvBz2DozxqOXjka0OLvjUrNfehc ecvGANV0UIhuYJbrFvyTJTl3tC49koplUL3HcGhdeZP1yj08P5pQzrqCppeBeHgsQcGDaW 1Hq2b4yRCbZ7ByblIKawzWmH3+EDZ3I= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-363-qgeD9gsjMQKAx0xBlp4ktw-1; Mon, 10 Jul 2023 19:05:21 -0400 X-MC-Unique: qgeD9gsjMQKAx0xBlp4ktw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3faabd8fd33so31736565e9.0 for ; Mon, 10 Jul 2023 16:05:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030319; x=1691622319; 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=0+kiq79YBkXbXg7G5M89/OfLyf3rOZ0UzS1jeywjCIc=; b=Xj6zUDYtU7x0k333AqwiAP5/lu57/JxmNytcsCsvG8r28/CRtUMIyeGqiKOOnLhO4M KcPP4AeOydrJjMBBlnk2AT286PFu/uDpzyLMPyMwk4rXTwRsZrouaCP24+r/2jihF8fq DFgwrbeguVD/fixZ56ahYN8gj2DPpw1luMifDFtbIvNyHMUYgSasLkGk8NbZy+ZUpQ6J 5zx1GqfuNuxJY1+KHh92Mgtb41EtS+xzUXq79pK5GWM9VY+scMXeZfF1ABU7FeoZAYFI XWz6dAVd8B6Pb7137FYN6E9mSL/1jzOlPlEu/C+pIP/rC1S6QCs7bGp43674b7D3Aull emMQ== X-Gm-Message-State: ABy/qLaFSd8PqPpGmF12QVJkPRmegT2vGJQxMUq2kCe1E6vzFf4LCn4X bpJUyNLKnXZcN9qjIT8yxjrXO8RqYueoV+/mFrvmgFxecu8L8AmeJtspBTW6yt2EVzcUAqWsmzZ sqb2SoJWYB6dRZX3Iev5qdl2oZdx26CoObEwqUmBWhbYGV4ylFANuzmw2PchB0Rx+N/r2 X-Received: by 2002:a1c:770c:0:b0:3fc:e7d:ca57 with SMTP id t12-20020a1c770c000000b003fc0e7dca57mr4873033wmi.2.1689030319578; Mon, 10 Jul 2023 16:05:19 -0700 (PDT) X-Google-Smtp-Source: APBJJlE5C3g2jyvPe9+3XBil7ypmreD1JIqn5tUfHns9zVOxOc00Ow65kMtswE0Xp3/3srGkeuLcZg== X-Received: by 2002:a1c:770c:0:b0:3fc:e7d:ca57 with SMTP id t12-20020a1c770c000000b003fc0e7dca57mr4873017wmi.2.1689030319293; Mon, 10 Jul 2023 16:05:19 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id j11-20020a056000124b00b0031417fd473csm583481wrx.78.2023.07.10.16.05.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:05:18 -0700 (PDT) Date: Mon, 10 Jul 2023 19:05:17 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Jason Wang Subject: [PULL 60/66] vdpa: Restore packet receive filtering state relative with _F_CTRL_RX feature 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Hawkins Jiawei This patch introduces vhost_vdpa_net_load_rx_mode() and vhost_vdpa_net_load_rx() to restore the packet receive filtering state in relation to VIRTIO_NET_F_CTRL_RX feature at device's startup. Signed-off-by: Hawkins Jiawei Message-Id: <804cedac93e19ba3b810d52b274ca5ec11469f09.1688743107.git.yin31149@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 126afbc7a5..f299e446b0 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -794,6 +794,87 @@ static int vhost_vdpa_net_load_offloads(VhostVDPAState *s, return 0; } +static int vhost_vdpa_net_load_rx_mode(VhostVDPAState *s, + uint8_t cmd, + uint8_t on) +{ + const struct iovec data = { + .iov_base = &on, + .iov_len = sizeof(on), + }; + return vhost_vdpa_net_load_cmd(s, VIRTIO_NET_CTRL_RX, + cmd, &data, 1); +} + +static int vhost_vdpa_net_load_rx(VhostVDPAState *s, + const VirtIONet *n) +{ + ssize_t dev_written; + + if (!virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_CTRL_RX)) { + return 0; + } + + /* + * According to virtio_net_reset(), device turns promiscuous mode + * on by default. + * + * Addtionally, according to VirtIO standard, "Since there are + * no guarantees, it can use a hash filter or silently switch to + * allmulti or promiscuous mode if it is given too many addresses.". + * QEMU marks `n->mac_table.uni_overflow` if guest sets too many + * non-multicast MAC addresses, indicating that promiscuous mode + * should be enabled. + * + * Therefore, QEMU should only send this CVQ command if the + * `n->mac_table.uni_overflow` is not marked and `n->promisc` is off, + * which sets promiscuous mode on, different from the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + if (!n->mac_table.uni_overflow && !n->promisc) { + dev_written = vhost_vdpa_net_load_rx_mode(s, + VIRTIO_NET_CTRL_RX_PROMISC, 0); + if (unlikely(dev_written < 0)) { + return dev_written; + } + if (*s->status != VIRTIO_NET_OK) { + return -EIO; + } + } + + /* + * According to virtio_net_reset(), device turns all-multicast mode + * off by default. + * + * According to VirtIO standard, "Since there are no guarantees, + * it can use a hash filter or silently switch to allmulti or + * promiscuous mode if it is given too many addresses.". QEMU marks + * `n->mac_table.multi_overflow` if guest sets too many + * non-multicast MAC addresses. + * + * Therefore, QEMU should only send this CVQ command if the + * `n->mac_table.multi_overflow` is marked or `n->allmulti` is on, + * which sets all-multicast mode on, different from the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + if (n->mac_table.multi_overflow || n->allmulti) { + dev_written = vhost_vdpa_net_load_rx_mode(s, + VIRTIO_NET_CTRL_RX_ALLMULTI, 1); + if (unlikely(dev_written < 0)) { + return dev_written; + } + if (*s->status != VIRTIO_NET_OK) { + return -EIO; + } + } + + return 0; +} + static int vhost_vdpa_net_load(NetClientState *nc) { VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); @@ -820,6 +901,10 @@ static int vhost_vdpa_net_load(NetClientState *nc) if (unlikely(r)) { return r; } + r = vhost_vdpa_net_load_rx(s, n); + if (unlikely(r)) { + return r; + } return 0; } From patchwork Mon Jul 10 23:05:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806108 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=T4NaMyAR; dkim-atps=neutral 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 4R0KTH6Nq9z20ZZ for ; Tue, 11 Jul 2023 09:09:39 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwj-0004Pk-V1; Mon, 10 Jul 2023 19:05:33 -0400 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 1qIzwd-0003Z9-GC for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:28 -0400 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 1qIzwb-0004ru-AL for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030324; 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=CpelzGsd50X9x3Tst4WfltV5TKRJ5M8f+SltSoP+x1c=; b=T4NaMyARvIz1KmFUkN7neE12D5uK2mRCWVsvjBaN51/Og5JmCMmvqDEAZkeJNV8q3DR7hy kdpsd+xnBjtnWIYZE3M/ug9SEfydGjSwydUOEs0G3ejQydJnbs5JuKIZA/Ms+7Msl8wXRM MWPhgMvx9kiNWtnNiOr1mJ+r5IhjdUI= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-5-CinlWnN1Mw69i1g43iUviw-1; Mon, 10 Jul 2023 19:05:23 -0400 X-MC-Unique: CinlWnN1Mw69i1g43iUviw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3fc020021efso22651945e9.0 for ; Mon, 10 Jul 2023 16:05:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030322; x=1691622322; 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=CpelzGsd50X9x3Tst4WfltV5TKRJ5M8f+SltSoP+x1c=; b=ehZrqNIAnB1Q0eBm7EykzmBuKS0Z2HfceAsLoTlfsSHYGA/tuLKt7tj9fcglzlxyKW l7tGwQGOHAwEYbZpwtQHrp7fvsK+JYm+lQwJndAyg9JkIfh16CCgOvBYiPADmePC/ujV bIkPvQwnRTnXtxjdL47ZbLyAqawuFEsFIO1BlcvVLMgaaCnQranCcDnAmF0NGyp6W7Te z/bZs7DTH9ieH03orqluq7/0En+RDUn1qTuxjhwpBx2qddv/+EEzqANnfA55LcTYHWr+ oT1ZH/VwzuM9Tgv+QLOavy8Css6mVDQyys4cqp8thTCjjbPNy5aGjdPQbPwMlhsMIc3X C5zQ== X-Gm-Message-State: ABy/qLZXsZEhcYAej9jXut4g5Czcl4veg56vpLSStdVupf6hx9ufy4o2 pKt8ETM+popxddgqRicC/aLansHW8Wzv3qWqapFDRA9g63IXk7RgFTzLpsiLC4fe5X+c9wZXacN LWvzneF24VrpZltLECgxk9p2KC4Jh/MrLoxFh3HjcBDSo5K4yHk8f8F1uZ9cqvgZcy1Oy X-Received: by 2002:a7b:ce91:0:b0:3f8:f663:921d with SMTP id q17-20020a7bce91000000b003f8f663921dmr13511280wmj.41.1689030321824; Mon, 10 Jul 2023 16:05:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlFKS7kXBaVmFoFLcU9FRC/SXfBtolXr6LyEgezNL27uH32rsq9cuRZcS2H66M8Zn1/dHA43JQ== X-Received: by 2002:a7b:ce91:0:b0:3f8:f663:921d with SMTP id q17-20020a7bce91000000b003f8f663921dmr13511265wmj.41.1689030321605; Mon, 10 Jul 2023 16:05:21 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id l20-20020a7bc354000000b003fbb8c7c799sm11470984wmj.30.2023.07.10.16.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:05:21 -0700 (PDT) Date: Mon, 10 Jul 2023 19:05:19 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Eugenio =?utf-8?b?UMOpcmV6?= Subject: [PULL 61/66] vhost: Fix false positive out-of-bounds 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Hawkins Jiawei QEMU uses vhost_svq_translate_addr() to translate addresses between the QEMU's virtual address and the SVQ IOVA. In order to validate this translation, QEMU checks whether the translated range falls within the mapped range. Yet the problem is that, the value of `needle_last`, which is calculated by `needle.translated_addr + iovec[i].iov_len`, should represent the exclusive boundary of the translated range, rather than the last inclusive addresses of the range. Consequently, QEMU fails the check when the translated range matches the size of the mapped range. This patch solves this problem by fixing the `needle_last` value to the last inclusive address of the translated range. Note that this bug cannot be triggered at the moment, because QEMU is unable to translate such a big range due to the truncation of the CVQ command in vhost_vdpa_net_handle_ctrl_avail(). Fixes: 34e3c94eda ("vdpa: Add custom IOTLB translations to SVQ") Signed-off-by: Hawkins Jiawei Message-Id: Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-shadow-virtqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c index 1b1d85306c..49e5aed931 100644 --- a/hw/virtio/vhost-shadow-virtqueue.c +++ b/hw/virtio/vhost-shadow-virtqueue.c @@ -111,7 +111,7 @@ static bool vhost_svq_translate_addr(const VhostShadowVirtqueue *svq, addrs[i] = map->iova + off; needle_last = int128_add(int128_make64(needle.translated_addr), - int128_make64(iovec[i].iov_len)); + int128_makes64(iovec[i].iov_len - 1)); map_last = int128_make64(map->translated_addr + map->size); if (unlikely(int128_gt(needle_last, map_last))) { qemu_log_mask(LOG_GUEST_ERROR, From patchwork Mon Jul 10 23:05:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806102 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=XdzN39hF; dkim-atps=neutral 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 4R0KSt2qnbz20ZZ for ; Tue, 11 Jul 2023 09:09:18 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwi-0004FV-SQ; Mon, 10 Jul 2023 19:05:32 -0400 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 1qIzwf-0003eG-9a for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:29 -0400 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 1qIzwd-0004tf-RB for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030327; 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=iQNmObWIEytSrAM/8yu+agFnazGV0A9drwm3zFDQ0PQ=; b=XdzN39hFmqvSJXChgYHfKnFOF8lci+R/GV6gEOgk7SQVTsCu7ov0lePycpZZfqI1L9Su6K xyAbF9k9VvjcYQaNN2ituFGQ345TPesjCQidgG4k+HCd7iY4DpRO9C95xkSUxn7qm/mKzN IMNlnKVnMUN1Q7NGx5FaPHpZ3jd4x9U= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-614-lQ354izxP2CRTukUlu3Sfw-1; Mon, 10 Jul 2023 19:05:26 -0400 X-MC-Unique: lQ354izxP2CRTukUlu3Sfw-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3142665f122so2947798f8f.0 for ; Mon, 10 Jul 2023 16:05:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030324; x=1691622324; 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=iQNmObWIEytSrAM/8yu+agFnazGV0A9drwm3zFDQ0PQ=; b=R2J5ybqlojaM57RKjKSmXQpcJ1d41/QoL1aMmgIVJ+mF7H+9VtveXB91HUWy+nwlWQ BzJbqM969zTQp7kZ5mg9CIdELnxjwIRekwPN88bbPgJ3Uvjdw46h4avCKdhLCzX0eyh2 27iDvQXgMVgmdHg0BBDOgnflfXMLSPKez01nj4ndpu/d0DOM7VkgAiRylXrc7TtaUtsl K2gqdD/MLDdoVFBNb3k9tDGdAkkvSb02NqoMFcSHnWN1Ks588AobhwOoLa6Wr6/xTlm4 p8VJBuyB7EQ3Mx11S9QDGBA8TXdNB3hEVvGu8lPZjDcTIZeGhvz0CIpnwrDEj1/RsHjQ 7FAg== X-Gm-Message-State: ABy/qLbIXDRO6tLEqVt8NJyXk+BWC2W3OZAJdDCB4qTW46S7n1YHPGQk KkjirZUmJzyO2M+Aemy4mjFhlFAvU+wlObBvLGBEzAnQd12u6+Y25atlHuye39+TSRUiCQ/K5Wz E3gNpcnPbuU2SOEdPalaxfW7upXi/6gPrAIuw5eUsH5exXm0FWwdsCUtceHDV361YvPTa X-Received: by 2002:a5d:6601:0:b0:314:10c1:881d with SMTP id n1-20020a5d6601000000b0031410c1881dmr14695943wru.68.1689030324611; Mon, 10 Jul 2023 16:05:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlGLGDYaws/Ff7XvxQR59UaHqjo75ittUi8KRw9xhXJpHDN+3bA5l9ce2pAQXFxEBkvvTDOnjA== X-Received: by 2002:a5d:6601:0:b0:314:10c1:881d with SMTP id n1-20020a5d6601000000b0031410c1881dmr14695926wru.68.1689030324408; Mon, 10 Jul 2023 16:05:24 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id o18-20020a5d6712000000b003113ed02080sm565863wru.95.2023.07.10.16.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:05:23 -0700 (PDT) Date: Mon, 10 Jul 2023 19:05:22 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Jason Wang Subject: [PULL 62/66] vdpa: Accessing CVQ header through its structure Message-ID: <45c4101828a483b87863f2e2ba6d98faf0ff7d92.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Hawkins Jiawei We can access the CVQ header through `struct virtio_net_ctrl_hdr`, instead of accessing it through a `uint8_t` pointer, which improves the code's readability and maintainability. Signed-off-by: Hawkins Jiawei Message-Id: Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index f299e446b0..eee4b2a09e 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -934,6 +934,7 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq, { VhostVDPAState *s = opaque; size_t in_len; + const struct virtio_net_ctrl_hdr *ctrl; virtio_net_ctrl_ack status = VIRTIO_NET_ERR; /* Out buffer sent to both the vdpa device and the device model */ struct iovec out = { @@ -949,7 +950,9 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq, out.iov_len = iov_to_buf(elem->out_sg, elem->out_num, 0, s->cvq_cmd_out_buffer, vhost_vdpa_net_cvq_cmd_len()); - if (*(uint8_t *)s->cvq_cmd_out_buffer == VIRTIO_NET_CTRL_ANNOUNCE) { + + ctrl = s->cvq_cmd_out_buffer; + if (ctrl->class == VIRTIO_NET_CTRL_ANNOUNCE) { /* * Guest announce capability is emulated by qemu, so don't forward to * the device. From patchwork Mon Jul 10 23:05:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806103 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=ftNg+F+Y; dkim-atps=neutral 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 4R0KSz0nkxz20ZZ for ; Tue, 11 Jul 2023 09:09:23 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwn-0004Xd-3Z; Mon, 10 Jul 2023 19:05:37 -0400 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 1qIzwk-0004Ts-St for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:34 -0400 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 1qIzwi-0004ua-Pd for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030332; 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=NFfTVSt523EXMOANw1qtqt3SiBZHXYJa2ZzCOv5S19A=; b=ftNg+F+Y97/t2cqiG2YQTkPmdI1lHZvLXK7cam2RHLrvIHrmuXzth1+dKimYr83hKE0yL2 cKWAnKTJWMpQOzCivVh6YhAynx0QL3pX5EksbxqhsmEBP8zlAeDl9d44A1JFPhxRDliXDC dD+Gwd0Pzz6yDzoIcM7FLzKzTSeIOSM= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-656-DBB_zOGjOq67zDFZUn4PzA-1; Mon, 10 Jul 2023 19:05:29 -0400 X-MC-Unique: DBB_zOGjOq67zDFZUn4PzA-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fc08035926so10307085e9.0 for ; Mon, 10 Jul 2023 16:05:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030327; x=1691622327; 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=NFfTVSt523EXMOANw1qtqt3SiBZHXYJa2ZzCOv5S19A=; b=lY+aufp1x1pL/hSnsn0d01Bk2sJbi+NMalkecoMN4xGYqQkX0OEORpkBnXlnESqF8w w+HaLFY9cdR7NZbJXEN+8eVByWAWc6qERg5OU295hMJkyAnwwyIezVrszTnpoPdPBGx3 BgxfsWJLVYC9EeIg5+ZvtZyU+U3B1+tnDHlFDDc0SzcBOVzsDwbXqab84Ii3tFIITvNT sVQP4AOOkTqaiCf2kh2xZATbspCjkSmln5oBCxREgTcvIBalW4djJkPajs/FxYxo1jhJ zcHl5cjTRBt4iYL/oIgyvXwgraO0x4gGPGp15PFd4Kz5NxxlOIxpP3z2PUQZ7KNApksV 4W7g== X-Gm-Message-State: ABy/qLZPN0eUzkyinsobjwOWPlegw5mQqFSKP7+S+jm+XJuEK3R1ayoi XCA+JP5JJ1x4VBiuarJH9maBKvAbevRpmOM3EIVi56+7O/d1LOkTWQJReSx0+xhwOcPVYIV6BZT Iq7kwhMXZjAOVvNE4Was2U3R+0YTCcvTLU1YQTV3PT2nAleMpF7nDGCeE7zOUvq228AWx X-Received: by 2002:a05:600c:20c:b0:3fa:aeac:e978 with SMTP id 12-20020a05600c020c00b003faaeace978mr12983745wmi.0.1689030327568; Mon, 10 Jul 2023 16:05:27 -0700 (PDT) X-Google-Smtp-Source: APBJJlGhL5cZ4Le644R0qu2u0pBv9FW0wdavjb6HTKxakQ8D7fionCfWsoIUDZSnYJQ+smRB1oagWg== X-Received: by 2002:a05:600c:20c:b0:3fa:aeac:e978 with SMTP id 12-20020a05600c020c00b003faaeace978mr12983734wmi.0.1689030327220; Mon, 10 Jul 2023 16:05:27 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id o4-20020a05600c378400b003fbfc61d36asm978132wmr.5.2023.07.10.16.05.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:05:26 -0700 (PDT) Date: Mon, 10 Jul 2023 19:05:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Jason Wang Subject: [PULL 63/66] vdpa: Avoid forwarding large CVQ command failures 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Hawkins Jiawei Due to the size limitation of the out buffer sent to the vdpa device, which is determined by vhost_vdpa_net_cvq_cmd_len(), excessive CVQ command is truncated in QEMU. As a result, the vdpa device rejects this flawd CVQ command. However, the problem is that, the VIRTIO_NET_CTRL_MAC_TABLE_SET CVQ command has a variable length, which may exceed vhost_vdpa_net_cvq_cmd_len() if the guest sets more than `MAC_TABLE_ENTRIES` MAC addresses for the filter table. This patch solves this problem by following steps: * Increase the out buffer size to vhost_vdpa_net_cvq_cmd_page_len(), which represents the size of the buffer that is allocated and mmaped. This ensures that everything works correctly as long as the guest sets fewer than `(vhost_vdpa_net_cvq_cmd_page_len() - sizeof(struct virtio_net_ctrl_hdr) - 2 * sizeof(struct virtio_net_ctrl_mac)) / ETH_ALEN` MAC addresses. Considering the highly unlikely scenario for the guest setting more than that number of MAC addresses for the filter table, this should work fine for the majority of cases. * If the CVQ command exceeds vhost_vdpa_net_cvq_cmd_page_len(), instead of directly sending this CVQ command, QEMU should send a VIRTIO_NET_CTRL_RX_PROMISC CVQ command to vdpa device. Addtionally, a fake VIRTIO_NET_CTRL_MAC_TABLE_SET command including (`MAC_TABLE_ENTRIES` + 1) non-multicast MAC addresses and (`MAC_TABLE_ENTRIES` + 1) multicast MAC addresses should be provided to the device model. By doing so, the vdpa device turns promiscuous mode on, aligning with the VirtIO standard. The device model marks `n->mac_table.uni_overflow` and `n->mac_table.multi_overflow`, which aligns with the state of the vdpa device. Note that the bug cannot be triggered at the moment, since VIRTIO_NET_F_CTRL_RX feature is not enabled for SVQ. Fixes: 7a7f87e94c ("vdpa: Move command buffers map to start of net device") Signed-off-by: Hawkins Jiawei Message-Id: <267e15e4eed2d7aeb9887f193da99a13d22a2f1d.1688743107.git.yin31149@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 162 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 161 insertions(+), 1 deletion(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index eee4b2a09e..7610589a60 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -922,6 +922,148 @@ static NetClientInfo net_vhost_vdpa_cvq_info = { .check_peer_type = vhost_vdpa_check_peer_type, }; +/* + * Forward the excessive VIRTIO_NET_CTRL_MAC_TABLE_SET CVQ command to + * vdpa device. + * + * Considering that QEMU cannot send the entire filter table to the + * vdpa device, it should send the VIRTIO_NET_CTRL_RX_PROMISC CVQ + * command to enable promiscuous mode to receive all packets, + * according to VirtIO standard, "Since there are no guarantees, + * it can use a hash filter or silently switch to allmulti or + * promiscuous mode if it is given too many addresses.". + * + * Since QEMU ignores MAC addresses beyond `MAC_TABLE_ENTRIES` and + * marks `n->mac_table.x_overflow` accordingly, it should have + * the same effect on the device model to receive + * (`MAC_TABLE_ENTRIES` + 1) or more non-multicast MAC addresses. + * The same applies to multicast MAC addresses. + * + * Therefore, QEMU can provide the device model with a fake + * VIRTIO_NET_CTRL_MAC_TABLE_SET command with (`MAC_TABLE_ENTRIES` + 1) + * non-multicast MAC addresses and (`MAC_TABLE_ENTRIES` + 1) multicast + * MAC addresses. This ensures that the device model marks + * `n->mac_table.uni_overflow` and `n->mac_table.multi_overflow`, + * allowing all packets to be received, which aligns with the + * state of the vdpa device. + */ +static int vhost_vdpa_net_excessive_mac_filter_cvq_add(VhostVDPAState *s, + VirtQueueElement *elem, + struct iovec *out) +{ + struct virtio_net_ctrl_mac mac_data, *mac_ptr; + struct virtio_net_ctrl_hdr *hdr_ptr; + uint32_t cursor; + ssize_t r; + + /* parse the non-multicast MAC address entries from CVQ command */ + cursor = sizeof(*hdr_ptr); + r = iov_to_buf(elem->out_sg, elem->out_num, cursor, + &mac_data, sizeof(mac_data)); + if (unlikely(r != sizeof(mac_data))) { + /* + * If the CVQ command is invalid, we should simulate the vdpa device + * to reject the VIRTIO_NET_CTRL_MAC_TABLE_SET CVQ command + */ + *s->status = VIRTIO_NET_ERR; + return sizeof(*s->status); + } + cursor += sizeof(mac_data) + le32_to_cpu(mac_data.entries) * ETH_ALEN; + + /* parse the multicast MAC address entries from CVQ command */ + r = iov_to_buf(elem->out_sg, elem->out_num, cursor, + &mac_data, sizeof(mac_data)); + if (r != sizeof(mac_data)) { + /* + * If the CVQ command is invalid, we should simulate the vdpa device + * to reject the VIRTIO_NET_CTRL_MAC_TABLE_SET CVQ command + */ + *s->status = VIRTIO_NET_ERR; + return sizeof(*s->status); + } + cursor += sizeof(mac_data) + le32_to_cpu(mac_data.entries) * ETH_ALEN; + + /* validate the CVQ command */ + if (iov_size(elem->out_sg, elem->out_num) != cursor) { + /* + * If the CVQ command is invalid, we should simulate the vdpa device + * to reject the VIRTIO_NET_CTRL_MAC_TABLE_SET CVQ command + */ + *s->status = VIRTIO_NET_ERR; + return sizeof(*s->status); + } + + /* + * According to VirtIO standard, "Since there are no guarantees, + * it can use a hash filter or silently switch to allmulti or + * promiscuous mode if it is given too many addresses.". + * + * Therefore, considering that QEMU is unable to send the entire + * filter table to the vdpa device, it should send the + * VIRTIO_NET_CTRL_RX_PROMISC CVQ command to enable promiscuous mode + */ + r = vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_PROMISC, 1); + if (unlikely(r < 0)) { + return r; + } + if (*s->status != VIRTIO_NET_OK) { + return sizeof(*s->status); + } + + /* + * QEMU should also send a fake VIRTIO_NET_CTRL_MAC_TABLE_SET CVQ + * command to the device model, including (`MAC_TABLE_ENTRIES` + 1) + * non-multicast MAC addresses and (`MAC_TABLE_ENTRIES` + 1) + * multicast MAC addresses. + * + * By doing so, the device model can mark `n->mac_table.uni_overflow` + * and `n->mac_table.multi_overflow`, enabling all packets to be + * received, which aligns with the state of the vdpa device. + */ + cursor = 0; + uint32_t fake_uni_entries = MAC_TABLE_ENTRIES + 1, + fake_mul_entries = MAC_TABLE_ENTRIES + 1, + fake_cvq_size = sizeof(struct virtio_net_ctrl_hdr) + + sizeof(mac_data) + fake_uni_entries * ETH_ALEN + + sizeof(mac_data) + fake_mul_entries * ETH_ALEN; + + assert(fake_cvq_size < vhost_vdpa_net_cvq_cmd_page_len()); + out->iov_len = fake_cvq_size; + + /* pack the header for fake CVQ command */ + hdr_ptr = out->iov_base + cursor; + hdr_ptr->class = VIRTIO_NET_CTRL_MAC; + hdr_ptr->cmd = VIRTIO_NET_CTRL_MAC_TABLE_SET; + cursor += sizeof(*hdr_ptr); + + /* + * Pack the non-multicast MAC addresses part for fake CVQ command. + * + * According to virtio_net_handle_mac(), QEMU doesn't verify the MAC + * addresses provieded in CVQ command. Therefore, only the entries + * field need to be prepared in the CVQ command. + */ + mac_ptr = out->iov_base + cursor; + mac_ptr->entries = cpu_to_le32(fake_uni_entries); + cursor += sizeof(*mac_ptr) + fake_uni_entries * ETH_ALEN; + + /* + * Pack the multicast MAC addresses part for fake CVQ command. + * + * According to virtio_net_handle_mac(), QEMU doesn't verify the MAC + * addresses provieded in CVQ command. Therefore, only the entries + * field need to be prepared in the CVQ command. + */ + mac_ptr = out->iov_base + cursor; + mac_ptr->entries = cpu_to_le32(fake_mul_entries); + + /* + * Simulating QEMU poll a vdpa device used buffer + * for VIRTIO_NET_CTRL_MAC_TABLE_SET CVQ command + */ + return sizeof(*s->status); +} + /** * Validate and copy control virtqueue commands. * @@ -949,7 +1091,7 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq, out.iov_len = iov_to_buf(elem->out_sg, elem->out_num, 0, s->cvq_cmd_out_buffer, - vhost_vdpa_net_cvq_cmd_len()); + vhost_vdpa_net_cvq_cmd_page_len()); ctrl = s->cvq_cmd_out_buffer; if (ctrl->class == VIRTIO_NET_CTRL_ANNOUNCE) { @@ -959,6 +1101,24 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq, */ dev_written = sizeof(status); *s->status = VIRTIO_NET_OK; + } else if (unlikely(ctrl->class == VIRTIO_NET_CTRL_MAC && + ctrl->cmd == VIRTIO_NET_CTRL_MAC_TABLE_SET && + iov_size(elem->out_sg, elem->out_num) > out.iov_len)) { + /* + * Due to the size limitation of the out buffer sent to the vdpa device, + * which is determined by vhost_vdpa_net_cvq_cmd_page_len(), excessive + * MAC addresses set by the driver for the filter table can cause + * truncation of the CVQ command in QEMU. As a result, the vdpa device + * rejects the flawed CVQ command. + * + * Therefore, QEMU must handle this situation instead of sending + * the CVQ command direclty. + */ + dev_written = vhost_vdpa_net_excessive_mac_filter_cvq_add(s, elem, + &out); + if (unlikely(dev_written < 0)) { + goto out; + } } else { dev_written = vhost_vdpa_net_cvq_add(s, out.iov_len, sizeof(status)); if (unlikely(dev_written < 0)) { From patchwork Mon Jul 10 23:05:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806112 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=Vc3PTFVv; dkim-atps=neutral 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 4R0KTP0KgJz20ZZ for ; Tue, 11 Jul 2023 09:09:45 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwn-0004eF-S7; Mon, 10 Jul 2023 19:05:37 -0400 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 1qIzwk-0004Tb-RG for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:34 -0400 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 1qIzwj-0004uh-5Q for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030332; 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=IA9Q76kZr4fcEo5oRA3QJtuIiFw5g8VxB1RjNQ65Hy4=; b=Vc3PTFVvHffqO2FAeVhePg47edwVOQvJCJnzyQilWSSg5Rg4J/BgFyJreXtN3D6ig6fnUz BoFG7UfbLejzeTBp5kq7CAhkTs0lXqt8cl3VDGvIdmiMDWmzbprZsN6qntaoPBhTfqqETR ReAew6Xc7pnLnnwcm340tvd+7v+xoDU= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-bpKJyEv5OWC-kNDcLgLVOQ-1; Mon, 10 Jul 2023 19:05:31 -0400 X-MC-Unique: bpKJyEv5OWC-kNDcLgLVOQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-315a03cae87so488897f8f.0 for ; Mon, 10 Jul 2023 16:05:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030330; x=1691622330; 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=IA9Q76kZr4fcEo5oRA3QJtuIiFw5g8VxB1RjNQ65Hy4=; b=MzvAZtRYajQ4vtQadrSQtGpWkbbjNZRrLWXYEhV2lepBbHgb8qLDNDQyrfWS9LrZ5u xbHCuOzQd0M275TaMxRcYHR7Vld2tgb3n90XgtHIFCsmPnE6E9sw+t81KqjkKWTOHw2a dAg2CNMLf7mkDpRIkYf6IxVV7RzhZ8BzU8bh55+PUSBXe9TFH5o+Pzr0QGIlZ7pSCCEI gFA8hROiWS+OE7YNiMDlNSVt3fOQyNQ1efJQ3vTsvU0ji2Mdt+hITxg+xEnRJwIEYGw3 j/aKRAbDV+j3sdhnKDJGxO7q80bYsQrzD2epUKvgNyV0l71UlrXJ1QewRhN5SRg0V3YM utmQ== X-Gm-Message-State: ABy/qLYy1HWDZhELVUl4yunh4yBB1e5O28QMqI+I9tsrwUApGVMMIa1m BMn17Jrszypb/Xl2sTCsCa0ckC4VbZE2n9CYLTxPTYZXLuODLHERKO+VxzPeKUHLy8XTRlQYxQ6 WcOPHggp5Cu5zFYmfiBeHuDanThaVS3JBQD3dL4r2IqdgIxgyctXJTFXnlfq4ovyQVxne X-Received: by 2002:adf:fa89:0:b0:314:3f86:dd9f with SMTP id h9-20020adffa89000000b003143f86dd9fmr14838048wrr.25.1689030329940; Mon, 10 Jul 2023 16:05:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlGhVUyEmEBU4jLc+8sJMXd8ha834ZRA98HO1uMkJlnDQw14h+7/dTd57h3RuedLeZ8PZam6FQ== X-Received: by 2002:adf:fa89:0:b0:314:3f86:dd9f with SMTP id h9-20020adffa89000000b003143f86dd9fmr14838036wrr.25.1689030329750; Mon, 10 Jul 2023 16:05:29 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id v2-20020adfe4c2000000b0031434c08bb7sm567559wrm.105.2023.07.10.16.05.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:05:29 -0700 (PDT) Date: Mon, 10 Jul 2023 19:05:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Eugenio =?utf-8?b?UMOpcmV6?= , Jason Wang Subject: [PULL 64/66] vdpa: Allow VIRTIO_NET_F_CTRL_RX in SVQ 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Hawkins Jiawei Enable SVQ with VIRTIO_NET_F_CTRL_RX feature. Signed-off-by: Hawkins Jiawei Acked-by: Eugenio Pérez Message-Id: <5d6173a6d7c4c514c98362b404c019f52d73b06c.1688743107.git.yin31149@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 7610589a60..5cd671bfb9 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -110,6 +110,7 @@ static const uint64_t vdpa_svq_device_features = BIT_ULL(VIRTIO_NET_F_MRG_RXBUF) | BIT_ULL(VIRTIO_NET_F_STATUS) | BIT_ULL(VIRTIO_NET_F_CTRL_VQ) | + BIT_ULL(VIRTIO_NET_F_CTRL_RX) | BIT_ULL(VIRTIO_NET_F_MQ) | BIT_ULL(VIRTIO_F_ANY_LAYOUT) | BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) | From patchwork Mon Jul 10 23:05:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806089 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=O6OGNrIm; dkim-atps=neutral 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 4R0KRv5DNVz20cZ for ; Tue, 11 Jul 2023 09:08:27 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwp-0004qq-Ga; Mon, 10 Jul 2023 19:05:39 -0400 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 1qIzwn-0004YB-A3 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:37 -0400 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 1qIzwl-0004vV-Nl for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030335; 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=7IFqp1H6rwpWHqy0sAsAkOpjQIWvgkCXKQLg3lFhmnQ=; b=O6OGNrIm11Yowt6a+1ws0quehj/jHNaf1EqjbFj/wDptNVQZiISpSIYShsP6+RHbKoNGw/ QWIlDGVVJR1VfdhQS6zxfxqKHParHBw/8a0SOKErladoS1dJwhAE5o+++brJT1ENliWpTx /p6x/LovqIZhrGK5HjRO0ATSLbiQqhg= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-488-YxgyPDhrPpWNX9snPkN0rg-1; Mon, 10 Jul 2023 19:05:33 -0400 X-MC-Unique: YxgyPDhrPpWNX9snPkN0rg-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3113da8b778so2713972f8f.3 for ; Mon, 10 Jul 2023 16:05:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030332; x=1691622332; 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=7IFqp1H6rwpWHqy0sAsAkOpjQIWvgkCXKQLg3lFhmnQ=; b=LbUixos+P3sxUtv4lBpOtILq2wuK1HvtaioQAYhfZKU9TOIYrGKoCNoj+N7YP9PgcS 6Sth3mraeypcevGKX+uHtLm/FLQcFZTVX7P3l10OAnBskHl+gS1h49BUuByAuL+wv2ht XHKUeW3WjMJbtNfQYm/DFVVCbhINZqm+6cQKzDcCzOnlWNNXCq+ilqEQXemrczAbkjiu 5FhRRpnmpYh//Zu0Yky2UqSyI9yuZrXYyttYoU0QBcm2Z88sMrFMf1O+WrWiri+UYvRS XXBXBWfeB2u3c/8ZfqcKcGbB0LFuI2hDC3UDYRbrUEEyydccE+3717+iaVbvhB/r4VMb pTPg== X-Gm-Message-State: ABy/qLaqnU0Fie+MROk2atH6LK7FahmNkKtDZVadwe4qQkPXJcmXMckO o828MsvSrnaHczx4tObnP1dqA6SQJdeZsiaMWN9XrWa3stXjKlVhyxvtky5tT837DU4+c9ZzrNa u3tByY1Mb2UINpSOYPNebMaKX1ImhI1Qj8gHUPw+xdOu2RVcFxRLSWOWqTHl29VmFrae3 X-Received: by 2002:a5d:504d:0:b0:314:38e4:259f with SMTP id h13-20020a5d504d000000b0031438e4259fmr12382617wrt.37.1689030332363; Mon, 10 Jul 2023 16:05:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlHcXAgXOwD3VyqE6/cvZAiiXSSEdFZhqHEUDFt6FzIg+tGufiHMRPpr/zwc1B76TYLtuGcNbA== X-Received: by 2002:a5d:504d:0:b0:314:38e4:259f with SMTP id h13-20020a5d504d000000b0031438e4259fmr12382601wrt.37.1689030332143; Mon, 10 Jul 2023 16:05:32 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id c3-20020adffb03000000b0031432f1528csm589189wrr.45.2023.07.10.16.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:05:31 -0700 (PDT) Date: Mon, 10 Jul 2023 19:05:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Jason Wang Subject: [PULL 65/66] vdpa: Restore packet receive filtering state relative with _F_CTRL_RX_EXTRA feature Message-ID: <4fd180c7bb476d0793f3849ae4e6c0f932b6e3ab.1689030052.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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Hawkins Jiawei This patch refactors vhost_vdpa_net_load_rx() to restore the packet receive filtering state in relation to VIRTIO_NET_F_CTRL_RX_EXTRA feature at device's startup. Signed-off-by: Hawkins Jiawei Message-Id: Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 5cd671bfb9..0c1c0760a7 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -873,6 +873,94 @@ static int vhost_vdpa_net_load_rx(VhostVDPAState *s, } } + if (!virtio_vdev_has_feature(&n->parent_obj, VIRTIO_NET_F_CTRL_RX_EXTRA)) { + return 0; + } + + /* + * According to virtio_net_reset(), device turns all-unicast mode + * off by default. + * + * Therefore, QEMU should only send this CVQ command if the driver + * sets all-unicast mode on, different from the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + if (n->alluni) { + dev_written = vhost_vdpa_net_load_rx_mode(s, + VIRTIO_NET_CTRL_RX_ALLUNI, 1); + if (dev_written < 0) { + return dev_written; + } + if (*s->status != VIRTIO_NET_OK) { + return -EIO; + } + } + + /* + * According to virtio_net_reset(), device turns non-multicast mode + * off by default. + * + * Therefore, QEMU should only send this CVQ command if the driver + * sets non-multicast mode on, different from the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + if (n->nomulti) { + dev_written = vhost_vdpa_net_load_rx_mode(s, + VIRTIO_NET_CTRL_RX_NOMULTI, 1); + if (dev_written < 0) { + return dev_written; + } + if (*s->status != VIRTIO_NET_OK) { + return -EIO; + } + } + + /* + * According to virtio_net_reset(), device turns non-unicast mode + * off by default. + * + * Therefore, QEMU should only send this CVQ command if the driver + * sets non-unicast mode on, different from the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + if (n->nouni) { + dev_written = vhost_vdpa_net_load_rx_mode(s, + VIRTIO_NET_CTRL_RX_NOUNI, 1); + if (dev_written < 0) { + return dev_written; + } + if (*s->status != VIRTIO_NET_OK) { + return -EIO; + } + } + + /* + * According to virtio_net_reset(), device turns non-broadcast mode + * off by default. + * + * Therefore, QEMU should only send this CVQ command if the driver + * sets non-broadcast mode on, different from the device's defaults. + * + * Note that the device's defaults can mismatch the driver's + * configuration only at live migration. + */ + if (n->nobcast) { + dev_written = vhost_vdpa_net_load_rx_mode(s, + VIRTIO_NET_CTRL_RX_NOBCAST, 1); + if (dev_written < 0) { + return dev_written; + } + if (*s->status != VIRTIO_NET_OK) { + return -EIO; + } + } + return 0; } From patchwork Mon Jul 10 23:05:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1806076 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=) 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=aUM82acj; dkim-atps=neutral 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 4R0KQy62S5z20ZZ for ; Tue, 11 Jul 2023 09:07:38 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzwr-00058v-Gk; Mon, 10 Jul 2023 19:05:41 -0400 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 1qIzwq-0004zh-DU for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:40 -0400 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 1qIzwo-0004vv-Tf for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:05:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030338; 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=8SuoEmdvJLF1kbhsp7zcp3gnkEzxAK2svLYwoxlfO4Y=; b=aUM82acjs9uxU3X2nRr5HL9QOnbkfwRqJct4/qsA0+MVVTEQDn1a/Mt5jfU1onSenbv20O sMRT+ofVAXaFZq98sq65D/phK24/XBvTYCDEVkuuikDKpQMS6NWqWKFCdw1Yg9pzrK/aaq OjmuHCdz8IgzFqok0o11nfD64SGfh0U= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-182-JzoOHrggNhuiuth2COv3CQ-1; Mon, 10 Jul 2023 19:05:37 -0400 X-MC-Unique: JzoOHrggNhuiuth2COv3CQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3f42bcef2acso29885605e9.2 for ; Mon, 10 Jul 2023 16:05:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030335; x=1691622335; 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=8SuoEmdvJLF1kbhsp7zcp3gnkEzxAK2svLYwoxlfO4Y=; b=CMwq9Nnae/OpwoQS6rUByS6Zr1VbGjVVdPm44jlbAatK3EEfh25FGXZJhNxLGLJ3O6 xZwhKHtVwu067ZpfE5Pd1pBXA7XMM+dcLFTB2kr/TMIHnR+n2E6HcXDP3v3GWnmZJl/f 7VVnOv+6i8i4/ICvJgMHbSEEVbxsb07A5xPQHigrD8aj+2BTP3DdCAiOgkLF0vPisWB7 j0Lgt1101bj/zytAP8T2iAb9HhbQo7wScrfNdklb+HnhdskANwFWFCg9ktmsB9NpvJrk /exvUbEZGGu6GvPCqSQihAlKc0MdM716sKU5YfyxSSv3wI+DYBkBJ7T2cSMAeVlMfHNG J5RA== X-Gm-Message-State: ABy/qLYq0fbQG67g1m38kpT3zvPT+rCk/Z/yziqR6x6riFMABxDHeavT 870poOII9ZQecJIT64/0hhlEv//ksuHMp/M0LQ0bgHv9a0UI2gzCAeQMqBpXfm3P7Ru3Z0RA8b/ mQW67HTmff5sK0Q6SmkemVdDT9/F5bNaOZI+eKXcaMUBMxWKtju3kQx4E/FI3xCe00PpM X-Received: by 2002:a7b:c7d1:0:b0:3fa:9590:a365 with SMTP id z17-20020a7bc7d1000000b003fa9590a365mr11036862wmk.17.1689030335028; Mon, 10 Jul 2023 16:05:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlEUncl2xjLuAfv79XMuvzE8Uknd8OnTNCC83EDohK2+6D9aazUuIYwNA+Iv8ICsrZJqquvMnA== X-Received: by 2002:a7b:c7d1:0:b0:3fa:9590:a365 with SMTP id z17-20020a7bc7d1000000b003fa9590a365mr11036847wmk.17.1689030334748; Mon, 10 Jul 2023 16:05:34 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id w22-20020a1cf616000000b003faef96ee78sm11348818wmc.33.2023.07.10.16.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:05:34 -0700 (PDT) Date: Mon, 10 Jul 2023 19:05:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hawkins Jiawei , Eugenio =?utf-8?b?UMOpcmV6?= , Jason Wang Subject: [PULL 66/66] vdpa: Allow VIRTIO_NET_F_CTRL_RX_EXTRA in SVQ 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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: Hawkins Jiawei Enable SVQ with VIRTIO_NET_F_CTRL_RX_EXTRA feature. Signed-off-by: Hawkins Jiawei Acked-by: Eugenio Pérez Message-Id: <15ecc49975f9b8d1316ed4296879564a18abf31e.1688797728.git.yin31149@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 0c1c0760a7..9795306742 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -111,6 +111,7 @@ static const uint64_t vdpa_svq_device_features = BIT_ULL(VIRTIO_NET_F_STATUS) | BIT_ULL(VIRTIO_NET_F_CTRL_VQ) | BIT_ULL(VIRTIO_NET_F_CTRL_RX) | + BIT_ULL(VIRTIO_NET_F_CTRL_RX_EXTRA) | BIT_ULL(VIRTIO_NET_F_MQ) | BIT_ULL(VIRTIO_F_ANY_LAYOUT) | BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) |