From patchwork Wed Jul 3 22:44:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722953 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1022AC31D97 for ; Wed, 3 Jul 2024 22:46:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8iE-0001xe-07; Wed, 03 Jul 2024 18:44: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 1sP8iC-0001xB-51 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:44:28 -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 1sP8i8-0000rU-2x for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:44:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046662; 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=gfd+vfybB3O3+4pkXHRWr1BbxFsd2M2r8td4r0aSbjQ=; b=DpakpC+RHtybI+92CYXmmvWyEaCPajkHdmO6DksKYxZ1JMOkwIa3Xyp/+T8HBm7782RK4p xR7tnw/DJ16G7ELyPzd2re5bX4LgvngMjbeXZWSEn7GuF5B+7fdPvhl0tNGBBkudl3bozy B8HtXovjLrgQfctKSXIHZMog2eKUW8k= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-VcZP3O6JPY6Kz1FwZBMPZw-1; Wed, 03 Jul 2024 18:44:21 -0400 X-MC-Unique: VcZP3O6JPY6Kz1FwZBMPZw-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-58c7800d03eso4724a12.0 for ; Wed, 03 Jul 2024 15:44:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046660; x=1720651460; 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=gfd+vfybB3O3+4pkXHRWr1BbxFsd2M2r8td4r0aSbjQ=; b=IxuziDzHyDsYa3ktKCGobVQIIv0bOJtWNX7ESDm6KcBNklzHNYfCTjIu3wWUxVWen7 chMIXawif+OT4bnKXr7swP7IqlKt6OvN3RbYCKufVe5X6SOOrTaQxVz08qbzI5M0Cg4Y 6l9xhA0u1Szv5cxCtuytK+nUb0f+HjKSiObrhxstgQNeOl8ZYyZNnBR49J6BlVSMWp8w c43CbjOkrzCzPrLYD852bAFPaNkG0K1HWj4jNcXTZrAebTM4rv5nmxxnfocsuDVOtNEa LnOpFuJItZXLn05/JeTysCIviXNaqcuarz11BrketR2hNzfLf8k2dyGyo505p2u9GHNy +B+A== X-Gm-Message-State: AOJu0YwzAlk3bXCbVYKh9QT7TWGAsEtjTSAToeKcdDdgbaSFji2hpw2U 5mq/W/Q/CXCfv2eLitanpCLkFaNg9j8TY4yblVYl8Q6cDG3mymVT4zWa9SI1P5fTg55DnetMdkF Tnjoc9lkr8sDiWvqFHuZMRrdHbtqlWbegBLQGH9nAIeGRmFMNnQYOm+JGdzhfXqzSSXwX/5q4C3 Qa9nntFD/oI+dzuiccyPyizf+m49leyg== X-Received: by 2002:a05:6402:234f:b0:58d:b83c:6404 with SMTP id 4fb4d7f45d1cf-58db83c65dcmr1084961a12.13.1720046659967; Wed, 03 Jul 2024 15:44:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvcN4XQqXSHuRAhpXDQO35qvl+D4d+Z490OpTN05A3CxxU3CmAwKUebV/X1LB3ywCenaBryA== X-Received: by 2002:a05:6402:234f:b0:58d:b83c:6404 with SMTP id 4fb4d7f45d1cf-58db83c65dcmr1084941a12.13.1720046659138; Wed, 03 Jul 2024 15:44:19 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58613159103sm7632478a12.24.2024.07.03.15.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:44:18 -0700 (PDT) Date: Wed, 3 Jul 2024 18:44:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Si-Wei Liu Subject: [PULL v3 01/85] vhost: dirty log should be per backend type Message-ID: <51d59a64eed6c2cd2d2f991f44ffbe21eb33c733.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Si-Wei Liu There could be a mix of both vhost-user and vhost-kernel clients in the same QEMU process, where separate vhost loggers for the specific vhost type have to be used. Make the vhost logger per backend type, and have them properly reference counted. Suggested-by: Michael S. Tsirkin Signed-off-by: Si-Wei Liu Message-Id: <1710448055-11709-1-git-send-email-si-wei.liu@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost.c | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 4acd77e890..a1e8b79e1a 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -43,8 +43,8 @@ do { } while (0) #endif -static struct vhost_log *vhost_log; -static struct vhost_log *vhost_log_shm; +static struct vhost_log *vhost_log[VHOST_BACKEND_TYPE_MAX]; +static struct vhost_log *vhost_log_shm[VHOST_BACKEND_TYPE_MAX]; /* Memslots used by backends that support private memslots (without an fd). */ static unsigned int used_memslots; @@ -287,6 +287,10 @@ static int vhost_set_backend_type(struct vhost_dev *dev, r = -1; } + if (r == 0) { + assert(dev->vhost_ops->backend_type == backend_type); + } + return r; } @@ -319,16 +323,22 @@ static struct vhost_log *vhost_log_alloc(uint64_t size, bool share) return log; } -static struct vhost_log *vhost_log_get(uint64_t size, bool share) +static struct vhost_log *vhost_log_get(VhostBackendType backend_type, + uint64_t size, bool share) { - struct vhost_log *log = share ? vhost_log_shm : vhost_log; + struct vhost_log *log; + + assert(backend_type > VHOST_BACKEND_TYPE_NONE); + assert(backend_type < VHOST_BACKEND_TYPE_MAX); + + log = share ? vhost_log_shm[backend_type] : vhost_log[backend_type]; if (!log || log->size != size) { log = vhost_log_alloc(size, share); if (share) { - vhost_log_shm = log; + vhost_log_shm[backend_type] = log; } else { - vhost_log = log; + vhost_log[backend_type] = log; } } else { ++log->refcnt; @@ -340,11 +350,20 @@ static struct vhost_log *vhost_log_get(uint64_t size, bool share) static void vhost_log_put(struct vhost_dev *dev, bool sync) { struct vhost_log *log = dev->log; + VhostBackendType backend_type; if (!log) { return; } + assert(dev->vhost_ops); + backend_type = dev->vhost_ops->backend_type; + + if (backend_type == VHOST_BACKEND_TYPE_NONE || + backend_type >= VHOST_BACKEND_TYPE_MAX) { + return; + } + --log->refcnt; if (log->refcnt == 0) { /* Sync only the range covered by the old log */ @@ -352,13 +371,13 @@ static void vhost_log_put(struct vhost_dev *dev, bool sync) vhost_log_sync_range(dev, 0, dev->log_size * VHOST_LOG_CHUNK - 1); } - if (vhost_log == log) { + if (vhost_log[backend_type] == log) { g_free(log->log); - vhost_log = NULL; - } else if (vhost_log_shm == log) { + vhost_log[backend_type] = NULL; + } else if (vhost_log_shm[backend_type] == log) { qemu_memfd_free(log->log, log->size * sizeof(*(log->log)), log->fd); - vhost_log_shm = NULL; + vhost_log_shm[backend_type] = NULL; } g_free(log); @@ -376,7 +395,8 @@ static bool vhost_dev_log_is_shared(struct vhost_dev *dev) static inline void vhost_dev_log_resize(struct vhost_dev *dev, uint64_t size) { - struct vhost_log *log = vhost_log_get(size, vhost_dev_log_is_shared(dev)); + struct vhost_log *log = vhost_log_get(dev->vhost_ops->backend_type, + size, vhost_dev_log_is_shared(dev)); uint64_t log_base = (uintptr_t)log->log; int r; @@ -2044,7 +2064,8 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings) uint64_t log_base; hdev->log_size = vhost_get_log_size(hdev); - hdev->log = vhost_log_get(hdev->log_size, + hdev->log = vhost_log_get(hdev->vhost_ops->backend_type, + hdev->log_size, vhost_dev_log_is_shared(hdev)); log_base = (uintptr_t)hdev->log->log; r = hdev->vhost_ops->vhost_set_log_base(hdev, From patchwork Wed Jul 3 22:44:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722956 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E828BC41513 for ; Wed, 3 Jul 2024 22:46:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8iG-0001yQ-Sd; Wed, 03 Jul 2024 18:44: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 1sP8iF-0001yE-LL for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:44:31 -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 1sP8iD-0000sG-T7 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:44:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046668; 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=uKK/AiLdjMfeKEPpHLdhaqq0Kf5J8WlC0WD4BsUonqY=; b=On/H69i/g4OAD7urwGfAFSCjHWPGdE1QyeibfRBAACOdZNEcVtrmzSWzsD1Uwbi7JWk+GS Gx5PAYb+H+6Hq8uZkCgRlUR5A3x4v/ZGFDi7zvCWXqy82+C6IHaFIDdW2d+wB7XPIEZK58 yJAkgE1EZljL9oJGHzVCPI4HLzqMT4U= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-nE7yoPyCPh6-qmpjdza7Fg-1; Wed, 03 Jul 2024 18:44:26 -0400 X-MC-Unique: nE7yoPyCPh6-qmpjdza7Fg-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-58cd7a95dabso650838a12.2 for ; Wed, 03 Jul 2024 15:44:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046664; x=1720651464; 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=uKK/AiLdjMfeKEPpHLdhaqq0Kf5J8WlC0WD4BsUonqY=; b=g8ThQqX4XCVXIFJQytkm8pgV7kgyAWWL9877wE+b/kndCmBXsAOfZVBJ7E5Wrzejrh 2vFUlFiqEB+ux09aUWh20OqzUo19Kubi7kmIQx1HMuMvoBqGB1L3JLV1O3bBfeu1zk6x JHj+phNyNI1GFkZeL2sGGTjrNkj/5+IqL9ea+iOjiO7j9/IkKvsuQs0ICVvTGgiNK1dp E4HOfp3m+JAuGqUo7nURZLZywD/Y6PsG6kjINNApofJLnYrlMjP+UagnfqKHokJE+O/7 xfb4EQ4bF2sbIxHe03vylsXE9rbM91UPUNsvcxvyT7U6v9XHJl4Dw1D2wbP2fb64FRBd krmw== X-Gm-Message-State: AOJu0YzNu0ZQ524rDlo16DHvVCZv8zxC3y1erV7e8/F2lB7PAno1UFyH J7JIGldj3lN48EgWgRlKJ2VsdcsUmrh/0DtrKHHMXkxxgyeCnIB1If8swzMFOL98hH6RkrfLr1S 6NOlOMWvAYTEu2Fb3IGgR6+33VHrJMNiT54UjenjXuAJc/P1DA4VGsPhKMaSXe+kaAUQFYD8TfZ 7puZwoJqWKfbArUldDZBuELFX0uDowXw== X-Received: by 2002:a05:6402:1913:b0:587:2dd1:4b6c with SMTP id 4fb4d7f45d1cf-587a0822bdemr11691843a12.30.1720046663912; Wed, 03 Jul 2024 15:44:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPVA3gyimLwz7HWkXro6XcDKREO2jj8DTMtOdzI7ag7EE0wqmlhPN0pJg9R4LjRAs0oKo9zA== X-Received: by 2002:a05:6402:1913:b0:587:2dd1:4b6c with SMTP id 4fb4d7f45d1cf-587a0822bdemr11691824a12.30.1720046663179; Wed, 03 Jul 2024 15:44:23 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58d3ab39f06sm1138310a12.5.2024.07.03.15.44.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:44:22 -0700 (PDT) Date: Wed, 3 Jul 2024 18:44:19 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Si-Wei Liu , Joao Martins , Jason Wang Subject: [PULL v3 02/85] vhost: Perform memory section dirty scans once per iteration 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Si-Wei Liu On setups with one or more virtio-net devices with vhost on, dirty tracking iteration increases cost the bigger the number amount of queues are set up e.g. on idle guests migration the following is observed with virtio-net with vhost=on: 48 queues -> 78.11% [.] vhost_dev_sync_region.isra.13 8 queues -> 40.50% [.] vhost_dev_sync_region.isra.13 1 queue -> 6.89% [.] vhost_dev_sync_region.isra.13 2 devices, 1 queue -> 18.60% [.] vhost_dev_sync_region.isra.14 With high memory rates the symptom is lack of convergence as soon as it has a vhost device with a sufficiently high number of queues, the sufficient number of vhost devices. On every migration iteration (every 100msecs) it will redundantly query the *shared log* the number of queues configured with vhost that exist in the guest. For the virtqueue data, this is necessary, but not for the memory sections which are the same. So essentially we end up scanning the dirty log too often. To fix that, select a vhost device responsible for scanning the log with regards to memory sections dirty tracking. It is selected when we enable the logger (during migration) and cleared when we disable the logger. If the vhost logger device goes away for some reason, the logger will be re-selected from the rest of vhost devices. After making mem-section logger a singleton instance, constant cost of 7%-9% (like the 1 queue report) will be seen, no matter how many queues or how many vhost devices are configured: 48 queues -> 8.71% [.] vhost_dev_sync_region.isra.13 2 devices, 8 queues -> 7.97% [.] vhost_dev_sync_region.isra.14 Co-developed-by: Joao Martins Signed-off-by: Joao Martins Signed-off-by: Si-Wei Liu Message-Id: <1710448055-11709-2-git-send-email-si-wei.liu@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- include/hw/virtio/vhost.h | 1 + hw/virtio/vhost.c | 67 +++++++++++++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 6 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 02477788df..d75faf46e9 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -129,6 +129,7 @@ struct vhost_dev { void *opaque; struct vhost_log *log; QLIST_ENTRY(vhost_dev) entry; + QLIST_ENTRY(vhost_dev) logdev_entry; QLIST_HEAD(, vhost_iommu) iommu_list; IOMMUNotifier n; const VhostDevConfigOps *config_ops; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index a1e8b79e1a..06fc71746e 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -45,6 +45,7 @@ static struct vhost_log *vhost_log[VHOST_BACKEND_TYPE_MAX]; static struct vhost_log *vhost_log_shm[VHOST_BACKEND_TYPE_MAX]; +static QLIST_HEAD(, vhost_dev) vhost_log_devs[VHOST_BACKEND_TYPE_MAX]; /* Memslots used by backends that support private memslots (without an fd). */ static unsigned int used_memslots; @@ -149,6 +150,47 @@ bool vhost_dev_has_iommu(struct vhost_dev *dev) } } +static inline bool vhost_dev_should_log(struct vhost_dev *dev) +{ + assert(dev->vhost_ops); + assert(dev->vhost_ops->backend_type > VHOST_BACKEND_TYPE_NONE); + assert(dev->vhost_ops->backend_type < VHOST_BACKEND_TYPE_MAX); + + return dev == QLIST_FIRST(&vhost_log_devs[dev->vhost_ops->backend_type]); +} + +static inline void vhost_dev_elect_mem_logger(struct vhost_dev *hdev, bool add) +{ + VhostBackendType backend_type; + + assert(hdev->vhost_ops); + + backend_type = hdev->vhost_ops->backend_type; + assert(backend_type > VHOST_BACKEND_TYPE_NONE); + assert(backend_type < VHOST_BACKEND_TYPE_MAX); + + if (add && !QLIST_IS_INSERTED(hdev, logdev_entry)) { + if (QLIST_EMPTY(&vhost_log_devs[backend_type])) { + QLIST_INSERT_HEAD(&vhost_log_devs[backend_type], + hdev, logdev_entry); + } else { + /* + * The first vhost_device in the list is selected as the shared + * logger to scan memory sections. Put new entry next to the head + * to avoid inadvertent change to the underlying logger device. + * This is done in order to get better cache locality and to avoid + * performance churn on the hot path for log scanning. Even when + * new devices come and go quickly, it wouldn't end up changing + * the active leading logger device at all. + */ + QLIST_INSERT_AFTER(QLIST_FIRST(&vhost_log_devs[backend_type]), + hdev, logdev_entry); + } + } else if (!add && QLIST_IS_INSERTED(hdev, logdev_entry)) { + QLIST_REMOVE(hdev, logdev_entry); + } +} + static int vhost_sync_dirty_bitmap(struct vhost_dev *dev, MemoryRegionSection *section, hwaddr first, @@ -166,12 +208,14 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *dev, start_addr = MAX(first, start_addr); end_addr = MIN(last, end_addr); - for (i = 0; i < dev->mem->nregions; ++i) { - struct vhost_memory_region *reg = dev->mem->regions + i; - vhost_dev_sync_region(dev, section, start_addr, end_addr, - reg->guest_phys_addr, - range_get_last(reg->guest_phys_addr, - reg->memory_size)); + if (vhost_dev_should_log(dev)) { + for (i = 0; i < dev->mem->nregions; ++i) { + struct vhost_memory_region *reg = dev->mem->regions + i; + vhost_dev_sync_region(dev, section, start_addr, end_addr, + reg->guest_phys_addr, + range_get_last(reg->guest_phys_addr, + reg->memory_size)); + } } for (i = 0; i < dev->nvqs; ++i) { struct vhost_virtqueue *vq = dev->vqs + i; @@ -383,6 +427,7 @@ static void vhost_log_put(struct vhost_dev *dev, bool sync) g_free(log); } + vhost_dev_elect_mem_logger(dev, false); dev->log = NULL; dev->log_size = 0; } @@ -998,6 +1043,15 @@ static int vhost_dev_set_log(struct vhost_dev *dev, bool enable_log) goto err_vq; } } + + /* + * At log start we select our vhost_device logger that will scan the + * memory sections and skip for the others. This is possible because + * the log is shared amongst all vhost devices for a given type of + * backend. + */ + vhost_dev_elect_mem_logger(dev, enable_log); + return 0; err_vq: for (; i >= 0; --i) { @@ -2075,6 +2129,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev, bool vrings) VHOST_OPS_DEBUG(r, "vhost_set_log_base failed"); goto fail_log; } + vhost_dev_elect_mem_logger(hdev, true); } if (vrings) { r = vhost_dev_set_vring_enable(hdev, true); From patchwork Wed Jul 3 22:44:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF617C31D97 for ; Wed, 3 Jul 2024 22:49:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8iQ-000220-7o; Wed, 03 Jul 2024 18:44: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 1sP8iO-00021Q-Fa for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:44: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 1sP8iM-0000sn-RZ for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:44:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046677; 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=ZMYpex8C2s46cF0GfMcoGvUcCxmqXFvGY/Nt+8TTLHo=; b=K0VyH5rpSv2qWcn15X/c1ktc8DjuhIzw2bRqKZc5zIzyL0xFp9XbppFbJhEoAzbXvbO7w6 +SBrX67u36x/1O6ED4Nna8HZqzmGM+AVjdWT9sfAJAzen2s+nDqXi7PZ28YGn5VH+ftT6N 3lQzZx81SCHa6etp2bgKutGXiyTvCW4= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-302-jUUD6836Pout-wHBxs9P_Q-1; Wed, 03 Jul 2024 18:44:32 -0400 X-MC-Unique: jUUD6836Pout-wHBxs9P_Q-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-58c859c5d96so1038560a12.3 for ; Wed, 03 Jul 2024 15:44:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046669; x=1720651469; 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=ZMYpex8C2s46cF0GfMcoGvUcCxmqXFvGY/Nt+8TTLHo=; b=NToue104VHqhuFnp5biaGZPP9vOhMYlPO8ssNuHI03H6xFFNF1GTKOSf+wYJwOrcoL Y4naQ1wBtWye/qekII8hgkSBoby9zrwZF4BofuF4eYc/fD+i1717VBVVJKq2eAPkW8lT sVaKN2NPw+1TBo6SGm9T21AgiJX1hH6xWaEqHRvSq9GziaoUo1R/hZhJJungOD8h9lhQ z5tJAdxHtg1QLcDGd0EM/B3RBB6BFFXAu3LwvP+C3h5AM5HwZbJhNP8S25VhnkV9a08T +Vh+NdBuFRHl6eP++G/OncZ+jSFS3AFIRLtx+h1FzXTesTteePGM2ailDKH5GHeVmeVy qC5w== X-Gm-Message-State: AOJu0YzVISAWFBA2v+Di+m+u8EY0yQqd2Ze7WrOCSL8d/+WxEVjrp4FD tq8h/8DSLGnDohSYA+kmhFjzT7Klb0SK491PwVIi4sh/KpE3PibmrTp6GcPmWncFCW3cQQnxV6Q 2OZJcmOyhRdG1pTexlYnWQCCwjAvsqIA1SbMbcK7m2vuCFqSpCM+7qwJgkIlF4hP2wdioQ67Fx/ 1d73Z3HLfqr021xPb7yF2OwhdJAv9Oow== X-Received: by 2002:a05:6402:1e8b:b0:586:e6a4:c173 with SMTP id 4fb4d7f45d1cf-587a0bfc6b1mr8196016a12.28.1720046668963; Wed, 03 Jul 2024 15:44:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1d1GPAdI2F06sCYFgpvk4JO5xApbuY9Xuo/L8KpkO9Y+sLuGXCWsuVH2M0HkQAJ5YHoeRLw== X-Received: by 2002:a05:6402:1e8b:b0:586:e6a4:c173 with SMTP id 4fb4d7f45d1cf-587a0bfc6b1mr8195997a12.28.1720046668391; Wed, 03 Jul 2024 15:44:28 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58ceee04b51sm1362861a12.71.2024.07.03.15.44.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:44:27 -0700 (PDT) Date: Wed, 3 Jul 2024 18:44:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , Eugenio =?utf-8?b?UMOpcmV6?= , Jason Wang , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PULL v3 03/85] vhost-vdpa: check vhost_vdpa_set_vring_ready() return value Message-ID: <9d5a807c4cb56837f11be9a9250f854fab951290.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stefano Garzarella vhost_vdpa_set_vring_ready() could already fail, but if Linux's patch [1] will be merged, it may fail with more chance if userspace does not activate virtqueues before DRIVER_OK when VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK is not negotiated. So better check its return value anyway. [1] https://lore.kernel.org/virtualization/20240206145154.118044-1-sgarzare@redhat.com/T/#u Acked-by: Eugenio Pérez Acked-by: Jason Wang Signed-off-by: Stefano Garzarella Message-Id: <20240322092315.31885-1-sgarzare@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- net/vhost-vdpa.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 85e73dd6a7..eda714d1a4 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -399,7 +399,10 @@ static int vhost_vdpa_net_data_load(NetClientState *nc) } for (int i = 0; i < v->dev->nvqs; ++i) { - vhost_vdpa_set_vring_ready(v, i + v->dev->vq_index); + int ret = vhost_vdpa_set_vring_ready(v, i + v->dev->vq_index); + if (ret < 0) { + return ret; + } } return 0; } @@ -1238,7 +1241,10 @@ static int vhost_vdpa_net_cvq_load(NetClientState *nc) assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA); - vhost_vdpa_set_vring_ready(v, v->dev->vq_index); + r = vhost_vdpa_set_vring_ready(v, v->dev->vq_index); + if (unlikely(r < 0)) { + return r; + } if (v->shadow_vqs_enabled) { n = VIRTIO_NET(v->dev->vdev); @@ -1277,7 +1283,10 @@ static int vhost_vdpa_net_cvq_load(NetClientState *nc) } for (int i = 0; i < v->dev->vq_index; ++i) { - vhost_vdpa_set_vring_ready(v, i); + r = vhost_vdpa_set_vring_ready(v, i); + if (unlikely(r < 0)) { + return r; + } } return 0; From patchwork Wed Jul 3 22:44:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722952 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79E58C2BD09 for ; Wed, 3 Jul 2024 22:46:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8iR-00022L-Ef; Wed, 03 Jul 2024 18:44: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 1sP8iQ-000222-DN for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:44: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 1sP8iL-0000sr-OA for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:44:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046677; 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=rU41nJqg3mDUGH1bcBpKF5g1VLC3bOtqyqIezIWqM9s=; b=EmR4LJ0inU5W99aJfRYs8dQtmDsT+KteuVWQqDv6AhHj17x7QLv1fqVbPWNGfFaCfiEAhJ wH40cOc/didbvN+X28UhGhI5Nw3Jc1GrI8pyhPi9Wi6CunqCOGvqWKhBiGy1u3j8G7iJ0h XzX6tOrpEQiLY46RYb//njo9CBB/VxE= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-446-LYi9pBkMO0idL0PD5lrAjQ-1; Wed, 03 Jul 2024 18:44:36 -0400 X-MC-Unique: LYi9pBkMO0idL0PD5lrAjQ-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a72436378bdso1152366b.1 for ; Wed, 03 Jul 2024 15:44:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046674; x=1720651474; 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=rU41nJqg3mDUGH1bcBpKF5g1VLC3bOtqyqIezIWqM9s=; b=SJ9gn//d80V66eTBZyQgSloZCZSr/rVjRJxQoMz/XXdMm6zNY+6xB27tJnPiuvci15 A2VopJBbrodz6sxSNjm3WcPWPvNfDEhKcpu5ywcg3iFExVfkrX9VZZFpJkS+84kU33K/ YcCTgHdXo64HORAKsqNiBfqm2YOI09cjXYxSnue+N00raJPsvlDSfT/gqWBPvIbvNzlI KM06HOVJLNbbf7I6xB5B+9jByHg8gNnpnhszTUsauexB8YExHVAfHhXM2+ZSSJjfw7wp 9ol9OniLV7MwUAlFvSd3ZJ0UEAA5by1OrOPaJuExDEz3KqcJfwr319EVE1hcygm0J7vd jrOA== X-Gm-Message-State: AOJu0YyrrLszi10xLgZ9wTCk4T4afs9kFxBmEeGr3ViuZ4tAdO89iWPq MKJDdEYzfLSbdLAeTlyqg9pIFlxH0BaFfY/UDq9kdv3b0malTZOjqVneLrBgpbM6/q3xhU8Mp2m qkxZGszzL6dkn8BgXLNUYB3H6uXBr/1v1AiVKxPmPlG+sNHCJYB3XNr4iuG284MQdts2TyupFpH ac2N5eDYSDShHXtODRPY0zgC4qmoIeVA== X-Received: by 2002:a17:907:6e9f:b0:a6f:668b:3442 with SMTP id a640c23a62f3a-a75144de9c7mr838167966b.77.1720046674370; Wed, 03 Jul 2024 15:44:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGq7GHOZ+FvW4R+yCyNqJUbyJV5EMmQwZDW8qsKuD2pWcSkK8f+BVPQfmJWbCixKkaImfdFMw== X-Received: by 2002:a17:907:6e9f:b0:a6f:668b:3442 with SMTP id a640c23a62f3a-a75144de9c7mr838165966b.77.1720046673380; Wed, 03 Jul 2024 15:44:33 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf1ba77sm545010666b.33.2024.07.03.15.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:44:32 -0700 (PDT) Date: Wed, 3 Jul 2024 18:44:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Eugenio =?utf-8?b?UMOpcmV6?= Subject: [PULL v3 04/85] virtio/virtio-pci: Handle extra notification data 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, 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonah Palmer Add support to virtio-pci devices for handling the extra data sent from the driver to the device when the VIRTIO_F_NOTIFICATION_DATA transport feature has been negotiated. The extra data that's passed to the virtio-pci device when this feature is enabled varies depending on the device's virtqueue layout. In a split virtqueue layout, this data includes: - upper 16 bits: shadow_avail_idx - lower 16 bits: virtqueue index In a packed virtqueue layout, this data includes: - upper 16 bits: 1-bit wrap counter & 15-bit shadow_avail_idx - lower 16 bits: virtqueue index Signed-off-by: Jonah Palmer Message-Id: <20240315165557.26942-2-jonah.palmer@oracle.com> Reviewed-by: Eugenio Pérez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 2 ++ hw/virtio/virtio-pci.c | 12 +++++++++--- hw/virtio/virtio.c | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 7d5ffdc145..1451926a13 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -307,6 +307,8 @@ int virtio_queue_ready(VirtQueue *vq); int virtio_queue_empty(VirtQueue *vq); +void virtio_queue_set_shadow_avail_idx(VirtQueue *vq, uint16_t idx); + /* Host binding interface. */ uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr); diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index b1d02f4b3d..cffc7efcae 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -384,7 +384,7 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val) { VirtIOPCIProxy *proxy = opaque; VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); - uint16_t vector; + uint16_t vector, vq_idx; hwaddr pa; switch (addr) { @@ -408,8 +408,14 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val) vdev->queue_sel = val; break; case VIRTIO_PCI_QUEUE_NOTIFY: - if (val < VIRTIO_QUEUE_MAX) { - virtio_queue_notify(vdev, val); + vq_idx = val; + if (vq_idx < VIRTIO_QUEUE_MAX && virtio_queue_get_num(vdev, vq_idx)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_F_NOTIFICATION_DATA)) { + VirtQueue *vq = virtio_get_queue(vdev, vq_idx); + + virtio_queue_set_shadow_avail_idx(vq, val >> 16); + } + virtio_queue_notify(vdev, vq_idx); } break; case VIRTIO_PCI_STATUS: diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 893a072c9d..f7c99e3a96 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2264,6 +2264,24 @@ void virtio_queue_set_align(VirtIODevice *vdev, int n, int align) } } +void virtio_queue_set_shadow_avail_idx(VirtQueue *vq, uint16_t shadow_avail_idx) +{ + if (!vq->vring.desc) { + return; + } + + /* + * 16-bit data for packed VQs include 1-bit wrap counter and + * 15-bit shadow_avail_idx. + */ + if (virtio_vdev_has_feature(vq->vdev, VIRTIO_F_RING_PACKED)) { + vq->shadow_avail_wrap_counter = (shadow_avail_idx >> 15) & 0x1; + vq->shadow_avail_idx = shadow_avail_idx & 0x7FFF; + } else { + vq->shadow_avail_idx = shadow_avail_idx; + } +} + static void virtio_queue_notify_vq(VirtQueue *vq) { if (vq->vring.desc && vq->handle_output) { From patchwork Wed Jul 3 22:44:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8070BC2BD09 for ; Wed, 3 Jul 2024 22:45:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8iS-00022l-OP; Wed, 03 Jul 2024 18:44:44 -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 1sP8iQ-00022B-Ne for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:44: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 1sP8iP-0000tN-80 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:44:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046680; 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=czI6QAqPz2gxBOi54M6w2CiDVJgkcwfGVW3OGis4Be4=; b=UUSTtBZ0iskQvP0Tlxk3vJ83C2bnyLLAF0t02TCIeGZn3KbZQEgtc5N2ceDNJsGXlMmaW4 DP2uBs9SMHAggMm4H6BSh8i+Gc3dP+qTs0M0CR+Zz87L1EF7K7Rgqf2n/nhWiooMSee5fD 5EN9LSx+B2059mTIm33qa/c7hbPWNe8= 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-230-M6yfTxGHPByf42RpDEhRYQ-1; Wed, 03 Jul 2024 18:44:39 -0400 X-MC-Unique: M6yfTxGHPByf42RpDEhRYQ-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4256718144dso23595e9.1 for ; Wed, 03 Jul 2024 15:44:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046678; x=1720651478; 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=czI6QAqPz2gxBOi54M6w2CiDVJgkcwfGVW3OGis4Be4=; b=KdpgsWVQTwVB2jPgX5+gSSFwko9WuDQ7Haf85GJoGzpmiwiPyAvE34Mo2OUKVsgsi/ a6kibXciNc4XKETZoYjtkBpdqr4rc+UBbzbImYLqkd5Jub3TCN0wXyfqSt05vbYHG/WA XEULwdiK5EGlJ66Ln16FfedAvg3/1utEKzgYEV4cdfrZRWFfWliXIY+tLLuH/TcE1nmz 3DpriYZRmfMIty3aC5TLmxZFx4Q/Z32R1WCrfQnaP6ob/Ll0SUL0twMC3JrvlPK1ysLU GI2RixbdtOnNMUmJOSVGSks0jCJbeXcd2x3pmP71X/W3u866zoWPh7V1BCOQV9LUMzsQ s3eA== X-Gm-Message-State: AOJu0YzzZ6O9kNyiw8DcbDoQsTN+TB3M9+vMwsZprkW08K3oQeRcROhD A8r7V8WZQfASIJ1SD7FCBFhg9QlWZPeuy05sQ/xSpfV2lYj9kYT0zsMTw00s38IefFhq/i0y6x/ pQvnj2mg0oNbQQwTjkt4vGhDhOcVyJsfFUxsdgCLGJzpoOPGqJu0WU6glKq3/CXHsNvBSGvXVbe 8Ppp+tWwsFjNq99sukuyCGgZvHzuvDdQ== X-Received: by 2002:adf:e552:0:b0:367:92c7:3ac0 with SMTP id ffacd0b85a97d-3679dd2761dmr9451f8f.22.1720046678271; Wed, 03 Jul 2024 15:44:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGB0Gz7EUxGj1I1NI838U7/bX3Gq2PsJCDUswCTVJ6CyTi4vb76KelzWvyEng5YTwwgwrwYOg== X-Received: by 2002:adf:e552:0:b0:367:92c7:3ac0 with SMTP id ffacd0b85a97d-3679dd2761dmr9414f8f.22.1720046677312; Wed, 03 Jul 2024 15:44:37 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aafb3c2esm548349866b.91.2024.07.03.15.44.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:44:36 -0700 (PDT) Date: Wed, 3 Jul 2024 18:44:33 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer Subject: [PULL v3 05/85] virtio: Prevent creation of device using notification-data with ioeventfd Message-ID: <78378f450a723eed34156259ca2861a0c5ca77cf.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonah Palmer Prevent the realization of a virtio device that attempts to use the VIRTIO_F_NOTIFICATION_DATA transport feature without disabling ioeventfd. Due to ioeventfd not being able to carry the extra data associated with this feature, having both enabled is a functional mismatch and therefore Qemu should not continue the device's realization process. Although the device does not yet know if the feature will be successfully negotiated, many devices using this feature wont actually work without this extra data and would fail FEATURES_OK anyway. If ioeventfd is able to work with the extra notification data in the future, this compatibility check can be removed. Signed-off-by: Jonah Palmer Message-Id: <20240315165557.26942-3-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index f7c99e3a96..28cd406e16 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2980,6 +2980,20 @@ int virtio_set_features(VirtIODevice *vdev, uint64_t val) return ret; } +static void virtio_device_check_notification_compatibility(VirtIODevice *vdev, + Error **errp) +{ + VirtioBusState *bus = VIRTIO_BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(bus); + DeviceState *proxy = DEVICE(BUS(bus)->parent); + + if (virtio_host_has_feature(vdev, VIRTIO_F_NOTIFICATION_DATA) && + k->ioeventfd_enabled(proxy)) { + error_setg(errp, + "notification_data=on without ioeventfd=off is not supported"); + } +} + size_t virtio_get_config_size(const VirtIOConfigSizeParams *params, uint64_t host_features) { @@ -3740,6 +3754,14 @@ static void virtio_device_realize(DeviceState *dev, Error **errp) } } + /* Devices should not use both ioeventfd and notification data feature */ + virtio_device_check_notification_compatibility(vdev, &err); + if (err != NULL) { + error_propagate(errp, err); + vdc->unrealize(dev); + return; + } + virtio_bus_device_plugged(vdev, &err); if (err != NULL) { error_propagate(errp, err); From patchwork Wed Jul 3 22:44:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722951 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D1618C31D97 for ; Wed, 3 Jul 2024 22:45:52 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8iX-00023P-V3; Wed, 03 Jul 2024 18:44:50 -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 1sP8iW-000234-B2 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:44:48 -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 1sP8iU-0000te-UR for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:44:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046686; 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=uByx4Oz+CQ80E+9HMb1HUHKkD83RXYCyv+000WUVwgE=; b=MLYrDlrZ9xe/2FZrpRoVU754aqYpqqgfN3xIZ8gr02AJ9RYs99z+4/McsxPqa8b4WNIbfU hMyDIZNw3NaEzAnJYXQ2ZyD7HxOZ2frCq3ijLZE7Q4cmJrHduNpS8xCIJcMBzw6FyDHArm AM4qkRKtcQbBEmdB1vmPjL1CxToOHG4= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-361-qV9kRkMxOk-t4ziYx-A18A-1; Wed, 03 Jul 2024 18:44:44 -0400 X-MC-Unique: qV9kRkMxOk-t4ziYx-A18A-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a751eb024abso1034566b.0 for ; Wed, 03 Jul 2024 15:44:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046682; x=1720651482; 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=uByx4Oz+CQ80E+9HMb1HUHKkD83RXYCyv+000WUVwgE=; b=mzMWkITh5ajbz7ZhtErh0cFih7gAMg6WlqlYIyml6wYuuT0pl2RqnmFlU5556FpdbI +eU1S2Qh3wicMRzVXUKokN4WmOYbC0y+1JDk0t7kVHlMHve8L0nl6xe7j+a8dlA1pWkY 2Vgp+5jfjAswOvtvo/s2tyJ6lVWBTEv43MJnRX57r2b5wT9F3YyGFP9UVYp/lc864vEu 9QM54HL1VFt8hESZ1o6J0+v0ciZwf5xlX1DjtAj0Fv4gmdUQR2YfuKxMQT4qHQ9Fnl+0 Cf/6J1babYnPXPKMiqQqPEXSI9iNbtZMi7kkZWMqW4X5Xs4STjN/PvGz9Gk98EPZc3/f +wIg== X-Gm-Message-State: AOJu0YwzcFLHJ5a2rzfMbUs9P5fHejRgeRSGRqo9FPPzgDUQ3YZOdh4/ r9d/oxbrV4c/np3s/n+m2LxBR8djnih1+H5n955A3Jm2V3oXxhB/w/4M9W6UJWw5O7D+yqKeEA5 MAk5Hj81Xng6NmVfZicBVAZygYSRFEWvnKbDWNulRFaCuIINLjCl1IUwwu81rs/o6ZtnWjJ/XIG Bfa6E3f5vGGu2Y36qY7ZISuglzmSlDhA== X-Received: by 2002:a05:6402:1d53:b0:57c:dd3a:f399 with SMTP id 4fb4d7f45d1cf-5879f3ac31cmr12412872a12.12.1720046682750; Wed, 03 Jul 2024 15:44:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6BaNgtRNtOqLP1M0YQIRWr9YOpRrDtW1kO6IfIIC+qIuz6K7XGhED+kG1EAzMMhOoJlj4gw== X-Received: by 2002:a05:6402:1d53:b0:57c:dd3a:f399 with SMTP id 4fb4d7f45d1cf-5879f3ac31cmr12412849a12.12.1720046681755; Wed, 03 Jul 2024 15:44:41 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58b4a97b1f3sm2914010a12.18.2024.07.03.15.44.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:44:41 -0700 (PDT) Date: Wed, 3 Jul 2024 18:44:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer Subject: [PULL v3 06/85] virtio-mmio: Handle extra notification data Message-ID: <54869366be60af2eb52cffaedad73ba1f4247e15.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonah Palmer Add support to virtio-mmio devices for handling the extra data sent from the driver to the device when the VIRTIO_F_NOTIFICATION_DATA transport feature has been negotiated. The extra data that's passed to the virtio-mmio device when this feature is enabled varies depending on the device's virtqueue layout. The data passed to the virtio-mmio device is in the same format as the data passed to virtio-pci devices. Signed-off-by: Jonah Palmer Message-Id: <20240315165557.26942-4-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mmio.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 22f9fbcf5a..320428ac0d 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -248,6 +248,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value, { VirtIOMMIOProxy *proxy = (VirtIOMMIOProxy *)opaque; VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); + uint16_t vq_idx; trace_virtio_mmio_write_offset(offset, value); @@ -407,8 +408,14 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value, } break; case VIRTIO_MMIO_QUEUE_NOTIFY: - if (value < VIRTIO_QUEUE_MAX) { - virtio_queue_notify(vdev, value); + vq_idx = value; + if (vq_idx < VIRTIO_QUEUE_MAX && virtio_queue_get_num(vdev, vq_idx)) { + if (virtio_vdev_has_feature(vdev, VIRTIO_F_NOTIFICATION_DATA)) { + VirtQueue *vq = virtio_get_queue(vdev, vq_idx); + + virtio_queue_set_shadow_avail_idx(vq, (value >> 16) & 0xFFFF); + } + virtio_queue_notify(vdev, vq_idx); } break; case VIRTIO_MMIO_INTERRUPT_ACK: From patchwork Wed Jul 3 22:44:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14823C2BD09 for ; Wed, 3 Jul 2024 22:46:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8iw-00029z-RE; Wed, 03 Jul 2024 18:45: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 1sP8it-00028A-Al for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45: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 1sP8id-0000uG-Ch for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046693; 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=N8epoI+2XR2IZhKNbWvFqqmIBG6jX2/y5dIWNKzyj2M=; b=Gtu+L2sQgngilZs8geSlmw7cr+6Cb/ZpOfaWjROhKwY74YiKsYL1WiWCL0hnmOS/oMlTPS rw6sUKO7l8atv8EecYYpsjwDuHJKABkZERFJE703IDCX+/MsfMWExNbfGmiWe+Nbcj08lZ PW8mk8YlebKxmQWixzMV7qxqss6OdtM= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-ITj7JCrkP9e4PEdjslWTDQ-1; Wed, 03 Jul 2024 18:44:49 -0400 X-MC-Unique: ITj7JCrkP9e4PEdjslWTDQ-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a77af33ce50so1193666b.2 for ; Wed, 03 Jul 2024 15:44:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046688; x=1720651488; 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=N8epoI+2XR2IZhKNbWvFqqmIBG6jX2/y5dIWNKzyj2M=; b=pg+POTc2S8LlZlqoIQnd89fdYGH0yovm7Ml8ZZRh0tW+lGPAJj6AAYLh/u1txuDBA2 AOvDp6AbxsASx0/vXz0aRDZ7Np5PGCQ4r5SUSlSJR7py2RQqfObV2jaxLhxKURWvU6Du QG994EP40e75Z4nsMSvoDO8ytqGConrk2k3eukf4iZaG7g8k2io8zbN+kc43CdoIabLJ z78hmJWCbn6yLX8HHZeOuEGKrySmWw2thKzuqR9w0ZCmjuYKjOgGDg5gXgOsgKMXwN/N yHmyeym6Hf2G6WPBd1kXH/GEzUmqRuJV9b9NDMcwJ5h/DdNACVB6isiVBrvVPqmibxD9 z5oQ== X-Gm-Message-State: AOJu0YzgXuYRt4nidcHynOK4i0hxQIonQXSkfDZZmbwz1h6KR3z1IJFl WT9w2i6ORDX2qw4g+wkEX4e0friK5TGkz37m7OjDJsDNMZcAO16p/BW19bioB5OF1fA57b6qrwl KpZAWNAcDSkZBTF/vuU8UJX0qq4L9u8RFjzqP6VMyAitmjqny2SWIWEDc6DVpTBgT7A4jKW6ziP 3PJzyH+dOceCsSb9ZfHoJ7PSe+4x1N4g== X-Received: by 2002:a17:906:f2d3:b0:a72:7e82:7a15 with SMTP id a640c23a62f3a-a751440e853mr719976666b.23.1720046688355; Wed, 03 Jul 2024 15:44:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYEQfzEs56MqWzOGDNAszCwhmos9UJKAtVuYn8Pk/MD4SYmLmw+MWhidktg1HcFjUSI8B+rw== X-Received: by 2002:a17:906:f2d3:b0:a72:7e82:7a15 with SMTP id a640c23a62f3a-a751440e853mr719974566b.23.1720046687334; Wed, 03 Jul 2024 15:44:47 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72b4280d6bsm501909866b.206.2024.07.03.15.44.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:44:46 -0700 (PDT) Date: Wed, 3 Jul 2024 18:44:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Halil Pasic , Christian Borntraeger , Eric Farman , qemu-s390x@nongnu.org Subject: [PULL v3 07/85] virtio-ccw: Handle extra notification data Message-ID: <594b543a4a75d08f47e5ea92c96a89502a3eab72.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonah Palmer Add support to virtio-ccw devices for handling the extra data sent from the driver to the device when the VIRTIO_F_NOTIFICATION_DATA transport feature has been negotiated. The extra data that's passed to the virtio-ccw device when this feature is enabled varies depending on the device's virtqueue layout. That data passed to the virtio-ccw device is in the same format as the data passed to virtio-pci devices. Signed-off-by: Jonah Palmer Message-Id: <20240315165557.26942-5-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/s390x/s390-virtio-ccw.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index cd063f8b64..8cd912f20e 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -126,9 +126,11 @@ static void subsystem_reset(void) static int virtio_ccw_hcall_notify(const uint64_t *args) { uint64_t subch_id = args[0]; - uint64_t queue = args[1]; + uint64_t data = args[1]; SubchDev *sch; + VirtIODevice *vdev; int cssid, ssid, schid, m; + uint16_t vq_idx = data; if (ioinst_disassemble_sch_ident(subch_id, &m, &cssid, &ssid, &schid)) { return -EINVAL; @@ -137,12 +139,19 @@ static int virtio_ccw_hcall_notify(const uint64_t *args) if (!sch || !css_subch_visible(sch)) { return -EINVAL; } - if (queue >= VIRTIO_QUEUE_MAX) { + + vdev = virtio_ccw_get_vdev(sch); + if (vq_idx >= VIRTIO_QUEUE_MAX || !virtio_queue_get_num(vdev, vq_idx)) { return -EINVAL; } - virtio_queue_notify(virtio_ccw_get_vdev(sch), queue); - return 0; + if (virtio_vdev_has_feature(vdev, VIRTIO_F_NOTIFICATION_DATA)) { + virtio_queue_set_shadow_avail_idx(virtio_get_queue(vdev, vq_idx), + (data >> 16) & 0xFFFF); + } + + virtio_queue_notify(vdev, vq_idx); + return 0; } static int virtio_ccw_hcall_early_printk(const uint64_t *args) From patchwork Wed Jul 3 22:44:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723014 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6E78CC31D97 for ; Wed, 3 Jul 2024 22:51:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8ir-000271-1R; Wed, 03 Jul 2024 18:45: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 1sP8ip-00026P-DC for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:07 -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 1sP8if-0000uk-Lc for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046696; 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=OCCVtvSfvqBAUBpNFi/zb/m65iBLwl7XEHTViiftxcE=; b=cFcuxYfTKzBoBlpLQ1q3nbc3ddngwye/0gnRYLQE/giHBsplqhy+7Ivl5vfIgl+6NEWwyH uVyCACkP4Kte0eknVfpnlm/lLceA+cVvZbe/RLc58heN2oneNNZlulpVohIW344XPhXMk2 Xqx90lsJeGx1pxGY+CT12Zey3rtVESE= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-279-AQyMzSOENR-7lRw03WptyA-1; Wed, 03 Jul 2024 18:44:54 -0400 X-MC-Unique: AQyMzSOENR-7lRw03WptyA-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-57d5467c427so5923a12.0 for ; Wed, 03 Jul 2024 15:44:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046693; x=1720651493; 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=OCCVtvSfvqBAUBpNFi/zb/m65iBLwl7XEHTViiftxcE=; b=aeSeJk4iSHXhlOixWCXtrtS16mqnE479kVazD6Y2iyTWe+eSqbuS+/KOjKcRnfhyw0 Q5K1knWBpNhPgVWIuYlp8yVDBc+gEyooF0JBnijQFPlgCo63nXkoA8rd2wNjxoiOqaf5 PHorJd1xHYk4Yc4YOTWTGao0wq5Sn6b+LxoCgaAgqsNhzgBdqEkgYgogQe/CON9Rxt5a NStz958l/V95379eAiw6BRP/A4jwBARngT/3G7a6HD2X4mvQWA7IqpjCx16hXbtKjy5P TfiOutp9Kwrx5qx0b7FgKTiOy1L/gcqz+Sq3cXVZ7HQEnLaIzL8/rhzn1s4z0rU1ovGc nXGQ== X-Gm-Message-State: AOJu0Yxc08KaWP6f00nLNIxmh7TVLQwmu7xSXXQCAQkiP813NMINfxRD Y4Urm2skn+gNY1op/OP/9bgrXKSBJ1AKh+oyC88mUqNEdOL/9iZGQke+5l0rtgxz3JUAxxNx+4u YX4Lxgq38zNQpVdWcffFoxEuejrc4UAj1t6RXceubXqsmOyc5KNjNu+OiP19udNYp9Wdva3TKsN CIOTyROT88A6xFIHbdL0it25mV+x3mNg== X-Received: by 2002:a05:6402:1d4e:b0:57c:60f0:98bc with SMTP id 4fb4d7f45d1cf-5879f59bc5bmr9191127a12.11.1720046693302; Wed, 03 Jul 2024 15:44:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwt0cgeX7IzE5SqJO3nOeUkZXrRoV1CshiFn78EWfICEMahzxy9ojl/p5VnzrZmp+wx076qg== X-Received: by 2002:a05:6402:1d4e:b0:57c:60f0:98bc with SMTP id 4fb4d7f45d1cf-5879f59bc5bmr9191098a12.11.1720046692666; Wed, 03 Jul 2024 15:44:52 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58612c835dfsm7618146a12.20.2024.07.03.15.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:44:52 -0700 (PDT) Date: Wed, 3 Jul 2024 18:44:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonah Palmer , Lei Yang , Eugenio =?utf-8?b?UMOpcmV6?= , Srujana Challa , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Jason Wang , Paolo Bonzini , Fam Zheng , Stefan Hajnoczi , qemu-block@nongnu.org, virtio-fs@lists.linux.dev Subject: [PULL v3 08/85] vhost/vhost-user: Add VIRTIO_F_NOTIFICATION_DATA to vhost feature bits 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonah Palmer Add support for the VIRTIO_F_NOTIFICATION_DATA feature across a variety of vhost devices. The inclusion of VIRTIO_F_NOTIFICATION_DATA in the feature bits arrays for these devices ensures that the backend is capable of offering and providing support for this feature, and that it can be disabled if the backend does not support it. Tested-by: Lei Yang Reviewed-by: Eugenio Pérez Signed-off-by: Jonah Palmer Message-Id: <20240315165557.26942-6-jonah.palmer@oracle.com> Acked-by: Srujana Challa Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/block/vhost-user-blk.c | 1 + hw/net/vhost_net.c | 2 ++ hw/scsi/vhost-scsi.c | 1 + hw/scsi/vhost-user-scsi.c | 1 + hw/virtio/vhost-user-fs.c | 2 +- hw/virtio/vhost-user-vsock.c | 1 + net/vhost-vdpa.c | 1 + 7 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 9e6bbc6950..bc2677dbef 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -51,6 +51,7 @@ static const int user_feature_bits[] = { VIRTIO_F_RING_PACKED, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_RESET, + VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index fd1a93701a..18898afe81 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -48,6 +48,7 @@ static const int kernel_feature_bits[] = { VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, VIRTIO_F_RING_RESET, + VIRTIO_F_NOTIFICATION_DATA, VIRTIO_NET_F_HASH_REPORT, VHOST_INVALID_FEATURE_BIT }; @@ -55,6 +56,7 @@ static const int kernel_feature_bits[] = { /* Features supported by others. */ static const int user_feature_bits[] = { VIRTIO_F_NOTIFY_ON_EMPTY, + VIRTIO_F_NOTIFICATION_DATA, VIRTIO_RING_F_INDIRECT_DESC, VIRTIO_RING_F_EVENT_IDX, diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index ae26bc19a4..3d5fe0994d 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -38,6 +38,7 @@ static const int kernel_feature_bits[] = { VIRTIO_RING_F_EVENT_IDX, VIRTIO_SCSI_F_HOTPLUG, VIRTIO_F_RING_RESET, + VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index a63b1f4948..0b050805a8 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -36,6 +36,7 @@ static const int user_feature_bits[] = { VIRTIO_RING_F_EVENT_IDX, VIRTIO_SCSI_F_HOTPLUG, VIRTIO_F_RING_RESET, + VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index cca2cd41be..ae48cc1c96 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -33,7 +33,7 @@ static const int user_feature_bits[] = { VIRTIO_F_RING_PACKED, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_RESET, - + VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; diff --git a/hw/virtio/vhost-user-vsock.c b/hw/virtio/vhost-user-vsock.c index 9431b9792c..802b44a07d 100644 --- a/hw/virtio/vhost-user-vsock.c +++ b/hw/virtio/vhost-user-vsock.c @@ -21,6 +21,7 @@ static const int user_feature_bits[] = { VIRTIO_RING_F_INDIRECT_DESC, VIRTIO_RING_F_EVENT_IDX, VIRTIO_F_NOTIFY_ON_EMPTY, + VIRTIO_F_NOTIFICATION_DATA, VHOST_INVALID_FEATURE_BIT }; diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index eda714d1a4..daa38428c5 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -62,6 +62,7 @@ const int vdpa_feature_bits[] = { VIRTIO_F_RING_PACKED, VIRTIO_F_RING_RESET, VIRTIO_F_VERSION_1, + VIRTIO_F_NOTIFICATION_DATA, VIRTIO_NET_F_CSUM, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, VIRTIO_NET_F_CTRL_MAC_ADDR, From patchwork Wed Jul 3 22:44:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A24A8C3271E for ; Wed, 3 Jul 2024 22:46:12 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8iu-000289-PZ; Wed, 03 Jul 2024 18:45: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 1sP8ir-00027K-Ju for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:09 -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 1sP8im-0000vD-J0 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046704; 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=Q0Pfb548kulwNGCVafgBGSBiO4uWmp/hiUtG94za6C8=; b=HNq76qj2Iq4gy4KjT7UfPw0fHWjGm5hAW9Pi4o0F7hV1XjhATZlZ01PTnzsBd3ereK5AiQ P0R/SZwF6jlJg8woN66ZfaF6FW7B7Cd8rn4ASx/olUKSC826xkJlj90KlT3su4IeR50UrP b1W/iLZvkoxxbODY2zPhWgRl0b6rlBs= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-76-DX0RKLmuOUyaQ21mk_v_Tw-1; Wed, 03 Jul 2024 18:45:02 -0400 X-MC-Unique: DX0RKLmuOUyaQ21mk_v_Tw-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-52e98697a27so1331658e87.2 for ; Wed, 03 Jul 2024 15:45:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046701; x=1720651501; 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=Q0Pfb548kulwNGCVafgBGSBiO4uWmp/hiUtG94za6C8=; b=RM6vEquYEmBVQsnN6f1LniYwtuNViney/SEwYBO8Tx/EREDhxA07PDtvL4fEzjkIec vPWZUfCrLamYII3Xx06LYDr3Vhheyv/wYyPYiwOXPYCDddo5ynvOazuxogrAcOoZKyWq OQzBuBUTGELXbhgiZMMbe0Sxi4NwbHJ3ND3P/9Fv5vDppmbxybtm/j8SwDZHPbclGSyl 2O4nP6HeHRAWfFr8o4MTorNt1luRKHWSdnlb3XKM1C1OV3Va9YM/qDwgmFFy5GKLOJ4q cYnzmtGgglxHtMwfRLYlTyPMEXPSe+lLkxIDpcyjDXjTCRI4IBEf0rCzltu7rhf6JB6A jcyQ== X-Gm-Message-State: AOJu0YxzLb8ueNuRr4g6bJsJoX3gthjcAFrGC+N9N0Z+EI18h7/5lEOs z7y0XHlz/mZIOHV+OlbA5RpR3GADtqOjN0fJ5G4n89mm2TcUyu465BFLEPJDmPyclY+07Xv8cmM 9DFanE95aZs5iM47nI6lKdXvafgudjFuZsX2YCYtIkilYUuEqp56UMGxqVMIVF800K/nbZdI99X ropI96w6QQEPLOdK9hc/sOBu1/gOn1NA== X-Received: by 2002:ac2:4e05:0:b0:52d:6663:5cbe with SMTP id 2adb3069b0e04-52e8264e53fmr8197327e87.12.1720046700784; Wed, 03 Jul 2024 15:45:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAMVY3DMxNt0O68gztr0SxHQAvxN/VKW+4hzU8/Rfz0z+oAQnEzcY2kFIx+Ku39SSlZKfsPA== X-Received: by 2002:ac2:4e05:0:b0:52d:6663:5cbe with SMTP id 2adb3069b0e04-52e8264e53fmr8197276e87.12.1720046697719; Wed, 03 Jul 2024 15:44:57 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5861324ed2dsm7634044a12.28.2024.07.03.15.44.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:44:57 -0700 (PDT) Date: Wed, 3 Jul 2024 18:44:52 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Christian =?utf-8?q?P=C3=B6tzs?= =?utf-8?q?ch?= Subject: [PULL v3 09/85] Fix vhost user assertion when sending more than one fd Message-ID: <5093bee0fa8a6c9712c96653da3a79bc37a4e45d.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Christian Pötzsch If the client sends more than one region this assert triggers. The reason is that two fd's are 8 bytes and VHOST_MEMORY_BASELINE_NREGIONS is exactly 8. The assert is wrong because it should not test for the size of the fd array, but for the numbers of regions. Signed-off-by: Christian Pötzsch Message-Id: <20240426083313.3081272-1-christian.poetzsch@kernkonzept.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c index a879149fef..8adb277d54 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -568,7 +568,7 @@ vu_message_read_default(VuDev *dev, int conn_fd, VhostUserMsg *vmsg) if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { fd_size = cmsg->cmsg_len - CMSG_LEN(0); vmsg->fd_num = fd_size / sizeof(int); - assert(fd_size < VHOST_MEMORY_BASELINE_NREGIONS); + assert(vmsg->fd_num <= VHOST_MEMORY_BASELINE_NREGIONS); memcpy(vmsg->fds, CMSG_DATA(cmsg), fd_size); break; } From patchwork Wed Jul 3 22:45:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722950 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A593C31D97 for ; Wed, 3 Jul 2024 22:45:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8iw-00029y-PC; Wed, 03 Jul 2024 18:45: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 1sP8is-00027s-Qp for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45: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 1sP8iq-0000vn-8L for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046707; 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=QKgBtghpdntZCNxsubdg5dbN8fdbQsXq4OpajtHNP9c=; b=R2AzVgrgsoph+785N35kc7Cl/ErY29uW/0dIVROOH7cKkWZiheKyIMiqPTeyY00TwufC4r rqchoI6e1BK9jOBQ9vq3T3k5rs9kiRjvcuI1Tya8JMymLCkRV+VNBoQ4KD3kEZYoalLv5C k4N52QxWUovI42UAR8mK2fdZg/S0iiA= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-570-bG9D81FqM9mKCv6JljQWVQ-1; Wed, 03 Jul 2024 18:45:06 -0400 X-MC-Unique: bG9D81FqM9mKCv6JljQWVQ-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2ee848b2fedso11601011fa.0 for ; Wed, 03 Jul 2024 15:45:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046704; x=1720651504; 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=QKgBtghpdntZCNxsubdg5dbN8fdbQsXq4OpajtHNP9c=; b=OqBDaHFfWw1I0XSBC57kyBfcdUNA6iVZymjN5GNh2QwOu6s7ZGlBsxo8fY90HiuVEC d5hIIQXyoYBdh2yJWY68w9iDzvggzRSU0JsQbXWdF9otfk6C0b/JHWoLfYxWQmENcXJx 0+AxuPxFxCM9fwzgNz88RJ6U9l4M8BllNF2dHhHSIqAkhg/FW3Ueg9o8sfHz77A1Gqyp JHzpdveqwfj9I4mkN7HoxQj93TWVW96Rg+wrABVTUxnLB5zU6fwSOJonPq0MgAqo2vjd H/4HKNzL/1DiFOHPmTdQ2D0B3tY1jHW+zQSygbzNmNrBZLE+jvfn8YaGa4UJmvKxxDgt BIRQ== X-Gm-Message-State: AOJu0Yz2nsgJ+fh4Ib/dX1P6nmlxYgP11rzOMDmjkCkkMPIG15TlD/Yy E7b2yFXXJ6r7BStcms1bsxZ81tbV1bJi1lfLANMGph4buEbJ8nR37x7YFzVLRGkTi5n6zUULwal slwb3TyteiYXU7WA5ftlODjNrB60jEW+ovakg1rUSCYH8CjExWpgg+ISrABcdYcgSqY/97CaDmQ 7xvouHk6S1cRwtOYJjqmCkAJkX46jCbw== X-Received: by 2002:a05:6512:b8e:b0:52c:8210:13bc with SMTP id 2adb3069b0e04-52e8273e3acmr8869018e87.64.1720046704454; Wed, 03 Jul 2024 15:45:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE84nkf35ngiUNRT2yltt70Aw4yWlCZ3EPgIZZL/eHBTnkq2TYJtHXDUMYwCLHy4nGtnYI+bg== X-Received: by 2002:a05:6512:b8e:b0:52c:8210:13bc with SMTP id 2adb3069b0e04-52e8273e3acmr8869005e87.64.1720046703705; Wed, 03 Jul 2024 15:45:03 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab0651dfsm556055166b.142.2024.07.03.15.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:45:03 -0700 (PDT) Date: Wed, 3 Jul 2024 18:45:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Halil Pasic , Marc Hartmayer Subject: [PULL v3 10/85] vhost-vsock: add VIRTIO_F_RING_PACKED to feature_bits 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Halil Pasic Not having VIRTIO_F_RING_PACKED in feature_bits[] is a problem when the vhost-vsock device does not offer the feature bit VIRTIO_F_RING_PACKED but the in QEMU device is configured to try to use the packed layout (the virtio property "packed" is on). As of today, the Linux kernel vhost-vsock device does not support the packed queue layout (as vhost does not support packed), and does not offer VIRTIO_F_RING_PACKED. Thus when for example a vhost-vsock-ccw is used with packed=on, VIRTIO_F_RING_PACKED ends up being negotiated, despite the fact that the device does not actually support it, and one gets to keep the pieces. Fixes: 74b3e46630 ("virtio: add property to enable packed virtqueue") Reported-by: Marc Hartmayer Signed-off-by: Halil Pasic Message-Id: <20240429113334.2454197-1-pasic@linux.ibm.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-vsock-common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index 12ea87d7a7..fd88df2560 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -22,6 +22,7 @@ const int feature_bits[] = { VIRTIO_VSOCK_F_SEQPACKET, VIRTIO_F_RING_RESET, + VIRTIO_F_RING_PACKED, VHOST_INVALID_FEATURE_BIT }; From patchwork Wed Jul 3 22:45:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B60EDC2BD09 for ; Wed, 3 Jul 2024 22:45:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8j4-0002GV-3E; Wed, 03 Jul 2024 18:45:22 -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 1sP8j2-0002AR-Fk for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:20 -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 1sP8iy-0000yQ-KR for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046711; 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=Bf3inGfH3C1OrX/KdJFaqQvDHDePnfUDWhDjBaZ52tk=; b=QfCY+A5I6haxeveELgfHaZX+/tJnGHaN2Cye38PiKhIHUw6Uf9dAk9yl9Z7Zb2Oj7TEsS3 bWlpQ5P4aX8jctKNqxktQat5j3f0pxtyZNCFrVDIN468zq2Y/MpoB7yVQGFiWhR6s95Pxe r8Qw3PhmTsld+EIjHjZm2fEoEpDpg14= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-664-Al_VjRHoOiOpiEhHGFNO6A-1; Wed, 03 Jul 2024 18:45:10 -0400 X-MC-Unique: Al_VjRHoOiOpiEhHGFNO6A-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a725eed1cfeso1103966b.3 for ; Wed, 03 Jul 2024 15:45:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046709; x=1720651509; 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=Bf3inGfH3C1OrX/KdJFaqQvDHDePnfUDWhDjBaZ52tk=; b=AN2RbS/c6j1XeHWXj6UT7rW9woT9MXDAz+jjyNpi4LChwgMkTl0yp3HoKpC3cQN0rs X1ZS5ECGpBDYgKb1whn8KM7y9dL/dLaQIvEYwFiQT6bIV9fGvuuDNsZ70/BXbRD0wEw6 brWHD1THLGbopYfBIxik8FVboTgnxB5aTHhmBXaQH5FGQSdGNwTKU0nxykXFsJw2T1F/ rSd5rYZaHYmSG8sHl9K5NDE+UmQz3kEr7ywdm59F8NbR5xTbFtZxVMupxzEDSKbPmgxn 9FJM5rjZ9U/ANTvm3GfgoUC8ekNYWJfHsEl08WSnx9q6H/ZDA77Ap1Og3LpehDq8UpOF Q2qQ== X-Gm-Message-State: AOJu0YwmhuVgsfE/hiEZ/856cfzj6SO39zofU1Iv4Iu4w+LRl72mPDPy DlJs9+Nz7oNRcb59pEo6VR5gH6svcjrTygvejJmrkhGOlkqh31d0WcXEbTIiOhtsHtVBhvBg3+R QnT4w6OeEiX5+VbOwDwPCvHaNHGeed6XvpK/7N5LDo8MjCJ8niIeSQlVKz8Si/XCLYk3Kur96dL 8MFrhnqzX0wZjg4TE1L0ObJ73hzENjvg== X-Received: by 2002:a17:906:a854:b0:a72:b361:41df with SMTP id a640c23a62f3a-a75144a8a77mr743358366b.73.1720046709195; Wed, 03 Jul 2024 15:45:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2HDThedYpbb99Ti4RJkj71FX4UuvnZi3mATmGLkUvACJLtWRqqto38n1iClVxJJHumt+ClA== X-Received: by 2002:a17:906:a854:b0:a72:b361:41df with SMTP id a640c23a62f3a-a75144a8a77mr743356566b.73.1720046707995; Wed, 03 Jul 2024 15:45:07 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab0651f5sm547982366b.138.2024.07.03.15.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:45:07 -0700 (PDT) Date: Wed, 3 Jul 2024 18:45:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Wafer , Jason Wang , Eugenio =?utf-8?b?UMOpcmV6?= Subject: [PULL v3 11/85] hw/virtio: Fix obtain the buffer id from the last descriptor Message-ID: <33abfea239592a706e98269b01c0096249612ea4.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Wafer The virtio-1.3 specification writes: 2.8.6 Next Flag: Descriptor Chaining Buffer ID is included in the last descriptor in the list. If the feature (_F_INDIRECT_DESC) has been negotiated, install only one descriptor in the virtqueue. Therefor the buffer id should be obtained from the first descriptor. In descriptor chaining scenarios, the buffer id should be obtained from the last descriptor. Fixes: 86044b24e8 ("virtio: basic packed virtqueue support") Signed-off-by: Wafer Reviewed-by: Jason Wang Reviewed-by: Eugenio Pérez Acked-by: Jason Wang Message-Id: <20240510072753.26158-2-wafer@jaguarmicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 28cd406e16..3678ec2f88 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -1745,6 +1745,11 @@ static void *virtqueue_packed_pop(VirtQueue *vq, size_t sz) &indirect_desc_cache); } while (rc == VIRTQUEUE_READ_DESC_MORE); + if (desc_cache != &indirect_desc_cache) { + /* Buffer ID is included in the last descriptor in the list. */ + id = desc.id; + } + /* Now copy what we have collected and mapped */ elem = virtqueue_alloc_element(sz, out_num, in_num); for (i = 0; i < out_num; i++) { From patchwork Wed Jul 3 22:45:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722997 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 63AA0C2BD09 for ; Wed, 3 Jul 2024 22:50:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8jD-0002h1-86; Wed, 03 Jul 2024 18:45: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 1sP8j7-0002Tq-Su for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45: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 1sP8j4-0001BE-BW for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046719; 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=Hq1ZdMUpXgQO0jHpQkHjtkURKxmq/FjBLx45BW2ity0=; b=HLmfV3g+rCYDj+IWEqh/9Gn1oP+VKHi4LoGYkNbwOIW47r16qZWJZXuxFsQ6XWtyQWugc9 aqc6ALAgiV6EL/SI3YH5d5bWdaFEhzuoMlwQbgfSol9SI7XI5/uvytd6FGZ5DaBe4UE/DF MDo8LVjrXh6geHxoU46AZ23IP1g16d4= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-219-96zP0JrcPkurDFmtphKVSw-1; Wed, 03 Jul 2024 18:45:16 -0400 X-MC-Unique: 96zP0JrcPkurDFmtphKVSw-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-52e9345073aso2058484e87.3 for ; Wed, 03 Jul 2024 15:45:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046714; x=1720651514; 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=Hq1ZdMUpXgQO0jHpQkHjtkURKxmq/FjBLx45BW2ity0=; b=uSenhd6Q/YMwquno5u2UR2mQIW/ZPvoB0vUpr0iyrliXl7po0GqrgmaAZ495qL9WC1 IW/KlWI1ZkYhuo7PyFrWyJg6oY7jpLVZfL1YQR19spw4GnnkcO6Xr9t+A2QI0Vv3hUDd 0N5uWTxiLCp6taNQ6Ds5O6NLWpq9jsPUOA+Rqhx3iaSNh8czquwNjQUkMkYlxNG3E3Cm iN5+uOpWxO+uChE+y6woa+wEqb6yyjVwEp1zcJQ/zY2oUxgEnMFBAgal/4VEz1Z6kRA9 L3XuRXp50tUuO+CqaJDxZg3jCFcGmt9QtUVZEAFPejNxa521fmTaBZgDpqcamgVDQrTR YTjg== X-Gm-Message-State: AOJu0Yytv9Fp4MGu60VnKIGINe5rreQk2FDDm64A6r8BNMZ5YNwnEVIu ymAR52LV5AlqW39IgtMUm6cubMSbFroKoGFGxyMLiYswyQ6OAt3f0YJ6baePaYgRRCbo+axMIVg EPw1hmIDmQfMNyp179lOQbXGK6RdU/LXWA66bwWtc4OVcXstbcKSTfad06/VhcJuI9jFkW/Wf7M y+JvnnLKNUTlmDsaprTanL83IBgjChHw== X-Received: by 2002:a05:6512:ac6:b0:52c:dc6f:75a3 with SMTP id 2adb3069b0e04-52e8268610dmr9713164e87.40.1720046714062; Wed, 03 Jul 2024 15:45:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFHrvjPWmo5M6Bp+qHr04U+rRanKmzSCIePRqp3sDFPBo4fLdOJq6O/XpBKNb0gvoO83XdZRw== X-Received: by 2002:a05:6512:ac6:b0:52c:dc6f:75a3 with SMTP id 2adb3069b0e04-52e8268610dmr9713142e87.40.1720046713325; Wed, 03 Jul 2024 15:45:13 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58cf5bdeda0sm1333015a12.73.2024.07.03.15.45.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:45:12 -0700 (PDT) Date: Wed, 3 Jul 2024 18:45:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jiqian Chen Subject: [PULL v3 12/85] virtio-pci: only reset pm state during resetting Message-ID: <84b58169e40f5c7428db6f0b229e01213068aa21.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jiqian Chen Fix bug imported by 27ce0f3afc9dd ("fix Power Management Control Register for PCI Express virtio devices" After this change, observe that QEMU may erroneously clear the power status of the device, or may erroneously clear non writable registers, such as NO_SOFT_RESET, etc. Only state of PM_CTRL is writable. Only when flag VIRTIO_PCI_FLAG_INIT_PM is set, need to reset state. Fixes: 27ce0f3afc9dd ("fix Power Management Control Register for PCI Express virtio devices" Signed-off-by: Jiqian Chen Message-Id: <20240515073526.17297-2-Jiqian.Chen@amd.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index cffc7efcae..7d62e92365 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -2306,10 +2306,16 @@ static void virtio_pci_bus_reset_hold(Object *obj, ResetType type) virtio_pci_reset(qdev); if (pci_is_express(dev)) { + VirtIOPCIProxy *proxy = VIRTIO_PCI(dev); + pcie_cap_deverr_reset(dev); pcie_cap_lnkctl_reset(dev); - pci_set_word(dev->config + dev->exp.pm_cap + PCI_PM_CTRL, 0); + if (proxy->flags & VIRTIO_PCI_FLAG_INIT_PM) { + pci_word_test_and_clear_mask( + dev->config + dev->exp.pm_cap + PCI_PM_CTRL, + PCI_PM_CTRL_STATE_MASK); + } } } From patchwork Wed Jul 3 22:45:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722962 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C5022C2BD09 for ; Wed, 3 Jul 2024 22:46:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8j7-0002Sl-J7; Wed, 03 Jul 2024 18:45: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 1sP8j5-0002PG-GQ for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:23 -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 1sP8j3-0001CM-Pj for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046721; 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=3bV+n5a+n2PubUhTQh2qtot7neovPmYiRH9+8WKEDSw=; b=cAwpix/5+B+evUegPzVHBxaRn3FjYXpFENSdgo2qXM9QCxUeQJ7UjvGiHS5SXqpTh8DRxT vq37YKa1D4aXbt3r1wt1xf6CLZLeCIGQnfbjOxk0G5dSoqVsNoR6T17HQqeyQT6dHIw5wz rkOc/QXAiOXUGkAGMFhZ3hkMXoCzccM= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-118-EfRyHZmqNsq0eodr1D2z8g-1; Wed, 03 Jul 2024 18:45:19 -0400 X-MC-Unique: EfRyHZmqNsq0eodr1D2z8g-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-52e9345073aso2058518e87.3 for ; Wed, 03 Jul 2024 15:45:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046718; x=1720651518; 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=3bV+n5a+n2PubUhTQh2qtot7neovPmYiRH9+8WKEDSw=; b=br6cGoc3RO/JjTOOQTHiKqJVeZ1v8h3Butb0xjqyVEFM1bDbUilN1bLFEpjHNgjCsV AI6dLgEbx4V0x6v5ShZxxa5cik0YGxK+ptCLRziLP1xHj63OcQFv9UWuhxR+vCRXoaym 0cXYBGkEa5owF+fUYB6SYjEG9FQrGW3YY966Z8vIIgkUzzVRFtSInuhO6aCdedb6FdRT SJWqpe+6mx53bNcLAbMQQd7VTVvVimmXMQ7FySivElYV1XW0xRjGF1luTY/KxVGSeU6S dNswBVu0r/PkKLUg7vCOnmKoQAaCrAK44V7Pvhjn0kPe4fDGsXsuNyMRabazP4OFhqZO Hrzg== X-Gm-Message-State: AOJu0YyeX9gbclwX44/6pZXWLwKwGazdD8zuuiR3xzBbkyux2JG6qw+B 39xl4oykSIEdZkxJCygOCC5flfCiLzuReID7KtIotew8JO1/faYm926rR5qM6NDIO7bzqaS9OX3 SHDdWAm9K+HNOzdmY2cdP6SB4h3OWfGOHGTEtEGWLJg4ottfHdJRc5BfNnWKPZE2yWIAcHSPlyl fncY5Eqb3rAtZwySsG8jZAcdk/mPJmzA== X-Received: by 2002:a05:6512:3e28:b0:52c:a5cb:69e4 with SMTP id 2adb3069b0e04-52e826f12d1mr8789741e87.54.1720046717957; Wed, 03 Jul 2024 15:45:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHm1y1ODxOBNU/ryGMbozUFLY20+fUNub+N3ibywlpMDzs+QpQSYKKEK8Gx3+D+rVXzzsGseQ== X-Received: by 2002:a05:6512:3e28:b0:52c:a5cb:69e4 with SMTP id 2adb3069b0e04-52e826f12d1mr8789726e87.54.1720046716940; Wed, 03 Jul 2024 15:45:16 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab09028dsm553241466b.179.2024.07.03.15.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:45:16 -0700 (PDT) Date: Wed, 3 Jul 2024 18:45:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?q?Marc-Andr=C3=A9?= Lureau Subject: [PULL v3 13/85] vhost-user-gpu: fix import of DMABUF Message-ID: <80c8a26de5f1b7d67d4594957c0d82a0c47626be.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Marc-André Lureau When using vhost-user-gpu with GL, qemu -display gtk doesn't show output and prints: qemu: eglCreateImageKHR failed Since commit 9ac06df8b ("virtio-gpu-udmabuf: correct naming of QemuDmaBuf size properties"), egl_dmabuf_import_texture() uses backing_{width,height} for the texture dimension. Fixes: 9ac06df8b ("virtio-gpu-udmabuf: correct naming of QemuDmaBuf size properties") Signed-off-by: Marc-André Lureau Message-Id: <20240515105237.1074116-1-marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/display/vhost-user-gpu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index e4b398d26c..63c64ddde6 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -281,8 +281,9 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg) modifier = m2->modifier; } - dmabuf = qemu_dmabuf_new(m->fd_width, m->fd_height, - m->fd_stride, 0, 0, 0, 0, + dmabuf = qemu_dmabuf_new(m->width, m->height, + m->fd_stride, 0, 0, + m->fd_width, m->fd_height, m->fd_drm_fourcc, modifier, fd, false, m->fd_flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP); From patchwork Wed Jul 3 22:45:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4FCF0C2BD09 for ; Wed, 3 Jul 2024 22:50:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8jD-0002ih-Ko; Wed, 03 Jul 2024 18:45: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 1sP8jB-0002e5-KU for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45: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 1sP8j9-0001FH-NT for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046726; 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=+cVsXdQI2RthGLy7TxkQZRDMuYIrDeTU2bckWSqVXa0=; b=IIg/JPz1NCnNjsYeWOtmuTelRx/An3gyUKOs1T/iIxBg3JF7UGO4rTYJnB1NZdViigosCs uQwileXCldQGcln6mNejdFktP0HCp7piBeC+/hDvpLFnTsWZAi1sB6JHcEbXvYzCehZgV5 wyMURSHAkVccNAnBtUgdU7RP1Y1S6LI= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-144-lJAiBGiKNgyCenagrttjuw-1; Wed, 03 Jul 2024 18:45:24 -0400 X-MC-Unique: lJAiBGiKNgyCenagrttjuw-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a6fe8b2bcc4so1621066b.0 for ; Wed, 03 Jul 2024 15:45:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046723; x=1720651523; 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=+cVsXdQI2RthGLy7TxkQZRDMuYIrDeTU2bckWSqVXa0=; b=MNKwbrjd+J7JWkIg0tPbUWf+AJiEfzJd+oTIqStYYeBK1C6+o3e1RPLdfJtoFJaQ9J 3D3sGVdu9vFVZ/nshC5QRfXmS/BlPyjVTrIpaN06OWHl/0NXqG07ZZiGU8yVHUIa9Jdo eAzauCrTH2dN3pah3E+sgOxBh5oH4ZB81SWybh7BvBf/+tQvMQa2+P/UGU1ah7evVgHi 1eqDzag7YavJOMtCcCYLYk/VeEJOopETt93DRYhkctc+zHHdntgR5FIJglKLmOwSmjYh 3ct46JK/i/bDuaP8WiG3GEfLZ8HTziDX3VzLCeovlWVtbqgLaGzyVjoZCsdTbzvU4TWt DFSA== X-Gm-Message-State: AOJu0YyXeCEh6Mcw9C93luxKMaj2PeGFAqNx1M0TANJafKXgWB9Irr9/ pT4zVyqTXQNXANsX0pvXbrxYAjnT1n6rvPSVhwbmDGIUJT2LprUXWwzdn4wqDfV2S3yeLHWbdrp XBmXtfaSEITGnr36kEqh1l0AoNaH7rcxIDPLOtadiJ1SZDGJCcYtZAOSNqmDIsyWS1VjTn6tP37 btC2uTioc0uEKsM5OKEF15a7C+xOxlTw== X-Received: by 2002:a17:907:6e8c:b0:a77:ae4b:7bf6 with SMTP id a640c23a62f3a-a77ae4bb7a7mr91579966b.54.1720046723134; Wed, 03 Jul 2024 15:45:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFaav2fH519aTU8uhRinkPdE+Mm92T90rR0WBIhzL2LiwvcqGmMhx0mQJvjrnmjxGoOse19Hg== X-Received: by 2002:a17:907:6e8c:b0:a77:ae4b:7bf6 with SMTP id a640c23a62f3a-a77ae4bb7a7mr91577066b.54.1720046722161; Wed, 03 Jul 2024 15:45:22 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf18c99sm544904566b.2.2024.07.03.15.45.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:45:21 -0700 (PDT) Date: Wed, 3 Jul 2024 18:45:17 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Li Feng , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Paolo Bonzini , Fam Zheng , Alex =?utf-8?q?Benn=C3=A9e?= , qemu-block@nongnu.org Subject: [PULL v3 14/85] Revert "vhost-user: fix lost reconnect" Message-ID: <9569fe0aacbe6c7752935c9ede427ca1e8aafe51.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Li Feng This reverts commit f02a4b8e6431598612466f76aac64ab492849abf. Since the current patch cannot completely fix the lost reconnect problem, there is a scenario that is not considered: - When the virtio-blk driver is removed from the guest os, s->connected has no chance to be set to false, resulting in subsequent reconnection not being executed. The next patch will completely fix this issue with a better approach. Signed-off-by: Li Feng Message-Id: <20240516025753.130171-2-fengli@smartx.com> Reviewed-by: Raphael Norwitz Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user.h | 3 +-- hw/block/vhost-user-blk.c | 2 +- hw/scsi/vhost-user-scsi.c | 3 +-- hw/virtio/vhost-user-base.c | 2 +- hw/virtio/vhost-user.c | 10 ++-------- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/include/hw/virtio/vhost-user.h b/include/hw/virtio/vhost-user.h index d7c09ffd34..324cd8663a 100644 --- a/include/hw/virtio/vhost-user.h +++ b/include/hw/virtio/vhost-user.h @@ -108,7 +108,6 @@ typedef void (*vu_async_close_fn)(DeviceState *cb); void vhost_user_async_close(DeviceState *d, CharBackend *chardev, struct vhost_dev *vhost, - vu_async_close_fn cb, - IOEventHandler *event_cb); + vu_async_close_fn cb); #endif diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index bc2677dbef..15cc24d017 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -385,7 +385,7 @@ static void vhost_user_blk_event(void *opaque, QEMUChrEvent event) case CHR_EVENT_CLOSED: /* defer close until later to avoid circular close */ vhost_user_async_close(dev, &s->chardev, &s->dev, - vhost_user_blk_disconnect, vhost_user_blk_event); + vhost_user_blk_disconnect); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 0b050805a8..421cd654f8 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -215,8 +215,7 @@ static void vhost_user_scsi_event(void *opaque, QEMUChrEvent event) case CHR_EVENT_CLOSED: /* defer close until later to avoid circular close */ vhost_user_async_close(dev, &vs->conf.chardev, &vsc->dev, - vhost_user_scsi_disconnect, - vhost_user_scsi_event); + vhost_user_scsi_disconnect); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index a83167191e..4b54255682 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -254,7 +254,7 @@ static void vub_event(void *opaque, QEMUChrEvent event) case CHR_EVENT_CLOSED: /* defer close until later to avoid circular close */ vhost_user_async_close(dev, &vub->chardev, &vub->vhost_dev, - vub_disconnect, vub_event); + vub_disconnect); break; case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index cdf9af4a4b..c929097e87 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2776,7 +2776,6 @@ typedef struct { DeviceState *dev; CharBackend *cd; struct vhost_dev *vhost; - IOEventHandler *event_cb; } VhostAsyncCallback; static void vhost_user_async_close_bh(void *opaque) @@ -2791,10 +2790,7 @@ static void vhost_user_async_close_bh(void *opaque) */ if (vhost->vdev) { data->cb(data->dev); - } else if (data->event_cb) { - qemu_chr_fe_set_handlers(data->cd, NULL, NULL, data->event_cb, - NULL, data->dev, NULL, true); - } + } g_free(data); } @@ -2806,8 +2802,7 @@ static void vhost_user_async_close_bh(void *opaque) */ void vhost_user_async_close(DeviceState *d, CharBackend *chardev, struct vhost_dev *vhost, - vu_async_close_fn cb, - IOEventHandler *event_cb) + vu_async_close_fn cb) { if (!runstate_check(RUN_STATE_SHUTDOWN)) { /* @@ -2823,7 +2818,6 @@ void vhost_user_async_close(DeviceState *d, data->dev = d; data->cd = chardev; data->vhost = vhost; - data->event_cb = event_cb; /* Disable any further notifications on the chardev */ qemu_chr_fe_set_handlers(chardev, From patchwork Wed Jul 3 22:45:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722954 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D55D7C2BD09 for ; Wed, 3 Jul 2024 22:46:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8jL-00033b-9p; Wed, 03 Jul 2024 18:45: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 1sP8jI-000330-Gt for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:36 -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 1sP8jG-0001Gn-L2 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046733; 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=cwZ47LpotxgqMUotTFYaru0nOsyfZI/sw2MfKtbkph8=; b=C/gR0BEN4ADc/AAe0ze/6FfuF7dHwXHXWcnE6tVAt2gMRNblv3P4MdILn/faJIRM4ZvXUN UwwpeHkJ9YpUTByR8fjhyHvI86YZoB3VijHJ9K/pp/xS5Txc/cZtOIsXPJgc0k3X+Bh3G5 RPY8NXiKwRZ9xs8xfB5o5mwNPrBVp9s= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-501-UWxIRvh9O2C6Xh4-I9MF_A-1; Wed, 03 Jul 2024 18:45:32 -0400 X-MC-Unique: UWxIRvh9O2C6Xh4-I9MF_A-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a725b0f8ba9so405666b.2 for ; Wed, 03 Jul 2024 15:45:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046730; x=1720651530; 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=cwZ47LpotxgqMUotTFYaru0nOsyfZI/sw2MfKtbkph8=; b=fc1j+9MKRcXlhIT24qyEsjXT3mQyJAmRvozcP7EwsRuS/rQhrz3kPrUuYn++nPOkb5 sj6shEjDVaPZAuR+/zzhOgxFppzQJ9fq8nFg2+vME7El9ionUgKExx7scChKtG7dX8f+ JUcsCmhvVAWTCzUFd2e5Bo1OOyXlKnpXor+Fhq0eqjUYR7yKHx054vZWAaB/P4pa/oJt Zq1QzsG67p1j3lO2OQewoEAgZpCzjRfZn327NyzJGdr2cxLuUmo9VXOUN6oJN1nQDWcB OG9Im+CgHnExOIq3WV5gnfZEcXhxOhOdAe+Tc5S2FFWpT0MlCu6cDUIfztDJ/QJUd/GN 85Xw== X-Gm-Message-State: AOJu0Ywgjbv9HxCsKAolfyBc165nOoQMUNQhyINsNaJduIFOoZ0KY0uy 8V/4uj+gSnOD032T6AK+vzhk6txu9bIM3XPE6haz/iwWfsAgE2f/f+w68tWJcMyq0RRG6LGjI5I 3lAYRvoEsowNR1m27v9VE7/1KI+/GlUlSxzJAfK/65du/7Bw9Ly9DmQ59rTHxKv0Xg4fFVghiUv szpcFuW6aH02hHRKt1Jx1Wue/mA/cv8w== X-Received: by 2002:a05:6402:1cc1:b0:57c:7c44:74df with SMTP id 4fb4d7f45d1cf-587a0822c1dmr9303822a12.29.1720046729807; Wed, 03 Jul 2024 15:45:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEf+u9KR/aVkIEBTVVLe5R5Xz/bgzPvtsMH1bviz8Q/1691IGmyGyBEIxKJ8pw7FHj6XvNFGw== X-Received: by 2002:a05:6402:1cc1:b0:57c:7c44:74df with SMTP id 4fb4d7f45d1cf-587a0822c1dmr9303800a12.29.1720046729079; Wed, 03 Jul 2024 15:45:29 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58d50c4dad9sm1053214a12.10.2024.07.03.15.45.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:45:28 -0700 (PDT) Date: Wed, 3 Jul 2024 18:45:22 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Li Feng , Raphael Norwitz , Kevin Wolf , Hanna Reitz , Paolo Bonzini , Fam Zheng , Alex =?utf-8?q?Benn=C3=A9e?= , qemu-block@nongnu.org Subject: [PULL v3 15/85] vhost-user: fix lost reconnect again Message-ID: <6eaf0e612b415877d1c411b95bed2ecb53b546bb.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Li Feng When the vhost-user is reconnecting to the backend, and if the vhost-user fails at the get_features in vhost_dev_init(), then the reconnect will fail and it will not be retriggered forever. The reason is: When the vhost-user fail at get_features, the vhost_dev_cleanup will be called immediately. vhost_dev_cleanup calls 'memset(hdev, 0, sizeof(struct vhost_dev))'. The reconnect path is: vhost_user_blk_event vhost_user_async_close(.. vhost_user_blk_disconnect ..) qemu_chr_fe_set_handlers <----- clear the notifier callback schedule vhost_user_async_close_bh The vhost->vdev is null, so the vhost_user_blk_disconnect will not be called, then the event fd callback will not be reinstalled. We need to ensure that even if vhost_dev_init initialization fails, the event handler still needs to be reinstalled when s->connected is false. All vhost-user devices have this issue, including vhost-user-blk/scsi. Fixes: 71e076a07d ("hw/virtio: generalise CHR_EVENT_CLOSED handling") Signed-off-by: Li Feng Message-Id: <20240516025753.130171-3-fengli@smartx.com> Reviewed-by: Raphael Norwitz Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/block/vhost-user-blk.c | 3 ++- hw/scsi/vhost-user-scsi.c | 3 ++- hw/virtio/vhost-user-base.c | 3 ++- hw/virtio/vhost-user.c | 10 +--------- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 15cc24d017..fdbc30b9ce 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -354,7 +354,7 @@ static void vhost_user_blk_disconnect(DeviceState *dev) VHostUserBlk *s = VHOST_USER_BLK(vdev); if (!s->connected) { - return; + goto done; } s->connected = false; @@ -362,6 +362,7 @@ static void vhost_user_blk_disconnect(DeviceState *dev) vhost_dev_cleanup(&s->dev); +done: /* Re-instate the event handler for new connections */ qemu_chr_fe_set_handlers(&s->chardev, NULL, NULL, vhost_user_blk_event, NULL, dev, NULL, true); diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c index 421cd654f8..cc91ade525 100644 --- a/hw/scsi/vhost-user-scsi.c +++ b/hw/scsi/vhost-user-scsi.c @@ -182,7 +182,7 @@ static void vhost_user_scsi_disconnect(DeviceState *dev) VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev); if (!s->connected) { - return; + goto done; } s->connected = false; @@ -190,6 +190,7 @@ static void vhost_user_scsi_disconnect(DeviceState *dev) vhost_dev_cleanup(&vsc->dev); +done: /* Re-instate the event handler for new connections */ qemu_chr_fe_set_handlers(&vs->conf.chardev, NULL, NULL, vhost_user_scsi_event, NULL, dev, NULL, true); diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index 4b54255682..11e72b1e3b 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -225,13 +225,14 @@ static void vub_disconnect(DeviceState *dev) VHostUserBase *vub = VHOST_USER_BASE(vdev); if (!vub->connected) { - return; + goto done; } vub->connected = false; vub_stop(vdev); vhost_dev_cleanup(&vub->vhost_dev); +done: /* Re-instate the event handler for new connections */ qemu_chr_fe_set_handlers(&vub->chardev, NULL, NULL, vub_event, diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index c929097e87..c407ea8939 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2781,16 +2781,8 @@ typedef struct { static void vhost_user_async_close_bh(void *opaque) { VhostAsyncCallback *data = opaque; - struct vhost_dev *vhost = data->vhost; - /* - * If the vhost_dev has been cleared in the meantime there is - * nothing left to do as some other path has completed the - * cleanup. - */ - if (vhost->vdev) { - data->cb(data->dev); - } + data->cb(data->dev); g_free(data); } From patchwork Wed Jul 3 22:45:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 522D1C31D97 for ; Wed, 3 Jul 2024 22:47:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8jc-0003o5-RK; Wed, 03 Jul 2024 18:45:56 -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 1sP8jO-0003Pv-LF for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:44 -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 1sP8jJ-0001HM-Jl for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046737; 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=2dkENUzfzIIIcUTPF2EEwEXmUV3lpfWAm7D6XMdf5LE=; b=XhD66ozsSpZ7WR9iYabHQjKpADPEzo1pakZovXRFYlWdqUvKAloss0wHUy2AiLAVnFJPJT aU9lPxu8op5J0poIUzUpt9v1FNGMm1PKgIeIZeXLD+8nTp7h93ssy7/yuvpj9hIeKbDIFs InHroW+v/RO0F08JrN+Mle5sZPUkYz4= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-653-4P1TOXXxO_qlQxGN2WQw_A-1; Wed, 03 Jul 2024 18:45:35 -0400 X-MC-Unique: 4P1TOXXxO_qlQxGN2WQw_A-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-58c859c5d96so1039110a12.3 for ; Wed, 03 Jul 2024 15:45:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046734; x=1720651534; 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=2dkENUzfzIIIcUTPF2EEwEXmUV3lpfWAm7D6XMdf5LE=; b=A1sa4erN88nNpgBw9UMeo48IKvA1oWfyVwK3K2Be9IONtkEUwFamuzalba7gMXu8Pg eUr/czh0JEo9/0XtBARmtQ4L2eVhpQq7oHGOPLCMSYnkTlB8tQcDvmRydbv82Ti4rPIp EZOZrjg4b9JoL9hlome6cFemGqcv2sYMBkDa2LsJCZ7T2ej7jFQfnfXGTE2T/BYAAdvq fCaPV0Y3MWQPV5aC6E1YNwyaI68H1kl6JXt1kdy13OptkfTtyW6rIHLN/tYMxiM3aV2W LHXCAxZerQdhOhXFwA4uXg840xh3o81IE/HgQ0uSEFRlPGGjSKo3wKLxYI7P44koYh5y xV1w== X-Gm-Message-State: AOJu0YxnOUPvoyon88xk5Y+GVA7MC3mn8MIsmY/EXnTp0GzO3HLo5Lcv 1YCLF1X46QWDGPvEFbcV7DzBBaeViocFe8mc6zem+gAVJ8sLXJZGpNJLNjgX/U90So7bK+dRqWE IzjN9gUzElZXNn71lExwQUkGDOsydQLE10hGkcOTN9U/PCMSYvz6tm/OT6rmjdQF1G2CbLp/2Xm 9SovK1Qw4KtuNuBFISlvyQD/GQ3bsdaw== X-Received: by 2002:a05:6402:2345:b0:58d:10a0:36c0 with SMTP id 4fb4d7f45d1cf-58d10a03b2cmr1765912a12.14.1720046734142; Wed, 03 Jul 2024 15:45:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEez081FkmCv+4WXnMyf10orIFemARh3Bv5Kak8t+EYBl1tDio916mj1mVWdiBiqysSYc6ccw== X-Received: by 2002:a05:6402:2345:b0:58d:10a0:36c0 with SMTP id 4fb4d7f45d1cf-58d10a03b2cmr1765890a12.14.1720046733130; Wed, 03 Jul 2024 15:45:33 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-586132502ecsm7687298a12.40.2024.07.03.15.45.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:45:32 -0700 (PDT) Date: Wed, 3 Jul 2024 18:45:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Gregory Price , Gregory Price , Jonathan Cameron , Fan Ni Subject: [PULL v3 16/85] hw/cxl/mailbox: change CCI cmd set structure to be a member, not a reference Message-ID: <05b70ceba033759d44c6d3d9b24118cd9fc9d616.1720046570.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, T_SPF_TEMPERROR=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Gregory Price This allows devices to have fully customized CCIs, along with complex devices where wrapper devices can override or add additional CCI commands without having to replicate full command structures or pollute a base device with every command that might ever be used. Signed-off-by: Gregory Price Signed-off-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-2-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 2 +- hw/cxl/cxl-mailbox-utils.c | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 279b276bda..ccc4611875 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -164,7 +164,7 @@ typedef struct CXLEventLog { } CXLEventLog; typedef struct CXLCCI { - const struct cxl_cmd (*cxl_cmd_set)[256]; + struct cxl_cmd cxl_cmd_set[256][256]; struct cel_log { uint16_t opcode; uint16_t effect; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index e5eb97cb91..2c9f50f0f9 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1447,10 +1447,21 @@ void cxl_init_cci(CXLCCI *cci, size_t payload_max) bg_timercb, cci); } +static void cxl_copy_cci_commands(CXLCCI *cci, const struct cxl_cmd (*cxl_cmds)[256]) +{ + for (int set = 0; set < 256; set++) { + for (int cmd = 0; cmd < 256; cmd++) { + if (cxl_cmds[set][cmd].handler) { + cci->cxl_cmd_set[set][cmd] = cxl_cmds[set][cmd]; + } + } + } +} + void cxl_initialize_mailbox_swcci(CXLCCI *cci, DeviceState *intf, DeviceState *d, size_t payload_max) { - cci->cxl_cmd_set = cxl_cmd_set_sw; + cxl_copy_cci_commands(cci, cxl_cmd_set_sw); cci->d = d; cci->intf = intf; cxl_init_cci(cci, payload_max); @@ -1458,7 +1469,7 @@ void cxl_initialize_mailbox_swcci(CXLCCI *cci, DeviceState *intf, void cxl_initialize_mailbox_t3(CXLCCI *cci, DeviceState *d, size_t payload_max) { - cci->cxl_cmd_set = cxl_cmd_set; + cxl_copy_cci_commands(cci, cxl_cmd_set); cci->d = d; /* No separation for PCI MB as protocol handled in PCI device */ @@ -1476,7 +1487,7 @@ static const struct cxl_cmd cxl_cmd_set_t3_ld[256][256] = { void cxl_initialize_t3_ld_cci(CXLCCI *cci, DeviceState *d, DeviceState *intf, size_t payload_max) { - cci->cxl_cmd_set = cxl_cmd_set_t3_ld; + cxl_copy_cci_commands(cci, cxl_cmd_set_t3_ld); cci->d = d; cci->intf = intf; cxl_init_cci(cci, payload_max); @@ -1496,7 +1507,7 @@ void cxl_initialize_t3_fm_owned_ld_mctpcci(CXLCCI *cci, DeviceState *d, DeviceState *intf, size_t payload_max) { - cci->cxl_cmd_set = cxl_cmd_set_t3_fm_owned_ld_mctp; + cxl_copy_cci_commands(cci, cxl_cmd_set_t3_fm_owned_ld_mctp); cci->d = d; cci->intf = intf; cxl_init_cci(cci, payload_max); From patchwork Wed Jul 3 22:45:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722964 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6802DC2BD09 for ; Wed, 3 Jul 2024 22:47:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8jg-000495-5M; Wed, 03 Jul 2024 18:46:01 -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 1sP8jV-0003UP-Tu for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:52 -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 1sP8jU-0001LG-7g for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046744; 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=I7oOBawQ17ekJGPjTeJH6qenvWsB1BSkAwbq0wuPpCg=; b=azgngmo286x2WoMi5lFr0k4SDtxjTnQXxKer/TQOXqlkfuFWeUq+QSkemkjRO3gwg3nz8P MrYfX6TZAw47tPDWB9P2iSMs8gWejZlWuuggMoC4xscRmBxK0G4cwFaNM9Kfuz9zgL98/D teBVuu423rCKuMXK5bxFZvMjx896FSQ= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-364-OkcMpryLNvegmI-L_0QqsQ-1; Wed, 03 Jul 2024 18:45:42 -0400 X-MC-Unique: OkcMpryLNvegmI-L_0QqsQ-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-57cad6e94e5so2907495a12.3 for ; Wed, 03 Jul 2024 15:45:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046739; x=1720651539; 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=I7oOBawQ17ekJGPjTeJH6qenvWsB1BSkAwbq0wuPpCg=; b=EDeJdDcvKrOuYUI7+0+eqvksHP69+Ba1yjDUxt/LN2gmQCvK5uBnyYFHr/NpSlmFuV R3LMDg0L8YEoNGJRyVN8ZRhdEXkNAuyCcWYXV9/ePIyy+z98qI26HP19WvjhoK7vOmy7 pqtHSIdXpfZXUXCvl23+BHVgjpOQfIIJHoi3Ol9HXSQvs/4H2lqR3rTE77X6MYR+p6g9 KogvGXAHzAyUDIqN7bOiGfi//DjbX50NKfXQk2Or4DsbNY7iOACP5P5EGQM4CD5wlqNF gseUmtTScK7mLZUmNqWcgMpGyDaNHSDYIbfZDvtRb74lFKK+8FNOLKjM4O2yifaP92tk skAA== X-Gm-Message-State: AOJu0YxUgYX4TvTZV9PrYLcmttg1hdPVQhlvRKgWU+Fuy5gRxYQnhSYW ODYT6zzk8OAEAdx22hQk8pFxO98czciADEMp+SreCZFw1/ltbm+T+JMP24v+OzPYr95y5i/w4t/ 7LJV22ddzenlXG9BmSvE4P8cpftIHr5FoLzhpblZvctQJq1lL445Pj21FU2yDR1HE8uuPauibBI bhxGdXKwf/V6STFKS6ld0sdmsXvSqgEQ== X-Received: by 2002:a05:6402:51d3:b0:57c:947c:f9cf with SMTP id 4fb4d7f45d1cf-5879eed9408mr9390423a12.11.1720046738905; Wed, 03 Jul 2024 15:45:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHZcOFLTyGAEO6NXvv5yhaYNaCwNKD0DVZreB/5Mu/jQWKsJHTsk9pKkhFpORLLotXjQ+/Z+Q== X-Received: by 2002:a05:6402:51d3:b0:57c:947c:f9cf with SMTP id 4fb4d7f45d1cf-5879eed9408mr9390402a12.11.1720046738283; Wed, 03 Jul 2024 15:45:38 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58de8fe6322sm442672a12.53.2024.07.03.15.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:45:37 -0700 (PDT) Date: Wed, 3 Jul 2024 18:45:33 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Gregory Price , Gregory Price , Jonathan Cameron , Fan Ni Subject: [PULL v3 17/85] hw/cxl/mailbox: interface to add CCI commands to an existing CCI Message-ID: <67adb7979b6c1151a906d99f19fccf1e789316b1.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Gregory Price This enables wrapper devices to customize the base device's CCI (for example, with custom commands outside the specification) without the need to change the base device. The also enabled the base device to dispatch those commands without requiring additional driver support. Heavily edited by Jonathan Cameron to increase code reuse Signed-off-by: Gregory Price Signed-off-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-3-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 2 ++ hw/cxl/cxl-mailbox-utils.c | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index ccc4611875..a5f8e25020 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -301,6 +301,8 @@ void cxl_initialize_mailbox_t3(CXLCCI *cci, DeviceState *d, size_t payload_max); void cxl_initialize_mailbox_swcci(CXLCCI *cci, DeviceState *intf, DeviceState *d, size_t payload_max); void cxl_init_cci(CXLCCI *cci, size_t payload_max); +void cxl_add_cci_commands(CXLCCI *cci, const struct cxl_cmd (*cxl_cmd_set)[256], + size_t payload_max); int cxl_process_cci_message(CXLCCI *cci, uint8_t set, uint8_t cmd, size_t len_in, uint8_t *pl_in, size_t *len_out, uint8_t *pl_out, diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 2c9f50f0f9..2a64c58e2f 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1424,9 +1424,9 @@ static void bg_timercb(void *opaque) } } -void cxl_init_cci(CXLCCI *cci, size_t payload_max) +static void cxl_rebuild_cel(CXLCCI *cci) { - cci->payload_max = payload_max; + cci->cel_size = 0; /* Reset for a fresh build */ for (int set = 0; set < 256; set++) { for (int cmd = 0; cmd < 256; cmd++) { if (cci->cxl_cmd_set[set][cmd].handler) { @@ -1440,6 +1440,13 @@ void cxl_init_cci(CXLCCI *cci, size_t payload_max) } } } +} + +void cxl_init_cci(CXLCCI *cci, size_t payload_max) +{ + cci->payload_max = payload_max; + cxl_rebuild_cel(cci); + cci->bg.complete_pct = 0; cci->bg.starttime = 0; cci->bg.runtime = 0; @@ -1458,6 +1465,14 @@ static void cxl_copy_cci_commands(CXLCCI *cci, const struct cxl_cmd (*cxl_cmds)[ } } +void cxl_add_cci_commands(CXLCCI *cci, const struct cxl_cmd (*cxl_cmd_set)[256], + size_t payload_max) +{ + cci->payload_max = MAX(payload_max, cci->payload_max); + cxl_copy_cci_commands(cci, cxl_cmd_set); + cxl_rebuild_cel(cci); +} + void cxl_initialize_mailbox_swcci(CXLCCI *cci, DeviceState *intf, DeviceState *d, size_t payload_max) { From patchwork Wed Jul 3 22:45:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722978 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9230CC2BD09 for ; Wed, 3 Jul 2024 22:48:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8ja-0003fl-Cm; Wed, 03 Jul 2024 18:45: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 1sP8jV-0003UO-Lb for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:52 -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 1sP8jT-0001MX-JK for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046746; 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=R2rkXgOWy7oaxjC82Fwhko4ewIXnfZhtW9KkNOPqa7A=; b=WZlby+uO1+S/JH/q8kFmJwi4wLu73xNeegptpDy0euys8I4f8YlIbSVoSAU8PMAa9tRrpc N5tbuN4JQnB0MFeAmiUjwJYzv+z4NQ5mbNqP6R9lJnp9t2GAu7bSTWHgU5xryeMWY5QTrd cGNFP/6L422+fX9O3cZoc92IvcVkizI= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-17-Raqsfjl-OiO3YhT-TIM_Kw-1; Wed, 03 Jul 2024 18:45:44 -0400 X-MC-Unique: Raqsfjl-OiO3YhT-TIM_Kw-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-58d152f7f67so2163a12.1 for ; Wed, 03 Jul 2024 15:45:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046743; x=1720651543; 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=R2rkXgOWy7oaxjC82Fwhko4ewIXnfZhtW9KkNOPqa7A=; b=Qfs03rv9EFLE7jOBzs+clmfwfBXQYKXhOz159OC/SGf76YEpb0UQL5FDqWaMnQhYYz Y/MSxC/zAwwaePm1ObiRzJ+AntlW12mR3nBb2oypm/cbjPIILYkGcCJjpc0QyBX2GOXS 3iCVxt1GWbIaMw18FfTsKQ0hFxgB2lb4YSdHtBPkEbiPb8pBy4Cnd6w0E37zno8gJsKr uaANwdZHiBxOpEhdN0SjYI0Gccxs0d5uEPIuMaWe4PJ9jROs/EAjNx9j0WL4Y+Q7YuxP 7qM8+M/L61UcIVhoRqeLAQRkAP50qla2VREtOEqtoZ8Od1ylm69UgDYetG4HrPpkSC+p mvJQ== X-Gm-Message-State: AOJu0Yyy+w7vhHdS3/3GSLpXmbLcdf5LRjctFCASMXxJt1dxhQt/8qNs 0zmxbo5Pal5NlgDU2neSiNeBIaOYeeE0RKMQZ9xymBlp8vz/+2nBlkv/HHX7Os+6zgf0bj3kADa Q12TFMCNKAYVNeMDEpXgfrJ2j3PM7V43JD3l1d662FESLemP0+MykblfIiDxWUsMlPMbwP4K95z HCqSMx8D9SoDZeRYSz8AS0vkUJiAd6Vw== X-Received: by 2002:a05:6402:2547:b0:57a:33a5:9b71 with SMTP id 4fb4d7f45d1cf-587a0919556mr10421990a12.33.1720046743291; Wed, 03 Jul 2024 15:45:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8XneULyE7BI0vXo7U7CggJHhbMaGu29VQXp96igGoEXH6Ez+E85gtATcAr2hxrM81v/uUUQ== X-Received: by 2002:a05:6402:2547:b0:57a:33a5:9b71 with SMTP id 4fb4d7f45d1cf-587a0919556mr10421958a12.33.1720046742268; Wed, 03 Jul 2024 15:45:42 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58614d50464sm7570642a12.69.2024.07.03.15.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:45:41 -0700 (PDT) Date: Wed, 3 Jul 2024 18:45:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL v3 18/85] hw/cxl/cxl-mailbox-utils: Add dc_event_log_size field to output payload of identify memory device command Message-ID: <7a21e5dedbbcec11ebab7a53186085f09a53f9e7.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni Based on CXL spec r3.1 Table 8-127 (Identify Memory Device Output Payload), dynamic capacity event log size should be part of output of the Identify command. Add dc_event_log_size to the output payload for the host to get the info. Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-4-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 2a64c58e2f..626acc1d0d 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -21,6 +21,7 @@ #include "sysemu/hostmem.h" #define CXL_CAPACITY_MULTIPLIER (256 * MiB) +#define CXL_DC_EVENT_LOG_SIZE 8 /* * How to add a new command, example. The command set FOO, with cmd BAR. @@ -780,8 +781,9 @@ static CXLRetCode cmd_identify_memory_device(const struct cxl_cmd *cmd, uint16_t inject_poison_limit; uint8_t poison_caps; uint8_t qos_telemetry_caps; + uint16_t dc_event_log_size; } QEMU_PACKED *id; - QEMU_BUILD_BUG_ON(sizeof(*id) != 0x43); + QEMU_BUILD_BUG_ON(sizeof(*id) != 0x45); CXLType3Dev *ct3d = CXL_TYPE3(cci->d); CXLType3Class *cvc = CXL_TYPE3_GET_CLASS(ct3d); CXLDeviceState *cxl_dstate = &ct3d->cxl_dstate; @@ -807,6 +809,7 @@ static CXLRetCode cmd_identify_memory_device(const struct cxl_cmd *cmd, st24_le_p(id->poison_list_max_mer, 256); /* No limit - so limited by main poison record limit */ stw_le_p(&id->inject_poison_limit, 0); + stw_le_p(&id->dc_event_log_size, CXL_DC_EVENT_LOG_SIZE); *len_out = sizeof(*id); return CXL_MBOX_SUCCESS; From patchwork Wed Jul 3 22:45:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD447C31D97 for ; Wed, 3 Jul 2024 22:47:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8jg-0004CP-6n; Wed, 03 Jul 2024 18:46:02 -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 1sP8ja-0003hg-HA for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:54 -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 1sP8jY-0001Ne-Hm for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046751; 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=Q5yMEJxQrvHs2013SKJXv7QWp1/VlpmqevozX2UnFx8=; b=Gci07JTBQxE1O8O2lid/Mq3Ug9kfVPRQ2Zs+YDLznAzh3XJ7Y7PNpynIl0uwXMO2eDOXWq +85tZFyLYYSKv79LegOS8vui2IqlPggMFBW1Gf41HUQUSVknysX0PfI94Nlcfxb0AFfGri He8KQVSfYpfqcJixGaHfJVTj0Wh85OU= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-231-ZxSjruN1MLyOxVQ-t8L8nw-1; Wed, 03 Jul 2024 18:45:49 -0400 X-MC-Unique: ZxSjruN1MLyOxVQ-t8L8nw-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2ee86eda4e4so9771771fa.3 for ; Wed, 03 Jul 2024 15:45:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046747; x=1720651547; 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=Q5yMEJxQrvHs2013SKJXv7QWp1/VlpmqevozX2UnFx8=; b=DVdChoI274rYLB+pJ06KFA4/2WGr+WOoOjRUfX28Ey5gRdJoJGIEmnWBUJvR6E/b7B /TsHfwwXeKU+SBL43B21rbmbYVcjmczGs5eGQYbmXkR/29ExMSk8+ePcKYrnYV2secTm PoBp92kA6yJkL4fLIx0JXIC2aDT+tdzrJ1YQn8u4YAw04LhUelmp3zk0UN/Nf9Gn5tc/ IZtalDUZzP4XsbJ37vEbJiyJntENm6NK6trCGNRbOD1aL0omwl3x2sVxjfGNb7QZEmC5 rLHXpSwiNa1u+7AvoSRFkMezWKRaeQkLEATNFwSDPB0NBoH1+C7q/TGHmpQMPFEg5n53 3CEw== X-Gm-Message-State: AOJu0Ywgxb1N0FQSaXdkrV7pwo3sIAxdnXQQxRq8FCSSTrC3lcXlBLO4 jd91cAg5R9BDPmHsTcZPpxM5QM6sRo90DcP5CCsV6cYh/CwPfyBx4z/0PHWaQtOOZmaAiH+H89r /oJZ9ruAoHkE14Q8PyOzi9jsFYoOxNQt9CM1wTsVIykAY3MpcOLT8l1j2ySXqWllllFX3zj32Pg 9b7rdHP03jrxK7T7xapLPxiYFYHDjakw== X-Received: by 2002:a05:651c:1a20:b0:2ee:44f7:cc74 with SMTP id 38308e7fff4ca-2ee5e34591cmr96368611fa.6.1720046747518; Wed, 03 Jul 2024 15:45:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7mXFUpgNQBCgd7X2pTuYRWexbGaRz0u5FOqZYJpq1l6njhQ2DXVDYitiAWwivRIC3Fm5llA== X-Received: by 2002:a05:651c:1a20:b0:2ee:44f7:cc74 with SMTP id 38308e7fff4ca-2ee5e34591cmr96368411fa.6.1720046746829; Wed, 03 Jul 2024 15:45:46 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58614f3d51asm7646980a12.81.2024.07.03.15.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:45:46 -0700 (PDT) Date: Wed, 3 Jul 2024 18:45:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL v3 19/85] hw/cxl/cxl-mailbox-utils: Add dynamic capacity region representative and mailbox command support Message-ID: <0f0f140b100392fd938eb6933752155ea68b26a8.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni Per cxl spec r3.1, add dynamic capacity (DC) region representative based on Table 8-165 and extend the cxl type3 device definition to include DC region information. Also, based on info in 8.2.9.9.9.1, add 'Get Dynamic Capacity Configuration' mailbox support. Note: we store region decode length as byte-wise length on the device, which should be divided by 256 * MiB before being returned to the host for "Get Dynamic Capacity Configuration" mailbox command per specification. Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-5-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 16 +++++++ hw/cxl/cxl-mailbox-utils.c | 96 +++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index a5f8e25020..e839370266 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -422,6 +422,17 @@ typedef struct CXLPoison { typedef QLIST_HEAD(, CXLPoison) CXLPoisonList; #define CXL_POISON_LIST_LIMIT 256 +#define DCD_MAX_NUM_REGION 8 + +typedef struct CXLDCRegion { + uint64_t base; /* aligned to 256*MiB */ + uint64_t decode_len; /* aligned to 256*MiB */ + uint64_t len; + uint64_t block_size; + uint32_t dsmadhandle; + uint8_t flags; +} CXLDCRegion; + struct CXLType3Dev { /* Private */ PCIDevice parent_obj; @@ -454,6 +465,11 @@ struct CXLType3Dev { unsigned int poison_list_cnt; bool poison_list_overflowed; uint64_t poison_list_overflow_ts; + + struct dynamic_capacity { + uint8_t num_regions; /* 0-8 regions */ + CXLDCRegion regions[DCD_MAX_NUM_REGION]; + } dc; }; #define TYPE_CXL_TYPE3 "cxl-type3" diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 626acc1d0d..bede28e3c8 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -22,6 +22,8 @@ #define CXL_CAPACITY_MULTIPLIER (256 * MiB) #define CXL_DC_EVENT_LOG_SIZE 8 +#define CXL_NUM_EXTENTS_SUPPORTED 512 +#define CXL_NUM_TAGS_SUPPORTED 0 /* * How to add a new command, example. The command set FOO, with cmd BAR. @@ -80,6 +82,8 @@ enum { #define GET_POISON_LIST 0x0 #define INJECT_POISON 0x1 #define CLEAR_POISON 0x2 + DCD_CONFIG = 0x48, + #define GET_DC_CONFIG 0x0 PHYSICAL_SWITCH = 0x51, #define IDENTIFY_SWITCH_DEVICE 0x0 #define GET_PHYSICAL_PORT_STATE 0x1 @@ -1238,6 +1242,88 @@ static CXLRetCode cmd_media_clear_poison(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } +/* + * CXL r3.1 section 8.2.9.9.9.1: Get Dynamic Capacity Configuration + * (Opcode: 4800h) + */ +static CXLRetCode cmd_dcd_get_dyn_cap_config(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + struct { + uint8_t region_cnt; + uint8_t start_rid; + } QEMU_PACKED *in = (void *)payload_in; + struct { + uint8_t num_regions; + uint8_t regions_returned; + uint8_t rsvd1[6]; + struct { + uint64_t base; + uint64_t decode_len; + uint64_t region_len; + uint64_t block_size; + uint32_t dsmadhandle; + uint8_t flags; + uint8_t rsvd2[3]; + } QEMU_PACKED records[]; + } QEMU_PACKED *out = (void *)payload_out; + struct { + uint32_t num_extents_supported; + uint32_t num_extents_available; + uint32_t num_tags_supported; + uint32_t num_tags_available; + } QEMU_PACKED *extra_out; + uint16_t record_count; + uint16_t i; + uint16_t out_pl_len; + uint8_t start_rid; + + start_rid = in->start_rid; + if (start_rid >= ct3d->dc.num_regions) { + return CXL_MBOX_INVALID_INPUT; + } + + record_count = MIN(ct3d->dc.num_regions - in->start_rid, in->region_cnt); + + out_pl_len = sizeof(*out) + record_count * sizeof(out->records[0]); + extra_out = (void *)(payload_out + out_pl_len); + out_pl_len += sizeof(*extra_out); + assert(out_pl_len <= CXL_MAILBOX_MAX_PAYLOAD_SIZE); + + out->num_regions = ct3d->dc.num_regions; + out->regions_returned = record_count; + for (i = 0; i < record_count; i++) { + stq_le_p(&out->records[i].base, + ct3d->dc.regions[start_rid + i].base); + stq_le_p(&out->records[i].decode_len, + ct3d->dc.regions[start_rid + i].decode_len / + CXL_CAPACITY_MULTIPLIER); + stq_le_p(&out->records[i].region_len, + ct3d->dc.regions[start_rid + i].len); + stq_le_p(&out->records[i].block_size, + ct3d->dc.regions[start_rid + i].block_size); + stl_le_p(&out->records[i].dsmadhandle, + ct3d->dc.regions[start_rid + i].dsmadhandle); + out->records[i].flags = ct3d->dc.regions[start_rid + i].flags; + } + /* + * TODO: Assign values once extents and tags are introduced + * to use. + */ + stl_le_p(&extra_out->num_extents_supported, CXL_NUM_EXTENTS_SUPPORTED); + stl_le_p(&extra_out->num_extents_available, CXL_NUM_EXTENTS_SUPPORTED); + stl_le_p(&extra_out->num_tags_supported, CXL_NUM_TAGS_SUPPORTED); + stl_le_p(&extra_out->num_tags_available, CXL_NUM_TAGS_SUPPORTED); + + *len_out = out_pl_len; + return CXL_MBOX_SUCCESS; +} + #define IMMEDIATE_CONFIG_CHANGE (1 << 1) #define IMMEDIATE_DATA_CHANGE (1 << 2) #define IMMEDIATE_POLICY_CHANGE (1 << 3) @@ -1282,6 +1368,11 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = { cmd_media_clear_poison, 72, 0 }, }; +static const struct cxl_cmd cxl_cmd_set_dcd[256][256] = { + [DCD_CONFIG][GET_DC_CONFIG] = { "DCD_GET_DC_CONFIG", + cmd_dcd_get_dyn_cap_config, 2, 0 }, +}; + static const struct cxl_cmd cxl_cmd_set_sw[256][256] = { [INFOSTAT][IS_IDENTIFY] = { "IDENTIFY", cmd_infostat_identify, 0, 0 }, [INFOSTAT][BACKGROUND_OPERATION_STATUS] = { "BACKGROUND_OPERATION_STATUS", @@ -1487,7 +1578,12 @@ void cxl_initialize_mailbox_swcci(CXLCCI *cci, DeviceState *intf, void cxl_initialize_mailbox_t3(CXLCCI *cci, DeviceState *d, size_t payload_max) { + CXLType3Dev *ct3d = CXL_TYPE3(d); + cxl_copy_cci_commands(cci, cxl_cmd_set); + if (ct3d->dc.num_regions) { + cxl_copy_cci_commands(cci, cxl_cmd_set_dcd); + } cci->d = d; /* No separation for PCI MB as protocol handled in PCI device */ From patchwork Wed Jul 3 22:45:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D00B5C41513 for ; Wed, 3 Jul 2024 22:47:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8jl-0004f3-TJ; Wed, 03 Jul 2024 18:46: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 1sP8jg-0004Hv-7n for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:02 -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 1sP8jc-0001Od-9y for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:45:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046754; 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=/tkdF9wBgRXJ0C7b2uR1oP4dL+2Be2HPdzcygUpss9I=; b=LAIOujXqfnn+NUxXlvvHeyrQiRYpE7VAMDoACnj4NC/4qyINz2Tfm9QyTCafy64I6oLFlk Ti1WOPOyZPv9NhTjQvr/NRG45xeV8Urc0hSpBsIIZsB18jS2V3Rju3/ZTLY9ym1KAOB+2W 3Qtr9vDDrNgomFtTcArTZtPenI5Q9AQ= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-136-7WFWSkXVOyOXUz0UD9SQhA-1; Wed, 03 Jul 2024 18:45:53 -0400 X-MC-Unique: 7WFWSkXVOyOXUz0UD9SQhA-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-52ce42bb0efso6843914e87.2 for ; Wed, 03 Jul 2024 15:45:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046752; x=1720651552; 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=/tkdF9wBgRXJ0C7b2uR1oP4dL+2Be2HPdzcygUpss9I=; b=tzNarQPClaZr34WZsaEc57WU2NimHwtf126kfloY/Xm2LZtOPCYxOT23/5s0GvUSir QPkGcvUnace0jswNg9ZG2AC9fgqtzJMuLGC9neOJI+7Zg3matLkcwR19aNh0LWetBANj Yhguum3iLKJhdgMwUg3EujgTHrwzc+1rJ8wB3VCwZIc4srHwPucFC7S45lZjpQPw//58 8/Y0IJyUy3er5EAC+v9OeTRLuXNpuqY4543bB1CcRIyg48BBNjnEFDdwdbq0NavovX3B KK8WGhpuVIXM31AJBwRvBRTohoH1P3aUAwlEOVRiR/r+D9Vg1FK6c0Azhe6fi2d6daw/ iRlA== X-Gm-Message-State: AOJu0Ywn5PhgsrUryO6Fpflq2hMz9KF3kId97Ks43LBTf/eQShK1F0Zh 5QcQJi0FL+3YdSBqc/VNUZ+PqQ2a+f6ALbS5jZa6N7VZxCUnybTpY4+rBtiojxydAlY3eQH2pq4 DTd1ATeY8uFMIHYzH0GRCmGziCZUx5092U7LzJHGaI3kfC83foh/fFhQ3XsWcnAftqAKONzPJD1 47L+bYgreNCS7LajAF7d1auCjeTseQFA== X-Received: by 2002:a05:6512:4013:b0:52c:8abe:51fb with SMTP id 2adb3069b0e04-52e8264bd0fmr9103860e87.10.1720046751724; Wed, 03 Jul 2024 15:45:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqisPTGGV66vDsiDIvIasHNUqZC7CAH8HMT+8BoW8oC7wSJSJBJwk0Ntykr1b2Llf7fuPx6g== X-Received: by 2002:a05:6512:4013:b0:52c:8abe:51fb with SMTP id 2adb3069b0e04-52e8264bd0fmr9103839e87.10.1720046751030; Wed, 03 Jul 2024 15:45:51 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5861324feb7sm7696523a12.37.2024.07.03.15.45.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:45:50 -0700 (PDT) Date: Wed, 3 Jul 2024 18:45:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL v3 20/85] include/hw/cxl/cxl_device: Rename mem_size as static_mem_size for type3 memory devices Message-ID: <25851080772387ae33d6ee94250b3a31bf719e5c.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni Rename mem_size as static_mem_size for type3 memdev to cover static RAM and pmem capacity, preparing for the introduction of dynamic capacity to support dynamic capacity devices. Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-6-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 2 +- hw/cxl/cxl-mailbox-utils.c | 4 ++-- hw/mem/cxl_type3.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index e839370266..f7f56b44e3 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -234,7 +234,7 @@ typedef struct cxl_device_state { } timestamp; /* memory region size, HDM */ - uint64_t mem_size; + uint64_t static_mem_size; uint64_t pmem_size; uint64_t vmem_size; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index bede28e3c8..b592473587 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -803,7 +803,7 @@ static CXLRetCode cmd_identify_memory_device(const struct cxl_cmd *cmd, snprintf(id->fw_revision, 0x10, "BWFW VERSION %02d", 0); stq_le_p(&id->total_capacity, - cxl_dstate->mem_size / CXL_CAPACITY_MULTIPLIER); + cxl_dstate->static_mem_size / CXL_CAPACITY_MULTIPLIER); stq_le_p(&id->persistent_capacity, cxl_dstate->pmem_size / CXL_CAPACITY_MULTIPLIER); stq_le_p(&id->volatile_capacity, @@ -1179,7 +1179,7 @@ static CXLRetCode cmd_media_clear_poison(const struct cxl_cmd *cmd, struct clear_poison_pl *in = (void *)payload_in; dpa = ldq_le_p(&in->dpa); - if (dpa + CXL_CACHE_LINE_SIZE > cxl_dstate->mem_size) { + if (dpa + CXL_CACHE_LINE_SIZE > cxl_dstate->static_mem_size) { return CXL_MBOX_INVALID_PA; } diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 3e42490b6c..7194c8f902 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -608,7 +608,7 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) } address_space_init(&ct3d->hostvmem_as, vmr, v_name); ct3d->cxl_dstate.vmem_size = memory_region_size(vmr); - ct3d->cxl_dstate.mem_size += memory_region_size(vmr); + ct3d->cxl_dstate.static_mem_size += memory_region_size(vmr); g_free(v_name); } @@ -631,7 +631,7 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) } address_space_init(&ct3d->hostpmem_as, pmr, p_name); ct3d->cxl_dstate.pmem_size = memory_region_size(pmr); - ct3d->cxl_dstate.mem_size += memory_region_size(pmr); + ct3d->cxl_dstate.static_mem_size += memory_region_size(pmr); g_free(p_name); } @@ -837,7 +837,7 @@ static int cxl_type3_hpa_to_as_and_dpa(CXLType3Dev *ct3d, return -EINVAL; } - if (*dpa_offset > ct3d->cxl_dstate.mem_size) { + if (*dpa_offset > ct3d->cxl_dstate.static_mem_size) { return -EINVAL; } @@ -1010,7 +1010,7 @@ static bool set_cacheline(CXLType3Dev *ct3d, uint64_t dpa_offset, uint8_t *data) return false; } - if (dpa_offset + CXL_CACHE_LINE_SIZE > ct3d->cxl_dstate.mem_size) { + if (dpa_offset + CXL_CACHE_LINE_SIZE > ct3d->cxl_dstate.static_mem_size) { return false; } From patchwork Wed Jul 3 22:45:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1510DC3271E for ; Wed, 3 Jul 2024 22:48:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8jn-0004wx-Ey; Wed, 03 Jul 2024 18:46: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 1sP8jj-0004Ow-D9 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46: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 1sP8jh-0001Ou-KT for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046760; 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=1ElU1S3yGZ4jv6gdF/qOH23dlnO7FdnAYenskxuOvWI=; b=bu17zeh6e1sR1dpadqAKUxytmgwCeCOLL8+1LtTMgSCDTGu6WydNsXLbTkXgaRxvG5sSf+ sIjulOg5RhrowjsiY09alFal6NOijUd0B5a5EaPaX6TJ/qUf4wmx6QIj3mDwzQuOWsMTvX JGBNVnTe2Gl8CUQv64SNWcNiOTFN86E= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-683-mmH_molnOSqvSYousO7jAw-1; Wed, 03 Jul 2024 18:45:58 -0400 X-MC-Unique: mmH_molnOSqvSYousO7jAw-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-52e98697a27so1332393e87.2 for ; Wed, 03 Jul 2024 15:45:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046757; x=1720651557; 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=1ElU1S3yGZ4jv6gdF/qOH23dlnO7FdnAYenskxuOvWI=; b=UphXROtVA0DJWWRmba627ctOYtLikH4aP983XTDmxQltLbZimc7PeVpU5z2GaS54zf rmm18J4tV7Hn04GuoP6lJOzbRveN5gToqiH5giHpfaEq2eyIann45z17a7ofRUkoggqz nUYt40wPWy5DBEwTXUdunCJWKv+zOTad8WeeHjqH9yZJUq+pp3fyptgjcX7Hie6kWa7B fHrHy/3GGovpu99L5h9006hGhMiG4CVaGWEarpHOjhSU3JS4Ugu9qf00RJ0oeMkTk67R CyDkCeYelGXIekbP+av16Wu9hChq9uXhZ7Amtjnv93aJXV1GZSZ5unkEBcsqxPvgHM2G jxug== X-Gm-Message-State: AOJu0YxBSFkcbg+/mqBtdL8Wag0zz/XKld11LqHqV+mDVnzu9+lmgYfp RfAzwnZn/QA1s/4ey1zIXIZ7+H0hQRyZQQfD44nBn5bgL674EgwRaiK4jr1ii8I2QQiXVFt4gX1 1My+gyq7wtTvYhlFmmeF94Tp6baoWZ5MtPv92zzy5CUaXkJmja+leJjNNfcc7kbdGe3+tqg25DL 9VLMA51yks/iogHaLhkk0xm9iNAqofbQ== X-Received: by 2002:a05:6512:3d91:b0:52c:c1aa:dd52 with SMTP id 2adb3069b0e04-52e8268aa24mr9205105e87.30.1720046756989; Wed, 03 Jul 2024 15:45:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKipgOaio9YbDukqlH2oh1020WKcEazRdIlfzVqpnThpSLZApOU1nmX0uTAKZEFWjqNnFKWQ== X-Received: by 2002:a05:6512:3d91:b0:52c:c1aa:dd52 with SMTP id 2adb3069b0e04-52e8268aa24mr9205082e87.30.1720046756155; Wed, 03 Jul 2024 15:45:56 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf5a612sm548367266b.51.2024.07.03.15.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:45:55 -0700 (PDT) Date: Wed, 3 Jul 2024 18:45:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron , Li Zhijian Subject: [PULL v3 21/85] hw/mem/cxl_type3: Add support to create DC regions to type3 memory devices Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni With the change, when setting up memory for type3 memory device, we can create DC regions. A property 'num-dc-regions' is added to ct3_props to allow users to pass the number of DC regions to create. To make it easier, other region parameters like region base, length, and block size are hard coded. If needed, these parameters can be added easily. With the change, we can create DC regions with proper kernel side support like below: region=$(cat /sys/bus/cxl/devices/decoder0.0/create_dc_region) echo $region > /sys/bus/cxl/devices/decoder0.0/create_dc_region echo 256 > /sys/bus/cxl/devices/$region/interleave_granularity echo 1 > /sys/bus/cxl/devices/$region/interleave_ways echo "dc0" >/sys/bus/cxl/devices/decoder2.0/mode echo 0x40000000 >/sys/bus/cxl/devices/decoder2.0/dpa_size echo 0x40000000 > /sys/bus/cxl/devices/$region/size echo "decoder2.0" > /sys/bus/cxl/devices/$region/target0 echo 1 > /sys/bus/cxl/devices/$region/commit echo $region > /sys/bus/cxl/drivers/cxl_region/bind Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-7-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Li Zhijian --- hw/mem/cxl_type3.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 7194c8f902..06c6f9bb78 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -30,6 +30,7 @@ #include "hw/pci/msix.h" #define DWORD_BYTE 4 +#define CXL_CAPACITY_MULTIPLIER (256 * MiB) /* Default CDAT entries for a memory region */ enum { @@ -567,6 +568,50 @@ static void ct3d_reg_write(void *opaque, hwaddr offset, uint64_t value, } } +/* + * TODO: dc region configuration will be updated once host backend and address + * space support is added for DCD. + */ +static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Error **errp) +{ + int i; + uint64_t region_base = 0; + uint64_t region_len = 2 * GiB; + uint64_t decode_len = 2 * GiB; + uint64_t blk_size = 2 * MiB; + CXLDCRegion *region; + MemoryRegion *mr; + + if (ct3d->hostvmem) { + mr = host_memory_backend_get_memory(ct3d->hostvmem); + region_base += memory_region_size(mr); + } + if (ct3d->hostpmem) { + mr = host_memory_backend_get_memory(ct3d->hostpmem); + region_base += memory_region_size(mr); + } + if (region_base % CXL_CAPACITY_MULTIPLIER != 0) { + error_setg(errp, "DC region base not aligned to 0x%lx", + CXL_CAPACITY_MULTIPLIER); + return false; + } + + for (i = 0, region = &ct3d->dc.regions[0]; + i < ct3d->dc.num_regions; + i++, region++, region_base += region_len) { + *region = (CXLDCRegion) { + .base = region_base, + .decode_len = decode_len, + .len = region_len, + .block_size = blk_size, + /* dsmad_handle set when creating CDAT table entries */ + .flags = 0, + }; + } + + return true; +} + static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) { DeviceState *ds = DEVICE(ct3d); @@ -635,6 +680,13 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) g_free(p_name); } + if (ct3d->dc.num_regions > 0) { + if (!cxl_create_dc_regions(ct3d, errp)) { + error_append_hint(errp, "setup DC regions failed"); + return false; + } + } + return true; } @@ -930,6 +982,7 @@ static Property ct3_props[] = { HostMemoryBackend *), DEFINE_PROP_UINT64("sn", CXLType3Dev, sn, UI64_NULL), DEFINE_PROP_STRING("cdat", CXLType3Dev, cxl_cstate.cdat.filename), + DEFINE_PROP_UINT8("num-dc-regions", CXLType3Dev, dc.num_regions, 0), DEFINE_PROP_END_OF_LIST(), }; From patchwork Wed Jul 3 22:45:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9CAD8C31D97 for ; Wed, 3 Jul 2024 22:49:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8js-0005YF-Mu; Wed, 03 Jul 2024 18:46: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 1sP8jq-0005Mq-MG for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46: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 1sP8jk-0001Pa-O0 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046764; 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=FMOgEcAe53x2nl/kUwLBbhwXiRFlv4+KNdbX+UZGPhI=; b=iA3iGItmUKEEOApfP5YA6DpFD9rS1pwZka6FqB60IIjs7mbU3BIwdXq7JxCNH7JGY7XqxA pEwbuskNczS8HTbjGoU4nC9uTk9iomM2OTC0vBSVZaSsII7j9TwrvHiv68DkkNHgnydIDs gAvodMsmN6g+zPOfIs4R3/7EBU8b6a4= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-672-pqB9G4KpP02BHwZyJfQMbQ-1; Wed, 03 Jul 2024 18:46:02 -0400 X-MC-Unique: pqB9G4KpP02BHwZyJfQMbQ-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-52e981abb3fso1175598e87.0 for ; Wed, 03 Jul 2024 15:46:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046761; x=1720651561; 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=FMOgEcAe53x2nl/kUwLBbhwXiRFlv4+KNdbX+UZGPhI=; b=UmZ+n4xUIrW3jGleenLxWTH9eInTcBYDcUBzfOBGpmhZoofNDgwbZ2tV835DufDPX2 o8iDXbo7DBjvsvMQ9iLYApNVLImwA7qldWXQUmS6gk7AK0dRiJpqdH0eVcHlOxY3Ybxi 9MNINzmg1GerTGO849re8JB9zQH4E1mSW4WzbFvvTvPHP6DNwrZbc8EsNew1FLb3q+4C kDNeLhxHFO58rhO4269BJNEIVt9ZmJz1EHXXOKfUKnSTj80UlejJ6vI6rckFZsIrFWzj zOF7BBX2g0Sf5+SbLfoJjImyIdsXHw9c7omqXrLCdrRQ5Q87mWV6TKb6hICt5nuXovkc d4+A== X-Gm-Message-State: AOJu0Yx9oBYZiuvd1tDP2CTyXI556LFDAj+6ya3gA1xDPIcGVancJv9h kzXIgMCAXOmycbUTCRAL62ZgUOqheXoGbqv7brnjSe87TkaGpT9eFVT2vBH1mrQpxMeaonY4iZh 9y0dFBgDL4br+0yzk01PB7BXcgPuHBuk9oLgo4UAaV0sR/fUbgp5PUdM1W5nsQR7qb3w7FC3N3Y PYkD0vD41SBgfzCGl7IizAZqX9mmDHgA== X-Received: by 2002:a05:6512:ac6:b0:52c:dc6f:75a3 with SMTP id 2adb3069b0e04-52e8268610dmr9713858e87.40.1720046760958; Wed, 03 Jul 2024 15:46:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF8YTnmipE5QRr+nTQGV4egR4ha6soPpcmvAovcIzbLCRrMpEJoROVHET9BKoO2ZQsFgB5DFg== X-Received: by 2002:a05:6512:ac6:b0:52c:dc6f:75a3 with SMTP id 2adb3069b0e04-52e8268610dmr9713846e87.40.1720046760254; Wed, 03 Jul 2024 15:46:00 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a750fb362d4sm435528566b.49.2024.07.03.15.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:45:59 -0700 (PDT) Date: Wed, 3 Jul 2024 18:45:56 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL v3 22/85] hw/mem/cxl-type3: Refactor ct3_build_cdat_entries_for_mr to take mr size instead of mr as argument Message-ID: <69e4fb569dc1602bfeef5b8c58de5f40cd5d756e.1720046570.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, T_SPF_TEMPERROR=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni The function ct3_build_cdat_entries_for_mr only uses size of the passed memory region argument, refactor the function definition to make the passed arguments more specific. Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-8-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/cxl_type3.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 06c6f9bb78..51be50ce87 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -44,7 +44,7 @@ enum { }; static void ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, - int dsmad_handle, MemoryRegion *mr, + int dsmad_handle, uint64_t size, bool is_pmem, uint64_t dpa_base) { CDATDsmas *dsmas; @@ -63,7 +63,7 @@ static void ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, .DSMADhandle = dsmad_handle, .flags = is_pmem ? CDAT_DSMAS_FLAG_NV : 0, .DPA_base = dpa_base, - .DPA_length = memory_region_size(mr), + .DPA_length = size, }; /* For now, no memory side cache, plausiblish numbers */ @@ -132,7 +132,7 @@ static void ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, */ .EFI_memory_type_attr = is_pmem ? 2 : 1, .DPA_offset = 0, - .DPA_length = memory_region_size(mr), + .DPA_length = size, }; /* Header always at start of structure */ @@ -149,6 +149,7 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_table, void *priv) g_autofree CDATSubHeader **table = NULL; CXLType3Dev *ct3d = priv; MemoryRegion *volatile_mr = NULL, *nonvolatile_mr = NULL; + uint64_t vmr_size = 0, pmr_size = 0; int dsmad_handle = 0; int cur_ent = 0; int len = 0; @@ -163,6 +164,7 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_table, void *priv) return -EINVAL; } len += CT3_CDAT_NUM_ENTRIES; + vmr_size = memory_region_size(volatile_mr); } if (ct3d->hostpmem) { @@ -171,21 +173,22 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_table, void *priv) return -EINVAL; } len += CT3_CDAT_NUM_ENTRIES; + pmr_size = memory_region_size(nonvolatile_mr); } table = g_malloc0(len * sizeof(*table)); /* Now fill them in */ if (volatile_mr) { - ct3_build_cdat_entries_for_mr(table, dsmad_handle++, volatile_mr, + ct3_build_cdat_entries_for_mr(table, dsmad_handle++, vmr_size, false, 0); cur_ent = CT3_CDAT_NUM_ENTRIES; } if (nonvolatile_mr) { - uint64_t base = volatile_mr ? memory_region_size(volatile_mr) : 0; + uint64_t base = vmr_size; ct3_build_cdat_entries_for_mr(&(table[cur_ent]), dsmad_handle++, - nonvolatile_mr, true, base); + pmr_size, true, base); cur_ent += CT3_CDAT_NUM_ENTRIES; } assert(len == cur_ent); From patchwork Wed Jul 3 22:46:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722982 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C6722C2BD09 for ; Wed, 3 Jul 2024 22:49:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8ju-0005jK-I0; Wed, 03 Jul 2024 18:46: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 1sP8js-0005Zi-UL for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46: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 1sP8jo-0001Q5-RT for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046768; 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=eEQf5dMTcN0eNEr2HFQRzAcaAdzyZe0zdBh6kTUpqX4=; b=QDRphH0Ba4X6ED92vxssXJIADC5VGfZpU9Ki9DoaApf7ypURBaT3TPT/cS28R3ZJUhE1nP Tkt48ZYYv9fqSqg/FkFT5r2DLxPzf8VYtkB1wh0SJepfMJtHomsXf7tK38AEugtbiwsiTD IMJwzDD7gUL/dNpSOi68PoZXkC7XpWw= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-486-FIqhV_E1NnWFKIWvWDPViA-1; Wed, 03 Jul 2024 18:46:06 -0400 X-MC-Unique: FIqhV_E1NnWFKIWvWDPViA-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-586c45fc092so2781046a12.3 for ; Wed, 03 Jul 2024 15:46:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046765; x=1720651565; 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=eEQf5dMTcN0eNEr2HFQRzAcaAdzyZe0zdBh6kTUpqX4=; b=WZag3eBAHoIQUW8WZmXGbDjvAVNcy5uEPRj6dozi/QtkBzQbqi58NJ5OdOnHcnKqAA 35sYDo3xehGAmmmkoWPUWQC6Yl2a/YvNKOvuTd900dhTK4Zfr96nJFLdGMhRTNZj7PHy CBiPaRhBW5mIQopOOHfPbq+8uhzsuLlpeuWuvN4WSDCyWw8FfmLkm/nalpUiNEnyEwUz ZeuHaskF29dnLxfe/KFPTnPw5Hyx1Kd67alG27/OoB6Nxr5jzGWoibHgODqSTtlwmvsz /siFjQWeMF2SOk+CN8Op2xH7+vqFFd4j3K23JQ2MYJK4TnKQGRUnZ6Zw77tMnkunMqdI cV6A== X-Gm-Message-State: AOJu0YwJJDfYXHUTrtgafxPoT2vYNgv2rMD1B4Qm+8vcsR3woZqH2/L8 DVSL3XyYpJ+IhmPgNYIW+ZjJPEVIahngf/aVyK3bSL+PwoKvI/onbDfxveG9G4vjmiaXL6f3D+p aOLnkZQPyRWc4x1kc28hvDvrjacRzMiD+bAzZJeiIeEoNRMRGjHDTsM07FN3+kwpBI13bHP8nAd vkaeDKCYDrweJ1A9OkS8GKnA5rTp8e/w== X-Received: by 2002:a05:6402:27c7:b0:58c:eee0:48f8 with SMTP id 4fb4d7f45d1cf-58ceee04bf6mr2462808a12.5.1720046765168; Wed, 03 Jul 2024 15:46:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7YWwNz5TqHCnmXa06vVieCzrtYGXGC3ZgXRu2vqtTR19mJ31yX05jj/gAiWbmJFT9H062zg== X-Received: by 2002:a05:6402:27c7:b0:58c:eee0:48f8 with SMTP id 4fb4d7f45d1cf-58ceee04bf6mr2462796a12.5.1720046764551; Wed, 03 Jul 2024 15:46:04 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58615038a86sm7625340a12.95.2024.07.03.15.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:46:04 -0700 (PDT) Date: Wed, 3 Jul 2024 18:46:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Gregory Price , Jonathan Cameron Subject: [PULL v3 23/85] hw/mem/cxl_type3: Add host backend and address space handling for DC regions Message-ID: <90de94612bb568117e038c6ce9edd35d17d239f9.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni Add (file/memory backed) host backend for DCD. All the dynamic capacity regions will share a single, large enough host backend. Set up address space for DC regions to support read/write operations to dynamic capacity for DCD. With the change, the following support is added: 1. Add a new property to type3 device "volatile-dc-memdev" to point to host memory backend for dynamic capacity. Currently, all DC regions share one host backend; 2. Add namespace for dynamic capacity for read/write support; 3. Create cdat entries for each dynamic capacity region. Reviewed-by: Gregory Price Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-9-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 8 ++ hw/cxl/cxl-mailbox-utils.c | 16 +++- hw/mem/cxl_type3.c | 177 +++++++++++++++++++++++++++++------- 3 files changed, 164 insertions(+), 37 deletions(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index f7f56b44e3..c2c3df0d2a 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -467,6 +467,14 @@ struct CXLType3Dev { uint64_t poison_list_overflow_ts; struct dynamic_capacity { + HostMemoryBackend *host_dc; + AddressSpace host_dc_as; + /* + * total_capacity is equivalent to the dynamic capability + * memory region size. + */ + uint64_t total_capacity; /* 256M aligned */ + uint8_t num_regions; /* 0-8 regions */ CXLDCRegion regions[DCD_MAX_NUM_REGION]; } dc; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index b592473587..6ad227f112 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -622,7 +622,8 @@ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, size_t *len_out, CXLCCI *cci) { - CXLDeviceState *cxl_dstate = &CXL_TYPE3(cci->d)->cxl_dstate; + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + CXLDeviceState *cxl_dstate = &ct3d->cxl_dstate; struct { uint8_t slots_supported; uint8_t slot_info; @@ -636,7 +637,8 @@ static CXLRetCode cmd_firmware_update_get_info(const struct cxl_cmd *cmd, QEMU_BUILD_BUG_ON(sizeof(*fw_info) != 0x50); if ((cxl_dstate->vmem_size < CXL_CAPACITY_MULTIPLIER) || - (cxl_dstate->pmem_size < CXL_CAPACITY_MULTIPLIER)) { + (cxl_dstate->pmem_size < CXL_CAPACITY_MULTIPLIER) || + (ct3d->dc.total_capacity < CXL_CAPACITY_MULTIPLIER)) { return CXL_MBOX_INTERNAL_ERROR; } @@ -793,7 +795,8 @@ static CXLRetCode cmd_identify_memory_device(const struct cxl_cmd *cmd, CXLDeviceState *cxl_dstate = &ct3d->cxl_dstate; if ((!QEMU_IS_ALIGNED(cxl_dstate->vmem_size, CXL_CAPACITY_MULTIPLIER)) || - (!QEMU_IS_ALIGNED(cxl_dstate->pmem_size, CXL_CAPACITY_MULTIPLIER))) { + (!QEMU_IS_ALIGNED(cxl_dstate->pmem_size, CXL_CAPACITY_MULTIPLIER)) || + (!QEMU_IS_ALIGNED(ct3d->dc.total_capacity, CXL_CAPACITY_MULTIPLIER))) { return CXL_MBOX_INTERNAL_ERROR; } @@ -835,9 +838,11 @@ static CXLRetCode cmd_ccls_get_partition_info(const struct cxl_cmd *cmd, uint64_t next_pmem; } QEMU_PACKED *part_info = (void *)payload_out; QEMU_BUILD_BUG_ON(sizeof(*part_info) != 0x20); + CXLType3Dev *ct3d = container_of(cxl_dstate, CXLType3Dev, cxl_dstate); if ((!QEMU_IS_ALIGNED(cxl_dstate->vmem_size, CXL_CAPACITY_MULTIPLIER)) || - (!QEMU_IS_ALIGNED(cxl_dstate->pmem_size, CXL_CAPACITY_MULTIPLIER))) { + (!QEMU_IS_ALIGNED(cxl_dstate->pmem_size, CXL_CAPACITY_MULTIPLIER)) || + (!QEMU_IS_ALIGNED(ct3d->dc.total_capacity, CXL_CAPACITY_MULTIPLIER))) { return CXL_MBOX_INTERNAL_ERROR; } @@ -1179,7 +1184,8 @@ static CXLRetCode cmd_media_clear_poison(const struct cxl_cmd *cmd, struct clear_poison_pl *in = (void *)payload_in; dpa = ldq_le_p(&in->dpa); - if (dpa + CXL_CACHE_LINE_SIZE > cxl_dstate->static_mem_size) { + if (dpa + CXL_CACHE_LINE_SIZE > cxl_dstate->static_mem_size + + ct3d->dc.total_capacity) { return CXL_MBOX_INVALID_PA; } diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 51be50ce87..658570aa1a 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -45,7 +45,8 @@ enum { static void ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, int dsmad_handle, uint64_t size, - bool is_pmem, uint64_t dpa_base) + bool is_pmem, bool is_dynamic, + uint64_t dpa_base) { CDATDsmas *dsmas; CDATDslbis *dslbis0; @@ -61,7 +62,8 @@ static void ct3_build_cdat_entries_for_mr(CDATSubHeader **cdat_table, .length = sizeof(*dsmas), }, .DSMADhandle = dsmad_handle, - .flags = is_pmem ? CDAT_DSMAS_FLAG_NV : 0, + .flags = (is_pmem ? CDAT_DSMAS_FLAG_NV : 0) | + (is_dynamic ? CDAT_DSMAS_FLAG_DYNAMIC_CAP : 0), .DPA_base = dpa_base, .DPA_length = size, }; @@ -149,12 +151,13 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_table, void *priv) g_autofree CDATSubHeader **table = NULL; CXLType3Dev *ct3d = priv; MemoryRegion *volatile_mr = NULL, *nonvolatile_mr = NULL; + MemoryRegion *dc_mr = NULL; uint64_t vmr_size = 0, pmr_size = 0; int dsmad_handle = 0; int cur_ent = 0; int len = 0; - if (!ct3d->hostpmem && !ct3d->hostvmem) { + if (!ct3d->hostpmem && !ct3d->hostvmem && !ct3d->dc.num_regions) { return 0; } @@ -176,21 +179,54 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_table, void *priv) pmr_size = memory_region_size(nonvolatile_mr); } + if (ct3d->dc.num_regions) { + if (!ct3d->dc.host_dc) { + return -EINVAL; + } + dc_mr = host_memory_backend_get_memory(ct3d->dc.host_dc); + if (!dc_mr) { + return -EINVAL; + } + len += CT3_CDAT_NUM_ENTRIES * ct3d->dc.num_regions; + } + table = g_malloc0(len * sizeof(*table)); /* Now fill them in */ if (volatile_mr) { ct3_build_cdat_entries_for_mr(table, dsmad_handle++, vmr_size, - false, 0); + false, false, 0); cur_ent = CT3_CDAT_NUM_ENTRIES; } if (nonvolatile_mr) { uint64_t base = vmr_size; ct3_build_cdat_entries_for_mr(&(table[cur_ent]), dsmad_handle++, - pmr_size, true, base); + pmr_size, true, false, base); cur_ent += CT3_CDAT_NUM_ENTRIES; } + + if (dc_mr) { + int i; + uint64_t region_base = vmr_size + pmr_size; + + /* + * We assume the dynamic capacity to be volatile for now. + * Non-volatile dynamic capacity will be added if needed in the + * future. + */ + for (i = 0; i < ct3d->dc.num_regions; i++) { + ct3_build_cdat_entries_for_mr(&(table[cur_ent]), + dsmad_handle++, + ct3d->dc.regions[i].len, + false, true, region_base); + ct3d->dc.regions[i].dsmadhandle = dsmad_handle - 1; + + cur_ent += CT3_CDAT_NUM_ENTRIES; + region_base += ct3d->dc.regions[i].len; + } + } + assert(len == cur_ent); *cdat_table = g_steal_pointer(&table); @@ -301,10 +337,17 @@ static void build_dvsecs(CXLType3Dev *ct3d) range2_size_lo = (2 << 5) | (2 << 2) | 0x3 | (ct3d->hostpmem->size & 0xF0000000); } - } else { + } else if (ct3d->hostpmem) { range1_size_hi = ct3d->hostpmem->size >> 32; range1_size_lo = (2 << 5) | (2 << 2) | 0x3 | (ct3d->hostpmem->size & 0xF0000000); + } else { + /* + * For DCD with no static memory, set memory active, memory class bits. + * No range is set. + */ + range1_size_hi = 0; + range1_size_lo = (2 << 5) | (2 << 2) | 0x3; } dvsec = (uint8_t *)&(CXLDVSECDevice){ @@ -579,11 +622,29 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Error **errp) { int i; uint64_t region_base = 0; - uint64_t region_len = 2 * GiB; - uint64_t decode_len = 2 * GiB; + uint64_t region_len; + uint64_t decode_len; uint64_t blk_size = 2 * MiB; CXLDCRegion *region; MemoryRegion *mr; + uint64_t dc_size; + + mr = host_memory_backend_get_memory(ct3d->dc.host_dc); + dc_size = memory_region_size(mr); + region_len = DIV_ROUND_UP(dc_size, ct3d->dc.num_regions); + + if (dc_size % (ct3d->dc.num_regions * CXL_CAPACITY_MULTIPLIER) != 0) { + error_setg(errp, + "backend size is not multiple of region len: 0x%" PRIx64, + region_len); + return false; + } + if (region_len % CXL_CAPACITY_MULTIPLIER != 0) { + error_setg(errp, "DC region size is unaligned to 0x%" PRIx64, + CXL_CAPACITY_MULTIPLIER); + return false; + } + decode_len = region_len; if (ct3d->hostvmem) { mr = host_memory_backend_get_memory(ct3d->hostvmem); @@ -594,7 +655,7 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Error **errp) region_base += memory_region_size(mr); } if (region_base % CXL_CAPACITY_MULTIPLIER != 0) { - error_setg(errp, "DC region base not aligned to 0x%lx", + error_setg(errp, "DC region base not aligned to 0x%" PRIx64, CXL_CAPACITY_MULTIPLIER); return false; } @@ -610,6 +671,7 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Error **errp) /* dsmad_handle set when creating CDAT table entries */ .flags = 0, }; + ct3d->dc.total_capacity += region->len; } return true; @@ -619,7 +681,8 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) { DeviceState *ds = DEVICE(ct3d); - if (!ct3d->hostmem && !ct3d->hostvmem && !ct3d->hostpmem) { + if (!ct3d->hostmem && !ct3d->hostvmem && !ct3d->hostpmem + && !ct3d->dc.num_regions) { error_setg(errp, "at least one memdev property must be set"); return false; } else if (ct3d->hostmem && ct3d->hostpmem) { @@ -683,7 +746,37 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) g_free(p_name); } + ct3d->dc.total_capacity = 0; if (ct3d->dc.num_regions > 0) { + MemoryRegion *dc_mr; + char *dc_name; + + if (!ct3d->dc.host_dc) { + error_setg(errp, "dynamic capacity must have a backing device"); + return false; + } + + dc_mr = host_memory_backend_get_memory(ct3d->dc.host_dc); + if (!dc_mr) { + error_setg(errp, "dynamic capacity must have a backing device"); + return false; + } + + /* + * Set DC regions as volatile for now, non-volatile support can + * be added in the future if needed. + */ + memory_region_set_nonvolatile(dc_mr, false); + memory_region_set_enabled(dc_mr, true); + host_memory_backend_set_mapped(ct3d->dc.host_dc, true); + if (ds->id) { + dc_name = g_strdup_printf("cxl-dcd-dpa-dc-space:%s", ds->id); + } else { + dc_name = g_strdup("cxl-dcd-dpa-dc-space"); + } + address_space_init(&ct3d->dc.host_dc_as, dc_mr, dc_name); + g_free(dc_name); + if (!cxl_create_dc_regions(ct3d, errp)) { error_append_hint(errp, "setup DC regions failed"); return false; @@ -779,6 +872,9 @@ err_release_cdat: err_free_special_ops: g_free(regs->special_ops); err_address_space_free: + if (ct3d->dc.host_dc) { + address_space_destroy(&ct3d->dc.host_dc_as); + } if (ct3d->hostpmem) { address_space_destroy(&ct3d->hostpmem_as); } @@ -797,6 +893,9 @@ static void ct3_exit(PCIDevice *pci_dev) pcie_aer_exit(pci_dev); cxl_doe_cdat_release(cxl_cstate); g_free(regs->special_ops); + if (ct3d->dc.host_dc) { + address_space_destroy(&ct3d->dc.host_dc_as); + } if (ct3d->hostpmem) { address_space_destroy(&ct3d->hostpmem_as); } @@ -875,16 +974,23 @@ static int cxl_type3_hpa_to_as_and_dpa(CXLType3Dev *ct3d, AddressSpace **as, uint64_t *dpa_offset) { - MemoryRegion *vmr = NULL, *pmr = NULL; + MemoryRegion *vmr = NULL, *pmr = NULL, *dc_mr = NULL; + uint64_t vmr_size = 0, pmr_size = 0, dc_size = 0; if (ct3d->hostvmem) { vmr = host_memory_backend_get_memory(ct3d->hostvmem); + vmr_size = memory_region_size(vmr); } if (ct3d->hostpmem) { pmr = host_memory_backend_get_memory(ct3d->hostpmem); + pmr_size = memory_region_size(pmr); + } + if (ct3d->dc.host_dc) { + dc_mr = host_memory_backend_get_memory(ct3d->dc.host_dc); + dc_size = memory_region_size(dc_mr); } - if (!vmr && !pmr) { + if (!vmr && !pmr && !dc_mr) { return -ENODEV; } @@ -892,19 +998,18 @@ static int cxl_type3_hpa_to_as_and_dpa(CXLType3Dev *ct3d, return -EINVAL; } - if (*dpa_offset > ct3d->cxl_dstate.static_mem_size) { + if (*dpa_offset >= vmr_size + pmr_size + dc_size) { return -EINVAL; } - if (vmr) { - if (*dpa_offset < memory_region_size(vmr)) { - *as = &ct3d->hostvmem_as; - } else { - *as = &ct3d->hostpmem_as; - *dpa_offset -= memory_region_size(vmr); - } - } else { + if (*dpa_offset < vmr_size) { + *as = &ct3d->hostvmem_as; + } else if (*dpa_offset < vmr_size + pmr_size) { *as = &ct3d->hostpmem_as; + *dpa_offset -= vmr_size; + } else { + *as = &ct3d->dc.host_dc_as; + *dpa_offset -= (vmr_size + pmr_size); } return 0; @@ -986,6 +1091,8 @@ static Property ct3_props[] = { DEFINE_PROP_UINT64("sn", CXLType3Dev, sn, UI64_NULL), DEFINE_PROP_STRING("cdat", CXLType3Dev, cxl_cstate.cdat.filename), DEFINE_PROP_UINT8("num-dc-regions", CXLType3Dev, dc.num_regions, 0), + DEFINE_PROP_LINK("volatile-dc-memdev", CXLType3Dev, dc.host_dc, + TYPE_MEMORY_BACKEND, HostMemoryBackend *), DEFINE_PROP_END_OF_LIST(), }; @@ -1052,33 +1159,39 @@ static void set_lsa(CXLType3Dev *ct3d, const void *buf, uint64_t size, static bool set_cacheline(CXLType3Dev *ct3d, uint64_t dpa_offset, uint8_t *data) { - MemoryRegion *vmr = NULL, *pmr = NULL; + MemoryRegion *vmr = NULL, *pmr = NULL, *dc_mr = NULL; AddressSpace *as; + uint64_t vmr_size = 0, pmr_size = 0, dc_size = 0; if (ct3d->hostvmem) { vmr = host_memory_backend_get_memory(ct3d->hostvmem); + vmr_size = memory_region_size(vmr); } if (ct3d->hostpmem) { pmr = host_memory_backend_get_memory(ct3d->hostpmem); + pmr_size = memory_region_size(pmr); } + if (ct3d->dc.host_dc) { + dc_mr = host_memory_backend_get_memory(ct3d->dc.host_dc); + dc_size = memory_region_size(dc_mr); + } - if (!vmr && !pmr) { + if (!vmr && !pmr && !dc_mr) { return false; } - if (dpa_offset + CXL_CACHE_LINE_SIZE > ct3d->cxl_dstate.static_mem_size) { + if (dpa_offset + CXL_CACHE_LINE_SIZE > vmr_size + pmr_size + dc_size) { return false; } - if (vmr) { - if (dpa_offset < memory_region_size(vmr)) { - as = &ct3d->hostvmem_as; - } else { - as = &ct3d->hostpmem_as; - dpa_offset -= memory_region_size(vmr); - } - } else { + if (dpa_offset < vmr_size) { + as = &ct3d->hostvmem_as; + } else if (dpa_offset < vmr_size + pmr_size) { as = &ct3d->hostpmem_as; + dpa_offset -= vmr_size; + } else { + as = &ct3d->dc.host_dc_as; + dpa_offset -= (vmr_size + pmr_size); } address_space_write(as, dpa_offset, MEMTXATTRS_UNSPECIFIED, &data, From patchwork Wed Jul 3 22:46:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722980 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4B175C2BD09 for ; Wed, 3 Jul 2024 22:49:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8jx-00061t-38; Wed, 03 Jul 2024 18:46:17 -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 1sP8jv-0005uO-Es for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:15 -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 1sP8jt-0001Rr-D0 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046772; 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=Y6BvONQ3xHQ5Uc0x7v2hZbGWG9V5fJeg5muDy0KhuLY=; b=U8cMPO0In1soYTxXrKVcESX16WGEKva9pnUdDRz4iHCiSEVkBrmcX+jyv/+quAkP77QtRD tE5Hp3O9zkyIrdoh14rPxaUXrWPQZkPVReKa4bpNp9kLwF1TbkBZOHzjlkKrolc6iG9rBG NtQluUqOz0HzgdB7bGdbh34pcKN/D2Q= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-497-hmkScTQ6OWufSwYM7XsdMg-1; Wed, 03 Jul 2024 18:46:11 -0400 X-MC-Unique: hmkScTQ6OWufSwYM7XsdMg-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a75101512aeso1714066b.0 for ; Wed, 03 Jul 2024 15:46:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046770; x=1720651570; 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=Y6BvONQ3xHQ5Uc0x7v2hZbGWG9V5fJeg5muDy0KhuLY=; b=D4Ag+QZtdNKTr36H4F81Ma0sGqdsrB4mEUfTjjmama+4BKgu+cckWPKvPTjY25znBK TsVNs8QNXV/RIxU+SxtRrrKoEOFCOafE5TF2yFdRB1EOhn8d4X1oIN0WBzEMmhSfOPn2 qDsy0DANsES4pcFQB5S7sMJk8ziT59w+hkKnDOWLLgJs+T4A6rrQ+FCU7xzNe6F79NS4 QG5tyWV4TAYeQVLgdLVannozwarNvH6hvz3ZNYDehvg21yRSbWUc+RUt1viR5onpDcvT Bzpc1dmoeJ65IGTIBoQp1CSnlhqiJ9i/KIzPgSW18sEdrcIkHZjj8irkEKt9bykVWCIV aYuw== X-Gm-Message-State: AOJu0YyA1aRZjCq2P2cKGH9MdyXRYBdB55U5hyFwUEociGLUlYqQ6+KQ ZNPMmWudwvgwkWFkSZfk1ep9+xiAk0r6uvmUxZmIP6bYLivG/l183xpxbRvR//SdhmVLGh4/jVN XgqZjmhzRuGXoqZ2MEH3rtOknPC9w204PPSt51fKe/COMuwNTlky9Sg9ZErBJF8IZQa6OXRdTzd ROUNhyxRnbwt3QXut8ZseoiVqpW3LXeQ== X-Received: by 2002:a17:906:c002:b0:a6f:2206:99ae with SMTP id a640c23a62f3a-a751444de1bmr790658466b.41.1720046770182; Wed, 03 Jul 2024 15:46:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFCxoq557ez1kAnv0YwIseNRuYbX/ltAP8CcgZTbRuXpTNf3ZsOs76A5Uocg1qxD3heLyx9PA== X-Received: by 2002:a17:906:c002:b0:a6f:2206:99ae with SMTP id a640c23a62f3a-a751444de1bmr790656866b.41.1720046769525; Wed, 03 Jul 2024 15:46:09 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72b92985desm463841066b.78.2024.07.03.15.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:46:09 -0700 (PDT) Date: Wed, 3 Jul 2024 18:46:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Jonathan Cameron Subject: [PULL v3 24/85] hw/mem/cxl_type3: Add DC extent list representative and get DC extent list mailbox support Message-ID: <1c9221f19e62e448a9ca71a2d5c8a369102a0c38.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni Add dynamic capacity extent list representative to the definition of CXLType3Dev and implement get DC extent list mailbox command per CXL.spec.3.1:.8.2.9.9.9.2. Tested-by: Svetly Todorov Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-10-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 22 +++++++++++ hw/cxl/cxl-mailbox-utils.c | 73 ++++++++++++++++++++++++++++++++++++- hw/mem/cxl_type3.c | 1 + 3 files changed, 95 insertions(+), 1 deletion(-) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index c2c3df0d2a..6aec6ac983 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -424,6 +424,25 @@ typedef QLIST_HEAD(, CXLPoison) CXLPoisonList; #define DCD_MAX_NUM_REGION 8 +typedef struct CXLDCExtentRaw { + uint64_t start_dpa; + uint64_t len; + uint8_t tag[0x10]; + uint16_t shared_seq; + uint8_t rsvd[0x6]; +} QEMU_PACKED CXLDCExtentRaw; + +typedef struct CXLDCExtent { + uint64_t start_dpa; + uint64_t len; + uint8_t tag[0x10]; + uint16_t shared_seq; + uint8_t rsvd[0x6]; + + QTAILQ_ENTRY(CXLDCExtent) node; +} CXLDCExtent; +typedef QTAILQ_HEAD(, CXLDCExtent) CXLDCExtentList; + typedef struct CXLDCRegion { uint64_t base; /* aligned to 256*MiB */ uint64_t decode_len; /* aligned to 256*MiB */ @@ -474,6 +493,9 @@ struct CXLType3Dev { * memory region size. */ uint64_t total_capacity; /* 256M aligned */ + CXLDCExtentList extents; + uint32_t total_extent_count; + uint32_t ext_list_gen_seq; uint8_t num_regions; /* 0-8 regions */ CXLDCRegion regions[DCD_MAX_NUM_REGION]; diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 6ad227f112..7872d2f3e6 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -84,6 +84,7 @@ enum { #define CLEAR_POISON 0x2 DCD_CONFIG = 0x48, #define GET_DC_CONFIG 0x0 + #define GET_DYN_CAP_EXT_LIST 0x1 PHYSICAL_SWITCH = 0x51, #define IDENTIFY_SWITCH_DEVICE 0x0 #define GET_PHYSICAL_PORT_STATE 0x1 @@ -1322,7 +1323,8 @@ static CXLRetCode cmd_dcd_get_dyn_cap_config(const struct cxl_cmd *cmd, * to use. */ stl_le_p(&extra_out->num_extents_supported, CXL_NUM_EXTENTS_SUPPORTED); - stl_le_p(&extra_out->num_extents_available, CXL_NUM_EXTENTS_SUPPORTED); + stl_le_p(&extra_out->num_extents_available, CXL_NUM_EXTENTS_SUPPORTED - + ct3d->dc.total_extent_count); stl_le_p(&extra_out->num_tags_supported, CXL_NUM_TAGS_SUPPORTED); stl_le_p(&extra_out->num_tags_available, CXL_NUM_TAGS_SUPPORTED); @@ -1330,6 +1332,72 @@ static CXLRetCode cmd_dcd_get_dyn_cap_config(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } +/* + * CXL r3.1 section 8.2.9.9.9.2: + * Get Dynamic Capacity Extent List (Opcode 4801h) + */ +static CXLRetCode cmd_dcd_get_dyn_cap_ext_list(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + struct { + uint32_t extent_cnt; + uint32_t start_extent_id; + } QEMU_PACKED *in = (void *)payload_in; + struct { + uint32_t count; + uint32_t total_extents; + uint32_t generation_num; + uint8_t rsvd[4]; + CXLDCExtentRaw records[]; + } QEMU_PACKED *out = (void *)payload_out; + uint32_t start_extent_id = in->start_extent_id; + CXLDCExtentList *extent_list = &ct3d->dc.extents; + uint16_t record_count = 0, i = 0, record_done = 0; + uint16_t out_pl_len, size; + CXLDCExtent *ent; + + if (start_extent_id > ct3d->dc.total_extent_count) { + return CXL_MBOX_INVALID_INPUT; + } + + record_count = MIN(in->extent_cnt, + ct3d->dc.total_extent_count - start_extent_id); + size = CXL_MAILBOX_MAX_PAYLOAD_SIZE - sizeof(*out); + record_count = MIN(record_count, size / sizeof(out->records[0])); + out_pl_len = sizeof(*out) + record_count * sizeof(out->records[0]); + + stl_le_p(&out->count, record_count); + stl_le_p(&out->total_extents, ct3d->dc.total_extent_count); + stl_le_p(&out->generation_num, ct3d->dc.ext_list_gen_seq); + + if (record_count > 0) { + CXLDCExtentRaw *out_rec = &out->records[record_done]; + + QTAILQ_FOREACH(ent, extent_list, node) { + if (i++ < start_extent_id) { + continue; + } + stq_le_p(&out_rec->start_dpa, ent->start_dpa); + stq_le_p(&out_rec->len, ent->len); + memcpy(&out_rec->tag, ent->tag, 0x10); + stw_le_p(&out_rec->shared_seq, ent->shared_seq); + + record_done++; + if (record_done == record_count) { + break; + } + } + } + + *len_out = out_pl_len; + return CXL_MBOX_SUCCESS; +} + #define IMMEDIATE_CONFIG_CHANGE (1 << 1) #define IMMEDIATE_DATA_CHANGE (1 << 2) #define IMMEDIATE_POLICY_CHANGE (1 << 3) @@ -1377,6 +1445,9 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = { static const struct cxl_cmd cxl_cmd_set_dcd[256][256] = { [DCD_CONFIG][GET_DC_CONFIG] = { "DCD_GET_DC_CONFIG", cmd_dcd_get_dyn_cap_config, 2, 0 }, + [DCD_CONFIG][GET_DYN_CAP_EXT_LIST] = { + "DCD_GET_DYNAMIC_CAPACITY_EXTENT_LIST", cmd_dcd_get_dyn_cap_ext_list, + 8, 0 }, }; static const struct cxl_cmd cxl_cmd_set_sw[256][256] = { diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 658570aa1a..2075846b1b 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -673,6 +673,7 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Error **errp) }; ct3d->dc.total_capacity += region->len; } + QTAILQ_INIT(&ct3d->dc.extents); return true; } From patchwork Wed Jul 3 22:46:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D09C2C2BD09 for ; Wed, 3 Jul 2024 22:50:53 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8kD-0007PN-3w; Wed, 03 Jul 2024 18:46: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 1sP8kA-00074G-Sg for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46: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 1sP8jz-0001SN-K0 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046779; 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=OLpu8QtF+gouN+ualw24jfsLt/1sw7VC0fnWp2szNZc=; b=J0Y1nKrJDY0c3wMOkSQQfAwXI1DxNJJYRWtrXOSlReyKxVC4CFqXr9sq8znMhqGZ1Qe51d 2wtggxmokM7Adpiqd813gnWcbi6eZoJ9drr2KUPniblbqXJClhyGP5sL633kd+y2wwwk/H lhIq8W3kJXeQNyYsuS2uYzOULFT4fSI= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-27-JSn1AkSZMaC6dveuFJRQtw-1; Wed, 03 Jul 2024 18:46:17 -0400 X-MC-Unique: JSn1AkSZMaC6dveuFJRQtw-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a706f279c56so1158266b.3 for ; Wed, 03 Jul 2024 15:46:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046775; x=1720651575; 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=OLpu8QtF+gouN+ualw24jfsLt/1sw7VC0fnWp2szNZc=; b=jPCAvqu7bCSINVYIqIkhMhrYx2EQxZoYabph8/o2ZhczKWQhmmX1m0kEgREuIDhM1R CXL0dW3Y0AkRrp1E0kjZNr3iGIZVUevao4YT50p0g3sIPerBBVEOYh5AROvu22bs5tNL NcUzzK+eA9A4LqQpdOsG3tdl7J/TZY/syZBj7Gl8e21KYuqlgLDVVTRy9pj1ipH0DK3o grIDvzOimE5LWrH7xemfx0wrbXyxurY/UjyzIoeo1ugOTfWjT3cWqOez2DDVgi/Bkdri ybycb2KKAvjI1MqMvapAfQ6bGEjAzzVjPwWsylpOV6Ap4z4rLAJg3or9pkll/ZXF63+/ QeXw== X-Gm-Message-State: AOJu0YyNvPl+IydsV4dtvsjGFeZQqoDchEECIDspLsY7PdKN+Bl+N4dG gSd6o2HR8ubAMwYPAW9hwcByM0giHSdmuz6XyNdeXJbSlxdNzHXHkHg9n8mDPuYfJrNzSiY/N7O AxQxvWdSc+03YK4/2v9S7wyyZ8q8z0c2Ph3NMFF1dHvwhBlpSJUpfV4EN7TO9nk93pUtSG+f5UB p2mQL5cT5yC/jt9D3aLMIHob6KMpL+ng== X-Received: by 2002:a17:906:730d:b0:a75:110d:fa51 with SMTP id a640c23a62f3a-a75144a2774mr1019168266b.58.1720046775446; Wed, 03 Jul 2024 15:46:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFi6RB4me/r3N/dUwCvN6N5l9gmTii1hE3Ni1rM/D8U8+oUmrC/wkiIVaSrZdPpDpul6ZgvhA== X-Received: by 2002:a17:906:730d:b0:a75:110d:fa51 with SMTP id a640c23a62f3a-a75144a2774mr1019165466b.58.1720046773799; Wed, 03 Jul 2024 15:46:13 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab0b84d5sm544071066b.223.2024.07.03.15.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:46:13 -0700 (PDT) Date: Wed, 3 Jul 2024 18:46:09 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron Subject: [PULL v3 25/85] hw/cxl/cxl-mailbox-utils: Add mailbox commands to support add/release dynamic capacity response Message-ID: <16fd1b1216a2895a7995345ad6630151954c43a3.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni Per CXL spec 3.1, two mailbox commands are implemented: Add Dynamic Capacity Response (Opcode 4802h) 8.2.9.9.9.3, and Release Dynamic Capacity (Opcode 4803h) 8.2.9.9.9.4. For the process of the above two commands, we use two-pass approach. Pass 1: Check whether the input payload is valid or not; if not, skip Pass 2 and return mailbox process error. Pass 2: Do the real work--add or release extents, respectively. Tested-by: Svetly Todorov Reviewed-by: Gregory Price Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-11-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 4 + hw/cxl/cxl-mailbox-utils.c | 394 ++++++++++++++++++++++++++++++++++++ hw/mem/cxl_type3.c | 11 + 3 files changed, 409 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 6aec6ac983..df3511e91b 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -551,4 +551,8 @@ void cxl_event_irq_assert(CXLType3Dev *ct3d); void cxl_set_poison_list_overflowed(CXLType3Dev *ct3d); +CXLDCRegion *cxl_find_dc_region(CXLType3Dev *ct3d, uint64_t dpa, uint64_t len); + +void cxl_remove_extent_from_extent_list(CXLDCExtentList *list, + CXLDCExtent *extent); #endif diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 7872d2f3e6..e322407fb3 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -19,6 +19,7 @@ #include "qemu/units.h" #include "qemu/uuid.h" #include "sysemu/hostmem.h" +#include "qemu/range.h" #define CXL_CAPACITY_MULTIPLIER (256 * MiB) #define CXL_DC_EVENT_LOG_SIZE 8 @@ -85,6 +86,8 @@ enum { DCD_CONFIG = 0x48, #define GET_DC_CONFIG 0x0 #define GET_DYN_CAP_EXT_LIST 0x1 + #define ADD_DYN_CAP_RSP 0x2 + #define RELEASE_DYN_CAP 0x3 PHYSICAL_SWITCH = 0x51, #define IDENTIFY_SWITCH_DEVICE 0x0 #define GET_PHYSICAL_PORT_STATE 0x1 @@ -1398,6 +1401,391 @@ static CXLRetCode cmd_dcd_get_dyn_cap_ext_list(const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } +/* + * Check whether any bit between addr[nr, nr+size) is set, + * return true if any bit is set, otherwise return false + */ +static bool test_any_bits_set(const unsigned long *addr, unsigned long nr, + unsigned long size) +{ + unsigned long res = find_next_bit(addr, size + nr, nr); + + return res < nr + size; +} + +CXLDCRegion *cxl_find_dc_region(CXLType3Dev *ct3d, uint64_t dpa, uint64_t len) +{ + int i; + CXLDCRegion *region = &ct3d->dc.regions[0]; + + if (dpa < region->base || + dpa >= region->base + ct3d->dc.total_capacity) { + return NULL; + } + + /* + * CXL r3.1 section 9.13.3: Dynamic Capacity Device (DCD) + * + * Regions are used in increasing-DPA order, with Region 0 being used for + * the lowest DPA of Dynamic Capacity and Region 7 for the highest DPA. + * So check from the last region to find where the dpa belongs. Extents that + * cross multiple regions are not allowed. + */ + for (i = ct3d->dc.num_regions - 1; i >= 0; i--) { + region = &ct3d->dc.regions[i]; + if (dpa >= region->base) { + if (dpa + len > region->base + region->len) { + return NULL; + } + return region; + } + } + + return NULL; +} + +static void cxl_insert_extent_to_extent_list(CXLDCExtentList *list, + uint64_t dpa, + uint64_t len, + uint8_t *tag, + uint16_t shared_seq) +{ + CXLDCExtent *extent; + + extent = g_new0(CXLDCExtent, 1); + extent->start_dpa = dpa; + extent->len = len; + if (tag) { + memcpy(extent->tag, tag, 0x10); + } + extent->shared_seq = shared_seq; + + QTAILQ_INSERT_TAIL(list, extent, node); +} + +void cxl_remove_extent_from_extent_list(CXLDCExtentList *list, + CXLDCExtent *extent) +{ + QTAILQ_REMOVE(list, extent, node); + g_free(extent); +} + +/* + * CXL r3.1 Table 8-168: Add Dynamic Capacity Response Input Payload + * CXL r3.1 Table 8-170: Release Dynamic Capacity Input Payload + */ +typedef struct CXLUpdateDCExtentListInPl { + uint32_t num_entries_updated; + uint8_t flags; + uint8_t rsvd[3]; + /* CXL r3.1 Table 8-169: Updated Extent */ + struct { + uint64_t start_dpa; + uint64_t len; + uint8_t rsvd[8]; + } QEMU_PACKED updated_entries[]; +} QEMU_PACKED CXLUpdateDCExtentListInPl; + +/* + * For the extents in the extent list to operate, check whether they are valid + * 1. The extent should be in the range of a valid DC region; + * 2. The extent should not cross multiple regions; + * 3. The start DPA and the length of the extent should align with the block + * size of the region; + * 4. The address range of multiple extents in the list should not overlap. + */ +static CXLRetCode cxl_detect_malformed_extent_list(CXLType3Dev *ct3d, + const CXLUpdateDCExtentListInPl *in) +{ + uint64_t min_block_size = UINT64_MAX; + CXLDCRegion *region; + CXLDCRegion *lastregion = &ct3d->dc.regions[ct3d->dc.num_regions - 1]; + g_autofree unsigned long *blk_bitmap = NULL; + uint64_t dpa, len; + uint32_t i; + + for (i = 0; i < ct3d->dc.num_regions; i++) { + region = &ct3d->dc.regions[i]; + min_block_size = MIN(min_block_size, region->block_size); + } + + blk_bitmap = bitmap_new((lastregion->base + lastregion->len - + ct3d->dc.regions[0].base) / min_block_size); + + for (i = 0; i < in->num_entries_updated; i++) { + dpa = in->updated_entries[i].start_dpa; + len = in->updated_entries[i].len; + + region = cxl_find_dc_region(ct3d, dpa, len); + if (!region) { + return CXL_MBOX_INVALID_PA; + } + + dpa -= ct3d->dc.regions[0].base; + if (dpa % region->block_size || len % region->block_size) { + return CXL_MBOX_INVALID_EXTENT_LIST; + } + /* the dpa range already covered by some other extents in the list */ + if (test_any_bits_set(blk_bitmap, dpa / min_block_size, + len / min_block_size)) { + return CXL_MBOX_INVALID_EXTENT_LIST; + } + bitmap_set(blk_bitmap, dpa / min_block_size, len / min_block_size); + } + + return CXL_MBOX_SUCCESS; +} + +static CXLRetCode cxl_dcd_add_dyn_cap_rsp_dry_run(CXLType3Dev *ct3d, + const CXLUpdateDCExtentListInPl *in) +{ + uint32_t i; + CXLDCExtent *ent; + uint64_t dpa, len; + Range range1, range2; + + for (i = 0; i < in->num_entries_updated; i++) { + dpa = in->updated_entries[i].start_dpa; + len = in->updated_entries[i].len; + + range_init_nofail(&range1, dpa, len); + + /* + * TODO: once the pending extent list is added, check against + * the list will be added here. + */ + + /* to-be-added range should not overlap with range already accepted */ + QTAILQ_FOREACH(ent, &ct3d->dc.extents, node) { + range_init_nofail(&range2, ent->start_dpa, ent->len); + if (range_overlaps_range(&range1, &range2)) { + return CXL_MBOX_INVALID_PA; + } + } + } + return CXL_MBOX_SUCCESS; +} + +/* + * CXL r3.1 section 8.2.9.9.9.3: Add Dynamic Capacity Response (Opcode 4802h) + * An extent is added to the extent list and becomes usable only after the + * response is processed successfully. + */ +static CXLRetCode cmd_dcd_add_dyn_cap_rsp(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + CXLUpdateDCExtentListInPl *in = (void *)payload_in; + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + CXLDCExtentList *extent_list = &ct3d->dc.extents; + uint32_t i; + uint64_t dpa, len; + CXLRetCode ret; + + if (in->num_entries_updated == 0) { + /* + * TODO: once the pending list is introduced, extents in the beginning + * will get wiped out. + */ + return CXL_MBOX_SUCCESS; + } + + /* Adding extents causes exceeding device's extent tracking ability. */ + if (in->num_entries_updated + ct3d->dc.total_extent_count > + CXL_NUM_EXTENTS_SUPPORTED) { + return CXL_MBOX_RESOURCES_EXHAUSTED; + } + + ret = cxl_detect_malformed_extent_list(ct3d, in); + if (ret != CXL_MBOX_SUCCESS) { + return ret; + } + + ret = cxl_dcd_add_dyn_cap_rsp_dry_run(ct3d, in); + if (ret != CXL_MBOX_SUCCESS) { + return ret; + } + + for (i = 0; i < in->num_entries_updated; i++) { + dpa = in->updated_entries[i].start_dpa; + len = in->updated_entries[i].len; + + cxl_insert_extent_to_extent_list(extent_list, dpa, len, NULL, 0); + ct3d->dc.total_extent_count += 1; + /* + * TODO: we will add a pending extent list based on event log record + * and process the list accordingly here. + */ + } + + return CXL_MBOX_SUCCESS; +} + +/* + * Copy extent list from src to dst + * Return value: number of extents copied + */ +static uint32_t copy_extent_list(CXLDCExtentList *dst, + const CXLDCExtentList *src) +{ + uint32_t cnt = 0; + CXLDCExtent *ent; + + if (!dst || !src) { + return 0; + } + + QTAILQ_FOREACH(ent, src, node) { + cxl_insert_extent_to_extent_list(dst, ent->start_dpa, ent->len, + ent->tag, ent->shared_seq); + cnt++; + } + return cnt; +} + +static CXLRetCode cxl_dc_extent_release_dry_run(CXLType3Dev *ct3d, + const CXLUpdateDCExtentListInPl *in, CXLDCExtentList *updated_list, + uint32_t *updated_list_size) +{ + CXLDCExtent *ent, *ent_next; + uint64_t dpa, len; + uint32_t i; + int cnt_delta = 0; + CXLRetCode ret = CXL_MBOX_SUCCESS; + + QTAILQ_INIT(updated_list); + copy_extent_list(updated_list, &ct3d->dc.extents); + + for (i = 0; i < in->num_entries_updated; i++) { + Range range; + + dpa = in->updated_entries[i].start_dpa; + len = in->updated_entries[i].len; + + while (len > 0) { + QTAILQ_FOREACH(ent, updated_list, node) { + range_init_nofail(&range, ent->start_dpa, ent->len); + + if (range_contains(&range, dpa)) { + uint64_t len1, len2 = 0, len_done = 0; + uint64_t ent_start_dpa = ent->start_dpa; + uint64_t ent_len = ent->len; + + len1 = dpa - ent->start_dpa; + /* Found the extent or the subset of an existing extent */ + if (range_contains(&range, dpa + len - 1)) { + len2 = ent_start_dpa + ent_len - dpa - len; + } else { + /* + * TODO: we reject the attempt to remove an extent + * that overlaps with multiple extents in the device + * for now. We will allow it once superset release + * support is added. + */ + ret = CXL_MBOX_INVALID_PA; + goto free_and_exit; + } + len_done = ent_len - len1 - len2; + + cxl_remove_extent_from_extent_list(updated_list, ent); + cnt_delta--; + + if (len1) { + cxl_insert_extent_to_extent_list(updated_list, + ent_start_dpa, + len1, NULL, 0); + cnt_delta++; + } + if (len2) { + cxl_insert_extent_to_extent_list(updated_list, + dpa + len, + len2, NULL, 0); + cnt_delta++; + } + + if (cnt_delta + ct3d->dc.total_extent_count > + CXL_NUM_EXTENTS_SUPPORTED) { + ret = CXL_MBOX_RESOURCES_EXHAUSTED; + goto free_and_exit; + } + + len -= len_done; + /* len == 0 here until superset release is added */ + break; + } + } + if (len) { + ret = CXL_MBOX_INVALID_PA; + goto free_and_exit; + } + } + } +free_and_exit: + if (ret != CXL_MBOX_SUCCESS) { + QTAILQ_FOREACH_SAFE(ent, updated_list, node, ent_next) { + cxl_remove_extent_from_extent_list(updated_list, ent); + } + *updated_list_size = 0; + } else { + *updated_list_size = ct3d->dc.total_extent_count + cnt_delta; + } + + return ret; +} + +/* + * CXL r3.1 section 8.2.9.9.9.4: Release Dynamic Capacity (Opcode 4803h) + */ +static CXLRetCode cmd_dcd_release_dyn_cap(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + CXLUpdateDCExtentListInPl *in = (void *)payload_in; + CXLType3Dev *ct3d = CXL_TYPE3(cci->d); + CXLDCExtentList updated_list; + CXLDCExtent *ent, *ent_next; + uint32_t updated_list_size; + CXLRetCode ret; + + if (in->num_entries_updated == 0) { + return CXL_MBOX_INVALID_INPUT; + } + + ret = cxl_detect_malformed_extent_list(ct3d, in); + if (ret != CXL_MBOX_SUCCESS) { + return ret; + } + + ret = cxl_dc_extent_release_dry_run(ct3d, in, &updated_list, + &updated_list_size); + if (ret != CXL_MBOX_SUCCESS) { + return ret; + } + + /* + * If the dry run release passes, the returned updated_list will + * be the updated extent list and we just need to clear the extents + * in the accepted list and copy extents in the updated_list to accepted + * list and update the extent count; + */ + QTAILQ_FOREACH_SAFE(ent, &ct3d->dc.extents, node, ent_next) { + cxl_remove_extent_from_extent_list(&ct3d->dc.extents, ent); + } + copy_extent_list(&ct3d->dc.extents, &updated_list); + QTAILQ_FOREACH_SAFE(ent, &updated_list, node, ent_next) { + cxl_remove_extent_from_extent_list(&updated_list, ent); + } + ct3d->dc.total_extent_count = updated_list_size; + + return CXL_MBOX_SUCCESS; +} + #define IMMEDIATE_CONFIG_CHANGE (1 << 1) #define IMMEDIATE_DATA_CHANGE (1 << 2) #define IMMEDIATE_POLICY_CHANGE (1 << 3) @@ -1448,6 +1836,12 @@ static const struct cxl_cmd cxl_cmd_set_dcd[256][256] = { [DCD_CONFIG][GET_DYN_CAP_EXT_LIST] = { "DCD_GET_DYNAMIC_CAPACITY_EXTENT_LIST", cmd_dcd_get_dyn_cap_ext_list, 8, 0 }, + [DCD_CONFIG][ADD_DYN_CAP_RSP] = { + "DCD_ADD_DYNAMIC_CAPACITY_RESPONSE", cmd_dcd_add_dyn_cap_rsp, + ~0, IMMEDIATE_DATA_CHANGE }, + [DCD_CONFIG][RELEASE_DYN_CAP] = { + "DCD_RELEASE_DYNAMIC_CAPACITY", cmd_dcd_release_dyn_cap, + ~0, IMMEDIATE_DATA_CHANGE }, }; static const struct cxl_cmd cxl_cmd_set_sw[256][256] = { diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 2075846b1b..db5191b3b7 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -678,6 +678,15 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Error **errp) return true; } +static void cxl_destroy_dc_regions(CXLType3Dev *ct3d) +{ + CXLDCExtent *ent, *ent_next; + + QTAILQ_FOREACH_SAFE(ent, &ct3d->dc.extents, node, ent_next) { + cxl_remove_extent_from_extent_list(&ct3d->dc.extents, ent); + } +} + static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) { DeviceState *ds = DEVICE(ct3d); @@ -874,6 +883,7 @@ err_free_special_ops: g_free(regs->special_ops); err_address_space_free: if (ct3d->dc.host_dc) { + cxl_destroy_dc_regions(ct3d); address_space_destroy(&ct3d->dc.host_dc_as); } if (ct3d->hostpmem) { @@ -895,6 +905,7 @@ static void ct3_exit(PCIDevice *pci_dev) cxl_doe_cdat_release(cxl_cstate); g_free(regs->special_ops); if (ct3d->dc.host_dc) { + cxl_destroy_dc_regions(ct3d); address_space_destroy(&ct3d->dc.host_dc_as); } if (ct3d->hostpmem) { From patchwork Wed Jul 3 22:46:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722968 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9693AC2BD09 for ; Wed, 3 Jul 2024 22:47:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8kK-0008CF-Ju; Wed, 03 Jul 2024 18:46: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 1sP8kE-0007eT-8p for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46: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 1sP8k8-0001Sq-6x for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046787; 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=luTRPHAeeb1OyXMCpOc0nu4ARMny/qSptOQ/dYaP6qI=; b=TF7xiXfDOg9eDjl+8c5ay8ZwMA78r7jtg8gvfdaOD3NHGthkHdvLzopO+uWXqn3BT28/0t wLB5VRHBa7sBNGPSeqa9p7mHRRHYcJbGcus02HBmaLtxOR02PfDrbl1/nMJY1ar6o8/4un 66uSqW9C1QNViVZcNBTN9Q93KnXsv7I= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-92-fY9txIauOeehXHGWGeZE9A-1; Wed, 03 Jul 2024 18:46:23 -0400 X-MC-Unique: fY9txIauOeehXHGWGeZE9A-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-584ef6c00c0so1684542a12.1 for ; Wed, 03 Jul 2024 15:46:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046782; x=1720651582; 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=luTRPHAeeb1OyXMCpOc0nu4ARMny/qSptOQ/dYaP6qI=; b=bQV/Ls/paxAam+IfjI7aPg9ax2zExrE95ArV0x83FTNv25Mz7gPd/huLmhh5wipT25 IlnZopaOQEfD5hwo5bszG9IiIcrKzp0U1dElDg9hzzbQX1cNgZfTlh34VDjFmX/PAHL5 x+4BsDO4lZbAQLpMP0aza9JajIpxDwmhdugX377ce+rLjoTuYqkC2/SvuKrYgQoXbzdJ WuT+AL41rvdlCiyqW8vGE7PRfeSN1f0627Fhib87G25Kd58gaRLKa0wOZXl0sr9JJWjg 6mDcABMC/aK2MVl7xMvE4fkT3sVPUTLWMf7pyRMB0NMcNUMt5WTkV47wxJHhrs8pxqew wCIQ== X-Gm-Message-State: AOJu0YwPBIufYFklyfHf5mrFDFh8nK/0AF5/7+IKxO2Zx80Z/131HARM ixXPQPr+Rk5/mSdofVwnSkW0/+KcxBBfuUca5rDfBnVUJH0LE2a6MfjatIPTscrZwYN2+qZfJTB YiqMj5doPQwdQQ/5ajKZbxBswibPIFAMctTFm3LqtOrsCr12n9Jeum9viqagQcPENqW+e3JgFYN Rj1XgjKdb6q9jsLtqWpP46mP8G2FIlkg== X-Received: by 2002:a17:906:f253:b0:a77:a1f1:cfa0 with SMTP id a640c23a62f3a-a77a24bf96bmr190754866b.36.1720046781908; Wed, 03 Jul 2024 15:46:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHg2wT/M13CEH2K+OZvTHPj3LYd3kxJxOq9Cohn/BEelMSHnHDXIUN7MQ5zDXw4mbfbB/WWog== X-Received: by 2002:a17:906:f253:b0:a77:a1f1:cfa0 with SMTP id a640c23a62f3a-a77a24bf96bmr190751966b.36.1720046780436; Wed, 03 Jul 2024 15:46:20 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab08fb70sm543323566b.180.2024.07.03.15.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:46:19 -0700 (PDT) Date: Wed, 3 Jul 2024 18:46:15 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron , Eric Blake , Markus Armbruster Subject: [PULL v3 26/85] hw/cxl/events: Add qmp interfaces to add/release dynamic capacity extents 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni To simulate FM functionalities for initiating Dynamic Capacity Add (Opcode 5604h) and Dynamic Capacity Release (Opcode 5605h) as in CXL spec r3.1 7.6.7.6.5 and 7.6.7.6.6, we implemented two QMP interfaces to issue add/release dynamic capacity extents requests. With the change, we allow to release an extent only when its DPA range is contained by a single accepted extent in the device. That is to say, extent superset release is not supported yet. 1. Add dynamic capacity extents: For example, the command to add two continuous extents (each 128MiB long) to region 0 (starting at DPA offset 0) looks like below: { "execute": "qmp_capabilities" } { "execute": "cxl-add-dynamic-capacity", "arguments": { "path": "/machine/peripheral/cxl-dcd0", "host-id": 0, "selection-policy": "prescriptive", "region": 0, "extents": [ { "offset": 0, "len": 134217728 }, { "offset": 134217728, "len": 134217728 } ] } } 2. Release dynamic capacity extents: For example, the command to release an extent of size 128MiB from region 0 (DPA offset 128MiB) looks like below: { "execute": "cxl-release-dynamic-capacity", "arguments": { "path": "/machine/peripheral/cxl-dcd0", "host-id": 0, "removal-policy":"prescriptive", "region": 0, "extents": [ { "offset": 134217728, "len": 134217728 } ] } } Tested-by: Svetly Todorov Reviewed-by: Gregory Price Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-12-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/cxl.json | 143 +++++++++++++++++ include/hw/cxl/cxl_device.h | 22 +++ include/hw/cxl/cxl_events.h | 18 +++ hw/cxl/cxl-mailbox-utils.c | 62 ++++++-- hw/mem/cxl_type3.c | 306 +++++++++++++++++++++++++++++++++++- hw/mem/cxl_type3_stubs.c | 25 +++ 6 files changed, 563 insertions(+), 13 deletions(-) diff --git a/qapi/cxl.json b/qapi/cxl.json index 4281726dec..57d9f82014 100644 --- a/qapi/cxl.json +++ b/qapi/cxl.json @@ -361,3 +361,146 @@ ## {'command': 'cxl-inject-correctable-error', 'data': {'path': 'str', 'type': 'CxlCorErrorType'}} + +## +# @CXLDynamicCapacityExtent: +# +# A single dynamic capacity extent +# +# @offset: The offset (in bytes) to the start of the region +# where the extent belongs to. +# +# @len: The length of the extent in bytes. +# +# Since: 9.1 +## +{ 'struct': 'CXLDynamicCapacityExtent', + 'data': { + 'offset':'uint64', + 'len': 'uint64' + } +} + +## +# @CXLExtSelPolicy: +# +# The policy to use for selecting which extents comprise the added +# capacity, as defined in cxl spec r3.1 Table 7-70. +# +# @free: 0h = Free +# +# @contiguous: 1h = Continuous +# +# @prescriptive: 2h = Prescriptive +# +# @enable-shared-access: 3h = Enable Shared Access +# +# Since: 9.1 +## +{ 'enum': 'CXLExtSelPolicy', + 'data': ['free', + 'contiguous', + 'prescriptive', + 'enable-shared-access'] +} + +## +# @cxl-add-dynamic-capacity: +# +# Command to initiate to add dynamic capacity extents to a host. It +# simulates operations defined in cxl spec r3.1 7.6.7.6.5. +# +# @path: CXL DCD canonical QOM path. +# +# @host-id: The "Host ID" field as defined in cxl spec r3.1 +# Table 7-70. +# +# @selection-policy: The "Selection Policy" bits as defined in +# cxl spec r3.1 Table 7-70. It specifies the policy to use for +# selecting which extents comprise the added capacity. +# +# @region: The "Region Number" field as defined in cxl spec r3.1 +# Table 7-70. The dynamic capacity region where the capacity +# is being added. Valid range is from 0-7. +# +# @tag: The "Tag" field as defined in cxl spec r3.1 Table 7-70. +# +# @extents: The "Extent List" field as defined in cxl spec r3.1 +# Table 7-70. +# +# Since : 9.1 +## +{ 'command': 'cxl-add-dynamic-capacity', + 'data': { 'path': 'str', + 'host-id': 'uint16', + 'selection-policy': 'CXLExtSelPolicy', + 'region': 'uint8', + '*tag': 'str', + 'extents': [ 'CXLDynamicCapacityExtent' ] + } +} + +## +# @CXLExtRemovalPolicy: +# +# The policy to use for selecting which extents comprise the released +# capacity, defined in the "Flags" field in cxl spec r3.1 Table 7-71. +# +# @tag-based: value = 0h. Extents are selected by the device based +# on tag, with no requirement for contiguous extents. +# +# @prescriptive: value = 1h. Extent list of capacity to release is +# included in the request payload. +# +# Since: 9.1 +## +{ 'enum': 'CXLExtRemovalPolicy', + 'data': ['tag-based', + 'prescriptive'] +} + +## +# @cxl-release-dynamic-capacity: +# +# Command to initiate to release dynamic capacity extents from a +# host. It simulates operations defined in cxl spec r3.1 7.6.7.6.6. +# +# @path: CXL DCD canonical QOM path. +# +# @host-id: The "Host ID" field as defined in cxl spec r3.1 +# Table 7-71. +# +# @removal-policy: Bit[3:0] of the "Flags" field as defined in cxl +# spec r3.1 Table 7-71. +# +# @forced-removal: Bit[4] of the "Flags" field in cxl spec r3.1 +# Table 7-71. When set, device does not wait for a Release +# Dynamic Capacity command from the host. Host immediately +# loses access to released capacity. +# +# @sanitize-on-release: Bit[5] of the "Flags" field in cxl spec r3.1 +# Table 7-71. When set, device should sanitize all released +# capacity as a result of this request. +# +# @region: The "Region Number" field as defined in cxl spec r3.1 +# Table 7-71. The dynamic capacity region where the capacity +# is being added. Valid range is from 0-7. +# +# @tag: The "Tag" field as defined in cxl spec r3.1 Table 7-71. +# +# @extents: The "Extent List" field as defined in cxl spec r3.1 +# Table 7-71. +# +# Since : 9.1 +## +{ 'command': 'cxl-release-dynamic-capacity', + 'data': { 'path': 'str', + 'host-id': 'uint16', + 'removal-policy': 'CXLExtRemovalPolicy', + '*forced-removal': 'bool', + '*sanitize-on-release': 'bool', + 'region': 'uint8', + '*tag': 'str', + 'extents': [ 'CXLDynamicCapacityExtent' ] + } +} diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index df3511e91b..c69ff6b5de 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -443,6 +443,12 @@ typedef struct CXLDCExtent { } CXLDCExtent; typedef QTAILQ_HEAD(, CXLDCExtent) CXLDCExtentList; +typedef struct CXLDCExtentGroup { + CXLDCExtentList list; + QTAILQ_ENTRY(CXLDCExtentGroup) node; +} CXLDCExtentGroup; +typedef QTAILQ_HEAD(, CXLDCExtentGroup) CXLDCExtentGroupList; + typedef struct CXLDCRegion { uint64_t base; /* aligned to 256*MiB */ uint64_t decode_len; /* aligned to 256*MiB */ @@ -494,6 +500,7 @@ struct CXLType3Dev { */ uint64_t total_capacity; /* 256M aligned */ CXLDCExtentList extents; + CXLDCExtentGroupList extents_pending; uint32_t total_extent_count; uint32_t ext_list_gen_seq; @@ -555,4 +562,19 @@ CXLDCRegion *cxl_find_dc_region(CXLType3Dev *ct3d, uint64_t dpa, uint64_t len); void cxl_remove_extent_from_extent_list(CXLDCExtentList *list, CXLDCExtent *extent); +void cxl_insert_extent_to_extent_list(CXLDCExtentList *list, uint64_t dpa, + uint64_t len, uint8_t *tag, + uint16_t shared_seq); +bool test_any_bits_set(const unsigned long *addr, unsigned long nr, + unsigned long size); +bool cxl_extents_contains_dpa_range(CXLDCExtentList *list, + uint64_t dpa, uint64_t len); +CXLDCExtentGroup *cxl_insert_extent_to_extent_group(CXLDCExtentGroup *group, + uint64_t dpa, + uint64_t len, + uint8_t *tag, + uint16_t shared_seq); +void cxl_extent_group_list_insert_tail(CXLDCExtentGroupList *list, + CXLDCExtentGroup *group); +void cxl_extent_group_list_delete_front(CXLDCExtentGroupList *list); #endif diff --git a/include/hw/cxl/cxl_events.h b/include/hw/cxl/cxl_events.h index 5170b8dbf8..38cadaa0f3 100644 --- a/include/hw/cxl/cxl_events.h +++ b/include/hw/cxl/cxl_events.h @@ -166,4 +166,22 @@ typedef struct CXLEventMemoryModule { uint8_t reserved[0x3d]; } QEMU_PACKED CXLEventMemoryModule; +/* + * CXL r3.1 section Table 8-50: Dynamic Capacity Event Record + * All fields little endian. + */ +typedef struct CXLEventDynamicCapacity { + CXLEventRecordHdr hdr; + uint8_t type; + uint8_t validity_flags; + uint16_t host_id; + uint8_t updated_region_id; + uint8_t flags; + uint8_t reserved2[2]; + uint8_t dynamic_capacity_extent[0x28]; /* defined in cxl_device.h */ + uint8_t reserved[0x18]; + uint32_t extents_avail; + uint32_t tags_avail; +} QEMU_PACKED CXLEventDynamicCapacity; + #endif /* CXL_EVENTS_H */ diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index e322407fb3..64387f34ce 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1405,7 +1405,7 @@ static CXLRetCode cmd_dcd_get_dyn_cap_ext_list(const struct cxl_cmd *cmd, * Check whether any bit between addr[nr, nr+size) is set, * return true if any bit is set, otherwise return false */ -static bool test_any_bits_set(const unsigned long *addr, unsigned long nr, +bool test_any_bits_set(const unsigned long *addr, unsigned long nr, unsigned long size) { unsigned long res = find_next_bit(addr, size + nr, nr); @@ -1444,7 +1444,7 @@ CXLDCRegion *cxl_find_dc_region(CXLType3Dev *ct3d, uint64_t dpa, uint64_t len) return NULL; } -static void cxl_insert_extent_to_extent_list(CXLDCExtentList *list, +void cxl_insert_extent_to_extent_list(CXLDCExtentList *list, uint64_t dpa, uint64_t len, uint8_t *tag, @@ -1470,6 +1470,44 @@ void cxl_remove_extent_from_extent_list(CXLDCExtentList *list, g_free(extent); } +/* + * Add a new extent to the extent "group" if group exists; + * otherwise, create a new group + * Return value: the extent group where the extent is inserted. + */ +CXLDCExtentGroup *cxl_insert_extent_to_extent_group(CXLDCExtentGroup *group, + uint64_t dpa, + uint64_t len, + uint8_t *tag, + uint16_t shared_seq) +{ + if (!group) { + group = g_new0(CXLDCExtentGroup, 1); + QTAILQ_INIT(&group->list); + } + cxl_insert_extent_to_extent_list(&group->list, dpa, len, + tag, shared_seq); + return group; +} + +void cxl_extent_group_list_insert_tail(CXLDCExtentGroupList *list, + CXLDCExtentGroup *group) +{ + QTAILQ_INSERT_TAIL(list, group, node); +} + +void cxl_extent_group_list_delete_front(CXLDCExtentGroupList *list) +{ + CXLDCExtent *ent, *ent_next; + CXLDCExtentGroup *group = QTAILQ_FIRST(list); + + QTAILQ_REMOVE(list, group, node); + QTAILQ_FOREACH_SAFE(ent, &group->list, node, ent_next) { + cxl_remove_extent_from_extent_list(&group->list, ent); + } + g_free(group); +} + /* * CXL r3.1 Table 8-168: Add Dynamic Capacity Response Input Payload * CXL r3.1 Table 8-170: Release Dynamic Capacity Input Payload @@ -1541,6 +1579,7 @@ static CXLRetCode cxl_dcd_add_dyn_cap_rsp_dry_run(CXLType3Dev *ct3d, { uint32_t i; CXLDCExtent *ent; + CXLDCExtentGroup *ext_group; uint64_t dpa, len; Range range1, range2; @@ -1551,9 +1590,13 @@ static CXLRetCode cxl_dcd_add_dyn_cap_rsp_dry_run(CXLType3Dev *ct3d, range_init_nofail(&range1, dpa, len); /* - * TODO: once the pending extent list is added, check against - * the list will be added here. + * The host-accepted DPA range must be contained by the first extent + * group in the pending list */ + ext_group = QTAILQ_FIRST(&ct3d->dc.extents_pending); + if (!cxl_extents_contains_dpa_range(&ext_group->list, dpa, len)) { + return CXL_MBOX_INVALID_PA; + } /* to-be-added range should not overlap with range already accepted */ QTAILQ_FOREACH(ent, &ct3d->dc.extents, node) { @@ -1586,10 +1629,7 @@ static CXLRetCode cmd_dcd_add_dyn_cap_rsp(const struct cxl_cmd *cmd, CXLRetCode ret; if (in->num_entries_updated == 0) { - /* - * TODO: once the pending list is introduced, extents in the beginning - * will get wiped out. - */ + cxl_extent_group_list_delete_front(&ct3d->dc.extents_pending); return CXL_MBOX_SUCCESS; } @@ -1615,11 +1655,9 @@ static CXLRetCode cmd_dcd_add_dyn_cap_rsp(const struct cxl_cmd *cmd, cxl_insert_extent_to_extent_list(extent_list, dpa, len, NULL, 0); ct3d->dc.total_extent_count += 1; - /* - * TODO: we will add a pending extent list based on event log record - * and process the list accordingly here. - */ } + /* Remove the first extent group in the pending list */ + cxl_extent_group_list_delete_front(&ct3d->dc.extents_pending); return CXL_MBOX_SUCCESS; } diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index db5191b3b7..f53bcca6d3 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -674,6 +674,7 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Error **errp) ct3d->dc.total_capacity += region->len; } QTAILQ_INIT(&ct3d->dc.extents); + QTAILQ_INIT(&ct3d->dc.extents_pending); return true; } @@ -681,10 +682,19 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Error **errp) static void cxl_destroy_dc_regions(CXLType3Dev *ct3d) { CXLDCExtent *ent, *ent_next; + CXLDCExtentGroup *group, *group_next; QTAILQ_FOREACH_SAFE(ent, &ct3d->dc.extents, node, ent_next) { cxl_remove_extent_from_extent_list(&ct3d->dc.extents, ent); } + + QTAILQ_FOREACH_SAFE(group, &ct3d->dc.extents_pending, node, group_next) { + QTAILQ_REMOVE(&ct3d->dc.extents_pending, group, node); + QTAILQ_FOREACH_SAFE(ent, &group->list, node, ent_next) { + cxl_remove_extent_from_extent_list(&group->list, ent); + } + g_free(group); + } } static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) @@ -1449,7 +1459,6 @@ static int ct3d_qmp_cxl_event_log_enc(CxlEventLog log) return CXL_EVENT_TYPE_FAIL; case CXL_EVENT_LOG_FATAL: return CXL_EVENT_TYPE_FATAL; -/* DCD not yet supported */ default: return -EINVAL; } @@ -1700,6 +1709,301 @@ void qmp_cxl_inject_memory_module_event(const char *path, CxlEventLog log, } } +/* CXL r3.1 Table 8-50: Dynamic Capacity Event Record */ +static const QemuUUID dynamic_capacity_uuid = { + .data = UUID(0xca95afa7, 0xf183, 0x4018, 0x8c, 0x2f, + 0x95, 0x26, 0x8e, 0x10, 0x1a, 0x2a), +}; + +typedef enum CXLDCEventType { + DC_EVENT_ADD_CAPACITY = 0x0, + DC_EVENT_RELEASE_CAPACITY = 0x1, + DC_EVENT_FORCED_RELEASE_CAPACITY = 0x2, + DC_EVENT_REGION_CONFIG_UPDATED = 0x3, + DC_EVENT_ADD_CAPACITY_RSP = 0x4, + DC_EVENT_CAPACITY_RELEASED = 0x5, +} CXLDCEventType; + +/* + * Check whether the range [dpa, dpa + len - 1] has overlaps with extents in + * the list. + * Return value: return true if has overlaps; otherwise, return false + */ +static bool cxl_extents_overlaps_dpa_range(CXLDCExtentList *list, + uint64_t dpa, uint64_t len) +{ + CXLDCExtent *ent; + Range range1, range2; + + if (!list) { + return false; + } + + range_init_nofail(&range1, dpa, len); + QTAILQ_FOREACH(ent, list, node) { + range_init_nofail(&range2, ent->start_dpa, ent->len); + if (range_overlaps_range(&range1, &range2)) { + return true; + } + } + return false; +} + +/* + * Check whether the range [dpa, dpa + len - 1] is contained by extents in + * the list. + * Will check multiple extents containment once superset release is added. + * Return value: return true if range is contained; otherwise, return false + */ +bool cxl_extents_contains_dpa_range(CXLDCExtentList *list, + uint64_t dpa, uint64_t len) +{ + CXLDCExtent *ent; + Range range1, range2; + + if (!list) { + return false; + } + + range_init_nofail(&range1, dpa, len); + QTAILQ_FOREACH(ent, list, node) { + range_init_nofail(&range2, ent->start_dpa, ent->len); + if (range_contains_range(&range2, &range1)) { + return true; + } + } + return false; +} + +static bool cxl_extent_groups_overlaps_dpa_range(CXLDCExtentGroupList *list, + uint64_t dpa, uint64_t len) +{ + CXLDCExtentGroup *group; + + if (!list) { + return false; + } + + QTAILQ_FOREACH(group, list, node) { + if (cxl_extents_overlaps_dpa_range(&group->list, dpa, len)) { + return true; + } + } + return false; +} + +/* + * The main function to process dynamic capacity event with extent list. + * Currently DC extents add/release requests are processed. + */ +static void qmp_cxl_process_dynamic_capacity_prescriptive(const char *path, + uint16_t hid, CXLDCEventType type, uint8_t rid, + CXLDynamicCapacityExtentList *records, Error **errp) +{ + Object *obj; + CXLEventDynamicCapacity dCap = {}; + CXLEventRecordHdr *hdr = &dCap.hdr; + CXLType3Dev *dcd; + uint8_t flags = 1 << CXL_EVENT_TYPE_INFO; + uint32_t num_extents = 0; + CXLDynamicCapacityExtentList *list; + CXLDCExtentGroup *group = NULL; + g_autofree CXLDCExtentRaw *extents = NULL; + uint8_t enc_log = CXL_EVENT_TYPE_DYNAMIC_CAP; + uint64_t dpa, offset, len, block_size; + g_autofree unsigned long *blk_bitmap = NULL; + int i; + + obj = object_resolve_path_type(path, TYPE_CXL_TYPE3, NULL); + if (!obj) { + error_setg(errp, "Unable to resolve CXL type 3 device"); + return; + } + + dcd = CXL_TYPE3(obj); + if (!dcd->dc.num_regions) { + error_setg(errp, "No dynamic capacity support from the device"); + return; + } + + + if (rid >= dcd->dc.num_regions) { + error_setg(errp, "region id is too large"); + return; + } + block_size = dcd->dc.regions[rid].block_size; + blk_bitmap = bitmap_new(dcd->dc.regions[rid].len / block_size); + + /* Sanity check and count the extents */ + list = records; + while (list) { + offset = list->value->offset; + len = list->value->len; + dpa = offset + dcd->dc.regions[rid].base; + + if (len == 0) { + error_setg(errp, "extent with 0 length is not allowed"); + return; + } + + if (offset % block_size || len % block_size) { + error_setg(errp, "dpa or len is not aligned to region block size"); + return; + } + + if (offset + len > dcd->dc.regions[rid].len) { + error_setg(errp, "extent range is beyond the region end"); + return; + } + + /* No duplicate or overlapped extents are allowed */ + if (test_any_bits_set(blk_bitmap, offset / block_size, + len / block_size)) { + error_setg(errp, "duplicate or overlapped extents are detected"); + return; + } + bitmap_set(blk_bitmap, offset / block_size, len / block_size); + + if (type == DC_EVENT_RELEASE_CAPACITY) { + if (cxl_extent_groups_overlaps_dpa_range(&dcd->dc.extents_pending, + dpa, len)) { + error_setg(errp, + "cannot release extent with pending DPA range"); + return; + } + if (!cxl_extents_contains_dpa_range(&dcd->dc.extents, dpa, len)) { + error_setg(errp, + "cannot release extent with non-existing DPA range"); + return; + } + } else if (type == DC_EVENT_ADD_CAPACITY) { + if (cxl_extents_overlaps_dpa_range(&dcd->dc.extents, dpa, len)) { + error_setg(errp, + "cannot add DPA already accessible to the same LD"); + return; + } + if (cxl_extent_groups_overlaps_dpa_range(&dcd->dc.extents_pending, + dpa, len)) { + error_setg(errp, + "cannot add DPA again while still pending"); + return; + } + } + list = list->next; + num_extents++; + } + + /* Create extent list for event being passed to host */ + i = 0; + list = records; + extents = g_new0(CXLDCExtentRaw, num_extents); + while (list) { + offset = list->value->offset; + len = list->value->len; + dpa = dcd->dc.regions[rid].base + offset; + + extents[i].start_dpa = dpa; + extents[i].len = len; + memset(extents[i].tag, 0, 0x10); + extents[i].shared_seq = 0; + if (type == DC_EVENT_ADD_CAPACITY) { + group = cxl_insert_extent_to_extent_group(group, + extents[i].start_dpa, + extents[i].len, + extents[i].tag, + extents[i].shared_seq); + } + + list = list->next; + i++; + } + if (group) { + cxl_extent_group_list_insert_tail(&dcd->dc.extents_pending, group); + } + + /* + * CXL r3.1 section 8.2.9.2.1.6: Dynamic Capacity Event Record + * + * All Dynamic Capacity event records shall set the Event Record Severity + * field in the Common Event Record Format to Informational Event. All + * Dynamic Capacity related events shall be logged in the Dynamic Capacity + * Event Log. + */ + cxl_assign_event_header(hdr, &dynamic_capacity_uuid, flags, sizeof(dCap), + cxl_device_get_timestamp(&dcd->cxl_dstate)); + + dCap.type = type; + /* FIXME: for now, validity flag is cleared */ + dCap.validity_flags = 0; + stw_le_p(&dCap.host_id, hid); + /* only valid for DC_REGION_CONFIG_UPDATED event */ + dCap.updated_region_id = 0; + dCap.flags = 0; + for (i = 0; i < num_extents; i++) { + memcpy(&dCap.dynamic_capacity_extent, &extents[i], + sizeof(CXLDCExtentRaw)); + + if (i < num_extents - 1) { + /* Set "More" flag */ + dCap.flags |= BIT(0); + } + + if (cxl_event_insert(&dcd->cxl_dstate, enc_log, + (CXLEventRecordRaw *)&dCap)) { + cxl_event_irq_assert(dcd); + } + } +} + +void qmp_cxl_add_dynamic_capacity(const char *path, uint16_t host_id, + CXLExtSelPolicy sel_policy, uint8_t region, + const char *tag, + CXLDynamicCapacityExtentList *extents, + Error **errp) +{ + switch (sel_policy) { + case CXL_EXT_SEL_POLICY_PRESCRIPTIVE: + qmp_cxl_process_dynamic_capacity_prescriptive(path, host_id, + DC_EVENT_ADD_CAPACITY, + region, extents, errp); + return; + default: + error_setg(errp, "Selection policy not supported"); + return; + } +} + +void qmp_cxl_release_dynamic_capacity(const char *path, uint16_t host_id, + CXLExtRemovalPolicy removal_policy, + bool has_forced_removal, + bool forced_removal, + bool has_sanitize_on_release, + bool sanitize_on_release, + uint8_t region, + const char *tag, + CXLDynamicCapacityExtentList *extents, + Error **errp) +{ + CXLDCEventType type = DC_EVENT_RELEASE_CAPACITY; + + if (has_forced_removal && forced_removal) { + /* TODO: enable forced removal in the future */ + type = DC_EVENT_FORCED_RELEASE_CAPACITY; + error_setg(errp, "Forced removal not supported yet"); + return; + } + + switch (removal_policy) { + case CXL_EXT_REMOVAL_POLICY_PRESCRIPTIVE: + qmp_cxl_process_dynamic_capacity_prescriptive(path, host_id, type, + region, extents, errp); + return; + default: + error_setg(errp, "Removal policy not supported"); + return; + } +} + static void ct3_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); diff --git a/hw/mem/cxl_type3_stubs.c b/hw/mem/cxl_type3_stubs.c index 3e1851e32b..45419bbefe 100644 --- a/hw/mem/cxl_type3_stubs.c +++ b/hw/mem/cxl_type3_stubs.c @@ -67,3 +67,28 @@ void qmp_cxl_inject_correctable_error(const char *path, CxlCorErrorType type, { error_setg(errp, "CXL Type 3 support is not compiled in"); } + +void qmp_cxl_add_dynamic_capacity(const char *path, + uint16_t host_id, + CXLExtSelPolicy sel_policy, + uint8_t region, + const char *tag, + CXLDynamicCapacityExtentList *extents, + Error **errp) +{ + error_setg(errp, "CXL Type 3 support is not compiled in"); +} + +void qmp_cxl_release_dynamic_capacity(const char *path, uint16_t host_id, + CXLExtRemovalPolicy removal_policy, + bool has_forced_removal, + bool forced_removal, + bool has_sanitize_on_release, + bool sanitize_on_release, + uint8_t region, + const char *tag, + CXLDynamicCapacityExtentList *extents, + Error **errp) +{ + error_setg(errp, "CXL Type 3 support is not compiled in"); +} From patchwork Wed Jul 3 22:46:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722961 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 221C1C2BD09 for ; Wed, 3 Jul 2024 22:46:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8kJ-0007z3-Ak; Wed, 03 Jul 2024 18:46: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 1sP8kC-0007LY-Ht for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46: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 1sP8kA-0001Su-F2 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046787; 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=J5j8n04Q1gRbmovO7PmlswqpHPYyPExcO8mAPNVjzhI=; b=ZumbHijc/pXb8GILc+jCgK65nyvQcfbJH2qy9lEz6hA0SqP2I3WLUKn0xEckWyenxRtxDX pi+zywZRbyUBF/HKL/YC+Ce1XvElFvypJXlgc1VDvLvOAXAoD+vfCxM/zdOIC8yLqf62oJ EsnwdhSjMNwzoMm0+A+lCyFEU4fS2zs= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-274-riuGUR6sOL2mSjzzceo39Q-1; Wed, 03 Jul 2024 18:46:26 -0400 X-MC-Unique: riuGUR6sOL2mSjzzceo39Q-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a7293303843so1246866b.3 for ; Wed, 03 Jul 2024 15:46:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046785; x=1720651585; 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=J5j8n04Q1gRbmovO7PmlswqpHPYyPExcO8mAPNVjzhI=; b=MtGArOZiDkwbMnF3s8nOiHgTTPuXGmutpEvXUAF+SBDVhucCt43qMOb6B3Hi2/KUag WvV6wM1jGwOgfhuixkq8+kkkLYOApN1CefogPB6UYcIsG6+7rSw9yrPrwmohiRbeeOda sSuCz3re649l5BkyeiNQjEL4KLX6Ir9ifwuVdORAankpK7Mn8ozXSaRm0PnIkHO4RHwL g0pikRnA9UmrZATmD90g/VRIGFbvijWi1QH8Lq69zTJv7vnDRBD20nHnVxX32NnXQvGd X/xmYwAS4TSNLLJPXT0DpcIknpJ7TOyDbnMbRRKQ/tsVw7DtwwG4K/0EsLGRaNwLmg32 oJkw== X-Gm-Message-State: AOJu0Yx82vOg/q2CGRdIWLUDy8C689OM9ngmRJSbeU5nNthLuJD5Od6G jt+GOIKft/ZtakI2XYe4HHlKkVqJtraz19rZ1lF7s22kFHBd9pAk8AK5BP6fN6Z4oC9NJmYRJpG SSbFL6s6hH5J8x+ks7RRyjHSSXUUqKJCqHwMrXFHTPog07x11fWen9YnNDxjqMD09x4zeRJpXTm dGJ2DUhz6WPPy/imGVOQFiPTssI2aYrw== X-Received: by 2002:a17:907:3e9f:b0:a6e:f62d:bd02 with SMTP id a640c23a62f3a-a75142d87femr1031456266b.7.1720046785322; Wed, 03 Jul 2024 15:46:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuMbIEgL0qAJqGFUd2iuDbn5RZzw0rnVdRSezTtQblMW8EZwe/RzWv0+YkfRGWCxTxqhLrfQ== X-Received: by 2002:a17:907:3e9f:b0:a6e:f62d:bd02 with SMTP id a640c23a62f3a-a75142d87femr1031454566b.7.1720046784672; Wed, 03 Jul 2024 15:46:24 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a750fb362d4sm435549966b.49.2024.07.03.15.46.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:46:24 -0700 (PDT) Date: Wed, 3 Jul 2024 18:46:20 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron Subject: [PULL v3 27/85] hw/mem/cxl_type3: Add DPA range validation for accesses to DC regions 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni All DPA ranges in the DC regions are invalid to access until an extent covering the range has been successfully accepted by the host. A bitmap is added to each region to record whether a DC block in the region has been backed by a DC extent. Each bit in the bitmap represents a DC block. When a DC extent is accepted, all the bits representing the blocks in the extent are set, which will be cleared when the extent is released. Tested-by: Svetly Todorov Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-13-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/cxl/cxl_device.h | 7 ++++ hw/cxl/cxl-mailbox-utils.c | 3 ++ hw/mem/cxl_type3.c | 76 +++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index c69ff6b5de..0a4fcb2800 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -456,6 +456,7 @@ typedef struct CXLDCRegion { uint64_t block_size; uint32_t dsmadhandle; uint8_t flags; + unsigned long *blk_bitmap; } CXLDCRegion; struct CXLType3Dev { @@ -577,4 +578,10 @@ CXLDCExtentGroup *cxl_insert_extent_to_extent_group(CXLDCExtentGroup *group, void cxl_extent_group_list_insert_tail(CXLDCExtentGroupList *list, CXLDCExtentGroup *group); void cxl_extent_group_list_delete_front(CXLDCExtentGroupList *list); +void ct3_set_region_block_backed(CXLType3Dev *ct3d, uint64_t dpa, + uint64_t len); +void ct3_clear_region_block_backed(CXLType3Dev *ct3d, uint64_t dpa, + uint64_t len); +bool ct3_test_region_block_backed(CXLType3Dev *ct3d, uint64_t dpa, + uint64_t len); #endif diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 64387f34ce..c4852112fe 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1655,6 +1655,7 @@ static CXLRetCode cmd_dcd_add_dyn_cap_rsp(const struct cxl_cmd *cmd, cxl_insert_extent_to_extent_list(extent_list, dpa, len, NULL, 0); ct3d->dc.total_extent_count += 1; + ct3_set_region_block_backed(ct3d, dpa, len); } /* Remove the first extent group in the pending list */ cxl_extent_group_list_delete_front(&ct3d->dc.extents_pending); @@ -1813,10 +1814,12 @@ static CXLRetCode cmd_dcd_release_dyn_cap(const struct cxl_cmd *cmd, * list and update the extent count; */ QTAILQ_FOREACH_SAFE(ent, &ct3d->dc.extents, node, ent_next) { + ct3_clear_region_block_backed(ct3d, ent->start_dpa, ent->len); cxl_remove_extent_from_extent_list(&ct3d->dc.extents, ent); } copy_extent_list(&ct3d->dc.extents, &updated_list); QTAILQ_FOREACH_SAFE(ent, &updated_list, node, ent_next) { + ct3_set_region_block_backed(ct3d, ent->start_dpa, ent->len); cxl_remove_extent_from_extent_list(&updated_list, ent); } ct3d->dc.total_extent_count = updated_list_size; diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index f53bcca6d3..0d18259ec0 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -672,6 +672,7 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Error **errp) .flags = 0, }; ct3d->dc.total_capacity += region->len; + region->blk_bitmap = bitmap_new(region->len / region->block_size); } QTAILQ_INIT(&ct3d->dc.extents); QTAILQ_INIT(&ct3d->dc.extents_pending); @@ -683,6 +684,8 @@ static void cxl_destroy_dc_regions(CXLType3Dev *ct3d) { CXLDCExtent *ent, *ent_next; CXLDCExtentGroup *group, *group_next; + int i; + CXLDCRegion *region; QTAILQ_FOREACH_SAFE(ent, &ct3d->dc.extents, node, ent_next) { cxl_remove_extent_from_extent_list(&ct3d->dc.extents, ent); @@ -695,6 +698,11 @@ static void cxl_destroy_dc_regions(CXLType3Dev *ct3d) } g_free(group); } + + for (i = 0; i < ct3d->dc.num_regions; i++) { + region = &ct3d->dc.regions[i]; + g_free(region->blk_bitmap); + } } static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp) @@ -926,6 +934,70 @@ static void ct3_exit(PCIDevice *pci_dev) } } +/* + * Mark the DPA range [dpa, dap + len - 1] to be backed and accessible. This + * happens when a DC extent is added and accepted by the host. + */ +void ct3_set_region_block_backed(CXLType3Dev *ct3d, uint64_t dpa, + uint64_t len) +{ + CXLDCRegion *region; + + region = cxl_find_dc_region(ct3d, dpa, len); + if (!region) { + return; + } + + bitmap_set(region->blk_bitmap, (dpa - region->base) / region->block_size, + len / region->block_size); +} + +/* + * Check whether the DPA range [dpa, dpa + len - 1] is backed with DC extents. + * Used when validating read/write to dc regions + */ +bool ct3_test_region_block_backed(CXLType3Dev *ct3d, uint64_t dpa, + uint64_t len) +{ + CXLDCRegion *region; + uint64_t nbits; + long nr; + + region = cxl_find_dc_region(ct3d, dpa, len); + if (!region) { + return false; + } + + nr = (dpa - region->base) / region->block_size; + nbits = DIV_ROUND_UP(len, region->block_size); + /* + * if bits between [dpa, dpa + len) are all 1s, meaning the DPA range is + * backed with DC extents, return true; else return false. + */ + return find_next_zero_bit(region->blk_bitmap, nr + nbits, nr) == nr + nbits; +} + +/* + * Mark the DPA range [dpa, dap + len - 1] to be unbacked and inaccessible. + * This happens when a dc extent is released by the host. + */ +void ct3_clear_region_block_backed(CXLType3Dev *ct3d, uint64_t dpa, + uint64_t len) +{ + CXLDCRegion *region; + uint64_t nbits; + long nr; + + region = cxl_find_dc_region(ct3d, dpa, len); + if (!region) { + return; + } + + nr = (dpa - region->base) / region->block_size; + nbits = len / region->block_size; + bitmap_clear(region->blk_bitmap, nr, nbits); +} + static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa) { int hdm_inc = R_CXL_HDM_DECODER1_BASE_LO - R_CXL_HDM_DECODER0_BASE_LO; @@ -1030,6 +1102,10 @@ static int cxl_type3_hpa_to_as_and_dpa(CXLType3Dev *ct3d, *as = &ct3d->hostpmem_as; *dpa_offset -= vmr_size; } else { + if (!ct3_test_region_block_backed(ct3d, *dpa_offset, size)) { + return -ENODEV; + } + *as = &ct3d->dc.host_dc_as; *dpa_offset -= (vmr_size + pmr_size); } From patchwork Wed Jul 3 22:46:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723046 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A63DCC2BD09 for ; Wed, 3 Jul 2024 22:53:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8kL-0008IL-EG; Wed, 03 Jul 2024 18:46: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 1sP8kI-0007sJ-2P for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46: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 1sP8kG-0001Tq-Br for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046793; 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=QuE+o0AC9wdLKXlzVTnODsdNe5/ti8zXK/7OKFfOYUM=; b=AVSEF8+zEympD4adq/49z6PndipH/bK2ShYW90HyCz0FZ1AH9vGcOhxaB94FhX6VqT5Uqx +lFtyXoRQxum/LAuVpbQrVbo6hC9+kcr8STT2JFveHn8zbrHbxEwMglIfF34zM333yF11C Pnkd3hMKfWmtsH4Zzt1YKm1cyXmY1K0= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-520-J7qPAOdRPrCgyekVBHlzQA-1; Wed, 03 Jul 2024 18:46:32 -0400 X-MC-Unique: J7qPAOdRPrCgyekVBHlzQA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a72af18f571so1315566b.2 for ; Wed, 03 Jul 2024 15:46:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046790; x=1720651590; 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=QuE+o0AC9wdLKXlzVTnODsdNe5/ti8zXK/7OKFfOYUM=; b=QT3IxG+kiS8dO0eVkMLxy+25Qd0zGyMQVSIiUtS96zxCdjgNKkHZC3skwe89znA27B DjoZLuVzwp1rUv9pnsyZaU6biLcT90ww/0mwiP+Ikh7ZT/V23mfGTyrShuLYgYZ2GJrS 51xFDHU3frpQBQk0cDvWD/xuNe6qnh9M5yC8sRlmxSSwgFXjy6/unki5qhPD1Xprvu/L AxJ8h5pQKwR04gwQ63FDCxnhcoXMBAwsHehjrdgjB+Q1syFLvzwKVyuK5sr2DM4trjNZ dFjqT00HKOTLyM3ZfcltyjVf0admApNl45j3Ebqxy9KTL2dPA09laCjsQPW/2cs3TmnX S3Gw== X-Gm-Message-State: AOJu0YxIXCWckOebS/vRKUlrNZso3WQIU+fbA9t8zXe8e3IHKYbpCYNu IcU65CL3RZ054ZLvy17SPmxxW0Q5qONhEXiGeSgyCmC0nlMgG1q+zrThtwe5C3S56AZchFcoSTA ILqxHxxkGncrbObbwQKR74p7DAptU+SObZ0SLcofYyguY/pKMzHKJeYneQ0Osk1M7ZC7gH3x3sw Uxj7oRPHLRpLBRk7/Mw5t17CUU2GCwKg== X-Received: by 2002:a17:907:a0b:b0:a72:676a:7d7b with SMTP id a640c23a62f3a-a751441efeamr955844366b.9.1720046790505; Wed, 03 Jul 2024 15:46:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEyKXP6bb6bD/iXdL1BwzS94SOjMemi5MP7Q0Hg31DFAZ3L2cfv5s1yJQwcHez6O3fQsLXfg== X-Received: by 2002:a17:907:a0b:b0:a72:676a:7d7b with SMTP id a640c23a62f3a-a751441efeamr955841966b.9.1720046789432; Wed, 03 Jul 2024 15:46:29 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a77b784de44sm3449966b.56.2024.07.03.15.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:46:29 -0700 (PDT) Date: Wed, 3 Jul 2024 18:46:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron Subject: [PULL v3 28/85] hw/cxl/cxl-mailbox-utils: Add superset extent release mailbox support Message-ID: <3083f018b59fd35b9ee993715694f967c49afeb1.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni With the change, we extend the extent release mailbox command processing to allow more flexible release. As long as the DPA range of the extent to release is covered by accepted extent(s) in the device, the release can be performed. Tested-by: Svetly Todorov Reviewed-by: Gregory Price Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-14-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index c4852112fe..74eeb6fde7 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1704,6 +1704,13 @@ static CXLRetCode cxl_dc_extent_release_dry_run(CXLType3Dev *ct3d, dpa = in->updated_entries[i].start_dpa; len = in->updated_entries[i].len; + /* Check if the DPA range is not fully backed with valid extents */ + if (!ct3_test_region_block_backed(ct3d, dpa, len)) { + ret = CXL_MBOX_INVALID_PA; + goto free_and_exit; + } + + /* After this point, extent overflow is the only error can happen */ while (len > 0) { QTAILQ_FOREACH(ent, updated_list, node) { range_init_nofail(&range, ent->start_dpa, ent->len); @@ -1718,14 +1725,7 @@ static CXLRetCode cxl_dc_extent_release_dry_run(CXLType3Dev *ct3d, if (range_contains(&range, dpa + len - 1)) { len2 = ent_start_dpa + ent_len - dpa - len; } else { - /* - * TODO: we reject the attempt to remove an extent - * that overlaps with multiple extents in the device - * for now. We will allow it once superset release - * support is added. - */ - ret = CXL_MBOX_INVALID_PA; - goto free_and_exit; + dpa = ent_start_dpa + ent_len; } len_done = ent_len - len1 - len2; @@ -1752,14 +1752,9 @@ static CXLRetCode cxl_dc_extent_release_dry_run(CXLType3Dev *ct3d, } len -= len_done; - /* len == 0 here until superset release is added */ break; } } - if (len) { - ret = CXL_MBOX_INVALID_PA; - goto free_and_exit; - } } } free_and_exit: From patchwork Wed Jul 3 22:46:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6F559C3271E for ; Wed, 3 Jul 2024 22:47:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8kS-0000tl-CC; Wed, 03 Jul 2024 18:46:48 -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 1sP8kR-0000gq-0e for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46: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 1sP8kO-0001Uo-Bm for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046803; 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=WFUPapk07PnJ8CLhVhbjjsuC+NoP2UxN6SJb+Hfxl60=; b=WEdfvfbrwUPKp1PJkoJ9O5dDp7DMcgXp6p2mcZad3MeuJwZ/CIQX+veuY4tOW4ICJ5hZDs VeqjmK0ZcvZKUQzNtIkhURZjDzEYwgesePqz3U475Pkgsqwf7tDM5XmSxNVXAR1m7nEkRl 6jM8HJX1SuXDtyWK0hbfmpT/y3t/QGk= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-CBAk51sYMMqnzcC1N4PHgg-1; Wed, 03 Jul 2024 18:46:36 -0400 X-MC-Unique: CBAk51sYMMqnzcC1N4PHgg-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-57c93227bbeso2847049a12.3 for ; Wed, 03 Jul 2024 15:46:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046795; x=1720651595; 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=WFUPapk07PnJ8CLhVhbjjsuC+NoP2UxN6SJb+Hfxl60=; b=qHE4wBWPSHCjLDZYK2KiriHujvMZarPC3QAyw6yRbGeihEU3lJDVEewm3ZOJkmmpdo xu56N0tWpRga0IlvU+PJV1VWUDLXOORDFsQvVYMxOlk/6djwhJvn3Q2X3hEd+SzQvFkL 40OiSwhuyIHzOkLpAjYHlPTZkBjNSeyiwn7iAx+s1sROX23dFa6Yf30BMhP0zSC6Vr88 SKYpa1VQ7Xe33fZFIN22mZr129igV82d0eCkTMkNcY+TdwHClEcOjsWCUN39hfP5Byje gUFQAxGWLeOyxMKGgu0a1128VKKdSUvGjb5hWyAT2/PstBNzrlHWuK9Im+bAidDlcXZn 91Eg== X-Gm-Message-State: AOJu0YxJyHHzwUd1b7pV4FZAHhZC9de2Bv8be9kVgr8gLRy47ylyKm0c RC1OrpIAx7KxorP7fsL2SbTVTh0CxMm3ZQ6DeWB4ELlhfFhl8+eGwTs8KSQgzvGBlL+P5ANUwGD q5qUvfAYZQlkyYfxsMVq+nTVKDOaFGA4rwuqfItPML1vTg7l8urdKGTgLIMPfHrrJmMrrqsCI7E SK9ntYqOQgH3AuugGN1OnBFZwXKxJduw== X-Received: by 2002:a17:906:68d8:b0:a6f:1025:8dd6 with SMTP id a640c23a62f3a-a75144b50b1mr785261266b.71.1720046795120; Wed, 03 Jul 2024 15:46:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHn8JibTmMf4vuYP1+dSTzvAzAkwnT9Yw/yZLUnI36/nSkW29iBIG9f0zEz1CIhJudHWwRaZg== X-Received: by 2002:a17:906:68d8:b0:a6f:1025:8dd6 with SMTP id a640c23a62f3a-a75144b50b1mr785259266b.71.1720046794459; Wed, 03 Jul 2024 15:46:34 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a77b784de44sm3452566b.56.2024.07.03.15.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:46:33 -0700 (PDT) Date: Wed, 3 Jul 2024 18:46:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron Subject: [PULL v3 29/85] hw/mem/cxl_type3: Allow to release extent superset in QMP interface 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Fan Ni Before the change, the QMP interface used for add/release DC extents only allows to release an extent whose DPA range is contained by a single accepted extent in the device. With the change, we relax the constraints. As long as the DPA range of the extent is covered by accepted extents, we allow the release. Tested-by: Svetly Todorov Reviewed-by: Gregory Price Reviewed-by: Jonathan Cameron Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-15-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/mem/cxl_type3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 0d18259ec0..5d4a1276be 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1947,7 +1947,7 @@ static void qmp_cxl_process_dynamic_capacity_prescriptive(const char *path, "cannot release extent with pending DPA range"); return; } - if (!cxl_extents_contains_dpa_range(&dcd->dc.extents, dpa, len)) { + if (!ct3_test_region_block_backed(dcd, dpa, len)) { error_setg(errp, "cannot release extent with non-existing DPA range"); return; From patchwork Wed Jul 3 22:46:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722966 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 938C6C2BD09 for ; Wed, 3 Jul 2024 22:47:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8kX-0001If-Uw; Wed, 03 Jul 2024 18:46: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 1sP8kT-00010N-AZ for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:52 -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 1sP8kP-0001V1-Px for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046805; 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=6YLYsco4l6cXmk5+8G0baLpqo+8dcgJ41Mj5z/Hl5Ws=; b=iOi9uYF08I+rL+LKhuNLoTsSwGcxuX1w3VwUrIxPz6UR9aPi6gxbFC685MsJ4JmNpJtuZO kk9zq4P4bUPZijYsjnBP51fzOX5j8QC5mg4V109o63KYgwYpvuHvsrgxl9KtfnP1Vnb++u SUH3zmU/rQ4h5rhz079Ps3uEwpkqDqA= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-477-xqqpEaUJPfGKezJ0UQUsJw-1; Wed, 03 Jul 2024 18:46:42 -0400 X-MC-Unique: xqqpEaUJPfGKezJ0UQUsJw-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-52cd67973e0so7692235e87.0 for ; Wed, 03 Jul 2024 15:46:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046800; x=1720651600; 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=6YLYsco4l6cXmk5+8G0baLpqo+8dcgJ41Mj5z/Hl5Ws=; b=YZhKlPvIVbN9Rt4j4x91M5Wfk2Ub8WtwpOWM+VYpaR6ILw5kg4dFeY8E1cfGRrmxSz awbdJ7krpnHmycAfH3lLoRq3o7USWVJX2kKXlDlsVQfvDh/vgCmJbSysKbNoJ/yPBLjY Df9t11gfBuxumcFU0CnVVu8P7qBx0jt+0yOdvs/DTeaFxFBctS5pgrcy2yeno/FT+Je6 SDmCGDxIVsG/teU34XbnqrviW3otisQyojIkOCYc2N3EAWgyzE23HDaY+U8pNDOXbknN sb148VrzvlpsmXxJq1in8i02IfEVpm+BgQnVNTBJBbGyx6je1e1KeEH9OUYVv/xMeYXC 6j3Q== X-Gm-Message-State: AOJu0YzyjYkj6tCwM8GZXho5tlHzT4npy93QwoKBpWVmbQueGWE7QQX0 9GBzWqNYGKQerSXvJ0O4KelGdnsPAMM34wYC1CMCVNPgArSCISOs21uyjxLyYgTieXyTdPU6SXf WJa2U/KBmyiZ1b6nxZHSMbcbSeuN0jWp2lC3o+CHavMlSukCCrCxAYFrrkWutBC7CPxVL+kJ3ft MVYw+8sXnh5rZgZ0yX2/YpDpKFxK4eAA== X-Received: by 2002:a05:6512:2814:b0:52c:db0e:6c4a with SMTP id 2adb3069b0e04-52e8264bc06mr12021669e87.2.1720046800514; Wed, 03 Jul 2024 15:46:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGffBAqru7HAWThABBLCiVEackwaX68SSbQ6Bj1MIZGcQU3SsdNumOUghLVym2RP0mw8CZ6Gw== X-Received: by 2002:a05:6512:2814:b0:52c:db0e:6c4a with SMTP id 2adb3069b0e04-52e8264bc06mr12021637e87.2.1720046799474; Wed, 03 Jul 2024 15:46:39 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a752d528ee5sm270137266b.212.2024.07.03.15.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:46:38 -0700 (PDT) Date: Wed, 3 Jul 2024 18:46:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?q?Wei=C3=9Fschu?= =?utf-8?q?h?= , Cornelia Huck , Paolo Bonzini , kvm@vger.kernel.org Subject: [PULL v3 30/85] linux-headers: update to 6.10-rc1 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Thomas Weißschuh Signed-off-by: Thomas Weißschuh Message-Id: <20240527-pvpanic-shutdown-v8-2-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/standard-headers/linux/ethtool.h | 55 ++++++++ include/standard-headers/linux/pci_regs.h | 6 + include/standard-headers/linux/virtio_bt.h | 1 - include/standard-headers/linux/virtio_mem.h | 2 + include/standard-headers/linux/virtio_net.h | 143 ++++++++++++++++++++ include/standard-headers/misc/pvpanic.h | 7 +- linux-headers/asm-generic/unistd.h | 5 +- linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 2 + linux-headers/linux/kvm.h | 4 +- linux-headers/linux/stddef.h | 8 ++ 19 files changed, 236 insertions(+), 6 deletions(-) diff --git a/include/standard-headers/linux/ethtool.h b/include/standard-headers/linux/ethtool.h index 01503784d2..b0b4b68410 100644 --- a/include/standard-headers/linux/ethtool.h +++ b/include/standard-headers/linux/ethtool.h @@ -752,6 +752,61 @@ enum ethtool_module_power_mode { ETHTOOL_MODULE_POWER_MODE_HIGH, }; +/** + * enum ethtool_pse_types - Types of PSE controller. + * @ETHTOOL_PSE_UNKNOWN: Type of PSE controller is unknown + * @ETHTOOL_PSE_PODL: PSE controller which support PoDL + * @ETHTOOL_PSE_C33: PSE controller which support Clause 33 (PoE) + */ +enum ethtool_pse_types { + ETHTOOL_PSE_UNKNOWN = 1 << 0, + ETHTOOL_PSE_PODL = 1 << 1, + ETHTOOL_PSE_C33 = 1 << 2, +}; + +/** + * enum ethtool_c33_pse_admin_state - operational state of the PoDL PSE + * functions. IEEE 802.3-2022 30.9.1.1.2 aPSEAdminState + * @ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN: state of PSE functions is unknown + * @ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED: PSE functions are disabled + * @ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED: PSE functions are enabled + */ +enum ethtool_c33_pse_admin_state { + ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN = 1, + ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED, + ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED, +}; + +/** + * enum ethtool_c33_pse_pw_d_status - power detection status of the PSE. + * IEEE 802.3-2022 30.9.1.1.3 aPoDLPSEPowerDetectionStatus: + * @ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN: PSE status is unknown + * @ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED: The enumeration "disabled" + * indicates that the PSE State diagram is in the state DISABLED. + * @ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING: The enumeration "searching" + * indicates the PSE State diagram is in a state other than those + * listed. + * @ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING: The enumeration + * "deliveringPower" indicates that the PSE State diagram is in the + * state POWER_ON. + * @ETHTOOL_C33_PSE_PW_D_STATUS_TEST: The enumeration "test" indicates that + * the PSE State diagram is in the state TEST_MODE. + * @ETHTOOL_C33_PSE_PW_D_STATUS_FAULT: The enumeration "fault" indicates that + * the PSE State diagram is in the state TEST_ERROR. + * @ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT: The enumeration "otherFault" + * indicates that the PSE State diagram is in the state IDLE due to + * the variable error_condition = true. + */ +enum ethtool_c33_pse_pw_d_status { + ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN = 1, + ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED, + ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING, + ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING, + ETHTOOL_C33_PSE_PW_D_STATUS_TEST, + ETHTOOL_C33_PSE_PW_D_STATUS_FAULT, + ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT, +}; + /** * enum ethtool_podl_pse_admin_state - operational state of the PoDL PSE * functions. IEEE 802.3-2018 30.15.1.1.2 aPoDLPSEAdminState diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-headers/linux/pci_regs.h index a39193213f..94c00996e6 100644 --- a/include/standard-headers/linux/pci_regs.h +++ b/include/standard-headers/linux/pci_regs.h @@ -1144,8 +1144,14 @@ #define PCI_DOE_DATA_OBJECT_HEADER_2_LENGTH 0x0003ffff #define PCI_DOE_DATA_OBJECT_DISC_REQ_3_INDEX 0x000000ff +#define PCI_DOE_DATA_OBJECT_DISC_REQ_3_VER 0x0000ff00 #define PCI_DOE_DATA_OBJECT_DISC_RSP_3_VID 0x0000ffff #define PCI_DOE_DATA_OBJECT_DISC_RSP_3_PROTOCOL 0x00ff0000 #define PCI_DOE_DATA_OBJECT_DISC_RSP_3_NEXT_INDEX 0xff000000 +/* Compute Express Link (CXL r3.1, sec 8.1.5) */ +#define PCI_DVSEC_CXL_PORT 3 +#define PCI_DVSEC_CXL_PORT_CTL 0x0c +#define PCI_DVSEC_CXL_PORT_CTL_UNMASK_SBR 0x00000001 + #endif /* LINUX_PCI_REGS_H */ diff --git a/include/standard-headers/linux/virtio_bt.h b/include/standard-headers/linux/virtio_bt.h index a11ecc3f92..6f0dee7e32 100644 --- a/include/standard-headers/linux/virtio_bt.h +++ b/include/standard-headers/linux/virtio_bt.h @@ -13,7 +13,6 @@ enum virtio_bt_config_type { VIRTIO_BT_CONFIG_TYPE_PRIMARY = 0, - VIRTIO_BT_CONFIG_TYPE_AMP = 1, }; enum virtio_bt_config_vendor { diff --git a/include/standard-headers/linux/virtio_mem.h b/include/standard-headers/linux/virtio_mem.h index 18c74c527c..6bfa41bd8b 100644 --- a/include/standard-headers/linux/virtio_mem.h +++ b/include/standard-headers/linux/virtio_mem.h @@ -90,6 +90,8 @@ #define VIRTIO_MEM_F_ACPI_PXM 0 /* unplugged memory must not be accessed */ #define VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE 1 +/* plugged memory will remain plugged when suspending+resuming */ +#define VIRTIO_MEM_F_PERSISTENT_SUSPEND 2 /* --- virtio-mem: guest -> host requests --- */ diff --git a/include/standard-headers/linux/virtio_net.h b/include/standard-headers/linux/virtio_net.h index 0f88417742..fc594fe5fc 100644 --- a/include/standard-headers/linux/virtio_net.h +++ b/include/standard-headers/linux/virtio_net.h @@ -56,6 +56,7 @@ #define VIRTIO_NET_F_MQ 22 /* Device supports Receive Flow * Steering */ #define VIRTIO_NET_F_CTRL_MAC_ADDR 23 /* Set MAC address */ +#define VIRTIO_NET_F_DEVICE_STATS 50 /* Device can provide device-level statistics. */ #define VIRTIO_NET_F_VQ_NOTF_COAL 52 /* Device supports virtqueue notification coalescing */ #define VIRTIO_NET_F_NOTF_COAL 53 /* Device supports notifications coalescing */ #define VIRTIO_NET_F_GUEST_USO4 54 /* Guest can handle USOv4 in. */ @@ -406,4 +407,146 @@ struct virtio_net_ctrl_coal_vq { struct virtio_net_ctrl_coal coal; }; +/* + * Device Statistics + */ +#define VIRTIO_NET_CTRL_STATS 8 +#define VIRTIO_NET_CTRL_STATS_QUERY 0 +#define VIRTIO_NET_CTRL_STATS_GET 1 + +struct virtio_net_stats_capabilities { + +#define VIRTIO_NET_STATS_TYPE_CVQ (1ULL << 32) + +#define VIRTIO_NET_STATS_TYPE_RX_BASIC (1ULL << 0) +#define VIRTIO_NET_STATS_TYPE_RX_CSUM (1ULL << 1) +#define VIRTIO_NET_STATS_TYPE_RX_GSO (1ULL << 2) +#define VIRTIO_NET_STATS_TYPE_RX_SPEED (1ULL << 3) + +#define VIRTIO_NET_STATS_TYPE_TX_BASIC (1ULL << 16) +#define VIRTIO_NET_STATS_TYPE_TX_CSUM (1ULL << 17) +#define VIRTIO_NET_STATS_TYPE_TX_GSO (1ULL << 18) +#define VIRTIO_NET_STATS_TYPE_TX_SPEED (1ULL << 19) + + uint64_t supported_stats_types[1]; +}; + +struct virtio_net_ctrl_queue_stats { + struct { + uint16_t vq_index; + uint16_t reserved[3]; + uint64_t types_bitmap[1]; + } stats[1]; +}; + +struct virtio_net_stats_reply_hdr { +#define VIRTIO_NET_STATS_TYPE_REPLY_CVQ 32 + +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC 0 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM 1 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO 2 +#define VIRTIO_NET_STATS_TYPE_REPLY_RX_SPEED 3 + +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC 16 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM 17 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO 18 +#define VIRTIO_NET_STATS_TYPE_REPLY_TX_SPEED 19 + uint8_t type; + uint8_t reserved; + uint16_t vq_index; + uint16_t reserved1; + uint16_t size; +}; + +struct virtio_net_stats_cvq { + struct virtio_net_stats_reply_hdr hdr; + + uint64_t command_num; + uint64_t ok_num; +}; + +struct virtio_net_stats_rx_basic { + struct virtio_net_stats_reply_hdr hdr; + + uint64_t rx_notifications; + + uint64_t rx_packets; + uint64_t rx_bytes; + + uint64_t rx_interrupts; + + uint64_t rx_drops; + uint64_t rx_drop_overruns; +}; + +struct virtio_net_stats_tx_basic { + struct virtio_net_stats_reply_hdr hdr; + + uint64_t tx_notifications; + + uint64_t tx_packets; + uint64_t tx_bytes; + + uint64_t tx_interrupts; + + uint64_t tx_drops; + uint64_t tx_drop_malformed; +}; + +struct virtio_net_stats_rx_csum { + struct virtio_net_stats_reply_hdr hdr; + + uint64_t rx_csum_valid; + uint64_t rx_needs_csum; + uint64_t rx_csum_none; + uint64_t rx_csum_bad; +}; + +struct virtio_net_stats_tx_csum { + struct virtio_net_stats_reply_hdr hdr; + + uint64_t tx_csum_none; + uint64_t tx_needs_csum; +}; + +struct virtio_net_stats_rx_gso { + struct virtio_net_stats_reply_hdr hdr; + + uint64_t rx_gso_packets; + uint64_t rx_gso_bytes; + uint64_t rx_gso_packets_coalesced; + uint64_t rx_gso_bytes_coalesced; +}; + +struct virtio_net_stats_tx_gso { + struct virtio_net_stats_reply_hdr hdr; + + uint64_t tx_gso_packets; + uint64_t tx_gso_bytes; + uint64_t tx_gso_segments; + uint64_t tx_gso_segments_bytes; + uint64_t tx_gso_packets_noseg; + uint64_t tx_gso_bytes_noseg; +}; + +struct virtio_net_stats_rx_speed { + struct virtio_net_stats_reply_hdr hdr; + + /* rx_{packets,bytes}_allowance_exceeded are too long. So rename to + * short name. + */ + uint64_t rx_ratelimit_packets; + uint64_t rx_ratelimit_bytes; +}; + +struct virtio_net_stats_tx_speed { + struct virtio_net_stats_reply_hdr hdr; + + /* tx_{packets,bytes}_allowance_exceeded are too long. So rename to + * short name. + */ + uint64_t tx_ratelimit_packets; + uint64_t tx_ratelimit_bytes; +}; + #endif /* _LINUX_VIRTIO_NET_H */ diff --git a/include/standard-headers/misc/pvpanic.h b/include/standard-headers/misc/pvpanic.h index 54b7485390..b115094431 100644 --- a/include/standard-headers/misc/pvpanic.h +++ b/include/standard-headers/misc/pvpanic.h @@ -3,7 +3,10 @@ #ifndef __PVPANIC_H__ #define __PVPANIC_H__ -#define PVPANIC_PANICKED (1 << 0) -#define PVPANIC_CRASH_LOADED (1 << 1) +#include "standard-headers/linux/const.h" + +#define PVPANIC_PANICKED _BITUL(0) +#define PVPANIC_CRASH_LOADED _BITUL(1) +#define PVPANIC_SHUTDOWN _BITUL(2) #endif /* __PVPANIC_H__ */ diff --git a/linux-headers/asm-generic/unistd.h b/linux-headers/asm-generic/unistd.h index 75f00965ab..d983c48a3b 100644 --- a/linux-headers/asm-generic/unistd.h +++ b/linux-headers/asm-generic/unistd.h @@ -842,8 +842,11 @@ __SYSCALL(__NR_lsm_set_self_attr, sys_lsm_set_self_attr) #define __NR_lsm_list_modules 461 __SYSCALL(__NR_lsm_list_modules, sys_lsm_list_modules) +#define __NR_mseal 462 +__SYSCALL(__NR_mseal, sys_mseal) + #undef __NR_syscalls -#define __NR_syscalls 462 +#define __NR_syscalls 463 /* * 32 bit systems traditionally used different diff --git a/linux-headers/asm-mips/unistd_n32.h b/linux-headers/asm-mips/unistd_n32.h index ce2e050a9b..fc93b3be30 100644 --- a/linux-headers/asm-mips/unistd_n32.h +++ b/linux-headers/asm-mips/unistd_n32.h @@ -390,5 +390,6 @@ #define __NR_lsm_get_self_attr (__NR_Linux + 459) #define __NR_lsm_set_self_attr (__NR_Linux + 460) #define __NR_lsm_list_modules (__NR_Linux + 461) +#define __NR_mseal (__NR_Linux + 462) #endif /* _ASM_UNISTD_N32_H */ diff --git a/linux-headers/asm-mips/unistd_n64.h b/linux-headers/asm-mips/unistd_n64.h index 5bfb3733ff..e72a3eb2c9 100644 --- a/linux-headers/asm-mips/unistd_n64.h +++ b/linux-headers/asm-mips/unistd_n64.h @@ -366,5 +366,6 @@ #define __NR_lsm_get_self_attr (__NR_Linux + 459) #define __NR_lsm_set_self_attr (__NR_Linux + 460) #define __NR_lsm_list_modules (__NR_Linux + 461) +#define __NR_mseal (__NR_Linux + 462) #endif /* _ASM_UNISTD_N64_H */ diff --git a/linux-headers/asm-mips/unistd_o32.h b/linux-headers/asm-mips/unistd_o32.h index 02eaecd020..b86eb0786c 100644 --- a/linux-headers/asm-mips/unistd_o32.h +++ b/linux-headers/asm-mips/unistd_o32.h @@ -436,5 +436,6 @@ #define __NR_lsm_get_self_attr (__NR_Linux + 459) #define __NR_lsm_set_self_attr (__NR_Linux + 460) #define __NR_lsm_list_modules (__NR_Linux + 461) +#define __NR_mseal (__NR_Linux + 462) #endif /* _ASM_UNISTD_O32_H */ diff --git a/linux-headers/asm-powerpc/unistd_32.h b/linux-headers/asm-powerpc/unistd_32.h index bbab08d6ec..28627b6546 100644 --- a/linux-headers/asm-powerpc/unistd_32.h +++ b/linux-headers/asm-powerpc/unistd_32.h @@ -443,6 +443,7 @@ #define __NR_lsm_get_self_attr 459 #define __NR_lsm_set_self_attr 460 #define __NR_lsm_list_modules 461 +#define __NR_mseal 462 #endif /* _ASM_UNISTD_32_H */ diff --git a/linux-headers/asm-powerpc/unistd_64.h b/linux-headers/asm-powerpc/unistd_64.h index af34cde70f..1fc42a8300 100644 --- a/linux-headers/asm-powerpc/unistd_64.h +++ b/linux-headers/asm-powerpc/unistd_64.h @@ -415,6 +415,7 @@ #define __NR_lsm_get_self_attr 459 #define __NR_lsm_set_self_attr 460 #define __NR_lsm_list_modules 461 +#define __NR_mseal 462 #endif /* _ASM_UNISTD_64_H */ diff --git a/linux-headers/asm-s390/unistd_32.h b/linux-headers/asm-s390/unistd_32.h index a3ece69d82..7706c21b87 100644 --- a/linux-headers/asm-s390/unistd_32.h +++ b/linux-headers/asm-s390/unistd_32.h @@ -434,5 +434,6 @@ #define __NR_lsm_get_self_attr 459 #define __NR_lsm_set_self_attr 460 #define __NR_lsm_list_modules 461 +#define __NR_mseal 462 #endif /* _ASM_S390_UNISTD_32_H */ diff --git a/linux-headers/asm-s390/unistd_64.h b/linux-headers/asm-s390/unistd_64.h index 8c5fd93495..62082d592d 100644 --- a/linux-headers/asm-s390/unistd_64.h +++ b/linux-headers/asm-s390/unistd_64.h @@ -382,5 +382,6 @@ #define __NR_lsm_get_self_attr 459 #define __NR_lsm_set_self_attr 460 #define __NR_lsm_list_modules 461 +#define __NR_mseal 462 #endif /* _ASM_S390_UNISTD_64_H */ diff --git a/linux-headers/asm-x86/unistd_32.h b/linux-headers/asm-x86/unistd_32.h index 5c9c329e93..fb7b8b169b 100644 --- a/linux-headers/asm-x86/unistd_32.h +++ b/linux-headers/asm-x86/unistd_32.h @@ -452,6 +452,7 @@ #define __NR_lsm_get_self_attr 459 #define __NR_lsm_set_self_attr 460 #define __NR_lsm_list_modules 461 +#define __NR_mseal 462 #endif /* _ASM_UNISTD_32_H */ diff --git a/linux-headers/asm-x86/unistd_64.h b/linux-headers/asm-x86/unistd_64.h index d9aab7ae87..da439afee1 100644 --- a/linux-headers/asm-x86/unistd_64.h +++ b/linux-headers/asm-x86/unistd_64.h @@ -374,6 +374,7 @@ #define __NR_lsm_get_self_attr 459 #define __NR_lsm_set_self_attr 460 #define __NR_lsm_list_modules 461 +#define __NR_mseal 462 #endif /* _ASM_UNISTD_64_H */ diff --git a/linux-headers/asm-x86/unistd_x32.h b/linux-headers/asm-x86/unistd_x32.h index 63cdd1ee43..4fcb607c72 100644 --- a/linux-headers/asm-x86/unistd_x32.h +++ b/linux-headers/asm-x86/unistd_x32.h @@ -318,6 +318,7 @@ #define __NR_set_mempolicy_home_node (__X32_SYSCALL_BIT + 450) #define __NR_cachestat (__X32_SYSCALL_BIT + 451) #define __NR_fchmodat2 (__X32_SYSCALL_BIT + 452) +#define __NR_map_shadow_stack (__X32_SYSCALL_BIT + 453) #define __NR_futex_wake (__X32_SYSCALL_BIT + 454) #define __NR_futex_wait (__X32_SYSCALL_BIT + 455) #define __NR_futex_requeue (__X32_SYSCALL_BIT + 456) @@ -326,6 +327,7 @@ #define __NR_lsm_get_self_attr (__X32_SYSCALL_BIT + 459) #define __NR_lsm_set_self_attr (__X32_SYSCALL_BIT + 460) #define __NR_lsm_list_modules (__X32_SYSCALL_BIT + 461) +#define __NR_mseal (__X32_SYSCALL_BIT + 462) #define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512) #define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513) #define __NR_ioctl (__X32_SYSCALL_BIT + 514) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 038731cdef..c93876ca0b 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1217,9 +1217,9 @@ struct kvm_vfio_spapr_tce { /* Available with KVM_CAP_SPAPR_RESIZE_HPT */ #define KVM_PPC_RESIZE_HPT_PREPARE _IOR(KVMIO, 0xad, struct kvm_ppc_resize_hpt) #define KVM_PPC_RESIZE_HPT_COMMIT _IOR(KVMIO, 0xae, struct kvm_ppc_resize_hpt) -/* Available with KVM_CAP_PPC_RADIX_MMU or KVM_CAP_PPC_HASH_MMU_V3 */ +/* Available with KVM_CAP_PPC_MMU_RADIX or KVM_CAP_PPC_MMU_HASH_V3 */ #define KVM_PPC_CONFIGURE_V3_MMU _IOW(KVMIO, 0xaf, struct kvm_ppc_mmuv3_cfg) -/* Available with KVM_CAP_PPC_RADIX_MMU */ +/* Available with KVM_CAP_PPC_MMU_RADIX */ #define KVM_PPC_GET_RMMU_INFO _IOW(KVMIO, 0xb0, struct kvm_ppc_rmmu_info) /* Available with KVM_CAP_PPC_GET_CPU_CHAR */ #define KVM_PPC_GET_CPU_CHAR _IOR(KVMIO, 0xb1, struct kvm_ppc_cpu_char) diff --git a/linux-headers/linux/stddef.h b/linux-headers/linux/stddef.h index bf9749dd14..96aa341942 100644 --- a/linux-headers/linux/stddef.h +++ b/linux-headers/linux/stddef.h @@ -55,4 +55,12 @@ #define __counted_by(m) #endif +#ifndef __counted_by_le +#define __counted_by_le(m) +#endif + +#ifndef __counted_by_be +#define __counted_by_be(m) +#endif + #endif /* _LINUX_STDDEF_H */ From patchwork Wed Jul 3 22:46:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722967 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC286C31D97 for ; Wed, 3 Jul 2024 22:47:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8kZ-0001Tm-Ka; Wed, 03 Jul 2024 18:46:55 -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 1sP8kV-00017B-Lm for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:52 -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 1sP8kT-0001VP-MT for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046809; 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=j+up8MRKOgqTt/+B4PZNRXPDsgBlrNg7Q1TqZFnoDR0=; b=WlYMpXYwO9HzGPhRrE+U3eaLojyAmqCfyhG3EHAFQjAbVpQBnBo2O3Q+3FCT5xdlXjiZNd 1QpU6TD+t+d486HFF3kl7kh03Rr7F/5xzF2julfe01kbeUb59Y2c7pQ3c/wTLdFiGXNwQL MOsdJtC48PLOmCyZnRaQfr3ctSISfTI= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-Jr6rwW8JMyy7T1LQRV5xAw-1; Wed, 03 Jul 2024 18:46:47 -0400 X-MC-Unique: Jr6rwW8JMyy7T1LQRV5xAw-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a74914bc770so1331666b.3 for ; Wed, 03 Jul 2024 15:46:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046806; x=1720651606; 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=j+up8MRKOgqTt/+B4PZNRXPDsgBlrNg7Q1TqZFnoDR0=; b=Fz+HgD7nTOsOqjhDHv+R+f2kRb4qxVjSL1ZscPWgXUFxlbFQI/PH6ag7+QVWHLj9bw FehXxFo+rHFNjlRIbHx4UDcSdlLrYrL3VrUc2JmjqKcEq6nYFVyhwH5Ur9qVcLLX1XFr /h91ZIPgDrAsmzxz4mOP+LpfcamCRHqEUrTqtEEVNaT+8xA2Qh+xdjqbjtXlUWl/3ZGS h8GPgrO6zsc0uj7+GXWvCPwyiKmsvLtQOruyXRHrtezaNQBEfTODEJk2koUwDA+BfdAc YGSIjCaS7JxCLeGU/TvDHryndfG7GWnQ43vNdhOI/EgK0IMongbPc8vSTDorJ8z3iyJl X36Q== X-Gm-Message-State: AOJu0Yz23QWIqCPmXzTapcbArlbfdnTEMlvsvtbid2hfQoEiUWh5iNNq 2x4+KdbPnxS2Jp1xWbcaW9PsAAFjPTAlNAqo5szzHgdDTmb6GANri7asXBal85W7Td+CvKzwtdM pLKKcbS5svTRJ8OfJlNb1Ih+j1p2O7R8a95XzQHnJo5pC1ezPGdSyEgczpgYnChdaXxQ/VIoKWv HqbNoKVZNtJfUsU6fcmdohqSa8A5hpVw== X-Received: by 2002:a17:907:970e:b0:a72:6ff6:b91a with SMTP id a640c23a62f3a-a751447b21dmr985020966b.51.1720046806240; Wed, 03 Jul 2024 15:46:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGqDIcr1nehmyqq/Q/H9NH88MFEmFa/7HKpee3t40YW08L2g5qo6fdLWWU/J0b0dV2kH0Eugw== X-Received: by 2002:a17:907:970e:b0:a72:6ff6:b91a with SMTP id a640c23a62f3a-a751447b21dmr985018666b.51.1720046805467; Wed, 03 Jul 2024 15:46:45 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab0b8021sm549382566b.216.2024.07.03.15.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:46:44 -0700 (PDT) Date: Wed, 3 Jul 2024 18:46:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?q?Wei=C3=9Fschu?= =?utf-8?q?h?= , Thomas Huth , Cornelia Huck , Paolo Bonzini , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PULL v3 31/85] hw/misc/pvpanic: centralize definition of supported events Message-ID: <9b13640da3f94c0fbacbae6d23bd91febfa44588.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Thomas Weißschuh The different components of pvpanic duplicate the list of supported events. Move it to the shared header file to minimize changes when new events are added. MST: tweak: keep header included in pvpanic.c to avoid header dependency, rebase. Reviewed-by: Thomas Huth Reviewed-by: Cornelia Huck Signed-off-by: Thomas Weißschuh Message-Id: <20240527-pvpanic-shutdown-v8-3-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/misc/pvpanic.h | 4 ++++ hw/misc/pvpanic-isa.c | 3 +-- hw/misc/pvpanic-pci.c | 2 +- hw/misc/pvpanic.c | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h index fab94165d0..1e5b20e4ed 100644 --- a/include/hw/misc/pvpanic.h +++ b/include/hw/misc/pvpanic.h @@ -18,6 +18,10 @@ #include "exec/memory.h" #include "qom/object.h" +#include "standard-headers/misc/pvpanic.h" + +#define PVPANIC_EVENTS (PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) + #define TYPE_PVPANIC_ISA_DEVICE "pvpanic" #define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci" diff --git a/hw/misc/pvpanic-isa.c b/hw/misc/pvpanic-isa.c index b4f84c4110..9a923b7869 100644 --- a/hw/misc/pvpanic-isa.c +++ b/hw/misc/pvpanic-isa.c @@ -21,7 +21,6 @@ #include "hw/misc/pvpanic.h" #include "qom/object.h" #include "hw/isa/isa.h" -#include "standard-headers/misc/pvpanic.h" #include "hw/acpi/acpi_aml_interface.h" OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE) @@ -102,7 +101,7 @@ static void build_pvpanic_isa_aml(AcpiDevAmlIf *adev, Aml *scope) static Property pvpanic_isa_properties[] = { DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505), DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events, - PVPANIC_PANICKED | PVPANIC_CRASH_LOADED), + PVPANIC_EVENTS), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c index 4d44a881da..106d03ccd6 100644 --- a/hw/misc/pvpanic-pci.c +++ b/hw/misc/pvpanic-pci.c @@ -55,7 +55,7 @@ static void pvpanic_pci_realizefn(PCIDevice *dev, Error **errp) static Property pvpanic_pci_properties[] = { DEFINE_PROP_UINT8("events", PVPanicPCIState, pvpanic.events, - PVPANIC_PANICKED | PVPANIC_CRASH_LOADED), + PVPANIC_EVENTS), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index 80289ecf5f..4b2307d2c2 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -27,7 +27,7 @@ static void handle_event(int event) { static bool logged; - if (event & ~(PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) && !logged) { + if (event & ~PVPANIC_EVENTS && !logged) { qemu_log_mask(LOG_GUEST_ERROR, "pvpanic: unknown event %#x.\n", event); logged = true; } From patchwork Wed Jul 3 22:46:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722976 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7AEAEC2BD09 for ; Wed, 3 Jul 2024 22:48:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8kf-00026e-KL; Wed, 03 Jul 2024 18:47:02 -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 1sP8kc-0001qh-G4 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:58 -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 1sP8ka-0001W8-NF for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:46:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046815; 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=3+zh1wfaSmmaGh+SRQcFGybC5BaSt211Udvwvhl5h14=; b=XFY5RH29j8/GjOKIHHlxN4hhmp/glUGOfWj0h1GySreuVF1UIVE36dKN0W21rh7Rw8ZUNr iFuUCG7CnxvpxzGre9U6A0V793UHz8KMP1SWxbAtsitX5E6vfBF1NYz/ieHtLDf2u8l3lm 2cbVXipx33Z5hsAJ3tYNMjwg5zMZ8Lc= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-191-cBJFv0OxM9isbwyIZoNIYw-1; Wed, 03 Jul 2024 18:46:52 -0400 X-MC-Unique: cBJFv0OxM9isbwyIZoNIYw-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a751eb024abso1108666b.0 for ; Wed, 03 Jul 2024 15:46:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046811; x=1720651611; 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=3+zh1wfaSmmaGh+SRQcFGybC5BaSt211Udvwvhl5h14=; b=NkiloIDK1R99VC7Ww/LzDvhgD0GbH7ZshFFY65x1JLOnTSIjVhrkMRVCnLwdxiKk1x lcIY3FALvej3M7SFHGkbXlExVUua0zvbYU2RR0Q5ssRQRTv5pnG4OTqIDwyXcYpBYI0G eVxATnOq50AtztcRr8mO+BI2GF4OMExTDOukKLpX+ZSm6BZAQZwY5rx7+OHWC9vK55DL dpuMHHCBZdNP5JPoN2shdaBG7yrEbZYDdKhdwrpbGAFqeRM+2HR749CLMA9xqxT/wTPJ d6mjbbIrTEJTCqlhhUZK/7BgzAUzQm+7WVLHkQdaOMOxQDuqMC3GEhv1K1V/isu32F50 hjwA== X-Gm-Message-State: AOJu0YyW6/ixha/RLW27FofS8If2xnSk0MCxKj/q1BcMhN4TERUgbXMk rzKlihzTSqFjjGl4QQxGRmCgZotGz+CqDF5vvAuTefo7yv5gfDDKAWscX1GkRQLCMrMDk1aiUsr U1WzFayirJska3g1Mr/VekJ8jqhTmkFzW4ME2bf5mnOJ18tV2K/wx5NPOOlP2oiI1CqkF0PEdfa 02DcVvb464aFkCau3ohMgVNZ27dpdmFQ== X-Received: by 2002:a05:6402:1ec1:b0:57c:5d4a:4122 with SMTP id 4fb4d7f45d1cf-5879ede26f9mr12876717a12.9.1720046810889; Wed, 03 Jul 2024 15:46:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPExu6usZD/kMUaYFt8GRmAvEeGxM0F4buZe1an1sEqDRFzlEgbRy/ouE7urzM2Edl0+WHxw== X-Received: by 2002:a05:6402:1ec1:b0:57c:5d4a:4122 with SMTP id 4fb4d7f45d1cf-5879ede26f9mr12876687a12.9.1720046809853; Wed, 03 Jul 2024 15:46:49 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58612c838casm7684286a12.4.2024.07.03.15.46.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:46:49 -0700 (PDT) Date: Wed, 3 Jul 2024 18:46:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?q?Wei=C3=9Fschu?= =?utf-8?q?h?= , Thomas Huth , Cornelia Huck , Laurent Vivier , Paolo Bonzini Subject: [PULL v3 32/85] tests/qtest/pvpanic: use centralized definition of supported events Message-ID: <462dc749c110fe8e41ae0fb554b9bc2f2671e973.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Thomas Weißschuh Avoid the necessity to update all tests when new events are added to the device. Acked-by: Thomas Huth Reviewed-by: Cornelia Huck Signed-off-by: Thomas Weißschuh Message-Id: <20240527-pvpanic-shutdown-v8-4-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/pvpanic-pci-test.c | 5 +++-- tests/qtest/pvpanic-test.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/qtest/pvpanic-pci-test.c b/tests/qtest/pvpanic-pci-test.c index 2c05b376ba..b372caf41d 100644 --- a/tests/qtest/pvpanic-pci-test.c +++ b/tests/qtest/pvpanic-pci-test.c @@ -16,6 +16,7 @@ #include "qapi/qmp/qdict.h" #include "libqos/pci.h" #include "libqos/pci-pc.h" +#include "hw/misc/pvpanic.h" #include "hw/pci/pci_regs.h" static void test_panic_nopause(void) @@ -34,7 +35,7 @@ static void test_panic_nopause(void) bar = qpci_iomap(dev, 0, NULL); qpci_memread(dev, bar, 0, &val, sizeof(val)); - g_assert_cmpuint(val, ==, 3); + g_assert_cmpuint(val, ==, PVPANIC_EVENTS); val = 1; qpci_memwrite(dev, bar, 0, &val, sizeof(val)); @@ -67,7 +68,7 @@ static void test_panic(void) bar = qpci_iomap(dev, 0, NULL); qpci_memread(dev, bar, 0, &val, sizeof(val)); - g_assert_cmpuint(val, ==, 3); + g_assert_cmpuint(val, ==, PVPANIC_EVENTS); val = 1; qpci_memwrite(dev, bar, 0, &val, sizeof(val)); diff --git a/tests/qtest/pvpanic-test.c b/tests/qtest/pvpanic-test.c index 78f1cf8186..ccc603472f 100644 --- a/tests/qtest/pvpanic-test.c +++ b/tests/qtest/pvpanic-test.c @@ -10,6 +10,7 @@ #include "qemu/osdep.h" #include "libqtest.h" #include "qapi/qmp/qdict.h" +#include "hw/misc/pvpanic.h" static void test_panic_nopause(void) { @@ -20,7 +21,7 @@ static void test_panic_nopause(void) qts = qtest_init("-device pvpanic -action panic=none"); val = qtest_inb(qts, 0x505); - g_assert_cmpuint(val, ==, 3); + g_assert_cmpuint(val, ==, PVPANIC_EVENTS); qtest_outb(qts, 0x505, 0x1); @@ -43,7 +44,7 @@ static void test_panic(void) qts = qtest_init("-device pvpanic -action panic=pause"); val = qtest_inb(qts, 0x505); - g_assert_cmpuint(val, ==, 3); + g_assert_cmpuint(val, ==, PVPANIC_EVENTS); qtest_outb(qts, 0x505, 0x1); From patchwork Wed Jul 3 22:46:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 731E7C31D97 for ; Wed, 3 Jul 2024 22:48:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8km-00037T-Mm; Wed, 03 Jul 2024 18:47: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 1sP8kj-0002jZ-AF for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47: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 1sP8ke-0001Wj-HO for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046816; 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=kZkfnrsmrcpCA4paPRwjE2CzS2LM1h/03EC8/LUs/AI=; b=NrxoEYT0UgUrRrjexz4nq9yYlSaoE/kXFGnghMfCFAt5/DN5SSy2MOsLkNkfUJlNrP3Twa +5/7Niu2LL/V6G9Assqk5R4ByNxqhxe5IzjTOcaOFIMtoX34RpTeKjrcMkIxzRIYNaheYu 3HSjzn5Rj0KNYFmL4Ds/LMxK+KYEHLA= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-421-lh1XtLPJNtW_lRclZy1qvA-1; Wed, 03 Jul 2024 18:46:55 -0400 X-MC-Unique: lh1XtLPJNtW_lRclZy1qvA-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a728c02df80so1419666b.1 for ; Wed, 03 Jul 2024 15:46:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046814; x=1720651614; 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=kZkfnrsmrcpCA4paPRwjE2CzS2LM1h/03EC8/LUs/AI=; b=J4NbrLgwO0cBhwYMQjmqFQn4pOZgaWEQq+g+pDkVLJSZt4PoGcwaVWL+cKiFMeCbBN Vz5o30EL0K0Nj6GTUYcJzQ8XX7PUSDz/3pQNBSPhNg8xsUf2qlp4SCs4Do27jvhH1T5g RuP/Uq6qCvb9jMeQFDzcFfZ+bBRFmIpI6TioedzPWK3kK+8f0NXVzfbqi1lnoEQrBtd4 /rkXwIAEKkdAx9wuwApCdRhJVfEfKNvJdGlKl7goCEHDnGYWzfaRGK67nRBX9xGJ4u5W 5nkVuWSb9afCL9SGx0p/itaRnkspt4pZUNWYfrIlts3N203tpp9lLqJpm5kGL3x+8YJy nhEg== X-Gm-Message-State: AOJu0YweBf68Yi5qpzjyn2FrZaYWrAcJgkCKoj/5NNS2ChxfOkK/Xp83 D4XO4tUK8VGPUdf6D2oA7MO+JDhiD/K6T6U8ZoRG+2uPtuFOaRyN7kn7vXjv0u91Iz+i3QrRCux iwC5ZNye8DCoRNFeQIZHUhOm1Qhbbj6Ei2Evp1UJNfMzYpAeyBR3/6aPpskjf2OPRWm6N/qWnNv LHDp4PbTvZUVOGFLgu0iwgfUSQQXv1Rw== X-Received: by 2002:a17:906:e206:b0:a6f:b3af:2add with SMTP id a640c23a62f3a-a7514454648mr794781666b.45.1720046814158; Wed, 03 Jul 2024 15:46:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH2ZS0q05QJ4Am/5bRx7I4vmSPmcFJve5W+TRFKbc82EfIWirtYxQGQ6oF6m6APGWFD/3/Zfg== X-Received: by 2002:a17:906:e206:b0:a6f:b3af:2add with SMTP id a640c23a62f3a-a7514454648mr794780466b.45.1720046813435; Wed, 03 Jul 2024 15:46:53 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab0900f1sm543684566b.168.2024.07.03.15.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:46:52 -0700 (PDT) Date: Wed, 3 Jul 2024 18:46:50 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?q?Wei=C3=9Fschu?= =?utf-8?q?h?= , Cornelia Huck , Paolo Bonzini Subject: [PULL v3 33/85] hw/misc/pvpanic: add support for normal shutdowns Message-ID: <6269086b0179e3d70750672174ed7fbd29ac7eaa.1720046570.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, T_SPF_TEMPERROR=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Thomas Weißschuh Shutdown requests are normally hardware dependent. By extending pvpanic to also handle shutdown requests, guests can submit such requests with an easily implementable and cross-platform mechanism. Acked-by: Cornelia Huck Signed-off-by: Thomas Weißschuh Message-Id: <20240527-pvpanic-shutdown-v8-5-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/misc/pvpanic.h | 4 +++- include/sysemu/runstate.h | 1 + hw/misc/pvpanic.c | 5 +++++ system/runstate.c | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h index 1e5b20e4ed..9a71a5ad0d 100644 --- a/include/hw/misc/pvpanic.h +++ b/include/hw/misc/pvpanic.h @@ -20,7 +20,9 @@ #include "standard-headers/misc/pvpanic.h" -#define PVPANIC_EVENTS (PVPANIC_PANICKED | PVPANIC_CRASH_LOADED) +#define PVPANIC_EVENTS (PVPANIC_PANICKED | \ + PVPANIC_CRASH_LOADED | \ + PVPANIC_SHUTDOWN) #define TYPE_PVPANIC_ISA_DEVICE "pvpanic" #define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci" diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 0117d243c4..e210a37abf 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -104,6 +104,7 @@ void qemu_system_killed(int signal, pid_t pid); void qemu_system_reset(ShutdownCause reason); void qemu_system_guest_panicked(GuestPanicInformation *info); void qemu_system_guest_crashloaded(GuestPanicInformation *info); +void qemu_system_guest_pvshutdown(void); bool qemu_system_dump_in_progress(void); #endif diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index 4b2307d2c2..3b893340c0 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -41,6 +41,11 @@ static void handle_event(int event) qemu_system_guest_crashloaded(NULL); return; } + + if (event & PVPANIC_SHUTDOWN) { + qemu_system_guest_pvshutdown(); + return; + } } /* return supported events on read */ diff --git a/system/runstate.c b/system/runstate.c index ec32e270cb..fc49fd3e61 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -584,6 +584,11 @@ void qemu_system_guest_crashloaded(GuestPanicInformation *info) qapi_free_GuestPanicInformation(info); } +void qemu_system_guest_pvshutdown(void) +{ + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); +} + void qemu_system_reset_request(ShutdownCause reason) { if (reboot_action == REBOOT_ACTION_SHUTDOWN && From patchwork Wed Jul 3 22:46:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722999 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D0FE0C2BD09 for ; Wed, 3 Jul 2024 22:50:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8kr-0003aP-L9; Wed, 03 Jul 2024 18:47:13 -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 1sP8kp-0003Pi-Pl for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:11 -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 1sP8ki-0001X9-GO for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046821; 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=YhLUD4bgFXykNLby5YqUbG3vAr/0cDl4XOSKHnOq4eQ=; b=fywVA3o56V5cL5jlEqAbQjb9uLH6N7V6M7QgekzLLD1B97WfmeWz9EOQWhvMlp2IHAHipD QWH6CkZcdr+ohcKHrINDWmSczPAHQPmCDmJTgOfyf/J9vFPQOELo1HJpV9Xa0HliLb6M0G LDFjIP4r8YtUxHTjGBy+li5ruXwGGyY= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-p55CqpImPtS0xiMFQHoLJw-1; Wed, 03 Jul 2024 18:47:00 -0400 X-MC-Unique: p55CqpImPtS0xiMFQHoLJw-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-584ef6c00c0so1685181a12.1 for ; Wed, 03 Jul 2024 15:47:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046819; x=1720651619; 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=YhLUD4bgFXykNLby5YqUbG3vAr/0cDl4XOSKHnOq4eQ=; b=YrAhbpbjf4VjdSNBsXbVbP/wsTM250xOvtUFVeeW2KXs3S0zf+XNwvUNPknR7VXphv C6wC7e8zw7V/Pgt+dE403AzNtNOO39Yg9kSYPtht/SaTJJ5Sssxes0OTxuCVxuC4xyEk 8I4qCXhUdJr2M5kopfMWPNI6BtPLos2G2avg1zLjY7LuhpyVoOmk8pbpE2cYcjaVYHUN aqFBhAN0o4cTUAtC16KibuseOugfkCvagu+0/4Vh//8NGNBmS3QKoDpFc45yHCOKaEK7 o7I94jkGOifTJsBxf8dexSMSf1nCpeBtXmYhmTWa82foSmeuO4z9bdSdk2qQHPmrcEjW zaWg== X-Gm-Message-State: AOJu0YzWIe4cXpw5Lh1dlYQam679Mb1dtdWXmn7Q0VEbn6m8pQ8EMDU3 YJf5tLynRcOUlMQPmxX58G0B0EKo1ptTzh69tgoxj5TMQxPMZexuHqF/gbeC+OYCS7OskUeBFsR rnpi9N7bzgudVbj4AfRvgWw9jnaTUCKsoNYcj9wDmGnLaV+qj35qb3Hig5z/k4JI13nfT8geZ+1 10BrPi+2//Hf7pSZBXY8Kv2llBV/mp2Q== X-Received: by 2002:a05:6402:40c5:b0:586:178f:aaa4 with SMTP id 4fb4d7f45d1cf-58ce5169885mr2529743a12.9.1720046818825; Wed, 03 Jul 2024 15:46:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENdjYuJum/0AUWZOYdpsjlAu/xeqTbkfywve+ZRZCJpAlgJW3rf9MBRkFeWZhx6xBDabQRzg== X-Received: by 2002:a05:6402:40c5:b0:586:178f:aaa4 with SMTP id 4fb4d7f45d1cf-58ce5169885mr2529725a12.9.1720046818289; Wed, 03 Jul 2024 15:46:58 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58612c8368esm7573106a12.19.2024.07.03.15.46.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:46:57 -0700 (PDT) Date: Wed, 3 Jul 2024 18:46:53 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Paolo Bonzini , Eric Blake , Markus Armbruster Subject: [PULL v3 34/85] pvpanic: Emit GUEST_PVSHUTDOWN QMP event on pvpanic shutdown signal Message-ID: <8db1f7be788b23f8eca189fe4546298ed387e9cb.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Alejandro Jimenez Emit a QMP event on receiving a PVPANIC_SHUTDOWN event. Even though a typical SHUTDOWN event will be sent, it will be indistinguishable from a shutdown originating from other cases (e.g. KVM exit due to KVM_SYSTEM_EVENT_SHUTDOWN) that also issue the guest-shutdown cause. A management layer application can detect the new GUEST_PVSHUTDOWN event to determine if the guest is using the pvpanic interface to request shutdowns. Signed-off-by: Alejandro Jimenez Message-Id: <20240527-pvpanic-shutdown-v8-6-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/run-state.json | 14 ++++++++++++++ system/runstate.c | 1 + 2 files changed, 15 insertions(+) diff --git a/qapi/run-state.json b/qapi/run-state.json index f8773f23b2..5ac0fec852 100644 --- a/qapi/run-state.json +++ b/qapi/run-state.json @@ -462,6 +462,20 @@ { 'event': 'GUEST_CRASHLOADED', 'data': { 'action': 'GuestPanicAction', '*info': 'GuestPanicInformation' } } +## +# @GUEST_PVSHUTDOWN: +# +# Emitted when guest submits a shutdown request via pvpanic interface +# +# Since: 9.1 +# +# Example: +# +# <- { "event": "GUEST_PVSHUTDOWN", +# "timestamp": { "seconds": 1648245259, "microseconds": 893771 } } +## +{ 'event': 'GUEST_PVSHUTDOWN' } + ## # @GuestPanicAction: # diff --git a/system/runstate.c b/system/runstate.c index fc49fd3e61..c833316f6d 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -586,6 +586,7 @@ void qemu_system_guest_crashloaded(GuestPanicInformation *info) void qemu_system_guest_pvshutdown(void) { + qapi_event_send_guest_pvshutdown(); qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); } From patchwork Wed Jul 3 22:46:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722972 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E3F5BC2BD09 for ; Wed, 3 Jul 2024 22:48:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8kq-0003Sn-TD; Wed, 03 Jul 2024 18:47: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 1sP8kn-0003GL-VP for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47: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 1sP8km-0001Xk-1t for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046827; 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=qGhmwqguo7pIYQaZC7WOHDuKcF1Cau7swIzTfVk8co4=; b=Yjc3IJw9i2fXiCoBQ7+FveUd8sPhFCS29V14aIylc3mQoqFlau387mSvZSwVmqRLL7iysS 0H7O7WIW2yqBpaUOSgdrhS7wT27gjgcffV6hlenTsOQ8o3wQj0h4r20hvYqKQx0MIXDBnr MgAop+8+aLgsGM8maja9om7N+YDOqxQ= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-562-Z4JkYvqLOA-zuY2XZI772A-1; Wed, 03 Jul 2024 18:47:06 -0400 X-MC-Unique: Z4JkYvqLOA-zuY2XZI772A-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-57cd2950eefso6616a12.0 for ; Wed, 03 Jul 2024 15:47:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046825; x=1720651625; 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=qGhmwqguo7pIYQaZC7WOHDuKcF1Cau7swIzTfVk8co4=; b=bw3G2cvE5v/UO9S50mDVUDMi5vICLl5tllh3iA9H+s4opq2XSMsMP6cB+5IdjbUfXA p+5FDbBKfWxG/JTNTf5nmhCegCtQNivRaEg1xHW8cuJ68/se2qezL7VZkhXrnseD4aJC JNOuvc4rswF4y5ATA07E4TE56cS3TpXJLMDaw20Y7t6vWlxZ6xvhh+atvVb7Uz6P0MqP Sji43aBCP/aZKViVLYRQT7tuYSXDZddBKWldtWITu26pJrJKj/yZb4l9jkbKDzVR5kFK 6d+d6Mr0YpcAYo5CoyjqymSrCoeWraV+tqS6g+9M9MpwhRtYa/xptALyFTR/hFCwb2gO IbfA== X-Gm-Message-State: AOJu0YxLtOnpaZTUcT+FaGOJx2XuFxe2bdb6o7eCQmtuARQzAugTQvCb wgnUc/dl+45YxzjNgYVi1iiusUWex2xS0WhzFbDupy6xxMXsWuwTlAHpcqI+RneOJL/0rSVMb99 B7C9kheoWZdX/VLjqPBYy133Ho2HYkwmWrl0qgQwtUfslGEqYihWpGtISAk45/7T246Sr7Xgd4o WHeMxw8MQlnNs4924iX8pH3rcZQPb29w== X-Received: by 2002:a17:906:36c6:b0:a6f:b75f:3d46 with SMTP id a640c23a62f3a-a7514475c22mr878954566b.43.1720046824755; Wed, 03 Jul 2024 15:47:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPlxWsC2gdMHau1HWYY/a/6YQtTGMUy5LcCafRaKt91Mv1Drlv/1Msod3dn5FnoXKlACj6og== X-Received: by 2002:a17:906:36c6:b0:a6f:b75f:3d46 with SMTP id a640c23a62f3a-a7514475c22mr878952266b.43.1720046823699; Wed, 03 Jul 2024 15:47:03 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf18b15sm551162766b.19.2024.07.03.15.47.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:47:03 -0700 (PDT) Date: Wed, 3 Jul 2024 18:46:58 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?q?Wei=C3=9Fschu?= =?utf-8?q?h?= , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL v3 35/85] tests/qtest/pvpanic: add tests for pvshutdown event 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Thomas Weißschuh Validate that a shutdown via the pvpanic device emits the correct QMP events. Signed-off-by: Thomas Weißschuh Reviewed-by: Thomas Huth Message-Id: <20240527-pvpanic-shutdown-v8-7-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/pvpanic-pci-test.c | 39 ++++++++++++++++++++++++++++++++++ tests/qtest/pvpanic-test.c | 29 +++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/tests/qtest/pvpanic-pci-test.c b/tests/qtest/pvpanic-pci-test.c index b372caf41d..dc021c2fdf 100644 --- a/tests/qtest/pvpanic-pci-test.c +++ b/tests/qtest/pvpanic-pci-test.c @@ -85,11 +85,50 @@ static void test_panic(void) qtest_quit(qts); } +static void test_pvshutdown(void) +{ + uint8_t val; + QDict *response, *data; + QTestState *qts; + QPCIBus *pcibus; + QPCIDevice *dev; + QPCIBar bar; + + qts = qtest_init("-device pvpanic-pci,addr=04.0"); + pcibus = qpci_new_pc(qts, NULL); + dev = qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0)); + qpci_device_enable(dev); + bar = qpci_iomap(dev, 0, NULL); + + qpci_memread(dev, bar, 0, &val, sizeof(val)); + g_assert_cmpuint(val, ==, PVPANIC_EVENTS); + + val = PVPANIC_SHUTDOWN; + qpci_memwrite(dev, bar, 0, &val, sizeof(val)); + + response = qtest_qmp_eventwait_ref(qts, "GUEST_PVSHUTDOWN"); + qobject_unref(response); + + response = qtest_qmp_eventwait_ref(qts, "SHUTDOWN"); + g_assert(qdict_haskey(response, "data")); + data = qdict_get_qdict(response, "data"); + g_assert(qdict_haskey(data, "guest")); + g_assert(qdict_get_bool(data, "guest")); + g_assert(qdict_haskey(data, "reason")); + g_assert_cmpstr(qdict_get_str(data, "reason"), ==, "guest-shutdown"); + qobject_unref(response); + + g_free(dev); + qpci_free_pc(pcibus); + qtest_quit(qts); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); qtest_add_func("/pvpanic-pci/panic", test_panic); qtest_add_func("/pvpanic-pci/panic-nopause", test_panic_nopause); + qtest_add_func("/pvpanic-pci/pvshutdown", test_pvshutdown); return g_test_run(); } diff --git a/tests/qtest/pvpanic-test.c b/tests/qtest/pvpanic-test.c index ccc603472f..d49d2ba931 100644 --- a/tests/qtest/pvpanic-test.c +++ b/tests/qtest/pvpanic-test.c @@ -58,11 +58,40 @@ static void test_panic(void) qtest_quit(qts); } +static void test_pvshutdown(void) +{ + uint8_t val; + QDict *response, *data; + QTestState *qts; + + qts = qtest_init("-device pvpanic"); + + val = qtest_inb(qts, 0x505); + g_assert_cmpuint(val, ==, PVPANIC_EVENTS); + + qtest_outb(qts, 0x505, PVPANIC_SHUTDOWN); + + response = qtest_qmp_eventwait_ref(qts, "GUEST_PVSHUTDOWN"); + qobject_unref(response); + + response = qtest_qmp_eventwait_ref(qts, "SHUTDOWN"); + g_assert(qdict_haskey(response, "data")); + data = qdict_get_qdict(response, "data"); + g_assert(qdict_haskey(data, "guest")); + g_assert(qdict_get_bool(data, "guest")); + g_assert(qdict_haskey(data, "reason")); + g_assert_cmpstr(qdict_get_str(data, "reason"), ==, "guest-shutdown"); + qobject_unref(response); + + qtest_quit(qts); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); qtest_add_func("/pvpanic/panic", test_panic); qtest_add_func("/pvpanic/panic-nopause", test_panic_nopause); + qtest_add_func("/pvpanic/pvshutdown", test_pvshutdown); return g_test_run(); } From patchwork Wed Jul 3 22:47:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723045 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 893E7C2BD09 for ; Wed, 3 Jul 2024 22:53:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8kv-000403-3y; Wed, 03 Jul 2024 18:47:17 -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 1sP8kt-0003lG-PB for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:15 -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 1sP8kq-0001Zc-Vi for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046832; 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=g4UiaVaJHqFRMzcgj8Lsoa2O3CKB9KU5Hs0p0vn09PA=; b=f98gqa6XZyuA5q/1nw1o3NWZlNYN+7+GIuf6KHxHJBW0cJ8Ao3dg+dSnlUjodrXLBDEvny CQWytZlH9nEcHpMx7bXsR3i/yddWzpMeMz4j+7GhFi/79xEzSMNA5R5zpTFmZKAsFfj86n KwitXelRWc1mqzlMK+yyazUQ/4Bcw2U= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-281-uGaIPky4M0eZvtWkFH4IXg-1; Wed, 03 Jul 2024 18:47:10 -0400 X-MC-Unique: uGaIPky4M0eZvtWkFH4IXg-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a72716df71eso1114566b.1 for ; Wed, 03 Jul 2024 15:47:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046828; x=1720651628; 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=g4UiaVaJHqFRMzcgj8Lsoa2O3CKB9KU5Hs0p0vn09PA=; b=G/CXPeRBIipORqxPXR/kYMZwNKDorAkfInlMD0Ofm+2H2PTwNeHnntGZ/7Qv3Iqfw1 gbtghUPA2Kk8cqKp0UXpazCUQJ15XMElbz0EdrUQqW9+XN2E8xmLDcwZQ7A4yFNnKFBH 3T6CpUM3dgxJU0Gr4LZe7QnwBUklKK6iVLiN5yLwPdn1S56C9ZcYX9etG697I8m0BaMW Xq8CDkFz9wp/i21lhfTAqkl+8paJJq06S33BlHfiS0IE09bXqwUo0YrtbORJF+KLfOwe OPfX8MS0sVYEn4hxgoXt5rHlFj4nqUlydNcjXWfUDtnmgPjU3UEE6f895BaDqO5qj55C xH+g== X-Gm-Message-State: AOJu0YyxA6AIEHvrQwFEj1cP/dcoVH7HOnd183SYLRaLObJKCVPf7A9U meC4QPgNTI94L21kVENimIZaHUL9uA+qqCuXB6BxL0gtVpGJFBVBpqbYeNtkzPdpQ2Upa5AEPTN 2Xp2QZlyLxi900MFQtMEUO4aOQjVqdFcLxXfZZ2hJ5mS3T1baEBSU2NlJztyRYrXEoiCfoXrOhk 5CjIvJu81iy28ac4FylaZ2oQ7Epd6gxw== X-Received: by 2002:a17:906:3518:b0:a72:b278:5a7 with SMTP id a640c23a62f3a-a751449f46cmr939805866b.44.1720046828492; Wed, 03 Jul 2024 15:47:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0tgV/R+7BiCjys6UuOvXJNtdz1hKaqFOBJGBXHpiOv/lsyw5B4nhwHjR1S7ese8Mj7kFSHA== X-Received: by 2002:a17:906:3518:b0:a72:b278:5a7 with SMTP id a640c23a62f3a-a751449f46cmr939804266b.44.1720046827930; Wed, 03 Jul 2024 15:47:07 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab065651sm543222366b.126.2024.07.03.15.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:47:07 -0700 (PDT) Date: Wed, 3 Jul 2024 18:47:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas =?utf-8?q?Wei=C3=9Fschu?= =?utf-8?q?h?= , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PULL v3 36/85] Revert "docs/specs/pvpanic: mark shutdown event as not implemented" Message-ID: <0c0cc13d319cf7b876f327fa1c5cc1866ad868cc.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Thomas Weißschuh The missing functionality has been implemented now. This reverts commit e739d1935c461d0668057e9dbba9d06f728d29ec. Signed-off-by: Thomas Weißschuh Message-Id: <20240527-pvpanic-shutdown-v8-8-5a28ec02558b@t-8ch.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/specs/pvpanic.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/specs/pvpanic.rst b/docs/specs/pvpanic.rst index b0f27860ec..61a80480ed 100644 --- a/docs/specs/pvpanic.rst +++ b/docs/specs/pvpanic.rst @@ -29,7 +29,7 @@ bit 1 a guest panic has happened and will be handled by the guest; the host should record it or report it, but should not affect the execution of the guest. -bit 2 (to be implemented) +bit 2 a regular guest shutdown has happened and should be processed by the host PCI Interface From patchwork Wed Jul 3 22:47:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722979 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81502C2BD09 for ; Wed, 3 Jul 2024 22:48:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8l0-0004Pu-Ur; Wed, 03 Jul 2024 18:47: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 1sP8kx-0004E6-OC for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:19 -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 1sP8kv-0001a8-54 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046836; 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=PMqT3UA862JsOGcigX9iEr1iG7UpaUmQpd1D/p7t/1Y=; b=BLMtR6OT0BqKhiN4AKbUYPVMLNMZEg3men9ovwthi8t7xnBh+BI5QLmmkCcus7arEgNUHx /4QPLsFUEDmlDHip3kQu0bZP1yA+e76gurM9nMWn1SNz+0iM4HQ/YwDWx1YzgwKY84NfQW luPdl1IX2L5qP1P4yiEKJqvdizjcxeQ= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-612-1-j-HpKBOv6sbQvbDD60Aw-1; Wed, 03 Jul 2024 18:47:15 -0400 X-MC-Unique: 1-j-HpKBOv6sbQvbDD60Aw-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-52e98c1a9d2so1207817e87.3 for ; Wed, 03 Jul 2024 15:47:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046833; x=1720651633; 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=PMqT3UA862JsOGcigX9iEr1iG7UpaUmQpd1D/p7t/1Y=; b=rTGu24lDELN7XIscv2vdecvr5icMfXB01mztW+hc0cGk9Moxt0kvic72mEa0okLJty /I+6cKbOToMpJncx7fCU2aPuWMvjb8U/9+wWsr9lh5qD8HdV46Kvb7mHRxO/nt8zj24P dhPrt/Ggznf5xLCbgp4XYTZIMbdGo42oB0Pin+E/yOH8gYFTacoGYg2OI8DE4OD76SPh AaAPjLK3g+ImFlzigVGBNt4R18xD7dJs0uYLEo6i/YOz8AePQlgRUHUM6y0+jLHEa9Uu gEIm9nVp0kLhGisGCBA1t0Qj4wFydmXf0XtCJAO+mZSRM4O7QsuqwPdGeQF1r8V3eLrw W64Q== X-Gm-Message-State: AOJu0YxB3tbuojGShu6HBCfnySyTx2foShwCtdCGaCUDNbK7W9LFWdyd qBgZ08pUNCHEhniF1mbj8+wiUPzIIlpDAGDe6I2EgqhW8eM5SRPhANvpzoq9TpIfRwfkS237Qk8 UcBXHxZTg+EaZ6Nta8mVN+U3IMAGBf7EI5Ugx9Tri0ldT4/xropX2awzmGsRIoqdHDGyty6KWoY et8SNZqEiNlmylAARKYn3j+NiZomzfPQ== X-Received: by 2002:a05:6512:3610:b0:52c:825e:3b1c with SMTP id 2adb3069b0e04-52e8266f836mr6460157e87.26.1720046833227; Wed, 03 Jul 2024 15:47:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHujyPKjr2Wl8Siz3B5hB6YJWFLDZ7BWmFStpBTX1i51rqT+3LekGS1RtyKu8QCGwGvE2bmNQ== X-Received: by 2002:a05:6512:3610:b0:52c:825e:3b1c with SMTP id 2adb3069b0e04-52e8266f836mr6460142e87.26.1720046832220; Wed, 03 Jul 2024 15:47:12 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf18b15sm551172866b.19.2024.07.03.15.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:47:11 -0700 (PDT) Date: Wed, 3 Jul 2024 18:47:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Cindy Lu , qemu-stable@nongnu.org Subject: [PULL v3 37/85] virtio-pci: Fix the failure process in kvm_virtio_pci_vector_use_one() 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Cindy Lu In function kvm_virtio_pci_vector_use_one(), the function will only use the irqfd/vector for itself. Therefore, in the undo label, the failing process is incorrect. To fix this, we can just remove this label. Fixes: f9a09ca3ea ("vhost: add support for configure interrupt") Cc: qemu-stable@nongnu.org Signed-off-by: Cindy Lu Message-Id: <20240528084840.194538-1-lulu@redhat.com> Reviewed-by: Peter Maydell Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 7d62e92365..5941f1a94d 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -898,7 +898,7 @@ static int kvm_virtio_pci_vector_use_one(VirtIOPCIProxy *proxy, int queue_no) } ret = kvm_virtio_pci_vq_vector_use(proxy, vector); if (ret < 0) { - goto undo; + return ret; } /* * If guest supports masking, set up irqfd now. @@ -908,25 +908,11 @@ static int kvm_virtio_pci_vector_use_one(VirtIOPCIProxy *proxy, int queue_no) ret = kvm_virtio_pci_irqfd_use(proxy, n, vector); if (ret < 0) { kvm_virtio_pci_vq_vector_release(proxy, vector); - goto undo; + return ret; } } return 0; -undo: - - vector = virtio_queue_vector(vdev, queue_no); - if (vector >= msix_nr_vectors_allocated(dev)) { - return ret; - } - if (vdev->use_guest_notifier_mask && k->guest_notifier_mask) { - ret = virtio_pci_get_notifier(proxy, queue_no, &n, &vector); - if (ret < 0) { - return ret; - } - kvm_virtio_pci_irqfd_release(proxy, n, vector); - } - return ret; } static int kvm_virtio_pci_vector_vq_use(VirtIOPCIProxy *proxy, int nvqs) { From patchwork Wed Jul 3 22:47:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 86EFDC2BD09 for ; Wed, 3 Jul 2024 22:48:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8l7-0004pj-DL; Wed, 03 Jul 2024 18:47: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 1sP8l1-0004Va-Sl for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:24 -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 1sP8l0-0001ao-6i for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046840; 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=3jl4Qu4kLpM2wQ0qiu2Lf05x2qWhSbW1JbTTyjioPSc=; b=fWPd8LjsH3d1sKln/PUdIdxzuhAbAteGCXq2U7UCLTt5NkA3K6PnXRhObUXJVnnGTQE+Pk vfbZJaeJxGqJLX5cCPnO8DU5Ep/tcoP+P41yMcklEUMNcNvXcVzSaRxOnIrko6bqEqYZWq 56ia9Rlr89Xuw9NB/NKudJo/FuOW+Ew= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-333-BmsJdodkM_esErekfvqRWw-1; Wed, 03 Jul 2024 18:47:19 -0400 X-MC-Unique: BmsJdodkM_esErekfvqRWw-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a7194d0fd53so2218166b.0 for ; Wed, 03 Jul 2024 15:47:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046837; x=1720651637; 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=3jl4Qu4kLpM2wQ0qiu2Lf05x2qWhSbW1JbTTyjioPSc=; b=enHpUVKW1vw3Ac8gkVg7bhUXCy2qof4FpsHRV7nvMM/pV6m+f65H8h+BK+MlfC0UAO SjDJBvPyNcZSg73/Pjbk5SRGRDJN10u0JHyuX/rhpbh0HMSpXHht3T7PbAcGEQKRJ7IW ksOuxW0Uf1zNPijBeuxdX2c2et1EOTkz1YQiPVbf9KDX/HOyejfCt4ehtW/lYSg7fBUm h1ayidrqF8MTzv9bo7EAmY2fDFMoDSYSAWSang5oBxENTURtfU3Cy5DO4OEahMkInMVf D5oxKPu0ykjA+RR/OLB2qYYRzlxWDHLRm5pTdwAmAP35iLgLgbXSQfx8fibMOVGwSYFe /17w== X-Gm-Message-State: AOJu0YxHTGaXHCNs6ylOJRldBS7Yf3xFOx0/a+YenqkLJDdjxv3auUWj DtngNVhRLe2bEyh/Y6bhxsWBOEr/9KNkTSZVYdm6UoRJ+Un7J+TrmpgSU6MxWSXn3FNXw11BLhP 0G2VWtldFzl3xriR3rejLFTSdg2snYufNqDS5LphMgo0NNv6tqbT3h6YFQ5YkjeHgNtrT58+isS sMGZXU7FSfWvgb00Sq3XGxZsCVhV5YEA== X-Received: by 2002:a17:906:782:b0:a72:75b1:2bf2 with SMTP id a640c23a62f3a-a7514498ab2mr733599366b.36.1720046837464; Wed, 03 Jul 2024 15:47:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQC+9Xz5S/z4N2m/+2ZSYYlMZhXApoUf9RYtBIzxYEERcImlFtc3g7y/X7IVIQvK40oAL5yw== X-Received: by 2002:a17:906:782:b0:a72:75b1:2bf2 with SMTP id a640c23a62f3a-a7514498ab2mr733598366b.36.1720046836794; Wed, 03 Jul 2024 15:47:16 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf18493sm544775966b.7.2024.07.03.15.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:47:16 -0700 (PDT) Date: Wed, 3 Jul 2024 18:47:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ira Weiny , Jonathan Cameron , Fan Ni Subject: [PULL v3 38/85] hw/cxl: Fix read from bogus memory 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Ira Weiny Peter and coverity report: We've passed '&data' to address_space_write(), which means "read from the address on the stack where the function argument 'data' lives", so instead of writing 64 bytes of data to the guest , we'll write 64 bytes which start with a host pointer value and then continue with whatever happens to be on the host stack after that. Indeed the intention was to write 64 bytes of data at the address given. Fix the parameter to address_space_write(). Reported-by: Peter Maydell Link: https://lore.kernel.org/all/CAFEAcA-u4sytGwTKsb__Y+_+0O2-WwARntm3x8WNhvL1WfHOBg@mail.gmail.com/ Fixes: 6bda41a69bdc ("hw/cxl: Add clear poison mailbox command support.") Cc: Jonathan Cameron Signed-off-by: Ira Weiny Message-Id: <20240531-fix-poison-set-cacheline-v1-1-e3bc7e8f1158@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Jonathan Cameron --- hw/mem/cxl_type3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 5d4a1276be..3274e5dcbb 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1292,7 +1292,7 @@ static bool set_cacheline(CXLType3Dev *ct3d, uint64_t dpa_offset, uint8_t *data) dpa_offset -= (vmr_size + pmr_size); } - address_space_write(as, dpa_offset, MEMTXATTRS_UNSPECIFIED, &data, + address_space_write(as, dpa_offset, MEMTXATTRS_UNSPECIFIED, data, CXL_CACHE_LINE_SIZE); return true; } From patchwork Wed Jul 3 22:47:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722974 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 99390C2BD09 for ; Wed, 3 Jul 2024 22:48:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8l9-00058g-Jb; Wed, 03 Jul 2024 18:47: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 1sP8l6-0004oy-9m for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47: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 1sP8l4-0001bL-8M for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046844; 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=KfDnOZZL3lNpO7yBVqmvfyK4tBARWzqdyh5lLLcyyUM=; b=ObU7ne7PfksMdenSirO2i6bQWpTismX3FT+5tWvmoyxOYdCX+zg5Cx0IrpnfaVu4C5neYz OcSu142r6IJ+vCXhUdg6DQuyj7CrPlTvOvyF+xtMuQBa5FT7a9eIIXlTWoc7EHgUph3ZZ7 P4hbx/fl1IT8K26CDyFJUU06S542hgY= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-HDjiA-kUPtKcLHERXSpcoA-1; Wed, 03 Jul 2024 18:47:23 -0400 X-MC-Unique: HDjiA-kUPtKcLHERXSpcoA-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-58c38bcd765so571a12.1 for ; Wed, 03 Jul 2024 15:47:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046841; x=1720651641; 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=KfDnOZZL3lNpO7yBVqmvfyK4tBARWzqdyh5lLLcyyUM=; b=RbYRQ9tItZjGMe8XfX5aec8Cu799gW0qpJ3dE55/Qdyp66zooydf/BsVfttB8dBQj5 zdleqphGO4sjOBlggSyQA6RxQPx4xssrpiIq15S4UaFN+ht6vhM1qmx88B/c3lF6qKvm zSR+NJ35mMDeFfsV0ET5HBal5xbb5EyhT/IMYFm3hE7r5T2/wb9p8AFDi/WqGoNxBw6C oylNxytYNXdRdC0q/bXflHXWXSgvBE27bwFReG3s10kJI0JLGY8tjnFrAD8mTV6zH9bj Y0ao/Eudc++inrx5O6DyM2AxEwm1kK4Z/SV3XtVPSJZaxi8WP/To2zAwExJGPKilo1u3 vbUw== X-Gm-Message-State: AOJu0YyD6Doi2Y2Rf1vEhSOFGkG5bn+bTedrU9/Byq1fFBu1tDnQgymv yvQNj9E34SaiyfSQfGBC4RtBmwJuZMA7PJSAL6cB7teEMq8/l2FBeWOCQvFAgChpKAh3JNHphHV JgciCXxZOH5mIWP4qZXdXOtC+SNlVVG4/BoLLRG9V5hI/ENfW9GIpySOR2pAHtKoi0davTPNcJH Q/XuC7lgNEm+4NI0+5lFnyFp1orWzEJg== X-Received: by 2002:a05:6402:2113:b0:57a:2ccb:b3f2 with SMTP id 4fb4d7f45d1cf-5879f59bc0dmr8842031a12.16.1720046841489; Wed, 03 Jul 2024 15:47:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHqtpYRzqCE5H9Su/cH0xHDWfRFqfsRuGfXq/1nFsEn7AI+uxa0ETm2EpEeJ25aI4C777sezQ== X-Received: by 2002:a05:6402:2113:b0:57a:2ccb:b3f2 with SMTP id 4fb4d7f45d1cf-5879f59bc0dmr8842005a12.16.1720046840911; Wed, 03 Jul 2024 15:47:20 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58dafc1d009sm681778a12.63.2024.07.03.15.47.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:47:20 -0700 (PDT) Date: Wed, 3 Jul 2024 18:47:17 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jiqian Chen , Eduardo Habkost , Marcel Apfelbaum , Philippe =?utf-8?q?Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang Subject: [PULL v3 39/85] virtio-pci: implement No_Soft_Reset bit Message-ID: <5d98e18823af6d5230fca8098a7ee966aaedeb29.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jiqian Chen In current code, when guest does S3, virtio-gpu are reset due to the bit No_Soft_Reset is not set. After resetting, the display resources of virtio-gpu are destroyed, then the display can't come back and only show blank after resuming. Implement No_Soft_Reset bit of PCI_PM_CTRL register, then guest can check this bit, if this bit is set, the devices resetting will not be done, and then the display can work after resuming. No_Soft_Reset bit is implemented for all virtio devices, and was tested only on virtio-gpu device. Set it false by default for safety. Signed-off-by: Jiqian Chen Message-Id: <20240606102205.114671-3-Jiqian.Chen@amd.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-pci.h | 5 +++++ hw/core/machine.c | 1 + hw/virtio/virtio-pci.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index 59d88018c1..9e67ba38c7 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -43,6 +43,7 @@ enum { VIRTIO_PCI_FLAG_INIT_FLR_BIT, VIRTIO_PCI_FLAG_AER_BIT, VIRTIO_PCI_FLAG_ATS_PAGE_ALIGNED_BIT, + VIRTIO_PCI_FLAG_PM_NO_SOFT_RESET_BIT, }; /* Need to activate work-arounds for buggy guests at vmstate load. */ @@ -79,6 +80,10 @@ enum { /* Init Power Management */ #define VIRTIO_PCI_FLAG_INIT_PM (1 << VIRTIO_PCI_FLAG_INIT_PM_BIT) +/* Init The No_Soft_Reset bit of Power Management */ +#define VIRTIO_PCI_FLAG_PM_NO_SOFT_RESET \ + (1 << VIRTIO_PCI_FLAG_PM_NO_SOFT_RESET_BIT) + /* Init Function Level Reset capability */ #define VIRTIO_PCI_FLAG_INIT_FLR (1 << VIRTIO_PCI_FLAG_INIT_FLR_BIT) diff --git a/hw/core/machine.c b/hw/core/machine.c index 655d75c21f..f4cba6496c 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -38,6 +38,7 @@ GlobalProperty hw_compat_9_0[] = { {"arm-cpu", "backcompat-cntfrq", "true" }, {"scsi-disk-base", "migrate-emulated-scsi-request", "false" }, {"vfio-pci", "skip-vsc-check", "false" }, + { "virtio-pci", "x-pcie-pm-no-soft-reset", "off" }, }; const size_t hw_compat_9_0_len = G_N_ELEMENTS(hw_compat_9_0); diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 5941f1a94d..9534730bba 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -2222,6 +2222,11 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp) pcie_cap_lnkctl_init(pci_dev); } + if (proxy->flags & VIRTIO_PCI_FLAG_PM_NO_SOFT_RESET) { + pci_set_word(pci_dev->config + pos + PCI_PM_CTRL, + PCI_PM_CTRL_NO_SOFT_RESET); + } + if (proxy->flags & VIRTIO_PCI_FLAG_INIT_PM) { /* Init Power Management Control Register */ pci_set_word(pci_dev->wmask + pos + PCI_PM_CTRL, @@ -2284,11 +2289,33 @@ static void virtio_pci_reset(DeviceState *qdev) } } +static bool virtio_pci_no_soft_reset(PCIDevice *dev) +{ + uint16_t pmcsr; + + if (!pci_is_express(dev) || !dev->exp.pm_cap) { + return false; + } + + pmcsr = pci_get_word(dev->config + dev->exp.pm_cap + PCI_PM_CTRL); + + /* + * When No_Soft_Reset bit is set and the device + * is in D3hot state, don't reset device + */ + return (pmcsr & PCI_PM_CTRL_NO_SOFT_RESET) && + (pmcsr & PCI_PM_CTRL_STATE_MASK) == 3; +} + static void virtio_pci_bus_reset_hold(Object *obj, ResetType type) { PCIDevice *dev = PCI_DEVICE(obj); DeviceState *qdev = DEVICE(obj); + if (virtio_pci_no_soft_reset(dev)) { + return; + } + virtio_pci_reset(qdev); if (pci_is_express(dev)) { @@ -2328,6 +2355,8 @@ static Property virtio_pci_properties[] = { VIRTIO_PCI_FLAG_INIT_LNKCTL_BIT, true), DEFINE_PROP_BIT("x-pcie-pm-init", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_INIT_PM_BIT, true), + DEFINE_PROP_BIT("x-pcie-pm-no-soft-reset", VirtIOPCIProxy, flags, + VIRTIO_PCI_FLAG_PM_NO_SOFT_RESET_BIT, false), DEFINE_PROP_BIT("x-pcie-flr-init", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_INIT_FLR_BIT, true), DEFINE_PROP_BIT("aer", VirtIOPCIProxy, flags, From patchwork Wed Jul 3 22:47:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 133D2C2BD09 for ; Wed, 3 Jul 2024 22:51:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8lI-0005oU-0G; Wed, 03 Jul 2024 18:47: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 1sP8lF-0005cm-Ne for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47: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 1sP8lC-0001bx-2Z for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046851; 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=LYdZnAc26juhzysGXK6UuvaiCGSQLeNMHoi5Vg2b1dE=; b=hq6AYHuxxYnwsdi29jyyQaZBFZSN2+vHfMNj4w/K1UVnO/FG+IiAPks23CDxVx+xvUc2uK k3nib8/76QxR8xHiGb9tOF/8/jZ3GSzLSlAMhYcaDUqT9mPfUVKSU5sRs3L83bsIBj85hc qim1eS/mLjuKcVThZuv6LwamL4KK4RQ= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-218-3kL2Y8V5Ofq6mggGDQqFBg-1; Wed, 03 Jul 2024 18:47:28 -0400 X-MC-Unique: 3kL2Y8V5Ofq6mggGDQqFBg-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-52cda76173dso5431677e87.2 for ; Wed, 03 Jul 2024 15:47:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046847; x=1720651647; 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=LYdZnAc26juhzysGXK6UuvaiCGSQLeNMHoi5Vg2b1dE=; b=hbFKaS3L6IURLQr6h2IxXMHZdhRz3e5T3GR6KLWbuWy8PYz8A5s4mqKvj38sTQ+zMn qwRkp8Xj0cXgBEcZo9Z5Lzyx6BAqZ8mlLA1GlT4HGizBg2Quqrb3pnFsYMnt/9HsItaP gAIcTbnqkw44MxEavaOTavtFgkYA+dm9JtfBMkpJFkQK1pUJqB9sDjUOK2Zdu++AXzqS nun9l46GIAMSJKNblMgoVLWB9mjR8P/ErNz2Mt4nst1Ed2VbyJAaIdRlj5LAp+i+/OmA T/DZmTcpFvN10gV+vhNT78/kWtMI0ryx1+b5g+MyBcs9roWsvN92dKcurYee7X7sqRD4 lw/g== X-Gm-Message-State: AOJu0Yy8YXz1Rhyp49iFfjdH8rGrigIMZHlyi7co2faKbv5pFvWAy9O8 mZccej0ZGcMp2cenAKZu/5oQ1FX1H96zS4X5qUFPa2j2piicbPTHJ92oxt9hYCqDVJ3vSxOkFaz utFthk9NteFQ8oAuausCGqUcvXIqjZCYhtcRhv/npa7lsfxFaTbt4VjONvrUNEFMf3wuPtwjhQu 7qzO/Ti2MmlytUZvOgh3qqWwh7XoSHHQ== X-Received: by 2002:ac2:5487:0:b0:52e:934f:bda5 with SMTP id 2adb3069b0e04-52e934fbdf5mr2360933e87.21.1720046847024; Wed, 03 Jul 2024 15:47:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZtg+8b7ZwW4Xu+gbxk61NEm7H3iipD5KMEeUFWkNdKVicZ5eh/ox7UMMfuXQmzJa24fOD9Q== X-Received: by 2002:ac2:5487:0:b0:52e:934f:bda5 with SMTP id 2adb3069b0e04-52e934fbdf5mr2360923e87.21.1720046846345; Wed, 03 Jul 2024 15:47:26 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a77ae5bfcddsm39242866b.173.2024.07.03.15.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:47:25 -0700 (PDT) Date: Wed, 3 Jul 2024 18:47:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Yuxue Liu , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL v3 40/85] vhost-user-test: no set non-blocking for cal fd less than 0. 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Yuxue Liu In the scenario where vhost-user sets eventfd to -1, qemu_chr_fe_get_msgfds retrieves fd as -1. When vhost_user_read receives, it does not perform blocking operations on the descriptor with fd=-1, so non-blocking operations should not be performed here either.This is a normal use case. Calling g_unix_set_fd_nonblocking at this point will cause the test to interrupt. When vhost_user_write sets the call fd to -1, it sets the number of fds to 0, so the fds obtained by qemu_chr_fe_get_msgfds will also be 0. Signed-off-by: Yuxue Liu Message-Id: <20240411073555.1357-1-yuxue.liu@jaguarmicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/vhost-user-test.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index d4e437265f..255bde54ab 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -458,7 +458,10 @@ static void chr_read(void *opaque, const uint8_t *buf, int size) case VHOST_USER_SET_VRING_KICK: case VHOST_USER_SET_VRING_CALL: /* consume the fd */ - qemu_chr_fe_get_msgfds(chr, &fd, 1); + if (!qemu_chr_fe_get_msgfds(chr, &fd, 1) && fd < 0) { + qos_printf("call fd: %d, do not set non-blocking\n", fd); + break; + } /* * This is a non-blocking eventfd. * The receive function forces it to be blocking, From patchwork Wed Jul 3 22:47:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 45A52C41513 for ; Wed, 3 Jul 2024 22:50:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8lH-0005jv-5u; Wed, 03 Jul 2024 18:47: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 1sP8lF-0005cE-CG for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47: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 1sP8lD-0001jf-MB for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046855; 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=TisxAqM9JFoRTBzvBR2/yPIkvvWOj6XGjDsm9k9s/20=; b=ahcZkK5Cidr5k1V0oUh3CYppNyHtCFLLj6m5oIFZSZpT6oZjqUqPR6zyOnPuPm7sL2XotF wC1iW41iR8P1hdR2evJLrafKbAnDg1sSQ9ap+E6xRVdqOEFIWVhTqAC2fb1A/ZwjS2xfHL YmFK7KF+VvmfvzaeOednKct/TTrP6gE= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-625-7bZXWk2pPOaeCnMSkdC19A-1; Wed, 03 Jul 2024 18:47:34 -0400 X-MC-Unique: 7bZXWk2pPOaeCnMSkdC19A-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-57d539484ddso4440a12.1 for ; Wed, 03 Jul 2024 15:47:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046852; x=1720651652; 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=TisxAqM9JFoRTBzvBR2/yPIkvvWOj6XGjDsm9k9s/20=; b=GMG3GzVP2fvJr05rtoKE4FIQxUxr2heDHGcZaly/grOGpikDXZlp7EdGwdFS8L02Ha Nr6pwW8uzEDb75m7dU12DT4May77C9gIBPlclNpmcLfecXPWymPPvyy3u257XPZLdLTt HTjWc52Xnnnrk2Lk+8/9133RV86670VbCe0Qd//BHcfaUEkejcrcjDH7H5fMgGFgJSUV A1bMGPCg9SAZxz5zUHoi4cAVKONXbCRcPHZx0UePJx7ljry0yX2J9CxNbEhLdpJnnVb0 gNdG48YyfQPIsz6Iu9pUUoDy0Vyvz+a8Id39gY5FbhmDzb/L7Py5YKpUXuUsijmyxrZN iYvw== X-Gm-Message-State: AOJu0YwFPJwi1cvITj65av87BkkEK9BVCO+RFms8F/xP+USG/wAF8Z25 qNg1wHk+LLb2M/mS7xKo0veZtTbVMI/F8pUATrr7ob7Bc07nwbC3/cYOWtgyFFpBFIftpQDlJNv rfdSopqoQqtqswXNMtiR99W6q7NGKN0ZsQZneqc5wFbfSzClkVBt6lcIIV/XkBo7tvP/LIX6L9y ATm8v00CCDpgGNvgQmL8krXgRsqtTsAw== X-Received: by 2002:a05:6402:c92:b0:58b:fe68:9e51 with SMTP id 4fb4d7f45d1cf-58bfe68a2bdmr2356121a12.35.1720046852418; Wed, 03 Jul 2024 15:47:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXiyx2t40TZhpm/bdjIeIoR2XWhN/Kb/mgEeScw8k0KU1RNlVMs6KXe1nV8dIO8ISFA29EpQ== X-Received: by 2002:a05:6402:c92:b0:58b:fe68:9e51 with SMTP id 4fb4d7f45d1cf-58bfe68a2bdmr2356103a12.35.1720046851239; Wed, 03 Jul 2024 15:47:31 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58612c8371dsm7648617a12.9.2024.07.03.15.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:47:30 -0700 (PDT) Date: Wed, 3 Jul 2024 18:47:26 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhao Liu , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Paolo Bonzini Subject: [PULL v3 41/85] i386/apic: Add hint on boot failure because of disabling x2APIC 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Zhao Liu Currently, the Q35 supports up to 4096 vCPUs (since v9.0), but for TCG cases, if x2APIC is not actively enabled to boot more than 255 vCPUs ( e.g., qemu-system-i386 -M pc-q35-9.0 -smp 666), the following error is reported: Unexpected error in apic_common_set_id() at ../hw/intc/apic_common.c:449: qemu-system-i386: APIC ID 255 requires x2APIC feature in CPU Aborted (core dumped) This error can be resolved by setting x2apic=on in -cpu. In order to better help users deal with this scenario, add the error hint to instruct users on how to enable the x2apic feature. Then, the error report becomes the following: Unexpected error in apic_common_set_id() at ../hw/intc/apic_common.c:448: qemu-system-i386: APIC ID 255 requires x2APIC feature in CPU Try x2apic=on in -cpu. Aborted (core dumped) Note since @errp is &error_abort, error_append_hint() can't be applied on @errp. And in order to separate the exact error message from the (perhaps effectively) hint, adding a hint via error_append_hint() is also necessary. Therefore, introduce @local_error in apic_common_set_id() to handle both the error message and the error hint. Suggested-by: Philippe Mathieu-Daudé Signed-off-by: Zhao Liu Message-Id: <20240606140858.2157106-1-zhao1.liu@intel.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/intc/apic_common.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index d8fc1e2815..c13cdd7994 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -433,6 +433,7 @@ static void apic_common_set_id(Object *obj, Visitor *v, const char *name, APICCommonState *s = APIC_COMMON(obj); DeviceState *dev = DEVICE(obj); uint32_t value; + Error *local_err = NULL; if (dev->realized) { qdev_prop_set_after_realize(dev, name, errp); @@ -444,7 +445,11 @@ static void apic_common_set_id(Object *obj, Visitor *v, const char *name, } if (value >= 255 && !cpu_has_x2apic_feature(&s->cpu->env)) { - error_setg(errp, "APIC ID %d requires x2APIC feature in CPU", value); + error_setg(&local_err, + "APIC ID %d requires x2APIC feature in CPU", + value); + error_append_hint(&local_err, "Try x2apic=on in -cpu.\n"); + error_propagate(errp, local_err); return; } From patchwork Wed Jul 3 22:47:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7679EC31D97 for ; Wed, 3 Jul 2024 22:50:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8lP-0006FS-28; Wed, 03 Jul 2024 18:47: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 1sP8lN-0006Ca-UU for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:45 -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 1sP8lJ-0001t1-6P for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046860; 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=y6iaejVuyK6cotgddPWIYQA8dIBm4KoXB6zsOD2vQwU=; b=JhEWSjAFmJ3FqpmDMhqLPBVrpbpVuogHA4MxjN9qpHXV6SBUwiZp1G/tP2oy8dH2jg49QT t6gUEEX/qHkl/9qjMBZ2O/kkvtAFcXeNKPcxdoTdWeaz2BI5EEZ50XLzJky7SWDNWgMKDd 9Ai8oq/cZ8UswQIqRpWkZZ1heTRfy7Q= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-43-U-3D-YjIOz2MEwcdV25q2w-1; Wed, 03 Jul 2024 18:47:38 -0400 X-MC-Unique: U-3D-YjIOz2MEwcdV25q2w-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-57c93227bbeso2847627a12.3 for ; Wed, 03 Jul 2024 15:47:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046856; x=1720651656; 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=y6iaejVuyK6cotgddPWIYQA8dIBm4KoXB6zsOD2vQwU=; b=JEr0HzyySoMvls1pNHre/fA7xxPf2iexTw4mrUtxZN+KM+OliHXe6oZ1C4n8tgEwfO dTTExFONlDF5pM8Wx8vBboAj7i9/Xmtd9uXY+JI7cfobPk9Xu+chjoCy3rok3lnxlvY+ 3H8euj7+y5k77diXMlOvot3BPcBtTltgQfdW/ctGeDTAS5sDjt59NlrO3pUHmjWp9q38 /ShqPANuFv4ZwCJtiwAI9bWqENuRiVIyY1yotQhxzTXZrx50GJCnxdOF3KFK0lLQZ8/7 pzB79xzytPuG8G1ycbLZQ1d/pIRcs3w3gvOcZ/O+dDQhoGZuUJC7+jgmYaSLRV2bEVDh idkA== X-Gm-Message-State: AOJu0YxLUE8iBRxJkvU23umDtSjT18+TZBNw64jNN50j+qhu8G5uRKoV 4NVGBEWwXmdViR1oYxU8xG0rpZjp7nMjRA/Y1vt+PfwJANtUXikZSVVjim84IrM1JPk15UejPP3 jzn8To4ezPOWDy6T9fKGFU2duZBu3w5aKocjx7ZbUgG/+aysYT4ON1uVCEHNj/hhZoE3XqAAIa8 JevMLAbI8PudgZAk+UZ4ItgKIO5K33mg== X-Received: by 2002:a17:907:1ca0:b0:a75:100a:7966 with SMTP id a640c23a62f3a-a7514419725mr1110446766b.1.1720046856266; Wed, 03 Jul 2024 15:47:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGHtGX/WuSUUSmSVxT8AYAPdIj/WcNwtqXJ7GqrO2j/GS7QYr+p9QPWp/2gJnt7ECL8KbiNg== X-Received: by 2002:a17:907:1ca0:b0:a75:100a:7966 with SMTP id a640c23a62f3a-a7514419725mr1110445266b.1.1720046855642; Wed, 03 Jul 2024 15:47:35 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a77af07bd1bsm36213166b.172.2024.07.03.15.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:47:35 -0700 (PDT) Date: Wed, 3 Jul 2024 18:47:31 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL v3 42/85] hw/virtio: Free vqs after vhost_dev_cleanup() Message-ID: <25b8a0f40c7f408442c5fd4da195fce9997cfb78.1720046570.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: -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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Akihiko Odaki This fixes LeakSanitizer warnings. Signed-off-by: Akihiko Odaki Message-Id: <20240627-san-v2-7-750bb0946dbd@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user-base.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/vhost-user-base.c b/hw/virtio/vhost-user-base.c index 11e72b1e3b..2bc3423326 100644 --- a/hw/virtio/vhost-user-base.c +++ b/hw/virtio/vhost-user-base.c @@ -223,6 +223,7 @@ static void vub_disconnect(DeviceState *dev) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VHostUserBase *vub = VHOST_USER_BASE(vdev); + struct vhost_virtqueue *vhost_vqs = vub->vhost_dev.vqs; if (!vub->connected) { goto done; @@ -231,6 +232,7 @@ static void vub_disconnect(DeviceState *dev) vub_stop(vdev); vhost_dev_cleanup(&vub->vhost_dev); + g_free(vhost_vqs); done: /* Re-instate the event handler for new connections */ From patchwork Wed Jul 3 22:47:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723011 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37212C31D97 for ; Wed, 3 Jul 2024 22:51:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8lQ-0006Lt-Mg; Wed, 03 Jul 2024 18:47:48 -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 1sP8lP-0006Fo-89 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:47 -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 1sP8lN-0001yl-FV for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046863; 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=f1RnRBcwUZd5byR6UedM+mwZMcF5dchy820Keg4IB1o=; b=jIg29T0nQdx/vBqSySmm5NESYfBHE92i1LLfDcbb7m/lqVftofepqnqOz+Mau4pWl/FPzn zAiZlHw5azfFV85aU2TFwVIvYEEzRSPIl84ckpCh/0ZtjAdkdSJj9xYfMf1TqjxghZ7evE Rm571E2cAL5HK1b9U6HG6oiJFXAeVrQ= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-ElRzljU7NOuDcNr_xasF0A-1; Wed, 03 Jul 2024 18:47:42 -0400 X-MC-Unique: ElRzljU7NOuDcNr_xasF0A-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-52ce7a15a62so6360329e87.3 for ; Wed, 03 Jul 2024 15:47:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046861; x=1720651661; 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=f1RnRBcwUZd5byR6UedM+mwZMcF5dchy820Keg4IB1o=; b=d7andKQs6seXXyD5oY1wswAboUBoyxfEI2lMRN9woGuLhu1rga2iOXfn8mqznae9f2 t6+R63ZVcxi5hdpy9mnayMmPCXXKsqIiipYlsUruTMbKE0JTydjgBpPllxG5+5k7b3tB YvY1/KKVeT6QMLDMs/RSzac5CPKZfunIdqkCbf3uqBphD5NJVbkilpZhpUKk/5U39Mc3 zXEIB+hrs8CBLTXKrCSGIqLrdk+4mRDL3t7RVLN1HOi9N6QTcj/UU+r/m17p7Df0S+LN agfSp71VSuNb4KakSVyqrB0rZ6RJgQZumMJ/JJ2l56HAoXurIk9gh4UuP41mrYGwqlYf 39ww== X-Gm-Message-State: AOJu0YzOzpFKc0jyCbYJnw6IOo9SaseAONk9LJoOxRBhpjBiNV8FPJOS 3OPOMiTaDaujoTQ72VKMxam9mVjiQfgQYkfwemzbW4wuDvo6rNXxpnP/eYaEZZ1IpfE3elY3m1a ve0YXV2xi1Bye6S2ok3ak3D1V0zYyaN2MsYd1U+FJCVynazgj+PoPQszMqpK/ntarvBy1aLcJNP 0njjjJbG0NFhQmH1JjFexf9GQkdH+gTQ== X-Received: by 2002:a05:6512:104c:b0:52c:e133:7b2e with SMTP id 2adb3069b0e04-52e8268b956mr8673589e87.35.1720046860963; Wed, 03 Jul 2024 15:47:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFOFyv9bE/A2/4QPauIzJPfpNAjXyFMaCGFIXPPZdL1FvIMdqSIufgqUtSGivODNvqiGZbbzg== X-Received: by 2002:a05:6512:104c:b0:52c:e133:7b2e with SMTP id 2adb3069b0e04-52e8268b956mr8673570e87.35.1720046860184; Wed, 03 Jul 2024 15:47:40 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58de4581536sm469309a12.16.2024.07.03.15.47.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:47:39 -0700 (PDT) Date: Wed, 3 Jul 2024 18:47:36 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Manos Pitsidianakis , Zheyu Ma , Eric Auger Subject: [PULL v3 43/85] virtio-iommu: add error check before assert Message-ID: <704391f94a5494f10b886ba79c157363a79b1239.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Manos Pitsidianakis A fuzzer case discovered by Zheyu Ma causes an assert failure. Add a check before the assert, and respond with an error before moving on to the next queue element. To reproduce the failure: cat << EOF | \ qemu-system-x86_64 \ -display none -machine accel=qtest -m 512M -machine q35 -nodefaults \ -device virtio-iommu -qtest stdio outl 0xcf8 0x80000804 outw 0xcfc 0x06 outl 0xcf8 0x80000820 outl 0xcfc 0xe0004000 write 0x10000e 0x1 0x01 write 0xe0004020 0x4 0x00001000 write 0xe0004028 0x4 0x00101000 write 0xe000401c 0x1 0x01 write 0x106000 0x1 0x05 write 0x100001 0x1 0x60 write 0x100002 0x1 0x10 write 0x100009 0x1 0x04 write 0x10000c 0x1 0x01 write 0x100018 0x1 0x04 write 0x10001c 0x1 0x02 write 0x101003 0x1 0x01 write 0xe0007001 0x1 0x00 EOF Reported-by: Zheyu Ma Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2359 Signed-off-by: Manos Pitsidianakis Message-Id: <20240613-fuzz-2359-fix-v2-manos.pitsidianakis@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index b9a7ddcd14..ed7426afc7 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -974,6 +974,9 @@ static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq) iov = elem->out_sg; sz = iov_to_buf(iov, iov_cnt, 0, &head, sizeof(head)); if (unlikely(sz != sizeof(head))) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: read %zu bytes from command head" + "but expected %zu\n", __func__, sz, sizeof(head)); tail.status = VIRTIO_IOMMU_S_DEVERR; goto out; } @@ -1010,6 +1013,25 @@ static void virtio_iommu_handle_command(VirtIODevice *vdev, VirtQueue *vq) out: sz = iov_from_buf(elem->in_sg, elem->in_num, 0, buf ? buf : &tail, output_size); + if (unlikely(sz != output_size)) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: wrote %zu bytes to command response" + "but response size is %zu\n", + __func__, sz, output_size); + tail.status = VIRTIO_IOMMU_S_DEVERR; + /* + * We checked that sizeof(tail) can fit to elem->in_sg at the + * beginning of the loop + */ + output_size = sizeof(tail); + g_free(buf); + buf = NULL; + sz = iov_from_buf(elem->in_sg, + elem->in_num, + 0, + &tail, + output_size); + } assert(sz == output_size); virtqueue_push(vq, elem, sz); From patchwork Wed Jul 3 22:47:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723042 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2D2EDC2BD09 for ; Wed, 3 Jul 2024 22:53:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8lV-0006WC-UG; Wed, 03 Jul 2024 18:47:53 -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 1sP8lT-0006QY-19 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:52 -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 1sP8lR-0002GP-1I for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046868; 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=iKFeowSJAGhilDZfxfLdJ5fHZQGvWfI2BMoyWfTY0Wo=; b=bo7FKmbbc1G0KaxeCRlvOw9ACUdpeRXf2UsxsxjqY3a7cgSFCgbDDt7oNq9dp/KRzcVQsU bqNTn4J8uTnie/wdl+6cpBF71d6cjdLKsJ5eBBYFGIczg4ACLJmRkr0bfogYYjPdMbbueZ F1pZGg6Ox0YDRntKmTY2VxafBH5/h34= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-298-KmtqptZANoO0JclCX1T86g-1; Wed, 03 Jul 2024 18:47:47 -0400 X-MC-Unique: KmtqptZANoO0JclCX1T86g-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a72b3066669so9667266b.0 for ; Wed, 03 Jul 2024 15:47:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046865; x=1720651665; 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=iKFeowSJAGhilDZfxfLdJ5fHZQGvWfI2BMoyWfTY0Wo=; b=odMf74fbwOfTwWdcDcIpI9e/gameFjpZpa5bZO4az3hGg5U0aYDWOUv5ACT8O+bN/k yBrb4DDuj5agbETRzIZ4sW/sin3Br5c6td3xGIi+HJjTl4Vk2rx6pLcPDhVgd0fSFZB+ L34/J4FkMw0pZ1RPRKDNuqSs82CFt0sr6GFkFAB3T4J01C2h0ZKSqzOQDBqitZ3omzlX pdpqFeFvHdOUkfwdHq32769Tr3UGxeu193d8EfDBp1Ne1X3E+xW/B5tkX/aslVnSWE8v 5HNPXO+fKGMABtr/40DVhPt6SiIiXs/1PFDNNyBlFrLHA8xq95xKArR4MwmcH33PhoW0 aHIg== X-Gm-Message-State: AOJu0YwxOlxVPvnZpg7HnRKCPtnfvqZickd+qb2sdYQGa6s35XanjzW2 Sb/Azk5n5twe48tvkDhlkpBzc9Dd4xeVvOSnKCq9AiIqISO2kyLj5QtIYaaaoMcnAmBe49WxK1/ tF0hItq6xvSr0V/KNUZ1tK0s3n8UtvJ57f0cMSA/nRh4XAQR40zBZYwBHYFs4JMsj3drGKaP0RH fcfVIBAfzs7fUbZ9YnLAXr3KkwSJWHAA== X-Received: by 2002:a17:906:f253:b0:a77:a1f1:cfa0 with SMTP id a640c23a62f3a-a77a24bf96bmr190866066b.36.1720046865683; Wed, 03 Jul 2024 15:47:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFt2C9AeF7MAAHhDNoynI8ekEyZnCbl/v3ZvJszo1gwJJSLEtFbwPtTGbeBmVKxzpuRZbD0/A== X-Received: by 2002:a17:906:f253:b0:a77:a1f1:cfa0 with SMTP id a640c23a62f3a-a77a24bf96bmr190864566b.36.1720046864904; Wed, 03 Jul 2024 15:47:44 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab08d0dcsm542426866b.166.2024.07.03.15.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:47:44 -0700 (PDT) Date: Wed, 3 Jul 2024 18:47:40 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , BillXiang Subject: [PULL v3 44/85] vhost-user: Skip unnecessary duplicated VHOST_USER_SET_LOG_BASE requests Message-ID: <7c211eb078c42146ee9a441cc028fbc4c378ef5a.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: BillXiang The VHOST_USER_SET_LOG_BASE requests should be categorized into non-vring specific messages, and should be sent only once. If send more than once, dpdk will munmap old log_addr which may has been used and cause segmentation fault. Signed-off-by: BillXiang Message-Id: <20240613065150.3100-1-xiangwencheng@dayudpu.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- 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 c407ea8939..00561daa06 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -371,6 +371,7 @@ static bool vhost_user_per_device_request(VhostUserRequest request) case VHOST_USER_RESET_DEVICE: case VHOST_USER_ADD_MEM_REG: case VHOST_USER_REM_MEM_REG: + case VHOST_USER_SET_LOG_BASE: return true; default: return false; From patchwork Wed Jul 3 22:47:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722984 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD98CC2BD09 for ; Wed, 3 Jul 2024 22:49:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8lZ-0006Zj-6a; Wed, 03 Jul 2024 18:47: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 1sP8lX-0006Ym-3D for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47: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 1sP8lU-0002Zq-HN for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:47:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046872; 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=pgJQy7t094Dms9DBv10pUkz+7onKHwqzjJeEHsSRcQk=; b=KhZClW9J6+9nCmPdk/xPbzcSyR32Oqwhwacyy03IgCWayqFxiGMzfSZdnykmHr604s8h6A EoICniw77InRAcizGslq3uuXqcQ8Ta08dtEJCIRLVlmy4IVakKta9oO5HF5zafjHX/6xQ/ iCEyPMTxR5hym08t9WvUPETKRQ0ACTg= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-472-bGFmHej4M--So3VSl5Z7mA-1; Wed, 03 Jul 2024 18:47:50 -0400 X-MC-Unique: bGFmHej4M--So3VSl5Z7mA-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a77b2edfe06so1684266b.0 for ; Wed, 03 Jul 2024 15:47:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046869; x=1720651669; 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=pgJQy7t094Dms9DBv10pUkz+7onKHwqzjJeEHsSRcQk=; b=dtjYMh/bVOYIdiqmcBJ2wtoBLvgQrf8Yi5tqNtC1ZwcGY6DwmvXx0Q/e/VLQL28W9W WZ6D7A0vVub2xnd/pkYRPkbHVo7Lj3wRezFxBEq8FKmy1BYr//k6kUlio4+tTF0S+skn nOqP/vdjvsjQ6Nzw4xvltsIj+7MGMgVzc8XkzhlNDng5+El6sm5AHwrYzsTSzZYXAmz8 Bh4HvHwsBOMmZaL0C5qf3m87iX2iluvy7LaeQwb2wgbAJhm4DdfUT2U50fXg6xDMhHY3 IfAZxXzc7TvvYobgTOoY83nh1FHpw7JdgDkkrd5EQvRvvCdFGwbfJKZgeCEc9srS4BjN N99g== X-Gm-Message-State: AOJu0Yw5HjE/qtGp/XXg99QzY3QdapPq26srPcqBjyjX9lJDbGsBr2xw xJbmPG1ada2HdzGn3bHrdOt089YrwvtpwNVqi9/NLCBsuPmPUjlnOXTRwqCuz+e6rilOQ3Jg0AZ kG4vehgFZFsYN8LaQ6n2CGmE4kUlMs0IBrrh8s8dX8/1A05uMRFI0GySd5MvaS6FFOSH7hNtUhh jqecifzBfcngWaV+Xz+49anJCKrKfb7g== X-Received: by 2002:a17:906:bc90:b0:a72:8296:ca1f with SMTP id a640c23a62f3a-a75144a916emr746671566b.50.1720046869324; Wed, 03 Jul 2024 15:47:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgRJSMC3QzbTGARJ91rozWLwkA96WxT8m3Vv/tE7ScxrC2cOGvnaGMeO55TC+uXiA3FPtyaA== X-Received: by 2002:a17:906:bc90:b0:a72:8296:ca1f with SMTP id a640c23a62f3a-a75144a916emr746670566b.50.1720046868774; Wed, 03 Jul 2024 15:47:48 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab0652c6sm546779866b.109.2024.07.03.15.47.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:47:48 -0700 (PDT) Date: Wed, 3 Jul 2024 18:47:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Dmitry Frolov , Jason Wang Subject: [PULL v3 45/85] hw/net/virtio-net.c: fix crash in iov_copy() 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Dmitry Frolov A crash found while fuzzing device virtio-net-socket-check-used. Assertion "offset == 0" in iov_copy() fails if less than guest_hdr_len bytes were transmited. Signed-off-by: Dmitry Frolov Message-Id: <20240613143529.602591-2-frolov@swemel.ru> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/net/virtio-net.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 9c7e85caea..8f30972708 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -2735,6 +2735,10 @@ static int32_t virtio_net_flush_tx(VirtIONetQueue *q) */ assert(n->host_hdr_len <= n->guest_hdr_len); if (n->host_hdr_len != n->guest_hdr_len) { + if (iov_size(out_sg, out_num) < n->guest_hdr_len) { + virtio_error(vdev, "virtio-net header is invalid"); + goto detach; + } unsigned sg_num = iov_copy(sg, ARRAY_SIZE(sg), out_sg, out_num, 0, n->host_hdr_len); From patchwork Wed Jul 3 22:47:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723030 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E9DD6C2BD09 for ; Wed, 3 Jul 2024 22:51:58 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8lu-0007qW-7q; Wed, 03 Jul 2024 18:48: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 1sP8ls-0007kq-PF for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:16 -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 1sP8lc-0002zB-Tb for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046879; 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=UGyASDiFbODYa7hIKIzPzDlV0Bv9TAjx5HfpD5vtANQ=; b=ROcXKIAFzULHY9q0/arcs0MqoMEzARO37amDh3sSgOe2n9TF7ncKOIsEHTHyIwtR0/lpnM VJFsytHS9O8RrDCG09hSz1XUZFJSDr1nuohDwpkGgDVddwho7YqwfW4qq0fxw9meiXjDqG wGfXX2CLcLQYNBBfTIzuOMIozSVmAoY= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-352-p2RyT2TIN7-HR1ZlKBbA5g-1; Wed, 03 Jul 2024 18:47:57 -0400 X-MC-Unique: p2RyT2TIN7-HR1ZlKBbA5g-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-57851ae6090so2669554a12.3 for ; Wed, 03 Jul 2024 15:47:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046876; x=1720651676; 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=UGyASDiFbODYa7hIKIzPzDlV0Bv9TAjx5HfpD5vtANQ=; b=w9AhXB2TZbEaaWWBdeFmdC5754/OgPMQP8m3qgjXuAhplKXOK/v5D6Dm9lEOrjcG8v ypZYILn4JJt7BmhQ1q4RkpP5jXh9P+tR1ax13o/8hMxJKkOFGh7Hx/WRVBrgk2jcQ832 zJbqDHgUDKFneyeAPFYV234DWqfDY7KHr/2SGdx2FOXmKqKrEpI5Z3ZSsCa7jDSr0roE YVH4my1zlrI2kJIOuGlFr2D/l+bBEvV01wBKely0Qr4qPw0M4g5GdTLEjaqfTkAW22Bd rYsKAmhKvyis+iqSmAsctt6EOX2QuQiqhuk1jTGR0wQKntep+Z26EGgOCN4haMypNYqi Qaow== X-Gm-Message-State: AOJu0Yy8X4Gwb3DqSl20qGt2CFebiQvj9L48zy6XzwpB9VycFeP11SyU Zia5iFEEtGrRuFEmsTgRnr0X/CuL40FZ4B2RmCijqQf09q9jWGkzAr0AAiBr/TQQcds/fwssB5e HmNkSwsDF94W1Q62QI2tHVi//mCtwUFam+mYB6NaeCdrzndIg0cdt6/0Ea4QHhU/ZnYh8PLAj2Q 7kWW7Fyv6vQrXmYlNCrGrLBZv795WhcA== X-Received: by 2002:a05:6402:34d5:b0:57c:7ed7:897a with SMTP id 4fb4d7f45d1cf-587a0635e59mr9511008a12.27.1720046876108; Wed, 03 Jul 2024 15:47:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFddIdSxHvSZopxh2efHwEdaQjBLMxvfF26rQtKChqYpQvHtnDe4DGhezKvxkfjrjbZnzJKqw== X-Received: by 2002:a05:6402:34d5:b0:57c:7ed7:897a with SMTP id 4fb4d7f45d1cf-587a0635e59mr9510990a12.27.1720046875537; Wed, 03 Jul 2024 15:47:55 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58612c835dfsm7620813a12.20.2024.07.03.15.47.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:47:55 -0700 (PDT) Date: Wed, 3 Jul 2024 18:47:49 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , David Hildenbrand , Markus Armbruster , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Paolo Bonzini , Daniel =?utf-8?b?UC4gQmVycmFuZ8Op?= , Eduardo Habkost , Eric Blake Subject: [PULL v3 46/85] qapi: clarify that the default is backend dependent Message-ID: <0aa7f10c7af222a32e49e38df8383e394a0aa5c3.1720046570.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stefano Garzarella The default value of the @share option of the @MemoryBackendProperties really depends on the backend type, so let's document the default values in the same place where we define the option to avoid dispersing the information. Cc: David Hildenbrand Suggested-by: Markus Armbruster Reviewed-by: Markus Armbruster Signed-off-by: Stefano Garzarella Message-Id: <20240618100043.144657-2-sgarzare@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/qom.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/qapi/qom.json b/qapi/qom.json index 8bd299265e..9b8f6a7ab5 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -600,7 +600,9 @@ # preallocation threads (default: none) (since 7.2) # # @share: if false, the memory is private to QEMU; if true, it is -# shared (default: false) +# shared (default false for backends memory-backend-file and +# memory-backend-ram, true for backends memory-backend-epc and +# memory-backend-memfd) # # @reserve: if true, reserve swap space (or huge pages) if applicable # (default: true) (since 6.1) @@ -700,8 +702,6 @@ # # Properties for memory-backend-memfd objects. # -# The @share boolean option is true by default with memfd. -# # @hugetlb: if true, the file to be created resides in the hugetlbfs # filesystem (default: false) # @@ -726,8 +726,6 @@ # # Properties for memory-backend-epc objects. # -# The @share boolean option is true by default with epc -# # The @merge boolean option is false by default with epc # # The @dump boolean option is false by default with epc From patchwork Wed Jul 3 22:47:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722983 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44567C2BD09 for ; Wed, 3 Jul 2024 22:49:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8lu-0007sJ-HO; Wed, 03 Jul 2024 18:48: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 1sP8lt-0007oA-Cd for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48: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 1sP8li-00039u-7l for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046884; 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=9Yh+r83dQTqjKVESuK/txPttml/pXNBlxCl8GGxw4h4=; b=V0ANs8c0Dq/pSNrHtSKaCJ49VsfycLELhGcU/k5WjcaQMvkKG+q8wBYfMNT6S/LdV5Vmoi kUfg7Dkl7iP70J3vd5vcc0rOQYiJXPXQaACPxDkeCyaAnkfbJfz8I7WSHOY6iWeNwZ6s2/ DeA5/RZ1NrH+ozvY4YVfJv8zpG6SlCE= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-397-k645Jv5NPWiPjlsFVPr7xA-1; Wed, 03 Jul 2024 18:48:03 -0400 X-MC-Unique: k645Jv5NPWiPjlsFVPr7xA-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-52e9b943e6dso634717e87.2 for ; Wed, 03 Jul 2024 15:48:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046881; x=1720651681; 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=9Yh+r83dQTqjKVESuK/txPttml/pXNBlxCl8GGxw4h4=; b=LMcWCDZMMP0VzGHVG44qrH3X+nrWYXYFuRWVschb43Ufp7Y5qbzbd6RYE24fbwn0iq 2Lp4AY+uVyW2Lt5oo+y8r/+4lkiGUSH9eMRMnOQsnMxBgIyrRLVXHfxKYtrFKB8466y7 mkSJmiam9pReIwEsTbTkg/QQBHlRQUxnIaD4oG41bTe1LiuVdiFUjg/OrYKf+ZUqMxD3 KspAni56SVefs2A1wGeltc49FvvIn9H/p5nsnvV+RM5tvm6d2f38ppxePVAo7WkMbBh3 kSMSfz1AyF4E0uj5MMSl5C5NdmGi27iVyGA3TngAMM1v1E4z6PrFQa+splCpmAzzADh7 THzw== X-Gm-Message-State: AOJu0Ywm2LoocdhtCb7/kAH1JqXL741LsVkxREcP5iZbFwzRm4PqTQ/9 b2nx8Ihcgt6Wd5SwnmP5rqegzrXjvjUcycsyPeg8n3jXp8A2355fgwsYwvpHx1UHCOZv4iacAPJ uEdvzLLE32/9yqQHfqRLrIKyNuoKyQUvJx7qqB65Ok4dtmp9WZU1w+uVPoU5xD0kXCzi1WZ/Vt7 n4Vw8l0AuC4vao27/o8YasuZC6tOTxgQ== X-Received: by 2002:a05:6512:1111:b0:52c:a724:5ae3 with SMTP id 2adb3069b0e04-52e8270b916mr7904370e87.51.1720046881296; Wed, 03 Jul 2024 15:48:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFD+bSZN+ET+IwHWLsTiUzQwRdIfXJyYn1vUutJOdiKLqhbpFXw1rE9p4NLNecJhHcKv9pMCQ== X-Received: by 2002:a05:6512:1111:b0:52c:a724:5ae3 with SMTP id 2adb3069b0e04-52e8270b916mr7904355e87.51.1720046880510; Wed, 03 Jul 2024 15:48:00 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58612c838casm7685331a12.4.2024.07.03.15.47.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:48:00 -0700 (PDT) Date: Wed, 3 Jul 2024 18:47:55 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , Eric Blake , David Hildenbrand , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Stefan Hajnoczi Subject: [PULL v3 47/85] libvhost-user: set msg.msg_control to NULL when it is empty Message-ID: <516dfbb783484959cf33f051864f2e44cbed45ca.1720046570.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, T_SPF_TEMPERROR=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stefano Garzarella On some OS (e.g. macOS) sendmsg() returns -1 (errno EINVAL) if the `struct msghdr` has the field `msg_controllen` set to 0, but `msg_control` is not NULL. Reviewed-by: Eric Blake Reviewed-by: David Hildenbrand Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Acked-by: Stefan Hajnoczi Signed-off-by: Stefano Garzarella Message-Id: <20240618100043.144657-3-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c index 8adb277d54..53bf1adda6 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -632,6 +632,7 @@ vu_message_write(VuDev *dev, int conn_fd, VhostUserMsg *vmsg) memcpy(CMSG_DATA(cmsg), vmsg->fds, fdsize); } else { msg.msg_controllen = 0; + msg.msg_control = NULL; } do { From patchwork Wed Jul 3 22:48:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723048 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AA418C2BD09 for ; Wed, 3 Jul 2024 22:53:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8lv-00082K-BK; Wed, 03 Jul 2024 18:48: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 1sP8lt-0007oR-JG for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48: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 1sP8lk-0003L4-KL for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046888; 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=scNChYFZ1BVuw6o3t83CBrfTE58zls/yBMV5gH+83JU=; b=NgMjOeQ0K4cD6/o/bfVEqWKc6xaXA2dum5OiV//AhGx2OeTabgAfB0vOH1DzbizRPKVCvl 4U6MDyuMvlI+MFv0+CrOZfUwtFdZ0nkmHMqt2tN+VyHMrcs/84NxT+39cA0XZFvyZi3PZU JR8bwzmfFoW7FWCRnkgAINWiTmtfNC0= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-158-I2XGo_AvNse_UfcwiEdJCw-1; Wed, 03 Jul 2024 18:48:07 -0400 X-MC-Unique: I2XGo_AvNse_UfcwiEdJCw-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-58d152f7f67so3253a12.1 for ; Wed, 03 Jul 2024 15:48:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046885; x=1720651685; 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=scNChYFZ1BVuw6o3t83CBrfTE58zls/yBMV5gH+83JU=; b=Tlt157/pUMrkyw1Mz4SDedBQfrDma9/ssYZVGeu7GBFFlLThtgUrOz1mAWRFjyQPpW nLUUR8vRZo6eh+F5NEh/VYR3020vl2Y2yX34C9077c1dgEfNVZQYAjb9VGzhKiaDpzve 6aHa8ql6CxKXt8FpNCNBexrHC4gS54quy4Q3SKXUPxUYbnyE6NA/6Svz67Gt4Dhk2tRH e6kdTRjv4ht0M5/7PCk5Vnvf7hOVK/VFJSKPAO8nHN4sJteC5gaM8xJQS1WkghkJMZEr 3D3PhG5q8ROr5UPr5yts5Sub11BLDY11ymqZjfY8KqYlVCT+8NGTSXo4ZOfYFMvltmdi SNOw== X-Gm-Message-State: AOJu0Yxj0bncnhH1wUHCZb+xOOjZ9adU0tmH+u3OwCEcJbKfgs2B0reK TekepoEVTCkgoMjRlbtMcvyxz1MHD9u0kTfki4JMd1JIctfBiGs/k2OVANqMtiOw8ehNJp1nHX1 O8twglzbe6qkLocS241sde/MFp56LE5pzgvpRbteuR7W2Pa6ulanXhxkVpncxrDgna5kpoItAVo RRbqfwY0IIzzHEzxJ+sb4s+jry/XcF4Q== X-Received: by 2002:a05:6402:50cb:b0:57c:80bf:9267 with SMTP id 4fb4d7f45d1cf-5879ede2ab6mr10478060a12.6.1720046885600; Wed, 03 Jul 2024 15:48:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTuRyAhNOe+KY4BzSb/gPd1hPUPDh7S5yzsm9XCPAOXJMOKieHxXzKJi8dxh5LiSyd/YNNbw== X-Received: by 2002:a05:6402:50cb:b0:57c:80bf:9267 with SMTP id 4fb4d7f45d1cf-5879ede2ab6mr10478034a12.6.1720046884898; Wed, 03 Jul 2024 15:48:04 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58d10ef413esm1261827a12.66.2024.07.03.15.48.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:48:04 -0700 (PDT) Date: Wed, 3 Jul 2024 18:48:00 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , Daniel P =?utf-8?b?LiBCZXJyYW5n?= =?utf-8?b?w6k=?= , Philippe =?utf-8?q?Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Stefan Hajnoczi , David Hildenbrand Subject: [PULL v3 48/85] libvhost-user: fail vu_message_write() if sendmsg() is failing Message-ID: <92b58bc7e9086e489295040d408118a81c47b31d.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stefano Garzarella In vu_message_write() we use sendmsg() to send the message header, then a write() to send the payload. If sendmsg() fails we should avoid sending the payload, since we were unable to send the header. Discovered before fixing the issue with the previous patch, where sendmsg() failed on macOS due to wrong parameters, but the frontend still sent the payload which the backend incorrectly interpreted as a wrong header. Reviewed-by: Daniel P. Berrangé Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Acked-by: Stefan Hajnoczi Reviewed-by: David Hildenbrand Signed-off-by: Stefano Garzarella Message-Id: <20240618100043.144657-4-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c index 53bf1adda6..ea27683dac 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -639,6 +639,11 @@ vu_message_write(VuDev *dev, int conn_fd, VhostUserMsg *vmsg) rc = sendmsg(conn_fd, &msg, 0); } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); + if (rc <= 0) { + vu_panic(dev, "Error while writing: %s", strerror(errno)); + return false; + } + if (vmsg->size) { do { if (vmsg->data) { From patchwork Wed Jul 3 22:48:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C31F5C31D97 for ; Wed, 3 Jul 2024 22:53:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8lx-0008HR-IH; Wed, 03 Jul 2024 18:48:21 -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 1sP8lt-0007ob-Pa for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48: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 1sP8lq-0003Um-Ho for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046893; 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=QrTyYgO+P/l4LBdE4jQm9EUMOljixFZgw03WGI4si6s=; b=e0afm35x2Dh5wCFs+8mzfmPJcwwN0K7uQBeGnr3lBitBqx+Iyk9/rxyOeAY3VO/PqO4Uw/ CN/LQ/RukjkQf8QqzJZk5/Rlq2VkEyM+LSOxSo6MIpEw2Qq70rlJeOT/7/TVa/o9d6CF9v LrIMPUpUjiziBMvJAjvC4RrxmVGcAQY= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-460-KcfLPtAVMDeyexIL6xLxGw-1; Wed, 03 Jul 2024 18:48:12 -0400 X-MC-Unique: KcfLPtAVMDeyexIL6xLxGw-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a6fe837c066so9030066b.1 for ; Wed, 03 Jul 2024 15:48:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046890; x=1720651690; 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=QrTyYgO+P/l4LBdE4jQm9EUMOljixFZgw03WGI4si6s=; b=KY6w+IOcdcF8J05o+2SzrjaCyNb2qFoMP68z23htHTuPINsihowipBAWr8oPhpuVnr WSsXKQIbNof6j8N4TxirJcNhBTFKvhu/faF4fBs/3UOi3OcyURB/m/la//6V8RA0Tp97 NFbcDtG6V8Cpq69sj64GZb2F7+KxiNBStXpMsgy1wAJaix6h1VBtTWzLef3dFmz9CQmb H0qF7Afl7ZZKbHuXdGqW7EruO0azzGKrhpEtdvY2DgJS6CKjHZYzRqqXkMOsMXV0Y1+8 N4tyBR28AYlE1cf9YBAZ3jn67hlxvr0UqqnktSTc3XavET+2Ko6J3n0L6OI49+YAWXAb hdbw== X-Gm-Message-State: AOJu0YwNE/Utbt85rkeePDThmrF5RFIw0sObAFB0wCr5w8c0fOHFqpe4 qgHpV0l0qtTjGBcSpiT4DAIOw8jfHWMdBkQkYo9yEUpv6lWIMiZB48KQ6mIyEtqfpK3aqZiTjqV 9SqiWCzWHfbW6J8/9XmxdT/tWedNGSrv3zlRxajRH7otam47eItNBfLHRjzY6VJqmDOu2CAGIrv cJZEd6P8mbo6/Di9noW+G1eoiJbPHxUg== X-Received: by 2002:a17:906:a259:b0:a6f:dd93:7ffb with SMTP id a640c23a62f3a-a77a2404383mr193536566b.1.1720046890242; Wed, 03 Jul 2024 15:48:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHig2bzfs8B101b6zoi98QMSZGI61PWTDRQjv0sU+bCjptEC+Uu7uhrnDLaOdxxA241+roeXA== X-Received: by 2002:a17:906:a259:b0:a6f:dd93:7ffb with SMTP id a640c23a62f3a-a77a2404383mr193534866b.1.1720046889731; Wed, 03 Jul 2024 15:48:09 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58612c835cfsm7582950a12.14.2024.07.03.15.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:48:09 -0700 (PDT) Date: Wed, 3 Jul 2024 18:48:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , Philippe =?utf-8?q?Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Stefan Hajnoczi , David Hildenbrand Subject: [PULL v3 49/85] libvhost-user: mask F_INFLIGHT_SHMFD if memfd is not supported 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stefano Garzarella libvhost-user will panic when receiving VHOST_USER_GET_INFLIGHT_FD message if MFD_ALLOW_SEALING is not defined, since it's not able to create a memfd. VHOST_USER_GET_INFLIGHT_FD is used only if VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD is negotiated. So, let's mask that feature if the backend is not able to properly handle these messages. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Acked-by: Stefan Hajnoczi Reviewed-by: David Hildenbrand Signed-off-by: Stefano Garzarella Message-Id: <20240618100043.144657-5-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- subprojects/libvhost-user/libvhost-user.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c index ea27683dac..9c630c2170 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -1674,6 +1674,17 @@ vu_get_protocol_features_exec(VuDev *dev, VhostUserMsg *vmsg) features |= dev->iface->get_protocol_features(dev); } +#ifndef MFD_ALLOW_SEALING + /* + * If MFD_ALLOW_SEALING is not defined, we are not able to handle + * VHOST_USER_GET_INFLIGHT_FD messages, since we can't create a memfd. + * Those messages are used only if VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD + * is negotiated. A device implementation can enable it, so let's mask + * it to avoid a runtime panic. + */ + features &= ~(1ULL << VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD); +#endif + vmsg_set_reply_u64(vmsg, features); return true; } From patchwork Wed Jul 3 22:48:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3BEEDC31D97 for ; Wed, 3 Jul 2024 22:48:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8m0-0000EX-CF; Wed, 03 Jul 2024 18:48: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 1sP8lw-00086p-Bl for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:20 -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 1sP8lu-0003tg-Pj for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046898; 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=SxEb4qxo9i3miZ1US5mo9RXgQJuGwUKVIRe5VRPOVeg=; b=BK9PRDDb7owX58Nwe66Y6glx+VHarnPU+M9o9W+K/RuvYMhudN3P1S3oCaMkbYSWh+Bar2 m20q7rZHfxN3dhfO3xv3SUPUiBma0xPvrlCeHTMrPHk015kKqL0A91RdTkKMBZ8cluxpyT ECJo16SVy78PET1CRL1hsxR1lpPGyEI= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-136-OMtj9WM9OzeN_l9XyFz52A-1; Wed, 03 Jul 2024 18:48:17 -0400 X-MC-Unique: OMtj9WM9OzeN_l9XyFz52A-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-52e98693f43so1141085e87.3 for ; Wed, 03 Jul 2024 15:48:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046895; x=1720651695; 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=SxEb4qxo9i3miZ1US5mo9RXgQJuGwUKVIRe5VRPOVeg=; b=ws5Rbkc5vmF2iXl8QzYWRZL98mUT0NTmVoMB5MiyhJuLSzysFj6mZZPEH8HSFtgygR +D5rA56x02D4nYSsaa2JpmcFGdrkX49r9uVXVmaNpYmJvBO4RWe4HJPo/OKwZO1GRCP9 x9Tx1O3s0XCOIOBsrBXMbKWOrUfYMfKJyoBgXMmwVNDGMOK+iDX1RQG5Y3HIaiqOl4nK N8F4j5k20Wf022drgeXLdoBVT+QaGYGYVLsncW4gO7w96aYjKYkzHr6q9FAMJPKWa237 kWtAoBSljdkb7JxzCrRTy8lLIMxMFjJxJUTdJv6z9cUayvPpV5EqIEe0aX+jQ5Akic5x P4NA== X-Gm-Message-State: AOJu0Yyy/n7qb2rUMLs15vTWaDkZYHJz8a26wqqBVXNcdtXCIfqJQX4g 8Udwkn6WOKXBZ30r1wh2U81lij1QFkni9OfoINbhqTBZbjlRZZBwSwJ9bIT06bneBSmce5Istar uvmMyNO/manKRsHefueGAAo9kYo7tSNbeDYPsoqdksG3fyd0LTRvcwAEF4VTEhsBPBDtxbMy/4D SJJY3GND1Dm7qxMVD7mPTPmT7w0LYfJA== X-Received: by 2002:a05:6512:1387:b0:52c:8339:d09b with SMTP id 2adb3069b0e04-52e82651f75mr10349876e87.1.1720046895260; Wed, 03 Jul 2024 15:48:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJ2JSk5VrTqKVB9bK6M/xzcvPqQ4UVmgwFKg9BdWTWuzkobEjD+y57MmuqE0ry9ZOiIL50Bg== X-Received: by 2002:a05:6512:1387:b0:52c:8339:d09b with SMTP id 2adb3069b0e04-52e82651f75mr10349857e87.1.1720046894636; Wed, 03 Jul 2024 15:48:14 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a751561bb1bsm412719466b.37.2024.07.03.15.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:48:13 -0700 (PDT) Date: Wed, 3 Jul 2024 18:48:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , Daniel P =?utf-8?b?LiBCZXJyYW5n?= =?utf-8?b?w6k=?= , Stefan Hajnoczi , David Hildenbrand , Coiby Xu Subject: [PULL v3 50/85] vhost-user-server: do not set memory fd non-blocking Message-ID: <4c58843e5d3192c67394b28a3330144ea56eefac.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stefano Garzarella In vhost-user-server we set all fd received from the other peer in non-blocking mode. For some of them (e.g. memfd, shm_open, etc.) it's not really needed, because we don't use these fd with blocking operations, but only to map memory. In addition, in some systems this operation can fail (e.g. in macOS setting an fd returned by shm_open() non-blocking fails with errno = ENOTTY). So, let's avoid setting fd non-blocking for those messages that we know carry memory fd (e.g. VHOST_USER_ADD_MEM_REG, VHOST_USER_SET_MEM_TABLE). Reviewed-by: Daniel P. Berrangé Acked-by: Stefan Hajnoczi Reviewed-by: David Hildenbrand Signed-off-by: Stefano Garzarella Message-Id: <20240618100043.144657-6-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- util/vhost-user-server.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/util/vhost-user-server.c b/util/vhost-user-server.c index 3bfb1ad3ec..b19229074a 100644 --- a/util/vhost-user-server.c +++ b/util/vhost-user-server.c @@ -65,6 +65,18 @@ static void vmsg_close_fds(VhostUserMsg *vmsg) static void vmsg_unblock_fds(VhostUserMsg *vmsg) { int i; + + /* + * These messages carry fd used to map memory, not to send/receive messages, + * so this operation is useless. In addition, in some systems this + * operation can fail (e.g. in macOS setting an fd returned by shm_open() + * non-blocking fails with errno = ENOTTY) + */ + if (vmsg->request == VHOST_USER_ADD_MEM_REG || + vmsg->request == VHOST_USER_SET_MEM_TABLE) { + return; + } + for (i = 0; i < vmsg->fd_num; i++) { qemu_socket_set_nonblock(vmsg->fds[i]); } From patchwork Wed Jul 3 22:48:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 239C5C3814E for ; Wed, 3 Jul 2024 22:50:15 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8m3-0000Tr-7c; Wed, 03 Jul 2024 18:48:27 -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 1sP8m1-0000Ho-DQ for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:25 -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 1sP8ly-00047U-QE for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046902; 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=hyIX+6gMMv2zX4UnJSMWLVmYqSE0wXcA/BACsQ8Un/M=; b=YP/j/qdn/tdzRdH6cFML/70+zmqGnLMQtIfp1tHwXXgbtjHCOnkWATLd4trgOVeF6GATSl qOaiEEJMiLAVd99oKzs3fmVmcPMd15JtZVmHOgtpeUoAFFzGO1ID75zFQakxY9/MrZWwPy Sfkn3sxUTKIPJfl6NFofFoM+PkPSe8k= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-611-Vxs0kUeIPE-L3XMs23MHVw-1; Wed, 03 Jul 2024 18:48:20 -0400 X-MC-Unique: Vxs0kUeIPE-L3XMs23MHVw-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-57cd2950eefso7256a12.0 for ; Wed, 03 Jul 2024 15:48:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046899; x=1720651699; 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=hyIX+6gMMv2zX4UnJSMWLVmYqSE0wXcA/BACsQ8Un/M=; b=LVRb1ZLDnrk1hSM/wsp04rQvyvEMixGqTWy6k3h5ipLOPOInJiLHWp/qaJiisqbsqc 9mrD1GS+fqdbt18ESsBQ81m4rUMGIDXaL4ZRlNo71pPWI1Wv5ZbMIhxfBEL3uLGF3fu1 uvIK4SJBJZYuA7jCJEnWfS3+DhHPiZB2Wn7WGNDeNmtaQYqd2hHL6jBQRVWgj40w79mZ vZx0473kz/EBjzyoyzVgeWoPTG0zwyMFrcjpnLupYFkag38lAnkPaQqzEiE0JuuOOBcY 5/Czq3fGPn+2ujOwjKf9w75vl1DtawAXJ0ZkLRfecWf0SyiLs//0J5JRbH4As89fYZpM ZEag== X-Gm-Message-State: AOJu0YzInnahclCkCoDEA2AArfDgXCiIQkQGx+HStWZyZ9QLhAmhFChy bXnfdBaOtFnLurXkgJoYERcGMx3obDAiMz1UtFAzH9B3RCDyStSQw8mIYZJS5bkHhzRE2LacKyL 2M2p/k200xuK+x6TENxZokUaLOBbzkOlpPoT38sQQO4ZQCsUCnHcI3AMIbcOCLJFDU60gTXP7bl vpTFXBHKa3IdOWm43/dxdWZFyyxMtY8g== X-Received: by 2002:a17:906:fccc:b0:a72:548a:6f42 with SMTP id a640c23a62f3a-a751445451dmr825381666b.18.1720046899402; Wed, 03 Jul 2024 15:48:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4A+KCXjcekCAj8XtlIjcEhjkXdKLdsCGNZZ1xPlggqsjz6zr21Ju4KIo+4DXpBxlvELmqbg== X-Received: by 2002:a17:906:fccc:b0:a72:548a:6f42 with SMTP id a640c23a62f3a-a751445451dmr825379366b.18.1720046898759; Wed, 03 Jul 2024 15:48:18 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72ab0b56e6sm542229266b.202.2024.07.03.15.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:48:18 -0700 (PDT) Date: Wed, 3 Jul 2024 18:48:15 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , Philippe =?utf-8?q?Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Stefan Hajnoczi , David Hildenbrand , Raphael Norwitz Subject: [PULL v3 51/85] contrib/vhost-user-blk: fix bind() using the right size of the address Message-ID: <03582094da1ea7ce978cec58008c81f7458ee8dd.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stefano Garzarella On macOS passing `-s /tmp/vhost.socket` parameter to the vhost-user-blk application, the bind was done on `/tmp/vhost.socke` pathname, missing the last character. This sounds like one of the portability problems described in the unix(7) manpage: Pathname sockets When binding a socket to a pathname, a few rules should be observed for maximum portability and ease of coding: • The pathname in sun_path should be null-terminated. • The length of the pathname, including the terminating null byte, should not exceed the size of sun_path. • The addrlen argument that describes the enclosing sockaddr_un structure should have a value of at least: offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path)+1 or, more simply, addrlen can be specified as sizeof(struct sockaddr_un). So let's follow the last advice and simplify the code as well. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Acked-by: Stefan Hajnoczi Reviewed-by: David Hildenbrand Signed-off-by: Stefano Garzarella Message-Id: <20240618100440.145664-1-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/vhost-user-blk/vhost-user-blk.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c index 89e5f11a64..a8ab9269a2 100644 --- a/contrib/vhost-user-blk/vhost-user-blk.c +++ b/contrib/vhost-user-blk/vhost-user-blk.c @@ -469,7 +469,6 @@ static int unix_sock_new(char *unix_fn) { int sock; struct sockaddr_un un; - size_t len; assert(unix_fn); @@ -481,10 +480,9 @@ static int unix_sock_new(char *unix_fn) un.sun_family = AF_UNIX; (void)snprintf(un.sun_path, sizeof(un.sun_path), "%s", unix_fn); - len = sizeof(un.sun_family) + strlen(un.sun_path); (void)unlink(unix_fn); - if (bind(sock, (struct sockaddr *)&un, len) < 0) { + if (bind(sock, (struct sockaddr *)&un, sizeof(un)) < 0) { perror("bind"); goto fail; } From patchwork Wed Jul 3 22:48:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722996 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3F4F0C3271E for ; Wed, 3 Jul 2024 22:50:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8mH-0000rH-2b; Wed, 03 Jul 2024 18:48: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 1sP8mF-0000ok-GN for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:39 -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 1sP8m7-0004IC-NP for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046911; 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=Xz1NfthBeUYnFyP8G3rI1icjzqQ87e2k5Q1ZCQ4OJGs=; b=MuUTyR34HlBbfbI/A3TUN/Xcp7m8DUVlZiUPms6UYtua67yX8+XMvEKHCzl3Ku8NknB8Xw I4NOCG3Y573F7Mm0ywNONYA82Znql1vqXZUHqV/M0L3bJsx+fvzMQfn3yT7ciLqfyNsM7X do98T3ejiR8HEfI0pCgzrEh/jJSzdnc= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-17-jcDVhuxxOVS9JHAAY9pobw-1; Wed, 03 Jul 2024 18:48:27 -0400 X-MC-Unique: jcDVhuxxOVS9JHAAY9pobw-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a725b0f8ba9so480866b.2 for ; Wed, 03 Jul 2024 15:48:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046905; x=1720651705; 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=Xz1NfthBeUYnFyP8G3rI1icjzqQ87e2k5Q1ZCQ4OJGs=; b=GS10zAQfvYYHW4bcRPqz2pYs1G5ViO+kuXD8yvYzWg0YV+AO9sB5+eJZ9pXYXwG2TE msjwbIeLkrJvE/fuZrrS224qTbzrxLts/UBMbpCgQ21wlWVuGa+t4Y/lEjdUEvvw6MOO eYTrXBqjBw2QplKoRwnU1sn3Kb3L9VK8XdKoI7ZYlXRG1rH11+BhrU4Y4XlvcTEt3tTi 3/EXkAr3ZMrhaWIf4bJTX6hnsV6XisyzdsK+DlJ5uerlfeMPg1NGKxVwpPHfZhRsXHeN 2/aWDlSNGFbziii1bAkzUm6ohhLzUkc6KhZZLiXFiUfN3sUJ/9mcxnoiVR3Z/WlSJsxm ez1g== X-Gm-Message-State: AOJu0Ywmx6CeVQ4M+1zJeKpXnSMehXeJDqf+fbNdDFiGYnApLf97CvKY P3rziMWTIyZUBwt19auTTwONDNX8U58yL2Jy5zpqodB9k3KEMSVbuPwvjU/QFYwkLkMt7fyF8K2 sKRum4VRiPJzw2RI18/1ZBJEOqMK2ZmqF+QFc9a0rD16ErYm9GDvlG1r4/k5nEHkB2KcoTvbM8U 6dW5UDDRDVga50Dj7oQAcTh0xGRSErww== X-Received: by 2002:a05:6402:50cc:b0:578:638e:3683 with SMTP id 4fb4d7f45d1cf-5879ede2742mr12161174a12.5.1720046904896; Wed, 03 Jul 2024 15:48:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF28sHLGiyPyMidKAWw22ItsxN1HRjXNcR2KzSx7Zi3PbVvL8xmzTlcXmNlk2AaajREtXjbNQ== X-Received: by 2002:a05:6402:50cc:b0:578:638e:3683 with SMTP id 4fb4d7f45d1cf-5879ede2742mr12161157a12.5.1720046904300; Wed, 03 Jul 2024 15:48:24 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58613815e1csm7720372a12.44.2024.07.03.15.48.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:48:23 -0700 (PDT) Date: Wed, 3 Jul 2024 18:48:19 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , Philippe =?utf-8?q?Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Stefan Hajnoczi , David Hildenbrand , Raphael Norwitz , Gerd Hoffmann Subject: [PULL v3 52/85] contrib/vhost-user-*: use QEMU bswap helper functions Message-ID: <5ab04420c3de11ae4a573b08b53584a2a0c5dd00.1720046570.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stefano Garzarella Let's replace the calls to le*toh() and htole*() with qemu/bswap.h helpers to make the code more portable. Suggested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Acked-by: Stefan Hajnoczi Reviewed-by: David Hildenbrand Signed-off-by: Stefano Garzarella Message-Id: <20240618100447.145697-1-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- contrib/vhost-user-blk/vhost-user-blk.c | 9 +++++---- contrib/vhost-user-input/main.c | 16 ++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c index a8ab9269a2..9492146855 100644 --- a/contrib/vhost-user-blk/vhost-user-blk.c +++ b/contrib/vhost-user-blk/vhost-user-blk.c @@ -16,6 +16,7 @@ */ #include "qemu/osdep.h" +#include "qemu/bswap.h" #include "standard-headers/linux/virtio_blk.h" #include "libvhost-user-glib.h" @@ -194,8 +195,8 @@ vub_discard_write_zeroes(VubReq *req, struct iovec *iov, uint32_t iovcnt, #if defined(__linux__) && defined(BLKDISCARD) && defined(BLKZEROOUT) VubDev *vdev_blk = req->vdev_blk; desc = buf; - uint64_t range[2] = { le64toh(desc->sector) << 9, - le32toh(desc->num_sectors) << 9 }; + uint64_t range[2] = { le64_to_cpu(desc->sector) << 9, + le32_to_cpu(desc->num_sectors) << 9 }; if (type == VIRTIO_BLK_T_DISCARD) { if (ioctl(vdev_blk->blk_fd, BLKDISCARD, range) == 0) { g_free(buf); @@ -267,13 +268,13 @@ static int vub_virtio_process_req(VubDev *vdev_blk, req->in = (struct virtio_blk_inhdr *)elem->in_sg[in_num - 1].iov_base; in_num--; - type = le32toh(req->out->type); + type = le32_to_cpu(req->out->type); switch (type & ~VIRTIO_BLK_T_BARRIER) { case VIRTIO_BLK_T_IN: case VIRTIO_BLK_T_OUT: { ssize_t ret = 0; bool is_write = type & VIRTIO_BLK_T_OUT; - req->sector_num = le64toh(req->out->sector); + req->sector_num = le64_to_cpu(req->out->sector); if (is_write) { ret = vub_writev(req, &elem->out_sg[1], out_num); } else { diff --git a/contrib/vhost-user-input/main.c b/contrib/vhost-user-input/main.c index 081230da54..f3362d41ac 100644 --- a/contrib/vhost-user-input/main.c +++ b/contrib/vhost-user-input/main.c @@ -51,8 +51,8 @@ static void vi_input_send(VuInput *vi, struct virtio_input_event *event) vi->queue[vi->qindex++].event = *event; /* ... until we see a report sync ... */ - if (event->type != htole16(EV_SYN) || - event->code != htole16(SYN_REPORT)) { + if (event->type != cpu_to_le16(EV_SYN) || + event->code != cpu_to_le16(SYN_REPORT)) { return; } @@ -103,9 +103,9 @@ vi_evdev_watch(VuDev *dev, int condition, void *data) g_debug("input %d %d %d", evdev.type, evdev.code, evdev.value); - virtio.type = htole16(evdev.type); - virtio.code = htole16(evdev.code); - virtio.value = htole32(evdev.value); + virtio.type = cpu_to_le16(evdev.type); + virtio.code = cpu_to_le16(evdev.code); + virtio.value = cpu_to_le32(evdev.value); vi_input_send(vi, &virtio); } } @@ -124,9 +124,9 @@ static void vi_handle_status(VuInput *vi, virtio_input_event *event) evdev.input_event_sec = tval.tv_sec; evdev.input_event_usec = tval.tv_usec; - evdev.type = le16toh(event->type); - evdev.code = le16toh(event->code); - evdev.value = le32toh(event->value); + evdev.type = le16_to_cpu(event->type); + evdev.code = le16_to_cpu(event->code); + evdev.value = le32_to_cpu(event->value); rc = write(vi->evdevfd, &evdev, sizeof(evdev)); if (rc == -1) { From patchwork Wed Jul 3 22:48:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 455AAC41513 for ; Wed, 3 Jul 2024 22:51:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8mE-0000oa-5H; Wed, 03 Jul 2024 18:48: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 1sP8mC-0000nd-7g for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:36 -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 1sP8mA-0004Wp-6m for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046913; 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=nT/3bEAHv/ccVmumWuUDEQosc383NR5xwSBkJ1pU+nE=; b=RHl8IGDYJN9icaZQR0xdEGEYlB+PT2bfOIt9pzBRHmJkpDkdW7F77kTDbkGmxu5iKxYYoy 6vctobn6CEYJML8G+f7BHtFdets7RPMZD/uxjLwQBGbwUVIk6ZKEdaapRsw9e4aKd6GcK/ II8v9qOQQ1cWXvXbQxSoPB65oWrpoAo= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-307-SlvQhxRHMW-1ez-uEx0UAQ-1; Wed, 03 Jul 2024 18:48:32 -0400 X-MC-Unique: SlvQhxRHMW-1ez-uEx0UAQ-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-586c45fc092so2782291a12.3 for ; Wed, 03 Jul 2024 15:48:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046911; x=1720651711; 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=nT/3bEAHv/ccVmumWuUDEQosc383NR5xwSBkJ1pU+nE=; b=e5DtawXizb+a5jsVvNcB1ylEBabxWn2HTX/UIG89qkw/kErQ5GtfQ/DFAiCag+txjP CKZeDwxYdxC5JXsq/70juwjgTqfn9YkthNlBHrLdL8Wr3zLDR63Va4nJ+uj3RHnwDRy7 oFcYCo9/IpzXWnz3rdE8IB1CUqB2Wk7oHpHIMzVFJcPtqOwsqkpAMF92tdu7dathkzte ITnDkb8rw9hpVE4lwb4ZSuBx7wZPCMuIsLXgkVyP0qMCPQHBpbDdDCvHjqdOXBddWOhA eV7iMfb6ZdukL9oZKCC36l27qQHSioVFBqf9VoXaThlINszqJCS4FfNJyqgtTa+q1z1J tSzQ== X-Gm-Message-State: AOJu0Yz256Po6xQG2/jO6Y403xOFGZko3RVdyeXf/FuAwMWXXQoxKxH5 siBRG6FI7bveYyrgoEVsK1ibnRv3BbmWS/aP8FnyencV3+2f07FhMW0j9GWXlGc66uYT7Qqy5Aa Vwj/5EFF7aCCZS7Oc/UFTW6eouKZIkJLPTNLCisF2D1gd3/omPDlI3v25HeVHmb/qmDnevdtsyv zTlJjxaVw5pMfxxwqzxkDL1H6xM15IuQ== X-Received: by 2002:a05:6402:354c:b0:57c:a77d:a61e with SMTP id 4fb4d7f45d1cf-5879ede2779mr9469304a12.7.1720046910827; Wed, 03 Jul 2024 15:48:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1CpDi8g8001mRuuRomIjteSgUp7J9coi8GeJJUJynn3T0HgEETgOZoox3ES71S7fZBZKSzg== X-Received: by 2002:a05:6402:354c:b0:57c:a77d:a61e with SMTP id 4fb4d7f45d1cf-5879ede2779mr9469265a12.7.1720046909788; Wed, 03 Jul 2024 15:48:29 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58d50c4dad9sm1055799a12.10.2024.07.03.15.48.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:48:29 -0700 (PDT) Date: Wed, 3 Jul 2024 18:48:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , David Hildenbrand , Stefan Hajnoczi , Markus Armbruster , Igor Mammedov , Paolo Bonzini , Daniel =?utf-8?b?UC4gQmVycmFuZ8Op?= , Eduardo Habkost , Eric Blake Subject: [PULL v3 53/85] hostmem: add a new memory backend based on POSIX shm_open() Message-ID: <4e647fa08586a5ada74cf6d3ae1cdf3a027202cb.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stefano Garzarella shm_open() creates and opens a new POSIX shared memory object. A POSIX shared memory object allows creating memory backend with an associated file descriptor that can be shared with external processes (e.g. vhost-user). The new `memory-backend-shm` can be used as an alternative when `memory-backend-memfd` is not available (Linux only), since shm_open() should be provided by any POSIX-compliant operating system. This backend mimics memfd, allocating memory that is practically anonymous. In theory shm_open() requires a name, but this is allocated for a short time interval and shm_unlink() is called right after shm_open(). After that, only fd is shared with external processes (e.g., vhost-user) as if it were associated with anonymous memory. In the future we may also allow the user to specify the name to be passed to shm_open(), but for now we keep the backend simple, mimicking anonymous memory such as memfd. Acked-by: David Hildenbrand Acked-by: Stefan Hajnoczi Acked-by: Markus Armbruster (QAPI schema) Signed-off-by: Stefano Garzarella Message-Id: <20240618100519.145853-1-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/qom.json | 23 +++++- backends/hostmem-shm.c | 123 +++++++++++++++++++++++++++++ backends/meson.build | 1 + docs/system/devices/vhost-user.rst | 5 +- qemu-options.hx | 16 ++++ 5 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 backends/hostmem-shm.c diff --git a/qapi/qom.json b/qapi/qom.json index 9b8f6a7ab5..92b0fea76c 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -601,8 +601,8 @@ # # @share: if false, the memory is private to QEMU; if true, it is # shared (default false for backends memory-backend-file and -# memory-backend-ram, true for backends memory-backend-epc and -# memory-backend-memfd) +# memory-backend-ram, true for backends memory-backend-epc, +# memory-backend-memfd, and memory-backend-shm) # # @reserve: if true, reserve swap space (or huge pages) if applicable # (default: true) (since 6.1) @@ -721,6 +721,21 @@ '*hugetlbsize': 'size', '*seal': 'bool' } } +## +# @MemoryBackendShmProperties: +# +# Properties for memory-backend-shm objects. +# +# This memory backend supports only shared memory, which is the +# default. +# +# Since: 9.1 +## +{ 'struct': 'MemoryBackendShmProperties', + 'base': 'MemoryBackendProperties', + 'data': { }, + 'if': 'CONFIG_POSIX' } + ## # @MemoryBackendEpcProperties: # @@ -1049,6 +1064,8 @@ { 'name': 'memory-backend-memfd', 'if': 'CONFIG_LINUX' }, 'memory-backend-ram', + { 'name': 'memory-backend-shm', + 'if': 'CONFIG_POSIX' }, 'pef-guest', { 'name': 'pr-manager-helper', 'if': 'CONFIG_LINUX' }, @@ -1121,6 +1138,8 @@ 'memory-backend-memfd': { 'type': 'MemoryBackendMemfdProperties', 'if': 'CONFIG_LINUX' }, 'memory-backend-ram': 'MemoryBackendProperties', + 'memory-backend-shm': { 'type': 'MemoryBackendShmProperties', + 'if': 'CONFIG_POSIX' }, 'pr-manager-helper': { 'type': 'PrManagerHelperProperties', 'if': 'CONFIG_LINUX' }, 'qtest': 'QtestProperties', diff --git a/backends/hostmem-shm.c b/backends/hostmem-shm.c new file mode 100644 index 0000000000..374edc3db8 --- /dev/null +++ b/backends/hostmem-shm.c @@ -0,0 +1,123 @@ +/* + * QEMU host POSIX shared memory object backend + * + * Copyright (C) 2024 Red Hat Inc + * + * Authors: + * Stefano Garzarella + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "sysemu/hostmem.h" +#include "qapi/error.h" + +#define TYPE_MEMORY_BACKEND_SHM "memory-backend-shm" + +OBJECT_DECLARE_SIMPLE_TYPE(HostMemoryBackendShm, MEMORY_BACKEND_SHM) + +struct HostMemoryBackendShm { + HostMemoryBackend parent_obj; +}; + +static bool +shm_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) +{ + g_autoptr(GString) shm_name = g_string_new(NULL); + g_autofree char *backend_name = NULL; + uint32_t ram_flags; + int fd, oflag; + mode_t mode; + + if (!backend->size) { + error_setg(errp, "can't create shm backend with size 0"); + return false; + } + + if (!backend->share) { + error_setg(errp, "can't create shm backend with `share=off`"); + return false; + } + + /* + * Let's use `mode = 0` because we don't want other processes to open our + * memory unless we share the file descriptor with them. + */ + mode = 0; + oflag = O_RDWR | O_CREAT | O_EXCL; + backend_name = host_memory_backend_get_name(backend); + + /* + * Some operating systems allow creating anonymous POSIX shared memory + * objects (e.g. FreeBSD provides the SHM_ANON constant), but this is not + * defined by POSIX, so let's create a unique name. + * + * From Linux's shm_open(3) man-page: + * For portable use, a shared memory object should be identified + * by a name of the form /somename;" + */ + g_string_printf(shm_name, "/qemu-" FMT_pid "-shm-%s", getpid(), + backend_name); + + fd = shm_open(shm_name->str, oflag, mode); + if (fd < 0) { + error_setg_errno(errp, errno, + "failed to create POSIX shared memory"); + return false; + } + + /* + * We have the file descriptor, so we no longer need to expose the + * POSIX shared memory object. However it will remain allocated as long as + * there are file descriptors pointing to it. + */ + shm_unlink(shm_name->str); + + if (ftruncate(fd, backend->size) == -1) { + error_setg_errno(errp, errno, + "failed to resize POSIX shared memory to %" PRIu64, + backend->size); + close(fd); + return false; + } + + ram_flags = RAM_SHARED; + ram_flags |= backend->reserve ? 0 : RAM_NORESERVE; + + return memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), + backend_name, backend->size, + ram_flags, fd, 0, errp); +} + +static void +shm_backend_instance_init(Object *obj) +{ + HostMemoryBackendShm *m = MEMORY_BACKEND_SHM(obj); + + MEMORY_BACKEND(m)->share = true; +} + +static void +shm_backend_class_init(ObjectClass *oc, void *data) +{ + HostMemoryBackendClass *bc = MEMORY_BACKEND_CLASS(oc); + + bc->alloc = shm_backend_memory_alloc; +} + +static const TypeInfo shm_backend_info = { + .name = TYPE_MEMORY_BACKEND_SHM, + .parent = TYPE_MEMORY_BACKEND, + .instance_init = shm_backend_instance_init, + .class_init = shm_backend_class_init, + .instance_size = sizeof(HostMemoryBackendShm), +}; + +static void register_types(void) +{ + type_register_static(&shm_backend_info); +} + +type_init(register_types); diff --git a/backends/meson.build b/backends/meson.build index 106312f0c8..749b491f12 100644 --- a/backends/meson.build +++ b/backends/meson.build @@ -13,6 +13,7 @@ system_ss.add([files( if host_os != 'windows' system_ss.add(files('rng-random.c')) system_ss.add(files('hostmem-file.c')) + system_ss.add([files('hostmem-shm.c'), rt]) endif if host_os == 'linux' system_ss.add(files('hostmem-memfd.c')) diff --git a/docs/system/devices/vhost-user.rst b/docs/system/devices/vhost-user.rst index 9b2da106ce..35259d8ec7 100644 --- a/docs/system/devices/vhost-user.rst +++ b/docs/system/devices/vhost-user.rst @@ -98,8 +98,9 @@ Shared memory object In order for the daemon to access the VirtIO queues to process the requests it needs access to the guest's address space. This is -achieved via the ``memory-backend-file`` or ``memory-backend-memfd`` -objects. A reference to a file-descriptor which can access this object +achieved via the ``memory-backend-file``, ``memory-backend-memfd``, or +``memory-backend-shm`` objects. +A reference to a file-descriptor which can access this object will be passed via the socket as part of the protocol negotiation. Currently the shared memory object needs to match the size of the main diff --git a/qemu-options.hx b/qemu-options.hx index 8ca7f34ef0..ad6521ef5e 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -5240,6 +5240,22 @@ SRST The ``share`` boolean option is on by default with memfd. + ``-object memory-backend-shm,id=id,merge=on|off,dump=on|off,share=on|off,prealloc=on|off,size=size,host-nodes=host-nodes,policy=default|preferred|bind|interleave`` + Creates a POSIX shared memory backend object, which allows + QEMU to share the memory with an external process (e.g. when + using vhost-user). + + ``memory-backend-shm`` is a more portable and less featureful version + of ``memory-backend-memfd``. It can then be used in any POSIX system, + especially when memfd is not supported. + + Please refer to ``memory-backend-file`` for a description of the + options. + + The ``share`` boolean option is on by default with shm. Setting it to + off will cause a failure during allocation because it is not supported + by this backend. + ``-object iommufd,id=id[,fd=fd]`` Creates an iommufd backend which allows control of DMA mapping through the ``/dev/iommu`` device. From patchwork Wed Jul 3 22:48:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722986 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0471C31D97 for ; Wed, 3 Jul 2024 22:49:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8mK-0000tk-4a; Wed, 03 Jul 2024 18:48:44 -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 1sP8mH-0000rJ-6B for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:41 -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 1sP8mF-0004u9-MT for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046919; 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=R3m1Xw9Ub15rW4o3esEC0MkiVgr91nuiCfcAKrltL4I=; b=gLXVBeNnXJ8IB6Sds6w6bO15BWiBQbFy/VAYVAqPhZycinXuGop37Xx/dJ76cAoqTKXRy6 GzD94knMuvc0WSOO4n1UvTI5IGze/C9y6s9rwv1Obfa1qdmeG/H1SdjxjwYhCVjgw/xTL2 vJsEau0NLi6t7JHHh7NxWozi/uyaj+U= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-57-onQhYNbOMBGVh91aRUk3gw-1; Wed, 03 Jul 2024 18:48:37 -0400 X-MC-Unique: onQhYNbOMBGVh91aRUk3gw-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-57c93227bbeso2848118a12.3 for ; Wed, 03 Jul 2024 15:48:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046916; x=1720651716; 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=R3m1Xw9Ub15rW4o3esEC0MkiVgr91nuiCfcAKrltL4I=; b=WoByO90matRelWjwdZpiunVKCI2hCsRtIILv4asopnMPOTnrAutMFZzstoJNAXhJgQ ZailbZbX52iHZ4q2mvykaQf8jz1k1enSCohC/tqejEDEznpuHigHpodlJgToszqA6/cT 5PdD/FkLpOQUS0vtiIxSIQ/QBn1twtQBLForIWVfa5ocmKaNUERXF2iIMYjp6lsSeF2W kYg7bgwlQi9hq5BDghRHsmRX7pdAWLEbdOhAi8amHABDM/gmBHidQ4SIFdnIArlxgKw3 zFH+ba4WVkdNA/x0WZd5FM9jVYRA7MdpBa5MSIYXkDZ1LTZTeIeatxfvEAPGGvK4fv8P K/Nw== X-Gm-Message-State: AOJu0YwfTPivsk2ln4DUgPd7RQ6UmdmJwyQ69UkVFczdgd/u5VYOq+/v LU5doCoJPLr3hWFn0sXZPcxlK228v1TpTAcrZXMxrQ0v5b/jzOcSKRfByVbpLA52Wgg/q4zMD17 bWeOpJ2UmIIZXbMTaGC9q9FRpNKRTH2ILvydATK4L3I0PMQxYtDfGJkfSFF0ODMsuvkYr4p5JW5 Oqb/b6A1nEZGaF/eUoqCuG4qe6Zjzo4Q== X-Received: by 2002:a05:6402:358d:b0:57d:4ca2:fdab with SMTP id 4fb4d7f45d1cf-5879f0c68d1mr8884830a12.3.1720046916445; Wed, 03 Jul 2024 15:48:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8UBCVXWDCCux2Am9uUGEs2H0c4tVgBuv20zn9EgbKXUA7mtcJj51lLPMzIURZgiDFAqzcGg== X-Received: by 2002:a05:6402:358d:b0:57d:4ca2:fdab with SMTP id 4fb4d7f45d1cf-5879f0c68d1mr8884810a12.3.1720046915828; Wed, 03 Jul 2024 15:48:35 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5861324ff85sm7692218a12.29.2024.07.03.15.48.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:48:35 -0700 (PDT) Date: Wed, 3 Jul 2024 18:48:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , Thomas Huth , Stefan Hajnoczi , Philippe =?utf-8?q?Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Hildenbrand , Coiby Xu , Laurent Vivier , Paolo Bonzini Subject: [PULL v3 54/85] tests/qtest/vhost-user-blk-test: use memory-backend-shm 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stefano Garzarella `memory-backend-memfd` is available only on Linux while the new `memory-backend-shm` can be used on any POSIX-compliant operating system. Let's use it so we can run the test in multiple environments. Since we are here, let`s remove `share=on` which is the default for shm (and also for memfd). Acked-by: Thomas Huth Acked-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Reviewed-by: David Hildenbrand Signed-off-by: Stefano Garzarella Message-Id: <20240618100527.145883-1-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/vhost-user-blk-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk-test.c index 117b9acd10..ea90d41232 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -906,7 +906,7 @@ static void start_vhost_user_blk(GString *cmd_line, int vus_instances, vhost_user_blk_bin); g_string_append_printf(cmd_line, - " -object memory-backend-memfd,id=mem,size=256M,share=on " + " -object memory-backend-shm,id=mem,size=256M " " -M memory-backend=mem -m 256M "); for (i = 0; i < vus_instances; i++) { From patchwork Wed Jul 3 22:48:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722998 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BDAC8C38150 for ; Wed, 3 Jul 2024 22:50:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8mQ-0001TH-RW; Wed, 03 Jul 2024 18:48:50 -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 1sP8mO-0001Ag-E4 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48: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 1sP8mL-0005EH-PV for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046924; 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=QybIKg16iYqXdH14Jxyn469nV1P/mwHXBmUUNkfpRqo=; b=ffqJMdghg5tVf+DxQZ8CmvPp3kWft4jBc6lB/v+ZcyS/XOgQD9bVrfdC/giRfngGS4u75H 9ll03g29LfgLRVDDwA0AVzafxVnsWAKie+wlcOrIkEm6dnMMGJqdBz58peZVsNZ8rk2qvD rGRVsT7WMhwHEFvhW8dfX1u5G2gSzHo= 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-453-BEohjOQBMiyqKxmYSJ0pPg-1; Wed, 03 Jul 2024 18:48:43 -0400 X-MC-Unique: BEohjOQBMiyqKxmYSJ0pPg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-364b75a8194so34068f8f.0 for ; Wed, 03 Jul 2024 15:48:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046921; x=1720651721; 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=QybIKg16iYqXdH14Jxyn469nV1P/mwHXBmUUNkfpRqo=; b=loFjG1vLoatjyaFaqHEWDXaOpuNzQjRX/YNinPqNO91cYM4Mkl70j3prHieyMNI1Do iJpm2mnBZyVMJb9yMGF+Ic5U85uzVmjh35Z9hWXMPc94AWnF9LAsFHjEGDL6CAjp/36K OMEPGEJNZ6ST8qRCELh+Bp6OyuyrP9BrKXPbett6WyGuLpETylxWEF9Te86NRtQsYlL6 S7977rc0TqmkOGI6YfOiPw3nT3JHJcMWHCn3PRNAbfULGILQB+OU2NiMDhWTRj6eiOEi VF9Zl1Up8F5isWXH6cW2Hqn7rZ1vHA93LE3uIsvt5dPocVdUypVJmXzM6zP5YCP5fAQ6 ZO1w== X-Gm-Message-State: AOJu0Yz8y6LHJETcXao8Zzh/shndPKXlKInMnGL82jlsBAuYvFt4fxDx mqbavcgulUwELt2QeE/u2PZA2DVeJ9CZnBQUkUSNf77D5Z/O91cxFNSTyZ1t8ZcGCrgsl39nflp t4/aei3/1IJzixMcua6rYTGqBhxaRx4eRsAiR3We3mr0EHjT3pk3eCU+c1Pbid0lausH4DSktXe N/gaIHYIkoz2YlJsaajRZBh6erOjqcAg== X-Received: by 2002:adf:e5c9:0:b0:367:94f7:88f3 with SMTP id ffacd0b85a97d-3679dd72b16mr2212f8f.57.1720046921389; Wed, 03 Jul 2024 15:48:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDTHY/Gvoyw2qkyB8B+bZX8Vd466iBKU/h2FTOOwHiO6Ov4rfPrbCgPbNnB0tyRisupbeiEg== X-Received: by 2002:adf:e5c9:0:b0:367:94f7:88f3 with SMTP id ffacd0b85a97d-3679dd72b16mr2190f8f.57.1720046920590; Wed, 03 Jul 2024 15:48:40 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3679976da15sm702065f8f.94.2024.07.03.15.48.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:48:40 -0700 (PDT) Date: Wed, 3 Jul 2024 18:48:36 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , Thomas Huth , Stefan Hajnoczi , David Hildenbrand , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Laurent Vivier , Paolo Bonzini Subject: [PULL v3 55/85] tests/qtest/vhost-user-test: add a test case for memory-backend-shm Message-ID: <0173ce4b2bb4f159f4a6d54e14adbe35f826a848.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stefano Garzarella `memory-backend-shm` can be used with vhost-user devices, so let's add a new test case for it. Acked-by: Thomas Huth Acked-by: Stefan Hajnoczi Reviewed-by: David Hildenbrand Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Stefano Garzarella Message-Id: <20240618100534.145917-1-sgarzare@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/vhost-user-test.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 255bde54ab..0fa8951c9f 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -44,6 +44,8 @@ "mem-path=%s,share=on -numa node,memdev=mem" #define QEMU_CMD_MEMFD " -m %d -object memory-backend-memfd,id=mem,size=%dM," \ " -numa node,memdev=mem" +#define QEMU_CMD_SHM " -m %d -object memory-backend-shm,id=mem,size=%dM," \ + " -numa node,memdev=mem" #define QEMU_CMD_CHR " -chardev socket,id=%s,path=%s%s" #define QEMU_CMD_NETDEV " -netdev vhost-user,id=hs0,chardev=%s,vhostforce=on" @@ -195,6 +197,7 @@ enum test_memfd { TEST_MEMFD_AUTO, TEST_MEMFD_YES, TEST_MEMFD_NO, + TEST_MEMFD_SHM, }; static void append_vhost_net_opts(TestServer *s, GString *cmd_line, @@ -228,6 +231,8 @@ static void append_mem_opts(TestServer *server, GString *cmd_line, if (memfd == TEST_MEMFD_YES) { g_string_append_printf(cmd_line, QEMU_CMD_MEMFD, size, size); + } else if (memfd == TEST_MEMFD_SHM) { + g_string_append_printf(cmd_line, QEMU_CMD_SHM, size, size); } else { const char *root = init_hugepagefs() ? : server->tmpfs; @@ -791,6 +796,19 @@ static void *vhost_user_test_setup_memfd(GString *cmd_line, void *arg) return server; } +static void *vhost_user_test_setup_shm(GString *cmd_line, void *arg) +{ + TestServer *server = test_server_new("vhost-user-test", arg); + test_server_listen(server); + + append_mem_opts(server, cmd_line, 256, TEST_MEMFD_SHM); + server->vu_ops->append_opts(server, cmd_line, ""); + + g_test_queue_destroy(vhost_user_test_cleanup, server); + + return server; +} + static void test_read_guest_mem(void *obj, void *arg, QGuestAllocator *alloc) { TestServer *server = arg; @@ -1084,6 +1102,11 @@ static void register_vhost_user_test(void) "virtio-net", test_read_guest_mem, &opts); + opts.before = vhost_user_test_setup_shm; + qos_add_test("vhost-user/read-guest-mem/shm", + "virtio-net", + test_read_guest_mem, &opts); + if (qemu_memfd_check(MFD_ALLOW_SEALING)) { opts.before = vhost_user_test_setup_memfd; qos_add_test("vhost-user/read-guest-mem/memfd", From patchwork Wed Jul 3 22:48:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723013 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5EA21C2BD09 for ; Wed, 3 Jul 2024 22:51:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8mX-00027R-HX; Wed, 03 Jul 2024 18:48: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 1sP8mU-0001vW-Mp for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:54 -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 1sP8mO-0005Er-P0 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046927; 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=/8Z7JyQo+HEEofucdvOkehCzjauROI/8uJ9hGYzaVe8=; b=en8+Y/RtVJJ0ESaSUYFrpUgTIPJp1XPuuxi71mkEIoFDaaz/dRO03EnFPTzjoCaEdqavDp 6x3Yxw3P/q9U5vSWnLQXNBNiy1acqUp/woCHepCYlvZV6WNY19g8kz5OW6mFLr5EdYTV6l TFBFPhDYCOEvO4Hu/ked4vkJDu4xspU= 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-132-pR3UJFLcN7ehZCAdJQiAyQ-1; Wed, 03 Jul 2024 18:48:45 -0400 X-MC-Unique: pR3UJFLcN7ehZCAdJQiAyQ-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-366e0a4c965so36907f8f.1 for ; Wed, 03 Jul 2024 15:48:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046924; x=1720651724; 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=/8Z7JyQo+HEEofucdvOkehCzjauROI/8uJ9hGYzaVe8=; b=Nnw5Rh+Kzgb66wql9jthM/PUo6gcKvXSlE11TNdHjIf6YMT8E1tEDtaG4O+hHyriWJ NfKUcvFyP9LTmeFDp/PW8F0pUK1+iNrOegYmRz1QDq1ywwV5kbgJ0NSPjguc3f7EyjTs SYR9e+MIajFziAsoypGrQNh6eNFhvraa5Z9xaoRp7KfTisHMxGFJ8RyWzmCjZxhrGa6l cGfYikwaBUbP1CpNu58KVhiFtZZ3zv6xBZypTqb+UuiXIu2nvnIVdTmanJZjyZvSCJNJ Oes6g1urMStExhsP1VV7xKFBZw47CdXI2mxZ/Sg5rnytSSVYeIL2JEygmLX4GhOlIgvK aflQ== X-Gm-Message-State: AOJu0Yxdj9THjwDWOj00PTYTu6Y4tkotgl1SKRol7tNzgZR8pQz+idea kmov2egF0qFSdQdjzhSBVcPEJX0cTqwJ5905A7+H4cqsFNmXVk9OD3w/q+9yKDJ6Wrq7n0Q8BxM cTLVjaLSMzNrfKjcyMvk93mE2600YdTi9uLiAOuhY7/MPi58wBrR0KQCbO9lR0De6a7NL/MPmSk zTmamIAshga0QoMPXRtfNqm7BI8a+BTw== X-Received: by 2002:a05:6000:1c7:b0:367:9d7f:f83f with SMTP id ffacd0b85a97d-3679dd726b2mr1664f8f.58.1720046924304; Wed, 03 Jul 2024 15:48:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF8qZJqSjyfGvwcojzk4qPbCDfOBYwefYkkeeU6ewQsN2S56NidapcoEG7//gi59wnWpnqbWA== X-Received: by 2002:a05:6000:1c7:b0:367:9d7f:f83f with SMTP id ffacd0b85a97d-3679dd726b2mr1654f8f.58.1720046923694; Wed, 03 Jul 2024 15:48:43 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36795e3fe31sm2235346f8f.21.2024.07.03.15.48.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:48:43 -0700 (PDT) Date: Wed, 3 Jul 2024 18:48:40 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas Huth , Manos Pitsidianakis Subject: [PULL v3 56/85] hw/virtio: Fix the de-initialization of vhost-user devices Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass client-ip=170.10.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, T_SPF_TEMPERROR=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Thomas Huth The unrealize functions of the various vhost-user devices are calling the corresponding vhost_*_set_status() functions with a status of 0 to shut down the device correctly. Now these vhost_*_set_status() functions all follow this scheme: bool should_start = virtio_device_should_start(vdev, status); if (vhost_dev_is_started(&vvc->vhost_dev) == should_start) { return; } if (should_start) { /* ... do the initialization stuff ... */ } else { /* ... do the cleanup stuff ... */ } The problem here is virtio_device_should_start(vdev, 0) currently always returns "true" since it internally only looks at vdev->started instead of looking at the "status" parameter. Thus once the device got started once, virtio_device_should_start() always returns true and thus the vhost_*_set_status() functions return early, without ever doing any clean-up when being called with status == 0. This causes e.g. problems when trying to hot-plug and hot-unplug a vhost user devices multiple times since the de-initialization step is completely skipped during the unplug operation. This bug has been introduced in commit 9f6bcfd99f ("hw/virtio: move vm_running check to virtio_device_started") which replaced should_start = status & VIRTIO_CONFIG_S_DRIVER_OK; with should_start = virtio_device_started(vdev, status); which later got replaced by virtio_device_should_start(). This blocked the possibility to set should_start to false in case the status flag VIRTIO_CONFIG_S_DRIVER_OK was not set. Fix it by adjusting the virtio_device_should_start() function to only consider the status flag instead of vdev->started. Since this function is only used in the various vhost_*_set_status() functions for exactly the same purpose, it should be fine to fix it in this central place there without any risk to change the behavior of other code. Fixes: 9f6bcfd99f ("hw/virtio: move vm_running check to virtio_device_started") Buglink: https://issues.redhat.com/browse/RHEL-40708 Signed-off-by: Thomas Huth Message-Id: <20240618121958.88673-1-thuth@redhat.com> Reviewed-by: Manos Pitsidianakis Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 1451926a13..7512afbc84 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -472,9 +472,9 @@ static inline bool virtio_device_started(VirtIODevice *vdev, uint8_t status) * @vdev - the VirtIO device * @status - the devices status bits * - * This is similar to virtio_device_started() but also encapsulates a - * check on the VM status which would prevent a device starting - * anyway. + * This is similar to virtio_device_started() but ignores vdev->started + * and also encapsulates a check on the VM status which would prevent a + * device from starting anyway. */ static inline bool virtio_device_should_start(VirtIODevice *vdev, uint8_t status) { @@ -482,7 +482,7 @@ static inline bool virtio_device_should_start(VirtIODevice *vdev, uint8_t status return false; } - return virtio_device_started(vdev, status); + return status & VIRTIO_CONFIG_S_DRIVER_OK; } static inline void virtio_set_started(VirtIODevice *vdev, bool started) From patchwork Wed Jul 3 22:48:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722994 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C0087C2BD09 for ; Wed, 3 Jul 2024 22:50:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8mZ-0002L4-4z; Wed, 03 Jul 2024 18:48:59 -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 1sP8mW-0001zF-Km for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48: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 1sP8mT-0005Nc-ES for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:48:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046932; 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=SUxXXLDnAjmmN0Yi+4nhd+mhBCkrJEwNWiEK8gau7L4=; b=da2wTwNDPJqzl07KEHi6mU7b3U3NFxAXamv6JNKvlhLQ80jumT6HJKACnWMhvGn/c1NCMj llw4eHv96o3fC8Qzpr1E3xYgLgwS+swT8VISftfPX+xN3pCCIFgtCx+FYrjh9rS6eI99HT 4Nbye9NeH+YbZMxPseiUuRo8bGSGgPM= 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-388-hDfBGpSXPzm8HFFD0MPo0w-1; Wed, 03 Jul 2024 18:48:51 -0400 X-MC-Unique: hDfBGpSXPzm8HFFD0MPo0w-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4257dd7d594so62605e9.0 for ; Wed, 03 Jul 2024 15:48:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046929; x=1720651729; 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=SUxXXLDnAjmmN0Yi+4nhd+mhBCkrJEwNWiEK8gau7L4=; b=TwGMb8fnVmeX3+aIGqKERbk1aCL6dR44JhQX1U3TuOgcPmht8XLg4uZ1UZA+dU+/0l Z1q8Ta3CyG92A3oYv633oW4VkXw1T9gK9ikzZ8dfS++CS3Uz4WCMX3zgA2cxsHtMcVIT WVcKmywaTlvYZwIEwObQcB78woc4oLDkRCh7zL1kX3ELDLt7Rx840kbtE+h1Yta6vgUA 1Dq1OMgimj+gKhO0fE5lfsJi9Rx+iEw/HwKTajgIGV2YdzbsCmpWJ4IUS6Is4JuGZ20x VlNxHTbMCZo0I5HG8FJXcP9+ySa7A3tKQ1ndx7Z+hbuILkSkbXFrKwlRfliVWoRu2l73 Ncvg== X-Gm-Message-State: AOJu0Yyy3tpwb7en+AsxLr6dHTrmGVIkYw9zrgBwNgMdI+4BlFhWq6UY N+2glcoMs3hQMht6LOwAVJCykNXDwVZptBpqsdIk04L6QBzfmiMPtmoThfJHrk8ylfvM0r6RxMH b1y+7AStqw5Y3KyxpPziemTK1suX1AXYk0pqK0EnPGFYnvSg1XWz9wCbJ4FKDQ/XS3biAeNNVHt lrcgjoGlzrHDVAui/tzsp67DEMtIzftw== X-Received: by 2002:a05:600c:1584:b0:424:90f4:309e with SMTP id 5b1f17b1804b1-4264a3d83famr342045e9.6.1720046929697; Wed, 03 Jul 2024 15:48:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/rXY0IBdUZd+Gs2Grgok6scRx8soI8zNGjb4IVXH4MiwDUvPEz00YaM8OzBV9Em58di2VCQ== X-Received: by 2002:a05:600c:1584:b0:424:90f4:309e with SMTP id 5b1f17b1804b1-4264a3d83famr341895e9.6.1720046929043; Wed, 03 Jul 2024 15:48:49 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd623sm16964110f8f.16.2024.07.03.15.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:48:47 -0700 (PDT) Date: Wed, 3 Jul 2024 18:48:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Nicolin Chen , Richard Henderson , Eric Auger , Igor Mammedov , Ani Sinha , Shannon Zhao , qemu-arm@nongnu.org Subject: [PULL v3 57/85] hw/arm/virt-acpi-build: Drop local iort_node_offset 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Nicolin Chen Both the other two callers of build_iort_id_mapping() just directly pass in the IORT_NODE_OFFSET macro. Keeping a "const uint32_t" local variable storing the same value doesn't have any gain. Simplify this by replacing the only place using this local variable with the macro directly. Signed-off-by: Nicolin Chen Message-Id: <20240619001708.926511-1-nicolinc@nvidia.com> Reviewed-by: Richard Henderson Reviewed-by: Eric Auger Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/arm/virt-acpi-build.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index b2366f24f9..102e2da934 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -269,7 +269,6 @@ static void build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { int i, nb_nodes, rc_mapping_count; - const uint32_t iort_node_offset = IORT_NODE_OFFSET; size_t node_size, smmu_offset = 0; AcpiIortIdMapping *idmap; uint32_t id = 0; @@ -415,7 +414,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) range = &g_array_index(its_idmaps, AcpiIortIdMapping, i); /* output IORT node is the ITS group node (the first node) */ build_iort_id_mapping(table_data, range->input_base, - range->id_count, iort_node_offset); + range->id_count, IORT_NODE_OFFSET); } } else { /* output IORT node is the ITS group node (the first node) */ From patchwork Wed Jul 3 22:48:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722993 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 055E0C3814E for ; Wed, 3 Jul 2024 22:50:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8ms-0004mj-Gm; Wed, 03 Jul 2024 18:49: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 1sP8mo-0004U9-QB for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49: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 1sP8mY-0005Tu-Cu for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046937; 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=H3osRPyR8JjW6MeyHBrRsmkcAIK1uR3HKs135scl6wM=; b=SY1YGsNQGllu8x5XJjc1PDJESSF/C3fPbPzxuIeWTnO33yfa93oV4ZNo0c2e+hhOnDkOEn MsYCNfA4YVIrfo4+byO1y0ds0G4XM3DSv92R6r1WYlWxJcqgxg3Erc8YTlWi9zwr49KXX7 c50CII3l0xmRJyjHd4/2jodc7laKsWc= 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-557-p_0d4iUpMsCdtph_woEHiA-1; Wed, 03 Jul 2024 18:48:56 -0400 X-MC-Unique: p_0d4iUpMsCdtph_woEHiA-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-367987cff30so35037f8f.1 for ; Wed, 03 Jul 2024 15:48:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046935; x=1720651735; 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=H3osRPyR8JjW6MeyHBrRsmkcAIK1uR3HKs135scl6wM=; b=MkR6YfX043vIwW/EU467l3iaMUWs8Sz9QbxEYMzz9FBaDPMkKqSw/DOmc15/c4Xqx2 aFhB9CK6hzQ7/rSGdI1nuZwt8M0JpI/Dh6vJnRUkfNQ+HQZa6i9xJfvvbi/Ra5QAbej4 U26zfhyA6rMvnNVyobOp08eW7SJ26XJaIXxQZ5zrmGmm0rSqgEC9JfuFEK8NeHvI2bng VnDEiEVcNuxzUlbNyvrbtT9J61jrKLqJ/U8xosHflFqBfBNjR7UAtG6F8XjqVlLTn4Qw 4mo6Tq7nBchTQ52MZRLmSX6RmLdr0fBXBmXcdkEvvDkEWeBca7TZkHIOPvWYep0bBz33 tKRw== X-Gm-Message-State: AOJu0YzY2KMDLn3yEXp/LaTDAs/SwQCALeMrCk8S1UgZOcRGROuETgAd fmkjbDpWJLfoKaJCRdycl6aRSoprJawEVdIwIh2C2Sc6NFe6tMDGLCTJaPZ4y8XKNoakp5VsAcn JOntytBSxO1D7scjOLnGPfj0Ikr5uXqkngS8VlEwN0+y966A4gQnAtbiZ0nJk/kN5TejQkrwDJk G4z06gp9rPmy8P8lun/sRld4DjL0BfXg== X-Received: by 2002:a5d:66ca:0:b0:367:8f29:f7ae with SMTP id ffacd0b85a97d-3679dd66b1bmr5160f8f.49.1720046934776; Wed, 03 Jul 2024 15:48:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFKhCAyPDpugccROJeD258jAmHezRr/Sn4NGzUPphB9Iay3BGmMuCHosOVZfO24CbmP1GOMg== X-Received: by 2002:a5d:66ca:0:b0:367:8f29:f7ae with SMTP id ffacd0b85a97d-3679dd66b1bmr5139f8f.49.1720046934182; Wed, 03 Jul 2024 15:48:54 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1d0b24sm1234945e9.3.2024.07.03.15.48.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:48:53 -0700 (PDT) Date: Wed, 3 Jul 2024 18:48:49 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , David Woodhouse , David Woodhouse , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum , Sergio Lopez , Marcelo Tosatti , Paul Durrant , kvm@vger.kernel.org Subject: [PULL v3 58/85] hw/i386/fw_cfg: Add etc/e820 to fw_cfg late Message-ID: <93c76555d842b5d84b95f66abecb6b19545338d9.1720046570.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: -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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: David Woodhouse In e820_add_entry() the e820_table is reallocated with g_renew() to make space for a new entry. However, fw_cfg_arch_create() just uses the existing e820_table pointer. This leads to a use-after-free if anything adds a new entry after fw_cfg is set up. Shift the addition of the etc/e820 file to the machine done notifier, via a new fw_cfg_add_e820() function. Also make e820_table private and use an e820_get_table() accessor function for it, which sets a flag that will trigger an assert() for any *later* attempts to add to the table. Make e820_add_entry() return void, as most callers don't check for error anyway. Signed-off-by: David Woodhouse Message-Id: Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/e820_memory_layout.h | 8 ++------ hw/i386/fw_cfg.h | 1 + hw/i386/e820_memory_layout.c | 17 ++++++++++++----- hw/i386/fw_cfg.c | 18 +++++++++++++----- hw/i386/microvm.c | 4 ++-- hw/i386/pc.c | 1 + target/i386/kvm/kvm.c | 6 +----- target/i386/kvm/xen-emu.c | 7 +------ 8 files changed, 33 insertions(+), 29 deletions(-) diff --git a/hw/i386/e820_memory_layout.h b/hw/i386/e820_memory_layout.h index 7c239aa033..b50acfa201 100644 --- a/hw/i386/e820_memory_layout.h +++ b/hw/i386/e820_memory_layout.h @@ -22,13 +22,9 @@ struct e820_entry { uint32_t type; } QEMU_PACKED __attribute((__aligned__(4))); -extern struct e820_entry *e820_table; - -int e820_add_entry(uint64_t address, uint64_t length, uint32_t type); -int e820_get_num_entries(void); +void e820_add_entry(uint64_t address, uint64_t length, uint32_t type); bool e820_get_entry(int index, uint32_t type, uint64_t *address, uint64_t *length); - - +int e820_get_table(struct e820_entry **table); #endif diff --git a/hw/i386/fw_cfg.h b/hw/i386/fw_cfg.h index 92e310f5fd..e560fd7be8 100644 --- a/hw/i386/fw_cfg.h +++ b/hw/i386/fw_cfg.h @@ -27,5 +27,6 @@ void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg, SmbiosEntryPointType ep_type); void fw_cfg_build_feature_control(MachineState *ms, FWCfgState *fw_cfg); void fw_cfg_add_acpi_dsdt(Aml *scope, FWCfgState *fw_cfg); +void fw_cfg_add_e820(FWCfgState *fw_cfg); #endif diff --git a/hw/i386/e820_memory_layout.c b/hw/i386/e820_memory_layout.c index 06970ac44a..3e848fb69c 100644 --- a/hw/i386/e820_memory_layout.c +++ b/hw/i386/e820_memory_layout.c @@ -11,22 +11,29 @@ #include "e820_memory_layout.h" static size_t e820_entries; -struct e820_entry *e820_table; +static struct e820_entry *e820_table; +static gboolean e820_done; -int e820_add_entry(uint64_t address, uint64_t length, uint32_t type) +void e820_add_entry(uint64_t address, uint64_t length, uint32_t type) { + assert(!e820_done); + /* new "etc/e820" file -- include ram and reserved entries */ e820_table = g_renew(struct e820_entry, e820_table, e820_entries + 1); e820_table[e820_entries].address = cpu_to_le64(address); e820_table[e820_entries].length = cpu_to_le64(length); e820_table[e820_entries].type = cpu_to_le32(type); e820_entries++; - - return e820_entries; } -int e820_get_num_entries(void) +int e820_get_table(struct e820_entry **table) { + e820_done = true; + + if (table) { + *table = e820_table; + } + return e820_entries; } diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index 7c43c325ef..0e4494627c 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -48,6 +48,15 @@ const char *fw_cfg_arch_key_name(uint16_t key) return NULL; } +/* Add etc/e820 late, once all regions should be present */ +void fw_cfg_add_e820(FWCfgState *fw_cfg) +{ + struct e820_entry *table; + int nr_e820 = e820_get_table(&table); + + fw_cfg_add_file(fw_cfg, "etc/e820", table, nr_e820 * sizeof(*table)); +} + void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg, SmbiosEntryPointType ep_type) { @@ -60,6 +69,7 @@ void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg, PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); MachineClass *mc = MACHINE_GET_CLASS(pcms); X86CPU *cpu = X86_CPU(ms->possible_cpus->cpus[0].cpu); + int nr_e820; if (pcmc->smbios_defaults) { /* These values are guest ABI, do not change */ @@ -78,8 +88,9 @@ void fw_cfg_build_smbios(PCMachineState *pcms, FWCfgState *fw_cfg, } /* build the array of physical mem area from e820 table */ - mem_array = g_malloc0(sizeof(*mem_array) * e820_get_num_entries()); - for (i = 0, array_count = 0; i < e820_get_num_entries(); i++) { + nr_e820 = e820_get_table(NULL); + mem_array = g_malloc0(sizeof(*mem_array) * nr_e820); + for (i = 0, array_count = 0; i < nr_e820; i++) { uint64_t addr, len; if (e820_get_entry(i, E820_RAM, &addr, &len)) { @@ -138,9 +149,6 @@ FWCfgState *fw_cfg_arch_create(MachineState *ms, #endif fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, 1); - fw_cfg_add_file(fw_cfg, "etc/e820", e820_table, - sizeof(struct e820_entry) * e820_get_num_entries()); - fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, &hpet_cfg, sizeof(hpet_cfg)); /* allocate memory for the NUMA channel: one (64bit) word for the number * of nodes, one word for each VCPU->node and one word for each node to diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index fec63cacfa..40edcee7af 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -324,8 +324,6 @@ static void microvm_memory_init(MicrovmMachineState *mms) fw_cfg_add_i16(fw_cfg, FW_CFG_MAX_CPUS, machine->smp.max_cpus); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)machine->ram_size); fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, 1); - fw_cfg_add_file(fw_cfg, "etc/e820", e820_table, - sizeof(struct e820_entry) * e820_get_num_entries()); rom_set_fw(fw_cfg); @@ -586,9 +584,11 @@ static void microvm_machine_done(Notifier *notifier, void *data) { MicrovmMachineState *mms = container_of(notifier, MicrovmMachineState, machine_done); + X86MachineState *x86ms = X86_MACHINE(mms); acpi_setup_microvm(mms); dt_setup_microvm(mms); + fw_cfg_add_e820(x86ms->fw_cfg); } static void microvm_powerdown_req(Notifier *notifier, void *data) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 77415064c6..d2c29fbfcb 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -625,6 +625,7 @@ void pc_machine_done(Notifier *notifier, void *data) acpi_setup(); if (x86ms->fw_cfg) { fw_cfg_build_smbios(pcms, x86ms->fw_cfg, pcms->smbios_entry_point_type); + fw_cfg_add_e820(x86ms->fw_cfg); fw_cfg_build_feature_control(MACHINE(pcms), x86ms->fw_cfg); /* update FW_CFG_NB_CPUS to account for -device added CPUs */ fw_cfg_modify_i16(x86ms->fw_cfg, FW_CFG_NB_CPUS, x86ms->boot_cpus); diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index dd8b0f3313..bf182570fe 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2706,11 +2706,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) } /* Tell fw_cfg to notify the BIOS to reserve the range. */ - ret = e820_add_entry(identity_base, 0x4000, E820_RESERVED); - if (ret < 0) { - fprintf(stderr, "e820_add_entry() table is full\n"); - return ret; - } + e820_add_entry(identity_base, 0x4000, E820_RESERVED); shadow_mem = object_property_get_int(OBJECT(s), "kvm-shadow-mem", &error_abort); if (shadow_mem != -1) { diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c index fc2c2321ac..2f89dc628e 100644 --- a/target/i386/kvm/xen-emu.c +++ b/target/i386/kvm/xen-emu.c @@ -176,12 +176,7 @@ int kvm_xen_init(KVMState *s, uint32_t hypercall_msr) s->xen_caps = xen_caps; /* Tell fw_cfg to notify the BIOS to reserve the range. */ - ret = e820_add_entry(XEN_SPECIAL_AREA_ADDR, XEN_SPECIAL_AREA_SIZE, - E820_RESERVED); - if (ret < 0) { - fprintf(stderr, "e820_add_entry() table is full\n"); - return ret; - } + e820_add_entry(XEN_SPECIAL_AREA_ADDR, XEN_SPECIAL_AREA_SIZE, E820_RESERVED); /* The pages couldn't be overlaid until KVM was initialized */ xen_primary_console_reset(); From patchwork Wed Jul 3 22:48:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722995 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B22FC31D97 for ; Wed, 3 Jul 2024 22:50:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8mt-0004rD-L9; Wed, 03 Jul 2024 18:49: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 1sP8mq-0004fg-7e for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:16 -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 1sP8me-0005iU-TW for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046942; 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=FXwifnBJIBh3zju1O5LT6q/8nalot/g3k4ePiwaH62E=; b=ZVTCsj1mlm79tsobKDPMb5xT4y3tuQkEReBQz+DGvCjpSw37h4QtXOJdScUUITYEXTUdVE EQjSvnVLMmOELlOyPIIS9rMnyAK6bHHi9AJwzT/bQ1m2SjT/qengMP5MN4fuJQ8X74qdYR iQ5O/OcgGRQTuu/2YCba7Yqgb2172kM= 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-81-biRXV3JaNEO04Rmtgfk6IQ-1; Wed, 03 Jul 2024 18:49:01 -0400 X-MC-Unique: biRXV3JaNEO04Rmtgfk6IQ-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-425685183edso104365e9.0 for ; Wed, 03 Jul 2024 15:49:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046939; x=1720651739; 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=FXwifnBJIBh3zju1O5LT6q/8nalot/g3k4ePiwaH62E=; b=FAXtf+GH5J119YUN7j2pZ74wS1z5eyLAmV3JXsXq7AKCpX1QsMcedf09DQiqlQ2l43 oAW0BsZdeIOOrX0JR7gcsXpauq6oUtNxrzwlpeoDBVLqJTTBSjzw2qNSl44PBE1edVVC lpoVVu2+CXuyGScaUXn3u+2iaGpy0pb0d5lkZovpuKEAlnLxRowFBA3I1u8h50wKqMwR oDxgrXCzCdAa5WTVmV4GaTXNY9DTUb1rqtG7bZIeBDz7EN7xueljd0EnOJGtT/uLvqb8 wn2G4oW3nNTQD9x4SwIeQMGZ1JzffaQhd+PZRVM2ZEjbD1Hox4r8/5NLVBwZf72rqG56 z4Ag== X-Gm-Message-State: AOJu0YyctfvLwejaXw84eaTdF8F3B4wE+JvD10poT0F7acGEPLBIVR5g Q+yHulngYuEpZHg+7Pu9Fc/Ppn2NI3j8pAMLeukPdm4ghnwb5b924PVWBjAAuV1XURBDRBSwgwd VQZTEQjSqZDgP2kmmje85EcFOgZrgq7zzWMdHcfrowJtm20ar3xRAcxxB9yAVeRWCrohuazMe7E gvQXHRYvvPmnLWWpdA3BzaLmxl6NmE5w== X-Received: by 2002:a05:600c:1d01:b0:424:a823:51d7 with SMTP id 5b1f17b1804b1-4264a3d98edmr343105e9.5.1720046938874; Wed, 03 Jul 2024 15:48:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSkQI1Qx2aVlbsBEWx5hEBMzJWxGE8eTgPoQwJ7lVZrkUmZoWytvo3wHaUROOtX8hQwMEaWQ== X-Received: by 2002:a05:600c:1d01:b0:424:a823:51d7 with SMTP id 5b1f17b1804b1-4264a3d98edmr342935e9.5.1720046937884; Wed, 03 Jul 2024 15:48:57 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a21d2adsm1174445e9.29.2024.07.03.15.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:48:57 -0700 (PDT) Date: Wed, 3 Jul 2024 18:48:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Nicolin Chen , Eric Auger , Igor Mammedov , Ani Sinha , Shannon Zhao , qemu-arm@nongnu.org Subject: [PULL v3 59/85] hw/arm/virt-acpi-build: Fix id_count in build_iort_id_mapping Message-ID: <5786827f47a0721bb997ad3f653d2b843ba3fd76.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Nicolin Chen It's observed that Linux kernel booting with the VM reports a "conflicting mapping for input ID" FW_BUG. The IORT doc defines "Number of IDs" to be "the number of IDs in the range minus one", while virt-acpi-build.c simply stores the number of IDs in the id_count without the "minus one". Meanwhile, some of the callers pass in a 0xFFFF following the spec. So, this is a mismatch between the function and its callers. Fix build_iort_id_mapping() by internally subtracting one from the pass-in @id_count. Accordingly make sure that all existing callers pass in a value without the "minus one", i.e. change all 0xFFFFs to 0x10000s. Also, add a few lines of comments to highlight this change along with the referencing document for this build_iort_id_mapping(). Fixes: 42e0f050e3a5 ("hw/arm/virt-acpi-build: Add IORT support to bypass SMMUv3") Suggested-by: Michael S. Tsirkin Reviewed-by: Eric Auger Signed-off-by: Nicolin Chen Message-Id: <20240619201243.936819-1-nicolinc@nvidia.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/arm/virt-acpi-build.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 102e2da934..e10cad86dd 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -209,12 +209,19 @@ static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms) #define ROOT_COMPLEX_ENTRY_SIZE 36 #define IORT_NODE_OFFSET 48 +/* + * Append an ID mapping entry as described by "Table 4 ID mapping format" in + * "IO Remapping Table System Software on ARM Platforms", Chapter 3. + * Document number: ARM DEN 0049E.f, Apr 2024 + * + * Note that @id_count gets internally subtracted by one, following the spec. + */ static void build_iort_id_mapping(GArray *table_data, uint32_t input_base, uint32_t id_count, uint32_t out_ref) { - /* Table 4 ID mapping format */ build_append_int_noprefix(table_data, input_base, 4); /* Input base */ - build_append_int_noprefix(table_data, id_count, 4); /* Number of IDs */ + /* Number of IDs - The number of IDs in the range minus one */ + build_append_int_noprefix(table_data, id_count - 1, 4); build_append_int_noprefix(table_data, input_base, 4); /* Output base */ build_append_int_noprefix(table_data, out_ref, 4); /* Output Reference */ /* Flags */ @@ -305,8 +312,8 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) } /* Append the last RC -> ITS ID mapping */ - if (next_range.input_base < 0xFFFF) { - next_range.id_count = 0xFFFF - next_range.input_base; + if (next_range.input_base < 0x10000) { + next_range.id_count = 0x10000 - next_range.input_base; g_array_append_val(its_idmaps, next_range); } @@ -365,7 +372,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) build_append_int_noprefix(table_data, 0, 4); /* output IORT node is the ITS group node (the first node) */ - build_iort_id_mapping(table_data, 0, 0xFFFF, IORT_NODE_OFFSET); + build_iort_id_mapping(table_data, 0, 0x10000, IORT_NODE_OFFSET); } /* Table 17 Root Complex Node */ @@ -418,7 +425,7 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) } } else { /* output IORT node is the ITS group node (the first node) */ - build_iort_id_mapping(table_data, 0, 0xFFFF, IORT_NODE_OFFSET); + build_iort_id_mapping(table_data, 0, 0x10000, IORT_NODE_OFFSET); } acpi_table_end(linker, &table); From patchwork Wed Jul 3 22:48:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723032 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1351EC31D97 for ; Wed, 3 Jul 2024 22:52:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8my-0005Lg-3H; Wed, 03 Jul 2024 18:49: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 1sP8ms-0004ou-9g for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:19 -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 1sP8mh-0005jI-BW for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046945; 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=Qq6X3kMK8U5RTSY4JoCXP6cD3LHFaX4iQOeFqnwxYP8=; b=dfBQV6p845Sxk+L00Ag7hBM4ygLxVzyK9VJR6oe96Jpy6DjMn65wMEo8jZJH+S8sb2kNHz 2Jho2K8AJanxilDPvtqhluuTlpwJIiZ8cOQ/BPYpXxjwZu8XBlc5yPJpStCcDyys8O5gJd ma02KLOkCO9wzvIHygzm3YN3G4d1vv0= 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-686-eDJGmhNYNCGuaVCEWCgtwg-1; Wed, 03 Jul 2024 18:49:04 -0400 X-MC-Unique: eDJGmhNYNCGuaVCEWCgtwg-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-36794ef4815so33833f8f.1 for ; Wed, 03 Jul 2024 15:49:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046942; x=1720651742; 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=Qq6X3kMK8U5RTSY4JoCXP6cD3LHFaX4iQOeFqnwxYP8=; b=kXszI61jxEiF/eE6n7kkhDZtbyeD/lGFw1c9xtvHBS3tGUyf0qgd8fgx5Gs5GdJf0E FWHN4AAOIhOMVnvCiMomPAOUDyB5c4sGKi9bWT6AxKquby7CWmjv1BjQHGkG2rYbyO7W EoLZgrLxzKqrVeIfiv2XY2QtnCnPsy/GiSw4vsV5/K5O0THYbkRv47pAPxD0LTbc8D92 LftY0Y2NjlTzoF48Od2gIEN4rGWEh1PY5FQjRmlZf0GXnzkKvI556UHoS8Xv6GXtQMB8 ieYwPbx/zgVvKS8wA+Zedrn/dzS2dkvvAWbGArMqjAKOtAf/3xyrQg35sBTLCN1QxIJ+ U31A== X-Gm-Message-State: AOJu0Yy6IzQ7Ms+04dSpif0dVUkEMLKK01cjBuG7mf8kF3/xk2Tkycx0 MJy74XylFKipw8YsNcFfYQrkJP7iOH/y6gJJ1AR+xnt4ztNzfBqEzdel3jNioPlLn6QmF9R/KsH gOG10toUqYG22iBA4Kt8r8V1Vcg+hQayP2xBSNdhk17cKyb1AdZe+ugTPwe4XV6acK3cSiP49Cp ls4zHSCdrxw2KAkki0APE7FzhVi/07xA== X-Received: by 2002:a5d:634b:0:b0:367:40e6:46bd with SMTP id ffacd0b85a97d-3679dd73dd5mr3268f8f.61.1720046942680; Wed, 03 Jul 2024 15:49:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwNgm45H9+37MtlccIZDiJAMzaIGI9WslSjpYndIx3Pphid0K6fLJy+PomiNZpDtDL2fpBEA== X-Received: by 2002:a5d:634b:0:b0:367:40e6:46bd with SMTP id ffacd0b85a97d-3679dd73dd5mr3258f8f.61.1720046942114; Wed, 03 Jul 2024 15:49:02 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a10337csm16824378f8f.97.2024.07.03.15.48.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:49:01 -0700 (PDT) Date: Wed, 3 Jul 2024 18:48:58 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Gerd Hoffmann , Alistair Francis , Igor Mammedov , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PULL v3 60/85] uefi-test-tools/UefiTestToolsPkg: Add RISC-V support 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Sunil V L Enable building the test application for RISC-V with appropriate dependencies updated. Signed-off-by: Sunil V L Acked-by: Gerd Hoffmann Acked-by: Alistair Francis Acked-by: Igor Mammedov Message-Id: <20240625150839.1358279-3-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/uefi-test-tools/UefiTestToolsPkg/UefiTestToolsPkg.dsc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/uefi-test-tools/UefiTestToolsPkg/UefiTestToolsPkg.dsc b/tests/uefi-test-tools/UefiTestToolsPkg/UefiTestToolsPkg.dsc index c8511cd732..0902fd3c73 100644 --- a/tests/uefi-test-tools/UefiTestToolsPkg/UefiTestToolsPkg.dsc +++ b/tests/uefi-test-tools/UefiTestToolsPkg/UefiTestToolsPkg.dsc @@ -19,7 +19,7 @@ PLATFORM_VERSION = 0.1 PLATFORM_NAME = UefiTestTools SKUID_IDENTIFIER = DEFAULT - SUPPORTED_ARCHITECTURES = ARM|AARCH64|IA32|X64 + SUPPORTED_ARCHITECTURES = ARM|AARCH64|IA32|X64|RISCV64 BUILD_TARGETS = DEBUG [BuildOptions.IA32] @@ -60,6 +60,10 @@ [LibraryClasses.IA32, LibraryClasses.X64] BaseMemoryLib|MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr.inf + RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf + +[LibraryClasses.RISCV64] + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf [PcdsFixedAtBuild] gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8040004F From patchwork Wed Jul 3 22:49:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723008 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18B24C2BD09 for ; Wed, 3 Jul 2024 22:51:18 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8mw-00059p-EM; Wed, 03 Jul 2024 18:49:22 -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 1sP8ms-0004p2-Mf for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:19 -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 1sP8mk-0005sY-LJ for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046950; 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=wXu48vkZ7/C+tOxLrIxzTN9h9b+wSo5eOaPVc/4Fs+U=; b=O8ZzZOWqIM1Q9OzBili2HlSxa6WJQBcBvP37XeHvADaHSBiLrsJoxXQDnhDnBVG+Z3E3DF k83WQKxY7bheZwZC8sJYnPoCu/JjIt/rQKOUDHqj0pWSpwHvVZhw8UxvaAMsdqnt2fGkRZ eyWsItTB+rujOrkhZ8S1FjaWI5DBSIo= 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-90-26da-2vkPaCC8s8efYIqmQ-1; Wed, 03 Jul 2024 18:49:08 -0400 X-MC-Unique: 26da-2vkPaCC8s8efYIqmQ-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-367960f4673so535709f8f.1 for ; Wed, 03 Jul 2024 15:49:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046947; x=1720651747; 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=wXu48vkZ7/C+tOxLrIxzTN9h9b+wSo5eOaPVc/4Fs+U=; b=fsN7e7LiK79M4kF8JcJOfxkDxFPcZ3f6BMO0BiCrg6oqdGrLsMI2m1NvxDAVl+OMza aRdm8PshhtaVmKuTI8teqR7OdzWjuiYB8bsBfgkm6hv70qAu7cUU/gP10mcw4YmqQp9F 1TRzaUt9k8gctNngw0qbR6NSwRhC/94F4PMJ6igiiCrFLmcOojjbc8LFeiX3OHAwB97u kFCOFCGYRktVtGCVX6wnKF5z4wxtBRqIVhf+RvV0XetfKHwUlE9a5CbbRYXchFMfpxuX 2mTzGqonWGcXqCJlhfxX7OpsAPmkg761C/va5dvVWordAtiGB3ApVGYt2wfIWKus3V3F fxeA== X-Gm-Message-State: AOJu0Yxl7HxzsfEDq5VE2lypFN5fEC6mjR+PKHK74STAZnQFOb3SVKuo k5/KveXWSiGFeWVm3cssm6q/MGR/CsN70MeXKogq1IIraAHgqEkBZ1WgFaf27CoGrJGNxNRJiGQ FNYTquFl4uqheagqR8djVUedC4EfY6BYmPX3mamCQvlCsegryVfECW+9hzFXUOiIwlJnRZ3Ue1y p4d+AIqYQQjioxtAhqZUZpuJ2+NofYNw== X-Received: by 2002:a05:600c:4f0c:b0:424:84fb:9fd2 with SMTP id 5b1f17b1804b1-42640b6e086mr27145925e9.19.1720046947030; Wed, 03 Jul 2024 15:49:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEWnl5KRGoJO02dkcidekGahK4zIsQQ5S6iCycyafTAJap5UPntX81nwoYOHPFb2EEwymqyAQ== X-Received: by 2002:a05:600c:4f0c:b0:424:84fb:9fd2 with SMTP id 5b1f17b1804b1-42640b6e086mr27145635e9.19.1720046946049; Wed, 03 Jul 2024 15:49:06 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36796351169sm1995299f8f.95.2024.07.03.15.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:49:05 -0700 (PDT) Date: Wed, 3 Jul 2024 18:49:02 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Gerd Hoffmann , Igor Mammedov , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PULL v3 61/85] uefi-test-tools: Add support for python based build script 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Sunil V L edk2-funcs.sh which is used in this Makefile, was removed in the commit c28a2891f3 ("edk2: update build script"). It is replaced with a python based script. So, update the Makefile and add the configuration file as required to support the python based build script. Signed-off-by: Sunil V L Acked-by: Gerd Hoffmann Acked-by: Igor Mammedov Message-Id: <20240625150839.1358279-4-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/uefi-test-tools/Makefile | 19 +++---- tests/uefi-test-tools/uefi-test-build.config | 52 ++++++++++++++++++++ 2 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 tests/uefi-test-tools/uefi-test-build.config diff --git a/tests/uefi-test-tools/Makefile b/tests/uefi-test-tools/Makefile index 0c003f2877..f4eaebd8ff 100644 --- a/tests/uefi-test-tools/Makefile +++ b/tests/uefi-test-tools/Makefile @@ -12,7 +12,7 @@ edk2_dir := ../../roms/edk2 images_dir := ../data/uefi-boot-images -emulation_targets := arm aarch64 i386 x86_64 +emulation_targets := arm aarch64 i386 x86_64 riscv64 uefi_binaries := bios-tables-test intermediate_suffixes := .efi .fat .iso.raw @@ -56,7 +56,8 @@ Build/%.iso.raw: Build/%.fat # stripped from, the argument. map_arm_to_uefi = $(subst arm,ARM,$(1)) map_aarch64_to_uefi = $(subst aarch64,AA64,$(call map_arm_to_uefi,$(1))) -map_i386_to_uefi = $(subst i386,IA32,$(call map_aarch64_to_uefi,$(1))) +map_riscv64_to_uefi = $(subst riscv64,RISCV64,$(call map_aarch64_to_uefi,$(1))) +map_i386_to_uefi = $(subst i386,IA32,$(call map_riscv64_to_uefi,$(1))) map_x86_64_to_uefi = $(subst x86_64,X64,$(call map_i386_to_uefi,$(1))) map_to_uefi = $(subst .,,$(call map_x86_64_to_uefi,$(1))) @@ -70,7 +71,7 @@ Build/%.fat: Build/%.efi uefi_bin_b=$$(stat --format=%s -- $<) && \ uefi_fat_kb=$$(( (uefi_bin_b * 11 / 10 + 1023) / 1024 )) && \ uefi_fat_kb=$$(( uefi_fat_kb >= 64 ? uefi_fat_kb : 64 )) && \ - mkdosfs -C $@ -n $(basename $(@F)) -- $$uefi_fat_kb + mkdosfs -C $@ -n "bios-test" -- $$uefi_fat_kb MTOOLS_SKIP_CHECK=1 mmd -i $@ ::EFI MTOOLS_SKIP_CHECK=1 mmd -i $@ ::EFI/BOOT MTOOLS_SKIP_CHECK=1 mcopy -i $@ -- $< \ @@ -95,15 +96,9 @@ Build/%.fat: Build/%.efi # we must mark the recipe manually as recursive, by using the "+" indicator. # This way, when the inner "make" starts a parallel build of the target edk2 # module, it can communicate with the outer "make"'s job server. -Build/bios-tables-test.%.efi: build-edk2-tools - +./build.sh $(edk2_dir) BiosTablesTest $* $@ - -build-edk2-tools: - cd $(edk2_dir)/BaseTools && git submodule update --init --force - $(MAKE) -C $(edk2_dir)/BaseTools \ - PYTHON_COMMAND=$${EDK2_PYTHON_COMMAND:-python3} \ - EXTRA_OPTFLAGS='$(EDK2_BASETOOLS_OPTFLAGS)' \ - EXTRA_LDFLAGS='$(EDK2_BASETOOLS_LDFLAGS)' +Build/bios-tables-test.%.efi: + $(PYTHON) ../../roms/edk2-build.py --config uefi-test-build.config \ + --match $* clean: rm -rf Build Conf log diff --git a/tests/uefi-test-tools/uefi-test-build.config b/tests/uefi-test-tools/uefi-test-build.config new file mode 100644 index 0000000000..1f389ae541 --- /dev/null +++ b/tests/uefi-test-tools/uefi-test-build.config @@ -0,0 +1,52 @@ +[global] +core = ../../roms/edk2 + +#################################################################################### +# arm + +[build.arm] +conf = UefiTestToolsPkg/UefiTestToolsPkg.dsc +plat = UefiTestTools +dest = ./Build +arch = ARM +cpy1 = ARM/BiosTablesTest.efi bios-tables-test.arm.efi + +#################################################################################### +# aarch64 + +[build.aarch64] +conf = UefiTestToolsPkg/UefiTestToolsPkg.dsc +plat = UefiTestTools +dest = ./Build +arch = AARCH64 +cpy1 = AARCH64/BiosTablesTest.efi bios-tables-test.aarch64.efi + +#################################################################################### +# riscv64 + +[build.riscv] +conf = UefiTestToolsPkg/UefiTestToolsPkg.dsc +plat = UefiTestTools +dest = ./Build +arch = RISCV64 +cpy1 = RISCV64/BiosTablesTest.efi bios-tables-test.riscv64.efi + +#################################################################################### +# ia32 + +[build.ia32] +conf = UefiTestToolsPkg/UefiTestToolsPkg.dsc +plat = UefiTestTools +dest = ./Build +arch = IA32 +cpy1 = IA32/BiosTablesTest.efi bios-tables-test.i386.efi + +#################################################################################### +# x64 + +[build.x64] +conf = UefiTestToolsPkg/UefiTestToolsPkg.dsc +plat = UefiTestTools +dest = ./Build +arch = X64 +cpy1 = X64/BiosTablesTest.efi bios-tables-test.x86_64.efi From patchwork Wed Jul 3 22:49:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722990 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D6B38C31D97 for ; Wed, 3 Jul 2024 22:50:14 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8mz-0005Vd-PW; Wed, 03 Jul 2024 18:49: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 1sP8mt-0004rB-Gi for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:19 -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 1sP8mo-000697-GB for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046953; 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=XZlKbjCfDnCk5ojJHJFE0MXkNQoHYTrUaZpWkcL5Y50=; b=Ez9tkp8ALWjvANQUYRDoDOvllwToxiL6sV1uy5hYOaOZo0AAIK7/cEf2k/5Yp/yRl3skXe v3MhYzyLwSIK1TxMjvjNQG8dsdBDzFi24Nbs+6Sfl1+bzS0tf5qJhc65GLf47UqWBruA+3 xRuCnr3vJt3FhYht4dGWR04o6ZsAIhw= 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-269-uasoGAkMP7KMzxAIMYwwAQ-1; Wed, 03 Jul 2024 18:49:12 -0400 X-MC-Unique: uasoGAkMP7KMzxAIMYwwAQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4256809ae27so20245e9.1 for ; Wed, 03 Jul 2024 15:49:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046951; x=1720651751; 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=XZlKbjCfDnCk5ojJHJFE0MXkNQoHYTrUaZpWkcL5Y50=; b=LHTGbbRYcFY9WtqQiesk+SyRGfzrhJnrXSckIOVUvxLtZKNBlIuUSneZYVO+KKGBMD PW+NdMXciFTIg4G3DOjT2+SBnX0EithkWHGLaGb6FRn8W6e6r1JXM7r7KkvC+nsp5sPH 2vh3S4NP1iyi8BnvaBej28JBwEKZKpi61BPlxn68s+A9B6yxap53kMPGWPJEsqTMDJg3 uPhU34xLLGXdlLf2ogTqY04y9+ObBc5D5wEBLhi8FPZ477bmRN74fp+WmXLsXjsI1Lm3 HxFRQSbdLVesAkNL5GdV9KFpMdSZhMtmVXlKvoW95Cois1CW4fbxtW1pfgV5YhMjCH45 sSbg== X-Gm-Message-State: AOJu0YzQA5S8Ma+z9Izxd2tQUrP+pOBgQpBeAvTVNkG7UIb4Ggwriaco IKO42/9kn49ce2Wdckd0ukaWUxFK0UAVFyVmoSEvS8doP+GaN7TOmQWwcPLjb/UKUR5DTmE+2Fl Wd7tVRItmF8UixtIhB8tdQdHg3gqYcWBuZDdtS/nF6DI8yUb7WgFiamG7a29qQxN2Fhhxd7dKTc H8muohJ/5/hhQQXv+BbIA0tQtnzA1cfw== X-Received: by 2002:a05:600c:6dd9:b0:425:78a9:b3cc with SMTP id 5b1f17b1804b1-4264a3e76c8mr345355e9.17.1720046950508; Wed, 03 Jul 2024 15:49:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGIdIfLQjIJkk3VT7yl2D+7fSv/mxb3zhllRvogy1UCDEKlReovwjcT5rokl2dM8ccC1tIaog== X-Received: by 2002:a05:600c:6dd9:b0:425:78a9:b3cc with SMTP id 5b1f17b1804b1-4264a3e76c8mr345205e9.17.1720046949753; Wed, 03 Jul 2024 15:49:09 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a28d3dasm1115005e9.46.2024.07.03.15.49.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:49:08 -0700 (PDT) Date: Wed, 3 Jul 2024 18:49:06 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Gerd Hoffmann Subject: [PULL v3 62/85] tests/data/uefi-boot-images: Add RISC-V ISO image Message-ID: <2f95279aa8c3ced9607eb5959c20d2995ecd980b.1720046570.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: 4 X-Spam_score: 0.4 X-Spam_bar: / X-Spam_report: (0.4 / 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, LOTS_OF_MONEY=0.001, MONEY_NOHTML=2.499, 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Sunil V L To test ACPI tables, edk2 needs to be booted with a disk image having EFI partition. This image is created using UefiTestToolsPkg. The image is generated using tests/uefi-test-tools source. Signed-off-by: Sunil V L Message-Id: <20240625150839.1358279-5-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- .../bios-tables-test.riscv64.iso.qcow2 | Bin 0 -> 16896 bytes tests/uefi-test-tools/uefi-test-build.config | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 tests/data/uefi-boot-images/bios-tables-test.riscv64.iso.qcow2 diff --git a/tests/data/uefi-boot-images/bios-tables-test.riscv64.iso.qcow2 b/tests/data/uefi-boot-images/bios-tables-test.riscv64.iso.qcow2 new file mode 100644 index 0000000000000000000000000000000000000000..c720bf99a45fab6d1e21963cca563ee0ea059b82 GIT binary patch literal 16896 zcmeIZbx>SSw>CPs4er4PLV%!yTYy1A2ofN82rzg8g9R8|1`7!qNN|D#CrEG$?#v)T z2Z!M9gkWFgN8bD0``$X=cmB9l_td@T*;9M%XRXz{cdzcfx_eiRw(`?U004jm_`ibS zABr3JFD>!i1@2#t`A1^>%lN+mHUI!{{@?igH~wG6pDy}u{QnXd|HnZHzyn|aFacNq ztbfj!f6xD7|I+`FcLz2A>pz_Z{u}?LahK`w|4Neo($D(e_#4 zE8%}-+<#Q=zX~kf;DTVVmDR!F2~m_*D{-1h(3Rg|uP~$yhl)@fip@r5v$zOd48nJL z2g>P!gir)yhj6yFVq{Cu&C<~utq>dFWcu*pGkTr?uOnM11AUJM~e=}4HpBji|h%fjCc>3y&^6X?$dDZry`VDTlHyI*NP`;ZFWyE954WuzC(eOUsZ`r#xZO} z!75AoVuWE}0KmsVm{nZ5#880mTL|J^=m*3*L?L1c?|v{K76*$Mm_mRf?7?omM!TJm zLzBqGRVNunckdw=*FoQYM5)mix6BY}7}0_wJggGarA&@aMv@1ve{|Xs8;P{Q0rd|E zXshU|^bZLdDm?u$y)l8qKgf2nw zJGe3h0f6Hu3lM`yY#B8P=1Y3I=a@;_owDE!L1$q>u*5G+!TU-`1VNB_E5`egHUwFS z6hGS>2omH&iVYy3!3`t20Rn~CH|}Gfs6OXWrOWiUQ5f!pAP}tb0uR2if54#NC%(bI zM=t?LFEsd=5}yHd;X$IH_w>>!|EuJV{}uk`zlQ(F=dXS7e{Cn0x$`6Yn`g;R?>Gg~ zUEZbizvEQFcbpn|CuwEx^mOHSoF08A8FcR?WBHw(nfZ>hSl>y|-#pF+x#Ra=+)4Ji zJAV%TJI)z&C%MM%^xUdjwsbXY9w4KQcGu|Ve>~rrS94oI`8Z)bg&vw&f}QS@mhHf2%1*E zdjApWk96O+={RiN&ad?@XMdLLwd=G9D=1O$m)T`_enx*?U2xOMj4(ElyFVbrODS#% zC9_ex6iPnDYLU6wjC zaS)($Z_GpMxHfxwH#4MsW(kxxNBmZ67Z>0&f3SE^boOpN8TH~uL);pgH0yohQrvhj zwjVi)Lr3>nTtxk@R-ZE~A^X6vLe01OZE+`QNMafCK}ez&aB&Lv=16!-Uyy5fqMwqV~y?QpJ%QKJgzowV=zBQ zL?yw6Vam1A=0rtvr3SIq^wX^He3Nu!1BPAgmV3d4D?L38HTY8!1`xLEMFzo~KAM8@17QYY zQ%9s5MF9|l>)@m}f%bZhCfi@I^Qk730QPnTyjGXlCkS~9Zwai9m9ur>b@rjcd7pdj z_8DTFUS`F053z#5+am*aF_PetUy0Vth;Pa_WbCD}amwKMz^lF6E1Mj(nqf3ks;@tp zx7p93b|acvd!;5jIEX!xC5vNqmgW}DeBK9=iATSJp_@P`ZNP7a z8%^Jbmm{J59K5$5i36v?R%0q~23W%9S4|)px;&}Ah(qahcBjIylo>%zuO}C!XJTh2 zqnA^)8U{7Ljs`q1hS%gqO%O*Vn)bUdSZlaEOYJhe7}3uJ1$@_Tq>WZ*w+4aQCZhF}YrCwm@bS+jD`LU^g>PnOYO(?=+l`KBu6X&jp1+4+O?><4_$p&nFL*+qO6^?!)N54nC|0b z?Ub33P=P|4S8t`=%(oZs)6vtJ+icxG!2zGiY+N&0Ckk=SiPyV@hFuidh-c3*2KjUQk+k@H~ zvNqWr-<%v4zaMWE(bKaOjx~_R&`T?i*Zhp)GYZ>nI6M5i1ktH{BVo?RA5E)j{U}El zSyk8Q4+AE)eG5YC`Md3jT<2(Kf4n>=t`(WwT~u&2A*4;&7OKPFjy9ydF4L)Zk&YN= zua2B?QL7uT4Nk2ncEsx`X=a+0Zrp-fUt&4Lw5VYTQuT}uj6_mPxjB;y&rY{_b8&ql zIj7y2mv7(>FLiKr$W(kRoD=+vZ$b{j?WU6@?$IFE%6bdg>?03YIeMYx+&6I9G$h`H zyzGGQgi{7}y)kO742$1JU4HC(W>Sv+G`huPMw49WWP8IAG zeIEux@Z`7o_cFn@^e%yq7u`#0Ed)L17G@qENWc0>B1fJ7_*y{`! z#*+5)f@^o0imM-yKUhdj17$)V>oMXb3>#bX2w&T8KDL5uQ~0t^=%_@JI?o1%7;@gb zeSrL!VB&XdC{)jOct$*~^X`81RO!=XN4D1mWM^5asx~%kPYKT+=-hgvOB9i$)lWAr z7yYuH|B}8}9n>+{VRW-xHSf5WzJ7Z4gmNVPL*6Q96i*gzS%di$ZE0Qc4W8?wftcY@ z8M))w9<=6i*KOCs&F3&IWq%YI#u*~ zgz0;<;Y97lw*;)$+WYA)>SiZRjkR+1o+)qQ1P501#RZTFGxF+JpEKi5pE@o3xQOE7 znv2!E&nR6kg3xS_5*Eze16{0b?*Jk36lu>5zok^Qdg@*3mOmBF;>e}ev>{#$Ov-(M zS*=N*V-YPZ8&7vKq9K(ao?MM!uy}4SJ0>ex{vR?Dqjzng)>lN z)6+xDGYCa=l0F=kR=mrMtC0Uf5eyvmJO4;rGmF)55M9yrNqThd&(zqcCdOiG3jp~1 z@|D8E>NpO=t=HStAr()poK3wjeHn$2PeSpz3vJ`*yXb*ZKZz1&t0J5l07y+PVkYtJpYWh^yB*lk6+ef;Y6Lt;qC!?_q6%`;$36YmkWLL^h{svZ2|$gct^{9ZK{|G)8e~ z!9pSoBHV(hU~U3oA?`n6{ntESv64~ImJrY{_T)ySK`^!Y%0bNfq6ap8M7o@T=k!0P z9f141o*23AbKI0p5Z0I%X~8kG);d!-!z?-_rcyY~k7P;4HaU(L+5aX3oxRG>HI{_P z0ua}##4dnj)g%bq<&M)<3iDZaeyW37kTO8gx8!KsoyY>&)KU_COPq>&?Q5vVm*1T~ z$>NzND)|F@D~uJaI0I~L?R57;`UR4rm^q?@R5j@&K;F@*3MW-?EP%c40_+B1essQn z1us#37#*oWeCLu^EDTn6^bmKH9UL4km`BfrXGLpkZ4&<-z12O$YZ647wzd{&v#|N2 zeOoyNzvqPZY!%+t!F;!Qjln170aoq?j-G?9y#Sq#KjXfkXmvjsWpsn`oCUIg+!C-_`DAz+ws+A+Dh_%*EnQPyD}N+9r*Mmb+3&^b!dS@9gf~P z-7;->LAz@R!Cnj*N0sC=8$D=P(xM%KcB(V+$`(_Xmg`;z((?e{T=`NaguZ8oqf!il zf{KPtdk~;wDncEc0LCZT@=(3Timn8+evT*p54Zg;MAH$7B`?K}IlW!i81dBFD+CtEC{oRH#oiQ0P4=Ae7-ub$5dG`bFoep z2x#RnksBO_;l^F^+*AjwE!}01#ynvx_q~)-*x@Q^=T|HPgX(i;y!SUa$;nrXl9Xen z`F&pr9+COzM6ue@M?dqhg(l73T+ODfNUp}C4R653EEgzP_mPJI&lmeqH|yXBw}E+A zYR&C~!yEq2^s=m6Sfs(2A5d}2mFkP}zWS=t-Y;P> zAv@*YQhGnG@eN}32WD zwcQ=IWk-lb_CFR$*f@nT%|6s&d1 zQs<=_Z^YyYTKmSWh$;^HUCfl7f>SD`;VNVg(5)`QRH|0IaC4948TA-)any6tb)s-e zo9!-z9jvlcJ|q$uqj`xJDjKpojP2fGmQ?6a6mLWe(U9TB5j>SQuQVEPg5ux2#!bNl zSc*AZNZ)0RpyofT0Mr_9fH!GyujD2QB59+OAg3|to?uCWUjg2XWMk&V>9Uzrfk@{bzlOydQHOx|pIg5zcoW{S zn|&gZ8BrlO#+ReFyZFUyZ&5oPHov*`J(= z1V#d5DAHQDxIg&jz`m`LiZsRPR}bM_W>x#Fd4&s1v2#|+Lf`&cE}&AH3x>p|bpHg& zA$@@WdpB{DtUs}Fm#>r@SZG;BuJPT*>9hz3dNx76B?Of0^mCZqAPgOLAn2CHJaIEy zTh9vyc8ke|g22K~(Qk!W6IJtfr;~T*0jTkdtvf#1Hmqz|)42BMJYg{Sk&{GgXKy(d;$hbZauW^&IctYVRw3d8MvlTJ zftG1H!u*Z2&kUn&W-|1mU!g`ol_k(o%;-oH4IPlPPQ4GQHM8jeY_Fv!MkEi^jFPe&=wsGaq~<3qDVsVi?s0Y6O;{KKq#8dFiFGs zM&5*{rHDx~?Eqc081{Pm+gRUMJZ#pQnmolZK5!^nYL0QG4E~nB4`t{O0E&kBSh3Eq zLKNRZ%ye!kemC=x{>K*w0@FoyTHPE z?yypJ_61mR0QcE9-S@@s4ec5Zx_jBBx51=@cE76@eTCd#MDf~y20WjEI`)NrXLSF3 zAE_+=M5@~@YpXlLTD0UI#u<-@YxWX*Ih)?(KznbNU`SB5SU!V-t*HRRY*hGk0Myig zF9vx=hI{5#`U`%*O$wO7tigd1iJ7-?Y%QANMfsT`uqW1zp1kf6yJu#W_lQbz1kSx^ zwLhIDK^D3$GdD>`(3N?{^r@+EKvwL7_^}QT;;qYCmBWqXoVW0sDc9wan$gq3J!7WR zG+*PErq53HVzyqBznVs5%v#&3&`qmzEBiaVYMPp~|IF-K1rnwx$45oI7!=C9BOl>T+~UKET(Pxiz5j~u12u&{=$d8(#axu=*| zYe2I(HBh1AAgN9bO*N2>&{bH9?c0u~F6U!d=2~0(6I?o38nYWl^;@1&*wJdtKH)1* zL$;S+TO*whU0ip>7!7eN&FddFM4;C&0J+-V?Ajr8vL`1sFP^dv2jRaaaF5H5!r5Go z9e=`Q75mH!!S?xH(6F6DnBo@HK8ti1l_gOXA{%7Psu-4##HwNUZn|+weB;gS^@88+ zc>s$od+FmF0D%9{``PU2v}4l{0cl`X>XVN592VdDEPonB&}JzD0B}q1#8L6co~!b9 z(@z2nP@}oQJW(SquPnsuN3DbQx-qy^^ORgciCkvaAa8Utk+m>ey#)*e`mV3;X(WN$HAM!z>RI zHcr%I${%f;AL{0NFJ(WWHlfztR`-Jn$w*aJY_)ZDmt=iO4`0grV z^CFbuDo;Q*-9u70>Y)ikxm}_Bo>ooDnZI^T!&xce?5qTi-!AK5nyNGX1^nh`>aMO7 zS4Yb>RdHCLzC1h2PvzjO* z$^FS1Ej5MWG@DwTk9%XEI+KlNg)hcxE^dJ6l{n>s4)2jF6~-=c!Bu#ItfG)>T7(@7molQ zkiEprfzqK_uWr71$^b!GiuS#-RD_* z?W<3Hk6enCWD;iPcIJ|wChq6bX6<-IlzQ_7y)w{fbDZE2pHV5y_ANPfiqZMZ10LOd z4w{%mg9L3r_7=ZU{z+GDd-Y|hD5LqH@g{0VCtIx=uOpjhZ@x5CbS0Yc&<3v1RA8Z< zAYb1uyQax6H}OE4lFPJD1FfhGGPhpM&)=}HlT_GSc&s1x?Euvy&@H}Lhth3V#LhSE zd)+@v_9D=rN3jEw&1RdWu;W#=%F9nqf4*I0c-~_>z82`cE&)kq_VKpFJCzH|`<_(> zY+0(%6$l58soS&wL^D>;ZO%wZK((-!0G-AoFgwtDA$WyhJhhX7GgxvC@bF3W8W!Fr} z7F${U8t4Tp@FUjy>se8zjdn96M8E8E?Py=U9~bK3Z~q9jO_JUATi!xzp_UnU6BDrg zXaP2Oq*Hf&d24!(T3Sd>LNu9-e&TDsdIi5da`>~;71j*at*Qv_LK^#H8Ht(s3#QgK z*=w|*%V0;VCdG|Hmx)f0dXM;)O5q2!l|G26lDWQk5N~FI!W+^?Jf)!(_*q!Sb)U|Z zOyJrLMsl_L1H*AwI9}{)$VjcQ8P?-@!rEG4u9-((!kqM6H)<|8DmJXWOiqxmYrDI* z^2?AO=!sUU=ZRdF}9H}CkbYpO3+fvb% zNSg3UOor-7LOOEr2*XZb7Dbw9?p}>SV!#mSR(WOTOYBnEAlusniKTDZd66&oXZaVb zuvi4Q&J{3&SWu#uvgaY%^5GlmbsHF(nFRnXk(a9jJF@VwHRl9@AJ>q31w|L0(j7Y_ zbUspwU!=fc0fLPJwoqLsG0O`afW2%@RF-xWI&zh^az+qWx!Oi2!3_1JOh}|i2+Igr zs!30$m&_N)8^Z#OyodDWHw#HNl9jq1{+)f^wh@IUD&~Zf7D+W%(^hL5SVEI#6Y`K7 zV#%V2r$z1!fInY*uqZhyD}8mvE{=HIo>oc@%p{kkqKyAfVKhRo4Ul$GgOWpc`f1GO z0}W9#Gq=H=2<`x}=Fg=hBDFFm1SbtVdL~npxx!-)(ofoSn!UmnA624-b)kwcAE>r!=J(! z;Vio^@`VF`etG$ZTI-By_^Ji+9T#wUREkbpH92;H|7lQ|jc`Is$zGq#0v#l~WCwJp ze2N~OLF6n3DW9iaM{U7(QEPkw{%1U?z89^q`6KgOpNbWau+1$XFn(sHJ}|rGjRC}S z3(7p4(~^polK^9B%!-E3$EV4V;`w7=HRkDDYUO?;5_!XZLiXCYqL5_ASFAm zYD&FIo5Se!@2Ly=(B@2iKbVb-2vhJU_f`Y0BrN(CfHrLew5#1BWMJG`M?)98ze~(fc5h4awQlC?1g@kv2&9dM;? zJC-?4Or8D1Rg*=u)q9nBI4Rp(G_Tic=tg{vcyj2f#gSe1ruTtM$Mzw7!i(GC{zDV= zGPi^;{#%U*-Tk~{dc#S?ckt3wNEBlWKoE9H!>je8p7mG7>oQfLzQPREK{}~6*xI;V zS)JP+<+YcU>*pqqcZ16tNNT2my)nwYCxZC^mr+CX^>*DlK~I-c0_Qd6NsTXia&tfFc?%b@-tn4pb&@$r| zc8FA-O7J3#J82=(Q(;hYvq(wWIBx&miFJjtl9WCs&+*-~4*l9zO9d)X6MGipOrz3hz}C$}A`S1dCv6o^ zYe=Ac&kWx{q|pqc(P7^ub4olj31e6eqF?4yG3!BNjg`5*WQSN@kY7rC`71q?Zc^Pw zx;11kCBzam*{Z?)XNx1Jf@x0IEw}%yrMpu#OHPGlWed6qdZM^7ZQ~I3*j|Cy!6SW= zoQmWvBSn~!h=`Jwh{{;z;_&n`1s(x$*QT@Eb-lEYoaigb&p!M0=jV^gx>OF^YsWe_ zawCbw2L1XsUv5*66h>Yi6Z*duzYoRf;ASRXx8Wu66+`;xMf|YosPCrf=q9q!xGy-0 zZOsVtr&e=X+|W%4Fm>iTx*QwgDIyj8@o2r`I5c`<_tX^UI+}fmYawE(THILtjXZn#p&EDpv@&@_EBAWH- zaq7G(P$3}kN2iELEjl!a`20=aI?xk+?_GNR$DV<8qlMqNTJU38*O~~0lYv}?xYi`m zIdlJOg~GAi-Z&oR%=MQo>%m*sI3`*H&)OkWOstMmb=;A&jjH<>SJI3?6ZfIagCQ+1WYYl`v#;4 zB$`nk96IY7=M0SQ*BUj5n0y_(*dF+~x`Wmfq+ig4VE3IBgh`WR-OB<7MivxRWYZt% zb;MHV=0Z%ZlR~LXA^c=Q&?w%a`uQVKSU%Hc$qkKTG=0Nl2T@w2n+ zrC)8}_=Pk!JJeZq4l~h*kTY;#f7|eSuV8_$Pg+Y_m!x`{wVR|8Gv+D7H)20YLi6#o+A|_u4z8j^a&Bn=V~}oKVu$T8 zDSj?lqvaH*W$z;uWijJhm04P*o^1h z!U8FFwUtS!K}F;e(4~39`23X-dmx&nL`z1q159>0Yi1s%LZDb?p|l0b3|D=uE0L}h z%755p_-@ythwsWqolIw@Wb}K?(sv)%&+9(<4_f$teT4#L(^&CGwwOr7In>pSkUr7CCLsf_nGe z6|>qKZW(qW1^4om+>1zbawQ7OMroHOlcP>x`z)Vg=hQmDR9%-%Ez5iIPpMERUew%f z;Hfp0AM0_|wW41&L>$hS%$z2usi;Se<6>Md(g!4~cBr@cMeFtjkmv^UB&U6}P|sekP-!P*V$sIl&_C)IxpZpE7413l21qY^)aiqn=`#mV+4*WFtj2_Mi}=Cr{ck z1zD|{<9Jj(c`2J!LnE!&HozJW)y)-x1C>7UYeeORs{J~tLrBX}hJhuIC5r4yRAGx4 zzg>I1cHUz$MJj@E`#x^V)URTRfXD<8P*KrAxFmG&{h+UClmz zy>4^KZ{!2#MJ6T&bSVcLKqZt{; zrMaqL^YBaIL*%fqGIMwjCG)ehv*-9Fk=%N&sCvHi{a3fKHnU#5^ z@jZ3me1Z=}&>}^}4Y>Y^1gDID;55ZnS+MV_Q&4V3M5u57V~PP!`nMDJCm+}%s<&6X z=F?GSPYbCvQD!`IG;0mVaDNzg8l?&I{?ph|A!4R^hjEd&ij!x!N zBlS+%k4g+!C1ofABGbS|xMa?5St2QeMyp@SOmclX(38_CEtja7l$l{2y)pd}UtHGt z##)!Kmfw?~D1}!saoqp2*GBt9DZeEBju@w48@Uq?w^UGv96f5(lXJ;3<_=9x>(*Twh}M>mPx)ZFq$o3WSf9*oR!>T719qKd6VT7#l!PEASj9fa4 zHnpSy@_9u#d0pQ~ZB9PuSyFV)8d)ykzo(S-Iq~*>xty`a8I4g(md*gaI+5Iiz~!=3@THbl0-5Sd%Wg zIBXR%P!%%bF{1Fb!-FM4l_!JjjS53Y0}oN@LihM7A+PK|2HFF$Ef+{7330+=7qB$) zDV1rhO`FPLroW80_zcBTt;)Do==5KTKA*+>_@i21@s$9k2<|T&zmtGUg?iQ@IfL9LEl*7vHDe@^K3GATo-tqvA8V%sd(M(I;?-hu zZMuNL+8<)RSo!whP%EXt3Zoa@932C?a+Up%i{RFTxANbs@UtL_toS#9AMYRe@S)#aKNBb}t|bjg{Stu){69at1p zsXlo_HgOa6lVXyQ=aBSuIGAMM;Z& zlWw=G9+Nl`lzy;=q91#;bOe@y5`!PkUZ*)Xk|9KvmnMEaW>$dmfe#bw=<#92#w-#6 zwV$dVjKq|}yX|eQ;s@-wk46TO`Cs5szC9cA%H9<=h*!S|(m%+N27$@CF1Xg=AS~W) z47@SAr&qKi$s$?@6kNE3tp46ST}mA}CMiDk&6jibwpgV#H(n$O^a&c&t_&yNe`4k> zrYHw!eM)XZ)B++abkdXytQEZ|9-0qHai_GGS!QeLvkP5!?l2vc5aosiHgw#e zzdre$+79MG#5Pgzk{b29D{8SAo38GV)U8#sx3Pa}4>QQxp|Ui7e)NIV9}k;m>}1ip zDBjJs%qU?GgEVc>o$=?Wclev^1W)5&VZhCxII|oF^DP&fX>iBt0k%WzfMYwD?C}Lv zS&@|v-fvU45vu2`+VAg?4cMgspTGmG>MPbGr8W|bR4=dR&ojFw65}3@eWy5UEYvRb8ViLmO44^@3DOT zv3>&@@YBw$PM1r;+AI%8x#gmiD{1SC4IGA_ydyEfRq$@7Ns5;^j9Da$)QB>#$9xzA zx++(iz{9g05GKF!wPh;OIf$k)@tiazOTdT(euP1+3fw!i0uWRWQUM4;^K)2UNtwN( zqueAH@u)`AOJ7S%+@E;XAHF+wfPo>WT#V8l+pi=9V_6+y>Gr;=z_=kaIPVE#Ys)^? zh0e};UR{LW7m8GJPN_aG+DgZcF4)x&on9QL58)F&%(&=#Mn<9@q&zH(jNyftSu18E zaYyIUde`Z*IM*1h>CKR=0*j#}K2^_Zo!vcJeYc%2x*qK@a^cOu;dvlR7`U#c@-yW_ z_Lm47rY}T^Hok7Fp#JO^dRi2yAmXCqm%=Y-8-z<5i{RHc2Lg4N_quH>Ii7}H6_pc( ztrc{o%e052G2*x@#H;-hPhz}y&Xe%``dh$@!kV@TkFUafuR&%b?E~90q)}RJj_qLJ zZoX$?;hg#AVmk&&D?|~q@ScjaewIt{Jd0 zHe^;K-rhAECy6322i(x5zF*IV;aX~qvL1-ksIJUoqh&O$UoQ~~&LX2p5B@fio8A6o zWXA4OTjvYQFO78L*6(PTamjjoC}%S$B)$hbsD~oQQ>dir8m*hAv`fDo?obv>S-o{_ zZ-3LH1(Sxcf@f64@~c&q3l!66F}mWJ;&(fRMy@L~=q z^EG~BKEWTBR^*gX6wsic1A-h*YZ39K4=5yWmUvtVXCoa7AC#&*{ie-7NtHr+A_tFS- z(>U^cQ&Ka_8)W_bxx-^$ei`@kOQdFafqDeZP3; zZ}l!P29QtRk*Yj9)cD$q=`5*Qp)y|)y)CBs5b%*uAW4h(v^oGMV@roim z2EM9jxbV7gqu4XG<1v7+BURToRPWn_;LiTuuWjBl8Jdo_W-Azsw_-n|(+dQrA)@K& zVo`j3NR7~B%a7Tl57eJiQ9;ys$T0Lst2i;0j^D`tYJz-qzP`Pc5y!U_$dqCQO<-Bj zfNtD~+59nk{gtpex=Ad`iK$UR=71U3pSQO%N*1Zxx3`URm$w15R4nxo&=?DBlE%=7 zXB$%HeowXhdIGD)h(qc+9ooG$m2iy+sH6CBD*D@i*V$LI7T04RVfXzOK8^+M zxcOxubFw?LRsHfimvuqL3lA!J$B;SgQ(Ro4;)22g52{rJlFf&MZnXeEFCXiNq&2hb zkFC2|T*s6~b7Rfbmr1(`5DijTCS^JX4A&k!R_^KHOvE|o5)@&q-F)Rnetr46-;Jp( z*;~^i!@%=V7n#QQg=STon(gXA2IRut@PcU-cA_+ImOrP>Lz45wd`_o`GyOHBEp=H<*2ysVNwAxBI@g;LK}J-rKMB1 z@Vs!P-zFz#a^v?toAl^M3XuHya|RzS!57yyj!c5B+?5sZA}%*1t>Yy6VZ;T!E5(3J z0>uP-jnmF$9m+G!vy~8=j*c-gocuXLdq6%cGY_I^!XvDqvyo z)za^du2xhl3NwTe(u);>3E{#Fp@48D`r8`S zK%80woB3ux)Qt5uno-(i3t3Opa_zF&U(Havcjdm{_JwoEw8{H;uOnX|ScQy${>*GF z$%T?bnsrb$)TQd)KNt*he{E4YReATZ6l{?2LJ%WCQxw( zU=S2c2Mhw?;|8}u$*_Y#_(AjbWY}$gTQ?>6J2B}rfJ)hXr?c=~VRF6jI{(WThA)g} u>fShPcb7 X-Patchwork-Id: 13723035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1F22BC2BD09 for ; Wed, 3 Jul 2024 22:52:35 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8n3-0005nN-6D; Wed, 03 Jul 2024 18:49: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 1sP8mw-0005Ci-Qy for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49: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 1sP8ms-0006Kd-3s for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046957; 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=tLYMiEpSTV+muhM/St/OMTi5MMjd/r9xWUNm5/42vJU=; b=epTU3BIvhEvvhFkRYhGTkhSvtCDeUED+oArvrEXHkWci9338BH/AdCj92R80Inb4y98ALn gOwIJ+owAuj5/qrG4p39KP65UnPQ5WEAnVyDDNahHCRhPKvqPGwtp6A2sq76vV70NvLRn8 zcxKK42YntjHFxRb5hvreZIm3VTJpQc= 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-625-0RQiX2h4O5OOJI6A7QMCnw-1; Wed, 03 Jul 2024 18:49:16 -0400 X-MC-Unique: 0RQiX2h4O5OOJI6A7QMCnw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-425897358f0so1635e9.2 for ; Wed, 03 Jul 2024 15:49:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046954; x=1720651754; 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=tLYMiEpSTV+muhM/St/OMTi5MMjd/r9xWUNm5/42vJU=; b=v5t7jMoizav7P4x45TtIq7LX5HcYbtzz+40cpNtsFLQQnCDjL7cNF/5740MlUB3Pa1 u4r0A4aZajUQh+zsBJ1QRkf8+ukqW5KPkov9TAQRXWJJRHj4x586VjidQtb9f3pVYYQk V+lwoAgfC7uLmRyYHIKbu69cyQt566/Y61mUqRc0o/KL2i2HSRwMDhn4dq5GQGq+x2ao k+Xilxe7knrTaF2Q00pPGwCmhHwnH2kKXA5/Tovhq1pS+JfNaa1/LPkeqG0djHA/+YjE hl4ULtAipPa4ab6GXPE2jAkC0cqD9o2+k2FzER2RYVJXJ8DE4763rr3XIHdg9X6RcmBh 7lUQ== X-Gm-Message-State: AOJu0Yx375qtT9WXpI1+YLQ5DTMHxd7DLKm6j8DIStXiIGOce6dWoYeQ 4ghDTuIE76WtRKZ2IVu4h2bZVm4P71oDFkPOyuQo0oy4a9JYmUeNwo4Ek3Xksmnt8CrBI8rHzrs 0pVv5ODVZBvh+pOlLajDS6gyXIJE/l6OPcWPvSixd157W4n8p98QrQC+DFCupVBp/PPrtbM0bzU zQpNktVWITlQmzOKvSfzB+3elhAuIPNA== X-Received: by 2002:a05:600c:1688:b0:425:5a26:a129 with SMTP id 5b1f17b1804b1-4264a428f7cmr291095e9.37.1720046954623; Wed, 03 Jul 2024 15:49:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfl+BkzL+FTZ2Ef6a/y7OrBvij0CyDjjmJj2XH/3ADm5b18QYxqQsHqL2S+8aUUHB/6iiKxA== X-Received: by 2002:a05:600c:1688:b0:425:5a26:a129 with SMTP id 5b1f17b1804b1-4264a428f7cmr290945e9.37.1720046953962; Wed, 03 Jul 2024 15:49:13 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a21cbf9sm1183855e9.23.2024.07.03.15.49.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:49:12 -0700 (PDT) Date: Wed, 3 Jul 2024 18:49:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Alistair Francis , Igor Mammedov , Ani Sinha Subject: [PULL v3 63/85] qtest: bios-tables-test: Rename aarch64 tests with aarch64 in them Message-ID: <2fd69da2640188ca869a2d81385d13dd4662e65c.1720046570.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: -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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Sunil V L Existing AARCH64 virt test functions do not have AARCH64 in their name. To add RISC-V virt related test cases, better to rename existing functions to indicate they are ARM only. Signed-off-by: Sunil V L Reviewed-by: Alistair Francis Reviewed-by: Igor Mammedov Message-Id: <20240625150839.1358279-6-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 35 ++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index d1ff4db7a2..c4a4d1c7bf 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -1570,7 +1570,7 @@ static void test_acpi_piix4_tcg_dimm_pxm(void) test_acpi_tcg_dimm_pxm(MACHINE_PC); } -static void test_acpi_virt_tcg_memhp(void) +static void test_acpi_aarch64_virt_tcg_memhp(void) { test_data data = { .machine = "virt", @@ -1663,7 +1663,7 @@ static void test_acpi_microvm_ioapic2_tcg(void) free_test_data(&data); } -static void test_acpi_virt_tcg_numamem(void) +static void test_acpi_aarch64_virt_tcg_numamem(void) { test_data data = { .machine = "virt", @@ -1685,7 +1685,7 @@ static void test_acpi_virt_tcg_numamem(void) } -static void test_acpi_virt_tcg_pxb(void) +static void test_acpi_aarch64_virt_tcg_pxb(void) { test_data data = { .machine = "virt", @@ -1758,7 +1758,7 @@ static void test_acpi_piix4_tcg_acpi_hmat(void) test_acpi_tcg_acpi_hmat(MACHINE_PC); } -static void test_acpi_virt_tcg_acpi_hmat(void) +static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) { test_data data = { .machine = "virt", @@ -1914,7 +1914,7 @@ static void test_acpi_microvm_acpi_erst(void) } #endif /* CONFIG_POSIX */ -static void test_acpi_virt_tcg(void) +static void test_acpi_aarch64_virt_tcg(void) { test_data data = { .machine = "virt", @@ -1933,7 +1933,7 @@ static void test_acpi_virt_tcg(void) free_test_data(&data); } -static void test_acpi_virt_tcg_topology(void) +static void test_acpi_aarch64_virt_tcg_topology(void) { test_data data = { .machine = "virt", @@ -2016,7 +2016,7 @@ static void test_acpi_q35_cxl(void) } #endif /* CONFIG_POSIX */ -static void test_acpi_virt_viot(void) +static void test_acpi_aarch64_virt_viot(void) { test_data data = { .machine = "virt", @@ -2192,7 +2192,7 @@ static void test_acpi_microvm_oem_fields(void) g_free(args); } -static void test_acpi_virt_oem_fields(void) +static void test_acpi_aarch64_virt_oem_fields(void) { test_data data = { .machine = "virt", @@ -2364,16 +2364,19 @@ int main(int argc, char *argv[]) } } else if (strcmp(arch, "aarch64") == 0) { if (has_tcg && qtest_has_device("virtio-blk-pci")) { - qtest_add_func("acpi/virt", test_acpi_virt_tcg); + qtest_add_func("acpi/virt", test_acpi_aarch64_virt_tcg); qtest_add_func("acpi/virt/acpihmatvirt", - test_acpi_virt_tcg_acpi_hmat); - qtest_add_func("acpi/virt/topology", test_acpi_virt_tcg_topology); - qtest_add_func("acpi/virt/numamem", test_acpi_virt_tcg_numamem); - qtest_add_func("acpi/virt/memhp", test_acpi_virt_tcg_memhp); - qtest_add_func("acpi/virt/pxb", test_acpi_virt_tcg_pxb); - qtest_add_func("acpi/virt/oem-fields", test_acpi_virt_oem_fields); + test_acpi_aarch64_virt_tcg_acpi_hmat); + qtest_add_func("acpi/virt/topology", + test_acpi_aarch64_virt_tcg_topology); + qtest_add_func("acpi/virt/numamem", + test_acpi_aarch64_virt_tcg_numamem); + qtest_add_func("acpi/virt/memhp", test_acpi_aarch64_virt_tcg_memhp); + qtest_add_func("acpi/virt/pxb", test_acpi_aarch64_virt_tcg_pxb); + qtest_add_func("acpi/virt/oem-fields", + test_acpi_aarch64_virt_oem_fields); if (qtest_has_device("virtio-iommu-pci")) { - qtest_add_func("acpi/virt/viot", test_acpi_virt_viot); + qtest_add_func("acpi/virt/viot", test_acpi_aarch64_virt_viot); } } } From patchwork Wed Jul 3 22:49:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CBAADC2BD09 for ; Wed, 3 Jul 2024 22:51:20 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8n2-0005lG-I2; Wed, 03 Jul 2024 18:49: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 1sP8n0-0005d8-QH for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:26 -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 1sP8my-0006ZZ-2N for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046962; 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=J8ROLmjYrb+QdAQNPXPEEZlctlgKEo5Cy/u0jGb6NPk=; b=bPGyG8+eYw5xJyT1H+N5E47r+lxcI/VbL4OfTvFUywAkOkx+eePA48sFQspyDfkUOswZfb bAjYDmfRzqkQXzHvFstK6IoOHzlH53IRMMtw4HDZ/8v8kcUWY+J00AXWdOUrq5I6Noqyyt C/fsBL16O9ByNI3SzRQwL3ul/YnZJLM= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-586-c6LC3rtONZq5c0YUFigneQ-1; Wed, 03 Jul 2024 18:49:21 -0400 X-MC-Unique: c6LC3rtONZq5c0YUFigneQ-1 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2ec61a87db0so59745681fa.2 for ; Wed, 03 Jul 2024 15:49:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046959; x=1720651759; 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=J8ROLmjYrb+QdAQNPXPEEZlctlgKEo5Cy/u0jGb6NPk=; b=OABlgufPWENc6KgVMX0wGBb1bl3YgZDr5VkZhVVGswn/nxyzoJe27fKq3grjWPy6hZ zNntpZQLAL6DSw10HjHFchGFC4otYu7j7PYUZWKcccVDk7RQHnwsQZpAQOoRY+iEFq/4 nOp/7JKhvkDwi81YAoMUWnWcA9l6z6MMQkgBpi2OYEWbP5H6GXB6PqXo8I5G0/Wef3vu Xf6Hu24Dn0g8SeTgfCxS1QxRWYqwUrCOd+xOErnK9PgFTWsqMFOz0BUkRysDFUz0HCMy u7ZZTWKOHZDf2AWiYRLA1L642le/v9IaDiqmW/e6LXvnBiaAhMqIOvlCnuXIQus4kejq HkyA== X-Gm-Message-State: AOJu0Yw9ib4rKsFRoErEG7DzniWk21S5vEJdwHk3MhLjYVB/6GMzxGxU 5ofvr9z5CeMSnZXEi7Zk+nrFZ2cmQjbZqv3VoOo9ZxQ2KzLC1Ow4prBOeHejG9ZZ1dq8uGFYP9r e6uZ8K8snGPrBxbFeP1N9TidZ8BihL9dpSbxRVxaLMQgT6wEgLrOJ1eSRQmWHQh6UWL5CiGgoQX MdPuRU7aQSkMaukyTV2Vt8k4w0OC3/3A== X-Received: by 2002:a2e:7d0a:0:b0:2ee:8c8d:d9dd with SMTP id 38308e7fff4ca-2ee8c8ddbbfmr2785741fa.36.1720046959289; Wed, 03 Jul 2024 15:49:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGr8xUrsmSAGleVs8PLCQSnGg6KMYREeErjndTr2piNjY/inasSibXo5bij3rGQ/FV/yYzI2g== X-Received: by 2002:a2e:7d0a:0:b0:2ee:8c8d:d9dd with SMTP id 38308e7fff4ca-2ee8c8ddbbfmr2785591fa.36.1720046958506; Wed, 03 Jul 2024 15:49:18 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1d0b24sm1242535e9.3.2024.07.03.15.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:49:17 -0700 (PDT) Date: Wed, 3 Jul 2024 18:49:14 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Alistair Francis , Igor Mammedov , Ani Sinha Subject: [PULL v3 64/85] tests/qtest/bios-tables-test.c: Add support for arch in path 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Sunil V L Since machine name can be common for multiple architectures (ex: virt), add "arch" in the path to search for expected AML files. Since the AML files are still under old path, add support for searching with and without arch in the path. Signed-off-by: Sunil V L Acked-by: Alistair Francis Reviewed-by: Igor Mammedov Message-Id: <20240625150839.1358279-7-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index c4a4d1c7bf..29c52952f4 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -78,6 +78,7 @@ typedef struct { bool tcg_only; const char *machine; + const char *arch; const char *machine_param; const char *variant; const char *uefi_fl1; @@ -262,8 +263,19 @@ static void dump_aml_files(test_data *data, bool rebuild) g_assert(exp_sdt->aml); if (rebuild) { - aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine, + aml_file = g_strdup_printf("%s/%s/%s/%.4s%s", data_dir, + data->arch, data->machine, sdt->aml, ext); + + /* + * To keep test cases not failing before the DATA files are moved to + * ${arch}/${machine} folder, add this check as well. + */ + if (!g_file_test(aml_file, G_FILE_TEST_EXISTS)) { + aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, + data->machine, sdt->aml, ext); + } + if (!g_file_test(aml_file, G_FILE_TEST_EXISTS) && sdt->aml_len == exp_sdt->aml_len && !memcmp(sdt->aml, exp_sdt->aml, sdt->aml_len)) { @@ -398,8 +410,13 @@ static GArray *load_expected_aml(test_data *data) memset(&exp_sdt, 0, sizeof(exp_sdt)); try_again: - aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine, - sdt->aml, ext); + aml_file = g_strdup_printf("%s/%s/%s/%.4s%s", data_dir, data->arch, + data->machine, sdt->aml, ext); + if (!g_file_test(aml_file, G_FILE_TEST_EXISTS)) { + aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine, + sdt->aml, ext); + } + if (verbosity_level >= 2) { fprintf(stderr, "Looking for expected file '%s'\n", aml_file); } From patchwork Wed Jul 3 22:49:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722992 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7DB60C3271E for ; Wed, 3 Jul 2024 22:50:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8n4-0005rd-1U; Wed, 03 Jul 2024 18:49: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 1sP8n1-0005iM-Tr for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:27 -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 1sP8n0-0006iD-8y for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046965; 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=PxS1+bCJZBeQoTfbYKSlDoSTgSREcQFLu7+nTuWUmeY=; b=ALW0AIpIqljriJlhC0hi+yzqYNFIFlylAVXr4UxU+HcCnx22UFyLB7ehyRefZUnHxyxVCk j9aL8VussqQc3idTumwg6UgjlEintBZ94jwAgnF98mHD75zTbTSt8q7HU2tjJxC9ZehEuy pTliVSUrlY4rGODlgxlCvpvWps7q2QM= 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-636-kQKBlIczMpCGwNuRK1aFJQ-1; Wed, 03 Jul 2024 18:49:24 -0400 X-MC-Unique: kQKBlIczMpCGwNuRK1aFJQ-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-36784fee457so21515f8f.3 for ; Wed, 03 Jul 2024 15:49:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046962; x=1720651762; 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=PxS1+bCJZBeQoTfbYKSlDoSTgSREcQFLu7+nTuWUmeY=; b=g2gjztKrrx6WACuAVhod6lByPFaiHVrIsCS7yiC2PZfbS2xu8iiKFIKoyUAQ1H5c0L rOpdR6/h5co9X1q7yK66JONO5OMmnmnIt/4axxuu4DngFe59Lnm6/uTmyNf08l4riarg Q2V6b/CYbIMKH043UE1NUXXNDoiouG5xOjOEEyWMxxRAj/yuoLW9d05npaPvzSlvHD6H 4GKwOD25KqxWNFQ/8hg3xE7Z26GeqOLYJ+VjZ76qgL1fl5yJjNORBd9IH0OnBuAhnDYh pmwJ4r2/NQJqppTeKSjLcQ6dJWH2YOhVrr/867h4178tEFr1GFBKdHL2XC4PcaG7iW2H b6lA== X-Gm-Message-State: AOJu0YzQM/lvUVBESbheC8kLXrCpgyurg1H+le0e2fL17G1yx6l5+8c9 fsXW+hRiplP2p6OuOudOYLfjF1RhGE0uD9Buf2wLrq+seZsPTpsZmCOYa5cIgrMa/t3JFgtjaXX MFm0YwuiZJQf4nD/W0vIPqwwjVXU2KWqBgmavqUIyYk5I0GeFoFVKJBIVu9+SrsT2iwUx27T3o9 sG7TApzkweukfmW5BNYZCCCPQaaNzzkA== X-Received: by 2002:a05:600c:6b0c:b0:424:8fe1:41f9 with SMTP id 5b1f17b1804b1-4264a3e1af3mr327185e9.11.1720046962647; Wed, 03 Jul 2024 15:49:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE3P6CVBIsZuWNGY8hxhhI6cul8B4LAFx9vZds+09AO+A7q44/PiIcSSmnFdAJ604n8oSV39g== X-Received: by 2002:a05:600c:6b0c:b0:424:8fe1:41f9 with SMTP id 5b1f17b1804b1-4264a3e1af3mr327015e9.11.1720046962031; Wed, 03 Jul 2024 15:49:22 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264879e491sm3680065e9.0.2024.07.03.15.49.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:49:21 -0700 (PDT) Date: Wed, 3 Jul 2024 18:49:18 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Alistair Francis , Igor Mammedov , Ani Sinha Subject: [PULL v3 65/85] tests/qtest/bios-tables-test.c: Set "arch" for aarch64 tests Message-ID: <193e4b90d60a3a976ee7940d6e318ebab4db00e9.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Sunil V L To search for expected AML files under ${arch}/${machine} path, set this field for AARCH64 related test cases. Signed-off-by: Sunil V L Acked-by: Alistair Francis Reviewed-by: Igor Mammedov Message-Id: <20240625150839.1358279-8-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index 29c52952f4..007c281c9a 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -1591,6 +1591,7 @@ static void test_acpi_aarch64_virt_tcg_memhp(void) { test_data data = { .machine = "virt", + .arch = "aarch64", .tcg_only = true, .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", @@ -1684,6 +1685,7 @@ static void test_acpi_aarch64_virt_tcg_numamem(void) { test_data data = { .machine = "virt", + .arch = "aarch64", .tcg_only = true, .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", @@ -1706,6 +1708,7 @@ static void test_acpi_aarch64_virt_tcg_pxb(void) { test_data data = { .machine = "virt", + .arch = "aarch64", .tcg_only = true, .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", @@ -1779,6 +1782,7 @@ static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) { test_data data = { .machine = "virt", + .arch = "aarch64", .tcg_only = true, .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", @@ -1935,6 +1939,7 @@ static void test_acpi_aarch64_virt_tcg(void) { test_data data = { .machine = "virt", + .arch = "aarch64", .tcg_only = true, .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", @@ -1954,6 +1959,7 @@ static void test_acpi_aarch64_virt_tcg_topology(void) { test_data data = { .machine = "virt", + .arch = "aarch64", .variant = ".topology", .tcg_only = true, .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", @@ -2037,6 +2043,7 @@ static void test_acpi_aarch64_virt_viot(void) { test_data data = { .machine = "virt", + .arch = "aarch64", .tcg_only = true, .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", @@ -2213,6 +2220,7 @@ static void test_acpi_aarch64_virt_oem_fields(void) { test_data data = { .machine = "virt", + .arch = "aarch64", .tcg_only = true, .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", From patchwork Wed Jul 3 22:49:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723004 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0DE1CC3271E for ; Wed, 3 Jul 2024 22:51:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8nJ-00071q-GV; Wed, 03 Jul 2024 18:49:45 -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 1sP8nI-0006ss-7V for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49: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 1sP8n6-00070X-Tb for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046972; 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=H0Zx9hcjCb8TTX+fknLAFuiiboZn7NyIn2VBiJnNZQk=; b=VM0MAfFVGW2BXCHzp/faGQO2tsFj0ogvcBqNneOzyM0n07F00EstmN9EwqhM2J8SJuy10o hJJBCc/s9SkIabXwbF89gdA33OpFMTNxGVQ9TR8ViMLSi+BYYk5mRBranpESlhWaFg61wf 9VJOLej5MD2S1CBxw37eqCO32FvZHT4= 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-618-oWlJxF-QNiO9cApJStP49A-1; Wed, 03 Jul 2024 18:49:29 -0400 X-MC-Unique: oWlJxF-QNiO9cApJStP49A-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3678f403afaso45147f8f.0 for ; Wed, 03 Jul 2024 15:49:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046968; x=1720651768; 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=H0Zx9hcjCb8TTX+fknLAFuiiboZn7NyIn2VBiJnNZQk=; b=jVFfQE1gMizsFtCmgAP9MQW68Q2ZZT/vN7/HWZ0JVC/a+u45it9lxP0fHrTagQMR2S BXX2oMvAfcrcy7007gF6bMQL0NmojzcKJZ/JoXTLuF6gnUjLfftyOs9FTrg9g4x+p+Xd RfKeIeW0Q4r7rSSwn6rqaudQPtJRAVIVIrOGtByIt2EYYTO5w/BAlGMCPCjU0O8i+TpF vZro7zDpLIR0VlrdWM+p/K+DaiwTstfyb4GMGbTit6l++QcjRoIc7BOZcPwvyj2TqlRc 4UdRfEXAJGdIuSEF9zSD4OZFnb5MfNU/j/5rN2k0lewYawu6EwKdkjatarXO+IXdxqkF FZJQ== X-Gm-Message-State: AOJu0Yzwd8r9XAa2bts8y/sNTeKqjDNic4wtUrJZaE75be8eus7JGrXw +nKL9bMg1bXqjtU95aj5N5SvKWwS2NP4CGpX2hpL8rhnXESWgCN2dVfddRc/T5/AKicQ06W2W3t XalSnRtZnnBXwA+BVQ0IaAZv+k5MtnNZOT7PUXvp8du2kiSb6Vj4p08LpzmNnsdi4PByJT/vjO8 hUSHYk+Mfa012yjzpffSQnos6YIZNvQg== X-Received: by 2002:a5d:680b:0:b0:367:9801:9c5b with SMTP id ffacd0b85a97d-3679dd67bbfmr5824f8f.50.1720046967888; Wed, 03 Jul 2024 15:49:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHQUIKbVgMSXeKuVxtELqP5V/h+UXoApWANU5a/GwchrI2Dm0aUGXRESjDruHud9UvF2xwpg== X-Received: by 2002:a5d:680b:0:b0:367:9801:9c5b with SMTP id ffacd0b85a97d-3679dd67bbfmr5812f8f.50.1720046967138; Wed, 03 Jul 2024 15:49:27 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3678fefc01dsm3614889f8f.26.2024.07.03.15.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:49:25 -0700 (PDT) Date: Wed, 3 Jul 2024 18:49:22 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Igor Mammedov , Ani Sinha Subject: [PULL v3 66/85] tests/qtest/bios-tables-test.c: Set "arch" for x86 tests 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Sunil V L To search for expected AML files under ${arch}/${machine} path, set this field for X86 related test cases. Signed-off-by: Sunil V L Reviewed-by: Igor Mammedov Message-Id: <20240625150839.1358279-9-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test.c | 77 ++++++++++++++++++++++++++++------ 1 file changed, 64 insertions(+), 13 deletions(-) diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c index 007c281c9a..f4c4704bab 100644 --- a/tests/qtest/bios-tables-test.c +++ b/tests/qtest/bios-tables-test.c @@ -933,6 +933,7 @@ static void test_acpi_piix4_tcg(void) * This is to make guest actually run. */ data.machine = MACHINE_PC; + data.arch = "x86"; data.required_struct_types = base_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); test_acpi_one(NULL, &data); @@ -944,6 +945,7 @@ static void test_acpi_piix4_tcg_bridge(void) test_data data = {}; data.machine = MACHINE_PC; + data.arch = "x86"; data.variant = ".bridge"; data.required_struct_types = base_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); @@ -981,6 +983,7 @@ static void test_acpi_piix4_no_root_hotplug(void) test_data data = {}; data.machine = MACHINE_PC; + data.arch = "x86"; data.variant = ".roothp"; data.required_struct_types = base_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); @@ -997,6 +1000,7 @@ static void test_acpi_piix4_no_bridge_hotplug(void) test_data data = {}; data.machine = MACHINE_PC; + data.arch = "x86"; data.variant = ".hpbridge"; data.required_struct_types = base_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); @@ -1013,6 +1017,7 @@ static void test_acpi_piix4_no_acpi_pci_hotplug(void) test_data data = {}; data.machine = MACHINE_PC; + data.arch = "x86"; data.variant = ".hpbrroot"; data.required_struct_types = base_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); @@ -1034,6 +1039,7 @@ static void test_acpi_q35_tcg(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86"; data.required_struct_types = base_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); test_acpi_one(NULL, &data); @@ -1049,6 +1055,7 @@ static void test_acpi_q35_kvm_type4_count(void) { test_data data = { .machine = MACHINE_Q35, + .arch = "x86", .variant = ".type4-count", .required_struct_types = base_required_struct_types, .required_struct_types_len = ARRAY_SIZE(base_required_struct_types), @@ -1065,6 +1072,7 @@ static void test_acpi_q35_kvm_core_count(void) { test_data data = { .machine = MACHINE_Q35, + .arch = "x86", .variant = ".core-count", .required_struct_types = base_required_struct_types, .required_struct_types_len = ARRAY_SIZE(base_required_struct_types), @@ -1082,6 +1090,7 @@ static void test_acpi_q35_kvm_core_count2(void) { test_data data = { .machine = MACHINE_Q35, + .arch = "x86", .variant = ".core-count2", .required_struct_types = base_required_struct_types, .required_struct_types_len = ARRAY_SIZE(base_required_struct_types), @@ -1099,6 +1108,7 @@ static void test_acpi_q35_kvm_thread_count(void) { test_data data = { .machine = MACHINE_Q35, + .arch = "x86", .variant = ".thread-count", .required_struct_types = base_required_struct_types, .required_struct_types_len = ARRAY_SIZE(base_required_struct_types), @@ -1116,6 +1126,7 @@ static void test_acpi_q35_kvm_thread_count2(void) { test_data data = { .machine = MACHINE_Q35, + .arch = "x86", .variant = ".thread-count2", .required_struct_types = base_required_struct_types, .required_struct_types_len = ARRAY_SIZE(base_required_struct_types), @@ -1134,6 +1145,7 @@ static void test_acpi_q35_tcg_bridge(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86", data.variant = ".bridge"; data.required_struct_types = base_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); @@ -1148,6 +1160,7 @@ static void test_acpi_q35_tcg_no_acpi_hotplug(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86", data.variant = ".noacpihp"; data.required_struct_types = base_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); @@ -1176,6 +1189,7 @@ static void test_acpi_q35_multif_bridge(void) { test_data data = { .machine = MACHINE_Q35, + .arch = "x86", .variant = ".multi-bridge", }; test_vm_prepare("-S" @@ -1225,6 +1239,7 @@ static void test_acpi_q35_tcg_mmio64(void) { test_data data = { .machine = MACHINE_Q35, + .arch = "x86", .variant = ".mmio64", .tcg_only = true, .required_struct_types = base_required_struct_types, @@ -1245,6 +1260,7 @@ static void test_acpi_piix4_tcg_cphp(void) test_data data = {}; data.machine = MACHINE_PC; + data.arch = "x86"; data.variant = ".cphp"; test_acpi_one("-smp 2,cores=3,sockets=2,maxcpus=6" " -object memory-backend-ram,id=ram0,size=64M" @@ -1260,6 +1276,7 @@ static void test_acpi_q35_tcg_cphp(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86", data.variant = ".cphp"; test_acpi_one(" -smp 2,cores=3,sockets=2,maxcpus=6" " -object memory-backend-ram,id=ram0,size=64M" @@ -1279,6 +1296,7 @@ static void test_acpi_q35_tcg_ipmi(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86", data.variant = ".ipmibt"; data.required_struct_types = ipmi_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); @@ -1293,6 +1311,7 @@ static void test_acpi_q35_tcg_smbus_ipmi(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86", data.variant = ".ipmismbus"; data.required_struct_types = ipmi_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); @@ -1310,6 +1329,7 @@ static void test_acpi_piix4_tcg_ipmi(void) * This is to make guest actually run. */ data.machine = MACHINE_PC; + data.arch = "x86"; data.variant = ".ipmikcs"; data.required_struct_types = ipmi_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types); @@ -1324,6 +1344,7 @@ static void test_acpi_q35_tcg_memhp(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86", data.variant = ".memhp"; test_acpi_one(" -m 128,slots=3,maxmem=1G" " -object memory-backend-ram,id=ram0,size=64M" @@ -1339,6 +1360,7 @@ static void test_acpi_piix4_tcg_memhp(void) test_data data = {}; data.machine = MACHINE_PC; + data.arch = "x86"; data.variant = ".memhp"; test_acpi_one(" -m 128,slots=3,maxmem=1G" " -object memory-backend-ram,id=ram0,size=64M" @@ -1354,6 +1376,7 @@ static void test_acpi_piix4_tcg_nosmm(void) test_data data = {}; data.machine = MACHINE_PC; + data.arch = "x86"; data.variant = ".nosmm"; test_acpi_one("-machine smm=off", &data); free_test_data(&data); @@ -1364,6 +1387,7 @@ static void test_acpi_piix4_tcg_smm_compat(void) test_data data = {}; data.machine = MACHINE_PC; + data.arch = "x86"; data.variant = ".smm-compat"; test_acpi_one("-global PIIX4_PM.smm-compat=on", &data); free_test_data(&data); @@ -1374,6 +1398,7 @@ static void test_acpi_piix4_tcg_smm_compat_nosmm(void) test_data data = {}; data.machine = MACHINE_PC; + data.arch = "x86"; data.variant = ".smm-compat-nosmm"; test_acpi_one("-global PIIX4_PM.smm-compat=on -machine smm=off", &data); free_test_data(&data); @@ -1384,6 +1409,7 @@ static void test_acpi_piix4_tcg_nohpet(void) test_data data = {}; data.machine = MACHINE_PC; + data.arch = "x86"; data.machine_param = ",hpet=off"; data.variant = ".nohpet"; test_acpi_one(NULL, &data); @@ -1395,6 +1421,7 @@ static void test_acpi_q35_tcg_numamem(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86", data.variant = ".numamem"; test_acpi_one(" -object memory-backend-ram,id=ram0,size=128M" " -numa node -numa node,memdev=ram0", &data); @@ -1406,6 +1433,7 @@ static void test_acpi_q35_kvm_xapic(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86", data.variant = ".xapic"; test_acpi_one(" -object memory-backend-ram,id=ram0,size=128M" " -numa node -numa node,memdev=ram0" @@ -1418,6 +1446,7 @@ static void test_acpi_q35_tcg_nosmm(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86", data.variant = ".nosmm"; test_acpi_one("-machine smm=off", &data); free_test_data(&data); @@ -1428,6 +1457,7 @@ static void test_acpi_q35_tcg_smm_compat(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86", data.variant = ".smm-compat"; test_acpi_one("-global ICH9-LPC.smm-compat=on", &data); free_test_data(&data); @@ -1438,6 +1468,7 @@ static void test_acpi_q35_tcg_smm_compat_nosmm(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86", data.variant = ".smm-compat-nosmm"; test_acpi_one("-global ICH9-LPC.smm-compat=on -machine smm=off", &data); free_test_data(&data); @@ -1448,6 +1479,7 @@ static void test_acpi_q35_tcg_nohpet(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86", data.machine_param = ",hpet=off"; data.variant = ".nohpet"; test_acpi_one(NULL, &data); @@ -1459,6 +1491,7 @@ static void test_acpi_q35_kvm_dmar(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86", data.variant = ".dmar"; test_acpi_one("-machine kernel-irqchip=split -accel kvm" " -device intel-iommu,intremap=on,device-iotlb=on", &data); @@ -1470,6 +1503,7 @@ static void test_acpi_q35_tcg_ivrs(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86", data.variant = ".ivrs"; data.tcg_only = true, test_acpi_one(" -device amd-iommu", &data); @@ -1481,6 +1515,7 @@ static void test_acpi_piix4_tcg_numamem(void) test_data data = {}; data.machine = MACHINE_PC; + data.arch = "x86"; data.variant = ".numamem"; test_acpi_one(" -object memory-backend-ram,id=ram0,size=128M" " -numa node -numa node,memdev=ram0", &data); @@ -1489,8 +1524,9 @@ static void test_acpi_piix4_tcg_numamem(void) uint64_t tpm_tis_base_addr; -static void test_acpi_tcg_tpm(const char *machine, const char *tpm_if, - uint64_t base, enum TPMVersion tpm_version) +static void test_acpi_tcg_tpm(const char *machine, const char *arch, + const char *tpm_if, uint64_t base, + enum TPMVersion tpm_version) { gchar *tmp_dir_name = g_strdup_printf("qemu-test_acpi_%s_tcg_%s.XXXXXX", machine, tpm_if); @@ -1517,6 +1553,7 @@ static void test_acpi_tcg_tpm(const char *machine, const char *tpm_if, tpm_emu_test_wait_cond(&test); data.machine = machine; + data.arch = arch; data.variant = variant; args = g_strdup_printf( @@ -1540,19 +1577,20 @@ static void test_acpi_tcg_tpm(const char *machine, const char *tpm_if, static void test_acpi_q35_tcg_tpm2_tis(void) { - test_acpi_tcg_tpm("q35", "tis", 0xFED40000, TPM_VERSION_2_0); + test_acpi_tcg_tpm("q35", "x86", "tis", 0xFED40000, TPM_VERSION_2_0); } static void test_acpi_q35_tcg_tpm12_tis(void) { - test_acpi_tcg_tpm("q35", "tis", 0xFED40000, TPM_VERSION_1_2); + test_acpi_tcg_tpm("q35", "x86", "tis", 0xFED40000, TPM_VERSION_1_2); } -static void test_acpi_tcg_dimm_pxm(const char *machine) +static void test_acpi_tcg_dimm_pxm(const char *machine, const char *arch) { test_data data = {}; data.machine = machine; + data.arch = arch; data.variant = ".dimmpxm"; test_acpi_one(" -machine nvdimm=on,nvdimm-persistence=cpu" " -smp 4,sockets=4" @@ -1579,12 +1617,12 @@ static void test_acpi_tcg_dimm_pxm(const char *machine) static void test_acpi_q35_tcg_dimm_pxm(void) { - test_acpi_tcg_dimm_pxm(MACHINE_Q35); + test_acpi_tcg_dimm_pxm(MACHINE_Q35, "x86"); } static void test_acpi_piix4_tcg_dimm_pxm(void) { - test_acpi_tcg_dimm_pxm(MACHINE_PC); + test_acpi_tcg_dimm_pxm(MACHINE_PC, "x86"); } static void test_acpi_aarch64_virt_tcg_memhp(void) @@ -1621,6 +1659,7 @@ static void test_acpi_aarch64_virt_tcg_memhp(void) static void test_acpi_microvm_prepare(test_data *data) { data->machine = "microvm"; + data->arch = "x86"; data->required_struct_types = NULL; /* no smbios */ data->required_struct_types_len = 0; data->blkdev = "virtio-blk-device"; @@ -1737,11 +1776,12 @@ static void test_acpi_aarch64_virt_tcg_pxb(void) free_test_data(&data); } -static void test_acpi_tcg_acpi_hmat(const char *machine) +static void test_acpi_tcg_acpi_hmat(const char *machine, const char *arch) { test_data data = {}; data.machine = machine; + data.arch = arch; data.variant = ".acpihmat"; test_acpi_one(" -machine hmat=on" " -smp 2,sockets=2" @@ -1770,12 +1810,12 @@ static void test_acpi_tcg_acpi_hmat(const char *machine) static void test_acpi_q35_tcg_acpi_hmat(void) { - test_acpi_tcg_acpi_hmat(MACHINE_Q35); + test_acpi_tcg_acpi_hmat(MACHINE_Q35, "x86"); } static void test_acpi_piix4_tcg_acpi_hmat(void) { - test_acpi_tcg_acpi_hmat(MACHINE_PC); + test_acpi_tcg_acpi_hmat(MACHINE_PC, "x86"); } static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) @@ -1841,6 +1881,7 @@ static void test_acpi_q35_tcg_acpi_hmat_noinitiator(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86"; data.variant = ".acpihmat-noinitiator"; test_acpi_one(" -machine hmat=on" " -smp 4,sockets=2" @@ -1884,13 +1925,14 @@ static void test_acpi_q35_tcg_acpi_hmat_noinitiator(void) } #ifdef CONFIG_POSIX -static void test_acpi_erst(const char *machine) +static void test_acpi_erst(const char *machine, const char *arch) { gchar *tmp_path = g_dir_make_tmp("qemu-test-erst.XXXXXX", NULL); gchar *params; test_data data = {}; data.machine = machine; + data.arch = arch; data.variant = ".acpierst"; params = g_strdup_printf( " -object memory-backend-file,id=erstnvram," @@ -1905,12 +1947,12 @@ static void test_acpi_erst(const char *machine) static void test_acpi_piix4_acpi_erst(void) { - test_acpi_erst(MACHINE_PC); + test_acpi_erst(MACHINE_PC, "x86"); } static void test_acpi_q35_acpi_erst(void) { - test_acpi_erst(MACHINE_Q35); + test_acpi_erst(MACHINE_Q35, "x86"); } static void test_acpi_microvm_acpi_erst(void) @@ -1978,6 +2020,7 @@ static void test_acpi_q35_viot(void) { test_data data = { .machine = MACHINE_Q35, + .arch = "x86", .variant = ".viot", }; @@ -2002,6 +2045,7 @@ static void test_acpi_q35_cxl(void) test_data data = { .machine = MACHINE_Q35, + .arch = "x86", .variant = ".cxl", }; /* @@ -2067,6 +2111,7 @@ static void test_acpi_q35_slic(void) { test_data data = { .machine = MACHINE_Q35, + .arch = "x86", .variant = ".slic", }; @@ -2081,6 +2126,7 @@ static void test_acpi_q35_applesmc(void) { test_data data = { .machine = MACHINE_Q35, + .arch = "x86", .variant = ".applesmc", }; @@ -2094,6 +2140,7 @@ static void test_acpi_q35_pvpanic_isa(void) { test_data data = { .machine = MACHINE_Q35, + .arch = "x86", .variant = ".pvpanic-isa", }; @@ -2106,6 +2153,7 @@ static void test_acpi_pc_smbios_options(void) uint8_t req_type11[] = { 11 }; test_data data = { .machine = MACHINE_PC, + .arch = "x86", .variant = ".pc_smbios_options", .required_struct_types = req_type11, .required_struct_types_len = ARRAY_SIZE(req_type11), @@ -2120,6 +2168,7 @@ static void test_acpi_pc_smbios_blob(void) uint8_t req_type11[] = { 11 }; test_data data = { .machine = MACHINE_PC, + .arch = "x86", .variant = ".pc_smbios_blob", .required_struct_types = req_type11, .required_struct_types_len = ARRAY_SIZE(req_type11), @@ -2169,6 +2218,7 @@ static void test_acpi_piix4_oem_fields(void) test_data data = {}; data.machine = MACHINE_PC; + data.arch = "x86"; data.required_struct_types = base_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); @@ -2187,6 +2237,7 @@ static void test_acpi_q35_oem_fields(void) test_data data = {}; data.machine = MACHINE_Q35; + data.arch = "x86"; data.required_struct_types = base_required_struct_types; data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types); From patchwork Wed Jul 3 22:49:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13722988 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4EFCAC2BD09 for ; Wed, 3 Jul 2024 22:50:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8nG-0006c2-6Y; Wed, 03 Jul 2024 18:49: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 1sP8nD-0006RF-98 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:39 -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 1sP8n9-000791-Gz for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046974; 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=0nP2DrQRonjaFy24Ds+EPs3WzJvfgKW/1tcH3BUQFDo=; b=dZ6A20N6+2ueXAY7jCtpasqdpU6CRXSdEbxqlAllAxhXxHTCMjE3jeq3NibteJ5fUFm2eM bWxjh3vOCBfY7KD8pjbH3tbecj2Gs+rlW3IyVcykreMaN7pLIV0FZy99DJ8ZkgaPbbfCQV uis/FMyRemFu7e/NaGTKN7GKl25jXaM= 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-630-G-FwGl3uPUacUO6d5kq_8Q-1; Wed, 03 Jul 2024 18:49:33 -0400 X-MC-Unique: G-FwGl3uPUacUO6d5kq_8Q-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-425739141c2so5985e9.2 for ; Wed, 03 Jul 2024 15:49:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046972; x=1720651772; 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=0nP2DrQRonjaFy24Ds+EPs3WzJvfgKW/1tcH3BUQFDo=; b=Rp9bQKgKG7KtaBdeO57cOR2O/uo4G2TTkqc/WgLhH288ngeRHrB13jqrwpQXFo58Ml NMN1bZa5OskaZCBK5J60xpDEirBH1kAbGBLHjivnTokzYdbLW4rzJlROKg3La+vw+VOE MTnrZsv2Bl4dIzNjla+0a71u0fSUnpgzH1tuZiAA3Yu2t9WVWGg7dx5YlkishEOJNHuh ruTpIkQzrd+O9v8ax9AuCu5JBYIJj80WgIxsqVwjEIBgxZh8L3OZ+bKhmHYYPXFsP24J bjn72erzEvVdXrnTQABDxhPxUvlU942oH2ghiQByo/tg6CPggmL9yv11H8uDBclNBM94 XBWw== X-Gm-Message-State: AOJu0YwsMmET0wZKHSNbDA828+RxXU2YxVPj/ypBngQNqBKNW7BsEYQe /IyxzYesX/nkfTSk6BtAe9j3N6bQCLhrMCmx65WZlH4ZpwB2hYFSyibsErs2W1dR6nDEc1CJcjF oMseo30tkHVFxvymB7Bg2N4QKFcVca4OJIF7UbW+VGJaj3LwICEPUgL72G4FCo+qF9BDUfinDhD I4M72WR1sFo/ZOHYkCnzLxOq0oewtxfA== X-Received: by 2002:a05:600c:4811:b0:426:4659:12d2 with SMTP id 5b1f17b1804b1-4264a3e72a8mr387695e9.17.1720046971351; Wed, 03 Jul 2024 15:49:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlLONosuYN+9btSoNf0DwATSWUfuaJbopIG6f8z7OFNvIWJYz7HACu/KIZCib+XuD6AYOk+A== X-Received: by 2002:a05:600c:4811:b0:426:4659:12d2 with SMTP id 5b1f17b1804b1-4264a3e72a8mr387555e9.17.1720046970635; Wed, 03 Jul 2024 15:49:30 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1d6133sm1241415e9.13.2024.07.03.15.49.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:49:30 -0700 (PDT) Date: Wed, 3 Jul 2024 18:49:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Igor Mammedov Subject: [PULL v3 67/85] tests/data/acpi: Move x86 ACPI tables under x86/${machine} path Message-ID: <7c08eefcaf6588b80bd8ce027fab748db3c53f11.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Sunil V L To support multiple architectures using same machine name, create x86 folder and move all x86 related AML files for each machine type inside. Signed-off-by: Sunil V L Reviewed-by: Igor Mammedov Message-Id: <20240625150839.1358279-10-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/data/acpi/{ => x86}/microvm/APIC | Bin tests/data/acpi/{ => x86}/microvm/APIC.ioapic2 | Bin tests/data/acpi/{ => x86}/microvm/APIC.pcie | Bin tests/data/acpi/{ => x86}/microvm/DSDT | Bin tests/data/acpi/{ => x86}/microvm/DSDT.ioapic2 | Bin tests/data/acpi/{ => x86}/microvm/DSDT.pcie | Bin tests/data/acpi/{ => x86}/microvm/DSDT.rtc | Bin tests/data/acpi/{ => x86}/microvm/DSDT.usb | Bin tests/data/acpi/{ => x86}/microvm/ERST.pcie | Bin tests/data/acpi/{ => x86}/microvm/FACP | Bin tests/data/acpi/{ => x86}/pc/APIC | Bin tests/data/acpi/{ => x86}/pc/APIC.acpihmat | Bin tests/data/acpi/{ => x86}/pc/APIC.cphp | Bin tests/data/acpi/{ => x86}/pc/APIC.dimmpxm | Bin tests/data/acpi/{ => x86}/pc/DSDT | Bin tests/data/acpi/{ => x86}/pc/DSDT.acpierst | Bin tests/data/acpi/{ => x86}/pc/DSDT.acpihmat | Bin tests/data/acpi/{ => x86}/pc/DSDT.bridge | Bin tests/data/acpi/{ => x86}/pc/DSDT.cphp | Bin tests/data/acpi/{ => x86}/pc/DSDT.dimmpxm | Bin tests/data/acpi/{ => x86}/pc/DSDT.hpbridge | Bin tests/data/acpi/{ => x86}/pc/DSDT.hpbrroot | Bin tests/data/acpi/{ => x86}/pc/DSDT.ipmikcs | Bin tests/data/acpi/{ => x86}/pc/DSDT.memhp | Bin tests/data/acpi/{ => x86}/pc/DSDT.nohpet | Bin tests/data/acpi/{ => x86}/pc/DSDT.numamem | Bin tests/data/acpi/{ => x86}/pc/DSDT.roothp | Bin tests/data/acpi/{ => x86}/pc/ERST.acpierst | Bin tests/data/acpi/{ => x86}/pc/FACP | Bin tests/data/acpi/{ => x86}/pc/FACP.nosmm | Bin tests/data/acpi/{ => x86}/pc/FACS | Bin tests/data/acpi/{ => x86}/pc/HMAT.acpihmat | Bin tests/data/acpi/{ => x86}/pc/HPET | Bin tests/data/acpi/{ => x86}/pc/NFIT.dimmpxm | Bin tests/data/acpi/{ => x86}/pc/SLIT.cphp | Bin tests/data/acpi/{ => x86}/pc/SLIT.memhp | Bin tests/data/acpi/{ => x86}/pc/SRAT.acpihmat | Bin tests/data/acpi/{ => x86}/pc/SRAT.cphp | Bin tests/data/acpi/{ => x86}/pc/SRAT.dimmpxm | Bin tests/data/acpi/{ => x86}/pc/SRAT.memhp | Bin tests/data/acpi/{ => x86}/pc/SRAT.numamem | Bin tests/data/acpi/{ => x86}/pc/SSDT.dimmpxm | Bin tests/data/acpi/{ => x86}/pc/WAET | Bin tests/data/acpi/{ => x86}/q35/APIC | Bin tests/data/acpi/{ => x86}/q35/APIC.acpihmat | Bin .../acpi/{ => x86}/q35/APIC.acpihmat-noinitiator | Bin tests/data/acpi/{ => x86}/q35/APIC.core-count | Bin tests/data/acpi/{ => x86}/q35/APIC.core-count2 | Bin tests/data/acpi/{ => x86}/q35/APIC.cphp | Bin tests/data/acpi/{ => x86}/q35/APIC.dimmpxm | Bin tests/data/acpi/{ => x86}/q35/APIC.thread-count | Bin tests/data/acpi/{ => x86}/q35/APIC.thread-count2 | Bin tests/data/acpi/{ => x86}/q35/APIC.type4-count | Bin tests/data/acpi/{ => x86}/q35/APIC.xapic | Bin tests/data/acpi/{ => x86}/q35/CEDT.cxl | Bin tests/data/acpi/{ => x86}/q35/DMAR.dmar | Bin tests/data/acpi/{ => x86}/q35/DSDT | Bin tests/data/acpi/{ => x86}/q35/DSDT.acpierst | Bin tests/data/acpi/{ => x86}/q35/DSDT.acpihmat | Bin .../acpi/{ => x86}/q35/DSDT.acpihmat-noinitiator | Bin tests/data/acpi/{ => x86}/q35/DSDT.applesmc | Bin tests/data/acpi/{ => x86}/q35/DSDT.bridge | Bin tests/data/acpi/{ => x86}/q35/DSDT.core-count | Bin tests/data/acpi/{ => x86}/q35/DSDT.core-count2 | Bin tests/data/acpi/{ => x86}/q35/DSDT.cphp | Bin tests/data/acpi/{ => x86}/q35/DSDT.cxl | Bin tests/data/acpi/{ => x86}/q35/DSDT.dimmpxm | Bin tests/data/acpi/{ => x86}/q35/DSDT.ipmibt | Bin tests/data/acpi/{ => x86}/q35/DSDT.ipmismbus | Bin tests/data/acpi/{ => x86}/q35/DSDT.ivrs | Bin tests/data/acpi/{ => x86}/q35/DSDT.memhp | Bin tests/data/acpi/{ => x86}/q35/DSDT.mmio64 | Bin tests/data/acpi/{ => x86}/q35/DSDT.multi-bridge | Bin tests/data/acpi/{ => x86}/q35/DSDT.noacpihp | Bin tests/data/acpi/{ => x86}/q35/DSDT.nohpet | Bin tests/data/acpi/{ => x86}/q35/DSDT.numamem | Bin tests/data/acpi/{ => x86}/q35/DSDT.pvpanic-isa | Bin tests/data/acpi/{ => x86}/q35/DSDT.thread-count | Bin tests/data/acpi/{ => x86}/q35/DSDT.thread-count2 | Bin tests/data/acpi/{ => x86}/q35/DSDT.tis.tpm12 | Bin tests/data/acpi/{ => x86}/q35/DSDT.tis.tpm2 | Bin tests/data/acpi/{ => x86}/q35/DSDT.type4-count | Bin tests/data/acpi/{ => x86}/q35/DSDT.viot | Bin tests/data/acpi/{ => x86}/q35/DSDT.xapic | Bin tests/data/acpi/{ => x86}/q35/ERST.acpierst | Bin tests/data/acpi/{ => x86}/q35/FACP | Bin tests/data/acpi/{ => x86}/q35/FACP.core-count | Bin tests/data/acpi/{ => x86}/q35/FACP.core-count2 | Bin tests/data/acpi/{ => x86}/q35/FACP.nosmm | Bin tests/data/acpi/{ => x86}/q35/FACP.slic | Bin tests/data/acpi/{ => x86}/q35/FACP.thread-count | Bin tests/data/acpi/{ => x86}/q35/FACP.thread-count2 | Bin tests/data/acpi/{ => x86}/q35/FACP.type4-count | Bin tests/data/acpi/{ => x86}/q35/FACP.xapic | Bin tests/data/acpi/{ => x86}/q35/FACS | Bin tests/data/acpi/{ => x86}/q35/HMAT.acpihmat | Bin .../acpi/{ => x86}/q35/HMAT.acpihmat-noinitiator | Bin tests/data/acpi/{ => x86}/q35/HPET | Bin tests/data/acpi/{ => x86}/q35/IVRS.ivrs | Bin tests/data/acpi/{ => x86}/q35/MCFG | Bin tests/data/acpi/{ => x86}/q35/NFIT.dimmpxm | Bin tests/data/acpi/{ => x86}/q35/SLIC.slic | Bin tests/data/acpi/{ => x86}/q35/SLIT.cphp | Bin tests/data/acpi/{ => x86}/q35/SLIT.memhp | Bin tests/data/acpi/{ => x86}/q35/SRAT.acpihmat | Bin .../acpi/{ => x86}/q35/SRAT.acpihmat-noinitiator | Bin tests/data/acpi/{ => x86}/q35/SRAT.cphp | Bin tests/data/acpi/{ => x86}/q35/SRAT.dimmpxm | Bin tests/data/acpi/{ => x86}/q35/SRAT.memhp | Bin tests/data/acpi/{ => x86}/q35/SRAT.mmio64 | Bin tests/data/acpi/{ => x86}/q35/SRAT.numamem | Bin tests/data/acpi/{ => x86}/q35/SRAT.xapic | Bin tests/data/acpi/{ => x86}/q35/SSDT.dimmpxm | Bin tests/data/acpi/{ => x86}/q35/TCPA.tis.tpm12 | Bin tests/data/acpi/{ => x86}/q35/TPM2.tis.tpm2 | Bin tests/data/acpi/{ => x86}/q35/VIOT.viot | Bin tests/data/acpi/{ => x86}/q35/WAET | Bin 117 files changed, 0 insertions(+), 0 deletions(-) rename tests/data/acpi/{ => x86}/microvm/APIC (100%) rename tests/data/acpi/{ => x86}/microvm/APIC.ioapic2 (100%) rename tests/data/acpi/{ => x86}/microvm/APIC.pcie (100%) rename tests/data/acpi/{ => x86}/microvm/DSDT (100%) rename tests/data/acpi/{ => x86}/microvm/DSDT.ioapic2 (100%) rename tests/data/acpi/{ => x86}/microvm/DSDT.pcie (100%) rename tests/data/acpi/{ => x86}/microvm/DSDT.rtc (100%) rename tests/data/acpi/{ => x86}/microvm/DSDT.usb (100%) rename tests/data/acpi/{ => x86}/microvm/ERST.pcie (100%) rename tests/data/acpi/{ => x86}/microvm/FACP (100%) rename tests/data/acpi/{ => x86}/pc/APIC (100%) rename tests/data/acpi/{ => x86}/pc/APIC.acpihmat (100%) rename tests/data/acpi/{ => x86}/pc/APIC.cphp (100%) rename tests/data/acpi/{ => x86}/pc/APIC.dimmpxm (100%) rename tests/data/acpi/{ => x86}/pc/DSDT (100%) rename tests/data/acpi/{ => x86}/pc/DSDT.acpierst (100%) rename tests/data/acpi/{ => x86}/pc/DSDT.acpihmat (100%) rename tests/data/acpi/{ => x86}/pc/DSDT.bridge (100%) rename tests/data/acpi/{ => x86}/pc/DSDT.cphp (100%) rename tests/data/acpi/{ => x86}/pc/DSDT.dimmpxm (100%) rename tests/data/acpi/{ => x86}/pc/DSDT.hpbridge (100%) rename tests/data/acpi/{ => x86}/pc/DSDT.hpbrroot (100%) rename tests/data/acpi/{ => x86}/pc/DSDT.ipmikcs (100%) rename tests/data/acpi/{ => x86}/pc/DSDT.memhp (100%) rename tests/data/acpi/{ => x86}/pc/DSDT.nohpet (100%) rename tests/data/acpi/{ => x86}/pc/DSDT.numamem (100%) rename tests/data/acpi/{ => x86}/pc/DSDT.roothp (100%) rename tests/data/acpi/{ => x86}/pc/ERST.acpierst (100%) rename tests/data/acpi/{ => x86}/pc/FACP (100%) rename tests/data/acpi/{ => x86}/pc/FACP.nosmm (100%) rename tests/data/acpi/{ => x86}/pc/FACS (100%) rename tests/data/acpi/{ => x86}/pc/HMAT.acpihmat (100%) rename tests/data/acpi/{ => x86}/pc/HPET (100%) rename tests/data/acpi/{ => x86}/pc/NFIT.dimmpxm (100%) rename tests/data/acpi/{ => x86}/pc/SLIT.cphp (100%) rename tests/data/acpi/{ => x86}/pc/SLIT.memhp (100%) rename tests/data/acpi/{ => x86}/pc/SRAT.acpihmat (100%) rename tests/data/acpi/{ => x86}/pc/SRAT.cphp (100%) rename tests/data/acpi/{ => x86}/pc/SRAT.dimmpxm (100%) rename tests/data/acpi/{ => x86}/pc/SRAT.memhp (100%) rename tests/data/acpi/{ => x86}/pc/SRAT.numamem (100%) rename tests/data/acpi/{ => x86}/pc/SSDT.dimmpxm (100%) rename tests/data/acpi/{ => x86}/pc/WAET (100%) rename tests/data/acpi/{ => x86}/q35/APIC (100%) rename tests/data/acpi/{ => x86}/q35/APIC.acpihmat (100%) rename tests/data/acpi/{ => x86}/q35/APIC.acpihmat-noinitiator (100%) rename tests/data/acpi/{ => x86}/q35/APIC.core-count (100%) rename tests/data/acpi/{ => x86}/q35/APIC.core-count2 (100%) rename tests/data/acpi/{ => x86}/q35/APIC.cphp (100%) rename tests/data/acpi/{ => x86}/q35/APIC.dimmpxm (100%) rename tests/data/acpi/{ => x86}/q35/APIC.thread-count (100%) rename tests/data/acpi/{ => x86}/q35/APIC.thread-count2 (100%) rename tests/data/acpi/{ => x86}/q35/APIC.type4-count (100%) rename tests/data/acpi/{ => x86}/q35/APIC.xapic (100%) rename tests/data/acpi/{ => x86}/q35/CEDT.cxl (100%) rename tests/data/acpi/{ => x86}/q35/DMAR.dmar (100%) rename tests/data/acpi/{ => x86}/q35/DSDT (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.acpierst (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.acpihmat (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.acpihmat-noinitiator (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.applesmc (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.bridge (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.core-count (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.core-count2 (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.cphp (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.cxl (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.dimmpxm (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.ipmibt (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.ipmismbus (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.ivrs (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.memhp (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.mmio64 (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.multi-bridge (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.noacpihp (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.nohpet (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.numamem (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.pvpanic-isa (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.thread-count (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.thread-count2 (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.tis.tpm12 (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.tis.tpm2 (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.type4-count (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.viot (100%) rename tests/data/acpi/{ => x86}/q35/DSDT.xapic (100%) rename tests/data/acpi/{ => x86}/q35/ERST.acpierst (100%) rename tests/data/acpi/{ => x86}/q35/FACP (100%) rename tests/data/acpi/{ => x86}/q35/FACP.core-count (100%) rename tests/data/acpi/{ => x86}/q35/FACP.core-count2 (100%) rename tests/data/acpi/{ => x86}/q35/FACP.nosmm (100%) rename tests/data/acpi/{ => x86}/q35/FACP.slic (100%) rename tests/data/acpi/{ => x86}/q35/FACP.thread-count (100%) rename tests/data/acpi/{ => x86}/q35/FACP.thread-count2 (100%) rename tests/data/acpi/{ => x86}/q35/FACP.type4-count (100%) rename tests/data/acpi/{ => x86}/q35/FACP.xapic (100%) rename tests/data/acpi/{ => x86}/q35/FACS (100%) rename tests/data/acpi/{ => x86}/q35/HMAT.acpihmat (100%) rename tests/data/acpi/{ => x86}/q35/HMAT.acpihmat-noinitiator (100%) rename tests/data/acpi/{ => x86}/q35/HPET (100%) rename tests/data/acpi/{ => x86}/q35/IVRS.ivrs (100%) rename tests/data/acpi/{ => x86}/q35/MCFG (100%) rename tests/data/acpi/{ => x86}/q35/NFIT.dimmpxm (100%) rename tests/data/acpi/{ => x86}/q35/SLIC.slic (100%) rename tests/data/acpi/{ => x86}/q35/SLIT.cphp (100%) rename tests/data/acpi/{ => x86}/q35/SLIT.memhp (100%) rename tests/data/acpi/{ => x86}/q35/SRAT.acpihmat (100%) rename tests/data/acpi/{ => x86}/q35/SRAT.acpihmat-noinitiator (100%) rename tests/data/acpi/{ => x86}/q35/SRAT.cphp (100%) rename tests/data/acpi/{ => x86}/q35/SRAT.dimmpxm (100%) rename tests/data/acpi/{ => x86}/q35/SRAT.memhp (100%) rename tests/data/acpi/{ => x86}/q35/SRAT.mmio64 (100%) rename tests/data/acpi/{ => x86}/q35/SRAT.numamem (100%) rename tests/data/acpi/{ => x86}/q35/SRAT.xapic (100%) rename tests/data/acpi/{ => x86}/q35/SSDT.dimmpxm (100%) rename tests/data/acpi/{ => x86}/q35/TCPA.tis.tpm12 (100%) rename tests/data/acpi/{ => x86}/q35/TPM2.tis.tpm2 (100%) rename tests/data/acpi/{ => x86}/q35/VIOT.viot (100%) rename tests/data/acpi/{ => x86}/q35/WAET (100%) diff --git a/tests/data/acpi/microvm/APIC b/tests/data/acpi/x86/microvm/APIC similarity index 100% rename from tests/data/acpi/microvm/APIC rename to tests/data/acpi/x86/microvm/APIC diff --git a/tests/data/acpi/microvm/APIC.ioapic2 b/tests/data/acpi/x86/microvm/APIC.ioapic2 similarity index 100% rename from tests/data/acpi/microvm/APIC.ioapic2 rename to tests/data/acpi/x86/microvm/APIC.ioapic2 diff --git a/tests/data/acpi/microvm/APIC.pcie b/tests/data/acpi/x86/microvm/APIC.pcie similarity index 100% rename from tests/data/acpi/microvm/APIC.pcie rename to tests/data/acpi/x86/microvm/APIC.pcie diff --git a/tests/data/acpi/microvm/DSDT b/tests/data/acpi/x86/microvm/DSDT similarity index 100% rename from tests/data/acpi/microvm/DSDT rename to tests/data/acpi/x86/microvm/DSDT diff --git a/tests/data/acpi/microvm/DSDT.ioapic2 b/tests/data/acpi/x86/microvm/DSDT.ioapic2 similarity index 100% rename from tests/data/acpi/microvm/DSDT.ioapic2 rename to tests/data/acpi/x86/microvm/DSDT.ioapic2 diff --git a/tests/data/acpi/microvm/DSDT.pcie b/tests/data/acpi/x86/microvm/DSDT.pcie similarity index 100% rename from tests/data/acpi/microvm/DSDT.pcie rename to tests/data/acpi/x86/microvm/DSDT.pcie diff --git a/tests/data/acpi/microvm/DSDT.rtc b/tests/data/acpi/x86/microvm/DSDT.rtc similarity index 100% rename from tests/data/acpi/microvm/DSDT.rtc rename to tests/data/acpi/x86/microvm/DSDT.rtc diff --git a/tests/data/acpi/microvm/DSDT.usb b/tests/data/acpi/x86/microvm/DSDT.usb similarity index 100% rename from tests/data/acpi/microvm/DSDT.usb rename to tests/data/acpi/x86/microvm/DSDT.usb diff --git a/tests/data/acpi/microvm/ERST.pcie b/tests/data/acpi/x86/microvm/ERST.pcie similarity index 100% rename from tests/data/acpi/microvm/ERST.pcie rename to tests/data/acpi/x86/microvm/ERST.pcie diff --git a/tests/data/acpi/microvm/FACP b/tests/data/acpi/x86/microvm/FACP similarity index 100% rename from tests/data/acpi/microvm/FACP rename to tests/data/acpi/x86/microvm/FACP diff --git a/tests/data/acpi/pc/APIC b/tests/data/acpi/x86/pc/APIC similarity index 100% rename from tests/data/acpi/pc/APIC rename to tests/data/acpi/x86/pc/APIC diff --git a/tests/data/acpi/pc/APIC.acpihmat b/tests/data/acpi/x86/pc/APIC.acpihmat similarity index 100% rename from tests/data/acpi/pc/APIC.acpihmat rename to tests/data/acpi/x86/pc/APIC.acpihmat diff --git a/tests/data/acpi/pc/APIC.cphp b/tests/data/acpi/x86/pc/APIC.cphp similarity index 100% rename from tests/data/acpi/pc/APIC.cphp rename to tests/data/acpi/x86/pc/APIC.cphp diff --git a/tests/data/acpi/pc/APIC.dimmpxm b/tests/data/acpi/x86/pc/APIC.dimmpxm similarity index 100% rename from tests/data/acpi/pc/APIC.dimmpxm rename to tests/data/acpi/x86/pc/APIC.dimmpxm diff --git a/tests/data/acpi/pc/DSDT b/tests/data/acpi/x86/pc/DSDT similarity index 100% rename from tests/data/acpi/pc/DSDT rename to tests/data/acpi/x86/pc/DSDT diff --git a/tests/data/acpi/pc/DSDT.acpierst b/tests/data/acpi/x86/pc/DSDT.acpierst similarity index 100% rename from tests/data/acpi/pc/DSDT.acpierst rename to tests/data/acpi/x86/pc/DSDT.acpierst diff --git a/tests/data/acpi/pc/DSDT.acpihmat b/tests/data/acpi/x86/pc/DSDT.acpihmat similarity index 100% rename from tests/data/acpi/pc/DSDT.acpihmat rename to tests/data/acpi/x86/pc/DSDT.acpihmat diff --git a/tests/data/acpi/pc/DSDT.bridge b/tests/data/acpi/x86/pc/DSDT.bridge similarity index 100% rename from tests/data/acpi/pc/DSDT.bridge rename to tests/data/acpi/x86/pc/DSDT.bridge diff --git a/tests/data/acpi/pc/DSDT.cphp b/tests/data/acpi/x86/pc/DSDT.cphp similarity index 100% rename from tests/data/acpi/pc/DSDT.cphp rename to tests/data/acpi/x86/pc/DSDT.cphp diff --git a/tests/data/acpi/pc/DSDT.dimmpxm b/tests/data/acpi/x86/pc/DSDT.dimmpxm similarity index 100% rename from tests/data/acpi/pc/DSDT.dimmpxm rename to tests/data/acpi/x86/pc/DSDT.dimmpxm diff --git a/tests/data/acpi/pc/DSDT.hpbridge b/tests/data/acpi/x86/pc/DSDT.hpbridge similarity index 100% rename from tests/data/acpi/pc/DSDT.hpbridge rename to tests/data/acpi/x86/pc/DSDT.hpbridge diff --git a/tests/data/acpi/pc/DSDT.hpbrroot b/tests/data/acpi/x86/pc/DSDT.hpbrroot similarity index 100% rename from tests/data/acpi/pc/DSDT.hpbrroot rename to tests/data/acpi/x86/pc/DSDT.hpbrroot diff --git a/tests/data/acpi/pc/DSDT.ipmikcs b/tests/data/acpi/x86/pc/DSDT.ipmikcs similarity index 100% rename from tests/data/acpi/pc/DSDT.ipmikcs rename to tests/data/acpi/x86/pc/DSDT.ipmikcs diff --git a/tests/data/acpi/pc/DSDT.memhp b/tests/data/acpi/x86/pc/DSDT.memhp similarity index 100% rename from tests/data/acpi/pc/DSDT.memhp rename to tests/data/acpi/x86/pc/DSDT.memhp diff --git a/tests/data/acpi/pc/DSDT.nohpet b/tests/data/acpi/x86/pc/DSDT.nohpet similarity index 100% rename from tests/data/acpi/pc/DSDT.nohpet rename to tests/data/acpi/x86/pc/DSDT.nohpet diff --git a/tests/data/acpi/pc/DSDT.numamem b/tests/data/acpi/x86/pc/DSDT.numamem similarity index 100% rename from tests/data/acpi/pc/DSDT.numamem rename to tests/data/acpi/x86/pc/DSDT.numamem diff --git a/tests/data/acpi/pc/DSDT.roothp b/tests/data/acpi/x86/pc/DSDT.roothp similarity index 100% rename from tests/data/acpi/pc/DSDT.roothp rename to tests/data/acpi/x86/pc/DSDT.roothp diff --git a/tests/data/acpi/pc/ERST.acpierst b/tests/data/acpi/x86/pc/ERST.acpierst similarity index 100% rename from tests/data/acpi/pc/ERST.acpierst rename to tests/data/acpi/x86/pc/ERST.acpierst diff --git a/tests/data/acpi/pc/FACP b/tests/data/acpi/x86/pc/FACP similarity index 100% rename from tests/data/acpi/pc/FACP rename to tests/data/acpi/x86/pc/FACP diff --git a/tests/data/acpi/pc/FACP.nosmm b/tests/data/acpi/x86/pc/FACP.nosmm similarity index 100% rename from tests/data/acpi/pc/FACP.nosmm rename to tests/data/acpi/x86/pc/FACP.nosmm diff --git a/tests/data/acpi/pc/FACS b/tests/data/acpi/x86/pc/FACS similarity index 100% rename from tests/data/acpi/pc/FACS rename to tests/data/acpi/x86/pc/FACS diff --git a/tests/data/acpi/pc/HMAT.acpihmat b/tests/data/acpi/x86/pc/HMAT.acpihmat similarity index 100% rename from tests/data/acpi/pc/HMAT.acpihmat rename to tests/data/acpi/x86/pc/HMAT.acpihmat diff --git a/tests/data/acpi/pc/HPET b/tests/data/acpi/x86/pc/HPET similarity index 100% rename from tests/data/acpi/pc/HPET rename to tests/data/acpi/x86/pc/HPET diff --git a/tests/data/acpi/pc/NFIT.dimmpxm b/tests/data/acpi/x86/pc/NFIT.dimmpxm similarity index 100% rename from tests/data/acpi/pc/NFIT.dimmpxm rename to tests/data/acpi/x86/pc/NFIT.dimmpxm diff --git a/tests/data/acpi/pc/SLIT.cphp b/tests/data/acpi/x86/pc/SLIT.cphp similarity index 100% rename from tests/data/acpi/pc/SLIT.cphp rename to tests/data/acpi/x86/pc/SLIT.cphp diff --git a/tests/data/acpi/pc/SLIT.memhp b/tests/data/acpi/x86/pc/SLIT.memhp similarity index 100% rename from tests/data/acpi/pc/SLIT.memhp rename to tests/data/acpi/x86/pc/SLIT.memhp diff --git a/tests/data/acpi/pc/SRAT.acpihmat b/tests/data/acpi/x86/pc/SRAT.acpihmat similarity index 100% rename from tests/data/acpi/pc/SRAT.acpihmat rename to tests/data/acpi/x86/pc/SRAT.acpihmat diff --git a/tests/data/acpi/pc/SRAT.cphp b/tests/data/acpi/x86/pc/SRAT.cphp similarity index 100% rename from tests/data/acpi/pc/SRAT.cphp rename to tests/data/acpi/x86/pc/SRAT.cphp diff --git a/tests/data/acpi/pc/SRAT.dimmpxm b/tests/data/acpi/x86/pc/SRAT.dimmpxm similarity index 100% rename from tests/data/acpi/pc/SRAT.dimmpxm rename to tests/data/acpi/x86/pc/SRAT.dimmpxm diff --git a/tests/data/acpi/pc/SRAT.memhp b/tests/data/acpi/x86/pc/SRAT.memhp similarity index 100% rename from tests/data/acpi/pc/SRAT.memhp rename to tests/data/acpi/x86/pc/SRAT.memhp diff --git a/tests/data/acpi/pc/SRAT.numamem b/tests/data/acpi/x86/pc/SRAT.numamem similarity index 100% rename from tests/data/acpi/pc/SRAT.numamem rename to tests/data/acpi/x86/pc/SRAT.numamem diff --git a/tests/data/acpi/pc/SSDT.dimmpxm b/tests/data/acpi/x86/pc/SSDT.dimmpxm similarity index 100% rename from tests/data/acpi/pc/SSDT.dimmpxm rename to tests/data/acpi/x86/pc/SSDT.dimmpxm diff --git a/tests/data/acpi/pc/WAET b/tests/data/acpi/x86/pc/WAET similarity index 100% rename from tests/data/acpi/pc/WAET rename to tests/data/acpi/x86/pc/WAET diff --git a/tests/data/acpi/q35/APIC b/tests/data/acpi/x86/q35/APIC similarity index 100% rename from tests/data/acpi/q35/APIC rename to tests/data/acpi/x86/q35/APIC diff --git a/tests/data/acpi/q35/APIC.acpihmat b/tests/data/acpi/x86/q35/APIC.acpihmat similarity index 100% rename from tests/data/acpi/q35/APIC.acpihmat rename to tests/data/acpi/x86/q35/APIC.acpihmat diff --git a/tests/data/acpi/q35/APIC.acpihmat-noinitiator b/tests/data/acpi/x86/q35/APIC.acpihmat-noinitiator similarity index 100% rename from tests/data/acpi/q35/APIC.acpihmat-noinitiator rename to tests/data/acpi/x86/q35/APIC.acpihmat-noinitiator diff --git a/tests/data/acpi/q35/APIC.core-count b/tests/data/acpi/x86/q35/APIC.core-count similarity index 100% rename from tests/data/acpi/q35/APIC.core-count rename to tests/data/acpi/x86/q35/APIC.core-count diff --git a/tests/data/acpi/q35/APIC.core-count2 b/tests/data/acpi/x86/q35/APIC.core-count2 similarity index 100% rename from tests/data/acpi/q35/APIC.core-count2 rename to tests/data/acpi/x86/q35/APIC.core-count2 diff --git a/tests/data/acpi/q35/APIC.cphp b/tests/data/acpi/x86/q35/APIC.cphp similarity index 100% rename from tests/data/acpi/q35/APIC.cphp rename to tests/data/acpi/x86/q35/APIC.cphp diff --git a/tests/data/acpi/q35/APIC.dimmpxm b/tests/data/acpi/x86/q35/APIC.dimmpxm similarity index 100% rename from tests/data/acpi/q35/APIC.dimmpxm rename to tests/data/acpi/x86/q35/APIC.dimmpxm diff --git a/tests/data/acpi/q35/APIC.thread-count b/tests/data/acpi/x86/q35/APIC.thread-count similarity index 100% rename from tests/data/acpi/q35/APIC.thread-count rename to tests/data/acpi/x86/q35/APIC.thread-count diff --git a/tests/data/acpi/q35/APIC.thread-count2 b/tests/data/acpi/x86/q35/APIC.thread-count2 similarity index 100% rename from tests/data/acpi/q35/APIC.thread-count2 rename to tests/data/acpi/x86/q35/APIC.thread-count2 diff --git a/tests/data/acpi/q35/APIC.type4-count b/tests/data/acpi/x86/q35/APIC.type4-count similarity index 100% rename from tests/data/acpi/q35/APIC.type4-count rename to tests/data/acpi/x86/q35/APIC.type4-count diff --git a/tests/data/acpi/q35/APIC.xapic b/tests/data/acpi/x86/q35/APIC.xapic similarity index 100% rename from tests/data/acpi/q35/APIC.xapic rename to tests/data/acpi/x86/q35/APIC.xapic diff --git a/tests/data/acpi/q35/CEDT.cxl b/tests/data/acpi/x86/q35/CEDT.cxl similarity index 100% rename from tests/data/acpi/q35/CEDT.cxl rename to tests/data/acpi/x86/q35/CEDT.cxl diff --git a/tests/data/acpi/q35/DMAR.dmar b/tests/data/acpi/x86/q35/DMAR.dmar similarity index 100% rename from tests/data/acpi/q35/DMAR.dmar rename to tests/data/acpi/x86/q35/DMAR.dmar diff --git a/tests/data/acpi/q35/DSDT b/tests/data/acpi/x86/q35/DSDT similarity index 100% rename from tests/data/acpi/q35/DSDT rename to tests/data/acpi/x86/q35/DSDT diff --git a/tests/data/acpi/q35/DSDT.acpierst b/tests/data/acpi/x86/q35/DSDT.acpierst similarity index 100% rename from tests/data/acpi/q35/DSDT.acpierst rename to tests/data/acpi/x86/q35/DSDT.acpierst diff --git a/tests/data/acpi/q35/DSDT.acpihmat b/tests/data/acpi/x86/q35/DSDT.acpihmat similarity index 100% rename from tests/data/acpi/q35/DSDT.acpihmat rename to tests/data/acpi/x86/q35/DSDT.acpihmat diff --git a/tests/data/acpi/q35/DSDT.acpihmat-noinitiator b/tests/data/acpi/x86/q35/DSDT.acpihmat-noinitiator similarity index 100% rename from tests/data/acpi/q35/DSDT.acpihmat-noinitiator rename to tests/data/acpi/x86/q35/DSDT.acpihmat-noinitiator diff --git a/tests/data/acpi/q35/DSDT.applesmc b/tests/data/acpi/x86/q35/DSDT.applesmc similarity index 100% rename from tests/data/acpi/q35/DSDT.applesmc rename to tests/data/acpi/x86/q35/DSDT.applesmc diff --git a/tests/data/acpi/q35/DSDT.bridge b/tests/data/acpi/x86/q35/DSDT.bridge similarity index 100% rename from tests/data/acpi/q35/DSDT.bridge rename to tests/data/acpi/x86/q35/DSDT.bridge diff --git a/tests/data/acpi/q35/DSDT.core-count b/tests/data/acpi/x86/q35/DSDT.core-count similarity index 100% rename from tests/data/acpi/q35/DSDT.core-count rename to tests/data/acpi/x86/q35/DSDT.core-count diff --git a/tests/data/acpi/q35/DSDT.core-count2 b/tests/data/acpi/x86/q35/DSDT.core-count2 similarity index 100% rename from tests/data/acpi/q35/DSDT.core-count2 rename to tests/data/acpi/x86/q35/DSDT.core-count2 diff --git a/tests/data/acpi/q35/DSDT.cphp b/tests/data/acpi/x86/q35/DSDT.cphp similarity index 100% rename from tests/data/acpi/q35/DSDT.cphp rename to tests/data/acpi/x86/q35/DSDT.cphp diff --git a/tests/data/acpi/q35/DSDT.cxl b/tests/data/acpi/x86/q35/DSDT.cxl similarity index 100% rename from tests/data/acpi/q35/DSDT.cxl rename to tests/data/acpi/x86/q35/DSDT.cxl diff --git a/tests/data/acpi/q35/DSDT.dimmpxm b/tests/data/acpi/x86/q35/DSDT.dimmpxm similarity index 100% rename from tests/data/acpi/q35/DSDT.dimmpxm rename to tests/data/acpi/x86/q35/DSDT.dimmpxm diff --git a/tests/data/acpi/q35/DSDT.ipmibt b/tests/data/acpi/x86/q35/DSDT.ipmibt similarity index 100% rename from tests/data/acpi/q35/DSDT.ipmibt rename to tests/data/acpi/x86/q35/DSDT.ipmibt diff --git a/tests/data/acpi/q35/DSDT.ipmismbus b/tests/data/acpi/x86/q35/DSDT.ipmismbus similarity index 100% rename from tests/data/acpi/q35/DSDT.ipmismbus rename to tests/data/acpi/x86/q35/DSDT.ipmismbus diff --git a/tests/data/acpi/q35/DSDT.ivrs b/tests/data/acpi/x86/q35/DSDT.ivrs similarity index 100% rename from tests/data/acpi/q35/DSDT.ivrs rename to tests/data/acpi/x86/q35/DSDT.ivrs diff --git a/tests/data/acpi/q35/DSDT.memhp b/tests/data/acpi/x86/q35/DSDT.memhp similarity index 100% rename from tests/data/acpi/q35/DSDT.memhp rename to tests/data/acpi/x86/q35/DSDT.memhp diff --git a/tests/data/acpi/q35/DSDT.mmio64 b/tests/data/acpi/x86/q35/DSDT.mmio64 similarity index 100% rename from tests/data/acpi/q35/DSDT.mmio64 rename to tests/data/acpi/x86/q35/DSDT.mmio64 diff --git a/tests/data/acpi/q35/DSDT.multi-bridge b/tests/data/acpi/x86/q35/DSDT.multi-bridge similarity index 100% rename from tests/data/acpi/q35/DSDT.multi-bridge rename to tests/data/acpi/x86/q35/DSDT.multi-bridge diff --git a/tests/data/acpi/q35/DSDT.noacpihp b/tests/data/acpi/x86/q35/DSDT.noacpihp similarity index 100% rename from tests/data/acpi/q35/DSDT.noacpihp rename to tests/data/acpi/x86/q35/DSDT.noacpihp diff --git a/tests/data/acpi/q35/DSDT.nohpet b/tests/data/acpi/x86/q35/DSDT.nohpet similarity index 100% rename from tests/data/acpi/q35/DSDT.nohpet rename to tests/data/acpi/x86/q35/DSDT.nohpet diff --git a/tests/data/acpi/q35/DSDT.numamem b/tests/data/acpi/x86/q35/DSDT.numamem similarity index 100% rename from tests/data/acpi/q35/DSDT.numamem rename to tests/data/acpi/x86/q35/DSDT.numamem diff --git a/tests/data/acpi/q35/DSDT.pvpanic-isa b/tests/data/acpi/x86/q35/DSDT.pvpanic-isa similarity index 100% rename from tests/data/acpi/q35/DSDT.pvpanic-isa rename to tests/data/acpi/x86/q35/DSDT.pvpanic-isa diff --git a/tests/data/acpi/q35/DSDT.thread-count b/tests/data/acpi/x86/q35/DSDT.thread-count similarity index 100% rename from tests/data/acpi/q35/DSDT.thread-count rename to tests/data/acpi/x86/q35/DSDT.thread-count diff --git a/tests/data/acpi/q35/DSDT.thread-count2 b/tests/data/acpi/x86/q35/DSDT.thread-count2 similarity index 100% rename from tests/data/acpi/q35/DSDT.thread-count2 rename to tests/data/acpi/x86/q35/DSDT.thread-count2 diff --git a/tests/data/acpi/q35/DSDT.tis.tpm12 b/tests/data/acpi/x86/q35/DSDT.tis.tpm12 similarity index 100% rename from tests/data/acpi/q35/DSDT.tis.tpm12 rename to tests/data/acpi/x86/q35/DSDT.tis.tpm12 diff --git a/tests/data/acpi/q35/DSDT.tis.tpm2 b/tests/data/acpi/x86/q35/DSDT.tis.tpm2 similarity index 100% rename from tests/data/acpi/q35/DSDT.tis.tpm2 rename to tests/data/acpi/x86/q35/DSDT.tis.tpm2 diff --git a/tests/data/acpi/q35/DSDT.type4-count b/tests/data/acpi/x86/q35/DSDT.type4-count similarity index 100% rename from tests/data/acpi/q35/DSDT.type4-count rename to tests/data/acpi/x86/q35/DSDT.type4-count diff --git a/tests/data/acpi/q35/DSDT.viot b/tests/data/acpi/x86/q35/DSDT.viot similarity index 100% rename from tests/data/acpi/q35/DSDT.viot rename to tests/data/acpi/x86/q35/DSDT.viot diff --git a/tests/data/acpi/q35/DSDT.xapic b/tests/data/acpi/x86/q35/DSDT.xapic similarity index 100% rename from tests/data/acpi/q35/DSDT.xapic rename to tests/data/acpi/x86/q35/DSDT.xapic diff --git a/tests/data/acpi/q35/ERST.acpierst b/tests/data/acpi/x86/q35/ERST.acpierst similarity index 100% rename from tests/data/acpi/q35/ERST.acpierst rename to tests/data/acpi/x86/q35/ERST.acpierst diff --git a/tests/data/acpi/q35/FACP b/tests/data/acpi/x86/q35/FACP similarity index 100% rename from tests/data/acpi/q35/FACP rename to tests/data/acpi/x86/q35/FACP diff --git a/tests/data/acpi/q35/FACP.core-count b/tests/data/acpi/x86/q35/FACP.core-count similarity index 100% rename from tests/data/acpi/q35/FACP.core-count rename to tests/data/acpi/x86/q35/FACP.core-count diff --git a/tests/data/acpi/q35/FACP.core-count2 b/tests/data/acpi/x86/q35/FACP.core-count2 similarity index 100% rename from tests/data/acpi/q35/FACP.core-count2 rename to tests/data/acpi/x86/q35/FACP.core-count2 diff --git a/tests/data/acpi/q35/FACP.nosmm b/tests/data/acpi/x86/q35/FACP.nosmm similarity index 100% rename from tests/data/acpi/q35/FACP.nosmm rename to tests/data/acpi/x86/q35/FACP.nosmm diff --git a/tests/data/acpi/q35/FACP.slic b/tests/data/acpi/x86/q35/FACP.slic similarity index 100% rename from tests/data/acpi/q35/FACP.slic rename to tests/data/acpi/x86/q35/FACP.slic diff --git a/tests/data/acpi/q35/FACP.thread-count b/tests/data/acpi/x86/q35/FACP.thread-count similarity index 100% rename from tests/data/acpi/q35/FACP.thread-count rename to tests/data/acpi/x86/q35/FACP.thread-count diff --git a/tests/data/acpi/q35/FACP.thread-count2 b/tests/data/acpi/x86/q35/FACP.thread-count2 similarity index 100% rename from tests/data/acpi/q35/FACP.thread-count2 rename to tests/data/acpi/x86/q35/FACP.thread-count2 diff --git a/tests/data/acpi/q35/FACP.type4-count b/tests/data/acpi/x86/q35/FACP.type4-count similarity index 100% rename from tests/data/acpi/q35/FACP.type4-count rename to tests/data/acpi/x86/q35/FACP.type4-count diff --git a/tests/data/acpi/q35/FACP.xapic b/tests/data/acpi/x86/q35/FACP.xapic similarity index 100% rename from tests/data/acpi/q35/FACP.xapic rename to tests/data/acpi/x86/q35/FACP.xapic diff --git a/tests/data/acpi/q35/FACS b/tests/data/acpi/x86/q35/FACS similarity index 100% rename from tests/data/acpi/q35/FACS rename to tests/data/acpi/x86/q35/FACS diff --git a/tests/data/acpi/q35/HMAT.acpihmat b/tests/data/acpi/x86/q35/HMAT.acpihmat similarity index 100% rename from tests/data/acpi/q35/HMAT.acpihmat rename to tests/data/acpi/x86/q35/HMAT.acpihmat diff --git a/tests/data/acpi/q35/HMAT.acpihmat-noinitiator b/tests/data/acpi/x86/q35/HMAT.acpihmat-noinitiator similarity index 100% rename from tests/data/acpi/q35/HMAT.acpihmat-noinitiator rename to tests/data/acpi/x86/q35/HMAT.acpihmat-noinitiator diff --git a/tests/data/acpi/q35/HPET b/tests/data/acpi/x86/q35/HPET similarity index 100% rename from tests/data/acpi/q35/HPET rename to tests/data/acpi/x86/q35/HPET diff --git a/tests/data/acpi/q35/IVRS.ivrs b/tests/data/acpi/x86/q35/IVRS.ivrs similarity index 100% rename from tests/data/acpi/q35/IVRS.ivrs rename to tests/data/acpi/x86/q35/IVRS.ivrs diff --git a/tests/data/acpi/q35/MCFG b/tests/data/acpi/x86/q35/MCFG similarity index 100% rename from tests/data/acpi/q35/MCFG rename to tests/data/acpi/x86/q35/MCFG diff --git a/tests/data/acpi/q35/NFIT.dimmpxm b/tests/data/acpi/x86/q35/NFIT.dimmpxm similarity index 100% rename from tests/data/acpi/q35/NFIT.dimmpxm rename to tests/data/acpi/x86/q35/NFIT.dimmpxm diff --git a/tests/data/acpi/q35/SLIC.slic b/tests/data/acpi/x86/q35/SLIC.slic similarity index 100% rename from tests/data/acpi/q35/SLIC.slic rename to tests/data/acpi/x86/q35/SLIC.slic diff --git a/tests/data/acpi/q35/SLIT.cphp b/tests/data/acpi/x86/q35/SLIT.cphp similarity index 100% rename from tests/data/acpi/q35/SLIT.cphp rename to tests/data/acpi/x86/q35/SLIT.cphp diff --git a/tests/data/acpi/q35/SLIT.memhp b/tests/data/acpi/x86/q35/SLIT.memhp similarity index 100% rename from tests/data/acpi/q35/SLIT.memhp rename to tests/data/acpi/x86/q35/SLIT.memhp diff --git a/tests/data/acpi/q35/SRAT.acpihmat b/tests/data/acpi/x86/q35/SRAT.acpihmat similarity index 100% rename from tests/data/acpi/q35/SRAT.acpihmat rename to tests/data/acpi/x86/q35/SRAT.acpihmat diff --git a/tests/data/acpi/q35/SRAT.acpihmat-noinitiator b/tests/data/acpi/x86/q35/SRAT.acpihmat-noinitiator similarity index 100% rename from tests/data/acpi/q35/SRAT.acpihmat-noinitiator rename to tests/data/acpi/x86/q35/SRAT.acpihmat-noinitiator diff --git a/tests/data/acpi/q35/SRAT.cphp b/tests/data/acpi/x86/q35/SRAT.cphp similarity index 100% rename from tests/data/acpi/q35/SRAT.cphp rename to tests/data/acpi/x86/q35/SRAT.cphp diff --git a/tests/data/acpi/q35/SRAT.dimmpxm b/tests/data/acpi/x86/q35/SRAT.dimmpxm similarity index 100% rename from tests/data/acpi/q35/SRAT.dimmpxm rename to tests/data/acpi/x86/q35/SRAT.dimmpxm diff --git a/tests/data/acpi/q35/SRAT.memhp b/tests/data/acpi/x86/q35/SRAT.memhp similarity index 100% rename from tests/data/acpi/q35/SRAT.memhp rename to tests/data/acpi/x86/q35/SRAT.memhp diff --git a/tests/data/acpi/q35/SRAT.mmio64 b/tests/data/acpi/x86/q35/SRAT.mmio64 similarity index 100% rename from tests/data/acpi/q35/SRAT.mmio64 rename to tests/data/acpi/x86/q35/SRAT.mmio64 diff --git a/tests/data/acpi/q35/SRAT.numamem b/tests/data/acpi/x86/q35/SRAT.numamem similarity index 100% rename from tests/data/acpi/q35/SRAT.numamem rename to tests/data/acpi/x86/q35/SRAT.numamem diff --git a/tests/data/acpi/q35/SRAT.xapic b/tests/data/acpi/x86/q35/SRAT.xapic similarity index 100% rename from tests/data/acpi/q35/SRAT.xapic rename to tests/data/acpi/x86/q35/SRAT.xapic diff --git a/tests/data/acpi/q35/SSDT.dimmpxm b/tests/data/acpi/x86/q35/SSDT.dimmpxm similarity index 100% rename from tests/data/acpi/q35/SSDT.dimmpxm rename to tests/data/acpi/x86/q35/SSDT.dimmpxm diff --git a/tests/data/acpi/q35/TCPA.tis.tpm12 b/tests/data/acpi/x86/q35/TCPA.tis.tpm12 similarity index 100% rename from tests/data/acpi/q35/TCPA.tis.tpm12 rename to tests/data/acpi/x86/q35/TCPA.tis.tpm12 diff --git a/tests/data/acpi/q35/TPM2.tis.tpm2 b/tests/data/acpi/x86/q35/TPM2.tis.tpm2 similarity index 100% rename from tests/data/acpi/q35/TPM2.tis.tpm2 rename to tests/data/acpi/x86/q35/TPM2.tis.tpm2 diff --git a/tests/data/acpi/q35/VIOT.viot b/tests/data/acpi/x86/q35/VIOT.viot similarity index 100% rename from tests/data/acpi/q35/VIOT.viot rename to tests/data/acpi/x86/q35/VIOT.viot diff --git a/tests/data/acpi/q35/WAET b/tests/data/acpi/x86/q35/WAET similarity index 100% rename from tests/data/acpi/q35/WAET rename to tests/data/acpi/x86/q35/WAET From patchwork Wed Jul 3 22:49:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723038 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B0BCC2BD09 for ; Wed, 3 Jul 2024 22:52:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8nK-0007Hz-Vk; Wed, 03 Jul 2024 18:49:48 -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 1sP8nH-0006qU-Sm for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:43 -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 1sP8nE-00079E-9C for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046978; 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=MwYyD/KUkbkxSb1TRAT8zXkqiqU7/n4SuhkILToxS/w=; b=bvVTQ4X9pOFfMm5kv6Y2KDsTKbCWcwqwIbqa8B6MGr94fpLl1vSq5RWloFLrAZVx+rRhZF u19cbuQTxFEKPjfwJpjtBcAFQWbaGcVtiZVddayqaLd5nBHu2VDz/wYtM8JA7MpDb4EMDE +LNzP7dBpyvRWUkCKr7cma8mZrJRdXQ= 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-463-1lMVX2Z3OGevlAPlEd0Sug-1; Wed, 03 Jul 2024 18:49:36 -0400 X-MC-Unique: 1lMVX2Z3OGevlAPlEd0Sug-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-367879e8395so42989f8f.0 for ; Wed, 03 Jul 2024 15:49:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046975; x=1720651775; 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=MwYyD/KUkbkxSb1TRAT8zXkqiqU7/n4SuhkILToxS/w=; b=kJdp3SOwOp245+pFwMR39r0dE7YUViAIxggLXOAuvIMI8HaCSwcSTZ1HZn1u4pB9i+ pup/fbHLVRYJ7rsXzi0Cq6Ai94kO3udy+mCfUvDiQIk8qH1wTZfhbGmrPVbsLxJcN8A/ dAArKix+E0yALXrUwMVHR5tfqKjhcirWdyu+Vw28OinBc6XDAIrf9VOskuNSNucwjcJW NTgRDkBbU5FNkQEadwq6QGepY0BJ36VqgM1RAGy1kpDbPGT6uinWy0OPEZf8hxiXX1Wk f8LXUeEDZEDoJxY1zPjIKib/XfvOC96NrOa7xnc4aJspa3/KeB/8o/HnkZQMu6bLwpL9 Fv+g== X-Gm-Message-State: AOJu0YwGWU3pk7SHVDU7veZswotKgUmqOqqhQjQTmyMmFAccoV7uOQ3X oyCY2D+YOP+A8f/w8UOJ1XDO0h47iPlsoeOV9WfIqhfmBrvzmc+++PeknneU/XMf0hLKbYRRqzc u2Y/nzLK6G6Oy3ViUtRh8YtE0AyVOvrtfcS2w5QazCKW7X5LZ7Ch+S6sHeCKbRVeHE0wjZR8wld XCKPEnnqHeGDhIABe8XIjmnzRdL9Z/gQ== X-Received: by 2002:adf:f1c8:0:b0:367:97bb:4de8 with SMTP id ffacd0b85a97d-3679dd6f714mr3756f8f.68.1720046975087; Wed, 03 Jul 2024 15:49:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEmKULTlon2WThAEFspQoRH9KSD9SBx7wRJH557Zlt0Txb+vnty6SP74uYel0LyBLpiyTABw== X-Received: by 2002:adf:f1c8:0:b0:367:97bb:4de8 with SMTP id ffacd0b85a97d-3679dd6f714mr3740f8f.68.1720046974521; Wed, 03 Jul 2024 15:49:34 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367900fd1e5sm3519520f8f.63.2024.07.03.15.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:49:33 -0700 (PDT) Date: Wed, 3 Jul 2024 18:49:31 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Igor Mammedov Subject: [PULL v3 68/85] tests/data/acpi/virt: Move ARM64 ACPI tables under aarch64/${machine} path Message-ID: <7434f904673c36b78871a3b18ab1f5c09c640131.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Sunil V L Same machine name can be used by different architectures. Hence, create aarch64 folder and move all aarch64 related AML files for virt machine inside. Signed-off-by: Sunil V L Reviewed-by: Igor Mammedov Message-Id: <20240625150839.1358279-11-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/data/acpi/{ => aarch64}/virt/APIC | Bin .../data/acpi/{ => aarch64}/virt/APIC.acpihmatvirt | Bin tests/data/acpi/{ => aarch64}/virt/APIC.topology | Bin tests/data/acpi/{ => aarch64}/virt/DBG2 | Bin tests/data/acpi/{ => aarch64}/virt/DSDT | Bin .../data/acpi/{ => aarch64}/virt/DSDT.acpihmatvirt | Bin tests/data/acpi/{ => aarch64}/virt/DSDT.memhp | Bin tests/data/acpi/{ => aarch64}/virt/DSDT.pxb | Bin tests/data/acpi/{ => aarch64}/virt/DSDT.topology | Bin tests/data/acpi/{ => aarch64}/virt/FACP | Bin tests/data/acpi/{ => aarch64}/virt/GTDT | Bin .../data/acpi/{ => aarch64}/virt/HMAT.acpihmatvirt | Bin tests/data/acpi/{ => aarch64}/virt/IORT | Bin tests/data/acpi/{ => aarch64}/virt/MCFG | Bin tests/data/acpi/{ => aarch64}/virt/NFIT.memhp | Bin tests/data/acpi/{ => aarch64}/virt/PPTT | Bin .../data/acpi/{ => aarch64}/virt/PPTT.acpihmatvirt | Bin tests/data/acpi/{ => aarch64}/virt/PPTT.topology | Bin tests/data/acpi/{ => aarch64}/virt/SLIT.memhp | Bin tests/data/acpi/{ => aarch64}/virt/SPCR | Bin .../data/acpi/{ => aarch64}/virt/SRAT.acpihmatvirt | Bin tests/data/acpi/{ => aarch64}/virt/SRAT.memhp | Bin tests/data/acpi/{ => aarch64}/virt/SRAT.numamem | Bin tests/data/acpi/{ => aarch64}/virt/SSDT.memhp | Bin tests/data/acpi/{ => aarch64}/virt/VIOT | Bin 25 files changed, 0 insertions(+), 0 deletions(-) rename tests/data/acpi/{ => aarch64}/virt/APIC (100%) rename tests/data/acpi/{ => aarch64}/virt/APIC.acpihmatvirt (100%) rename tests/data/acpi/{ => aarch64}/virt/APIC.topology (100%) rename tests/data/acpi/{ => aarch64}/virt/DBG2 (100%) rename tests/data/acpi/{ => aarch64}/virt/DSDT (100%) rename tests/data/acpi/{ => aarch64}/virt/DSDT.acpihmatvirt (100%) rename tests/data/acpi/{ => aarch64}/virt/DSDT.memhp (100%) rename tests/data/acpi/{ => aarch64}/virt/DSDT.pxb (100%) rename tests/data/acpi/{ => aarch64}/virt/DSDT.topology (100%) rename tests/data/acpi/{ => aarch64}/virt/FACP (100%) rename tests/data/acpi/{ => aarch64}/virt/GTDT (100%) rename tests/data/acpi/{ => aarch64}/virt/HMAT.acpihmatvirt (100%) rename tests/data/acpi/{ => aarch64}/virt/IORT (100%) rename tests/data/acpi/{ => aarch64}/virt/MCFG (100%) rename tests/data/acpi/{ => aarch64}/virt/NFIT.memhp (100%) rename tests/data/acpi/{ => aarch64}/virt/PPTT (100%) rename tests/data/acpi/{ => aarch64}/virt/PPTT.acpihmatvirt (100%) rename tests/data/acpi/{ => aarch64}/virt/PPTT.topology (100%) rename tests/data/acpi/{ => aarch64}/virt/SLIT.memhp (100%) rename tests/data/acpi/{ => aarch64}/virt/SPCR (100%) rename tests/data/acpi/{ => aarch64}/virt/SRAT.acpihmatvirt (100%) rename tests/data/acpi/{ => aarch64}/virt/SRAT.memhp (100%) rename tests/data/acpi/{ => aarch64}/virt/SRAT.numamem (100%) rename tests/data/acpi/{ => aarch64}/virt/SSDT.memhp (100%) rename tests/data/acpi/{ => aarch64}/virt/VIOT (100%) diff --git a/tests/data/acpi/virt/APIC b/tests/data/acpi/aarch64/virt/APIC similarity index 100% rename from tests/data/acpi/virt/APIC rename to tests/data/acpi/aarch64/virt/APIC diff --git a/tests/data/acpi/virt/APIC.acpihmatvirt b/tests/data/acpi/aarch64/virt/APIC.acpihmatvirt similarity index 100% rename from tests/data/acpi/virt/APIC.acpihmatvirt rename to tests/data/acpi/aarch64/virt/APIC.acpihmatvirt diff --git a/tests/data/acpi/virt/APIC.topology b/tests/data/acpi/aarch64/virt/APIC.topology similarity index 100% rename from tests/data/acpi/virt/APIC.topology rename to tests/data/acpi/aarch64/virt/APIC.topology diff --git a/tests/data/acpi/virt/DBG2 b/tests/data/acpi/aarch64/virt/DBG2 similarity index 100% rename from tests/data/acpi/virt/DBG2 rename to tests/data/acpi/aarch64/virt/DBG2 diff --git a/tests/data/acpi/virt/DSDT b/tests/data/acpi/aarch64/virt/DSDT similarity index 100% rename from tests/data/acpi/virt/DSDT rename to tests/data/acpi/aarch64/virt/DSDT diff --git a/tests/data/acpi/virt/DSDT.acpihmatvirt b/tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt similarity index 100% rename from tests/data/acpi/virt/DSDT.acpihmatvirt rename to tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt diff --git a/tests/data/acpi/virt/DSDT.memhp b/tests/data/acpi/aarch64/virt/DSDT.memhp similarity index 100% rename from tests/data/acpi/virt/DSDT.memhp rename to tests/data/acpi/aarch64/virt/DSDT.memhp diff --git a/tests/data/acpi/virt/DSDT.pxb b/tests/data/acpi/aarch64/virt/DSDT.pxb similarity index 100% rename from tests/data/acpi/virt/DSDT.pxb rename to tests/data/acpi/aarch64/virt/DSDT.pxb diff --git a/tests/data/acpi/virt/DSDT.topology b/tests/data/acpi/aarch64/virt/DSDT.topology similarity index 100% rename from tests/data/acpi/virt/DSDT.topology rename to tests/data/acpi/aarch64/virt/DSDT.topology diff --git a/tests/data/acpi/virt/FACP b/tests/data/acpi/aarch64/virt/FACP similarity index 100% rename from tests/data/acpi/virt/FACP rename to tests/data/acpi/aarch64/virt/FACP diff --git a/tests/data/acpi/virt/GTDT b/tests/data/acpi/aarch64/virt/GTDT similarity index 100% rename from tests/data/acpi/virt/GTDT rename to tests/data/acpi/aarch64/virt/GTDT diff --git a/tests/data/acpi/virt/HMAT.acpihmatvirt b/tests/data/acpi/aarch64/virt/HMAT.acpihmatvirt similarity index 100% rename from tests/data/acpi/virt/HMAT.acpihmatvirt rename to tests/data/acpi/aarch64/virt/HMAT.acpihmatvirt diff --git a/tests/data/acpi/virt/IORT b/tests/data/acpi/aarch64/virt/IORT similarity index 100% rename from tests/data/acpi/virt/IORT rename to tests/data/acpi/aarch64/virt/IORT diff --git a/tests/data/acpi/virt/MCFG b/tests/data/acpi/aarch64/virt/MCFG similarity index 100% rename from tests/data/acpi/virt/MCFG rename to tests/data/acpi/aarch64/virt/MCFG diff --git a/tests/data/acpi/virt/NFIT.memhp b/tests/data/acpi/aarch64/virt/NFIT.memhp similarity index 100% rename from tests/data/acpi/virt/NFIT.memhp rename to tests/data/acpi/aarch64/virt/NFIT.memhp diff --git a/tests/data/acpi/virt/PPTT b/tests/data/acpi/aarch64/virt/PPTT similarity index 100% rename from tests/data/acpi/virt/PPTT rename to tests/data/acpi/aarch64/virt/PPTT diff --git a/tests/data/acpi/virt/PPTT.acpihmatvirt b/tests/data/acpi/aarch64/virt/PPTT.acpihmatvirt similarity index 100% rename from tests/data/acpi/virt/PPTT.acpihmatvirt rename to tests/data/acpi/aarch64/virt/PPTT.acpihmatvirt diff --git a/tests/data/acpi/virt/PPTT.topology b/tests/data/acpi/aarch64/virt/PPTT.topology similarity index 100% rename from tests/data/acpi/virt/PPTT.topology rename to tests/data/acpi/aarch64/virt/PPTT.topology diff --git a/tests/data/acpi/virt/SLIT.memhp b/tests/data/acpi/aarch64/virt/SLIT.memhp similarity index 100% rename from tests/data/acpi/virt/SLIT.memhp rename to tests/data/acpi/aarch64/virt/SLIT.memhp diff --git a/tests/data/acpi/virt/SPCR b/tests/data/acpi/aarch64/virt/SPCR similarity index 100% rename from tests/data/acpi/virt/SPCR rename to tests/data/acpi/aarch64/virt/SPCR diff --git a/tests/data/acpi/virt/SRAT.acpihmatvirt b/tests/data/acpi/aarch64/virt/SRAT.acpihmatvirt similarity index 100% rename from tests/data/acpi/virt/SRAT.acpihmatvirt rename to tests/data/acpi/aarch64/virt/SRAT.acpihmatvirt diff --git a/tests/data/acpi/virt/SRAT.memhp b/tests/data/acpi/aarch64/virt/SRAT.memhp similarity index 100% rename from tests/data/acpi/virt/SRAT.memhp rename to tests/data/acpi/aarch64/virt/SRAT.memhp diff --git a/tests/data/acpi/virt/SRAT.numamem b/tests/data/acpi/aarch64/virt/SRAT.numamem similarity index 100% rename from tests/data/acpi/virt/SRAT.numamem rename to tests/data/acpi/aarch64/virt/SRAT.numamem diff --git a/tests/data/acpi/virt/SSDT.memhp b/tests/data/acpi/aarch64/virt/SSDT.memhp similarity index 100% rename from tests/data/acpi/virt/SSDT.memhp rename to tests/data/acpi/aarch64/virt/SSDT.memhp diff --git a/tests/data/acpi/virt/VIOT b/tests/data/acpi/aarch64/virt/VIOT similarity index 100% rename from tests/data/acpi/virt/VIOT rename to tests/data/acpi/aarch64/virt/VIOT From patchwork Wed Jul 3 22:56:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF3D3C2BD09 for ; Wed, 3 Jul 2024 22:57:09 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8uA-000419-1T; Wed, 03 Jul 2024 18:56:50 -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 1sP8u7-0003zq-FP for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:56: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 1sP8u5-0001fI-Vv for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:56:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720047403; 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=1oVRcGRoVnZxLtAHt3a+cAY1LWRp/f7zSpgrYQ7D4JQ=; b=SMFSyLHtTdXOtCEuljm5bbmragCyaW9gZ5EmaIi85/hxfaatQu7oRd1dLbwtOk00fOnzR4 HYsU/qHnQUaa48VJEsrT7AhHDEkTyNKEI2iE9FWL1UPKffvGpYZhkUiIQM9jN+SZ12wC19 WiY/aTEfpZqqe/csF+NbdbWcQNN23+E= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-511-ntHMIserPt6nrlzEMP_xRg-1; Wed, 03 Jul 2024 18:56:41 -0400 X-MC-Unique: ntHMIserPt6nrlzEMP_xRg-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-58c537ae6c9so2521a12.2 for ; Wed, 03 Jul 2024 15:56:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720047400; x=1720652200; 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=1oVRcGRoVnZxLtAHt3a+cAY1LWRp/f7zSpgrYQ7D4JQ=; b=PyYE2ieJ0QSQIXjtq12pMZYf5QGgwNWktmzKzQphH24jPPL1C/egACb6n902J2dFIb +jQxPnkZ/xmEuYBV5G73qLzWIhuMLUyQJw0pEWofm4/80zv2aZydwPpqqbohQz1oCZrV 05UWQPRZuykB+MybusKtngOQTQQ73PfDhy6oTzicSGkKpDqJSfnFIafkwWdk/csSAUs5 /60E7hqTOp+PiZhBZEJr/mZxACw9E1lXlWE7J64L1SaD6R4W5v/EUhm9rg4zNTUMNzHp 0sw6mV0hQ5VssW8HMJWqw9biFZxQppY0rDeEGZtUGlMgSum94rwuNhmiS1JG35y2yt/k Bd9w== X-Gm-Message-State: AOJu0YxIZSM4gApQ0F6lvsFr9Ocr5VU6irZVp8d7badlMlTOnLyW/yyK slu4xk+ydVRhZSkSVBeDRvvTbgVLvFC7KY75mmLIjzTMYVguoP04wbDgqOPm8xwkSgHZrxmor/Y X1e8R8iK9Vq18trP5VbjRLoaP3ePAxWYJcPpAYwudXph66IyCgOgoZzVp8TNkZzt2+xCC8wVCFQ WuigkA3NS7rdSKJtOvuIB21IHsoArXSA== X-Received: by 2002:a05:6402:1e8b:b0:57c:78fb:1a32 with SMTP id 4fb4d7f45d1cf-5879f9849a9mr9898923a12.19.1720047399704; Wed, 03 Jul 2024 15:56:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEuphDOjpkxQrmECF0kal6y5Q9p5QSAbT+KR4MktLQlWDRykJn/y7802L78UWRH8cXC7jYEwQ== X-Received: by 2002:a05:6402:1e8b:b0:57c:78fb:1a32 with SMTP id 4fb4d7f45d1cf-5879f9849a9mr9898903a12.19.1720047398893; Wed, 03 Jul 2024 15:56:38 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58c9061becfsm1717241a12.83.2024.07.03.15.56.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:56:38 -0700 (PDT) Date: Wed, 3 Jul 2024 18:56:33 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Alistair Francis , Igor Mammedov , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , Daniel =?utf-8?b?UC4gQmVycmFuZ8Op?= , Thomas Huth , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= Subject: [PULL v3 69/85] meson.build: Add RISC-V to the edk2-target list Message-ID: <008115bba06a30b13b3fd86cade8a280490e06f3.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Sunil V L so that ACPI table test can be supported. Signed-off-by: Sunil V L Reviewed-by: Alistair Francis Reviewed-by: Igor Mammedov Message-Id: <20240625150839.1358279-12-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 54e6b09f4f..efd3d4c6e5 100644 --- a/meson.build +++ b/meson.build @@ -93,7 +93,7 @@ else iasl = find_program(get_option('iasl'), required: true) endif -edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu' ] +edk2_targets = [ 'arm-softmmu', 'aarch64-softmmu', 'i386-softmmu', 'x86_64-softmmu', 'riscv64-softmmu' ] unpack_edk2_blobs = false foreach target : edk2_targets if target in target_dirs From patchwork Wed Jul 3 22:49:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723006 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2CD59C31D97 for ; Wed, 3 Jul 2024 22:51:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8nP-0007m1-Mw; Wed, 03 Jul 2024 18:49: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 1sP8nN-0007Wp-AB for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49: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 1sP8nL-0007AR-GL for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046986; 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=f1BCTKIu7zTn8KYIwKYaAlAh7ZMPZO9ZVLyIB5EQHjk=; b=eMJ+VCrAISPwhMOrSLFgZlhElbArLj5m3mg08RbFyIxlv6Ghhxr3hFJ+i98o7Hbj1arYVi Z+XAnFmGVyWepbivn9XxC7V9L31Utvb83SJpThTwigYwJ/jN0sr3fTNRS0siphIMY+6YsJ 2HsP0a5M3Tf4igy2/qD1tes/E64FOFw= 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-675-RO3i55C9M2-6SWBJKPn4UQ-1; Wed, 03 Jul 2024 18:49:45 -0400 X-MC-Unique: RO3i55C9M2-6SWBJKPn4UQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4257f95fe85so21265e9.1 for ; Wed, 03 Jul 2024 15:49:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046984; x=1720651784; 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=f1BCTKIu7zTn8KYIwKYaAlAh7ZMPZO9ZVLyIB5EQHjk=; b=hOOtSvQyNM71xon4Le+3h96SoP4oU+ewAeFihoZXjKlDfHJGNAyXe2OIGh/1ig/Kzz QVu0VRMFSdeKn4+mqEyKcKx31JK9RIGilj0JJxGmlZ9vDAFOeeBtXXxUBBf/o0nKPB89 rY37jn9opS2k4UeMwIvaYiXbPWjV0rsXGYRP3mAep/seiSMWIkc7IyDwKjeV9Xc34s7f YnHUDhZ8YkVwJzDbVioY6JTMPo/vJcByHnN6w6TbYZn22Z3rQuLazVdC6TV0iB2vQ7PJ KkzyZt+PyRaDfPOsqSKi4U8GMxKggGDqaZ7vpT2v1IQzXvth1s5w1g7u3NSFVlBvvpm1 xq6g== X-Gm-Message-State: AOJu0YwNg7PidZpaUhv1ApJhOwuTNHj+Z4rnLjrRYfoqvv7BCUsptTAE dj29yCEg0mMEhqCToqq74atVF5NR5MRCd2rnIWsD1TZTSoOSeSJKKvfI7F1/P55IwylTIEDLQv6 cb+pTywMN/zFDLnCMcsd0kLJXKypzHmrDl3Y6tAest8kDxIdviqL07cFPC5D9CbvxPc+m8oobmT nswDZBrO8psfHgILi6PbzReA/70YnJAQ== X-Received: by 2002:a7b:c84c:0:b0:426:47f5:66ef with SMTP id 5b1f17b1804b1-4264a48cea4mr216405e9.40.1720046984002; Wed, 03 Jul 2024 15:49:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdhuLVsoiWVx8mB7byFmr85tdMU3KTuTy3lsurMZLVFjYMNZl2q+tsxaxcaNZWLQzQrxjJDQ== X-Received: by 2002:a7b:c84c:0:b0:426:47f5:66ef with SMTP id 5b1f17b1804b1-4264a48cea4mr216275e9.40.1720046983516; Wed, 03 Jul 2024 15:49:43 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1f2375sm1215675e9.27.2024.07.03.15.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:49:41 -0700 (PDT) Date: Wed, 3 Jul 2024 18:49:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Alistair Francis , Igor Mammedov , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PULL v3 70/85] pc-bios/meson.build: Add support for RISC-V in unpack_edk2_blobs 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Sunil V L Update list of images supported in unpack_edk2_blobs to enable RISC-V ACPI table testing. Signed-off-by: Sunil V L Reviewed-by: Alistair Francis Reviewed-by: Igor Mammedov Message-Id: <20240625150839.1358279-13-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- pc-bios/meson.build | 2 ++ tests/qtest/meson.build | 3 +++ 2 files changed, 5 insertions(+) diff --git a/pc-bios/meson.build b/pc-bios/meson.build index 0760612bea..8602b45b9b 100644 --- a/pc-bios/meson.build +++ b/pc-bios/meson.build @@ -4,6 +4,8 @@ if unpack_edk2_blobs 'edk2-aarch64-code.fd', 'edk2-arm-code.fd', 'edk2-arm-vars.fd', + 'edk2-riscv-code.fd', + 'edk2-riscv-vars.fd', 'edk2-i386-code.fd', 'edk2-i386-secure-code.fd', 'edk2-i386-vars.fd', diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 12792948ff..6508bfb1a2 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -259,6 +259,9 @@ qtests_s390x = \ qtests_riscv32 = \ (config_all_devices.has_key('CONFIG_SIFIVE_E_AON') ? ['sifive-e-aon-watchdog-test'] : []) +qtests_riscv64 = \ + (unpack_edk2_blobs ? ['bios-tables-test'] : []) + qos_test_ss = ss.source_set() qos_test_ss.add( 'ac97-test.c', From patchwork Wed Jul 3 22:49:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723044 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00C64C3271E for ; Wed, 3 Jul 2024 22:53:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8nU-0008RG-Bu; Wed, 03 Jul 2024 18:49:56 -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 1sP8nS-000848-4U for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:54 -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 1sP8nQ-0007B7-Dd for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046991; 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=Dp+XdzPzdo45On8QxmeO3KbH8ukLhYQRI6dbRMmEeEA=; b=WgLq6QlIeamBYY8ZSudbE0T6nMRJFEl6Dl/17l1lTZe1AFsegEtrFVyhm7En6ka9TJmkDe KtAbfx1fd9fSuF1XvltNn05OY7if4PHCDRV/DIDft57OEon1o1XjnGBZWYR+5Mdklv4xpm N5CZMBz8jA6y4AI8PWDPY9A2h3V3YLU= 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-573-mQA2QOvIPTyiyCkbFsE4kg-1; Wed, 03 Jul 2024 18:49:50 -0400 X-MC-Unique: mQA2QOvIPTyiyCkbFsE4kg-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-36796a0687bso41640f8f.2 for ; Wed, 03 Jul 2024 15:49:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046989; x=1720651789; 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=Dp+XdzPzdo45On8QxmeO3KbH8ukLhYQRI6dbRMmEeEA=; b=g7zBafCAjBvlYnRYoQxYUo2paHLXW3Xw+Oy4cfeLqEooC4yB9NFTnqZ3ZjdMFdc9kC Da9zqjCrHwNYEw29KLSDi2nAyJVtXnZ04xsS7eLkLOF3SpFNgID252cGFvWqy+p8BV9u 2rAvmH0R1JG/tbOl0rSxCH0QiozT60IaOGrfkGccWAvLgwZS2JQv7NU5tYXwPCiU7lml SifRKb1mcM5MDWu99vm/dEghDni0rTeYceF1FmTlsjqmZ9w/raTrp0v93n1fygr6W0rQ VIaM5ieIFkePPPNtzfafmEKf9dg+xhK7TqSyKCwPJQQyuvEfrwewMechGnLEB0Bek+8o 9P8Q== X-Gm-Message-State: AOJu0YzG1yD+QOl937xZWdU9TWWIHMa2BAEkPbStjpdIa8vIXVpfCiko tKQqLVwETc+/V+i6QUTWWzvc1bfoMkPc/3BsgRU398TaM5kZLqrUW4l39ZqeGzXRR8SWeagYa4b s3tyZdt3WLCRMZF+YmIHs+GeBZwmB62m27gtNVfRcB1/PJI3hKz26c0gF3eiGsCcLA3E8oDoZSg cQ53It5OQxuKdczpwY3aGZCEXNpD0QVw== X-Received: by 2002:a05:600c:2d44:b0:425:5fe5:f273 with SMTP id 5b1f17b1804b1-4264a443e54mr262075e9.26.1720046988858; Wed, 03 Jul 2024 15:49:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHy0AEjGll0NdaFcLsXu/dJZs2t9ZR5+kuPZTJLug7ifo6pHl95fprhPkFzrUgQSU89DDgmKw== X-Received: by 2002:a05:600c:2d44:b0:425:5fe5:f273 with SMTP id 5b1f17b1804b1-4264a443e54mr261905e9.26.1720046988280; Wed, 03 Jul 2024 15:49:48 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1d5100sm1239325e9.4.2024.07.03.15.49.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:49:47 -0700 (PDT) Date: Wed, 3 Jul 2024 18:49:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Sunil V L , Alistair Francis , Igor Mammedov , Ani Sinha Subject: [PULL v3 71/85] tests/data/acpi/rebuild-expected-aml.sh: Add RISC-V Message-ID: <0f130d9e372552ef900bfac062ffc6a77b4049cc.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Sunil V L Update the list of supported architectures to include RISC-V. Signed-off-by: Sunil V L Reviewed-by: Alistair Francis Reviewed-by: Igor Mammedov Message-Id: <20240625150839.1358279-14-sunilvl@ventanamicro.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/data/acpi/rebuild-expected-aml.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/data/acpi/rebuild-expected-aml.sh b/tests/data/acpi/rebuild-expected-aml.sh index dcf2e2f221..c1092fb8ba 100755 --- a/tests/data/acpi/rebuild-expected-aml.sh +++ b/tests/data/acpi/rebuild-expected-aml.sh @@ -12,7 +12,7 @@ # This work is licensed under the terms of the GNU GPLv2. # See the COPYING.LIB file in the top-level directory. -qemu_arches="x86_64 aarch64" +qemu_arches="x86_64 aarch64 riscv64" if [ ! -e "tests/qtest/bios-tables-test" ]; then echo "Test: bios-tables-test is required! Run make check before this script." @@ -36,7 +36,8 @@ fi if [ -z "$qemu_bins" ]; then echo "Only the following architectures are currently supported: $qemu_arches" echo "None of these configured!" - echo "To fix, run configure --target-list=x86_64-softmmu,aarch64-softmmu" + echo "To fix, run configure \ + --target-list=x86_64-softmmu,aarch64-softmmu,riscv64-softmmu" exit 1; fi From patchwork Wed Jul 3 22:49:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723041 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B49A9C2BD09 for ; Wed, 3 Jul 2024 22:53:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8nZ-00011I-10; Wed, 03 Jul 2024 18:50:01 -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 1sP8nX-0000ap-4M for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:59 -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 1sP8nU-0007Bj-KE for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:49:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720046996; 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=Q9nP82XxVIGsGRwJDQ3jJpLzlD/V4rH3MYQjc7zH+sg=; b=As3DU3TFfHnRfPTrKFOuwhd3jxqLXzZQGvHw0oFn6w2EaSaap5pSTJr9/KG6KVv3ZH617H gRwOYwvnQAgHoK2meuGH+1hiXpmN3hf18Ul/3s6q3pjrruzJMKuOUYgXlqqATqVLV5IDLG PrdTzbPRCyxNGm3anpUEe+P5I8KSZBA= 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-526-xWGoHoW4M4aUKyNRuN2fsw-1; Wed, 03 Jul 2024 18:49:54 -0400 X-MC-Unique: xWGoHoW4M4aUKyNRuN2fsw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4256849a9f4so965e9.3 for ; Wed, 03 Jul 2024 15:49:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046993; x=1720651793; 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=Q9nP82XxVIGsGRwJDQ3jJpLzlD/V4rH3MYQjc7zH+sg=; b=CWolMwfjx6ux0DiBOpbkM+i/KduzQOrbZNvWmIYsXREMEdL70jiJqoIZok+n1jzU/b /ZhyqZ1R0Ma2/FHDvb06UB18/Vmvp8s6Ka1gX8yrgmmdHedImx1cBWXKQ5mnVTeVYZ/7 gC+HcVr6Ug4IslvymBpnYvJId0qJdUl5RYf8eU7yaMaoOMyQJGo7KIOrAkIb9ulLVSju 6Wc2K72IZRLseXlwvLCSgjGGR26iW/OzdEQJ9wdG148hd5g0pNxAZq27JftLsR24bpd2 HCl/Mnh+FkM5YXQNtErOb84/4pnlyFbk7NUeciz3kpTUucUVZm/ILssUDh4+Otlh0M1b 7Arw== X-Gm-Message-State: AOJu0YwWCiA7Q7tD0d2iydQk0VxZIgRgg+Zu/DWdWmLJ0kqMobyVepsT HytXwMFnJ33JoD28wlr9AAq6uaPw887G3ZDjvVaG59S+Eh4VDXE8GWq42jw0jUpvB/qwm3W/J7A I+t5QDSHEfOtpbwxwRFc2kq2cgXUVOuo+pRVLUaVaCE57yyu6LFiLzZ561eYGyMK2sjh6JAuSgv XVgU4+0SFCgNNX5q5iZKMKTCTdrnE02A== X-Received: by 2002:a05:600c:4186:b0:425:7c99:eb59 with SMTP id 5b1f17b1804b1-4264a4691e9mr280885e9.33.1720046993257; Wed, 03 Jul 2024 15:49:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTDdCZgGlkZy3KakJjfhD8geH13pphOvEbUy3XMHmbRT/bhtbjFIiVyBn3km0P9XK0tt6gXw== X-Received: by 2002:a05:600c:4186:b0:425:7c99:eb59 with SMTP id 5b1f17b1804b1-4264a4691e9mr280705e9.33.1720046992618; Wed, 03 Jul 2024 15:49:52 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a283551sm1137735e9.42.2024.07.03.15.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:49:51 -0700 (PDT) Date: Wed, 3 Jul 2024 18:49:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Markus Armbruster , Fan Ni , Eric Blake Subject: [PULL v3 72/85] hw/cxl/events: Improve QMP interfaces and documentation for add/release dynamic capacity. 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron New DCD command definitions updated in response to review comments from Markus. - Used CxlXXXX instead of CXLXXXXX for newly added types. - Expanded some abreviations in type names to be easier to read. - Additional documentation for some fields. - Replace slightly vague cxl r3.1 references with "Compute Express Link (CXL) Specification, Revision 3.1, XXXX" to bring them inline with what it says on the specification cover. Suggested-by: Markus Armbruster Signed-off-by: Jonathan Cameron Message-Id: <20240625170805.359278-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/cxl.json | 144 ++++++++++++++++++++++++--------------- hw/mem/cxl_type3.c | 18 ++--- hw/mem/cxl_type3_stubs.c | 8 +-- 3 files changed, 103 insertions(+), 67 deletions(-) diff --git a/qapi/cxl.json b/qapi/cxl.json index 57d9f82014..a38622a0d1 100644 --- a/qapi/cxl.json +++ b/qapi/cxl.json @@ -363,9 +363,11 @@ 'data': {'path': 'str', 'type': 'CxlCorErrorType'}} ## -# @CXLDynamicCapacityExtent: +# @CxlDynamicCapacityExtent: # -# A single dynamic capacity extent +# A single dynamic capacity extent. This is a contiguous allocation +# of memory by Device Physical Address within a single Dynamic +# Capacity Region on a CXL Type 3 Device. # # @offset: The offset (in bytes) to the start of the region # where the extent belongs to. @@ -374,7 +376,7 @@ # # Since: 9.1 ## -{ 'struct': 'CXLDynamicCapacityExtent', +{ 'struct': 'CxlDynamicCapacityExtent', 'data': { 'offset':'uint64', 'len': 'uint64' @@ -382,22 +384,40 @@ } ## -# @CXLExtSelPolicy: +# @CxlExtentSelectionPolicy: # # The policy to use for selecting which extents comprise the added -# capacity, as defined in cxl spec r3.1 Table 7-70. +# capacity, as defined in Compute Express Link (CXL) Specification, +# Revision 3.1, Table 7-70. # -# @free: 0h = Free +# @free: Device is responsible for allocating the requested memory +# capacity and is free to do this using any combination of +# supported extents. # -# @contiguous: 1h = Continuous +# @contiguous: Device is responsible for allocating the requested +# memory capacity but must do so as a single contiguous +# extent. # -# @prescriptive: 2h = Prescriptive +# @prescriptive: The precise set of extents to be allocated is +# specified by the command. Thus allocation is being managed +# by the issuer of the allocation command, not the device. # -# @enable-shared-access: 3h = Enable Shared Access +# @enable-shared-access: Capacity has already been allocated to a +# different host using free, contiguous or prescriptive policy +# with a known tag. This policy then instructs the device to +# make the capacity with the specified tag available to an +# additional host. Capacity is implicit as it matches that +# already associated with the tag. Note that the extent list +# (and hence Device Physical Addresses) used are per host, so +# a device may use different representations on each host. +# The ordering of the extents provided to each host is indicated +# to the host using per extent sequence numbers generated by +# the device. Has a similar meaning for temporal sharing, but +# in that case there may be only one host involved. # # Since: 9.1 ## -{ 'enum': 'CXLExtSelPolicy', +{ 'enum': 'CxlExtentSelectionPolicy', 'data': ['free', 'contiguous', 'prescriptive', @@ -407,54 +427,60 @@ ## # @cxl-add-dynamic-capacity: # -# Command to initiate to add dynamic capacity extents to a host. It -# simulates operations defined in cxl spec r3.1 7.6.7.6.5. +# Initiate adding dynamic capacity extents to a host. This simulates +# operations defined in Compute Express Link (CXL) Specification, +# Revision 3.1, Section 7.6.7.6.5. Note that, currently, establishing +# success or failure of the full Add Dynamic Capacity flow requires +# out of band communication with the OS of the CXL host. # -# @path: CXL DCD canonical QOM path. +# @path: path to the CXL Dynamic Capacity Device in the QOM tree. # -# @host-id: The "Host ID" field as defined in cxl spec r3.1 -# Table 7-70. +# @host-id: The "Host ID" field as defined in Compute Express Link +# (CXL) Specification, Revision 3.1, Table 7-70. # # @selection-policy: The "Selection Policy" bits as defined in -# cxl spec r3.1 Table 7-70. It specifies the policy to use for -# selecting which extents comprise the added capacity. +# Compute Express Link (CXL) Specification, Revision 3.1, +# Table 7-70. It specifies the policy to use for selecting +# which extents comprise the added capacity. # -# @region: The "Region Number" field as defined in cxl spec r3.1 -# Table 7-70. The dynamic capacity region where the capacity -# is being added. Valid range is from 0-7. +# @region: The "Region Number" field as defined in Compute Express +# Link (CXL) Specification, Revision 3.1, Table 7-70. Valid +# range is from 0-7. # -# @tag: The "Tag" field as defined in cxl spec r3.1 Table 7-70. +# @tag: The "Tag" field as defined in Compute Express Link (CXL) +# Specification, Revision 3.1, Table 7-70. # -# @extents: The "Extent List" field as defined in cxl spec r3.1 -# Table 7-70. +# @extents: The "Extent List" field as defined in Compute Express Link +# (CXL) Specification, Revision 3.1, Table 7-70. # # Since : 9.1 ## { 'command': 'cxl-add-dynamic-capacity', 'data': { 'path': 'str', 'host-id': 'uint16', - 'selection-policy': 'CXLExtSelPolicy', + 'selection-policy': 'CxlExtentSelectionPolicy', 'region': 'uint8', '*tag': 'str', - 'extents': [ 'CXLDynamicCapacityExtent' ] + 'extents': [ 'CxlDynamicCapacityExtent' ] } } ## -# @CXLExtRemovalPolicy: +# @CxlExtentRemovalPolicy: # # The policy to use for selecting which extents comprise the released -# capacity, defined in the "Flags" field in cxl spec r3.1 Table 7-71. +# capacity, defined in the "Flags" field in Compute Express Link (CXL) +# Specification, Revision 3.1, Table 7-71. # -# @tag-based: value = 0h. Extents are selected by the device based -# on tag, with no requirement for contiguous extents. +# @tag-based: Extents are selected by the device based on tag, with +# no requirement for contiguous extents. # -# @prescriptive: value = 1h. Extent list of capacity to release is -# included in the request payload. +# @prescriptive: Extent list of capacity to release is included in +# the request payload. # # Since: 9.1 ## -{ 'enum': 'CXLExtRemovalPolicy', +{ 'enum': 'CxlExtentRemovalPolicy', 'data': ['tag-based', 'prescriptive'] } @@ -462,45 +488,55 @@ ## # @cxl-release-dynamic-capacity: # -# Command to initiate to release dynamic capacity extents from a -# host. It simulates operations defined in cxl spec r3.1 7.6.7.6.6. +# Initiate release of dynamic capacity extents from a host. This +# simulates operations defined in Compute Express Link (CXL) +# Specification, Revision 3.1, Section 7.6.7.6.6. Note that, +# currently, success or failure of the full Release Dynamic Capacity +# flow requires out of band communication with the OS of the CXL host. # -# @path: CXL DCD canonical QOM path. +# @path: path to the CXL Dynamic Capacity Device in the QOM tree. # -# @host-id: The "Host ID" field as defined in cxl spec r3.1 +# @host-id: The "Host ID" field as defined in Compute Express Link +# (CXL) Specification, Revision 3.1, Table 7-71. +# +# @removal-policy: Bit[3:0] of the "Flags" field as defined in +# Compute Express Link (CXL) Specification, Revision 3.1, # Table 7-71. # -# @removal-policy: Bit[3:0] of the "Flags" field as defined in cxl -# spec r3.1 Table 7-71. +# @forced-removal: Bit[4] of the "Flags" field in Compute Express +# Link (CXL) Specification, Revision 3.1, Table 7-71. When set, +# the device does not wait for a Release Dynamic Capacity command +# from the host. Instead, the host immediately looses access to +# the released capacity. # -# @forced-removal: Bit[4] of the "Flags" field in cxl spec r3.1 -# Table 7-71. When set, device does not wait for a Release -# Dynamic Capacity command from the host. Host immediately -# loses access to released capacity. +# @sanitize-on-release: Bit[5] of the "Flags" field in Compute +# Express Link (CXL) Specification, Revision 3.1, Table 7-71. +# When set, the device should sanitize all released capacity as +# a result of this request. This ensures that all user data +# and metadata is made permanently unavailable by whatever +# means is appropriate for the media type. Note that changing +# encryption keys is not sufficient. # -# @sanitize-on-release: Bit[5] of the "Flags" field in cxl spec r3.1 -# Table 7-71. When set, device should sanitize all released -# capacity as a result of this request. +# @region: The "Region Number" field as defined in Compute Express +# Link Specification, Revision 3.1, Table 7-71. Valid range +# is from 0-7. # -# @region: The "Region Number" field as defined in cxl spec r3.1 -# Table 7-71. The dynamic capacity region where the capacity -# is being added. Valid range is from 0-7. +# @tag: The "Tag" field as defined in Compute Express Link (CXL) +# Specification, Revision 3.1, Table 7-71. # -# @tag: The "Tag" field as defined in cxl spec r3.1 Table 7-71. -# -# @extents: The "Extent List" field as defined in cxl spec r3.1 -# Table 7-71. +# @extents: The "Extent List" field as defined in Compute Express +# Link (CXL) Specification, Revision 3.1, Table 7-71. # # Since : 9.1 ## { 'command': 'cxl-release-dynamic-capacity', 'data': { 'path': 'str', 'host-id': 'uint16', - 'removal-policy': 'CXLExtRemovalPolicy', + 'removal-policy': 'CxlExtentRemovalPolicy', '*forced-removal': 'bool', '*sanitize-on-release': 'bool', 'region': 'uint8', '*tag': 'str', - 'extents': [ 'CXLDynamicCapacityExtent' ] + 'extents': [ 'CxlDynamicCapacityExtent' ] } } diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 3274e5dcbb..35ac59883a 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1874,7 +1874,7 @@ static bool cxl_extent_groups_overlaps_dpa_range(CXLDCExtentGroupList *list, */ static void qmp_cxl_process_dynamic_capacity_prescriptive(const char *path, uint16_t hid, CXLDCEventType type, uint8_t rid, - CXLDynamicCapacityExtentList *records, Error **errp) + CxlDynamicCapacityExtentList *records, Error **errp) { Object *obj; CXLEventDynamicCapacity dCap = {}; @@ -1882,7 +1882,7 @@ static void qmp_cxl_process_dynamic_capacity_prescriptive(const char *path, CXLType3Dev *dcd; uint8_t flags = 1 << CXL_EVENT_TYPE_INFO; uint32_t num_extents = 0; - CXLDynamicCapacityExtentList *list; + CxlDynamicCapacityExtentList *list; CXLDCExtentGroup *group = NULL; g_autofree CXLDCExtentRaw *extents = NULL; uint8_t enc_log = CXL_EVENT_TYPE_DYNAMIC_CAP; @@ -2032,13 +2032,13 @@ static void qmp_cxl_process_dynamic_capacity_prescriptive(const char *path, } void qmp_cxl_add_dynamic_capacity(const char *path, uint16_t host_id, - CXLExtSelPolicy sel_policy, uint8_t region, - const char *tag, - CXLDynamicCapacityExtentList *extents, + CxlExtentSelectionPolicy sel_policy, + uint8_t region, const char *tag, + CxlDynamicCapacityExtentList *extents, Error **errp) { switch (sel_policy) { - case CXL_EXT_SEL_POLICY_PRESCRIPTIVE: + case CXL_EXTENT_SELECTION_POLICY_PRESCRIPTIVE: qmp_cxl_process_dynamic_capacity_prescriptive(path, host_id, DC_EVENT_ADD_CAPACITY, region, extents, errp); @@ -2050,14 +2050,14 @@ void qmp_cxl_add_dynamic_capacity(const char *path, uint16_t host_id, } void qmp_cxl_release_dynamic_capacity(const char *path, uint16_t host_id, - CXLExtRemovalPolicy removal_policy, + CxlExtentRemovalPolicy removal_policy, bool has_forced_removal, bool forced_removal, bool has_sanitize_on_release, bool sanitize_on_release, uint8_t region, const char *tag, - CXLDynamicCapacityExtentList *extents, + CxlDynamicCapacityExtentList *extents, Error **errp) { CXLDCEventType type = DC_EVENT_RELEASE_CAPACITY; @@ -2070,7 +2070,7 @@ void qmp_cxl_release_dynamic_capacity(const char *path, uint16_t host_id, } switch (removal_policy) { - case CXL_EXT_REMOVAL_POLICY_PRESCRIPTIVE: + case CXL_EXTENT_REMOVAL_POLICY_PRESCRIPTIVE: qmp_cxl_process_dynamic_capacity_prescriptive(path, host_id, type, region, extents, errp); return; diff --git a/hw/mem/cxl_type3_stubs.c b/hw/mem/cxl_type3_stubs.c index 45419bbefe..c1a5e4a7c1 100644 --- a/hw/mem/cxl_type3_stubs.c +++ b/hw/mem/cxl_type3_stubs.c @@ -70,24 +70,24 @@ void qmp_cxl_inject_correctable_error(const char *path, CxlCorErrorType type, void qmp_cxl_add_dynamic_capacity(const char *path, uint16_t host_id, - CXLExtSelPolicy sel_policy, + CxlExtentSelectionPolicy sel_policy, uint8_t region, const char *tag, - CXLDynamicCapacityExtentList *extents, + CxlDynamicCapacityExtentList *extents, Error **errp) { error_setg(errp, "CXL Type 3 support is not compiled in"); } void qmp_cxl_release_dynamic_capacity(const char *path, uint16_t host_id, - CXLExtRemovalPolicy removal_policy, + CxlExtentRemovalPolicy removal_policy, bool has_forced_removal, bool forced_removal, bool has_sanitize_on_release, bool sanitize_on_release, uint8_t region, const char *tag, - CXLDynamicCapacityExtentList *extents, + CxlDynamicCapacityExtentList *extents, Error **errp) { error_setg(errp, "CXL Type 3 support is not compiled in"); From patchwork Wed Jul 3 22:49:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723000 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DF3F6C41513 for ; Wed, 3 Jul 2024 22:50:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8nl-0002Jz-3r; Wed, 03 Jul 2024 18:50:13 -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 1sP8ne-0001zF-80 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50: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 1sP8nc-0007Db-6k for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720047003; 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=C8uBwo3DHXNNhuf3rApspBTWgLSO8s/xdDqrmh63AMQ=; b=IgElybKm+ZA8n06MVeZ562pAhUutTo5/fyGX+DZaQJ9RLMdCNHNpvekAHUKYMhu5ypn7z8 C+MRN4oqvWC3kDxvgsoW7NPOx0JjhPyIW9tFGO6UOnxRWzsvodmvA0Rc4YHk0DGol1kpnA ZPW64TTEEjXIGeSjyb5iVqbby/dtI/o= 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-615-HThBkHcJMpGbyxpfRUDUUw-1; Wed, 03 Jul 2024 18:49:59 -0400 X-MC-Unique: HThBkHcJMpGbyxpfRUDUUw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4257a75193aso41575e9.1 for ; Wed, 03 Jul 2024 15:49:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720046997; x=1720651797; 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=C8uBwo3DHXNNhuf3rApspBTWgLSO8s/xdDqrmh63AMQ=; b=sRwNVMkHy9UamGPbB6ajaf3LD58XUDVgaiQutJRiNueCdv1YuyrMBrG+XbnNShrE9F swxeB4A5rh3v2MK7ruJkHFHU5l2ts72hOm1zzIGH5KScoY1eVfE/6+hbb4b0zVGvBLkD G0TYcHAlWvX2nzzSAPDu1WmagIFGYQQ32rZTSxpBf4ygSTQcewO3Cy24y13EzbdKIEaM qR3i+rGDhAQo1mk5btiLZE7uDxtYB6doTrIAnkcMiGjKQEmU3ou5UalSrcYCuAEz2Wsz /W9FIN5iu0qUKEjGcXtd0vi02XeYO7mwmH9ORSBc23o17fTRYHRC6/76RoYms6VHeYKl lMIw== X-Gm-Message-State: AOJu0YwLu665DZXaRllvuciPGiiUM1uZ6XETFYKxUUsUy2E924EeHDCk JCxcu7zP/55LS+eYIt6MLdEvD4wP1fos3/E0MNMvn9ygBxvmOEnsC8J2MaSx59MrmDh5EU/uK7D 2ZQQuEa63ZIOk7iN3I90DFaquE1GqCwnL4N1F4VSuu8X3/TF9M10KG9xoE+mAlh97jdVXA3faEo gO0afo2yqsAQmxWQOl+IRrUv46gegaZg== X-Received: by 2002:a05:600c:63ce:b0:424:aa83:ef01 with SMTP id 5b1f17b1804b1-4264a3d1e2emr354315e9.10.1720046997383; Wed, 03 Jul 2024 15:49:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGxeHLkFA9vFSVUs2nluB7hT2NCNMOHVvzFKql/6T+8kYJJHYwOs5zGw3Vabv0YclKur8iCbw== X-Received: by 2002:a05:600c:63ce:b0:424:aa83:ef01 with SMTP id 5b1f17b1804b1-4264a3d1e2emr354135e9.10.1720046996637; Wed, 03 Jul 2024 15:49:56 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1d1668sm1261255e9.1.2024.07.03.15.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:49:56 -0700 (PDT) Date: Wed, 3 Jul 2024 18:49:52 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Markus Armbruster , Fan Ni , Eric Blake Subject: [PULL v3 73/85] hw/cxl/events: Mark cxl-add-dynamic-capacity and cxl-release-dynamic-capcity unstable Message-ID: <5e3cd0a2f526c2e52dd513ee6b4385f1fb47a19e.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Jonathan Cameron Markus suggested that we make the unstable. I don't expect these interfaces to change because of their tight coupling to the Compute Express Link (CXL) Specification, Revision 3.1 Fabric Management API definitions which can only be extended in backwards compatible way. However, there seems little disadvantage in taking a cautious path for now and marking them as unstable interfaces. Suggested-by: Markus Armbruster Signed-off-by: Jonathan Cameron Message-Id: <20240625170805.359278-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- qapi/cxl.json | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/qapi/cxl.json b/qapi/cxl.json index a38622a0d1..bdfac67c47 100644 --- a/qapi/cxl.json +++ b/qapi/cxl.json @@ -453,6 +453,10 @@ # @extents: The "Extent List" field as defined in Compute Express Link # (CXL) Specification, Revision 3.1, Table 7-70. # +# Features: +# +# @unstable: For now this command is subject to change. +# # Since : 9.1 ## { 'command': 'cxl-add-dynamic-capacity', @@ -462,7 +466,8 @@ 'region': 'uint8', '*tag': 'str', 'extents': [ 'CxlDynamicCapacityExtent' ] - } + }, + 'features': [ 'unstable' ] } ## @@ -527,6 +532,10 @@ # @extents: The "Extent List" field as defined in Compute Express # Link (CXL) Specification, Revision 3.1, Table 7-71. # +# Features: +# +# @unstable: For now this command is subject to change. +# # Since : 9.1 ## { 'command': 'cxl-release-dynamic-capacity', @@ -538,5 +547,6 @@ 'region': 'uint8', '*tag': 'str', 'extents': [ 'CxlDynamicCapacityExtent' ] - } + }, + 'features': [ 'unstable' ] } From patchwork Wed Jul 3 22:49:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723040 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18882C2BD09 for ; Wed, 3 Jul 2024 22:52:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8nn-0002kl-Hl; Wed, 03 Jul 2024 18:50: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 1sP8nf-0002FF-Am for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50: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 1sP8nd-0007LH-DL for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720047004; 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=YWXH9YhJGBTUPtLIg1EJaieR/oMq54SMMzeEyf0UDBU=; b=c7zSluSRuDpWrqfgi2GQhy643W65ujq3kS73qkE5rZYT/EhLXEulmae2M+eo8MaUG8PAho H1zxDtFMQ/HfoE45MJvqdf+ho53b62wEZHvmOUAQ8P5/DS55Zi1uq7mBgpInnZeYAViu2W b5bXxtYuCrkcOWtMusvwKLC1jpE2KZM= 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-146-PMnSLp06PZSIy1j1SIF9sw-1; Wed, 03 Jul 2024 18:50:03 -0400 X-MC-Unique: PMnSLp06PZSIy1j1SIF9sw-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-366e0a4c965so37448f8f.1 for ; Wed, 03 Jul 2024 15:50:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720047002; x=1720651802; 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=YWXH9YhJGBTUPtLIg1EJaieR/oMq54SMMzeEyf0UDBU=; b=MmM7uTND3+QmlHSDAcRwE6iGfxXqV56LAgca8MnrhxahSyYUD9Mu3FfbHEhCwCZEG2 8jx+WVXl/rYe478MItgHIgMKEpdWcjJX37xTxebr/k12QFJovDYZTDJ9obxsVA3ncKuC vc8LinWjFtS8dHrcV2P8CqM/OKG9gRLEGKwEtuk0t9oIYAW7RKYOOEVHnzUYaReq0YcV IuFSji6qPqGla+0tq1no9zchMyn6Mwj1/SSCZ/gr17VMO1bIJHQpZwXkoCdbUVWcPsY5 ZX5tvnKE0k81wlBD0l6wMf+253M+jdJjmWnjYoPcfecr2IiHjl1IwQQO6lsIVY4YHhlb Bofg== X-Gm-Message-State: AOJu0Yzr+fpNG7es4wwDi0mbxLxDqR/5um+JmQgvTlaXBwGNPtd0vIEv qM0K0dC7mtF8JxAbRdeCtJroMRiqFYAYMfuUkI+hQ1oR5zqYUv8F5QKgSkaat5VdAaNKam3o+/C ArFX0c4+qwYFotGLczLuJlsRizWr5An8yyffxAwH8VWa/QEJuD6aykC/eAqWbjhbSLGllWGUT74 /RsrRGQVm872R/UPOZ5JHpP9uGq3dd1A== X-Received: by 2002:adf:e50d:0:b0:367:900c:c0a4 with SMTP id ffacd0b85a97d-3679dd15a36mr10220f8f.11.1720047002061; Wed, 03 Jul 2024 15:50:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYFHxYAFZf4yivxY1Cn3du2bgc6ZWiPpVzv+mVZHEU0YZRJVuCNQ1CVifNwbnyrzrSvJlq5Q== X-Received: by 2002:adf:e50d:0:b0:367:900c:c0a4 with SMTP id ffacd0b85a97d-3679dd15a36mr10205f8f.11.1720047001138; Wed, 03 Jul 2024 15:50:01 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3678a648dd3sm4937131f8f.89.2024.07.03.15.49.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:50:00 -0700 (PDT) Date: Wed, 3 Jul 2024 18:49:57 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefano Garzarella , jasowang@redhat.com, qemu-stable@nongnu.org, Xoykie , Eugenio =?utf-8?b?UMOp?= =?utf-8?b?cmV6?= Subject: [PULL v3 74/85] virtio: remove virtio_tswap16s() call in vring_packed_event_read() Message-ID: <7aa6492401e95fb296dec7cda81e67d91f6037d7.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Stefano Garzarella Commit d152cdd6f6 ("virtio: use virtio accessor to access packed event") switched using of address_space_read_cached() to virito_lduw_phys_cached() to access packed descriptor event. When we used address_space_read_cached(), we needed to call virtio_tswap16s() to handle the endianess of the field, but virito_lduw_phys_cached() already handles it internally, so we no longer need to call virtio_tswap16s() (as the commit had done for `off_wrap`, but forgot for `flags`). Fixes: d152cdd6f6 ("virtio: use virtio accessor to access packed event") Cc: jasowang@redhat.com Cc: qemu-stable@nongnu.org Reported-by: Xoykie Link: https://lore.kernel.org/qemu-devel/CAFU8RB_pjr77zMLsM0Unf9xPNxfr_--Tjr49F_eX32ZBc5o2zQ@mail.gmail.com Signed-off-by: Stefano Garzarella Message-Id: <20240701075208.19634-1-sgarzare@redhat.com> Acked-by: Jason Wang Reviewed-by: Peter Maydell Reviewed-by: Eugenio Pérez Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 3678ec2f88..583a224163 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -323,7 +323,6 @@ static void vring_packed_event_read(VirtIODevice *vdev, /* Make sure flags is seen before off_wrap */ smp_rmb(); e->off_wrap = virtio_lduw_phys_cached(vdev, cache, off_off); - virtio_tswap16s(vdev, &e->flags); } static void vring_packed_off_wrap_write(VirtIODevice *vdev, From patchwork Wed Jul 3 22:50:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D9BFC2BD09 for ; Wed, 3 Jul 2024 22:52:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8nr-00039l-1v; Wed, 03 Jul 2024 18:50: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 1sP8np-0002a6-6W for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50: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 1sP8ni-0007P9-B3 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720047008; 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=sYzP7D9xykWeqZt2i0B3IIaPj2W0maOmrsq57DCD/d0=; b=HL8yTB28u1rUpzQRZplp0nHuAk0xEFUpO1iQFuYivAdMK/xLfJRGnGahO7Fha54vflbjGF daRL476UeHnznkVvWlcTMCS01s2OzK1YbRXBpNY7Vxr/2+nQloer/GDhkFiDn9WjgF83g5 CqOofWJr2VtfFlKJpAAoOfoiaOVjNLk= 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-346-01SiHKRjOve5eOJGJFbcyQ-1; Wed, 03 Jul 2024 18:50:07 -0400 X-MC-Unique: 01SiHKRjOve5eOJGJFbcyQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3678ff75122so52125f8f.0 for ; Wed, 03 Jul 2024 15:50:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720047005; x=1720651805; 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=sYzP7D9xykWeqZt2i0B3IIaPj2W0maOmrsq57DCD/d0=; b=IySrL4OOx8NlA3m6dav6TUB79OXYl3Wxt1mJWyo281LvvV16/PlQJOXRIc0A5Ca65G 5xp6rAPSSgT/NgQuJ3ej6str8lor9M5PnIJgvCol/BqxkV68QAxgJ5DsRjQO8lVI6G0E 19OPjsHhW2D/LcaxCJqFyhSpLDt07Owy3/YxqLSTunIlgS9RJ1vvOHvrXrQ4Z5rBjkeV lF86xbT0n4ixSgkwZvS+lhQ4dAPl6+AuxaNJoXOlwV4/d9+2aJ6HAlwnitt4/19IAFmT wXaiKbIFqxFlrdRWgM91XMk1zH1o7GEChhmapVAoF30nku8jor6xY7mPcsaxO1tEtkWs 7/Bw== X-Gm-Message-State: AOJu0Yx3LBIbEQTG5JGRLLjx0JpuQE12CxdiWF3HZXnJLqfszck05Z8U PjZoFRzAV17l3We5bwW/V+fDomjwYxgk32vu+FKSLyuAft/YVxoM+DgFlqJUuOlIRajTdbCldcj P83/JZppL6K8msX6kyaNi2N74MKGCRhwnBJaCFH6Vszr0mwhEeLC83jdUmzw/KTOltYhJgRluB/ zgnktUdJOFSFfjr0k1NwhGwJaN2Sf06g== X-Received: by 2002:a5d:4d4e:0:b0:367:900c:c0a3 with SMTP id ffacd0b85a97d-3679dd15be0mr14789f8f.4.1720047005357; Wed, 03 Jul 2024 15:50:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE42dKA7uESBquH/igR/A8qDsT9V2sfQCdLMEsgJwRfsfIdN24Iw7nIriyz48t2jOSlpT09Yw== X-Received: by 2002:a5d:4d4e:0:b0:367:900c:c0a3 with SMTP id ffacd0b85a97d-3679dd15be0mr14780f8f.4.1720047004708; Wed, 03 Jul 2024 15:50:04 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cdc5csm16868540f8f.18.2024.07.03.15.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:50:03 -0700 (PDT) Date: Wed, 3 Jul 2024 18:50:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , =?utf-8?q?C=C3=A9dric?= Le Goater , Eric Auger Subject: [PULL v3 75/85] virtio-iommu: Clear IOMMUDevice when VFIO device is unplugged Message-ID: <1b889d6e39c32d709f1114699a014b381bcf1cb1.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Cédric Le Goater When a VFIO device is hoplugged in a VM using virtio-iommu, IOMMUPciBus and IOMMUDevice cache entries are created in the .get_address_space() handler of the machine IOMMU device. However, these entries are never destroyed, not even when the VFIO device is detached from the machine. This can lead to an assert if the device is reattached again. When reattached, the .get_address_space() handler reuses an IOMMUDevice entry allocated when the VFIO device was first attached. virtio_iommu_set_host_iova_ranges() is called later on from the .set_iommu_device() handler an fails with an assert on 'probe_done' because the device appears to have been already probed when this is not the case. The IOMMUDevice entry is allocated in pci_device_iommu_address_space() called from under vfio_realize(), the VFIO PCI realize handler. Since pci_device_unset_iommu_device() is called from vfio_exitfn(), a sub function of the PCIDevice unrealize() handler, it seems that the .unset_iommu_device() handler is the best place to release resources allocated at realize time. Clear the IOMMUDevice cache entry there to fix hotplug. Fixes: 817ef10da23c ("virtio-iommu: Implement set|unset]_iommu_device() callbacks") Signed-off-by: Cédric Le Goater Message-Id: <20240701101453.203985-1-clg@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-iommu.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index ed7426afc7..7c54c6b5e2 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -467,6 +467,26 @@ static AddressSpace *virtio_iommu_find_add_as(PCIBus *bus, void *opaque, return &sdev->as; } +static void virtio_iommu_device_clear(VirtIOIOMMU *s, PCIBus *bus, int devfn) +{ + IOMMUPciBus *sbus = g_hash_table_lookup(s->as_by_busptr, bus); + IOMMUDevice *sdev; + + if (!sbus) { + return; + } + + sdev = sbus->pbdev[devfn]; + if (!sdev) { + return; + } + + g_list_free_full(sdev->resv_regions, g_free); + sdev->resv_regions = NULL; + g_free(sdev); + sbus->pbdev[devfn] = NULL; +} + static gboolean hiod_equal(gconstpointer v1, gconstpointer v2) { const struct hiod_key *key1 = v1; @@ -650,6 +670,7 @@ virtio_iommu_unset_iommu_device(PCIBus *bus, void *opaque, int devfn) } g_hash_table_remove(viommu->host_iommu_devices, &key); + virtio_iommu_device_clear(viommu, bus, devfn); } static const PCIIOMMUOps virtio_iommu_ops = { From patchwork Wed Jul 3 22:50:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 741EFC31D97 for ; Wed, 3 Jul 2024 22:51:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8ns-0003Hc-Ho; Wed, 03 Jul 2024 18:50: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 1sP8nr-0003DN-BH for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:19 -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 1sP8nn-0007Qu-Lg for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720047012; 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=PtAXW6LVwA3P89VkFVi94GjAlNMJ1XHCqV5FMloDGgI=; b=AMolVbH2kguEj4tA7choLGdmHig5QFYcQ5nGT6Duk7sixWILIY0lrCb11yDLSDZLfaNl7z CQeUa893mAV6p3SBcAi77/ztXvZBW4wanho8e2cbXufLf2jGZOyQ1WxWci9x+6EBIOee7N /lCBwSmNgMl2ZBv4S0MZUyCPX7P8Y78= 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-343-fRc4uKRTMxChNLYPGNeHqg-1; Wed, 03 Jul 2024 18:50:11 -0400 X-MC-Unique: fRc4uKRTMxChNLYPGNeHqg-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-425897358f0so5405e9.2 for ; Wed, 03 Jul 2024 15:50:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720047009; x=1720651809; 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=PtAXW6LVwA3P89VkFVi94GjAlNMJ1XHCqV5FMloDGgI=; b=tiR9QcPY62S0RXRjFNk2RajLyaQv7SrESZcgYM/LonWM8V5FWO1SKwGqh7yhrn/pxc BGQnY8Xrixgztpeske7+U1vXzfftCAsNwy4HLpvvb+p3W+Y4/fLGO0Cc9DGinh4Sjrpt eDX24xt4syYIOhWVd+kb6mQbPK5/yGDZan7uLsbSuiHPAOpaL2lQPS33pH0Mty+ej8Ib AIjVkvgQ1NVcY3HDrdVBW0MEbGFRESEE6Ls8oxgqCS184Nl4sbB+pM+bXVN2CvDPhZ3D 2o9TnfjioSpAxgYX8uID92Eds3AYK5Sqsplwmuvd+7oxROSvi0JLy/yhe30L6dtZfmYd xkNg== X-Gm-Message-State: AOJu0YyIIr3SZfsc26my+qqkJJtxqr0rqGkMj9uI1HpRBV0kAMWoPjlD 0CluhZxBTrgx0R4uegHD6O2RaxXTlxoBq+1sJsndTpbK+5+sBwkFlLBz0EiLOHH47udC9DgJr1h xTCdQL//YmtazgwOFo/5EWZv5m0D7EtrIAf+3BCV4VBt1HdXWmRUYerGCVwC6TYTqpuqRFloVrP r0r84+qlZZNokOn4b76PEbooarTnzuTA== X-Received: by 2002:a05:600c:4b17:b0:424:a578:fc7 with SMTP id 5b1f17b1804b1-4264a3cc9f5mr415515e9.3.1720047009045; Wed, 03 Jul 2024 15:50:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFpa77sy9qcpEziIeS7eh+YqAW5vVfTokYAPRI+PfSjMPs8mQy0gyLw0cLiwbfI2y2KQ/aGaA== X-Received: by 2002:a05:600c:4b17:b0:424:a578:fc7 with SMTP id 5b1f17b1804b1-4264a3cc9f5mr415265e9.3.1720047008069; Wed, 03 Jul 2024 15:50:08 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a1dd902sm1233625e9.12.2024.07.03.15.50.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:50:07 -0700 (PDT) Date: Wed, 3 Jul 2024 18:50:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL v3 76/85] hw/pci: Rename has_power to enabled Message-ID: <6a31b219a5338564f3978251c79f96f689e037da.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Akihiko Odaki The renamed state will not only represent powering state of PFs, but also represent SR-IOV VF enablement in the future. Signed-off-by: Akihiko Odaki Message-Id: <20240627-reuse-v10-1-7ca0b8ed3d9f@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 7 ++++++- include/hw/pci/pci_device.h | 2 +- hw/pci/pci.c | 14 +++++++------- hw/pci/pci_host.c | 4 ++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index eb26cac810..fe04b4fafd 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -678,6 +678,11 @@ static inline void pci_irq_pulse(PCIDevice *pci_dev) } MSIMessage pci_get_msi_message(PCIDevice *dev, int vector); -void pci_set_power(PCIDevice *pci_dev, bool state); +void pci_set_enabled(PCIDevice *pci_dev, bool state); + +static inline void pci_set_power(PCIDevice *pci_dev, bool state) +{ + pci_set_enabled(pci_dev, state); +} #endif diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index d3dd0f64b2..d57f9ce838 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -56,7 +56,7 @@ typedef struct PCIReqIDCache PCIReqIDCache; struct PCIDevice { DeviceState qdev; bool partially_hotplugged; - bool has_power; + bool enabled; /* PCI config space */ uint8_t *config; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 50b86d5790..68d30feb86 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1525,7 +1525,7 @@ static void pci_update_mappings(PCIDevice *d) continue; new_addr = pci_bar_address(d, i, r->type, r->size); - if (!d->has_power) { + if (!d->enabled) { new_addr = PCI_BAR_UNMAPPED; } @@ -1613,7 +1613,7 @@ void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val_in, int pci_update_irq_disabled(d, was_irq_disabled); memory_region_set_enabled(&d->bus_master_enable_region, (pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER) && d->has_power); + & PCI_COMMAND_MASTER) && d->enabled); } msi_write_config(d, addr, val_in, l); @@ -2884,18 +2884,18 @@ MSIMessage pci_get_msi_message(PCIDevice *dev, int vector) return msg; } -void pci_set_power(PCIDevice *d, bool state) +void pci_set_enabled(PCIDevice *d, bool state) { - if (d->has_power == state) { + if (d->enabled == state) { return; } - d->has_power = state; + d->enabled = state; pci_update_mappings(d); memory_region_set_enabled(&d->bus_master_enable_region, (pci_get_word(d->config + PCI_COMMAND) - & PCI_COMMAND_MASTER) && d->has_power); - if (!d->has_power) { + & PCI_COMMAND_MASTER) && d->enabled); + if (!d->enabled) { pci_device_reset(d); } } diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c index dfe6fe6184..0d82727cc9 100644 --- a/hw/pci/pci_host.c +++ b/hw/pci/pci_host.c @@ -86,7 +86,7 @@ void pci_host_config_write_common(PCIDevice *pci_dev, uint32_t addr, * allowing direct removal of unexposed functions. */ if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) || - !pci_dev->has_power || is_pci_dev_ejected(pci_dev)) { + !pci_dev->enabled || is_pci_dev_ejected(pci_dev)) { return; } @@ -111,7 +111,7 @@ uint32_t pci_host_config_read_common(PCIDevice *pci_dev, uint32_t addr, * allowing direct removal of unexposed functions. */ if ((pci_dev->qdev.hotplugged && !pci_get_function_0(pci_dev)) || - !pci_dev->has_power || is_pci_dev_ejected(pci_dev)) { + !pci_dev->enabled || is_pci_dev_ejected(pci_dev)) { return ~0x0; } From patchwork Wed Jul 3 22:50:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0685AC31D97 for ; Wed, 3 Jul 2024 22:51:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8nu-0003Xr-Ph; Wed, 03 Jul 2024 18:50: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 1sP8nr-0003FT-RI for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:19 -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 1sP8nq-0007Rl-8z for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720047016; 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=actUboiQ+IrTgCsdz18KhXUIoDAvYkrEhXUsAIxh/Nc=; b=ZOMPW1bNqKYYfm1AP1dYJiw1I9FLoK0ZLYehz+Fx4+SQd4zbg+/vLSrG8thyw0yKJQzrtT gKVHJ7YRn+A75K3ZbyxMFD18VHYCXj9LplI0LAexcwLx/vR8jQFbHO12K3WjbErKlsSUt2 v/3PGBaxejrJPoawPF78DUdZHZ0ImQM= 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-65-YLK5RpOCOCaZOGW5uBkhmQ-1; Wed, 03 Jul 2024 18:50:14 -0400 X-MC-Unique: YLK5RpOCOCaZOGW5uBkhmQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4263fff5eaeso105725e9.0 for ; Wed, 03 Jul 2024 15:50:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720047013; x=1720651813; 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=actUboiQ+IrTgCsdz18KhXUIoDAvYkrEhXUsAIxh/Nc=; b=ZXmG2Za2GEhoy/fgjbGcIEx9IRUjDAjw8yZRfQdqQg9rngm5pHvREpUkC8ipm/VhTB 93zJ7CXcg5l6mNUW4OVQLzSxfsnmvB5OOIXsBIrl+g6QtnT565J8OXtS4WTL7LHLIHwS ycB7rLVK3FTFeZLtQZnOCdmx0S1eWSo3LzmxX8Mm3CyEXStfXlFtddiloJByAK+G2/Do +dnFed8OAzEhEk359u60UkSuUceCNrAvTKAZeBM9IRUyZLvV9wCro4ZsurycQBdaxKdl z7UJYoL9wAB1vtfQl/nC4/9QfG0pPtuftYGTyF3ZbgsonD7QL05n8D2u1yK+NH304q8F 49dA== X-Gm-Message-State: AOJu0YxPi0C+knJlavaJAlCyD5UPDtEdprRl7hJGoWX5XWvYUnhcrLdK mm3kDI3ENb3fnJrHtyHdujohPLMy5W5EnXSNucesmVMuESGln9f6aJT6klVPwwS5iU3YM/yJMRr ldUkDW1GFKWNNxVbpMsoHPbIoUA6tluMZmzYWJgvXlDXrCTvvF8SzKzDouONXZbPyMpu45MOJb5 mjT8szZAPEuD8EQtUolBVkvjMhN5NK0g== X-Received: by 2002:a05:600c:63ce:b0:424:aa83:ef01 with SMTP id 5b1f17b1804b1-4264a3d1e2emr357115e9.10.1720047012991; Wed, 03 Jul 2024 15:50:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFXo/zzTggwe17jzj0Xhk3SPjb+uH2NxGoezo62WozFu8slXIycgNJSg2oK2kTztQNBOV4Mfg== X-Received: by 2002:a05:600c:63ce:b0:424:aa83:ef01 with SMTP id 5b1f17b1804b1-4264a3d1e2emr356935e9.10.1720047012419; Wed, 03 Jul 2024 15:50:12 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a21cbb7sm1204725e9.26.2024.07.03.15.50.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:50:11 -0700 (PDT) Date: Wed, 3 Jul 2024 18:50:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , qemu-ppc@nongnu.org Subject: [PULL v3 77/85] hw/ppc/spapr_pci: Do not create DT for disabled PCI device Message-ID: <723c5b4628d047e43825a046c6ee517b82b88117.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Akihiko Odaki Disabled means it is a disabled SR-IOV VF or it is powered off, and hidden from the guest. Signed-off-by: Akihiko Odaki Message-Id: <20240627-reuse-v10-2-7ca0b8ed3d9f@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/ppc/spapr_pci.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 7cf9904c35..f63182a03c 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1296,6 +1296,10 @@ static void spapr_dt_pci_device_cb(PCIBus *bus, PCIDevice *pdev, return; } + if (!pdev->enabled) { + return; + } + err = spapr_dt_pci_device(p->sphb, pdev, p->fdt, p->offset); if (err < 0) { p->err = err; From patchwork Wed Jul 3 22:50:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 854B0C31D97 for ; Wed, 3 Jul 2024 22:50:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8nz-0004Eq-N0; Wed, 03 Jul 2024 18:50:27 -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 1sP8nx-0003xS-8W for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50: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 1sP8nt-0007UB-Ks for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720047021; 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=DMkazJvXlCFuPVFo5zwsqgTLcz0EAKKfqUw3BcILaOs=; b=AdZvQWvyyJXX3dqBB5/ARhMTF1R8i7n5UdD4IRvnMo93vDKYMgzbyiJpGMg5jJiILhGXOk AHL2q1wjfkmiuBNB8h7ue/4bd3+JN1SC0PXWoPLXzCDHwL8J2pqoSs8v/2OWvxNGxc3dBZ lgODEP1vN/Va6gHkcZCi+Ptj1u279fI= 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-220-2fItBZLdPeeP1VmiJOks3g-1; Wed, 03 Jul 2024 18:50:20 -0400 X-MC-Unique: 2fItBZLdPeeP1VmiJOks3g-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-366e0a4c965so37627f8f.1 for ; Wed, 03 Jul 2024 15:50:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720047018; x=1720651818; 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=DMkazJvXlCFuPVFo5zwsqgTLcz0EAKKfqUw3BcILaOs=; b=nl+Ph5nxFzu0gcHYaSJqiXSKdwGOuOIHEhkTndElFaxJk3W6sPrXard2mllEuXNFTA LaJTQdeeQxjtl7L+dG9PKOLUbRSp4IXRbp+gyxsN2LCGYhu5Olw871On8fZraJaI7RRo FdNkEpQB1H+YntV1OBHWgmh3/kPGoimv8+wOVQyz+7ij943Xvn6Mr8UIu7Ot9MWPoGt/ TGZWGoQlKQ0DoJLmKeAK3ii1WCSaHXtgnc3mhPRqVPcqnR1bFsygM+b/KNVKtXxqLHYx msPSyKygNp0Yb+vHGoIph7+x7FDUlgIZy5Jim0IPOho0Evo4u05nyowjNmMtgLFvam/s +BFQ== X-Gm-Message-State: AOJu0YxDy3/ReKvMgGnLTYsnpH3LX+h6uwgHGUW8NRfCRZSPABz3Sj0B Pizu9kRzDslQzFh7z1F7xnLX7mn/KZCmraHUDBl+xPQStvLPol40rmVxIKGNKoQzUsla+xzg7VK uU73gnVAqCmcdbzxngj+dv7Gp9F51BOxe7ucXjbzXasxIUn6uCoW1VYfsxHhBPD4/p2klR14Z65 QXzGIikqBiQKU9OgbGjz4m2MjnO0qIag== X-Received: by 2002:adf:fccd:0:b0:366:ebd2:662f with SMTP id ffacd0b85a97d-3679dd34163mr9149f8f.30.1720047018140; Wed, 03 Jul 2024 15:50:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEaooaPw282ZT5JS2s5r681ut3H6DUwmgSQ+036eoYeugyGzbJ1HayzLRizzhHO1CsgMTAyxw== X-Received: by 2002:adf:fccd:0:b0:366:ebd2:662f with SMTP id ffacd0b85a97d-3679dd34163mr9136f8f.30.1720047017589; Wed, 03 Jul 2024 15:50:17 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3678eb6593bsm4188588f8f.93.2024.07.03.15.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:50:16 -0700 (PDT) Date: Wed, 3 Jul 2024 18:50:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Nicholas Piggin , Daniel Henrique Barboza , David Gibson , Harsh Prateek Bora , qemu-ppc@nongnu.org Subject: [PULL v3 78/85] hw/ppc/spapr_pci: Do not reject VFs created after a PF Message-ID: <26f86093ec989cb73ad03e8a234f5dc321e1e267.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Akihiko Odaki A PF may automatically create VFs and the PF may be function 0. Signed-off-by: Akihiko Odaki Message-Id: <20240627-reuse-v10-3-7ca0b8ed3d9f@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/ppc/spapr_pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index f63182a03c..ed4454bbf7 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1573,7 +1573,9 @@ static void spapr_pci_pre_plug(HotplugHandler *plug_handler, * hotplug, we do not allow functions to be hotplugged to a * slot that already has function 0 present */ - if (plugged_dev->hotplugged && bus->devices[PCI_DEVFN(slotnr, 0)] && + if (plugged_dev->hotplugged && + !pci_is_vf(pdev) && + bus->devices[PCI_DEVFN(slotnr, 0)] && PCI_FUNC(pdev->devfn) != 0) { error_setg(errp, "PCI: slot %d function 0 already occupied by %s," " additional functions can no longer be exposed to guest.", From patchwork Wed Jul 3 22:50:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723037 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7A25C3271E for ; Wed, 3 Jul 2024 22:52:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8o1-0004fJ-VC; Wed, 03 Jul 2024 18:50: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 1sP8nz-0004Kb-Vg for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:28 -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 1sP8ny-0007X7-7t for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720047025; 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=6T5wYohIMyfJ7zfD4BymibarRz8jk6tb2fFAczZH0qE=; b=EwCL+JBFFQR3+TI7uBKW6tggUuG7VkEnVmP7HZSw06s3GIQk2aPwSoiw+xE+jfcS1M42C+ nASF5P9wAIrjM4PHmKZGlZC8AhtUJv4sYOne/ERTY0HLaItt/VcZvqUO8iYozd5esIY90y NJ3xZTzct6HESb5NkbhwAX28koe1cbs= 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-428-tDgj2u9OOsOC2l5U9pe00g-1; Wed, 03 Jul 2024 18:50:24 -0400 X-MC-Unique: tDgj2u9OOsOC2l5U9pe00g-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3678e549a1eso36889f8f.0 for ; Wed, 03 Jul 2024 15:50:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720047022; x=1720651822; 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=6T5wYohIMyfJ7zfD4BymibarRz8jk6tb2fFAczZH0qE=; b=YPk06O06lHsIfrGGs7/mFa/wBNQZJa/arMJVz2aUe3rvECxWpVATyhQpgFTRh2q38T FFmYYZpLEKkEv8LbXFwNPgdHvivWrz89iF+ZFU0JvrZ9i8haSwxYtbpTK+bzwM4W0f2m IG8kg5U1amtlnJU9legK9L4mdEWceUt4qIeMHy66rXOYEaCpbd39HiQDw5v9cZaGntae JerPtGhr4vG44wxIcoMe3DnIAVUQaqx+LRrZMvjlU+OLpsynPDaF6qOyVJlea/d7+jew kzKwScDy5b4kxesAHxFYVPA3EUGbV82SGq5x2udck6ZL7nspdtxhf96tppXxKiyzHZaj atTA== X-Gm-Message-State: AOJu0Yz7tw3cv6RYHQuVsutOi7S5TmmBnu8VduMejiTA9I0a4DP1+wIB uzzbnMcy+JvaqmqLlGmKIyapsl/4tEXaKeJzOvvTFmRVaPSKI/eJHRIriiNBTDlv18J7JLbNVmI mZcczYND2Mcpkwf6YwaOO3nuYjPWTNdG0NpkFNSVXcLQA5CZ+2YqhthuiI+iBLRXMZsD9RUFv4V wFJ0hVF3Ydbq7XalwwO/qiKzsbf/l5rQ== X-Received: by 2002:adf:fe03:0:b0:367:3404:1c06 with SMTP id ffacd0b85a97d-367947a6c35mr2645055f8f.20.1720047022205; Wed, 03 Jul 2024 15:50:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8nRWl6r6HY/AR80oLiKIOloEJjI9UzbQZyAoSCZIK3/30EKBGMLJU9n0fkFgSpinRlNVoXw== X-Received: by 2002:adf:fe03:0:b0:367:3404:1c06 with SMTP id ffacd0b85a97d-367947a6c35mr2645038f8f.20.1720047021600; Wed, 03 Jul 2024 15:50:21 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-367957d3451sm2319022f8f.101.2024.07.03.15.50.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:50:20 -0700 (PDT) Date: Wed, 3 Jul 2024 18:50:18 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL v3 79/85] pcie_sriov: Do not manually unrealize 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Akihiko Odaki A device gets automatically unrealized when being unparented. Signed-off-by: Akihiko Odaki Message-Id: <20240627-reuse-v10-4-7ca0b8ed3d9f@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pcie_sriov.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index e9b23221d7..499becd527 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -204,11 +204,7 @@ static void unregister_vfs(PCIDevice *dev) trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), num_vfs); for (i = 0; i < num_vfs; i++) { - Error *err = NULL; PCIDevice *vf = dev->exp.sriov_pf.vf[i]; - if (!object_property_set_bool(OBJECT(vf), "realized", false, &err)) { - error_reportf_err(err, "Failed to unplug: "); - } object_unparent(OBJECT(vf)); object_unref(OBJECT(vf)); } From patchwork Wed Jul 3 22:50:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723010 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 881E2C2BD09 for ; Wed, 3 Jul 2024 22:51:25 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8o8-0005ZN-Qs; Wed, 03 Jul 2024 18:50:36 -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 1sP8o4-0004xt-CO for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50: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 1sP8o2-0007Xo-6z for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720047029; 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=30vtT+Bk+aBG/k9psr6e7+phVupnPVIwCqnHm1QF2rI=; b=ZbZ85pPvR/ilXUQCB8ktSoFgVBFN2omtIjiNPIPEVo/2zDfaoqJhaoeHFLFUbFX9U0yc6E HRT/fZAK3UGcwkCPoWDPspHYBi6lukRBhbdPoV2kY6Bj2nvEIYASUrKG98ksdlfm24Epg9 Q58CkZUDkxKpKAxDHYYc1kD/t/loT3g= 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-222-nvh8kc6UMGWX5CBkDLpmDQ-1; Wed, 03 Jul 2024 18:50:28 -0400 X-MC-Unique: nvh8kc6UMGWX5CBkDLpmDQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-36740a84ad8so51066f8f.0 for ; Wed, 03 Jul 2024 15:50:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720047027; x=1720651827; 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=30vtT+Bk+aBG/k9psr6e7+phVupnPVIwCqnHm1QF2rI=; b=v7ttbxXcrMNmRLIerifMUKHcxUU0ZZDaCyj54TyZ+m9hxpI5Rtk62B5v5FyR2gyiLy PmU7uWootBRKOC0TZsAlp1DzhZWbMBOaFaVtvv0Vd28ASEwU+w1/BK8N9Hb5cKtTtb40 JxqBs15P8uW/ldqyGxMN0haVES6vgH+M4FQRLSC8ZSIV3mBbVmJm5iu3JEE2S2lVQTsy MmU0b8vIo1ummCj+/mGNopU2EmbFaAwW7nPgW/ylTG6VVrM78zgpPxlxYTq6MNDd1Pys cpiZMo2MTT4SmT9nEOFu/b1GxY4zT++dVuy4A1TxomjqmOAmJr0FJCfyER7ynkXn43ag mZIQ== X-Gm-Message-State: AOJu0YyacO5uRK7slA56kxa+zSfsw+36VCr/wR33KgaeT7UwQPGB4rs/ tgpQK2F+3kfps6Z/FpCSYXiDGxdRN2QyG1V9iNu+Ku9M4vypqi3MjtEnQQVIgxB9m3HvNRoWEI3 8rVX7I/6JPKext9Hh7TkvT7fFk2JnbCIpU0+Dg8RoIknx/8uYZgPa21Y/JyBqvYOlAEpATdP/x2 Uyc5lwhjkli2bKW9D07gjYv38PDKd83A== X-Received: by 2002:a5d:55c5:0:b0:367:2d2f:e634 with SMTP id ffacd0b85a97d-3679dd66971mr5124f8f.55.1720047026919; Wed, 03 Jul 2024 15:50:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFf44Meb/FUzXp1aYvGqhquZJdCtebhyMNFNhxMMcEXtPSxBDnGrO8ppKWaEhcqXWND6Wk0LQ== X-Received: by 2002:a5d:55c5:0:b0:367:2d2f:e634 with SMTP id ffacd0b85a97d-3679dd66971mr5101f8f.55.1720047026011; Wed, 03 Jul 2024 15:50:26 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3679c12440asm292045f8f.73.2024.07.03.15.50.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:50:25 -0700 (PDT) Date: Wed, 3 Jul 2024 18:50:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org Subject: [PULL v3 80/85] pcie_sriov: Ensure VF function number does not overflow Message-ID: <77718701157f6ca77ea7a57b536fa0a22f676082.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Akihiko Odaki pci_new() aborts when creating a VF with a function number equals to or is greater than PCI_DEVFN_MAX. Signed-off-by: Akihiko Odaki Message-Id: <20240627-reuse-v10-5-7ca0b8ed3d9f@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- docs/pcie_sriov.txt | 8 +++++--- include/hw/pci/pcie_sriov.h | 5 +++-- hw/net/igb.c | 13 ++++++++++--- hw/nvme/ctrl.c | 24 ++++++++++++++++-------- hw/pci/pcie_sriov.c | 19 +++++++++++++++++-- 5 files changed, 51 insertions(+), 18 deletions(-) diff --git a/docs/pcie_sriov.txt b/docs/pcie_sriov.txt index a47aad0bfa..ab2142807f 100644 --- a/docs/pcie_sriov.txt +++ b/docs/pcie_sriov.txt @@ -52,9 +52,11 @@ setting up a BAR for a VF. ... /* Add and initialize the SR/IOV capability */ - pcie_sriov_pf_init(d, 0x200, "your_virtual_dev", - vf_devid, initial_vfs, total_vfs, - fun_offset, stride); + if (!pcie_sriov_pf_init(d, 0x200, "your_virtual_dev", + vf_devid, initial_vfs, total_vfs, + fun_offset, stride, errp)) { + return; + } /* Set up individual VF BARs (parameters as for normal BARs) */ pcie_sriov_pf_init_vf_bar( ... ) diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 450cbef6c2..aa704e8f9d 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -27,10 +27,11 @@ typedef struct PCIESriovVF { uint16_t vf_number; /* Logical VF number of this function */ } PCIESriovVF; -void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, +bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, const char *vfname, uint16_t vf_dev_id, uint16_t init_vfs, uint16_t total_vfs, - uint16_t vf_offset, uint16_t vf_stride); + uint16_t vf_offset, uint16_t vf_stride, + Error **errp); void pcie_sriov_pf_exit(PCIDevice *dev); /* Set up a VF bar in the SR/IOV bar area */ diff --git a/hw/net/igb.c b/hw/net/igb.c index b92bba402e..b6ca2f1b8a 100644 --- a/hw/net/igb.c +++ b/hw/net/igb.c @@ -446,9 +446,16 @@ static void igb_pci_realize(PCIDevice *pci_dev, Error **errp) 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, - IGB_VF_OFFSET, IGB_VF_STRIDE); + if (!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, + IGB_VF_OFFSET, IGB_VF_STRIDE, + errp)) { + pcie_cap_exit(pci_dev); + igb_cleanup_msix(s); + msi_uninit(pci_dev); + return; + } pcie_sriov_pf_init_vf_bar(pci_dev, IGBVF_MMIO_BAR_IDX, PCI_BASE_ADDRESS_MEM_TYPE_64 | PCI_BASE_ADDRESS_MEM_PREFETCH, diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 127c3d2383..066389e391 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8048,7 +8048,8 @@ out: return pow2ceil(bar_size); } -static void nvme_init_sriov(NvmeCtrl *n, PCIDevice *pci_dev, uint16_t offset) +static bool nvme_init_sriov(NvmeCtrl *n, PCIDevice *pci_dev, uint16_t offset, + Error **errp) { uint16_t vf_dev_id = n->params.use_intel_id ? PCI_DEVICE_ID_INTEL_NVME : PCI_DEVICE_ID_REDHAT_NVME; @@ -8057,12 +8058,17 @@ static void nvme_init_sriov(NvmeCtrl *n, PCIDevice *pci_dev, uint16_t offset) le16_to_cpu(cap->vifrsm), NULL, NULL); - pcie_sriov_pf_init(pci_dev, offset, "nvme", vf_dev_id, - n->params.sriov_max_vfs, n->params.sriov_max_vfs, - NVME_VF_OFFSET, NVME_VF_STRIDE); + if (!pcie_sriov_pf_init(pci_dev, offset, "nvme", vf_dev_id, + n->params.sriov_max_vfs, n->params.sriov_max_vfs, + NVME_VF_OFFSET, NVME_VF_STRIDE, + errp)) { + return false; + } pcie_sriov_pf_init_vf_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | PCI_BASE_ADDRESS_MEM_TYPE_64, bar_size); + + return true; } static int nvme_add_pm_capability(PCIDevice *pci_dev, uint8_t offset) @@ -8155,6 +8161,12 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pci_dev, Error **errp) return false; } + if (!pci_is_vf(pci_dev) && n->params.sriov_max_vfs && + !nvme_init_sriov(n, pci_dev, 0x120, errp)) { + msix_uninit(pci_dev, &n->bar0, &n->bar0); + return false; + } + nvme_update_msixcap_ts(pci_dev, n->conf_msix_qsize); if (n->params.cmb_size_mb) { @@ -8165,10 +8177,6 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pci_dev, Error **errp) nvme_init_pmr(n, pci_dev); } - if (!pci_is_vf(pci_dev) && n->params.sriov_max_vfs) { - nvme_init_sriov(n, pci_dev, 0x120); - } - return true; } diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 499becd527..f0bde0d3fc 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -24,14 +24,27 @@ static PCIDevice *register_vf(PCIDevice *pf, int devfn, const char *name, uint16_t vf_num); static void unregister_vfs(PCIDevice *dev); -void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, +bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, const char *vfname, uint16_t vf_dev_id, uint16_t init_vfs, uint16_t total_vfs, - uint16_t vf_offset, uint16_t vf_stride) + uint16_t vf_offset, uint16_t vf_stride, + Error **errp) { uint8_t *cfg = dev->config + offset; uint8_t *wmask; + if (total_vfs) { + uint16_t ari_cap = pcie_find_capability(dev, PCI_EXT_CAP_ID_ARI); + uint16_t first_vf_devfn = dev->devfn + vf_offset; + uint16_t last_vf_devfn = first_vf_devfn + vf_stride * (total_vfs - 1); + + if ((!ari_cap && PCI_SLOT(dev->devfn) != PCI_SLOT(last_vf_devfn)) || + last_vf_devfn >= PCI_DEVFN_MAX) { + error_setg(errp, "VF function number overflows"); + return false; + } + } + pcie_add_capability(dev, PCI_EXT_CAP_ID_SRIOV, 1, offset, PCI_EXT_CAP_SRIOV_SIZEOF); dev->exp.sriov_cap = offset; @@ -69,6 +82,8 @@ void pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, pci_set_word(wmask + PCI_SRIOV_SYS_PGSIZE, 0x553); qdev_prop_set_bit(&dev->qdev, "multifunction", true); + + return true; } void pcie_sriov_pf_exit(PCIDevice *dev) From patchwork Wed Jul 3 22:50:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723036 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C855EC2BD09 for ; Wed, 3 Jul 2024 22:52:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8oD-0006F4-9F; Wed, 03 Jul 2024 18:50: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 1sP8oB-0005u5-2b for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:39 -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 1sP8o6-0007ZB-8T for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720047033; 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=L4UFSErF8Ci7X9ojGTRrl+PVA8jTE90RlPCAhdXfrho=; b=a7JOllFoIDmINg3ETAnXUKDhEjokLtAk3Y3NcRMIQ7m2sTU5aMcAJZoQoqbhIswmqj0rkW tXQjN84Qtl6f9mdX0izGzOQj9fYoWEaua6CWWWC+hsNIgU9aEOthwasGp7aGJsi6BQYAG0 pjMOFiMS5gu2WUHZNIKVRBLGfmfRe/w= 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-288-87OYWLRMMzilwtm5H_q-uw-1; Wed, 03 Jul 2024 18:50:32 -0400 X-MC-Unique: 87OYWLRMMzilwtm5H_q-uw-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-4257f95ffc6so11285e9.1 for ; Wed, 03 Jul 2024 15:50:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720047030; x=1720651830; 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=L4UFSErF8Ci7X9ojGTRrl+PVA8jTE90RlPCAhdXfrho=; b=D3t4kidlJvMF5uB4ci0EOKz6iwfiHBKH4zl7ccRTUyCrlNrTe+tHAzrycHYmhfEn8/ DBiFLJCseC/Cipxd4KSFblvbOxJ9x3Wy9AiEiFrSfvuawQZ30//oDQ3U9Xs9tJgwWksb E25tzjDhnLS4BJegxKDLAuWAEzt0o7oyK3rPIF6tP2YkWgjB7a3YR1By5KZe/mNt1Uvo vRW+0Fb0PjEUu/ByMeBWSJ0Hh0NY7cxzwP49KBfirbg2bmpVLGysNPf6yYa0oeFBiZpr sCxhwiqxn/e4OAcEHDIausnxddA7NC+03a+V0atM1iAXNoBtAXsrq/pse4cZroRGfntH ztFQ== X-Gm-Message-State: AOJu0Yyc4sWyVfXKadLF74lCUZFbQ8qITN4f7+kxjLak3jj9TaYOk2ys 7GsghXpzIosjsbk784m6h+G/X5ykgwmoERqfY/oZQlzdbW5bFiWULJYusDCkkzwpaBTUXsx+9eM 0FPRXtVLy4sCYgTLtV3RsicXbOOv/SFicAhU5Y065mS7NxSdSGteIYMtn4OxmO7NtzMuJ+BvuXs CRYbXqw0jKXjYFQRsawRNaI9GVHrz1QQ== X-Received: by 2002:a05:600c:28a:b0:424:9f28:22ff with SMTP id 5b1f17b1804b1-4264a3cf814mr353095e9.5.1720047030747; Wed, 03 Jul 2024 15:50:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdl8KWDXUE7OjJnPO3OwkYv4TJIdiTCSdwNerRIowPNWdhLXr7NOXnyMhAO43/5fT9oFl+3g== X-Received: by 2002:a05:600c:28a:b0:424:9f28:22ff with SMTP id 5b1f17b1804b1-4264a3cf814mr352945e9.5.1720047030069; Wed, 03 Jul 2024 15:50:30 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36795d1fc9csm2270500f8f.83.2024.07.03.15.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:50:29 -0700 (PDT) Date: Wed, 3 Jul 2024 18:50:26 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL v3 81/85] pcie_sriov: Reuse SR-IOV VF device instances Message-ID: <139610ae67f6ecf92127bb7bf53ac6265b459ec8.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Akihiko Odaki Disable SR-IOV VF devices by reusing code to power down PCI devices instead of removing them when the guest requests to disable VFs. This allows to realize devices and report VF realization errors at PF realization time. Signed-off-by: Akihiko Odaki Message-Id: <20240627-reuse-v10-6-7ca0b8ed3d9f@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 5 -- include/hw/pci/pci_device.h | 15 ++++++ include/hw/pci/pcie_sriov.h | 1 - hw/pci/pci.c | 2 +- hw/pci/pcie_sriov.c | 95 ++++++++++++++++--------------------- 5 files changed, 56 insertions(+), 62 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index fe04b4fafd..14a869eeaa 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -680,9 +680,4 @@ static inline void pci_irq_pulse(PCIDevice *pci_dev) MSIMessage pci_get_msi_message(PCIDevice *dev, int vector); void pci_set_enabled(PCIDevice *pci_dev, bool state); -static inline void pci_set_power(PCIDevice *pci_dev, bool state) -{ - pci_set_enabled(pci_dev, state); -} - #endif diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index d57f9ce838..ca15132508 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -205,6 +205,21 @@ static inline uint16_t pci_get_bdf(PCIDevice *dev) return PCI_BUILD_BDF(pci_bus_num(pci_get_bus(dev)), dev->devfn); } +static inline void pci_set_power(PCIDevice *pci_dev, bool state) +{ + /* + * Don't change the enabled state of VFs when powering on/off the device. + * + * When powering on, VFs must not be enabled immediately but they must + * wait until the guest configures SR-IOV. + * When powering off, their corresponding PFs will be reset and disable + * VFs. + */ + if (!pci_is_vf(pci_dev)) { + pci_set_enabled(pci_dev, state); + } +} + uint16_t pci_requester_id(PCIDevice *dev); /* DMA access functions */ diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index aa704e8f9d..70649236c1 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -18,7 +18,6 @@ typedef struct PCIESriovPF { uint16_t num_vfs; /* Number of virtual functions created */ uint8_t vf_bar_type[PCI_NUM_REGIONS]; /* Store type for each VF bar */ - const char *vfname; /* Reference to the device type used for the VFs */ PCIDevice **vf; /* Pointer to an array of num_vfs VF devices */ } PCIESriovPF; diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 68d30feb86..e32a69f3fa 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2895,7 +2895,7 @@ void pci_set_enabled(PCIDevice *d, bool state) memory_region_set_enabled(&d->bus_master_enable_region, (pci_get_word(d->config + PCI_COMMAND) & PCI_COMMAND_MASTER) && d->enabled); - if (!d->enabled) { + if (d->qdev.realized) { pci_device_reset(d); } } diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index f0bde0d3fc..faadb0d2ea 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -20,9 +20,16 @@ #include "qapi/error.h" #include "trace.h" -static PCIDevice *register_vf(PCIDevice *pf, int devfn, - const char *name, uint16_t vf_num); -static void unregister_vfs(PCIDevice *dev); +static void unparent_vfs(PCIDevice *dev, uint16_t total_vfs) +{ + for (uint16_t i = 0; i < total_vfs; i++) { + PCIDevice *vf = dev->exp.sriov_pf.vf[i]; + object_unparent(OBJECT(vf)); + object_unref(OBJECT(vf)); + } + g_free(dev->exp.sriov_pf.vf); + dev->exp.sriov_pf.vf = NULL; +} bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, const char *vfname, uint16_t vf_dev_id, @@ -30,6 +37,8 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, uint16_t vf_offset, uint16_t vf_stride, Error **errp) { + BusState *bus = qdev_get_parent_bus(&dev->qdev); + int32_t devfn = dev->devfn + vf_offset; uint8_t *cfg = dev->config + offset; uint8_t *wmask; @@ -49,7 +58,6 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, offset, PCI_EXT_CAP_SRIOV_SIZEOF); dev->exp.sriov_cap = offset; dev->exp.sriov_pf.num_vfs = 0; - dev->exp.sriov_pf.vfname = g_strdup(vfname); dev->exp.sriov_pf.vf = NULL; pci_set_word(cfg + PCI_SRIOV_VF_OFFSET, vf_offset); @@ -83,14 +91,34 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, qdev_prop_set_bit(&dev->qdev, "multifunction", true); + dev->exp.sriov_pf.vf = g_new(PCIDevice *, total_vfs); + + for (uint16_t i = 0; i < total_vfs; i++) { + PCIDevice *vf = pci_new(devfn, vfname); + vf->exp.sriov_vf.pf = dev; + vf->exp.sriov_vf.vf_number = i; + + if (!qdev_realize(&vf->qdev, bus, errp)) { + unparent_vfs(dev, i); + return false; + } + + /* set vid/did according to sr/iov spec - they are not used */ + pci_config_set_vendor_id(vf->config, 0xffff); + pci_config_set_device_id(vf->config, 0xffff); + + dev->exp.sriov_pf.vf[i] = vf; + devfn += vf_stride; + } + return true; } void pcie_sriov_pf_exit(PCIDevice *dev) { - unregister_vfs(dev); - g_free((char *)dev->exp.sriov_pf.vfname); - dev->exp.sriov_pf.vfname = NULL; + uint8_t *cfg = dev->config + dev->exp.sriov_cap; + + unparent_vfs(dev, pci_get_word(cfg + PCI_SRIOV_TOTAL_VF)); } void pcie_sriov_pf_init_vf_bar(PCIDevice *dev, int region_num, @@ -156,38 +184,11 @@ void pcie_sriov_vf_register_bar(PCIDevice *dev, int region_num, } } -static PCIDevice *register_vf(PCIDevice *pf, int devfn, const char *name, - uint16_t vf_num) -{ - PCIDevice *dev = pci_new(devfn, name); - dev->exp.sriov_vf.pf = pf; - dev->exp.sriov_vf.vf_number = vf_num; - PCIBus *bus = pci_get_bus(pf); - Error *local_err = NULL; - - qdev_realize(&dev->qdev, &bus->qbus, &local_err); - if (local_err) { - error_report_err(local_err); - return NULL; - } - - /* set vid/did according to sr/iov spec - they are not used */ - pci_config_set_vendor_id(dev->config, 0xffff); - pci_config_set_device_id(dev->config, 0xffff); - - return dev; -} - static void register_vfs(PCIDevice *dev) { uint16_t num_vfs; uint16_t i; uint16_t sriov_cap = dev->exp.sriov_cap; - uint16_t vf_offset = - pci_get_word(dev->config + sriov_cap + PCI_SRIOV_VF_OFFSET); - uint16_t vf_stride = - pci_get_word(dev->config + sriov_cap + PCI_SRIOV_VF_STRIDE); - int32_t devfn = dev->devfn + vf_offset; assert(sriov_cap > 0); num_vfs = pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF); @@ -195,18 +196,10 @@ static void register_vfs(PCIDevice *dev) return; } - dev->exp.sriov_pf.vf = g_new(PCIDevice *, num_vfs); - trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), num_vfs); for (i = 0; i < num_vfs; i++) { - dev->exp.sriov_pf.vf[i] = register_vf(dev, devfn, - dev->exp.sriov_pf.vfname, i); - if (!dev->exp.sriov_pf.vf[i]) { - num_vfs = i; - break; - } - devfn += vf_stride; + pci_set_enabled(dev->exp.sriov_pf.vf[i], true); } dev->exp.sriov_pf.num_vfs = num_vfs; } @@ -219,12 +212,8 @@ static void unregister_vfs(PCIDevice *dev) trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn), num_vfs); for (i = 0; i < num_vfs; i++) { - PCIDevice *vf = dev->exp.sriov_pf.vf[i]; - object_unparent(OBJECT(vf)); - object_unref(OBJECT(vf)); + pci_set_enabled(dev->exp.sriov_pf.vf[i], false); } - g_free(dev->exp.sriov_pf.vf); - dev->exp.sriov_pf.vf = NULL; dev->exp.sriov_pf.num_vfs = 0; } @@ -246,14 +235,10 @@ void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, PCI_FUNC(dev->devfn), off, val, len); if (range_covers_byte(off, len, PCI_SRIOV_CTRL)) { - if (dev->exp.sriov_pf.num_vfs) { - if (!(val & PCI_SRIOV_CTRL_VFE)) { - unregister_vfs(dev); - } + if (val & PCI_SRIOV_CTRL_VFE) { + register_vfs(dev); } else { - if (val & PCI_SRIOV_CTRL_VFE) { - register_vfs(dev); - } + unregister_vfs(dev); } } } From patchwork Wed Jul 3 22:50:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723043 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44FEBC31D97 for ; Wed, 3 Jul 2024 22:53:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8oG-0006c9-1M; Wed, 03 Jul 2024 18:50:45 -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 1sP8oE-0006RN-Pk for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50: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 1sP8oA-0007ZL-66 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720047037; 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=fFIfkLYWXfsdkRs/ADDmSifhmh+YyxsrJ8fplItaj14=; b=a+dgtwMExna07Q+Yk2RQP6C11GLDuepbkYIlLcJz2Y4Gfm8FqE3XpxNrHDMAjSrPcNUe8B OX7fvQSE/+EhkLI42eSWayywO+/eiFf3pBtMogLWNIRE6L9QhBidKPDXDI/PU569FIZ9rF rKIPYtyRj4B1ZBbrNDeVIJmLnhRltxM= 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-576-wPaCuijON3SRSusQH0g80g-1; Wed, 03 Jul 2024 18:50:36 -0400 X-MC-Unique: wPaCuijON3SRSusQH0g80g-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-421179fd82bso13485e9.1 for ; Wed, 03 Jul 2024 15:50:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720047034; x=1720651834; 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=fFIfkLYWXfsdkRs/ADDmSifhmh+YyxsrJ8fplItaj14=; b=lKbFhRVbdBreI13OX91GxflR+GrvmsuwRDacpGIeARfe8YgeaiBbgn/J7BirSFO4+n SJqlrgwroXncBQwWlGBih4B2SYoyQbjNaXZ3bez8w4sUR0WP/S47A4NKCam6y4QZ+MX6 XKKv7C/aOPoDL0JBD5MG+NO1D08QgnOb5svcxhONkyOcMhxo/26IsBrhe29N+HUMtkBz YrjUW/t7+h/DefXtLyGQdjMtyhMQe4aUpoZTeYt3XRddH6Xno5kosE8ni/lsiD60FliW 4hSG/FdY6nceM86er0DX1vsqkmQO77tFptvjZXEc7v8T/lRssUzEIU+0RZC5xggcVgTf pOag== X-Gm-Message-State: AOJu0YyX3RD0HwRpyayk17gDeJaiqlNQm3HL5kKhphcYDD3/29E94VQH zkhzT1sjdChhn+ylluHCfbCviB1k9pHIXnUoryuQSi+hwZ47qInMbsF6Otw97M6F6V7tQ6T6vn/ 17/8A67xAFsholfDUuOHy8G7El5Z/vjijFR70pgygbD+hA+Rj/Vx3irjKHNOvTHuS+xrcdSV34e wmMF/xxKWINyq2gKx+gmjzaLQr2rymMA== X-Received: by 2002:a05:600c:4b95:b0:424:8ae8:d9fe with SMTP id 5b1f17b1804b1-4264a3d9714mr366415e9.6.1720047034720; Wed, 03 Jul 2024 15:50:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGN5JPfXc4OuhVvccE5GcBK3xl0DMhGcdDpFU/R0Nlctq5mW8jzjvAbxFdcynxz4GMitiowJw== X-Received: by 2002:a05:600c:4b95:b0:424:8ae8:d9fe with SMTP id 5b1f17b1804b1-4264a3d9714mr366315e9.6.1720047034135; Wed, 03 Jul 2024 15:50:34 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd784sm16993260f8f.7.2024.07.03.15.50.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:50:33 -0700 (PDT) Date: Wed, 3 Jul 2024 18:50:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL v3 82/85] pcie_sriov: Release VFs failed to realize Message-ID: <1a9bf009012e590cb166a4a9bae4bc18fb084d76.1720046570.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, T_SPF_TEMPERROR=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Akihiko Odaki Release VFs failed to realize just as we do in unregister_vfs(). Fixes: 7c0fa8dff811 ("pcie: Add support for Single Root I/O Virtualization (SR/IOV)") Signed-off-by: Akihiko Odaki Message-Id: <20240627-reuse-v10-7-7ca0b8ed3d9f@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pcie_sriov.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index faadb0d2ea..9bd7f8acc3 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -99,6 +99,8 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, vf->exp.sriov_vf.vf_number = i; if (!qdev_realize(&vf->qdev, bus, errp)) { + object_unparent(OBJECT(vf)); + object_unref(vf); unparent_vfs(dev, i); return false; } From patchwork Wed Jul 3 22:50:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C187EC2BD09 for ; Wed, 3 Jul 2024 22:52:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8oK-0007Ih-VJ; Wed, 03 Jul 2024 18:50:48 -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 1sP8oI-0006wL-6g for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:46 -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 1sP8oF-0007ZX-8j for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720047041; 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=7pMoBjPNl8oUEg5zlwInizxqA4Nbo5A/7NGMCDnRaVI=; b=IOSuWbW3mbJDoj6v7sUNXlBzEYJIFna9KEgVZlzJ/sKVRoYK4t0eDJS4u3uTIsRUhAJoCF zoz4zMtqGz7FOCzGw4Y+FrisLLscIysW4uSyJ6q7tc4eXpJbnR+8MyV3pq6dqqWomFEWB1 Iw8SxDNDs1kqO8DTk45L3JXPBq0T0l8= 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-635-IyYphl9GPjubaKIhGZqjeA-1; Wed, 03 Jul 2024 18:50:40 -0400 X-MC-Unique: IyYphl9GPjubaKIhGZqjeA-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-367990a5796so37940f8f.1 for ; Wed, 03 Jul 2024 15:50:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720047039; x=1720651839; 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=7pMoBjPNl8oUEg5zlwInizxqA4Nbo5A/7NGMCDnRaVI=; b=iIL+WhIRruEB7Dkm1bJONqfybBwCj8RbNsZ5FZ0nHCtfT5zwIvuNhdXq3Zo0W1F1H5 5cbTw39VRVl7ckjAuI2B6HkMjj8pscjVcMT0bBTHBVnxMuEg+ZlXT2DbDTI3ycLAF3Fh PbuuFAUSeUysEthClVNHRcwPxDSWkDyOQzkBcYJ0MYCLsnPo+FIx9drwvCLfkwDRqCeX 1UPnJSvVydDq4Hd/1GbPwqCDrNRO2gFaAkcU4R3mTJeoyCx9nc2JqD3rG8CQrQErnp9Z oA79kMuN9J94KXtPEXQsVuxT+1ooSnGwqSsdq/dFY7g4HKN526PD0gXvBKWJIxaai6DX d8iQ== X-Gm-Message-State: AOJu0YxjS3/eYbP+90pc22kUsu/sMWElZiyDwf7MB3vT9HAHbeK4WMp6 Ci8T0oejzBWL/9Zg4uHsYTZtGOUbBkW8i51SxtjNi92VhpW26a+kHc4bS40OhzmdbOPLZJWsnzI K5JJPv1wrWarr2h7HkMW3uN78TgqonrO+nZidtD8V0wSWqaszKWy6eXDubD1FRm0fcIkPYIm/YL xDgPiccWZtCR4zBA3/lrm+WSW3NuYkhw== X-Received: by 2002:adf:ab1c:0:b0:367:9791:f155 with SMTP id ffacd0b85a97d-3679dd55b9emr6329f8f.40.1720047038991; Wed, 03 Jul 2024 15:50:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEz+/O6OKa3U+zJ0ZaSq4rcJq6NDT/4RPPZrwaJI3pI8rH1AIPNCBLHN6KAQw3eHFMV+DDiPw== X-Received: by 2002:adf:ab1c:0:b0:367:9791:f155 with SMTP id ffacd0b85a97d-3679dd55b9emr6306f8f.40.1720047038120; Wed, 03 Jul 2024 15:50:38 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd6b4sm16822306f8f.17.2024.07.03.15.50.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:50:37 -0700 (PDT) Date: Wed, 3 Jul 2024 18:50:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL v3 83/85] pcie_sriov: Remove num_vfs from PCIESriovPF 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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Akihiko Odaki num_vfs is not migrated so use PCI_SRIOV_CTRL_VFE and PCI_SRIOV_NUM_VF instead. Signed-off-by: Akihiko Odaki Message-Id: <20240627-reuse-v10-8-7ca0b8ed3d9f@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pcie_sriov.h | 1 - hw/pci/pcie_sriov.c | 28 ++++++++++++++++++++-------- hw/pci/trace-events | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 70649236c1..5148c5b77d 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -16,7 +16,6 @@ #include "hw/pci/pci.h" typedef struct PCIESriovPF { - uint16_t num_vfs; /* Number of virtual functions created */ uint8_t vf_bar_type[PCI_NUM_REGIONS]; /* Store type for each VF bar */ PCIDevice **vf; /* Pointer to an array of num_vfs VF devices */ } PCIESriovPF; diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 9bd7f8acc3..fae6acea4a 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -57,7 +57,6 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, pcie_add_capability(dev, PCI_EXT_CAP_ID_SRIOV, 1, offset, PCI_EXT_CAP_SRIOV_SIZEOF); dev->exp.sriov_cap = offset; - dev->exp.sriov_pf.num_vfs = 0; dev->exp.sriov_pf.vf = NULL; pci_set_word(cfg + PCI_SRIOV_VF_OFFSET, vf_offset); @@ -186,6 +185,12 @@ void pcie_sriov_vf_register_bar(PCIDevice *dev, int region_num, } } +static void clear_ctrl_vfe(PCIDevice *dev) +{ + uint8_t *ctrl = dev->config + dev->exp.sriov_cap + PCI_SRIOV_CTRL; + pci_set_word(ctrl, pci_get_word(ctrl) & ~PCI_SRIOV_CTRL_VFE); +} + static void register_vfs(PCIDevice *dev) { uint16_t num_vfs; @@ -195,6 +200,7 @@ static void register_vfs(PCIDevice *dev) assert(sriov_cap > 0); num_vfs = pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF); if (num_vfs > pci_get_word(dev->config + sriov_cap + PCI_SRIOV_TOTAL_VF)) { + clear_ctrl_vfe(dev); return; } @@ -203,20 +209,18 @@ static void register_vfs(PCIDevice *dev) for (i = 0; i < num_vfs; i++) { pci_set_enabled(dev->exp.sriov_pf.vf[i], true); } - dev->exp.sriov_pf.num_vfs = num_vfs; } static void unregister_vfs(PCIDevice *dev) { - uint16_t num_vfs = dev->exp.sriov_pf.num_vfs; uint16_t i; + uint8_t *cfg = dev->config + dev->exp.sriov_cap; trace_sriov_unregister_vfs(dev->name, PCI_SLOT(dev->devfn), - PCI_FUNC(dev->devfn), num_vfs); - for (i = 0; i < num_vfs; i++) { + PCI_FUNC(dev->devfn)); + for (i = 0; i < pci_get_word(cfg + PCI_SRIOV_TOTAL_VF); i++) { pci_set_enabled(dev->exp.sriov_pf.vf[i], false); } - dev->exp.sriov_pf.num_vfs = 0; } void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, @@ -242,6 +246,9 @@ void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, } else { unregister_vfs(dev); } + } else if (range_covers_byte(off, len, PCI_SRIOV_NUM_VF)) { + clear_ctrl_vfe(dev); + unregister_vfs(dev); } } @@ -304,7 +311,7 @@ PCIDevice *pcie_sriov_get_pf(PCIDevice *dev) PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n) { assert(!pci_is_vf(dev)); - if (n < dev->exp.sriov_pf.num_vfs) { + if (n < pcie_sriov_num_vfs(dev)) { return dev->exp.sriov_pf.vf[n]; } return NULL; @@ -312,5 +319,10 @@ PCIDevice *pcie_sriov_get_vf_at_index(PCIDevice *dev, int n) uint16_t pcie_sriov_num_vfs(PCIDevice *dev) { - return dev->exp.sriov_pf.num_vfs; + uint16_t sriov_cap = dev->exp.sriov_cap; + uint8_t *cfg = dev->config + sriov_cap; + + return sriov_cap && + (pci_get_word(cfg + PCI_SRIOV_CTRL) & PCI_SRIOV_CTRL_VFE) ? + pci_get_word(cfg + PCI_SRIOV_NUM_VF) : 0; } diff --git a/hw/pci/trace-events b/hw/pci/trace-events index 19643aa8c6..e98f575a9d 100644 --- a/hw/pci/trace-events +++ b/hw/pci/trace-events @@ -14,7 +14,7 @@ msix_write_config(char *name, bool enabled, bool masked) "dev %s enabled %d mask # hw/pci/pcie_sriov.c sriov_register_vfs(const char *name, int slot, int function, int num_vfs) "%s %02x:%x: creating %d vf devs" -sriov_unregister_vfs(const char *name, int slot, int function, int num_vfs) "%s %02x:%x: Unregistering %d vf devs" +sriov_unregister_vfs(const char *name, int slot, int function) "%s %02x:%x: Unregistering vf devs" sriov_config_write(const char *name, int slot, int fun, uint32_t offset, uint32_t val, uint32_t len) "%s %02x:%x: sriov offset 0x%x val 0x%x len %d" # pcie.c From patchwork Wed Jul 3 22:50:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723034 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B2E8CC31D97 for ; Wed, 3 Jul 2024 22:52:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8oN-0007iA-W6; Wed, 03 Jul 2024 18:50:52 -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 1sP8oM-0007UP-7r for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:50 -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 1sP8oJ-0007a1-F9 for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720047045; 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=H7aKbBLrPfQyo8uVQsyzpZUHAgZT+25N0abSYuF1Pc4=; b=Pr+wNY/Npov9cDgCtEgot2nqs1BCakG25Z1sCIFD81i6UhxZUNWA8K6fsgBXXt/j+p5VNG Xh60CPYrzHl9hMq8+KYeLbJg/7VeOQ1Z2ML5PGcBntxlMfXmyaNcwbGWUSu5Qf+ViKKdVM d2PjFP3h77P3CjKNYTxWIc3tGAQ3A7c= 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-297-epLLlYnbMkSYBVL576DsIQ-1; Wed, 03 Jul 2024 18:50:44 -0400 X-MC-Unique: epLLlYnbMkSYBVL576DsIQ-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-367988464ceso40855f8f.2 for ; Wed, 03 Jul 2024 15:50:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720047042; x=1720651842; 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=H7aKbBLrPfQyo8uVQsyzpZUHAgZT+25N0abSYuF1Pc4=; b=mbQziGLCS8McYsdaVSdP1+gpDVbK5aITPhnQfenrD/dXU7NYAk3Lukje17t+4eB30L 22jENLmCG4E8L2ifUeqTKiPW9VVCmfttFYptvUHliyON4YlB7nY+UUAEbnDufoppW2RT OtOYgs9Rx1NvCX4ktMbamy4empySUypxI35YGA1h3Cp4ts2DYUo5y5rVonutmtxlIxKQ lrVtCSQSzFDyfnG2myOQVYniil1m8UXowt/7DVn8bR7D20zrbiC6JqJ7lPQmSkwdnMgO huQ4jQ0snEaJpfyj9Php0v3TtFyi00yMhgDEKekKkIFHYZbMhhzSaXu0eiWyZufC+jXK 4kOg== X-Gm-Message-State: AOJu0YxE/S6E9Q3tcmAFhixQI16XJCweVXJ1xrxkQ4a+JWGO68x/jrRy AWOKyz/EE2DJkM7wjywwS8kIOoDqRR8c/VOz+Jei0N+meLQx6ZGg0nXUHCnJ8vMDxBESWtk+ilY sc1naIl9Utrrw33Qurw4OrjWiwmf/nL3hUJOP8d1bbk6R67b+bLBC2OHghyV0rt7MLVq8240R7d c3hiaNWsOGkq58cnzEh9oM6R7oVARvvA== X-Received: by 2002:adf:f105:0:b0:367:4dc3:7943 with SMTP id ffacd0b85a97d-3679dd7e4demr4349f8f.71.1720047042323; Wed, 03 Jul 2024 15:50:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEu5Wrm8OprHgFlPV1jKUftykv1SlnbBuYekfIAVH8n62lAPpjkw8SVNEo1OXHM8hn/OV4F1g== X-Received: by 2002:adf:f105:0:b0:367:4dc3:7943 with SMTP id ffacd0b85a97d-3679dd7e4demr4336f8f.71.1720047041791; Wed, 03 Jul 2024 15:50:41 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36791d7a93bsm3000735f8f.81.2024.07.03.15.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:50:41 -0700 (PDT) Date: Wed, 3 Jul 2024 18:50:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Marcel Apfelbaum Subject: [PULL v3 84/85] pcie_sriov: Register VFs after migration Message-ID: <107a64b9a360cf5ca046852bc03334f7a9f22aef.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Akihiko Odaki pcie_sriov doesn't have code to restore its state after migration, but igb, which uses pcie_sriov, naively claimed its migration capability. Add code to register VFs after migration and fix igb migration. Fixes: 3a977deebe6b ("Intrdocue igb device emulation") Signed-off-by: Akihiko Odaki Message-Id: <20240627-reuse-v10-9-7ca0b8ed3d9f@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pcie_sriov.h | 2 ++ hw/pci/pci.c | 7 +++++++ hw/pci/pcie_sriov.c | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 5148c5b77d..c5d2d318d3 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -57,6 +57,8 @@ void pcie_sriov_pf_add_sup_pgsize(PCIDevice *dev, uint16_t opt_sup_pgsize); void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, uint32_t val, int len); +void pcie_sriov_pf_post_load(PCIDevice *dev); + /* Reset SR/IOV */ void pcie_sriov_pf_reset(PCIDevice *dev); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e32a69f3fa..fa85f87b1c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -733,10 +733,17 @@ static bool migrate_is_not_pcie(void *opaque, int version_id) return !pci_is_express((PCIDevice *)opaque); } +static int pci_post_load(void *opaque, int version_id) +{ + pcie_sriov_pf_post_load(opaque); + return 0; +} + const VMStateDescription vmstate_pci_device = { .name = "PCIDevice", .version_id = 2, .minimum_version_id = 1, + .post_load = pci_post_load, .fields = (const VMStateField[]) { VMSTATE_INT32_POSITIVE_LE(version_id, PCIDevice), VMSTATE_BUFFER_UNSAFE_INFO_TEST(config, PCIDevice, diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index fae6acea4a..56523ab4e8 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -252,6 +252,13 @@ void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, } } +void pcie_sriov_pf_post_load(PCIDevice *dev) +{ + if (dev->exp.sriov_cap) { + register_vfs(dev); + } +} + /* Reset SR/IOV */ void pcie_sriov_pf_reset(PCIDevice *dev) From patchwork Wed Jul 3 22:50:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 13723039 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C946CC31D97 for ; Wed, 3 Jul 2024 22:52:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sP8oR-00088t-18; Wed, 03 Jul 2024 18:50:55 -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 1sP8oP-0007sn-5J for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:53 -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 1sP8oN-0007aG-Ao for qemu-devel@nongnu.org; Wed, 03 Jul 2024 18:50:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1720047049; 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=bN0cTm8m+n/A4V5Tgbpm0TUAfWebEt6LcyWQbTcpz4g=; b=Eui+RqHgA0+BA8StBatp5vu1upqwU4ECUHdd1Y+hSk0AKYvga7GeSdkB4cYKKKOvxgxOLo R+5ZVnP6dUvYEHyEXJ8nvw1bhamFteiv2VAzxqw1t4pOcmsZNG8SHbhcJR952MOG0woVM0 rym91oxT+yyy/KaRN5RbSn5RPr8b4s4= 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-99-0aFcczPxOBumtE8voqanJw-1; Wed, 03 Jul 2024 18:50:48 -0400 X-MC-Unique: 0aFcczPxOBumtE8voqanJw-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4257c42f035so31563265e9.3 for ; Wed, 03 Jul 2024 15:50:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720047046; x=1720651846; 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=bN0cTm8m+n/A4V5Tgbpm0TUAfWebEt6LcyWQbTcpz4g=; b=YmxK1ChFTWiZXaSzcUKdkOQznq7LXh5San4VZpGKqakM4fs+Td2wPbCoEUSOL7crJW BM0916w4huw2OHlxk4WryQwS3UD11GRG3W3B8V8aQBh/sc7BjY58a7KBmA+2LDn5A4Vw wiSUfoUvmgiLX5cG3cr0run7x8j7R96PE2tRYoaFmo04sIbtLl9eREZcCB9a7Zsup9/e TbY6ZxYleb9lC46fWj46Z9AkzJ7XsZtgl8cZQlLMLCcuqhAK612yM2YJz4x/iN7SM1MI MZrG42OmIWK376ixGWrAbErxHPH9Wpp9AfJyjNcWUh9CjdMFdtOQ04b5JrzreQoF6g4x ArlA== X-Gm-Message-State: AOJu0YzW0AcIws4VBr5B1wB3UiY+YvNdQp6Qb9IQ1BoyRWsYOMgPK3kp EhintXVLgO62M3FMXnhbiyRoJ6hk+/wHReU502AF4JHg4VMb6ukhM1hz2Cn/rmVfIajr39zw4iJ IeuXtDLSvcEkaO+5Z0r/O9rnKFZPCfdMMCI6PZmShGaN6OA9RNLlKuKjm38DAYy+LMwRHMO+3Tf 6L2aBmXOOk4v7KPNlbZ7MSdJNA0pYYtA== X-Received: by 2002:a7b:cd95:0:b0:425:6dce:8c54 with SMTP id 5b1f17b1804b1-4264a48c4e0mr219965e9.33.1720047046520; Wed, 03 Jul 2024 15:50:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHOSRByIk9k3rv668VG4ZZgH3goxRYz4rLRrmCDty5VxwTtGnPAQNDI+3zjtturXDoaidQjDg== X-Received: by 2002:a7b:cd95:0:b0:425:6dce:8c54 with SMTP id 5b1f17b1804b1-4264a48c4e0mr219825e9.33.1720047046024; Wed, 03 Jul 2024 15:50:46 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:441:91a8:a47d:5a9:c02f:92f2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a0cd634sm17094726f8f.9.2024.07.03.15.50.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jul 2024 15:50:45 -0700 (PDT) Date: Wed, 3 Jul 2024 18:50:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Akihiko Odaki , Markus Armbruster , Marcel Apfelbaum , Stefano Stabellini , Anthony PERARD , Paul Durrant , xen-devel@lists.xenproject.org Subject: [PULL v3 85/85] hw/pci: Replace -1 with UINT32_MAX for romsize Message-ID: <6a67577d8003428bdbeba61d32a9f8158f12624b.1720046570.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 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Akihiko Odaki romsize is an uint32_t variable. Specifying -1 as an uint32_t value is obscure way to denote UINT32_MAX. Worse, if int is wider than 32-bit, it will change the behavior of a construct like the following: romsize = -1; if (romsize != -1) { ... } When -1 is assigned to romsize, -1 will be implicitly casted into uint32_t, resulting in UINT32_MAX. On contrary, when evaluating romsize != -1, romsize will be casted into int, and it will be a comparison of UINT32_MAX and -1, and result in false. Replace -1 with UINT32_MAX for statements involving the variable to clarify the intent and prevent potential breakage. Signed-off-by: Akihiko Odaki Reviewed-by: Markus Armbruster Message-Id: <20240627-reuse-v10-10-7ca0b8ed3d9f@daynix.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pci.c | 8 ++++---- hw/xen/xen_pt_load_rom.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index fa85f87b1c..4c7be52951 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -70,7 +70,7 @@ static bool pcie_has_upstream_port(PCIDevice *dev); static Property pci_props[] = { DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1), DEFINE_PROP_STRING("romfile", PCIDevice, romfile), - DEFINE_PROP_UINT32("romsize", PCIDevice, romsize, -1), + DEFINE_PROP_UINT32("romsize", PCIDevice, romsize, UINT32_MAX), DEFINE_PROP_UINT32("rombar", PCIDevice, rom_bar, 1), DEFINE_PROP_BIT("multifunction", PCIDevice, cap_present, QEMU_PCI_CAP_MULTIFUNCTION_BITNR, false), @@ -2073,7 +2073,7 @@ static void pci_qdev_realize(DeviceState *qdev, Error **errp) g_cmp_uint32, NULL); } - if (pci_dev->romsize != -1 && !is_power_of_2(pci_dev->romsize)) { + if (pci_dev->romsize != UINT32_MAX && !is_power_of_2(pci_dev->romsize)) { error_setg(errp, "ROM size %u is not a power of two", pci_dev->romsize); return; } @@ -2359,7 +2359,7 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom, return; } - if (load_file || pdev->romsize == -1) { + if (load_file || pdev->romsize == UINT32_MAX) { path = qemu_find_file(QEMU_FILE_TYPE_BIOS, pdev->romfile); if (path == NULL) { path = g_strdup(pdev->romfile); @@ -2378,7 +2378,7 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom, pdev->romfile); return; } - if (pdev->romsize != -1) { + if (pdev->romsize != UINT_MAX) { if (size > pdev->romsize) { error_setg(errp, "romfile \"%s\" (%u bytes) " "is too large for ROM size %u", diff --git a/hw/xen/xen_pt_load_rom.c b/hw/xen/xen_pt_load_rom.c index 03422a8a71..6bc64acd33 100644 --- a/hw/xen/xen_pt_load_rom.c +++ b/hw/xen/xen_pt_load_rom.c @@ -53,7 +53,7 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, } fseek(fp, 0, SEEK_SET); - if (dev->romsize != -1) { + if (dev->romsize != UINT_MAX) { if (st.st_size > dev->romsize) { error_report("ROM BAR \"%s\" (%ld bytes) is too large for ROM size %u", rom_file, (long) st.st_size, dev->romsize);