From patchwork Wed Sep 11 13:51:25 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: 1983998 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=hact8nxC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3jhH2wN6z1y1l for ; Thu, 12 Sep 2024 00:32:15 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOKF-0000p7-OY; Wed, 11 Sep 2024 10:28: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 1soOJR-00079d-Tr for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:27:27 -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 1soOJN-0003NJ-A1 for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:27:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726064832; 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=R5ePHMPfQwBzPpsGte/yR9q9ulk7hoKYYN7lCYMftAw=; b=hact8nxCQRbz/LW1pUfuNLnCNHF9q7LiOsihXR0nvrzY/Z408PCtPu0CQybB9TE45hxKaJ NUoTx6i+7SmLmSO8dR/0qV8g+edDBmK1krMe9bMcxEmZD/x+P1HpRAqDTKFa/QHMJaS5lg STXLN0UPv5sqhKECkCh1FMMsj8VfoOM= 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-316-BiHTkPcBPKySs71RUCzzFQ-1; Wed, 11 Sep 2024 09:51:32 -0400 X-MC-Unique: BiHTkPcBPKySs71RUCzzFQ-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a870f3a65a0so490938166b.0 for ; Wed, 11 Sep 2024 06:51:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062689; x=1726667489; 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=R5ePHMPfQwBzPpsGte/yR9q9ulk7hoKYYN7lCYMftAw=; b=sZOcBhElDOcYQociXdLEyLkJq8si2HMPuZf+B6Bsag9wFrMGYhJDKqDpvUe7INTi3Y O8dLBZtCLiDQl+ai/gGzmorI3j7QCasFWCb3I1a1kjdxg7eQ/N25mDQi6u2E48Y8wK/D +yGFbcc06wn7TorBCE+MRMLWN7f1AhgeDgwrhneO0QnVDrnuo9Rvgq5hzIaGmf3DMlvv r3TnZ9trUZ/aDJ/pxJRhBXimmdK1KDu7waMMrcOfXUcRbfKMofgcg+iLUjWeuSCXQfw9 mqBaEKE4NkTcZSaG7I4Hi+ZEmsEbX/J1/8Sb5nXPvlilFt9k6YMoJb+J7ZVqs+pSq7X2 NGQw== X-Gm-Message-State: AOJu0YzVjuha4S+PI/Ygj+4qAz46ho8NxdThQYQSAy54hyKKpbdT3kr3 uC7W9gCjA8nmr8l/ZD3soRiWDD//xZ3lsMGEiYSM1jv2Nn/ikUjw2GiNII+K+D7yI+mwwTT5vRA x6JIIjSVFzuCNJppKZ2pE4voeW3CJ1tfes+rtDxjjcqEy25cQI7MRNPULpCyUDstKigBKrPiFPn uZDmyVOvqG0kxSFEjNK+tc+dNZR25KnA== X-Received: by 2002:a17:907:9487:b0:a86:7924:11bd with SMTP id a640c23a62f3a-a8ffad9d1a8mr452160566b.41.1726062689271; Wed, 11 Sep 2024 06:51:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFY+bWB+IztdPuwAyYLrFzsLbCvl61KtjpyJeZQfkrPuLoif8uHr5PqRAsy2azdqO7WXIAXmA== X-Received: by 2002:a17:907:9487:b0:a86:7924:11bd with SMTP id a640c23a62f3a-a8ffad9d1a8mr452156966b.41.1726062688686; Wed, 11 Sep 2024 06:51:28 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25cec10asm613690266b.160.2024.09.11.06.51.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:51:28 -0700 (PDT) Date: Wed, 11 Sep 2024 09:51:25 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , Stefano Garzarella , Jason Wang , "Gonglei (Arei)" Subject: [PULL 01/18] virtio: Allow .get_vhost() without vhost_started Message-ID: <00adced5c3166ee65b6880b48c1e0826b7304f76.1726062663.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Hanna Czenczek Historically, .get_vhost() was probably only called when vdev->vhost_started is true. However, we now decidedly want to call it also when vhost_started is false, specifically so we can issue a reset to the vhost back-end while device operation is stopped. Some .get_vhost() implementations dereference some pointers (or return offsets from them) that are probably guaranteed to be non-NULL when vhost_started is true, but not necessarily otherwise. This patch makes all such implementations check all such pointers, returning NULL if any is NULL. Signed-off-by: Hanna Czenczek Message-Id: <20240723163941.48775-2-hreitz@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi --- include/hw/virtio/virtio.h | 1 + hw/display/vhost-user-gpu.c | 2 +- hw/net/virtio-net.c | 19 +++++++++++++++++-- hw/virtio/virtio-crypto.c | 18 +++++++++++++++--- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 0fcbc5c0c6..f526ecc8fc 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -223,6 +223,7 @@ struct VirtioDeviceClass { int (*post_load)(VirtIODevice *vdev); const VMStateDescription *vmsd; bool (*primary_unplug_pending)(void *opaque); + /* May be called even when vdev->vhost_started is false */ struct vhost_dev *(*get_vhost)(VirtIODevice *vdev); void (*toggle_device_iotlb)(VirtIODevice *vdev); }; diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index c0c66910f1..14548f1a57 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -642,7 +642,7 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error **errp) static struct vhost_dev *vhost_user_gpu_get_vhost(VirtIODevice *vdev) { VhostUserGPU *g = VHOST_USER_GPU(vdev); - return &g->vhost->dev; + return g->vhost ? &g->vhost->dev : NULL; } static Property vhost_user_gpu_properties[] = { diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index ed33a32877..fb84d142ee 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3896,8 +3896,23 @@ static bool dev_unplug_pending(void *opaque) static struct vhost_dev *virtio_net_get_vhost(VirtIODevice *vdev) { VirtIONet *n = VIRTIO_NET(vdev); - NetClientState *nc = qemu_get_queue(n->nic); - struct vhost_net *net = get_vhost_net(nc->peer); + NetClientState *nc; + struct vhost_net *net; + + if (!n->nic) { + return NULL; + } + + nc = qemu_get_queue(n->nic); + if (!nc) { + return NULL; + } + + net = get_vhost_net(nc->peer); + if (!net) { + return NULL; + } + return &net->dev; } diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 5034768bff..0793f56965 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -1247,9 +1247,21 @@ static bool virtio_crypto_guest_notifier_pending(VirtIODevice *vdev, int idx) static struct vhost_dev *virtio_crypto_get_vhost(VirtIODevice *vdev) { VirtIOCrypto *vcrypto = VIRTIO_CRYPTO(vdev); - CryptoDevBackend *b = vcrypto->cryptodev; - CryptoDevBackendClient *cc = b->conf.peers.ccs[0]; - CryptoDevBackendVhost *vhost_crypto = cryptodev_get_vhost(cc, b, 0); + CryptoDevBackend *b; + CryptoDevBackendClient *cc; + CryptoDevBackendVhost *vhost_crypto; + + b = vcrypto->cryptodev; + if (!b) { + return NULL; + } + + cc = b->conf.peers.ccs[0]; + vhost_crypto = cryptodev_get_vhost(cc, b, 0); + if (!vhost_crypto) { + return NULL; + } + return &vhost_crypto->dev; } From patchwork Wed Sep 11 13:51: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: 1984033 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QMF+C6SX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3kRZ5S25z1y1C for ; Thu, 12 Sep 2024 01:06:18 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOjN-000488-Kr; Wed, 11 Sep 2024 10:54: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 1soOiS-0001fb-G1 for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:53:13 -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 1soOiP-0007HI-Jt for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:53:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726066383; 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=H3/RbhQGQ6+o6xoRvkRMHa82wsOC3BKipqBPf5VTk9U=; b=QMF+C6SXSVE0pa9s6W1VyOtHDYEy/KPVtWBzqhdDV+1Bg3W5JbB/9zl7AhCmTO3aAxhGEN ojQrmZjntMkHCY45wy+D32Qe56QfrgorgxbFPJa40AZUJMT0DjqQwU8CRQURwpSQ/KHT7d IG7wXbDGe8jZKFEQAZychwYdn/u9EEE= 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-250-xX71cbeAMSaKl3xvr-KG7A-1; Wed, 11 Sep 2024 09:51:34 -0400 X-MC-Unique: xX71cbeAMSaKl3xvr-KG7A-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-536589936d3so1813392e87.0 for ; Wed, 11 Sep 2024 06:51:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062693; x=1726667493; 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=H3/RbhQGQ6+o6xoRvkRMHa82wsOC3BKipqBPf5VTk9U=; b=kNT1yLa5UkyETYzsCfAZiH2akdmB6GlxcZxOHvBlMwTzDuIIQB0guCy4be2J5ZvdcT yaLZcIQy/IZEFrptZi7CYiOvAxLElzRXtHLg+vIdNBpQE/a1PR1pI02GWzye0Da2kGjH fXzukTo9pJ3Vhs97edLavWjKBIKRzphSEKa6KRElDeLM4ZgcAu+ao8vfTVWSJnMhhniG ZExSroEnmKiv6vo7mjbHMuEIfTV0fJrD+HvqQV0i0QWapzmb7Bpa8NNE5ZQ613eJMiZU NA08VSTUUHZckv78S09UATUWy1hq0IdslPiqL75S9UaSzK/ohVSe/7n/guHQWaam66Lw pXRQ== X-Gm-Message-State: AOJu0YxKvpErl8AINKOpLYwnx6YDZ9TtQIUWrqX/D7ZSMCvAFjZwazYk T2HNnbL1+wW77PJwm8jv7DdJEIqHX2aswqfNMJOqODsA35QWwQyHTnEZbdiFc/qGhHBnlp3EXGR HmFHd0p760Lo4BFu6IvmfI7TPumectNK2NOREC9DINWdpwifQAr6Dt02phhhz+U/BTlmDW5N0Dh eG+eC9ddiNp0fdBjPwxvMA2nY17h8XWw== X-Received: by 2002:a05:6512:b1c:b0:52c:dfa2:5ac1 with SMTP id 2adb3069b0e04-53673b5fa9bmr1671326e87.24.1726062692846; Wed, 11 Sep 2024 06:51:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYvyO7rDO2vQrMeqXdTh83xQG9qGuW9kbCIlblfYqUWqLcu2QsOKRrsj/bTuarXyVcehKXBg== X-Received: by 2002:a05:6512:b1c:b0:52c:dfa2:5ac1 with SMTP id 2adb3069b0e04-53673b5fa9bmr1671271e87.24.1726062691756; Wed, 11 Sep 2024 06:51:31 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25835b0bsm625639466b.12.2024.09.11.06.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:51:31 -0700 (PDT) Date: Wed, 11 Sep 2024 09:51:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Hanna Czenczek , Stefan Hajnoczi Subject: [PULL 02/18] virtio: Always reset vhost devices Message-ID: <2688e8df60f5a655dc34c5e38523e425556f8483.1726062663.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Hanna Czenczek Requiring `vhost_started` to be true for resetting vhost devices in `virtio_reset()` seems like the wrong condition: Most importantly, the preceding `virtio_set_status(vdev, 0)` call will (for vhost devices) end up in `vhost_dev_stop()` (through vhost devices' `.set_status` implementations), setting `vdev->vhost_started = false`. Therefore, the gated `vhost_reset_device()` call is unreachable. `vhost_started` is not documented, so it is hard to say what exactly it is supposed to mean, but judging from the fact that `vhost_dev_start()` sets it and `vhost_dev_stop()` clears it, it seems like it indicates whether there is a vhost back-end, and whether that back-end is currently running and processing virtio requests. Making a reset conditional on whether the vhost back-end is processing virtio requests seems wrong; in fact, it is probably better to reset it only when it is not currently processing requests, which is exactly the current order of operations in `virtio_reset()`: First, the back-end is stopped through `virtio_set_status(vdev, 0)`, then we want to send a reset. Therefore, we should drop the `vhost_started` condition, but in its stead we then have to verify that we can indeed send a reset to this vhost device, by not just checking `k->get_vhost != NULL` (introduced by commit 95e1019a4a9), but also that the vhost back-end is connected (`hdev = k->get_vhost(); hdev != NULL && hdev->vhost_ops != NULL`). Reviewed-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Signed-off-by: Hanna Czenczek Message-Id: <20240723163941.48775-3-hreitz@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 9e10cbc058..42589adf2c 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2331,8 +2331,12 @@ void virtio_reset(void *opaque) vdev->device_endian = virtio_default_endian(); } - if (vdev->vhost_started && k->get_vhost) { - vhost_reset_device(k->get_vhost(vdev)); + if (k->get_vhost) { + struct vhost_dev *hdev = k->get_vhost(vdev); + /* Only reset when vhost back-end is connected */ + if (hdev && hdev->vhost_ops) { + vhost_reset_device(hdev); + } } if (k->reset) { From patchwork Wed Sep 11 13:51:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1984034 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UOzKZ/Lk; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3kRt2xCPz1y1C for ; Thu, 12 Sep 2024 01:06:34 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOmg-0001My-8V; Wed, 11 Sep 2024 10:57:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1soOhi-00070k-Be for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52: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 1soOhX-0007Dd-73 for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726066329; 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=cW6rJsKhPMN4DAXnpRk9aJejhnXYOKSdkgv1oLepLKc=; b=UOzKZ/LkrVY2P0xxqap6GqTzzhVJfUEyCR5O9WnyYM/hYdutN79nbugmOSRosPxLBPcdiJ 3aAY84fHcvs6idYVd+FJe2fgS4YMqoK1Oo90TD0WYRO1Yh4T6Lk+rvRixYSZqK6g71Mck1 Wzt4GJFe36rDGTw545bhb3q1w5KDauU= 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-550-uku9yfBzMNqmtwfAvz6AZA-1; Wed, 11 Sep 2024 09:51:37 -0400 X-MC-Unique: uku9yfBzMNqmtwfAvz6AZA-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5c25c45afb2so4829182a12.1 for ; Wed, 11 Sep 2024 06:51:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062695; x=1726667495; 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=cW6rJsKhPMN4DAXnpRk9aJejhnXYOKSdkgv1oLepLKc=; b=U6edi+VD2seSGOTusjonRapM/ryDqo+ePL252+7kyZh5am2rv9KY9asmiCIPswb4Yj n+9acIwUU2+7dna2CGRgUlYYqd0iDYEGIKnKd7PgvrPXM/OC2F74ea0ViWHUlqi2bBRx j2GNnlKT09IwrOqSGfYAndUqXYzKneqkGJESZEHpJaNATMHus7IvCb7/WHI6G8uj78zf RCEybm+g2+LrZbvpXtrYqTi7YeZkKR4FP65Nw/NO2GcXlQDLMQ5D6rQ0X68FTzC23Ldo QDeB9r1tcTl3KGwABkHnX2oGE2g49ivTzKtbxKoWfkiKcLQpiQKGOM4pE5+F40pcx95G XtzA== X-Gm-Message-State: AOJu0Ywhjg/IbJiikg4ThA+/m5Yttblo+beeTo5MeJtoEmyJReDiT1L9 lyEPGNku6A3pTGYmpsSwNjBXTp8M0pSg5gPHwsg+BKBw4Cnyw/W1C7kasvsN9bGoTtXBAdYgEt1 SYnBm7ZsA8LDs+jA2CY1PHzpC+zVD+AN+KSxukGSoQtkBXRENzHp6EbPVO8YIPBuFRrytP19Vuo 5HZNt/FPQBt7Oggh64v48RE0mDza777A== X-Received: by 2002:a17:907:7f10:b0:a8b:6ee7:ba25 with SMTP id a640c23a62f3a-a8ffadb0612mr405072366b.47.1726062695518; Wed, 11 Sep 2024 06:51:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlSiPBnTtHcvdwGtlu9vE+aMb07EQGcKjwLV6c8rHV3ngBWdOtgs2ai/xRWXpg0D8Crxxr8w== X-Received: by 2002:a17:907:7f10:b0:a8b:6ee7:ba25 with SMTP id a640c23a62f3a-a8ffadb0612mr405067566b.47.1726062694589; Wed, 11 Sep 2024 06:51:34 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d259c1fa3sm616631166b.80.2024.09.11.06.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:51:34 -0700 (PDT) Date: Wed, 11 Sep 2024 09:51:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , BALATON Zoltan Subject: [PULL 03/18] hw: Move declaration of IRQState to header and add init function 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: BALATON Zoltan To allow embedding a qemu_irq in a struct move its definition to the header and add a function to init it in place without allocating it. Signed-off-by: BALATON Zoltan Message-Id: Signed-off-by: BALATON Zoltan --- include/hw/irq.h | 18 ++++++++++++++++++ hw/core/irq.c | 25 +++++++++++-------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/include/hw/irq.h b/include/hw/irq.h index 645b73d251..c861c1debd 100644 --- a/include/hw/irq.h +++ b/include/hw/irq.h @@ -1,9 +1,20 @@ #ifndef QEMU_IRQ_H #define QEMU_IRQ_H +#include "qom/object.h" + /* Generic IRQ/GPIO pin infrastructure. */ #define TYPE_IRQ "irq" +OBJECT_DECLARE_SIMPLE_TYPE(IRQState, IRQ) + +struct IRQState { + Object parent_obj; + + qemu_irq_handler handler; + void *opaque; + int n; +}; void qemu_set_irq(qemu_irq irq, int level); @@ -23,6 +34,13 @@ static inline void qemu_irq_pulse(qemu_irq irq) qemu_set_irq(irq, 0); } +/* + * Init a single IRQ. The irq is assigned with a handler, an opaque data + * and the interrupt number. + */ +void qemu_init_irq(IRQState *irq, qemu_irq_handler handler, void *opaque, + int n); + /* Returns an array of N IRQs. Each IRQ is assigned the argument handler and * opaque data. */ diff --git a/hw/core/irq.c b/hw/core/irq.c index 3f14e2dda7..db95ffc18f 100644 --- a/hw/core/irq.c +++ b/hw/core/irq.c @@ -26,16 +26,6 @@ #include "hw/irq.h" #include "qom/object.h" -OBJECT_DECLARE_SIMPLE_TYPE(IRQState, IRQ) - -struct IRQState { - Object parent_obj; - - qemu_irq_handler handler; - void *opaque; - int n; -}; - void qemu_set_irq(qemu_irq irq, int level) { if (!irq) @@ -44,6 +34,15 @@ void qemu_set_irq(qemu_irq irq, int level) irq->handler(irq->opaque, irq->n, level); } +void qemu_init_irq(IRQState *irq, qemu_irq_handler handler, void *opaque, + int n) +{ + object_initialize(irq, sizeof(*irq), TYPE_IRQ); + irq->handler = handler; + irq->opaque = opaque; + irq->n = n; +} + qemu_irq *qemu_extend_irqs(qemu_irq *old, int n_old, qemu_irq_handler handler, void *opaque, int n) { @@ -69,10 +68,8 @@ qemu_irq qemu_allocate_irq(qemu_irq_handler handler, void *opaque, int n) { IRQState *irq; - irq = IRQ(object_new(TYPE_IRQ)); - irq->handler = handler; - irq->opaque = opaque; - irq->n = n; + irq = g_new(IRQState, 1); + qemu_init_irq(irq, handler, opaque, n); return irq; } From patchwork Wed Sep 11 13:51: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: 1984028 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iXgLLhbp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3kFT0PRXz1y21 for ; Thu, 12 Sep 2024 00:57:32 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOjv-00078Q-Mu; Wed, 11 Sep 2024 10:54: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 1soOhk-00079M-P3 for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52:27 -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 1soOhc-0007Dw-N9 for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726066332; 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=Hje9oGIw2otX3n3e6GR0YuFJNQxqhspv7J1M4mo3f28=; b=iXgLLhbpWthxegEe79bIE076DuOoVSiaWIJ62txPcBAK90mTl+aCUgEiqmnU+KJwmPhhMX bNPKmCznPjS5y1nv1/S5PD1Co1DThT02fJTVnw5JuKIwYXQd8LmU/U3NvNXe+Q1lgLEG2t cUEtIISt7Pik0cnZLY6APkPnDuMxzt0= 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-524-VH3gesR8PkCYoMjLDScvAw-1; Wed, 11 Sep 2024 09:51:40 -0400 X-MC-Unique: VH3gesR8PkCYoMjLDScvAw-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a8a877c1d22so330361966b.1 for ; Wed, 11 Sep 2024 06:51:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062698; x=1726667498; 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=Hje9oGIw2otX3n3e6GR0YuFJNQxqhspv7J1M4mo3f28=; b=SGUB0kLBwIocZ/v9yq5xJXf4XGzAMZu74r5STeebOySSnTGBZMhv6/nyl5CTgk6PE7 oGdTWh+PlTYT8maeUxrkOBgjZduXMveW2HhCP5xmcA332onxg3zLoDiBEzWyZG85WYg9 L/j+AVdpAROd3ikFJH6t49dHF//rMunqTrsUwfrEiMiPuMEf8iQo8xlRrKTkIWCZMKcE A0isqGjjSMJjjcEhiroShtOccqY7TUI8b4uq8DR38fb3Qbe/BaF0rUsHSbRFOiCtnD+y 0egNrQyFEqgzs6JoO9/v3V2xBClxoGMAM65zfl65lEVRnKB0QZWNGA8z7jKayjoKuctq mc4w== X-Gm-Message-State: AOJu0YwjVcjebpPGkLDmbbWNJPMJQXeR2Gakrynm3pH0T7VZQUUkV5q+ aBrrsQ/yOjQiYEcs02/f8MNAq9Oatg+z/b2UI6or0UQFT/5p18N09vQ0iuMXb9fLxkhJf/WhNOo V23D2kzsLh5BUPxzB2Ky3ovjGtNeeqZKjznlzTDPBBOzgdXtuHOGleARVH4PgqQtjG/HCRUH9Tn TbIDnjvfhj6Ud287gkK04DqSz/rh87PA== X-Received: by 2002:a17:907:6d0e:b0:a8a:835f:4cb9 with SMTP id a640c23a62f3a-a8ffadf04ffmr336003966b.46.1726062698536; Wed, 11 Sep 2024 06:51:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6bD5XcAmB/xGWz6Ei3wFwoAeoEQsyQsfXaF1vCQ+x21OsHGZC9dt/pUD5oEbtl1oNshF04w== X-Received: by 2002:a17:907:6d0e:b0:a8a:835f:4cb9 with SMTP id a640c23a62f3a-a8ffadf04ffmr336000366b.46.1726062698036; Wed, 11 Sep 2024 06:51:38 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25a073b1sm612326266b.82.2024.09.11.06.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:51:37 -0700 (PDT) Date: Wed, 11 Sep 2024 09:51:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , BALATON Zoltan , Philippe =?utf-8?q?Mathieu-Daud=C3=A9?= , Jiaxun Yang Subject: [PULL 04/18] hw/isa/vt82c686.c: Embed i8259 irq in device state instead of allocating Message-ID: <2225dc562a93dc191c3b2a43f273639bebad5d9a.1726062663.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: BALATON Zoltan To avoid a warning about unfreed qemu_irq embed the i8259 irq in the device state instead of allocating it. Signed-off-by: BALATON Zoltan Message-Id: Signed-off-by: BALATON Zoltan --- hw/isa/vt82c686.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 505b44c4e6..82591e3e07 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -592,6 +592,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(ViaISAState, VIA_ISA) struct ViaISAState { PCIDevice dev; + + IRQState i8259_irq; qemu_irq cpu_intr; qemu_irq *isa_irqs_in; uint16_t irq_state[ISA_NUM_IRQS]; @@ -715,13 +717,12 @@ static void via_isa_realize(PCIDevice *d, Error **errp) ViaISAState *s = VIA_ISA(d); DeviceState *dev = DEVICE(d); PCIBus *pci_bus = pci_get_bus(d); - qemu_irq *isa_irq; ISABus *isa_bus; int i; qdev_init_gpio_out_named(dev, &s->cpu_intr, "intr", 1); qdev_init_gpio_in_named(dev, via_isa_pirq, "pirq", PCI_NUM_PINS); - isa_irq = qemu_allocate_irqs(via_isa_request_i8259_irq, s, 1); + qemu_init_irq(&s->i8259_irq, via_isa_request_i8259_irq, s, 0); isa_bus = isa_bus_new(dev, pci_address_space(d), pci_address_space_io(d), errp); @@ -729,7 +730,7 @@ static void via_isa_realize(PCIDevice *d, Error **errp) return; } - s->isa_irqs_in = i8259_init(isa_bus, *isa_irq); + s->isa_irqs_in = i8259_init(isa_bus, &s->i8259_irq); isa_bus_register_input_irqs(isa_bus, s->isa_irqs_in); i8254_pit_init(isa_bus, 0x40, 0, NULL); i8257_dma_init(OBJECT(d), isa_bus, 0); From patchwork Wed Sep 11 13:51: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: 1984032 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LZzR9+bL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3kM40WgDz1y1l for ; Thu, 12 Sep 2024 01:02:24 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOkP-0000Jr-78; Wed, 11 Sep 2024 10:55: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 1soOhl-0007AC-09 for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52: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 1soOhe-0007Dm-T6 for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726066330; 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=rBqbG6UDFb2lXZqZscxyCV5To5/Zi8zm0XTznNZpuMA=; b=LZzR9+bLH/4pv3pqpi4CWl6IVdM5IGDOlldeBtnU7pekrvt8GhI3Mkrh2Q/vtCfUT1vt4F MyA+xjmRvT9020Q8m7SgCbMbvoAzHrEadMQyXdEwd7IbgMYa+81p8klYX3pHCV5ZxCDSEA 4NFsILYEly/wMeEpJ8yMe30dQPGF29s= 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-674-InaZLajGMWCDvGbR7dM2kA-1; Wed, 11 Sep 2024 09:51:43 -0400 X-MC-Unique: InaZLajGMWCDvGbR7dM2kA-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5c3ea11cabcso3033020a12.1 for ; Wed, 11 Sep 2024 06:51:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062702; x=1726667502; 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=rBqbG6UDFb2lXZqZscxyCV5To5/Zi8zm0XTznNZpuMA=; b=rL0E+1+KF94czu8X4phH5Pu3x3M2x1cLuCbS3rITki8ujKk+ekMXqXlVaXIfJs1cNs fqI3oUDWH+VptdLqA9ILCaF7h568aLOpdXoGzrDoTbZjZhx6QKSb5ZE0/aUwAZ/0FZ/+ 51Vv7wgZKJJv7+Ao0j4FzpJXp8aXJla1+yhR2x8KUVt7PGpwmZMzlP6HBnxbfYyatR65 n6V2kQyOHdKL/m8KtuS2D6+ltzDwmwW8914LY10DLjRKcURFCSmZZGfpvHUjaiNVcGAm GwLHJ2qpmaKvfsfinZMPX0rFAUVZxIzkWkBn5fYG5pS42PNbVjMGgyR7wP7lKEkhsTR5 DfKw== X-Gm-Message-State: AOJu0YzX9gWocVnBxDaN50H+UiPmeQCY5eMAU5bFn+G4j5UEj6UCjZka BpH6NXft3pXDUpjkVx4udUS8LREQphyYF/e4A8HfzA+CHT5ZHEStmPjfxaQuG+C3odZTaugXLbU BlBxZFI0LmRAUYTVCiMUUDvPJjzxOLwMf3ydGAI2nCqMSU4lA3aChmyOjrUfh6Xn8lx/iWRnHhe 6NEwILM6FF8yLlxz5ZE+X4lzQkG6bb8g== X-Received: by 2002:a05:6402:13cc:b0:5c2:68e9:8cf with SMTP id 4fb4d7f45d1cf-5c3dc7baefemr15736950a12.24.1726062702262; Wed, 11 Sep 2024 06:51:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrVtn1ykVlfRoVI4AyHGxcVezidGX8RW5X7BjjPMETGEVnKYajuEHMepFWgmtWmq8iKQ2t9g== X-Received: by 2002:a05:6402:13cc:b0:5c2:68e9:8cf with SMTP id 4fb4d7f45d1cf-5c3dc7baefemr15736913a12.24.1726062701706; Wed, 11 Sep 2024 06:51:41 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd467desm5376296a12.40.2024.09.11.06.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:51:41 -0700 (PDT) Date: Wed, 11 Sep 2024 09:51:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Dongli Zhang , Aswin Unnikrishnan , Marcel Apfelbaum Subject: [PULL 05/18] pci: don't skip function 0 occupancy verification for devfn auto assign 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Dongli Zhang When the devfn is already assigned in the command line, the do_pci_register_device() may verify if the function 0 is already occupied. However, when devfn < 0, the verification is skipped because it is part of the last "else if". For instance, suppose there is already a device at addr=00.00 of a port. -device pcie-root-port,bus=pcie.0,chassis=115,id=port01,addr=0e.00 \ -device virtio-net-pci,bus=port01,id=vnet01,addr=00.00 \ When 'addr' is specified for the 2nd device, the hotplug is denied. (qemu) device_add virtio-net-pci,bus=port01,id=vnet02,addr=01.00 Error: PCI: slot 0 function 0 already occupied by virtio-net-pci, new func virtio-net-pci cannot be exposed to guest. When 'addr' is automatically assigned, the hotplug is not denied. This is because the verification is skipped. (qemu) device_add virtio-net-pci,bus=port01,id=vnet02 warning: PCI: slot 1 is not valid for virtio-net-pci, parent device only allows plugging into slot 0. Fix the issue by moving the verification into an independent 'if' statement. Fixes: 3f1e1478db2d ("enable multi-function hot-add") Reported-by: Aswin Unnikrishnan Signed-off-by: Dongli Zhang Message-Id: <20240708041056.54504-1-dongli.zhang@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pci.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index d2caf3ee8b..87da35ca9b 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1181,14 +1181,15 @@ static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name, bus->devices[devfn]->qdev.id); return NULL; - } /* - * Populating function 0 triggers a scan from the guest that - * exposes other non-zero functions. Hence we need to ensure that - * function 0 wasn't added yet. - */ - else if (dev->hotplugged && - !pci_is_vf(pci_dev) && - pci_get_function_0(pci_dev)) { + } + + /* + * Populating function 0 triggers a scan from the guest that + * exposes other non-zero functions. Hence we need to ensure that + * function 0 wasn't added yet. + */ + if (dev->hotplugged && !pci_is_vf(pci_dev) && + pci_get_function_0(pci_dev)) { error_setg(errp, "PCI: slot %d function 0 already occupied by %s," " new func %s cannot be exposed to guest.", PCI_SLOT(pci_get_function_0(pci_dev)->devfn), From patchwork Wed Sep 11 13:51:41 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: 1983993 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=K4bUneE5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3jfq1PV9z1y1l for ; Thu, 12 Sep 2024 00:30:59 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOKD-0000Vd-7q; Wed, 11 Sep 2024 10:28: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 1soOJR-00079e-Ti for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:27:29 -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 1soOJO-0003NK-3q for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:27:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726064832; 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=iEUY6iNItmilx4GQ008agO3v3YGH5P6LxKz939t7m08=; b=K4bUneE59c19ooa5tkGnHmgw2y1zGKa6q6umzd/YW2L7qqaazPvTbwMD1AXdoSyRTnBFEG jlH0ZRMWv/QK2CpNugmNvrxhfHai7ev+MrVR+g4DECgF8+Vi3t17Fdk3IMpqgtGhLd9H6R mP1gKOVCpk2izKy3SJ0BG1xVqXK7GiE= 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-345-BgIOjzUWOwmXZs7R1SCXDA-1; Wed, 11 Sep 2024 09:51:47 -0400 X-MC-Unique: BgIOjzUWOwmXZs7R1SCXDA-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a870f3a65a0so490947966b.0 for ; Wed, 11 Sep 2024 06:51:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062705; x=1726667505; 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=iEUY6iNItmilx4GQ008agO3v3YGH5P6LxKz939t7m08=; b=tHxZcFXGiE7zWYXFZUFjCKqkzvDwoZeJhuJh3QXy51m0ysyfDV7SYPAJrK9AKh4Ae/ oS8mk0Dmd77cgcqcaaVAQqotkzqEnqc425yPCcV1ui1y4MXzeTCnYXpWj3f52i2RItJu IgYlAK0/6PCWx/1Ju8r4Y7GssDgF8A53MUKMOCaaRsHEGa9ol1mJzClhscAzy5/M3s+q 1pTTbzh7zv3b8OwM7+zn62AviZSU4w1g4D9N4It/OadbiFlofg2Ki/8Q7+AIM1sDfuak kzk4YaIyVkaW+MJbosN462ZCYracsnbSipJzJNI4E0CVwH7AXsEszZ0ukEvrhXnUHglf loWA== X-Gm-Message-State: AOJu0YyHv+kRkIJdNvB1CVapv4/zqeRYMxufEJTmCzuDGIqGgfMQNymu zlLDTEZrSbRskz84oxWrKPvKYljQ5yD9oM6i2Mp2c35JWZd1mVyopfvOunZyZCgc6YHX5sZywkQ a3Ww9lBRID8R9p9IGozyt/UkPDy/fi95oY0xL2hESehtg17nL7cuTNcm5YoYTy9YBwgxcjKjS1x YPuCpNO8NuLTEb7Cs/6K/s0j9+Azo2Eg== X-Received: by 2002:a17:906:794f:b0:a86:91c3:9517 with SMTP id a640c23a62f3a-a8ffab70902mr459445666b.35.1726062705417; Wed, 11 Sep 2024 06:51:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXPDKKnMF35RBQtFeyBFrrESbl4FumZQ7bj7lit8s9FtDwIrT3ZqdsFp8v83Z6DooXPauh/A== X-Received: by 2002:a17:906:794f:b0:a86:91c3:9517 with SMTP id a640c23a62f3a-a8ffab70902mr459442066b.35.1726062704829; Wed, 11 Sep 2024 06:51:44 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d2593dbb7sm616986366b.56.2024.09.11.06.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:51:44 -0700 (PDT) Date: Wed, 11 Sep 2024 09:51:41 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Philippe =?utf-8?q?Mathieu-Dau?= =?utf-8?q?d=C3=A9?= , Marcel Apfelbaum Subject: [PULL 06/18] hw/pci/pci-hmp-cmds: Avoid displaying bogus size in 'info pci' 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Philippe Mathieu-Daudé When BAR aren't mapped, we get: (qemu) info pci Bus 0, device 0, function 0: Host bridge: PCI device dead:beef ... BAR4: 32 bit memory at 0xffffffffffffffff [0x00000ffe]. BAR5: I/O at 0xffffffffffffffff [0x0ffe]. Check the BAR is mapped comparing its address to PCI_BAR_UNMAPPED which is what the PCI layer uses for unmapped BARs. See pci_bar_address and pci_update_mappings implementations and in "hw/pci/pci.h": typedef struct PCIIORegion { pcibus_t addr; /* current PCI mapping address. -1 means not mapped */ #define PCI_BAR_UNMAPPED (~(pcibus_t)0) ... This improves the logging, not displaying bogus sizes: (qemu) info pci Bus 0, device 0, function 0: Host bridge: PCI device dead:beef ... BAR4: 32 bit memory (not mapped) BAR5: I/O (not mapped) Remove trailing dot which is not used in other commands format. Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20240801131449.51328-1-philmd@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/pci/pci-hmp-cmds.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/hw/pci/pci-hmp-cmds.c b/hw/pci/pci-hmp-cmds.c index b09fce9377..fdfe44435c 100644 --- a/hw/pci/pci-hmp-cmds.c +++ b/hw/pci/pci-hmp-cmds.c @@ -83,15 +83,25 @@ static void hmp_info_pci_device(Monitor *mon, const PciDeviceInfo *dev) monitor_printf(mon, " BAR%" PRId64 ": ", region->value->bar); if (!strcmp(region->value->type, "io")) { - monitor_printf(mon, "I/O at 0x%04" PRIx64 - " [0x%04" PRIx64 "].\n", - addr, addr + size - 1); + if (addr != PCI_BAR_UNMAPPED) { + monitor_printf(mon, "I/O at 0x%04" PRIx64 + " [0x%04" PRIx64 "]\n", + addr, addr + size - 1); + } else { + monitor_printf(mon, "I/O (not mapped)\n"); + } } else { - monitor_printf(mon, "%d bit%s memory at 0x%08" PRIx64 - " [0x%08" PRIx64 "].\n", - region->value->mem_type_64 ? 64 : 32, - region->value->prefetch ? " prefetchable" : "", - addr, addr + size - 1); + if (addr != PCI_BAR_UNMAPPED) { + monitor_printf(mon, "%d bit%s memory at 0x%08" PRIx64 + " [0x%08" PRIx64 "]\n", + region->value->mem_type_64 ? 64 : 32, + region->value->prefetch ? " prefetchable" : "", + addr, addr + size - 1); + } else { + monitor_printf(mon, "%d bit%s memory (not mapped)\n", + region->value->mem_type_64 ? 64 : 32, + region->value->prefetch ? " prefetchable" : ""); + } } } From patchwork Wed Sep 11 13:51: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: 1984002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=IIPwhmyM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3jhV5rBrz1y1l for ; Thu, 12 Sep 2024 00:32:26 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOMQ-0003HC-0t; Wed, 11 Sep 2024 10:30: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 1soOMJ-0002mo-Mj for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:30:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1soOMH-0003z7-Id for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:30:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726065012; 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=9zYqBsPTLqrTzbWp9haBTVRFIhZalRfUREIb3ugShtk=; b=IIPwhmyMf1kwfeTvJpCfsdxz6ceQYAcGzlW0/nnblhtebE6IFN/GeXrXFmsMFj4vJl6CgQ JwwWpJGzCx8CfzVIeXvjEfoqtm9XlNonkLD4Y9hLbgWN+IaDn2FKMiLLgyehvuSUye0uAv gbT5H7uPQjRcZr/XnQEN4rQAf0so1lE= 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-164-S1qeoSNsPQmPUueHa0qQHw-1; Wed, 11 Sep 2024 09:51:50 -0400 X-MC-Unique: S1qeoSNsPQmPUueHa0qQHw-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a8a7463c3d0so428596866b.2 for ; Wed, 11 Sep 2024 06:51:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062708; x=1726667508; 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=9zYqBsPTLqrTzbWp9haBTVRFIhZalRfUREIb3ugShtk=; b=ZAcjcVjv0HJSfq8L3ZLj2Ph+Ui21QvtgxrfuNzGsVHQP2KdJNdsoNSuG7dRu0AbGjW xDiRcMFvZBATsE80q3mUqST3AhAwNRQzaEjbTzYKiLf/SOKyrypzX+2bXArwTgW5MV1t NqnDnV9JQ9XCGGvVnKnq8OPvwb2QLJN8K0Qz9AJisoDpEVe5a5pxELopKGp6XkEX6q2Y Pj/NYgNB5NjIg4HbmpTpZtPEUbhoNooXlPRsHzh92UIlZq/Ygne/4Ntr7SzYVe+dmqRo MPbZdx0/gMTQ0IHq/Lu5if4deg88fs6lgKhmC4QPUVFlaY2vrpDZiTTOyaALiqfWCR+h f3yA== X-Gm-Message-State: AOJu0Yzfyf41rM1mspZ1ygvtxa7xmM2MHYBbCByK35E/Bjwkzd8LyfJW 2u74smDqlByZIM4rF8+sHcsLG0dd5vZxhsav6TykOboY1QcJrdxYCzzWnrPqt76GsfTwZi8dNL7 tGfArLO4iJJUJqCUZ2kX57ZEde7ozVhKZh0jUbeEJFr7pSYYW8wAvbdiHf0PoePp545Kowztz24 doCPKd3dCExtzhAGSjeGyZ7xT4TvzooA== X-Received: by 2002:a17:907:3d8e:b0:a8d:4e13:55f9 with SMTP id a640c23a62f3a-a8ffaae3670mr459512166b.19.1726062708365; Wed, 11 Sep 2024 06:51:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXJxl0aTKQb2byWlm3XEdxeHepi5POGTMCrx84gqqyUSQ7HgXr1fjPY9AUOB0fBDYzlpIwmQ== X-Received: by 2002:a17:907:3d8e:b0:a8d:4e13:55f9 with SMTP id a640c23a62f3a-a8ffaae3670mr459508666b.19.1726062707830; Wed, 11 Sep 2024 06:51:47 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25c62541sm621866966b.111.2024.09.11.06.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:51:47 -0700 (PDT) Date: Wed, 11 Sep 2024 09:51:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Wenyu Huang Subject: [PULL 07/18] virtio: rename virtio_split_packed_update_used_idx 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Wenyu Huang virtio_split_packed_update_used_idx should be virtio_queue_split_update_used_idx like virtio_split_packed_update_used_idx. Signed-off-by: Wenyu Huang Message-Id: Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 42589adf2c..a26f18908e 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3669,7 +3669,7 @@ static void virtio_queue_packed_update_used_idx(VirtIODevice *vdev, int n) return; } -static void virtio_split_packed_update_used_idx(VirtIODevice *vdev, int n) +static void virtio_queue_split_update_used_idx(VirtIODevice *vdev, int n) { RCU_READ_LOCK_GUARD(); if (vdev->vq[n].vring.desc) { @@ -3682,7 +3682,7 @@ void virtio_queue_update_used_idx(VirtIODevice *vdev, int n) if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) { return virtio_queue_packed_update_used_idx(vdev, n); } else { - return virtio_split_packed_update_used_idx(vdev, n); + return virtio_queue_split_update_used_idx(vdev, n); } } From patchwork Wed Sep 11 13:51:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1984037 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=cZOl26mR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3kVF5nmdz1y1C for ; Thu, 12 Sep 2024 01:08:37 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOn7-0003ig-Ph; Wed, 11 Sep 2024 10:57: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 1soOhk-00078a-Ib for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52: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 1soOha-0007Dt-Sd for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726066332; 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=bY3kFhk2MQOhFrrXbGMngbSdwByo8f4uY8jy3ERVqew=; b=cZOl26mRMJ/eJnI/OdKQr8YFGRU5qnjDxfcT+ogVKaP8n49g7KY87qHCPmX1xUdZg/qZoq VB8Gx1bLhFl+p9sDGumKJIKmNkyd3QRi25OH7t0crXllFyWV11ZsMWjwpPOE80iDTFDPUH jG58bJvR4W5yoJk61kKdEm9S9dvVuBY= 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-412-0xm-B_Y7OL--D-ct_F0bXg-1; Wed, 11 Sep 2024 09:51:54 -0400 X-MC-Unique: 0xm-B_Y7OL--D-ct_F0bXg-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5c3c256e2a3so5362058a12.2 for ; Wed, 11 Sep 2024 06:51:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062712; x=1726667512; 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=bY3kFhk2MQOhFrrXbGMngbSdwByo8f4uY8jy3ERVqew=; b=LV4wkkVSb0zFluHNAqdsKi+C20owZuNSPTNQ1lOwXzxIIoW5kwuziqf5bePiK7j2Kq 5GgzQZr4zQxqqa4d6HSayU5DWWb0l8x15lVW1CvBDw4VZHrBv1ZI2OrIh1CZlLDkc3Q7 EICB+PzkrLt0LN0H9ggOo4zgVX50sfZddV1KHXQkXdkF2vNG8kG2PMM74sP3SU5Nwyum 26Uye73rt50oEXxdYdKlfJ9oY+mxfMKyBaKa05s6JtDfnr7+9WpiGMuDifPCZdQIZP0g sZldntAq431+uDy8+EMvvmbBpOFMxdL817fyHPoqns22958EPmltWF+L4gAEmu1puCsS zhQA== X-Gm-Message-State: AOJu0Yxi5QIl4oHEYG4SYqUBCRopbPgbqADNUlCjVDSvjNkwn3kzSzcy Nm7ssSuFdO7finMvAI6TEhvs3ck4R5o2RiGokLDQhDpizwnt50nL5hzh5+mOoJHG39lh1nXvuTY 2MAJTcqU1eWOcz5M38mZv8GDLAs79/98chx5q3IitlHiNTJdzDyjoho/u+HE3txKwb+K/dUPqwN djPBW7UYROUSAiDwBJjHmKwT2dKgS1KQ== X-Received: by 2002:a17:906:d54b:b0:a8c:d6a3:d03a with SMTP id a640c23a62f3a-a8ffab18781mr379087666b.21.1726062712056; Wed, 11 Sep 2024 06:51:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdUTOIul3p3RXD60SbSrV4T0ZNZ8f38tSJB3JJikoRHl9kx7775iRWvtWUySz6TnMaK7nc1Q== X-Received: by 2002:a17:906:d54b:b0:a8c:d6a3:d03a with SMTP id a640c23a62f3a-a8ffab18781mr379083266b.21.1726062711359; Wed, 11 Sep 2024 06:51:51 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d258354d1sm620068366b.13.2024.09.11.06.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:51:50 -0700 (PDT) Date: Wed, 11 Sep 2024 09:51:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhenzhong Duan , =?utf-8?q?Cl=C3=A9ment?= Mathieu--Drif , Yi Liu , Jason Wang , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 08/18] intel_iommu: Fix invalidation descriptor type field Message-ID: <663168943d3db6d9b51d3dfa0998848a6e6eda71.1726062663.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Zhenzhong Duan According to spec, invalidation descriptor type is 7bits which is concatenation of bits[11:9] and bits[3:0] of invalidation descriptor. Currently we only pick bits[3:0] as the invalidation type and treat bits[11:9] as reserved zero. This is not a problem for now as bits[11:9] is zero for all current invalidation types. But it will break if newer type occupies bits[11:9]. Fix it by taking bits[11:9] into type and make reserved bits check accurate. Suggested-by: Clément Mathieu--Drif Signed-off-by: Zhenzhong Duan Reviewed-by: Yi Liu Reviewed-by: Clément Mathieu--Drif Message-Id: <20240814071321.2621384-2-zhenzhong.duan@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 11 ++++++----- hw/i386/intel_iommu.c | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 5f32c36943..13d5d129ae 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -356,7 +356,8 @@ union VTDInvDesc { typedef union VTDInvDesc VTDInvDesc; /* Masks for struct VTDInvDesc */ -#define VTD_INV_DESC_TYPE 0xf +#define VTD_INV_DESC_TYPE(val) ((((val) >> 5) & 0x70ULL) | \ + ((val) & 0xfULL)) #define VTD_INV_DESC_CC 0x1 /* Context-cache Invalidate Desc */ #define VTD_INV_DESC_IOTLB 0x2 #define VTD_INV_DESC_DEVICE 0x3 @@ -372,7 +373,7 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_WAIT_IF (1ULL << 4) #define VTD_INV_DESC_WAIT_FN (1ULL << 6) #define VTD_INV_DESC_WAIT_DATA_SHIFT 32 -#define VTD_INV_DESC_WAIT_RSVD_LO 0Xffffff80ULL +#define VTD_INV_DESC_WAIT_RSVD_LO 0Xfffff180ULL #define VTD_INV_DESC_WAIT_RSVD_HI 3ULL /* Masks for Context-cache Invalidation Descriptor */ @@ -383,7 +384,7 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_CC_DID(val) (((val) >> 16) & VTD_DOMAIN_ID_MASK) #define VTD_INV_DESC_CC_SID(val) (((val) >> 32) & 0xffffUL) #define VTD_INV_DESC_CC_FM(val) (((val) >> 48) & 3UL) -#define VTD_INV_DESC_CC_RSVD 0xfffc00000000ffc0ULL +#define VTD_INV_DESC_CC_RSVD 0xfffc00000000f1c0ULL /* Masks for IOTLB Invalidate Descriptor */ #define VTD_INV_DESC_IOTLB_G (3ULL << 4) @@ -393,7 +394,7 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_IOTLB_DID(val) (((val) >> 16) & VTD_DOMAIN_ID_MASK) #define VTD_INV_DESC_IOTLB_ADDR(val) ((val) & ~0xfffULL) #define VTD_INV_DESC_IOTLB_AM(val) ((val) & 0x3fULL) -#define VTD_INV_DESC_IOTLB_RSVD_LO 0xffffffff0000ff00ULL +#define VTD_INV_DESC_IOTLB_RSVD_LO 0xffffffff0000f100ULL #define VTD_INV_DESC_IOTLB_RSVD_HI 0xf80ULL #define VTD_INV_DESC_IOTLB_PASID_PASID (2ULL << 4) #define VTD_INV_DESC_IOTLB_PASID_PAGE (3ULL << 4) @@ -406,7 +407,7 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_DEVICE_IOTLB_SIZE(val) ((val) & 0x1) #define VTD_INV_DESC_DEVICE_IOTLB_SID(val) (((val) >> 32) & 0xFFFFULL) #define VTD_INV_DESC_DEVICE_IOTLB_RSVD_HI 0xffeULL -#define VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO 0xffff0000ffe0fff8 +#define VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO 0xffff0000ffe0f1f0 /* Rsvd field masks for spte */ #define VTD_SPTE_SNP 0x800ULL diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 16d2885fcc..68cb72a481 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2744,7 +2744,7 @@ static bool vtd_process_inv_desc(IntelIOMMUState *s) return false; } - desc_type = inv_desc.lo & VTD_INV_DESC_TYPE; + desc_type = VTD_INV_DESC_TYPE(inv_desc.lo); /* FIXME: should update at first or at last? */ s->iq_last_desc_type = desc_type; From patchwork Wed Sep 11 13:51:51 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: 1984031 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=K5Xwx0Vy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3kKH0Y9hz1y1l for ; Thu, 12 Sep 2024 01:00:51 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOnZ-00066F-Ke; Wed, 11 Sep 2024 10:58: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 1soOhn-0007Kz-Sc for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52: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 1soOhi-0007EO-4A for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726066336; 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=3Zv+AcVES8CQaHrznfI8esSyWVUaPQBotZar40Wzxw0=; b=K5Xwx0VyTDzfewXyWrnj+5dPpjk0I8w65d4moWpE3UW8Vz31QxrxdfNGzdKege/393IQ/7 K9Apx9h/+VKfyzRNioBd48LJShneBouA2jSiznmD4EXsUYV+KZyaKFNINtkrTVPFKVNG/S LEGcb61N6B8hCoIuzfNFNkfsLoAJaNk= 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-617-L2d2ENr7OYmhmroUZu_fjw-1; Wed, 11 Sep 2024 09:51:56 -0400 X-MC-Unique: L2d2ENr7OYmhmroUZu_fjw-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a868b6d6882so96312266b.1 for ; Wed, 11 Sep 2024 06:51:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062715; x=1726667515; 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=3Zv+AcVES8CQaHrznfI8esSyWVUaPQBotZar40Wzxw0=; b=xQfMshW0+XC+exFHH4UuMgmDJ1G+xZUNj6iTKHFK2AM5GNMV4g/B00mPma9GeXLZkx yW/1xaYkXKO3kMOjZ4cYkUb+YLM8oUNek54LyhVGnrTO9rRu9tkY/22PR1tBTvv3TZO8 wLYs/fr/0usNEHx8MjO+ovIapVSkdRqehlO4nVGy/rnX09UIWEEA0YqfJ74ILmEXUwm9 GEGRt913ZNjyq5CP6KRIDQobo/mbZW4/HeGyML7Psb0LJUMc4PgtF0EedJKyUJFzcEGc 4r/0BETJ7fs42B/lFCWcUNG2grQHAHHF/zNPppL0lhx6y/J/PQoBe4F6Pt1NhAW/iOzx DpGA== X-Gm-Message-State: AOJu0Yysixc2YAmn+DPr6VPnLldPG5qTpwJMNmsG44w8ezxZb2y6zP67 OVDioBr3Bz6y/PSunsl7rwqflAv4Gblvm+npn8/84gFDd1wKx7BQmWLQdmyJjgp3Xdy3nJNfirc g39lZsPTJUUe5ld2jyf7cNyBkmMbaPjZEQBnmAVjKQklhaVRswphv1g0YwqfNcN+sxa2lZs1n1O phVxwYx7HUg7A8wBI705KfT8GRvUZI1w== X-Received: by 2002:a17:907:7f16:b0:a8a:6db7:6659 with SMTP id a640c23a62f3a-a8ffab6cbbfmr442551866b.9.1726062715335; Wed, 11 Sep 2024 06:51:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQ563Z43scq9UThhGmH4KPDKOFBk+Lb1vsH7g6KkuYMmRsuy+k/OUdBc9E6TCx/appZJrk3Q== X-Received: by 2002:a17:907:7f16:b0:a8a:6db7:6659 with SMTP id a640c23a62f3a-a8ffab6cbbfmr442545666b.9.1726062714737; Wed, 11 Sep 2024 06:51:54 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25c82eaesm619003566b.118.2024.09.11.06.51.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:51:54 -0700 (PDT) Date: Wed, 11 Sep 2024 09:51:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhenzhong Duan , Yi Liu , =?utf-8?q?Cl=C3=A9ment?= Mathieu--Drif , Jason Wang , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 09/18] intel_iommu: Make PASID-cache and PIOTLB type invalid in legacy mode Message-ID: <3b52cea829d873706ff86913ae99b4bd621c20e6.1726062663.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Zhenzhong Duan In vtd_process_inv_desc(), VTD_INV_DESC_PC and VTD_INV_DESC_PIOTLB are bypassed without scalable mode check. These two types are not valid in legacy mode and we should report error. Fixes: 4a4f219e8a10 ("intel_iommu: add scalable-mode option to make scalable mode work") Suggested-by: Yi Liu Signed-off-by: Zhenzhong Duan Reviewed-by: Clément Mathieu--Drif Reviewed-by: Yi Liu Message-Id: <20240814071321.2621384-3-zhenzhong.duan@intel.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 68cb72a481..90cd4e5044 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2763,17 +2763,6 @@ static bool vtd_process_inv_desc(IntelIOMMUState *s) } break; - /* - * TODO: the entity of below two cases will be implemented in future series. - * To make guest (which integrates scalable mode support patch set in - * iommu driver) work, just return true is enough so far. - */ - case VTD_INV_DESC_PC: - break; - - case VTD_INV_DESC_PIOTLB: - break; - case VTD_INV_DESC_WAIT: trace_vtd_inv_desc("wait", inv_desc.hi, inv_desc.lo); if (!vtd_process_wait_desc(s, &inv_desc)) { @@ -2795,6 +2784,17 @@ static bool vtd_process_inv_desc(IntelIOMMUState *s) } break; + /* + * TODO: the entity of below two cases will be implemented in future series. + * To make guest (which integrates scalable mode support patch set in + * iommu driver) work, just return true is enough so far. + */ + case VTD_INV_DESC_PC: + case VTD_INV_DESC_PIOTLB: + if (s->scalable_mode) { + break; + } + /* fallthrough */ default: error_report_once("%s: invalid inv desc: hi=%"PRIx64", lo=%"PRIx64 " (unknown type)", __func__, inv_desc.hi, From patchwork Wed Sep 11 13:51:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1984039 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BcxKmx2N; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3kVl6zLcz1y1C for ; Thu, 12 Sep 2024 01:09:03 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOoH-0000Oj-9w; Wed, 11 Sep 2024 10:59: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 1soOhn-0007KT-NZ for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52:30 -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 1soOhi-0007EU-Uv for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726066338; 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=8ycrQIYgW1gN05eLNxaUg6SdKNvOfcU2FQLbxdjG4Rw=; b=BcxKmx2N0Xbp0chQzZaHeaWPbpJqIxPpEvJsWxYX+qYx9xreD7KnndhcDa6pQu1XAg5beI HhwSbnoLAu0vwk6kNdsLd//+1Gf5xy26t59ezRlzqYCvCnmUjTDPlW3x4EPq2kvdzF4Blk wCJPsz8HrJW/UJuaKWCrjlWnHJj8v2g= 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-147-5mNS_49oPDCgvbWvTk6fXg-1; Wed, 11 Sep 2024 09:52:00 -0400 X-MC-Unique: 5mNS_49oPDCgvbWvTk6fXg-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-5c3c256e2a3so5362107a12.2 for ; Wed, 11 Sep 2024 06:52:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062719; x=1726667519; 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=8ycrQIYgW1gN05eLNxaUg6SdKNvOfcU2FQLbxdjG4Rw=; b=PZpqkqMvVyvRjbl/0ov+f7XZFWncAallft1XNd6a1nwsoH+EqBMPe3Q1xh1DApEyff XEbvmUGyU9VII9Cy2tb1m+EdRuCJe3I8GRxMj4oCOqNZKyqUTgxv2quncwJ+eI2MkB1U JKEE5Aq8jXJOAmpbSRQ/FvfKbZiUnORbFYq7J7TN7Endg1puTxHc3pFzbuMbrUOrPZ9z kB/FLwf+P0hEyA0ibknTWzd+6MSzYacVO3zjwb+iyMlWtsLUVGlRrYAE/H6AHzRvuaMh KWkk7rXNAVjNvEbodHso5ocwGGX+exUIyfkpVWL1fDOPHMz1jdYDqZ525spyn5OVQ1Pl OxIw== X-Gm-Message-State: AOJu0Yz+mB92nwhpP1/qKOWfiKHnZkEKIlaKRlcevhv8ihoEMIK4aFEj yaOitnpvxiHWvMpvPijuEfoNk83+yi+nNINTo07EBzCqd6n7q5RRXWe/4L4o2dikS39/m/ppfQh 9N+uXv1zNNeAIo+ohMZ1J4jP/hhPOED4xfOd6PsGd9wElT/eHOtd2dlVmE6Icx3C2O2nM1mzoiO HDSkogVK7Czy8v/raG6+gKfNJy2GBj5w== X-Received: by 2002:a05:6402:2551:b0:5c2:769a:df79 with SMTP id 4fb4d7f45d1cf-5c3dc7c6c83mr12618121a12.32.1726062718815; Wed, 11 Sep 2024 06:51:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGa1U2meNUnhGlkhb8QGTZBePl0Blwq+nl0sH21K51an8Q2T6CcuWRGWK3mDSR+gMZEoY/yrA== X-Received: by 2002:a05:6402:2551:b0:5c2:769a:df79 with SMTP id 4fb4d7f45d1cf-5c3dc7c6c83mr12618092a12.32.1726062718157; Wed, 11 Sep 2024 06:51:58 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd8cdebsm5375494a12.95.2024.09.11.06.51.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:51:57 -0700 (PDT) Date: Wed, 11 Sep 2024 09:51:55 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ricardo Ribalda , Igor Mammedov , Ani Sinha Subject: [PULL 10/18] tests/acpi: pc: allow DSDT acpi table changes 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Ricardo Ribalda Signed-off-by: Ricardo Ribalda Message-Id: <20240814115736.1580337-2-ribalda@chromium.org> Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios-tables-test-allowed-diff.h index dfb8523c8b..f81f4e2469 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,16 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/x86/pc/DSDT", +"tests/data/acpi/x86/pc/DSDT.acpierst", +"tests/data/acpi/x86/pc/DSDT.acpihmat", +"tests/data/acpi/x86/pc/DSDT.bridge", +"tests/data/acpi/x86/pc/DSDT.cphp", +"tests/data/acpi/x86/pc/DSDT.dimmpxm", +"tests/data/acpi/x86/pc/DSDT.hpbridge", +"tests/data/acpi/x86/pc/DSDT.hpbrroot", +"tests/data/acpi/x86/pc/DSDT.ipmikcs", +"tests/data/acpi/x86/pc/DSDT.memhp", +"tests/data/acpi/x86/pc/DSDT.nohpet", +"tests/data/acpi/x86/pc/DSDT.numamem", +"tests/data/acpi/x86/pc/DSDT.roothp", +"tests/data/acpi/x86/q35/DSDT.cxl", +"tests/data/acpi/x86/q35/DSDT.viot", From patchwork Wed Sep 11 13:51: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: 1984065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=AbnWMPuL; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3ksL4FXzz1y1S for ; Thu, 12 Sep 2024 01:25:10 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOlE-00043C-Kg; Wed, 11 Sep 2024 10:56: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 1soOhn-0007L8-U0 for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52: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 1soOhk-0007EZ-4b for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:52:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726066341; 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=21NUaZFIhKQyua/2/GS7TeIRDshB3RMyrgRirFWhK1A=; b=AbnWMPuLXPFNq6bNiaEZ2hIAf026U5DtimHGNHQ2YTZNIS/ADur7WbGQyH7RB3SsVCK9Vo 17OpJGyKensvSgFlRDVYVA5njXBKc/avh4/dMU8NPqm6S2XD9BJar8IX3s4D0WB+bDckup /jUxUWda9QwBSEfC3Gbh0MnqjXaDIe0= 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-581-oxgrtz_VOhSIef3AGv6bXg-1; Wed, 11 Sep 2024 09:52:04 -0400 X-MC-Unique: oxgrtz_VOhSIef3AGv6bXg-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-374c960ee7aso4965221f8f.3 for ; Wed, 11 Sep 2024 06:52:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062722; x=1726667522; 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=21NUaZFIhKQyua/2/GS7TeIRDshB3RMyrgRirFWhK1A=; b=Ir7FvGQvDvLpQEa478T4thqzNbmTr9zrUK9p0ybPJIC40ytDA6bIUHBMHpfGOQregM Yu8JLjy0ykarwD0oNJi4dtqHZrghg70XNhdNAEDUu+pdmQYDIare4L7gFBeJ1xka5KCx E0ncf8S83xaJzkv0V1oO+v1pRd2tUqyHlC10gif5az00QJRYDa71apPhQqjWTBkW8NvV ozd0E0EgKodvN/jALr2mpELKZ3RKEhhho3BlMePWIqRQInM/lLEqUNaPgbtTQ681keS9 DJ4pUNBltsblJ9yXl3DRhT8oamjCT7wqkb4OspAQqFdS15rg8Jgovl2AO/3BS67fvK1e bNEw== X-Gm-Message-State: AOJu0YxXFBsJkZq98bVhcwtdxn7phtqDh93VBXjCCXNXpc37wvl9GTY+ 7kvw87v1acIbuIw4pdW6j5NVdI/AQLZWS/oM6tvPEv1Fr3pf2oeQoT6oL+MVtVdmvJzTo4uiI9m dgtjmFVatP4NuocTDva85jPnuQ049Vs/6HNH30wJmIu40DC9pTtSJDo5YuZsMuFhur0I8kO80Ok tHadHI0EE6PhRHB0OcXDIQ3pxT/y80kQ== X-Received: by 2002:adf:fa0e:0:b0:374:c1c5:43ca with SMTP id ffacd0b85a97d-378922b76a7mr11326639f8f.32.1726062722297; Wed, 11 Sep 2024 06:52:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgJ9pcGrlZ32rWOY4HYbjerStdbxUQoPUG/5a/myHUXn/GwQj1W6gKLd0zWa/Et38nB572FA== X-Received: by 2002:adf:fa0e:0:b0:374:c1c5:43ca with SMTP id ffacd0b85a97d-378922b76a7mr11326597f8f.32.1726062721645; Wed, 11 Sep 2024 06:52:01 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d2598b85bsm613363966b.77.2024.09.11.06.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:52:00 -0700 (PDT) Date: Wed, 11 Sep 2024 09:51:58 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ricardo Ribalda , Igor Mammedov , Richard Henderson , Ani Sinha , Paolo Bonzini , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 11/18] hw/i386/acpi-build: Return a pre-computed _PRT table Message-ID: <99cb2c6c7b3674359c61a40fb17a75516b8e159d.1726062663.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Ricardo Ribalda When qemu runs without kvm acceleration the ACPI executions take a great amount of time. If they take more than the default time (30sec), the ACPI calls fail and the system might not behave correctly. Now the _PRT table is computed on the fly. We can drastically reduce the execution of the _PRT method if we return a pre-computed table. Without this patch: [ 51.343484] ACPI Error: Aborting method \_SB.PCI0._PRT due to previous error (AE_AML_LOOP_TIMEOUT) (20230628/psparse-529) [ 51.527032] ACPI Error: Method execution failed \_SB.PCI0._PRT due to previous error (AE_AML_LOOP_TIMEOUT) (20230628/uteval-68) [ 51.530049] virtio-pci 0000:00:02.0: can't derive routing for PCI INT A [ 51.530797] virtio-pci 0000:00:02.0: PCI INT A: no GSI [ 81.922901] ACPI Error: Aborting method \_SB.PCI0._PRT due to previous error (AE_AML_LOOP_TIMEOUT) (20230628/psparse-529) [ 82.103534] ACPI Error: Method execution failed \_SB.PCI0._PRT due to previous error (AE_AML_LOOP_TIMEOUT) (20230628/uteval-68) [ 82.106088] virtio-pci 0000:00:04.0: can't derive routing for PCI INT A [ 82.106761] virtio-pci 0000:00:04.0: PCI INT A: no GSI [ 112.192568] ACPI Error: Aborting method \_SB.PCI0._PRT due to previous error (AE_AML_LOOP_TIMEOUT) (20230628/psparse-529) [ 112.486687] ACPI Error: Method execution failed \_SB.PCI0._PRT due to previous error (AE_AML_LOOP_TIMEOUT) (20230628/uteval-68) [ 112.489554] virtio-pci 0000:00:05.0: can't derive routing for PCI INT A [ 112.490027] virtio-pci 0000:00:05.0: PCI INT A: no GSI [ 142.559448] ACPI Error: Aborting method \_SB.PCI0._PRT due to previous error (AE_AML_LOOP_TIMEOUT) (20230628/psparse-529) [ 142.718596] ACPI Error: Method execution failed \_SB.PCI0._PRT due to previous error (AE_AML_LOOP_TIMEOUT) (20230628/uteval-68) [ 142.722889] virtio-pci 0000:00:06.0: can't derive routing for PCI INT A [ 142.724578] virtio-pci 0000:00:06.0: PCI INT A: no GSI With this patch: [ 22.938076] ACPI: \_SB_.LNKB: Enabled at IRQ 10 [ 24.214002] ACPI: \_SB_.LNKD: Enabled at IRQ 11 [ 25.465170] ACPI: \_SB_.LNKA: Enabled at IRQ 10 [ 27.944920] ACPI: \_SB_.LNKC: Enabled at IRQ 11 ACPI disassembly: Scope (PCI0) { Method (_PRT, 0, NotSerialized) // _PRT: PCI Routing Table { Return (Package (0x80) { Package (0x04) { 0xFFFF, Zero, LNKD, Zero }, Package (0x04) { 0xFFFF, One, LNKA, Zero }, Package (0x04) { 0xFFFF, 0x02, LNKB, Zero }, Package (0x04) { 0xFFFF, 0x03, LNKC, Zero }, Package (0x04) { 0x0001FFFF, Zero, LNKS, Zero }, Context: https://lore.kernel.org/virtualization/20240417145544.38d7b482@imammedo.users.ipa.redhat.com/T/#t Signed-off-by: Ricardo Ribalda Reviewed-by: Igor Mammedov Reviewed-by: Richard Henderson Message-Id: <20240814115736.1580337-3-ribalda@chromium.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 118 ++++++++----------------------------------- 1 file changed, 21 insertions(+), 97 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 5d4bd2b710..4967aa7459 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -724,120 +724,44 @@ static Aml *aml_pci_pdsm(void) return method; } -/** - * build_prt_entry: - * @link_name: link name for PCI route entry - * - * build AML package containing a PCI route entry for @link_name - */ -static Aml *build_prt_entry(const char *link_name) -{ - Aml *a_zero = aml_int(0); - Aml *pkg = aml_package(4); - aml_append(pkg, a_zero); - aml_append(pkg, a_zero); - aml_append(pkg, aml_name("%s", link_name)); - aml_append(pkg, a_zero); - return pkg; -} - /* - * initialize_route - Initialize the interrupt routing rule - * through a specific LINK: - * if (lnk_idx == idx) - * route using link 'link_name' - */ -static Aml *initialize_route(Aml *route, const char *link_name, - Aml *lnk_idx, int idx) -{ - Aml *if_ctx = aml_if(aml_equal(lnk_idx, aml_int(idx))); - Aml *pkg = build_prt_entry(link_name); - - aml_append(if_ctx, aml_store(pkg, route)); - - return if_ctx; -} - -/* - * build_prt - Define interrupt rounting rules + * build_prt - Define interrupt routing rules * * Returns an array of 128 routes, one for each device, * based on device location. * The main goal is to equally distribute the interrupts * over the 4 existing ACPI links (works only for i440fx). - * The hash function is (slot + pin) & 3 -> "LNK[D|A|B|C]". + * The hash function is: (slot + pin) & 3 -> "LNK[D|A|B|C]". * */ static Aml *build_prt(bool is_pci0_prt) { - Aml *method, *while_ctx, *pin, *res; + const int nroutes = 128; + Aml *rt_pkg, *method; + int pin; method = aml_method("_PRT", 0, AML_NOTSERIALIZED); - res = aml_local(0); - pin = aml_local(1); - aml_append(method, aml_store(aml_package(128), res)); - aml_append(method, aml_store(aml_int(0), pin)); + rt_pkg = aml_varpackage(nroutes); - /* while (pin < 128) */ - while_ctx = aml_while(aml_lless(pin, aml_int(128))); - { - Aml *slot = aml_local(2); - Aml *lnk_idx = aml_local(3); - Aml *route = aml_local(4); + for (pin = 0; pin < nroutes; pin++) { + Aml *pkg = aml_package(4); + int slot = pin >> 2; - /* slot = pin >> 2 */ - aml_append(while_ctx, - aml_store(aml_shiftright(pin, aml_int(2), NULL), slot)); - /* lnk_idx = (slot + pin) & 3 */ - aml_append(while_ctx, - aml_store(aml_and(aml_add(pin, slot, NULL), aml_int(3), NULL), - lnk_idx)); - - /* route[2] = "LNK[D|A|B|C]", selection based on pin % 3 */ - aml_append(while_ctx, initialize_route(route, "LNKD", lnk_idx, 0)); - if (is_pci0_prt) { - Aml *if_device_1, *if_pin_4, *else_pin_4; - - /* device 1 is the power-management device, needs SCI */ - if_device_1 = aml_if(aml_equal(lnk_idx, aml_int(1))); - { - if_pin_4 = aml_if(aml_equal(pin, aml_int(4))); - { - aml_append(if_pin_4, - aml_store(build_prt_entry("LNKS"), route)); - } - aml_append(if_device_1, if_pin_4); - else_pin_4 = aml_else(); - { - aml_append(else_pin_4, - aml_store(build_prt_entry("LNKA"), route)); - } - aml_append(if_device_1, else_pin_4); - } - aml_append(while_ctx, if_device_1); + aml_append(pkg, aml_int((slot << 16) | 0xFFFF)); + aml_append(pkg, aml_int(pin & 3)); + /* device 1 is the power-management device, needs SCI */ + if (is_pci0_prt && pin == 4) { + aml_append(pkg, aml_name("%s", "LNKS")); } else { - aml_append(while_ctx, initialize_route(route, "LNKA", lnk_idx, 1)); + static const char link_name[][5] = {"LNKD", "LNKA", "LNKB", "LNKC"}; + int hash = (slot + pin) & 3; + aml_append(pkg, aml_name("%s", link_name[hash])); } - aml_append(while_ctx, initialize_route(route, "LNKB", lnk_idx, 2)); - aml_append(while_ctx, initialize_route(route, "LNKC", lnk_idx, 3)); - - /* route[0] = 0x[slot]FFFF */ - aml_append(while_ctx, - aml_store(aml_or(aml_shiftleft(slot, aml_int(16)), aml_int(0xFFFF), - NULL), - aml_index(route, aml_int(0)))); - /* route[1] = pin & 3 */ - aml_append(while_ctx, - aml_store(aml_and(pin, aml_int(3), NULL), - aml_index(route, aml_int(1)))); - /* res[pin] = route */ - aml_append(while_ctx, aml_store(route, aml_index(res, pin))); - /* pin++ */ - aml_append(while_ctx, aml_increment(pin)); + aml_append(pkg, aml_int(0)); + aml_append(rt_pkg, pkg); } - aml_append(method, while_ctx); - /* return res*/ - aml_append(method, aml_return(res)); + + aml_append(method, aml_return(rt_pkg)); return method; } From patchwork Wed Sep 11 13:52:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1984004 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=B+GidpO9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3jhc4X97z1y1l for ; Thu, 12 Sep 2024 00:32:32 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soONQ-0000ER-VT; Wed, 11 Sep 2024 10:31: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 1soON7-0007YX-EO for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:31: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 1soON3-00047N-Of for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:31:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726065060; 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=MWvinVVNh5bzHESG2Go2I3vqMmFKIn5JdAQAKvb4He4=; b=B+GidpO9I3A/N9TW1NzvHZKeOsdycInjbxUOT7RjFSzb2hp1/tGKL+2NIo9Jdg4vuIsANx wIF44Wf56Cal5HJuVAnUEwp9Qwd7dn/3bz9R9sKf1kTKeqmjfLp2iYs/yFCR+sGYN2/hZy SD5Jg/uqOGZGug6U5/hNBhKYeX5D0aM= 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-670-8lxJOfJCO1iE-lkZMGJNCA-1; Wed, 11 Sep 2024 09:52:08 -0400 X-MC-Unique: 8lxJOfJCO1iE-lkZMGJNCA-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5c40e867910so227840a12.2 for ; Wed, 11 Sep 2024 06:52:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062727; x=1726667527; 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=MWvinVVNh5bzHESG2Go2I3vqMmFKIn5JdAQAKvb4He4=; b=Yx+qLSYD+/Iq6KLeb3ph24Ohuxj3TMk9+AtNXRX+omEYvGjjTiG8cby+9DtqrkdZ+g i6Z/EdQylJ0kg+AiHPGVYNbEk47AOwb3kPa+SXDue7ZquGsvI4Z2Cxk2YXsj4zvRLZnk r4ZSMvflnsBRvPfop9yJf99v6K5IuPpYnOAS0ZTKMEQzqOhAyONafGT42hPjyjh7Gav1 Y9LOap2Gov6jM6eDuGhT3utRE2YkuZI1oql6Nn2p/sAno2w0CV7b+47q7CvdJ7Tn2Xx3 8znmkiY0YEB9dZXGQwilKM4/HguJHmYnjdX/BeqPV38KsrhM3DCU/QYTYwH7We2emdRP MH+A== X-Gm-Message-State: AOJu0YyauB9y2KeX2+S264l3bSMIrLrNbMmHF90kxonYau+cH/HsyKPT sAhprBA9dMRPDuAnBPFMQt46e8r8Gd0cYCnTZGZ8cKsnBkHQ7qGpoeGedLWNQ3HOWunnE9Y96r2 1vucv1eosAfIy27gv23vTCwsLbg5weImwaeRNY7PeiRkNl9C78XzF7jedqfHG0a2Pahmnn3XhyM LT/NuPKXoBoC1fazOHUY50R3X0s6uLKQ== X-Received: by 2002:a05:6402:34c3:b0:5c2:58fe:9304 with SMTP id 4fb4d7f45d1cf-5c3dc77b0a4mr18389128a12.1.1726062726202; Wed, 11 Sep 2024 06:52:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbF0tqpV83JVygqv7GTdJvqukQXRqCbIqG6bJ3IQnJGPxf1d8iuoEKKj54aizkOPuIHsfAqw== X-Received: by 2002:a05:6402:34c3:b0:5c2:58fe:9304 with SMTP id 4fb4d7f45d1cf-5c3dc77b0a4mr18389045a12.1.1726062725200; Wed, 11 Sep 2024 06:52:05 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd467a7sm5368254a12.28.2024.09.11.06.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:52:04 -0700 (PDT) Date: Wed, 11 Sep 2024 09:52:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ricardo Ribalda , Igor Mammedov , Ani Sinha Subject: [PULL 12/18] tests/acpi: pc: update golden masters for DSDT 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Ricardo Ribalda Signed-off-by: Ricardo Ribalda Message-Id: <20240814115736.1580337-4-ribalda@chromium.org> Acked-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 15 --------------- tests/data/acpi/x86/pc/DSDT | Bin 6830 -> 8527 bytes tests/data/acpi/x86/pc/DSDT.acpierst | Bin 6741 -> 8438 bytes tests/data/acpi/x86/pc/DSDT.acpihmat | Bin 8155 -> 9852 bytes tests/data/acpi/x86/pc/DSDT.bridge | Bin 13701 -> 15398 bytes tests/data/acpi/x86/pc/DSDT.cphp | Bin 7294 -> 8991 bytes tests/data/acpi/x86/pc/DSDT.dimmpxm | Bin 8484 -> 10181 bytes tests/data/acpi/x86/pc/DSDT.hpbridge | Bin 6781 -> 8478 bytes tests/data/acpi/x86/pc/DSDT.hpbrroot | Bin 3337 -> 5034 bytes tests/data/acpi/x86/pc/DSDT.ipmikcs | Bin 6902 -> 8599 bytes tests/data/acpi/x86/pc/DSDT.memhp | Bin 8189 -> 9886 bytes tests/data/acpi/x86/pc/DSDT.nohpet | Bin 6688 -> 8385 bytes tests/data/acpi/x86/pc/DSDT.numamem | Bin 6836 -> 8533 bytes tests/data/acpi/x86/pc/DSDT.roothp | Bin 10623 -> 12320 bytes tests/data/acpi/x86/q35/DSDT.cxl | Bin 9714 -> 13148 bytes tests/data/acpi/x86/q35/DSDT.viot | Bin 9464 -> 14615 bytes 16 files changed, 15 deletions(-) diff --git a/tests/data/acpi/x86/pc/DSDT b/tests/data/acpi/x86/pc/DSDT index c93ad6b7f83a168a1833d7dba1112dd2ab8a431f..92225236e717b2e522a2ee00492fb0ded418dc7b 100644 GIT binary patch delta 1914 zcmY+_OODep0DxgPNnd%jP12_CiUT0A;Q&p;V$`UN=xkV3oPpV!ldxiqgg66h&cP{+ zY{yalUETPX{l!W9^Znl{tnc;9$2UR@KK}~edh+S}<6b@H&Fk~!>0R;R_3`}aMf}K{ zui>{W3L>RMbGz2UejYTp>se&6{yy}Y+qH57zqws6B1?i;se#bVy&LJO5?N}mneO6- zQkb-ECwnHXx{*%ZT+gO;n|ii9w{v|{x-IyobW?p>p4-y5rCCMBN(Cl$TL?_*<_0!( z+YfB&mKmDTZD9!MkkTQcqZTUdEgL~PqI5**7}7DMV@k(8X{^))(1|W(C!J6_p>zuA z6w)cBQ%b{DYM~*Zp^)Zra0eAq8bKOC8c`Zi8bcbJ(j95shf1Z#{iip9G=VgsG@&$w zG=(&^rGusp+MfRm(ix;PN@tYLA)P}y?@N^)_Mr=1n)5er?E=yTr3*?kNHa(?N;4<5 ztK@*@Lh3i%-IbiuoYDf)0@8xgg3_fa-D|q+L#0|$x}XXxTxf z`Bf|_T|>HtbWQ1+(ha1WzEo`p-I!A9J(=_0Lb`=?OX-%<9i%%*cb(KgcZBYRZ2w-& v7WR&3@8YKQCul;%81oaj=^7L(1Z93hC)pF2U};b!Ak^BO@J!EO)E` z8Q_hhIHYHpz=)r`$a7P VSu!$E3k_1#Im4bk^4G2;e?PvR!t!3eyuDMZ_w#r7-qTM%9{2NOR=qx7o<8KCULVh&U(~Ox z`WAjqqaZRyRkv%Y?B`x}yPi}U*WZU;b-SM3z^`uCi%KU!Y)ntp&AlDf)mf#9y(Zno z4YiWAY$kh>p4(BKy1AZB%O>?~d1~hRQo1epQo5ibJ}V2`pD}1ksKa*IGw0GP_P8Zv9R^MC&L{dN;v;W{Q*1RR|$ZhmvgczF#x~ WkQE~XjnE)PQ!wn=qj+7c?eGW5el%79 diff --git a/tests/data/acpi/x86/pc/DSDT.acpihmat b/tests/data/acpi/x86/pc/DSDT.acpihmat index 9d3695ff289036856886a093733926667a32a058..73a9ce59e9426b180fea0ec5820c4841ebdb6700 100644 GIT binary patch delta 1914 zcmY+_OODzw0DxhWgjZfb62dFMuDeRTK?S6X5fK`d*`uDJv#jKvq^n+_>T!C4Zo3}I zmF+mnzr)18>@QB>&&RhWtnc;9w|7De%3tAoPd@#4+|Q4B^ZI;w`cQm&eLR1D5kK?h zYxq5jf=DUR+^)5-p9jtDdJs17FlYqneO6- zQkb-ECwnG6cO#v;xt>kyHuY?IYUlc8AR&Jhi27OS6iMl?qJiwh)-q%?)ho zwjbEkEi*Kw+rkjiA*Dk?M=ey^TQ-7pMCpjqF{EQi$CQqH(paeppc7rnPCB7-3G=?-br90BN50y%f`%iBIX##0NX+miV zX$om-O9xFIv_1bBq%%lol+GxfLpq0a-j^yp>_Zp2H0N*L+6ANwN*9!7kYM4bk#wn z`Bhv|x`uQO>6+3tr5i{$eW}_Ix-q5Hdot(0g>(z)meMVyJ4kns?mDS~?g*`fZ2w-& u7Ai<9N-IkDknSPfQ@XdMgC6?OFX{m4fzkt|M@Wy59w|LK>F>YZzv@4Lfz1m5 delta 204 zcmX}gy$XU*7zW_ipT#c%mByf@H3({t)S*x!(p`_|T)-h{D2W`U_0Vq74MaE5J#-h% zfzjglJm2U&qaY5F_W;md4;tyG#Wan*)DCIwFUP%r()A{RboDZmU^maYFe>GNk&avz zTb6?i@Y+@!(zQ$=T7>~bJycw)9mU9OJBGM+Tg@SAM{&~I@%}SWoQ$@72zlJ+WTVqG Ys01JjMg}UOL5eD4*s*)|JX@ds52i3S0{{R3 diff --git a/tests/data/acpi/x86/pc/DSDT.bridge b/tests/data/acpi/x86/pc/DSDT.bridge index 840b45f354ac14c858d0af8fbd31e97949a65d4b..4cef454e379e1009141694e0f4036a2a701c80d7 100644 GIT binary patch delta 1914 zcmY+_xsKC79DwnO?OZ-`*v@@*bStf>X_A;?6)Rei?IS7*O17XI8r}j?A$r79@f3sn zACKj)%f$0(=I61K@1K8v4U1dx^5&gVolk$l2Two!yx&guN%{JGetOK`zuuoeyr^GU z`6c|8MnPnZDzBG9+0UKwdO4~zuD%bw@_ISBfnQ!PXO$*FY)nU0&8-<#)k&ozdri8t z8)_wKQBU?HJvE~$b#pzN7Io^`@>tLHrF2{HrF2t$TORAux23G2V`BnI-4+5#-Q2*Y zZu@~v-7;M%-4?o#b}8)=+N+`3-m)H~JxY6&_95*<+NZSNlE%gi03B4NZlnWB2b2yW z9YQ*!bVzAfOD!}6G*nt12X{~*r4ghNq!FbNr7@(jl6+3tr5i{$kZu~OKsSVLm9GC@ wWD8qJx0G%v-9fs8bVupVmJYgaLqD25q5c|YF%2Z)!aP0Ui`Cgs-;0LeYG=KmA diff --git a/tests/data/acpi/x86/pc/DSDT.cphp b/tests/data/acpi/x86/pc/DSDT.cphp index dbc0141b2bbc77a6d806ff046dc137992c59a899..1dc928333d7ae7e4df6bb51d850af5e1cb480158 100644 GIT binary patch delta 1914 zcmY+_yROqP0DxgPNpHEeP0~wx%fO7p$l5j_9W|H%Q+->W+S0eBSw+T51txV{2u$kc1~zru z4{Yj|8Jf~Av(jlRv7Aoy68$mjvbVTVG(lMlCO2<8EtkeY1i7sU)olrWVbPDMd z(kZ1=O2bxap&_85kmhl42NhBpK^j3CQ5sPiLmHdX9ckQ$N~OpBr#FE#fi$5sp)`dw zg*3ILgQgDJp8pKe8Kg5xXOzw%okKeBOO+n>p$lD_^EYqp0@4Mg3raIcGe|Q^GbgpH zNniom7LO?(gM-~(t^^0(xoZgYr5=1rCL(Dq;v)83epv&D@xapu1)En>kcZ- zui~204Wt`LH!YQdJUKno{aLne*R5x`lL0>6X$Rq&rA=ozy^ggzklG|6a@% t_K@x=-BWsi^Z@CB(t|A>^w@`fR!2yWlpZOqAgv&+D6O3I_h0W@`5$`N%&PzZ delta 204 zcmX}gJqvEIjFA#mdj26e| zxzE2-Vj+vpeZbhhX=q*+lQ?u^$EUzsj=GHEU=u-g%xj{+pRQeSx~d~56RFB}JOx=0 zrK1H@$8G?twa*~Sffh#D)|?u3hmem}tr=w5)`HA>-2aTVAgeA9Qk@PdIcQcDatWx6 UlZ9LwP%=+A_WYH6Zg$c80pWTyqW}N^ diff --git a/tests/data/acpi/x86/pc/DSDT.dimmpxm b/tests/data/acpi/x86/pc/DSDT.dimmpxm index 1294f655d418dbdccc095e0d47ab220869a61a07..9f71d2e58b1707e733584e38dab7f73f9bda5eb7 100644 GIT binary patch delta 1914 zcmY+_OODzw0DxhWgjZfb65bG&T~+G7D?+*$5z$eZJ?a@cdw1JQbTt>KdWJbnPvOdT z9Od6(;$QX`C-7Fie+}z<{qp`nh{3Nv;YUwC{eIl5$GmxczC3*@zPvu3zrBdJy!jFS z%%UJtN;J1?E$rt(bGx2J7VGaruen_-H}IR=^&+w)h?N=$-Q2s8t}2nG_L}J~ZYYIG z>vpnd(yANj)Xnv5TDPfZ%X2%|H>KNxZ%Q}Sx8=DleOsDUWUN$RQn!V`q;76tQ@8!V zrf!*`Dcu%^kPayw5;|(3(%!NWq$5g4l#U@CLpr8(+>^#iO#q$fQg+e_r4vf0kWL|; zQaYtHY^4?&0vZZw9tU?&A*B(d5u_2N5v4Jtu_@h=#(k(%dfb0{6G#(C6G{_GQ%F-t zQ(HP{>Y(lU&mf&aI-_((=^WBIr1QR1>0uwb(4{$l^VTjPT~NB9G=nsQG@~?gQoBkH zXfC9F!`)rUDa|P@AT1y*C@m;mn$o?d%RW@9C8bMBSCFnCT~WHCbPeg+ln%P?pwj#* zt|{F>x`A{<>4wrRq}#q!Z3*3)QtCaK^WQ_fk+64H{=lF}2TCrD3}o}BdWKksw-AM!HHs{jB1 delta 204 zcmX}gy$XU*7zW_ipT#c%mF6I54T73#N*xNLB;ECR&IKHThLXrpS`Y0O-avE>U6;|~ z_&ncz<53U?$#?{4i#JX5+j^eHUTTLF`J3q=pfoxpkgi^4671z!4@RZDFw&9B;>dE4 z0bbjRL%Nm;Y0+EJYJZoL1@6epuAA3|QwIoas7Eh+)X Vf{}qrXpo}H7*4FoK6h(5`~hC_Got_i diff --git a/tests/data/acpi/x86/pc/DSDT.hpbridge b/tests/data/acpi/x86/pc/DSDT.hpbridge index 8012b5eb3155377dc7995b73059ecb267d19232c..db420593a3c51eced25cd57420353fbb9ccdf63c 100644 GIT binary patch delta 1914 zcmY+_OODzw0DxhWgjZfb5(sb9161mw7a*jI5fK`d*`uDJvv)7hUDvbf1*)E^hp0TV z9Y^_hnE03d#R>fX{8okay?!}<5MuE2Px#T3Pj8QV^_VxW&zGl9#h2H|^Vb*gJ8!;+ zKe8x@loHMDS_}Jm(A=(Pk;VG^&}(kj$_@PHcD;x!31X!NLO1trq^n9~sl8^piyKN| z(z>1OnY8LgI(2hBo7QdW+49`Z^-bxv;G5D-^=)}>OW&4e6&WiPnAB|{FsYjx*wk%5 zu&G;SXiB$*A*4e}hlGw=sI<3i1nG#<5v5~D$B>RG9rvWMQWHQYx|E%CLg|FkDWp?K zr<6`94O^*&hJc1bn#aK%R7hzAX#{CRX+&uZX>3Y&q;VfAl^*w>-UQMF(uC54(iGAZ z($tm?nmTBE{xe8tkj^NbQ96fo4(YrvReIQmE_7+m-@LU8NEehYD9s?vAk8SvoYbz8 z1DXq|-*9(Va!PYb3rGt{3rY)0m!@>D>9P-%YDwvm(iNmDNLQ4uC@mo^P3fRz2bJbm zv7~ej=^D~CrE5wzkZ$@?wIOt4N~!l`&VLK(7Sb)HTS|A3?jYTDQUl!)x)-wjdof$s tL%OGQPw4^D1EdE^54LpBV;}lW9U(nZdZhFO=?T&kr6(u-`_KDTz5}&$%xeGu delta 204 zcmX}gy$XU*7zW_ipT#c%l^|$t4T9VwbtsIGbl2lK7jOs~N+d^VJ++2KHxON46fKU= zbMrqQg-MuJBS4$KXriB%UY7Wo9Z?*trh|~Oc$-4HdYwzKhi_dO)$+(lMsXV3h7wl2dTv#B&= diff --git a/tests/data/acpi/x86/pc/DSDT.hpbrroot b/tests/data/acpi/x86/pc/DSDT.hpbrroot index 4fa0c6fe720f7859f0541b82f828c0329a3c0548..31b6adb4eb941e5bf0c02ec8c3819c9213adf022 100644 GIT binary patch delta 1913 zcmY+_yN=pG7(n3xo11TdZEogPrp+q=PO-v5tFS%F1Ek8f(WFh8K1!8p+q_WTWLEyi zWBGIpo}-!1W5dtl?L$!B%a^xIsowWr!GHbq=W#zjX4UKS<>_Po>Gkpa`9=NBs&B!M zH1tDbRCT+S%6{%ux9drzQT=_;uWr|~8+g_2dQoZYN5=G2-Q3$zU7b~$*lW^V+)yh? z%Vu(4(sMhiQ#ZG7)3QnXwmda+Jt^H5JSp8&&z7gA^lT}s=*SpfQnv+PQa9JPsoTD9 zQ@6}OO1FgpqytI^gbo|1wzq5u>5$SPr6Wj3kd7!Fb)=CoV?f7ssaxro(lMnINGFg^ zD4kFmG*Sx<01cFu$H5&`KxqhR2x&-ZNNEIVB&9pjs0-Dm9(SMK7}6Nhn9`Wi1kwc3 z#Fh@4IB0YJQ%I+fPAQ#II)iiu>8vX?^{@+_*QK1lytQ*k=akMVO(9JoO({*C)UJ{N znkiks;qIy6H;IhR}_ay55tVe*tL$X+dd0=@!y0q}x_1&@G`mrJKJO*}@Le r9i=-;_mJ)(-BY@^rGp;2&@biy>4DM%rAJ7QkRB;LI_baPy|3XrepAd$ delta 203 zcmX}gF$;n~7zW^1ZOBgom8RyPErMDbGKZpwNOwK&*5C*lN+L%a<7mI4skJ}UKPg&n ze4bbD(xEtsQ?~_J{VRRWvr(2rnZKa*bUtXul&v=@WN25p1bam8jZr0!jBFIL+_3`W zfNNiI$k1&7%he)=&|SqX9VkW((+R}AWi)}%f#PJFiT*QGoE%eA2zfdb`~9q*}J!xU01z8)wA>vy+F4f z#m*n)+hO8Q_AgH0|L3=JSlz0Zw+~A7{{9X>div?-{dT%f>(}S=)2HIg>;3ubi~5z< z-@_kS6hy|T`g*C9``oLqm!rz!=KIjAua}by{Q7!1t1Jm(V|uD-ZjVt@om7^(YqmSf zP%E2O?PSlUr^l#CWv=Jas!cst9^1LTEoBS7EoG|j%41vluC%M@*qFekvW38=GB800&{0$Bhjc{gh|)2n zV@Su8jwuaWse^`qhDzJVK@KXUG=emOG@>-3G=?;`r5tJ8g=*7`yH9TdX##0NX+miV zX$ooTN`a;VZO?xK=>*aVr4vf0kWL|;cBQ5ncA>MTwC8W%+8LxXN@tX2kYp(Qo5yd2k8#d9i=;03UuFvelvSW_mu7_JwSSZ^g!uBq<{W-N%;=-%*>hq delta 204 zcmX}gy$XU*7zW_ipT#c(m4;|;4T9Y)&M8d7^g9H!%bUjfc{$4xKXW3AgVm%TQWkGhNKdbF3HJ1@8>31d8R;lwxnl*$ z0B;<{AwA0k)|)7VXhw=_jjI@$T_+F^yVC-qaTO=M8~;C3#mVR@fRLv{K@NIti&_A( UWMrTg8lLDsuw&N)O z4io>fzc_(^pPygD>R!D)KL|0Xe}^AE`SN_+FOPZi{(61+RD5}VyncHVzw+is_%n-w zNGZ|W>PpzpgXUJBMHcJtL$A5j7dP;mTYVK-62wXkgl_KLNLLq;rS_WXu5KuWNvn3U zXVObI(y5#4*|cg?&z9$Qu5U`W1>clzs&C74Tl%&%tH@ZXz@%;qfl1xmz@~2dflb{q zLsPmf3?Us-IwW+|LZ!WBBS=S-jwl^NI)-#i>9{A2m6`xL(WUI96G|tPP9dE_I;C_< zY1m3FGz2sh(mW3Cph8L`NFzuiN+U{RNMlpFBaQn|sr0!2^d^udkS3HSl%|lTkfyeD z(9}WO^PfRFgLFpejM6!zb4cfXsnWwfbfHUg{^qS+K)RrGL1_kQ25ClV=A?F&9MD`y z{f4`{l2e*fT0mMrT2NY0x-_MGO_zPBR7*;il&&CMLAs)JMd=#SwJ9BR-9e@KRa{fL zfpi1uhSCkCTS&KksoD~{HKo*hGUva8bO-5<(jBFHNcWKLJE?*02|Wne{=Jwj93VYV pdZ4s~w1l*zw6vvz9{bSm>ImtP(j%oONKcTSC_OpppTAyF{s&CX%t`dVRh;eayeSKAyk6sNY%j zJ^YbIL1c`oZr4(|&%Nq)J*hOVzYo3Yc0J3$uWr|iN|PWqrl;!W-j3?(tkQ|QX1j|F zwX$j1O!jPgZbx-0b3K=qP3pPw)Xep5DO>PuDN}t{o|@8krCmkG#soH%Ed(}|xq(Y% z`+-YknZ7M$3w=oYl=cZ7G*Ins*#Oc3r2|TbkPaaoQabENV`D~uj_Ojk(h;R2O2?3n zAstgXrZjA%4jKX)Ds3MJIjE4*2+|1Bh|-AC7}D65a-?w=s!cuaKD`N~38V?738fQA zCy-8DDbR^PoAaMSI)!vf>6FqLq%%loU8$*uUFf_n?fKicb`I&B(mACmq$#8+rKw2W zDjA@e()AlIcO|1Vqcn#!hcu@&r*vUUc}*8xs5T2q7nCj`T|&B~bV+FeX<I=O3j+kwJmkMCwu-INH>sfDBV!Hg>(z)wv}4wme8Hj&EJdN u!Vc0Mr8`RZknSPfQ@VGhKo4E$H*a)`{F0!Nu=Cqp32CbBe)jEfY*tt~T_r$+)I;%Y=hDsea zyaKrpCeQ*Z@;zX&oTrecr-fre&B?Q!LEf5HV@MNfLCj9_pP?4y+L}PBKlA2W z_&tk)NGZ|WuC=hA2hHtz7Fn#n554Agt=zzGZr6**k|0)UAarx@M!Kp*mfCBkySSkg zCav4ao=K~2q*FK7vuWL?o-NPqT;G%)7cRNt28w)AajR*|t%fl1vK0+YJAflb}^ z1Dm>KhNg5|7(zOvbV%r^g-UzNMv#su9Z@=lbPVa3(s553D>VUhqD$FHCzMVookBW= zbV})z(y*0UXb5O1qwORU1M#rj&Y5=KQyiZXw-Lx}|gn=?>CeCpFL=p?e|QzZbKG tJ*0a|_mmzWJwSS(^k7Q|J@%nr)e+JorAJCnke(ntQF?OH-*4XE@;}cy%sv1B delta 204 zcmX}gy$XU*7zW_ipT#c%l^|$t4T9F32XiM+%PY2z=)y?~On$v=T*7)EUv!~z3Os4%D}HK=ab5kAU39>>gIYM)zwjDsk>&olMJ=8 zY1vHnYQv@>E-jnXbLF9#>)TSc;M-EB`mQ`QrSD3+ijIv5Y${s_Y$|gDm&*17 zm&!6-Tgn!?kaj8U654B^+TF4qq&-S|l=dO*L)xdb-;&103;-R}rM^oClny8zLOO(W zNa>K$u#q}w2xzFZeH`SVLP{e@BS<4kBT8dPV_V9R#%-uJ^|<}?CXgnOCX^bPVYj(s5gA>R}r?sY`qQ_N|>jI-ztzX$ENqX+~)#QnyMD zXs&eqhRa>aDa|P@AT1y*C@mCsp~!2^It)_f^9p>zxB7Sb)HTUQEn*M@#IJ4knw?kL?ux`%X6>0YFNKfE8G{{x?A%_RT; delta 204 zcmX}gO$vfQ7zW_ipN(GxDjgw$7C}%KNL>_0NV?Z?<^V&`q9k-FZHH<*MHh$;XtZ(p zJi6%i6s1vCPXXicp_y5)mw6iGZcItInU5mMlYIv1n@u6XUV(FC)W|a<6Q!&UtOQx$ z+EpCVcWhw0iz5g|K1X&VBL&G=nuA diff --git a/tests/data/acpi/x86/q35/DSDT.cxl b/tests/data/acpi/x86/q35/DSDT.cxl index afcdc0d0ba8e41bb70ac20a78dcc8562ca0cb74b..f561750cab8b061c123c041fe2209d74c7a740f1 100644 GIT binary patch delta 3550 zcmeI#JC4&p0LJn0BZ=cj9(GA$B`fN(V@k&=2AOQ0x`x*aqzp zxCWPi3k>p%C&~W^NbWL;Kl%I3#52j?^7q@YxG8S$o(bWUKf~-I+J3t`+-weSzP$YU zczJQ<$mgF9uU_AZ@7eBS_&JUINGY+~mxVB|o!!1%i!`p@58d6q+}MG)+m~CBCVs4x zBdW~$II2<`k@n1II=4Lyt7K7MD_tGk)I(QC?X|9n7IoAWI%;p@>7=dT>7>2XGs$(G z^i0y;#n(w)LB>k?I%===P1M%+P1N3|1!)V?7Nsqdw9+=9?HVf0B(*7RQ`&*F18IlS z4yD0K8Y>k58dOPnTBv~1E~H&ZyOee*4IvF{sey)shLX|<(g@Os(umR+(iqa%B<+&M zXV7Z>6G#(C6G{_Gdyw`Z?NQnzv|mG|d4T$m_9^XCI)HQl>44I~nKV{v2IO5*r%@Nle oamPo$IpXxswdRP^J63bV>2E`G#F>99dNTfpBX08e;>m;m5BYsr8UO$Q delta 354 zcmcbU_Q{*eCD`LRz;HxP*9yH$i>Xik;2GOkkXNm$WWTN XBw_M0)oc`J%BT%SXKtRQcZdZ54M$#( diff --git a/tests/data/acpi/x86/q35/DSDT.viot b/tests/data/acpi/x86/q35/DSDT.viot index 64e81f571120e3eb2b8c6c9545293a78c75b7bbd..8d98dd8845a60a08df5aff27097646bea4913b75 100644 GIT binary patch literal 14615 zcmeI3O>7&-6~|}zrPXpNE~%Ad%d$l{3DP!2LfMIvwrEgtmtU4huep?+U=5IxoL062 zWD(myoWOuA1Bv5PW7R>AOuzuWwWnTVpqKXMTT}GZLoc}&MSKd2H#5(gM^Qipp8|*n zYIkp`LXmhTn{g#u@c!8ZK08;MIS-15q`E>Fi2 zJiL<@+g`a=Hk_Y&<<%Ph{buj;Uhl>yJ-!yP^)Ky*>ub^7d%blAoo=p2rU@JN@^m*S zcf;*Q)^{64qg!uyR_U>67+qIx#f|Q2!(-0MME6|aChlKju6J>%-%9Rm=B7Blk*cHDAnwOQ~R-dlx` zmsi|n=Dgs$m9w$%IoKNxqfO`$-Qrgmj1j&F%>(AVRBCu{jq3$tMex>BeS1!M(ii8` zOC9Khvb6|A#0k86?_JK;`|}TO@2s<(b!#{r4%zKBzIJ=<7B?q$PjLSQa`s0Ch}PxD zVE7HU${effH(VZV!k)c-fy4Q=-EYOU>9;$6e);-VKAlJphis*_Tw!vXue6q{EN?-( z8Cz*B*KjAk(ps*wd?sNHhnzu7_30i&)mVN?9usl(-Cc;RsJ<}~S$nz%k=QjRBP%L0 z#zZ8l#6=`#5EqfyH7+BoDl#r3Q6(WFF@uDN#I6Y$iODBqB&s9{XOeIxDQ8kfqDqQz zrU++>a;7Nf1mT<@oD-CDf^r&!(;%D%DZ)8LIj1ORmT+bXXO?niDW^?1ZNh0& zPMdP(2xpFP<|t>5a^?wVo^a+VXP$CS6V7SEIZZjIDW^j?9m45QPKR>N5Y8FGIYT*T zDCaEUoF$yIlyjDH&JoTz!Z}Ad=P2h9!g+*n9-*8^DCbcTSyE5Uqaw1b9(G4%q`SKd z&s$IRohOm=Byyfc&Pz>mA`sK%KkoLRyN z1ytjN0;+M^gwrORP(U?KD4-f=j&SA(ClpYP6AGxtnJ1ii!U+Xb~4;hZ6yP(U?KD4-hWEa99boKQeDPAH%n=N#djBb-n` zHBKm?8s`zhd4zC60o6F6fNGpaMWj|hYe7RVptYc(7tmVJz%n>bBIkuBMnVDABB6k4 zk;h2nF%k&{REvZHszol4$ORG!1yqZK0;)wGCy~cVBot6B5(=mmc|t_uGya5##AiGd zQ0?480oBg!BGFtVnovMBO(>v3)0yx3?GEc(JL1dg0KSlZk%B)ZXS#7d=*=Gwr$ij4tU3MZ6q}4E8Dl16EX^3Z#hh$6=#o@*YzwNZg$LYvTf{ed#=+tI^5it;ba>f&TblV`M+Y+{YnR~ey$e%!>zjCX)=qk z$KR(}BD`b6{`7@P%PaV8uUl}=h{_W|OD}?^wGVry-RoPQ?ey4AFFhO%SbyrXoi+Bm zHH-c0zsUg`m|1xR=gg^(Ct*4L@%JnNb#r8-@7;*rz4@EM`|n(T@8&hO47->o$A}MzPYo>K6Z=6;uWW! za)VB3GJNjRD+wJG0ASsJv^l7(MBs$%j2-}l$jtV_7xx@lSswJ9W)iRtCd5aFs+=v3 z9p9G6jfJYv0QV^mTA zk2bnZuRr&2wACwhHoodl?yQ-^h+qCH8h5<^{GKxhpL?`%4{}^%H`gNG`{MQfYkRth zE2C3=d&7+HJu&U(g^2fVZh-ApNl4!f23%(wB8EpB;nH}xJtw)*3U02CKh4ca_gv7i z_BqYtua-UIyG<{;GUnVwW^A+-x?UY^^h%wv*@buCfNNTsWsU_;31a|PH#54;QYV)- z4Q4O~(_v?-doJjt0fuc}x#}Fd^fEjKx|QN7rtWySk>HxL&uv|j4}+E$o>w5_nKvaK+AWm}<&w5^a+ z+E&+E$o>w5_nKvaK+AWm}<&w5>1$XQBAiUAT`M~gSJ|M1y z!}-AQa6TZegdgmDpuh@a=L1V>K48oFfPFY0IGhiN836qIF3wjE*9YL79L@(0=L3iH z0sQKDxIO^SgdgmDz-Hi+i}iu#jCA7UZ=2vZJ!jMApK&39u`K+Uiq-fN>xspUdl|;9 zICvJ{S&Tigp6+LcL&n&D#E*f*aro~W@zfNr7$ZLuGKRz9ALSAD2Xf@maQOB2^2nn% z@4v(tjwWB=hQQBg47HCh*uTZXZ8uT#E7Il=zf>v}&oF6yLc8X98sN8>X=$?x&$Ey! zq__=(oK5(3zb)oMBZK&EV~l^gcdSR&Ba0uo#q1wnf}^Lq`BZ{)2HUT8^G3pqnK7~V z8XN%#`xm<(L%98N^`a~7_00K7bG2A3o*JWKC+#G-w02`rcs_P%QT)(qI~^2@U87s_ z+AQ4uNl<)4?pW}VJ4QEH^4LIZoWhOMun}%&gC!McF&2{zyTNhMaB8p))@+tRR^Jz?yi_2|H%#-+&I5SS#BIbp5 w$98vR8U=%n8d)v%#gf5U~)1;fe2`a)27jb4tDX6VX;u2us{{Nq$BZYyXpgK{Ii X-Patchwork-Id: 1983972 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MzQrDSi3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3jZy1nBrz1y1S for ; Thu, 12 Sep 2024 00:27:37 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOI2-0004cx-65; Wed, 11 Sep 2024 10:25: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 1soOHL-00048E-DX for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:25: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 1soOGR-0007zt-Gt for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:25:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726064646; 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=XMtC5Kei8mxn7YHbK2SX3QVuhzxpI5xgFrkix64PgUI=; b=MzQrDSi3XPuvrpwYaQofeaJyfLPEPz0W+8yLnjZkJU1pw13+jQVuP54O2EqVXLVTy5sYQh anRm30au7E2Td1KU/3UAwFE49hXsZZB8xxHtrI6sBD8g5kphauhXg6IpSPWGV7c5shfPFY WfV+K8rUL/w5tAthHx2E8Viv/j6+Uss= 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-81-au1uDgSkPOGTLP08l9c3OA-1; Wed, 11 Sep 2024 09:52:11 -0400 X-MC-Unique: au1uDgSkPOGTLP08l9c3OA-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-53661a13121so3605555e87.0 for ; Wed, 11 Sep 2024 06:52:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062729; x=1726667529; 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=XMtC5Kei8mxn7YHbK2SX3QVuhzxpI5xgFrkix64PgUI=; b=vL0HtUo3TCtJEuLafKzM6zpf51K7Bj8DlWbjQ8UUwktFCEAsM5gWaDAmeB04QQ9/V9 54l/tsXkdNCiS6p5xyS6Ft9UkyxVdPMCzG6E1reBJqoaEaAWVTkRUlzFyqi2gAaN3H0+ aX/zGzht80Z/QrqYI/uL/1l3xmSJq/xX4YOBdLoI0JWJyC8yHay53c+B/AvBvMH4M27L nr53t3jAT4l829GZXOObu6GZFDoUH1jopycBNSYzgdQeaQ/J6qaQZfTVguKjVnYTV5S+ oIqPD2zWToRb6J7Y5ECYnhQVmeWEgztaUGZlBODF0QGzsCpOkdJYbVfBmJz8EeChPFUy ePAQ== X-Gm-Message-State: AOJu0Yx6inKm8YUAdPJKhMo7HgDY2EKT/PmH9wAjlz04+lWyDcIgYIWn 2qTT9dna8WxwmzfAS4p0O5r5+ECjq9s9NoWP23ty1Rl0bM8lMqprWEUkg5gRmZyZHC3OqRdIyKu YZ0XSuHCzrmUspUnV0xBxhNrSdNnbVISXaVTxyuJOLHuu4IOK1Zk+XkSMoq0N1CYbpeI7tu5dLK 2VExw3EIbKXvMDZWodcnISucRnobzD7A== X-Received: by 2002:a05:6512:1388:b0:535:6a84:68df with SMTP id 2adb3069b0e04-536587b5421mr11748610e87.27.1726062729259; Wed, 11 Sep 2024 06:52:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBWytkJ5CWSFxMbY7O4YMGl+gyzbtWIAORmncdYcSIAUTUOVvIm5SzPCDv1FawPAkuriqtwA== X-Received: by 2002:a05:6512:1388:b0:535:6a84:68df with SMTP id 2adb3069b0e04-536587b5421mr11748576e87.27.1726062728400; Wed, 11 Sep 2024 06:52:08 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25ced18csm612219766b.161.2024.09.11.06.52.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:52:07 -0700 (PDT) Date: Wed, 11 Sep 2024 09:52:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , zuoboqun , Stefano Garzarella , Jason Wang Subject: [PULL 13/18] vhost_net: configure all host notifiers in a single MR transaction Message-ID: <6166799f698512ab35e216b4ff4f7156f47923c6.1726062663.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: zuoboqun This allows the vhost_net device which has multiple virtqueues to batch the setup of all its host notifiers. This significantly reduces the vhost_net device starting and stoping time, e.g. the time spend on enabling notifiers reduce from 630ms to 75ms and the time spend on disabling notifiers reduce from 441ms to 45ms for a VM with 192 vCPUs and 15 vhost-user-net devices (64vq per device) in our case. Signed-off-by: zuoboqun Message-Id: <20240816070835.8309-1-zuoboqun@baidu.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost.h | 4 + hw/net/vhost_net.c | 155 +++++++++++++++++++++++++++++++++++--- hw/virtio/vhost.c | 6 +- 3 files changed, 150 insertions(+), 15 deletions(-) diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index d75faf46e9..c75be46c06 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -171,6 +171,10 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, */ void vhost_dev_cleanup(struct vhost_dev *hdev); +void vhost_dev_disable_notifiers_nvqs(struct vhost_dev *hdev, + VirtIODevice *vdev, + unsigned int nvqs); + /** * vhost_dev_enable_notifiers() - enable event notifiers * @hdev: common vhost_dev structure diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index dedf9ad7c2..997aab0557 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -162,6 +162,135 @@ void vhost_net_save_acked_features(NetClientState *nc) #endif } +static void vhost_net_disable_notifiers_nvhosts(VirtIODevice *dev, + NetClientState *ncs, int data_queue_pairs, int nvhosts) +{ + VirtIONet *n = VIRTIO_NET(dev); + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(dev))); + struct vhost_net *net; + struct vhost_dev *hdev; + int r, i, j; + NetClientState *peer; + + /* + * Batch all the host notifiers in a single transaction to avoid + * quadratic time complexity in address_space_update_ioeventfds(). + */ + memory_region_transaction_begin(); + + for (i = 0; i < nvhosts; i++) { + if (i < data_queue_pairs) { + peer = qemu_get_peer(ncs, i); + } else { + peer = qemu_get_peer(ncs, n->max_queue_pairs); + } + + net = get_vhost_net(peer); + hdev = &net->dev; + for (j = 0; j < hdev->nvqs; j++) { + r = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), + hdev->vq_index + j, + false); + if (r < 0) { + error_report("vhost %d VQ %d notifier cleanup failed: %d", + i, j, -r); + } + assert(r >= 0); + } + } + /* + * The transaction expects the ioeventfds to be open when it + * commits. Do it now, before the cleanup loop. + */ + memory_region_transaction_commit(); + + for (i = 0; i < nvhosts; i++) { + if (i < data_queue_pairs) { + peer = qemu_get_peer(ncs, i); + } else { + peer = qemu_get_peer(ncs, n->max_queue_pairs); + } + + net = get_vhost_net(peer); + hdev = &net->dev; + for (j = 0; j < hdev->nvqs; j++) { + virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), + hdev->vq_index + j); + } + virtio_device_release_ioeventfd(dev); + } +} + +static int vhost_net_enable_notifiers(VirtIODevice *dev, + NetClientState *ncs, int data_queue_pairs, int cvq) +{ + VirtIONet *n = VIRTIO_NET(dev); + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(dev))); + int nvhosts = data_queue_pairs + cvq; + struct vhost_net *net; + struct vhost_dev *hdev; + int r, i, j; + NetClientState *peer; + + /* + * Batch all the host notifiers in a single transaction to avoid + * quadratic time complexity in address_space_update_ioeventfds(). + */ + memory_region_transaction_begin(); + + for (i = 0; i < nvhosts; i++) { + if (i < data_queue_pairs) { + peer = qemu_get_peer(ncs, i); + } else { + peer = qemu_get_peer(ncs, n->max_queue_pairs); + } + + net = get_vhost_net(peer); + hdev = &net->dev; + /* + * We will pass the notifiers to the kernel, make sure that QEMU + * doesn't interfere. + */ + r = virtio_device_grab_ioeventfd(dev); + if (r < 0) { + error_report("binding does not support host notifiers"); + memory_region_transaction_commit(); + goto fail_nvhosts; + } + + for (j = 0; j < hdev->nvqs; j++) { + r = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), + hdev->vq_index + j, + true); + if (r < 0) { + error_report("vhost %d VQ %d notifier binding failed: %d", + i, j, -r); + memory_region_transaction_commit(); + vhost_dev_disable_notifiers_nvqs(hdev, dev, j); + goto fail_nvhosts; + } + } + } + + memory_region_transaction_commit(); + + return 0; +fail_nvhosts: + vhost_net_disable_notifiers_nvhosts(dev, ncs, data_queue_pairs, i); + return r; +} + +/* + * Stop processing guest IO notifications in qemu. + * Start processing them in vhost in kernel. + */ +static void vhost_net_disable_notifiers(VirtIODevice *dev, + NetClientState *ncs, int data_queue_pairs, int cvq) +{ + vhost_net_disable_notifiers_nvhosts(dev, ncs, data_queue_pairs, + data_queue_pairs + cvq); +} + static int vhost_net_get_fd(NetClientState *backend) { switch (backend->info->type) { @@ -272,11 +401,6 @@ static int vhost_net_start_one(struct vhost_net *net, } } - r = vhost_dev_enable_notifiers(&net->dev, dev); - if (r < 0) { - goto fail_notifiers; - } - r = vhost_dev_start(&net->dev, dev, false); if (r < 0) { goto fail_start; @@ -328,8 +452,6 @@ fail: } vhost_dev_stop(&net->dev, dev, false); fail_start: - vhost_dev_disable_notifiers(&net->dev, dev); -fail_notifiers: return r; } @@ -351,7 +473,6 @@ static void vhost_net_stop_one(struct vhost_net *net, if (net->nc->info->stop) { net->nc->info->stop(net->nc); } - vhost_dev_disable_notifiers(&net->dev, dev); } int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, @@ -396,10 +517,16 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, } } + r = vhost_net_enable_notifiers(dev, ncs, data_queue_pairs, cvq); + if (r < 0) { + error_report("Error enabling host notifiers: %d", -r); + goto err; + } + r = k->set_guest_notifiers(qbus->parent, total_notifiers, true); if (r < 0) { error_report("Error binding guest notifier: %d", -r); - goto err; + goto err_host_notifiers; } for (i = 0; i < nvhosts; i++) { @@ -414,19 +541,19 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, r = vhost_set_vring_enable(peer, peer->vring_enable); if (r < 0) { - goto err_start; + goto err_guest_notifiers; } } r = vhost_net_start_one(get_vhost_net(peer), dev); if (r < 0) { - goto err_start; + goto err_guest_notifiers; } } return 0; -err_start: +err_guest_notifiers: while (--i >= 0) { peer = qemu_get_peer(ncs, i < data_queue_pairs ? i : n->max_queue_pairs); @@ -437,6 +564,8 @@ err_start: fprintf(stderr, "vhost guest notifier cleanup failed: %d\n", e); fflush(stderr); } +err_host_notifiers: + vhost_net_disable_notifiers(dev, ncs, data_queue_pairs, cvq); err: return r; } @@ -468,6 +597,8 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs, fflush(stderr); } assert(r >= 0); + + vhost_net_disable_notifiers(dev, ncs, data_queue_pairs, cvq); } void vhost_net_cleanup(struct vhost_net *net) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 06fc71746e..7c5ef81b55 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1682,9 +1682,9 @@ void vhost_dev_cleanup(struct vhost_dev *hdev) memset(hdev, 0, sizeof(struct vhost_dev)); } -static void vhost_dev_disable_notifiers_nvqs(struct vhost_dev *hdev, - VirtIODevice *vdev, - unsigned int nvqs) +void vhost_dev_disable_notifiers_nvqs(struct vhost_dev *hdev, + VirtIODevice *vdev, + unsigned int nvqs) { BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); int i, r; From patchwork Wed Sep 11 13:52: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: 1983989 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iqhG2mQw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3jf34cXwz1y24 for ; Thu, 12 Sep 2024 00:30:19 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOKB-0000H5-4X; Wed, 11 Sep 2024 10:28:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1soOJP-00076Y-HO for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:27: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 1soOJN-0003NH-0g for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:27:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726064832; 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=7SP0llBIv1hTkxB2e1G9eZTNJY30OOtKHAC0GZkH5pk=; b=iqhG2mQw+L4d0UJpHk0V0paQYZlaolYPVK4XUrIddbBQptD2AW/zToaE9VeqGzA8w6+1Kk VZoiPGg12sA8gHoxF09RgXsSGePUnPvGOQC73MCxHZ2eZdSw2CiRn61ohJhqQudaKcez/g be+VcFiLuhmXYueFaK/haQCcUKzVgE8= 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-356-4IZLYEVzO3-T-EduSWVDiw-1; Wed, 11 Sep 2024 09:52:13 -0400 X-MC-Unique: 4IZLYEVzO3-T-EduSWVDiw-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a8d10954458so367259666b.3 for ; Wed, 11 Sep 2024 06:52:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062732; x=1726667532; 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=7SP0llBIv1hTkxB2e1G9eZTNJY30OOtKHAC0GZkH5pk=; b=kpoVlGJxdX+2VK+jPzgmBpDhLaRiNVHG/8YC6a9GXTKJTiBvo8RBCmOe74OCeq68h8 22SAOLLaAAq235Hs7oC7Bl0RHxNJRccers7jcVCOhC9SPOhbpaJHAi9ODFtIVMXkHmmC uC2efNj1jSWSPZXZsaD8yp4IudCVIsmut4vIEfsE+auoutH52zrVMGT7ZXLSVsqVrAoA 9IkDQQOrnsbZoT/wv0wS2fwavcFZnI6EMF33MtDHZx42WF09df9hV2ODAh7SzwVsGf6E 1k/i0Vjgb/TbujynZ8ZkPgwBGpy6RRDZ4HhajhMT3rYMoSpILsSqEGWB/TFo2jgX9sx9 S19g== X-Gm-Message-State: AOJu0YxSDTer921HGdwz1AXL1L8iI9v91y/vWPjahtu7nw6UNf0wd1n1 R1QZHIAIlTcxu4BiYMj+czdyfmej+kuNik6G6p949IrTEPQzuSdF8GOGKuBrqDNmmXByClUqvSa GOtv61fDl/mXzXbPV7yy29g0CZ4dA2U683PgeLTmO7+8V1WzZEf+F23u+CHSWq1Cnx/jR3jVvRm +h2t24OrwJYOUqSsOFTaNC1taHxt2+aQ== X-Received: by 2002:a17:907:2d0c:b0:a8d:2e5f:8fdd with SMTP id a640c23a62f3a-a8ffae0bea7mr436046766b.59.1726062732015; Wed, 11 Sep 2024 06:52:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9j3Zx7fBOmvGDs7LU/brNk/yeDDdgCfqQPYw6awSNHdmBK8k+8SMZdZd0Drc88ss0oO7qvA== X-Received: by 2002:a17:907:2d0c:b0:a8d:2e5f:8fdd with SMTP id a640c23a62f3a-a8ffae0bea7mr436043766b.59.1726062731403; Wed, 11 Sep 2024 06:52:11 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25a455besm622550566b.93.2024.09.11.06.52.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:52:10 -0700 (PDT) Date: Wed, 11 Sep 2024 09:52:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Gao Shiyuan , Zuo Boqun Subject: [PULL 14/18] virtio-pci: Add lookup subregion of VirtIOPCIRegion MR 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Gao Shiyuan Now virtio_address_space_lookup only lookup common/isr/device/notify MR and exclude their subregions. When VHOST_USER_PROTOCOL_F_HOST_NOTIFIER enable, the notify MR has host-notifier subregions and we need use host-notifier MR to notify the hardware accelerator directly instead of eventfd notify. Further more, maybe common/isr/device MR also has subregions in the future, so need memory_region_find for each MR incluing their subregions. Add lookup subregion of VirtIOPCIRegion MR instead of only lookup container MR. Fixes: a93c8d8 ("virtio-pci: Replace modern_as with direct access to modern_bar") Co-developed-by: Zuo Boqun Signed-off-by: Gao Shiyuan Signed-off-by: Zuo Boqun Message-Id: <20240903120304.97833-1-gaoshiyuan@baidu.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-pci.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 524b63e5c7..4d832fe845 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -615,8 +615,12 @@ static MemoryRegion *virtio_address_space_lookup(VirtIOPCIProxy *proxy, reg = &proxy->regs[i]; if (*off >= reg->offset && *off + len <= reg->offset + reg->size) { - *off -= reg->offset; - return ®->mr; + MemoryRegionSection mrs = memory_region_find(®->mr, + *off - reg->offset, len); + assert(mrs.mr); + *off = mrs.offset_within_region; + memory_region_unref(mrs.mr); + return mrs.mr; } } From patchwork Wed Sep 11 13:52:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 1984001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eISEn2qV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3jhR6qVYz1y1l for ; Thu, 12 Sep 2024 00:32:23 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOMk-00052k-Cm; Wed, 11 Sep 2024 10:30: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 1soOMh-0004tQ-Cz for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:30: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 1soOMf-00044c-9f for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:30:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726065036; 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=s7eWEC+J3I9Lev0M7HtiUi/IanEUkElHv0I4GaiCIw8=; b=eISEn2qVf62ZM2n5aB8zkDG75esudLUoEsfGXjIE/wtIlmAxURar5yHVvCEMHhOsaJ+G8s VHk5o9SRmp1zCpVt/T+U7Kh7AHyhFZing5eFtEXTII8SThdGZJ4b/4A2DEwQ8L10kKhrbM jD6aTv1pJ2iDxYnerS+eule4ZydXg1g= 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-68-RJmG23MwOHSOHOvb3rg9Qg-1; Wed, 11 Sep 2024 09:52:17 -0400 X-MC-Unique: RJmG23MwOHSOHOvb3rg9Qg-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5c25c45afb2so4829621a12.1 for ; Wed, 11 Sep 2024 06:52:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062735; x=1726667535; 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=s7eWEC+J3I9Lev0M7HtiUi/IanEUkElHv0I4GaiCIw8=; b=ufvTDFT8p+uem6p/jSuqxLqNhECafJ0omcHXyLC9RKReXkD0ODlxlM5dG6QgCNLzed 2Ty7OtTVdWfBArNqWHzNF17w9bpqLAjSPw6i9wNwRkA119tqrWsTnHYPt31pKLgpB2HD alB3YwVWjJK98L7YpaM4+f8zj9ZJEf4UpTpvp96M98iZw2QiGu6TTlx9mGGSTiWBhTkV ClylMeDGRNeXAx++Mzqk6J4z2zjogQEenTeOmZUDHjneR/J0ydX+ZTscqHFiniW99W1k MIvSjof5rmsQP5c5/B3J6K40mIcyBCrmIHiHHCIPrLVQGnfW/IcwmBrcVvBh6Wx96XCv CUvg== X-Gm-Message-State: AOJu0YzxMOlEUki71X4br/AsIcSMp9flIeQEON2Q0xiqbUuzHAIedKpc yNx3kSu7kcZ21GNnGgvRBAhsYfSRUT6sX529W7eHpGbFy0sMlR5rtkdWs1uRVc0hYQ+OF2IN1br KEybP6AhESmn05rNzA3STt42iX0QocEnZDFS8CZPKWxCIYrn4QGyQxaSeE6+BB5MhB7DQnDfmK9 gKIJvcNg3yiaucu0rXW8+UOsV/LyXSng== X-Received: by 2002:a05:6402:528d:b0:5be:fd66:edf3 with SMTP id 4fb4d7f45d1cf-5c3dc79b7a6mr12720156a12.18.1726062735419; Wed, 11 Sep 2024 06:52:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzLNZKPzU44WOHzWzxWuIOTk/S6psIjrahnWH+D/HwRtJ/7DEgGqSrj3xM9gxcltyj57xeeA== X-Received: by 2002:a05:6402:528d:b0:5be:fd66:edf3 with SMTP id 4fb4d7f45d1cf-5c3dc79b7a6mr12720129a12.18.1726062734725; Wed, 11 Sep 2024 06:52:14 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd41be4sm5361685a12.18.2024.09.11.06.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:52:14 -0700 (PDT) Date: Wed, 11 Sep 2024 09:52:11 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , peng guo , Jonathan Cameron , Fan Ni Subject: [PULL 15/18] hw/cxl: fix physical address field in get scan media results output 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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: peng guo When using the mailbox command get scan media results, the scan media restart physical address field in the ouput palyload is not 64-byte aligned. This patch removed the error source of the restart physical address. The Scan Media Restart Physical Address is the location from which the host should restart the Scan Media operation. [5:0] bits are reserved. Refer to CXL spec r3.1 Table 8-146 Fixes: 89b5cfcc31e6 ("hw/cxl: Add get scan media results cmd support") Reviewed-by: Jonathan Cameron Link: https://lore.kernel.org/linux-cxl/20240819154206.16456-1-engguopeng@buaa.edu.cn/ Signed-off-by: peng guo Message-Id: <20240825102212.3871-1-engguopeng@buaa.edu.cn> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 3ebbd32e10..9258e48f95 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -2076,7 +2076,7 @@ static CXLRetCode cmd_media_get_scan_media_results(const struct cxl_cmd *cmd, start = ROUND_DOWN(ent->start, 64ull); stop = ROUND_DOWN(ent->start, 64ull) + ent->length; - stq_le_p(&out->records[i].addr, start | (ent->type & 0x7)); + stq_le_p(&out->records[i].addr, start); stl_le_p(&out->records[i].length, (stop - start) / CXL_CACHE_LINE_SIZE); i++; From patchwork Wed Sep 11 13:52: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: 1984000 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eotXh7+4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3jhQ5mMMz1y1l for ; Thu, 12 Sep 2024 00:32:22 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOKA-0000Ao-KU; Wed, 11 Sep 2024 10:28: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 1soOJR-00079c-S1 for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:27: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 1soOJN-0003NL-9A for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:27:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726064832; 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=DB9NGbeaAbvfzy7mNKPYp8OuO5yV58WQSC8D88JNFOQ=; b=eotXh7+4MPPvOD4EKTyVDdEgp3MYOHNK2m+0SbRwXUQ+wueZGqOPfF3aOwYbmC2PsQg5MB E2s+TT/SCsH+A4N3+AsB01uSd2U9KjACa051zXub8k9FhkNnbZKMmSPesrLKbup3hhgtoz t8qFZpe2tmK4G9a+4AjkY0x/Bzw7Yeg= 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-214-UrGgz0SqPeKAk9b-vi0G1A-1; Wed, 11 Sep 2024 09:52:21 -0400 X-MC-Unique: UrGgz0SqPeKAk9b-vi0G1A-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a8d2e6a6989so251058666b.1 for ; Wed, 11 Sep 2024 06:52:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062738; x=1726667538; 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=DB9NGbeaAbvfzy7mNKPYp8OuO5yV58WQSC8D88JNFOQ=; b=hhD829JtsUSXq5Z2l1GvS/8MAJIFgm0/nuSyp8uK1MpsrxoGE7yhGnOl+kCw5UPeuo dU8Gcjnq4Xja1xKm5YaLc8xcvKQbtucGpkY6RD/x0NYfDI8/17G21mEqE9ndqruX5FNA fg4aWy894wXgpB1dL6PbfLFLSVJ3tRhMA37FB0RGCQ7iwvtFhaVBjVGCGMZH2ksqgUd8 qHjyWF7/xK2UKPLV2gJNjQzovRiSRIkZediTlE4Fg582N+GXJD+YOl3Hi+j6c+03jeTU hL6a6km7kKN4mP2NfNSPVZQcbNMn5/Jy6JLqsCajb9q6cCxCCA6KkAkPCpF5KQymtx4b 65ew== X-Gm-Message-State: AOJu0YxkbOexp//ys0yxBwvU8DbO9SqjqwRZUkYpQvMCIhBQM3nunXX0 Zyd5Zt+ruTbdb7jENW+9Iaz2OufPV6LX5Dvgeue45C4pZy2UDoxwPsefSZiEp39AKV2+50T2Pci eNr1MnOiW1laCY5o0OhCcatwuEClZ7Dw3S0XVnAqR3o3k/uTEbhTNQjVu5n7LFnWwvWi0orPnoa ec0O2SpKe9KGki2SEFp+Q5sp79xba2bw== X-Received: by 2002:a17:907:60ca:b0:a8d:3e29:a82d with SMTP id a640c23a62f3a-a8ffab771b9mr459881066b.37.1726062738367; Wed, 11 Sep 2024 06:52:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEyRf5v+DYP/9JUh8QHbJzGLb2wgjxLVIaqhTZr6pP7FjtSjnlbJet8bU6YApEOMBOSO/qlgQ== X-Received: by 2002:a17:907:60ca:b0:a8d:3e29:a82d with SMTP id a640c23a62f3a-a8ffab771b9mr459877466b.37.1726062737792; Wed, 11 Sep 2024 06:52:17 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d25c727e4sm614180366b.126.2024.09.11.06.52.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:52:17 -0700 (PDT) Date: Wed, 11 Sep 2024 09:52:15 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Volker =?utf-8?q?R=C3=BCmelin?= , Gerd Hoffmann , Manos Pitsidianakis Subject: [PULL 16/18] hw/audio/virtio-sound: fix heap buffer overflow Message-ID: <7fc6611cad3e9627b23ce83e550b668abba6c886.1726062663.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Volker Rümelin Currently, the guest may write to the device configuration space, whereas the virtio sound device specification in chapter 5.14.4 clearly states that the fields in the device configuration space are driver-read-only. Remove the set_config function from the virtio_snd class. This also prevents a heap buffer overflow. See QEMU issue #2296. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2296 Signed-off-by: Volker Rümelin Message-Id: <20240901130112.8242-1-vr_qemu@t-online.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/audio/virtio-snd.c | 24 ------------------------ hw/audio/trace-events | 1 - 2 files changed, 25 deletions(-) diff --git a/hw/audio/virtio-snd.c b/hw/audio/virtio-snd.c index d1cf5eb445..69838181dd 100644 --- a/hw/audio/virtio-snd.c +++ b/hw/audio/virtio-snd.c @@ -107,29 +107,6 @@ virtio_snd_get_config(VirtIODevice *vdev, uint8_t *config) } -static void -virtio_snd_set_config(VirtIODevice *vdev, const uint8_t *config) -{ - VirtIOSound *s = VIRTIO_SND(vdev); - const virtio_snd_config *sndconfig = - (const virtio_snd_config *)config; - - - trace_virtio_snd_set_config(vdev, - s->snd_conf.jacks, - sndconfig->jacks, - s->snd_conf.streams, - sndconfig->streams, - s->snd_conf.chmaps, - sndconfig->chmaps); - - memcpy(&s->snd_conf, sndconfig, sizeof(virtio_snd_config)); - le32_to_cpus(&s->snd_conf.jacks); - le32_to_cpus(&s->snd_conf.streams); - le32_to_cpus(&s->snd_conf.chmaps); - -} - static void virtio_snd_pcm_buffer_free(VirtIOSoundPCMBuffer *buffer) { @@ -1400,7 +1377,6 @@ static void virtio_snd_class_init(ObjectClass *klass, void *data) vdc->realize = virtio_snd_realize; vdc->unrealize = virtio_snd_unrealize; vdc->get_config = virtio_snd_get_config; - vdc->set_config = virtio_snd_set_config; vdc->get_features = get_features; vdc->reset = virtio_snd_reset; vdc->legacy_features = 0; diff --git a/hw/audio/trace-events b/hw/audio/trace-events index b1870ff224..b8ef572767 100644 --- a/hw/audio/trace-events +++ b/hw/audio/trace-events @@ -41,7 +41,6 @@ asc_update_irq(int irq, int a, int b) "set IRQ to %d (A: 0x%x B: 0x%x)" #virtio-snd.c virtio_snd_get_config(void *vdev, uint32_t jacks, uint32_t streams, uint32_t chmaps) "snd %p: get_config jacks=%"PRIu32" streams=%"PRIu32" chmaps=%"PRIu32"" -virtio_snd_set_config(void *vdev, uint32_t jacks, uint32_t new_jacks, uint32_t streams, uint32_t new_streams, uint32_t chmaps, uint32_t new_chmaps) "snd %p: set_config jacks from %"PRIu32"->%"PRIu32", streams from %"PRIu32"->%"PRIu32", chmaps from %"PRIu32"->%"PRIu32 virtio_snd_get_features(void *vdev, uint64_t features) "snd %p: get_features 0x%"PRIx64 virtio_snd_vm_state_running(void) "vm state running" virtio_snd_vm_state_stopped(void) "vm state stopped" From patchwork Wed Sep 11 13:52: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: 1984030 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VBZloT7g; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3kJn5B9kz1y1l for ; Thu, 12 Sep 2024 01:00:25 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOli-0006Zz-8z; Wed, 11 Sep 2024 10:56: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 1soOig-0002ck-KS for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:53: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 1soOid-0007IU-1t for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:53:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726066398; 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=4veiozMEGfv+9OEJSb+cGyfH7FXaz+7Wyk7isIZPzXI=; b=VBZloT7g8sNtsVS+csbWn3h0Zy6zGrhaVDLTSaTHcnVNRgaTMvRnRgq/gjJwVvD8pbiO8H Y7KBftllqj8H9wL3GBEnw4L+tbG06lXsag569BW4YfcKfjAl3g/FFvgrHLpe283QdgrdnN SfAN22RyhJRwKcPw383LpNJhoAj4dFM= 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-76-JNxwyFy8OGS6N0S9wd4tQA-1; Wed, 11 Sep 2024 09:52:23 -0400 X-MC-Unique: JNxwyFy8OGS6N0S9wd4tQA-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-374b981dd62so1079003f8f.3 for ; Wed, 11 Sep 2024 06:52:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062742; x=1726667542; 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=4veiozMEGfv+9OEJSb+cGyfH7FXaz+7Wyk7isIZPzXI=; b=YuGQU+Y439gQWsqF1oLI37OSiObE1Te/gi8Ih/q49GvZXVvnA8s5ACtzS+1CipTwtw FjaWI8Bov6utRAjqWLz95an+xiB9GTEklaB+894hP0bcfX+uysog8EdbUmdwo0VAC6eN 4zAdSKOMw5Q5i0A8PFbBBe2F97ubiJdHoG0AcaO+HLHkkV/PX2Q3vWx+gcqfr3VHASiy kmoQpnEh/y8sCQ9+68G6ZL2rVQuf1u2XYnprF/NfamLCTqRzLa8ESxM5kAAWhf+QU0C5 UXlxOi7zzwkuk/QU5xgikXhKgaxiZomaeFJ4+XrKbTqiqqI8RB+oedD/vFDIG9evv86V dq5Q== X-Gm-Message-State: AOJu0YxkaoLhlzxiIwTkHUxyfXOVaLkY5UBLgiCJC1kc03cxh4ayD4r0 Zlef37Yh/EPGavQ4NhEpqXR7Clx5u+1yPhwFdeboNfKYYd+HkxfgV1F+QzluzWZqbbpOgbaasWC 7G/oBccmt8sYYlo15KHtXtcx0cRrvCE27GI5IRkrwhkaAmjB52dPL5ZPJ/8oVZqPtWtrkIbZOfa D9tgeWAyKXWaQpxYp+aRBHU8x1CI2NKg== X-Received: by 2002:a05:6000:156e:b0:378:7e94:d613 with SMTP id ffacd0b85a97d-378b07f6ad8mr2411386f8f.42.1726062741683; Wed, 11 Sep 2024 06:52:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE3fvnhE/laytZOuXh9GtvogEZU9g8iP2CK+EAn9uPy3+gHAc7EKj5dFV1iyfaiUOt7pcxJ0Q== X-Received: by 2002:a05:6000:156e:b0:378:7e94:d613 with SMTP id ffacd0b85a97d-378b07f6ad8mr2411344f8f.42.1726062740959; Wed, 11 Sep 2024 06:52:20 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd46886sm5388659a12.34.2024.09.11.06.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:52:20 -0700 (PDT) Date: Wed, 11 Sep 2024 09:52:18 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , David Hildenbrand , Gavin Shan , Juraj Marcin Subject: [PULL 17/18] virtio-mem: don't warn about THP sizes on a kernel without THP support Message-ID: <95b717a8154b955de2782305f305b63f357b0576.1726062663.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: David Hildenbrand If the config directory in sysfs does not exist at all, we are dealing with a system that does not support THPs. Simply use 1 MiB block size then, instead of warning "Could not detect THP size, falling back to ..." and falling back to the default THP size. Cc: "Michael S. Tsirkin" Cc: Gavin Shan Cc: Juraj Marcin Signed-off-by: David Hildenbrand Message-Id: <20240910163433.2100295-1-david@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-mem.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c index ef64bf1b4a..4075f3d4ce 100644 --- a/hw/virtio/virtio-mem.c +++ b/hw/virtio/virtio-mem.c @@ -88,6 +88,7 @@ static uint32_t virtio_mem_default_thp_size(void) static uint32_t thp_size; #define HPAGE_PMD_SIZE_PATH "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size" +#define HPAGE_PATH "/sys/kernel/mm/transparent_hugepage/" static uint32_t virtio_mem_thp_size(void) { gchar *content = NULL; @@ -98,6 +99,12 @@ static uint32_t virtio_mem_thp_size(void) return thp_size; } + /* No THP -> no restrictions. */ + if (!g_file_test(HPAGE_PATH, G_FILE_TEST_EXISTS)) { + thp_size = VIRTIO_MEM_MIN_BLOCK_SIZE; + return thp_size; + } + /* * Try to probe the actual THP size, fallback to (sane but eventually * incorrect) default sizes. From patchwork Wed Sep 11 13:52: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: 1984046 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dkR4Fz7k; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3kdT0d0sz1y1S for ; Thu, 12 Sep 2024 01:14:53 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soOqc-0000Xd-2f; Wed, 11 Sep 2024 11:01: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 1soOjO-0005Zg-Nc for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:54:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1soOjM-0007Kf-8I for qemu-devel@nongnu.org; Wed, 11 Sep 2024 10:54:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726066443; 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=2Jbb3zSd/FAyigLmm8Lyz5T3+QqcWo7wpMZLcIaqupo=; b=dkR4Fz7kS0LBnYfMQ7eUyVsUd6ibCM8UOiIzWtLPX5MAS7N7a2JDr+7XfZgvhgDto3kGCS 0EXDngq7++dDYeUvi2VzS0HaGD/8bA9DpGVb/jcJHL71t81VcswPSvLtKHkX1Dk8MUS4Qn Cns+RXr86+X67sj1zmnqFeuxcddyb9o= 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-628-U_Vu12O9MAaTryrxCbcBUA-1; Wed, 11 Sep 2024 09:52:27 -0400 X-MC-Unique: U_Vu12O9MAaTryrxCbcBUA-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5c3c398b511so5902301a12.2 for ; Wed, 11 Sep 2024 06:52:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726062745; x=1726667545; 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=2Jbb3zSd/FAyigLmm8Lyz5T3+QqcWo7wpMZLcIaqupo=; b=klS0f7B4hHHqs0K5I6tzo3JKoyf0V4oDB3tOUfCxfZhHoe8dwLAgXRm0c+pWGB2zzp JB1oqRajKo0dbq4YYl1GRude0cLaITDzUvOmtglQcKiJQ8DFKKvpX2nX2HimejMPsLcP m9rZx4XjQRcaZJJ3k3uxncuIU+N8Qr9guhbSaJrShMvCyyI2dPYn1gizJjSyjWRI6vO1 +XiSl1vxA3bLihPO3riQU1pserOHSubkQZDg3mC/rJOiSUisiHTeKl5ZJCH8TtoBIQ5N wrcHqOdLFLjqM1UKIaxwitTuLr3kq82gZ/hWqiB1lJT7FJEw1h9S8WSPDaP2qK7sNw+v od9A== X-Gm-Message-State: AOJu0YwnG5Ki1YMhlqP9VXmDSzQwT4U34QaaCXoKHngEnv2+OVtbZT1l YjSiX4L2XL+b+frU/d6HtKNhEqTzPyoaS/lqvPXudlLRU83wd6TtdpE2+95vDMWfc0BUkNYA5y8 59B0xNw5KZ/tYtx1UcxxZvfTm4GI6ruKhDcM80ZZ8ISFVGKUjEISLVF9ykz6xzVmKuSArK2A9qR gbsdV5KmLUu8fargOkkVqpiE2ojcBbOw== X-Received: by 2002:a05:6402:5188:b0:5c3:9fa9:1b72 with SMTP id 4fb4d7f45d1cf-5c3e95335d1mr13501485a12.6.1726062745174; Wed, 11 Sep 2024 06:52:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYbuGXOLRVFU4WvXWJNIWM/47EeOtk49Kxsno0na54m4y3am4dPgDW5XboDfLP1T0Ph57CpA== X-Received: by 2002:a05:6402:5188:b0:5c3:9fa9:1b72 with SMTP id 4fb4d7f45d1cf-5c3e95335d1mr13501446a12.6.1726062744563; Wed, 11 Sep 2024 06:52:24 -0700 (PDT) Received: from redhat.com ([2.55.9.133]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3ebd8cdf7sm5424056a12.92.2024.09.11.06.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Sep 2024 06:52:24 -0700 (PDT) Date: Wed, 11 Sep 2024 09:52:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Dominic Prinz , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 18/18] hw/acpi/ich9: Add periodic and swsmi timer Message-ID: <6e3c2d58e967cde3dadae298e81c5e8eb9fb9080.1726062663.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: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.144, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Dominic Prinz This patch implements the periodic and the swsmi ICH9 chipset timers. They are especially useful when prototyping UEFI firmware (e.g. with EDK2's OVMF) using QEMU. For backwards compatibility, the compat properties "x-smi-swsmi-timer", and "x-smi-periodic-timer" are introduced. Additionally, writes to the SMI_STS register are enabled for the corresponding two bits using a write mask to make future work easier. Signed-off-by: Dominic Prinz Message-Id: <1d90ea69e01ab71a0f2ced116801dc78e04f4448.1725991505.git.git@dprinz.de> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/ich9.h | 6 +++ include/hw/acpi/ich9_timer.h | 23 +++++++++ include/hw/southbridge/ich9.h | 4 ++ hw/acpi/ich9.c | 23 +++++++++ hw/acpi/ich9_timer.c | 93 +++++++++++++++++++++++++++++++++++ hw/i386/pc.c | 5 +- hw/isa/lpc_ich9.c | 14 ++++++ hw/acpi/meson.build | 2 +- 8 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 include/hw/acpi/ich9_timer.h create mode 100644 hw/acpi/ich9_timer.c diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h index 2faf7f0cae..245fe08dc2 100644 --- a/include/hw/acpi/ich9.h +++ b/include/hw/acpi/ich9.h @@ -46,6 +46,7 @@ typedef struct ICH9LPCPMRegs { uint32_t smi_en; uint32_t smi_en_wmask; uint32_t smi_sts; + uint32_t smi_sts_wmask; qemu_irq irq; /* SCI */ @@ -68,6 +69,11 @@ typedef struct ICH9LPCPMRegs { bool smm_compat; bool enable_tco; TCOIORegs tco_regs; + + bool swsmi_timer_enabled; + bool periodic_timer_enabled; + QEMUTimer *swsmi_timer; + QEMUTimer *periodic_timer; } ICH9LPCPMRegs; #define ACPI_PM_PROP_TCO_ENABLED "enable_tco" diff --git a/include/hw/acpi/ich9_timer.h b/include/hw/acpi/ich9_timer.h new file mode 100644 index 0000000000..5112df4385 --- /dev/null +++ b/include/hw/acpi/ich9_timer.h @@ -0,0 +1,23 @@ +/* + * QEMU ICH9 Timer emulation + * + * Copyright (c) 2024 Dominic Prinz + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef HW_ACPI_ICH9_TIMER_H +#define HW_ACPI_ICH9_TIMER_H + +#include "hw/acpi/ich9.h" + +void ich9_pm_update_swsmi_timer(ICH9LPCPMRegs *pm, bool enable); + +void ich9_pm_swsmi_timer_init(ICH9LPCPMRegs *pm); + +void ich9_pm_update_periodic_timer(ICH9LPCPMRegs *pm, bool enable); + +void ich9_pm_periodic_timer_init(ICH9LPCPMRegs *pm); + +#endif diff --git a/include/hw/southbridge/ich9.h b/include/hw/southbridge/ich9.h index fd01649d04..6c60017024 100644 --- a/include/hw/southbridge/ich9.h +++ b/include/hw/southbridge/ich9.h @@ -196,8 +196,12 @@ struct ICH9LPCState { #define ICH9_PMIO_GPE0_LEN 16 #define ICH9_PMIO_SMI_EN 0x30 #define ICH9_PMIO_SMI_EN_APMC_EN (1 << 5) +#define ICH9_PMIO_SMI_EN_SWSMI_EN (1 << 6) #define ICH9_PMIO_SMI_EN_TCO_EN (1 << 13) +#define ICH9_PMIO_SMI_EN_PERIODIC_EN (1 << 14) #define ICH9_PMIO_SMI_STS 0x34 +#define ICH9_PMIO_SMI_STS_SWSMI_STS (1 << 6) +#define ICH9_PMIO_SMI_STS_PERIODIC_STS (1 << 14) #define ICH9_PMIO_TCO_RLD 0x60 #define ICH9_PMIO_TCO_LEN 32 diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c index 02d8546bd3..c15e5b8281 100644 --- a/hw/acpi/ich9.c +++ b/hw/acpi/ich9.c @@ -35,6 +35,7 @@ #include "sysemu/runstate.h" #include "hw/acpi/acpi.h" #include "hw/acpi/ich9_tco.h" +#include "hw/acpi/ich9_timer.h" #include "hw/southbridge/ich9.h" #include "hw/mem/pc-dimm.h" @@ -108,6 +109,18 @@ static void ich9_smi_writel(void *opaque, hwaddr addr, uint64_t val, } pm->smi_en &= ~pm->smi_en_wmask; pm->smi_en |= (val & pm->smi_en_wmask); + if (pm->swsmi_timer_enabled) { + ich9_pm_update_swsmi_timer(pm, pm->smi_en & + ICH9_PMIO_SMI_EN_SWSMI_EN); + } + if (pm->periodic_timer_enabled) { + ich9_pm_update_periodic_timer(pm, pm->smi_en & + ICH9_PMIO_SMI_EN_PERIODIC_EN); + } + break; + case 4: + pm->smi_sts &= ~pm->smi_sts_wmask; + pm->smi_sts |= (val & pm->smi_sts_wmask); break; } } @@ -286,6 +299,8 @@ static void pm_powerdown_req(Notifier *n, void *opaque) void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, qemu_irq sci_irq) { + pm->smi_sts_wmask = 0; + memory_region_init(&pm->io, OBJECT(lpc_pci), "ich9-pm", ICH9_PMIO_SIZE); memory_region_set_enabled(&pm->io, false); memory_region_add_subregion(pci_address_space_io(lpc_pci), @@ -305,6 +320,14 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, qemu_irq sci_irq) "acpi-smi", 8); memory_region_add_subregion(&pm->io, ICH9_PMIO_SMI_EN, &pm->io_smi); + if (pm->swsmi_timer_enabled) { + ich9_pm_swsmi_timer_init(pm); + } + + if (pm->periodic_timer_enabled) { + ich9_pm_periodic_timer_init(pm); + } + if (pm->enable_tco) { acpi_pm_tco_init(&pm->tco_regs, &pm->io); } diff --git a/hw/acpi/ich9_timer.c b/hw/acpi/ich9_timer.c new file mode 100644 index 0000000000..5b1c910156 --- /dev/null +++ b/hw/acpi/ich9_timer.c @@ -0,0 +1,93 @@ +/* + * QEMU ICH9 Timer emulation + * + * Copyright (c) 2024 Dominic Prinz + * + * 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 "hw/core/cpu.h" +#include "hw/pci/pci.h" +#include "hw/southbridge/ich9.h" +#include "qemu/timer.h" + +#include "hw/acpi/ich9_timer.h" + +void ich9_pm_update_swsmi_timer(ICH9LPCPMRegs *pm, bool enable) +{ + uint16_t swsmi_rate_sel; + int64_t expire_time; + ICH9LPCState *lpc; + + if (enable) { + lpc = container_of(pm, ICH9LPCState, pm); + swsmi_rate_sel = + (pci_get_word(lpc->d.config + ICH9_LPC_GEN_PMCON_3) & 0xc0) >> 6; + + if (swsmi_rate_sel == 0) { + expire_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 1500000LL; + } else { + expire_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + + 8 * (1 << swsmi_rate_sel) * 1000000LL; + } + + timer_mod(pm->swsmi_timer, expire_time); + } else { + timer_del(pm->swsmi_timer); + } +} + +static void ich9_pm_swsmi_timer_expired(void *opaque) +{ + ICH9LPCPMRegs *pm = opaque; + + pm->smi_sts |= ICH9_PMIO_SMI_STS_SWSMI_STS; + ich9_generate_smi(); + + ich9_pm_update_swsmi_timer(pm, pm->smi_en & ICH9_PMIO_SMI_EN_SWSMI_EN); +} + +void ich9_pm_swsmi_timer_init(ICH9LPCPMRegs *pm) +{ + pm->smi_sts_wmask |= ICH9_PMIO_SMI_STS_SWSMI_STS; + pm->swsmi_timer = + timer_new_ns(QEMU_CLOCK_VIRTUAL, ich9_pm_swsmi_timer_expired, pm); +} + +void ich9_pm_update_periodic_timer(ICH9LPCPMRegs *pm, bool enable) +{ + uint16_t per_smi_sel; + int64_t expire_time; + ICH9LPCState *lpc; + + if (enable) { + lpc = container_of(pm, ICH9LPCState, pm); + per_smi_sel = pci_get_word(lpc->d.config + ICH9_LPC_GEN_PMCON_1) & 3; + expire_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + + 8 * (1 << (3 - per_smi_sel)) * NANOSECONDS_PER_SECOND; + + timer_mod(pm->periodic_timer, expire_time); + } else { + timer_del(pm->periodic_timer); + } +} + +static void ich9_pm_periodic_timer_expired(void *opaque) +{ + ICH9LPCPMRegs *pm = opaque; + + pm->smi_sts = ICH9_PMIO_SMI_STS_PERIODIC_STS; + ich9_generate_smi(); + + ich9_pm_update_periodic_timer(pm, + pm->smi_en & ICH9_PMIO_SMI_EN_PERIODIC_EN); +} + +void ich9_pm_periodic_timer_init(ICH9LPCPMRegs *pm) +{ + pm->smi_sts_wmask |= ICH9_PMIO_SMI_STS_PERIODIC_STS; + pm->periodic_timer = + timer_new_ns(QEMU_CLOCK_VIRTUAL, ich9_pm_periodic_timer_expired, pm); +} diff --git a/hw/i386/pc.c b/hw/i386/pc.c index ba0ff51183..8d84c22458 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -79,7 +79,10 @@ { "qemu64-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },\ { "athlon-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, }, -GlobalProperty pc_compat_9_1[] = {}; +GlobalProperty pc_compat_9_1[] = { + { "ICH9-LPC", "x-smi-swsmi-timer", "off" }, + { "ICH9-LPC", "x-smi-periodic-timer", "off" }, +}; const size_t pc_compat_9_1_len = G_N_ELEMENTS(pc_compat_9_1); GlobalProperty pc_compat_9_0[] = { diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index bd727b2320..ab17b76f54 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -43,6 +43,7 @@ #include "hw/southbridge/ich9.h" #include "hw/acpi/acpi.h" #include "hw/acpi/ich9.h" +#include "hw/acpi/ich9_timer.h" #include "hw/pci/pci_bus.h" #include "hw/qdev-properties.h" #include "sysemu/runstate.h" @@ -531,6 +532,15 @@ ich9_lpc_pmcon_update(ICH9LPCState *lpc) uint16_t gen_pmcon_1 = pci_get_word(lpc->d.config + ICH9_LPC_GEN_PMCON_1); uint16_t wmask; + if (lpc->pm.swsmi_timer_enabled) { + ich9_pm_update_swsmi_timer( + &lpc->pm, lpc->pm.smi_en & ICH9_PMIO_SMI_EN_SWSMI_EN); + } + if (lpc->pm.periodic_timer_enabled) { + ich9_pm_update_periodic_timer( + &lpc->pm, lpc->pm.smi_en & ICH9_PMIO_SMI_EN_PERIODIC_EN); + } + if (gen_pmcon_1 & ICH9_LPC_GEN_PMCON_1_SMI_LOCK) { wmask = pci_get_word(lpc->d.wmask + ICH9_LPC_GEN_PMCON_1); wmask &= ~ICH9_LPC_GEN_PMCON_1_SMI_LOCK; @@ -826,6 +836,10 @@ static Property ich9_lpc_properties[] = { ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT, true), DEFINE_PROP_BIT64("x-smi-cpu-hotunplug", ICH9LPCState, smi_host_features, ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT, true), + DEFINE_PROP_BOOL("x-smi-swsmi-timer", ICH9LPCState, + pm.swsmi_timer_enabled, true), + DEFINE_PROP_BOOL("x-smi-periodic-timer", ICH9LPCState, + pm.periodic_timer_enabled, true), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/acpi/meson.build b/hw/acpi/meson.build index fa5c07db90..7f8ccc9b7a 100644 --- a/hw/acpi/meson.build +++ b/hw/acpi/meson.build @@ -24,7 +24,7 @@ acpi_ss.add(when: 'CONFIG_ACPI_PCI_BRIDGE', if_true: files('pci-bridge.c')) acpi_ss.add(when: 'CONFIG_ACPI_PCIHP', if_true: files('pcihp.c')) acpi_ss.add(when: 'CONFIG_ACPI_PCIHP', if_false: files('acpi-pci-hotplug-stub.c')) acpi_ss.add(when: 'CONFIG_ACPI_VIOT', if_true: files('viot.c')) -acpi_ss.add(when: 'CONFIG_ACPI_ICH9', if_true: files('ich9.c', 'ich9_tco.c')) +acpi_ss.add(when: 'CONFIG_ACPI_ICH9', if_true: files('ich9.c', 'ich9_tco.c', 'ich9_timer.c')) acpi_ss.add(when: 'CONFIG_ACPI_ERST', if_true: files('erst.c')) acpi_ss.add(when: 'CONFIG_IPMI', if_true: files('ipmi.c'), if_false: files('ipmi-stub.c')) acpi_ss.add(when: 'CONFIG_PC', if_false: files('acpi-x86-stub.c'))