From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691896; cv=none; d=zohomail.com; s=zohoarc; b=oAAF1nGUU/yJc7quVCNfsQjWSeFCLUUULB8TyeO5SjdjP63dQk8qynu7rcBduMBXp5CD9fgMz1+toosKTrcp3bNtuA1fQA6tcnEjpOUgow26eiY2eCErwgDuvre46bjApK7MUXTDort+JVBHUgaxQ74+bLmBxcNbYmTp5p1yuf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691896; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Rh5F3iR0qYWe5wSoBa0ieaCgok0ju7ghEdEEZdYuvW4=; b=ZrUS/1yCLW6dZyWE8oEZ/Qd1BvEA4pdcdsG3j6ADa7cgWL6qQYgrfizKuIWRNI4svqD6a6ZXhTWbNYi5wkNNgvba2DQjkoaWOh4rNqQsxy5iDXrc7savbiSytx6rqavfFWqXR3+d1ae9jbkZ6B6SGO6Md53pV+1KtiosdSUMsGw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175969189685666.89837186613704; Sun, 5 Oct 2025 12:18:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDi-0007S0-QM; Sun, 05 Oct 2025 15:16: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 1v5UDP-0007Q7-MH for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDN-0006Km-4U for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:15 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-543-DD5911nQON2KAqBq_ZY2iQ-1; Sun, 05 Oct 2025 15:16:08 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e3ed6540fso22341055e9.0 for ; Sun, 05 Oct 2025 12:16:07 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e61a020a3sm224357575e9.10.2025.10.05.12.16.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691769; 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=Rh5F3iR0qYWe5wSoBa0ieaCgok0ju7ghEdEEZdYuvW4=; b=FFM4cuSIIphc+7ES+LTdqeD/C725IcLPozJJUYwWcMWG1EOw/OJE0T5P1XhXFdmH4jCkqA XLwbduZwIVuldLTPj4bz5voUG0cOOVRgO1IP92ckO/+gN3ib5KbKfhuBL3YFBu+R69K2nd 3bthI/U8oCfYke0kamKI7kGMQtaMGrM= X-MC-Unique: DD5911nQON2KAqBq_ZY2iQ-1 X-Mimecast-MFC-AGG-ID: DD5911nQON2KAqBq_ZY2iQ_1759691767 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691766; x=1760296566; 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=Rh5F3iR0qYWe5wSoBa0ieaCgok0ju7ghEdEEZdYuvW4=; b=AaPlfeZH0Yr125ZaWeEs1occHRxj7MXbb11+lJ+Hj+0q5az1G2sRpoLx1mFZqij2Xj bt3wgzCFLV/j/hCuqDNnalXTG2n09LH+UkpyR6WoEZCTZGBihzOM+u3hzE4i5IyFALGC B/pkDfAfBhQvg08zvja0VUCZRaO9U5njqvdVXucvDhAJiHBPp/TBfzXVAGXi2WDOSX6l A7U3sLPhgFEyVjZNNLOuc9c2aRYKd/pekdN259xwxPObb6SuiQwrWvvM65siJ1yhqdgv CjBXX9huuAcF0P80VBk+UeaJ7YqchyEI6uLs78vK9we+yqwIyHxIhxiteE1LfkC/qnb6 gDkA== X-Gm-Message-State: AOJu0YxFo1Rs5SDrnCQeLG8GTAgWyuExm5ekH8thdYLfsIOul+iDcUC8 yU4tjMDdRISVe5DK769RAmEQYlaUy3+zO5mF3OSBDuwdS3Vh58MYtVpwQck4fFBNI0SDxBW1m55 AkjnDz0X+pHxrQZVn6t5MTghuaA1GlIJBQWw/SvdX6CVXwwXSUo5XtNf2FORIbOYEkUc0I3adFU 5wkOCodvnTscg3uXeaQPcxAVpGNofIGc/N8g== X-Gm-Gg: ASbGncsWOidzeMkpX1uOmToIKG3NxzotniT0/lWQfiq9XjJ8hj18G8q20CkH8sGGcfq B4L6k7uPepKavuOf8leSJVzR/yqVUy51vCp0EAUPoOUSmAJCPwsewSeeC3+a8WgByKcfPG17NiQ MXdGXw3mHv/JNsbB4caWNUA8acK0oR78MqjAWnduVQZIsSEN6kP1rMykd70n/hEBwEC4ubwiXUx OOHAkh8LvJ17ux8+KHbie320DaUgWdox35+F38kCo6KbG8TDC+xjYPegYZYO5Y52x+k3WQn/j13 xpLKWaV7pRzGoDdtB4KuBJqp0NWGV+RhEyDSpYw= X-Received: by 2002:a05:600c:45c9:b0:46e:3b58:1b40 with SMTP id 5b1f17b1804b1-46e70c49676mr78317155e9.4.1759691766429; Sun, 05 Oct 2025 12:16:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHALY+cypn8YkvnkXe8TwgZtAZG390MsUptzMg20MqiY8kzR8TGvURBMqeWjTOpmQ2py+Y5bQ== X-Received: by 2002:a05:600c:45c9:b0:46e:3b58:1b40 with SMTP id 5b1f17b1804b1-46e70c49676mr78316905e9.4.1759691765868; Sun, 05 Oct 2025 12:16:05 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:03 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Abeni , Lei Yang , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione Subject: [PULL 01/75] net: bundle all offloads in a single struct 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691899137116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni The set_offload() argument list is already pretty long and we are going to introduce soon a bunch of additional offloads. Replace the offload arguments with a single struct and update all the relevant call-sites. No functional changes intended. Signed-off-by: Paolo Abeni Tested-by: Lei Yang Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- include/net/net.h | 15 ++++++++++++--- net/tap_int.h | 4 ++-- hw/net/e1000e_core.c | 5 +++-- hw/net/igb_core.c | 5 +++-- hw/net/virtio-net.c | 19 +++++++++++-------- hw/net/vmxnet3.c | 13 +++++-------- net/net.c | 5 ++--- net/netmap.c | 3 +-- net/tap-bsd.c | 3 +-- net/tap-linux.c | 21 ++++++++++++--------- net/tap-solaris.c | 4 ++-- net/tap-stub.c | 3 +-- net/tap.c | 8 ++++---- 13 files changed, 59 insertions(+), 49 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 84ee18e0f9..48ba333d02 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -35,6 +35,16 @@ typedef struct NICConf { int32_t bootindex; } NICConf; =20 +typedef struct NetOffloads { + bool csum; + bool tso4; + bool tso6; + bool ecn; + bool ufo; + bool uso4; + bool uso6; +} NetOffloads; + #define DEFINE_NIC_PROPERTIES(_state, _conf) \ DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr), \ DEFINE_PROP_NETDEV("netdev", _state, _conf.peers) @@ -57,7 +67,7 @@ typedef bool (HasUfo)(NetClientState *); typedef bool (HasUso)(NetClientState *); typedef bool (HasVnetHdr)(NetClientState *); typedef bool (HasVnetHdrLen)(NetClientState *, int); -typedef void (SetOffload)(NetClientState *, int, int, int, int, int, int, = int); +typedef void (SetOffload)(NetClientState *, const NetOffloads *); typedef int (GetVnetHdrLen)(NetClientState *); typedef void (SetVnetHdrLen)(NetClientState *, int); typedef bool (GetVnetHashSupportedTypes)(NetClientState *, uint32_t *); @@ -189,8 +199,7 @@ bool qemu_has_ufo(NetClientState *nc); bool qemu_has_uso(NetClientState *nc); bool qemu_has_vnet_hdr(NetClientState *nc); bool qemu_has_vnet_hdr_len(NetClientState *nc, int len); -void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6, - int ecn, int ufo, int uso4, int uso6); +void qemu_set_offload(NetClientState *nc, const NetOffloads *ol); int qemu_get_vnet_hdr_len(NetClientState *nc); void qemu_set_vnet_hdr_len(NetClientState *nc, int len); bool qemu_get_vnet_hash_supported_types(NetClientState *nc, uint32_t *type= s); diff --git a/net/tap_int.h b/net/tap_int.h index 8857ff299d..f8bbe1cb0c 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -27,6 +27,7 @@ #define NET_TAP_INT_H =20 #include "qapi/qapi-types-net.h" +#include "net/net.h" =20 int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required, int mq_required, Error **errp); @@ -37,8 +38,7 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, = Error **errp); int tap_probe_vnet_hdr(int fd, Error **errp); int tap_probe_has_ufo(int fd); int tap_probe_has_uso(int fd); -void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int= ufo, - int uso4, int uso6); +void tap_fd_set_offload(int fd, const NetOffloads *ol); void tap_fd_set_vnet_hdr_len(int fd, int len); int tap_fd_set_vnet_le(int fd, int vnet_is_le); int tap_fd_set_vnet_be(int fd, int vnet_is_be); diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 06657bb3ac..8fef598b49 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -2822,8 +2822,9 @@ e1000e_update_rx_offloads(E1000ECore *core) trace_e1000e_rx_set_cso(cso_state); =20 if (core->has_vnet) { - qemu_set_offload(qemu_get_queue(core->owner_nic)->peer, - cso_state, 0, 0, 0, 0, 0, 0); + NetOffloads ol =3D { .csum =3D cso_state }; + + qemu_set_offload(qemu_get_queue(core->owner_nic)->peer, &ol); } } =20 diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 39e3ce1c8f..45d8fd795b 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -3058,8 +3058,9 @@ igb_update_rx_offloads(IGBCore *core) trace_e1000e_rx_set_cso(cso_state); =20 if (core->has_vnet) { - qemu_set_offload(qemu_get_queue(core->owner_nic)->peer, - cso_state, 0, 0, 0, 0, 0, 0); + NetOffloads ol =3D {.csum =3D cso_state }; + + qemu_set_offload(qemu_get_queue(core->owner_nic)->peer, &ol); } } =20 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 7848e26278..129bebd82e 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -773,14 +773,17 @@ static uint64_t virtio_net_bad_features(VirtIODevice = *vdev) =20 static void virtio_net_apply_guest_offloads(VirtIONet *n) { - qemu_set_offload(qemu_get_queue(n->nic)->peer, - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_CSUM)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_TSO4)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_TSO6)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_ECN)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_UFO)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_USO4)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_USO6))= ); + NetOffloads ol =3D { + .csum =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_C= SUM)), + .tso4 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_T= SO4)), + .tso6 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_T= SO6)), + .ecn =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_E= CN)), + .ufo =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= FO)), + .uso4 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= SO4)), + .uso6 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= SO6)), + }; + + qemu_set_offload(qemu_get_queue(n->nic)->peer, &ol); } =20 static uint64_t virtio_net_guest_offloads_by_features(uint64_t features) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index af73aa8ef2..03732375a7 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -1322,14 +1322,11 @@ static void vmxnet3_update_features(VMXNET3State *s) s->lro_supported, rxcso_supported, s->rx_vlan_stripping); if (s->peer_has_vhdr) { - qemu_set_offload(qemu_get_queue(s->nic)->peer, - rxcso_supported, - s->lro_supported, - s->lro_supported, - 0, - 0, - 0, - 0); + NetOffloads ol =3D { .csum =3D rxcso_supported, + .tso4 =3D s->lro_supported, + .tso6 =3D s->lro_supported }; + + qemu_set_offload(qemu_get_queue(s->nic)->peer, &ol); } } =20 diff --git a/net/net.c b/net/net.c index da275db86e..63872b6855 100644 --- a/net/net.c +++ b/net/net.c @@ -540,14 +540,13 @@ bool qemu_has_vnet_hdr_len(NetClientState *nc, int le= n) return nc->info->has_vnet_hdr_len(nc, len); } =20 -void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6, - int ecn, int ufo, int uso4, int uso6) +void qemu_set_offload(NetClientState *nc, const NetOffloads *ol) { if (!nc || !nc->info->set_offload) { return; } =20 - nc->info->set_offload(nc, csum, tso4, tso6, ecn, ufo, uso4, uso6); + nc->info->set_offload(nc, ol); } =20 int qemu_get_vnet_hdr_len(NetClientState *nc) diff --git a/net/netmap.c b/net/netmap.c index 297510e190..6cd8f2bdc5 100644 --- a/net/netmap.c +++ b/net/netmap.c @@ -366,8 +366,7 @@ static void netmap_set_vnet_hdr_len(NetClientState *nc,= int len) } } =20 -static void netmap_set_offload(NetClientState *nc, int csum, int tso4, int= tso6, - int ecn, int ufo, int uso4, int uso6) +static void netmap_set_offload(NetClientState *nc, const NetOffloads *ol) { NetmapState *s =3D DO_UPCAST(NetmapState, nc, nc); =20 diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 3f98d0ea82..38eb28cb58 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -239,8 +239,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) return -EINVAL; } =20 -void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +void tap_fd_set_offload(int fd, const NetOffloads *ol) { } =20 diff --git a/net/tap-linux.c b/net/tap-linux.c index e832810665..79a9dd0da0 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -244,8 +244,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) abort(); } =20 -void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +void tap_fd_set_offload(int fd, const NetOffloads *ol) { unsigned int offload =3D 0; =20 @@ -254,20 +253,24 @@ void tap_fd_set_offload(int fd, int csum, int tso4, return; } =20 - if (csum) { + if (ol->csum) { offload |=3D TUN_F_CSUM; - if (tso4) + if (ol->tso4) { offload |=3D TUN_F_TSO4; - if (tso6) + } + if (ol->tso6) { offload |=3D TUN_F_TSO6; - if ((tso4 || tso6) && ecn) + } + if ((ol->tso4 || ol->tso6) && ol->ecn) { offload |=3D TUN_F_TSO_ECN; - if (ufo) + } + if (ol->ufo) { offload |=3D TUN_F_UFO; - if (uso4) { + } + if (ol->uso4) { offload |=3D TUN_F_USO4; } - if (uso6) { + if (ol->uso6) { offload |=3D TUN_F_USO6; } } diff --git a/net/tap-solaris.c b/net/tap-solaris.c index af2ebb16f5..ef8e0feeb0 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -27,6 +27,7 @@ #include "tap_int.h" #include "qemu/ctype.h" #include "qemu/cutils.h" +#include "net/net.h" =20 #include #include @@ -240,8 +241,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) return -EINVAL; } =20 -void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +void tap_fd_set_offload(int fd, const NetOffloads *ol) { } =20 diff --git a/net/tap-stub.c b/net/tap-stub.c index 38673434cb..67d14ad4d5 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -66,8 +66,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) return -EINVAL; } =20 -void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +void tap_fd_set_offload(int fd, const NetOffloads *ol) { } =20 diff --git a/net/tap.c b/net/tap.c index f37133e301..df23283744 100644 --- a/net/tap.c +++ b/net/tap.c @@ -285,15 +285,14 @@ static int tap_set_vnet_be(NetClientState *nc, bool i= s_be) return tap_fd_set_vnet_be(s->fd, is_be); } =20 -static void tap_set_offload(NetClientState *nc, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +static void tap_set_offload(NetClientState *nc, const NetOffloads *ol) { TAPState *s =3D DO_UPCAST(TAPState, nc, nc); if (s->fd < 0) { return; } =20 - tap_fd_set_offload(s->fd, csum, tso4, tso6, ecn, ufo, uso4, uso6); + tap_fd_set_offload(s->fd, ol); } =20 static void tap_exit_notify(Notifier *notifier, void *data) @@ -391,6 +390,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer, int fd, int vnet_hdr) { + NetOffloads ol =3D {}; NetClientState *nc; TAPState *s; =20 @@ -404,7 +404,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer, s->has_ufo =3D tap_probe_has_ufo(s->fd); s->has_uso =3D tap_probe_has_uso(s->fd); s->enabled =3D true; - tap_set_offload(&s->nc, 0, 0, 0, 0, 0, 0, 0); + tap_set_offload(&s->nc, &ol); /* * Make sure host header length is set correctly in tap: * it might have been modified by another instance of qemu. --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691840; cv=none; d=zohomail.com; s=zohoarc; b=mxjLnZcBQEB0oa1nDTLB1coXmnPgLVj+alrbOl96B4oxKyXQJ01hqYXms6tuHsk9k7+bqwMyTd2przSuTI10KO48MDyUvy0yXNN92+KeQPGRBWBtu7ue6fZygjBvzORHh+PVeua+HsBW+yw54MGs5XPwccxXg3Fd9sQbiLRAai4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691840; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=O9X9dIbEl6s4Z3IkjW3gtvVAsBNJXdx9I4ylsa8ctmA=; b=GSy3o0NaBysAWBjOTlF2Lfs3Ibfo7PmbJ1u3RHoqCED8vXH6ks2OQ7vsmRwNGYITv+MwBqypk/HEcd+bUAnyuP/rvOhgXrsFg+DP4KP8iPAl9KxBoWe8C0phjvxnAm9hldbTnJXGqylGv9ZmWhbKaPcb4CbOCsXvFmKX9Gueu1A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691840961822.8982834666504; Sun, 5 Oct 2025 12:17:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDQ-0007Q6-IB; Sun, 05 Oct 2025 15:16:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDN-0007OW-R1 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDM-0006Kq-AM for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:13 -0400 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-551-9LVe8Q7GN9KZ0_BeGXzLUA-1; Sun, 05 Oct 2025 15:16:10 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3ee12ab7f33so2159087f8f.2 for ; Sun, 05 Oct 2025 12:16:09 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8e9762sm17448010f8f.38.2025.10.05.12.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691771; 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=O9X9dIbEl6s4Z3IkjW3gtvVAsBNJXdx9I4ylsa8ctmA=; b=Gq005mLTynf2QwTyB3o3+fwUpXpUefwWAa4/lM1lOL5tsit1Yz38fHxaf99tVoT/1AKSSm s9uMUMc2a5FlXGsAq35yVj34NDwfN9j1cRBWl3qxhLpVV/yy0ihxGFhswdLgtihdTvt4ry kP260pYUZvgIPSwdwxru2iP8lRUDUb4= X-MC-Unique: 9LVe8Q7GN9KZ0_BeGXzLUA-1 X-Mimecast-MFC-AGG-ID: 9LVe8Q7GN9KZ0_BeGXzLUA_1759691769 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691769; x=1760296569; 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=O9X9dIbEl6s4Z3IkjW3gtvVAsBNJXdx9I4ylsa8ctmA=; b=aBiPghS9svI3SQScQBFbUII/BQtRTc32fSgv18E7OqIwHn5Zg4tMrPmPpLrp4v44Uz 8Zbu10WwZWajSCoBjltpDZ+o1EA9ywsZMd9zRlF26q42yQ5/OjsyzDUUT69i5+DsMCHD YP4UeL+Aex1GLXpuPL8ESHBpgpbGMl3zYkGQu+SBNnWtESWILxoLF0G9fqReElONp4op Cb44pjKMgWY7BSMabzSnqC6BgACB+zIGJzPG09U377lO9oRIZwJTXkbKRHwK6F9r5RWB K4KDtghrA4IhIVoUU9cfSZH42bN/66Zds5Pmw3pIQv+fA8jdHcfHHNvAuwSJMCI+g9kP b/LA== X-Gm-Message-State: AOJu0YwAvKLvI6zwm58+yWSyWKnfFOgMOfIL/deFQgrk6Z4Y1U7DS6mt AP8slSHHClWvwAvW+UvMvhhY3kuO6FmEaU0EXYEUvtVfcfFl++sZl96kYwcS/zDGDNMdzjgLP3e QAL6Rd6EuNRZ6yoCdieYegpIjlwXrFfk+keu/+GCNWgoOe406IO63g0+ZtDuWOn+wZ1qJr1L30w wCJn0Ai0LYjKxNq1WbQkmt8jreRqMpaEe3Bg== X-Gm-Gg: ASbGncu+Bks7PQwRtWzTiWTyH6lzEOzjly6Xx6Fq2jARz35LTEBwpn0/KA5a6988vlC AWhmF6za2kO+1ugAfqep+LZd8paPPaEObieMiXD0sP+KzWz5tMinhnLfJsAYCz5jBaiBNJ34wD2 5MYx4dGrJd01P0ZoSeHqUkPPl7aYTYi/cbnkd3DNkly6t95HEErnLii+u94Hh6U6sNWrMQUQnpe 8ZazRZTF31c9nr28cvXOT4znHsMa9zJSmeHmyX8UNYvnrBt7OzAySrN5+NdwR168f6rLq7BOwNC bnjrLVcA18R1j/fle31kbM/Sk5lEnybyYgSqkCU= X-Received: by 2002:a05:6000:2401:b0:3ea:e0fd:28e8 with SMTP id ffacd0b85a97d-4256719e9c6mr5917257f8f.32.1759691768659; Sun, 05 Oct 2025 12:16:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOjobanu4yMzNe/1zq5h6ZXPy/A/BH9w8F+1A+e/yvEMTagvhieTZaj1Hz/o6LB4SeNmPQaw== X-Received: by 2002:a05:6000:2401:b0:3ea:e0fd:28e8 with SMTP id ffacd0b85a97d-4256719e9c6mr5917238f8f.32.1759691768061; Sun, 05 Oct 2025 12:16:08 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:06 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Abeni , Akihiko Odaki , Jason Wang , Stefano Garzarella , Lei Yang , Cornelia Huck , Paolo Bonzini Subject: [PULL 02/75] linux-headers: deal with counted_by annotation 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691851527116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni Such annotation is present into the kernel uAPI headers since v6.7, and will be used soon by the vhost_type.h. Deal with it just stripping it. Reviewed-by: Akihiko Odaki Acked-by: Jason Wang Acked-by: Stefano Garzarella Signed-off-by: Paolo Abeni Tested-by: Lei Yang Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- scripts/update-linux-headers.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers= .sh index 717c379f9e..64c0d7c4eb 100755 --- a/scripts/update-linux-headers.sh +++ b/scripts/update-linux-headers.sh @@ -90,6 +90,7 @@ cp_portable() { -e 's/]*\)>/"standard-headers\/linux\/\1"/' \ -e "$arch_cmd" \ -e 's/__bitwise//' \ + -e 's/__counted_by(\w*)//' \ -e 's/__attribute__((packed))/QEMU_PACKED/' \ -e 's/__inline__/inline/' \ -e 's/__BITS_PER_LONG/HOST_LONG_BITS/' \ --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691845; cv=none; d=zohomail.com; s=zohoarc; b=lhUAhwxYObZ95GdEGRYLLDrASYs7m1nrfTqWVit68kz//AS0W4cxVKz6YThhNhuXnOluyW8pCo3f4K8mKRTwBPHxoxszHRZSV5LNXA09yyxtPE3iPk60UNx2EIHz9W9dnxgYX4kdttbaKy3I88DKzaUy8C8jffSLtz7aXLD9g6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691845; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=co3VQJs0tdvZzjIbzfak6bX2un3VvU+zoV0UkR/KKBs=; b=Q09jlOZtDHbT3OOfk/9MiMPx8Gf8izuVu3RSS02vqtDSkyKg//qlOl/46vjVl4P7eOO9YKfbEUHPRZKmLIg0UB4WB0AIe9f1zZhCSg7qCmw0V9mTtVIRZI5725FtXY49O7ynjSdq7hgylsB5zwiaFQxEAhHUG379DpyT5dUVjYw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691845144890.4967039584408; Sun, 5 Oct 2025 12:17:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDj-0007Sw-Co; Sun, 05 Oct 2025 15:16:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDT-0007Qb-Jj for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:21 -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 1v5UDP-0006L2-ES for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:19 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-169-4l-_oLjLMwGOR0KnBGCwGQ-1; Sun, 05 Oct 2025 15:16:13 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e4cc8ed76so16591945e9.1 for ; Sun, 05 Oct 2025 12:16:12 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e723614c9sm122976045e9.14.2025.10.05.12.16.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691774; 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=co3VQJs0tdvZzjIbzfak6bX2un3VvU+zoV0UkR/KKBs=; b=hhsYY7RIZ+AL4GbQQpdL0sbhkwn6lK0qVqzCNL7jCStm/qickIlhH+ZBbVf8eYVT9M0Cgb YBXR1cSoCIKKEl/4ulMUnrqPvhmj/eTuT7zswCtYzux7Y57HGHiPARFdht8iRtOD87LKWn 3zF8AhBe25K/moUrO3kGs3W0abkaDqA= X-MC-Unique: 4l-_oLjLMwGOR0KnBGCwGQ-1 X-Mimecast-MFC-AGG-ID: 4l-_oLjLMwGOR0KnBGCwGQ_1759691772 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691772; x=1760296572; 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=co3VQJs0tdvZzjIbzfak6bX2un3VvU+zoV0UkR/KKBs=; b=fyutI3/Nn8fC6I12jQ+FdijXLNxTOI7wF4hxf04FTo0/ma8n4UST8vi3QBdnPAblmY hA+iTPHQrvsjvsTqEdllB4uYM49vJxTAm7fqJTqmXjFuIIXg9CZd3UEsqlB699zoRrUI MGN5z30j1u4mFXdQdkP8rp2TRE/icMR2D2LIpTWN5T4YmVCxu1E7+eoFHNgpgSfqDyiB zv1YvNhrytYOTmKcZ8EmxHa5O7eBMxJZ8hgVRGGg6sf80whmGMo18JbcDrusZowdlFEY CapL0H6c9HFBikst2uri2QHlCf7ksl7B6XvkJ1/rpd3NBpvvHekX979bhNDA9ZdOC69I S82g== X-Gm-Message-State: AOJu0YwYwilLxJaJ//GRtfyBfltVl5vXq1BhyHalX4gJX0mdBMeBOVa1 2vT583Vj+jaS6KgZxcaje5HKgZUztrmnH8ewz24lGhG3KUoebucYnuFeFWeTooS/LKcO+krSvcp XRyjxtB8uxkTkgX3xIL3ipqI6hJrfZ2xH8K6PwTyITBvy8TfGI6xh5RxEacPoKPUNZ9SX9nFTI/ HJWeyPM32fikfkRhpzYX0Uo1yzrs6CefpT9Q== X-Gm-Gg: ASbGncuiFRROC775MAtHyuuBguo4h1CC72ePtjCNcMd7G9jqOH+AY3j+o7BWuPytpwE drxw3+GarmaeqWZcsielcL5oW5iKQgCdXL2YOgfqIj5fSVAoDl/SY3NMTpJpl49TQw3c/cr6t/q lPjg3L/RU6/TJKgVueCOgu4PrGlD6K89Lry4A/lmJMuNr9fXQpFci4McY+nQ4b0UqMYbphzokb0 6vY8fRQGzAqRfd+A/1gCPVcQi80o8GVXSZQp9r0GmffKCR/5g7XbqKdBqR7N5pyfkJixV3O7ynK ciNAZuGemmzliJ/bDdN0Fmd2m6ibT/3t2ax6o5E= X-Received: by 2002:a05:600c:3d87:b0:46e:206a:78cc with SMTP id 5b1f17b1804b1-46e71144748mr58024575e9.28.1759691771201; Sun, 05 Oct 2025 12:16:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQ2Bj5/JQuSV1uFr1EsIq8o65PRmM5LUx85rgj5OQ0OucEKxUAEadpGhJ4HfrHIJF/BPCgGg== X-Received: by 2002:a05:600c:3d87:b0:46e:206a:78cc with SMTP id 5b1f17b1804b1-46e71144748mr58024345e9.28.1759691770413; Sun, 05 Oct 2025 12:16:10 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Abeni , Akihiko Odaki , Jason Wang , Lei Yang , Stefano Garzarella , Cornelia Huck , Paolo Bonzini , kvm@vger.kernel.org Subject: [PULL 03/75] linux-headers: Update to Linux v6.17-rc1 Message-ID: <8de6cd5452eb9c58c0d105dbc9718bd0e83cc70f.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691862030116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni Update headers to include the virtio GSO over UDP tunnel features Reviewed-by: Akihiko Odaki Acked-by: Jason Wang Signed-off-by: Paolo Abeni Tested-by: Lei Yang Acked-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin Message-ID: <0b1f3c011f90583ab52aa4fef04df6db35cc4a69.1758549625.git.pabeni= @redhat.com> Signed-off-by: Michael S. Tsirkin --- include/standard-headers/drm/drm_fourcc.h | 56 ++++++- include/standard-headers/linux/ethtool.h | 4 +- .../linux/input-event-codes.h | 8 + include/standard-headers/linux/input.h | 1 + include/standard-headers/linux/pci_regs.h | 9 + include/standard-headers/linux/vhost_types.h | 5 + include/standard-headers/linux/virtio_net.h | 33 ++++ linux-headers/asm-arm64/unistd_64.h | 2 + linux-headers/asm-generic/unistd.h | 8 +- linux-headers/asm-loongarch/unistd_64.h | 2 + linux-headers/asm-mips/unistd_n32.h | 2 + linux-headers/asm-mips/unistd_n64.h | 2 + linux-headers/asm-mips/unistd_o32.h | 2 + linux-headers/asm-powerpc/kvm.h | 13 -- linux-headers/asm-powerpc/unistd_32.h | 2 + linux-headers/asm-powerpc/unistd_64.h | 2 + linux-headers/asm-riscv/kvm.h | 1 + linux-headers/asm-riscv/unistd_32.h | 2 + linux-headers/asm-riscv/unistd_64.h | 2 + linux-headers/asm-s390/unistd_32.h | 2 + linux-headers/asm-s390/unistd_64.h | 2 + linux-headers/asm-x86/unistd_32.h | 2 + linux-headers/asm-x86/unistd_64.h | 2 + linux-headers/asm-x86/unistd_x32.h | 2 + linux-headers/linux/iommufd.h | 154 +++++++++++++++++- linux-headers/linux/kvm.h | 2 + linux-headers/linux/vfio.h | 12 +- linux-headers/linux/vhost.h | 35 ++++ linux-headers/LICENSES/preferred/GPL-2.0 | 10 +- 29 files changed, 352 insertions(+), 27 deletions(-) diff --git a/include/standard-headers/drm/drm_fourcc.h b/include/standard-h= eaders/drm/drm_fourcc.h index c8309d378b..cef077dfb3 100644 --- a/include/standard-headers/drm/drm_fourcc.h +++ b/include/standard-headers/drm/drm_fourcc.h @@ -209,6 +209,10 @@ extern "C" { #define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0') /* [31:0] R= :G:B:A 10:10:10:2 little endian */ #define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') /* [31:0] B= :G:R:A 10:10:10:2 little endian */ =20 +/* 48 bpp RGB */ +#define DRM_FORMAT_RGB161616 fourcc_code('R', 'G', '4', '8') /* [47:0] R:G= :B 16:16:16 little endian */ +#define DRM_FORMAT_BGR161616 fourcc_code('B', 'G', '4', '8') /* [47:0] B:G= :R 16:16:16 little endian */ + /* 64 bpp RGB */ #define DRM_FORMAT_XRGB16161616 fourcc_code('X', 'R', '4', '8') /* [63:0] = x:R:G:B 16:16:16:16 little endian */ #define DRM_FORMAT_XBGR16161616 fourcc_code('X', 'B', '4', '8') /* [63:0] = x:B:G:R 16:16:16:16 little endian */ @@ -217,7 +221,7 @@ extern "C" { #define DRM_FORMAT_ABGR16161616 fourcc_code('A', 'B', '4', '8') /* [63:0] = A:B:G:R 16:16:16:16 little endian */ =20 /* - * Floating point 64bpp RGB + * Half-Floating point - 16b/component * IEEE 754-2008 binary16 half-precision float * [15:0] sign:exponent:mantissa 1:5:10 */ @@ -227,6 +231,20 @@ extern "C" { #define DRM_FORMAT_ARGB16161616F fourcc_code('A', 'R', '4', 'H') /* [63:0]= A:R:G:B 16:16:16:16 little endian */ #define DRM_FORMAT_ABGR16161616F fourcc_code('A', 'B', '4', 'H') /* [63:0]= A:B:G:R 16:16:16:16 little endian */ =20 +#define DRM_FORMAT_R16F fourcc_code('R', ' ', ' ', 'H') /* [15:0]= R 16 little endian */ +#define DRM_FORMAT_GR1616F fourcc_code('G', 'R', ' ', 'H') /* [31:0]= G:R 16:16 little endian */ +#define DRM_FORMAT_BGR161616F fourcc_code('B', 'G', 'R', 'H') /* [47:0]= B:G:R 16:16:16 little endian */ + +/* + * Floating point - 32b/component + * IEEE 754-2008 binary32 float + * [31:0] sign:exponent:mantissa 1:8:23 + */ +#define DRM_FORMAT_R32F fourcc_code('R', ' ', ' ', 'F') /* [31:0]= R 32 little endian */ +#define DRM_FORMAT_GR3232F fourcc_code('G', 'R', ' ', 'F') /* [63:0]= R:G 32:32 little endian */ +#define DRM_FORMAT_BGR323232F fourcc_code('B', 'G', 'R', 'F') /* [95:0]= R:G:B 32:32:32 little endian */ +#define DRM_FORMAT_ABGR32323232F fourcc_code('A', 'B', '8', 'F') /* [127:0= ] R:G:B:A 32:32:32:32 little endian */ + /* * RGBA format with 10-bit components packed in 64-bit per pixel, with 6 b= its * of unused padding per component: @@ -376,6 +394,42 @@ extern "C" { */ #define DRM_FORMAT_Q401 fourcc_code('Q', '4', '0', '1') =20 +/* + * 3 plane YCbCr LSB aligned + * In order to use these formats in a similar fashion to MSB aligned ones + * implementation can multiply the values by 2^6=3D64. For that reason the= padding + * must only contain zeros. + * index 0 =3D Y plane, [15:0] z:Y [6:10] little endian + * index 1 =3D Cr plane, [15:0] z:Cr [6:10] little endian + * index 2 =3D Cb plane, [15:0] z:Cb [6:10] little endian + */ +#define DRM_FORMAT_S010 fourcc_code('S', '0', '1', '0') /* 2x2 subsampled = Cb (1) and Cr (2) planes 10 bits per channel */ +#define DRM_FORMAT_S210 fourcc_code('S', '2', '1', '0') /* 2x1 subsampled = Cb (1) and Cr (2) planes 10 bits per channel */ +#define DRM_FORMAT_S410 fourcc_code('S', '4', '1', '0') /* non-subsampled = Cb (1) and Cr (2) planes 10 bits per channel */ + +/* + * 3 plane YCbCr LSB aligned + * In order to use these formats in a similar fashion to MSB aligned ones + * implementation can multiply the values by 2^4=3D16. For that reason the= padding + * must only contain zeros. + * index 0 =3D Y plane, [15:0] z:Y [4:12] little endian + * index 1 =3D Cr plane, [15:0] z:Cr [4:12] little endian + * index 2 =3D Cb plane, [15:0] z:Cb [4:12] little endian + */ +#define DRM_FORMAT_S012 fourcc_code('S', '0', '1', '2') /* 2x2 subsampled = Cb (1) and Cr (2) planes 12 bits per channel */ +#define DRM_FORMAT_S212 fourcc_code('S', '2', '1', '2') /* 2x1 subsampled = Cb (1) and Cr (2) planes 12 bits per channel */ +#define DRM_FORMAT_S412 fourcc_code('S', '4', '1', '2') /* non-subsampled = Cb (1) and Cr (2) planes 12 bits per channel */ + +/* + * 3 plane YCbCr + * index 0 =3D Y plane, [15:0] Y little endian + * index 1 =3D Cr plane, [15:0] Cr little endian + * index 2 =3D Cb plane, [15:0] Cb little endian + */ +#define DRM_FORMAT_S016 fourcc_code('S', '0', '1', '6') /* 2x2 subsampled = Cb (1) and Cr (2) planes 16 bits per channel */ +#define DRM_FORMAT_S216 fourcc_code('S', '2', '1', '6') /* 2x1 subsampled = Cb (1) and Cr (2) planes 16 bits per channel */ +#define DRM_FORMAT_S416 fourcc_code('S', '4', '1', '6') /* non-subsampled = Cb (1) and Cr (2) planes 16 bits per channel */ + /* * 3 plane YCbCr * index 0: Y plane, [7:0] Y diff --git a/include/standard-headers/linux/ethtool.h b/include/standard-he= aders/linux/ethtool.h index cef0d207a6..eb80314028 100644 --- a/include/standard-headers/linux/ethtool.h +++ b/include/standard-headers/linux/ethtool.h @@ -2314,7 +2314,7 @@ enum { IPV6_USER_FLOW =3D 0x0e, /* spec only (usr_ip6_spec; nfc only) */ IPV4_FLOW =3D 0x10, /* hash only */ IPV6_FLOW =3D 0x11, /* hash only */ - ETHER_FLOW =3D 0x12, /* spec only (ether_spec) */ + ETHER_FLOW =3D 0x12, /* hash or spec (ether_spec) */ =20 /* Used for GTP-U IPv4 and IPv6. * The format of GTP packets only includes @@ -2371,7 +2371,7 @@ enum { /* Flag to enable RSS spreading of traffic matching rule (nfc only) */ #define FLOW_RSS 0x20000000 =20 -/* L3-L4 network traffic flow hash options */ +/* L2-L4 network traffic flow hash options */ #define RXH_L2DA (1 << 1) #define RXH_VLAN (1 << 2) #define RXH_L3_PROTO (1 << 3) diff --git a/include/standard-headers/linux/input-event-codes.h b/include/s= tandard-headers/linux/input-event-codes.h index a82ff795e0..00dc9caac9 100644 --- a/include/standard-headers/linux/input-event-codes.h +++ b/include/standard-headers/linux/input-event-codes.h @@ -601,6 +601,11 @@ #define BTN_DPAD_LEFT 0x222 #define BTN_DPAD_RIGHT 0x223 =20 +#define BTN_GRIPL 0x224 +#define BTN_GRIPR 0x225 +#define BTN_GRIPL2 0x226 +#define BTN_GRIPR2 0x227 + #define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */ #define KEY_ROTATE_LOCK_TOGGLE 0x231 /* Display rotation lock */ #define KEY_REFRESH_RATE_TOGGLE 0x232 /* Display refresh rate toggle */ @@ -765,6 +770,9 @@ #define KEY_KBD_LCD_MENU4 0x2bb #define KEY_KBD_LCD_MENU5 0x2bc =20 +/* Performance Boost key (Alienware)/G-Mode key (Dell) */ +#define KEY_PERFORMANCE 0x2bd + #define BTN_TRIGGER_HAPPY 0x2c0 #define BTN_TRIGGER_HAPPY1 0x2c0 #define BTN_TRIGGER_HAPPY2 0x2c1 diff --git a/include/standard-headers/linux/input.h b/include/standard-head= ers/linux/input.h index 942ea6aaa9..d4512c20b5 100644 --- a/include/standard-headers/linux/input.h +++ b/include/standard-headers/linux/input.h @@ -272,6 +272,7 @@ struct input_mask { #define BUS_CEC 0x1E #define BUS_INTEL_ISHTP 0x1F #define BUS_AMD_SFH 0x20 +#define BUS_SDW 0x21 =20 /* * MT_TOOL types diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-h= eaders/linux/pci_regs.h index a3a3e942de..f5b17745de 100644 --- a/include/standard-headers/linux/pci_regs.h +++ b/include/standard-headers/linux/pci_regs.h @@ -745,6 +745,7 @@ #define PCI_EXT_CAP_ID_L1SS 0x1E /* L1 PM Substates */ #define PCI_EXT_CAP_ID_PTM 0x1F /* Precision Time Measurement */ #define PCI_EXT_CAP_ID_DVSEC 0x23 /* Designated Vendor-Specific */ +#define PCI_EXT_CAP_ID_VF_REBAR 0x24 /* VF Resizable BAR */ #define PCI_EXT_CAP_ID_DLF 0x25 /* Data Link Feature */ #define PCI_EXT_CAP_ID_PL_16GT 0x26 /* Physical Layer 16.0 GT/s */ #define PCI_EXT_CAP_ID_NPEM 0x29 /* Native PCIe Enclosure Management */ @@ -1141,6 +1142,14 @@ #define PCI_DVSEC_HEADER2 0x8 /* Designated Vendor-Specific Header2 */ #define PCI_DVSEC_HEADER2_ID(x) ((x) & 0xffff) =20 +/* VF Resizable BARs, same layout as PCI_REBAR */ +#define PCI_VF_REBAR_CAP PCI_REBAR_CAP +#define PCI_VF_REBAR_CAP_SIZES PCI_REBAR_CAP_SIZES +#define PCI_VF_REBAR_CTRL PCI_REBAR_CTRL +#define PCI_VF_REBAR_CTRL_BAR_IDX PCI_REBAR_CTRL_BAR_IDX +#define PCI_VF_REBAR_CTRL_NBAR_MASK PCI_REBAR_CTRL_NBAR_MASK +#define PCI_VF_REBAR_CTRL_BAR_SIZE PCI_REBAR_CTRL_BAR_SIZE + /* Data Link Feature */ #define PCI_DLF_CAP 0x04 /* Capabilities Register */ #define PCI_DLF_EXCHANGE_ENABLE 0x80000000 /* Data Link Feature Exchange= Enable */ diff --git a/include/standard-headers/linux/vhost_types.h b/include/standar= d-headers/linux/vhost_types.h index fd54044936..79b53a931a 100644 --- a/include/standard-headers/linux/vhost_types.h +++ b/include/standard-headers/linux/vhost_types.h @@ -110,6 +110,11 @@ struct vhost_msg_v2 { }; }; =20 +struct vhost_features_array { + uint64_t count; /* number of entries present in features array */ + uint64_t features[] ; +}; + struct vhost_memory_region { uint64_t guest_phys_addr; uint64_t memory_size; /* bytes */ diff --git a/include/standard-headers/linux/virtio_net.h b/include/standard= -headers/linux/virtio_net.h index 982e854f14..93abaae0b9 100644 --- a/include/standard-headers/linux/virtio_net.h +++ b/include/standard-headers/linux/virtio_net.h @@ -70,6 +70,28 @@ * with the same MAC. */ #define VIRTIO_NET_F_SPEED_DUPLEX 63 /* Device set linkspeed and duplex */ +#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO 65 /* Driver can receive + * GSO-over-UDP-tunnel packets + */ +#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM 66 /* Driver handles + * GSO-over-UDP-tunnel + * packets with partial csum + * for the outer header + */ +#define VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO 67 /* Device can receive + * GSO-over-UDP-tunnel packets + */ +#define VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM 68 /* Device handles + * GSO-over-UDP-tunnel + * packets with partial csum + * for the outer header + */ + +/* Offloads bits corresponding to VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO{,_CSUM} + * features + */ +#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_MAPPED 46 +#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM_MAPPED 47 =20 #ifndef VIRTIO_NET_NO_LEGACY #define VIRTIO_NET_F_GSO 6 /* Host handles pkts w/ any GSO type */ @@ -131,12 +153,17 @@ struct virtio_net_hdr_v1 { #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */ #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */ #define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc info in csum_ fields */ +#define VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM 8 /* UDP tunnel csum offload */ uint8_t flags; #define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */ #define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */ #define VIRTIO_NET_HDR_GSO_UDP 3 /* GSO frame, IPv4 UDP (UFO) */ #define VIRTIO_NET_HDR_GSO_TCPV6 4 /* GSO frame, IPv6 TCP */ #define VIRTIO_NET_HDR_GSO_UDP_L4 5 /* GSO frame, IPv4& IPv6 UDP (USO) */ +#define VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4 0x20 /* UDPv4 tunnel present */ +#define VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6 0x40 /* UDPv6 tunnel present */ +#define VIRTIO_NET_HDR_GSO_UDP_TUNNEL (VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4 = | \ + VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6) #define VIRTIO_NET_HDR_GSO_ECN 0x80 /* TCP has ECN set */ uint8_t gso_type; __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ @@ -181,6 +208,12 @@ struct virtio_net_hdr_v1_hash { uint16_t padding; }; =20 +struct virtio_net_hdr_v1_hash_tunnel { + struct virtio_net_hdr_v1_hash hash_hdr; + uint16_t outer_th_offset; + uint16_t inner_nh_offset; +}; + #ifndef VIRTIO_NET_NO_LEGACY /* This header comes first in the scatter-gather list. * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must diff --git a/linux-headers/asm-arm64/unistd_64.h b/linux-headers/asm-arm64/= unistd_64.h index ee9aaebdf3..4ae25c2b91 100644 --- a/linux-headers/asm-arm64/unistd_64.h +++ b/linux-headers/asm-arm64/unistd_64.h @@ -324,6 +324,8 @@ #define __NR_listxattrat 465 #define __NR_removexattrat 466 #define __NR_open_tree_attr 467 +#define __NR_file_getattr 468 +#define __NR_file_setattr 469 =20 =20 #endif /* _ASM_UNISTD_64_H */ diff --git a/linux-headers/asm-generic/unistd.h b/linux-headers/asm-generic= /unistd.h index 2892a45023..04e0077fb4 100644 --- a/linux-headers/asm-generic/unistd.h +++ b/linux-headers/asm-generic/unistd.h @@ -852,8 +852,14 @@ __SYSCALL(__NR_removexattrat, sys_removexattrat) #define __NR_open_tree_attr 467 __SYSCALL(__NR_open_tree_attr, sys_open_tree_attr) =20 +/* fs/inode.c */ +#define __NR_file_getattr 468 +__SYSCALL(__NR_file_getattr, sys_file_getattr) +#define __NR_file_setattr 469 +__SYSCALL(__NR_file_setattr, sys_file_setattr) + #undef __NR_syscalls -#define __NR_syscalls 468 +#define __NR_syscalls 470 =20 /* * 32 bit systems traditionally used different diff --git a/linux-headers/asm-loongarch/unistd_64.h b/linux-headers/asm-lo= ongarch/unistd_64.h index 50d22df8f7..5033fc8f2f 100644 --- a/linux-headers/asm-loongarch/unistd_64.h +++ b/linux-headers/asm-loongarch/unistd_64.h @@ -320,6 +320,8 @@ #define __NR_listxattrat 465 #define __NR_removexattrat 466 #define __NR_open_tree_attr 467 +#define __NR_file_getattr 468 +#define __NR_file_setattr 469 =20 =20 #endif /* _ASM_UNISTD_64_H */ diff --git a/linux-headers/asm-mips/unistd_n32.h b/linux-headers/asm-mips/u= nistd_n32.h index bdcc2f460b..c99c10e5bf 100644 --- a/linux-headers/asm-mips/unistd_n32.h +++ b/linux-headers/asm-mips/unistd_n32.h @@ -396,5 +396,7 @@ #define __NR_listxattrat (__NR_Linux + 465) #define __NR_removexattrat (__NR_Linux + 466) #define __NR_open_tree_attr (__NR_Linux + 467) +#define __NR_file_getattr (__NR_Linux + 468) +#define __NR_file_setattr (__NR_Linux + 469) =20 #endif /* _ASM_UNISTD_N32_H */ diff --git a/linux-headers/asm-mips/unistd_n64.h b/linux-headers/asm-mips/u= nistd_n64.h index 3b6b0193b6..0d975bb185 100644 --- a/linux-headers/asm-mips/unistd_n64.h +++ b/linux-headers/asm-mips/unistd_n64.h @@ -372,5 +372,7 @@ #define __NR_listxattrat (__NR_Linux + 465) #define __NR_removexattrat (__NR_Linux + 466) #define __NR_open_tree_attr (__NR_Linux + 467) +#define __NR_file_getattr (__NR_Linux + 468) +#define __NR_file_setattr (__NR_Linux + 469) =20 #endif /* _ASM_UNISTD_N64_H */ diff --git a/linux-headers/asm-mips/unistd_o32.h b/linux-headers/asm-mips/u= nistd_o32.h index 4609a4b4d3..86ac0ac84b 100644 --- a/linux-headers/asm-mips/unistd_o32.h +++ b/linux-headers/asm-mips/unistd_o32.h @@ -442,5 +442,7 @@ #define __NR_listxattrat (__NR_Linux + 465) #define __NR_removexattrat (__NR_Linux + 466) #define __NR_open_tree_attr (__NR_Linux + 467) +#define __NR_file_getattr (__NR_Linux + 468) +#define __NR_file_setattr (__NR_Linux + 469) =20 #endif /* _ASM_UNISTD_O32_H */ diff --git a/linux-headers/asm-powerpc/kvm.h b/linux-headers/asm-powerpc/kv= m.h index eaeda00178..077c5437f5 100644 --- a/linux-headers/asm-powerpc/kvm.h +++ b/linux-headers/asm-powerpc/kvm.h @@ -1,18 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ /* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2, as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US= A. - * * Copyright IBM Corp. 2007 * * Authors: Hollis Blanchard diff --git a/linux-headers/asm-powerpc/unistd_32.h b/linux-headers/asm-powe= rpc/unistd_32.h index 5d38a427e0..d7a32c5e06 100644 --- a/linux-headers/asm-powerpc/unistd_32.h +++ b/linux-headers/asm-powerpc/unistd_32.h @@ -449,6 +449,8 @@ #define __NR_listxattrat 465 #define __NR_removexattrat 466 #define __NR_open_tree_attr 467 +#define __NR_file_getattr 468 +#define __NR_file_setattr 469 =20 =20 #endif /* _ASM_UNISTD_32_H */ diff --git a/linux-headers/asm-powerpc/unistd_64.h b/linux-headers/asm-powe= rpc/unistd_64.h index 860a488e4d..ff35c51fc6 100644 --- a/linux-headers/asm-powerpc/unistd_64.h +++ b/linux-headers/asm-powerpc/unistd_64.h @@ -421,6 +421,8 @@ #define __NR_listxattrat 465 #define __NR_removexattrat 466 #define __NR_open_tree_attr 467 +#define __NR_file_getattr 468 +#define __NR_file_setattr 469 =20 =20 #endif /* _ASM_UNISTD_64_H */ diff --git a/linux-headers/asm-riscv/kvm.h b/linux-headers/asm-riscv/kvm.h index 5f59fd226c..ef27d4289d 100644 --- a/linux-headers/asm-riscv/kvm.h +++ b/linux-headers/asm-riscv/kvm.h @@ -18,6 +18,7 @@ #define __KVM_HAVE_IRQ_LINE =20 #define KVM_COALESCED_MMIO_PAGE_OFFSET 1 +#define KVM_DIRTY_LOG_PAGE_OFFSET 64 =20 #define KVM_INTERRUPT_SET -1U #define KVM_INTERRUPT_UNSET -2U diff --git a/linux-headers/asm-riscv/unistd_32.h b/linux-headers/asm-riscv/= unistd_32.h index a5e769f1d9..6083373e88 100644 --- a/linux-headers/asm-riscv/unistd_32.h +++ b/linux-headers/asm-riscv/unistd_32.h @@ -315,6 +315,8 @@ #define __NR_listxattrat 465 #define __NR_removexattrat 466 #define __NR_open_tree_attr 467 +#define __NR_file_getattr 468 +#define __NR_file_setattr 469 =20 =20 #endif /* _ASM_UNISTD_32_H */ diff --git a/linux-headers/asm-riscv/unistd_64.h b/linux-headers/asm-riscv/= unistd_64.h index 8df4d64841..f0c7585c60 100644 --- a/linux-headers/asm-riscv/unistd_64.h +++ b/linux-headers/asm-riscv/unistd_64.h @@ -325,6 +325,8 @@ #define __NR_listxattrat 465 #define __NR_removexattrat 466 #define __NR_open_tree_attr 467 +#define __NR_file_getattr 468 +#define __NR_file_setattr 469 =20 =20 #endif /* _ASM_UNISTD_64_H */ diff --git a/linux-headers/asm-s390/unistd_32.h b/linux-headers/asm-s390/un= istd_32.h index 85eedbd18e..37b8f6f358 100644 --- a/linux-headers/asm-s390/unistd_32.h +++ b/linux-headers/asm-s390/unistd_32.h @@ -440,5 +440,7 @@ #define __NR_listxattrat 465 #define __NR_removexattrat 466 #define __NR_open_tree_attr 467 +#define __NR_file_getattr 468 +#define __NR_file_setattr 469 =20 #endif /* _ASM_S390_UNISTD_32_H */ diff --git a/linux-headers/asm-s390/unistd_64.h b/linux-headers/asm-s390/un= istd_64.h index c03b1b9701..0652ba6331 100644 --- a/linux-headers/asm-s390/unistd_64.h +++ b/linux-headers/asm-s390/unistd_64.h @@ -388,5 +388,7 @@ #define __NR_listxattrat 465 #define __NR_removexattrat 466 #define __NR_open_tree_attr 467 +#define __NR_file_getattr 468 +#define __NR_file_setattr 469 =20 #endif /* _ASM_S390_UNISTD_64_H */ diff --git a/linux-headers/asm-x86/unistd_32.h b/linux-headers/asm-x86/unis= td_32.h index 491d6b4eb6..8f784a5634 100644 --- a/linux-headers/asm-x86/unistd_32.h +++ b/linux-headers/asm-x86/unistd_32.h @@ -458,6 +458,8 @@ #define __NR_listxattrat 465 #define __NR_removexattrat 466 #define __NR_open_tree_attr 467 +#define __NR_file_getattr 468 +#define __NR_file_setattr 469 =20 =20 #endif /* _ASM_UNISTD_32_H */ diff --git a/linux-headers/asm-x86/unistd_64.h b/linux-headers/asm-x86/unis= td_64.h index 7cf88bf9bd..2f55bebb81 100644 --- a/linux-headers/asm-x86/unistd_64.h +++ b/linux-headers/asm-x86/unistd_64.h @@ -381,6 +381,8 @@ #define __NR_listxattrat 465 #define __NR_removexattrat 466 #define __NR_open_tree_attr 467 +#define __NR_file_getattr 468 +#define __NR_file_setattr 469 =20 =20 #endif /* _ASM_UNISTD_64_H */ diff --git a/linux-headers/asm-x86/unistd_x32.h b/linux-headers/asm-x86/uni= std_x32.h index 82959111e6..8cc8673f15 100644 --- a/linux-headers/asm-x86/unistd_x32.h +++ b/linux-headers/asm-x86/unistd_x32.h @@ -334,6 +334,8 @@ #define __NR_listxattrat (__X32_SYSCALL_BIT + 465) #define __NR_removexattrat (__X32_SYSCALL_BIT + 466) #define __NR_open_tree_attr (__X32_SYSCALL_BIT + 467) +#define __NR_file_getattr (__X32_SYSCALL_BIT + 468) +#define __NR_file_setattr (__X32_SYSCALL_BIT + 469) #define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512) #define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513) #define __NR_ioctl (__X32_SYSCALL_BIT + 514) diff --git a/linux-headers/linux/iommufd.h b/linux-headers/linux/iommufd.h index cb0f7d6b4d..2105a03955 100644 --- a/linux-headers/linux/iommufd.h +++ b/linux-headers/linux/iommufd.h @@ -56,6 +56,7 @@ enum { IOMMUFD_CMD_VDEVICE_ALLOC =3D 0x91, IOMMUFD_CMD_IOAS_CHANGE_PROCESS =3D 0x92, IOMMUFD_CMD_VEVENTQ_ALLOC =3D 0x93, + IOMMUFD_CMD_HW_QUEUE_ALLOC =3D 0x94, }; =20 /** @@ -590,17 +591,44 @@ struct iommu_hw_info_arm_smmuv3 { __u32 aidr; }; =20 +/** + * struct iommu_hw_info_tegra241_cmdqv - NVIDIA Tegra241 CMDQV Hardware + * Information (IOMMU_HW_INFO_TYPE_TEGRA241_CMDQV) + * + * @flags: Must be 0 + * @version: Version number for the CMDQ-V HW for PARAM bits[03:00] + * @log2vcmdqs: Log2 of the total number of VCMDQs for PARAM bits[07:04] + * @log2vsids: Log2 of the total number of SID replacements for PARAM bits= [15:12] + * @__reserved: Must be 0 + * + * VMM can use these fields directly in its emulated global PARAM register= . Note + * that only one Virtual Interface (VINTF) should be exposed to a VM, i.e.= PARAM + * bits[11:08] should be set to 0 for log2 of the total number of VINTFs. + */ +struct iommu_hw_info_tegra241_cmdqv { + __u32 flags; + __u8 version; + __u8 log2vcmdqs; + __u8 log2vsids; + __u8 __reserved; +}; + /** * enum iommu_hw_info_type - IOMMU Hardware Info Types - * @IOMMU_HW_INFO_TYPE_NONE: Used by the drivers that do not report hardwa= re + * @IOMMU_HW_INFO_TYPE_NONE: Output by the drivers that do not report hard= ware * info + * @IOMMU_HW_INFO_TYPE_DEFAULT: Input to request for a default type * @IOMMU_HW_INFO_TYPE_INTEL_VTD: Intel VT-d iommu info type * @IOMMU_HW_INFO_TYPE_ARM_SMMUV3: ARM SMMUv3 iommu info type + * @IOMMU_HW_INFO_TYPE_TEGRA241_CMDQV: NVIDIA Tegra241 CMDQV (extension fo= r ARM + * SMMUv3) info type */ enum iommu_hw_info_type { IOMMU_HW_INFO_TYPE_NONE =3D 0, + IOMMU_HW_INFO_TYPE_DEFAULT =3D 0, IOMMU_HW_INFO_TYPE_INTEL_VTD =3D 1, IOMMU_HW_INFO_TYPE_ARM_SMMUV3 =3D 2, + IOMMU_HW_INFO_TYPE_TEGRA241_CMDQV =3D 3, }; =20 /** @@ -625,6 +653,15 @@ enum iommufd_hw_capabilities { IOMMU_HW_CAP_PCI_PASID_PRIV =3D 1 << 2, }; =20 +/** + * enum iommufd_hw_info_flags - Flags for iommu_hw_info + * @IOMMU_HW_INFO_FLAG_INPUT_TYPE: If set, @in_data_type carries an input = type + * for user space to request for a specifi= c info + */ +enum iommufd_hw_info_flags { + IOMMU_HW_INFO_FLAG_INPUT_TYPE =3D 1 << 0, +}; + /** * struct iommu_hw_info - ioctl(IOMMU_GET_HW_INFO) * @size: sizeof(struct iommu_hw_info) @@ -634,6 +671,12 @@ enum iommufd_hw_capabilities { * data that kernel supports * @data_uptr: User pointer to a user-space buffer used by the kernel to f= ill * the iommu type specific hardware information data + * @in_data_type: This shares the same field with @out_data_type, making i= t be + * a bidirectional field. When IOMMU_HW_INFO_FLAG_INPUT_TYP= E is + * set, an input type carried via this @in_data_type field = will + * be valid, requesting for the info data to the given type= . If + * IOMMU_HW_INFO_FLAG_INPUT_TYPE is unset, any input value = will + * be seen as IOMMU_HW_INFO_TYPE_DEFAULT * @out_data_type: Output the iommu hardware info type as defined in the e= num * iommu_hw_info_type. * @out_capabilities: Output the generic iommu capability info type as def= ined @@ -663,7 +706,10 @@ struct iommu_hw_info { __u32 dev_id; __u32 data_len; __aligned_u64 data_uptr; - __u32 out_data_type; + union { + __u32 in_data_type; + __u32 out_data_type; + }; __u8 out_max_pasid_log2; __u8 __reserved[3]; __aligned_u64 out_capabilities; @@ -951,10 +997,29 @@ struct iommu_fault_alloc { * enum iommu_viommu_type - Virtual IOMMU Type * @IOMMU_VIOMMU_TYPE_DEFAULT: Reserved for future use * @IOMMU_VIOMMU_TYPE_ARM_SMMUV3: ARM SMMUv3 driver specific type + * @IOMMU_VIOMMU_TYPE_TEGRA241_CMDQV: NVIDIA Tegra241 CMDQV (extension for= ARM + * SMMUv3) enabled ARM SMMUv3 type */ enum iommu_viommu_type { IOMMU_VIOMMU_TYPE_DEFAULT =3D 0, IOMMU_VIOMMU_TYPE_ARM_SMMUV3 =3D 1, + IOMMU_VIOMMU_TYPE_TEGRA241_CMDQV =3D 2, +}; + +/** + * struct iommu_viommu_tegra241_cmdqv - NVIDIA Tegra241 CMDQV Virtual Inte= rface + * (IOMMU_VIOMMU_TYPE_TEGRA241_CMDQV) + * @out_vintf_mmap_offset: mmap offset argument for VINTF's page0 + * @out_vintf_mmap_length: mmap length argument for VINTF's page0 + * + * Both @out_vintf_mmap_offset and @out_vintf_mmap_length are reported by = kernel + * for user space to mmap the VINTF page0 from the host physical address s= pace + * to the guest physical address space so that a guest kernel can directly= R/W + * access to the VINTF page0 in order to control its virtual command queue= s. + */ +struct iommu_viommu_tegra241_cmdqv { + __aligned_u64 out_vintf_mmap_offset; + __aligned_u64 out_vintf_mmap_length; }; =20 /** @@ -965,6 +1030,9 @@ enum iommu_viommu_type { * @dev_id: The device's physical IOMMU will be used to back the virtual I= OMMU * @hwpt_id: ID of a nesting parent HWPT to associate to * @out_viommu_id: Output virtual IOMMU ID for the allocated object + * @data_len: Length of the type specific data + * @__reserved: Must be 0 + * @data_uptr: User pointer to a driver-specific virtual IOMMU data * * Allocate a virtual IOMMU object, representing the underlying physical I= OMMU's * virtualization support that is a security-isolated slice of the real IO= MMU HW @@ -985,6 +1053,9 @@ struct iommu_viommu_alloc { __u32 dev_id; __u32 hwpt_id; __u32 out_viommu_id; + __u32 data_len; + __u32 __reserved; + __aligned_u64 data_uptr; }; #define IOMMU_VIOMMU_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VIOMMU_ALLOC) =20 @@ -995,10 +1066,15 @@ struct iommu_viommu_alloc { * @dev_id: The physical device to allocate a virtual instance on the vIOM= MU * @out_vdevice_id: Object handle for the vDevice. Pass to IOMMU_DESTORY * @virt_id: Virtual device ID per vIOMMU, e.g. vSID of ARM SMMUv3, vDevic= eID - * of AMD IOMMU, and vRID of a nested Intel VT-d to a Context Ta= ble + * of AMD IOMMU, and vRID of Intel VT-d * * Allocate a virtual device instance (for a physical device) against a vI= OMMU. * This instance holds the device's information (related to its vIOMMU) in= a VM. + * User should use IOMMU_DESTROY to destroy the virtual device before + * destroying the physical device (by closing vfio_cdev fd). Otherwise the + * virtual device would be forcibly destroyed on physical device destructi= on, + * its vdevice_id would be permanently leaked (unremovable & unreusable) u= ntil + * iommu fd closed. */ struct iommu_vdevice_alloc { __u32 size; @@ -1075,10 +1151,12 @@ struct iommufd_vevent_header { * enum iommu_veventq_type - Virtual Event Queue Type * @IOMMU_VEVENTQ_TYPE_DEFAULT: Reserved for future use * @IOMMU_VEVENTQ_TYPE_ARM_SMMUV3: ARM SMMUv3 Virtual Event Queue + * @IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV: NVIDIA Tegra241 CMDQV Extension IRQ */ enum iommu_veventq_type { IOMMU_VEVENTQ_TYPE_DEFAULT =3D 0, IOMMU_VEVENTQ_TYPE_ARM_SMMUV3 =3D 1, + IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV =3D 2, }; =20 /** @@ -1102,6 +1180,19 @@ struct iommu_vevent_arm_smmuv3 { __aligned_le64 evt[4]; }; =20 +/** + * struct iommu_vevent_tegra241_cmdqv - Tegra241 CMDQV IRQ + * (IOMMU_VEVENTQ_TYPE_TEGRA241_CMDQV) + * @lvcmdq_err_map: 128-bit logical vcmdq error map, little-endian. + * (Refer to register LVCMDQ_ERR_MAPs per VINTF ) + * + * The 128-bit register value from HW exclusively reflect the error bits f= or a + * Virtual Interface represented by a vIOMMU object. Read and report direc= tly. + */ +struct iommu_vevent_tegra241_cmdqv { + __aligned_le64 lvcmdq_err_map[2]; +}; + /** * struct iommu_veventq_alloc - ioctl(IOMMU_VEVENTQ_ALLOC) * @size: sizeof(struct iommu_veventq_alloc) @@ -1141,4 +1232,61 @@ struct iommu_veventq_alloc { __u32 __reserved; }; #define IOMMU_VEVENTQ_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VEVENTQ_ALLOC) + +/** + * enum iommu_hw_queue_type - HW Queue Type + * @IOMMU_HW_QUEUE_TYPE_DEFAULT: Reserved for future use + * @IOMMU_HW_QUEUE_TYPE_TEGRA241_CMDQV: NVIDIA Tegra241 CMDQV (extension f= or ARM + * SMMUv3) Virtual Command Queue (VCM= DQ) + */ +enum iommu_hw_queue_type { + IOMMU_HW_QUEUE_TYPE_DEFAULT =3D 0, + /* + * TEGRA241_CMDQV requirements (otherwise, allocation will fail) + * - alloc starts from the lowest @index=3D0 in ascending order + * - destroy starts from the last allocated @index in descending order + * - @base_addr must be aligned to @length in bytes and mapped in IOAS + * - @length must be a power of 2, with a minimum 32 bytes and a maximum + * 2 ^ idr[1].CMDQS * 16 bytes (use GET_HW_INFO call to read idr[1] + * from struct iommu_hw_info_arm_smmuv3) + * - suggest to back the queue memory with contiguous physical pages or + * a single huge page with alignment of the queue size, and limit the + * emulated vSMMU's IDR1.CMDQS to log2(huge page size / 16 bytes) + */ + IOMMU_HW_QUEUE_TYPE_TEGRA241_CMDQV =3D 1, +}; + +/** + * struct iommu_hw_queue_alloc - ioctl(IOMMU_HW_QUEUE_ALLOC) + * @size: sizeof(struct iommu_hw_queue_alloc) + * @flags: Must be 0 + * @viommu_id: Virtual IOMMU ID to associate the HW queue with + * @type: One of enum iommu_hw_queue_type + * @index: The logical index to the HW queue per virtual IOMMU for a multi= -queue + * model + * @out_hw_queue_id: The ID of the new HW queue + * @nesting_parent_iova: Base address of the queue memory in the guest phy= sical + * address space + * @length: Length of the queue memory + * + * Allocate a HW queue object for a vIOMMU-specific HW-accelerated queue, = which + * allows HW to access a guest queue memory described using @nesting_paren= t_iova + * and @length. + * + * A vIOMMU can allocate multiple queues, but it must use a different @ind= ex per + * type to separate each allocation, e.g:: + * + * Type1 HW queue0, Type1 HW queue1, Type2 HW queue0, ... + */ +struct iommu_hw_queue_alloc { + __u32 size; + __u32 flags; + __u32 viommu_id; + __u32 type; + __u32 index; + __u32 out_hw_queue_id; + __aligned_u64 nesting_parent_iova; + __aligned_u64 length; +}; +#define IOMMU_HW_QUEUE_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HW_QUEUE_ALLOC) #endif diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 32c5885a3c..be704965d8 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -636,6 +636,7 @@ struct kvm_ioeventfd { #define KVM_X86_DISABLE_EXITS_HLT (1 << 1) #define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) #define KVM_X86_DISABLE_EXITS_CSTATE (1 << 3) +#define KVM_X86_DISABLE_EXITS_APERFMPERF (1 << 4) =20 /* for KVM_ENABLE_CAP */ struct kvm_enable_cap { @@ -952,6 +953,7 @@ struct kvm_enable_cap { #define KVM_CAP_ARM_EL2 240 #define KVM_CAP_ARM_EL2_E2H0 241 #define KVM_CAP_RISCV_MP_STATE_RESET 242 +#define KVM_CAP_ARM_CACHEABLE_PFNMAP_SUPPORTED 243 =20 struct kvm_irq_routing_irqchip { __u32 irqchip; diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index 79bf8c0cc5..4d96d1fc12 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -905,10 +905,12 @@ struct vfio_device_feature { * VFIO_DEVICE_BIND_IOMMUFD - _IOR(VFIO_TYPE, VFIO_BASE + 18, * struct vfio_device_bind_iommufd) * @argsz: User filled size of this data. - * @flags: Must be 0. + * @flags: Must be 0 or a bit flags of VFIO_DEVICE_BIND_* * @iommufd: iommufd to bind. * @out_devid: The device id generated by this bind. devid is a handle for * this device/iommufd bond and can be used in IOMMUFD commands. + * @token_uuid_ptr: Valid if VFIO_DEVICE_BIND_FLAG_TOKEN. Points to a 16 b= yte + * UUID in the same format as VFIO_DEVICE_FEATURE_PCI_VF_= TOKEN. * * Bind a vfio_device to the specified iommufd. * @@ -917,13 +919,21 @@ struct vfio_device_feature { * * Unbind is automatically conducted when device fd is closed. * + * A token is sometimes required to open the device, unless this is known = to be + * needed VFIO_DEVICE_BIND_FLAG_TOKEN should not be set and token_uuid_ptr= is + * ignored. The only case today is a PF/VF relationship where the VF bind = must + * be provided the same token as VFIO_DEVICE_FEATURE_PCI_VF_TOKEN provided= to + * the PF. + * * Return: 0 on success, -errno on failure. */ struct vfio_device_bind_iommufd { __u32 argsz; __u32 flags; +#define VFIO_DEVICE_BIND_FLAG_TOKEN (1 << 0) __s32 iommufd; __u32 out_devid; + __aligned_u64 token_uuid_ptr; }; =20 #define VFIO_DEVICE_BIND_IOMMUFD _IO(VFIO_TYPE, VFIO_BASE + 18) diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h index d4b3e2ae13..283348b64a 100644 --- a/linux-headers/linux/vhost.h +++ b/linux-headers/linux/vhost.h @@ -235,4 +235,39 @@ */ #define VHOST_VDPA_GET_VRING_SIZE _IOWR(VHOST_VIRTIO, 0x82, \ struct vhost_vring_state) + +/* Extended features manipulation */ +#define VHOST_GET_FEATURES_ARRAY _IOR(VHOST_VIRTIO, 0x83, \ + struct vhost_features_array) +#define VHOST_SET_FEATURES_ARRAY _IOW(VHOST_VIRTIO, 0x83, \ + struct vhost_features_array) + +/* fork_owner values for vhost */ +#define VHOST_FORK_OWNER_KTHREAD 0 +#define VHOST_FORK_OWNER_TASK 1 + +/** + * VHOST_SET_FORK_FROM_OWNER - Set the fork_owner flag for the vhost devic= e, + * This ioctl must called before VHOST_SET_OWNER. + * Only available when CONFIG_VHOST_ENABLE_FORK_OWNER_CONTROL=3Dy + * + * @param fork_owner: An 8-bit value that determines the vhost thread mode + * + * When fork_owner is set to VHOST_FORK_OWNER_TASK(default value): + * - Vhost will create vhost worker as tasks forked from the owner, + * inheriting all of the owner's attributes. + * + * When fork_owner is set to VHOST_FORK_OWNER_KTHREAD: + * - Vhost will create vhost workers as kernel threads. + */ +#define VHOST_SET_FORK_FROM_OWNER _IOW(VHOST_VIRTIO, 0x83, __u8) + +/** + * VHOST_GET_FORK_OWNER - Get the current fork_owner flag for the vhost de= vice. + * Only available when CONFIG_VHOST_ENABLE_FORK_OWNER_CONTROL=3Dy + * + * @return: An 8-bit value indicating the current thread mode. + */ +#define VHOST_GET_FORK_FROM_OWNER _IOR(VHOST_VIRTIO, 0x84, __u8) + #endif diff --git a/linux-headers/LICENSES/preferred/GPL-2.0 b/linux-headers/LICEN= SES/preferred/GPL-2.0 index ff0812fd89..ea8e93dc44 100644 --- a/linux-headers/LICENSES/preferred/GPL-2.0 +++ b/linux-headers/LICENSES/preferred/GPL-2.0 @@ -20,8 +20,8 @@ License-Text: GNU GENERAL PUBLIC LICENSE Version 2, June 1991 =20 - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301= USA + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. =20 @@ -322,10 +322,8 @@ the "copyright" line and a pointer to where the full n= otice is found. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. =20 - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 = USA - + You should have received a copy of the GNU General Public License along + with this program; if not, see . =20 Also add information on how to contact you by electronic and paper mail. =20 --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691862; cv=none; d=zohomail.com; s=zohoarc; b=FAQfGsaVrdRvXHsDr5UU88j9Joxjof00qWxUq1T2aF+jO9q+qvs5gQKHPh/bRmVYqqn3DXlWzKFqbMJnaaRrD6r6uGGnH0Bq5l65gwgJMcaFgvrDPx8s5UzEDo9DPBP3bM1UYx6q54FpbyJEiYV+/5FRIc6u9Zr+txkYP+/fsOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691862; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=k/FVkGhjGelmiF0arfWEd4Yssbg2l6aFP6I25x3tKr8=; b=Cb32YEvddQikfXR81y9blJ2FfEOk4ox+j7EHtd80eQIOAHlo86vFcA+EB6x/8O/q0ZuugSrpkxlQ7ZTsfhD5d+i5Inj1hw22f/HOpY6k88fvJrAWxZ/FWWU2gGNPKvGnYueP7btuEdc4ML9jjRAofgkV27nfVftdwk71BS/d2g0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691862297118.09432594324187; Sun, 5 Oct 2025 12:17:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDi-0007SU-Sy; Sun, 05 Oct 2025 15:16: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 1v5UDU-0007Qc-IH for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:21 -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 1v5UDS-0006LN-QF for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:20 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-464-XX0OwY0vPWekIltDAjH3Jw-1; Sun, 05 Oct 2025 15:16:14 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-401dbafbcfaso2576856f8f.1 for ; Sun, 05 Oct 2025 12:16:14 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6c3esm17613547f8f.1.2025.10.05.12.16.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691776; 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=k/FVkGhjGelmiF0arfWEd4Yssbg2l6aFP6I25x3tKr8=; b=iC1i2DoyvxWyUNrT7Nj4AIN2EVguiPkOVKb/WqPalwBLAV06212g3P4PXuAbblm4agpYxG 5MeCQTcN37T7BHE2szwzahZLd4KZ53YycC9XdTeuf3s91mzwK4S5ayyK2XgZevP9zzM9B4 h+zYhBaURBs+VVBniUjW8rwlOYJRDd0= X-MC-Unique: XX0OwY0vPWekIltDAjH3Jw-1 X-Mimecast-MFC-AGG-ID: XX0OwY0vPWekIltDAjH3Jw_1759691774 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691773; x=1760296573; 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=k/FVkGhjGelmiF0arfWEd4Yssbg2l6aFP6I25x3tKr8=; b=wB0SM1evlNoepAaqQRU/RaixBjYSTvcgMZDQSIJS5s+5fBHx1nk0LkgBYhF1xPG61T lL5OsIRhZalIm61hKS/nQ2lClgonZsmxcMs8HdCG1VSGfjS+zFEYo+26JF/gLt2DVAF1 zGKEAZa3Mp8ro/lx2f6Go/hKh6+//Au2JNRcCGwDd+UKeE55oX9WzuJnnI8naivUOlFO OGwSNnoyJVn8dBLJ1itzBSMOyMGs/MNssWmweP3uQFvHLILvZE72lz1JwmIsbajTJQcP JuhKjlEVIEyU0oTc/ZE4XaISKESWoSFIvJatkM7LCGKpD6/67iBVOxV6JVotyqOncKiw uN5w== X-Gm-Message-State: AOJu0YyGE8DGbxQC61mn8zN6ws06HrlbSQ9GUOlKP3H7nyA8/jsPEunq chd7iQ3x4ICDDvLuoIZLsN8X6GK2AaySE2eo6gMxUuKKoB7pZ6UeXtEV3FJeOkm2SpCZie5C7de iND45PYh36PIR2zauyRKm4bCpxwMndbV/tqSnWUmNQC41XfO79NFzNurYtaa9yVOGnDubbR5HaM zqYE3fn5+8IRPS3l6h6qxDJPgbaJdg9FfPQQ== X-Gm-Gg: ASbGncsCo2phb22AGKH1Ft7XPQAc0uipmN1rhswtneCMhIGuYwKabhnUoUO/cWpV1bI sH8FVWJERmrYZ+00Gbi9jVU2mW/yq5xX9I+Rrq3tgNHX/BPJLMWqN1MWqpTOa0jvHNdAPgJjdCt uFhZMfGusSTD5aIkLEvrxV0jj2VjffzWTIt+iJMwSyf+INDwpo7LSfWimlAhaqLc541hXmqS1YP YjshB20F+W7O7ZfdFPXSZ7QS/fHT+vdTm+p/hFd37S8Rjb9xSh50Nv9o9O5n/JKPqqk8X6wJ5fa aa5s+4l3DiUO/41ZS2TSbuO13v+LzETco+d48hM= X-Received: by 2002:a05:6000:220b:b0:3eb:5e99:cbb9 with SMTP id ffacd0b85a97d-4256713c1dfmr7107170f8f.10.1759691773192; Sun, 05 Oct 2025 12:16:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECSt2L02YdM0xY1VPnS59Lxr2AYdSlggt+ipJCF6zhbGVdvCYZdKFb3KVdsL5hhGhnkhzqYQ== X-Received: by 2002:a05:6000:220b:b0:3eb:5e99:cbb9 with SMTP id ffacd0b85a97d-4256713c1dfmr7107144f8f.10.1759691772546; Sun, 05 Oct 2025 12:16:12 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Abeni , Akihiko Odaki , Jason Wang , Stefano Garzarella , Lei Yang Subject: [PULL 04/75] virtio: introduce extended features type 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691878928116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni The virtio specifications allows for up to 128 bits for the device features. Soon we are going to use some of the 'extended' bits features (bit 64 and above) for the virtio net driver. Represent the virtio features bitmask with a fixed size array, and introduce a few helpers to help manipulate them. Most drivers will keep using only 64 bits features space: use union to allow them access the lower part of the extended space without any per driver change. Reviewed-by: Akihiko Odaki Acked-by: Jason Wang Acked-by: Stefano Garzarella Signed-off-by: Paolo Abeni Tested-by: Lei Yang Reviewed-by: Michael S. Tsirkin Message-ID: <6a9bbb5eb33830f20afbcb7e64d300af4126dd98.1758549625.git.pabeni= @redhat.com> Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-features.h | 126 ++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 7 +- 2 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 include/hw/virtio/virtio-features.h diff --git a/include/hw/virtio/virtio-features.h b/include/hw/virtio/virtio= -features.h new file mode 100644 index 0000000000..e29b7fe48f --- /dev/null +++ b/include/hw/virtio/virtio-features.h @@ -0,0 +1,126 @@ +/* + * Virtio features helpers + * + * Copyright 2025 Red Hat, Inc. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef QEMU_VIRTIO_FEATURES_H +#define QEMU_VIRTIO_FEATURES_H + +#include "qemu/bitops.h" + +#define VIRTIO_FEATURES_FMT "%016"PRIx64"%016"PRIx64 +#define VIRTIO_FEATURES_PR(f) (f)[1], (f)[0] + +#define VIRTIO_FEATURES_MAX 128 +#define VIRTIO_FEATURES_BIT(b) BIT_ULL((b) % 64) +#define VIRTIO_FEATURES_U64(b) ((b) / 64) +#define VIRTIO_FEATURES_NU32S (VIRTIO_FEATURES_MAX / 32) +#define VIRTIO_FEATURES_NU64S (VIRTIO_FEATURES_MAX / 64) + +#define VIRTIO_DECLARE_FEATURES(name) \ + union { \ + uint64_t name; \ + uint64_t name##_ex[VIRTIO_FEATURES_NU64S]; \ + } + +#define VIRTIO_DEFINE_PROP_FEATURE(_name, _state, _field, _bit, _defval) = \ + DEFINE_PROP_BIT64(_name, _state, _field[VIRTIO_FEATURES_U64(_bit)], = \ + (_bit) % 64, _defval) + +static inline void virtio_features_clear(uint64_t *features) +{ + memset(features, 0, sizeof(features[0]) * VIRTIO_FEATURES_NU64S); +} + +static inline void virtio_features_from_u64(uint64_t *features, uint64_t f= rom) +{ + virtio_features_clear(features); + features[0] =3D from; +} + +static inline bool virtio_has_feature_ex(const uint64_t *features, + unsigned int fbit) +{ + assert(fbit < VIRTIO_FEATURES_MAX); + return features[VIRTIO_FEATURES_U64(fbit)] & VIRTIO_FEATURES_BIT(fbit); +} + +static inline void virtio_add_feature_ex(uint64_t *features, + unsigned int fbit) +{ + assert(fbit < VIRTIO_FEATURES_MAX); + features[VIRTIO_FEATURES_U64(fbit)] |=3D VIRTIO_FEATURES_BIT(fbit); +} + +static inline void virtio_clear_feature_ex(uint64_t *features, + unsigned int fbit) +{ + assert(fbit < VIRTIO_FEATURES_MAX); + features[VIRTIO_FEATURES_U64(fbit)] &=3D ~VIRTIO_FEATURES_BIT(fbit); +} + +static inline bool virtio_features_equal(const uint64_t *f1, + const uint64_t *f2) +{ + return !memcmp(f1, f2, sizeof(uint64_t) * VIRTIO_FEATURES_NU64S); +} + +static inline bool virtio_features_use_ex(const uint64_t *features) +{ + int i; + + for (i =3D 1; i < VIRTIO_FEATURES_NU64S; ++i) { + if (features[i]) { + return true; + } + } + return false; +} + +static inline bool virtio_features_empty(const uint64_t *features) +{ + return !virtio_features_use_ex(features) && !features[0]; +} + +static inline void virtio_features_copy(uint64_t *to, const uint64_t *from) +{ + memcpy(to, from, sizeof(to[0]) * VIRTIO_FEATURES_NU64S); +} + +static inline bool virtio_features_andnot(uint64_t *to, const uint64_t *f1, + const uint64_t *f2) +{ + uint64_t diff =3D 0; + int i; + + for (i =3D 0; i < VIRTIO_FEATURES_NU64S; i++) { + to[i] =3D f1[i] & ~f2[i]; + diff |=3D to[i]; + } + return diff; +} + +static inline void virtio_features_and(uint64_t *to, const uint64_t *f1, + const uint64_t *f2) +{ + int i; + + for (i =3D 0; i < VIRTIO_FEATURES_NU64S; i++) { + to[i] =3D f1[i] & f2[i]; + } +} + +static inline void virtio_features_or(uint64_t *to, const uint64_t *f1, + const uint64_t *f2) +{ + int i; + + for (i =3D 0; i < VIRTIO_FEATURES_NU64S; i++) { + to[i] =3D f1[i] | f2[i]; + } +} + +#endif diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index c594764f23..39e4059a66 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -16,6 +16,7 @@ =20 #include "system/memory.h" #include "hw/qdev-core.h" +#include "hw/virtio/virtio-features.h" #include "net/net.h" #include "migration/vmstate.h" #include "qemu/event_notifier.h" @@ -121,9 +122,9 @@ struct VirtIODevice * backend (e.g. vhost) and could potentially be a subset of the * total feature set offered by QEMU. */ - uint64_t host_features; - uint64_t guest_features; - uint64_t backend_features; + VIRTIO_DECLARE_FEATURES(host_features); + VIRTIO_DECLARE_FEATURES(guest_features); + VIRTIO_DECLARE_FEATURES(backend_features); =20 size_t config_len; void *config; --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692443; cv=none; d=zohomail.com; s=zohoarc; b=JyLOnCrBFNCmXoQOeLbwsDnmYk1iTr9yBndb1xMneBoB+IyG8hOaPxaDLno3dyuSSXtv+EkxPiywV62VAwTxzMGKkDXkkhrGQ14SzzwLGTu8gFHJnEvbt8Y3Qp/6A+2EsZDU2TS0+6EgCxExX+ErzTScPceQkSQQOAmULucO07o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692443; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SHoGkBd1TLD0drMrg57V42M4WtKetbvg9QyJe5+quVA=; b=YuIMSKnjBW6nhVm9Lhu4MBKMRjl941oB7iTyRD4TD5RXRWzlEFTNN4IJBmQ5mGUamSRIz6SjUNR1Q/VfI3S3A1+NK9ocisVZ5SXKWA39TDsaM8Sh6F+kZUkODAU/wwDPg3te3yZR/xPWc0ti1dhBqs5BphtoljB9luPobDVbMSI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692443814194.9318120526376; Sun, 5 Oct 2025 12:27:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDg-0007Rf-S8; Sun, 05 Oct 2025 15:16: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 1v5UDV-0007Qp-Ex for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDT-0006LY-Ie for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:21 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-548-_G5q818VPku01xaWhWiGmQ-1; Sun, 05 Oct 2025 15:16:16 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3ecdd80ea44so2979708f8f.1 for ; Sun, 05 Oct 2025 12:16:16 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6bbesm17264105f8f.12.2025.10.05.12.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691778; 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=SHoGkBd1TLD0drMrg57V42M4WtKetbvg9QyJe5+quVA=; b=enJ4d7HlBXMQdyJ6TCJMdaNWZ+9a2t+iX/Rs+LaeqrMSPIYqu7l38cfF7xIaAujpMgM1QP 7R7rTQnj750Ubk9Ev7wTVxATzP99mT0PkU8aYpk678em4vnEcwoRfQ43BgcqhIVa6DJdSS kHcITlRWHYX7mrdJP9n6vLMfxrofTIU= X-MC-Unique: _G5q818VPku01xaWhWiGmQ-1 X-Mimecast-MFC-AGG-ID: _G5q818VPku01xaWhWiGmQ_1759691776 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691775; x=1760296575; 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=SHoGkBd1TLD0drMrg57V42M4WtKetbvg9QyJe5+quVA=; b=scre/1IblHZwCdclEe5UV1gacjAWetkNBEc9P4nttqjMD1hoNr2VL35hg+bFJZ6xC9 FJvyhIzD3SS4FVoWPc1h3d9dE0EGVN1AhbOpgMLgKf6YnUkfDc0c04i1Vxe8+wsuIlnL eT8eHk4XyKCfc+sCUbbAYNRTx3oD1kHlB0yhCFLktMz28OAraQu2riSGD1FfMre4TbNi w3D2avNjIystMQhQ7oOO8qPOgitVs2nC1VUUVkQfcqm33gomLVGHsWV7KdQm11Xn1CAj nrEOY/Gl+3iZg0jLc/1NuIK3gEHUwHPwipJ0vIQ0OMjbMR9+m29SgFzjjF3W+mSccMJp lzKg== X-Gm-Message-State: AOJu0Yz1alqAsALOqqSgV2xUugumcYHwbVuOn4xYi5SIuXaQKmTsKY+7 3EeeBWUHqs7Fa8G25batNj/pej6XMPmg0elzq/q5ONrzcENeeN0wk+bvri3wND5y13wrQye+2/y H7OABpiVPtO9NrYeUjFVs4IV98RaBdzNzj72hSdO3Hr8jG3e/wnxMpKMJWaYuZUfh7EovnQ0fTG UmxyDzwKttCY1GJ4wPwkW74GUwzvdr4n4Alw== X-Gm-Gg: ASbGncuvGnN/JEn8+UaU80YDaCK22nIsZT55KfIdL4XtU82VD1fUJkpgJMTA83gD51u 7p5Kf8zYmvbql6OkiN0rFRiMJIYZ4KJ7Kz7+TMfraAVawhIlFyC2GsEdN3RBUHaNVRoXuVe2YP7 LvtsSrqVl210LXbegjgaEoxZ0kiL4EDHfUfsbbaLReeqytqIK+5j0fHoMYJ6HeupsslgoOb6hbh PMvQTcXfb4agsw/BiyUH7mx288/ec7ixoPyWC3C4gXlxYSOrH9Orp8TZ8fOz2OjBpWD3ioiPnMr HzZzTAKHxkgP9d2/VbS5GLz6OOPIxwRnH0Kd/mA= X-Received: by 2002:a05:6000:2303:b0:401:ae97:a1ab with SMTP id ffacd0b85a97d-42566c0cb9fmr7741150f8f.10.1759691775187; Sun, 05 Oct 2025 12:16:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFL3qv77mJxwODQWdwHDFHPTrBRsqOo14oFf2LwqnJfkdsa/dTsrcMqaFNQ68enIl1DOQZ+zQ== X-Received: by 2002:a05:6000:2303:b0:401:ae97:a1ab with SMTP id ffacd0b85a97d-42566c0cb9fmr7741131f8f.10.1759691774613; Sun, 05 Oct 2025 12:16:14 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:12 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Abeni , Akihiko Odaki , Jason Wang , Stefano Garzarella , Lei Yang Subject: [PULL 05/75] virtio: serialize extended features state Message-ID: <0a49a97433279512a03f3d9f36164a46caf498c6.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692446247116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni If the driver uses any of the extended features (i.e. 64 or above), store the extended features range (64-127 bits). At load time, let legacy features initialize the full features range and pass it to the set helper; sub-states loading will have filled-up the extended part as needed. This is one of the few spots that need explicitly to know and set in stone the extended features array size; add a build bug to prevent breaking the migration should such size change again in the future: more serialization plumbing will be needed. Reviewed-by: Akihiko Odaki Acked-by: Jason Wang Acked-by: Stefano Garzarella Signed-off-by: Paolo Abeni Tested-by: Lei Yang Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 88 ++++++++++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 31 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 9a81ad912e..bf53c211e5 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2964,6 +2964,30 @@ static const VMStateDescription vmstate_virtio_disab= led =3D { } }; =20 +static bool virtio_128bit_features_needed(void *opaque) +{ + VirtIODevice *vdev =3D opaque; + + return virtio_features_use_ex(vdev->host_features_ex); +} + +static const VMStateDescription vmstate_virtio_128bit_features =3D { + .name =3D "virtio/128bit_features", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D &virtio_128bit_features_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT64(guest_features_ex[1], VirtIODevice), + VMSTATE_END_OF_LIST() + } +}; + +/* + * Avoid silently breaking migration should the feature space increase + * even more in the (far away) future + */ +QEMU_BUILD_BUG_ON(VIRTIO_FEATURES_NU64S !=3D 2); + static const VMStateDescription vmstate_virtio =3D { .name =3D "virtio", .version_id =3D 1, @@ -2973,6 +2997,7 @@ static const VMStateDescription vmstate_virtio =3D { }, .subsections =3D (const VMStateDescription * const []) { &vmstate_virtio_device_endian, + &vmstate_virtio_128bit_features, &vmstate_virtio_64bit_features, &vmstate_virtio_virtqueues, &vmstate_virtio_ringsize, @@ -3069,23 +3094,28 @@ const VMStateInfo virtio_vmstate_info =3D { .put =3D virtio_device_put, }; =20 -static int virtio_set_features_nocheck(VirtIODevice *vdev, uint64_t val) +static int virtio_set_features_nocheck(VirtIODevice *vdev, const uint64_t = *val) { VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); - bool bad =3D (val & ~(vdev->host_features)) !=3D 0; + uint64_t tmp[VIRTIO_FEATURES_NU64S]; + bool bad; + + bad =3D virtio_features_andnot(tmp, val, vdev->host_features_ex); + virtio_features_and(tmp, val, vdev->host_features_ex); =20 - val &=3D vdev->host_features; if (k->set_features) { - k->set_features(vdev, val); + bad =3D bad || virtio_features_use_ex(tmp); + k->set_features(vdev, tmp[0]); } - vdev->guest_features =3D val; + + virtio_features_copy(vdev->guest_features_ex, tmp); return bad ? -1 : 0; } =20 typedef struct VirtioSetFeaturesNocheckData { Coroutine *co; VirtIODevice *vdev; - uint64_t val; + uint64_t val[VIRTIO_FEATURES_NU64S]; int ret; } VirtioSetFeaturesNocheckData; =20 @@ -3098,14 +3128,15 @@ static void virtio_set_features_nocheck_bh(void *op= aque) } =20 static int coroutine_mixed_fn -virtio_set_features_nocheck_maybe_co(VirtIODevice *vdev, uint64_t val) +virtio_set_features_nocheck_maybe_co(VirtIODevice *vdev, + const uint64_t *val) { if (qemu_in_coroutine()) { VirtioSetFeaturesNocheckData data =3D { .co =3D qemu_coroutine_self(), .vdev =3D vdev, - .val =3D val, }; + virtio_features_copy(data.val, val); aio_bh_schedule_oneshot(qemu_get_current_aio_context(), virtio_set_features_nocheck_bh, &data); qemu_coroutine_yield(); @@ -3117,6 +3148,7 @@ virtio_set_features_nocheck_maybe_co(VirtIODevice *vd= ev, uint64_t val) =20 int virtio_set_features(VirtIODevice *vdev, uint64_t val) { + uint64_t features[VIRTIO_FEATURES_NU64S]; int ret; /* * The driver must not attempt to set features after feature negotiati= on @@ -3132,7 +3164,8 @@ int virtio_set_features(VirtIODevice *vdev, uint64_t = val) __func__, vdev->name); } =20 - ret =3D virtio_set_features_nocheck(vdev, val); + virtio_features_from_u64(features, val); + ret =3D virtio_set_features_nocheck(vdev, features); if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { /* VIRTIO_RING_F_EVENT_IDX changes the size of the caches. */ int i; @@ -3155,6 +3188,7 @@ void virtio_reset(void *opaque) { VirtIODevice *vdev =3D opaque; VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); + uint64_t features[VIRTIO_FEATURES_NU64S]; int i; =20 virtio_set_status(vdev, 0); @@ -3181,7 +3215,8 @@ void virtio_reset(void *opaque) vdev->start_on_kick =3D false; vdev->started =3D false; vdev->broken =3D false; - virtio_set_features_nocheck(vdev, 0); + virtio_features_clear(features); + virtio_set_features_nocheck(vdev, features); vdev->queue_sel =3D 0; vdev->status =3D 0; vdev->disabled =3D false; @@ -3264,7 +3299,7 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int vers= ion_id) * Note: devices should always test host features in future - don't cr= eate * new dependencies like this. */ - vdev->guest_features =3D features; + virtio_features_from_u64(vdev->guest_features_ex, features); =20 config_len =3D qemu_get_be32(f); =20 @@ -3343,26 +3378,17 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int ve= rsion_id) vdev->device_endian =3D virtio_default_endian(); } =20 - if (virtio_64bit_features_needed(vdev)) { - /* - * Subsection load filled vdev->guest_features. Run them - * through virtio_set_features to sanity-check them against - * host_features. - */ - uint64_t features64 =3D vdev->guest_features; - if (virtio_set_features_nocheck_maybe_co(vdev, features64) < 0) { - error_report("Features 0x%" PRIx64 " unsupported. " - "Allowed features: 0x%" PRIx64, - features64, vdev->host_features); - return -1; - } - } else { - if (virtio_set_features_nocheck_maybe_co(vdev, features) < 0) { - error_report("Features 0x%x unsupported. " - "Allowed features: 0x%" PRIx64, - features, vdev->host_features); - return -1; - } + /* + * guest_features_ex is fully initialized with u32 features and upper + * bits have been filled as needed by the later load. + */ + if (virtio_set_features_nocheck_maybe_co(vdev, + vdev->guest_features_ex) < 0)= { + error_report("Features 0x" VIRTIO_FEATURES_FMT " unsupported. " + "Allowed features: 0x" VIRTIO_FEATURES_FMT, + VIRTIO_FEATURES_PR(vdev->guest_features_ex), + VIRTIO_FEATURES_PR(vdev->host_features_ex)); + return -1; } =20 if (!virtio_device_started(vdev, vdev->status) && --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691956; cv=none; d=zohomail.com; s=zohoarc; b=hY9ezG4MhxwhWJQNAs3z4NJNEN/oQv7oSuXzRNumq6W/+59YF1MlxkbE00wYM92fkMWGHnE9190RVTtwVpK0K7UKLapqVqRcCk/+DroXUEo+A+/knzDvo5r23wvzEkpLXvgvfpEEM02O3DJe7ctKUhnw9fNAaGnKWylGvW0h7rg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691956; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qrOfnlzVApHW7nCp9cywejc9Pajk0HVvbfCIV3RzkUo=; b=fHw4epgRMSIXtW4/6LXZToAYzadWvB8Iv+rUc+uvU7yZJjtqRe5txvYPRC0pPKaC8YOaKH6IN/qxPYqoU57VT0WUrb0noenoz3wj6cgchmfLP/jWbmYYbPp2gAq09DKwQYygSmLHueROc9b+mYpBXLkKh0862S8IjmmP1TmOJLE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691956125188.31693277256227; Sun, 5 Oct 2025 12:19:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDj-0007Sv-Aa; Sun, 05 Oct 2025 15:16:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDX-0007R3-BF for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDV-0006Ll-7U for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:22 -0400 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-516-MYf0rnJsME-BQB2R7wspfQ-1; Sun, 05 Oct 2025 15:16:19 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-42421b15185so3097748f8f.1 for ; Sun, 05 Oct 2025 12:16:18 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6c54sm17766671f8f.11.2025.10.05.12.16.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691780; 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=qrOfnlzVApHW7nCp9cywejc9Pajk0HVvbfCIV3RzkUo=; b=QDJXhqTS6gZz1L67EXiFdjw3qbw0aFVTukPVQzJqZAPQMt/W9h9KFdaC5Hj083LtbPHjOd 7vmg5mO1WDu2tS4KOzNx359YnCawn41X+1YUCUiqOrDKyNhjjn/2rHtxOAm96s4JfNg52a IRMOHGZP9BZyxcWBDu0N5H9vubEihJw= X-MC-Unique: MYf0rnJsME-BQB2R7wspfQ-1 X-Mimecast-MFC-AGG-ID: MYf0rnJsME-BQB2R7wspfQ_1759691778 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691777; x=1760296577; 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=qrOfnlzVApHW7nCp9cywejc9Pajk0HVvbfCIV3RzkUo=; b=xTMuoDTG4hNkr10joPkQHgeMhBNTHvi1V1oFX0KW99RfFXYkbXdmfels3gpmUFOuH7 VqSC4d541xZA9Yc6fjK9QcjFjpPFDLTj1zSq9nO4HoyAye61ZPLIhhDF1FJbhTWif8SI jeqvmQdkJ9QaknxnABvKq/E7rdCZ9bcBgTG/nBx4u5Elw26ID5GNwnpX2uYOPrjy344o B1MT8MPMYFAZ3mv3OXX6RXaOmwLDGw0X0dyZc0glXVef9HwBn1Zvst2/GczVhr4dIQ+g xNb8xOyv3xNNd1kMnSj184hUHDnd035LKHPyDD4lcB5vqD/4igMtoTNJQaSZ/4uw1XNv Ay5Q== X-Gm-Message-State: AOJu0Yx1EWmQ8t5D8oFTlyEhSWddKlDzhiypi4EdhIVXP0c+cTlES6TT evy7UcT+qYKerjwm6c35TbfYGekDpt0HziLQYBmcKvewn6UzXWw3zTkQPD2yzQbr2w1fPUzvP3X 7Pe49IbOti5b++yQXr1qgH0Cg4epQtmCwweRfYa8bDl6/L25oebt4nSXVl2Z4FqnGQR/RxXRCdi 5tR+QfKbN+cTNKBgz80UTbNgNofa+O+umSZA== X-Gm-Gg: ASbGnctLK/uebvUxE4w5gN6A54rDrAqZIedf2E9ZcGKGxPhsBdl5x6Eeqe/jwqQ5cX/ S2zranWXkjZHgTqSCQo6EyS7mZ0bbDpdpPOQ4eA6OyyKPan2iTfnR/s2eV/miC7+7sRy2wQ1Imv 7vEkljQICY16/GRyKMdU6bbKSRqYQiuo3Zipoej3aV/61zFUz/iTGDYl8UmAMOqx0JoyJkJNgu4 H78NaA1B5v+E8hBwbseYmlSR5A1DC7dzab+lmD7SEIk1h0MGBxs+tYtF9mqA88nrT267yELRlVl dypwQ70J9d7q83FnY1Y76983J4OyRZOG8Qh9jUA= X-Received: by 2002:a05:6000:22c2:b0:3e6:f91e:fa72 with SMTP id ffacd0b85a97d-4256713edb3mr5851564f8f.7.1759691777245; Sun, 05 Oct 2025 12:16:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFs468vAjdBo/BoHJhvgXOcGckaMGaLlnNU12LRDFYAvwH/uzw/ZaWKOiAihqyswnFFqwHdPg== X-Received: by 2002:a05:6000:22c2:b0:3e6:f91e:fa72 with SMTP id ffacd0b85a97d-4256713edb3mr5851546f8f.7.1759691776740; Sun, 05 Oct 2025 12:16:16 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:14 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Abeni , Akihiko Odaki , Jason Wang , Stefano Garzarella , Lei Yang Subject: [PULL 06/75] virtio: add support for negotiating extended features Message-ID: <64a6a336f42bc6305ab7589fd874cb4a3d403bd0.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691960018116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni The virtio specifications allows for a device features space up to 128 bits and more. Soon we are going to use some of the 'extended' bits features for the virtio net driver. Add support to allow extended features negotiation on a per devices basis. Devices willing to negotiated extended features need to implemented a new pair of features getter/setter, the core will conditionally use them instead of the basic one. Note that 'bad_features' don't need to be extended, as they are bound to the 64 bits limit. Reviewed-by: Akihiko Odaki Acked-by: Jason Wang Acked-by: Stefano Garzarella Signed-off-by: Paolo Abeni Tested-by: Lei Yang Reviewed-by: Michael S. Tsirkin Message-ID: <9bb29d70adc3f2b8c7756d4e3cd076cffee87826.1758549625.git.pabeni= @redhat.com> Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 4 ++++ hw/virtio/virtio-bus.c | 11 ++++++++--- hw/virtio/virtio.c | 14 +++++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 39e4059a66..2aeb021fb3 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -178,6 +178,9 @@ struct VirtioDeviceClass { /* This is what a VirtioDevice must implement */ DeviceRealize realize; DeviceUnrealize unrealize; + void (*get_features_ex)(VirtIODevice *vdev, uint64_t *requested_featur= es, + Error **errp); + void (*set_features_ex)(VirtIODevice *vdev, const uint64_t *val); uint64_t (*get_features)(VirtIODevice *vdev, uint64_t requested_features, Error **errp); @@ -373,6 +376,7 @@ void virtio_queue_reset(VirtIODevice *vdev, uint32_t qu= eue_index); void virtio_queue_enable(VirtIODevice *vdev, uint32_t queue_index); void virtio_update_irq(VirtIODevice *vdev); int virtio_set_features(VirtIODevice *vdev, uint64_t val); +int virtio_set_features_ex(VirtIODevice *vdev, const uint64_t *val); =20 /* Base devices. */ typedef struct VirtIOBlkConf VirtIOBlkConf; diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index 11adfbf3ab..cef944e015 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -62,9 +62,14 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error= **errp) } =20 /* Get the features of the plugged device. */ - assert(vdc->get_features !=3D NULL); - vdev->host_features =3D vdc->get_features(vdev, vdev->host_features, - &local_err); + if (vdc->get_features_ex) { + vdc->get_features_ex(vdev, vdev->host_features_ex, &local_err); + } else { + assert(vdc->get_features !=3D NULL); + virtio_features_from_u64(vdev->host_features_ex, + vdc->get_features(vdev, vdev->host_featur= es, + &local_err)); + } if (local_err) { error_propagate(errp, local_err); return; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index bf53c211e5..34f977a3c9 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3103,7 +3103,9 @@ static int virtio_set_features_nocheck(VirtIODevice *= vdev, const uint64_t *val) bad =3D virtio_features_andnot(tmp, val, vdev->host_features_ex); virtio_features_and(tmp, val, vdev->host_features_ex); =20 - if (k->set_features) { + if (k->set_features_ex) { + k->set_features_ex(vdev, val); + } else if (k->set_features) { bad =3D bad || virtio_features_use_ex(tmp); k->set_features(vdev, tmp[0]); } @@ -3149,6 +3151,13 @@ virtio_set_features_nocheck_maybe_co(VirtIODevice *v= dev, int virtio_set_features(VirtIODevice *vdev, uint64_t val) { uint64_t features[VIRTIO_FEATURES_NU64S]; + + virtio_features_from_u64(features, val); + return virtio_set_features_ex(vdev, features); +} + +int virtio_set_features_ex(VirtIODevice *vdev, const uint64_t *features) +{ int ret; /* * The driver must not attempt to set features after feature negotiati= on @@ -3158,13 +3167,12 @@ int virtio_set_features(VirtIODevice *vdev, uint64_= t val) return -EINVAL; } =20 - if (val & (1ull << VIRTIO_F_BAD_FEATURE)) { + if (features[0] & (1ull << VIRTIO_F_BAD_FEATURE)) { qemu_log_mask(LOG_GUEST_ERROR, "%s: guest driver for %s has enabled UNUSED(30) feat= ure bit!\n", __func__, vdev->name); } =20 - virtio_features_from_u64(features, val); ret =3D virtio_set_features_nocheck(vdev, features); if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { /* VIRTIO_RING_F_EVENT_IDX changes the size of the caches. */ --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691841; cv=none; d=zohomail.com; s=zohoarc; b=lK8gBUeUM9hpaRRpIzgfCbOEmnJI3A2pnoiUvtJeuzJK7CCoe7wFJFAlITcRiXOA/jTi14S+a1xtZPMalU79BXo0aG6qe26nYo2WP3bxz7lN9XKfv2ZR8iIdoX487GfMG+JtDOzj87LwjxV+cZBWISIbOjotbBb4H+Q5NtbqaVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691841; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CYadMOaENieYb148icK+VaNmWm4vj/PKt597pX2AzBE=; b=nesQ5jyZWavMPIdF8BeXth/dpbQ+3GPh3GczXJozv2+ucwURi2EIy1NhDZp6LkJ2Pugswd8TE5Vg8I5dJx05nGZGq+/OZaLh8I2ugFTitNNHmQ4/niT9wAQj/hMbKx+bPVV4rBvXjqKfUMFQybYZ0aV/d/gKbzP4ndEh09maRHU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691841558654.714336852172; Sun, 5 Oct 2025 12:17:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDo-0007Up-L0; Sun, 05 Oct 2025 15:16:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDZ-0007RD-96 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16: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 1v5UDX-0006MD-4R for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:24 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-411-f1f9_LJENjyTO6ZX_CGNHQ-1; Sun, 05 Oct 2025 15:16:20 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46e41c32209so19661805e9.0 for ; Sun, 05 Oct 2025 12:16:20 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e619c3b75sm217403965e9.7.2025.10.05.12.16.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691782; 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=CYadMOaENieYb148icK+VaNmWm4vj/PKt597pX2AzBE=; b=DT1q2XlXoIL3+iC4eP3mOQXqkAMU4xSS9JhDEey3GjxyHO+qCwHRQbv76b7ke73vV1/LXV ra8foS6NLxSXK/HREU+xpkdeevZGW0UwkfM4cXnxKcEnSB/u4knZWkbECbKE97SQ+zmwqH eFJk8sOGyHrGeeT2r+MuolTHVDcWb/U= X-MC-Unique: f1f9_LJENjyTO6ZX_CGNHQ-1 X-Mimecast-MFC-AGG-ID: f1f9_LJENjyTO6ZX_CGNHQ_1759691779 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691779; x=1760296579; 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=CYadMOaENieYb148icK+VaNmWm4vj/PKt597pX2AzBE=; b=ca/c5HjXdvc7FN/0iXijJTSNbH8SsE2IM4eHJBDJGZsDBE5LVYjzWypwxAE3KuZkEO LiFA+271kfKmjYxiRPoImisPW9bXpdg0hBjheXkPXvv/YHs6XOw/nI0ulnX6qf3Ma7Dw mw2ChICgkF/VQFP5ltycNJeY8hz/WjE6e8MRF+Z7ESkhnk9O6Cdylp2/3VLqjqr6yonw MnHq4Nbg/sH4KQnPnKk4UkqLdb8H3KYCVGGpDILjsnoFCR5yW2tnNbxblOX+tR406I/+ UE9BxLEmLhb8Am+w1S2CEEsoc6fUmNT2jJ8ajVDzT/RFd4vEDYm856zUYlmTiN9GRZuB ZYbg== X-Gm-Message-State: AOJu0YzNmZBjC2I4MhP/qVn2TmZNHyrFy8OvEN3dlAF/88Gtoz3hbAlQ yBhyF/93uWH+CugDmr+u7j2EoxM3I/OqiaiSKQVmmn4sbYEVmA8h9jvojXRjWgJjwzzqjTtzsKv Fv3m6UsA4PvpaDqmfUG+eDCb9AMER14xfDbdGq0Kc4UVJZotEgGOLpepEllhpIf2Fvy6nuF+4kB KM8F7XH7Ox+m+xB98QXp65lwoMxqmrRP/UTQ== X-Gm-Gg: ASbGncv0C8WZfw+z/Qfuc8CG6MGdE6NmixYUFhltn6NgcBgqHkgmk0hN0QEzLUoQBR3 TV79WKqEeCaKMa1ih4seMEpj9pM0qXwRbeGGJOOfsaeluOFWn+I+h9lwU8wgmYmYFMTVYU53Q+4 0crWVTPH9BPIzqUobs1U26h0ft7gLOeV/S45YDtpBKzmdT1c5NMPgaIjINqPgeXvNxrZl5eqQFV TLT9ecleXIS6HGv7/YhdtB/gmWL+pi7otAWsgIJQUXtgRfbo4Bo2Cobls5DAUbsWN54FUzyidvF jSjJcKFrhoTKjGndr9zjwOZLmBTlejHNaRQ6PRM= X-Received: by 2002:a05:600c:8185:b0:468:7a5a:1494 with SMTP id 5b1f17b1804b1-46e710f6c7amr58387995e9.1.1759691779209; Sun, 05 Oct 2025 12:16:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVWPKvvenOMbUd1eVy/txA2vZ0SV/DPwJyyKrRQzLERmJditeSADYlFiEOHf7tbmEjv5f+Eg== X-Received: by 2002:a05:600c:8185:b0:468:7a5a:1494 with SMTP id 5b1f17b1804b1-46e710f6c7amr58387875e9.1.1759691778776; Sun, 05 Oct 2025 12:16:18 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:16 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Abeni , Akihiko Odaki , Jason Wang , Stefano Garzarella , Lei Yang Subject: [PULL 07/75] virtio-pci: implement support for extended features Message-ID: <712c79d6d374e7abe94599de5ba2d155d5a79955.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691853387116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni Extend the features configuration space to 128 bits. If the virtio device supports any extended features, allow the common read/write operation to access all of it, otherwise keep exposing only the lower 64 bits. On migration, save the 128 bit version of the features only if the upper bits are non zero. Relay on reset to clear all the feature space before load. Reviewed-by: Akihiko Odaki Acked-by: Jason Wang Acked-by: Stefano Garzarella Signed-off-by: Paolo Abeni Tested-by: Lei Yang Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-pci.h | 2 +- hw/virtio/virtio-pci.c | 76 ++++++++++++++++++++++++++++++---- 2 files changed, 68 insertions(+), 10 deletions(-) diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index eab5394898..639752977e 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -158,7 +158,7 @@ struct VirtIOPCIProxy { uint32_t nvectors; uint32_t dfselect; uint32_t gfselect; - uint32_t guest_features[2]; + uint32_t guest_features[VIRTIO_FEATURES_NU32S]; VirtIOPCIQueue vqs[VIRTIO_QUEUE_MAX]; =20 VirtIOIRQFD *vector_irqfd; diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 767216d795..01e4fecaf4 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -109,6 +109,29 @@ static const VMStateDescription vmstate_virtio_pci_mod= ern_queue_state =3D { } }; =20 +static bool virtio_pci_modern_state_features128_needed(void *opaque) +{ + VirtIOPCIProxy *proxy =3D opaque; + uint32_t features =3D 0; + int i; + + for (i =3D 2; i < ARRAY_SIZE(proxy->guest_features); ++i) { + features |=3D proxy->guest_features[i]; + } + return features; +} + +static const VMStateDescription vmstate_virtio_pci_modern_state_features12= 8 =3D { + .name =3D "virtio_pci/modern_state/features128", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D &virtio_pci_modern_state_features128_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32_SUB_ARRAY(guest_features, VirtIOPCIProxy, 2, 2), + VMSTATE_END_OF_LIST() + } +}; + static bool virtio_pci_modern_state_needed(void *opaque) { VirtIOPCIProxy *proxy =3D opaque; @@ -116,6 +139,12 @@ static bool virtio_pci_modern_state_needed(void *opaqu= e) return virtio_pci_modern(proxy); } =20 +/* + * Avoid silently breaking migration should the feature space increase + * even more in the (far away) future + */ +QEMU_BUILD_BUG_ON(VIRTIO_FEATURES_NU32S !=3D 4); + static const VMStateDescription vmstate_virtio_pci_modern_state_sub =3D { .name =3D "virtio_pci/modern_state", .version_id =3D 1, @@ -124,11 +153,15 @@ static const VMStateDescription vmstate_virtio_pci_mo= dern_state_sub =3D { .fields =3D (const VMStateField[]) { VMSTATE_UINT32(dfselect, VirtIOPCIProxy), VMSTATE_UINT32(gfselect, VirtIOPCIProxy), - VMSTATE_UINT32_ARRAY(guest_features, VirtIOPCIProxy, 2), + VMSTATE_UINT32_SUB_ARRAY(guest_features, VirtIOPCIProxy, 0, 2), VMSTATE_STRUCT_ARRAY(vqs, VirtIOPCIProxy, VIRTIO_QUEUE_MAX, 0, vmstate_virtio_pci_modern_queue_state, VirtIOPCIQueue), VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription * const []) { + &vmstate_virtio_pci_modern_state_features128, + NULL } }; =20 @@ -1477,6 +1510,19 @@ int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, return virtio_pci_add_mem_cap(proxy, &cap.cap); } =20 +static int virtio_pci_select_max(const VirtIODevice *vdev) +{ + int i; + + for (i =3D VIRTIO_FEATURES_NU64S - 1; i > 0; i--) { + if (vdev->host_features_ex[i]) { + return (i + 1) * 2; + } + } + + return 2; +} + static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, unsigned size) { @@ -1494,18 +1540,21 @@ static uint64_t virtio_pci_common_read(void *opaque= , hwaddr addr, val =3D proxy->dfselect; break; case VIRTIO_PCI_COMMON_DF: - if (proxy->dfselect <=3D 1) { + if (proxy->dfselect < virtio_pci_select_max(vdev)) { VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); =20 - val =3D (vdev->host_features & ~vdc->legacy_features) >> - (32 * proxy->dfselect); + val =3D vdev->host_features_ex[proxy->dfselect >> 1] >> + (32 * (proxy->dfselect & 1)); + if (proxy->dfselect <=3D 1) { + val &=3D (~vdc->legacy_features) >> (32 * proxy->dfselect); + } } break; case VIRTIO_PCI_COMMON_GFSELECT: val =3D proxy->gfselect; break; case VIRTIO_PCI_COMMON_GF: - if (proxy->gfselect < ARRAY_SIZE(proxy->guest_features)) { + if (proxy->gfselect < virtio_pci_select_max(vdev)) { val =3D proxy->guest_features[proxy->gfselect]; } break; @@ -1588,11 +1637,18 @@ static void virtio_pci_common_write(void *opaque, h= waddr addr, proxy->gfselect =3D val; break; case VIRTIO_PCI_COMMON_GF: - if (proxy->gfselect < ARRAY_SIZE(proxy->guest_features)) { + if (proxy->gfselect < virtio_pci_select_max(vdev)) { + uint64_t features[VIRTIO_FEATURES_NU64S]; + int i; + proxy->guest_features[proxy->gfselect] =3D val; - virtio_set_features(vdev, - (((uint64_t)proxy->guest_features[1]) << 3= 2) | - proxy->guest_features[0]); + virtio_features_clear(features); + for (i =3D 0; i < ARRAY_SIZE(proxy->guest_features); ++i) { + uint64_t cur =3D proxy->guest_features[i]; + + features[i >> 1] |=3D cur << ((i & 1) * 32); + } + virtio_set_features_ex(vdev, features); } break; case VIRTIO_PCI_COMMON_MSIX: @@ -2311,6 +2367,8 @@ static void virtio_pci_reset(DeviceState *qdev) virtio_bus_reset(bus); msix_unuse_all_vectors(&proxy->pci_dev); =20 + memset(proxy->guest_features, 0, sizeof(proxy->guest_features)); + for (i =3D 0; i < VIRTIO_QUEUE_MAX; i++) { proxy->vqs[i].enabled =3D 0; proxy->vqs[i].reset =3D 0; --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692327; cv=none; d=zohomail.com; s=zohoarc; b=aV+46Npc/DL19YMl6oL4IIF+oY/nXw5pLtOOaLEe6eiNtTgZTf3YpWJ6bhbNiy0JGy4yB6c+f10ERhJ1Py7H+rixCk7XgPzPaUiagG1plcMQaRlJDXZdiI2849n+NIhqThJOnzt3mI/EydPPvnQaLZ30yiMbG2FPsUPeYShGnu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692327; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WH77u1+96mDkB/R2j+jCbflBTMYfZQxMDJ7RQLEIVkk=; b=V16t4/8Cg7clDPWbSgjKj6JlCzrnRKGc/vlCQaxzBuuUezqrKSnOjFgdFx+mzsWJbat0G6unJw63obImxO9HWzNJAhXgsit47cvQYjVvb4fuP3fBht+5N/vjttUKP06Hf4+CNCPB4mheCSDqZJaO9KtTdiOxeGUwywxsncRJUdI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692327904894.7399663985761; Sun, 5 Oct 2025 12:25:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDl-0007TI-1x; Sun, 05 Oct 2025 15:16:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDd-0007Rj-5q for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDa-0006MQ-AT for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:28 -0400 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-180-pc4qlaD4OZ67nJTk8gdkdA-1; Sun, 05 Oct 2025 15:16:23 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3ef9218daf5so3095961f8f.1 for ; Sun, 05 Oct 2025 12:16:23 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6b77sm17440523f8f.6.2025.10.05.12.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691785; 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=WH77u1+96mDkB/R2j+jCbflBTMYfZQxMDJ7RQLEIVkk=; b=DPerjUJ5fIlXa56YU9iK5gXmr8jm7+Fx9yy0G8DIe97mfNKreON0nsOCnjIu5XB3yBNFC5 5ypKGtZQ+VzXfQfBEHv4MzgNUkn+A0j9iOZTpFMQuY+ms7p9ppt1oO3iH43EwXASmkgg7t fdPOKpmPlPjp4acR9UVcxFcXYLaGSa4= X-MC-Unique: pc4qlaD4OZ67nJTk8gdkdA-1 X-Mimecast-MFC-AGG-ID: pc4qlaD4OZ67nJTk8gdkdA_1759691782 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691782; x=1760296582; 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=WH77u1+96mDkB/R2j+jCbflBTMYfZQxMDJ7RQLEIVkk=; b=K7VPZuuZM3fqxOMnJyhP7Jh7VdMMLBxSnVtBgaU+QrcgkJ2QO4rCX7kr2ZntPr9Wt7 LUBIVLiRwT0dkFTHqbWYRWhNRi2ki9qScQWaB39iF/aDtA8CzeVzaUMYYq/wIt6ocR+p /hgq0zB7EI1HF0x1aOpCO1h3Qiv/60loD7Y+LeNFqmUi2b3HubX6m2baq6rVFzDH/pCT bXzpuNnAn6iPSd4szzxNKkKEDc+HfyIPzY+iuWlUdGu7CD+Iq8wh+6fm3VN1ZOxgcX13 0h3hWZUP1QRvUCLM3b9aI99P8OHlGJWc5RTljv+YCvFMqoZoBq/kzrLh94IGNV8qhnlM 3dwg== X-Gm-Message-State: AOJu0YxQIsyocqeInSeJu7Vh9BrvRz7LCQVTFgEopsKa/OWZ/Gw4MYyn W6Upp4EYvjQhfQzqGGD/Sqlr4R3hV0zqyJPKGYMynBBvzSiF627kQY+cJEvwW1N06c8nVdPhgo2 aQd3wH9NQQVXykF4szMzvhoAzouiEiMazDM6+FMnk7C9fE4B1HCkKR3NknoT8h/QUb8ku0jQIDN rY52WBFkjN8DG16v2xlIyoXkbpT5USnKAyEA== X-Gm-Gg: ASbGncvhBUEEquBwVvRPK2UyU7pOh1PwIw77jYg2V8TSV8cX40yqszLGjJFSggu+wK8 5Xu+9GxK9PFhfy2ZrIIKCmV2qrVwWxPNKVSXp35MZB08KBRouvoUTIhM9tWP0GgQYBUGEqokgBy +YuZ6cdBWO1FP8iuiTHu9BVvH5cxMUHaMPYPFdtVVHG68sL5llZAT2tfhM6UKZkw4w8jQnnp9Mv oskkzNYHlLc0xjZ21sEM66AGxVFdiREhTsFwx3BzDRA+bdF8DBHDJiLSHxO+KPL12hvQj4CmFDh tylGKZuZYx7iCYvq5tGK6GyoGW5eT0skokZ7Xrs= X-Received: by 2002:a05:6000:2386:b0:3ee:1357:e191 with SMTP id ffacd0b85a97d-425671a92f2mr5277708f8f.30.1759691781698; Sun, 05 Oct 2025 12:16:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKgr6PbFMDjTuF2vhS8IJwprAbxR4/bkSVCIkxkTOFjrlPH4LoWJrOVxW/Xoh+BnUpmTcIjg== X-Received: by 2002:a05:6000:2386:b0:3ee:1357:e191 with SMTP id ffacd0b85a97d-425671a92f2mr5277693f8f.30.1759691781122; Sun, 05 Oct 2025 12:16:21 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:18 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Abeni , Akihiko Odaki , Jason Wang , Stefano Garzarella , Lei Yang Subject: [PULL 08/75] vhost: add support for negotiating extended features Message-ID: <9f979ef0e01a2dd47d167c482a9e2d1dcdff2d3f.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692333482116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni Similar to virtio infra, vhost core maintains the features status in the full extended format and allows the devices to implement extended version of the getter/setter. Note that 'protocol_features' are not extended: they are only used by vhost-user, and the latter device is not going to implement extended features soon. Reviewed-by: Akihiko Odaki Acked-by: Jason Wang Acked-by: Stefano Garzarella Signed-off-by: Paolo Abeni Tested-by: Lei Yang Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-backend.h | 6 +++ include/hw/virtio/vhost.h | 56 +++++++++++++++++++++---- hw/virtio/vhost.c | 68 ++++++++++++++++++++++--------- 3 files changed, 103 insertions(+), 27 deletions(-) diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index d6df209a2f..ff94fa1734 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -95,6 +95,10 @@ typedef int (*vhost_new_worker_op)(struct vhost_dev *dev, struct vhost_worker_state *worker); typedef int (*vhost_free_worker_op)(struct vhost_dev *dev, struct vhost_worker_state *worker); +typedef int (*vhost_set_features_ex_op)(struct vhost_dev *dev, + const uint64_t *features); +typedef int (*vhost_get_features_ex_op)(struct vhost_dev *dev, + uint64_t *features); typedef int (*vhost_set_features_op)(struct vhost_dev *dev, uint64_t features); typedef int (*vhost_get_features_op)(struct vhost_dev *dev, @@ -186,6 +190,8 @@ typedef struct VhostOps { vhost_free_worker_op vhost_free_worker; vhost_get_vring_worker_op vhost_get_vring_worker; vhost_attach_vring_worker_op vhost_attach_vring_worker; + vhost_set_features_ex_op vhost_set_features_ex; + vhost_get_features_ex_op vhost_get_features_ex; vhost_set_features_op vhost_set_features; vhost_get_features_op vhost_get_features; vhost_set_backend_cap_op vhost_set_backend_cap; diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 66be6afc88..08bbb4dfe9 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -107,9 +107,9 @@ struct vhost_dev { * future use should be discouraged and the variable retired as * its easy to confuse with the VirtIO backend_features. */ - uint64_t features; - uint64_t acked_features; - uint64_t backend_features; + VIRTIO_DECLARE_FEATURES(features); + VIRTIO_DECLARE_FEATURES(acked_features); + VIRTIO_DECLARE_FEATURES(backend_features); =20 /** * @protocol_features: is the vhost-user only feature set by @@ -320,6 +320,20 @@ bool vhost_virtqueue_pending(struct vhost_dev *hdev, i= nt n); void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int = n, bool mask); =20 +/** + * vhost_get_features_ex() - sanitize the extended features set + * @hdev: common vhost_dev structure + * @feature_bits: pointer to terminated table of feature bits + * @features: original features set, filtered out on return + * + * This is the extended variant of vhost_get_features(), supporting the + * the extended features set. Filter it with the intersection of what is + * supported by the vhost backend (hdev->features) and the supported + * feature_bits. + */ +void vhost_get_features_ex(struct vhost_dev *hdev, + const int *feature_bits, + uint64_t *features); /** * vhost_get_features() - return a sanitised set of feature bits * @hdev: common vhost_dev structure @@ -330,8 +344,28 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, Virt= IODevice *vdev, int n, * is supported by the vhost backend (hdev->features), the supported * feature_bits and the requested feature set. */ -uint64_t vhost_get_features(struct vhost_dev *hdev, const int *feature_bit= s, - uint64_t features); +static inline uint64_t vhost_get_features(struct vhost_dev *hdev, + const int *feature_bits, + uint64_t features) +{ + uint64_t features_ex[VIRTIO_FEATURES_NU64S]; + + virtio_features_from_u64(features_ex, features); + vhost_get_features_ex(hdev, feature_bits, features_ex); + return features_ex[0]; +} + +/** + * vhost_ack_features_ex() - set vhost full set of acked_features + * @hdev: common vhost_dev structure + * @feature_bits: pointer to terminated table of feature bits + * @features: requested feature set + * + * This sets the internal hdev->acked_features to the intersection of + * the backends advertised features and the supported feature_bits. + */ +void vhost_ack_features_ex(struct vhost_dev *hdev, const int *feature_bits, + const uint64_t *features); =20 /** * vhost_ack_features() - set vhost acked_features @@ -342,8 +376,16 @@ uint64_t vhost_get_features(struct vhost_dev *hdev, co= nst int *feature_bits, * This sets the internal hdev->acked_features to the intersection of * the backends advertised features and the supported feature_bits. */ -void vhost_ack_features(struct vhost_dev *hdev, const int *feature_bits, - uint64_t features); +static inline void vhost_ack_features(struct vhost_dev *hdev, + const int *feature_bits, + uint64_t features) +{ + uint64_t features_ex[VIRTIO_FEATURES_NU64S]; + + virtio_features_from_u64(features_ex, features); + vhost_ack_features_ex(hdev, feature_bits, features_ex); +} + unsigned int vhost_get_max_memslots(void); unsigned int vhost_get_free_memslots(void); =20 diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 6557c58d12..5f485ad6cb 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -972,20 +972,34 @@ static int vhost_virtqueue_set_addr(struct vhost_dev = *dev, static int vhost_dev_set_features(struct vhost_dev *dev, bool enable_log) { - uint64_t features =3D dev->acked_features; + uint64_t features[VIRTIO_FEATURES_NU64S]; int r; + + virtio_features_copy(features, dev->acked_features_ex); if (enable_log) { - features |=3D 0x1ULL << VHOST_F_LOG_ALL; + virtio_add_feature_ex(features, VHOST_F_LOG_ALL); } if (!vhost_dev_has_iommu(dev)) { - features &=3D ~(0x1ULL << VIRTIO_F_IOMMU_PLATFORM); + virtio_clear_feature_ex(features, VIRTIO_F_IOMMU_PLATFORM); } if (dev->vhost_ops->vhost_force_iommu) { if (dev->vhost_ops->vhost_force_iommu(dev) =3D=3D true) { - features |=3D 0x1ULL << VIRTIO_F_IOMMU_PLATFORM; + virtio_add_feature_ex(features, VIRTIO_F_IOMMU_PLATFORM); } } - r =3D dev->vhost_ops->vhost_set_features(dev, features); + + if (virtio_features_use_ex(features) && + !dev->vhost_ops->vhost_set_features_ex) { + r =3D -EINVAL; + VHOST_OPS_DEBUG(r, "extended features without device support"); + goto out; + } + + if (dev->vhost_ops->vhost_set_features_ex) { + r =3D dev->vhost_ops->vhost_set_features_ex(dev, features); + } else { + r =3D dev->vhost_ops->vhost_set_features(dev, features[0]); + } if (r < 0) { VHOST_OPS_DEBUG(r, "vhost_set_features failed"); goto out; @@ -1508,12 +1522,27 @@ static void vhost_virtqueue_cleanup(struct vhost_vi= rtqueue *vq) } } =20 +static int vhost_dev_get_features(struct vhost_dev *hdev, + uint64_t *features) +{ + uint64_t features64; + int r; + + if (hdev->vhost_ops->vhost_get_features_ex) { + return hdev->vhost_ops->vhost_get_features_ex(hdev, features); + } + + r =3D hdev->vhost_ops->vhost_get_features(hdev, &features64); + virtio_features_from_u64(features, features64); + return r; +} + int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, uint32_t busyloop_timeou= t, Error **errp) { + uint64_t features[VIRTIO_FEATURES_NU64S]; unsigned int used, reserved, limit; - uint64_t features; int i, r, n_initialized_vqs =3D 0; =20 hdev->vdev =3D NULL; @@ -1533,7 +1562,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, goto fail; } =20 - r =3D hdev->vhost_ops->vhost_get_features(hdev, &features); + r =3D vhost_dev_get_features(hdev, features); if (r < 0) { error_setg_errno(errp, -r, "vhost_get_features failed"); goto fail; @@ -1571,7 +1600,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, } } =20 - hdev->features =3D features; + virtio_features_copy(hdev->features_ex, features); =20 hdev->memory_listener =3D (MemoryListener) { .name =3D "vhost", @@ -1594,7 +1623,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, }; =20 if (hdev->migration_blocker =3D=3D NULL) { - if (!(hdev->features & (0x1ULL << VHOST_F_LOG_ALL))) { + if (!virtio_has_feature_ex(hdev->features_ex, VHOST_F_LOG_ALL)) { error_setg(&hdev->migration_blocker, "Migration disabled: vhost lacks VHOST_F_LOG_ALL fe= ature."); } else if (vhost_dev_log_is_shared(hdev) && !qemu_memfd_alloc_chec= k()) { @@ -1859,28 +1888,27 @@ static void vhost_start_config_intr(struct vhost_de= v *dev) } } =20 -uint64_t vhost_get_features(struct vhost_dev *hdev, const int *feature_bit= s, - uint64_t features) +void vhost_get_features_ex(struct vhost_dev *hdev, + const int *feature_bits, + uint64_t *features) { const int *bit =3D feature_bits; + while (*bit !=3D VHOST_INVALID_FEATURE_BIT) { - uint64_t bit_mask =3D (1ULL << *bit); - if (!(hdev->features & bit_mask)) { - features &=3D ~bit_mask; + if (!virtio_has_feature_ex(hdev->features_ex, *bit)) { + virtio_clear_feature_ex(features, *bit); } bit++; } - return features; } =20 -void vhost_ack_features(struct vhost_dev *hdev, const int *feature_bits, - uint64_t features) +void vhost_ack_features_ex(struct vhost_dev *hdev, const int *feature_bits, + const uint64_t *features) { const int *bit =3D feature_bits; while (*bit !=3D VHOST_INVALID_FEATURE_BIT) { - uint64_t bit_mask =3D (1ULL << *bit); - if (features & bit_mask) { - hdev->acked_features |=3D bit_mask; + if (virtio_has_feature_ex(features, *bit)) { + virtio_add_feature_ex(hdev->acked_features_ex, *bit); } bit++; } --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692298; cv=none; d=zohomail.com; s=zohoarc; b=QnK8ZOAvhf6CmEuGQZJtTnF4BDt4WYEJRAkV8I3wjPf55LPoVNehIpZxmDx9+S3mjlLTvapemTYYPDkLAbcbLaZ9srqfQxMNbTZmtE/rVA5ovN3eJGrVOlfgMV+FuDMkG7Djwp6OQ/hfYdwk9YXsTm3vBEoW5HFS128MA13Acxk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692298; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vd4mdDSqlXlP9anYwvuHCBfNnSb8ZvgPYM0HvzpPyDo=; b=lphTwaPRtUNCOThni+2nrGj0fA2wLn3RlHSgeSKDNj0+vSVszn1/ZLH4YXUsU+5dyqNFD2sVpQJxJpMpeI+kpba29+jotFZ1GmYSi4UOT3SnQiarkTTBD8O3YRXIzhDFi5EWiciCKzIVDBIZc3OVIq4Fa2vxXkVidHy12ZHT7Bo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692298284889.4979108387095; Sun, 5 Oct 2025 12:24:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDl-0007TL-85; Sun, 05 Oct 2025 15:16:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDd-0007Rn-K2 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:32 -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 1v5UDb-0006Me-Gz for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:29 -0400 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-639-Pp3L1QMBPDqQNwBZZOKTKw-1; Sun, 05 Oct 2025 15:16:25 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-42421b15185so3097767f8f.1 for ; Sun, 05 Oct 2025 12:16:25 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6c3esm17614126f8f.1.2025.10.05.12.16.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691786; 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=vd4mdDSqlXlP9anYwvuHCBfNnSb8ZvgPYM0HvzpPyDo=; b=HttCYaaXeOGSoSVmJ7FIPlus4JQM1ofh2tiylI/W4JeZG/TUey9jWyNB87zynm6s9q97k8 pGtp94YDfthummM/eyAwejSzVobVYNlWqAao7kFeBLwumQCeEtbUrR4fFfanw+TCjw3Ypm 3vXw2ALzerlrjmbRb7bejdEJqHNaWtc= X-MC-Unique: Pp3L1QMBPDqQNwBZZOKTKw-1 X-Mimecast-MFC-AGG-ID: Pp3L1QMBPDqQNwBZZOKTKw_1759691784 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691784; x=1760296584; 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=vd4mdDSqlXlP9anYwvuHCBfNnSb8ZvgPYM0HvzpPyDo=; b=jsttjB4M8jB61mo2P1QarAF/0tarIsLgm3sesGHlSlkaxp11DSlQteHyEOUFvU8WRJ JRMuqE5GLvJCuXsiuwTV6N55PqwEAl4S5SFSZJ8ZDNKL5BkKqRxIcdst3bin/uXmDfEr n8GC4fZRCQfnrBoXDSVodLibigtVhXbXFpWDEETfJh1XwkOa8AGllWuP3zON7N9G5rFf 4iRA3/AIxAYx+J3cxShJbcE9oC42nz2vowC7d0yxxe/9zOuTahiPl6Q4Uf1Cl0/AutyG C656BLZDtfFhxcu+4g/LzQTuI1ttpsxiRrVsV/T7FF5CjlNxl03bFVPRZuBO+0HFO6qu Iy/Q== X-Gm-Message-State: AOJu0Yyd0I4bBas82kPZb7CrS/znXKbxLw/849VftfOzjhU+T33kK82U HTqBDrG5tvbx+uh8uODJii5BQyzhQD4eiY0lOKKpZ1I+9MGTvC8HB7Xos58vcNltR+pOy08ic97 OeUrz4AJdD0t3TFQ6MEbNr+WkHdxhFxVSpgZNGOVbfhZXPADciWqirnuK/HVqvaEvOsBaZp/R1t aFT5Kh+4NTtQy0QFp7X9gWwUv60kO8YEvXAA== X-Gm-Gg: ASbGnct+khwyhLsdvbEiZDEffWKzQ3hDZwvK84U/jaK0h6AcvCKshpuaUdaYOi/g8St x8Y7cnp/jKH8mK7Yj5opM2iLQ9tq+vdQv/MNtNkxvPmdZknEQqIzE+46VJaMmUZ7F4qERM3xGne DRJt1mCB/TdtpFEvZ3y73J2bm5Bxs6GXYSDsz5aeFKlAy9L/1inlzVSDoHySg2bxjvMRxbm+4SD 4pA7krQQwRkT4Lfa/bz6g1BXr06SZ8ufnhqYNxEjvs0EMOW4ERMoIAntZS7eLMz08ewKZE9qOlz tLPMJV+2ZoLQz//UuPWRXKJr/BMsKPTCQ4gZj2k= X-Received: by 2002:a05:6000:2282:b0:401:e7a8:5ca2 with SMTP id ffacd0b85a97d-425671a31e7mr6303241f8f.33.1759691783993; Sun, 05 Oct 2025 12:16:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXcbBfZ5c4zHoG1hZwR0SpEHYB3p+3cWzFl+zyJANyMlYfbetynLbuFEEmwIJ+7XbPc76ksQ== X-Received: by 2002:a05:6000:2282:b0:401:e7a8:5ca2 with SMTP id ffacd0b85a97d-425671a31e7mr6303215f8f.33.1759691783381; Sun, 05 Oct 2025 12:16:23 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Abeni , Akihiko Odaki , Jason Wang , Markus Armbruster , Stefano Garzarella , Lei Yang , Eric Blake Subject: [PULL 09/75] qmp: update virtio features map to support extended features 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692302076116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni Extend the VirtioDeviceFeatures struct with an additional u64 to track unknown features in the 64-127 bit range and decode the full virtio features spaces for vhost and virtio devices. Also add entries for the soon-to-be-supported virtio net GSO over UDP features. Reviewed-by: Akihiko Odaki Acked-by: Jason Wang Acked-by: Markus Armbruster Acked-by: Stefano Garzarella Signed-off-by: Paolo Abeni Tested-by: Lei Yang Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- qapi/virtio.json | 9 +++- hw/virtio/virtio-qmp.h | 3 +- hw/virtio/virtio-hmp-cmds.c | 3 +- hw/virtio/virtio-qmp.c | 91 +++++++++++++++++++++++++------------ 4 files changed, 74 insertions(+), 32 deletions(-) diff --git a/qapi/virtio.json b/qapi/virtio.json index 9d652fe4a8..05295ab665 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -247,6 +247,7 @@ # }, # "host-features": { # "unknown-dev-features": 1073741824, +# "unknown-dev-features2": 0, # "dev-features": [], # "transports": [ # "VIRTIO_RING_F_EVENT_IDX: Used & avail. event field= s enabled", @@ -490,14 +491,18 @@ # unique features) # # @unknown-dev-features: Virtio device features bitmap that have not -# been decoded +# been decoded (bits 0-63) +# +# @unknown-dev-features2: Virtio device features bitmap that have not +# been decoded (bits 64-127) (since 10.2) # # Since: 7.2 ## { 'struct': 'VirtioDeviceFeatures', 'data': { 'transports': [ 'str' ], '*dev-features': [ 'str' ], - '*unknown-dev-features': 'uint64' } } + '*unknown-dev-features': 'uint64', + '*unknown-dev-features2': 'uint64' } } =20 ## # @VirtQueueStatus: diff --git a/hw/virtio/virtio-qmp.h b/hw/virtio/virtio-qmp.h index 245a446a56..e0a1e49035 100644 --- a/hw/virtio/virtio-qmp.h +++ b/hw/virtio/virtio-qmp.h @@ -18,6 +18,7 @@ VirtIODevice *qmp_find_virtio_device(const char *path); VirtioDeviceStatus *qmp_decode_status(uint8_t bitmap); VhostDeviceProtocols *qmp_decode_protocols(uint64_t bitmap); -VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, uint64_t bit= map); +VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, + const uint64_t *bitmap); =20 #endif diff --git a/hw/virtio/virtio-hmp-cmds.c b/hw/virtio/virtio-hmp-cmds.c index 7d8677bcf0..1daae482d3 100644 --- a/hw/virtio/virtio-hmp-cmds.c +++ b/hw/virtio/virtio-hmp-cmds.c @@ -74,7 +74,8 @@ static void hmp_virtio_dump_features(Monitor *mon, } =20 if (features->has_unknown_dev_features) { - monitor_printf(mon, " unknown-features(0x%016"PRIx64")\n", + monitor_printf(mon, " unknown-features(0x%016"PRIx64"%016"PRIx64"= )\n", + features->unknown_dev_features2, features->unknown_dev_features); } } diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c index 3b6377cf0d..b338344c6c 100644 --- a/hw/virtio/virtio-qmp.c +++ b/hw/virtio/virtio-qmp.c @@ -325,6 +325,20 @@ static const qmp_virtio_feature_map_t virtio_net_featu= re_map[] =3D { FEATURE_ENTRY(VHOST_USER_F_PROTOCOL_FEATURES, \ "VHOST_USER_F_PROTOCOL_FEATURES: Vhost-user protocol features " "negotiation supported"), + FEATURE_ENTRY(VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO, \ + "VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO: Driver can receive GSO ove= r " + "UDP tunnel packets"), + FEATURE_ENTRY(VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM, \ + "VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO: Driver can receive GSO ove= r " + "UDP tunnel packets requiring checksum offload for the outer " + "header"), + FEATURE_ENTRY(VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO, \ + "VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO: Device can receive GSO over= " + "UDP tunnel packets"), + FEATURE_ENTRY(VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM, \ + "VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM: Device can receive GSO= over " + "UDP tunnel packets requiring checksum offload for the outer " + "header"), { -1, "" } }; #endif @@ -510,6 +524,24 @@ static const qmp_virtio_feature_map_t virtio_gpio_feat= ure_map[] =3D { list; \ }) =20 +#define CONVERT_FEATURES_EX(type, map, bitmap) \ + ({ \ + type *list =3D NULL; \ + type *node; \ + for (i =3D 0; map[i].virtio_bit !=3D -1; i++) { \ + bit =3D map[i].virtio_bit; \ + if (!virtio_has_feature_ex(bitmap, bit)) { \ + continue; \ + } \ + node =3D g_new0(type, 1); \ + node->value =3D g_strdup(map[i].feature_desc); \ + node->next =3D list; \ + list =3D node; \ + virtio_clear_feature_ex(bitmap, bit); \ + } \ + list; \ + }) + VirtioDeviceStatus *qmp_decode_status(uint8_t bitmap) { VirtioDeviceStatus *status; @@ -545,109 +577,112 @@ VhostDeviceProtocols *qmp_decode_protocols(uint64_t= bitmap) return vhu_protocols; } =20 -VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, uint64_t bit= map) +VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, + const uint64_t *bmap) { + uint64_t bitmap[VIRTIO_FEATURES_NU64S]; VirtioDeviceFeatures *features; uint64_t bit; int i; =20 + virtio_features_copy(bitmap, bmap); features =3D g_new0(VirtioDeviceFeatures, 1); features->has_dev_features =3D true; =20 /* transport features */ - features->transports =3D CONVERT_FEATURES(strList, virtio_transport_ma= p, 0, - bitmap); + features->transports =3D CONVERT_FEATURES_EX(strList, virtio_transport= _map, + bitmap); =20 /* device features */ switch (device_id) { #ifdef CONFIG_VIRTIO_SERIAL case VIRTIO_ID_CONSOLE: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_serial_feature_map, 0, bitmap= ); + CONVERT_FEATURES_EX(strList, virtio_serial_feature_map, bitmap= ); break; #endif #ifdef CONFIG_VIRTIO_BLK case VIRTIO_ID_BLOCK: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_blk_feature_map, 0, bitmap); + CONVERT_FEATURES_EX(strList, virtio_blk_feature_map, bitmap); break; #endif #ifdef CONFIG_VIRTIO_GPU case VIRTIO_ID_GPU: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_gpu_feature_map, 0, bitmap); + CONVERT_FEATURES_EX(strList, virtio_gpu_feature_map, bitmap); break; #endif #ifdef CONFIG_VIRTIO_NET case VIRTIO_ID_NET: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_net_feature_map, 0, bitmap); + CONVERT_FEATURES_EX(strList, virtio_net_feature_map, bitmap); break; #endif #ifdef CONFIG_VIRTIO_SCSI case VIRTIO_ID_SCSI: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_scsi_feature_map, 0, bitmap); + CONVERT_FEATURES_EX(strList, virtio_scsi_feature_map, bitmap); break; #endif #ifdef CONFIG_VIRTIO_BALLOON case VIRTIO_ID_BALLOON: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_balloon_feature_map, 0, bitma= p); + CONVERT_FEATURES_EX(strList, virtio_balloon_feature_map, bitma= p); break; #endif #ifdef CONFIG_VIRTIO_IOMMU case VIRTIO_ID_IOMMU: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_iommu_feature_map, 0, bitmap); + CONVERT_FEATURES_EX(strList, virtio_iommu_feature_map, bitmap); break; #endif #ifdef CONFIG_VIRTIO_INPUT case VIRTIO_ID_INPUT: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_input_feature_map, 0, bitmap); + CONVERT_FEATURES_EX(strList, virtio_input_feature_map, bitmap); break; #endif #ifdef CONFIG_VHOST_USER_FS case VIRTIO_ID_FS: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_fs_feature_map, 0, bitmap); + CONVERT_FEATURES_EX(strList, virtio_fs_feature_map, bitmap); break; #endif #ifdef CONFIG_VHOST_VSOCK case VIRTIO_ID_VSOCK: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_vsock_feature_map, 0, bitmap); + CONVERT_FEATURES_EX(strList, virtio_vsock_feature_map, bitmap); break; #endif #ifdef CONFIG_VIRTIO_CRYPTO case VIRTIO_ID_CRYPTO: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_crypto_feature_map, 0, bitmap= ); + CONVERT_FEATURES_EX(strList, virtio_crypto_feature_map, bitmap= ); break; #endif #ifdef CONFIG_VIRTIO_MEM case VIRTIO_ID_MEM: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_mem_feature_map, 0, bitmap); + CONVERT_FEATURES_EX(strList, virtio_mem_feature_map, bitmap); break; #endif #ifdef CONFIG_VIRTIO_I2C_ADAPTER case VIRTIO_ID_I2C_ADAPTER: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_i2c_feature_map, 0, bitmap); + CONVERT_FEATURES_EX(strList, virtio_i2c_feature_map, bitmap); break; #endif #ifdef CONFIG_VIRTIO_RNG case VIRTIO_ID_RNG: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_rng_feature_map, 0, bitmap); + CONVERT_FEATURES_EX(strList, virtio_rng_feature_map, bitmap); break; #endif #ifdef CONFIG_VHOST_USER_GPIO case VIRTIO_ID_GPIO: features->dev_features =3D - CONVERT_FEATURES(strList, virtio_gpio_feature_map, 0, bitmap); + CONVERT_FEATURES_EX(strList, virtio_gpio_feature_map, bitmap); break; #endif /* No features */ @@ -680,10 +715,9 @@ VirtioDeviceFeatures *qmp_decode_features(uint16_t dev= ice_id, uint64_t bitmap) g_assert_not_reached(); } =20 - features->has_unknown_dev_features =3D bitmap !=3D 0; - if (features->has_unknown_dev_features) { - features->unknown_dev_features =3D bitmap; - } + features->has_unknown_dev_features =3D !virtio_features_empty(bitmap); + features->unknown_dev_features =3D bitmap[0]; + features->unknown_dev_features2 =3D bitmap[1]; =20 return features; } @@ -743,11 +777,11 @@ VirtioStatus *qmp_x_query_virtio_status(const char *p= ath, Error **errp) status->device_id =3D vdev->device_id; status->vhost_started =3D vdev->vhost_started; status->guest_features =3D qmp_decode_features(vdev->device_id, - vdev->guest_features); + vdev->guest_features_ex); status->host_features =3D qmp_decode_features(vdev->device_id, - vdev->host_features); + vdev->host_features_ex); status->backend_features =3D qmp_decode_features(vdev->device_id, - vdev->backend_features); + vdev->backend_features_ex= ); =20 switch (vdev->device_endian) { case VIRTIO_DEVICE_ENDIAN_LITTLE: @@ -785,11 +819,12 @@ VirtioStatus *qmp_x_query_virtio_status(const char *p= ath, Error **errp) status->vhost_dev->nvqs =3D hdev->nvqs; status->vhost_dev->vq_index =3D hdev->vq_index; status->vhost_dev->features =3D - qmp_decode_features(vdev->device_id, hdev->features); + qmp_decode_features(vdev->device_id, hdev->features_ex); status->vhost_dev->acked_features =3D - qmp_decode_features(vdev->device_id, hdev->acked_features); + qmp_decode_features(vdev->device_id, hdev->acked_features_ex); status->vhost_dev->backend_features =3D - qmp_decode_features(vdev->device_id, hdev->backend_features); + qmp_decode_features(vdev->device_id, hdev->backend_features_ex= ); + status->vhost_dev->protocol_features =3D qmp_decode_protocols(hdev->protocol_features); status->vhost_dev->max_queues =3D hdev->max_queues; --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691926; cv=none; d=zohomail.com; s=zohoarc; b=iShuJfWL1DBA7fUvXNL+y4srYvHcvg9Qh2FTNz/UEQ70uIdYi2VLQp6dCTLYuVJ+/NPhv9ZVA0wQACOg+9HZxp4qxKRv6fKcAg4XUkchqVvQYsPLhC0QqffbhoR3PdBX3iX3pSHitgD1bIjrbQSi4Vqx9kh8S76vNcExdZVHA/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691926; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=T9JiUJVF1IY5GSi12FGsN+bySZ+KyddxbfjDd0ABMyI=; b=fmaYANAuvouX9vQ6VxDBDQ3wGx2/+xUUn0GKWB68A+8LdSslHH1O+GXD+YHkxwj5fvA3wnizxiMH2vPUphwPNo/xmMzvd9aZCc2VA/1RteJOIntzcSsI0b/1ZdJQ1lW6FW6UQzL4nm71Y+2+X5jqmCGKtT4SADQDElTcMBOaW6M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691926584913.804096534571; Sun, 5 Oct 2025 12:18:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDl-0007TN-OA; Sun, 05 Oct 2025 15:16:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDh-0007SO-OG for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDf-0006Mx-1j for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:33 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-fycBWVaFO4C5nqDsVRS78g-1; Sun, 05 Oct 2025 15:16:27 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-46e31191379so26930945e9.3 for ; Sun, 05 Oct 2025 12:16:27 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e619c3b75sm217407595e9.7.2025.10.05.12.16.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691788; 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=T9JiUJVF1IY5GSi12FGsN+bySZ+KyddxbfjDd0ABMyI=; b=Ojw7RRMQt8lI8OakStICf/yteUqlaiTXLJfZ4RO3djQSjDoXZEWKk+XftpgaxMYsY5Y0dC HjtxsOZHmxNjc6kG28GuT49F4vYeuTGSnuZoAkcJNUsw8Y2u45CTXU65FYXqDrw5kNuTi7 YUPd7CKizQdsP1boJN5ACm0yFDgLn64= X-MC-Unique: fycBWVaFO4C5nqDsVRS78g-1 X-Mimecast-MFC-AGG-ID: fycBWVaFO4C5nqDsVRS78g_1759691786 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691786; x=1760296586; 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=T9JiUJVF1IY5GSi12FGsN+bySZ+KyddxbfjDd0ABMyI=; b=ezd1fCYsouAkuHdUKTlYV91FXIRG6pF1EEoiwagMMTCen4CFBfkQhefmZmK9Jtw4eN mELGpy3BJSQ/cWJL+IpgiFiEgDtVmgyagxZhYrPWUbzw0RB1fv+Cx9zECb7bX/AO0pma 1FOko2k6rcysBLU89Y3c082ehFQmRLAxObFjJYK7G7eg1qg3esZa4gWprBMIv4M6jC+U 1no699mCl2/Kgc4csL+GImk2wI8uyBQHoeotZteqfu2Cg6OEoZspbskwxQL5nqL+4d1+ t917V1Lj2gFdpFc52W6NxPraJHlg4I8GgRJvWBeW8nr1TlmNF086LUOMV7RigSSRrfQd 9ZmA== X-Gm-Message-State: AOJu0YySHS/nLmeQhgjZ63EN4EiySE2wBGwsyy+jjBh7mHjh4fxJQV3w J6PzlAYTl1qYQCva4/TvLT0wXyjI1OBDOx6TTpOXAv7sMJcuL8+q+eLzgjMlA/AbYNs/8erjnTi czSzkyGQQxU7YuYVakCOwXg7d/KEGNyA+c0/fPSDazJhww7fGwjqQv5nI0Ty6OEDP7HjPFZUJ7r cOYUXDv9WyG4M2eNpwcCNJEJGfRfOuXbzRuw== X-Gm-Gg: ASbGncsx38TbSUAN8ym88if8to6kTDe4YW1YQBPO1eM7QkphRoQjF09B95SCG3vh+yw PCuzJJP4vTBoLOUy3aeCO6it+VVa6tq443MdY6pZ4WmHwPu1J1oh0ygYxqTVoPyUbiW4sLtNntY AMDbtaY9POXfzk5FjOZ6ncZC2wJGf81LzBv+MxE2OdGCIpwJMvPizRDWaJtOs5lprq21nam85hj MQY5DXlaF6Y7+hsjwWamL3D6AfV8HTNYCSQwmgwOF59UB6/7nseUPhRO1Tlj0zhWYQfL8S3rM3s GSNkme8DsNOpWlbC0fKD77y3jsURtvB7vI+cKIQ= X-Received: by 2002:a05:600c:350b:b0:459:e398:ed89 with SMTP id 5b1f17b1804b1-46e710fe3a0mr61011225e9.1.1759691785971; Sun, 05 Oct 2025 12:16:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYqrY5rQ+cewOwkdChC4gU0ClZemwx0HVQHJ0DU8aamsFmWPjG1tYZ2vir4AiUGsKrg09UbQ== X-Received: by 2002:a05:600c:350b:b0:459:e398:ed89 with SMTP id 5b1f17b1804b1-46e710fe3a0mr61011065e9.1.1759691785502; Sun, 05 Oct 2025 12:16:25 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:23 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Abeni , Akihiko Odaki , Jason Wang , Stefano Garzarella , Lei Yang Subject: [PULL 10/75] vhost-backend: implement extended features support Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691927387116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni Leverage the kernel extended features manipulation ioctls(), if available, and fallback to old ops otherwise. Error out when setting extended features but kernel support is not available. Note that extended support for get/set backend features is not needed, as the only feature that can be changed belongs to the 64 bit range. Reviewed-by: Akihiko Odaki Acked-by: Jason Wang Acked-by: Stefano Garzarella Signed-off-by: Paolo Abeni Tested-by: Lei Yang Reviewed-by: Michael S. Tsirkin Message-ID: <150daade3d59e77629276920e014ee8e5fc12121.1758549625.git.pabeni= @redhat.com> Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-backend.c | 62 ++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 11 deletions(-) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 833804dd40..4367db0d95 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -20,6 +20,11 @@ #include #include =20 +struct vhost_features { + uint64_t count; + uint64_t features[VIRTIO_FEATURES_NU64S]; +}; + static int vhost_kernel_call(struct vhost_dev *dev, unsigned long int requ= est, void *arg) { @@ -182,12 +187,6 @@ static int vhost_kernel_get_vring_worker(struct vhost_= dev *dev, return vhost_kernel_call(dev, VHOST_GET_VRING_WORKER, worker); } =20 -static int vhost_kernel_set_features(struct vhost_dev *dev, - uint64_t features) -{ - return vhost_kernel_call(dev, VHOST_SET_FEATURES, &features); -} - static int vhost_kernel_set_backend_cap(struct vhost_dev *dev) { uint64_t features; @@ -210,10 +209,51 @@ static int vhost_kernel_set_backend_cap(struct vhost_= dev *dev) return 0; } =20 -static int vhost_kernel_get_features(struct vhost_dev *dev, - uint64_t *features) +static int vhost_kernel_set_features(struct vhost_dev *dev, + const uint64_t *features) { - return vhost_kernel_call(dev, VHOST_GET_FEATURES, features); + struct vhost_features farray; + bool extended_in_use; + int r; + + farray.count =3D VIRTIO_FEATURES_NU64S; + virtio_features_copy(farray.features, features); + extended_in_use =3D virtio_features_use_ex(farray.features); + + /* + * Can't check for ENOTTY: for unknown ioctls the kernel interprets + * the argument as a virtio queue id and most likely errors out valida= ting + * such id, instead of reporting an unknown operation. + */ + r =3D vhost_kernel_call(dev, VHOST_SET_FEATURES_ARRAY, &farray); + if (!r) { + return 0; + } + + if (extended_in_use) { + error_report("Trying to set extended features without kernel suppo= rt"); + return -EINVAL; + } + return vhost_kernel_call(dev, VHOST_SET_FEATURES, &farray.features[0]); +} + +static int vhost_kernel_get_features(struct vhost_dev *dev, uint64_t *feat= ures) +{ + struct vhost_features farray; + int r; + + farray.count =3D VIRTIO_FEATURES_NU64S; + r =3D vhost_kernel_call(dev, VHOST_GET_FEATURES_ARRAY, &farray); + if (r) { + memset(&farray, 0, sizeof(farray)); + r =3D vhost_kernel_call(dev, VHOST_GET_FEATURES, &farray.features[= 0]); + } + if (r) { + return r; + } + + virtio_features_copy(features, farray.features); + return 0; } =20 static int vhost_kernel_set_owner(struct vhost_dev *dev) @@ -341,8 +381,8 @@ const VhostOps kernel_ops =3D { .vhost_attach_vring_worker =3D vhost_kernel_attach_vring_worker, .vhost_new_worker =3D vhost_kernel_new_worker, .vhost_free_worker =3D vhost_kernel_free_worker, - .vhost_set_features =3D vhost_kernel_set_features, - .vhost_get_features =3D vhost_kernel_get_features, + .vhost_set_features_ex =3D vhost_kernel_set_features, + .vhost_get_features_ex =3D vhost_kernel_get_features, .vhost_set_backend_cap =3D vhost_kernel_set_backend_cap, .vhost_set_owner =3D vhost_kernel_set_owner, .vhost_get_vq_index =3D vhost_kernel_get_vq_index, --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691989; cv=none; d=zohomail.com; s=zohoarc; b=jRqlLN04v/LwR5oCBVJWYWSPt5+eRJ5Jlzrg8K1RckqswH2jfQFPj9Uq83S3kkWafAvlZ9Gjep4J/p9HD0LlyB7ypjWUxdGz2s0I1nROQF8iAsVfhzu08MZrte9t6XYaxWadhsNVSWGwClSPnEH6SDo94rK1yi+uOVGR4c8a6CM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691989; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aOYwDQG7HKglv+vhXRjMfO1BIIi6ZI2WVuVvxD+8eTc=; b=CUQ+RiVjBpmeggnHgFi5Eb2hchepGz16AwC9ZK71AQn0wjUbYdV+YGNkBj4I9e1yvzszes55dmOk31ASFMjWitD7ZSF5H/F4WIH6fDZ7fv5+ewKWkgAoI+dhggOvMYmiu14cWhCV6b+wiN+2l/+t2HuKo2ZPCSBPZdyEGev4YVA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691989102510.75647202896835; Sun, 5 Oct 2025 12:19:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDm-0007U0-ER; Sun, 05 Oct 2025 15:16: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 1v5UDi-0007Sk-Uh for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDf-0006NC-UC for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:34 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-vwZSlVtcPu-xpep50_NXRg-1; Sun, 05 Oct 2025 15:16:29 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e3dcb36a1so24948715e9.2 for ; Sun, 05 Oct 2025 12:16:29 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f4bdcsm17534137f8f.54.2025.10.05.12.16.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691791; 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=aOYwDQG7HKglv+vhXRjMfO1BIIi6ZI2WVuVvxD+8eTc=; b=et/zI0tSJxLvOGoHB6v1K8/1q9xX4rdnqKvIoIhPdDaItwSuJXD8aIT/fLUI9ZHNym8Fkl 6ZwQrN+xTVBj2S+TWlodwlz4B0/qWM8EpbVJpRvfaCBQlxBAVMXO3j4ShBa97i3ImTHPxk 2GY5E0S/sIL+i2dmkLvUAlLkZoFZMS8= X-MC-Unique: vwZSlVtcPu-xpep50_NXRg-1 X-Mimecast-MFC-AGG-ID: vwZSlVtcPu-xpep50_NXRg_1759691788 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691788; x=1760296588; 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=aOYwDQG7HKglv+vhXRjMfO1BIIi6ZI2WVuVvxD+8eTc=; b=BObmu/Ox8XUmduYL3OkjERTqD5MHUvZIXKP5D2OPuTHOkN5dgCjL/PKMTIyTSRyapB RU01YsDRytH+yz301y0p/AyDBgrI0LIB4vP58CLUYRg5F5N/tiK/li2g0YX6nfgn/dxB pGLIKPBqYsAQIQabqVqvNkferymHeoYuZOzz30eGAGydY7+t6pZeS682FZf4Al9d5uVP Pmca0mCHSlEMnzckonRMFKbcQbCmxcTYkoevPPhegMWhkCIcJKnbRLttMat9WMhcDqQ6 fkf0Ug3w5ivRubluawC64hLNI2Y5nKPYchyck6Oo90lJY3LiDGXvZZd0dqXqHKgeXSww b31w== X-Gm-Message-State: AOJu0YyeK378qjFn97jUq6rcgSoowgyRtw6Txjf4GRrmsKYf7Ss7M8nc QNTaMXrRsJ1yxvKUUco8SM3hRyBQjCbPJHxbl1A/LRf2Xj/JBulUP0KF9gefEjJaNgbbGfprbMB Gzp8zXOL89iCre2ZddkTno4RwEbzsC53fdRIh2+pXY6LVnWZqM3+iYV6j+kb1oBoMX6EpTWMeFg p4xr03vVRhryEm2Q2M45Bf7klygsrEsctHQQ== X-Gm-Gg: ASbGncsytRlC6Ctnmt6qr5Ob7Q6kf3Bp7dxzb02KR8x7ZS6fq0cbgPuHL/xcF8+0eRv 7Ukc1uGMtlWHv6abv6+Zw9s20jP6UBm+4r5o7jGRJlVbOySgrzSUgeY13seHz4VLNdqXjxGD52b XUnDxu0oqOaE36kad1uMTgis09D5cENp+Hl2qXUCXBPH/yZ083FAm2n4WHYNLLS/YMgGeHz4u0j 41WGatzhqi6lF/aC8PTFBBUPEwdAxW0mycYme1KRKDxeQH7q4wZqKkphlRF7X4NUnqSskYUhUGZ ORORNG68I8MPuYlpc1ftqisKMxw8OpKbSqtkhis= X-Received: by 2002:a05:6000:616:b0:3fe:efa8:7f1d with SMTP id ffacd0b85a97d-42567137428mr5510432f8f.7.1759691788011; Sun, 05 Oct 2025 12:16:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHb+eHdLYkl7KmOdHavVhcGdeWtlpJiwkjIb0MIBqsoJ3t7i7a7zT7rzHDACsIqtxnmfEqXcg== X-Received: by 2002:a05:6000:616:b0:3fe:efa8:7f1d with SMTP id ffacd0b85a97d-42567137428mr5510416f8f.7.1759691787461; Sun, 05 Oct 2025 12:16:27 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:25 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Abeni , Akihiko Odaki , Jason Wang , Lei Yang , Stefano Garzarella Subject: [PULL 11/75] vhost-net: implement extended features support Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692013889116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni Provide extended version of the features manipulation helpers, and let the device initialization deal with the full features space, adjusting the relevant format strings accordingly. Reviewed-by: Akihiko Odaki Acked-by: Jason Wang Signed-off-by: Paolo Abeni Tested-by: Lei Yang Acked-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin Message-ID: <69c78c432e28e146a8874b2a7d00e9cbd111b1ba.1758549625.git.pabeni= @redhat.com> Signed-off-by: Michael S. Tsirkin --- include/net/vhost_net.h | 33 +++++++++++++++++++++++++++--- hw/net/vhost_net-stub.c | 8 +++----- hw/net/vhost_net.c | 45 +++++++++++++++++++++++------------------ 3 files changed, 58 insertions(+), 28 deletions(-) diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index 879781dad7..0225207491 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -2,6 +2,7 @@ #define VHOST_NET_H =20 #include "net/net.h" +#include "hw/virtio/virtio-features.h" #include "hw/virtio/vhost-backend.h" =20 struct vhost_net; @@ -33,8 +34,26 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *n= cs, =20 void vhost_net_cleanup(VHostNetState *net); =20 -uint64_t vhost_net_get_features(VHostNetState *net, uint64_t features); -void vhost_net_ack_features(VHostNetState *net, uint64_t features); +void vhost_net_get_features_ex(VHostNetState *net, uint64_t *features); +static inline uint64_t vhost_net_get_features(VHostNetState *net, + uint64_t features) +{ + uint64_t features_array[VIRTIO_FEATURES_NU64S]; + + virtio_features_from_u64(features_array, features); + vhost_net_get_features_ex(net, features_array); + return features_array[0]; +} + +void vhost_net_ack_features_ex(VHostNetState *net, const uint64_t *feature= s); +static inline void vhost_net_ack_features(VHostNetState *net, + uint64_t features) +{ + uint64_t features_array[VIRTIO_FEATURES_NU64S]; + + virtio_features_from_u64(features_array, features); + vhost_net_ack_features_ex(net, features_array); +} =20 int vhost_net_get_config(struct vhost_net *net, uint8_t *config, uint32_t config_len); @@ -51,7 +70,15 @@ VHostNetState *get_vhost_net(NetClientState *nc); =20 int vhost_net_set_vring_enable(NetClientState *nc, int enable); =20 -uint64_t vhost_net_get_acked_features(VHostNetState *net); +void vhost_net_get_acked_features_ex(VHostNetState *net, uint64_t *feature= s); +static inline uint64_t vhost_net_get_acked_features(VHostNetState *net) +{ + uint64_t features[VIRTIO_FEATURES_NU64S]; + + vhost_net_get_acked_features_ex(net, features); + assert(!virtio_features_use_ex(features)); + return features[0]; +} =20 int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu); =20 diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c index 7d49f82906..0740d5a2eb 100644 --- a/hw/net/vhost_net-stub.c +++ b/hw/net/vhost_net-stub.c @@ -46,9 +46,8 @@ void vhost_net_cleanup(struct vhost_net *net) { } =20 -uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) +void vhost_net_get_features_ex(struct vhost_net *net, uint64_t *features) { - return features; } =20 int vhost_net_get_config(struct vhost_net *net, uint8_t *config, @@ -62,13 +61,12 @@ int vhost_net_set_config(struct vhost_net *net, const u= int8_t *data, return 0; } =20 -void vhost_net_ack_features(struct vhost_net *net, uint64_t features) +void vhost_net_ack_features_ex(struct vhost_net *net, const uint64_t *feat= ures) { } =20 -uint64_t vhost_net_get_acked_features(VHostNetState *net) +void vhost_net_get_acked_features_ex(VHostNetState *net, uint64_t *feature= s) { - return 0; } =20 bool vhost_net_virtqueue_pending(VHostNetState *net, int idx) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 540492b37d..a8ee18a912 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -35,10 +35,9 @@ #include "hw/virtio/virtio-bus.h" #include "linux-headers/linux/vhost.h" =20 -uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) +void vhost_net_get_features_ex(struct vhost_net *net, uint64_t *features) { - return vhost_get_features(&net->dev, net->feature_bits, - features); + vhost_get_features_ex(&net->dev, net->feature_bits, features); } int vhost_net_get_config(struct vhost_net *net, uint8_t *config, uint32_t config_len) @@ -51,10 +50,11 @@ int vhost_net_set_config(struct vhost_net *net, const u= int8_t *data, return vhost_dev_set_config(&net->dev, data, offset, size, flags); } =20 -void vhost_net_ack_features(struct vhost_net *net, uint64_t features) +void vhost_net_ack_features_ex(struct vhost_net *net, const uint64_t *feat= ures) { - net->dev.acked_features =3D net->dev.backend_features; - vhost_ack_features(&net->dev, net->feature_bits, features); + virtio_features_copy(net->dev.acked_features_ex, + net->dev.backend_features_ex); + vhost_ack_features_ex(&net->dev, net->feature_bits, features); } =20 uint64_t vhost_net_get_max_queues(VHostNetState *net) @@ -62,9 +62,9 @@ uint64_t vhost_net_get_max_queues(VHostNetState *net) return net->dev.max_queues; } =20 -uint64_t vhost_net_get_acked_features(VHostNetState *net) +void vhost_net_get_acked_features_ex(VHostNetState *net, uint64_t *feature= s) { - return net->dev.acked_features; + virtio_features_copy(features, net->dev.acked_features_ex); } =20 void vhost_net_save_acked_features(NetClientState *nc) @@ -234,7 +234,8 @@ struct vhost_net *vhost_net_init(VhostNetOptions *optio= ns) int r; bool backend_kernel =3D options->backend_type =3D=3D VHOST_BACKEND_TYP= E_KERNEL; struct vhost_net *net =3D g_new0(struct vhost_net, 1); - uint64_t features =3D 0; + uint64_t missing_features[VIRTIO_FEATURES_NU64S]; + uint64_t features[VIRTIO_FEATURES_NU64S]; Error *local_err =3D NULL; =20 if (!options->net_backend) { @@ -247,6 +248,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *optio= ns) net->save_acked_features =3D options->save_acked_features; net->max_tx_queue_size =3D options->max_tx_queue_size; net->is_vhost_user =3D options->is_vhost_user; + virtio_features_clear(features); =20 net->dev.max_queues =3D 1; net->dev.vqs =3D net->vqs; @@ -261,7 +263,7 @@ struct vhost_net *vhost_net_init(VhostNetOptions *optio= ns) net->backend =3D r; net->dev.protocol_features =3D 0; } else { - net->dev.backend_features =3D 0; + virtio_features_clear(net->dev.backend_features_ex); net->dev.protocol_features =3D 0; net->backend =3D -1; =20 @@ -281,26 +283,29 @@ struct vhost_net *vhost_net_init(VhostNetOptions *opt= ions) sizeof(struct virtio_net_hdr_mrg_rxbuf))) { net->dev.features &=3D ~(1ULL << VIRTIO_NET_F_MRG_RXBUF); } - if (~net->dev.features & net->dev.backend_features) { - fprintf(stderr, "vhost lacks feature mask 0x%" PRIx64 - " for backend\n", - (uint64_t)(~net->dev.features & net->dev.backend_featur= es)); + + if (virtio_features_andnot(missing_features, + net->dev.backend_features_ex, + net->dev.features_ex)) { + fprintf(stderr, "vhost lacks feature mask 0x" VIRTIO_FEATURES_= FMT + " for backend\n", VIRTIO_FEATURES_PR(missing_features)); goto fail; } } =20 /* Set sane init value. Override when guest acks. */ if (options->get_acked_features) { - features =3D options->get_acked_features(net->nc); - if (~net->dev.features & features) { - fprintf(stderr, "vhost lacks feature mask 0x%" PRIx64 - " for backend\n", - (uint64_t)(~net->dev.features & features)); + virtio_features_from_u64(features, + options->get_acked_features(net->nc)); + if (virtio_features_andnot(missing_features, features, + net->dev.features_ex)) { + fprintf(stderr, "vhost lacks feature mask 0x" VIRTIO_FEATURES_= FMT + " for backend\n", VIRTIO_FEATURES_PR(missing_features)= ); goto fail; } } =20 - vhost_net_ack_features(net, features); + vhost_net_ack_features_ex(net, features); =20 return net; =20 --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691893; cv=none; d=zohomail.com; s=zohoarc; b=HiTh/Rub0XAql/Ihg7KdHTLKt6h+99+FHbmlI82U38wD+PjAxqCm0mzAzlDmonhWgm9oHKt/q/JRW5MpUL4vVQ01rVpbTFRuedv7i1VV3sfvxvpv2qANbSL8ISs6teWhKUob5wo01BxTR4ccCKlG+MUh+T02g1CLTr2UeoLJCjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691893; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bor2WhW2cNfFK9zamYg8ijHD2QP5w9JCub0cS59gaDM=; b=A6olmYYxLly/aRUNYcRxsi3gZoNfPzGu63YdOTuPEhzG1DiiHof6RvGlh+LsHETzaNb2c4NIa5HI9ck/k3C+IJgM9so8C8BkNJ8UgDdbNfUEyKhs8NU5cO0InXAiVCINqpDRqoxWjWw1HFhJeMYdnHiCpKTgefXXXC6rUatxuNA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691893809357.14067498985537; Sun, 5 Oct 2025 12:18:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDn-0007UK-S6; Sun, 05 Oct 2025 15:16:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDk-0007T2-59 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDi-0006NJ-1y for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:35 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-609-Wg6EeoHeM4SrgHYKga0LLw-1; Sun, 05 Oct 2025 15:16:32 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e46486972so11980365e9.0 for ; Sun, 05 Oct 2025 12:16:31 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e7236267bsm134160155e9.16.2025.10.05.12.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691793; 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=bor2WhW2cNfFK9zamYg8ijHD2QP5w9JCub0cS59gaDM=; b=CMV0JYrgfQvWOvYcGPTObC3OUWNmspt4+E7VHF4QJhxS4j+BAkTwC3Ss+lI1q1eMIerEbu R8BBKq/K7W6Yb+KvEh5KWe7NFtBOcg52qJH7FdBVCYxGR5ZyztT6UiG19UKsU4tUoy64Nl UVJVPGA1yz9IwdH+0OAWnayYXcd2Juw= X-MC-Unique: Wg6EeoHeM4SrgHYKga0LLw-1 X-Mimecast-MFC-AGG-ID: Wg6EeoHeM4SrgHYKga0LLw_1759691791 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691790; x=1760296590; 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=bor2WhW2cNfFK9zamYg8ijHD2QP5w9JCub0cS59gaDM=; b=tyiqx+Zwygoz7sUJC3yvaVfPZPi6bhY+7C5aG2Cmp7Y4JcArHaV2r6TUB75cJiPS5V GD5p5FKfphqtZR+LRUe0dw4cP+Ga70AI3NJOLis7mQtupC/0Pbsppqjwov0urVSn9mcc 0tDWimQjAihOeWR2ifguKe8CDfajpfSecwYG2TipkTt3UKbOJ4RIh6jyGpXArS1rArtk gCtJlVvdZVHR/aE7WQ53eWWkMWGWHPfO34WfZ/nhuQPixaJ4nk/B8/Tpka2HL7Kf6p3K NaQYZfC+mXWN5IDdkwZbcQXZg+/ErlSySgsKXwN7XLYx162yaLW/AymRr6+g/tplhRs/ YYLQ== X-Gm-Message-State: AOJu0Yynnc1bq5VE3+KdwJwQqsqUZH06yd2/bxkC7+nUXMoW7kd1TJBa 22cYBGda0st7q8+xsH9NUbQkzxsEXQcEVHC1OMZ9epTi38x9uLSeJjkVsL04Am9pUsX9oKb7og1 6w+kAU41sG0U+gHx4ZYr8937hNm8X6kHL9qqynF0WM1xXXIlVuUJ15VJL9GWGxLT9FLIK/Zng5Y ySmWNCuZEDm7yxB2DlB6mFe61Gdo9zn53hGQ== X-Gm-Gg: ASbGnctOZwvd+VDfPxIvIkF61t2/GusUeaeXscEBMRp7IgpycaOKW6elmaUYs8ZFiJp l/3avIviOKZn6eA9l5EbfQIPunIDeu2x67zkS36ycvLRl5t4Xuq85jf18ujfzZ8TbyMmCdLrb5+ I40S4AvQmODyPdb/qaZcCUOh8wkIMcF3SqapcDwv4C2SgNY6KYiQTidmX2K1VqWVTDCv4hO6d5D 8+ccRT1MIWLqSZuxQsKuesGvR5J0sjuGauRgwTJu3rFJe0FXooH2TC5vDAD9SH7G2/SE0FuxuFk FB2ZyQxgmiok/VxqhpcypUr3CLHkK68cV8nDWQE= X-Received: by 2002:a05:600c:4746:b0:46e:506b:20c9 with SMTP id 5b1f17b1804b1-46e71109f22mr72336665e9.12.1759691790275; Sun, 05 Oct 2025 12:16:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH3s0ZN7BayOIhpfkyuY1dr9uMESvVR/g22PJbgGMSvmQQ6HlEgClWGMCtYAIQxnVyt6a+PAQ== X-Received: by 2002:a05:600c:4746:b0:46e:506b:20c9 with SMTP id 5b1f17b1804b1-46e71109f22mr72336445e9.12.1759691789606; Sun, 05 Oct 2025 12:16:29 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:27 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Abeni , Akihiko Odaki , Jason Wang , Lei Yang , Stefano Garzarella Subject: [PULL 12/75] virtio-net: implement extended features support Message-ID: <3a7741c3bdc3537de4159418d712debbd22e4df6.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691897452116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni Use the extended types and helpers to manipulate the virtio_net features. Note that offloads are still 64bits wide, as per specification, and extended offloads will be mapped into such range. Reviewed-by: Akihiko Odaki Acked-by: Jason Wang Signed-off-by: Paolo Abeni Tested-by: Lei Yang Acked-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio-net.h | 2 +- hw/net/virtio-net.c | 140 +++++++++++++++++++-------------- 2 files changed, 83 insertions(+), 59 deletions(-) diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 73fdefc0dc..5b8ab7bda7 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -182,7 +182,7 @@ struct VirtIONet { uint32_t has_vnet_hdr; size_t host_hdr_len; size_t guest_hdr_len; - uint64_t host_features; + VIRTIO_DECLARE_FEATURES(host_features); uint32_t rsc_timeout; uint8_t rsc4_enabled; uint8_t rsc6_enabled; diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 129bebd82e..39f2a8c987 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -90,6 +90,19 @@ VIRTIO_NET_RSS_HASH_TYPE_TCP_EX |= \ VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) =20 +/* + * Features starting from VIRTIO_NET_FEATURES_MAP_MIN bit correspond + * to guest offloads in the VIRTIO_NET_OFFLOAD_MAP range + */ +#define VIRTIO_NET_OFFLOAD_MAP_MIN 46 +#define VIRTIO_NET_OFFLOAD_MAP_LENGTH 4 +#define VIRTIO_NET_OFFLOAD_MAP MAKE_64BIT_MASK( \ + VIRTIO_NET_OFFLOAD_MAP_MIN, \ + VIRTIO_NET_OFFLOAD_MAP_LENGT= H) +#define VIRTIO_NET_FEATURES_MAP_MIN 65 +#define VIRTIO_NET_F2O_SHIFT (VIRTIO_NET_OFFLOAD_MAP_MIN - \ + VIRTIO_NET_FEATURES_MAP_MIN + 64) + static const VirtIOFeature feature_sizes[] =3D { {.flags =3D 1ULL << VIRTIO_NET_F_MAC, .end =3D endof(struct virtio_net_config, mac)}, @@ -786,7 +799,14 @@ static void virtio_net_apply_guest_offloads(VirtIONet = *n) qemu_set_offload(qemu_get_queue(n->nic)->peer, &ol); } =20 -static uint64_t virtio_net_guest_offloads_by_features(uint64_t features) +static uint64_t virtio_net_features_to_offload(const uint64_t *features) +{ + return (features[0] & ~VIRTIO_NET_OFFLOAD_MAP) | + ((features[1] << VIRTIO_NET_F2O_SHIFT) & VIRTIO_NET_OFFLOAD_MAP= ); +} + +static uint64_t +virtio_net_guest_offloads_by_features(const uint64_t *features) { static const uint64_t guest_offloads_mask =3D (1ULL << VIRTIO_NET_F_GUEST_CSUM) | @@ -797,13 +817,13 @@ static uint64_t virtio_net_guest_offloads_by_features= (uint64_t features) (1ULL << VIRTIO_NET_F_GUEST_USO4) | (1ULL << VIRTIO_NET_F_GUEST_USO6); =20 - return guest_offloads_mask & features; + return guest_offloads_mask & virtio_net_features_to_offload(features); } =20 uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); - return virtio_net_guest_offloads_by_features(vdev->guest_features); + return virtio_net_guest_offloads_by_features(vdev->guest_features_ex); } =20 typedef struct { @@ -882,34 +902,39 @@ static void failover_add_primary(VirtIONet *n, Error = **errp) error_propagate(errp, err); } =20 -static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features) +static void virtio_net_set_features(VirtIODevice *vdev, + const uint64_t *in_features) { + uint64_t features[VIRTIO_FEATURES_NU64S]; VirtIONet *n =3D VIRTIO_NET(vdev); Error *err =3D NULL; int i; =20 + virtio_features_copy(features, in_features); if (n->mtu_bypass_backend && !virtio_has_feature(vdev->backend_features, VIRTIO_NET_F_MTU))= { - features &=3D ~(1ULL << VIRTIO_NET_F_MTU); + virtio_clear_feature_ex(features, VIRTIO_NET_F_MTU); } =20 virtio_net_set_multiqueue(n, - virtio_has_feature(features, VIRTIO_NET_F_RS= S) || - virtio_has_feature(features, VIRTIO_NET_F_MQ= )); + virtio_has_feature_ex(features, + VIRTIO_NET_F_RSS) || + virtio_has_feature_ex(features, + VIRTIO_NET_F_MQ)); =20 virtio_net_set_mrg_rx_bufs(n, - virtio_has_feature(features, + virtio_has_feature_ex(features, VIRTIO_NET_F_MRG_RXBUF), - virtio_has_feature(features, + virtio_has_feature_ex(features, VIRTIO_F_VERSION_1), - virtio_has_feature(features, + virtio_has_feature_ex(features, VIRTIO_NET_F_HASH_REPORT= )); =20 - n->rsc4_enabled =3D virtio_has_feature(features, VIRTIO_NET_F_RSC_EXT)= && - virtio_has_feature(features, VIRTIO_NET_F_GUEST_TSO4); - n->rsc6_enabled =3D virtio_has_feature(features, VIRTIO_NET_F_RSC_EXT)= && - virtio_has_feature(features, VIRTIO_NET_F_GUEST_TSO6); - n->rss_data.redirect =3D virtio_has_feature(features, VIRTIO_NET_F_RSS= ); + n->rsc4_enabled =3D virtio_has_feature_ex(features, VIRTIO_NET_F_RSC_E= XT) && + virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_TSO4); + n->rsc6_enabled =3D virtio_has_feature_ex(features, VIRTIO_NET_F_RSC_E= XT) && + virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_TSO6); + n->rss_data.redirect =3D virtio_has_feature_ex(features, VIRTIO_NET_F_= RSS); =20 if (n->has_vnet_hdr) { n->curr_guest_offloads =3D @@ -923,7 +948,7 @@ static void virtio_net_set_features(VirtIODevice *vdev,= uint64_t features) if (!get_vhost_net(nc->peer)) { continue; } - vhost_net_ack_features(get_vhost_net(nc->peer), features); + vhost_net_ack_features_ex(get_vhost_net(nc->peer), features); =20 /* * keep acked_features in NetVhostUserState up-to-date so it @@ -932,12 +957,14 @@ static void virtio_net_set_features(VirtIODevice *vde= v, uint64_t features) vhost_net_save_acked_features(nc->peer); } =20 - if (virtio_has_feature(vdev->guest_features ^ features, VIRTIO_NET_F_C= TRL_VLAN)) { - bool vlan =3D virtio_has_feature(features, VIRTIO_NET_F_CTRL_VLAN); + if (virtio_has_feature_ex(features, VIRTIO_NET_F_CTRL_VLAN) !=3D + virtio_has_feature_ex(vdev->guest_features_ex, + VIRTIO_NET_F_CTRL_VLAN)) { + bool vlan =3D virtio_has_feature_ex(features, VIRTIO_NET_F_CTRL_VL= AN); memset(n->vlans, vlan ? 0 : 0xff, MAX_VLAN >> 3); } =20 - if (virtio_has_feature(features, VIRTIO_NET_F_STANDBY)) { + if (virtio_has_feature_ex(features, VIRTIO_NET_F_STANDBY)) { qapi_event_send_failover_negotiated(n->netclient_name); qatomic_set(&n->failover_primary_hidden, false); failover_add_primary(n, &err); @@ -1908,10 +1935,10 @@ static ssize_t virtio_net_receive_rcu(NetClientStat= e *nc, const uint8_t *buf, virtio_error(vdev, "virtio-net unexpected empty queue: " "i %zd mergeable %d offset %zd, size %zd, " "guest hdr len %zd, host hdr len %zd " - "guest features 0x%" PRIx64, + "guest features 0x" VIRTIO_FEATURES_FMT, i, n->mergeable_rx_bufs, offset, size, n->guest_hdr_len, n->host_hdr_len, - vdev->guest_features); + VIRTIO_FEATURES_PR(vdev->guest_features_ex)); } err =3D -1; goto err; @@ -3018,8 +3045,8 @@ static int virtio_net_pre_load_queues(VirtIODevice *v= dev, uint32_t n) return 0; } =20 -static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t featu= res, - Error **errp) +static void virtio_net_get_features(VirtIODevice *vdev, uint64_t *features, + Error **errp) { VirtIONet *n =3D VIRTIO_NET(vdev); NetClientState *nc =3D qemu_get_queue(n->nic); @@ -3033,68 +3060,67 @@ static uint64_t virtio_net_get_features(VirtIODevic= e *vdev, uint64_t features, (supported_hash_types & peer_hash_types) =3D=3D supported_hash_typ= es; =20 /* Firstly sync all virtio-net possible supported features */ - features |=3D n->host_features; + virtio_features_or(features, features, n->host_features_ex); =20 - virtio_add_feature(&features, VIRTIO_NET_F_MAC); + virtio_add_feature_ex(features, VIRTIO_NET_F_MAC); =20 if (!peer_has_vnet_hdr(n)) { - virtio_clear_feature(&features, VIRTIO_NET_F_CSUM); - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_TSO4); - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_TSO6); - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_ECN); + virtio_clear_feature_ex(features, VIRTIO_NET_F_CSUM); + virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO4); + virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_TSO6); + virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_ECN); =20 - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_CSUM); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_TSO4); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_TSO6); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ECN); + virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_CSUM); + virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_TSO4); + virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_TSO6); + virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_ECN); =20 - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_USO); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO4); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO6); + virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_USO); + virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4); + virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6); =20 - virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT); + virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT); } =20 if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) { - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_UFO); - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_UFO); + virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UFO); + virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UFO); } - if (!peer_has_uso(n)) { - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_USO); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO4); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO6); + virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_USO); + virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4); + virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6); } =20 if (!get_vhost_net(nc->peer)) { if (!use_own_hash) { - virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT); - virtio_clear_feature(&features, VIRTIO_NET_F_RSS); - } else if (virtio_has_feature(features, VIRTIO_NET_F_RSS)) { + virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT); + virtio_clear_feature_ex(features, VIRTIO_NET_F_RSS); + } else if (virtio_has_feature_ex(features, VIRTIO_NET_F_RSS)) { virtio_net_load_ebpf(n, errp); } =20 - return features; + return; } =20 if (!use_peer_hash) { - virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT); + virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT); =20 if (!use_own_hash || !virtio_net_attach_ebpf_to_backend(n->nic, -1= )) { if (!virtio_net_load_ebpf(n, errp)) { - return features; + return; } =20 - virtio_clear_feature(&features, VIRTIO_NET_F_RSS); + virtio_clear_feature_ex(features, VIRTIO_NET_F_RSS); } } =20 - features =3D vhost_net_get_features(get_vhost_net(nc->peer), features); - vdev->backend_features =3D features; + vhost_net_get_features_ex(get_vhost_net(nc->peer), features); + virtio_features_copy(vdev->backend_features_ex, features); =20 if (n->mtu_bypass_backend && (n->host_features & 1ULL << VIRTIO_NET_F_MTU)) { - features |=3D (1ULL << VIRTIO_NET_F_MTU); + virtio_add_feature_ex(features, VIRTIO_NET_F_MTU); } =20 /* @@ -3109,10 +3135,8 @@ static uint64_t virtio_net_get_features(VirtIODevice= *vdev, uint64_t features, * support it. */ if (!virtio_has_feature(vdev->backend_features, VIRTIO_NET_F_CTRL_VQ))= { - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE); + virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_ANNOUNCE); } - - return features; } =20 static int virtio_net_post_load_device(void *opaque, int version_id) @@ -4244,8 +4268,8 @@ static void virtio_net_class_init(ObjectClass *klass,= const void *data) vdc->unrealize =3D virtio_net_device_unrealize; vdc->get_config =3D virtio_net_get_config; vdc->set_config =3D virtio_net_set_config; - vdc->get_features =3D virtio_net_get_features; - vdc->set_features =3D virtio_net_set_features; + vdc->get_features_ex =3D virtio_net_get_features; + vdc->set_features_ex =3D virtio_net_set_features; vdc->bad_features =3D virtio_net_bad_features; vdc->reset =3D virtio_net_reset; vdc->queue_reset =3D virtio_net_queue_reset; --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692118; cv=none; d=zohomail.com; s=zohoarc; b=YhJHsTHGNG4Voo9Ex83tf6j76610v4pTgCJt6vlvKdORFO7uqzUZUsafxnepQIbndmY17OQ3niUbv8cnYETd42LsjfNJR4ue9u/YjXBf+Z8r/XadMgnP3ICzaTQ66ybrNEO/LvL5FCHi3jcE1Z33duq0PZxnGK0Fdk8Bk8hs9Y0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692118; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GOY0xYbTallZrysMKoXU6E/qUfVtKp8T55T7WJoOLAE=; b=BVjoRDXEzRfOVInZCp5LHl1vc8lsLWx9XMdi1Dy37mRAzlXu7O3axkgBiccXEN1X1Deva1IF6go/KQS+CD33WIz62fWaIlCK3G3MEqpAlLofXtL7CWFnUoGRRjmGyVR6xvyP7jZzPhlAhZ/L/bDYiEOYz+nzXlkrXkWLMa6iu6E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692118793606.4560073265427; Sun, 5 Oct 2025 12:21:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDr-0007Xg-74; Sun, 05 Oct 2025 15:16:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDn-0007UC-5L for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDl-0006Nm-2M for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:38 -0400 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-642-wMsA42EoOKKGU5UgszcCgg-1; Sun, 05 Oct 2025 15:16:34 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-42557bdbe50so2378846f8f.1 for ; Sun, 05 Oct 2025 12:16:34 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e5c4afb3asm124981155e9.6.2025.10.05.12.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691796; 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=GOY0xYbTallZrysMKoXU6E/qUfVtKp8T55T7WJoOLAE=; b=iqWTl6vKHomFOBRidzUKzPCvfR0wMxe485TOyD7rjVVw8OwRU8Y7pfmeGbu9dWcKMFV2DT mPiVOmvtEITMqY8y5smOoTrRYU0xPgALTRqbk48sZiSnTuGAmFE+utzGk9zJgyhrqQMmi/ yIsXQzYVNq36jUbLILDaPS/sB64ljOE= X-MC-Unique: wMsA42EoOKKGU5UgszcCgg-1 X-Mimecast-MFC-AGG-ID: wMsA42EoOKKGU5UgszcCgg_1759691794 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691793; x=1760296593; 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=GOY0xYbTallZrysMKoXU6E/qUfVtKp8T55T7WJoOLAE=; b=udCkJW1J/CoJQMITMfoejgSEONxoDdAjXbnhjSVUpyWIrDmVN6xmRpPpzyC68V2dYg zqGhU58+t8noESEwwe88fUuBkU2BtCTyQti3J1jZgJGtRyzXdF9vMpJr3bYqRB8cMJd1 KFfdCMAyuS7R73H0HGuD0rm3wLWzIkFb8UfGhFIaL8UW9J0vTng+3NHer2IXuSwTrl2I g6WiyB3sNbr6vGhVOI9y8qosAnImiQCm7FusSb2F9Gk+faktS/HQur/3m8hE2T+YlVTI PaF3VPWDlnzoTDoUTnRLsMzvFXl67LymhhxFXyHpzw3qw34DLoNn7jXkMCP8MLaC5g4b MiLw== X-Gm-Message-State: AOJu0YwEgCHCQOnrcpSPEOUcqNGb4FHnbdnnaY9CbGI/TlFQNGt5gSGY 6vY5NwyXpW9MkpHE6M2DLfl5l6uAItjcgc9eq/fs0CMV/brF/mpHoeX1uPcEpyYvAngjIkH7IM6 4wlJ8dhvgJUc7E/tPb3lSqTcX22W39ZJrcw1Tyr3l4TdNtAwElFfccoZmcxRS650H2uvVoNqt8B lD8DAw8f/NNnHssxcyjr88ZumHZ+/UyEwrXg== X-Gm-Gg: ASbGncuo5DliJDCx5gfMk6a2IwS9hWhWP9Km4xgiP8j9yJCcmHOH4Z3dcX7huphiQZX wDKKX0h5jIB8+WFd0hQrwfULJix+oZPgSOOj+aXboSrdoHSmvlrtdqx+DPE/XCfnYTxUXFWULMT 8Ts66nXG9T6AuOCnxWRldYLaOEuLWU0vTTUffjJBRXBzjdz7nQmMsj6rqslfwWFUvKYZmpkmtH9 RYIW86z246QiW/pGLA/q7m78CeovNaMxIP3LXG+3crmPTb39BGMu7CG6wV4g094m9V2Z8+wAtGa zCc2mdwR+L28MoT4twUQhGG5Iz0o8A9iob0JExA= X-Received: by 2002:a05:600c:3404:b0:46e:25f2:705c with SMTP id 5b1f17b1804b1-46e68bffeedmr72023635e9.13.1759691793144; Sun, 05 Oct 2025 12:16:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFkL35SeNRQgm/lDSLzxAEg6n7QUVTB0rsoU/uQZ/9pJQE/AVfHkgz9qPjbgNx3Om+JOOytg== X-Received: by 2002:a05:600c:3404:b0:46e:25f2:705c with SMTP id 5b1f17b1804b1-46e68bffeedmr72023425e9.13.1759691792473; Sun, 05 Oct 2025 12:16:32 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:29 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Abeni , Akihiko Odaki , Jason Wang , Lei Yang , Stefano Garzarella Subject: [PULL 13/75] net: implement tunnel probing 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692120467116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni Tap devices support GSO over UDP tunnel offload. Probe for such feature in a similar manner to other offloads. GSO over UDP tunnel needs to be enabled in addition to a "plain" offload (TSO or USO). No need to check separately for the outer header checksum offload: the kernel is going to support both of them or none. The new features are disabled by default to avoid compat issues, and could be enabled, after that hw_compat_10_1 will be added, together with the related compat entries. Reviewed-by: Akihiko Odaki Acked-by: Jason Wang Signed-off-by: Paolo Abeni Tested-by: Lei Yang Acked-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- include/net/net.h | 3 +++ net/tap-linux.h | 9 +++++++++ net/tap_int.h | 1 + hw/net/virtio-net.c | 41 +++++++++++++++++++++++++++++++++++++++++ net/net.c | 9 +++++++++ net/tap-bsd.c | 5 +++++ net/tap-linux.c | 11 +++++++++++ net/tap-solaris.c | 5 +++++ net/tap-stub.c | 5 +++++ net/tap.c | 11 +++++++++++ 10 files changed, 100 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index 48ba333d02..9a9084690d 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -65,6 +65,7 @@ typedef void (NetClientDestructor)(NetClientState *); typedef RxFilterInfo *(QueryRxFilter)(NetClientState *); typedef bool (HasUfo)(NetClientState *); typedef bool (HasUso)(NetClientState *); +typedef bool (HasTunnel)(NetClientState *); typedef bool (HasVnetHdr)(NetClientState *); typedef bool (HasVnetHdrLen)(NetClientState *, int); typedef void (SetOffload)(NetClientState *, const NetOffloads *); @@ -95,6 +96,7 @@ typedef struct NetClientInfo { NetPoll *poll; HasUfo *has_ufo; HasUso *has_uso; + HasTunnel *has_tunnel; HasVnetHdr *has_vnet_hdr; HasVnetHdrLen *has_vnet_hdr_len; SetOffload *set_offload; @@ -197,6 +199,7 @@ void qemu_set_info_str(NetClientState *nc, void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]); bool qemu_has_ufo(NetClientState *nc); bool qemu_has_uso(NetClientState *nc); +bool qemu_has_tunnel(NetClientState *nc); bool qemu_has_vnet_hdr(NetClientState *nc); bool qemu_has_vnet_hdr_len(NetClientState *nc, int len); void qemu_set_offload(NetClientState *nc, const NetOffloads *ol); diff --git a/net/tap-linux.h b/net/tap-linux.h index 9a58cecb7f..8cd6b5874b 100644 --- a/net/tap-linux.h +++ b/net/tap-linux.h @@ -53,4 +53,13 @@ #define TUN_F_USO4 0x20 /* I can handle USO for IPv4 packets */ #define TUN_F_USO6 0x40 /* I can handle USO for IPv6 packets */ =20 +/* I can handle TSO/USO for UDP tunneled packets */ +#define TUN_F_UDP_TUNNEL_GSO 0x080 + +/* + * I can handle TSO/USO for UDP tunneled packets requiring csum offload for + * the outer header + */ +#define TUN_F_UDP_TUNNEL_GSO_CSUM 0x100 + #endif /* QEMU_TAP_LINUX_H */ diff --git a/net/tap_int.h b/net/tap_int.h index f8bbe1cb0c..b76a05044b 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -38,6 +38,7 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, = Error **errp); int tap_probe_vnet_hdr(int fd, Error **errp); int tap_probe_has_ufo(int fd); int tap_probe_has_uso(int fd); +bool tap_probe_has_tunnel(int fd); void tap_fd_set_offload(int fd, const NetOffloads *ol); void tap_fd_set_vnet_hdr_len(int fd, int len); int tap_fd_set_vnet_le(int fd, int vnet_is_le); diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 39f2a8c987..f8e2b4823e 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -649,6 +649,15 @@ static int peer_has_uso(VirtIONet *n) return qemu_has_uso(qemu_get_queue(n->nic)->peer); } =20 +static bool peer_has_tunnel(VirtIONet *n) +{ + if (!peer_has_vnet_hdr(n)) { + return false; + } + + return qemu_has_tunnel(qemu_get_queue(n->nic)->peer); +} + static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs, int version_1, int hash_report) { @@ -3079,6 +3088,13 @@ static void virtio_net_get_features(VirtIODevice *vd= ev, uint64_t *features, virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO4); virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6); =20 + virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GS= O); + virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO= ); + virtio_clear_feature_ex(features, + VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM); + virtio_clear_feature_ex(features, + VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM); + virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT); } =20 @@ -3092,6 +3108,15 @@ static void virtio_net_get_features(VirtIODevice *vd= ev, uint64_t *features, virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_USO6); } =20 + if (!peer_has_tunnel(n)) { + virtio_clear_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_GS= O); + virtio_clear_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO= ); + virtio_clear_feature_ex(features, + VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM); + virtio_clear_feature_ex(features, + VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM); + } + if (!get_vhost_net(nc->peer)) { if (!use_own_hash) { virtio_clear_feature_ex(features, VIRTIO_NET_F_HASH_REPORT); @@ -4254,6 +4279,22 @@ static const Property virtio_net_properties[] =3D { rss_data.specified_hash_types, VIRTIO_NET_HASH_REPORT_UDPv6_EX - 1, ON_OFF_AUTO_AUTO), + VIRTIO_DEFINE_PROP_FEATURE("host_tunnel", VirtIONet, + host_features_ex, + VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO, + false), + VIRTIO_DEFINE_PROP_FEATURE("host_tunnel_csum", VirtIONet, + host_features_ex, + VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM, + false), + VIRTIO_DEFINE_PROP_FEATURE("guest_tunnel", VirtIONet, + host_features_ex, + VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO, + false), + VIRTIO_DEFINE_PROP_FEATURE("guest_tunnel_csum", VirtIONet, + host_features_ex, + VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM, + false), }; =20 static void virtio_net_class_init(ObjectClass *klass, const void *data) diff --git a/net/net.c b/net/net.c index 63872b6855..9536184a0c 100644 --- a/net/net.c +++ b/net/net.c @@ -522,6 +522,15 @@ bool qemu_has_uso(NetClientState *nc) return nc->info->has_uso(nc); } =20 +bool qemu_has_tunnel(NetClientState *nc) +{ + if (!nc || !nc->info->has_tunnel) { + return false; + } + + return nc->info->has_tunnel(nc); +} + bool qemu_has_vnet_hdr(NetClientState *nc) { if (!nc || !nc->info->has_vnet_hdr) { diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 38eb28cb58..bbf84d1828 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -225,6 +225,11 @@ int tap_probe_has_uso(int fd) return 0; } =20 +bool tap_probe_has_tunnel(int fd) +{ + return false; +} + void tap_fd_set_vnet_hdr_len(int fd, int len) { } diff --git a/net/tap-linux.c b/net/tap-linux.c index 79a9dd0da0..98b0ae9602 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -201,6 +201,17 @@ int tap_probe_has_uso(int fd) return 1; } =20 +bool tap_probe_has_tunnel(int fd) +{ + unsigned offload; + + offload =3D TUN_F_CSUM | TUN_F_TSO4 | TUN_F_UDP_TUNNEL_GSO; + if (ioctl(fd, TUNSETOFFLOAD, offload) < 0) { + return false; + } + return true; +} + void tap_fd_set_vnet_hdr_len(int fd, int len) { if (ioctl(fd, TUNSETVNETHDRSZ, &len) =3D=3D -1) { diff --git a/net/tap-solaris.c b/net/tap-solaris.c index ef8e0feeb0..75397e6c54 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -227,6 +227,11 @@ int tap_probe_has_uso(int fd) return 0; } =20 +bool tap_probe_has_tunnel(int fd) +{ + return false; +} + void tap_fd_set_vnet_hdr_len(int fd, int len) { } diff --git a/net/tap-stub.c b/net/tap-stub.c index 67d14ad4d5..f7a5e0c163 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -52,6 +52,11 @@ int tap_probe_has_uso(int fd) return 0; } =20 +bool tap_probe_has_tunnel(int fd) +{ + return false; +} + void tap_fd_set_vnet_hdr_len(int fd, int len) { } diff --git a/net/tap.c b/net/tap.c index df23283744..5124372316 100644 --- a/net/tap.c +++ b/net/tap.c @@ -76,6 +76,7 @@ typedef struct TAPState { bool using_vnet_hdr; bool has_ufo; bool has_uso; + bool has_tunnel; bool enabled; VHostNetState *vhost_net; unsigned host_vnet_hdr_len; @@ -246,6 +247,14 @@ static bool tap_has_uso(NetClientState *nc) return s->has_uso; } =20 +static bool tap_has_tunnel(NetClientState *nc) +{ + TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); + return s->has_tunnel; +} + static bool tap_has_vnet_hdr(NetClientState *nc) { TAPState *s =3D DO_UPCAST(TAPState, nc, nc); @@ -374,6 +383,7 @@ static NetClientInfo net_tap_info =3D { .cleanup =3D tap_cleanup, .has_ufo =3D tap_has_ufo, .has_uso =3D tap_has_uso, + .has_tunnel =3D tap_has_tunnel, .has_vnet_hdr =3D tap_has_vnet_hdr, .has_vnet_hdr_len =3D tap_has_vnet_hdr_len, .set_offload =3D tap_set_offload, @@ -403,6 +413,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer, s->using_vnet_hdr =3D false; s->has_ufo =3D tap_probe_has_ufo(s->fd); s->has_uso =3D tap_probe_has_uso(s->fd); + s->has_tunnel =3D tap_probe_has_tunnel(s->fd); s->enabled =3D true; tap_set_offload(&s->nc, &ol); /* --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691927; cv=none; d=zohomail.com; s=zohoarc; b=JixNOeNUBBxqWWqGzu+a1Q8U2VB/9kXsQINDjrgL2SoFzhetCRhNIKp0PqZbKLVKnIR/ml+LCAYokibhO+ffAol6hl9qcQSXTyGJ/PeWjfU8zFV4tot31yQthd8W7gnwxNAcBgadum7SSv4hq4xGwkXnAQCK6qkybqHkvBa7XjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691927; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mLQzZp1MYba5uQ3+BNOy0Y3LASIlZed9Jbbmm8x+esA=; b=JrJR+NDIdLy+K6OGYf29gnr4Up5J4+B7YkyvYTgkjuXrEt0hR9Yml0YEUQNpNe87UZTGPTXQNuQWjJQ3wgWuN5j/zZbvC3SBK2fwdWcTMK+wkAsb9hZzd2RsprHC6V3Lj3iOV+EJrftDak7ljPOKhZobAquevmXVvG8Vy0hYD6c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691927159290.5647873191; Sun, 5 Oct 2025 12:18:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDr-0007Xr-CV; Sun, 05 Oct 2025 15:16:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDo-0007V0-TQ for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:40 -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 1v5UDn-0006Ns-2u for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:40 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-669-Lgn41wOaPzS-rfqtrXrIxg-1; Sun, 05 Oct 2025 15:16:37 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3f030846a41so2461039f8f.2 for ; Sun, 05 Oct 2025 12:16:36 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8ac750sm17613636f8f.24.2025.10.05.12.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691798; 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=mLQzZp1MYba5uQ3+BNOy0Y3LASIlZed9Jbbmm8x+esA=; b=eOqdzmU4/eeO2jAj9ArPN1UaRsJDJLWE393ALxTJAD3lPTgSx7hIfnWPu7XMSYv7GgZJK8 ofNyFQp3asoYlO0KFX7EZtgdtvg9sDBYY9V8Ww1wBthAJji0G80sZ3Mkj5Lw84v1GcPASN HMVoQlukipOtUBiSec9VZLtv4C/osK8= X-MC-Unique: Lgn41wOaPzS-rfqtrXrIxg-1 X-Mimecast-MFC-AGG-ID: Lgn41wOaPzS-rfqtrXrIxg_1759691796 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691795; x=1760296595; 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=mLQzZp1MYba5uQ3+BNOy0Y3LASIlZed9Jbbmm8x+esA=; b=R7mwmiAsd82J+rAT8YBYLKX6+KXMYJOFci0gNaB1CkGMZ2i+Lj0MMNZSF4JihspMon mRGCE+OlxB5aHraS48p8XE9Og/ldP0VSwVHaeWgmocY++kGZxrwx/xCs0HuLUCYwIP9F coORV04NLp++ZTbH2YCEniESJPGMC8m/G+B/3hhSuUdUpGBXF1d9ddLQbPgrfn4yj42j rA2y5w0BSx4Hdb4wqD9cYeo5wLeNb6957D79uvMth2vD6i8AH/Cl4UXRibzR8A/WSU8V TavcarB7QNDhS5e2dIZP377JtB6Csdmt47VIeJ0uNJK965bM2GjYOsQCW35TQbO3o230 /tng== X-Gm-Message-State: AOJu0Yx1UJNo2wcBq9YEnaFkTA9INDiJ9Dn9Ua7KNybwz0WOLDQiYUrM FO4Vs3vsTRwcAORL4EGeCvU4ISGVsb8aUaPo1cpxo0l7y4Y92SYxwa2OD3SWCGMx0cavLciuS6L 0OxS095W/8aNJKFxfTAG9a1DLI0zDaeSiWxY6O8WdQXi4W4cN4znAriP8eSmATc6ePomyMrAY6M tHw8X3Jnj1o+WBpcU5JIo9F25Wi39HCj1k9A== X-Gm-Gg: ASbGncvdwyHJQ3qMW6v8izEqgpeBUFpB+iQvVDXwztF9AW1BlNN7XnVTT4I9x1KEve6 7Nl6JGEgIxdU/l9Qehm8azFH+oVQ5ELu0ja/9wp7F2ZKQAa+ejk7U7SqPWsvYnByfoZxG0mYjP6 1d8EKCBRqlSE1OOw4gktCKwUM4D+ROBoRUEN7vu04lIsoVwDMkBphuswv9Y1t6HzN+TIn4H20we Sov1yt4FFmDvW83Y5kfFX7OfQ8e3Fh+T/TU5UFXYGvX7bpEFhz2UOGeUpKCMdUdjCycxnxnJPdX FWRiF/oEZi1Ro3Ik7fX8WCqTnGX1KEO38PLGU9k= X-Received: by 2002:a05:6000:1a85:b0:3e9:2fea:6795 with SMTP id ffacd0b85a97d-425671c7275mr6447379f8f.53.1759691795173; Sun, 05 Oct 2025 12:16:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEVtyKe2kxMlnMl8+oWf9X6bUdY5wNm9TaGCpRznKZ27aQWYmhtLdFFA7ZJIrYNICJcHo9xRw== X-Received: by 2002:a05:6000:1a85:b0:3e9:2fea:6795 with SMTP id ffacd0b85a97d-425671c7275mr6447361f8f.53.1759691794636; Sun, 05 Oct 2025 12:16:34 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Abeni , Akihiko Odaki , Jason Wang , Lei Yang , Stefano Garzarella Subject: [PULL 14/75] net: implement UDP tunnel features offloading 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691945876116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Paolo Abeni When any host or guest GSO over UDP tunnel offload is enabled the virtio net header includes the additional tunnel-related fields, update the size accordingly. Push the GSO over UDP tunnel offloads all the way down to the tap device extending the newly introduced NetFeatures struct, and eventually enable the associated features. As per virtio specification, to convert features bit to offload bit, map the extended features into the reserved range. Finally, make the vhost backend aware of the exact header layout, to copy it correctly. The tunnel-related field are present if either the guest or the host negotiated any UDP tunnel related feature: add them to the kernel supported features list, to allow qemu transfer to the backend the needed information. Reviewed-by: Akihiko Odaki Acked-by: Jason Wang Signed-off-by: Paolo Abeni Tested-by: Lei Yang Acked-by: Stefano Garzarella Reviewed-by: Michael S. Tsirkin Message-ID: <093b4bc68368046bffbcab2202227632d6e4e83b.1758549625.git.pabeni= @redhat.com> Signed-off-by: Michael S. Tsirkin --- include/net/net.h | 2 ++ hw/net/virtio-net.c | 34 ++++++++++++++++++++++++++-------- net/net.c | 3 ++- net/tap-linux.c | 6 ++++++ net/tap.c | 2 ++ 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 9a9084690d..72b476ee1d 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -43,6 +43,8 @@ typedef struct NetOffloads { bool ufo; bool uso4; bool uso6; + bool tnl; + bool tnl_csum; } NetOffloads; =20 #define DEFINE_NIC_PROPERTIES(_state, _conf) \ diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index f8e2b4823e..33116712eb 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -103,6 +103,12 @@ #define VIRTIO_NET_F2O_SHIFT (VIRTIO_NET_OFFLOAD_MAP_MIN - \ VIRTIO_NET_FEATURES_MAP_MIN + 64) =20 +static bool virtio_has_tunnel_hdr(const uint64_t *features) +{ + return virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GS= O) || + virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_G= SO); +} + static const VirtIOFeature feature_sizes[] =3D { {.flags =3D 1ULL << VIRTIO_NET_F_MAC, .end =3D endof(struct virtio_net_config, mac)}, @@ -659,7 +665,8 @@ static bool peer_has_tunnel(VirtIONet *n) } =20 static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs, - int version_1, int hash_report) + int version_1, int hash_report, + int tunnel) { int i; NetClientState *nc; @@ -667,9 +674,11 @@ static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, i= nt mergeable_rx_bufs, n->mergeable_rx_bufs =3D mergeable_rx_bufs; =20 if (version_1) { - n->guest_hdr_len =3D hash_report ? - sizeof(struct virtio_net_hdr_v1_hash) : - sizeof(struct virtio_net_hdr_mrg_rxbuf); + n->guest_hdr_len =3D tunnel ? + sizeof(struct virtio_net_hdr_v1_hash_tunnel) : + (hash_report ? + sizeof(struct virtio_net_hdr_v1_hash) : + sizeof(struct virtio_net_hdr_mrg_rxbuf)); n->rss_data.populate_hash =3D !!hash_report; } else { n->guest_hdr_len =3D n->mergeable_rx_bufs ? @@ -803,6 +812,10 @@ static void virtio_net_apply_guest_offloads(VirtIONet = *n) .ufo =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= FO)), .uso4 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= SO4)), .uso6 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= SO6)), + .tnl =3D !!(n->curr_guest_offloads & + (1ULL << VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_MAPPED)), + .tnl_csum =3D !!(n->curr_guest_offloads & + (1ULL << VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM_MAPP= ED)), }; =20 qemu_set_offload(qemu_get_queue(n->nic)->peer, &ol); @@ -824,7 +837,9 @@ virtio_net_guest_offloads_by_features(const uint64_t *f= eatures) (1ULL << VIRTIO_NET_F_GUEST_ECN) | (1ULL << VIRTIO_NET_F_GUEST_UFO) | (1ULL << VIRTIO_NET_F_GUEST_USO4) | - (1ULL << VIRTIO_NET_F_GUEST_USO6); + (1ULL << VIRTIO_NET_F_GUEST_USO6) | + (1ULL << VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_MAPPED) | + (1ULL << VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM_MAPPED); =20 return guest_offloads_mask & virtio_net_features_to_offload(features); } @@ -937,7 +952,8 @@ static void virtio_net_set_features(VirtIODevice *vdev, virtio_has_feature_ex(features, VIRTIO_F_VERSION_1), virtio_has_feature_ex(features, - VIRTIO_NET_F_HASH_REPORT= )); + VIRTIO_NET_F_HASH_REPORT= ), + virtio_has_tunnel_hdr(features)); =20 n->rsc4_enabled =3D virtio_has_feature_ex(features, VIRTIO_NET_F_RSC_E= XT) && virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_TSO4); @@ -3169,13 +3185,15 @@ static int virtio_net_post_load_device(void *opaque= , int version_id) VirtIONet *n =3D opaque; VirtIODevice *vdev =3D VIRTIO_DEVICE(n); int i, link_down; + bool has_tunnel_hdr =3D virtio_has_tunnel_hdr(vdev->guest_features_ex); =20 trace_virtio_net_post_load_device(); virtio_net_set_mrg_rx_bufs(n, n->mergeable_rx_bufs, virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1), virtio_vdev_has_feature(vdev, - VIRTIO_NET_F_HASH_R= EPORT)); + VIRTIO_NET_F_HASH_RE= PORT), + has_tunnel_hdr); =20 /* MAC_TABLE_ENTRIES may be different from the saved image */ if (n->mac_table.in_use > MAC_TABLE_ENTRIES) { @@ -3995,7 +4013,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) =20 n->vqs[0].tx_waiting =3D 0; n->tx_burst =3D n->net_conf.txburst; - virtio_net_set_mrg_rx_bufs(n, 0, 0, 0); + virtio_net_set_mrg_rx_bufs(n, 0, 0, 0, 0); n->promisc =3D 1; /* for compatibility */ =20 n->mac_table.macs =3D g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN); diff --git a/net/net.c b/net/net.c index 9536184a0c..27e0d27807 100644 --- a/net/net.c +++ b/net/net.c @@ -575,7 +575,8 @@ void qemu_set_vnet_hdr_len(NetClientState *nc, int len) =20 assert(len =3D=3D sizeof(struct virtio_net_hdr_mrg_rxbuf) || len =3D=3D sizeof(struct virtio_net_hdr) || - len =3D=3D sizeof(struct virtio_net_hdr_v1_hash)); + len =3D=3D sizeof(struct virtio_net_hdr_v1_hash) || + len =3D=3D sizeof(struct virtio_net_hdr_v1_hash_tunnel)); =20 nc->vnet_hdr_len =3D len; nc->info->set_vnet_hdr_len(nc, len); diff --git a/net/tap-linux.c b/net/tap-linux.c index 98b0ae9602..2a90b58467 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -284,6 +284,12 @@ void tap_fd_set_offload(int fd, const NetOffloads *ol) if (ol->uso6) { offload |=3D TUN_F_USO6; } + if (ol->tnl) { + offload |=3D TUN_F_UDP_TUNNEL_GSO; + } + if (ol->tnl_csum) { + offload |=3D TUN_F_UDP_TUNNEL_GSO_CSUM; + } } =20 if (ioctl(fd, TUNSETOFFLOAD, offload) !=3D 0) { diff --git a/net/tap.c b/net/tap.c index 5124372316..abe3b2d036 100644 --- a/net/tap.c +++ b/net/tap.c @@ -62,6 +62,8 @@ static const int kernel_feature_bits[] =3D { VIRTIO_F_NOTIFICATION_DATA, VIRTIO_NET_F_RSC_EXT, VIRTIO_NET_F_HASH_REPORT, + VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO, + VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO, VHOST_INVALID_FEATURE_BIT }; =20 --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692208; cv=none; d=zohomail.com; s=zohoarc; b=Z+kjweS07CP7NqpF/LYi84pxISyQx02shy5tobCYu9OpGffA7OXYw3zFFqRPQXLpkOr1y1UHhJcoNsLnBBzf5QRa4NZ/GbGKvCXdzv+otSTbekG3QX44+briB0VJXgtV7DM1hBSuRl54+sj1HIb40lfjxpOPhyw3JryTogte0cQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692208; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8c+cSIxub9P5Uar4OsTTBSJ3SPcqHsJGWNUFLj9euLM=; b=UME75ksNyC6fUI6z1DhDe6Afr2rZI0HWh519DQ41zaBpwr/cX39EFLEyA7fWBGvpYodkXqIKDXx1RMT41naYbxushOJX/vIbLLqPgNr3NvUaEa2QIgTAJ3c6q/lBpB/qRZPChr2UeE+H/yK7AQ/PeBh5KZ/EE95lde2FMsg4TRA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17596922083201.9876686688791096; Sun, 5 Oct 2025 12:23:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDs-0007YQ-8w; Sun, 05 Oct 2025 15:16:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDr-0007Xp-7L for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDo-0006OB-MH for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:42 -0400 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-279-m3I_9-utMLC7swfetAlJSA-1; Sun, 05 Oct 2025 15:16:39 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4256fae4b46so848616f8f.0 for ; Sun, 05 Oct 2025 12:16:38 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f0853sm17783203f8f.50.2025.10.05.12.16.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691800; 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=8c+cSIxub9P5Uar4OsTTBSJ3SPcqHsJGWNUFLj9euLM=; b=iagq0f9UTGOd9UwyWIUYNrx822q4yErdjSSQriZEQcjSIWqtJ5YNNDjfMxd5E3J6MNZgw4 XxO3fTjxwwwTuxKlcWgagWUoj7rrgRAIpvA6WGfhwzcn7jcKcLxh5APWrryc8aQCcnPZCq 1aYOgYygvoFZny81XNrJs927Zp5LnTU= X-MC-Unique: m3I_9-utMLC7swfetAlJSA-1 X-Mimecast-MFC-AGG-ID: m3I_9-utMLC7swfetAlJSA_1759691798 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691797; x=1760296597; 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=8c+cSIxub9P5Uar4OsTTBSJ3SPcqHsJGWNUFLj9euLM=; b=rphf8JBOMuljDb5wt/AAMnbQt7A62+oo0d6FHgdBMT5xg0fDMLpxIDFP7U4iF7vy99 9YtYxIr4Z48eLANmKKOq4CHBXSUeO4teoywoDRVqqgn/bnenDYOrfsIuUgtz+01i74LF IQv6viR6abLhZth9LfgaLol5tiEjYOm7C1gyjZ3FYNuBIZxLQi/klFxDNyoP1q0rgA0i iV71MvBsHpWvTlQTkvK1XfgbXDUusAn1D8VqroP8i6QQ/eyv3nS1b91wG6P5UbwaKwCn Q59lgwJpjdMPMxuLFDfNUhX4STcjrA+jlu2Q65aGWDJnPskOoAWXJO5aOtzk1Ck+R4Lk VhMg== X-Gm-Message-State: AOJu0YxM2sdjSmWRd1IZ+lTDL5oHfh3veQTXS11yBs7yqezxC+6l9+An 1weCvyjOdopK9EBbXecpwCSGMBdpZRCaS6tWLzuzV3xgaGECA2GZH/Abz+nmZKbvaPgJWQokNoL +xRxAOGujtuQ3gtg/ueZ2+cV7I9043Mje9h/+Zyq4Gz2epli1a1qUodDWys84G4QWaDfIGTVCjj v6SA4yCtcnZOr9igWzeGRlLgKFKLhu1y3vnA== X-Gm-Gg: ASbGncvUPIE5+OTxDyPt0RHgPRgS0mlXiVlgCAHlBhXh0dRr6JRBWnEa8n3Eku9JIev WoE+ZLDyNOF1ulauIUkZdIbsQoDbBwkrx5ruYjkISva9q4CeHSV910f2PXw0L1SRQGv4TrvxUc4 82R4kfYgBWeW53vItcRvdJ2/SiSurIpRF1gaDJFziRXmcmcwuaJsgBo9Sw3zM9w/OHYmWRvZRWJ 92SrsFw04wZUUnF4xvrNswnLhVpEQJwmY7roonc9xPcG4pB9FNDKn5Lgo4ArPH3i8mmJAz08cs6 PWeKgHA+kqy2GjaiZulb/BeX7H4LJV2pEn/dj5U= X-Received: by 2002:a05:6000:1a8d:b0:3ee:114f:f88f with SMTP id ffacd0b85a97d-425671c6404mr6429885f8f.59.1759691797386; Sun, 05 Oct 2025 12:16:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFkfvWjfHyD8oTcCkxBo4Dk8sacRcJpSTcBF87BvWoKuxfp3ts2iezeGvq0vevPmbERbC5nFQ== X-Received: by 2002:a05:6000:1a8d:b0:3ee:114f:f88f with SMTP id ffacd0b85a97d-425671c6404mr6429860f8f.59.1759691796789; Sun, 05 Oct 2025 12:16:36 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Igor Mammedov , Ani Sinha , Dongjiu Geng , qemu-arm@nongnu.org Subject: [PULL 15/75] Revert "hw/acpi/ghes: Make ghes_record_cper_errors() static" Message-ID: <6d65290d83919267a7775bd4877d923a505aae9a.1759691708.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692224799116600 From: Mauro Carvalho Chehab The ghes_record_cper_errors() function was introduced to be used by other types of errors, as part of the error injection patch series. That's why it is not static. Make it non-static again to allow its usage outside ghes.c This reverts commit 611f3bdb20f7828b0813aa90d47d1275ef18329b. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Message-ID: <14f2a888cfbf922d5f2bf94d7612114f25107d59.1758610789.git.mcheha= b+huawei@kernel.org> Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/ghes.h | 2 ++ hw/acpi/ghes.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 578a582203..39619a2457 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -75,6 +75,8 @@ void acpi_build_hest(GArray *table_data, GArray *hardware= _errors, void acpi_ghes_add_fw_cfg(AcpiGhesState *vms, FWCfgState *s, GArray *hardware_errors); int acpi_ghes_memory_errors(uint16_t source_id, uint64_t error_physical_ad= dr); +void ghes_record_cper_errors(const void *cper, size_t len, + uint16_t source_id, Error **errp); =20 /** * acpi_ghes_present: Report whether ACPI GHES table is present diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index b85bb48195..b709c177cd 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -390,8 +390,8 @@ static void get_hw_error_offsets(uint64_t ghes_addr, *read_ack_register_addr =3D ghes_addr + sizeof(uint64_t); } =20 -static void ghes_record_cper_errors(const void *cper, size_t len, - uint16_t source_id, Error **errp) +void ghes_record_cper_errors(const void *cper, size_t len, + uint16_t source_id, Error **errp) { uint64_t cper_addr =3D 0, read_ack_register_addr =3D 0, read_ack_regis= ter; AcpiGedState *acpi_ged_state; @@ -440,6 +440,8 @@ static void ghes_record_cper_errors(const void *cper, s= ize_t len, =20 /* Write the generic error data entry into guest memory */ cpu_physical_memory_write(cper_addr, cper, len); + + return; } =20 int acpi_ghes_memory_errors(uint16_t source_id, uint64_t physical_address) --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692161; cv=none; d=zohomail.com; s=zohoarc; b=M2lfgM5XF4w/+AWTVVS3ZaEZyxusUlfXIJ6DrMgFhv+m7uc7xDVNtjVYSXhtVZdlUsJgkHLHyGsTbFT7WwbqzFG3+zWPU09KFunO9Qh/5iX8h17xGT/hj8RMOrbWnBSaUlQaWCmes8ayHcoCQkNFCn9Vu/rUz2k/ILKcf8Ioifs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692161; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=G3bx+7LM3Llba1e5OHMznPMG9tdv+rmdE+oLgoJki90=; b=I+wVxth8pq/wPGEYIhVohM6HTmOVKyPlrYkA53a2H9u8Z01XV1YE8EgosnA4j1Q3/ekB49hr2RBeSUYIsSqUZpDHv/tF9gyrTLlb5PkgEgiltdGps5rkGLVEA0XGwo3Yr/45wdQmwgxVlvYQMldSUzyTpqHYVZW7/CrigxkKyj8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692161908569.1269584002443; Sun, 5 Oct 2025 12:22:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDw-0007cW-JL; Sun, 05 Oct 2025 15:16:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDt-0007Zh-GV for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDr-0006P4-DH for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:44 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-343-te7Wj2WzM8-5oubIoZENBA-1; Sun, 05 Oct 2025 15:16:41 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-42557bdbe50so2378861f8f.1 for ; Sun, 05 Oct 2025 12:16:41 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46f9c8873f1sm22226505e9.8.2025.10.05.12.16.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691802; 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=G3bx+7LM3Llba1e5OHMznPMG9tdv+rmdE+oLgoJki90=; b=d4nVmTXA5SIkipd6Nnrkk7vz0Cmu94ymV3XuMo2MJF8LuC0cjCY7nEYs7tAg53khbBOfDV jdfzCewDF1aHKhmE04l9233TfA1j28bjLcI/J1mJj5ZOBtmpTOy3GVnopa2w9ap/JJg9DX vEfSkkvGhxi6Euck2KCB0zAbxG6hJiE= X-MC-Unique: te7Wj2WzM8-5oubIoZENBA-1 X-Mimecast-MFC-AGG-ID: te7Wj2WzM8-5oubIoZENBA_1759691800 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691800; x=1760296600; 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=G3bx+7LM3Llba1e5OHMznPMG9tdv+rmdE+oLgoJki90=; b=RpJkjUA+7BZFhZaAk52yQMg1su24sOv8V0vqwUS0MuQ23hKGqvZ5LxtTQBd7tXhsHc 6HYZSILlJxAknqHGaSRlK5vJsdleHBD3SjrqAB2TI2/E/D2qi61nk8PcVyDP7hpblaNd qfpOy6USl+jYGzaSjz3M9OPBwu1piwBrltBnvUcjSPki3BWp+paHLv5u1ciRbzYbKx7Y aslYMrcZJQlu13QuJasY1bPgpA8QInslziDHT26eBN024c96Utn9yG8sPgIKtaBUyPVp dAP9HkDTOp/77Wi1lSAgtI6JOaYfMqWITbwaG5WxaQSDGV9Yknd591pywwa/GekEqUQE jr8Q== X-Gm-Message-State: AOJu0YwavB5hJvuVZ/xIRco+TJ1enrvat2CQuh/uV4jyZ8lEWEvo3GkF +aLiGt0y7TE09ZUAocFer7nFquJpIPncWUZxmpjXtxZdexNbqO5aC4SruyBWSQ4jCIKlByETqP7 sHs8nL5UDITVHUuTfGkK0/KvonwY78YW9juNubQSLxTeKkmnMHdQ4vm4zhccUvAQrWnXJf517cs xTn7p+gcM3pib30zWv9gvwM9CTWERpJszc2A== X-Gm-Gg: ASbGnctkbEockRWVIK/J4ZrxiSqT7bab9T+icy7qNleVRSZpCjE4TIL6synkfDn+Iyt Awa6eUTLogEFKklcgcnOFkQY6q8Kf8faUeqc6a/yhcQgAVKeS55hPg6ULnn1e5Wwm0KO2xUcvMe 7MAZZZ3ecVh877X927EQH+1ohHqcTdhQQf6bd5g8yqsEyv+L7PHCjDWfg4iX6fCcrXoAYmhokI6 H0ZVAeLALd2+eBZsBNAh5quQB7AKX0mCVjSg9uU/VFBlrmqTsKjyf/wP+jos95mXqEv2GCGUGcZ mbg35+ImaW/T5FT0HqeLIrsiIU9cQf6XBsjHH9c= X-Received: by 2002:a05:600c:6b70:b0:46e:33ed:bca4 with SMTP id 5b1f17b1804b1-46e68c0753amr67499645e9.15.1759691799718; Sun, 05 Oct 2025 12:16:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEuGB3l3pIDXSGVrRuUrUnctbOBh/MSrjC9rDycwWkkElXPcoaV30umY+0jkaNBvq5iVZK9zA== X-Received: by 2002:a05:600c:6b70:b0:46e:33ed:bca4 with SMTP id 5b1f17b1804b1-46e68c0753amr67499405e9.15.1759691799158; Sun, 05 Oct 2025 12:16:39 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:37 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Igor Mammedov , Ani Sinha , Dongjiu Geng , Paolo Bonzini , qemu-arm@nongnu.org, kvm@vger.kernel.org Subject: [PULL 16/75] acpi/ghes: Cleanup the code which gets ghes ged state Message-ID: <1547c5a5ff894eac9d3666ded3cbf80ce82a28e4.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692170070116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab Move the check logic into a common function and simplify the code which checks if GHES is enabled and was properly setup. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-ID: <2bbb1d3eb88b0a668114adef2f1c2a94deebba0e.1758610789.git.mcheha= b+huawei@kernel.org> Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/ghes.h | 14 +++++++------- hw/acpi/ghes-stub.c | 7 ++++--- hw/acpi/ghes.c | 38 +++++++++++--------------------------- target/arm/kvm.c | 7 +++++-- 4 files changed, 27 insertions(+), 39 deletions(-) diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 39619a2457..f96ac3e85c 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -66,7 +66,6 @@ enum { =20 typedef struct AcpiGhesState { uint64_t hw_error_le; - bool present; /* True if GHES is present at all on this board */ } AcpiGhesState; =20 void acpi_build_hest(GArray *table_data, GArray *hardware_errors, @@ -74,15 +73,16 @@ void acpi_build_hest(GArray *table_data, GArray *hardwa= re_errors, const char *oem_id, const char *oem_table_id); void acpi_ghes_add_fw_cfg(AcpiGhesState *vms, FWCfgState *s, GArray *hardware_errors); -int acpi_ghes_memory_errors(uint16_t source_id, uint64_t error_physical_ad= dr); -void ghes_record_cper_errors(const void *cper, size_t len, +int acpi_ghes_memory_errors(AcpiGhesState *ags, uint16_t source_id, + uint64_t error_physical_addr); +void ghes_record_cper_errors(AcpiGhesState *ags, const void *cper, size_t = len, uint16_t source_id, Error **errp); =20 /** - * acpi_ghes_present: Report whether ACPI GHES table is present + * acpi_ghes_get_state: Get a pointer for ACPI ghes state * - * Returns: true if the system has an ACPI GHES table and it is - * safe to call acpi_ghes_memory_errors() to record a memory error. + * Returns: a pointer to ghes state if the system has an ACPI GHES table, + * NULL, otherwise. */ -bool acpi_ghes_present(void); +AcpiGhesState *acpi_ghes_get_state(void); #endif diff --git a/hw/acpi/ghes-stub.c b/hw/acpi/ghes-stub.c index 7cec1812da..40f660c246 100644 --- a/hw/acpi/ghes-stub.c +++ b/hw/acpi/ghes-stub.c @@ -11,12 +11,13 @@ #include "qemu/osdep.h" #include "hw/acpi/ghes.h" =20 -int acpi_ghes_memory_errors(uint16_t source_id, uint64_t physical_address) +int acpi_ghes_memory_errors(AcpiGhesState *ags, uint16_t source_id, + uint64_t physical_address) { return -1; } =20 -bool acpi_ghes_present(void) +AcpiGhesState *acpi_ghes_get_state(void) { - return false; + return NULL; } diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index b709c177cd..84b891fd3d 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -360,18 +360,12 @@ void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgSt= ate *s, /* Create a read-write fw_cfg file for Address */ fw_cfg_add_file_callback(s, ACPI_HW_ERROR_ADDR_FW_CFG_FILE, NULL, NULL, NULL, &(ags->hw_error_le), sizeof(ags->hw_error_le), false); - - ags->present =3D true; } =20 static void get_hw_error_offsets(uint64_t ghes_addr, uint64_t *cper_addr, uint64_t *read_ack_register_addr) { - if (!ghes_addr) { - return; - } - /* * non-HEST version supports only one source, so no need to change * the start offset based on the source ID. Also, we can't validate @@ -390,35 +384,20 @@ static void get_hw_error_offsets(uint64_t ghes_addr, *read_ack_register_addr =3D ghes_addr + sizeof(uint64_t); } =20 -void ghes_record_cper_errors(const void *cper, size_t len, +void ghes_record_cper_errors(AcpiGhesState *ags, const void *cper, size_t = len, uint16_t source_id, Error **errp) { uint64_t cper_addr =3D 0, read_ack_register_addr =3D 0, read_ack_regis= ter; - AcpiGedState *acpi_ged_state; - AcpiGhesState *ags; =20 if (len > ACPI_GHES_MAX_RAW_DATA_LENGTH) { error_setg(errp, "GHES CPER record is too big: %zd", len); return; } =20 - acpi_ged_state =3D ACPI_GED(object_resolve_path_type("", TYPE_ACPI_GED, - NULL)); - if (!acpi_ged_state) { - error_setg(errp, "Can't find ACPI_GED object"); - return; - } - ags =3D &acpi_ged_state->ghes_state; - assert(ACPI_GHES_ERROR_SOURCE_COUNT =3D=3D 1); get_hw_error_offsets(le64_to_cpu(ags->hw_error_le), &cper_addr, &read_ack_register_addr); =20 - if (!cper_addr) { - error_setg(errp, "can not find Generic Error Status Block"); - return; - } - cpu_physical_memory_read(read_ack_register_addr, &read_ack_register, sizeof(read_ack_register)= ); =20 @@ -444,7 +423,8 @@ void ghes_record_cper_errors(const void *cper, size_t l= en, return; } =20 -int acpi_ghes_memory_errors(uint16_t source_id, uint64_t physical_address) +int acpi_ghes_memory_errors(AcpiGhesState *ags, uint16_t source_id, + uint64_t physical_address) { /* Memory Error Section Type */ const uint8_t guid[] =3D @@ -470,7 +450,7 @@ int acpi_ghes_memory_errors(uint16_t source_id, uint64_= t physical_address) acpi_ghes_build_append_mem_cper(block, physical_address); =20 /* Report the error */ - ghes_record_cper_errors(block->data, block->len, source_id, &errp); + ghes_record_cper_errors(ags, block->data, block->len, source_id, &errp= ); =20 g_array_free(block, true); =20 @@ -482,7 +462,7 @@ int acpi_ghes_memory_errors(uint16_t source_id, uint64_= t physical_address) return 0; } =20 -bool acpi_ghes_present(void) +AcpiGhesState *acpi_ghes_get_state(void) { AcpiGedState *acpi_ged_state; AcpiGhesState *ags; @@ -491,8 +471,12 @@ bool acpi_ghes_present(void) NULL)); =20 if (!acpi_ged_state) { - return false; + return NULL; } ags =3D &acpi_ged_state->ghes_state; - return ags->present; + + if (!ags->hw_error_le) { + return NULL; + } + return ags; } diff --git a/target/arm/kvm.c b/target/arm/kvm.c index b8a1c071f5..891d4fcde9 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -2433,10 +2433,12 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code,= void *addr) { ram_addr_t ram_addr; hwaddr paddr; + AcpiGhesState *ags; =20 assert(code =3D=3D BUS_MCEERR_AR || code =3D=3D BUS_MCEERR_AO); =20 - if (acpi_ghes_present() && addr) { + ags =3D acpi_ghes_get_state(); + if (ags && addr) { ram_addr =3D qemu_ram_addr_from_host(addr); if (ram_addr !=3D RAM_ADDR_INVALID && kvm_physical_memory_addr_from_host(c->kvm_state, addr, &paddr)= ) { @@ -2454,7 +2456,8 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, v= oid *addr) */ if (code =3D=3D BUS_MCEERR_AR) { kvm_cpu_synchronize_state(c); - if (!acpi_ghes_memory_errors(ACPI_HEST_SRC_ID_SEA, paddr))= { + if (!acpi_ghes_memory_errors(ags, ACPI_HEST_SRC_ID_SEA, + paddr)) { kvm_inject_arm_sea(c); } else { error_report("failed to record the error"); --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692153; cv=none; d=zohomail.com; s=zohoarc; b=KYA05uMHke51zn4CaEojpvIALLRXCaMv6g9bt5t82gLfW2oZYGqfgGNJ5qO/mYR0Vlj1qXVk7fe3Ckd/8VyYWcjkipAatnew/rpUzrxFK48Biy7bLLUwVRi0B/dEUolCcDuhmrUQCIk/KDqsJ+dbvIN3XoNTRyFhfxRgz3yjhmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692153; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AZLZ+M4Z2xFSAdN3unBr09StgBtq20YTeJFuMTz8nds=; b=J5ovNSEQvzplVwveqZB5jwwbFoCt/mqAbavpPhOYDT0W1QavvOtmmxxU1tYsfxzq8QO5OE+NEdoNE5kFEbJ2BPWesbx8tcW7UTb6I5WNQ6R2maOY7njhCHGnVBkhyKOnguDWfoH1Gnam9d2qvovXqzAujcgX7MeO73LIEMQUsmc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692153292289.3669843605975; Sun, 5 Oct 2025 12:22:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDw-0007ci-PU; Sun, 05 Oct 2025 15:16:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDv-0007ay-1w for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDt-0006Pj-9D for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:46 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-DL38IiY6Phue5rXAKiHh1A-1; Sun, 05 Oct 2025 15:16:43 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3f4fbdf144dso2262787f8f.2 for ; Sun, 05 Oct 2025 12:16:43 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8ab960sm17424352f8f.13.2025.10.05.12.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691804; 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=AZLZ+M4Z2xFSAdN3unBr09StgBtq20YTeJFuMTz8nds=; b=LTKEuzg7LD/f9PyHjy+BsVvnxkw2ViyjxPb/YUiah6WMOwpwQ+TmVcKHJGYDtAUi8SOPUl XkBMoE4tRL6Ur0t4xXPtbMYzKb01YeYUiQ3TYpvMP3QN/q9QZ4AnfA5nRNuyg/Ef3kRTZr TtQ6Cu82833kw65OmXLPfUbCYoG7A7Q= X-MC-Unique: DL38IiY6Phue5rXAKiHh1A-1 X-Mimecast-MFC-AGG-ID: DL38IiY6Phue5rXAKiHh1A_1759691802 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691802; x=1760296602; 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=AZLZ+M4Z2xFSAdN3unBr09StgBtq20YTeJFuMTz8nds=; b=KvPSo9Qdznse8Jy75gUzP1Ab81L4+YdxPWr97thZU5GdeX5PTouecIgsp9gi74QlLv WvVmhEyggt5o5xc4kbS5tjbA8VeRIdSUI3/ohpspj6zrrhil0o48Af5lUQg/N5wIsen3 6fmKJelz7kOZ2l4x0M52O52TZbtetreX160xCpEurnwc/Cer522pErM7N1mQGj/SMoS3 x0tQQZGUV5TKDkf7qFSGMeUndTLfU2LlPEvYIx2UwQ++RSc64eJuGfyynYuGbnGjWFyU SfAapGG2JUOsBxzeVEhu2Jf41rAFqWusItVdXyehgXJeBd2j8VsBrR/rLlovX6aD9JE4 9S+Q== X-Gm-Message-State: AOJu0Yxd8OzPMaRRp7iBaV9kqKeY8CNsowEnu9nVOAoQp/+YWa81NqAO nYaIdKAjc4NgWFsF3dc9QF7TJtII24QHVfK1c+5mx1rrMVtNdZfvlBkiPMnkQ50zPoGrC5hGloC WN7ZLtcEGfCLo7cphw808J4lOatq44+xsCRNiD5nDkg7mtXALlJPT9JAJJ2xH2fVVA8/LHNYySI sGrXGizUiPs3RrhU4G+YGYmDuHjpYIDyrn8A== X-Gm-Gg: ASbGncsJQjsSvKyFZFQ48yF8i0nl1E8JZYFe6dnA5BrkjQ4PYtXRfPxn6Vrn6QN2NYK 83sCsBdUwnk8Q1Px/ii+YxayaswzHhsObxlnNyxCR/XhyDGN8ixBfq+/XIwB/n488MmMiY8mZSa lMqNgoTJh0jgEDZfGTyNpvrCurfbQo7kdnM3EQnmraK2K6XGRnQUmLDMBdieCZGRkFaEoAf2a9K HbSaw/AX8zA3Ig9CIAIS9HIEABHlh/Z/kOdkoxiKmSU9I3bYR1xE034PF8zZEc7krYNMxuOmJhA 4hrpmV5Sw/Hq+8MRMFUo1b7RiIrpCi5tz7Hgf7w= X-Received: by 2002:a05:6000:43cc:20b0:425:7c32:d969 with SMTP id ffacd0b85a97d-4257c32d992mr829339f8f.5.1759691801962; Sun, 05 Oct 2025 12:16:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFP7tfgvID6SOJgZXvKkqaQKcHp8TAH3rrVIqIv+O3sexk1yHIzj9ICdRWYNoiwkIJ62fOP+A== X-Received: by 2002:a05:6000:43cc:20b0:425:7c32:d969 with SMTP id ffacd0b85a97d-4257c32d992mr829318f8f.5.1759691801312; Sun, 05 Oct 2025 12:16:41 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Igor Mammedov , Dongjiu Geng , Ani Sinha , Shannon Zhao , qemu-arm@nongnu.org Subject: [PULL 17/75] acpi/ghes: prepare to change the way HEST offsets are calculated Message-ID: <2e9c5c5bc85a4f79a5e5c9d52df6c62bd1b2e116.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692154859116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab Add a new ags flag to change the way HEST offsets are calculated. Currently, offsets needed to store ACPI HEST offsets and read ack are calculated based on a previous knowledge from the logic which creates the HEST table. Such logic is not generic, not allowing to easily add more HEST entries nor replicates what OSPM does. As the next patches will be adding a more generic logic, add a new use_hest_addr, set to false, in preparation for such changes. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/ghes.h | 12 +++++++++++- hw/acpi/ghes.c | 39 ++++++++++++++++++++++++--------------- hw/arm/virt-acpi-build.c | 13 ++++++++++--- 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index f96ac3e85c..411f592662 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -64,11 +64,21 @@ enum { ACPI_GHES_ERROR_SOURCE_COUNT }; =20 +/* + * AcpiGhesState stores GPA values that will be used to fill HEST entries. + * + * When use_hest_addr is false, the GPA of the etc/hardware_errors firmware + * is stored at hw_error_le. This is the default on QEMU 9.x. + * + * An GPA value equal to zero means that GHES is not present. + */ typedef struct AcpiGhesState { uint64_t hw_error_le; + bool use_hest_addr; /* Currently, always false */ } AcpiGhesState; =20 -void acpi_build_hest(GArray *table_data, GArray *hardware_errors, +void acpi_build_hest(AcpiGhesState *ags, GArray *table_data, + GArray *hardware_errors, BIOSLinker *linker, const char *oem_id, const char *oem_table_id); void acpi_ghes_add_fw_cfg(AcpiGhesState *vms, FWCfgState *s, diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index 84b891fd3d..9243b5ad4a 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -206,7 +206,8 @@ ghes_gen_err_data_uncorrectable_recoverable(GArray *blo= ck, * Initialize "etc/hardware_errors" and "etc/hardware_errors_addr" fw_cfg = blobs. * See docs/specs/acpi_hest_ghes.rst for blobs format. */ -static void build_ghes_error_table(GArray *hardware_errors, BIOSLinker *li= nker) +static void build_ghes_error_table(AcpiGhesState *ags, GArray *hardware_er= rors, + BIOSLinker *linker) { int i, error_status_block_offset; =20 @@ -251,13 +252,15 @@ static void build_ghes_error_table(GArray *hardware_e= rrors, BIOSLinker *linker) i * ACPI_GHES_MAX_RAW_DATA_LENGTH); } =20 - /* - * tell firmware to write hardware_errors GPA into - * hardware_errors_addr fw_cfg, once the former has been initialized. - */ - bios_linker_loader_write_pointer(linker, ACPI_HW_ERROR_ADDR_FW_CFG_FIL= E, 0, - sizeof(uint64_t), - ACPI_HW_ERROR_FW_CFG_FILE, 0); + if (!ags->use_hest_addr) { + /* + * Tell firmware to write hardware_errors GPA into + * hardware_errors_addr fw_cfg, once the former has been initializ= ed. + */ + bios_linker_loader_write_pointer(linker, ACPI_HW_ERROR_ADDR_FW_CFG= _FILE, + 0, sizeof(uint64_t), + ACPI_HW_ERROR_FW_CFG_FILE, 0); + } } =20 /* Build Generic Hardware Error Source version 2 (GHESv2) */ @@ -331,14 +334,15 @@ static void build_ghes_v2(GArray *table_data, } =20 /* Build Hardware Error Source Table */ -void acpi_build_hest(GArray *table_data, GArray *hardware_errors, +void acpi_build_hest(AcpiGhesState *ags, GArray *table_data, + GArray *hardware_errors, BIOSLinker *linker, const char *oem_id, const char *oem_table_id) { AcpiTable table =3D { .sig =3D "HEST", .rev =3D 1, .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; =20 - build_ghes_error_table(hardware_errors, linker); + build_ghes_error_table(ags, hardware_errors, linker); =20 acpi_table_begin(&table, table_data); =20 @@ -357,9 +361,11 @@ void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgSta= te *s, fw_cfg_add_file(s, ACPI_HW_ERROR_FW_CFG_FILE, hardware_error->data, hardware_error->len); =20 - /* Create a read-write fw_cfg file for Address */ - fw_cfg_add_file_callback(s, ACPI_HW_ERROR_ADDR_FW_CFG_FILE, NULL, NULL, - NULL, &(ags->hw_error_le), sizeof(ags->hw_error_le), false); + if (!ags->use_hest_addr) { + /* Create a read-write fw_cfg file for Address */ + fw_cfg_add_file_callback(s, ACPI_HW_ERROR_ADDR_FW_CFG_FILE, NULL, = NULL, + NULL, &(ags->hw_error_le), sizeof(ags->hw_error_le), false); + } } =20 static void get_hw_error_offsets(uint64_t ghes_addr, @@ -395,8 +401,11 @@ void ghes_record_cper_errors(AcpiGhesState *ags, const= void *cper, size_t len, } =20 assert(ACPI_GHES_ERROR_SOURCE_COUNT =3D=3D 1); - get_hw_error_offsets(le64_to_cpu(ags->hw_error_le), - &cper_addr, &read_ack_register_addr); + + if (!ags->use_hest_addr) { + get_hw_error_offsets(le64_to_cpu(ags->hw_error_le), + &cper_addr, &read_ack_register_addr); + } =20 cpu_physical_memory_read(read_ack_register_addr, &read_ack_register, sizeof(read_ack_register)= ); diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 96830f7c4e..bbe83fab9a 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -1181,9 +1181,16 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuil= dTables *tables) build_dbg2(tables_blob, tables->linker, vms); =20 if (vms->ras) { - acpi_add_table(table_offsets, tables_blob); - acpi_build_hest(tables_blob, tables->hardware_errors, tables->link= er, - vms->oem_id, vms->oem_table_id); + AcpiGedState *acpi_ged_state; + AcpiGhesState *ags; + + acpi_ged_state =3D ACPI_GED(vms->acpi_dev); + ags =3D &acpi_ged_state->ghes_state; + if (ags) { + acpi_add_table(table_offsets, tables_blob); + acpi_build_hest(ags, tables_blob, tables->hardware_errors, + tables->linker, vms->oem_id, vms->oem_table_id= ); + } } =20 if (ms->numa_state->num_nodes > 0) { --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692183; cv=none; d=zohomail.com; s=zohoarc; b=UiIBfQzXavPB0WdzpjJmGiGWytKNiAY5FKImir9xX2/u5EfZ2s2xT3G2MLCjTJrgktzVDIOuEjMGCPv472eeWpQvf+eQntBF9jR2wCYjX/K2+051q9zn66J18QGB97IBawmE5NSPfLUgEi9jQbK3Y+Q8At0iPwELScsn9h1qEnk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692183; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=swNEwSYytBCwmfM6PRGKjk51QDli8Xnv2NndUXljn+g=; b=OKTSyPZnLepZIyawMaCFQfCTQICjXvCrkVw6fUyzfU1l1iNPFaLuF5nlBlGj27BVdDZn3NFiDQBdRfRAFpSZcphawhqiqR2bE1swmFlXKgUKVrQBn52M94guXKSIcY94W9wn/tS9HKzh5ZUAlfOb+sc20/n6wvAnAheLBFjcczo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692183353445.94869796809326; Sun, 5 Oct 2025 12:23:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UDz-0007fV-NT; Sun, 05 Oct 2025 15:16:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDy-0007eX-Aa for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UDw-0006QF-Jd for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:50 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-515-7MlgWQ0SNx6i7_noPbicHQ-1; Sun, 05 Oct 2025 15:16:45 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3e997eb7232so1743931f8f.3 for ; Sun, 05 Oct 2025 12:16:45 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e61a4161bsm234285155e9.16.2025.10.05.12.16.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691807; 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=swNEwSYytBCwmfM6PRGKjk51QDli8Xnv2NndUXljn+g=; b=ZoRSCQRIgjcHokW1RDSMMKsTNXMC9ET9kDMPOxRzD254IeinrbksLKUAX/a86VsGHR6yF4 jCFpYJe4pyV2CZTrf2fk/32/CjAXbrNxnSGoYLv+exGIQmlCM6YcWS1FjQnHtTKaP8tixr 1xc8NVtV5Wn/ETtcXHp/5HtCGvMbONg= X-MC-Unique: 7MlgWQ0SNx6i7_noPbicHQ-1 X-Mimecast-MFC-AGG-ID: 7MlgWQ0SNx6i7_noPbicHQ_1759691804 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691804; x=1760296604; 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=swNEwSYytBCwmfM6PRGKjk51QDli8Xnv2NndUXljn+g=; b=Aa4k+l1UkjBYoCjfWNfvfUVDERrzMgp6j6AhYLyMMoZ//UiZmiU+Y7ZIvxAUsvCs/e WO2K9un+lDBwptUri3QMG9Xq3hjQwBpdRdpPl6fvg9hwYckf4wDSUCURz8+OMGF6zdKg UMERlQvLPv7EGI4Xr+zM4r+hgva7rl5RiPiN46uL8szaX/fDd1vyQAMxMQ/IdmnNMv/U 4J83x8wraN3Mb4tfhcT7+3t0ltwOBtUT7Zq/ibycH18QKjKoUu/9zdZMQfsssAPxRpTv HCQzRY0u8F5IZ0cdGHHXLVscGOlWicb2AeZmFPPhnwZb0lV5fT0VmrQvF5mppfuPaV1s INnw== X-Gm-Message-State: AOJu0YwdH8jxnkeNyfdVZ5tY9meKmhtwejoF5e4HjWbtNGEJHrKNul2K jLZC2C8q4h7j8VTxqbIblEht6J3oGdMfGj/VatIzEjl4Y4yRKTsseBwsET8qW+BFtLJuy8JUuky mYMtld5G+EV1SGZYqhl/vi3rzBy61ziNqYCIbWAhXDOkNwXJ3h4Q/XJ+GVoo+o7WsMKIjS7eL11 oqgo4oLh0f0rWudpTRJBnvX52bPL4NikcWmg== X-Gm-Gg: ASbGncvD6Qqf9Ei+Gvzcsj1wy4dVMh0ISpDnk0gGVA/d+KxnX99nJTmo6q3+vJMlJRq nc/WGZ3DPOCBTpXz1JfjeuhbZiqy5OeXDPKxwO3vB9sNeLGPlAvVNqFjAlpKggp/3DBvpWEGnmj c/6D6eE4cAQQuuxJxu+pcW89KRcS53TQr0FBxH2OH4U8x0X0FBgq9KreXv21jAsqYqS2aC7H+ex ISwiG/kcc4FpZebDb76MFJlD0fS66AwW0bsMhp2Uww8JJ1QmRuuRYyRU0tqi6ES1Gdi+9VQ/syO wYrkEk0gNgDLOzY8ee+4JF/Donylr5BtEUohkx0= X-Received: by 2002:a05:600c:83c4:b0:46e:3f75:da49 with SMTP id 5b1f17b1804b1-46e71172a04mr72841355e9.37.1759691803953; Sun, 05 Oct 2025 12:16:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8XpifGqdugAVZ4kjxOMzProQHDrm7VfKY7IxUESucu8e5Ibw1DdchA8edh0rhPmlex2J6uw== X-Received: by 2002:a05:600c:83c4:b0:46e:3f75:da49 with SMTP id 5b1f17b1804b1-46e71172a04mr72841145e9.37.1759691803342; Sun, 05 Oct 2025 12:16:43 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:41 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Igor Mammedov , Dongjiu Geng , Ani Sinha , qemu-arm@nongnu.org Subject: [PULL 18/75] acpi/ghes: add a firmware file with HEST address Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692187259116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab Store HEST table address at GPA, placing its the start of the table at hest_addr_le variable. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/ghes.h | 6 +++++- hw/acpi/ghes.c | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 411f592662..ea9baab764 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -70,9 +70,13 @@ enum { * When use_hest_addr is false, the GPA of the etc/hardware_errors firmware * is stored at hw_error_le. This is the default on QEMU 9.x. * - * An GPA value equal to zero means that GHES is not present. + * When use_hest_addr is true, the GPA of the HEST table is stored at + * hest_addr_le. This is the default for QEMU 10.x and above. + * + * Whe both GPA values are equal to zero means that GHES is not present. */ typedef struct AcpiGhesState { + uint64_t hest_addr_le; uint64_t hw_error_le; bool use_hest_addr; /* Currently, always false */ } AcpiGhesState; diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index 9243b5ad4a..cbc96c1909 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -30,6 +30,7 @@ =20 #define ACPI_HW_ERROR_FW_CFG_FILE "etc/hardware_errors" #define ACPI_HW_ERROR_ADDR_FW_CFG_FILE "etc/hardware_errors_addr" +#define ACPI_HEST_ADDR_FW_CFG_FILE "etc/acpi_table_hest_addr" =20 /* The max size in bytes for one error block */ #define ACPI_GHES_MAX_RAW_DATA_LENGTH (1 * KiB) @@ -341,6 +342,9 @@ void acpi_build_hest(AcpiGhesState *ags, GArray *table_= data, { AcpiTable table =3D { .sig =3D "HEST", .rev =3D 1, .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; + uint32_t hest_offset; + + hest_offset =3D table_data->len; =20 build_ghes_error_table(ags, hardware_errors, linker); =20 @@ -352,6 +356,17 @@ void acpi_build_hest(AcpiGhesState *ags, GArray *table= _data, ACPI_GHES_NOTIFY_SEA, ACPI_HEST_SRC_ID_SEA); =20 acpi_table_end(linker, &table); + + if (ags->use_hest_addr) { + /* + * Tell firmware to write into GPA the address of HEST via fw_cfg, + * once initialized. + */ + bios_linker_loader_write_pointer(linker, + ACPI_HEST_ADDR_FW_CFG_FILE, 0, + sizeof(uint64_t), + ACPI_BUILD_TABLE_FILE, hest_offse= t); + } } =20 void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgState *s, @@ -361,7 +376,10 @@ void acpi_ghes_add_fw_cfg(AcpiGhesState *ags, FWCfgSta= te *s, fw_cfg_add_file(s, ACPI_HW_ERROR_FW_CFG_FILE, hardware_error->data, hardware_error->len); =20 - if (!ags->use_hest_addr) { + if (ags->use_hest_addr) { + fw_cfg_add_file_callback(s, ACPI_HEST_ADDR_FW_CFG_FILE, NULL, NULL, + NULL, &(ags->hest_addr_le), sizeof(ags->hest_addr_le), false); + } else { /* Create a read-write fw_cfg file for Address */ fw_cfg_add_file_callback(s, ACPI_HW_ERROR_ADDR_FW_CFG_FILE, NULL, = NULL, NULL, &(ags->hw_error_le), sizeof(ags->hw_error_le), false); @@ -484,7 +502,7 @@ AcpiGhesState *acpi_ghes_get_state(void) } ags =3D &acpi_ged_state->ghes_state; =20 - if (!ags->hw_error_le) { + if (!ags->hw_error_le && !ags->hest_addr_le) { return NULL; } return ags; --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691915; cv=none; d=zohomail.com; s=zohoarc; b=JXkM+K9dSGpTM7psmJuumVQUdhRBRgdhvGsO0mwe5ilWONctDHkR5TryZI031YT1M2C1/WmWI3pvWHdOe8mZHGVXDB6QeMPt6unuJcT/QVa7tvB0ggX91RHlrqP5B0MkliIp0wBluv4ciUPJJRt6FDnDA2naGCDYK+1iTL4awFQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691915; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KJibYfYpYtxiVqZnl6aI5IzK4xu2t0BO2IPKoEwaGFY=; b=hq5N5V26iuZfReP6oLZ/IZFIeeH7lEhD8mrqfc2sL5eD/my/UKhA66efzg1HDoEjLsmkUOi3kNjlhXWrSfPD4ir83zwrcLymCDck4s0Vb7LB008MnOho/Ik4tOMqnN/L/cw/if851O/E7YYIGYxQqX9VtZuRPkBJTEIC566PtLg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691915705722.9797318169315; Sun, 5 Oct 2025 12:18:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UE6-0007gi-Sn; Sun, 05 Oct 2025 15:17: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 1v5UDz-0007f0-20 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:51 -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 1v5UDx-0006QN-EX for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:50 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-517-Q5yMXP6vPBKcIgfuW6bh7w-1; Sun, 05 Oct 2025 15:16:47 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e35baddc1so22644295e9.2 for ; Sun, 05 Oct 2025 12:16:47 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e723432c9sm124137125e9.1.2025.10.05.12.16.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691808; 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=KJibYfYpYtxiVqZnl6aI5IzK4xu2t0BO2IPKoEwaGFY=; b=YT+58reBFxJ/9OAqsk+b6rbzKKhLuWL+9dyTnL7z1aqWBAckhivY72CtB6vaTMaqgZZgxh 45EmlQW3X1aLKhNfCzZHFeGIBVtRUZvQJ5EbJKSUuQcTBBVmho1GrYeH3Wz5UyEWoZeWK0 U198XG9+B0uEDOHPf11rD3zF2Kyr+SQ= X-MC-Unique: Q5yMXP6vPBKcIgfuW6bh7w-1 X-Mimecast-MFC-AGG-ID: Q5yMXP6vPBKcIgfuW6bh7w_1759691806 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691806; x=1760296606; 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=KJibYfYpYtxiVqZnl6aI5IzK4xu2t0BO2IPKoEwaGFY=; b=Ddq0D+PxqGaYJbcEP4LyvonTH3RFBOsRuqKbW8+OMZejFJmDv4OS0cX5pPas/gnk2n K30K42NJImKbHZSpumLZJNhM23h16Z0Kld14PybMtfd5qT0nOxSoHcurpwVqLXdOBy4D 0F5uO7KVuRy+eMvYqZL45uuqLdHmABa5GFUh/kI0fV3hjbSdzqC+2RuLYKrTV7+49zBx vXnjchkvuaWoS/ihXCM1Iymy6N4JWgTZR65+cK/1GZbVLnQg0wHstsLwNz4rHopvBvxC ZHmU7ux4/ySqc8+LHXe6X8SEQmNizQKveD25uHFRVvdwew34fSnmX3h/wWOLdwxfn5Ua vxfA== X-Gm-Message-State: AOJu0YzaMxbJ+eR+v4jvly9LgUzuQ4p9kW8VB5RZYxFtYEiHW0d/bJWh v0+/l8Qc3KMMZLaU7jm/odE7qs5Xxy1rnPq+q/FNXR8jZbfiDMLuSY+E1SEksD6rO4f4lDgJqNU Fb1iUFPBDACmFkVCeNU/2TZ59gdm/Ck2sHIA10aW3A+QPu1zdJH1QjNnSUP3f+pchxaoAhG6qyP Qki2k0cG/zuuGhrP9wlLWJiDJ8CkxuPdyfEw== X-Gm-Gg: ASbGncsNOf/CzfPoIWgE++fua7f0hks1h0FeSUWvWxdyKF2zXziJ+Ci5qcTZPXa4h5o LO5Gr8LNdApvB4EGroq1QlG4ZNHQ/9DagvbVJgM3awA+HmzHeCBlZwBomdRlpu8EMjLlblWwoDl bVFDQnRJwmu/6atRCKjKu+/qaxZCHWID3OkW34Q0QW/RAbuqsgPlBdx1n6N01Yo82O5U3rdsGaL 1RIjN5sSWN1+wgc8xPoPiq/Dv8JBxJrvsaLnIXpFo9Davi8wk8LYieKr10C7nSv04RvP8O+wdOO cUbJpUredtrT4onpWBeZD8m95/BaoNRLDBuvIFs= X-Received: by 2002:a05:600c:3d9b:b0:46e:45fd:946e with SMTP id 5b1f17b1804b1-46e711474c0mr79374685e9.31.1759691805849; Sun, 05 Oct 2025 12:16:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXvSC4mMBfZswAakLq/v+QW6TW6WS+i3dHLhzCs7je25xzjM6vHgSWsV2vtseAs0CZmk3jcQ== X-Received: by 2002:a05:600c:3d9b:b0:46e:45fd:946e with SMTP id 5b1f17b1804b1-46e711474c0mr79374485e9.31.1759691805342; Sun, 05 Oct 2025 12:16:45 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Igor Mammedov , Dongjiu Geng , Ani Sinha , qemu-arm@nongnu.org Subject: [PULL 19/75] acpi/ghes: Use HEST table offsets when preparing GHES records 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691918420116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab There are two pointers that are needed during error injection: 1. The start address of the CPER block to be stored; 2. The address of the read ack. It is preferable to calculate them from the HEST table. This allows checking the source ID, the size of the table and the type of the HEST error block structures. Yet, keep the old code, as this is needed for migration purposes from older QEMU versions. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/ghes.h | 2 +- hw/acpi/ghes.c | 100 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index ea9baab764..5265102ba5 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -78,7 +78,7 @@ enum { typedef struct AcpiGhesState { uint64_t hest_addr_le; uint64_t hw_error_le; - bool use_hest_addr; /* Currently, always false */ + bool use_hest_addr; /* True if HEST address is present */ } AcpiGhesState; =20 void acpi_build_hest(AcpiGhesState *ags, GArray *table_data, diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index cbc96c1909..668ca72587 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -41,6 +41,12 @@ /* Address offset in Generic Address Structure(GAS) */ #define GAS_ADDR_OFFSET 4 =20 +/* + * ACPI spec 1.0b + * 5.2.3 System Description Table Header + */ +#define ACPI_DESC_HEADER_OFFSET 36 + /* * The total size of Generic Error Data Entry * ACPI 6.1/6.2: 18.3.2.7.1 Generic Error Data, @@ -61,6 +67,30 @@ */ #define ACPI_GHES_GESB_SIZE 20 =20 +/* + * See the memory layout map at docs/specs/acpi_hest_ghes.rst. + */ + +/* + * ACPI 6.1: 18.3.2.8 Generic Hardware Error Source version 2 + * Table 18-344 Generic Hardware Error Source version 2 (GHESv2) Structure + */ +#define HEST_GHES_V2_ENTRY_SIZE 92 + +/* + * ACPI 6.1: 18.3.2.8 Generic Hardware Error Source version 2 + * Table 18-344 Generic Hardware Error Source version 2 (GHESv2) Structure + * Read Ack Register + */ +#define GHES_READ_ACK_ADDR_OFF 64 + +/* + * ACPI 6.1: 18.3.2.7: Generic Hardware Error Source + * Table 18-341 Generic Hardware Error Source Structure + * Error Status Address + */ +#define GHES_ERR_STATUS_ADDR_OFF 20 + /* * Values for error_severity field */ @@ -408,6 +438,73 @@ static void get_hw_error_offsets(uint64_t ghes_addr, *read_ack_register_addr =3D ghes_addr + sizeof(uint64_t); } =20 +static void get_ghes_source_offsets(uint16_t source_id, + uint64_t hest_addr, + uint64_t *cper_addr, + uint64_t *read_ack_start_addr, + Error **errp) +{ + uint64_t hest_err_block_addr, hest_read_ack_addr; + uint64_t err_source_entry, error_block_addr; + uint32_t num_sources, i; + + hest_addr +=3D ACPI_DESC_HEADER_OFFSET; + + cpu_physical_memory_read(hest_addr, &num_sources, + sizeof(num_sources)); + num_sources =3D le32_to_cpu(num_sources); + + err_source_entry =3D hest_addr + sizeof(num_sources); + + /* + * Currently, HEST Error source navigates only for GHESv2 tables + */ + for (i =3D 0; i < num_sources; i++) { + uint64_t addr =3D err_source_entry; + uint16_t type, src_id; + + cpu_physical_memory_read(addr, &type, sizeof(type)); + type =3D le16_to_cpu(type); + + /* For now, we only know the size of GHESv2 table */ + if (type !=3D ACPI_GHES_SOURCE_GENERIC_ERROR_V2) { + error_setg(errp, "HEST: type %d not supported.", type); + return; + } + + /* Compare CPER source ID at the GHESv2 structure */ + addr +=3D sizeof(type); + cpu_physical_memory_read(addr, &src_id, sizeof(src_id)); + if (le16_to_cpu(src_id) =3D=3D source_id) { + break; + } + + err_source_entry +=3D HEST_GHES_V2_ENTRY_SIZE; + } + if (i =3D=3D num_sources) { + error_setg(errp, "HEST: Source %d not found.", source_id); + return; + } + + /* Navigate through table address pointers */ + hest_err_block_addr =3D err_source_entry + GHES_ERR_STATUS_ADDR_OFF + + GAS_ADDR_OFFSET; + + cpu_physical_memory_read(hest_err_block_addr, &error_block_addr, + sizeof(error_block_addr)); + error_block_addr =3D le64_to_cpu(error_block_addr); + + cpu_physical_memory_read(error_block_addr, cper_addr, + sizeof(*cper_addr)); + *cper_addr =3D le64_to_cpu(*cper_addr); + + hest_read_ack_addr =3D err_source_entry + GHES_READ_ACK_ADDR_OFF + + GAS_ADDR_OFFSET; + cpu_physical_memory_read(hest_read_ack_addr, read_ack_start_addr, + sizeof(*read_ack_start_addr)); + *read_ack_start_addr =3D le64_to_cpu(*read_ack_start_addr); +} + void ghes_record_cper_errors(AcpiGhesState *ags, const void *cper, size_t = len, uint16_t source_id, Error **errp) { @@ -423,6 +520,9 @@ void ghes_record_cper_errors(AcpiGhesState *ags, const = void *cper, size_t len, if (!ags->use_hest_addr) { get_hw_error_offsets(le64_to_cpu(ags->hw_error_le), &cper_addr, &read_ack_register_addr); + } else { + get_ghes_source_offsets(source_id, le64_to_cpu(ags->hest_addr_le), + &cper_addr, &read_ack_register_addr, errp); } =20 cpu_physical_memory_read(read_ack_register_addr, --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692039; cv=none; d=zohomail.com; s=zohoarc; b=d0eiXaWVCG58I2wgg20LxBZS2IuhdwMW6vGJZbpfo8fkLbRZ/Nn73ce0SuQHoHKe+9aoSTRMwWGr80AkQYcfNNSuF1o6pdEcNLe0KQdkah9Pnk6AClfZqQErt1CaaDFMM2GeRwwngB3bqJYUWDxLrGahKlI235e50906NBgYdtI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692039; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OhUIAcnmQM/zKU/vQjFpt3gEtPEYN7XIQ1W4eirGAyc=; b=kyHr6SBBrR/5Jzg3s1NUmGpJ9M71IYFT7saxocHuASZJX1ZqHtEh4GCAO/dWpBamopnfRSdmDGfvRmsm/5KjRhKGlEODy+aomYhtBOScXX8PWqMEc7IuIzvDFxI2vG7Jqj6dw7ecqVvGu1u0y5oVKh73Wmpe+nEsvWi4OpYfGaE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692039407890.8835878783417; Sun, 5 Oct 2025 12:20:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UEE-0007jw-7y; Sun, 05 Oct 2025 15:17:06 -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 1v5UE2-0007fz-O5 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UE0-0006R4-6w for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:53 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-569-zD49ztp1MFS_UBA2yT4ZMA-1; Sun, 05 Oct 2025 15:16:50 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46e46486972so11980605e9.0 for ; Sun, 05 Oct 2025 12:16:50 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e61a4161bsm234287055e9.16.2025.10.05.12.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691811; 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=OhUIAcnmQM/zKU/vQjFpt3gEtPEYN7XIQ1W4eirGAyc=; b=YfVpm00lgF21ibyOFl4N9XVBPDVT0IxNbHJMuN8ijpYMOoTRPx4hCBQALmNz8H68k0Df4u rud0r2VEUL0l7e2K+V/NWidDZHJkdIa2o05EsZvA5HNFXriA6n+5XJ9OxSySdS4N08j3SB ulj4b6/TParOxkD0pmCsaoNipKKGnIQ= X-MC-Unique: zD49ztp1MFS_UBA2yT4ZMA-1 X-Mimecast-MFC-AGG-ID: zD49ztp1MFS_UBA2yT4ZMA_1759691809 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691809; x=1760296609; 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=OhUIAcnmQM/zKU/vQjFpt3gEtPEYN7XIQ1W4eirGAyc=; b=kPxw+3ZffyFF32JfRSG1k1qefB83+jlmEnTp0srzSXnoCpdgDoJqge9IWMCSSh5Dty Kd+/p1NkOZ9vfu7nJE5wN+dY0c/YS/PgQ6hZIq/EgjA+1FK4sA+3VhvJsNpg1Bw+hB8p n1WVWvWH8mfQUZ0CthC4t4Sz+qvJp4lHia0F9rnPhHpyj8TZfpRRHZAELeGON+2dfaYg +oaDxxS0HD1NmS3uyRTGIllxsgOEXXttRuOjNQy74Kyi+R37LGsycVXYXKpE4xDf47/h Dl8vAHWJ8IerrdTXKA4cNDuG+NWG29poEkEK4pQU0gacB6VcRFLi9bNzUM6Wa0IU5aCv 7CcA== X-Gm-Message-State: AOJu0YxLZAUSwfFWidICMQltW+q7Y/pETDUgHnqCRcbbAk9FXoowOBaD ciCsMI3suewjT7ga72cMHqkcdvRUwnlbSfy0bbZayzODt1roxlZBSO56JOwujtnU5L/BMWN0b4C pNOiygwj1e6RLIuWhYR4OXJZSGsy6836oef4dL5dZzqjFV9yAEt8CkKQOwmYjsdUhWLjX1aGoqH +DfqkC/6Tmqs/vFNnjBK8vHxN3fXjgc5NNbg== X-Gm-Gg: ASbGncuBh+Bt4yW+fSiALvl98fG39j1yAIPDQYxTZOJzWQa4imB7PWHbobdUw7Bl5Sf Ay1hd4X/W4YVevqnfSBN+PDK92RpOCMYAGkAzSvICGyy5JIFnnp2ueWwk7urmgQFyKR90WhMMWE 4IJA8t5FaKsyIrEDES+bTh67ofCT0LLDGfmsQwBrJJpTL22zAyU5pk0OFiiv6Uwfh3pjxgWCxYD 18m00dwbvpKrSdxVg0+g2WasV0WKxTNWrtwdUUxaVBVQAGxmwKIJPbgc1qeHZip4jGw0gssHhTB F9mZjfdVE4Fyg0qHyJTMgJd2M/Fik33UqwtgS1Q= X-Received: by 2002:a05:600c:1d05:b0:45d:d353:a491 with SMTP id 5b1f17b1804b1-46e711002damr58957125e9.1.1759691808836; Sun, 05 Oct 2025 12:16:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFnI3QzF955EPnYrzFeohbyruMJEXq1zjmTD98cXJ4ebvS4vYaqwtEfv2fewDwhtSdDCnS+5Q== X-Received: by 2002:a05:600c:1d05:b0:45d:d353:a491 with SMTP id 5b1f17b1804b1-46e711002damr58956945e9.1.1759691808297; Sun, 05 Oct 2025 12:16:48 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Igor Mammedov , Dongjiu Geng , Ani Sinha , Shannon Zhao , Paolo Bonzini , qemu-arm@nongnu.org, kvm@vger.kernel.org Subject: [PULL 20/75] acpi/ghes: don't hard-code the number of sources for HEST table Message-ID: <2c5a2616ed047e9d5e70970af5c4b2a54e9fa290.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692045596116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab The current code is actually dependent on having just one error structure with a single source, as any change there would cause migration issues. As the number of sources should be arch-dependent, as it will depend on what kind of notifications will exist, and how many errors can be reported at the same time, change the logic to be more flexible, allowing the number of sources to be defined when building the HEST table by the caller. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-ID: <1698680848c11d6f26368426f1657e14faaf55c4.1758610789.git.mcheha= b+huawei@kernel.org> Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/ghes.h | 17 ++++++++++++----- hw/acpi/ghes.c | 39 +++++++++++++++++++++------------------ hw/arm/virt-acpi-build.c | 8 +++++++- target/arm/kvm.c | 2 +- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 5265102ba5..8c4b084337 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -57,13 +57,18 @@ enum AcpiGhesNotifyType { ACPI_GHES_NOTIFY_RESERVED =3D 12 }; =20 -enum { - ACPI_HEST_SRC_ID_SEA =3D 0, - /* future ids go here */ - - ACPI_GHES_ERROR_SOURCE_COUNT +/* + * ID numbers used to fill HEST source ID field + */ +enum AcpiGhesSourceID { + ACPI_HEST_SRC_ID_SYNC, }; =20 +typedef struct AcpiNotificationSourceId { + enum AcpiGhesSourceID source_id; + enum AcpiGhesNotifyType notify; +} AcpiNotificationSourceId; + /* * AcpiGhesState stores GPA values that will be used to fill HEST entries. * @@ -84,6 +89,8 @@ typedef struct AcpiGhesState { void acpi_build_hest(AcpiGhesState *ags, GArray *table_data, GArray *hardware_errors, BIOSLinker *linker, + const AcpiNotificationSourceId * const notif_source, + int num_sources, const char *oem_id, const char *oem_table_id); void acpi_ghes_add_fw_cfg(AcpiGhesState *vms, FWCfgState *s, GArray *hardware_errors); diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index 668ca72587..f49d0d628f 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -238,17 +238,17 @@ ghes_gen_err_data_uncorrectable_recoverable(GArray *b= lock, * See docs/specs/acpi_hest_ghes.rst for blobs format. */ static void build_ghes_error_table(AcpiGhesState *ags, GArray *hardware_er= rors, - BIOSLinker *linker) + BIOSLinker *linker, int num_sources) { int i, error_status_block_offset; =20 /* Build error_block_address */ - for (i =3D 0; i < ACPI_GHES_ERROR_SOURCE_COUNT; i++) { + for (i =3D 0; i < num_sources; i++) { build_append_int_noprefix(hardware_errors, 0, sizeof(uint64_t)); } =20 /* Build read_ack_register */ - for (i =3D 0; i < ACPI_GHES_ERROR_SOURCE_COUNT; i++) { + for (i =3D 0; i < num_sources; i++) { /* * Initialize the value of read_ack_register to 1, so GHES can be * writable after (re)boot. @@ -263,13 +263,13 @@ static void build_ghes_error_table(AcpiGhesState *ags= , GArray *hardware_errors, =20 /* Reserve space for Error Status Data Block */ acpi_data_push(hardware_errors, - ACPI_GHES_MAX_RAW_DATA_LENGTH * ACPI_GHES_ERROR_SOURCE_COUNT); + ACPI_GHES_MAX_RAW_DATA_LENGTH * num_sources); =20 /* Tell guest firmware to place hardware_errors blob into RAM */ bios_linker_loader_alloc(linker, ACPI_HW_ERROR_FW_CFG_FILE, hardware_errors, sizeof(uint64_t), false); =20 - for (i =3D 0; i < ACPI_GHES_ERROR_SOURCE_COUNT; i++) { + for (i =3D 0; i < num_sources; i++) { /* * Tell firmware to patch error_block_address entries to point to * corresponding "Generic Error Status Block" @@ -295,12 +295,14 @@ static void build_ghes_error_table(AcpiGhesState *ags= , GArray *hardware_errors, } =20 /* Build Generic Hardware Error Source version 2 (GHESv2) */ -static void build_ghes_v2(GArray *table_data, - BIOSLinker *linker, - enum AcpiGhesNotifyType notify, - uint16_t source_id) +static void build_ghes_v2_entry(GArray *table_data, + BIOSLinker *linker, + const AcpiNotificationSourceId *notif_src, + uint16_t index, int num_sources) { uint64_t address_offset; + const uint16_t notify =3D notif_src->notify; + const uint16_t source_id =3D notif_src->source_id; =20 /* * Type: @@ -331,7 +333,7 @@ static void build_ghes_v2(GArray *table_data, address_offset + GAS_ADDR_OFFSET, sizeof(uint64_t), ACPI_HW_ERROR_FW_CFG_FILE, - source_id * sizeof(uint64_t)); + index * sizeof(uint64_t)); =20 /* Notification Structure */ build_ghes_hw_error_notification(table_data, notify); @@ -351,8 +353,7 @@ static void build_ghes_v2(GArray *table_data, address_offset + GAS_ADDR_OFFSET, sizeof(uint64_t), ACPI_HW_ERROR_FW_CFG_FILE, - (ACPI_GHES_ERROR_SOURCE_COUNT + source_= id) - * sizeof(uint64_t)); + (num_sources + index) * sizeof(uint64_t= )); =20 /* * Read Ack Preserve field @@ -368,22 +369,26 @@ static void build_ghes_v2(GArray *table_data, void acpi_build_hest(AcpiGhesState *ags, GArray *table_data, GArray *hardware_errors, BIOSLinker *linker, + const AcpiNotificationSourceId *notif_source, + int num_sources, const char *oem_id, const char *oem_table_id) { AcpiTable table =3D { .sig =3D "HEST", .rev =3D 1, .oem_id =3D oem_id, .oem_table_id =3D oem_table_id= }; uint32_t hest_offset; + int i; =20 hest_offset =3D table_data->len; =20 - build_ghes_error_table(ags, hardware_errors, linker); + build_ghes_error_table(ags, hardware_errors, linker, num_sources); =20 acpi_table_begin(&table, table_data); =20 /* Error Source Count */ - build_append_int_noprefix(table_data, ACPI_GHES_ERROR_SOURCE_COUNT, 4); - build_ghes_v2(table_data, linker, - ACPI_GHES_NOTIFY_SEA, ACPI_HEST_SRC_ID_SEA); + build_append_int_noprefix(table_data, num_sources, 4); + for (i =3D 0; i < num_sources; i++) { + build_ghes_v2_entry(table_data, linker, ¬if_source[i], i, num_s= ources); + } =20 acpi_table_end(linker, &table); =20 @@ -515,8 +520,6 @@ void ghes_record_cper_errors(AcpiGhesState *ags, const = void *cper, size_t len, return; } =20 - assert(ACPI_GHES_ERROR_SOURCE_COUNT =3D=3D 1); - if (!ags->use_hest_addr) { get_hw_error_offsets(le64_to_cpu(ags->hw_error_le), &cper_addr, &read_ack_register_addr); diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index bbe83fab9a..c856d293c6 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -1125,6 +1125,10 @@ static void acpi_align_size(GArray *blob, unsigned a= lign) g_array_set_size(blob, ROUND_UP(acpi_data_len(blob), align)); } =20 +static const AcpiNotificationSourceId hest_ghes_notify[] =3D { + { ACPI_HEST_SRC_ID_SYNC, ACPI_GHES_NOTIFY_SEA }, +}; + static void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) { @@ -1189,7 +1193,9 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuild= Tables *tables) if (ags) { acpi_add_table(table_offsets, tables_blob); acpi_build_hest(ags, tables_blob, tables->hardware_errors, - tables->linker, vms->oem_id, vms->oem_table_id= ); + tables->linker, hest_ghes_notify, + ARRAY_SIZE(hest_ghes_notify), + vms->oem_id, vms->oem_table_id); } } =20 diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 891d4fcde9..4f769d69b3 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -2456,7 +2456,7 @@ void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, v= oid *addr) */ if (code =3D=3D BUS_MCEERR_AR) { kvm_cpu_synchronize_state(c); - if (!acpi_ghes_memory_errors(ags, ACPI_HEST_SRC_ID_SEA, + if (!acpi_ghes_memory_errors(ags, ACPI_HEST_SRC_ID_SYNC, paddr)) { kvm_inject_arm_sea(c); } else { --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691903; cv=none; d=zohomail.com; s=zohoarc; b=TYVdXi4UVFoKuXHiMFW1jU3wONSR+jjTWDEZKs5/FHbm3UHPuhFDDs+ZPZtXE05rOpKCjXI3+N1U9ev2HjvgmcHy+5YyuLthlSxew0F8sWKjXJmvew7B2wVGu8s3+eADDAZx53F1h0XfcFcL0NkycOYsm2VK2DjdYnwpGscbKg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691903; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Wxyrzlql11ovDqHJOPESJRe20F5QdV3aNELPdKJF3K8=; b=eTblYo8RH56AsBzBAZHYrSQhvitTb3K+mAx++/Naq+6MT/9Qh2u2wkjpvIq6+l4Q7nuSlNg7k8WdppCGHfaqf4jEr3pvRQAgB8/CHTky1jh8Ggkw92wl1kU+pQ7+3sZ2S/IOoY4urXwAI+e7//JHgR6Mg/TZldiaMidIcmVZjmY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691903900599.7511964598424; Sun, 5 Oct 2025 12:18:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UEF-0007ke-LY; Sun, 05 Oct 2025 15:17: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 1v5UE4-0007gd-KR for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:56 -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 1v5UE3-0006RI-1I for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:56 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-271-_ztXAuh4OEi-IzWr1fcloA-1; Sun, 05 Oct 2025 15:16:52 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3ecdd80ea44so2979773f8f.1 for ; Sun, 05 Oct 2025 12:16:52 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6daasm17721522f8f.7.2025.10.05.12.16.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691814; 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=Wxyrzlql11ovDqHJOPESJRe20F5QdV3aNELPdKJF3K8=; b=FbeLPEIPnCSYNSs+I1ve1J/3Brui14+IvbEjj52iS1qQz81J3ieSaA3FoYy3kFWXdelCMl 8cRTz+fadm3ucFgUR0i66OQ4hCQiZ8iaqcnJplQkfU/eAocumuF/Ui8aIqnt+3mukt2Vey GHE2cg+h88EbZtRBrd6YsxulZIje1/k= X-MC-Unique: _ztXAuh4OEi-IzWr1fcloA-1 X-Mimecast-MFC-AGG-ID: _ztXAuh4OEi-IzWr1fcloA_1759691811 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691811; x=1760296611; 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=Wxyrzlql11ovDqHJOPESJRe20F5QdV3aNELPdKJF3K8=; b=r9d6TB2oQAYNL+wXm7B6aNAFwaVfaMHQI8qY1o87n80j5cqV7SH/E1hnCayCU58+g0 0zO9IFjZz8io1JByiHc8pTtgmuN6hQ2K4TT/kzXOmvtIcOLCTu9+vmmfEsYhZEX42mCi aNS0BW8ewbbFnBVUp4q8P148SBO9PxA3z3RBA23XAzssVsdWTPkHdUObK+yi2EcB4SHM EjrPawLA7vtLtdahttQa2k3DksD5PZUzpvK4lXicJUhFSogHgtVC+iRXVVNEKUH6dk5k dAjg8ZTTEJpWN5LhU1MlMeUgjD+OKxXL4yZm5rXmQOPuHgviSsqi/g80je/HTx0VSHi6 6YXg== X-Gm-Message-State: AOJu0YzRJ5bQWHFYfwOrVp8QmSU8Z1vpaOGc1JyfwUwzm1O607WT+nMQ oaWB2ICaUgVantSAAcVl7Otqs8FXyOeRbAXaB95QjS3rgwWox37AxPwufluE46x+DGtkmj3exIE BkECYHI7EflGMFnIIPR31JAQUjWQSJJLkUO/M+YKuloBhWXHJhkcZdnXGmDVbIRGCM1dv94YW2Z QTdRKEJUf52ruPDuGjT5zii9SHQShHNkSmFw== X-Gm-Gg: ASbGnctCk2UbdCitkrbD65eBILbMTrP9OG91mH/fn457Abyo972iAEdZ0m4SxCoScqt 4SUugXmejH1JqjeqfLontMyc0P64Xi7gWxUmuzAK3FeMS9zLvWUeoD1Pec6B9nxzl6annyqJXaE sVEqx7QJTDLOZN/DICXePWcDGB1prCeXTriD2K3L9WJRxchVfV1WbMPtY2N/FmKLw6RR+giit4i hdfwyqTOl++U9txZ1Dszd/Os7YP8m/K0RXyHfEcRUkxULNEXTe1RihOUQQGz4tR9N0Gq1qkwwjY o+tWVV1mb8HlfBdnCw1YlPou4JGsGY6mpwBhVuQ= X-Received: by 2002:a05:6000:2681:b0:407:d776:4434 with SMTP id ffacd0b85a97d-4255d2d2212mr10039359f8f.30.1759691811072; Sun, 05 Oct 2025 12:16:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIHvQFTEUNq8I64/Tv83iJGs0Xg0f5n4V/HJfGx/NZltIXQrQLLbWxy26p+lnaZrn0NgdfGg== X-Received: by 2002:a05:6000:2681:b0:407:d776:4434 with SMTP id ffacd0b85a97d-4255d2d2212mr10039334f8f.30.1759691810475; Sun, 05 Oct 2025 12:16:50 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:48 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Igor Mammedov , Dongjiu Geng , Ani Sinha , qemu-arm@nongnu.org Subject: [PULL 21/75] acpi/ghes: add a notifier to notify when error data is ready Message-ID: <7a857a8933e073d6e0c5ae2c09ff6c45751be3d7.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691909447116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab Some error injection notify methods are async, like GPIO notify. Add a notifier to be used when the error record is ready to be sent to the guest OS. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Acked-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/ghes.h | 3 +++ hw/acpi/ghes.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 8c4b084337..390943e46d 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -24,6 +24,9 @@ =20 #include "hw/acpi/bios-linker-loader.h" #include "qapi/error.h" +#include "qemu/notify.h" + +extern NotifierList acpi_generic_error_notifiers; =20 /* * Values for Hardware Error Notification Type field diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index f49d0d628f..d666f1b10b 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -510,6 +510,9 @@ static void get_ghes_source_offsets(uint16_t source_id, *read_ack_start_addr =3D le64_to_cpu(*read_ack_start_addr); } =20 +NotifierList acpi_generic_error_notifiers =3D + NOTIFIER_LIST_INITIALIZER(acpi_generic_error_notifiers); + void ghes_record_cper_errors(AcpiGhesState *ags, const void *cper, size_t = len, uint16_t source_id, Error **errp) { @@ -550,7 +553,7 @@ void ghes_record_cper_errors(AcpiGhesState *ags, const = void *cper, size_t len, /* Write the generic error data entry into guest memory */ cpu_physical_memory_write(cper_addr, cper, len); =20 - return; + notifier_list_notify(&acpi_generic_error_notifiers, NULL); } =20 int acpi_ghes_memory_errors(AcpiGhesState *ags, uint16_t source_id, --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691966; cv=none; d=zohomail.com; s=zohoarc; b=fowKmXlbcxj6nCbSU2dR8sl4owhkPTwOhLNSVxvcTKqAw4cLnz0DG53H15QCEt3UMsCRhcy94QCXH6GX8t7Mw92/85cIrBlCO2MpOQ4p310zL+660M5h6peJ2tIImRANA/WGjRNfwMz9ems3dAC/y3B5NZReRRwYRUdBj0vetdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691966; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NIhiW5u2eQoMFtkoyQrTpDhwvgeVrThMS4HUlP2TBEA=; b=J+Y/dTfLuZrjTL/aJ3sRkX8ss2jmY2JMF/4c7ZM8uRcHvT5JqeYAwlJwPfSjvZWkprL0+7CVNYbO2+wvG3uYSfwxYGDmflEdAxn/Id+kocs+i50O0za8CNA/wk3UbSxC46NywiEWM6iJtXn4yIMnHwNt5zmoRbmjJd8gBGyTEe8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691966108497.38554444533236; Sun, 5 Oct 2025 12:19:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UEL-0007ly-Jo; Sun, 05 Oct 2025 15:17:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UE6-0007h0-TB for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UE4-0006RR-DI for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:16:57 -0400 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-597-JERAcVWfP82WSeucE2IXRg-1; Sun, 05 Oct 2025 15:16:54 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3f42b54d159so3228473f8f.2 for ; Sun, 05 Oct 2025 12:16:54 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8e970esm17357225f8f.35.2025.10.05.12.16.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691815; 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=NIhiW5u2eQoMFtkoyQrTpDhwvgeVrThMS4HUlP2TBEA=; b=GRBJu6RmddsPFxaGInyw/lCoxvXQZN//4SnO5CmvLjCuG0jngID8fkDtAgTelus4R69COI dyhiL25myA277cRPonorKFsJ+7ZvjV4FlVr7UTIBePZkG4J6snXsafLK2PVxDOepei2y42 GgSDNLit+6iU7wMLki3UL8Q6Ninqpy4= X-MC-Unique: JERAcVWfP82WSeucE2IXRg-1 X-Mimecast-MFC-AGG-ID: JERAcVWfP82WSeucE2IXRg_1759691813 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691813; x=1760296613; 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=NIhiW5u2eQoMFtkoyQrTpDhwvgeVrThMS4HUlP2TBEA=; b=P+mCTboIPJNAS/HNx1b2xhDHxXdBZ63UvpVFprTGbgeTSv5W18zSJptUP2a/HIjWRn tv7Lcl3esC9tZGUNNmMVTp4l3EQngDlvPgwjmKDRSK4q2zC6+4ckIQaKmTV9XDNi+krb I95l2CxACiBgPdtAJwxMqqgal1wZxSwIGveHdocsefeW3joSKBgaEkWG7i6f4X7vlway miYom/HljCmIkz3LGEm0QMSabRxwQYVg1gVIRtm/OGNprIXPjeLgOnlpzYt0ociWTkr7 a7KyRobdsYgN3cOiw4FV27OQP4do0nmXV3ZIjlhNODOvOHqu8O2+HbrD5eOxqdqmhu0U dJsg== X-Gm-Message-State: AOJu0YyoCISkB88+VShcxrdTBbT4rjwAUWsMpumRlQTJMLCE06hZFER+ ZYNIyLhMUhH6i9IB3uyK6xhCgFEO2TqrX6YOc2/twgJIYeSoPkzeW3xaPkYYN6DIH4OiaAOdOlW wRvAtOA42XTEGPyO3eyl90q/ide0qv0OYt0rfxt/GGWciQWBE1FvMpguITWcpsJIy2yWEtat/wU wUgrqZze8AErRBL4eXM0zDW0y9rQyHmGkmRg== X-Gm-Gg: ASbGncsKBdHmvCI9Nqpu54+IZ5XPedjaV71zvPTBCT7TaVuZ2dSRWWnmaprC0MpSzji eHYkVcNeyRbaIHWgAc9QQx/QU4A5jnhdQiPyLVDqg7kyilBBovx5/cD6O5d7ehgxTKgpAynDHa3 onGjq7klXwyY1wDv9EAgu4zwkN/yYpTAxcybS9kjEBr/0FjnS3HZFXs9T0Z8S1U1u+Xdwc5ynDi C0H0RTxO9Z025fwb9scR/hys88kfh09u0CVj3zMu6N0CsjyPkaDTbuZMKKdgp5bsaq26MMvC+Zq NCjiajq2hJMYPJNIHPC2JWBKHDRU/oqOTGYb8SU= X-Received: by 2002:a05:6000:4013:b0:425:58d0:4834 with SMTP id ffacd0b85a97d-425671948cfmr6288978f8f.39.1759691812924; Sun, 05 Oct 2025 12:16:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsWN4zgw9e6n7Hk6GjBt1nA+9NTwZM/bYi3euHzHf3qQ7aiwEhTw9R7RDdL7iOv+R0g435wA== X-Received: by 2002:a05:6000:4013:b0:425:58d0:4834 with SMTP id ffacd0b85a97d-425671948cfmr6288960f8f.39.1759691812370; Sun, 05 Oct 2025 12:16:52 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:50 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Igor Mammedov , Ani Sinha Subject: [PULL 22/75] acpi/generic_event_device: Update GHES migration to cover hest addr 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691971055116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab The GHES migration logic should now support HEST table location too. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- hw/acpi/generic_event_device.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 95682b79a2..55998303c2 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -436,6 +436,34 @@ static const VMStateDescription vmstate_pcihp_state = =3D { } }; =20 +static const VMStateDescription vmstate_hest =3D { + .name =3D "acpi-hest", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT64(hest_addr_le, AcpiGhesState), + VMSTATE_END_OF_LIST() + }, +}; + +static bool hest_needed(void *opaque) +{ + AcpiGedState *s =3D opaque; + return s->ghes_state.hest_addr_le; +} + +static const VMStateDescription vmstate_hest_state =3D { + .name =3D "acpi-ged/hest", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D hest_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_STRUCT(ghes_state, AcpiGedState, 1, + vmstate_hest, AcpiGhesState), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_acpi_ged =3D { .name =3D "acpi-ged", .version_id =3D 1, @@ -449,6 +477,7 @@ static const VMStateDescription vmstate_acpi_ged =3D { &vmstate_cpuhp_state, &vmstate_ghes_state, &vmstate_pcihp_state, + &vmstate_hest_state, NULL } }; --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691914; cv=none; d=zohomail.com; s=zohoarc; b=bEn9dbxUiCP6zURW3F087dpo0sf696J2xBMxWTYZvJKdJdH0x1UFAGDAzSwMaEo3W7ZdUmWKgk6y9KLqhF79p4kI00iicfPd5C78zMLuPTE3cg+uvEwFk2oWyA0GAQkjDxhwOLFEj7mtOH+xnBOLaWGY/UZAMxmdhR56zRygIyg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691914; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xavtbsO28Ury7dy3GVu2kZqo6kk8GLRJLz1jzaO4qT4=; b=mQ7zgIQZ5BM+Mc9Ycfw1GL4Jtu5a7U8Fc+C3woUwEShJ4NNo2CQw18Jj0m2iGup4OMNnR8BMH1CDo8CfjQ2OcxvQ2gGS8j9/gB/VruzqSqKyb409HxMM0yDCukANNUso6ApT+Hoqw1qTkrVsrYEISchqQA9BlfRejzBubpaf8cA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691914886992.9973904935085; Sun, 5 Oct 2025 12:18:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UEd-00084q-Jy; Sun, 05 Oct 2025 15:17:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEA-0007hC-9i for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UE6-0006Rp-Pr for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:01 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-277-Ra0R3UedN7ee0Pg8blQt6Q-1; Sun, 05 Oct 2025 15:16:56 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e31191379so26931965e9.3 for ; Sun, 05 Oct 2025 12:16:56 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e61a0241bsm215815915e9.11.2025.10.05.12.16.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691817; 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=xavtbsO28Ury7dy3GVu2kZqo6kk8GLRJLz1jzaO4qT4=; b=GZT7I4CBzZn50goRAoNn6WTJk2A1g/ElWPT1QM8217u/iY2H756H5B1c6Tr+SkcWSgckU/ LHACx6Q222qDgsCJVCV64mwwTaXkhg5IMaDZivqz69z7XRb2NXMJ2SMu4sfzQNUnxQ6DY/ zRdROxM/u/1AfoBBBRd1Ts0Nt87yXIs= X-MC-Unique: Ra0R3UedN7ee0Pg8blQt6Q-1 X-Mimecast-MFC-AGG-ID: Ra0R3UedN7ee0Pg8blQt6Q_1759691816 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691815; x=1760296615; 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=xavtbsO28Ury7dy3GVu2kZqo6kk8GLRJLz1jzaO4qT4=; b=Vhzka+QrtWpHOXsZaqG31EIlrGqh16gFbHx1F4wlaWO7z2Y8qZgYXTSkiO7RUASBQf FTioCCVBgOQmj+jodBoFHjazX+Z1z0XyZDAVbpby0HrvSBJUzb5OH3nDSDZvHEb5Pbhy K0I8AZ8Aq0GIYZE60scM3brSjAxoB4xXd8JuxBoN0OpYLGcRNmKDHAkFOtMPNHDbWB2m k1Sv4RfsGypRpYp0qEHOTQzyzqIj0WV3WwrpOD695sim0bExLO2KG7xp1S7+WJt3/DB8 HdgObmHKfVWcvsS+4jwgK/tj41+wKuQEoSei9NtuXd3cp2RxNuqHOYlAhCY04rzI2CGu EELA== X-Gm-Message-State: AOJu0YwDBgiSUzqWLsncULd6uphfJWrJYMLiszVPf72r6MPa433aTv9v W/7H0VPhZm5CioGDT/ew2HBAgQf32Vs5hdGMgyUMjmz61N1KFAOYaWqIYyDl4PXZeGnVG17bDrE J/0XnPvFSw543MYQkhgn0PErU0RWNr05az/pMkPDbV+W+1KJCDrXj3nQC8xLxoZK1qgIp4wA1yb ps1Qs8JQXR8oPMmOkBwjq1D9xhAZi/oNh/sw== X-Gm-Gg: ASbGncvoPPDfgULm9yR/ri9UEpJAFHkTF20t6O+IXE3XOOeEqXnUQPLiWq8zpWJRkaz EFZNbIhHbyPjHeDbKVz+XWWQTT6oOZiUEGxpOyXB9ejg0PJPvqY9GRr/fX4jF/+mv8yVs9MWfXG TcYhRJIfHHiC5g9I8pXjPONO7yTygqRVDEd4dGCPhbwZ9BLpxyVWl7bcTl3ZmN0zz0wENlu6spg 1flEaoFlG9q7bPdEyWHP930bElc8VNafTui52KPlT+KXJj7DtxIeNx9RkXiMHmsKwG4/jEM80f4 MVAFjxhasgJNeRB66JllNzymhOI5Wn192X3z6lM= X-Received: by 2002:a05:600c:154a:b0:46e:45d3:82fa with SMTP id 5b1f17b1804b1-46e7226ec1amr71530395e9.10.1759691815276; Sun, 05 Oct 2025 12:16:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgwK2V48bBV5m648z4rnqwwnHr2PY/NKOjrKUyPg13UZLzoeVoUF8y4L8b9Nzty4+OleOLMA== X-Received: by 2002:a05:600c:154a:b0:46e:45d3:82fa with SMTP id 5b1f17b1804b1-46e7226ec1amr71530125e9.10.1759691814751; Sun, 05 Oct 2025 12:16:54 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:52 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Igor Mammedov , Ani Sinha , Shannon Zhao , Eduardo Habkost , Marcel Apfelbaum , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Yanan Wang , Zhao Liu , qemu-arm@nongnu.org Subject: [PULL 23/75] acpi/generic_event_device: add logic to detect if HEST addr is available 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691923425116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab Create a new property (x-has-hest-addr) and use it to detect if the GHES table offsets can be calculated from the HEST address (qemu 10.0 and upper) or via the legacy way via an offset obtained from the hardware_errors firmware file. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- hw/acpi/generic_event_device.c | 2 ++ hw/arm/virt-acpi-build.c | 18 ++++++++++++++++-- hw/core/machine.c | 5 ++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 55998303c2..b1ff6ab74d 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -349,6 +349,8 @@ static const Property acpi_ged_properties[] =3D { pcihp_state.use_acpi_hotplug_bridge, 0), DEFINE_PROP_LINK("bus", AcpiGedState, pcihp_state.root, TYPE_PCI_BUS, PCIBus *), + DEFINE_PROP_BOOL("x-has-hest-addr", AcpiGedState, + ghes_state.use_hest_addr, false), }; =20 static const VMStateDescription vmstate_memhp_state =3D { diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index c856d293c6..ff3b7a794b 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -1129,6 +1129,10 @@ static const AcpiNotificationSourceId hest_ghes_noti= fy[] =3D { { ACPI_HEST_SRC_ID_SYNC, ACPI_GHES_NOTIFY_SEA }, }; =20 +static const AcpiNotificationSourceId hest_ghes_notify_10_0[] =3D { + { ACPI_HEST_SRC_ID_SYNC, ACPI_GHES_NOTIFY_SEA }, +}; + static void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) { @@ -1186,15 +1190,25 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBui= ldTables *tables) =20 if (vms->ras) { AcpiGedState *acpi_ged_state; + static const AcpiNotificationSourceId *notify; + unsigned int notify_sz; AcpiGhesState *ags; =20 acpi_ged_state =3D ACPI_GED(vms->acpi_dev); ags =3D &acpi_ged_state->ghes_state; if (ags) { acpi_add_table(table_offsets, tables_blob); + + if (!ags->use_hest_addr) { + notify =3D hest_ghes_notify_10_0; + notify_sz =3D ARRAY_SIZE(hest_ghes_notify_10_0); + } else { + notify =3D hest_ghes_notify; + notify_sz =3D ARRAY_SIZE(hest_ghes_notify); + } + acpi_build_hest(ags, tables_blob, tables->hardware_errors, - tables->linker, hest_ghes_notify, - ARRAY_SIZE(hest_ghes_notify), + tables->linker, notify, notify_sz, vms->oem_id, vms->oem_table_id); } } diff --git a/hw/core/machine.c b/hw/core/machine.c index 38c949c4f2..7b7a381b0a 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -35,9 +35,12 @@ #include "hw/virtio/virtio-pci.h" #include "hw/virtio/virtio-net.h" #include "hw/virtio/virtio-iommu.h" +#include "hw/acpi/generic_event_device.h" #include "audio/audio.h" =20 -GlobalProperty hw_compat_10_1[] =3D {}; +GlobalProperty hw_compat_10_1[] =3D { + { TYPE_ACPI_GED, "x-has-hest-addr", "false" }, +}; const size_t hw_compat_10_1_len =3D G_N_ELEMENTS(hw_compat_10_1); =20 GlobalProperty hw_compat_10_0[] =3D { --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692405; cv=none; d=zohomail.com; s=zohoarc; b=EK0z5KRmky12JYgG95AM3iLpaF+GvTN/5lo/fxpikhsSGId028I/uu7K/UNMKHhIFv2qM0/9THE1z4aVd0xfwzMiBUYXy3+3DIdcrhqZcEqI/ovs8Yptm93Tl/vjfq0MBQOTda4lRrPgE++33FmMZDU652Qk1gtyx4H92CxkZ24= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692405; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wo4k0+GpbcFPiJ6gl4bLvcB2+0oAKyd5LRGZIg/TJvM=; b=HzZhv/Qcy+D72cJltUl7FGF8Dm4B5WUx1R2xznkD2Rbk/F1WcVmJF6ClhVWGgc0p4wJB6Q1xAr5ZQDhhnVDPzrJsxfkMCnc927kLUXqGz/8PaCZ5qtynGNXYFncDv8HEQcYUX/9A6LX1MVB34JVImGnse1o0HJjItzx8/SMGscs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692405698689.466772332869; Sun, 5 Oct 2025 12:26:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UEH-0007lK-1r; Sun, 05 Oct 2025 15:17: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 1v5UEC-0007hk-CO for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEA-0006Ry-AZ for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:04 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-lYG2sRL6Ovi7aWDvU2_X9A-1; Sun, 05 Oct 2025 15:16:59 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e375dab7dso18414165e9.3 for ; Sun, 05 Oct 2025 12:16:59 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e5b56c792sm126382675e9.0.2025.10.05.12.16.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691820; 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=wo4k0+GpbcFPiJ6gl4bLvcB2+0oAKyd5LRGZIg/TJvM=; b=d3DUCYu7l8nxBEZdMmp3Yd2b0om3BeFSxXQYoV5j4/p7spU3jsRpzpQa5XNQqW1LEGBIJ2 Mp/CVQQoiT8W2feLXoKcNZtt8e0WUM/QVcZqNyBpe91aDS/YjAsjJH42ilsVXE7Z62yIod OCdeI4/aVy4ThtZduPHXxwtSPhuTNBo= X-MC-Unique: lYG2sRL6Ovi7aWDvU2_X9A-1 X-Mimecast-MFC-AGG-ID: lYG2sRL6Ovi7aWDvU2_X9A_1759691818 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691818; x=1760296618; 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=wo4k0+GpbcFPiJ6gl4bLvcB2+0oAKyd5LRGZIg/TJvM=; b=i60w+u4TPvJQyO0/KJIBiNtfjScAmktxGT/NxalTfo76BtrTYoODr9o6qdthlfeH5C z+KzFy6/DQBYFGlsyamaGYkIulpZIJ5xvJxm3+tV+RF6wPlXckLR793Kg07CiVl3BNP7 UsE4MTRr8uHujDZgUBj7nFXpazaqGzAWypK47lAmaZhJUX8YpFnC+9sLFx0l0NxHFayc XtUIYFdLbxpOTOLqvhYWjTI+EHMuEILA3344Uv+1KmJEM+/8Zcu8STa8pMaJDYojNihP yrS1CCTvpWlmT6lHcyFdcc5LRS5PgnqQaITY373dov1mLp2ax4vlsgibtVv1aGO9Yoep jyUg== X-Gm-Message-State: AOJu0YwiTjYnVz3b6LyKdvlIyQlj3T+2CfxdsbVd/8L0nRtv8Jrzspe1 4M3+bivL4auhszQ3rPk0VXoIH2uD76i9T7cKmcmKLklzsttbq+FIhShwzyw5czWdWLCs4JzhyYH 2S2pRH6+PQ2/n347btGrhixJpg/DagS+iBCkuocX4Ztxv61kEECtn13pZeamGr61W5GCKnm6MLv ihREVfXWpLZdJnEuHSQR4/mi3noHGQf7A/JQ== X-Gm-Gg: ASbGnct2IC3zpfnl7M9trCNI2WGFZO6TcitVx5MNRI/JrxcQpUnr+XDr2TIa1YeHVGZ j3uLf5sl5OaTtp4ZPdP5VcvMXgRZkTRzenjyN4KGqPMxBkBvWfzFURM+NNHYyk0XLL/BlsSaJ7k aQPmYiOiBrGslEKAOk7o7Jl4w4OUfLGqXyVL9vNfCCcJRMkF6vye9G9R4mt4VZ7HlfXeII+3O9S 3AeRO2fxj6c6AchHvgLiQt1XdME6cHJB4LE/9Bn456L35f3RNfDecpXMflerpjkfyzHOMkrXxFe uvbF8drtMcWn2/8u/lMw2/fx8grosRv56HZ/mUI= X-Received: by 2002:a05:600c:a085:b0:45d:d609:1199 with SMTP id 5b1f17b1804b1-46e71151c24mr72241735e9.30.1759691817736; Sun, 05 Oct 2025 12:16:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkzDFi6nuyZGqMEwB9zdBqGx2j8fNsTRjslP3j3HYYpHUK0tMFl+PbY0uvSFypJ6Eh8F2qrQ== X-Received: by 2002:a05:600c:a085:b0:45d:d609:1199 with SMTP id 5b1f17b1804b1-46e71151c24mr72241535e9.30.1759691817138; Sun, 05 Oct 2025 12:16:57 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Igor Mammedov , Ani Sinha Subject: [PULL 24/75] acpi/generic_event_device: add an APEI error device Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692409406116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab Adds a generic error device to handle generic hardware error events as specified at ACPI 6.5 specification at 18.3.2.7.2: https://uefi.org/specs/ACPI/6.5/18_Platform_Error_Interfaces.html#event-not= ification-for-generic-error-sources using HID PNP0C33. The PNP0C33 device is used to report hardware errors to the guest via ACPI APEI Generic Hardware Error Source (GHES). Co-authored-by: Mauro Carvalho Chehab Co-authored-by: Jonathan Cameron Signed-off-by: Jonathan Cameron Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-ID: <2790f664c849d53de0ce3049fa8c7950c1de1f86.1758610789.git.mcheha= b+huawei@kernel.org> Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/acpi_dev_interface.h | 1 + include/hw/acpi/aml-build.h | 2 ++ include/hw/acpi/generic_event_device.h | 1 + hw/acpi/aml-build.c | 10 ++++++++++ hw/acpi/generic_event_device.c | 13 +++++++++++++ 5 files changed, 27 insertions(+) diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_de= v_interface.h index 68d9d15f50..8294f8f0cc 100644 --- a/include/hw/acpi/acpi_dev_interface.h +++ b/include/hw/acpi/acpi_dev_interface.h @@ -13,6 +13,7 @@ typedef enum { ACPI_NVDIMM_HOTPLUG_STATUS =3D 16, ACPI_VMGENID_CHANGE_STATUS =3D 32, ACPI_POWER_DOWN_STATUS =3D 64, + ACPI_GENERIC_ERROR =3D 128, } AcpiEventStatusBits; =20 #define TYPE_ACPI_DEVICE_IF "acpi-device-interface" diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index c18f681342..f38e129719 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -252,6 +252,7 @@ struct CrsRangeSet { /* Consumer/Producer */ #define AML_SERIAL_BUS_FLAG_CONSUME_ONLY (1 << 1) =20 +#define ACPI_APEI_ERROR_DEVICE "GEDD" /** * init_aml_allocator: * @@ -382,6 +383,7 @@ Aml *aml_dma(AmlDmaType typ, AmlDmaBusMaster bm, AmlTra= nsferSize sz, uint8_t channel); Aml *aml_sleep(uint64_t msec); Aml *aml_i2c_serial_bus_device(uint16_t address, const char *resource_sour= ce); +Aml *aml_error_device(void); =20 /* Block AML object primitives */ Aml *aml_scope(const char *name_format, ...) G_GNUC_PRINTF(1, 2); diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/gener= ic_event_device.h index 2c5b055327..130c014d3f 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -103,6 +103,7 @@ OBJECT_DECLARE_TYPE(AcpiGedState, AcpiGedClass, ACPI_GE= D) #define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4 #define ACPI_GED_CPU_HOTPLUG_EVT 0x8 #define ACPI_GED_PCI_HOTPLUG_EVT 0x10 +#define ACPI_GED_ERROR_EVT 0x20 =20 typedef struct GEDState { MemoryRegion evt; diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 1e685f982f..2d5826a8f1 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -2629,3 +2629,13 @@ Aml *aml_i2c_serial_bus_device(uint16_t address, con= st char *resource_source) =20 return var; } + +/* ACPI 5.0b: 18.3.2.6.2 Event Notification For Generic Error Sources */ +Aml *aml_error_device(void) +{ + Aml *dev =3D aml_device(ACPI_APEI_ERROR_DEVICE); + aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C33"))); + aml_append(dev, aml_name_decl("_UID", aml_int(0))); + + return dev; +} diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index b1ff6ab74d..e575b9404b 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -30,6 +30,7 @@ static const uint32_t ged_supported_events[] =3D { ACPI_GED_NVDIMM_HOTPLUG_EVT, ACPI_GED_CPU_HOTPLUG_EVT, ACPI_GED_PCI_HOTPLUG_EVT, + ACPI_GED_ERROR_EVT, }; =20 /* @@ -120,6 +121,16 @@ void build_ged_aml(Aml *table, const char *name, Hotpl= ugHandler *hotplug_dev, aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE), aml_int(0x80))); break; + case ACPI_GED_ERROR_EVT: + /* + * ACPI 5.0b: 5.6.6 Device Object Notifications + * Table 5-135 Error Device Notification Values + * Defines 0x80 as the value to be used on notifications + */ + aml_append(if_ctx, + aml_notify(aml_name(ACPI_APEI_ERROR_DEVICE), + aml_int(0x80))); + break; case ACPI_GED_NVDIMM_HOTPLUG_EVT: aml_append(if_ctx, aml_notify(aml_name("\\_SB.NVDR"), @@ -320,6 +331,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, Acp= iEventStatusBits ev) sel =3D ACPI_GED_MEM_HOTPLUG_EVT; } else if (ev & ACPI_POWER_DOWN_STATUS) { sel =3D ACPI_GED_PWR_DOWN_EVT; + } else if (ev & ACPI_GENERIC_ERROR) { + sel =3D ACPI_GED_ERROR_EVT; } else if (ev & ACPI_NVDIMM_HOTPLUG_STATUS) { sel =3D ACPI_GED_NVDIMM_HOTPLUG_EVT; } else if (ev & ACPI_CPU_HOTPLUG_STATUS) { --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692185; cv=none; d=zohomail.com; s=zohoarc; b=Nk3ghmB59tmoAPiNNmIJM4vTz9jXaxpRSDE6hnIJCUev+uTHJCXC3h5Yty2qF1mTK8B278Iw8lPWVY8hidpu04jgol49qbryao59pvKXukJr9ZmYpUew5P7C7SADiiFe/lpbhF9Pvrv/dR1xMbG0ztvbT9Aq0wF6bo7OiEBm2BM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692185; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mQccCBnzaI2vbnXja20gty2VSpVTUvCQbKMpL53IPwk=; b=D2JreURuwZgRFoWlvoQTdpk+GQ642fdF8Gz8oxg6Qa+lMLT8SacXgtvjrbYwPSTobnygI52chfsmVi1Igvgi8z2PBKIBi8nDf+WPrl4G+3cZYH2OG5yoDSzwYSXF9eDBta71qun8ZYy03ytRNOxFTsjgzyW1DpZlfIcDCenPUDQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692185878133.66903771146872; Sun, 5 Oct 2025 12:23:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UEG-0007l3-GT; Sun, 05 Oct 2025 15:17:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UED-0007jj-Mr for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:05 -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 1v5UEB-0006SH-JD for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:05 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-228-tHv4QRhoNgWgppWrKYPzew-1; Sun, 05 Oct 2025 15:17:01 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-46e47d14dceso17543905e9.2 for ; Sun, 05 Oct 2025 12:17:01 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f01a0sm17392040f8f.48.2025.10.05.12.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:16:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691822; 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=mQccCBnzaI2vbnXja20gty2VSpVTUvCQbKMpL53IPwk=; b=NssznSHdTm8jraZGctwD4vXzmQH88spgfsjIDrDij8wanuhe24R6DQjgIUL1Hr0lLzmyeY h1ibTxuSIj3YmbxJuYmqqQBRveUu+PtnRBe04im1QM1Iwx5WN7fdyquzgDyPVMc+ggLxdf DT5t/1g/b+rF6k1ND3yNdLDZJvRN/wQ= X-MC-Unique: tHv4QRhoNgWgppWrKYPzew-1 X-Mimecast-MFC-AGG-ID: tHv4QRhoNgWgppWrKYPzew_1759691820 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691820; x=1760296620; 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=mQccCBnzaI2vbnXja20gty2VSpVTUvCQbKMpL53IPwk=; b=lMertB5lEijbcle5yK9RrH85bG518wuQAGecrm8TyvK0RW4Q/pr7izIwz57KgPxoBH pT8Yvxy2o9gUS6wbDY+PQu9jOf2U1c5kMTn+erjlkMprcAOQBbm/f1juurRjFp+N8VEN Ez3Fy5mwzCnHgYn9QyCISoz4/ke3VLrvJeRoIp89046QP/GyVCcIemwtqchNhUO6/LeQ vhjPo9Fcz7MujmDYL2rJA9tve6exVIv1dd2u+UBnWL0fsYqHpXAB82YhK+RMMZFscP8G 5B6Vp1MH9eAxtjUpWMDInXZ7ZL5jRSyMGIPltAZpHm+CI7Q9odc4XWv2g/vLPukQCUBA TCQA== X-Gm-Message-State: AOJu0YwT0zYl8AKIRlXCA4Ek2hQwgOcIJQmiaEgcVXm87AYYvMhc5TQX 74EtqEt8/iLn19hTaTiV3+0zJCtL/aLZk2KZnGjwjLwzNsUmd6MbfTAoj0V6Glm7c6vhTcD83sL nTSJbnjOD2TjHQv7X0fgQ+9Pm1+R0QOKz+zA4aH1Vsgwm6Hdy12YuTPIh3rg/61qAkhm+1052L7 Wl1TmYxJbBW7VDXU6hNs8g1/MboKuWLKB9jw== X-Gm-Gg: ASbGncuh0OS/gDFppOQzrMTRJtIcCh8sLCY1hXoJ+UL/fWscu13hS/auYnbbYXWHcg+ BHP2/Wn9inArzxCRal6MCD5jt80sArdTxjMmkgApchkMOfCLiCuYTZTUtJlYk2mKZ4i9OSa//6b Y9GG31UP6ClJSOFIFWvrnfXh2AJ72s1ZnVGQOm6v01fOpXi4YDQmL+mimCQVvQCb5sUNfU5xso2 XihSNaYIP31kcFm4N3LavEgbxXqch7ldcQ5Q4GhaVaJpK//R5CgXLsd87T5X117M1Yap6ZmZMK0 QTCdk8IpPCcl6CWX5BDFk4t1F9ajLXRbqySdjPo= X-Received: by 2002:a05:600c:468e:b0:43c:ec4c:25b4 with SMTP id 5b1f17b1804b1-46e71102467mr68691045e9.10.1759691819681; Sun, 05 Oct 2025 12:16:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGbCnpofifWPAe5hJdopMskr+0e13LIxhzNteStsJu5IOJLR3rNy/zKd/DT6uVpHyMUMissA== X-Received: by 2002:a05:600c:468e:b0:43c:ec4c:25b4 with SMTP id 5b1f17b1804b1-46e71102467mr68690895e9.10.1759691819139; Sun, 05 Oct 2025 12:16:59 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:57 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Igor Mammedov , Jonathan Cameron , Ani Sinha Subject: [PULL 25/75] tests/acpi: virt: allow acpi table changes at DSDT and HEST tables Message-ID: <79b10b6639456d244118cf564214495637494931.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692187471116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab We'll be adding a new GED device for HEST GPIO notification and increasing the number of entries at the HEST table. Blocklist testing HEST and DSDT tables until such changes are completed. Signed-off-by: Mauro Carvalho Chehab Acked-by: Igor Mammedov Reviewed-by: Jonathan Cameron Reviewed-by: Michael S. Tsirkin Message-ID: <7fca7eb9b801f1b196210f66538234b94bd31c23.1758610789.git.mcheha= b+huawei@kernel.org> Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index dfb8523c8b..cb4b0a9469 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1 +1,12 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/aarch64/virt/HEST", +"tests/data/acpi/aarch64/virt/DSDT", +"tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt", +"tests/data/acpi/aarch64/virt/DSDT.acpipcihp", +"tests/data/acpi/aarch64/virt/DSDT.hpoffacpiindex", +"tests/data/acpi/aarch64/virt/DSDT.memhp", +"tests/data/acpi/aarch64/virt/DSDT.pxb", +"tests/data/acpi/aarch64/virt/DSDT.topology", +"tests/data/acpi/aarch64/virt/DSDT.viot", +"tests/data/acpi/aarch64/virt/DSDT.smmuv3-dev", +"tests/data/acpi/aarch64/virt/DSDT.smmuv3-legacy", --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692216; cv=none; d=zohomail.com; s=zohoarc; b=akZckIfufeFuhUA6nlSxOOYVby65lW2QlxBUyFIqBp6rDExn69+fmk1yJ6aEGFVEX4DhAJjPPs0kyrLpAYO1EFQuvNQWCuImsk5VABOtsL/UcuiEEoR773xC0gKcij6Wl7HJ+DpVPGkWTy2Zt2KeFfa2vdQoUpn1fXVqJoINOeU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692216; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=n2yaew7sPmdwqoSuzt/4g3R5wabDe7Wq8iiNEDRaEec=; b=N5/4hYupmGiVgGeAH1n2Fpnm+XncePFbUYiZGmCkzs0815lJtE77HSHrDkDVRu5fcHXkNQfSWK/GpDzHz91oKdyoJb38qdLuLfdiWPVifkUBz7IAHK3GHk8+QUSUB4Bauc9zihrElei70n/XftivFyaFV7sSzPaz5kgVkXp24Zs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692216153702.6021596223848; Sun, 5 Oct 2025 12:23:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UF8-0000ee-FH; Sun, 05 Oct 2025 15:18: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 1v5UEF-0007kg-Jv for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17: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 1v5UED-0006Si-Lq for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:07 -0400 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-128-gvtimDmOMraJr1sO78NKTQ-1; Sun, 05 Oct 2025 15:17:03 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-40fd1b17d2bso1774071f8f.1 for ; Sun, 05 Oct 2025 12:17:03 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8e9719sm17755739f8f.31.2025.10.05.12.17.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691825; 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=n2yaew7sPmdwqoSuzt/4g3R5wabDe7Wq8iiNEDRaEec=; b=DsHqXmwoN072gRqrDEdjk799vG2EZD1kzna2KsfDvW7jirBL2HPwVwA1Y0qgSbgmoY+cnQ 7ZQPOOokniFAo4RLhuuXXLuFGKlHR8qYHhoKzzLVBzWnQUKZcW+VHGI1GkSKO/KJISIWNp 1nev0SSrEfk2OXVyRovvg/I0LjXFH24= X-MC-Unique: gvtimDmOMraJr1sO78NKTQ-1 X-Mimecast-MFC-AGG-ID: gvtimDmOMraJr1sO78NKTQ_1759691822 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691822; x=1760296622; 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=n2yaew7sPmdwqoSuzt/4g3R5wabDe7Wq8iiNEDRaEec=; b=d/DKA8JkNqUqm73MU2p1hBWuBCVUUyilxTORcDurfvT8Mejo7Eon1jmqtVJoYNiXwH 1P2dbr0kCkxSPcDc77qWFJbOzRCMsl2d+TvjKoQY82gYAX1g/9BDnEtwyYM/QZDy4liV hqlYZYpqFcPb9CZclU2dCwTyK0IpFLq8Ky52QUhTLBNDsn6EEGFgo7uUPVbS4luB70iX R+VyEaFJzrFDQdtjcEIur3do7HGESLS9DhU63e0tG7Mj7wbR1WtoAr6YqTSq0XcRzX74 r+oPZxsKCEpgWxQShFaHvT5XAOapG2ccnDAZ1aWdIEp/TocEXtL8wNxLDUn7ruEmwNDE UMug== X-Gm-Message-State: AOJu0YylMYtzPCaVirHUQl5+ybQoU+j8yqHqytWVs+G2X+cZz8Bh3+fJ DTpbwrpQzQoVJo5y5Oi3zE9Ji3jSiqp8DxvmwiBj1sb1m636ItF77LTPOjonbp2U3e5OgTQXEO7 MbpHkfVjlt7azBpRslDRcYxnUSDdOZ6AVg+ymw4PGfPzaO9h4flXvF3b1fTnyXHRstjQfELjF9N DpohxAuGFy37rTgPte+IanTKqvpY68p5vHZg== X-Gm-Gg: ASbGncsenLiffXFZw+SdufaOIrVohWSrYChH4STU8qStLmrTprHMNLIGEOYJR/Gs+5b OdgpKj9lWO+6IktCVfwbDRFSCDZOasFHV6Ga45ysHbUQPrzCQPSIC2PgINP948ATYl5rLw0A1On yARJXnZnrn7jKDBrA7GvSQyzAB2R1lquxURG1sqDQMTwym9qbWiW3HvLq+H9J0jGiZb6Cz4nogu JDqtOZ5QG26VJa5FZnC+bPXMrtZPe9G1otw0BNEBO0UKRUdR3Cp+Rnr0IL2A5GEuw0VZntf36gW vtNf5pLgFWikb9oFqyu93Hhl+mWyWoapuxKP38w= X-Received: by 2002:a05:6000:3105:b0:3e5:47a9:1c7f with SMTP id ffacd0b85a97d-425671b2410mr6544790f8f.47.1759691821770; Sun, 05 Oct 2025 12:17:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRURCRu0Nwht+Dp8zRejMGpCvhKOig5UJaICV2rwPLpdKx7n6ZmoTroR9mTPUTjNIxeRzv/Q== X-Received: by 2002:a05:6000:3105:b0:3e5:47a9:1c7f with SMTP id ffacd0b85a97d-425671b2410mr6544769f8f.47.1759691821273; Sun, 05 Oct 2025 12:17:01 -0700 (PDT) Date: Sun, 5 Oct 2025 15:16:59 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Igor Mammedov , Ani Sinha , Shannon Zhao , qemu-arm@nongnu.org Subject: [PULL 26/75] arm/virt: Wire up a GED error device for ACPI / GHES 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692228784116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab Adds support to ARM virtualization to allow handling generic error ACPI Event via GED & error source device. It is aligned with Linux Kernel patch: https://lore.kernel.org/lkml/1272350481-27951-8-git-send-email-ying.huang@i= ntel.com/ Co-authored-by: Mauro Carvalho Chehab Co-authored-by: Jonathan Cameron Signed-off-by: Jonathan Cameron Signed-off-by: Mauro Carvalho Chehab Acked-by: Igor Mammedov Reviewed-by: Jonathan Cameron Reviewed-by: Michael S. Tsirkin Message-ID: <3237a76b1469d669436399495825348bf34122cd.1758610789.git.mcheha= b+huawei@kernel.org> Signed-off-by: Michael S. Tsirkin --- include/hw/arm/virt.h | 1 + hw/arm/virt-acpi-build.c | 1 + hw/arm/virt.c | 12 +++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index ea2cff05b0..e14ea0f9d4 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -174,6 +174,7 @@ struct VirtMachineState { DeviceState *gic; DeviceState *acpi_dev; Notifier powerdown_notifier; + Notifier generic_error_notifier; PCIBus *bus; char *oem_id; char *oem_table_id; diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index ff3b7a794b..2b63008df0 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -1066,6 +1066,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) } =20 acpi_dsdt_add_power_button(scope); + aml_append(scope, aml_error_device()); #ifdef CONFIG_TPM acpi_dsdt_add_tpm(scope, vms); #endif diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 02209fadcf..6960f6113f 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -693,7 +693,7 @@ static inline DeviceState *create_acpi_ged(VirtMachineS= tate *vms) MachineState *ms =3D MACHINE(vms); SysBusDevice *sbdev; int irq =3D vms->irqmap[VIRT_ACPI_GED]; - uint32_t event =3D ACPI_GED_PWR_DOWN_EVT; + uint32_t event =3D ACPI_GED_PWR_DOWN_EVT | ACPI_GED_ERROR_EVT; bool acpi_pcihp; =20 if (ms->ram_slots) { @@ -1050,6 +1050,13 @@ static void virt_powerdown_req(Notifier *n, void *op= aque) } } =20 +static void virt_generic_error_req(Notifier *n, void *opaque) +{ + VirtMachineState *s =3D container_of(n, VirtMachineState, generic_erro= r_notifier); + + acpi_send_event(s->acpi_dev, ACPI_GENERIC_ERROR); +} + static void create_gpio_keys(char *fdt, DeviceState *pl061_dev, uint32_t phandle) { @@ -2500,6 +2507,9 @@ static void machvirt_init(MachineState *machine) =20 if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)= ) { vms->acpi_dev =3D create_acpi_ged(vms); + vms->generic_error_notifier.notify =3D virt_generic_error_req; + notifier_list_add(&acpi_generic_error_notifiers, + &vms->generic_error_notifier); } else { create_gpio_devices(vms, VIRT_GPIO, sysmem); } --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692129; cv=none; d=zohomail.com; s=zohoarc; b=jVQgDnONM+u0Al9a36proKEbBNGGOMvZV2739efVXPNELWx/j1O3hyjm+Dux7+xpVHOH3K1ekP19c6NiT8bDyzvm1iuAdem2RYuE99Sh5DzTVPUkIhiYmJBFn8HByaM6utbcsA5s83WJQMAe32OtvVYAJM63mUdXE7QNUBkRbyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692129; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zoo23lLJOe1UY22DY2evFce08dzQGIGFIEQ1PeuRF6g=; b=MMMkG7ZDnjetNBaZhyJ18/b1K1mCwZ9oC+P9gqhuzeB2m/LKznOmERNMPYd7OOSHPaZb67OKYaUOr02pSTJQRvZhDNWxzdrc6tHyxTnlSk63cQeBAvYoD+uyixhstA1n6sMPoRzKKqlCZNXSBzwqn7uOADiaB3BjgRcboYrVChE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17596921298863.8795599361119457; Sun, 5 Oct 2025 12:22:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFC-00015N-CT; Sun, 05 Oct 2025 15:18:06 -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 1v5UEN-0007mN-8G for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:20 -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 1v5UEG-0006TD-KK for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:14 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-81-cGU3Jm13PCC9zgThy7QmcQ-1; Sun, 05 Oct 2025 15:17:06 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-401dbafbcfaso2577009f8f.1 for ; Sun, 05 Oct 2025 12:17:06 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f027csm17692870f8f.40.2025.10.05.12.17.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691827; 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=zoo23lLJOe1UY22DY2evFce08dzQGIGFIEQ1PeuRF6g=; b=MFmhRyD/Kp07bDgmVK6WgACzk1AxeMwuqxcXrSiWIID5TnoO/TEpgHJ8A6oZEWDGHFi+0O 4QJw4wj3gZLS5KsBA1byJQ71QDZi5LgYpsFqWrAAqsPus/2o3x/beVM7ABPsb29ZR33UUt eYwLTMY13miOLF5TDUtUlB5KidTTxvc= X-MC-Unique: cGU3Jm13PCC9zgThy7QmcQ-1 X-Mimecast-MFC-AGG-ID: cGU3Jm13PCC9zgThy7QmcQ_1759691825 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691825; x=1760296625; 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=zoo23lLJOe1UY22DY2evFce08dzQGIGFIEQ1PeuRF6g=; b=QP1w4cx1eJMxX90V+yeefFBlnB09kwQUoECUD4zh6bNB0bG0wunF7Wtd2vgIyrqBD7 /OpJFPuojDsmytEj4M0e4nrmpVqyxB5bC0iQj+Yhw2YCOeuFfGXQbf5NLMgyf7jlACTp Z72+rpIHysByJeE8PQ4TmaViTqWn96U0IF92vp0MUVvhIMu5iWYcIqsvih1Wrn2OEZzU 6ACuOa6ktskkMZRdp4GeVoCKiJkRj1vm3MhOgvuvZROburMv9tKuESc4z0sGedAkYOzX WHdtZa+EGhjvITjjXDre0XDB2LIR8clkQCxHD8UmcMpncLURaS3GPbKgrDQMUJ8+Hghw VnSA== X-Gm-Message-State: AOJu0Ywsl6DNetfcLV5JWxJ3S8TIMtiKUwoEX3c3MH85R7bjuvQcjR/a 0VqEYZ0bkvTtbnvT5QX1XinL/HD3KkCR/W+cXPFE+KKSkU5wFtTfuVxxyTQYi7h06V6yy7b6EV2 NEX3ce+kEg0416+9DLL4UW4aePDaWwMyTLAJiLp5lQgKQVYU7MpIMy78vsQxKXamTjsqqnC418p sy8HIEbxUXzq8Dj4VrQrBPhLF7HlfEJNq1BQ== X-Gm-Gg: ASbGnctqDs+ToCu2UM4rdwMGsHdV0y770t5DTDW8GQZUMyTPrbC9DzUT0F+0cbQ/iKi mdolYL8C9lD6xQU2xMdx8cshTKFLpHZjnVqjWA/6kE6De/Xi4/FU2gfb9LKyWg8rj1CeFfLtqgT /yxrIzPBgkBNAiKepBV7mYBqaMDOHsNH6cmXx7GlNz+SXd8nWVFEOtgfGNWU/Haq0Q4nLEaNTTh kp5sOKyUqeh2Wq/VZPfA22g46ykEWSJ5sdr8xpyHwHalE65NHYg93h3meB3NQrFnNLx57gz8tUO RkhfpgEgn5WzNHxp74+drx+6WIfQ8f+BdNtrHF0= X-Received: by 2002:a05:6000:2083:b0:3ea:fb3d:c4cb with SMTP id ffacd0b85a97d-425671c5e49mr7574436f8f.56.1759691825000; Sun, 05 Oct 2025 12:17:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEc/un9kSCmaLjU7k6r7VuKi/l5IaSlZol5DIlwtNnVTC1dFbukWODQkQbUykX9nxfuQAfH3A== X-Received: by 2002:a05:6000:2083:b0:3ea:fb3d:c4cb with SMTP id ffacd0b85a97d-425671c5e49mr7574404f8f.56.1759691824369; Sun, 05 Oct 2025 12:17:04 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Shiju Jose , Igor Mammedov , Markus Armbruster , Ani Sinha , Paolo Bonzini , Dongjiu Geng , Shannon Zhao , Eric Blake , Michael Roth , qemu-arm@nongnu.org Subject: [PULL 27/75] qapi/acpi-hest: add an interface to do generic CPER error injection 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692138876116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab Create a QMP command to be used for generic ACPI APEI hardware error injection (HEST) via GHESv2, and add support for it for ARM guests. Error injection uses ACPI_HEST_SRC_ID_QMP source ID to be platform independent. This is mapped at arch virt bindings, depending on the types supported by QEMU and by the BIOS. So, on ARM, this is supported via ACPI_GHES_NOTIFY_GPIO notification type. This patch was co-authored: - original ghes logic to inject a simple ARM record by Shiju Jose; - generic logic to handle block addresses by Jonathan Cameron; - generic GHESv2 error inject by Mauro Carvalho Chehab; Co-authored-by: Jonathan Cameron Co-authored-by: Shiju Jose Co-authored-by: Mauro Carvalho Chehab Signed-off-by: Jonathan Cameron Signed-off-by: Shiju Jose Signed-off-by: Mauro Carvalho Chehab Acked-by: Igor Mammedov Acked-by: Markus Armbruster Reviewed-by: Michael S. Tsirkin Message-ID: <81e2118b3c8b7e5da341817f277d61251655e0db.1758610789.git.mcheha= b+huawei@kernel.org> Signed-off-by: Michael S. Tsirkin --- qapi/acpi-hest.json | 36 ++++++++++++++++++++++++++++++++++++ qapi/qapi-schema.json | 1 + include/hw/acpi/ghes.h | 1 + include/hw/arm/virt.h | 1 + hw/acpi/ghes.c | 2 +- hw/acpi/ghes_cper.c | 40 ++++++++++++++++++++++++++++++++++++++++ hw/acpi/ghes_cper_stub.c | 20 ++++++++++++++++++++ hw/arm/virt-acpi-build.c | 1 + hw/arm/virt.c | 7 +++++++ MAINTAINERS | 7 +++++++ hw/acpi/Kconfig | 5 +++++ hw/acpi/meson.build | 2 ++ qapi/meson.build | 1 + 13 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 qapi/acpi-hest.json create mode 100644 hw/acpi/ghes_cper.c create mode 100644 hw/acpi/ghes_cper_stub.c diff --git a/qapi/acpi-hest.json b/qapi/acpi-hest.json new file mode 100644 index 0000000000..28af1266a7 --- /dev/null +++ b/qapi/acpi-hest.json @@ -0,0 +1,36 @@ +# -*- Mode: Python -*- +# vim: filetype=3Dpython +# SPDX-License-Identifier: GPL-2.0-or-later + +## +# =3D=3D GHESv2 CPER Error Injection +# +# Defined since ACPI Specification 6.1, +# section 18.3.2.8 Generic Hardware Error Source version 2. See: +# +# https://uefi.org/sites/default/files/resources/ACPI_6_1.pdf +## + + +## +# @inject-ghes-v2-error: +# +# Inject an error with additional ACPI 6.1 GHESv2 error information +# +# @cper: contains a base64 encoded string with raw data for a single +# CPER record with Generic Error Status Block, Generic Error Data +# Entry and generic error data payload, as described at +# https://uefi.org/specs/UEFI/2.10/Apx_N_Common_Platform_Error_Record.= html#format +# +# Features: +# +# @unstable: This command is experimental. +# +# Since: 10.2 +## +{ 'command': 'inject-ghes-v2-error', + 'data': { + 'cper': 'str' + }, + 'features': [ 'unstable' ] +} diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index 82f111ba06..b93dd68d94 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -68,6 +68,7 @@ { 'include': 'misc-i386.json' } { 'include': 'audio.json' } { 'include': 'acpi.json' } +{ 'include': 'acpi-hest.json' } { 'include': 'pci.json' } { 'include': 'stats.json' } { 'include': 'virtio.json' } diff --git a/include/hw/acpi/ghes.h b/include/hw/acpi/ghes.h index 390943e46d..df2ecbf6e4 100644 --- a/include/hw/acpi/ghes.h +++ b/include/hw/acpi/ghes.h @@ -65,6 +65,7 @@ enum AcpiGhesNotifyType { */ enum AcpiGhesSourceID { ACPI_HEST_SRC_ID_SYNC, + ACPI_HEST_SRC_ID_QMP, /* Use it only for QMP injected errors */ }; =20 typedef struct AcpiNotificationSourceId { diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index e14ea0f9d4..04a09af354 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -33,6 +33,7 @@ #include "exec/hwaddr.h" #include "qemu/notify.h" #include "hw/boards.h" +#include "hw/acpi/ghes.h" #include "hw/arm/boot.h" #include "hw/arm/bsa.h" #include "hw/block/flash.h" diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c index d666f1b10b..06555905ce 100644 --- a/hw/acpi/ghes.c +++ b/hw/acpi/ghes.c @@ -553,7 +553,7 @@ void ghes_record_cper_errors(AcpiGhesState *ags, const = void *cper, size_t len, /* Write the generic error data entry into guest memory */ cpu_physical_memory_write(cper_addr, cper, len); =20 - notifier_list_notify(&acpi_generic_error_notifiers, NULL); + notifier_list_notify(&acpi_generic_error_notifiers, &source_id); } =20 int acpi_ghes_memory_errors(AcpiGhesState *ags, uint16_t source_id, diff --git a/hw/acpi/ghes_cper.c b/hw/acpi/ghes_cper.c new file mode 100644 index 0000000000..31cb2ffabe --- /dev/null +++ b/hw/acpi/ghes_cper.c @@ -0,0 +1,40 @@ +/* + * CPER payload parser for error injection + * + * Copyright(C) 2024-2025 Huawei LTD. + * + * This code is licensed under the GPL version 2 or later. See the + * COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" + +#include "qemu/base64.h" +#include "qemu/error-report.h" +#include "qemu/uuid.h" +#include "qapi/qapi-commands-acpi-hest.h" +#include "hw/acpi/ghes.h" + +void qmp_inject_ghes_v2_error(const char *qmp_cper, Error **errp) +{ + AcpiGhesState *ags; + uint8_t *cper; + size_t len; + + ags =3D acpi_ghes_get_state(); + if (!ags) { + return; + } + + cper =3D qbase64_decode(qmp_cper, -1, &len, errp); + if (!cper) { + error_setg(errp, "missing GHES CPER payload"); + return; + } + + ghes_record_cper_errors(ags, cper, len, ACPI_HEST_SRC_ID_QMP, errp); + + g_free(cper); +} diff --git a/hw/acpi/ghes_cper_stub.c b/hw/acpi/ghes_cper_stub.c new file mode 100644 index 0000000000..b16be73502 --- /dev/null +++ b/hw/acpi/ghes_cper_stub.c @@ -0,0 +1,20 @@ +/* + * Stub interface for CPER payload parser for error injection + * + * Copyright(C) 2024-2025 Huawei LTD. + * + * This code is licensed under the GPL version 2 or later. See the + * COPYING file in the top-level directory. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-acpi-hest.h" +#include "hw/acpi/ghes.h" + +void qmp_inject_ghes_v2_error(const char *cper, Error **errp) +{ + error_setg(errp, "GHES QMP error inject is not compiled in"); +} diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 2b63008df0..8bb6b60515 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -1128,6 +1128,7 @@ static void acpi_align_size(GArray *blob, unsigned al= ign) =20 static const AcpiNotificationSourceId hest_ghes_notify[] =3D { { ACPI_HEST_SRC_ID_SYNC, ACPI_GHES_NOTIFY_SEA }, + { ACPI_HEST_SRC_ID_QMP, ACPI_GHES_NOTIFY_GPIO }, }; =20 static const AcpiNotificationSourceId hest_ghes_notify_10_0[] =3D { diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 6960f6113f..aad557be1a 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1052,6 +1052,13 @@ static void virt_powerdown_req(Notifier *n, void *op= aque) =20 static void virt_generic_error_req(Notifier *n, void *opaque) { + uint16_t *source_id =3D opaque; + + /* Currently, only QMP source ID is async */ + if (*source_id !=3D ACPI_HEST_SRC_ID_QMP) { + return; + } + VirtMachineState *s =3D container_of(n, VirtMachineState, generic_erro= r_notifier); =20 acpi_send_event(s->acpi_dev, ACPI_GENERIC_ERROR); diff --git a/MAINTAINERS b/MAINTAINERS index 406cef88f0..b31ae5193d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2173,6 +2173,13 @@ F: hw/acpi/ghes.c F: include/hw/acpi/ghes.h F: docs/specs/acpi_hest_ghes.rst =20 +ACPI/HEST/GHES/ARM processor CPER +R: Mauro Carvalho Chehab +S: Maintained +F: hw/arm/ghes_cper.c +F: hw/acpi/ghes_cper_stub.c +F: qapi/acpi-hest.json + ppc4xx L: qemu-ppc@nongnu.org S: Orphan diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index 1d4e9f0845..daabbe6cd1 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -51,6 +51,11 @@ config ACPI_APEI bool depends on ACPI =20 +config GHES_CPER + bool + depends on ACPI_APEI + default y + config ACPI_PCI bool depends on ACPI && PCI diff --git a/hw/acpi/meson.build b/hw/acpi/meson.build index 73f02b9691..56b5d1ec96 100644 --- a/hw/acpi/meson.build +++ b/hw/acpi/meson.build @@ -34,4 +34,6 @@ endif system_ss.add(when: 'CONFIG_ACPI', if_false: files('acpi-stub.c', 'aml-bui= ld-stub.c', 'ghes-stub.c', 'acpi_interface.c')) system_ss.add(when: 'CONFIG_ACPI_PCI_BRIDGE', if_false: files('pci-bridge-= stub.c')) system_ss.add_all(when: 'CONFIG_ACPI', if_true: acpi_ss) +system_ss.add(when: 'CONFIG_GHES_CPER', if_true: files('ghes_cper.c')) +system_ss.add(when: 'CONFIG_GHES_CPER', if_false: files('ghes_cper_stub.c'= )) system_ss.add(files('acpi-qmp-cmds.c')) diff --git a/qapi/meson.build b/qapi/meson.build index ca6b61a608..a46269b5a0 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -59,6 +59,7 @@ if have_system qapi_all_modules +=3D [ 'accelerator', 'acpi', + 'acpi-hest', 'audio', 'cryptodev', 'qdev', --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692444; cv=none; d=zohomail.com; s=zohoarc; b=NcoP3F91i8Kj5qWMWLL5gXHOsMhIZsckVAn9TuPWfn+rncfSLnboXhbUJjh2NQZ+sLqAIk/htmYdyHVtAEFB4DSWXLxY2xrojFuzwuXpm3fJYFhBe9zxQ0n2HVbwIWNBQdZbWbbTbbjEKaG6HI+7CvIZbYCb6Na9rZUCgdOgmy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692444; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0Ap/LxYRjTXw/E9jnwsKOS4crdgiKccCt++rQMqKO54=; b=DViNjkkcaKLlq5T7M49kc0MvNkWWZBeymuGH74GPGkkkcK2eH2xPO/vBuc2SPr2zwdwrS6SqwO6zXy799NJG40GPpFyQj44ud8mcO0gIRrBP6hUi9+jtHaoyB2e/z9F4DvroyUTvvrsYvxlOlRR7IGQ0oGIfK9MZFQWIGq9Z1Ug= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692443824338.15410778754506; Sun, 5 Oct 2025 12:27:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UEg-0008Gd-8L; Sun, 05 Oct 2025 15:17: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 1v5UEK-0007lx-HO for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEI-0006TL-AT for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:12 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-49-1H68GBitMTOV-suT9xqdSA-1; Sun, 05 Oct 2025 15:17:08 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e3ed6540fso22342855e9.0 for ; Sun, 05 Oct 2025 12:17:08 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8abe90sm17389924f8f.23.2025.10.05.12.17.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691829; 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=0Ap/LxYRjTXw/E9jnwsKOS4crdgiKccCt++rQMqKO54=; b=R63KbwppCvf21kPMxmGJAk27fzM10n06qsfyJzZta3EluiVvJ26SQCU+/THJwF8DYEZnnc cuRPWYJRq7h9GKZzwPz0zrZlGkLRiNj1zELRz+AWnb1545oQ+2tb5j8Ho2N3+WQkkfRcVD dMgxGIJ1Geigm4MP0QKwdzq99m9WzTM= X-MC-Unique: 1H68GBitMTOV-suT9xqdSA-1 X-Mimecast-MFC-AGG-ID: 1H68GBitMTOV-suT9xqdSA_1759691827 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691827; x=1760296627; 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=0Ap/LxYRjTXw/E9jnwsKOS4crdgiKccCt++rQMqKO54=; b=NaJYnk2vToFBCPhgFTn8pevUExPL4dXYcG4/BCatPlYRN7d3edtnZnh+Kqqrwlri9N 5M9cLKIhPncvznSI5USyCjXukaEdJEVKr6qlLvNwJnP1q0UBkUqjm4OuWg0V2ZO+Ohgf 31gH21E6lTQ81UE7ahflBvVxTMQb7jfrcvk555NvYHf6dnsPDHgeCU0jj8R3IVGmCWQ3 tn/kb6Jq/+PAbRpJkXJn0fabDOMEPchISIjtmmzFrb/ZZwBEEip5iwjfeW2pOuILrey8 UluNZWHsdAi3cPlmzVpZZ88V/ueiH+5bV8ulcFS6L01Qkq7+UfYo8xknqhUWMjYFvuzQ gz5Q== X-Gm-Message-State: AOJu0Yzd5SJaNE5YMsm7p0PQL9mU/SRPvHj3F/b41dkyjkS0m09OEOuC t1dM3dP6gGZRtU4uiMgEIHNBC2fp+mhM81V5VDk+zSg4yvO1+1CQPli3fCPshptNpbTUn44Me7n 7c5U/Q2J9HqRqEql0lyhJQWnV5EmLK6KZuXiEap2lmA9F1Zig4HzVDbufSQpkqDiqgJxoRCLRLn 30xe1W4R03RAo3z9RGQ9IKodamUSlkqW8mkg== X-Gm-Gg: ASbGncsoooTjZ54AZ0gO+Hwd5WLkd9a+fq1sWDxRdXcQnORvqXocos4f8UjqMx7PNRp ZI/GQmtwAiVOjs6OPHpXHhjbfSnsboTMKnYC3cH0IrlgzbhhVTLlbrY5fjYPqyHs2MqI+Bc/Hdx ruizak/ag0zzN08MUIx+sTDd8g9AVdQ7M5uua59M+J87JukisoWfIWa68hNjMMNRoem7j6wpLVe H1i5PpenD/xFoPQM46FBecCz/U+mHDUhCYG9TrA3IzbT0c4+tK+Jn9LHcN6lSlxdE5cXO7vjXDL A3ENLYsBE7gJq0an/ERC9rpJDTgbOhgJMUcvx0Y= X-Received: by 2002:a05:600c:4688:b0:458:b8b0:6338 with SMTP id 5b1f17b1804b1-46e70c5c8b0mr83985095e9.6.1759691826790; Sun, 05 Oct 2025 12:17:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0gQ3dn4NTitApkZbmpXZqvahU3vql06deKIwIzNnOW1wUTcKaTq3B9kPyG8gMkbQXaZnV2g== X-Received: by 2002:a05:600c:4688:b0:458:b8b0:6338 with SMTP id 5b1f17b1804b1-46e70c5c8b0mr83984895e9.6.1759691826377; Sun, 05 Oct 2025 12:17:06 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:04 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Igor Mammedov , Ani Sinha Subject: [PULL 28/75] acpi/generic_event_device.c: enable use_hest_addr for QEMU 10.x 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692447046116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab Now that we have everything in place, enable using HEST GPA instead of etc/hardware_errors GPA. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- hw/acpi/generic_event_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index e575b9404b..e7b773d84d 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -363,7 +363,7 @@ static const Property acpi_ged_properties[] =3D { DEFINE_PROP_LINK("bus", AcpiGedState, pcihp_state.root, TYPE_PCI_BUS, PCIBus *), DEFINE_PROP_BOOL("x-has-hest-addr", AcpiGedState, - ghes_state.use_hest_addr, false), + ghes_state.use_hest_addr, true), }; =20 static const VMStateDescription vmstate_memhp_state =3D { --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692449; cv=none; d=zohomail.com; s=zohoarc; b=naVimKsfWber0tec4i4sjfcvzZUrZRRB7XQMMyo6qqOQEBzJt/vfvOceWSdq2lFGe0Y+NMzq5+kDYUyfBfInnyHmS2RHAYz2c5vG3d7h9+WXKwU1Dewg0RvtUc1OL1F/p3BwlUc/5dDO4JIe/w7CHJOUB1uidi/E4JU8Crno/Ew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692449; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MCh7a2KtkUaaSGsInrqfUkf7JBaKZj7e2ekOGZtPcVA=; b=IcFBFleAVGWjVJJP5B3H+Y5On0Bm4N59/souqQ2a5E0cyDzPWHRnA3wOwlE4e3bIaYKg+kdlmJGSdFVscmZ+HL3I46GvOCt46ZTEfvcvhhYJo/cd6o9pDtUng7E5qB5eZ1QkDYsTZzvMQWWeSkMrhZVDnMYi3SNEBJE5ZZfGEFM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692449522818.9870856440104; Sun, 5 Oct 2025 12:27:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFd-0003NW-IJ; Sun, 05 Oct 2025 15:18:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEP-0007y0-Hq for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEK-0006Ti-PX for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:15 -0400 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-542-cD2Ro_DNO3mFYSEHTLXeaQ-1; Sun, 05 Oct 2025 15:17:10 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3ed9557f976so2674242f8f.3 for ; Sun, 05 Oct 2025 12:17:10 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8e9780sm17257442f8f.29.2025.10.05.12.17.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691832; 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=MCh7a2KtkUaaSGsInrqfUkf7JBaKZj7e2ekOGZtPcVA=; b=K53j4IFaspCg8JIIn7js9K+hWxs5X0ytzXNxh5UOqwc28V9ic4p5CjleQzFCUjjyXhPXSZ iw55+Ez8R3QgZbRySexD67JxXUl1k9L35KsrsugsI9HnP+yosHcjZoXq71V9yz/4sT5OVP 7w2QfTucPglRaiQZuBzxgLZh6/l4plg= X-MC-Unique: cD2Ro_DNO3mFYSEHTLXeaQ-1 X-Mimecast-MFC-AGG-ID: cD2Ro_DNO3mFYSEHTLXeaQ_1759691829 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691829; x=1760296629; 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=MCh7a2KtkUaaSGsInrqfUkf7JBaKZj7e2ekOGZtPcVA=; b=Ag/KpG2WBS+Gugm5vyN9yn2Je8wmEXLDCIvUf/0nmdNdsgFX1zzqTKJhkizucukeLe pxPfcghfaDaS72TfDiylJusTGoQ1NJXnUx6FbpvvZKj8Wkaxsk8sXkmBccr0bkq6ax/Y 7vKu6dYkanH+XNgUH+nc5Vh5amj3UOKDWRG6WvHn24v/jQ/yhi+TMwSHAuZ0g794bCOo rTpR7rf8sOHB6n2TYpqrGT3NhxGmmBQBk5RyTXTiIAtuqw17smMHXetPWF+mb49/7Yrg kumeiYGcSF8o+NE/HS7s6VuUwJl0HnN3p1mmLK/IhXyF2IWRKQioTXdMO+hKiSoQrQI7 CsIw== X-Gm-Message-State: AOJu0Yxads8pXqajyT1CLDBnG3wPO2mvn+aNZVRa4U/IPbcu5sJprMan cUaN5AM9uk1+Xwg10/RncxDMLtqF6p2rXIX5VuXltfioVYzaRpz3e9g7vVYbEnjV5wsccv7cE1O trU3GRVKkhC8a80j9BoBQDD/hofFoOuxRPTpokvoLe9nq6xBo30yyLdQcqPDUEhunQoaPyeYInU 8b3OVDQMM0xPU7+8azvGDWcWyt4/0jDPeFDg== X-Gm-Gg: ASbGncuHsmDUgGTQELBMMNNemr5+b3GMYee5T2BJN32OAeUbAJLUSDQdKgKxrTFi8cV 3tVzDs88ndUo3BxWFpgU8EBEQ2lyy2IynzFMTBY5ZKa8TwCcLqGAjOUOs1xGz3KZnCZvn5h1AgC 2+5Mwrcwqr5eaq6cYELJ3C2rQsDgBpo7NqXPM/OncKKqPmXMdUilM/ti9ut/xzXkdltWw6Ed6YB Bb862BmcUhe+M0RNYZ0jED80iFkt3VSQlw53FsD37cg9l5+FCF1Jo5Kgf5WnnQ6uhL92C654dx/ 3rn152F1/LVOi7TD/yER1PplBrbBBOqlGzioi2M= X-Received: by 2002:a05:6000:2910:b0:3ee:1118:df7d with SMTP id ffacd0b85a97d-425671c0c93mr6123612f8f.47.1759691828921; Sun, 05 Oct 2025 12:17:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmvAo0c00EdoK7uv/IYZud2I4A7bP4NWzWFLBlJlbr3yWAXE9XXIpsdk13hA4iN6S7JDG+Nw== X-Received: by 2002:a05:6000:2910:b0:3ee:1118:df7d with SMTP id ffacd0b85a97d-425671c0c93mr6123596f8f.47.1759691828309; Sun, 05 Oct 2025 12:17:08 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:06 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Igor Mammedov , Ani Sinha Subject: [PULL 29/75] tests/acpi: virt: update HEST and DSDT tables Message-ID: <237ca3d57898e4438bc3af6cd87f0a3279198bae.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692455310116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab The following changes for DSDT affecting all files under tests/data/acpi/aarch64/virt/DSDT* : -"tests/data/acpi/aarch64/virt/DSDT", -"tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt", -"tests/data/acpi/aarch64/virt/DSDT.acpipcihp", -"tests/data/acpi/aarch64/virt/DSDT.hpoffacpiindex", -"tests/data/acpi/aarch64/virt/DSDT.memhp", -"tests/data/acpi/aarch64/virt/DSDT.pxb", -"tests/data/acpi/aarch64/virt/DSDT.topology", -"tests/data/acpi/aarch64/virt/DSDT.viot", -"tests/data/acpi/aarch64/virt/DSDT.smmuv3-dev", -"tests/data/acpi/aarch64/virt/DSDT.smmuv3-legacy", --- /tmp/DSDT_old.dsl 2025-09-05 15:03:18.964968499 +0200 +++ /tmp/DSDT.dsl 2025-09-05 15:03:18.966968470 +0200 @@ -1886,6 +1886,11 @@ { Notify (PWRB, 0x80) // Status Change } + + If (((Local0 & 0x20) =3D=3D 0x20)) + { + Notify (GEDD, 0x80) // Status Change + } } } @@ -1894,6 +1899,12 @@ Name (_HID, "PNP0C0C" /* Power Button Device */) // _HID:= Hardware ID Name (_UID, Zero) // _UID: Unique ID } + + Device (GEDD) + { + Name (_HID, "PNP0C33" /* Error Device */) // _HID: Hardwa= re ID + Name (_UID, Zero) // _UID: Unique ID + } } Scope (\_SB.PCI0) Additionally, HEST changes: -"tests/data/acpi/aarch64/virt/HEST", --- /tmp/HEST_old.dsl 2025-09-05 15:03:19.078653625 +0200 +++ /tmp/HEST.dsl 2025-09-05 15:03:19.079511472 +0200 @@ -3,7 +3,7 @@ * AML/ASL+ Disassembler version 20240322 (64-bit version) * Copyright (c) 2000 - 2023 Intel Corporation * - * Disassembly of /tmp/HEST_old + * Disassembly of /tmp/HEST * * ACPI Data Table [HEST] * @@ -11,16 +11,16 @@ */ [000h 0000 004h] Signature : "HEST" [Hardware Err= or Source Table] -[004h 0004 004h] Table Length : 00000084 +[004h 0004 004h] Table Length : 000000E0 [008h 0008 001h] Revision : 01 -[009h 0009 001h] Checksum : E2 +[009h 0009 001h] Checksum : 6C [00Ah 0010 006h] Oem ID : "BOCHS " [010h 0016 008h] Oem Table ID : "BXPC " [018h 0024 004h] Oem Revision : 00000001 [01Ch 0028 004h] Asl Compiler ID : "BXPC" [020h 0032 004h] Asl Compiler Revision : 00000001 -[024h 0036 004h] Error Source Count : 00000001 +[024h 0036 004h] Error Source Count : 00000002 [028h 0040 002h] Subtable Type : 000A [Generic Hardware = Error Source V2] [02Ah 0042 002h] Source Id : 0000 @@ -55,19 +55,62 @@ [069h 0105 001h] Bit Width : 40 [06Ah 0106 001h] Bit Offset : 00 [06Bh 0107 001h] Encoded Access Width : 04 [QWord Access:64] -[06Ch 0108 008h] Address : 0000000043DA0008 +[06Ch 0108 008h] Address : 0000000043DA0010 [074h 0116 008h] Read Ack Preserve : FFFFFFFFFFFFFFFE [07Ch 0124 008h] Read Ack Write : 0000000000000001 -Raw Table Data: Length 132 (0x84) +[084h 0132 002h] Subtable Type : 000A [Generic Hardware = Error Source V2] +[086h 0134 002h] Source Id : 0001 +[088h 0136 002h] Related Source Id : FFFF +[08Ah 0138 001h] Reserved : 00 +[08Bh 0139 001h] Enabled : 01 +[08Ch 0140 004h] Records To Preallocate : 00000001 +[090h 0144 004h] Max Sections Per Record : 00000001 +[094h 0148 004h] Max Raw Data Length : 00000400 + +[098h 0152 00Ch] Error Status Address : [Generic Address Struct= ure] +[098h 0152 001h] Space ID : 00 [SystemMemory] +[099h 0153 001h] Bit Width : 40 +[09Ah 0154 001h] Bit Offset : 00 +[09Bh 0155 001h] Encoded Access Width : 04 [QWord Access:64] +[09Ch 0156 008h] Address : 0000000043DA0008 + +[0A4h 0164 01Ch] Notify : [Hardware Error Notific= ation Structure] +[0A4h 0164 001h] Notify Type : 07 [GPIO] +[0A5h 0165 001h] Notify Length : 1C +[0A6h 0166 002h] Configuration Write Enable : 0000 +[0A8h 0168 004h] PollInterval : 00000000 +[0ACh 0172 004h] Vector : 00000000 +[0B0h 0176 004h] Polling Threshold Value : 00000000 +[0B4h 0180 004h] Polling Threshold Window : 00000000 +[0B8h 0184 004h] Error Threshold Value : 00000000 +[0BCh 0188 004h] Error Threshold Window : 00000000 + +[0C0h 0192 004h] Error Status Block Length : 00000400 +[0C4h 0196 00Ch] Read Ack Register : [Generic Address Struct= ure] +[0C4h 0196 001h] Space ID : 00 [SystemMemory] +[0C5h 0197 001h] Bit Width : 40 +[0C6h 0198 001h] Bit Offset : 00 +[0C7h 0199 001h] Encoded Access Width : 04 [QWord Access:64] +[0C8h 0200 008h] Address : 0000000043DA0018 - 0000: 48 45 53 54 84 00 00 00 01 E2 42 4F 43 48 53 20 // HEST....= ..BOCHS +[0D0h 0208 008h] Read Ack Preserve : FFFFFFFFFFFFFFFE +[0D8h 0216 008h] Read Ack Write : 0000000000000001 + +Raw Table Data: Length 224 (0xE0) + + 0000: 48 45 53 54 E0 00 00 00 01 6C 42 4F 43 48 53 20 // HEST....= .lBOCHS 0010: 42 58 50 43 20 20 20 20 01 00 00 00 42 58 50 43 // BXPC = ....BXPC - 0020: 01 00 00 00 01 00 00 00 0A 00 00 00 FF FF 00 01 // ........= ........ + 0020: 01 00 00 00 02 00 00 00 0A 00 00 00 FF FF 00 01 // ........= ........ 0030: 01 00 00 00 01 00 00 00 00 04 00 00 00 40 00 04 // ........= .....@.. 0040: 00 00 DA 43 00 00 00 00 08 1C 00 00 00 00 00 00 // ...C....= ........ 0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ........= ........ - 0060: 00 00 00 00 00 04 00 00 00 40 00 04 08 00 DA 43 // ........= .@.....C + 0060: 00 00 00 00 00 04 00 00 00 40 00 04 10 00 DA 43 // ........= .@.....C 0070: 00 00 00 00 FE FF FF FF FF FF FF FF 01 00 00 00 // ........= ........ - 0080: 00 00 00 00 // .... + 0080: 00 00 00 00 0A 00 01 00 FF FF 00 01 01 00 00 00 // ........= ........ + 0090: 01 00 00 00 00 04 00 00 00 40 00 04 08 00 DA 43 // ........= .@.....C + 00A0: 00 00 00 00 07 1C 00 00 00 00 00 00 00 00 00 00 // ........= ........ + 00B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // ........= ........ + 00C0: 00 04 00 00 00 40 00 04 18 00 DA 43 00 00 00 00 // .....@..= ...C.... + 00D0: FE FF FF FF FF FF FF FF 01 00 00 00 00 00 00 00 // ........= ........ Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Acked-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-ID: <2253eb50df797ab320b4ca610bd22a38e5cfd17a.1758610789.git.mcheha= b+huawei@kernel.org> Signed-off-by: Michael S. Tsirkin --- tests/qtest/bios-tables-test-allowed-diff.h | 11 ----------- tests/data/acpi/aarch64/virt/DSDT | Bin 5293 -> 5337 bytes .../data/acpi/aarch64/virt/DSDT.acpihmatvirt | Bin 5379 -> 5423 bytes tests/data/acpi/aarch64/virt/DSDT.acpipcihp | Bin 6202 -> 6246 bytes .../acpi/aarch64/virt/DSDT.hpoffacpiindex | Bin 5347 -> 5391 bytes tests/data/acpi/aarch64/virt/DSDT.memhp | Bin 6654 -> 6698 bytes tests/data/acpi/aarch64/virt/DSDT.pxb | Bin 7768 -> 7812 bytes tests/data/acpi/aarch64/virt/DSDT.smmuv3-dev | Bin 10230 -> 10274 bytes .../data/acpi/aarch64/virt/DSDT.smmuv3-legacy | Bin 10230 -> 10274 bytes tests/data/acpi/aarch64/virt/DSDT.topology | Bin 5495 -> 5539 bytes tests/data/acpi/aarch64/virt/DSDT.viot | Bin 5310 -> 5354 bytes tests/data/acpi/aarch64/virt/HEST | Bin 132 -> 224 bytes 12 files changed, 11 deletions(-) diff --git a/tests/qtest/bios-tables-test-allowed-diff.h b/tests/qtest/bios= -tables-test-allowed-diff.h index cb4b0a9469..dfb8523c8b 100644 --- a/tests/qtest/bios-tables-test-allowed-diff.h +++ b/tests/qtest/bios-tables-test-allowed-diff.h @@ -1,12 +1 @@ /* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/aarch64/virt/HEST", -"tests/data/acpi/aarch64/virt/DSDT", -"tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt", -"tests/data/acpi/aarch64/virt/DSDT.acpipcihp", -"tests/data/acpi/aarch64/virt/DSDT.hpoffacpiindex", -"tests/data/acpi/aarch64/virt/DSDT.memhp", -"tests/data/acpi/aarch64/virt/DSDT.pxb", -"tests/data/acpi/aarch64/virt/DSDT.topology", -"tests/data/acpi/aarch64/virt/DSDT.viot", -"tests/data/acpi/aarch64/virt/DSDT.smmuv3-dev", -"tests/data/acpi/aarch64/virt/DSDT.smmuv3-legacy", diff --git a/tests/data/acpi/aarch64/virt/DSDT b/tests/data/acpi/aarch64/vi= rt/DSDT index 18d97e8f22979411a528705c0e314acb424bbfa5..38f01adb61e6e4704821cee5e39= 7888bb6b7e46d 100644 GIT binary patch delta 83 zcmZ3hc~g_iCD96aWAK delta 68 zcmZ3l)vU$k66_MfEXu&Zv}_`mG*i3lM)ecIOit{RKMDs+%f`Egg>V+Q2D|zsED)Gn YoxsJ!z{S)S5FX?-xj;mA@(Pi50D|okbpQYW diff --git a/tests/data/acpi/aarch64/virt/DSDT.acpipcihp b/tests/data/acpi/= aarch64/virt/DSDT.acpipcihp index 8d55a877a40cb4c4dffdc70378204e12d2261a75..04427e2d8eb8d2db0a7ae3dbe54= 6d9072406d09b 100644 GIT binary patch delta 87 zcmdmG@XUbACDGDJ_X{NsE8`X=3D1nVh&M&lV15@@1X;LD-9bfxzVI1TF;z nE`>ICR~MJf79#enBGFBfAPz^oho=3Di~fM0-tv$65y0?9rA9#a?T delta 48 zcmZ2w^3RydCDt4B11*BneW3BxP(od5!EE06qd8 AQ~&?~ delta 46 zcmZp%y{0+f CX%1!p diff --git a/tests/data/acpi/aarch64/virt/DSDT.smmuv3-dev b/tests/data/acpi= /aarch64/virt/DSDT.smmuv3-dev index 53d4c07f423886d8c4b57f1da6498eef5a08b556..e8c2b376df7bddc2392945ea8cb= b550b3d3b5e26 100644 GIT binary patch delta 107 zcmez7zbJsqCDP_ZUmvLAiFu6K`OM!t) zq0QaZ#f7UOx=3DAu1JjjV7-ow*{H^48zz}di=3Dfg?WD(}f|rNfM+6Ny^xGvZeZ707Eq# A^#A|> delta 63 zcmZ1!@XepgCDqsn(}Rgz(oEfj8`XQ%n4H)rZ&eFsl%33}E+Z1%BpDDMP_ZUmvLAiFu6K`OM!t) zq0QaZ#f7UOx=3DAu1JjjV7-ow*{H^48zz}di=3Dfg?WD(}f|rNfM+6Ny^xGvZeZ707Eq# A^#A|> delta 63 zcmZ1!@XepgCDqsn(}Rgz(oEfj8`XQ%n4H)rZ&eFsl%33}E+Z1%BpDDMP_A$BIB??U~+W=3DmjVNq zLYup*iwjpnbdzL2c#soEyoaX?Z-8HbfwO@#14n$Qrwc=3DLlO#wDl9aLWHI`4X{K(Ujp{ZcOit{RQ$>OqWhd_xkr9b*k_-qBa^i^h T@O0q~@Cz_-HgKLSD%uACG~E#{ diff --git a/tests/data/acpi/aarch64/virt/DSDT.viot b/tests/data/acpi/aarch= 64/virt/DSDT.viot index b897d667971500da4732000091a6f0828d05d89e..dd3775a0762ae1a5ddb89dd656d= 81eee581dccb6 100644 GIT binary patch delta 83 zcmdm|`AU<^CDP>zxEW^J*U~+W=3DmjVNq lLYup*i_2tA5m}MwCP@&RBi_T)g*U)2z`)tqc(T06d;r-X7McJ6 delta 46 zcmaE*xlfbJCDEGJ@nLCJHmL%S;Ru WnV7)J#lXPAz`)?Zz#=3Dg*R~!HcF%5eF delta 29 lcmaFB*uu!=3D;Tjy$!oa}5_-G=3DR6eHtARriT=3DI3|_|004Ge2nqlI --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692404; cv=none; d=zohomail.com; s=zohoarc; b=BQijiB01RsxoIFZELm0rZIniv/LzAyKwn50I/2DBllwUpyKZ8lRaetSuj8J26O2nQTSchxjzoeKDgYsHff07+GfFeYpF5aIC1LfJbhWRdGpbfxYwmKjpON2osW1QAN9cVMeRm31Be8PdyefqKvNWUWb22oDaCW/YCflfKG/tuzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692404; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WnDfxrNxACMbmdDqRpMpScz5AxDAbZ6usd6ALPkfGkQ=; b=RkcHEdTmwMW5rbeHcEiqCdsDlC2PIg5RSG3khrrD+rbItgHmwbS9HYSY4+y6UAYe1Lgb0mNKLh3oC3gC05nrHO5ZIKFyT+9j+it+0OTlR+ua+FAb+M1LtVckco9Yn1mBDvy1N/al10+loxVYIztUIvb5kAFkpbJYAM6R70dsTRQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692404633454.2056305311969; Sun, 5 Oct 2025 12:26:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFK-00022y-5Z; Sun, 05 Oct 2025 15:18:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UER-0007yQ-5P for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:24 -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 1v5UEN-0006Tx-2t for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:17 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-462-YFcK4520NjWG-K9V2jcfJA-1; Sun, 05 Oct 2025 15:17:12 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3f030846a41so2461279f8f.2 for ; Sun, 05 Oct 2025 12:17:12 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e723432c9sm124149855e9.1.2025.10.05.12.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691834; 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=WnDfxrNxACMbmdDqRpMpScz5AxDAbZ6usd6ALPkfGkQ=; b=NgOBKs/9oPJTZrYba9p+Zx2fMkkxebwwge/Ic1+Z0zyHSMNjRqUFbLYRzYJiSfe+CKVTWi LF8Igyq+CCNgRa3YNLdBmRu+VivjQ66U7h9ebhqZ5Y1cJ2ec0FSW4BTXF795vUSSEvZErb PSp/SmA6X4uH3Yad3OSllbqqRWxpIU0= X-MC-Unique: YFcK4520NjWG-K9V2jcfJA-1 X-Mimecast-MFC-AGG-ID: YFcK4520NjWG-K9V2jcfJA_1759691831 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691831; x=1760296631; 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=WnDfxrNxACMbmdDqRpMpScz5AxDAbZ6usd6ALPkfGkQ=; b=j5rHl0SnJ8MFgi8ZHvTnmcmUGhiq5Q/nQZgHwnuf4NuEzjLjgP+sxSAaMyvhsmuDhR 4VcEKsyNqAhaVpbx5rsNMJ1Y9jt7cDQcf4ZSmR7ODCIMjM56hToZMsWLkA707daBuDxp obsNaobvzWcOJ5+paCF27VsIUF3Tki3groExx0HP445Z2GKfGqiEUaYjVWHZZ6xbFbJn FcdzPPVQgeizOHBdKi3drza2X2JOWoWiE3PrSs6euwf06FbOukTPAaPQimbzw17FDo/d 6UQVbhqa4UXAHiUZqpl68rpwGC3LAUnUWoncAs3Gx3C8QVobmoFtvkMar5gMsR6EO+4w LNYQ== X-Gm-Message-State: AOJu0YwNxC3QNUVJ/Xafx5s9X99cLy8h2SCeLVzi3bh6qwcuteh8B9P/ QYhdMCcj4kxCM63c7YQz6NAbWCNTjc+vXhjKbt026NhNxfFP0qO49r/2MDK0vjmHusFNMH5+SDZ aFwkHsI8QwzTOADKOTF+0kfaMcO1CNj8AISctyPnG7wf6r+Q6mgAJhAmJU8acAKp5A6ACrh7Kpi wOeVWinHWVCg5WckZUD+c4o3CgwzfRCPBg7A== X-Gm-Gg: ASbGnct1GqZAvkLPe68zfYApIFqaKKn4+3nse2QnBHXDUOzu9Xowa+VQuHfi0lFnMkd 4nBGiLuun9Iyieysh+RVV6ZlUl01rJeaoGTcp1AyAip6Nx4weA44+Jo3gvMYwxICvC4h389N72R sPE615bG6gBtTGrU9ccMLP2Jj8n/caUz03TlAmqD7X4lm6WdEBHsXU6QZ+vWS+M2RaxqEpmORBG lEWzWNylgZTkwoeNyxKR3ASYNrRzxITyhtxLjq1gMosiawMxO5CnUYytQ8GnFzwvUTcNLHkZKWj IPOUCXhL1F5MOfDDNmg+u+WQT7w78lKliRIQgxw= X-Received: by 2002:a05:600d:420d:b0:45b:47e1:ef6d with SMTP id 5b1f17b1804b1-46e71172104mr65548765e9.36.1759691830828; Sun, 05 Oct 2025 12:17:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9KHgQKdExKVBqM1EG7cJqjJT/Waixo/3fiECA9mcAeyF3g2gDVdnVPPHr8FrKC3uk1qB7Lw== X-Received: by 2002:a05:600d:420d:b0:45b:47e1:ef6d with SMTP id 5b1f17b1804b1-46e71172104mr65548595e9.36.1759691830274; Sun, 05 Oct 2025 12:17:10 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:08 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , Igor Mammedov , Dongjiu Geng , qemu-arm@nongnu.org Subject: [PULL 30/75] docs: hest: add new "etc/acpi_table_hest_addr" and update workflow Message-ID: <92aad3fc4a0f511819a18a443797069aff77b9ba.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692410545116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab While the HEST layout didn't change, there are some internal changes related to how offsets are calculated and how memory error events are triggered. Update specs to reflect such changes. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Message-ID: Signed-off-by: Michael S. Tsirkin --- docs/specs/acpi_hest_ghes.rst | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/docs/specs/acpi_hest_ghes.rst b/docs/specs/acpi_hest_ghes.rst index c3e9f8d9a7..aaf7b1ad11 100644 --- a/docs/specs/acpi_hest_ghes.rst +++ b/docs/specs/acpi_hest_ghes.rst @@ -89,12 +89,21 @@ Design Details addresses in the "error_block_address" fields with a pointer to the respective "Error Status Data Block" in the "etc/hardware_errors" blob. =20 -(8) QEMU defines a third and write-only fw_cfg blob which is called - "etc/hardware_errors_addr". Through that blob, the firmware can send b= ack - the guest-side allocation addresses to QEMU. The "etc/hardware_errors_= addr" - blob contains a 8-byte entry. QEMU generates a single WRITE_POINTER co= mmand - for the firmware. The firmware will write back the start address of - "etc/hardware_errors" blob to the fw_cfg file "etc/hardware_errors_add= r". +(8) QEMU defines a third and write-only fw_cfg blob to store the location + where the error block offsets, read ack registers and CPER records are + stored. + + Up to QEMU 9.2, the location was at "etc/hardware_errors_addr", and + contains a GPA for the beginning of "etc/hardware_errors". + + Newer versions place the location at "etc/acpi_table_hest_addr", + pointing to the GPA of the HEST table. + + Using above mentioned 'fw_cfg' files, the firmware can send back the + guest-side allocation addresses to QEMU. They contain a 8-byte entry. + QEMU generates a single WRITE_POINTER command for the firmware. The + firmware will write back the start address of either "etc/hardware_err= ors" + or HEST table at the corresponding fw_cfg file. =20 (9) When QEMU gets a SIGBUS from the kernel, QEMU writes CPER into corresp= onding "Error Status Data Block", guest memory, and then injects platform spe= cific @@ -105,8 +114,5 @@ Design Details kernel, on receiving notification, guest APEI driver could read the C= PER error and take appropriate action. =20 -(11) kvm_arch_on_sigbus_vcpu() uses source_id as index in "etc/hardware_er= rors" to - find out "Error Status Data Block" entry corresponding to error sourc= e. So supported - source_id values should be assigned here and not be changed afterward= s to make sure - that guest will write error into expected "Error Status Data Block" e= ven if guest was - migrated to a newer QEMU. +(11) kvm_arch_on_sigbus_vcpu() reports RAS errors via a SEA notifications, + when a SIGBUS event is triggered. --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691905; cv=none; d=zohomail.com; s=zohoarc; b=VZHyLdAOBBbQ8unYvPQlLlxyU8LpvLrZCybqc9jMCQu63ssILqxPzJzB5xzOdw0rMjLDf0BKUT/khyvOJp2ZFHWpSRNyzkeIJXTISD/6wwp/O67pkhHjer9LIgce7lc+YwNB4cXcGVLeJYnwzZYGdkJt9O+ljPFNMzL07VYOpLw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691905; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CYUcGjFt2kkm0mayJOstdTSkKoGiUv/Jd7WurXsdDjE=; b=KLxDJL7KCJKl+lfk2QOP+phOAasgt6SWEKt3XO1CrlBg4T62DRtt3bf6msn4Nr5s+d4kRM9Wf6Eqfio+mM85aNUWc5CRX7WGNc5Fc5iqJNuZQJ6Gume7I/rxolINbELcyg83KjqkdXL1RK++AxE5pvH9TC1IGUJgXJr7WhsZe2s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691905966662.8690055024322; Sun, 5 Oct 2025 12:18:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UEo-0000Dc-AL; Sun, 05 Oct 2025 15:17:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEg-0008Sq-Rb for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:35 -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 1v5UEa-0006VO-MX for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:34 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-438-nCXAeXvlNE-klN5KlOuGRg-1; Sun, 05 Oct 2025 15:17:19 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e3a049abaso22006035e9.0 for ; Sun, 05 Oct 2025 12:17:17 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e674b6591sm191849695e9.4.2025.10.05.12.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691845; 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=CYUcGjFt2kkm0mayJOstdTSkKoGiUv/Jd7WurXsdDjE=; b=hg/NAcosOO1B2sLcdCIXqm9/otEEJ9pTM0XXS/nA61LcidEvpRHc83mejsFoGkTKs/5mVK qknVx6VHQZlY5FPOl6LsadLwfm/nbNt7mWkltTPoI7wsNu4yZJm4Tdzu4WiYek1wh7TcN7 BKYHq6zgyFGWmpg3oHfCI6eZ3ywlfrc= X-MC-Unique: nCXAeXvlNE-klN5KlOuGRg-1 X-Mimecast-MFC-AGG-ID: nCXAeXvlNE-klN5KlOuGRg_1759691836 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691834; x=1760296634; 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=CYUcGjFt2kkm0mayJOstdTSkKoGiUv/Jd7WurXsdDjE=; b=IKsuWxNZxpjvlhhwe9MaLQB57lxJJIQfy8eGYoYVQB3IggFzwvMzNij2b8ggoO1Nof qPzN0T0gYztFpXZIfAJeagYj87162cy8fHo9yqsgfy8CWLrtEi0kRruhXWmxt1UF9bTK rFQgWm8svEaBJQCa4R3l5hUmejN43qWcqSYhN4ZQKQze5fDaTtuPlR3zrQ78f22wvamW 7b+v20wIKrEsUNMmlOhNOBqTkARzPlyMMm+Jk3P7fo+xHfwIgO2/5O4/vX63o/DR9Y6l NlizuKZvxhw/soxiWOvuRE/rILnUWQ7QQyZFhpN8SmDHSGgPwCVf3rKGqX4CRWmLIY7w vC/Q== X-Gm-Message-State: AOJu0YxQVGMti2KzcEUgEypUO3X6Kkbgz0OXYPko1/uU/hDN3gRnKp+U UFE7rMELihQDeH8QD4AG9ze0xRfw5EFrVZ3J8rdwOKloDno927Xu5UG/YHMSpz/aLJihdJvp1R/ P/iWsnTR2T8AFOpVHWui5OXChjieXJGlju62peFl/4COGugUKl+krFQUS+9AQWYBtRR2yAR5+qZ SB5X8H/Ntnu3tslnI5TSkROWILgab2Krh8ZQ== X-Gm-Gg: ASbGnctC/x+2UYrOdbbiJKVb5VkjGtce+qKO4CIx4BmXymusOSOOAsPutpY3I+Gm9Bw AgIfwVH2WHhnAsC5x4qnHaANuFQZZfV5+7VDsia851Uy/sghFEgy0uuyFIwEP6xmDXB4BKqYtb0 znkfPiLOVsJupIkEEeNdYe1O4T9MmvRnFSBtFQelWv0aoc9B0kKnJtkmX8LOsMGkoTqELyQeXpC f9pWx9gN7fvqBxHOe85okYqAawpJBGZV9v1N6K1O0hRrnDbS3S6GKfvgnEsDoBmnDlvU/c6GtJl b8gHfoJF1HZkZffJNoWbUIP/W3n4kH9+ZpDILhA= X-Received: by 2002:a05:600c:3f1b:b0:46e:3686:a2dd with SMTP id 5b1f17b1804b1-46e7110c287mr68415315e9.11.1759691833508; Sun, 05 Oct 2025 12:17:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHCs/5NdmIunZOHlqsB33zYPwdjb3E9ruVj+BipP3mbQnWkfImng8E3b2H+wMxKSgm73mkTGw== X-Received: by 2002:a05:600c:3f1b:b0:46e:3686:a2dd with SMTP id 5b1f17b1804b1-46e7110c287mr68415095e9.11.1759691832627; Sun, 05 Oct 2025 12:17:12 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:10 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Mauro Carvalho Chehab , Jonathan Cameron , John Snow , Cleber Rosa Subject: [PULL 31/75] scripts/ghes_inject: add a script to generate GHES error inject Message-ID: <4cc103081b170a80afe3344da4899b525fd4d0a8.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691907583116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Mauro Carvalho Chehab Using the QMP GHESv2 API requires preparing a raw data array containing a CPER record. Add a helper script with subcommands to prepare such data. Currently, only ARM Processor error CPER record is supported, by using: $ ghes_inject.py arm which produces those warnings on Linux: [ 705.032426] [Firmware Warn]: GHES: Unhandled processor error type 0x02: = cache error [ 774.866308] {4}[Hardware Error]: Hardware error from APEI Generic Hardwa= re Error Source: 1 [ 774.866583] {4}[Hardware Error]: event severity: recoverable [ 774.866738] {4}[Hardware Error]: Error 0, type: recoverable [ 774.866889] {4}[Hardware Error]: section_type: ARM processor error [ 774.867048] {4}[Hardware Error]: MIDR: 0x00000000000f0510 [ 774.867189] {4}[Hardware Error]: running state: 0x0 [ 774.867321] {4}[Hardware Error]: Power State Coordination Interface st= ate: 0 [ 774.867511] {4}[Hardware Error]: Error info structure 0: [ 774.867679] {4}[Hardware Error]: num errors: 2 [ 774.867801] {4}[Hardware Error]: error_type: 0x02: cache error [ 774.867962] {4}[Hardware Error]: error_info: 0x000000000091000f [ 774.868124] {4}[Hardware Error]: transaction type: Data Access [ 774.868280] {4}[Hardware Error]: cache error, operation type: Data w= rite [ 774.868465] {4}[Hardware Error]: cache level: 2 [ 774.868592] {4}[Hardware Error]: processor context not corrupted [ 774.868774] [Firmware Warn]: GHES: Unhandled processor error type 0x02: = cache error Such script allows customizing the error data, allowing to change all fields at the record. Please use: $ ghes_inject.py arm -h For more details about its usage. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron Reviewed-by: Michael S. Tsirkin Message-ID: <5ea174638e33d23635332fa6d4ae9d751355f127.1758610789.git.mcheha= b+huawei@kernel.org> Signed-off-by: Michael S. Tsirkin --- MAINTAINERS | 3 + scripts/arm_processor_error.py | 476 ++++++++++++++++++++++ scripts/ghes_inject.py | 51 +++ scripts/qmp_helper.py | 703 +++++++++++++++++++++++++++++++++ 4 files changed, 1233 insertions(+) create mode 100644 scripts/arm_processor_error.py create mode 100755 scripts/ghes_inject.py create mode 100755 scripts/qmp_helper.py diff --git a/MAINTAINERS b/MAINTAINERS index b31ae5193d..75e1fa5c30 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2179,6 +2179,9 @@ S: Maintained F: hw/arm/ghes_cper.c F: hw/acpi/ghes_cper_stub.c F: qapi/acpi-hest.json +F: scripts/ghes_inject.py +F: scripts/arm_processor_error.py +F: scripts/qmp_helper.py =20 ppc4xx L: qemu-ppc@nongnu.org diff --git a/scripts/arm_processor_error.py b/scripts/arm_processor_error.py new file mode 100644 index 0000000000..73d069f070 --- /dev/null +++ b/scripts/arm_processor_error.py @@ -0,0 +1,476 @@ +#!/usr/bin/env python3 +# +# pylint: disable=3DC0301,C0114,R0903,R0912,R0913,R0914,R0915,W0511 +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2024-2025 Mauro Carvalho Chehab + +# TODO: current implementation has dummy defaults. +# +# For a better implementation, a QMP addition/call is needed to +# retrieve some data for ARM Processor Error injection: +# +# - ARM registers: power_state, mpidr. + +""" +Generate an ARM processor error CPER, compatible with +UEFI 2.9A Errata. + +Injecting such errors can be done using: + + $ ./scripts/ghes_inject.py arm + Error injected. + +Produces a simple CPER register, as detected on a Linux guest: + +[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1 +[Hardware Error]: event severity: recoverable +[Hardware Error]: Error 0, type: recoverable +[Hardware Error]: section_type: ARM processor error +[Hardware Error]: MIDR: 0x0000000000000000 +[Hardware Error]: running state: 0x0 +[Hardware Error]: Power State Coordination Interface state: 0 +[Hardware Error]: Error info structure 0: +[Hardware Error]: num errors: 2 +[Hardware Error]: error_type: 0x02: cache error +[Hardware Error]: error_info: 0x000000000091000f +[Hardware Error]: transaction type: Data Access +[Hardware Error]: cache error, operation type: Data write +[Hardware Error]: cache level: 2 +[Hardware Error]: processor context not corrupted +[Firmware Warn]: GHES: Unhandled processor error type 0x02: cache error + +The ARM Processor Error message can be customized via command line +parameters. For instance: + + $ ./scripts/ghes_inject.py arm --mpidr 0x444 --running --affinity 1 \ + --error-info 12345678 --vendor 0x13,123,4,5,1 --ctx-array 0,1,2,3,= 4,5 \ + -t cache tlb bus micro-arch tlb,micro-arch + Error injected. + +Injects this error, as detected on a Linux guest: + +[Hardware Error]: Hardware error from APEI Generic Hardware Error Source: 1 +[Hardware Error]: event severity: recoverable +[Hardware Error]: Error 0, type: recoverable +[Hardware Error]: section_type: ARM processor error +[Hardware Error]: MIDR: 0x0000000000000000 +[Hardware Error]: Multiprocessor Affinity Register (MPIDR): 0x0000000000= 000000 +[Hardware Error]: error affinity level: 0 +[Hardware Error]: running state: 0x1 +[Hardware Error]: Power State Coordination Interface state: 0 +[Hardware Error]: Error info structure 0: +[Hardware Error]: num errors: 2 +[Hardware Error]: error_type: 0x02: cache error +[Hardware Error]: error_info: 0x0000000000bc614e +[Hardware Error]: cache level: 2 +[Hardware Error]: processor context not corrupted +[Hardware Error]: Error info structure 1: +[Hardware Error]: num errors: 2 +[Hardware Error]: error_type: 0x04: TLB error +[Hardware Error]: error_info: 0x000000000054007f +[Hardware Error]: transaction type: Instruction +[Hardware Error]: TLB error, operation type: Instruction fetch +[Hardware Error]: TLB level: 1 +[Hardware Error]: processor context not corrupted +[Hardware Error]: the error has not been corrected +[Hardware Error]: PC is imprecise +[Hardware Error]: Error info structure 2: +[Hardware Error]: num errors: 2 +[Hardware Error]: error_type: 0x08: bus error +[Hardware Error]: error_info: 0x00000080d6460fff +[Hardware Error]: transaction type: Generic +[Hardware Error]: bus error, operation type: Generic read (type of ins= truction or data request cannot be determined) +[Hardware Error]: affinity level at which the bus error occurred: 1 +[Hardware Error]: processor context corrupted +[Hardware Error]: the error has been corrected +[Hardware Error]: PC is imprecise +[Hardware Error]: Program execution can be restarted reliably at the P= C associated with the error. +[Hardware Error]: participation type: Local processor observed +[Hardware Error]: request timed out +[Hardware Error]: address space: External Memory Access +[Hardware Error]: memory access attributes:0x20 +[Hardware Error]: access mode: secure +[Hardware Error]: Error info structure 3: +[Hardware Error]: num errors: 2 +[Hardware Error]: error_type: 0x10: micro-architectural error +[Hardware Error]: error_info: 0x0000000078da03ff +[Hardware Error]: Error info structure 4: +[Hardware Error]: num errors: 2 +[Hardware Error]: error_type: 0x14: TLB error|micro-architectural error +[Hardware Error]: Context info structure 0: +[Hardware Error]: register context type: AArch64 EL1 context registers +[Hardware Error]: 00000000: 00000000 00000000 +[Hardware Error]: Vendor specific error info has 5 bytes: +[Hardware Error]: 00000000: 13 7b 04 05 01 = .{... +[Firmware Warn]: GHES: Unhandled processor error type 0x02: cache error +[Firmware Warn]: GHES: Unhandled processor error type 0x04: TLB error +[Firmware Warn]: GHES: Unhandled processor error type 0x08: bus error +[Firmware Warn]: GHES: Unhandled processor error type 0x10: micro-architec= tural error +[Firmware Warn]: GHES: Unhandled processor error type 0x14: TLB error|micr= o-architectural error +""" + +import argparse +import re + +from qmp_helper import qmp, util, cper_guid + + +class ArmProcessorEinj: + """ + Implements ARM Processor Error injection via GHES + """ + + DESC =3D """ + Generates an ARM processor error CPER, compatible with + UEFI 2.9A Errata. + """ + + ACPI_GHES_ARM_CPER_LENGTH =3D 40 + ACPI_GHES_ARM_CPER_PEI_LENGTH =3D 32 + + # Context types + CONTEXT_AARCH32_EL1 =3D 1 + CONTEXT_AARCH64_EL1 =3D 5 + CONTEXT_MISC_REG =3D 8 + + def __init__(self, subparsers): + """Initialize the error injection class and add subparser""" + + # Valid choice values + self.arm_valid_bits =3D { + "mpidr": util.bit(0), + "affinity": util.bit(1), + "running": util.bit(2), + "vendor": util.bit(3), + } + + self.pei_flags =3D { + "first": util.bit(0), + "last": util.bit(1), + "propagated": util.bit(2), + "overflow": util.bit(3), + } + + self.pei_error_types =3D { + "cache": util.bit(1), + "tlb": util.bit(2), + "bus": util.bit(3), + "micro-arch": util.bit(4), + } + + self.pei_valid_bits =3D { + "multiple-error": util.bit(0), + "flags": util.bit(1), + "error-info": util.bit(2), + "virt-addr": util.bit(3), + "phy-addr": util.bit(4), + } + + self.data =3D bytearray() + + parser =3D subparsers.add_parser("arm", description=3Dself.DESC) + + arm_valid_bits =3D ",".join(self.arm_valid_bits.keys()) + flags =3D ",".join(self.pei_flags.keys()) + error_types =3D ",".join(self.pei_error_types.keys()) + pei_valid_bits =3D ",".join(self.pei_valid_bits.keys()) + + # UEFI N.16 ARM Validation bits + g_arm =3D parser.add_argument_group("ARM processor") + g_arm.add_argument("--arm", "--arm-valid", + help=3Df"ARM valid bits: {arm_valid_bits}") + g_arm.add_argument("-a", "--affinity", "--level", "--affinity-lev= el", + type=3Dlambda x: int(x, 0), + help=3D"Affinity level (when multiple levels ap= ply)") + g_arm.add_argument("-l", "--mpidr", type=3Dlambda x: int(x, 0), + help=3D"Multiprocessor Affinity Register") + g_arm.add_argument("-i", "--midr", type=3Dlambda x: int(x, 0), + help=3D"Main ID Register") + g_arm.add_argument("-r", "--running", + action=3Dargparse.BooleanOptionalAction, + default=3DNone, + help=3D"Indicates if the processor is running o= r not") + g_arm.add_argument("--psci", "--psci-state", + type=3Dlambda x: int(x, 0), + help=3D"Power State Coordination Interface - PS= CI state") + + # TODO: Add vendor-specific support + + # UEFI N.17 bitmaps (type and flags) + g_pei =3D parser.add_argument_group("ARM Processor Error Info (PEI= )") + g_pei.add_argument("-t", "--type", nargs=3D"+", + help=3Df"one or more error types: {error_types}") + g_pei.add_argument("-f", "--flags", nargs=3D"*", + help=3Df"zero or more error flags: {flags}") + g_pei.add_argument("-V", "--pei-valid", "--error-valid", nargs=3D"= *", + help=3Df"zero or more PEI valid bits: {pei_valid_b= its}") + + # UEFI N.17 Integer values + g_pei.add_argument("-m", "--multiple-error", nargs=3D"+", + help=3D"Number of errors: 0: Single error, 1: Mult= iple errors, 2-65535: Error count if known") + g_pei.add_argument("-e", "--error-info", nargs=3D"+", + help=3D"Error information (UEFI 2.10 tables N.18 t= o N.20)") + g_pei.add_argument("-p", "--physical-address", nargs=3D"+", + help=3D"Physical address") + g_pei.add_argument("-v", "--virtual-address", nargs=3D"+", + help=3D"Virtual address") + + # UEFI N.21 Context + g_ctx =3D parser.add_argument_group("Processor Context") + g_ctx.add_argument("--ctx-type", "--context-type", nargs=3D"*", + help=3D"Type of the context (0=3DARM32 GPR, 5=3DAR= M64 EL1, other values supported)") + g_ctx.add_argument("--ctx-size", "--context-size", nargs=3D"*", + help=3D"Minimal size of the context") + g_ctx.add_argument("--ctx-array", "--context-array", nargs=3D"*", + help=3D"Comma-separated arrays for each context") + + # Vendor-specific data + g_vendor =3D parser.add_argument_group("Vendor-specific data") + g_vendor.add_argument("--vendor", "--vendor-specific", nargs=3D"+", + help=3D"Vendor-specific byte arrays of data") + + # Add arguments for Generic Error Data + qmp.argparse(parser) + + parser.set_defaults(func=3Dself.send_cper) + + def send_cper(self, args): + """Parse subcommand arguments and send a CPER via QMP""" + + qmp_cmd =3D qmp(args.host, args.port, args.debug) + + # Handle Generic Error Data arguments if any + qmp_cmd.set_args(args) + + is_cpu_type =3D re.compile(r"^([\w+]+\-)?arm\-cpu$") + cpus =3D qmp_cmd.search_qom("/machine/unattached/device", + "type", is_cpu_type) + + cper =3D {} + pei =3D {} + ctx =3D {} + vendor =3D {} + + arg =3D vars(args) + + # Handle global parameters + if args.arm: + arm_valid_init =3D False + cper["valid"] =3D util.get_choice(name=3D"valid", + value=3Dargs.arm, + choices=3Dself.arm_valid_bits, + suffixes=3D["-error", "-err"]) + else: + cper["valid"] =3D 0 + arm_valid_init =3D True + + if "running" in arg: + if args.running: + cper["running-state"] =3D util.bit(0) + else: + cper["running-state"] =3D 0 + else: + cper["running-state"] =3D 0 + + if arm_valid_init: + if args.affinity: + cper["valid"] |=3D self.arm_valid_bits["affinity"] + + if args.mpidr: + cper["valid"] |=3D self.arm_valid_bits["mpidr"] + + if "running-state" in cper: + cper["valid"] |=3D self.arm_valid_bits["running"] + + if args.psci: + cper["valid"] |=3D self.arm_valid_bits["running"] + + # Handle PEI + if not args.type: + args.type =3D ["cache-error"] + + util.get_mult_choices( + pei, + name=3D"valid", + values=3Dargs.pei_valid, + choices=3Dself.pei_valid_bits, + suffixes=3D["-valid", "--addr"], + ) + util.get_mult_choices( + pei, + name=3D"type", + values=3Dargs.type, + choices=3Dself.pei_error_types, + suffixes=3D["-error", "-err"], + ) + util.get_mult_choices( + pei, + name=3D"flags", + values=3Dargs.flags, + choices=3Dself.pei_flags, + suffixes=3D["-error", "-cap"], + ) + util.get_mult_int(pei, "error-info", args.error_info) + util.get_mult_int(pei, "multiple-error", args.multiple_error) + util.get_mult_int(pei, "phy-addr", args.physical_address) + util.get_mult_int(pei, "virt-addr", args.virtual_address) + + # Handle context + util.get_mult_int(ctx, "type", args.ctx_type, allow_zero=3DTrue) + util.get_mult_int(ctx, "minimal-size", args.ctx_size, allow_zero= =3DTrue) + util.get_mult_array(ctx, "register", args.ctx_array, allow_zero=3D= True) + + util.get_mult_array(vendor, "bytes", args.vendor, max_val=3D255) + + # Store PEI + pei_data =3D bytearray() + default_flags =3D self.pei_flags["first"] + default_flags |=3D self.pei_flags["last"] + + error_info_num =3D 0 + + for i, p in pei.items(): # pylint: disable=3DW0612 + error_info_num +=3D 1 + + # UEFI 2.10 doesn't define how to encode error information + # when multiple types are raised. So, provide a default only + # if a single type is there + if "error-info" not in p: + if p["type"] =3D=3D util.bit(1): + p["error-info"] =3D 0x0091000F + if p["type"] =3D=3D util.bit(2): + p["error-info"] =3D 0x0054007F + if p["type"] =3D=3D util.bit(3): + p["error-info"] =3D 0x80D6460FFF + if p["type"] =3D=3D util.bit(4): + p["error-info"] =3D 0x78DA03FF + + if "valid" not in p: + p["valid"] =3D 0 + if "multiple-error" in p: + p["valid"] |=3D self.pei_valid_bits["multiple-error"] + + if "flags" in p: + p["valid"] |=3D self.pei_valid_bits["flags"] + + if "error-info" in p: + p["valid"] |=3D self.pei_valid_bits["error-info"] + + if "phy-addr" in p: + p["valid"] |=3D self.pei_valid_bits["phy-addr"] + + if "virt-addr" in p: + p["valid"] |=3D self.pei_valid_bits["virt-addr"] + + # Version + util.data_add(pei_data, 0, 1) + + util.data_add(pei_data, + self.ACPI_GHES_ARM_CPER_PEI_LENGTH, 1) + + util.data_add(pei_data, p["valid"], 2) + util.data_add(pei_data, p["type"], 1) + util.data_add(pei_data, p.get("multiple-error", 1), 2) + util.data_add(pei_data, p.get("flags", default_flags), 1) + util.data_add(pei_data, p.get("error-info", 0), 8) + util.data_add(pei_data, p.get("virt-addr", 0xDEADBEEF), 8) + util.data_add(pei_data, p.get("phy-addr", 0xABBA0BAD), 8) + + # Store Context + ctx_data =3D bytearray() + context_info_num =3D 0 + + if ctx: + ret =3D qmp_cmd.send_cmd("query-target", may_open=3DTrue) + + default_ctx =3D self.CONTEXT_MISC_REG + + if "arch" in ret: + if ret["arch"] =3D=3D "aarch64": + default_ctx =3D self.CONTEXT_AARCH64_EL1 + elif ret["arch"] =3D=3D "arm": + default_ctx =3D self.CONTEXT_AARCH32_EL1 + + for k in sorted(ctx.keys()): + context_info_num +=3D 1 + + if "type" not in ctx[k]: + ctx[k]["type"] =3D default_ctx + + if "register" not in ctx[k]: + ctx[k]["register"] =3D [] + + reg_size =3D len(ctx[k]["register"]) + size =3D 0 + + if "minimal-size" in ctx: + size =3D ctx[k]["minimal-size"] + + size =3D max(size, reg_size) + + size =3D (size + 1) % 0xFFFE + + # Version + util.data_add(ctx_data, 0, 2) + + util.data_add(ctx_data, ctx[k]["type"], 2) + + util.data_add(ctx_data, 8 * size, 4) + + for r in ctx[k]["register"]: + util.data_add(ctx_data, r, 8) + + for i in range(reg_size, size): # pylint: disable=3DW0612 + util.data_add(ctx_data, 0, 8) + + # Vendor-specific bytes are not grouped + vendor_data =3D bytearray() + if vendor: + for k in sorted(vendor.keys()): + for b in vendor[k]["bytes"]: + util.data_add(vendor_data, b, 1) + + # Encode ARM Processor Error + data =3D bytearray() + + util.data_add(data, cper["valid"], 4) + + util.data_add(data, error_info_num, 2) + util.data_add(data, context_info_num, 2) + + # Calculate the length of the CPER data + cper_length =3D self.ACPI_GHES_ARM_CPER_LENGTH + cper_length +=3D len(pei_data) + cper_length +=3D len(vendor_data) + cper_length +=3D len(ctx_data) + util.data_add(data, cper_length, 4) + + util.data_add(data, arg.get("affinity-level", 0), 1) + + # Reserved + util.data_add(data, 0, 3) + + if "midr-el1" not in arg: + if cpus: + cmd_arg =3D { + 'path': cpus[0], + 'property': "midr" + } + ret =3D qmp_cmd.send_cmd("qom-get", cmd_arg, may_open=3DTr= ue) + if isinstance(ret, int): + arg["midr-el1"] =3D ret + + util.data_add(data, arg.get("mpidr-el1", 0), 8) + util.data_add(data, arg.get("midr-el1", 0), 8) + util.data_add(data, cper["running-state"], 4) + util.data_add(data, arg.get("psci-state", 0), 4) + + # Add PEI + data.extend(pei_data) + data.extend(ctx_data) + data.extend(vendor_data) + + self.data =3D data + + qmp_cmd.send_cper(cper_guid.CPER_PROC_ARM, self.data) diff --git a/scripts/ghes_inject.py b/scripts/ghes_inject.py new file mode 100755 index 0000000000..9a23520141 --- /dev/null +++ b/scripts/ghes_inject.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2024-2025 Mauro Carvalho Chehab + +""" +Handle ACPI GHESv2 error injection logic QEMU QMP interface. +""" + +import argparse +import sys + +from arm_processor_error import ArmProcessorEinj + +EINJ_DESC =3D """ +Handle ACPI GHESv2 error injection logic QEMU QMP interface. + +It allows using UEFI BIOS EINJ features to generate GHES records. + +It helps testing CPER and GHES drivers at the guest OS and how +userspace applications at the guest handle them. +""" + +def main(): + """Main program""" + + # Main parser - handle generic args like QEMU QMP TCP socket options + parser =3D argparse.ArgumentParser(formatter_class=3Dargparse.Argument= DefaultsHelpFormatter, + usage=3D"%(prog)s [options]", + description=3DEINJ_DESC) + + g_options =3D parser.add_argument_group("QEMU QMP socket options") + g_options.add_argument("-H", "--host", default=3D"localhost", type=3Ds= tr, + help=3D"host name") + g_options.add_argument("-P", "--port", default=3D4445, type=3Dint, + help=3D"TCP port number") + g_options.add_argument('-d', '--debug', action=3D'store_true') + + subparsers =3D parser.add_subparsers() + + ArmProcessorEinj(subparsers) + + args =3D parser.parse_args() + if "func" in args: + args.func(args) + else: + sys.exit(f"Please specify a valid command for {sys.argv[0]}") + +if __name__ =3D=3D "__main__": + main() diff --git a/scripts/qmp_helper.py b/scripts/qmp_helper.py new file mode 100755 index 0000000000..c1e7e0fd80 --- /dev/null +++ b/scripts/qmp_helper.py @@ -0,0 +1,703 @@ +#!/usr/bin/env python3 +# +# pylint: disable=3DC0103,E0213,E1135,E1136,E1137,R0902,R0903,R0912,R0913,= R0917 +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2024-2025 Mauro Carvalho Chehab + +""" +Helper classes to be used by ghes_inject command classes. +""" + +import json +import sys + +from datetime import datetime +from os import path as os_path + +try: + qemu_dir =3D os_path.abspath(os_path.dirname(os_path.dirname(__file__)= )) + sys.path.append(os_path.join(qemu_dir, 'python')) + + from qemu.qmp.legacy import QEMUMonitorProtocol + +except ModuleNotFoundError as exc: + print(f"Module '{exc.name}' not found.") + print("Try export PYTHONPATH=3Dtop-qemu-dir/python or run from top-qem= u-dir") + sys.exit(1) + +from base64 import b64encode + +class util: + """ + Ancillary functions to deal with bitmaps, parse arguments, + generate GUID and encode data on a bytearray buffer. + """ + + # + # Helper routines to handle multiple choice arguments + # + def get_choice(name, value, choices, suffixes=3DNone, bitmask=3DTrue): + """Produce a list from multiple choice argument""" + + new_values =3D 0 + + if not value: + return new_values + + for val in value.split(","): + val =3D val.lower() + + if suffixes: + for suffix in suffixes: + val =3D val.removesuffix(suffix) + + if val not in choices.keys(): + if suffixes: + for suffix in suffixes: + if val + suffix in choices.keys(): + val +=3D suffix + break + + if val not in choices.keys(): + sys.exit(f"Error on '{name}': choice '{val}' is invalid.") + + val =3D choices[val] + + if bitmask: + new_values |=3D val + else: + if new_values: + sys.exit(f"Error on '{name}': only one value is accept= ed.") + + new_values =3D val + + return new_values + + def get_array(name, values, max_val=3DNone): + """Add numbered hashes from integer lists into an array""" + + array =3D [] + + for value in values: + for val in value.split(","): + try: + val =3D int(val, 0) + except ValueError: + sys.exit(f"Error on '{name}': {val} is not an integer") + + if val < 0: + sys.exit(f"Error on '{name}': {val} is not unsigned") + + if max_val and val > max_val: + sys.exit(f"Error on '{name}': {val} is too little") + + array.append(val) + + return array + + def get_mult_array(mult, name, values, allow_zero=3DFalse, max_val=3DN= one): + """Add numbered hashes from integer lists""" + + if not allow_zero: + if not values: + return + else: + if values is None: + return + + if not values: + i =3D 0 + if i not in mult: + mult[i] =3D {} + + mult[i][name] =3D [] + return + + i =3D 0 + for value in values: + for val in value.split(","): + try: + val =3D int(val, 0) + except ValueError: + sys.exit(f"Error on '{name}': {val} is not an integer") + + if val < 0: + sys.exit(f"Error on '{name}': {val} is not unsigned") + + if max_val and val > max_val: + sys.exit(f"Error on '{name}': {val} is too little") + + if i not in mult: + mult[i] =3D {} + + if name not in mult[i]: + mult[i][name] =3D [] + + mult[i][name].append(val) + + i +=3D 1 + + + def get_mult_choices(mult, name, values, choices, + suffixes=3DNone, allow_zero=3DFalse): + """Add numbered hashes from multiple choice arguments""" + + if not allow_zero: + if not values: + return + else: + if values is None: + return + + i =3D 0 + for val in values: + new_values =3D util.get_choice(name, val, choices, suffixes) + + if i not in mult: + mult[i] =3D {} + + mult[i][name] =3D new_values + i +=3D 1 + + + def get_mult_int(mult, name, values, allow_zero=3DFalse): + """Add numbered hashes from integer arguments""" + if not allow_zero: + if not values: + return + else: + if values is None: + return + + i =3D 0 + for val in values: + try: + val =3D int(val, 0) + except ValueError: + sys.exit(f"Error on '{name}': {val} is not an integer") + + if val < 0: + sys.exit(f"Error on '{name}': {val} is not unsigned") + + if i not in mult: + mult[i] =3D {} + + mult[i][name] =3D val + i +=3D 1 + + + # + # Data encode helper functions + # + def bit(b): + """Simple macro to define a bit on a bitmask""" + return 1 << b + + + def data_add(data, value, num_bytes): + """Adds bytes from value inside a bitarray""" + + data.extend(value.to_bytes(num_bytes, byteorder=3D"little")) # py= lint: disable=3DE1101 + + def dump_bytearray(name, data): + """Does an hexdump of a byte array, grouping in bytes""" + + print(f"{name} ({len(data)} bytes):") + + for ln_start in range(0, len(data), 16): + ln_end =3D min(ln_start + 16, len(data)) + print(f" {ln_start:08x} ", end=3D"") + for i in range(ln_start, ln_end): + print(f"{data[i]:02x} ", end=3D"") + for i in range(ln_end, ln_start + 16): + print(" ", end=3D"") + print(" ", end=3D"") + for i in range(ln_start, ln_end): + if data[i] >=3D 32 and data[i] < 127: + print(chr(data[i]), end=3D"") + else: + print(".", end=3D"") + + print() + print() + + def time(string): + """Handle BCD timestamps used on Generic Error Data Block""" + + time =3D None + + # Formats to be used when parsing time stamps + formats =3D [ + "%Y-%m-%d %H:%M:%S", + ] + + if string =3D=3D "now": + time =3D datetime.now() + + if time is None: + for fmt in formats: + try: + time =3D datetime.strptime(string, fmt) + break + except ValueError: + pass + + if time is None: + raise ValueError("Invalid time format") + + return time + +class guid: + """ + Simple class to handle GUID fields. + """ + + def __init__(self, time_low, time_mid, time_high, nodes): + """Initialize a GUID value""" + + assert len(nodes) =3D=3D 8 + + self.time_low =3D time_low + self.time_mid =3D time_mid + self.time_high =3D time_high + self.nodes =3D nodes + + @classmethod + def UUID(cls, guid_str): + """Initialize a GUID using a string on its standard format""" + + if len(guid_str) !=3D 36: + print("Size not 36") + raise ValueError('Invalid GUID size') + + # It is easier to parse without separators. So, drop them + guid_str =3D guid_str.replace('-', '') + + if len(guid_str) !=3D 32: + print("Size not 32", guid_str, len(guid_str)) + raise ValueError('Invalid GUID hex size') + + time_low =3D 0 + time_mid =3D 0 + time_high =3D 0 + nodes =3D [] + + for i in reversed(range(16, 32, 2)): + h =3D guid_str[i:i + 2] + value =3D int(h, 16) + nodes.insert(0, value) + + time_high =3D int(guid_str[12:16], 16) + time_mid =3D int(guid_str[8:12], 16) + time_low =3D int(guid_str[0:8], 16) + + return cls(time_low, time_mid, time_high, nodes) + + def __str__(self): + """Output a GUID value on its default string representation""" + + clock =3D self.nodes[0] << 8 | self.nodes[1] + + node =3D 0 + for i in range(2, len(self.nodes)): + node =3D node << 8 | self.nodes[i] + + s =3D f"{self.time_low:08x}-{self.time_mid:04x}-" + s +=3D f"{self.time_high:04x}-{clock:04x}-{node:012x}" + return s + + def to_bytes(self): + """Output a GUID value in bytes""" + + data =3D bytearray() + + util.data_add(data, self.time_low, 4) + util.data_add(data, self.time_mid, 2) + util.data_add(data, self.time_high, 2) + data.extend(bytearray(self.nodes)) + + return data + +class qmp: + """ + Opens a connection and send/receive QMP commands. + """ + + def send_cmd(self, command, args=3DNone, may_open=3DFalse, return_erro= r=3DTrue): + """Send a command to QMP, optinally opening a connection""" + + if may_open: + self._connect() + elif not self.connected: + return False + + msg =3D { 'execute': command } + if args: + msg['arguments'] =3D args + + try: + obj =3D self.qmp_monitor.cmd_obj(msg) + # Can we use some other exception class here? + except Exception as e: # pylint: disable= =3DW0718 + print(f"Command: {command}") + print(f"Failed to inject error: {e}.") + return None + + if "return" in obj: + if isinstance(obj.get("return"), dict): + if obj["return"]: + return obj["return"] + return "OK" + + return obj["return"] + + if isinstance(obj.get("error"), dict): + error =3D obj["error"] + if return_error: + print(f"Command: {msg}") + print(f'{error["class"]}: {error["desc"]}') + else: + print(json.dumps(obj)) + + return None + + def _close(self): + """Shutdown and close the socket, if opened""" + if not self.connected: + return + + self.qmp_monitor.close() + self.connected =3D False + + def _connect(self): + """Connect to a QMP TCP/IP port, if not connected yet""" + + if self.connected: + return True + + try: + self.qmp_monitor.connect(negotiate=3DTrue) + except ConnectionError: + sys.exit(f"Can't connect to QMP host {self.host}:{self.port}") + + self.connected =3D True + + return True + + BLOCK_STATUS_BITS =3D { + "uncorrectable": util.bit(0), + "correctable": util.bit(1), + "multi-uncorrectable": util.bit(2), + "multi-correctable": util.bit(3), + } + + ERROR_SEVERITY =3D { + "recoverable": 0, + "fatal": 1, + "corrected": 2, + "none": 3, + } + + VALIDATION_BITS =3D { + "fru-id": util.bit(0), + "fru-text": util.bit(1), + "timestamp": util.bit(2), + } + + GEDB_FLAGS_BITS =3D { + "recovered": util.bit(0), + "prev-error": util.bit(1), + "simulated": util.bit(2), + } + + GENERIC_DATA_SIZE =3D 72 + + def argparse(parser): + """Prepare a parser group to query generic error data""" + + block_status_bits =3D ",".join(qmp.BLOCK_STATUS_BITS.keys()) + error_severity_enum =3D ",".join(qmp.ERROR_SEVERITY.keys()) + validation_bits =3D ",".join(qmp.VALIDATION_BITS.keys()) + gedb_flags_bits =3D ",".join(qmp.GEDB_FLAGS_BITS.keys()) + + g_gen =3D parser.add_argument_group("Generic Error Data") # pylin= t: disable=3DE1101 + g_gen.add_argument("--block-status", + help=3Df"block status bits: {block_status_bits}= ") + g_gen.add_argument("--raw-data", nargs=3D"+", + help=3D"Raw data inside the Error Status Block") + g_gen.add_argument("--error-severity", "--severity", + help=3Df"error severity: {error_severity_enum}") + g_gen.add_argument("--gen-err-valid-bits", + "--generic-error-validation-bits", + help=3Df"validation bits: {validation_bits}") + g_gen.add_argument("--fru-id", type=3Dguid.UUID, + help=3D"GUID representing a physical device") + g_gen.add_argument("--fru-text", + help=3D"ASCII string identifying the FRU hardwa= re") + g_gen.add_argument("--timestamp", type=3Dutil.time, + help=3D"Time when the error info was collected") + g_gen.add_argument("--precise", "--precise-timestamp", + action=3D'store_true', + help=3D"Marks the timestamp as precise if --tim= estamp is used") + g_gen.add_argument("--gedb-flags", + help=3Df"General Error Data Block flags: {gedb_= flags_bits}") + + def set_args(self, args): + """Set the arguments optionally defined via self.argparse()""" + + if args.block_status: + self.block_status =3D util.get_choice(name=3D"block-status", + value=3Dargs.block_status, + choices=3Dself.BLOCK_STATU= S_BITS, + bitmask=3DFalse) + if args.raw_data: + self.raw_data =3D util.get_array("raw-data", args.raw_data, + max_val=3D255) + print(self.raw_data) + + if args.error_severity: + self.error_severity =3D util.get_choice(name=3D"error-severity= ", + value=3Dargs.error_sever= ity, + choices=3Dself.ERROR_SEV= ERITY, + bitmask=3DFalse) + + if args.fru_id: + self.fru_id =3D args.fru_id.to_bytes() + if not args.gen_err_valid_bits: + self.validation_bits |=3D self.VALIDATION_BITS["fru-id"] + + if args.fru_text: + text =3D bytearray(args.fru_text.encode('ascii')) + if len(text) > 20: + sys.exit("FRU text is too big to fit") + + self.fru_text =3D text + if not args.gen_err_valid_bits: + self.validation_bits |=3D self.VALIDATION_BITS["fru-text"] + + if args.timestamp: + time =3D args.timestamp + century =3D int(time.year / 100) + + bcd =3D bytearray() + util.data_add(bcd, (time.second // 10) << 4 | (time.second % 1= 0), 1) + util.data_add(bcd, (time.minute // 10) << 4 | (time.minute % 1= 0), 1) + util.data_add(bcd, (time.hour // 10) << 4 | (time.hour % 10), = 1) + + if args.precise: + util.data_add(bcd, 1, 1) + else: + util.data_add(bcd, 0, 1) + + util.data_add(bcd, (time.day // 10) << 4 | (time.day % 10), 1) + util.data_add(bcd, (time.month // 10) << 4 | (time.month % 10)= , 1) + util.data_add(bcd, + ((time.year % 100) // 10) << 4 | (time.year % 10= ), 1) + util.data_add(bcd, ((century % 100) // 10) << 4 | (century % 1= 0), 1) + + self.timestamp =3D bcd + if not args.gen_err_valid_bits: + self.validation_bits |=3D self.VALIDATION_BITS["timestamp"] + + if args.gen_err_valid_bits: + self.validation_bits =3D util.get_choice(name=3D"validation", + value=3Dargs.gen_err_va= lid_bits, + choices=3Dself.VALIDATI= ON_BITS) + + def __init__(self, host, port, debug=3DFalse): + """Initialize variables used by the QMP send logic""" + + self.connected =3D False + self.host =3D host + self.port =3D port + self.debug =3D debug + + # ACPI 6.1: 18.3.2.7.1 Generic Error Data: Generic Error Status Bl= ock + self.block_status =3D self.BLOCK_STATUS_BITS["uncorrectable"] + self.raw_data =3D [] + self.error_severity =3D self.ERROR_SEVERITY["recoverable"] + + # ACPI 6.1: 18.3.2.7.1 Generic Error Data: Generic Error Data Entry + self.validation_bits =3D 0 + self.flags =3D 0 + self.fru_id =3D bytearray(16) + self.fru_text =3D bytearray(20) + self.timestamp =3D bytearray(8) + + self.qmp_monitor =3D QEMUMonitorProtocol(address=3D(self.host, sel= f.port)) + + # + # Socket QMP send command + # + def send_cper_raw(self, cper_data): + """Send a raw CPER data to QEMU though QMP TCP socket""" + + data =3D b64encode(bytes(cper_data)).decode('ascii') + + cmd_arg =3D { + 'cper': data + } + + self._connect() + + if self.send_cmd("inject-ghes-v2-error", cmd_arg): + print("Error injected.") + + def send_cper(self, notif_type, payload): + """Send commands to QEMU though QMP TCP socket""" + + # Fill CPER record header + + # NOTE: bits 4 to 13 of block status contain the number of + # data entries in the data section. This is currently unsupported. + + cper_length =3D len(payload) + data_length =3D cper_length + len(self.raw_data) + self.GENERIC_DA= TA_SIZE + + # Generic Error Data Entry + gede =3D bytearray() + + gede.extend(notif_type.to_bytes()) + util.data_add(gede, self.error_severity, 4) + util.data_add(gede, 0x300, 2) + util.data_add(gede, self.validation_bits, 1) + util.data_add(gede, self.flags, 1) + util.data_add(gede, cper_length, 4) + gede.extend(self.fru_id) + gede.extend(self.fru_text) + gede.extend(self.timestamp) + + # Generic Error Status Block + gebs =3D bytearray() + + if self.raw_data: + raw_data_offset =3D len(gebs) + else: + raw_data_offset =3D 0 + + util.data_add(gebs, self.block_status, 4) + util.data_add(gebs, raw_data_offset, 4) + util.data_add(gebs, len(self.raw_data), 4) + util.data_add(gebs, data_length, 4) + util.data_add(gebs, self.error_severity, 4) + + cper_data =3D bytearray() + cper_data.extend(gebs) + cper_data.extend(gede) + cper_data.extend(bytearray(self.raw_data)) + cper_data.extend(bytearray(payload)) + + if self.debug: + print(f"GUID: {notif_type}") + + util.dump_bytearray("Generic Error Status Block", gebs) + util.dump_bytearray("Generic Error Data Entry", gede) + + if self.raw_data: + util.dump_bytearray("Raw data", bytearray(self.raw_data)) + + util.dump_bytearray("Payload", payload) + + self.send_cper_raw(cper_data) + + + def search_qom(self, path, prop, regex): + """ + Return a list of devices that match path array like: + + /machine/unattached/device + /machine/peripheral-anon/device + ... + """ + + found =3D [] + + i =3D 0 + while 1: + dev =3D f"{path}[{i}]" + args =3D { + 'path': dev, + 'property': prop + } + ret =3D self.send_cmd("qom-get", args, may_open=3DTrue, + return_error=3DFalse) + if not ret: + break + + if isinstance(ret, str): + if regex.search(ret): + found.append(dev) + + i +=3D 1 + if i > 10000: + print("Too many objects returned by qom-get!") + break + + return found + +class cper_guid: + """ + Contains CPER GUID, as per: + https://uefi.org/specs/UEFI/2.10/Apx_N_Common_Platform_Error_Record.ht= ml + """ + + CPER_PROC_GENERIC =3D guid(0x9876CCAD, 0x47B4, 0x4bdb, + [0xB6, 0x5E, 0x16, 0xF1, + 0x93, 0xC4, 0xF3, 0xDB]) + + CPER_PROC_X86 =3D guid(0xDC3EA0B0, 0xA144, 0x4797, + [0xB9, 0x5B, 0x53, 0xFA, + 0x24, 0x2B, 0x6E, 0x1D]) + + CPER_PROC_ITANIUM =3D guid(0xe429faf1, 0x3cb7, 0x11d4, + [0xbc, 0xa7, 0x00, 0x80, + 0xc7, 0x3c, 0x88, 0x81]) + + CPER_PROC_ARM =3D guid(0xE19E3D16, 0xBC11, 0x11E4, + [0x9C, 0xAA, 0xC2, 0x05, + 0x1D, 0x5D, 0x46, 0xB0]) + + CPER_PLATFORM_MEM =3D guid(0xA5BC1114, 0x6F64, 0x4EDE, + [0xB8, 0x63, 0x3E, 0x83, + 0xED, 0x7C, 0x83, 0xB1]) + + CPER_PLATFORM_MEM2 =3D guid(0x61EC04FC, 0x48E6, 0xD813, + [0x25, 0xC9, 0x8D, 0xAA, + 0x44, 0x75, 0x0B, 0x12]) + + CPER_PCIE =3D guid(0xD995E954, 0xBBC1, 0x430F, + [0xAD, 0x91, 0xB4, 0x4D, + 0xCB, 0x3C, 0x6F, 0x35]) + + CPER_PCI_BUS =3D guid(0xC5753963, 0x3B84, 0x4095, + [0xBF, 0x78, 0xED, 0xDA, + 0xD3, 0xF9, 0xC9, 0xDD]) + + CPER_PCI_DEV =3D guid(0xEB5E4685, 0xCA66, 0x4769, + [0xB6, 0xA2, 0x26, 0x06, + 0x8B, 0x00, 0x13, 0x26]) + + CPER_FW_ERROR =3D guid(0x81212A96, 0x09ED, 0x4996, + [0x94, 0x71, 0x8D, 0x72, + 0x9C, 0x8E, 0x69, 0xED]) + + CPER_DMA_GENERIC =3D guid(0x5B51FEF7, 0xC79D, 0x4434, + [0x8F, 0x1B, 0xAA, 0x62, + 0xDE, 0x3E, 0x2C, 0x64]) + + CPER_DMA_VT =3D guid(0x71761D37, 0x32B2, 0x45cd, + [0xA7, 0xD0, 0xB0, 0xFE, + 0xDD, 0x93, 0xE8, 0xCF]) + + CPER_DMA_IOMMU =3D guid(0x036F84E1, 0x7F37, 0x428c, + [0xA7, 0x9E, 0x57, 0x5F, + 0xDF, 0xAA, 0x84, 0xEC]) + + CPER_CCIX_PER =3D guid(0x91335EF6, 0xEBFB, 0x4478, + [0xA6, 0xA6, 0x88, 0xB7, + 0x28, 0xCF, 0x75, 0xD7]) + + CPER_CXL_PROT_ERR =3D guid(0x80B9EFB4, 0x52B5, 0x4DE3, + [0xA7, 0x77, 0x68, 0x78, + 0x4B, 0x77, 0x10, 0x48]) --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692447; cv=none; d=zohomail.com; s=zohoarc; b=YGuWRnaZgAOgFlyURFQQ54PM1GTBZdHDDsS1nVGecjddfaiuHvSCVf460IlXEy/Ew8r5Ert4+J3yFsKNQlc4hIqL7sqmb85ExwHEyrd5kqGaANXkl3hqd2W/e1HzKAAkcXLJe22zCpys5Nee6JXBhe4LzUaLu53+CuV3YHLlAkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692447; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kypaSeEg6IWRZMT772IZeY7cqyb72xxszsPDOfdio+s=; b=b14y/2FYUJbLPBBEarfPCM1iv5X0GUrrppJCNUqSz2CtnOqFfb70cw4H3tV+edUPeZAkRNi+5LzMZA9RkY3d9UIwmycR7UtU8jMkm+UEs+RX3BGiEDWVWJ/KJ8oJTQjjrVxuiqk2sWl78qFWUoO05LRu5vrhFZnjomDxMPjtdDs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692447324692.9829439504525; Sun, 5 Oct 2025 12:27:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UEg-0008If-HP; Sun, 05 Oct 2025 15:17: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 1v5UEc-00085b-D8 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEa-0006UZ-MR for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:30 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-448-HjKD3vp-Mea0lX9SMdtltw-1; Sun, 05 Oct 2025 15:17:17 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3ecdd80ea44so2979812f8f.1 for ; Sun, 05 Oct 2025 12:17:17 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e619c3b75sm217431125e9.7.2025.10.05.12.17.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691840; 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=kypaSeEg6IWRZMT772IZeY7cqyb72xxszsPDOfdio+s=; b=Xjr1BmnbufVf0FZDOS14ZOavhloBMQiwvKLe7dNJfZXIAcgEHTR/L2o45F0GYdSZ+D+p/h tOvgbAk8psePP2dlZKLcdk5OuTWo3IdEIoDwkbLo9xvyY7CK0mPJcH9YMLE4gGoooXhvwn /X5bX0U4xw6zpbkUL80UMXWnvPe+4so= X-MC-Unique: HjKD3vp-Mea0lX9SMdtltw-1 X-Mimecast-MFC-AGG-ID: HjKD3vp-Mea0lX9SMdtltw_1759691836 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691836; x=1760296636; 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=kypaSeEg6IWRZMT772IZeY7cqyb72xxszsPDOfdio+s=; b=W8zKVtw8szdBSzFMW4+EHy51TlRukkEq7qaeS4roKHmuEBQndjsysoT6GQH4wx7QTX 9G8Tw1ymJiVDAkik7McgszIXPBwc+8drTjGxWa+lIX2/yYKCq3XQL4evc/EWckLWyV67 rpK6FAQX4iphgBDFQCYQmw4L3aGIeK6MvVV/10tFf+53xgvvv2G8zsx4rS1j3+NZQSEh b64rBeY5lN9aM6dh6wDi6fNeU774grQ7HjRHL/nyNsBz05TA/9ko33rG36T1UsohaGPv Rur4KAYfzD0V0j3eI5ZSjX8eu3t0jyOWUVgub+gVPp3EfrG35HTPw2A4na07kkzPYpoa JeTw== X-Gm-Message-State: AOJu0Yyf3An7fBaDo5Kf6xBJ5m4nkZqHl0vsSqQQDdUm/jW+C67wxnMG enrt1Ws3/yui9yKVBJi31lpbqmMB5RxAAMeFA2vw7qm+8ZGtkokWgP5F/ld3RLXpazjzbLPQS3J jR8U/oJ4Dv+EU9bK/011/NWtY7OmqiQV7pzgst0lRlwr82NqHha3RBvzBMXv2gczkFKfWIRyOVn YXL6/ZJ1fnLLR9uAn61lX0C4vTPFhjAsP1CQ== X-Gm-Gg: ASbGncvsOJIMTZBarn8PgSSLB+ei2upPrAMdgOpWn3pVYB/ERzCZI1czJVPt3xhkD6O RxAiqNFIBx8V/+yDi6nEIDIAnWRPE3RiMHAMd/RWmkwPitGiA0UvU0EoPIoQnSvbce6Qds2HWmJ FNZCK9oYrpXdCPdJmilhUTi1qLsWA9qZ/TYUDhS8G7gZGrDLlrxpe4j5WFgxQutdzDTbLDSH8H8 8jlHWcWrNUJi6EHgygPf3auf6ty2z4EWF9m7smj1+UHetreO8UDPB27M1jLBEyrTnHNJT7DLBgm /LOYImMqjS/mVjJL+dTgRR78kqIgoFaY6VxARXs= X-Received: by 2002:a05:6000:3103:b0:401:c55d:2d20 with SMTP id ffacd0b85a97d-4255d2d12dfmr8775395f8f.26.1759691835891; Sun, 05 Oct 2025 12:17:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEa92RQmwa2ZNgL6xwPfs9sDM/3ON4IoKpumFUnz1MER50CLKuOv+FYc5D0XIWu3DJKe97WFg== X-Received: by 2002:a05:6000:3103:b0:401:c55d:2d20 with SMTP id ffacd0b85a97d-4255d2d12dfmr8775380f8f.26.1759691835298; Sun, 05 Oct 2025 12:17:15 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:12 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Daniil Tatianin , Igor Mammedov , Ani Sinha Subject: [PULL 32/75] hw/smbios: allow clearing the VM bit in SMBIOS table 0 Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692450623116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Daniil Tatianin This is useful to be able to freeze a specific version of SeaBIOS to prevent guest visible changes between BIOS updates. This is currently not possible since the extension byte 2 provided by SeaBIOS does not set the VM bit, whereas QEMU sets it unconditionally. Allowing to clear it also seems useful if we want to hide the fact that the guest system is running inside a virtual machine. Signed-off-by: Daniil Tatianin Reviewed-by: Michael S. Tsirkin Message-ID: <20250724195409.43499-1-d-tatianin@yandex-team.ru> Signed-off-by: Michael S. Tsirkin --- include/hw/firmware/smbios.h | 2 +- hw/smbios/smbios.c | 11 ++++++++++- qemu-options.hx | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/hw/firmware/smbios.h b/include/hw/firmware/smbios.h index f066ab7262..3ea732f4e6 100644 --- a/include/hw/firmware/smbios.h +++ b/include/hw/firmware/smbios.h @@ -22,7 +22,7 @@ extern GArray *usr_blobs_sizes; =20 typedef struct { const char *vendor, *version, *date; - bool have_major_minor, uefi; + bool have_major_minor, uefi, vm; uint8_t major, minor; } smbios_type0_t; extern smbios_type0_t smbios_type0; diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 1ac063cfb4..13e21a9c43 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -179,6 +179,10 @@ static const QemuOptDesc qemu_smbios_type0_opts[] =3D { .name =3D "uefi", .type =3D QEMU_OPT_BOOL, .help =3D "uefi support", + },{ + .name =3D "vm", + .type =3D QEMU_OPT_BOOL, + .help =3D "virtual machine", }, { /* end of list */ } }; @@ -574,10 +578,14 @@ static void smbios_build_type_0_table(void) =20 t->bios_characteristics =3D cpu_to_le64(0x08); /* Not supported */ t->bios_characteristics_extension_bytes[0] =3D 0; - t->bios_characteristics_extension_bytes[1] =3D 0x14; /* TCD/SVVP | VM = */ + + t->bios_characteristics_extension_bytes[1] =3D 0x04; /* TCD/SVVP */ if (smbios_type0.uefi) { t->bios_characteristics_extension_bytes[1] |=3D 0x08; /* |=3D UEFI= */ } + if (smbios_type0.vm) { + t->bios_characteristics_extension_bytes[1] |=3D 0x10; /* |=3D VM */ + } =20 if (smbios_type0.have_major_minor) { t->system_bios_major_release =3D smbios_type0.major; @@ -1405,6 +1413,7 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) save_opt(&smbios_type0.version, opts, "version"); save_opt(&smbios_type0.date, opts, "date"); smbios_type0.uefi =3D qemu_opt_get_bool(opts, "uefi", false); + smbios_type0.vm =3D qemu_opt_get_bool(opts, "vm", true); =20 val =3D qemu_opt_get(opts, "release"); if (val) { diff --git a/qemu-options.hx b/qemu-options.hx index 075f4be2e3..3ff10ec09d 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2700,7 +2700,7 @@ DEF("smbios", HAS_ARG, QEMU_OPTION_smbios, "-smbios file=3Dbinary\n" " load SMBIOS entry from binary file\n" "-smbios type=3D0[,vendor=3Dstr][,version=3Dstr][,date=3Dstr][,release= =3D%d.%d]\n" - " [,uefi=3Don|off]\n" + " [,uefi=3Don|off][,vm=3Don|off]\n" " specify SMBIOS type 0 fields\n" "-smbios type=3D1[,manufacturer=3Dstr][,product=3Dstr][,version=3Dstr]= [,serial=3Dstr]\n" " [,uuid=3Duuid][,sku=3Dstr][,family=3Dstr]\n" --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692111; cv=none; d=zohomail.com; s=zohoarc; b=K+lBitzv5FChXGKD5A7KwNOPNrGhxc2Df0ycC/KNN7wj3zeYiE8JKT1WOnPaqgBrkycCBanTFIDOGJ8ipK/hei1l4TvPoxcjIwBCqxiAdTlO0BlN5og0CLLeVj8vy78eWXG8qa0HmMlKs0+Pt9eXezxT/uZgYK3bcQxZTOj5owE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692111; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dOCKC2S0m2zbzh2H7cOU9of3P5ijZS88mc28+6tUt50=; b=YWGVI6kgBxwVBF04fHqqea1fAgoNinuIAW/DScA5FrwDHEkfBKLJ+kKN9bMTHj0U22DwHYB60A8BB3SfLfHkr9JQMMIJtDSjWTCLlxeGeSJ1b9VabigHP42dmSOds3UPiaCtPdkC62ED5tD1aglUnoKErtwoMjR1NcDuDzSjadQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692111388149.75666041936597; Sun, 5 Oct 2025 12:21:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFG-0001mK-Cv; Sun, 05 Oct 2025 15:18:10 -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 1v5UEf-0008H6-Rk for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEa-0006Uc-ST for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:33 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-160-IHcidCO2Mtavujls939-7g-1; Sun, 05 Oct 2025 15:17:19 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3ecdc9dbc5fso2219180f8f.1 for ; Sun, 05 Oct 2025 12:17:19 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8b005dsm17262051f8f.25.2025.10.05.12.17.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691840; 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=dOCKC2S0m2zbzh2H7cOU9of3P5ijZS88mc28+6tUt50=; b=Yew6rGyE4wKRlIBwvIBZPP0Dwc6lthEEOLDfNTNBd4gAqzZrZ1zgLTUkehacg/CCJ5TIDc wAsIfTnea8pHvKjTta0GBYxVQpk6WSuUlEhNXYbcgp31XjB8u43BPBR8Ol06/rsYDuc7W1 kl7CJCxOS0d2/GScjIrkO7EDXxNR4sQ= X-MC-Unique: IHcidCO2Mtavujls939-7g-1 X-Mimecast-MFC-AGG-ID: IHcidCO2Mtavujls939-7g_1759691838 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691838; x=1760296638; 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=dOCKC2S0m2zbzh2H7cOU9of3P5ijZS88mc28+6tUt50=; b=nryl6RM27/u5csX+TW1ZHQAmcep02mA4Yz/in33AH53Co0hVhXTZlLPildXOmyWmyD Gk33DJRsXJ6RhRkYmvCl7Pk31CXnj2GCZegZridAHpNtNN+ni7Yp1yMmdRlcKvN8+kj2 aLw4Y41Lx1RR5YSiPJlFGw+lBQW1C54yRBUTrjKmOzIB75vmbGGtzpaellph1qJhAbN+ Pl4+dFJZrWgvbK2ZRiiWuROxUWa7I8DBU6D4cKmGtws5dyKZRefX14ItOHvrkbLPvAL5 hm2wRKO+TPHY/6BOPjOh4ws1PcHIEAjT53vKwlt0+Wg4rKtFR4GxYPP3duNQCYRRzhDa L5UQ== X-Gm-Message-State: AOJu0YwyOHYAYdNBX80ZCI1lY4aK3hvyp6zGmgk/jfWlOSfjHxujKL77 N5z++mium62BqNxKXSy9pP6YUfWtHX6JC3GoeRpgefAa39qT36856R5BL/tKU92NtpfBb8Zrqik BO0Va9+AriFqigEK19k7cy2Wkgl2+1epBu0TfkMnBvXYQpyA5kXdWoeaB3gjTliIksO5iAdO/mJ qwr1YiRDiMeuv/NfgPvN6IbQaL+L/FfY9UIQ== X-Gm-Gg: ASbGncvAXlg99fJiQLaekGrqGJqdhFo6wq4a5twy8my2iAihhRi0XzwUos7XuebozAH gOUFfvQEDMlITP4yJklcWy/vIazWWML24jhrgpY04kn/5+wTP5aGcl5R0QHK78JeXHb5D5lXbw7 uP38rkeD8Fm1Cwo1rV/cEnjnunbTTyeCtM/aWG+fLsrk8fe8adZVBigH7LrzkNh8mTlcKZygZax /ztj1tIvysHmQU9NJvVfeO7ZHhlAzljYhe/mn8Nu6kuiwCPbEYdcMewSZ1J3txi67FjOlZsGdnq 1xfu+rMj03w83MeJpfl6zYjo7yp/VsRFVEQvfYQ= X-Received: by 2002:a05:6000:230c:b0:3ec:3d75:1330 with SMTP id ffacd0b85a97d-425671b037amr5855601f8f.52.1759691837881; Sun, 05 Oct 2025 12:17:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAOXcUYCeB2FcO8USs1GdU7SBrgkIqd+6HNRwNmXnCWamr//pWSH1hwgv4H/Pqzx9zML1Kug== X-Received: by 2002:a05:6000:230c:b0:3ec:3d75:1330 with SMTP id ffacd0b85a97d-425671b037amr5855584f8f.52.1759691837364; Sun, 05 Oct 2025 12:17:17 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:15 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , peng guo , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 33/75] hw/i386/pc: Avoid overlap between CXL window and PCI 64bit BARs in QEMU 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692116891116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: peng guo When using a CXL Type 3 device together with a virtio 9p device in QEMU on a physical server, the 9p device fails to initialize properly. The kernel rep= orts the following error: virtio: device uses modern interface but does not have VIRTIO_F_VERSION= _1 9pnet_virtio virtio0: probe with driver 9pnet_virtio failed with error = -22 Further investigation revealed that the 64-bit BAR space assigned to the 9p= net device was overlapped by the memory window allocated for the CXL devices. A= s a result, the kernel could not correctly access the BAR region, causing the virtio device to malfunction. An excerpt from /proc/iomem shows: 480010000-cffffffff : CXL Window 0 480010000-4bfffffff : PCI Bus 0000:00 4c0000000-4c01fffff : PCI Bus 0000:0c 4c0000000-4c01fffff : PCI Bus 0000:0d 4c0200000-cffffffff : PCI Bus 0000:00 4c0200000-4c0203fff : 0000:00:03.0 4c0200000-4c0203fff : virtio-pci-modern To address this issue, this patch adds the reserved memory end calculation for cxl devices to reserve sufficient address space and ensure that CXL mem= ory windows are allocated beyond all PCI 64-bit BARs. This prevents overlap with 64-bit BARs regions such as those used by virtio or other pcie devices, resolving the conflict. QEMU Build Configuration: ./configure --prefix=3D/home/work/qemu_master/build/ \ --target-list=3Dx86_64-softmmu \ --enable-kvm \ --enable-virtfs QEMU Boot Command: sudo /home/work/qemu_master/qemu/build/qemu-system-x86_64 \ -nographic -machine q35,cxl=3Don -enable-kvm -m 16G -smp 8 \ -hda /home/work/gp_qemu/rootfs.img \ -virtfs local,path=3D/home/work/gp_qemu/share,mount_tag=3Dhost0,sec= urity_model=3Dpassthrough,id=3Dhost0 \ -kernel /home/work/linux_output/arch/x86/boot/bzImage \ --append "console=3DttyS0 crashkernel=3D256M root=3D/dev/sda rootfs= type=3Dext4 rw loglevel=3D8" \ -object memory-backend-ram,id=3Dvmem0,share=3Don,size=3D4096M \ -device pxb-cxl,bus_nr=3D12,bus=3Dpcie.0,id=3Dcxl.1 \ -device cxl-rp,port=3D0,bus=3Dcxl.1,id=3Droot_port13,chassis=3D0,sl= ot=3D2 \ -device cxl-type3,bus=3Droot_port13,volatile-memdev=3Dvmem0,id=3Dcx= l-vmem0,sn=3D0x123456789 \ -M cxl-fmw.0.targets.0=3Dcxl.1,cxl-fmw.0.size=3D4G Fixes: 03b39fcf64bc ("hw/cxl: Make the CXL fixed memory window setup a mach= ine parameter") Signed-off-by: peng guo Reviewed-by: Michael S. Tsirkin Message-ID: <20250805142300.15226-1-engguopeng@buaa.edu.cn> Signed-off-by: Michael S. Tsirkin --- hw/i386/pc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index bc048a6d13..eb36d50589 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -837,6 +837,7 @@ void pc_memory_init(PCMachineState *pcms, hwaddr maxphysaddr, maxusedaddr; hwaddr cxl_base, cxl_resv_end =3D 0; X86CPU *cpu =3D X86_CPU(first_cpu); + uint64_t res_mem_end; =20 assert(machine->ram_size =3D=3D x86ms->below_4g_mem_size + x86ms->above_4g_mem_size); @@ -978,16 +979,17 @@ void pc_memory_init(PCMachineState *pcms, =20 rom_set_fw(fw_cfg); =20 - if (machine->device_memory) { - uint64_t *val =3D g_malloc(sizeof(*val)); - uint64_t res_mem_end; + if (pcms->cxl_devices_state.is_enabled) { + res_mem_end =3D cxl_resv_end; + } else if (machine->device_memory) { + res_mem_end =3D machine->device_memory->base + + memory_region_size(&machine->device_memory->mr); + } else { + res_mem_end =3D 0; + } =20 - if (pcms->cxl_devices_state.is_enabled) { - res_mem_end =3D cxl_resv_end; - } else { - res_mem_end =3D machine->device_memory->base - + memory_region_size(&machine->device_memory->mr= ); - } + if (res_mem_end) { + uint64_t *val =3D g_malloc(sizeof(*val)); *val =3D cpu_to_le64(ROUND_UP(res_mem_end, 1 * GiB)); fw_cfg_add_file(fw_cfg, "etc/reserved-memory-end", val, sizeof(*va= l)); } --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692203; cv=none; d=zohomail.com; s=zohoarc; b=I7kLY5SL0gzOjp36Y4a64bGier03OmVhcWHfcaW1EovPfVIrSEHsyi0mI+THhXpRv8lS13bH9YLCsPNlnTiCR3N/EHVfnSLRTNOegetaYoTjFmpBJzECaxXydsU1WiCFqZgTsIbNwC8T68zNItz6lWS5E7KuggVnUfc7HeTxg0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692203; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=n5WvGc63Ugvtn6YJdDflpDJWvjGDbZWJM3c/1ewQ4RE=; b=H5XUBG3uBkhW0f2Q1wYE1zTMiUjZ7jIElx/na4+Ch+s0xxXr1t+6jI1aO8TixwAd4xqylj/QN7JnqtPvDS3G7jvgVoUBpQQW1OjBCYmkn4NcoHb7Ahl3iyxRUo/hjo6JUNY+mriKRczJksFGi4cYl+KSPJNR4cFBN9dw1ON1eLY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692203585803.3104719466519; Sun, 5 Oct 2025 12:23:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UF8-0000iA-St; Sun, 05 Oct 2025 15:18: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 1v5UEe-000891-3E for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:32 -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 1v5UEa-0006Uw-Mx for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:31 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-3M6dB2fxNvq-Z3OeXYfx3A-1; Sun, 05 Oct 2025 15:17:22 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3ed9557f976so2674309f8f.3 for ; Sun, 05 Oct 2025 12:17:22 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f45e9sm17822998f8f.51.2025.10.05.12.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691843; 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=n5WvGc63Ugvtn6YJdDflpDJWvjGDbZWJM3c/1ewQ4RE=; b=ZroAUGUzXWqsXKrjOPAM0S4LX4giC5XfW5Snm9hemrkNQ9qxsZajfia31eIvy3B2D4tFR9 MGZ2V68EHw5/uBJrj1Hj0llwSOVOv/KkPwTgxEwzTbgvUUC/61FiUbvvbL5WEuAsf4TISj VsjKzLx0C7KqqI5XQt6qu2i0/F90uNE= X-MC-Unique: 3M6dB2fxNvq-Z3OeXYfx3A-1 X-Mimecast-MFC-AGG-ID: 3M6dB2fxNvq-Z3OeXYfx3A_1759691841 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691841; x=1760296641; 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=n5WvGc63Ugvtn6YJdDflpDJWvjGDbZWJM3c/1ewQ4RE=; b=gxp5Es/pD5Fu3g9i8h60YQpwPPiM+fhPsWVW9JpHxRt+ErXcodar39380PYuDl+kc7 corFHpDCK6fKLFvJW48vTitZR+uq9e40BoZj42M/deSOwld1DrZSW+QuLxd2UkFy7PoE Y78r7MLfEKrg9DB62BYi+fwwW2vUmwcxSZG2wLJXZtFmlxaB/NiWcfSnGtWZb5IhOCTw oGcyrHRQDValz7tBY4aUPtpcYM+VGOmzwjgb6/Fr+04Uce7Uv/HRbCEB8EVYuUyvni9d EAsnITPAouxYC2Iuzlpd94sez+L0fxoTVYXqR2hh0N8a9OD4cbqTpvoyrkQZ8qrezgOC K/1w== X-Gm-Message-State: AOJu0YxI6TamIHFPC5adCOOh7mA8DBHSCgbZyQgMY/sTS0RDV/KwOqAn MhIWXDTzJSaucr7tIuzl/inncMnJ6jZoz3vC68SJFwnToPQJbTmj2h15vTWi9G+gidm2xYI1nxy Cxzs2Cm6Njra245yCIYW3qt46XjrdLf+BLh4hcK6nVlyU/cWqIQfUp0VO+3n33xjoWdxj5wMyO5 1Kg3Bzc/9Sz7Gus+kTvXMzSoCRJxjs151Y8w== X-Gm-Gg: ASbGncuqynYMmpTAj2ICokBKz1qfe4lgK/uqREAJazKkEuOuMXtZqRB2JKpLPkibJ9b lh3QZQ6b/A5Sp0vED9Za+1LZyczdIMQdzoI/tLzoKFqcgQkaKILOZQJoDWZVZOlgQlflIuUySqy TpxmWlWv7Wrmuor/k0c8e8y2n2KOhwKAp0NEosNyLm+XXjy/b2LSPOkLm8/BMK/1w6x6FfZvojT vO3mJWISz9gDPUcawW3vHHiDZdnMY9YgXm3xOldlA6PTZ4HinSe4q6GnBd216uzBpwlJJLGblvq 42XdwzSTO0ZQDc+D2k98cXk94ui0/n2kf66xMyM= X-Received: by 2002:a05:6000:2289:b0:411:3c14:3aac with SMTP id ffacd0b85a97d-4256713be79mr5871227f8f.7.1759691840608; Sun, 05 Oct 2025 12:17:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE27CTVi53eXQm7AWxxDMWA9CZFQp5U0Lv8gyfXCy4U7U2VzH60ccOncgr7hbITZIZ3ACyHmw== X-Received: by 2002:a05:6000:2289:b0:411:3c14:3aac with SMTP id ffacd0b85a97d-4256713be79mr5871203f8f.7.1759691839805; Sun, 05 Oct 2025 12:17:19 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:17 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Damien Bergamini , Clement Mathieu--Drif , Akihiko Odaki , Marcel Apfelbaum , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Jesper Devantier , qemu-block@nongnu.org Subject: [PULL 34/75] pcie_sriov: Fix broken MMIO accesses from SR-IOV VFs Message-ID: <2e54e5fda779a7ba45578884276dca62462f7a06.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692207934116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Damien Bergamini Starting with commit cab1398a60eb, SR-IOV VFs are realized as soon as pcie_sriov_pf_init() is called. Because pcie_sriov_pf_init() must be called before pcie_sriov_pf_init_vf_bar(), the VF BARs types won't be known when the VF realize function calls pcie_sriov_vf_register_bar(). This breaks the memory regions of the VFs (for instance with igbvf): $ lspci ... Region 0: Memory at 281a00000 (64-bit, prefetchable) [virtual] [size=3D= 16K] Region 3: Memory at 281a20000 (64-bit, prefetchable) [virtual] [size=3D= 16K] $ info mtree ... address-space: pci_bridge_pci_mem 0000000000000000-ffffffffffffffff (prio 0, i/o): pci_bridge_pci 0000000081a00000-0000000081a03fff (prio 1, i/o): igbvf-mmio 0000000081a20000-0000000081a23fff (prio 1, i/o): igbvf-msix and causes MMIO accesses to fail: Invalid write at addr 0x281A01520, size 4, region '(null)', reason: rej= ected Invalid read at addr 0x281A00C40, size 4, region '(null)', reason: reje= cted To fix this, VF BARs are now registered with pci_register_bar() which has a type parameter and pcie_sriov_vf_register_bar() is removed. Fixes: cab1398a60eb ("pcie_sriov: Reuse SR-IOV VF device instances") Signed-off-by: Damien Bergamini Signed-off-by: Clement Mathieu--Drif Reviewed-by: Akihiko Odaki Reviewed-by: Michael S. Tsirkin Message-ID: <20250901151314.1038020-1-clement.mathieu--drif@eviden.com> Signed-off-by: Michael S. Tsirkin --- docs/pcie_sriov.txt | 5 ++--- include/hw/pci/pcie_sriov.h | 4 ---- hw/net/igbvf.c | 6 ++++-- hw/nvme/ctrl.c | 8 ++------ hw/pci/pci.c | 3 --- hw/pci/pcie_sriov.c | 11 ----------- 6 files changed, 8 insertions(+), 29 deletions(-) diff --git a/docs/pcie_sriov.txt b/docs/pcie_sriov.txt index ab2142807f..00d7bd93fd 100644 --- a/docs/pcie_sriov.txt +++ b/docs/pcie_sriov.txt @@ -72,8 +72,7 @@ setting up a BAR for a VF. 2) Similarly in the implementation of the virtual function, you need to make it a PCI Express device and add a similar set of capabilities except for the SR/IOV capability. Then you need to set up the VF BARs as - subregions of the PFs SR/IOV VF BARs by calling - pcie_sriov_vf_register_bar() instead of the normal pci_register_bar() c= all: + subregions of the PFs SR/IOV VF BARs by calling pci_register_bar(): =20 pci_your_vf_dev_realize( ... ) { @@ -83,7 +82,7 @@ setting up a BAR for a VF. pcie_ari_init(d, 0x100); ... memory_region_init(mr, ... ) - pcie_sriov_vf_register_bar(d, bar_nr, mr); + pci_register_bar(d, bar_nr, bar_type, mr); ... } =20 diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index aeaa38cf34..b0ea6a62c7 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -37,10 +37,6 @@ void pcie_sriov_pf_exit(PCIDevice *dev); void pcie_sriov_pf_init_vf_bar(PCIDevice *dev, int region_num, uint8_t type, dma_addr_t size); =20 -/* Instantiate a bar for a VF */ -void pcie_sriov_vf_register_bar(PCIDevice *dev, int region_num, - MemoryRegion *memory); - /** * pcie_sriov_pf_init_from_user_created_vfs() - Initialize PF with user-cr= eated * VFs, adding ARI to PF diff --git a/hw/net/igbvf.c b/hw/net/igbvf.c index 31d72c4977..9b0db8f841 100644 --- a/hw/net/igbvf.c +++ b/hw/net/igbvf.c @@ -251,10 +251,12 @@ static void igbvf_pci_realize(PCIDevice *dev, Error *= *errp) =20 memory_region_init_io(&s->mmio, OBJECT(dev), &mmio_ops, s, "igbvf-mmio= ", IGBVF_MMIO_SIZE); - pcie_sriov_vf_register_bar(dev, IGBVF_MMIO_BAR_IDX, &s->mmio); + pci_register_bar(dev, IGBVF_MMIO_BAR_IDX, PCI_BASE_ADDRESS_MEM_TYPE_64= | + PCI_BASE_ADDRESS_MEM_PREFETCH, &s->mmio); =20 memory_region_init(&s->msix, OBJECT(dev), "igbvf-msix", IGBVF_MSIX_SIZ= E); - pcie_sriov_vf_register_bar(dev, IGBVF_MSIX_BAR_IDX, &s->msix); + pci_register_bar(dev, IGBVF_MSIX_BAR_IDX, PCI_BASE_ADDRESS_MEM_TYPE_64= | + PCI_BASE_ADDRESS_MEM_PREFETCH, &s->msix); =20 ret =3D msix_init(dev, IGBVF_MSIX_VEC_NUM, &s->msix, IGBVF_MSIX_BAR_ID= X, 0, &s->msix, IGBVF_MSIX_BAR_IDX, 0x2000, 0x70, errp); diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index f5ee6bf260..cd81f73997 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8708,12 +8708,8 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pc= i_dev, Error **errp) msix_table_offset); memory_region_add_subregion(&n->bar0, 0, &n->iomem); =20 - if (pci_is_vf(pci_dev)) { - pcie_sriov_vf_register_bar(pci_dev, 0, &n->bar0); - } else { - pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | - PCI_BASE_ADDRESS_MEM_TYPE_64, &n->bar0); - } + pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_TYPE_64, &n->bar0); =20 ret =3D msix_init(pci_dev, nr_vectors, &n->bar0, 0, msix_table_offset, diff --git a/hw/pci/pci.c b/hw/pci/pci.c index c3df9d6656..4854d3d618 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1491,9 +1491,6 @@ void pci_register_bar(PCIDevice *pci_dev, int region_= num, : pci_get_bus(pci_dev)->address_space_mem; =20 if (pci_is_vf(pci_dev)) { - PCIDevice *pf =3D pci_dev->exp.sriov_vf.pf; - assert(!pf || type =3D=3D pf->exp.sriov_pf.vf_bar_type[region_num]= ); - r->addr =3D pci_bar_address(pci_dev, region_num, r->type, r->size); if (r->addr !=3D PCI_BAR_UNMAPPED) { memory_region_add_subregion_overlap(r->address_space, diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 8a4bf0d6f7..29474d749a 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -242,17 +242,6 @@ void pcie_sriov_pf_init_vf_bar(PCIDevice *dev, int reg= ion_num, dev->exp.sriov_pf.vf_bar_type[region_num] =3D type; } =20 -void pcie_sriov_vf_register_bar(PCIDevice *dev, int region_num, - MemoryRegion *memory) -{ - uint8_t type; - - assert(dev->exp.sriov_vf.pf); - type =3D dev->exp.sriov_vf.pf->exp.sriov_pf.vf_bar_type[region_num]; - - return pci_register_bar(dev, region_num, type, memory); -} - static gint compare_vf_devfns(gconstpointer a, gconstpointer b) { return (*(PCIDevice **)a)->devfn - (*(PCIDevice **)b)->devfn; --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691922; cv=none; d=zohomail.com; s=zohoarc; b=jyIKgcLxnk0PJMcuB43Ai3w15r4JHT9ypokZensbFdgVgg7NUsiX/9JMWdml2IRCM3weuKrq8fNPAfDT1meqJ/YfHHjEFWYWq2E2U5gDSYCFwjRl+9sqtniwRdBAtl5jX64QQe4nGdaGURPnKuwaqxQPvSwjOT7Iq+8D9e9M6T4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691922; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mfKdz/3nMvjpW+z6FeaL4DezlsHzfdVMCcRVA0zYnAA=; b=a9yGG5QpBXcW1ilA/fO8VtYfmpOiP+/sHxUcMOsgqR/D6LcCVPglZBGpNi0A2SV5+gFezSaeMH1RiEgmxDC8X+gs9R/6dv7rpMMNBtbV4+3iesPwbDlQryLy89N6WOi7B/ZuZhOuUlMNNtYpLFdERXtYCjHYlIiUoNNTmHPUSoI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691922526999.0253787878386; Sun, 5 Oct 2025 12:18:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UEm-00009R-Gt; Sun, 05 Oct 2025 15:17:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEe-00089v-CW for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEa-0006VM-Mm for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:32 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-350-4ydYZVfFPM6FRql5mRipXQ-1; Sun, 05 Oct 2025 15:17:24 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e31191379so26933245e9.3 for ; Sun, 05 Oct 2025 12:17:24 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a8542sm17438120f8f.9.2025.10.05.12.17.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691845; 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=mfKdz/3nMvjpW+z6FeaL4DezlsHzfdVMCcRVA0zYnAA=; b=cKDAsiFkXAvBSauY7NukK7KXanLoQ0J/kv6WVwChaZDI18BDMh3hWX/Wax5IMRsHuJYe77 +yVJPCcZaik/J9V+5elo/C7DSydwmdQQm47qC1rm+r5lcDhsMypOZJ+9iTDsSsrFGWd0Xp oyzTFGROvsmdUJKpFvSzRJPEQ+UC3qU= X-MC-Unique: 4ydYZVfFPM6FRql5mRipXQ-1 X-Mimecast-MFC-AGG-ID: 4ydYZVfFPM6FRql5mRipXQ_1759691843 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691843; x=1760296643; 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=mfKdz/3nMvjpW+z6FeaL4DezlsHzfdVMCcRVA0zYnAA=; b=frp1CMPhHJdVp5yfFWYAt7sPftTEjaz0xJH2VrPi/0BwPMVWBeB6myvldZOKmrF/FW mZr/hTNVMc3M4M7K76m8tJlYB8B8fbmATG7W+4Wv3Bz9uZUsVkSCl55VJDwAFXxFnFRX A4BjVmILGie0UWmjZFVEqAlbAAea+wGqV1vk+T0762IGr44I4SNiUNjva14EE3gu2cng Va8bwUKIqCJu73jQQ+VBW9X04iumDTqZB3fsxOblhkjiensNInL8AeTYezL8NRNNj40d Rz1Icq8/0DQxXAQrvqq5TPT40338z0xvksI6bGjJBX5QTTKmULM9MiyPwRTH9LnWLp40 d1vg== X-Gm-Message-State: AOJu0YzvkO+oXxIf31MLwSlPj1NDUR9KPUIvZRLbIUm4VqMZGsIpoOxf znxxSXmrHzq2htXB/gv6nDzqvzu6TJq1Gc6LokWXYU1cxtPZKZmzPw1w8DCPhxH1pq31AVNEBLp pd9q5TwZt3dbDepI2GIt3w1fWkICKqS/F9dgj/4YWsO7hedDyOm9QHk/mgrVcQDEBVcDl4u6C4N 7IY8JelvB5cos4gZBrbe5Ewu3Pk+fvZzz/tQ== X-Gm-Gg: ASbGncuM0FrAO82NM6hGJN/dzb416MrRB5ADL3t1+wI3UMNFh7tdUaS7FyQ0ThRl1Rt hkCodLMXkTl7uzQB2JYZwAjdA3S2HtF4ct+pNyAYDJa8k+IcNeiAg3P9jsqLib5pDNjVQzciIoy qvB2BkW7EM5mtY+s/pCtUAdqDNZt1jxkMQhPD9IJmW+WhRoZ6fLh9l3Ln15VN+vQLiKvc86KeRz Z+K7RphcP2ajwhlHzA+UhsfxkMto3yUyNIMUdWbJpv1zMf9gQeavPFeY3T7onzCNwk29MbVs/61 oWhuRsb8Fyg7FQNS2hJTVLi53vKB7RMY+zCPeY8= X-Received: by 2002:a05:600c:a103:b0:46e:731b:db0f with SMTP id 5b1f17b1804b1-46e731bdd23mr38825605e9.28.1759691842626; Sun, 05 Oct 2025 12:17:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/V5c7E9+JjAlIc9G9YdonWDZA0/PtZBjw04TKhvrfr2K5/2RKowjcleGT+zF8K6V2Mg16RA== X-Received: by 2002:a05:600c:a103:b0:46e:731b:db0f with SMTP id 5b1f17b1804b1-46e731bdd23mr38825445e9.28.1759691841958; Sun, 05 Oct 2025 12:17:21 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:20 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alex =?utf-8?Q?Benn=C3=A9e?= , Stefano Garzarella , Manos Pitsidianakis , Stefan Hajnoczi , Paolo Bonzini Subject: [PULL 35/75] hw/virtio: rename vhost-user-device and make user creatable Message-ID: <722e9022a0b6db175209bad75aa52b24033249e3.1759691708.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691923602116600 From: Alex Benn=C3=A9e We didn't make the device user creatable in the first place because we were worried users might get confused. Rename the device to make its nature as a test device even more explicit. While we are at it add a Kconfig variable so it can be skipped for those that want to thin out their build configuration even further. Acked-by: Stefano Garzarella Reviewed-by: Manos Pitsidianakis Reviewed-by: Stefan Hajnoczi Signed-off-by: Alex Benn=C3=A9e Message-ID: <20250820195632.1956795-1-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Message-ID: <20250901105948.982583-1-alex.bennee@linaro.org> Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/vhost-user-base.h | 2 +- ...ice-pci.c =3D> vhost-user-test-device-pci.c} | 17 +++++++--------- ...user-device.c =3D> vhost-user-test-device.c} | 9 +++------ docs/system/devices/vhost-user.rst | 20 +++++++------------ hw/virtio/Kconfig | 5 +++++ hw/virtio/meson.build | 5 +++-- 6 files changed, 26 insertions(+), 32 deletions(-) rename hw/virtio/{vhost-user-device-pci.c =3D> vhost-user-test-device-pci.= c} (77%) rename hw/virtio/{vhost-user-device.c =3D> vhost-user-test-device.c} (87%) diff --git a/include/hw/virtio/vhost-user-base.h b/include/hw/virtio/vhost-= user-base.h index 51d0968b89..387e434b80 100644 --- a/include/hw/virtio/vhost-user-base.h +++ b/include/hw/virtio/vhost-user-base.h @@ -44,6 +44,6 @@ struct VHostUserBaseClass { }; =20 =20 -#define TYPE_VHOST_USER_DEVICE "vhost-user-device" +#define TYPE_VHOST_USER_TEST_DEVICE "vhost-user-test-device" =20 #endif /* QEMU_VHOST_USER_BASE_H */ diff --git a/hw/virtio/vhost-user-device-pci.c b/hw/virtio/vhost-user-test-= device-pci.c similarity index 77% rename from hw/virtio/vhost-user-device-pci.c rename to hw/virtio/vhost-user-test-device-pci.c index f10bac874e..b4ed0efb50 100644 --- a/hw/virtio/vhost-user-device-pci.c +++ b/hw/virtio/vhost-user-test-device-pci.c @@ -18,13 +18,13 @@ struct VHostUserDevicePCI { VHostUserBase vub; }; =20 -#define TYPE_VHOST_USER_DEVICE_PCI "vhost-user-device-pci-base" +#define TYPE_VHOST_USER_TEST_DEVICE_PCI "vhost-user-test-device-pci-base" =20 -OBJECT_DECLARE_SIMPLE_TYPE(VHostUserDevicePCI, VHOST_USER_DEVICE_PCI) +OBJECT_DECLARE_SIMPLE_TYPE(VHostUserDevicePCI, VHOST_USER_TEST_DEVICE_PCI) =20 static void vhost_user_device_pci_realize(VirtIOPCIProxy *vpci_dev, Error = **errp) { - VHostUserDevicePCI *dev =3D VHOST_USER_DEVICE_PCI(vpci_dev); + VHostUserDevicePCI *dev =3D VHOST_USER_TEST_DEVICE_PCI(vpci_dev); DeviceState *vdev =3D DEVICE(&dev->vub); =20 vpci_dev->nvectors =3D 1; @@ -38,9 +38,6 @@ static void vhost_user_device_pci_class_init(ObjectClass = *klass, VirtioPCIClass *k =3D VIRTIO_PCI_CLASS(klass); PCIDeviceClass *pcidev_k =3D PCI_DEVICE_CLASS(klass); =20 - /* Reason: stop users confusing themselves */ - dc->user_creatable =3D false; - k->realize =3D vhost_user_device_pci_realize; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); pcidev_k->vendor_id =3D PCI_VENDOR_ID_REDHAT_QUMRANET; @@ -51,15 +48,15 @@ static void vhost_user_device_pci_class_init(ObjectClas= s *klass, =20 static void vhost_user_device_pci_instance_init(Object *obj) { - VHostUserDevicePCI *dev =3D VHOST_USER_DEVICE_PCI(obj); + VHostUserDevicePCI *dev =3D VHOST_USER_TEST_DEVICE_PCI(obj); =20 virtio_instance_init_common(obj, &dev->vub, sizeof(dev->vub), - TYPE_VHOST_USER_DEVICE); + TYPE_VHOST_USER_TEST_DEVICE); } =20 static const VirtioPCIDeviceTypeInfo vhost_user_device_pci_info =3D { - .base_name =3D TYPE_VHOST_USER_DEVICE_PCI, - .non_transitional_name =3D "vhost-user-device-pci", + .base_name =3D TYPE_VHOST_USER_TEST_DEVICE_PCI, + .non_transitional_name =3D "vhost-user-test-device-pci", .instance_size =3D sizeof(VHostUserDevicePCI), .instance_init =3D vhost_user_device_pci_instance_init, .class_init =3D vhost_user_device_pci_class_init, diff --git a/hw/virtio/vhost-user-device.c b/hw/virtio/vhost-user-test-devi= ce.c similarity index 87% rename from hw/virtio/vhost-user-device.c rename to hw/virtio/vhost-user-test-device.c index 3939bdf755..1b98ea3e48 100644 --- a/hw/virtio/vhost-user-device.c +++ b/hw/virtio/vhost-user-test-device.c @@ -1,5 +1,5 @@ /* - * Generic vhost-user-device implementation for any vhost-user-backend + * Generic vhost-user-test-device implementation for any vhost-user-backend * * This is a concrete implementation of vhost-user-base which can be * configured via properties. It is useful for development and @@ -25,7 +25,7 @@ */ =20 static const VMStateDescription vud_vmstate =3D { - .name =3D "vhost-user-device", + .name =3D "vhost-user-test-device", .unmigratable =3D 1, }; =20 @@ -41,16 +41,13 @@ static void vud_class_init(ObjectClass *klass, const vo= id *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 - /* Reason: stop inexperienced users confusing themselves */ - dc->user_creatable =3D false; - device_class_set_props(dc, vud_properties); dc->vmsd =3D &vud_vmstate; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); } =20 static const TypeInfo vud_info =3D { - .name =3D TYPE_VHOST_USER_DEVICE, + .name =3D TYPE_VHOST_USER_TEST_DEVICE, .parent =3D TYPE_VHOST_USER_BASE, .class_init =3D vud_class_init, }; diff --git a/docs/system/devices/vhost-user.rst b/docs/system/devices/vhost= -user.rst index 35259d8ec7..bddf8df5ed 100644 --- a/docs/system/devices/vhost-user.rst +++ b/docs/system/devices/vhost-user.rst @@ -62,26 +62,20 @@ platform details for what sort of virtio bus to use. The referenced *daemons* are not exhaustive, any conforming backend implementing the device and using the vhost-user protocol should work. =20 -vhost-user-device -^^^^^^^^^^^^^^^^^ +vhost-user-test-device +^^^^^^^^^^^^^^^^^^^^^^ =20 -The vhost-user-device is a generic development device intended for -expert use while developing new backends. The user needs to specify -all the required parameters including: +The vhost-user-test-device is a generic development device intended +for expert use while developing new backends. The user needs to +specify all the required parameters including: =20 - Device ``virtio-id`` - The ``num_vqs`` it needs and their ``vq_size`` - The ``config_size`` if needed =20 .. note:: - To prevent user confusion you cannot currently instantiate - vhost-user-device without first patching out:: - - /* Reason: stop inexperienced users confusing themselves */ - dc->user_creatable =3D false; - - in ``vhost-user-device.c`` and ``vhost-user-device-pci.c`` file and - rebuilding. + While this is a useful device for development it is not recommended + for production use. =20 vhost-user daemon =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/hw/virtio/Kconfig b/hw/virtio/Kconfig index 7648a2d68d..10f5c53ac0 100644 --- a/hw/virtio/Kconfig +++ b/hw/virtio/Kconfig @@ -126,3 +126,8 @@ config VHOST_USER_SCMI bool default y depends on VIRTIO && VHOST_USER && ARM + +config VHOST_USER_TEST + bool + default y + depends on VIRTIO && VHOST_USER diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 3ea7b3cec8..48b9fedfa5 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -22,7 +22,7 @@ if have_vhost system_virtio_ss.add(files('vhost-user-base.c')) =20 # MMIO Stubs - system_virtio_ss.add(files('vhost-user-device.c')) + system_virtio_ss.add(when: 'CONFIG_VHOST_USER_TEST', if_true: files('v= host-user-test-device.c')) system_virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('v= host-user-gpio.c')) system_virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vh= ost-user-i2c.c')) system_virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vh= ost-user-rng.c')) @@ -30,7 +30,8 @@ if have_vhost system_virtio_ss.add(when: 'CONFIG_VHOST_USER_INPUT', if_true: files('= vhost-user-input.c')) =20 # PCI Stubs - system_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-= user-device-pci.c')) + system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_TE= ST'], + if_true: files('vhost-user-test-device-pci.c')) system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GP= IO'], if_true: files('vhost-user-gpio-pci.c')) system_virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_I2= C'], --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692405; cv=none; d=zohomail.com; s=zohoarc; b=eQ4oDF7VVkitOqsToOcYdQuwVKdYhX12v5XuftRINZEAItK/h4eYO4knsDVbT1Fv4KaQmQUDJ41Z/+oFGXtjC0l0CwUBhYDnEfcAfzCvlPoJlC9YbYLRDgvkjkYWHvRZ4WVHNX5skhPGTfYgz5SJ/tzExcrYpPRas33VOk7HbAw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692405; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3aFxoIeUx803jBt31fbg+H6tlPcEQbGoaOIOlfDZlQk=; b=UUkSetafiO/clG03hErF3MQTMQ4iu5IqW8xbSnZZqB3ysZ260n8EDyD1/FR5G9k49D6u6CPtIbfvn4V5SfGB/ibF+Gyjr90IxEw7LlS7iuu9JlhAUgQ/Sh84+XbJU0LV2e/FdjOQw03vr3PDhgkW2vxzhrSOOvewvHyTOyTKEt4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692405536314.8823893195788; Sun, 5 Oct 2025 12:26:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFD-0001KQ-SK; Sun, 05 Oct 2025 15:18: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 1v5UEc-00085c-MZ for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEa-0006VX-ML for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:30 -0400 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-532-uq1zFbmuMPOy2kHo9jclLw-1; Sun, 05 Oct 2025 15:17:26 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3ece0fd841cso2209893f8f.0 for ; Sun, 05 Oct 2025 12:17:26 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6b77sm17443982f8f.6.2025.10.05.12.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691848; 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=3aFxoIeUx803jBt31fbg+H6tlPcEQbGoaOIOlfDZlQk=; b=fjIG2gi60r2L912QkI0PaDuzZDULQT97Y0MZyDj9SIjQ3OBzMZV6tukgyAyVrq9spxfFmP c0GKpKNbewkLNS39btKh0rIh6lsTIr5iG3N74XI57dcZPCUKYG46p6NnyicB4GjvKKr98m G3H+3AymS8TqiDEVMGhbst/n7C0svoQ= X-MC-Unique: uq1zFbmuMPOy2kHo9jclLw-1 X-Mimecast-MFC-AGG-ID: uq1zFbmuMPOy2kHo9jclLw_1759691845 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691845; x=1760296645; 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=3aFxoIeUx803jBt31fbg+H6tlPcEQbGoaOIOlfDZlQk=; b=bFvcGl4gKWQwytSAU576pKYgG0ZHFppiJHFg8B6KY139VP5UV//jy+8n6LqekUMZfI N7rGniOvk5rYMPysuMSfLBiF3w2fB7yG4Duh/AAQ9FdGYqZx5CJj9sFMotsvqzprVAqu xdLpIpJHitWjY9Ofj9XGKuib4YdJBIc4RS0NReidvg7R01G8eUBEGf9BovHGXfR2SmtU Xb4dHdtPLOYffYjodE29csaPz2DUiLqnKrh+KbNRu7EOUzRnacjC8drii0wZumMrpr73 DMX+V5ipbXFsrRMU938SQAxr+2obOfOBBrwzRYvmTm6xZ75cpop4+fkhTgurdggQxN0r u2Gg== X-Gm-Message-State: AOJu0Yx1RJ71PlXnHea/XDXD4h0N1+ssTNdAp50c0KctuI3WCO1JDaMw aMwFlG1F515F54a0NCIdeOKfqnPjRummhwckK83mKV0c/yVzS4VakM7GYRes5mRZG9JCnRgQ9Gn 6oxVU72VdW1j3xuiTUzxuA0P3wDTj4zZAsCgruPJdBh/b2VUTTRT9eE67NBtpBlbagVeqbAKGNB /iClwPl13ThJdtx0pWZ5OdkhotsnwZYQJuWQ== X-Gm-Gg: ASbGncvupvXngvhqb6sX97XOIsZudKfLAgqDwE7iUiwGA6W+SLjJafyQGdfKoLVixi7 eIZbKieXROMl0d4tGa4JyS+HfQxhNKV9XLyvHrCQwzD3K/cDDD4pGZL4B5VITJgyYrBlktd+W/9 3ePfl8gNEWY/8qUiUTp4SGMHHM+6NKVCDjT/Rl2qHrYX4MlGFS5HAut7997DzzsJ8bqrXG9OthW hOBLJ9/fkcVZ+gaXGp3T6dTHsOKsuIyp2WJ6vyXNtam5H6gCUwcLsuIY1eAztBUE1uJWPcPRVtq ira009Hky8cnKspwlzfeJ4xWpxoxfx6cwX13qNc= X-Received: by 2002:a05:600c:8b45:b0:46e:3dc2:ebac with SMTP id 5b1f17b1804b1-46e71168aa1mr67453965e9.27.1759691844971; Sun, 05 Oct 2025 12:17:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtSfa6Jgje5/BQ9bLxLZ5mbImqTOeqLt2mPARjKRMASsh58YgMsenlfLpaeNGUrpDk1crB/g== X-Received: by 2002:a05:600c:8b45:b0:46e:3dc2:ebac with SMTP id 5b1f17b1804b1-46e71168aa1mr67453745e9.27.1759691844328; Sun, 05 Oct 2025 12:17:24 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:22 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Igor Mammedov , Eduardo Habkost , Marcel Apfelbaum , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Yanan Wang , Zhao Liu , Paolo Bonzini , Richard Henderson , qemu-arm@nongnu.org Subject: [PULL 36/75] smbios: cap DIMM size to 2Tb as workaround for broken Windows Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692408566116600 From: Igor Mammedov With current limit set to match max spec size (2PTb), Windows fails to parse type 17 records when DIMM size reaches 4Tb+. Failure happens in GetPhysicallyInstalledSystemMemory() function, and fails "Check SMBIOS System Memory Tables" SVVP test. Though not fatal, it might cause issues for userspace apps, something like [1]. Lets cap default DIMM size to 2Tb for now, until MS fixes it. 1) https://issues.redhat.com/browse/RHEL-81999?focusedId=3D27731200&page=3D= com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-27= 731200 PS: It's obvious 32 int overflow math somewhere in Windows, MS admitted that it's Windows bug and in a process of fixing it. However it's unclear if W10 and earlier would get the fix. So however I dislike changing defaults, we heed to work around the issue (it looks like QEMU regression while not being it). Hopefully 2Tb/DIMM split will last longer until VM memory size will become large enough to cause to many type 17 records issue again. PPS: Alternatively, instead of messing with defaults, we can create a dedicated knob to ask for desired DIMM size cap explicitly on CLI. That will let users to enable workaround when they hit this corner case. Downside is that knob has to be propagated up all mgmt stack, which might be not desirable. PPPS: Yet alternatively, users can configure initial RAM to be less than 4Tb and all additional RAM add as DIMMs on QEMU CLI. (however it's the job to be done by mgmt which could know Windows version and total amount of RAM) Signed-off-by: Igor Mammedov Fixes: 62f182c97b ("smbios: make memory device size configurable per Machin= e") Reviewed-by: Michael S. Tsirkin Message-ID: <20250901084915.2607632-1-imammedo@redhat.com> Signed-off-by: Michael S. Tsirkin --- hw/arm/virt.c | 1 + hw/core/machine.c | 5 ++++- hw/i386/pc_piix.c | 1 + hw/i386/pc_q35.c | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index aad557be1a..175023897a 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -3537,6 +3537,7 @@ DEFINE_VIRT_MACHINE_AS_LATEST(10, 2) static void virt_machine_10_1_options(MachineClass *mc) { virt_machine_10_2_options(mc); + mc->smbios_memory_device_size =3D 2047 * TiB; compat_props_add(mc->compat_props, hw_compat_10_1, hw_compat_10_1_len); } DEFINE_VIRT_MACHINE(10, 1) diff --git a/hw/core/machine.c b/hw/core/machine.c index 7b7a381b0a..681adbb7ac 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1118,8 +1118,11 @@ static void machine_class_init(ObjectClass *oc, cons= t void *data) * SMBIOS 3.1.0 7.18.5 Memory Device =E2=80=94 Extended Size * use max possible value that could be encoded into * 'Extended Size' field (2047Tb). + * + * Unfortunately (current) Windows Server 2025 and earlier do not hand= le + * 4Tb+ DIMM size. */ - mc->smbios_memory_device_size =3D 2047 * TiB; + mc->smbios_memory_device_size =3D 2 * TiB; =20 /* numa node memory size aligned on 8MB by default. * On Linux, each node's border has to be 8MB aligned diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index caf8bab68e..7b3611e973 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -448,6 +448,7 @@ DEFINE_I440FX_MACHINE_AS_LATEST(10, 2); static void pc_i440fx_machine_10_1_options(MachineClass *m) { pc_i440fx_machine_10_2_options(m); + m->smbios_memory_device_size =3D 2047 * TiB; compat_props_add(m->compat_props, hw_compat_10_1, hw_compat_10_1_len); compat_props_add(m->compat_props, pc_compat_10_1, pc_compat_10_1_len); } diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index e89951285e..6015e639d7 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -384,6 +384,7 @@ DEFINE_Q35_MACHINE_AS_LATEST(10, 2); static void pc_q35_machine_10_1_options(MachineClass *m) { pc_q35_machine_10_2_options(m); + m->smbios_memory_device_size =3D 2047 * TiB; compat_props_add(m->compat_props, hw_compat_10_1, hw_compat_10_1_len); compat_props_add(m->compat_props, pc_compat_10_1, pc_compat_10_1_len); } --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692155; cv=none; d=zohomail.com; s=zohoarc; b=jti+Uv8drNWpeORZvtb/SqO9T8xPmsfAHrZqS6kO+Fmn9iEgHzmK9ycJCAPgNb5HYQySA9opHKQmc98bg2f/RlvSZUCkaDiRAmyJLh1DhOLehNEyAzBra8vNpCZ6NRyPtJkrWKUfX+KJLH8VsvYMRelsrUitwaMkAjFCp5aYGoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692155; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MyvBGvCg5pKlLTnNdcKGwoTb8nQEpmQV3fi/odf1v+M=; b=JR2gp2a3mRyvMWHazljYGLTaLgU177vcQCSpF5xq74jSsqXr9qgsYe6/l9aNkUzhhMs16Kkr5HdoIM/LUW8cUxrQ4FPrkjvx+lS6QH/sh7GNUQH1eIh8xdlYWbqPZwxqIJo4rN0XdSjEfixvmkYgY35KH5Uvyyu04C2Fp9fO0Hc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692155483523.3168100013196; Sun, 5 Oct 2025 12:22:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UEt-0000O8-TR; Sun, 05 Oct 2025 15:17: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 1v5UEh-0008TX-6t for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:35 -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 1v5UEc-0006Vi-Fl for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:34 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-299-QpO14XHxPoyqJZ_OTpQr5A-1; Sun, 05 Oct 2025 15:17:28 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3f42b54d159so3228678f8f.2 for ; Sun, 05 Oct 2025 12:17:28 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e619b86e1sm216921485e9.5.2025.10.05.12.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691849; 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=MyvBGvCg5pKlLTnNdcKGwoTb8nQEpmQV3fi/odf1v+M=; b=gYVBDav8EWPWF88A7R81gY+s4BLc1brIzWOBmpDkLbw0yAAGuTyjZoQpNPNzlGD7UQUOxX lh4aaRSdwLVJuesidMRVSuOVIz7cN0vVdVRiJ6IDF5xnUOyi6+JTg3587Ambq9kxnusER4 yby8TH+l4yPFBHEgW1/zzLgDa/vT12M= X-MC-Unique: QpO14XHxPoyqJZ_OTpQr5A-1 X-Mimecast-MFC-AGG-ID: QpO14XHxPoyqJZ_OTpQr5A_1759691847 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691847; x=1760296647; 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=MyvBGvCg5pKlLTnNdcKGwoTb8nQEpmQV3fi/odf1v+M=; b=bCdmTdml5G6q0TGovz3PA/+MQx5a099WJrPIqpOCqBanPBpUDCRJJZBjoBHQmaoOeB Urr9+qHd+71O6WKns5CqenuxpUtLBAB8itfatFsZlNh+xu5umuNuOzpiKgawp7sVMigR bKs2jXHDQlg0kVyZI4ip8LgtFsGNsITuaYleI3MQ2skJJhjDxhhrGAgHBqiGOnx2oLgH IN4VXHO/bL/j5pL/9zbq7oxPQE/iOnULsLhzW2iB6u80O2Kyw2ho3yLFsQveLXibxIJk kmJhtHSChVrn3fvMmijHDPu27Mpc+PtpMPfGR85WcLptnRNADq+f5ZQznc2tsLHZv5II x2OA== X-Gm-Message-State: AOJu0YwK2I+gBgVhu46vv+GO0R3swAqzEKyCcuWBQ/WdXSL5q/XKQIZ3 m+tYUphRunbw0EcsQhY59VmxfHUoqmMFCF02foETpRxtuKOQw+KXiMTd0IImF8kbsXKMW0zCqF1 rxNi8I4aBPdYsbAAjihMFFkUr5Lgt4wyeZktQeB5R24lebM9DaSEmn53yoisASJnpU5xuLBqXe+ vG1nozym+w7YB/cBv7Oc5WKJichezn0yCuFg== X-Gm-Gg: ASbGncugk6mk6gnZWRvlidjjNWl3Juw9sT2kY92e5In6Alm7MyYiDMdKsyAru+NQBb3 ABVTuE5BkCPaS9VqpIN5HXj+hheanmNrkxFri0h6YKjJzDjH+ySHdfyXGg4kGOvSDmNCimWrBmd qs4e4/epjO5ibJLCmEoyFQg3oT4dfed1XMiUnbJ4NV3VNkpJeMqBXWgzs+7xLNTV44QNQNozAYs Zbjo0tY0nPjHJs732NPXok8ZnOPlIfXVrA+lZerQiRLmbNmN1OOBbEkd+ydJb0EnllY1nsCPAEd qFA63RPYw6luamb480TwEPisaV4RnEc4ntS7AyA= X-Received: by 2002:a05:6000:2dc3:b0:3f7:b7ac:f3d2 with SMTP id ffacd0b85a97d-425671ab145mr6411636f8f.43.1759691846940; Sun, 05 Oct 2025 12:17:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEAKyTMToGPV/1BWGvkojDp3/sLUXg8J7hMSRVG4xXSiZ/2ZkWU0rdhU2Aey3ssz3wIgWRVNg== X-Received: by 2002:a05:6000:2dc3:b0:3f7:b7ac:f3d2 with SMTP id ffacd0b85a97d-425671ab145mr6411620f8f.43.1759691846410; Sun, 05 Oct 2025 12:17:26 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:24 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , CLEMENT MATHIEU--DRIF , Marcel Apfelbaum Subject: [PULL 37/75] pcie: Add a way to get the outstanding page request allocation (pri) from the config space. 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692157680116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: CLEMENT MATHIEU--DRIF Signed-off-by: Clement Mathieu--Drif Reviewed-by: Michael S. Tsirkin Message-ID: <20250901111630.1018573-2-clement.mathieu--drif@eviden.com> Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pcie.h | 1 + hw/pci/pcie.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index ff6ce08e13..42cebcd033 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -158,6 +158,7 @@ void pcie_pasid_init(PCIDevice *dev, uint16_t offset, u= int8_t pasid_width, void pcie_pri_init(PCIDevice *dev, uint16_t offset, uint32_t outstanding_p= r_cap, bool prg_response_pasid_req); =20 +uint32_t pcie_pri_get_req_alloc(const PCIDevice *dev); bool pcie_pri_enabled(const PCIDevice *dev); bool pcie_pasid_enabled(const PCIDevice *dev); bool pcie_ats_enabled(const PCIDevice *dev); diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index eaeb68894e..b302de6419 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -1266,6 +1266,14 @@ void pcie_pri_init(PCIDevice *dev, uint16_t offset, = uint32_t outstanding_pr_cap, dev->exp.pri_cap =3D offset; } =20 +uint32_t pcie_pri_get_req_alloc(const PCIDevice *dev) +{ + if (!pcie_pri_enabled(dev)) { + return 0; + } + return pci_get_long(dev->config + dev->exp.pri_cap + PCI_PRI_ALLOC_REQ= ); +} + bool pcie_pri_enabled(const PCIDevice *dev) { if (!pci_is_express(dev) || !dev->exp.pri_cap) { --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692518; cv=none; d=zohomail.com; s=zohoarc; b=kb+FO2mBjDdeDu1N+08/o7yDrYYMTYp2pDyzjf4eYimOp6xOhRVdXDN7aqLeXu/3z0DXeJ4Nf0y6fdnv/Kq6fbkpqBx3oQiDO+ukyr5wpOyuZPHe9IqynlMo+18s/30HhIdmc/zD9uKutjiOagPisZzitXF5pqSNXn1CuESWSiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692518; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OKnItQYBTrXiPTFJBSTJGUjxT2lE7EF9Yn/LDwcOwGM=; b=R1dUYGeLzBi562VLCCA0Ij4ALi+bfV9acVM/Z+8w8TysUeKy6/4jAT3YQPca9Mwv4xcl3b5ZWhKpDfah7Ovrq7qf8Zf4518a69ti/Z711T6wk1xU00bJ/nfyKEJGXC2qWOaKpvUc5+s5dvvVl26sOk9ntkBWDjUGeFIFVcjlB+k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692518982290.14450774776026; Sun, 5 Oct 2025 12:28:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFH-0001yb-9C; Sun, 05 Oct 2025 15:18:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEj-00005Q-De for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEe-0006WA-Sz for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:36 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-341-o6sV5EoXNGmpEI4kbzyHmQ-1; Sun, 05 Oct 2025 15:17:30 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-46e35baddc1so22645465e9.2 for ; Sun, 05 Oct 2025 12:17:30 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8ab8fdsm17343552f8f.15.2025.10.05.12.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691851; 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=OKnItQYBTrXiPTFJBSTJGUjxT2lE7EF9Yn/LDwcOwGM=; b=Tyuz/SLbHQcpJCJEkmVOFZ3OlO4ckM/0VkuCxytT2YhOGKXCVTRCFgKZtvZt0giVptDfdf frAzqeTGPbRualiTQ+UyXOeEpfuTw05AmVCcJ5IxHKBbdSjUFuENgncQI6t1zRecrB+t9M G0i3hBKx8EnhXMkXJ56HPYy8E45iUqg= X-MC-Unique: o6sV5EoXNGmpEI4kbzyHmQ-1 X-Mimecast-MFC-AGG-ID: o6sV5EoXNGmpEI4kbzyHmQ_1759691849 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691849; x=1760296649; 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=OKnItQYBTrXiPTFJBSTJGUjxT2lE7EF9Yn/LDwcOwGM=; b=CaVYb5nmP2VMtvdVPYg6FFgMLSPFjNgQqndFuT3EHZ31GQUwbCj/B63pgDQgEhvsxI kfjlWTf9ny9c7atz1OvLV1ns3s+kGeZpNr+B2AIEsTAqAoIXkErOh40ztQyiWodeK/nt iHvt5mhsVKDugW+kKdB+H+s4uHAPmUXIFWQHMm1qPWDAudwfBSzuv5L2zDTGkmAmJT0z zTArQbodV11mwg7Dea3rmFW8r1RWobcnJJVchne385BXrYxvRNugCw+WeOwa5ol4L5w5 A42ibZH1kLkVCaWicsyd/m8mDH83NW1CF/SZhpGuuC8MnuyjQxVaYdPsFTAOlGKFmZrY IsZg== X-Gm-Message-State: AOJu0Ywbz9uQhHSxYbxjn1+g88vIXz3JsSaAEjmfHdFKfehcLeDWMy7U ZIS7aJC1gCrL2eb/e5qKlaZvvnPc1l8VkELuI0LsjtkPuEJxb//FSLt3Owhn3sZuevhG+c8vg/C TPZH3erJjDqiTjs6U4Fb3l7zxkrp88VJpAHu5iEqp4HbxJyT48XR6rO8hzBPSSn71xIq/807pYs RJtkUuy4bmh7USfhcuJ+LNwvpHfB8jctfbPw== X-Gm-Gg: ASbGncvqxWllN2BiIQAdhzELbuMUwTWBDWPvt4Ivxda+mjE17kaH8qpOwkQ2T+591AG d6Gxuvwh7SpPMyHByseQvGWMogYs3+0dhP3NaNHE37Pxycw6cZSzP86u5+PGvkR/my1+VR50rYs 6JLY5g1FG0MuFj38oDc9o6Te9iNaXU81Mi4iBipGKdE0rUh6k3COplQnyZbzof7X4OziScDZ0Qt wE//ml7JunbO/BYG0NufaSMy6tuajtJr98yKsHyfclq/bdJBz0Qn+WwDUd3J/qjzINeIqB2w5XM iHtwM8qJ05nV56LWNVoI6ILM4HOTqVwv/tpm0IU= X-Received: by 2002:a05:600c:3149:b0:46e:33b2:c8da with SMTP id 5b1f17b1804b1-46e7114829cmr57999995e9.32.1759691849154; Sun, 05 Oct 2025 12:17:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4zTTH+d2bFR3+JzNmfeNs4T4/TmnBfZKwwYWYRt/p7obGkXFfF7XAkN+1Ryi6fd+ey1+9jA== X-Received: by 2002:a05:600c:3149:b0:46e:33b2:c8da with SMTP id 5b1f17b1804b1-46e7114829cmr57999785e9.32.1759691848535; Sun, 05 Oct 2025 12:17:28 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:26 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , CLEMENT MATHIEU--DRIF , Jason Wang , Yi Liu , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 38/75] intel_iommu: Bypass barrier wait descriptor Message-ID: <57ac646a2ecb2967c46febcfd0f40d396868b4dc.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692520388116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: CLEMENT MATHIEU--DRIF wait_desc with SW=3D0,IF=3D0,FN=3D1 must not be considered as an invalid descriptor as it is used to implement section 7.10 of the VT-d spec. Signed-off-by: Clement Mathieu--Drif Reviewed-by: Michael S. Tsirkin Message-ID: <20250901111630.1018573-3-clement.mathieu--drif@eviden.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 83c5e44413..4e7ad3a290 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2857,7 +2857,13 @@ static bool vtd_process_wait_desc(IntelIOMMUState *s= , VTDInvDesc *inv_desc) vtd_generate_completion_event(s); } =20 - if (!(inv_desc->lo & (VTD_INV_DESC_WAIT_IF | VTD_INV_DESC_WAIT_SW))) { + /* + * SW=3D0, IF=3D0, FN=3D1 is also a valid descriptor (VT-d 7.10) + * Nothing to do as we process the descriptors in order + */ + + if (!(inv_desc->lo & (VTD_INV_DESC_WAIT_IF | VTD_INV_DESC_WAIT_SW | + VTD_INV_DESC_WAIT_FN))) { error_report_once("%s: invalid wait desc: hi=3D%"PRIx64", lo=3D%"P= RIx64 " (unknown type)", __func__, inv_desc->hi, inv_desc->lo); --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692066; cv=none; d=zohomail.com; s=zohoarc; b=b5y3Sb9And1G4M9hxQSKjC3ld8lp0zjXNHmEujGRUX5ovysthT13P1DHjcMm3R9VgVyrzBA/FLOsJiJ702pkvGyYzYc9pqN9r1FW44pB6QBUUqClo6Iu3HX2zLqQOVmMAyiXDZ3PTrutehLIFa2+XMZXjt3VpULW4al1MGbEvpc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692066; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=u2jYeKWljJsB48uGOgCkPK+8PjN3Wtr/wWTKXDzpU98=; b=nItAZhpF1nqGnXG9jpzTpVCp1wd9G7QRwH78OCYN0igAzGblM3Ot9eGl/uUpLzCbLae77Sd/6GC3+3DlX6om1UM56tmlUyx73m10D0hlKt70cv4EPO53OimbVgi8Bo/2Pt0dCp2zdr9JPH8ZuuUhi0xMemLqv+hM7Y8QeCFqd9U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692066260714.64695733117; Sun, 5 Oct 2025 12:21:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFB-0000t5-3o; Sun, 05 Oct 2025 15:18: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 1v5UEl-000090-48 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17: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 1v5UEj-0006Wt-Ak for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:38 -0400 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-685-GsVZPDbvMeGZcOGS7Ldcpw-1; Sun, 05 Oct 2025 15:17:33 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3f030846a41so2461426f8f.2 for ; Sun, 05 Oct 2025 12:17:33 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e675c67f7sm96952125e9.2.2025.10.05.12.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691854; 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=u2jYeKWljJsB48uGOgCkPK+8PjN3Wtr/wWTKXDzpU98=; b=Mla1nz9Htn7fF5UmdFoAEjnW7WMJSXIaGxAgI+m4TblhdC5NCgbPYDkTJDnh8WxCXpq+3n KrNvubmGBTkWV/ZBNAs8ZE00O5JfuxM2XauIFg6Qo8FXABGjUlvgP0hPo5YFII3OT8BL4R ytAqrKo65dOVbCJFK+IhB6k1Qr5S0eM= X-MC-Unique: GsVZPDbvMeGZcOGS7Ldcpw-1 X-Mimecast-MFC-AGG-ID: GsVZPDbvMeGZcOGS7Ldcpw_1759691852 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691852; x=1760296652; 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=u2jYeKWljJsB48uGOgCkPK+8PjN3Wtr/wWTKXDzpU98=; b=tN/zNiARdwB+nUfvr3HDFSJtqvSxunZq/joq2HblvAEOf7Nd6TSsuTatQwkhaElA2f GCJeQSO0f7Lz1y+teK2HGUWhEw1xiK3Z0L8e9WgcbPql6kiOZ/gdSR4cGdT0XaIN6aQs yCwm7USOEKTjIVJCK00Evp37qv7Jd+4NbmW6pHWe/XtkRc9hiWjBO0TAdKdBiDaa2EGA 9QqEVvqVhsjdzgacDiy8iXI6vgK+qdkFPpx5aoBpCbgB10TiO7uHSNt4QZ8AO5z/InkW 4N+dIqkXh1nStznvwBvon9yWH0Q/EWQHSdGEJx250VkDr7g8Xfx50GAch0sFMNwlAi1Z e3fA== X-Gm-Message-State: AOJu0YzUTrKpUIf/9VHECzk0ORuO7/A8IqMQFTCxMQt6vMqxWjwR3R4H Hy8H6yDCFnn9Q/rGuXE/rbwYgS4oItgd1Zd3HuPJBGDff0Jq1n730XHu7VAfiVRWiruYGb4SuFS XwuvlDhUmxC1OXe8xAHEUaYvAAoE3RdR37Y2KmHajYfSCU14GrPeq9mn54TckdrksQ1slRrWSLH UrJ6u9tvEB2Fps0xp4WaW31JBtEoR6JhldJw== X-Gm-Gg: ASbGncsnWFSlAt9Ghs04jiR20p436saywMdqxtjVrsbTg2UZAp8Ie2C6JE7rH8s+6RA NfY7alB35Nq4Lv1Ctki1DbBvAyg7ke6WRquFihbcAOlecKTm1BADDXc7c+kef3muOPNmM1PnxRA aRVb9w1QfP6nJiXLHmMVBqea9FJiqMMPdppZr5O+O+3EO03LclWCc+q10R19/jQp3jFg3hXvgpk tBt4Nn7DejTMEgpIdmrZvQt0yRhlS09TElOvp6qSdSEI9jV2S84kL75U56pySJ4P3Hc09wlZMcV LsCG6xI5pQhGX+KfYlmqEewM7lIfV7b40cM1MRY= X-Received: by 2002:a05:600c:354f:b0:45b:868e:7f7f with SMTP id 5b1f17b1804b1-46e711640e1mr80744855e9.17.1759691851886; Sun, 05 Oct 2025 12:17:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGuTQKS+MaJPeSfqQqdkX41c2QDNE+YwNQJeMbK9ztQlLBQiNCSMn+pImwr9wOwWYLX2aVhaA== X-Received: by 2002:a05:600c:354f:b0:45b:868e:7f7f with SMTP id 5b1f17b1804b1-46e711640e1mr80744605e9.17.1759691851398; Sun, 05 Oct 2025 12:17:31 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , CLEMENT MATHIEU--DRIF , Jason Wang , Yi Liu , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 39/75] intel_iommu: Declare PRI constants and structures 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692069515116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: CLEMENT MATHIEU--DRIF Signed-off-by: Clement Mathieu--Drif Reviewed-by: Michael S. Tsirkin Message-ID: <20250901111630.1018573-4-clement.mathieu--drif@eviden.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 360e937989..04a8d4c769 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -190,6 +190,7 @@ #define VTD_ECAP_EIM (1ULL << 4) #define VTD_ECAP_PT (1ULL << 6) #define VTD_ECAP_SC (1ULL << 7) +#define VTD_ECAP_PRS (1ULL << 29) #define VTD_ECAP_MHMV (15ULL << 20) #define VTD_ECAP_SRS (1ULL << 31) #define VTD_ECAP_PSS (7ULL << 35) /* limit: MemTxAttrs::pid= */ @@ -376,6 +377,18 @@ union VTDInvDesc { }; typedef union VTDInvDesc VTDInvDesc; =20 +/* Page Request Descriptor */ +union VTDPRDesc { + struct { + uint64_t lo; + uint64_t hi; + }; + struct { + uint64_t val[4]; + }; +}; +typedef union VTDPRDesc VTDPRDesc; + /* Masks for struct VTDInvDesc */ #define VTD_INV_DESC_ALL_ONE -1ULL #define VTD_INV_DESC_TYPE(val) ((((val) >> 5) & 0x70ULL) | \ @@ -389,6 +402,7 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_PIOTLB 0x6 /* PASID-IOTLB Invalidate Desc= */ #define VTD_INV_DESC_PC 0x7 /* PASID-cache Invalidate Desc= */ #define VTD_INV_DESC_DEV_PIOTLB 0x8 /* PASID-based-DIOTLB inv_desc= */ +#define VTD_INV_DESC_PGRESP 0x9 /* Page Group Response Desc */ #define VTD_INV_DESC_NONE 0 /* Not an Invalidate Descripto= r */ =20 /* Masks for Invalidation Wait Descriptor*/ @@ -440,6 +454,15 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_PASID_DEVICE_IOTLB_RSVD_VAL0 0xfff000000000f000ULL #define VTD_INV_DESC_PASID_DEVICE_IOTLB_RSVD_VAL1 0x7feULL =20 +/* Mask for Page Group Response Descriptor */ +#define VTD_INV_DESC_PGRESP_RSVD_HI 0xfffffffffffff003ULL +#define VTD_INV_DESC_PGRESP_RSVD_LO 0xfff00000000001e0ULL +#define VTD_INV_DESC_PGRESP_PP(val) (((val) >> 4) & 0x1ULL) +#define VTD_INV_DESC_PGRESP_RC(val) (((val) >> 12) & 0xfULL) +#define VTD_INV_DESC_PGRESP_RID(val) (((val) >> 16) & 0xffffULL) +#define VTD_INV_DESC_PGRESP_PASID(val) (((val) >> 32) & 0xfffffUL= L) +#define VTD_INV_DESC_PGRESP_PRGI(val) (((val) >> 3) & 0x1ffULL) + /* Rsvd field masks for spte */ #define VTD_SPTE_SNP 0x800ULL =20 @@ -491,6 +514,31 @@ typedef union VTDInvDesc VTDInvDesc; #define VTD_INV_DESC_PIOTLB_RSVD_VAL0 0xfff000000000f1c0ULL #define VTD_INV_DESC_PIOTLB_RSVD_VAL1 0xf80ULL =20 +/* Page Request Descriptor */ +/* For the low 64-bit of 128-bit */ +#define VTD_PRD_TYPE (1ULL) +#define VTD_PRD_PP(val) (((val) & 1ULL) << 8) +#define VTD_PRD_RID(val) (((val) & 0xffffULL) << 16) +#define VTD_PRD_PASID(val) (((val) & 0xfffffULL) << 32) +#define VTD_PRD_EXR(val) (((val) & 1ULL) << 52) +#define VTD_PRD_PMR(val) (((val) & 1ULL) << 53) +/* For the high 64-bit of 128-bit */ +#define VTD_PRD_RDR(val) ((val) & 1ULL) +#define VTD_PRD_WRR(val) (((val) & 1ULL) << 1) +#define VTD_PRD_LPIG(val) (((val) & 1ULL) << 2) +#define VTD_PRD_PRGI(val) (((val) & 0x1ffULL) << 3) +#define VTD_PRD_ADDR(val) ((val) & 0xfffffffffffff000ULL) + +/* Page Request Queue constants */ +#define VTD_PQA_ENTRY_SIZE 32 /* Size of an entry in bytes */ +/* Page Request Queue masks */ +#define VTD_PQA_ADDR 0xfffffffffffff000ULL /* PR queue address = */ +#define VTD_PQA_SIZE 0x7ULL /* PR queue size */ +#define VTD_PR_STATUS_PPR 1UL /* Pending page request */ +#define VTD_PR_STATUS_PRO 2UL /* Page request overflow */ +#define VTD_PR_PECTL_IP 0x40000000UL /* PR control interrup pendin= g */ +#define VTD_PR_PECTL_IM 0x80000000UL /* PR control interrup mask */ + /* Information about page-selective IOTLB invalidate */ struct VTDIOTLBPageInvInfo { uint16_t domain_id; @@ -550,6 +598,7 @@ typedef struct VTDRootEntry VTDRootEntry; #define VTD_SM_CONTEXT_ENTRY_RID2PASID_MASK 0xfffff #define VTD_SM_CONTEXT_ENTRY_RSVD_VAL0(aw) (0x1e0ULL | ~VTD_HAW_MASK(aw)) #define VTD_SM_CONTEXT_ENTRY_RSVD_VAL1 0xffffffffffe00000ULL +#define VTD_SM_CONTEXT_ENTRY_PRE 0x10ULL =20 /* PASID Table Related Definitions */ #define VTD_PASID_DIR_BASE_ADDR_MASK (~0xfffULL) --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691972; cv=none; d=zohomail.com; s=zohoarc; b=RPA556x49Ba3cE24e7VyHi/phIxg74W33FQhL0VbRGQjDqW+uRVLyv19TlI9WBJkSsZoo4FtoUipxXBE5TbRB6f3xJ1PBbyiGdIGuDwqTHzyrwCmENqX16bOJuJHg/vR9ialn0hkC30sEOz/YBkrYtn3zXklCHiMwukNdhgon+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691972; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xzqumJdA2IU6uk2BKX0kvnJAwm1EzQzyigsDYU/IG3o=; b=DlUIFa+Ym5UfYVZ/nwAS9kOBEDYQXZiwsghFj0UvE1x97xz6dCrdJy/J4VbJr3URBpj4YKgBUus70SJdBPMFAc6JESkODtWp4TX14P/TNm8Dref6WtOfMFSbnSLXSOSRTccRfmvg+x2xsLNMwgjo7/KCS0ZSnGeFbCbQE/w91t4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691972061376.94324715726873; Sun, 5 Oct 2025 12:19:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFF-0001b9-4U; Sun, 05 Oct 2025 15:18: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 1v5UEm-0000A7-Aq for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:40 -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 1v5UEk-0006XL-KB for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:40 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-493-GN335gjcPEmM9CGuR0iy9w-1; Sun, 05 Oct 2025 15:17:36 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3ecdd80ea44so2979852f8f.1 for ; Sun, 05 Oct 2025 12:17:35 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8e9724sm17277219f8f.28.2025.10.05.12.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691857; 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=xzqumJdA2IU6uk2BKX0kvnJAwm1EzQzyigsDYU/IG3o=; b=XZMiWj0VK3hCkgYjbG8RLAfM4qM4KBOXb1Qd5TZJe9UD8b6R1H4IV1mEVv5jGJBGpJLsW5 0PBB0UVLq2U8TDFePiQFJCWqH3b9Q+JIW1UqQspMXklPKNI0vzZnogl/0+EmUcp5PX7rqJ yq17hmcOUDklD3DeqgO99H0mDRrgbuc= X-MC-Unique: GN335gjcPEmM9CGuR0iy9w-1 X-Mimecast-MFC-AGG-ID: GN335gjcPEmM9CGuR0iy9w_1759691855 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691855; x=1760296655; 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=xzqumJdA2IU6uk2BKX0kvnJAwm1EzQzyigsDYU/IG3o=; b=rsoc9A5ENKHjQ472Cb9dlwEsp5NIDKCg2VYdN2rXkgM8F53PiT/G2KoLbBg0uQOgWs TKkDRCuTRVBz3aYkcIbalAcJJSsRq3Wf+/ckd/kRhJ2h7ufvSOC7Svb+fPJLKrR8m/++ 7yg0mJOzx0p3rQXnRNc7Y5Wp5WWQo+iiO7r8nlsdJIjkKqgsjnIbQ0lw254vpz+e8/2U GSJNhLcSwh7wbZWhOx0BQPaDXaZIPyx4TodaqDFBa3lj7cgviaUGBpmv+N9oTdTW8Amf aLr1SPuqdEb6GmHop/9Phoa/q0sEECIi78L4SXbDq3rBnUzbqKx6vQ9XI/dFMprzfANH ZKEw== X-Gm-Message-State: AOJu0YzfAyb6F5mRoVcEUbEaKsXYkiGj+6g6KRfFU4mxH0bNaBP0MeLe 3mvJUKk3ja8uJu+R5ED8v0JEoeixgyYd4TDRY1goz9M1AazbYS60O/yKfh08kmIkt+GA0ajsrRr tmC6tObSdMYtkY1AmgxpScf6bU4mlgC+bMLDFSfheVeQpkf22xy8c+V9o14uzK+tTrlshXXgnCQ 4cU3WPOWTriyNCsfjkUL/Pm8y+6QBv6XoXWA== X-Gm-Gg: ASbGncsi47snKkYpQrb9s5mkowkoaTflmWqq0BGo7+2cMs6NjOuJrLI/8n238CNfcn6 oYmC2n6yNB6Z/YSBXedbbQBUz/sB/Vo21666fri/hmBNHEkIcRv6DGR2zKtIN3enPHjrIn9alyb +YAJL7KpfOtrKjoHWf7zKWLP1oTkSBs8EbbOlJdnQfmBU4Uy9pMrwraXn5LbJQWrcoYhETZnlel G07xe/0ew8MvQebxtKNm2aqQP0hDsUlmmgHQAdvePIKWzANPr5aOA4fJlShrBbnKUFrqLtW0CUy 6L/nS5SsW2PbakGkTFkkfE4Qo/ZxViOJBgZDnJM= X-Received: by 2002:a05:6000:2910:b0:414:c2e8:a739 with SMTP id ffacd0b85a97d-42566c5ef4amr6878664f8f.31.1759691854673; Sun, 05 Oct 2025 12:17:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF2uJeMWvF0P1wIRjdZRjb/My+GlBVAX1lKarrmf6fA8mj9QvBRLbnj37q8WTEsu2KuBJz1Fw== X-Received: by 2002:a05:6000:2910:b0:414:c2e8:a739 with SMTP id ffacd0b85a97d-42566c5ef4amr6878644f8f.31.1759691854167; Sun, 05 Oct 2025 12:17:34 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:31 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , CLEMENT MATHIEU--DRIF , Jason Wang , Yi Liu , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 40/75] intel_iommu: Declare registers for PRI 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691975601116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: CLEMENT MATHIEU--DRIF Signed-off-by: Clement Mathieu--Drif Reviewed-by: Michael S. Tsirkin Message-ID: <20250901111630.1018573-5-clement.mathieu--drif@eviden.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 4e7ad3a290..d952ec1428 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3386,6 +3386,27 @@ static void vtd_handle_iectl_write(IntelIOMMUState *= s) } } =20 +static void vtd_handle_prs_write(IntelIOMMUState *s) +{ + uint32_t prs =3D vtd_get_long_raw(s, DMAR_PRS_REG); + if (!(prs & VTD_PR_STATUS_PPR) && !(prs & VTD_PR_STATUS_PRO)) { + vtd_set_clear_mask_long(s, DMAR_PECTL_REG, VTD_PR_PECTL_IP, 0); + } +} + +static void vtd_handle_pectl_write(IntelIOMMUState *s) +{ + uint32_t pectl =3D vtd_get_long_raw(s, DMAR_PECTL_REG); + if ((pectl & VTD_PR_PECTL_IP) && !(pectl & VTD_PR_PECTL_IM)) { + /* + * If IP field was 1 when software clears the IM field, + * the interrupt is generated along with clearing the IP field. + */ + vtd_set_clear_mask_long(s, DMAR_PECTL_REG, VTD_PR_PECTL_IP, 0); + vtd_generate_interrupt(s, DMAR_PEADDR_REG, DMAR_PEDATA_REG); + } +} + static uint64_t vtd_mem_read(void *opaque, hwaddr addr, unsigned size) { IntelIOMMUState *s =3D opaque; @@ -3428,6 +3449,11 @@ static uint64_t vtd_mem_read(void *opaque, hwaddr ad= dr, unsigned size) val =3D s->iq >> 32; break; =20 + case DMAR_PEUADDR_REG: + assert(size =3D=3D 4); + val =3D vtd_get_long_raw(s, DMAR_PEUADDR_REG); + break; + default: if (size =3D=3D 4) { val =3D vtd_get_long(s, addr); @@ -3491,6 +3517,11 @@ static void vtd_mem_write(void *opaque, hwaddr addr, vtd_handle_iotlb_write(s); break; =20 + case DMAR_PEUADDR_REG: + assert(size =3D=3D 4); + vtd_set_long(s, addr, val); + break; + /* Invalidate Address Register, 64-bit */ case DMAR_IVA_REG: if (size =3D=3D 4) { @@ -3671,6 +3702,18 @@ static void vtd_mem_write(void *opaque, hwaddr addr, vtd_set_long(s, addr, val); break; =20 + case DMAR_PRS_REG: + assert(size =3D=3D 4); + vtd_set_long(s, addr, val); + vtd_handle_prs_write(s); + break; + + case DMAR_PECTL_REG: + assert(size =3D=3D 4); + vtd_set_long(s, addr, val); + vtd_handle_pectl_write(s); + break; + default: if (size =3D=3D 4) { vtd_set_long(s, addr, val); @@ -4722,6 +4765,18 @@ static void vtd_init(IntelIOMMUState *s) * Interrupt remapping registers. */ vtd_define_quad(s, DMAR_IRTA_REG, 0, 0xfffffffffffff80fULL, 0); + + /* Page request registers */ + if (s->ecap & VTD_ECAP_PRS) { + vtd_define_quad(s, DMAR_PQH_REG, 0, 0x7ffe0ULL, 0); + vtd_define_quad(s, DMAR_PQT_REG, 0, 0x7ffe0ULL, 0); + vtd_define_quad(s, DMAR_PQA_REG, 0, 0xfffffffffffff007ULL, 0); + vtd_define_long(s, DMAR_PRS_REG, 0, 0, 0x3UL); + vtd_define_long(s, DMAR_PECTL_REG, 0, 0x80000000UL, 0); + vtd_define_long(s, DMAR_PEDATA_REG, 0, 0xffffUL, 0); + vtd_define_long(s, DMAR_PEADDR_REG, 0, 0xfffffffcUL, 0); + vtd_define_long(s, DMAR_PEUADDR_REG, 0, 0xffffffffUL, 0); + } } =20 /* Should not reset address_spaces when reset because devices will still u= se --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692517; cv=none; d=zohomail.com; s=zohoarc; b=KZRJSHHbb071dwEEs+CDb+IllVg5GOTlsDEwbQsxZPHnpPsUlgBgCGJFQ/SHLrk0kzxUO2E1EV59VEgCQTZV0jC0ZF0d8WV2oElNN3Bs3iqwVKHNERVvJnzkUd28VtooZkwpgBoHxy3HYXd0FTJLk22u6DxE1yWGQs9ZPenBNhY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692517; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=EaVeE+H2gjZ5lunVQFTjUNgGLQ7U1xMjHlxoCmjXBr8=; b=Py9ZxPsd4ztDmTnEuPznY6lj3ZUzQ6NRc/JUY9kQJX+yxJ+7szZyhkY2U7SWgnYSWE5AFx6tuQI4FTrb4pQmjs+Ow0Wb05uRAkKs1mOH+SHbSYhMGLry/AT3mRt6GZZgNai5fJ3pNkJMnidUbVNwZ6YSYvLj48/BA8wABIpi2LI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692517566683.1508824298361; Sun, 5 Oct 2025 12:28:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFH-00022Z-Vk; Sun, 05 Oct 2025 15:18: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 1v5UEp-0000LZ-CI for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEm-0006Xt-JT for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:42 -0400 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-352-NuEW08BlNcWkYCrqENgFPg-1; Sun, 05 Oct 2025 15:17:38 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3f42b54d159so3228724f8f.2 for ; Sun, 05 Oct 2025 12:17:38 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6b5csm17507541f8f.5.2025.10.05.12.17.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691859; 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=EaVeE+H2gjZ5lunVQFTjUNgGLQ7U1xMjHlxoCmjXBr8=; b=BplfwDRQB+sLGuAyqIBQ/KL1wGNJ064W1jxQkx6nrG+9ukJpoQzb0KisBk5U6Pvrzzctyi GzPbsTuslBG7C42dD3cKTH96OHxU5rdBNLbdVV5WyXpdxOvXuxLu4icfVJWdjqilagLSdg pjylNM5PU8aZElW45c4tqiZN5pKlRCE= X-MC-Unique: NuEW08BlNcWkYCrqENgFPg-1 X-Mimecast-MFC-AGG-ID: NuEW08BlNcWkYCrqENgFPg_1759691857 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691857; x=1760296657; 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=EaVeE+H2gjZ5lunVQFTjUNgGLQ7U1xMjHlxoCmjXBr8=; b=mr1AwNE/jhKSfCxa11HDvE88u5R8pa40yMPT0dGN+2Ejswq+WVgsfThQI9Fv93JgM2 +BkkyW7eOr2ywd1X0yDBrYk58ZrEM5v5k6rw7FBCCrLrrgM75HHdWDaW0lwMqNpO+iqb scJ07BcY7DirgVDY3bXOxhlrEodq2cOj30COsy4MyD0At7thXvhy51yVQ9LErTo1nqGL baprtDA2fr3SCtNxEcSYuuIPC9okcI939ogz/4jCzKnum8mBTl+tQ95Li2ZlrHvURrkY Il5JzURkNDgd5TKke7U2XrX2RtBh6xtY4UF1ZlD77JknAadUNpM4EgWPlcm77/1lvb4F t7lQ== X-Gm-Message-State: AOJu0Yy3bJo0uW8etMSEIceUlW4vET5k6eiqjzelB77p2irVmzXFS6SM wA3XoEl1R0cEubPG8ce4PCWRTCmg/PuNrST0dBUA4FPYJZmp8e58muZzVAhkONNe2Jh59nzGfCS 8zXT/wm9GkRe4Pr4oBqZx9m+iUTp+JxmG4Uq8FpSyPXuLDIHBa92ZIePajXmQhVv0K17u5JqOvX UuFrPxGaanqr0PDfmJmwbP1NM+jtbF4p2P1g== X-Gm-Gg: ASbGnct3gYgqOwhDIH0bxrVYKG5pSB9Hhj5z+P5ElzJmSezatUeo1PqkK1VBoX6At7V uOjQYPgTvA7xr0+szUsN9hfV5UGUDmvi8fyZHCFREFRJIcdxJ4srZolJ/buh2fYvzwObyX+U8ce qsnEzFxUNyTkGiqC56+8WzX9sfwINmZoIZ/4YB5UfM3BJ/DO9RX8Xx04Cpv+gQZjAp4IhmL1avb CPE7Blt8I82cpV/CjxGytwXF2ihXEwe+md65LqUwSbHzNeuMNI1gEBEs9A0tlyAGslIP92ihqle 6btPm80DaCNlDv7HQ+yUEb6+6AVYCFDkT+fwm5M= X-Received: by 2002:a05:6000:2dc3:b0:3f7:b7ac:f3d2 with SMTP id ffacd0b85a97d-425671ab145mr6411799f8f.43.1759691856975; Sun, 05 Oct 2025 12:17:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqaLcGTgF4a02BvwinOgfJSNm12BUm9WGaJlFkanVLsWoC5nLphzKyPtft8DODYbQ13SgPlA== X-Received: by 2002:a05:6000:2dc3:b0:3f7:b7ac:f3d2 with SMTP id ffacd0b85a97d-425671ab145mr6411778f8f.43.1759691856266; Sun, 05 Oct 2025 12:17:36 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , CLEMENT MATHIEU--DRIF , Jason Wang , Yi Liu , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 41/75] intel_iommu: Add PRI operations support Message-ID: <676757e50ce0ce206969b02dc2433c9e825e55f5.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692532340116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: CLEMENT MATHIEU--DRIF Implement the PRI callbacks in vtd_iommu_ops. Signed-off-by: Clement Mathieu--Drif Reviewed-by: Michael S. Tsirkin Message-ID: <20250901111630.1018573-6-clement.mathieu--drif@eviden.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 2 + include/hw/i386/intel_iommu.h | 1 + hw/i386/intel_iommu.c | 274 +++++++++++++++++++++++++++++++++ 3 files changed, 277 insertions(+) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 04a8d4c769..0d0069a612 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -315,6 +315,8 @@ typedef enum VTDFaultReason { * request while disabled */ VTD_FR_IR_SID_ERR =3D 0x26, /* Invalid Source-ID */ =20 + VTD_FR_SM_PRE_ABS =3D 0x47, /* SCT.8 : PRE bit in a present SM CE is= 0 */ + /* PASID directory entry access failure */ VTD_FR_PASID_DIR_ACCESS_ERR =3D 0x50, /* The Present(P) field of pasid directory entry is 0 */ diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h index e95477e855..47730ac3c7 100644 --- a/include/hw/i386/intel_iommu.h +++ b/include/hw/i386/intel_iommu.h @@ -110,6 +110,7 @@ struct VTDAddressSpace { QLIST_ENTRY(VTDAddressSpace) next; /* Superset of notifier flags that this address space has */ IOMMUNotifierFlag notifier_flags; + IOMMUPRINotifier *pri_notifier; /* * @iova_tree traces mapped IOVA ranges. * diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index d952ec1428..2cc9bd5e45 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -45,6 +45,8 @@ ((ce)->val[1] & VTD_SM_CONTEXT_ENTRY_RID2PASID_MASK) #define VTD_CE_GET_PASID_DIR_TABLE(ce) \ ((ce)->val[0] & VTD_PASID_DIR_BASE_ADDR_MASK) +#define VTD_CE_GET_PRE(ce) \ + ((ce)->val[0] & VTD_SM_CONTEXT_ENTRY_PRE) =20 /* pe operations */ #define VTD_PE_GET_TYPE(pe) ((pe)->val[0] & VTD_SM_PASID_ENTRY_PGTT) @@ -1838,6 +1840,7 @@ static const bool vtd_qualified_faults[] =3D { [VTD_FR_FS_NON_CANONICAL] =3D true, [VTD_FR_FS_PAGING_ENTRY_US] =3D true, [VTD_FR_SM_WRITE] =3D true, + [VTD_FR_SM_PRE_ABS] =3D true, [VTD_FR_SM_INTERRUPT_ADDR] =3D true, [VTD_FR_FS_BIT_UPDATE_FAILED] =3D true, [VTD_FR_MAX] =3D false, @@ -3152,6 +3155,59 @@ static bool vtd_process_device_piotlb_desc(IntelIOMM= UState *s, return true; } =20 +static bool vtd_process_page_group_response_desc(IntelIOMMUState *s, + VTDInvDesc *inv_desc) +{ + VTDAddressSpace *vtd_dev_as; + bool pasid_present; + uint8_t response_code; + uint16_t rid; + uint32_t pasid; + uint16_t prgi; + IOMMUPRIResponse response; + + if ((inv_desc->lo & VTD_INV_DESC_PGRESP_RSVD_LO) || + (inv_desc->hi & VTD_INV_DESC_PGRESP_RSVD_HI)) { + error_report_once("%s: invalid page group response desc: hi=3D%"PR= Ix64 + ", lo=3D%"PRIx64" (reserved nonzero)", __func_= _, + inv_desc->hi, inv_desc->lo); + return false; + } + + pasid_present =3D VTD_INV_DESC_PGRESP_PP(inv_desc->lo); + response_code =3D VTD_INV_DESC_PGRESP_RC(inv_desc->lo); + rid =3D VTD_INV_DESC_PGRESP_RID(inv_desc->lo); + pasid =3D VTD_INV_DESC_PGRESP_PASID(inv_desc->lo); + prgi =3D VTD_INV_DESC_PGRESP_PRGI(inv_desc->hi); + + if (!pasid_present) { + error_report_once("Page group response without PASID is" + "not supported yet"); + return false; + } + + vtd_dev_as =3D vtd_get_as_by_sid_and_pasid(s, rid, pasid); + if (!vtd_dev_as) { + return true; + } + + response.prgi =3D prgi; + + if (response_code =3D=3D 0x0u) { + response.response_code =3D IOMMU_PRI_RESP_SUCCESS; + } else if (response_code =3D=3D 0x1u) { + response.response_code =3D IOMMU_PRI_RESP_INVALID_REQUEST; + } else { + response.response_code =3D IOMMU_PRI_RESP_FAILURE; + } + + if (vtd_dev_as->pri_notifier) { + vtd_dev_as->pri_notifier->notify(vtd_dev_as->pri_notifier, &respon= se); + } + + return true; +} + static bool vtd_process_device_iotlb_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc) { @@ -3252,6 +3308,13 @@ static bool vtd_process_inv_desc(IntelIOMMUState *s) } break; =20 + case VTD_INV_DESC_PGRESP: + trace_vtd_inv_desc("page group response", inv_desc.hi, inv_desc.lo= ); + if (!vtd_process_page_group_response_desc(s, &inv_desc)) { + return false; + } + break; + /* * TODO: the entity of below two cases will be implemented in future s= eries. * To make guest (which integrates scalable mode support patch set in @@ -4864,6 +4927,194 @@ static ssize_t vtd_ats_request_translation(PCIBus *= bus, void *opaque, return res_index; } =20 +/* 11.4.11.3 : The number of entries in the page request queue is 2^(PQS += 7) */ +static inline uint64_t vtd_prq_size(IntelIOMMUState *s) +{ + return 1ULL << ((vtd_get_quad(s, DMAR_PQA_REG) & VTD_PQA_SIZE) + 7); +} + +/** + * Return true if the bit is accessible and correctly set, false otherwise + */ +static bool vtd_check_pre_bit(VTDAddressSpace *vtd_as, hwaddr addr, + uint16_t sid, bool is_write) +{ + int ret; + IntelIOMMUState *s =3D vtd_as->iommu_state; + uint8_t bus_n =3D pci_bus_num(vtd_as->bus); + VTDContextEntry ce; + bool is_fpd_set =3D false; + + ret =3D vtd_dev_to_context_entry(s, bus_n, vtd_as->devfn, &ce); + + if (ret) { + goto error_report; + } + + if (!VTD_CE_GET_PRE(&ce)) { + ret =3D -VTD_FR_SM_PRE_ABS; + goto error_get_fpd_and_report; + } + + return true; + +error_get_fpd_and_report: + /* Try to get fpd (may not work but we are already on an error path) */ + is_fpd_set =3D ce.lo & VTD_CONTEXT_ENTRY_FPD; + vtd_ce_get_pasid_fpd(s, &ce, &is_fpd_set, vtd_as->pasid); +error_report: + vtd_report_fault(s, -ret, is_fpd_set, sid, addr, is_write, + vtd_as->pasid !=3D PCI_NO_PASID, vtd_as->pasid); + return false; +} + +/* Logic described in section 7.5 */ +static void vtd_generate_page_request_event(IntelIOMMUState *s, + uint32_t old_pr_status) +{ + uint32_t current_pectl =3D vtd_get_long(s, DMAR_PECTL_REG); + /* + * Hardware evaluates PPR and PRO fields in the Page Request Status Re= gister + * and if any of them is set, Page Request Event is not generated + */ + if (old_pr_status & (VTD_PR_STATUS_PRO | VTD_PR_STATUS_PPR)) { + return; + } + + vtd_set_clear_mask_long(s, DMAR_PECTL_REG, 0, VTD_PR_PECTL_IP); + if (!(current_pectl & VTD_PR_PECTL_IM)) { + vtd_set_clear_mask_long(s, DMAR_PECTL_REG, VTD_PR_PECTL_IP, 0); + vtd_generate_interrupt(s, DMAR_PEADDR_REG, DMAR_PEDATA_REG); + } +} + +/* When calling this function, we known that we are in scalable mode */ +static int vtd_pri_perform_implicit_invalidation(VTDAddressSpace *vtd_as, + hwaddr addr) +{ + IntelIOMMUState *s =3D vtd_as->iommu_state; + VTDContextEntry ce; + VTDPASIDEntry pe; + uint16_t pgtt; + uint16_t domain_id; + int ret =3D vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus), + vtd_as->devfn, &ce); + if (ret) { + return -EINVAL; + } + ret =3D vtd_ce_get_rid2pasid_entry(s, &ce, &pe, vtd_as->pasid); + if (ret) { + return -EINVAL; + } + pgtt =3D VTD_PE_GET_TYPE(&pe); + domain_id =3D VTD_SM_PASID_ENTRY_DID(pe.val[1]); + ret =3D 0; + switch (pgtt) { + case VTD_SM_PASID_ENTRY_FLT: + vtd_piotlb_page_invalidate(s, domain_id, vtd_as->pasid, addr, 0); + break; + /* Room for other pgtt values */ + default: + error_report_once("Translation type not supported yet : %d", pgtt); + ret =3D -EINVAL; + break; + } + + return ret; +} + +/* Page Request Descriptor : 7.4.1.1 */ +static int vtd_pri_request_page(PCIBus *bus, void *opaque, int devfn, + uint32_t pasid, bool priv_req, bool exec_r= eq, + hwaddr addr, bool lpig, uint16_t prgi, + bool is_read, bool is_write) +{ + IntelIOMMUState *s =3D opaque; + VTDAddressSpace *vtd_as; + + vtd_as =3D vtd_find_add_as(s, bus, devfn, pasid); + + uint64_t queue_addr_reg =3D vtd_get_quad(s, DMAR_PQA_REG); + uint64_t queue_tail_offset_reg =3D vtd_get_quad(s, DMAR_PQT_REG); + uint64_t new_queue_tail_offset =3D ( + (queue_tail_offset_reg + VTD_PQA_ENTRY_SIZ= E) % + (vtd_prq_size(s) * VTD_PQA_ENTRY_SIZE)); + uint64_t queue_head_offset_reg =3D vtd_get_quad(s, DMAR_PQH_REG); + hwaddr queue_tail =3D (queue_addr_reg & VTD_PQA_ADDR) + queue_tail_off= set_reg; + uint32_t old_pr_status =3D vtd_get_long(s, DMAR_PRS_REG); + uint16_t sid =3D PCI_BUILD_BDF(pci_bus_num(vtd_as->bus), vtd_as->devfn= ); + VTDPRDesc desc; + + if (!(s->ecap & VTD_ECAP_PRS)) { + return -EPERM; + } + + /* + * No need to check if scalable mode is enabled as we already known th= at + * VTD_ECAP_PRS is set (see vtd_decide_config) + */ + + /* We do not support PRI without PASID */ + if (vtd_as->pasid =3D=3D PCI_NO_PASID) { + return -EPERM; + } + if (exec_req && !is_read) { + return -EINVAL; + } + + /* Check PRE bit in the scalable mode context entry */ + if (!vtd_check_pre_bit(vtd_as, addr, sid, is_write)) { + return -EPERM; + } + + if (old_pr_status & VTD_PR_STATUS_PRO) { + /* + * No action is taken by hardware to report a fault + * or generate an event + */ + return -ENOSPC; + } + + /* Check for overflow */ + if (new_queue_tail_offset =3D=3D queue_head_offset_reg) { + vtd_set_clear_mask_long(s, DMAR_PRS_REG, 0, VTD_PR_STATUS_PRO); + vtd_generate_page_request_event(s, old_pr_status); + return -ENOSPC; + } + + if (vtd_pri_perform_implicit_invalidation(vtd_as, addr)) { + return -EINVAL; + } + + desc.lo =3D VTD_PRD_TYPE | VTD_PRD_PP(true) | VTD_PRD_RID(sid) | + VTD_PRD_PASID(vtd_as->pasid) | VTD_PRD_PMR(priv_req); + desc.hi =3D VTD_PRD_RDR(is_read) | VTD_PRD_WRR(is_write) | + VTD_PRD_LPIG(lpig) | VTD_PRD_PRGI(prgi) | VTD_PRD_ADDR(addr); + + desc.lo =3D cpu_to_le64(desc.lo); + desc.hi =3D cpu_to_le64(desc.hi); + if (dma_memory_write(&address_space_memory, queue_tail, &desc, sizeof(= desc), + MEMTXATTRS_UNSPECIFIED)) { + error_report_once("IO error, the PQ tail cannot be updated"); + return -EIO; + } + + /* increment the tail register and set the pending request bit */ + vtd_set_quad(s, DMAR_PQT_REG, new_queue_tail_offset); + /* + * read status again so that the kernel does not miss a request. + * in some cases, we can trigger an unecessary interrupt but this stra= tegy + * drastically improves performance as we don't need to take a lock. + */ + old_pr_status =3D vtd_get_long(s, DMAR_PRS_REG); + if (!(old_pr_status & VTD_PR_STATUS_PPR)) { + vtd_set_clear_mask_long(s, DMAR_PRS_REG, 0, VTD_PR_STATUS_PPR); + vtd_generate_page_request_event(s, old_pr_status); + } + + return 0; +} + static void vtd_init_iotlb_notifier(PCIBus *bus, void *opaque, int devfn, IOMMUNotifier *n, IOMMUNotify fn, void *user_opaque) @@ -4905,6 +5156,26 @@ static void vtd_unregister_iotlb_notifier(PCIBus *bu= s, void *opaque, memory_region_unregister_iommu_notifier(MEMORY_REGION(&vtd_as->iommu),= n); } =20 +static void vtd_pri_register_notifier(PCIBus *bus, void *opaque, int devfn, + uint32_t pasid, IOMMUPRINotifier *notifier) +{ + IntelIOMMUState *s =3D opaque; + VTDAddressSpace *vtd_as; + + vtd_as =3D vtd_find_add_as(s, bus, devfn, pasid); + vtd_as->pri_notifier =3D notifier; +} + +static void vtd_pri_unregister_notifier(PCIBus *bus, void *opaque, + int devfn, uint32_t pasid) +{ + IntelIOMMUState *s =3D opaque; + VTDAddressSpace *vtd_as; + + vtd_as =3D vtd_find_add_as(s, bus, devfn, pasid); + vtd_as->pri_notifier =3D NULL; +} + static PCIIOMMUOps vtd_iommu_ops =3D { .get_address_space =3D vtd_host_dma_iommu, .set_iommu_device =3D vtd_dev_set_iommu_device, @@ -4914,6 +5185,9 @@ static PCIIOMMUOps vtd_iommu_ops =3D { .register_iotlb_notifier =3D vtd_register_iotlb_notifier, .unregister_iotlb_notifier =3D vtd_unregister_iotlb_notifier, .ats_request_translation =3D vtd_ats_request_translation, + .pri_register_notifier =3D vtd_pri_register_notifier, + .pri_unregister_notifier =3D vtd_pri_unregister_notifier, + .pri_request_page =3D vtd_pri_request_page, }; =20 static bool vtd_decide_config(IntelIOMMUState *s, Error **errp) --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692448; cv=none; d=zohomail.com; s=zohoarc; b=YVi1RhJ3k6LzW5MzTQHKxAGYI4bCdZqgThwDJnNZn6UHVsAx1YBAlosXIexTFFfQbVrJUjiawDV5MhlNl21cjOp+wc8HaC7BJiqjUWLpWhkf+n46bFqDZxqAevrMo1dsfQ/5//ZIJ5KdDTHjkFx2k0Drmre9nVubwbc6ZdmeXv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692448; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ml2pFyRHG+5Bce2r6KPnxhJb7q8qJwL1Tv/Mz3Zw5Ls=; b=IpGz6LaZZO/4/MFgPkzpxfLbHu1v6g8UHaSjoTNvkz7VNHMVeO3YWaF+coZC+rvG5st678dgR0WBkF0kyhXVEENEaX+KqRr0MrAY3dXfSgPl9so+IuewK/hYilMpozfiJKTsUTDDIv81NJur/AkvMknUw4VgZ+dR2DcsFN5jJUM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692448000329.11839918583667; Sun, 5 Oct 2025 12:27:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFH-00022P-O8; Sun, 05 Oct 2025 15:18:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEp-0000Lc-VE for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEo-0006YA-12 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:43 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-47-HKJN_48YO4WlCkbFmeOOqA-1; Sun, 05 Oct 2025 15:17:40 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3efa77de998so2422407f8f.0 for ; Sun, 05 Oct 2025 12:17:40 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6c49sm17544030f8f.3.2025.10.05.12.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691861; 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=ml2pFyRHG+5Bce2r6KPnxhJb7q8qJwL1Tv/Mz3Zw5Ls=; b=T9HPp4m5UV8eG7PSON/9yYUwZEadOjNhrMhWKwiAeF809pUMXKeHPkiC27yaQYWS9phGgS dpVDDg7an3UxvvL735bx69rCs2Rx4jBKXrqMX3Yae4eNg9FXqi38hzADo/wmBhO/LUW4pF xcEwfavaoPH6Lp1tDIeaoix1KPi7vu8= X-MC-Unique: HKJN_48YO4WlCkbFmeOOqA-1 X-Mimecast-MFC-AGG-ID: HKJN_48YO4WlCkbFmeOOqA_1759691859 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691859; x=1760296659; 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=ml2pFyRHG+5Bce2r6KPnxhJb7q8qJwL1Tv/Mz3Zw5Ls=; b=rTquNMCF8HFHp/wkHetit+ZgIQywc34cWGd83e/DA7kLHF8DbJkqF2l46BF8ZIwAhw vFnFZOy+4TYU2oh4Vrzw7UvTrwiows5a/DhJDWOcwuM8wzLNY2u5WI60UwlSmSDzKf4V wOb+AgnkrzQs+QqrOAQ16FDI/Xj8x8rxH4gaCZwamP0KaeLyaUCzZur6Fi1SHf39lfco Pafz8ONUFkTeNhBeRqjZqelVB62X/Zc5wLNeH5CWzmRfwJPhdPOdMZ2CJo8gHcQTfNMR spjPbzSjeqMuA8RycAGTYU7uSoS70nLyD+8AZhN3kPO60xlFpbgQ+mmYYhQ7K1eHtnLA k3ag== X-Gm-Message-State: AOJu0YwxGvxLolAhDTLMlt+4sFNG/v2ZCXOvFpMXzG9UPpCCucRlmc1i WAMvfanyhb4GOfG1dulnpOtrvamzmZMh/cgyGDaEG+Llr66cQMEbwjsmyoVxgLQ0aceGnqe/NXj 6orlfk7PL0Ss8fSAo1xpmWmWYkAnVUff24uk+LKInYNGhADZ/7P+zXypkB5sQdci8BqDExWMreV SKMsfHGEWz8UFdw4ooQ1FYbLxWAZjNTdRv2A== X-Gm-Gg: ASbGncuRegTth6YnBUC7GJ3yp6UN0bA4rl49Cr5n5X4NPm244rmKxojZz3jvbNdPgcn 9E7jLji59riHp4mZtkplhtqLzB/702DHrdrHAnRCQ+CDttpdH65jqofyIRqaAlQ00BCd5MNvZdN r5HCBNB4BuLxmHZInqkkssaPWItSc3u1AxTDlPHJh3T86TsuBmrZf4u14IbQcCY8EjG4nflEYjk uxmbxJ+xNtwvklsjtiuSV421LjgvcUATrodmkfNuaTqHoqMIHwkiwqlimO1Qo6Igt1uBEFlunP7 GncAxplOpIV1kMn2DsTLX9xCxWmxxiC+Grl/QD0= X-Received: by 2002:a05:600c:628b:b0:46e:4883:27d with SMTP id 5b1f17b1804b1-46e71147470mr70617265e9.30.1759691858955; Sun, 05 Oct 2025 12:17:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHEocTYVD3Zo4TaQuwGW2gr/V5ZX8yY3DnPRKTTtMy4X0M78zGcVL/zOtaT54s2UT+a6t9zig== X-Received: by 2002:a05:600c:628b:b0:46e:4883:27d with SMTP id 5b1f17b1804b1-46e71147470mr70617115e9.30.1759691858416; Sun, 05 Oct 2025 12:17:38 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:36 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Igor Mammedov , Daniel P =?utf-8?B?LiBCZXJyYW5nw6k=?= , Marcel Apfelbaum Subject: [PULL 42/75] x86: ich9: fix default value of 'No Reboot' bit in GCS Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692454175116600 From: Igor Mammedov [2] initialized 'No Reboot' bit to 1 by default. And due to quirk it happen= ed to work with linux iTCO_wdt driver (which clears it on module load). However spec [1] states: " R/W. This bit is set when the =E2=80=9CNo Reboot=E2=80=9D strap (SPKR pin on ICH9) is sampled high on PWROK. " So it should be set only when '-global ICH9-LPC.noreboot=3Dtrue' and clear= ed when it's false (which should be default). Fix it to behave according to spec and set 'No Reboot' bit only when '-global ICH9-LPC.noreboot=3Dtrue'. 1) Intel I/O Controller Hub 9 (ICH9) Family Datasheet (rev: 004) 2) Fixes: 920557971b6 (ich9: add TCO interface emulation) Signed-off-by: Igor Mammedov Tested-by: Daniel P. Berrang=C3=A9 Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Michael S. Tsirkin Message-ID: <20250922132600.562193-1-imammedo@redhat.com> Signed-off-by: Michael S. Tsirkin --- include/hw/southbridge/ich9.h | 2 +- hw/isa/lpc_ich9.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/hw/southbridge/ich9.h b/include/hw/southbridge/ich9.h index 1e231e89c9..2c35dd0484 100644 --- a/include/hw/southbridge/ich9.h +++ b/include/hw/southbridge/ich9.h @@ -95,7 +95,7 @@ struct ICH9LPCState { #define ICH9_CC_OIC 0x31FF #define ICH9_CC_OIC_AEN 0x1 #define ICH9_CC_GCS 0x3410 -#define ICH9_CC_GCS_DEFAULT 0x00000020 +#define ICH9_CC_GCS_DEFAULT 0x00000000 #define ICH9_CC_GCS_NO_REBOOT (1 << 5) =20 /* D28:F[0-5] */ diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c index 304dffac32..c9cb8f7779 100644 --- a/hw/isa/lpc_ich9.c +++ b/hw/isa/lpc_ich9.c @@ -132,6 +132,11 @@ static void ich9_cc_init(ICH9LPCState *lpc) static void ich9_cc_reset(ICH9LPCState *lpc) { uint8_t *c =3D lpc->chip_config; + uint32_t gcs =3D ICH9_CC_GCS_DEFAULT; + + if (lpc->pin_strap.spkr_hi) { + gcs |=3D ICH9_CC_GCS_NO_REBOOT; + } =20 memset(lpc->chip_config, 0, sizeof(lpc->chip_config)); =20 @@ -142,7 +147,7 @@ static void ich9_cc_reset(ICH9LPCState *lpc) pci_set_long(c + ICH9_CC_D27IR, ICH9_CC_DIR_DEFAULT); pci_set_long(c + ICH9_CC_D26IR, ICH9_CC_DIR_DEFAULT); pci_set_long(c + ICH9_CC_D25IR, ICH9_CC_DIR_DEFAULT); - pci_set_long(c + ICH9_CC_GCS, ICH9_CC_GCS_DEFAULT); + pci_set_long(c + ICH9_CC_GCS, gcs); =20 ich9_cc_update(lpc); } --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692007; cv=none; d=zohomail.com; s=zohoarc; b=FTmJ+E3itkeLG1lvHb2uekv/nc9iN6O479cbkUMp6mw4Rv5ES/FjvZ8qNjiVZn7WKK0E8MI3MrXk9kFm5jBBILMywYImXArICN952Ga7Wg5oHY8tQ7gaGHSuNFI+QtV/L7vsGZGxAQ2fudIbDUbUAcje+a1qQflR/4ZaK1tlSgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692007; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qaaiPsY2w5X1nM8WzdUOv5p6rMVvIWhXGJwIV0z7Nm0=; b=UnHmophKQCuBkZwkDqWTx88TElx9f8bEDqsh5vv0/EUYdeZSVJ5ZWU6qNrkUI+RqJZcROmWRU152UQzX0WUrizqbf7T2n1SRZQc89Qe8weIwPrSigVuicuABeI5uuD04XplUTYcRt/km1PmqKhij24L7+Xy6Qt0ShwTRMSM1XMQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692007927525.994493889742; Sun, 5 Oct 2025 12:20:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFM-0002IZ-4B; Sun, 05 Oct 2025 15:18:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEs-0000Ux-SW for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEq-0006YY-JK for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:46 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-267-NL3s316JM_6O4lxWQfAn1g-1; Sun, 05 Oct 2025 15:17:42 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e46486972so11981475e9.0 for ; Sun, 05 Oct 2025 12:17:42 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f011bsm17778306f8f.46.2025.10.05.12.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691863; 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=qaaiPsY2w5X1nM8WzdUOv5p6rMVvIWhXGJwIV0z7Nm0=; b=G37fLBIz3CwVEs+afwETqFgyPdgvoEkVxbtAzVQ7CQGMzESUeS+DO6vozEj8HSDqWQD/p0 RW4rIYMrpU8E660OljKV6gq/lMckP74E7qQG6uepi2bE7cnpULN26AzpiPZEwEfo+xLJ0M X72TY62sl6B+cYZEe1TGKyUaSU9r7BQ= X-MC-Unique: NL3s316JM_6O4lxWQfAn1g-1 X-Mimecast-MFC-AGG-ID: NL3s316JM_6O4lxWQfAn1g_1759691861 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691861; x=1760296661; 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=qaaiPsY2w5X1nM8WzdUOv5p6rMVvIWhXGJwIV0z7Nm0=; b=KYZDq9HqaP6IZj/nCwJize6HhYvTa55hTe1SKVsHDEXqiXyBPAxxWAsL4YF3MmI0ic siBcB5cqSZMeI22CC7co6mR30sZwz/7X3fqMofB6mzPwS8B01PNdUCWI5Kia3VSs4PI0 dv+ZwhvgekiNAYPu2k9Q9kEOcPw09L3qGK7jlQrX8O/Bb7gVqZrvxCTyq+KdZ7YNHczx Ln2gxSXj590N/i7ts4UkyRUiIUZPF+DkwSW7Hspt2WEp7RVnZvFDSldWz7FUFucd7483 l3XQ9kt85w2jLfsWSQqjFEU18eixEOOlwXIfZfTqK+pWH1rPvNgctKo6q+GGpuTFmWDi CH1A== X-Gm-Message-State: AOJu0YwpI39Vz9q0dCzyQjyGYOekH+yUSD7yo9Dg5UftlZ4dSlVZLDkK lgX7h2r/ECaTcZfr12svOrVYytktSe50QBtJ06WM/DzjhJkDBum0q9ruYwEJhrmK/riDi+tbva4 2PGOwX+flwlnRSohlcOrwCN+4DX2Yz/szaYPB2xEKx4i80Apc03vucarbZrr3HSgsVIqYvLSmNY 9PmyDrCxQ0BXUbOHIl24Kz3f9OBiVdv0ihug== X-Gm-Gg: ASbGncvsKYlgyUBcqkxH7O2j3DB68hZYE+l6Aj2aXZF2RKJFwuSQDa60TsMHa2VfRGD he6HNMrBBU0tUG+lf0ssZYJ/FdEJtwaSeioFhs/4qS6lyJ0wE9/cFbKtAHvWsF3rQAPn2hMYS/6 z7DKzltlEl4nzqFYKXY8BYx4IqmXY04nqGtlMDbMUFct6jy0qALFzdEuPuG88FlG9Rgqig8zrCJ yKo9YWH84+aCbiGK8Do9dWMVaiVGUpHQ+Na3/4K2Ya/a0dWvICxr/d4xdOXkXBZ0aDlCSp/y9nV evvh9LFPoIHseiEvVu6K/GY0Zgu4rsBwt/RIHYs= X-Received: by 2002:a05:600c:348b:b0:46e:37fc:def0 with SMTP id 5b1f17b1804b1-46e71109e9bmr73743435e9.9.1759691861184; Sun, 05 Oct 2025 12:17:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7MG29ead6ZhiEZE+wFOJBGbwp4ZdkzxVyFIDonZ1hd485L+ZqXS/rKLyM/HEIehckecG8bg== X-Received: by 2002:a05:600c:348b:b0:46e:37fc:def0 with SMTP id 5b1f17b1804b1-46e71109e9bmr73743235e9.9.1759691860609; Sun, 05 Oct 2025 12:17:40 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:38 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Stefano Garzarella Subject: [PULL 43/75] vhost: use virtio_config_get_guest_notifier() Message-ID: <2e41580328a9cdfffce3ee496857c1b2d6ed365e.1759691708.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692010653116600 From: Stefan Hajnoczi There is a getter function so avoid accessing the ->config_notifier field directly. Signed-off-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Message-ID: <20250922220149.498967-2-stefanha@redhat.com> Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 5f485ad6cb..c120ef38b9 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1846,7 +1846,7 @@ void vhost_config_mask(struct vhost_dev *hdev, VirtIO= Device *vdev, bool mask) int r; EventNotifier *notifier =3D &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier; - EventNotifier *config_notifier =3D &vdev->config_notifier; + EventNotifier *config_notifier =3D virtio_config_get_guest_notifier(vd= ev); assert(hdev->vhost_ops); =20 if ((hdev->started =3D=3D false) || @@ -1877,13 +1877,15 @@ static void vhost_stop_config_intr(struct vhost_dev= *dev) static void vhost_start_config_intr(struct vhost_dev *dev) { int r; + EventNotifier *config_notifier =3D + virtio_config_get_guest_notifier(dev->vdev); =20 assert(dev->vhost_ops); - int fd =3D event_notifier_get_fd(&dev->vdev->config_notifier); + int fd =3D event_notifier_get_fd(config_notifier); if (dev->vhost_ops->vhost_set_config_call) { r =3D dev->vhost_ops->vhost_set_config_call(dev, fd); if (!r) { - event_notifier_set(&dev->vdev->config_notifier); + event_notifier_set(config_notifier); } } } @@ -2167,12 +2169,13 @@ static int do_vhost_dev_stop(struct vhost_dev *hdev= , VirtIODevice *vdev, { int i; int rc =3D 0; + EventNotifier *config_notifier =3D virtio_config_get_guest_notifier(vd= ev); =20 /* should only be called after backend is connected */ assert(hdev->vhost_ops); event_notifier_test_and_clear( &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier); - event_notifier_test_and_clear(&vdev->config_notifier); + event_notifier_test_and_clear(config_notifier); event_notifier_cleanup( &hdev->vqs[VHOST_QUEUE_NUM_CONFIG_INR].masked_config_notifier); =20 --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692515; cv=none; d=zohomail.com; s=zohoarc; b=QTMWsmzGTx0k+wCAEeGBn8iFp76NVaXMa/DVVvOHUyl4ndktXS2MKAeXGS2uqWnmhF6Dw7FgsB9nzFH3t+A1MvKqW+uQ3LXfj0u/Y2dzk0IpNCVBmg8j+5W2Cmk27RQuO734c/lIeEkAk4zbXQzXfzbbU7LOvNtl79VmcTpKJ30= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692515; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=K0uPqEt6u9YfLfkNfM1cQHFS+f7aPhD9qXs0swcauCo=; b=fCouO7OV6OYeyYiKaXLUHjWv/4Si9V1fbbNRz862DvIaKEUDewwV7rvBXU9PVogXPvRjCjNwDLefCwMZ/EkMj6U+Cw31xKbbo3JIeXKhX0EXYom8hGwqLKMnjyJSLoyF5wmud0ic8+uPUdpJEd2P9mfLLdGW/r6CBAIDV9Z4ua4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175969251555090.70538651270192; Sun, 5 Oct 2025 12:28:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFZ-0002nP-1L; Sun, 05 Oct 2025 15:18:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEv-0000ak-1C for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:51 -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 1v5UEt-0006Z4-6Z for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:48 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-118-JKvdfRyXOJKvsOaev5_P9A-1; Sun, 05 Oct 2025 15:17:44 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46e407c600eso21617175e9.3 for ; Sun, 05 Oct 2025 12:17:44 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e7236267bsm134197825e9.16.2025.10.05.12.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691866; 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=K0uPqEt6u9YfLfkNfM1cQHFS+f7aPhD9qXs0swcauCo=; b=NJeolQGINj6LdYjfBrLRETfwGECrdR44pRmDLPNbZpI4ya3o1UT6tk4SoJRJbDNYcZeJL3 QpOd/1TesN7eYh70PgcNvhCIAs2IIek0C+j6tp+fUAWylpXbvBHoB9dLL79ZP9F64rcliF Tp82sAOXczNpGdcEVtqqEQ1fBS9I5EU= X-MC-Unique: JKvdfRyXOJKvsOaev5_P9A-1 X-Mimecast-MFC-AGG-ID: JKvdfRyXOJKvsOaev5_P9A_1759691864 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691863; x=1760296663; 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=K0uPqEt6u9YfLfkNfM1cQHFS+f7aPhD9qXs0swcauCo=; b=mhlS4DfBrUYlXbrJCfM9zu+oTuUkix++JhfNRF0tNCKrqGYfuxUhIgzxiFSHgQkXdi KjX/d1aqVQoiokX5HVBF5eRT94euIE60hE02If3cemi8/gksxWj6V3DOrp6gxUFPMVzU nqq8+FW82i/8ErM7ndWbyBSLXNhs09ykgJlhenOfKpvklgl7Rq+He7i/8CvOOx4isWj4 tHBPA6HdRx3g3DiUiLS+Liv/wMkqAmyyPxD6YeiYYaOh5YDJ6EA9uXtUZFAD1SmJI5gb dTsi4VoPf4oT2L2S0Oy8Z+eFJoX78OmL1Bs/ax+DKezxfjsZtj+/DQoC5BpTLqzflRK3 2+Ig== X-Gm-Message-State: AOJu0YzrvtQC829STzF+AuVyzEAprOnMhniVlj+KeK6cGfLEc9PhViyY 6J1Rxh9NV8WALPo3VbEyuBQuVLnotHu0dC9WaO4yK/xXFLhmsMzV3STiaLhIPFyqiJij6Qgm+q+ F7bo3z6BbA81fmviv0wfje7AqAr8FgUcSt4vQib46AVwZEttcOIV4D6xpgxt5af01xgMEJ+zMp/ YpIcog4TV9be1KpjuHBDQZbteaPfLdJe+Bwg== X-Gm-Gg: ASbGncv/Kw3+fR5ZA16NEL8RhkW5P/gEzxEvDBFzyMzCXAR0XxLncpfTOzkDGwVMQjP gqxQRmjR3IdTIi3a7xUMtiFfGXQlfoOcBGb434OwOz6Wkd4MGmPGIVjN59tf37yXsrSm5WckDJ8 vA1neN5Qd1CTaQmUTwMahFLpzUmKDtNbluaTh8md0qBTzYYwnnHA8vBAUCMpj+F9nupkziaZeuD rlVs625/YNCNloL7XlVUH98X0kwRlAqX7OT5MFhfI0y8cP8P0xf88+ywljJnHRRVdMqvVv0OvzY qwvB/1QeoUMaiojPCnIjTbGqVBxlMA1Jd/h/070= X-Received: by 2002:a05:600c:64c4:b0:46d:45e:3514 with SMTP id 5b1f17b1804b1-46e7114310amr81609585e9.17.1759691863266; Sun, 05 Oct 2025 12:17:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEz8+QFjI/uSFb/4Des0Mu5TJVk8BaxcHcHYzng7TROCGTP1QwuCkiSx7iS/5INH+HPbSgAyw== X-Received: by 2002:a05:600c:64c4:b0:46d:45e:3514 with SMTP id 5b1f17b1804b1-46e7114310amr81609395e9.17.1759691862789; Sun, 05 Oct 2025 12:17:42 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:40 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Kevin Wolf , Hanna Reitz , Paolo Bonzini , Fam Zheng , qemu-block@nongnu.org Subject: [PULL 44/75] virtio: unify virtio_notify_irqfd() and virtio_notify() Message-ID: <1e9181dc5277f27fcda21f64a399f12bbf578e5e.1759691708.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692517470116600 From: Stefan Hajnoczi The difference between these two functions: - virtio_notify() uses the interrupt code path (MSI or classic IRQs) - virtio_notify_irqfd() uses guest notifiers (irqfds) virtio_notify() can only be called with the BQL held because the interrupt code path requires the BQL. Device models use virtio_notify_irqfd() from IOThreads since the BQL is not held. The two functions can be unified by pushing down the if (qemu_in_iothread()) check from virtio-blk and virtio-scsi into core virtio code. This is in preparation for the next commit that will add irqfd support to virtio_notify_config() and where it's unattractive to introduce another irqfd-only API for device model callers. Signed-off-by: Stefan Hajnoczi Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Message-ID: <20250922220149.498967-3-stefanha@redhat.com> Signed-off-by: Michael S. Tsirkin --- include/hw/virtio/virtio.h | 1 - hw/block/virtio-blk.c | 6 +----- hw/scsi/virtio-scsi.c | 6 +----- hw/virtio/virtio.c | 28 +++++++++++++--------------- hw/virtio/trace-events | 1 - 5 files changed, 15 insertions(+), 27 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 2aeb021fb3..d97529c3f1 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -294,7 +294,6 @@ int virtqueue_get_avail_bytes(VirtQueue *vq, unsigned i= nt *in_bytes, unsigned int *out_bytes, unsigned max_in_byt= es, unsigned max_out_bytes); =20 -void virtio_notify_irqfd(VirtIODevice *vdev, VirtQueue *vq); void virtio_notify(VirtIODevice *vdev, VirtQueue *vq); =20 int virtio_save(VirtIODevice *vdev, QEMUFile *f); diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 9bab2716c1..64efce4846 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -62,11 +62,7 @@ void virtio_blk_req_complete(VirtIOBlockReq *req, unsign= ed char status) iov_discard_undo(&req->inhdr_undo); iov_discard_undo(&req->outhdr_undo); virtqueue_push(req->vq, &req->elem, req->in_len); - if (qemu_in_iothread()) { - virtio_notify_irqfd(vdev, req->vq); - } else { - virtio_notify(vdev, req->vq); - } + virtio_notify(vdev, req->vq); } =20 static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index 34ae14f7bf..d817fc42b4 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -116,11 +116,7 @@ static void virtio_scsi_complete_req(VirtIOSCSIReq *re= q, QemuMutex *vq_lock) } =20 virtqueue_push(vq, &req->elem, req->qsgl.size + req->resp_iov.size); - if (s->dataplane_started && !s->dataplane_fenced) { - virtio_notify_irqfd(vdev, vq); - } else { - virtio_notify(vdev, vq); - } + virtio_notify(vdev, vq); =20 if (vq_lock) { qemu_mutex_unlock(vq_lock); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 34f977a3c9..6ce5823898 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -31,6 +31,7 @@ #include "hw/qdev-properties.h" #include "hw/virtio/virtio-access.h" #include "system/dma.h" +#include "system/iothread.h" #include "system/runstate.h" #include "virtio-qmp.h" =20 @@ -2654,16 +2655,8 @@ static void virtio_notify_irqfd_deferred_fn(void *op= aque) event_notifier_set(notifier); } =20 -void virtio_notify_irqfd(VirtIODevice *vdev, VirtQueue *vq) +static void virtio_irq(VirtQueue *vq) { - WITH_RCU_READ_LOCK_GUARD() { - if (!virtio_should_notify(vdev, vq)) { - return; - } - } - - trace_virtio_notify_irqfd(vdev, vq); - /* * virtio spec 1.0 says ISR bit 0 should be ignored with MSI, but * windows drivers included in virtio-win 1.8.0 (circa 2015) are @@ -2680,13 +2673,18 @@ void virtio_notify_irqfd(VirtIODevice *vdev, VirtQu= eue *vq) * to an atomic operation. */ virtio_set_isr(vq->vdev, 0x1); - defer_call(virtio_notify_irqfd_deferred_fn, &vq->guest_notifier); -} =20 -static void virtio_irq(VirtQueue *vq) -{ - virtio_set_isr(vq->vdev, 0x1); - virtio_notify_vector(vq->vdev, vq->vector); + /* + * The interrupt code path requires the Big QEMU Lock (BQL), so use the + * notifier instead when in an IOThread. This assumes that device mode= ls + * have already called ->set_guest_notifiers() sometime before calling= this + * function. + */ + if (qemu_in_iothread()) { + defer_call(virtio_notify_irqfd_deferred_fn, &vq->guest_notifier); + } else { + virtio_notify_vector(vq->vdev, vq->vector); + } } =20 void virtio_notify(VirtIODevice *vdev, VirtQueue *vq) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 76f0d458b2..658cc365e7 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -75,7 +75,6 @@ virtqueue_flush(void *vq, unsigned int count) "vq %p coun= t %u" virtqueue_pop(void *vq, void *elem, unsigned int in_num, unsigned int out_= num) "vq %p elem %p in_num %u out_num %u" virtio_queue_notify(void *vdev, int n, void *vq) "vdev %p n %d vq %p" virtio_notify_irqfd_deferred_fn(void *vdev, void *vq) "vdev %p vq %p" -virtio_notify_irqfd(void *vdev, void *vq) "vdev %p vq %p" virtio_notify(void *vdev, void *vq) "vdev %p vq %p" virtio_set_status(void *vdev, uint8_t val) "vdev %p val %u" =20 --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691904; cv=none; d=zohomail.com; s=zohoarc; b=HjfIvwtXEoMoTdVXCYNZzNL9DVp2Je7D2alo0wzd1/CfeYLI750qDJL5ndb9dS1MIy+FBAH2UTaLo7EEsxGQEOMJWlisbyPHCCreiwyHl+/MAYiSXMGH1sovuKcE4ZZ677McX0sBozEGEunJPJ93EO2SeXxzhRekVZCaJeuhWNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691904; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fsCkkNSHYfcaJuM2hlwVcv/fUH7NdmQE3XTFVuuNZ8Y=; b=MUduEPe3NV8QgylaJ0tRX5MZ50nn1OvePHwrhN+VPU6XJo57Q0qVO1uNuvQ9KPYq+fBML9YrP4tNDxleNhaCvatcjvvdypn6YDtI5H3fhFA9jcSl427vBa4e+KhWjFy7wppWRhcEOYhqZ+NllZc6zqsoZqnkybZnmce5cGms5Gg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691904046127.73350139587251; Sun, 5 Oct 2025 12:18:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFJ-0002AO-QF; Sun, 05 Oct 2025 15:18:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UEw-0000b6-GB for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:51 -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 1v5UEv-0006ZV-1X for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:50 -0400 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-294-0hl0lmFlNVWrbxgpBFgBcA-1; Sun, 05 Oct 2025 15:17:47 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3ecdc9dbc5fso2219232f8f.1 for ; Sun, 05 Oct 2025 12:17:46 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e61a022d8sm212110245e9.12.2025.10.05.12.17.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691868; 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=fsCkkNSHYfcaJuM2hlwVcv/fUH7NdmQE3XTFVuuNZ8Y=; b=YMyuopKWMNnnWZTU8LFB1VLpipQGjz9grLvWU2BmkqVoEMlfU9+HJNxIW0+Cyr/Ak8/HjG j8pRIzrSr/R1Jj+NaVtE0d/zCs0merwUojl0rBKuzlegaQH1RsOyTSB5dgvLwko5lKN/CC tn0ihiW1eYllten0wQKhhbLwI8s6vco= X-MC-Unique: 0hl0lmFlNVWrbxgpBFgBcA-1 X-Mimecast-MFC-AGG-ID: 0hl0lmFlNVWrbxgpBFgBcA_1759691866 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691865; x=1760296665; 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=fsCkkNSHYfcaJuM2hlwVcv/fUH7NdmQE3XTFVuuNZ8Y=; b=aSSlTkE8YfbTXZ81UbdOFbHdlzq4h0ECEg8AtLtM8epY0F11HXNj8BLgUQ1BJbxD3W a+IpSFRcCO1Fs6kY80WkY1WBQOOsSRxR2cLZUyuOj0YclBnzvytsgEVg5JLBgvzikbBu y6/fUSuPJ+JcfqTAUsobBcTZfiZnTLtK4Nt9QqlfnDpGlIQd8tB1xIxi2emAXskgsH1M FzB4s2VXJyiLfUFV4RK6XCoDeeIJQZvSW7zp7l7g0Hh259TMvSXbKt2UV+ifh77uIx+L X6V4d2DsbIqbxAzO5n5+y5p0vC6LROkEPPlEmRrGPQ/8X8eDOhvoYygKXnNJj2GHQse2 PhbA== X-Gm-Message-State: AOJu0YyGeCrIr9IsyoihBYKjvoRlrgILxoTwTzjTwKJcRt35nkl8sl2u Dx1Su/2luvZdq/pvJ78C2FGZZ4yA7A+Wu6Q6rsAmi+moPwzsIYUJm2fepQ2mowRhrUdGtS/g4y2 XPPh1/ClOQI29OVbG7QNLDu1Cly4fZxrHr7cuuPtsTXHIUZL+9j6tyztZH0gZaqtLl6cDrLJ7Y9 OEUgfIoiRTQl4vfov6UdkYrqDEiNbjz/0gkg== X-Gm-Gg: ASbGnctxS2vUV35KmpRi65vHHKeOAeVfLmlUvjspmyysmAREn/GXBffZlsaZyIiwdSN prabgVg2BZDJGSG8Ks41bU0l4DhIq+k6FayZ5q5J6UauZmsbzAXYgSF36p2tq+GdFtiyc4ut5I/ BNFZuu1K9FohccxO0tI68CKx4CALbOISjx56Tqp6MsRsskVWtIoxUFVoGxzGjq7GzZYarHHxbZT neGchzXnt55VuKbQe6AozIhZ/teb+3qyGWaeq8gW4z9gz3CqgnAL9wf1KMsmeHiuPik03Tjdf/l NcQWRjPUIz6X8m0Q7cgEZvx+6wXi8Yf2NRGUOrw= X-Received: by 2002:a05:600c:354d:b0:46e:6a6a:5cf7 with SMTP id 5b1f17b1804b1-46e711026c4mr71744945e9.12.1759691865532; Sun, 05 Oct 2025 12:17:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+NAHvSkvlMe7/e4a6hPO+bRAmn2Zl5nlJ0yUDRL1Nkcoz3/GKwi0PM6Ss0UYqSVkOQOK9DQ== X-Received: by 2002:a05:600c:354d:b0:46e:6a6a:5cf7 with SMTP id 5b1f17b1804b1-46e711026c4mr71744845e9.12.1759691865112; Sun, 05 Oct 2025 12:17:45 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:42 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi Subject: [PULL 45/75] virtio: support irqfd in virtio_notify_config() Message-ID: <3b11003fa67b3f055637ff52e1fe8327f7590ee1.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691907338116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi virtio_error() calls virtio_notify_config() to inject a VIRTIO Configuration Change Notification. This doesn't work from IOThreads because the BQL is not held and the interrupt code path requires the BQL. Follow the same approach as virtio_notify() and use ->config_notifier (an irqfd) when called from the IOThread. Signed-off-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Message-ID: <20250922220149.498967-4-stefanha@redhat.com> Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 6ce5823898..de89e8104a 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2706,7 +2706,12 @@ void virtio_notify_config(VirtIODevice *vdev) =20 virtio_set_isr(vdev, 0x3); vdev->generation++; - virtio_notify_vector(vdev, vdev->config_vector); + + if (qemu_in_iothread()) { + defer_call(virtio_notify_irqfd_deferred_fn, &vdev->config_notifier= ); + } else { + virtio_notify_vector(vdev, vdev->config_vector); + } } =20 static bool virtio_device_endian_needed(void *opaque) --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692482; cv=none; d=zohomail.com; s=zohoarc; b=VSk9gpb3/H2obwCVWS9PNJN2kflHIZlnIlWLQV37ZVs38HNYgSCdUjUkG89C9iWooGVq06R8RSBD6SK6/LxF4XH5zwugGqHEy0DOytuT41h4ZT+w+XPNfsbaxVHYNv059k1P6uQBbpQ0XkbCrzQWCDXRN8VGWgt0bH+wNP5SExY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692482; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=aUkGCRfY+3KGS8RLvcJBTE15uJQeumysIiIS7R/VTY4=; b=LKusJ7tnme0VeQEN9UUrE7Q7afRD7TttmNTACVhU255Ju66Pxx7o/8yRWV6chxQxtz8bROC8yfDavAMEMD+jEOrb3FsxxFokHm6MxSeRukPb8VJXcMFfp46qmAyRBTjFMpGJPANCIh7+0gEheo197cQP9hm0T+rTh3uclMkoHp0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692482644955.4335131373342; Sun, 5 Oct 2025 12:28:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFa-000328-Af; Sun, 05 Oct 2025 15:18:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFB-0000uA-4M for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:05 -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 1v5UEx-0006Zn-3t for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:17:52 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-589-vq57Lx3pMpq19lJ0ffWJrQ-1; Sun, 05 Oct 2025 15:17:49 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3ecdfe971abso3387895f8f.2 for ; Sun, 05 Oct 2025 12:17:48 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8acc4csm17211783f8f.16.2025.10.05.12.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691870; 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=aUkGCRfY+3KGS8RLvcJBTE15uJQeumysIiIS7R/VTY4=; b=ZAsjjbbKvft5+9qBQjfkxCO6Ad38mRPnrpu0gPKsC/Xdh/TIN7cVumr/G7u/99LKLWOfhZ xZof/kgRSBo797eTqRdw2Y2RMq6iZ0PIXHY324bqKjZaIkQU9lC4VGUbA30q7SL/Z8UtKs zomIE+qTKWyNjTJttebjf8kNyCIjgLw= X-MC-Unique: vq57Lx3pMpq19lJ0ffWJrQ-1 X-Mimecast-MFC-AGG-ID: vq57Lx3pMpq19lJ0ffWJrQ_1759691868 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691867; x=1760296667; 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=aUkGCRfY+3KGS8RLvcJBTE15uJQeumysIiIS7R/VTY4=; b=jMkE1Wq+rP9u5btwey7Gh7pQZjJIqb1ZYfxixFmKCbwfoVOsbocPx2/Uwb88ofNzjC Yi/QVI163wz0Y6dm8atQH3B9UtWgl35IfNULiSpf1eqOTz4t8HCYC9KrRm4YL2HEnxz/ ZcPny7p0cP0qfviL6on7iM2iqgno7q2foP4ri2vcR817hK0mB7bj+nmCGstUP5TVKMQP qF/EO5ml3fZGXC826F6YRLD1wPr8SiU6uLuVNXAdkS5O/pIbz4NqU+JpTI3W+edProfm 4VC0Mfj5I+TvuZXwb9UXbzbouygbNgjb2thRdz481yREIModSeP9zzlmopFHUEpG9WL3 fJuA== X-Gm-Message-State: AOJu0YxtP+tr0M2MlzH41mh1CxrxqWCY3aQUEaPPE4jJAprNLC/cEzQh b5zbl2Vz5DPZ5di0rXpD2W1ixYFkJyAznHt9N0AUVsnm16B+uDJ8CrOuhdlU58D5EKIPN40c3GA PzpWtj/buX8n7ZBo1aBBiqnwDW7ZdRdJ+A+Dn5QKufcbE8ov9m+Y5RGUwOGe46oi6hCL4u1dXq3 bBcjslWBHhwzJ5cR1wMxu8xq2Uz3ISiDR+BA== X-Gm-Gg: ASbGncuJjrYwHfZgnSOMCmSlR6V/45wHmSIpqcXhd3KkQPQEt0u+qMID+GGwXCSuXEi v0na+Gm2nzFYraoqFCvGjqKyYWSJ1nU9D26TpScfSOmtGAzkz7xHDxt7W6+2QlMy6cCVPmJMqxY n3VTCYV5qdxi9hPd/PfW18a3LB0q5mjVpCY42eVjW4qFuoD7TNnHNE5TxM34A/1wXZoQK2zFmow LwQm9McJw1bT+EIAmjbqsMGeHTv9FZDK2d/6rNYzePuglWcsVYdJet32Vgc9LQ2XH1GLxqClFE6 1kkVVNRiCNheS53ekMVjA0vsMMnUUNF77jM9GFw= X-Received: by 2002:a05:6000:43d4:20b0:425:75bd:7748 with SMTP id ffacd0b85a97d-42575bd77b6mr2050085f8f.58.1759691867570; Sun, 05 Oct 2025 12:17:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IESWqAM17weSRz6tNkuFOcXoHoGAXaaXqYqFFeWKQ+3m4H3+KLBOo1qy5v5MbtlXDYpBvGvFA== X-Received: by 2002:a05:6000:43d4:20b0:425:75bd:7748 with SMTP id ffacd0b85a97d-42575bd77b6mr2050076f8f.58.1759691867058; Sun, 05 Oct 2025 12:17:47 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , Fabiano Rosas , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Laurent Vivier , Paolo Bonzini Subject: [PULL 46/75] tests/libqos: extract qvirtqueue_set_avail_idx() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692483730116600 From: Stefan Hajnoczi Setting the vring's avail.idx can be useful for low-level VIRTIO tests, especially for testing error scenarios with invalid vrings. Extract it into a new function so that the next commit can add a test that uses this new test API. Signed-off-by: Stefan Hajnoczi Acked-by: Fabiano Rosas Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Michael S. Tsirkin Message-ID: <20250922220149.498967-5-stefanha@redhat.com> Signed-off-by: Michael S. Tsirkin --- tests/qtest/libqos/virtio.h | 2 ++ tests/qtest/libqos/virtio.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/qtest/libqos/virtio.h b/tests/qtest/libqos/virtio.h index 7adc7cbd10..e238f1726f 100644 --- a/tests/qtest/libqos/virtio.h +++ b/tests/qtest/libqos/virtio.h @@ -143,6 +143,8 @@ uint32_t qvirtqueue_add(QTestState *qts, QVirtQueue *vq= , uint64_t data, uint32_t len, bool write, bool next); uint32_t qvirtqueue_add_indirect(QTestState *qts, QVirtQueue *vq, QVRingIndirectDesc *indirect); +void qvirtqueue_set_avail_idx(QTestState *qts, QVirtioDevice *d, + QVirtQueue *vq, uint16_t idx); void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head); bool qvirtqueue_get_buf(QTestState *qts, QVirtQueue *vq, uint32_t *desc_id= x, diff --git a/tests/qtest/libqos/virtio.c b/tests/qtest/libqos/virtio.c index 5a709d0bc5..010ff40834 100644 --- a/tests/qtest/libqos/virtio.c +++ b/tests/qtest/libqos/virtio.c @@ -265,8 +265,9 @@ void qvring_init(QTestState *qts, const QGuestAllocator= *alloc, QVirtQueue *vq, =20 /* vq->avail->flags */ qvirtio_writew(vq->vdev, qts, vq->avail, 0); - /* vq->avail->idx */ - qvirtio_writew(vq->vdev, qts, vq->avail + 2, 0); + + qvirtqueue_set_avail_idx(qts, vq->vdev, vq, 0); + /* vq->avail->used_event */ qvirtio_writew(vq->vdev, qts, vq->avail + 4 + (2 * vq->size), 0); =20 @@ -388,6 +389,13 @@ uint32_t qvirtqueue_add_indirect(QTestState *qts, QVir= tQueue *vq, return vq->free_head++; /* Return and increase, in this order */ } =20 +void qvirtqueue_set_avail_idx(QTestState *qts, QVirtioDevice *d, + QVirtQueue *vq, uint16_t idx) +{ + /* vq->avail->idx */ + qvirtio_writew(d, qts, vq->avail + 2, idx); +} + void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d, QVirtQueue *vq, uint32_t free_head) { @@ -400,8 +408,8 @@ void qvirtqueue_kick(QTestState *qts, QVirtioDevice *d,= QVirtQueue *vq, =20 /* vq->avail->ring[idx % vq->size] */ qvirtio_writew(d, qts, vq->avail + 4 + (2 * (idx % vq->size)), free_he= ad); - /* vq->avail->idx */ - qvirtio_writew(d, qts, vq->avail + 2, idx + 1); + + qvirtqueue_set_avail_idx(qts, d, vq, idx + 1); =20 /* Must read after idx is updated */ flags =3D qvirtio_readw(d, qts, vq->used); --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692248; cv=none; d=zohomail.com; s=zohoarc; b=ClJ2YJHmf3+p3pQtzDSPYNJpJjU6uGN69xd9lrUle5oYSyvklqwQ9+aE89AZwzEPkWhZfp9ptFXWaQBjDmVxi++osN2Cjq1yi1ym0gN0pMlpXUhMr0NnlyKufAzte/FpC7BM+nMRua/92utaFEvl8X3XPrG1uYlT+dR6Y5+Eirk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692248; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6Ac5t+5JamsSWpgaQ7u9WqC+NkNvtLKNGeD6nXQRzw8=; b=XCf+pPP82txnzOt14FjhNj1A4UdBSjLEEZ0ITe2NvGdnUtCfIwINqdTmahQnLTh1moV5+jTfS5M4waATXJ2aXKGVesd3dsTpcg91YzS3S8LU80p8ZcPnrtqVRUIPj+pyiNxmLgFSqQh1qN8QBrh8xkFNQJSItNdVLjBqQ0Js0eU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692248399523.1385136172865; Sun, 5 Oct 2025 12:24:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFf-0003ZY-Lj; Sun, 05 Oct 2025 15:18:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFK-0002ER-Ge for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UF7-0006Zx-Nd for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:14 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-349-N8_govmGP9iWREAWctUTMw-1; Sun, 05 Oct 2025 15:17:51 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3ece14b9231so2278353f8f.0 for ; Sun, 05 Oct 2025 12:17:51 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8b0068sm17489436f8f.26.2025.10.05.12.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691873; 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=6Ac5t+5JamsSWpgaQ7u9WqC+NkNvtLKNGeD6nXQRzw8=; b=E2CiT5nmAxrVEBh57CCt0vMk0lLJzy8KhO6BI1e+sdeH8Xy1c90cp0qR3hd0IwA/9b7tEy SNOrxrQk4KNaQXHHO83vZ6y6dK965fgmMTE1oxqEKYibHifLwAjp7GHjI12tM2wf4j58S/ nLOCH5HLtWiB6UuGgwUBufaO6tLZ1Mo= X-MC-Unique: N8_govmGP9iWREAWctUTMw-1 X-Mimecast-MFC-AGG-ID: N8_govmGP9iWREAWctUTMw_1759691871 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691870; x=1760296670; 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=6Ac5t+5JamsSWpgaQ7u9WqC+NkNvtLKNGeD6nXQRzw8=; b=GybXkun7YWV+9atMZg3ci3t1HTrZ2IBjYF8TmUuhBhxFkpaaagqPrcyWc6TxhtfNOt lGOPGMdX/Tud3WYO0Sg1Du06/PKhlCvh1l2cSIBeMGsnD2dptirIf+r8OOPHWuQ5tJ6S bQtGdJydg1IT7WHHShW73LYvMhj0Gbzde2FfInSPCi+tzd6AEvKKlDZhUgTkUXggC0ZJ 4EY+R4gK1CJO194XhJ+4FpbTKb/zfnSbT4FEfVUKmYzrzhv9PLD9JVBeky2KJn/lYik2 htfGotvwsNgV3KVLwhfBJ3mvVNu4z0F3aV669NkbtwRLmvgm2AzYX4mnMVl/LkYeqX32 b9qA== X-Gm-Message-State: AOJu0YwDME7PjgJTplHdgJKruxLIH1VDUPaWdCJiZmzwclO0NUuKput4 XtfC6LYNJNOzIy7ElseFyz2zWGbzzB0WtM7PhsTB3KeT8u/BawN9M4hSFf3UBVzeyxOkEM4O/AK IuMimnM+9anVORPJSxk2yYgjS241ttnSbHdTJkYVcOaoIROwp6Gp4xTIfkoRsjzxnFrlcnDuHTt OxZfiw0rnAcNJ3Yz0LjrQ/curJXi07mHRGXw== X-Gm-Gg: ASbGncs4b+CSIyvZOZlmWI8qin09ZfBF2gIsha9ueheg/f8ct/fPMbd6uNA1IHOS5ZV TZ/QBBuisZX5jtEESzIb5ROdZcsVqaBKjplfbwk+yx5nc05WTcTbb+smp3bbpVOUg7cPSrn4sxQ uQECe0V2az+2/i+BRbvkuaHbyO7Gy9L9NvcikH+c7S3TZhpiyx1OGSqcsCizKehpGtQOFuNC7Af /3Bfsg+3yB6i+5hKtwWdOAz11xFpgZUghpT/YJr7qYFoxujRzwPmkptSzQuNWnKRPMgXI40ERsO 5Y1EEGAVa2Oh/miywhAC7pojv9N76DfCSPhH9qY= X-Received: by 2002:a05:6000:402a:b0:3f3:c137:680e with SMTP id ffacd0b85a97d-4256719354fmr5656793f8f.43.1759691870344; Sun, 05 Oct 2025 12:17:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE1KeyiuZfKkYNFK4IKbC0ym6867jjDbIELzz9isSUNo4h97AFbIkPHNpAYD239sW3kK4owRQ== X-Received: by 2002:a05:6000:402a:b0:3f3:c137:680e with SMTP id ffacd0b85a97d-4256719354fmr5656778f8f.43.1759691869745; Sun, 05 Oct 2025 12:17:49 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , Paolo Bonzini , Fam Zheng , Fabiano Rosas , Laurent Vivier Subject: [PULL 47/75] tests/virtio-scsi: add a virtio_error() IOThread test 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692253289116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Now that virtio_error() calls should work in an IOThread, add a virtio-scsi IOThread test cases that triggers virtio_error(). Signed-off-by: Stefan Hajnoczi Reviewed-by: Michael S. Tsirkin Message-ID: <20250922220149.498967-6-stefanha@redhat.com> Signed-off-by: Michael S. Tsirkin --- tests/qtest/virtio-scsi-test.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/qtest/virtio-scsi-test.c b/tests/qtest/virtio-scsi-test.c index db10d572d0..e2350c52f6 100644 --- a/tests/qtest/virtio-scsi-test.c +++ b/tests/qtest/virtio-scsi-test.c @@ -311,6 +311,31 @@ fail: unlink(tmp_path); } =20 +static void test_iothread_virtio_error(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVirtioSCSIPCI *scsi_pci =3D obj; + QVirtioSCSI *scsi =3D &scsi_pci->scsi; + QVirtioSCSIQueues *vs; + QVirtQueue *vq; + + alloc =3D t_alloc; + vs =3D qvirtio_scsi_init(scsi->vdev); + vq =3D vs->vq[2]; + + /* Move avail.idx out of bounds to trigger virtio_error() */ + qvirtqueue_set_avail_idx(global_qtest, scsi->vdev, vq, vq->size * 2); + scsi->vdev->bus->virtqueue_kick(scsi->vdev, vq); + + /* + * Reset the device out of the error state. If QEMU hangs or crashes t= hen + * this will fail. + */ + qvirtio_reset(scsi->vdev); + + qvirtio_scsi_pci_free(vs); +} + static void *virtio_scsi_hotplug_setup(GString *cmd_line, void *arg) { g_string_append(cmd_line, @@ -383,6 +408,13 @@ static void register_virtio_scsi_test(void) }; qos_add_test("iothread-attach-node", "virtio-scsi-pci", test_iothread_attach_node, &opts); + + opts.before =3D virtio_scsi_setup_iothread; + opts.edge =3D (QOSGraphEdgeOptions) { + .extra_device_opts =3D "iothread=3Dthread0", + }; + qos_add_test("iothread-virtio-error", "virtio-scsi-pci", + test_iothread_virtio_error, &opts); } =20 libqos_init(register_virtio_scsi_test); --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692413; cv=none; d=zohomail.com; s=zohoarc; b=c2odBc8NFhN/r6npYhj3bNpftoR1ZIiJz+x8iT+oQA+Ddqj54VtmD6+2AtA+Y7Tb3O6dGIv1KU5cZN0COaRgKML3kFH1iekm8f5XjSCdZ3lNliQSrE0SXMVdMYS8oOje5/N02kNriKSlI/6k6c6lukQWi6H/uzMc2A7XnUSeXjI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692413; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4PrhgJgfyKAMoMVpOpkddsOkrdYd1EBxIW2i7TwGfmI=; b=JSDzfYcvZNQOAty7K0MmP7ohXaDXbEPzl6pP5NlDkApfZgx9YkUdzc18zEtZazTpAKv+MF/+D/OGtXtjuw9NxOXNBQ3xoy2dhDOATRRP6ZduUDCPzNkAvh8QdhI+RbU7UC30OV7e/UVEz8IX5WnTSojaQFjx7QnviLWefMGqGZI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692413039798.6589832568474; Sun, 5 Oct 2025 12:26:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFc-0003HR-VE; Sun, 05 Oct 2025 15:18:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFN-0002OT-Qq for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFA-0006a7-Ub for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:17 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-436-_FK2ETdZN8qVoIO6mnxGmw-1; Sun, 05 Oct 2025 15:17:54 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e3a049abaso22007825e9.0 for ; Sun, 05 Oct 2025 12:17:53 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e5b5f3015sm130169035e9.1.2025.10.05.12.17.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691875; 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=4PrhgJgfyKAMoMVpOpkddsOkrdYd1EBxIW2i7TwGfmI=; b=ZIiDeCzQwlLIyneOgm1bB4aaTZT+CJHUmwOvC9b1utYoJXkuONDAjF9gS42dMewwNiJ0N9 AWO2uDIDsXIy0QxIqZGvg+ahu4rdQe5UQlo7aBmh08stV7mDb+zV8fuZmGI0AQfnrTybJ8 wtTu5f/diuX0mEsCqCnZ4PZ5pDEpl4M= X-MC-Unique: _FK2ETdZN8qVoIO6mnxGmw-1 X-Mimecast-MFC-AGG-ID: _FK2ETdZN8qVoIO6mnxGmw_1759691873 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691872; x=1760296672; 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=4PrhgJgfyKAMoMVpOpkddsOkrdYd1EBxIW2i7TwGfmI=; b=o8rd1GN7Ue6isFfWRoUzZFKGtS1ARMgFBPhwSv/PF1pRSxGlcKaZR0G2E2xWzCCpnP Qttwy2iKl+s+CkErvhY/KIBKZugLCfxE7xUKc+8WD5sKA4ig4xppCXfEb5DJXMlZnQS7 ah5jhZ7+QpPYW+gumS6GNGp4QJJL7JZhZpIT4vdwKQV7Nc3w36apG2WKfEazj6laaM96 Tfdr5KVwgKcGbLdYlXcFITMTos49XNRrWbB8LI7YtcyJw7Us64iwDTddiYDfwViE70jk a9G01V13TZZIxqW0rNB/pN0yxujaOaSvS9+QOATCO8Sbo0h/iMPJwvK9nGN8DU5O7FDS Rbuw== X-Gm-Message-State: AOJu0YyBKTbUbBFUfQgujNg1PC6kFqaszOLbVn4d0D3bebrOyunwLnxW NB+I6BF2fDhjshbl7+C5Y1mmGvmcD38/zK8RYk0yyML7YTWjrXJlgMHW8WMt0e4d+nm8goECYlF QUdTB7uFX43D0hiQ/+isJLdRRV3BgHGrSeouZ8hCizZI2fOgYLRozPklXHjDy+YwK0erULsd3Bc 8zyrvHH8zV8gExkpp48/1u4aYLXGuAJTuWdw== X-Gm-Gg: ASbGncscunrFYiu+8EP4hb0KdziM+jTU93NJut8havkuZGxk7bF3xwddciek/rmXZ7M W14T+AakWfWkDPr9Et7YuqOSJz5npu9MaN0cJRHUDmh9An2/6K847v+vd07L4sxtyYajNAFBgBK J10ktHDPOYkoTQY9Yucp3KDVCJhHc5etX6Zo49T/UVVb0eSMxmfk8lBrFEgAnHx5eZj+tXe7geo buKzDMwLbEsMADOgRrmvHx678MTbYe2bC3lRzpPASA8R6mDnlLfg//w5J4/8AmKU+dw34V+WRnS oyEKyTxETTN0NBBivxOJYW9ohrBT10wZpl21n3U= X-Received: by 2002:a05:600c:37cd:b0:46e:23d3:6413 with SMTP id 5b1f17b1804b1-46e710b23cfmr67730565e9.0.1759691872260; Sun, 05 Oct 2025 12:17:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqEbPnwAdt5mPeiOyYDSdCtDK1mFh+oYhWuPgIJumCYpLg8tW5pa7kMyZkWTn6L4dyd0sHuw== X-Received: by 2002:a05:600c:37cd:b0:46e:23d3:6413 with SMTP id 5b1f17b1804b1-46e710b23cfmr67730375e9.0.1759691871667; Sun, 05 Oct 2025 12:17:51 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:49 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , Akihiko Odaki , Qing Wang , Marcel Apfelbaum Subject: [PULL 48/75] pcie_sriov: make pcie_sriov_pf_exit() safe on non-SR-IOV devices Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692421617116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi Commit 3f9cfaa92c96 ("virtio-pci: Implement SR-IOV PF") added an unconditional call from virtio_pci_exit() to pcie_sriov_pf_exit(). pcie_sriov_pf_exit() reads from the SR-IOV Capability in Configuration Space: uint8_t *cfg =3D dev->config + dev->exp.sriov_cap; ... unparent_vfs(dev, pci_get_word(cfg + PCI_SRIOV_TOTAL_VF)); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This results in undefined behavior when dev->exp.sriov_cap is 0 because this is not an SR-IOV device. For example, unparent_vfs() segfaults when total_vfs happens to be non-zero. Fix this by returning early from pcie_sriov_pf_exit() when dev->exp.sriov_cap is 0 because this is not an SR-IOV device. Cc: Akihiko Odaki Cc: Michael S. Tsirkin Reported-by: Qing Wang Buglink: https://issues.redhat.com/browse/RHEL-116443 Signed-off-by: Stefan Hajnoczi Reviewed-by: Akihiko Odaki Fixes: cab1398a60eb ("pcie_sriov: Reuse SR-IOV VF device instances") Reviewed-by: Michael S. Tsirkin Message-ID: <20250924155153.579495-1-stefanha@redhat.com> Signed-off-by: Michael S. Tsirkin --- hw/pci/pcie_sriov.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index 29474d749a..c4f88f0975 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -195,7 +195,9 @@ bool pcie_sriov_pf_init(PCIDevice *dev, uint16_t offset, =20 void pcie_sriov_pf_exit(PCIDevice *dev) { - uint8_t *cfg =3D dev->config + dev->exp.sriov_cap; + if (dev->exp.sriov_cap =3D=3D 0) { + return; + } =20 if (dev->exp.sriov_pf.vf_user_created) { uint16_t ven_id =3D pci_get_word(dev->config + PCI_VENDOR_ID); @@ -211,6 +213,8 @@ void pcie_sriov_pf_exit(PCIDevice *dev) pci_config_set_device_id(dev->exp.sriov_pf.vf[i]->config, vf_d= ev_id); } } else { + uint8_t *cfg =3D dev->config + dev->exp.sriov_cap; + unparent_vfs(dev, pci_get_word(cfg + PCI_SRIOV_TOTAL_VF)); } } --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692374; cv=none; d=zohomail.com; s=zohoarc; b=e2dgcj1dvJLVqfQStLnHmLyI3H920GSaRMfzZRGr6F7YG0OSRBdVv1Dek7oI0gjbIKZOrEhB1GaneKP0KVmIAE8ctJ5FPo9EjoyDP4pcqY0UCmKziNyGt8dvq0wLVFsZTeRP6E3iVyS446CJQ1Wu4/Y8ljaLgO+0s8D4F22oSo8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692374; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=V41Pc7wPc/h125DbvUzzUxYHsFmka0IFpApuuOm1N4U=; b=jpx5oUHK49zGmmBMiq77M91egltLTDL7vn0niFD4+4WbM2c/VP9C0o2EBMmChq8QOXJNCiU72JUqkAkXiptjklpXR9QgHIFAQbGYDP4xcakvlRz5b7ZzI7F36XhOJMlpWcCZr5HvErtQola4zzPJzzWcB5r3CpGzxMCWPfZWKqM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175969237490049.29031209084849; Sun, 5 Oct 2025 12:26:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFh-0003q7-VC; Sun, 05 Oct 2025 15:18:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFK-0002ET-LE for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFA-0006aG-U9 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:14 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-496-ugGbudLiMTavVOHn-MuuXw-1; Sun, 05 Oct 2025 15:17:55 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3e997eb7232so1744325f8f.3 for ; Sun, 05 Oct 2025 12:17:55 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e72374b8dsm137218675e9.19.2025.10.05.12.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691876; 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=V41Pc7wPc/h125DbvUzzUxYHsFmka0IFpApuuOm1N4U=; b=V84VjRMCWozokdnWuuw6jdhR10KhsZUyVw/uVyxxNQ1vLxPGiB8dxNW7rKu8rHmjPaRWd1 /mjQmtrYQUcG6+d53eDOIAVvuC2O3QxaG7U9C/5+at7XP8x5H44/dVddQkyh3X0tzUnanK 3Ic5qzOvhMj4tIQCnDNC7Vpx1SUYFgg= X-MC-Unique: ugGbudLiMTavVOHn-MuuXw-1 X-Mimecast-MFC-AGG-ID: ugGbudLiMTavVOHn-MuuXw_1759691874 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691874; x=1760296674; 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=V41Pc7wPc/h125DbvUzzUxYHsFmka0IFpApuuOm1N4U=; b=dpvW9XMRHML7Ykxbd2RkSUlDMAfw1KCWWysMy0Aaqg+5jBctm2ypqo0LnH/hvroDu1 QODBq5lbbcvKjcgz/WlYk5J7kHePkhUpM8czfl4wSS0LTOfyevFvbrpjMbdpU/3lXXwl BnerLJw7Hxdy0CjBM3jwswpPRmCkpObStuyM06TBRzhRNhrmbnjcOtxJ0bVFagZiGWx/ f/0zOTetZY2vSP35P73kwDWuFObIb1fz8Z4J9szZmvSHFRR0S2NnBI7yCta3YTnngTz+ Q+iqqost0gfP2UvnTQKlUsy9Z9crLMZyjm7+XVUShk3dzaW1LrzL+Uv4QP4/xplxuV1Z DD8g== X-Gm-Message-State: AOJu0YwzXOvHvwzoVle91XNfE2OXZBV2EFjSGEFLG6Y5/OO74WmQpiO2 /0yRNBlLrrdEYLCFBsmifOhsFy2KDHenHey3mvxKzixmAmyHqAt8nnDPuIqmIyriHB7DEWPG1kF SMc99I1jE05zqhIQ8nlub9jgnETO5WHig6sv2KOcZaQ/RQRoQrIjhdfN2/GDPTqoOnxlxnwdBl8 /+J7BZopdOE5bkIJEz3BqWh+dIYZGaBC4Tng== X-Gm-Gg: ASbGncs/L6Z/mZIbk+WAbWx4/YLyDIBRqEOAzIiDKfKHd9vjyqD533KYyGuJmhezNDP tVMdCbs6a9iYiYZEH0VHrTHXA2MW7i4VJyxbkUTTY3GV+H6xdwp/a8ij+UjWk3z6w1EPvOAyD4J dgV0VPeYlC3BTiBMiaRQOARkDIZlR6rYH/x/hRFWLjorWc7fMbwBooic8FYZp+nYWOMz6PqjwI0 TtHgpH/HQc39n1bJOA5w1vDble4A1o3OKvtG4cv701dSqliLkC98w12KV7A3SOjqUGGCZ9cS5Sm ULlqWpV6UrZQtLKPEb7BYVhcbr+xmrnORDsL3AY= X-Received: by 2002:a05:600c:1d1c:b0:45b:8a0e:cda9 with SMTP id 5b1f17b1804b1-46e71111c47mr59682655e9.2.1759691874025; Sun, 05 Oct 2025 12:17:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGzex29tHDkjGvIUtPCv211VFdOMqX8odJvw1GLdsqOdrJsVU0+KBCad2lbwWPJN2LkXXkPA== X-Received: by 2002:a05:600c:1d1c:b0:45b:8a0e:cda9 with SMTP id 5b1f17b1804b1-46e71111c47mr59682515e9.2.1759691873501; Sun, 05 Oct 2025 12:17:53 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:51 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alessandro Ratti , Alex =?utf-8?Q?Benn=C3=A9e?= , David Hildenbrand Subject: [PULL 49/75] virtio: Add function name to error messages Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692382135116600 From: Alessandro Ratti Replace virtio_error() with a macro that automatically prepends the calling function name to error messages. This provides better context for debugging virtio issues by showing exactly which function encountered the error. Before: "Invalid queue size: 1024" After: "virtio_queue_set_num: Invalid queue size: 1024" The implementation uses a macro to insert __func__ at compile time, avoiding any runtime overhead while providing more specific error context than a generic "virtio:" prefix. Also remove manual __func__ usage in virtio-balloon to avoid duplicate function names in error messages. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/230 Buglink: https://bugs.launchpad.net/qemu/+bug/1919021 Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Alessandro Ratti Reviewed-by: Michael S. Tsirkin Message-ID: <20250915162643.44716-2-alessandro@0x65c.net> Signed-off-by: Michael S. Tsirkin Reviewed-by: https://lore.kernel.org/qemu-devel/aNO7J7Y6wsk1-wyw@redhat.com/ --- include/hw/virtio/virtio.h | 4 +++- hw/virtio/virtio-balloon.c | 2 +- hw/virtio/virtio.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index d97529c3f1..695bb56186 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -253,7 +253,9 @@ void virtio_init(VirtIODevice *vdev, uint16_t device_id= , size_t config_size); =20 void virtio_cleanup(VirtIODevice *vdev); =20 -void virtio_error(VirtIODevice *vdev, const char *fmt, ...) G_GNUC_PRINTF(= 2, 3); +#define virtio_error(vdev, fmt, ...) \ + virtio_error_impl(vdev, "%s: " fmt, __func__, ##__VA_ARGS__) +void virtio_error_impl(VirtIODevice *, const char *fmt, ...) G_GNUC_PRINTF= (2, 3); =20 /* Set the child bus name. */ void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name); diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index db787d00b3..e443f71c01 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -697,7 +697,7 @@ virtio_balloon_free_page_hint_notify(NotifierWithReturn= *n, void *data, case PRECOPY_NOTIFY_COMPLETE: break; default: - virtio_error(vdev, "%s: %d reason unknown", __func__, pnd->reason); + virtio_error(vdev, "%d reason unknown", pnd->reason); } =20 return 0; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index de89e8104a..0f33ca5d90 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3968,7 +3968,8 @@ void virtio_device_set_child_bus_name(VirtIODevice *v= dev, char *bus_name) vdev->bus_name =3D g_strdup(bus_name); } =20 -void G_GNUC_PRINTF(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt,= ...) +void G_GNUC_PRINTF(2, 3) +virtio_error_impl(VirtIODevice *vdev, const char *fmt, ...) { va_list ap; =20 --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692117; cv=none; d=zohomail.com; s=zohoarc; b=mfYiongwTxIVqasgpGJtmllGFygxsdrIROJAFxfMXMhvqYMvJR4LVJhFeXsHOwErNw1NfI8qKnf3uBT+/g+hDGeSJgwX/BjOm11JkFUR0BdWPdRB3fsw6fN4Z7MScMI6W79BKTXQoya9/NRzzont3j5ZfAnindyNbM1AiduulNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692117; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BsiJ9Y13upyZ0kSNDp9aMBJN8UvV+sDrJuDdQ0y5Q0M=; b=ELE/KeOa5kPu48cgbP/RLHT5wg0gbikAgSUXXkqDUrxPu/krEb4J8k4n0n/fyYWE8cpKO00wV1i8ITCjKxXDVhZ8t9dHOEES7WYPP3nHXxS6mKD5chT92rMRuRgCFl4UdPsUqhS8ojwwoFlKdE+GsWcpD6u4dAk/rePSZTkKI3Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692117741952.380591235655; Sun, 5 Oct 2025 12:21:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFj-00043W-Dv; Sun, 05 Oct 2025 15:18: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 1v5UFN-0002OX-Se for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18: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 1v5UFB-0006aM-LN for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:17 -0400 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-102-A4K6x0YhPbCdOKgSdd7-4A-1; Sun, 05 Oct 2025 15:17:57 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-41066f050a4so1555366f8f.1 for ; Sun, 05 Oct 2025 12:17:57 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f0853sm17787138f8f.50.2025.10.05.12.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691879; 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=BsiJ9Y13upyZ0kSNDp9aMBJN8UvV+sDrJuDdQ0y5Q0M=; b=UkayjyA7GT/+6KHLIrqMx8NHqTIEEk3Cmku93wT3/MqwvEqQMFNf9LEFZ6nOUJY/LLSL9B mw5qLQmFaQHJd5bpNdvtQnpaKiiPC4mLL9bBN0ueGuDAXFLiMnQRgUF10nGXkkGZQcXrWy 5EiDJqbmYoI8xjqWGD6cSVkOBBy8PEo= X-MC-Unique: A4K6x0YhPbCdOKgSdd7-4A-1 X-Mimecast-MFC-AGG-ID: A4K6x0YhPbCdOKgSdd7-4A_1759691876 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691876; x=1760296676; 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=BsiJ9Y13upyZ0kSNDp9aMBJN8UvV+sDrJuDdQ0y5Q0M=; b=romOGwCG8HPObLoO/R2vwFxAMtvAG7NuqyB+wfc5GY96vrR2R6a6g2gUQ6CjYMG+0f y5sGF/xWdka/+T4ZnbxSDvUpMm4yETBBRQMWyLLDSyNcvgsyldn09X2vP+aFMfn1pJPz CsCt/6o2CyZyW3zWQ4ooJRaWGvFftNqlpJJ26m9kcUyOabbfqsYbVswOioZp+O3oZMHa oz3XIQfsjVlIhyR6AoV9j2Gxaf2vSMuhFiBZ9rZg1LObYlHezUhj1YH9teJeNmw5oRvo 59NiBSiSLFK24dKNhbpfMfml9GLiPyuwzfnXj8rFEQUTtv2suKMh8V7xY+S48lf37af8 f/YA== X-Gm-Message-State: AOJu0YxTtu5+0f0dS9kpnxIJaIcXlu9DFDJGmCc1/TIYWMqHHtkfeB79 8wiqYI2I9SHoqzkyhs1Q728yFjhUx17HO57bHgj0AzXMU7/kTZC+xyFyOp2/flcVFN1Lq7+kWIQ OMiz+1++RGGIBxbZFD45p+wnUaEiJMXvsBgFp8RI6CdIdziPwOTv9YPksK+tLpfz+HQRfQOucBN gdCAeNHemDtYLsFxvwig83Qg0kRRLhN8JWDQ== X-Gm-Gg: ASbGncvaOe6uYyFnuaNRjxAtXQT2rC0oNv7z9TPDBJ7g9lgCOU4AazeDQhpeM8j6tUP l6lA2Xjch/BDYE3JzPtMpYBejJ3pvUKzDNLDaMIzBFRwaz5B6BFpcpDmkJhTb2mzUf+4hKCTV7L pMjet6BJBIvSywEOzNkVdlkqqEQzFCekP7rxcx8I9u/BIUgcphjkasudCMSDkXyhA75bBgEwRZB 2i6XaGCzIe60mn68mJrY3E79b5XvC8SVba5QqnssJI9IBAcEU78OBMgRRCPwHrJFVEjjaIbgCx6 +z+dtZNY63y+GmbGaFA00GTWoT86oHp7KCsEfU4= X-Received: by 2002:a5d:64e8:0:b0:3e2:da00:44af with SMTP id ffacd0b85a97d-42567176bd3mr6732613f8f.36.1759691876213; Sun, 05 Oct 2025 12:17:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJ5rjni9bo30IHHcLhTA82S275kGX4b/FUvcD9MP6/vucT6O956k7TyKlugPcWM1NKXuR/6A== X-Received: by 2002:a5d:64e8:0:b0:3e2:da00:44af with SMTP id ffacd0b85a97d-42567176bd3mr6732596f8f.36.1759691875588; Sun, 05 Oct 2025 12:17:55 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:53 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , David Hildenbrand , Peter Xu , Paolo Bonzini , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Subject: [PULL 50/75] memory: Adjust event ranges to fit within notifier boundaries Message-ID: <2e4d32f0af7eaf87f556fb1fe802874c1b0a0799.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692126312116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez Invalidating the entire address space (i.e. range of [0, ~0ULL]) is a valid and required operation by vIOMMU implementations. However, such invalidations currently trigger an assertion unless they originate from device IOTLB invalidations. Although in recent Linux guests this case is not exercised by the VTD implementation due to various optimizations, the assertion will be hit by upcoming AMD vIOMMU changes to support DMA address translation. More specifically, when running a Linux guest with VFIO passthrough device, and a kernel that does not contain commmit 3f2571fed2fa ("iommu/amd: Remove redundant domain flush from attach_device()"). Remove the assertion altogether and adjust the range to ensure it does not cross notifier boundaries. Signed-off-by: Alejandro Jimenez Acked-by: Michael S. Tsirkin Acked-by: David Hildenbrand Acked-by: Peter Xu Message-Id: <20201116165506.31315-6-eperezma@redhat.com> Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-2-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- system/memory.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/system/memory.c b/system/memory.c index cf8cad6961..5c6ccc5c57 100644 --- a/system/memory.c +++ b/system/memory.c @@ -2044,13 +2044,9 @@ void memory_region_notify_iommu_one(IOMMUNotifier *n= otifier, return; } =20 - if (notifier->notifier_flags & IOMMU_NOTIFIER_DEVIOTLB_UNMAP) { - /* Crop (iova, addr_mask) to range */ - tmp.iova =3D MAX(tmp.iova, notifier->start); - tmp.addr_mask =3D MIN(entry_end, notifier->end) - tmp.iova; - } else { - assert(entry->iova >=3D notifier->start && entry_end <=3D notifier= ->end); - } + /* Crop (iova, addr_mask) to range */ + tmp.iova =3D MAX(tmp.iova, notifier->start); + tmp.addr_mask =3D MIN(entry_end, notifier->end) - tmp.iova; =20 if (event->type & notifier->notifier_flags) { notifier->notify(notifier, &tmp); --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692321; cv=none; d=zohomail.com; s=zohoarc; b=Ms89tQcc4JNOIKQ2npcxF+XO8oEm/y324yjocPotb3Yc1TVipRwApYqZaw2tsqAPDqfbkNhloE5jpH4EYa9TRubKICVg0tFsQqu6AW2Dr9zFsdwoYCTjSpJ4cLv4XATqsGWL3KNOxW95ejafalD1IDVy8j0vrSBt8N+bQId7Zcg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692321; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oGAY834jKYfbFDJ68UHHIZdDsuzgPXz3Cw6hb0ar51o=; b=dQxNMI7IV/M24hRcxm2Uo9jNUKoCnS+ve8hrcGi2eKuptRMzzKiXVQvyS0EzxpwBBDyzu2jh5DLclyHJycXBYjPAf2pZzaQs58Wrdv6Wh1YNmJSjR5eQDnDVAqUUl7KWvtedPlMN1HrXegHanwlD4icvNCTNjETaltw+6hdXuRI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692321600179.2686294603061; Sun, 5 Oct 2025 12:25:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFe-0003To-9f; Sun, 05 Oct 2025 15:18: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 1v5UFO-0002RS-Su for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:20 -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 1v5UFL-0006b7-7F for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:18 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-y2r6h5l6MPSfVotsXLKhMw-1; Sun, 05 Oct 2025 15:18:09 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e375dab7dso18415455e9.3 for ; Sun, 05 Oct 2025 12:18:04 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e723593d8sm135637725e9.11.2025.10.05.12.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691893; 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=oGAY834jKYfbFDJ68UHHIZdDsuzgPXz3Cw6hb0ar51o=; b=JcfZcsqHX3AeGEaYwyDWrM0RhxqorXn6KhXDBodfW4+Jsn2C4WNYWdxyHSvMMe907Lv4ZN 09oH+YlVAI+wFBZ0XOSJCimrIuzaWHS/PboxYPTCUi657XCnF63T3haHw9IKVl3+D1qQYq Uz5DZSG32u5/fElybhPDVINVmiQHQZ0= X-MC-Unique: y2r6h5l6MPSfVotsXLKhMw-1 X-Mimecast-MFC-AGG-ID: y2r6h5l6MPSfVotsXLKhMw_1759691878 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691878; x=1760296678; 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=oGAY834jKYfbFDJ68UHHIZdDsuzgPXz3Cw6hb0ar51o=; b=q2faXsG70DbKNHQz6AfvLRTgSA1b21uXxkr+dI1uywqNjfiqfKosIKzsNQXrWCM583 y2NB4EOTjky9NsMGO8FcBzzzpYyiqxPcoI5Rlz6J3VguTh9wjDLAcA16ZylxocV8iosr Rh60/YTWnliItQ9Rn1MFdpC+n5J6BXniDy2H2s/Iuxko4T5eya896tF8+nOAAvMWaKXr jQMyNf6noJit+oYVDyCPYG7+FZmOSJcjDB4v/73fT/qCAhNl2C9Xoq4QRwSQVlRkf1w7 XfuEowRy2CBnlVd3FH0tGPxtDZP/mOoVVHEiqxRP5luv16QbgeTfyVTcMWVCAB/iev8p ybQg== X-Gm-Message-State: AOJu0YzZNVJc22qaCb4M5s4euqhkgQtrAqxEYFv/HsGHih8qCqWP612t 5tSlgIPL/BeYmxmV+jEr2jgc9pw6gHV27U4A5++ssO7g/7aoFn+5H6504elxwcoHvb7qkAsmpwb xcKxAyhPSrY0r3k3ozjt48DTiZxjfEWbqwARBCFRBTGK75MncjGQmpG17TTaH6C56I4/w5QDTQz n0nblBS7QSuKsECsecJV4KI2ameVBlYV4jyQ== X-Gm-Gg: ASbGncuElzCFglWf82mTvmbOHEEAFnAOmSAV4Yv5OhCotnatMk8zzoCf/VjURXF6FSN va8NUe0kg/3CqE8dwvdwlLvmEKWZOgWANR+TEa/flSZzZKRtQmVNN3SwLbQJgEplMXwJBLwZll8 5fubNkbfbXoPGKcTLinj+6cMCrKDV6f/pPx6foQgpH0haF2jxeJ2KnBQHr1wZowK5zBVQYtRGpu m7MxCK8gb2AP8q9t500zT5z9vKf/qjcaoghgoNAizqj/RVemVsYlyuDmqn3pzUwC1dR+rUQ0z5H TgMr231CAD3LMVFAQfdg2q7z2UcwaoHPzkwe6L0= X-Received: by 2002:a05:600c:a319:b0:46e:74cc:42b8 with SMTP id 5b1f17b1804b1-46e74cc4609mr51030425e9.17.1759691878156; Sun, 05 Oct 2025 12:17:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2Rx4DnBOal6t//z0yM/sD+4kOgczG33Pu07EYw0/ix+ith9EWVS0PcJ7lVfH5jiZme8Yf8g== X-Received: by 2002:a05:600c:a319:b0:46e:74cc:42b8 with SMTP id 5b1f17b1804b1-46e74cc4609mr51030315e9.17.1759691877627; Sun, 05 Oct 2025 12:17:57 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:55 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Peter Xu , Jason Wang Subject: [PULL 51/75] amd_iommu: Document '-device amd-iommu' common options Message-ID: <0888c071ff8370f118ce22c0fe873b13e11d319a.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692336277116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez Document the common parameters used when emulating AMD vIOMMU. Besides the two amd-iommu specific options: 'xtsup' and 'dma-remap', the the generic x86 IOMMU option 'intremap' is also included, since it is typically specified in QEMU command line examples and mailing list threads. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-3-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- qemu-options.hx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index 3ff10ec09d..9b4e870350 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1238,6 +1238,29 @@ SRST Accepts either the default root complex (pcie.0) or a pxb-pcie based root complex. =20 +``-device amd-iommu[,option=3D...]`` + Enables emulation of an AMD-Vi I/O Memory Management Unit (IOMMU). + Only available with ``-machine q35``, it supports the following option= s: + + ``dma-remap=3Don|off`` (default: off) + Support for DMA address translation and access permission checking= for + guests attaching passthrough devices to paging domains, using the = AMD v1 + I/O Page Table format. This enables ``-device vfio-pci,...`` to wo= rk + correctly with a guest using the DMA remapping feature of the vIOM= MU. + + ``intremap=3Don|off`` (default: auto) + Generic x86 IOMMU functionality implemented by ``amd-iommu`` devic= e. + Enables interrupt remapping feature in guests, which is also requi= red to + enable x2apic support. + Currently only available with ``kernel-irqchip=3Doff|split``, it is + automatically enabled when either of those modes is in use, and di= sabled + with ``kernel-irqchip=3Don``. + + ``xtsup=3Don|off`` (default: off) + Interrupt remapping table supports x2apic mode, enabling the use of + 128-bit IRTE format with 32-bit destination field by the guest. Re= quired + to support routing interrupts to vCPUs with APIC IDs larger than 0= xff. + ERST =20 DEF("name", HAS_ARG, QEMU_OPTION_name, --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692405; cv=none; d=zohomail.com; s=zohoarc; b=U9Or+E+XS/ESHcUojHrlq6tKv49ImgOn6qQdYubqBdw/zREEaZRm8RAyMIv9br6VV13oOdQOy+TBFCTYJiZHkc9FarFqXLuExQbLNRl0ruweZc9T0qazQCxES8QN8orIUkqk4JAk1AqmPQydqYt7L4gxsXwZMB+pvVl5cYQsY2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692405; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=g7mFYden9qH7zkZwD2EMTpua+ooliRaONw9JQmjB2ko=; b=bvq8YF+fw3vD5dOIFe7R1ROa0Or6u/FMINuAP/TmQPi361699bDUxu0TVwf/MEW7EE/dOA1iGVK49EyDQp6yHRfOyIl9RB0Eza/B7CfL/F2Bw5kjFojDEGBBaFD1YUNQEmMZVeWhdvawsKfLtn7usttQ1SjHLp3j+gbMgsxDpCs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692405765966.7210003885544; Sun, 5 Oct 2025 12:26:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFi-0003yP-7S; Sun, 05 Oct 2025 15:18: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 1v5UFN-0002OS-QF for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:18 -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 1v5UFB-0006aS-0g for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:17 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-25-F_CEArV2PDC9HEqfPBzRJw-1; Sun, 05 Oct 2025 15:18:01 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3f030846a41so2461912f8f.2 for ; Sun, 05 Oct 2025 12:18:01 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8e970esm17360456f8f.35.2025.10.05.12.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691882; 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=g7mFYden9qH7zkZwD2EMTpua+ooliRaONw9JQmjB2ko=; b=AxQ8VOi+BzVCWVH3UMEczsiypLxcCaaysjV9hSO7HeuPrj2DbkLxOEQ85RfRDJUEDf5sHW nxO8Djli4BCSvR+/rgP/NcGgKD9hZLY3WxwuoCBhI/WN51TWHLozMzQhY3npFqG0Xt0r/i VtL9g54Cg+pfZ5DmUaMtqx3ihUntq0E= X-MC-Unique: F_CEArV2PDC9HEqfPBzRJw-1 X-Mimecast-MFC-AGG-ID: F_CEArV2PDC9HEqfPBzRJw_1759691881 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691880; x=1760296680; 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=g7mFYden9qH7zkZwD2EMTpua+ooliRaONw9JQmjB2ko=; b=wdR8y5cKQIzhEaNWRerWMaVXx5QsoQcEyRs7ii6vItzrrg3DysBCEdaZybvkg3yh4g R/C42rznUhy5vzKEKT1yiLMFmFVxgA+SQIQdMaEjuzb8F5310AUcOOB0JvQVpC4zQYLg 3awUwsD3qYe7VLcyWRm7yHvYwn5Ft9XoRc3kvc6dWmEYQlWBEoSucg75yjCsSPoJKT8s ATbq1N6z3MktM0ef71SG8h/bjvaHPgtRWKX9STgQW/Dd5BqA8OODRi15L2ya4RTDZ+Q+ GvwonSZE3W+oQXmwXfyKgxhH/jYaipTpNutkCXUdXPkCAxgDsJrirok2iwdGh7XC4cv4 bEaQ== X-Gm-Message-State: AOJu0Yw9fnkZ0o0psfN6iFqnandUnf5L9WvPIc4OUixu5QO2/u2vP5Hf GNQRvIFoPB+U50AMC79V3iVNcTf7je/EzGJuU/9/3zmrpy8LEyzQXygtvaGwZEH4xnFDPoSlgzk 5I9bamP9cRRuGZ/eMzI9b7JaPAHIzPnfRwvlnNg+mlTOyYwTBSatmkpVZgfQdiagF9UMzpK6vWe HGwcG+CBsv/7h7t6vUhwPac8KHX9GOXT/4NQ== X-Gm-Gg: ASbGncveilJzKqU4J8pKT+cc0KMbGxMnN1MgWI4s6SF/8K9+1NsoLP3V1Y0z4XKmCzH 2uVK5vnN7KLz92Bqzie4ZJE42bsoERvj95o05gLZhLs1fkYIRm5lP1JRCZYLLm9cDuReeUDsz7k W0y8/lB/xjlYXwvghhE4AOGOyVb54QhDOUeM6PiL0Y1YySr6hOaqFjE9IcbJGrN9ko56bFvWqpW um3/NoOHkX3+ykrBdq+wKq4H/Xr+xDEXKBEdaABCEfdiGFAt+e/4eh5S3vD07TV7sqi/C2HeNkH pMBsHOK9vsfA3fYjc75PhkFrDSe0RoK24mpZ/Ns= X-Received: by 2002:a05:6000:659:20b0:425:76a7:c910 with SMTP id ffacd0b85a97d-42576a7c9afmr1618742f8f.49.1759691880205; Sun, 05 Oct 2025 12:18:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGGMCet7TBxc+rHzmr1Clg90kIGH16rZZPlQDq/DINB1SyfCLEFRKIVL2Duo3Ki136rAHavQ== X-Received: by 2002:a05:6000:659:20b0:425:76a7:c910 with SMTP id ffacd0b85a97d-42576a7c9afmr1618722f8f.49.1759691879679; Sun, 05 Oct 2025 12:17:59 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:57 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 52/75] amd_iommu: Reorder device and page table helpers Message-ID: <03e4960124b64e6798b5727a08358b8bed12f4a4.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692407625116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez Move code related to Device Table and Page Table to an earlier location in the file, where it does not require forward declarations to be used by the various invalidation functions that will need to query the DTE and walk the page table in upcoming changes. This change consist of code movement only, no functional change intended. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-4-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 172 ++++++++++++++++++++++---------------------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 26be69bec8..3cbc9499db 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -438,6 +438,92 @@ static void amdvi_completion_wait(AMDVIState *s, uint6= 4_t *cmd) trace_amdvi_completion_wait(addr, data); } =20 +static inline uint64_t amdvi_get_perms(uint64_t entry) +{ + return (entry & (AMDVI_DEV_PERM_READ | AMDVI_DEV_PERM_WRITE)) >> + AMDVI_DEV_PERM_SHIFT; +} + +/* validate that reserved bits are honoured */ +static bool amdvi_validate_dte(AMDVIState *s, uint16_t devid, + uint64_t *dte) +{ + if ((dte[0] & AMDVI_DTE_QUAD0_RESERVED) || + (dte[1] & AMDVI_DTE_QUAD1_RESERVED) || + (dte[2] & AMDVI_DTE_QUAD2_RESERVED) || + (dte[3] & AMDVI_DTE_QUAD3_RESERVED)) { + amdvi_log_illegaldevtab_error(s, devid, + s->devtab + + devid * AMDVI_DEVTAB_ENTRY_SIZE, 0); + return false; + } + + return true; +} + +/* get a device table entry given the devid */ +static bool amdvi_get_dte(AMDVIState *s, int devid, uint64_t *entry) +{ + uint32_t offset =3D devid * AMDVI_DEVTAB_ENTRY_SIZE; + + if (dma_memory_read(&address_space_memory, s->devtab + offset, entry, + AMDVI_DEVTAB_ENTRY_SIZE, MEMTXATTRS_UNSPECIFIED)) { + trace_amdvi_dte_get_fail(s->devtab, offset); + /* log error accessing dte */ + amdvi_log_devtab_error(s, devid, s->devtab + offset, 0); + return false; + } + + *entry =3D le64_to_cpu(*entry); + if (!amdvi_validate_dte(s, devid, entry)) { + trace_amdvi_invalid_dte(entry[0]); + return false; + } + + return true; +} + +/* get pte translation mode */ +static inline uint8_t get_pte_translation_mode(uint64_t pte) +{ + return (pte >> AMDVI_DEV_MODE_RSHIFT) & AMDVI_DEV_MODE_MASK; +} + +static inline uint64_t pte_override_page_mask(uint64_t pte) +{ + uint8_t page_mask =3D 13; + uint64_t addr =3D (pte & AMDVI_DEV_PT_ROOT_MASK) >> 12; + /* find the first zero bit */ + while (addr & 1) { + page_mask++; + addr =3D addr >> 1; + } + + return ~((1ULL << page_mask) - 1); +} + +static inline uint64_t pte_get_page_mask(uint64_t oldlevel) +{ + return ~((1UL << ((oldlevel * 9) + 3)) - 1); +} + +static inline uint64_t amdvi_get_pte_entry(AMDVIState *s, uint64_t pte_add= r, + uint16_t devid) +{ + uint64_t pte; + + if (dma_memory_read(&address_space_memory, pte_addr, + &pte, sizeof(pte), MEMTXATTRS_UNSPECIFIED)) { + trace_amdvi_get_pte_hwerror(pte_addr); + amdvi_log_pagetab_error(s, devid, pte_addr, 0); + pte =3D 0; + return pte; + } + + pte =3D le64_to_cpu(pte); + return pte; +} + /* log error without aborting since linux seems to be using reserved bits = */ static void amdvi_inval_devtab_entry(AMDVIState *s, uint64_t *cmd) { @@ -894,92 +980,6 @@ static void amdvi_mmio_write(void *opaque, hwaddr addr= , uint64_t val, } } =20 -static inline uint64_t amdvi_get_perms(uint64_t entry) -{ - return (entry & (AMDVI_DEV_PERM_READ | AMDVI_DEV_PERM_WRITE)) >> - AMDVI_DEV_PERM_SHIFT; -} - -/* validate that reserved bits are honoured */ -static bool amdvi_validate_dte(AMDVIState *s, uint16_t devid, - uint64_t *dte) -{ - if ((dte[0] & AMDVI_DTE_QUAD0_RESERVED) || - (dte[1] & AMDVI_DTE_QUAD1_RESERVED) || - (dte[2] & AMDVI_DTE_QUAD2_RESERVED) || - (dte[3] & AMDVI_DTE_QUAD3_RESERVED)) { - amdvi_log_illegaldevtab_error(s, devid, - s->devtab + - devid * AMDVI_DEVTAB_ENTRY_SIZE, 0); - return false; - } - - return true; -} - -/* get a device table entry given the devid */ -static bool amdvi_get_dte(AMDVIState *s, int devid, uint64_t *entry) -{ - uint32_t offset =3D devid * AMDVI_DEVTAB_ENTRY_SIZE; - - if (dma_memory_read(&address_space_memory, s->devtab + offset, entry, - AMDVI_DEVTAB_ENTRY_SIZE, MEMTXATTRS_UNSPECIFIED)) { - trace_amdvi_dte_get_fail(s->devtab, offset); - /* log error accessing dte */ - amdvi_log_devtab_error(s, devid, s->devtab + offset, 0); - return false; - } - - *entry =3D le64_to_cpu(*entry); - if (!amdvi_validate_dte(s, devid, entry)) { - trace_amdvi_invalid_dte(entry[0]); - return false; - } - - return true; -} - -/* get pte translation mode */ -static inline uint8_t get_pte_translation_mode(uint64_t pte) -{ - return (pte >> AMDVI_DEV_MODE_RSHIFT) & AMDVI_DEV_MODE_MASK; -} - -static inline uint64_t pte_override_page_mask(uint64_t pte) -{ - uint8_t page_mask =3D 13; - uint64_t addr =3D (pte & AMDVI_DEV_PT_ROOT_MASK) >> 12; - /* find the first zero bit */ - while (addr & 1) { - page_mask++; - addr =3D addr >> 1; - } - - return ~((1ULL << page_mask) - 1); -} - -static inline uint64_t pte_get_page_mask(uint64_t oldlevel) -{ - return ~((1UL << ((oldlevel * 9) + 3)) - 1); -} - -static inline uint64_t amdvi_get_pte_entry(AMDVIState *s, uint64_t pte_add= r, - uint16_t devid) -{ - uint64_t pte; - - if (dma_memory_read(&address_space_memory, pte_addr, - &pte, sizeof(pte), MEMTXATTRS_UNSPECIFIED)) { - trace_amdvi_get_pte_hwerror(pte_addr); - amdvi_log_pagetab_error(s, devid, pte_addr, 0); - pte =3D 0; - return pte; - } - - pte =3D le64_to_cpu(pte); - return pte; -} - static void amdvi_page_walk(AMDVIAddressSpace *as, uint64_t *dte, IOMMUTLBEntry *ret, unsigned perms, hwaddr addr) --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692408; cv=none; d=zohomail.com; s=zohoarc; b=Z1dVCo3sasPelalFpTB3jK7v814yN5REUT5afYagUvc3o4FvzyyJ2f1DRBpG+Azc70iJzY/Ucd/pZ0MjP1yOZhAGJqQ4hGj5E4SgAe4rfW54zCtpwDe30gFKQVkW7/HSgitk1s76rXIrE80hdy1i2O5BhTrPtabAV4iFEHGaWNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692408; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xISYYcoFQClxd+HhqK447x/hInZXjtzJhdgWUsDmah0=; b=UuILg5rLiYe+6P5CexXLrvCPePY9kRiPhb87xn1FFYCBowAwbmGxRJK1MdvIKp6/onkc2NGIdEoA50RKJxV3f4gyw/Nq+A+O0o9ivKpFBHU1VvEf39eayXPChb7JMcREzudqrNQqH7uw3uOeuOZ1k0E28aryE8Ea4ve64hMSBPU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692408605782.4154866454008; Sun, 5 Oct 2025 12:26:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFv-0004pp-VR; Sun, 05 Oct 2025 15:18:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFO-0002Pt-NH for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFG-0006ao-1W for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:18 -0400 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-210-s5lP3ZJtM2OrP1MpSwT0Cw-1; Sun, 05 Oct 2025 15:18:05 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3f6b44ab789so2162726f8f.3 for ; Sun, 05 Oct 2025 12:18:04 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a6c3esm17619080f8f.1.2025.10.05.12.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691887; 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=xISYYcoFQClxd+HhqK447x/hInZXjtzJhdgWUsDmah0=; b=dfE/Ej2WVPPZTKJFiFN6OXH2tiKJyhjvpE0+MSxriLKuWvjsW2FJlT84E9YnxYPgEkXvy/ hmgLuwXTbZIvGZCYwRTImncqrAgEaqdToUac9A8U/QxSxiwTu/kHHX/3lbrgSJOFaZ9K/f J3kRkAe+Ohg6AxtI4fHISVh3kcfZdvY= X-MC-Unique: s5lP3ZJtM2OrP1MpSwT0Cw-1 X-Mimecast-MFC-AGG-ID: s5lP3ZJtM2OrP1MpSwT0Cw_1759691884 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691882; x=1760296682; 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=xISYYcoFQClxd+HhqK447x/hInZXjtzJhdgWUsDmah0=; b=UdKTZXr2QK7Xai2IL9hw6OzYQ2j0zs83LEJ70p8lHci7jihIosVAvEV4gcezI4HjRG c504+BZ0mHzUvcybf3SHBL2lg/uIANwdI0FXFZtgd22tJr8TevuNpwPbLwttlHMpdYsn PCIw8mHDLAz6VNWtntu+K2mi2v6AwKRbHmr1qz/ZB7VtN1tphBUWVKh0C+CWjkadHtm6 94DNv06gVTS8MVPpouFFSJbAUtOJ0EgFlULS9cmWz/82rqt1CEwVuEUHhhFWwp7q8LMW LCcxEZYAeIUNc05xCZfSf7lw1124tWojXUZjZbA5/2e7tEC1aJ3hFLFyo9B1OJ+r1wMZ W2CA== X-Gm-Message-State: AOJu0YwwJHNpYc/qFYeCI8mnCuM/Mjvdgh675nP/uOUkcwxKMwgsuMUy /PDFfLsK/1/c7WZBP0k/0PoD1atQwzfePUYz02Vi+jvJhdbSv2A3rRGTEQElhq976rHyPxcaQJc flk5oJ2gqb4gXw0FAdiELF0kEXCV7r+3UUxO0I98k7zleBhQJNtjH8blTky1AriSxY1KINfCRm/ 82ujeq/06jaZz5CcIE1GhZVLPko0hhDG0vGA== X-Gm-Gg: ASbGncu64Uw4hpQsA8r8XeoX9mybrZedi7YPUUYIXlMzPKO79uGAJDZVXzhGbJEQhve KKTf48+k9/tbL884Z+Vd2K+frmijAcxOVzAhtjQDNrTPkGXOxS6gyAN0Zw+fhEthATENSt5Ag0s Gnv4LbhpTQhNby077zankuhwxKd9lECt9h4n8EpT3tr6lp0hIia5CGG1dH8s/2dbbFdkAZG8r76 uJq0WRPoBogan8+qIH7ObFOymHmKNAbDu8aQymk0CsUUfCc5w4r/IlEgP+jNb5uQ8YROzhpmxsv afrllE94BR+CNE1OcDC9wLeAMtSu5oAmEhKNtlE= X-Received: by 2002:a05:6000:4305:b0:3eb:f3de:1a87 with SMTP id ffacd0b85a97d-425671c2042mr7574172f8f.56.1759691882374; Sun, 05 Oct 2025 12:18:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwEnfi+OQJQCIiHpszPDOslfe2htzVCaY0Egr9eRwQ71+9kPsCgvdvUgIWNXlilAnlb9xoVw== X-Received: by 2002:a05:6000:4305:b0:3eb:f3de:1a87 with SMTP id ffacd0b85a97d-425671c2042mr7574149f8f.56.1759691881727; Sun, 05 Oct 2025 12:18:01 -0700 (PDT) Date: Sun, 5 Oct 2025 15:17:59 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 53/75] amd_iommu: Helper to decode size of page invalidation command Message-ID: <717d2f8805558ec39604c201bcbe3b36be2904db.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692410526116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez The size of the region to invalidate depends on the S bit and address encoded in the command. Add a helper to extract this information, which will be used to sync shadow page tables in upcoming changes. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-5-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.h | 4 ++++ hw/i386/amd_iommu.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 2476296c49..c1170a8202 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -126,6 +126,10 @@ #define AMDVI_CMD_COMPLETE_PPR_REQUEST 0x07 #define AMDVI_CMD_INVAL_AMDVI_ALL 0x08 =20 + +#define AMDVI_CMD_INVAL_IOMMU_PAGES_S (1ULL << 0) +#define AMDVI_INV_ALL_PAGES (1ULL << 52) + #define AMDVI_DEVTAB_ENTRY_SIZE 32 =20 /* Device table entry bits 0:63 */ diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 3cbc9499db..202f0f8c6e 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -577,6 +577,40 @@ static gboolean amdvi_iotlb_remove_by_domid(gpointer k= ey, gpointer value, return entry->domid =3D=3D domid; } =20 +/* + * Helper to decode the size of the range to invalidate encoded in the + * INVALIDATE_IOMMU_PAGES Command format. + * The size of the region to invalidate depends on the S bit and address. + * S bit value: + * 0 : Invalidation size is 4 Kbytes. + * 1 : Invalidation size is determined by first zero bit in the address + * starting from Address[12]. + * + * In the AMD IOMMU Linux driver, an invalidation command with address + * ((1 << 63) - 1) is sent when intending to clear the entire cache. + * However, Table 14: Example Page Size Encodings shows that an address of + * ((1ULL << 51) - 1) encodes the entire cache, so effectively any address= with + * first zero at bit 51 or larger is a request to invalidate the entire ad= dress + * space. + */ +static uint64_t __attribute__((unused)) +amdvi_decode_invalidation_size(hwaddr addr, uint16_t flags) +{ + uint64_t size =3D AMDVI_PAGE_SIZE; + uint8_t fzbit =3D 0; + + if (flags & AMDVI_CMD_INVAL_IOMMU_PAGES_S) { + fzbit =3D cto64(addr | 0xFFF); + + if (fzbit >=3D 51) { + size =3D AMDVI_INV_ALL_PAGES; + } else { + size =3D 1ULL << (fzbit + 1); + } + } + return size; +} + /* we don't have devid - we can't remove pages by address */ static void amdvi_inval_pages(AMDVIState *s, uint64_t *cmd) { --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692248; cv=none; d=zohomail.com; s=zohoarc; b=YpP8Q6HvYBsQXqLnrPRCGquIPPIrDvG/XY6RYVFJmYH6fGzvVF6bgLYyeMsJzx337UgEZ1i0D6VuRWyyYJkHnkWAA5xUTXIhMmM2mK4N5ncDHTZdLrrrJAhvU5o7Wx29qgBrP6hZ/actSd6QSSei4uWMnVVIfTDWdayZmRx26S8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692248; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8mgXBMkIPaubzZRCiKt5I0VhsqUbMTTDfaPPFluJjSA=; b=IcOTN7XJOjwN98xB3imqNFXZwz0RU6MBVOyKela9Ms7SdZlpZQlQjgVkC3yIQ8ar2ysP0nQGGwEYCbIGQBVYDp5AW4OPsYx4FDg2cp3eec3thYh6XX/PwGzXmJW3n42koQ5y92PW6lCP2uLUsKXrrjPBYI/snmVSEMh0mPduJgo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692248111514.8930904571115; Sun, 5 Oct 2025 12:24:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFf-0003ZK-2E; Sun, 05 Oct 2025 15:18:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFP-0002RV-8p for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFL-0006aq-Ly for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:18 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-282-oHMdGESXPgeYMsF-oD7qDg-1; Sun, 05 Oct 2025 15:18:05 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-46e46486972so11982155e9.0 for ; Sun, 05 Oct 2025 12:18:05 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e723432c9sm124177185e9.1.2025.10.05.12.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691887; 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=8mgXBMkIPaubzZRCiKt5I0VhsqUbMTTDfaPPFluJjSA=; b=dEiq5tknojR4X2Y20DUqSUalxHKV0c0euPC/sySvRaXGQYMiD1vdn2XYEMqeN3FjI/Ypbh ZScVITroWv3ai5k7gi5Kmzp4kOJKFkl8K3vaMOenpmyj/7F1vqFw3Zdcbef6Qp2JyuR2zn SYU72IiqUOBuh5xPJydYMp4uNRepoK4= X-MC-Unique: oHMdGESXPgeYMsF-oD7qDg-1 X-Mimecast-MFC-AGG-ID: oHMdGESXPgeYMsF-oD7qDg_1759691885 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691884; x=1760296684; 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=8mgXBMkIPaubzZRCiKt5I0VhsqUbMTTDfaPPFluJjSA=; b=OAldMTjPAbHmOwygQOgSdQvRfZAFS/bsMZ/dVgjNuDQOC+kdGVJfzFlytvQNszPCNt er82yuotNWRiyzvNea3ub9bb4liFDj1l4vtMwi242tl+/KOuyELqDs+44xWHgqrzM6Us 5lrrA+L9hznQFs7RLrLJyQiF5mRdF/7iIEsIRLrcGia1lygkZtq4jeLnMhDkObatZv/h 3tgNdTDDkV6ZIuRZLw/HqU+TcvSz+XyDrGWTzIOmbl851xtPiS/GQddm87JKRYPTkgvQ KoZfv/vfPc+7xXAJRwiz9b0BbHzNtd/f2MTeIvU6FsMWEcG3qqTVyyE/n2ICqCkU8++p p6Ng== X-Gm-Message-State: AOJu0YwrMiUdTPiqUgTlESV12uJRLgLyf4G9mZ7RtqrHD//8FQfL+doB J7BsL6o+tel0gDl1B1cCWk5HwWRiM9j4qbchgRa1qRCeo8FMecbborxUD4YBfIOvsxNqmJ8MKsu gILx+UDasqPoRYpE5M8bWzNj3K5IQfjElCuQ1V9hoDmbQfzmTzqzQMPYpgT0S+OCUphn6Nf/ZxM w6tH1YZ7ILF8f9oQPOy6p7hXCEMaJuNdozqA== X-Gm-Gg: ASbGncsp2votcgbMS04ubLcknrTvdAshBsIUilPS1W2h+toUVotDVX1lawgmKNA06Jf aRkYa23FjIYIOsv1zgXX1RJK1hIvOC0bljttJKTAxa2AGs0aqrFIYLFhXxQXqs6buFYA9mkuLCm Aw2dtjJVX7FI/HnZ0LPXppkfhnGqEZ9YBjLY3qQ2YlfNPDEafclKaO+xTNittHp5hYocwgp+JCU TfOIuWC+Lgxb0UPYhNKtz37T7alzHE7cSU/o34QX1IzC1j1g3UvugSGLy3DrrIvQ0JgOZ2ksm8M wj5jORbRPxwMKn1uiBV5GE6DtNWLnbuxMDPAmUo= X-Received: by 2002:a05:600c:1394:b0:46e:6d5f:f6c with SMTP id 5b1f17b1804b1-46e7110032dmr63962175e9.3.1759691884297; Sun, 05 Oct 2025 12:18:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE23IHBJvq+WxVfWuqq8+rVTeCQwqcgRfqyCH4iHiw25WeSpRhdFRbzASr//FtcbI9qYF0SuA== X-Received: by 2002:a05:600c:1394:b0:46e:6d5f:f6c with SMTP id 5b1f17b1804b1-46e7110032dmr63961955e9.3.1759691883727; Sun, 05 Oct 2025 12:18:03 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:01 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 54/75] amd_iommu: Add helper function to extract the DTE 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692254163116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez Extracting the DTE from a given AMDVIAddressSpace pointer structure is a common operation required for syncing the shadow page tables. Implement a helper to do it and check for common error conditions. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-6-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 48 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 202f0f8c6e..dc7531fd4a 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -77,6 +77,18 @@ typedef struct AMDVIIOTLBEntry { uint64_t page_mask; /* physical page size */ } AMDVIIOTLBEntry; =20 +/* + * These 'fault' reasons have an overloaded meaning since they are not only + * intended for describing reasons that generate an IO_PAGE_FAULT as per t= he AMD + * IOMMU specification, but are also used to signal internal errors in the + * emulation code. + */ +typedef enum AMDVIFaultReason { + AMDVI_FR_DTE_RTR_ERR =3D 1, /* Failure to retrieve DTE */ + AMDVI_FR_DTE_V, /* DTE[V] =3D 0 */ + AMDVI_FR_DTE_TV, /* DTE[TV] =3D 0 */ +} AMDVIFaultReason; + uint64_t amdvi_extended_feature_register(AMDVIState *s) { uint64_t feature =3D AMDVI_DEFAULT_EXT_FEATURES; @@ -524,6 +536,28 @@ static inline uint64_t amdvi_get_pte_entry(AMDVIState = *s, uint64_t pte_addr, return pte; } =20 +static int amdvi_as_to_dte(AMDVIAddressSpace *as, uint64_t *dte) +{ + uint16_t devid =3D PCI_BUILD_BDF(as->bus_num, as->devfn); + AMDVIState *s =3D as->iommu_state; + + if (!amdvi_get_dte(s, devid, dte)) { + /* Unable to retrieve DTE for devid */ + return -AMDVI_FR_DTE_RTR_ERR; + } + + if (!(dte[0] & AMDVI_DEV_VALID)) { + /* DTE[V] not set, address is passed untranslated for devid */ + return -AMDVI_FR_DTE_V; + } + + if (!(dte[0] & AMDVI_DEV_TRANSLATION_VALID)) { + /* DTE[TV] not set, host page table not valid for devid */ + return -AMDVI_FR_DTE_TV; + } + return 0; +} + /* log error without aborting since linux seems to be using reserved bits = */ static void amdvi_inval_devtab_entry(AMDVIState *s, uint64_t *cmd) { @@ -1081,6 +1115,7 @@ static void amdvi_do_translate(AMDVIAddressSpace *as,= hwaddr addr, uint16_t devid =3D PCI_BUILD_BDF(as->bus_num, as->devfn); AMDVIIOTLBEntry *iotlb_entry =3D amdvi_iotlb_lookup(s, addr, devid); uint64_t entry[4]; + int dte_ret; =20 if (iotlb_entry) { trace_amdvi_iotlb_hit(PCI_BUS_NUM(devid), PCI_SLOT(devid), @@ -1092,13 +1127,14 @@ static void amdvi_do_translate(AMDVIAddressSpace *a= s, hwaddr addr, return; } =20 - if (!amdvi_get_dte(s, devid, entry)) { - return; - } + dte_ret =3D amdvi_as_to_dte(as, entry); =20 - /* devices with V =3D 0 are not translated */ - if (!(entry[0] & AMDVI_DEV_VALID)) { - goto out; + if (dte_ret < 0) { + if (dte_ret =3D=3D -AMDVI_FR_DTE_V) { + /* DTE[V]=3D0, address is passed untranslated */ + goto out; + } + return; } =20 amdvi_page_walk(as, entry, ret, --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692520; cv=none; d=zohomail.com; s=zohoarc; b=k08n9K0UZbLjCw+MoxxXr9qXboSfsi+vtaba6uLRmqUIobCMjnhBK2sk5TlOSFxtcKqejHuFjKuBnbe8IHzle0N3NRNw+nMdVsvrjUCU8f6G8edLJF1wvzOJWGyvcw2EkHAB2naEb3aXHiqLiSQivkGL6CVAWQQRnC+tx7byBls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692520; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qi2c6v9N5AmCZh3R8EnHA/KH3jdmBYOZ9DKao79FqjE=; b=jL2sOyAN9EgJ5EThN37lZ3x6teQV5IO4MsP1oThOA+cp9rk29sIEUm1Xu3T+Np6opyhbw6tNlD3W82m/5qDdkI2JcYKnGWlOZ4XiAQOpfU00OEX6TBQF3COBrCR9xIo9zxsnPTRUYOR3WXqsMdTViF3xNHukqfzL2RHRGFExl3U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692520169835.0011426216083; Sun, 5 Oct 2025 12:28:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFZ-0002s6-G5; Sun, 05 Oct 2025 15:18:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFP-0002RU-79 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:20 -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 1v5UFL-0006ay-KD for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:18 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-279-2cFvU7-kM7aARIUlbLU0cw-1; Sun, 05 Oct 2025 15:18:07 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3ee10a24246so2032869f8f.3 for ; Sun, 05 Oct 2025 12:18:07 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8ab960sm17428614f8f.13.2025.10.05.12.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691890; 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=qi2c6v9N5AmCZh3R8EnHA/KH3jdmBYOZ9DKao79FqjE=; b=XRzyR8I7JBmyU8JscS4unSRIZFdCXRYj5bHg4zARHptRrYbHquQ+wcKOeFWgjlwXh9II2+ Nxj+b+wi19ZANNu7FCzvWS6qPpOGmjipLE3Ks6cg8hYCHTy4vn0sHYa4sXjKyXFxtSq89p 0GBFu4dNnCvFCSTu37bBpeyWHAq3c6I= X-MC-Unique: 2cFvU7-kM7aARIUlbLU0cw-1 X-Mimecast-MFC-AGG-ID: 2cFvU7-kM7aARIUlbLU0cw_1759691886 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691886; x=1760296686; 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=qi2c6v9N5AmCZh3R8EnHA/KH3jdmBYOZ9DKao79FqjE=; b=jCF2aeuf+ruFSbnAyYVtlAq9pP92Sg+0wwH2r3w1YHfl0l2jsb9PzVlLCxPm+VHf28 /9VxZ6e0oRoPcQ90OXkOAHmZM31cP0D7jwwI09CK9xxicCmXTioActQWpZZaxOAKoF6D FFZRkSU78yZNcZVlof4oKUp9bRp6TPB49dKFxBAXQ+2NS/8rUlOxDDiOj/fWRc05ggq1 XHoSSq4brHoyLGbZ2gq/GVrWJA/WgFbvJqslMtUrAmM6xhi4FlcnK0FbeIfVZhfGPKoM q/CxSkESAl+a0N2wf9G+N3QxHbxoEKSQmGGownhZG85YK/HuXFWoNMEeCup4X8ZA5E8E QjlQ== X-Gm-Message-State: AOJu0Yz8El5AFQUxQuOxLfOzwCNrDcnZaSe5m1uN1GAeZmDFLDCOGSyC SDo6j+bD4YmXzC63hfC1KfyoYcpvMR6tjWibQOR4yfqezIHkSWMPnCJ7s1iHSf30qxlnkXsrZMR Pw7wy+KQ8eQSkYqJixCuuuaElRBOQlq9IEtr/Y7RP0k/ZM7yUHoQhhhYh2OZSXD8bP79rpcK+ET bmm5xV97xn57xBT5FoyjzUBUX9ZKZP/KnNyg== X-Gm-Gg: ASbGncu/tlZAhlE4/I38YIRmoxyAG11ExXtZAVc6Z9vuGrMj3vQxzHTYjKC831x1CTq +GN9kegz6FFIfeT7XNCWBmcOluyC5JCQLlkChx/Majvjzsj2W6cG9g4QX2nLij9tP0sNK2+5uU7 vGiZKuzavebacFpFD24a3diHBFFPp86Q6v0XLpff7SJAKQBvif3VJVXuFaM8NLPeOhXoEjCtCK9 pxP0kBuRgsUOUpRLW3B50ekeJM7fWXx6PP0wX7cRS3iqdiAnC8cJAavFAZSb7PMncoI8IH4PVil hhdMvDB/nhdiyAY+bJdY0GAr3VrrQqLRxcSBPi4= X-Received: by 2002:a05:600c:4e09:b0:45f:2cf9:c229 with SMTP id 5b1f17b1804b1-46e710aec2dmr72682585e9.0.1759691886183; Sun, 05 Oct 2025 12:18:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHep4BPcVEfCzoBqhT/DZHq8Cnwa8tVa3o9UiW2501ooZkE8V3acfn8TwmOUaZEJtjRYeIUoQ== X-Received: by 2002:a05:600c:4e09:b0:45f:2cf9:c229 with SMTP id 5b1f17b1804b1-46e710aec2dmr72682435e9.0.1759691885704; Sun, 05 Oct 2025 12:18:05 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:03 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 55/75] amd_iommu: Return an error when unable to read PTE from guest memory Message-ID: <55d06ef8c9568761e2c92f4fa2b12e5b9465900d.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692524420116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez Make amdvi_get_pte_entry() return an error value (-1) in cases where the memory read fails, versus the current return of 0 to indicate failure. The reason is that 0 is also a valid value to have stored in the PTE in guest memory i.e. the guest does not have a mapping. Before this change, amdvi_get_pte_entry() returned 0 for both an error and for empty PTEs, but the page walker implementation that will be introduced in upcoming changes needs a method to differentiate between the two scenarios. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-7-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index dc7531fd4a..29ed3f0ef2 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -528,7 +528,7 @@ static inline uint64_t amdvi_get_pte_entry(AMDVIState *= s, uint64_t pte_addr, &pte, sizeof(pte), MEMTXATTRS_UNSPECIFIED)) { trace_amdvi_get_pte_hwerror(pte_addr); amdvi_log_pagetab_error(s, devid, pte_addr, 0); - pte =3D 0; + pte =3D (uint64_t)-1; return pte; } =20 @@ -1081,7 +1081,7 @@ static void amdvi_page_walk(AMDVIAddressSpace *as, ui= nt64_t *dte, /* add offset and load pte */ pte_addr +=3D ((addr >> (3 + 9 * level)) & 0x1FF) << 3; pte =3D amdvi_get_pte_entry(as->iommu_state, pte_addr, as->dev= fn); - if (!pte) { + if (!pte || (pte =3D=3D (uint64_t)-1)) { return; } oldlevel =3D level; --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692415; cv=none; d=zohomail.com; s=zohoarc; b=QzqDvWkiq6nJFHMCcsEZ7eMqoPPdx3+JeWoPnSUN4x7gCKQE7AzfgO1gR8Fkx++7gQeMTTil6WcvuXp+TkGUEuss8uAsZmaRh4tHddT5Bsc98OccE81kmIL26GTfWJR5gGPSu6W0tKeTrW6vH1fIBtPL943wEmW3gxfrFfnBoOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692415; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QUvenOCO68kLl2GvX+LSUfN8U9FY9cK3kWYV0GrRBjw=; b=CYr+mq+fXeq4vhaegoFEJFmC21DeoPHv9Suxg182lpa8yYAHGRRRcf7ZXpr+eaftWgrdNfp0fc3Yp3t2atys/a99SjRUgzmeaEuDMhS9cyiSEuBff4BtZrUhrebuvZRqkmELcyfYfKJJLdsD6CEHIcl8O1ma9A+ns3pHuqUATyU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692415110717.7456494168686; Sun, 5 Oct 2025 12:26:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFh-0003jm-0z; Sun, 05 Oct 2025 15:18:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFS-0002a3-Qo for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFQ-0006cU-HM for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:22 -0400 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-608-FulVQ9JCNhqSn2Rr01hjMA-1; Sun, 05 Oct 2025 15:18:13 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3ee10a24246so2032873f8f.3 for ; Sun, 05 Oct 2025 12:18:13 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f02a8sm17682605f8f.39.2025.10.05.12.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691899; 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=QUvenOCO68kLl2GvX+LSUfN8U9FY9cK3kWYV0GrRBjw=; b=UVH3git7/ueaFJVbkIXGFFlrcoQ7TtZ30WdwsT/g3/jNS3YIp2yUFa54OmsWrf4vCXJXSV Vty33tsZKt7J4piySwc/FHJo1K7SzkEsawrpD6LXr7Sm28KfHlth/9qd7ohsaxfAYNrWDm hE4jxFDG5qqmV+IwNZ3FVsX6TEEHcto= X-MC-Unique: FulVQ9JCNhqSn2Rr01hjMA-1 X-Mimecast-MFC-AGG-ID: FulVQ9JCNhqSn2Rr01hjMA_1759691892 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691888; x=1760296688; 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=QUvenOCO68kLl2GvX+LSUfN8U9FY9cK3kWYV0GrRBjw=; b=FJAUZ4/D9+VALfdanCluUbIVi29dZe8z46u20Y1469IdfgmZBo00IeW+LCO/x/c789 OiWLSzCsyriDNMpb0kjJA4Sy+M2sUw+upCZo+feqa/Dk7gsZWI5Q57BOYcDdb+P2cLVz FeXghZOYXuajJzhKb6b1pwdoq9+PQtPLSuiyhh7LkJ4duhuKU04zg8edGRPCJcYxDYj5 ybKAJAfiZkyfB4LdZ1UbSaoVtv9fpWrDmasAOFAfoZ0wX1+9mfaFDhulv5DTIqeGn0a/ mJlzjFnB3MnIZvtxhZDcBTW5St30/uwFP7SlHLQ7tIz4ycJyetLVT/OQq7ESkijFud5u OoFw== X-Gm-Message-State: AOJu0YzkWR7+QRvqmXBNYr1JHgzfh5Oi3qTTWRfl3KMiC9fsTwkp+xvV UAiE1v9RXmuQ13J18RvQTr3jejX2Rf/FzcpYxixCbCFn5HAia2O9No8QD6/BN6VNwrmMwieUf4A W+Q+T9jaPXs0Imci6opGRfp5cysFe31rT+DiVF0daHGAmvZpDhvfVazvgiz2gHHcOubmpioJ3VY NaR7J4DdgVjIvReP5PLrHdQhRFQZXF038LQA== X-Gm-Gg: ASbGnct+wvEOeqokzXuAMCefuQsBysft8adLwhYYsMENxLNcfHGa1dOjEJqjqo768jI sBDWGlYcQMqp2kcgKVLFbq0pI3UHGOztc+f0wwVjIZANFmH3YDmVIf5oHKtsu+kD6qCogaR5sZC 9Cx3TXRd+1l/J6Cx/PCg5DqH6YP3RFHS3dLbcIa55jc0fvEIDVzuYwgjsLAJ79xW0JtYSdtIwfz 6cR6+6ZWeOZMuHROCatlXCurg0el8f7S0oxH3T4eC6HCvZhfBEFy9GgpIaRTzP0d4n4/0GzzWob o8QrHiCK3+r/fcnFFlg35pVc0WiqJkjzbHL6fks= X-Received: by 2002:a05:6000:2401:b0:3ea:e0fd:28e8 with SMTP id ffacd0b85a97d-4256719e9c6mr5919195f8f.32.1759691888227; Sun, 05 Oct 2025 12:18:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtPM52Nj0JoCGtTCSnIYRGdunYIGeK2hexqu9nVPxW031A7jShUqMCt4B1cRrLU3+3LCgzRw== X-Received: by 2002:a05:6000:2401:b0:3ea:e0fd:28e8 with SMTP id ffacd0b85a97d-4256719e9c6mr5919177f8f.32.1759691887605; Sun, 05 Oct 2025 12:18:07 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:05 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 56/75] amd_iommu: Add helpers to walk AMD v1 Page Table format Message-ID: <39789107398c5c554efe0ff3726b3b3671dfb376.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692424885116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez The current amdvi_page_walk() is designed to be called by the replay() method. Rather than drastically altering it, introduce helpers to fetch guest PTEs that will be used by a page walker implementation. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-8-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.h | 40 ++++++++++++++ hw/i386/amd_iommu.c | 123 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index c1170a8202..9f833b297d 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -178,6 +178,46 @@ #define AMDVI_GATS_MODE (2ULL << 12) #define AMDVI_HATS_MODE (2ULL << 10) =20 +/* Page Table format */ + +#define AMDVI_PTE_PR (1ULL << 0) +#define AMDVI_PTE_NEXT_LEVEL_MASK GENMASK64(11, 9) + +#define IOMMU_PTE_PRESENT(pte) ((pte) & AMDVI_PTE_PR) + +/* Using level=3D0 for leaf PTE at 4K page size */ +#define PT_LEVEL_SHIFT(level) (12 + ((level) * 9)) + +/* Return IOVA bit group used to index the Page Table at specific level */ +#define PT_LEVEL_INDEX(level, iova) (((iova) >> PT_LEVEL_SHIFT(level))= & \ + GENMASK64(8, 0)) + +/* Return the max address for a specified level i.e. max_oaddr */ +#define PT_LEVEL_MAX_ADDR(x) (((x) < 5) ? \ + ((1ULL << PT_LEVEL_SHIFT((x + 1))) - 1) : \ + (~(0ULL))) + +/* Extract the NextLevel field from PTE/PDE */ +#define PTE_NEXT_LEVEL(pte) (((pte) & AMDVI_PTE_NEXT_LEVEL_MASK) >> 9) + +/* Take page table level and return default pagetable size for level */ +#define PTE_LEVEL_PAGE_SIZE(level) (1ULL << (PT_LEVEL_SHIFT(level))) + +/* + * Return address of lower level page table encoded in PTE and specified by + * current level and corresponding IOVA bit group at such level. + */ +#define NEXT_PTE_ADDR(pte, level, iova) (((pte) & AMDVI_DEV_PT_ROOT_MASK) = + \ + (PT_LEVEL_INDEX(level, iova) * 8)) + +/* + * Take a PTE value with mode=3D0x07 and return the page size it encodes. + */ +#define PTE_LARGE_PAGE_SIZE(pte) (1ULL << (1 + cto64(((pte) | 0xfffULL)= ))) + +/* Return number of PTEs to use for a given page size (expected power of 2= ) */ +#define PAGE_SIZE_PTE_COUNT(pgsz) (1ULL << ((ctz64(pgsz) - 12) % 9)) + /* IOTLB */ #define AMDVI_IOTLB_MAX_SIZE 1024 #define AMDVI_DEVID_SHIFT 36 diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 29ed3f0ef2..c25981ff93 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -87,6 +87,8 @@ typedef enum AMDVIFaultReason { AMDVI_FR_DTE_RTR_ERR =3D 1, /* Failure to retrieve DTE */ AMDVI_FR_DTE_V, /* DTE[V] =3D 0 */ AMDVI_FR_DTE_TV, /* DTE[TV] =3D 0 */ + AMDVI_FR_PT_ROOT_INV, /* Page Table Root ptr invalid */ + AMDVI_FR_PT_ENTRY_INV, /* Failure to read PTE from guest memory */ } AMDVIFaultReason; =20 uint64_t amdvi_extended_feature_register(AMDVIState *s) @@ -558,6 +560,127 @@ static int amdvi_as_to_dte(AMDVIAddressSpace *as, uin= t64_t *dte) return 0; } =20 +/* + * For a PTE encoding a large page, return the page size it encodes as des= cribed + * by the AMD IOMMU Specification Table 14: Example Page Size Encodings. + * No need to adjust the value of the PTE to point to the first PTE in the= large + * page since the encoding guarantees all "base" PTEs in the large page ar= e the + * same. + */ +static uint64_t large_pte_page_size(uint64_t pte) +{ + assert(PTE_NEXT_LEVEL(pte) =3D=3D 7); + + /* Determine size of the large/contiguous page encoded in the PTE */ + return PTE_LARGE_PAGE_SIZE(pte); +} + +/* + * Helper function to fetch a PTE using AMD v1 pgtable format. + * On successful page walk, returns 0 and pte parameter points to a valid = PTE. + * On failure, returns: + * -AMDVI_FR_PT_ROOT_INV: A page walk is not possible due to conditions li= ke DTE + * with invalid permissions, Page Table Root can not be read from DTE= , or a + * larger IOVA than supported by page table level encoded in DTE[Mode= ]. + * -AMDVI_FR_PT_ENTRY_INV: A PTE could not be read from guest memory durin= g a + * page table walk. This means that the DTE has valid data, but one o= f the + * lower level entries in the Page Table could not be read. + */ +static int __attribute__((unused)) +fetch_pte(AMDVIAddressSpace *as, hwaddr address, uint64_t dte, uint64_t *p= te, + hwaddr *page_size) +{ + IOMMUAccessFlags perms =3D amdvi_get_perms(dte); + + uint8_t level, mode; + uint64_t pte_addr; + + *pte =3D dte; + *page_size =3D 0; + + if (perms =3D=3D IOMMU_NONE) { + return -AMDVI_FR_PT_ROOT_INV; + } + + /* + * The Linux kernel driver initializes the default mode to 3, correspo= nding + * to a 39-bit GPA space, where each entry in the pagetable translates= to a + * 1GB (2^30) page size. + */ + level =3D mode =3D get_pte_translation_mode(dte); + assert(mode > 0 && mode < 7); + + /* + * If IOVA is larger than the max supported by the current pgtable lev= el, + * there is nothing to do. + */ + if (address > PT_LEVEL_MAX_ADDR(mode - 1)) { + /* IOVA too large for the current DTE */ + return -AMDVI_FR_PT_ROOT_INV; + } + + do { + level -=3D 1; + + /* Update the page_size */ + *page_size =3D PTE_LEVEL_PAGE_SIZE(level); + + /* Permission bits are ANDed at every level, including the DTE */ + perms &=3D amdvi_get_perms(*pte); + if (perms =3D=3D IOMMU_NONE) { + return 0; + } + + /* Not Present */ + if (!IOMMU_PTE_PRESENT(*pte)) { + return 0; + } + + /* Large or Leaf PTE found */ + if (PTE_NEXT_LEVEL(*pte) =3D=3D 7 || PTE_NEXT_LEVEL(*pte) =3D=3D 0= ) { + /* Leaf PTE found */ + break; + } + + /* + * Index the pgtable using the IOVA bits corresponding to current = level + * and walk down to the lower level. + */ + pte_addr =3D NEXT_PTE_ADDR(*pte, level, address); + *pte =3D amdvi_get_pte_entry(as->iommu_state, pte_addr, as->devfn); + + if (*pte =3D=3D (uint64_t)-1) { + /* + * A returned PTE of -1 indicates a failure to read the page t= able + * entry from guest memory. + */ + if (level =3D=3D mode - 1) { + /* Failure to retrieve the Page Table from Root Pointer */ + *page_size =3D 0; + return -AMDVI_FR_PT_ROOT_INV; + } else { + /* Failure to read PTE. Page walk skips a page_size chunk = */ + return -AMDVI_FR_PT_ENTRY_INV; + } + } + } while (level > 0); + + assert(PTE_NEXT_LEVEL(*pte) =3D=3D 0 || PTE_NEXT_LEVEL(*pte) =3D=3D 7 = || + level =3D=3D 0); + /* + * Page walk ends when Next Level field on PTE shows that either a lea= f PTE + * or a series of large PTEs have been reached. In the latter case, ev= en if + * the range starts in the middle of a contiguous page, the returned P= TE + * must be the first PTE of the series. + */ + if (PTE_NEXT_LEVEL(*pte) =3D=3D 7) { + /* Update page_size with the large PTE page size */ + *page_size =3D large_pte_page_size(*pte); + } + + return 0; +} + /* log error without aborting since linux seems to be using reserved bits = */ static void amdvi_inval_devtab_entry(AMDVIState *s, uint64_t *cmd) { --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691982; cv=none; d=zohomail.com; s=zohoarc; b=hUOZ9aJy+dJ1A9RjNqWRnl6UnjEbXcV/B5qvLrCHktZ1iaze4zPAWGhfnigeTDxlzkPa8NozLiRIgdnVMCHjR6IAIFr9+2oyTaXUsS3YGpNUfL2N5w0dx6TtbH7ENLowNb7J+TJmtTdU4bFN78743jXeX2BdA9++3p9FDw3NBuc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691982; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VRpFNHgPPbK5fpFtNVbPj3sQYNUpsLNHYrc3Cj0nCsg=; b=QzeYIEmmeteXtZfhkY6+s2tP9LR+CZjjaDI3qYe8Jo3dwnojW3SXKUuexxpgUs6avg7ZZfMDO8BUbdVHsvWYAoJv3AnVbYl9IkBGzeI3g2vIazViL6L8hmzeucXBmcvFal/t/z6+JQBkYC3Mw1/KbR+CrKlFYEcyXOmzg8ynPtM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691982523612.3133612342032; Sun, 5 Oct 2025 12:19:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UG8-00053i-QK; Sun, 05 Oct 2025 15:19:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFT-0002ao-3y for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFL-0006bQ-O6 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:22 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-517-0ZS5dOcAP_Kwj4TSD2nzLg-1; Sun, 05 Oct 2025 15:18:13 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46e3dcb36a1so24953165e9.2 for ; Sun, 05 Oct 2025 12:18:12 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8e97fbsm17251517f8f.34.2025.10.05.12.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691894; 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=VRpFNHgPPbK5fpFtNVbPj3sQYNUpsLNHYrc3Cj0nCsg=; b=LGtL+nFSnnZLUr0fLxMbinCBtc1uuXeGSWNjw8RAvKbvtO7+SvkH/8p6m7XXbRN5AtIN72 D9F8mWDOM20EJK2uCeQO4WycZnqIlLZ94ETuP/S7+BSb9rZ0QkyV4+ULVVmn36qv+mEuND zBZkW8cteh7GcUGBBYotSrwmCe6yQH8= X-MC-Unique: 0ZS5dOcAP_Kwj4TSD2nzLg-1 X-Mimecast-MFC-AGG-ID: 0ZS5dOcAP_Kwj4TSD2nzLg_1759691892 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691892; x=1760296692; 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=VRpFNHgPPbK5fpFtNVbPj3sQYNUpsLNHYrc3Cj0nCsg=; b=GOnOrSTuZxTQXmRMo/grkXrl8fUR428DpPZtHoPGxN+4Li1CPTm615NxqyZv4cIaQV 8IW+tRAVUmQHcf/WDUn9hXMD/t5blEaM2hKHyjtMdi9tExMUxIYWTt6mssq0T3UzTs9v JwgnDSsnwLGdqjhjf0ymX3BZi1Y3quPXUhvvnb/iZSYFiG0BWoig6D03XxEOfEMkwus0 fy6fcFUPJNqrg31YuMkpdF5cqHYVcJDnCqQo6kSUfpS6M0z7ZpmzLwtOul+BpadyEhK4 1bRkfXAuwiakUxObrjBpmnbMdjNWW8SaxfkwsFQFl1GgHJyRkwZdp5YI+Uk/psKIaDzG bZPQ== X-Gm-Message-State: AOJu0YxFKD0SD2vIHSs5vv/2pHUtJAQ247hQFlnG+MdXK4/+m4cpvsJ0 AP4rOx3Z7k/IhftH7Tfi/T5GDeDlndp0CfOJXd/9WDfogM7jgPJUR4eTkHTc4ngiJ3WNmoAm/6O TB31nP1iiD19dHCytKmXBUM84YHrFOec0A+xLhwFwhS9EBi1JkX1PloX1Yf2Z4iANaBH0/MaRmV S08URrhkyvhMv8VeMYCyluMJOXnTw8AIz1uw== X-Gm-Gg: ASbGncsAKejOKgDiu/mN1XC0Ui0caVLL+CJc18YOJF0sykhtuT2pYTZmh7SfD6BUEVu M6eOBRudNs0MXuoxHf8bWf28XAaAnCJFGXm0LT+3AGmaMXTyjZgzf9YO7KviyXWEYPxZlAgVbqV TlNSVWO3Q5SXp6ZPOe8VeZOTiCEeuujzBb1g7wzjValOeqRx7h+HrDO3SPW6yBDsxKP9R9TTrIN QXui0MXiQm97pWAgrUwqtfAwSAhS3U4Oj+pzxttsmehbqwaZSzylamVI1N3Vq7M8F9LGxC613KS xlGDYgBTQpFBIBYzCeow8ELKz15ONllXgON0yiI= X-Received: by 2002:a05:600c:c111:b0:46e:1b89:77f1 with SMTP id 5b1f17b1804b1-46e793feb40mr30967525e9.9.1759691891486; Sun, 05 Oct 2025 12:18:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHl3ZecWmg6mZlVpPSyYDkX74MDKqzRZ1HNJ0XHkecduebYpDX4xkqUVMX9nClZ1xreciYFrw== X-Received: by 2002:a05:600c:c111:b0:46e:1b89:77f1 with SMTP id 5b1f17b1804b1-46e793feb40mr30967395e9.9.1759691890929; Sun, 05 Oct 2025 12:18:10 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:07 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 57/75] amd_iommu: Add a page walker to sync shadow page tables on invalidation 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759691987688116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez For the specified address range, walk the page table identifying regions as mapped or unmapped and invoke registered notifiers with the corresponding event type. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-9-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 80 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index c25981ff93..0e45435c77 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -681,6 +681,86 @@ fetch_pte(AMDVIAddressSpace *as, hwaddr address, uint6= 4_t dte, uint64_t *pte, return 0; } =20 +/* + * Walk the guest page table for an IOVA and range and signal the register= ed + * notifiers to sync the shadow page tables in the host. + * Must be called with a valid DTE for DMA remapping i.e. V=3D1,TV=3D1 + */ +static void __attribute__((unused)) +amdvi_sync_shadow_page_table_range(AMDVIAddressSpace *as, uint64_t *dte, + hwaddr addr, uint64_t size, bool send_u= nmap) +{ + IOMMUTLBEvent event; + + hwaddr iova_next, page_mask, pagesize; + hwaddr iova =3D addr; + hwaddr end =3D iova + size - 1; + + uint64_t pte; + int ret; + + while (iova < end) { + + ret =3D fetch_pte(as, iova, dte[0], &pte, &pagesize); + + if (ret =3D=3D -AMDVI_FR_PT_ROOT_INV) { + /* + * Invalid conditions such as the IOVA being larger than suppo= rted + * by current page table mode as configured in the DTE, or a f= ailure + * to fetch the Page Table from the Page Table Root Pointer in= DTE. + */ + assert(pagesize =3D=3D 0); + return; + } + /* PTE has been validated for major errors and pagesize is set */ + assert(pagesize); + page_mask =3D ~(pagesize - 1); + iova_next =3D (iova & page_mask) + pagesize; + + if (ret =3D=3D -AMDVI_FR_PT_ENTRY_INV) { + /* + * Failure to read PTE from memory, the pagesize matches the c= urrent + * level. Unable to determine the region type, so a safe strat= egy is + * to skip the range and continue the page walk. + */ + goto next; + } + + event.entry.target_as =3D &address_space_memory; + event.entry.iova =3D iova & page_mask; + /* translated_addr is irrelevant for the unmap case */ + event.entry.translated_addr =3D (pte & AMDVI_DEV_PT_ROOT_MASK) & + page_mask; + event.entry.addr_mask =3D ~page_mask; + event.entry.perm =3D amdvi_get_perms(pte); + + /* + * In cases where the leaf PTE is not found, or it has invalid + * permissions, an UNMAP type notification is sent, but only if the + * caller requested it. + */ + if (!IOMMU_PTE_PRESENT(pte) || (event.entry.perm =3D=3D IOMMU_NONE= )) { + if (!send_unmap) { + goto next; + } + event.type =3D IOMMU_NOTIFIER_UNMAP; + } else { + event.type =3D IOMMU_NOTIFIER_MAP; + } + + /* Invoke the notifiers registered for this address space */ + memory_region_notify_iommu(&as->iommu, 0, event); + +next: + /* Check for 64-bit overflow and terminate walk in such cases */ + if (iova_next < iova) { + break; + } else { + iova =3D iova_next; + } + } +} + /* log error without aborting since linux seems to be using reserved bits = */ static void amdvi_inval_devtab_entry(AMDVIState *s, uint64_t *cmd) { --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692158; cv=none; d=zohomail.com; s=zohoarc; b=AW1lcrUjQA2GaRf9KUC3uBcfsn0HmFnRUBDcYSd+KRywQDWFpmrEActs3GiWZB+ZbYIE0hl8gYgMUXSk/K3T6mQxtCeuaCsB4Dq9jTgy4FHibSnDijGz5zs8CteT26rCqIAHfCnZ13uN7UDI6kxCat1mx2775VqlXcR6dADNpcY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692158; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+0h9FTrsqm/g/IFQsQ8t5vQ0TqkRAGX49Oc6QIoc2zU=; b=hrupXaWALz4nV/KZBZVHDN0BKz/82/ad7HXPNJDL7BN/w5Zc5tvYRVMX4bqr7Fa2bhXe0yUshclqvy0PUKHN0m73U4GPcm8vZXnLvLGUMSBTrz4n+S9nZwSyklaLpUgzZOQelX557oLok5TLJs/UozQBQP48YyZIDVBN+H+wBh4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175969215863078.8996499074434; Sun, 5 Oct 2025 12:22:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UG5-0004wf-JV; Sun, 05 Oct 2025 15:19: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 1v5UFQ-0002Rv-OC for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:21 -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 1v5UFN-0006bh-FN for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:20 -0400 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-55-wwPX6j4dO0G7fy4ypblObQ-1; Sun, 05 Oct 2025 15:18:15 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3ee12ab7f33so2159564f8f.2 for ; Sun, 05 Oct 2025 12:18:14 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e619b86e1sm216945195e9.5.2025.10.05.12.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691896; 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=+0h9FTrsqm/g/IFQsQ8t5vQ0TqkRAGX49Oc6QIoc2zU=; b=fFfKuH7W0+gApFj/LUDzNq7IA3l6vngQ5AhxD/rXUH2SgTWxivR2TPD1Ajf0leDLzhfM2I wQC4SokUXHI1zWSXqQplubFrspRAlIEgR2Ryb0zsyIOref5if96g8C01us5K0Tr15YuMtH 61rnNYDLI3F1mNyBrC0aGkKC9+6gaRs= X-MC-Unique: wwPX6j4dO0G7fy4ypblObQ-1 X-Mimecast-MFC-AGG-ID: wwPX6j4dO0G7fy4ypblObQ_1759691894 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691894; x=1760296694; 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=+0h9FTrsqm/g/IFQsQ8t5vQ0TqkRAGX49Oc6QIoc2zU=; b=aLwoQWS5PHjv+rTatCrn0d7QbGeEAw25A8L6QmPF3oNI/EQQOYNduLzSUdGV5WU0kR 962Kml8lNKOBkbjOKEEcAW4Jcg/+c5J/O9Mkniyq6/4p2awl7tRGIa29FvjESmidyDSC Tq9EGuPZ81+ml4chU2INbTLiGG3UVpLlWq5kWl7vd54zJRpAIPqYicfEQ7ciIVRuNFxD VnpALdr9TlAtHVjL8tsTfMzTBA9DqoBXaKXXhq7VJmM9bUxv8eYRbq2FaynvhLfZvrfu hmTAuZmUDUJQD/4GIxWGOOM01LAZvOU0g4ePxtlfNNKN/cK1u+9Cgjf37mcJXyFInmYf y2aQ== X-Gm-Message-State: AOJu0Yxrw7OST51Y8AsB9pPoQTjd/Hoqr8Pr/+d+omtaQqKEs8sScQ/h DBSmPqMfIUbVUtUeaGgVksepwDDyYUffkeY1UrNPSYLUgFokQHf+bfsdBKMZdmkxxWjiyBYlFQ8 l/ynLH0kRSVVYYQd2dLwtVcOw4EDj8OY/+a2ysrbA+TcPiH87l0IISgTB12NdoDAy667vgOfeBN hO+V9Ed0L4KoAZ1SWEe4GWp9cmJt6TQojeZQ== X-Gm-Gg: ASbGncsgoQ+CBRhXwpHq/OztJzlX7gS73FiCPK/EkJMsNPJY8pgSvKhWcGHVSYHM12s oK0QuEBfEUu/SAAHR1LnsVzE4FhossBT0j+W0zdi4NAgxfGuqQ+kFeEUpOKqAvmqagOEWcNccWc G6Cod1QkYVqOKNaxUD6+1gqYLT9SmMKRBurnkYyu/R8A8TgbWsAGpFDDRdII1FhIF1nP2VHMuRf 1OLpUtGWMfS0Wo+rF+FKOn/VtdjiW8RZuRKVrV6a+ps6Pl98tzb9HIx5lDYln0CPhWbyOKW6uW/ vQfrNloECKmdx6RRHjYTDqd3QA1Sv6TgklLGj7U= X-Received: by 2002:a05:6000:2287:b0:3ec:dc9d:bfcd with SMTP id ffacd0b85a97d-425671c8e29mr6571893f8f.63.1759691893529; Sun, 05 Oct 2025 12:18:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGL2HBwSu01KsmCEmh/1Yz/m4hN2iR8zjs/od1K9bPylvxZTcm+UyNQRCkNCBAoCoj1hnK/RQ== X-Received: by 2002:a05:6000:2287:b0:3ec:dc9d:bfcd with SMTP id ffacd0b85a97d-425671c8e29mr6571876f8f.63.1759691892936; Sun, 05 Oct 2025 12:18:12 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:11 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 58/75] amd_iommu: Add basic structure to support IOMMU notifier updates Message-ID: <325b2562600e0c25e4fe172d1a1e9499fc854250.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692160853116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez Add the minimal data structures required to maintain a list of address spaces (i.e. devices) with registered notifiers, and to update the type of events that require notifications. Note that the ability to register for MAP notifications is not available. It will be unblocked by following changes that enable the synchronization of guest I/O page tables with host IOMMU state, at which point an amd-iommu device property will be introduced to control this capability. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-10-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.h | 3 +++ hw/i386/amd_iommu.c | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index 9f833b297d..b51aa74368 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -409,6 +409,9 @@ struct AMDVIState { /* for each served device */ AMDVIAddressSpace **address_spaces[PCI_BUS_MAX]; =20 + /* list of address spaces with registered notifiers */ + QLIST_HEAD(, AMDVIAddressSpace) amdvi_as_with_notifiers; + /* IOTLB */ GHashTable *iotlb; =20 diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 0e45435c77..d8a451b3a5 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -66,6 +66,11 @@ struct AMDVIAddressSpace { MemoryRegion iommu_nodma; /* Alias of shared nodma memory region */ MemoryRegion iommu_ir; /* Device's interrupt remapping region */ AddressSpace as; /* device's corresponding address space */ + + /* DMA address translation support */ + IOMMUNotifierFlag notifier_flags; + /* entry in list of Address spaces with registered notifiers */ + QLIST_ENTRY(AMDVIAddressSpace) next; }; =20 /* AMDVI cache entry */ @@ -1773,6 +1778,7 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus= , void *opaque, int devfn) iommu_as[devfn]->bus_num =3D (uint8_t)bus_num; iommu_as[devfn]->devfn =3D (uint8_t)devfn; iommu_as[devfn]->iommu_state =3D s; + iommu_as[devfn]->notifier_flags =3D IOMMU_NOTIFIER_NONE; =20 amdvi_dev_as =3D iommu_as[devfn]; =20 @@ -1846,6 +1852,7 @@ static int amdvi_iommu_notify_flag_changed(IOMMUMemor= yRegion *iommu, Error **errp) { AMDVIAddressSpace *as =3D container_of(iommu, AMDVIAddressSpace, iommu= ); + AMDVIState *s =3D as->iommu_state; =20 if (new & IOMMU_NOTIFIER_MAP) { error_setg(errp, @@ -1854,6 +1861,19 @@ static int amdvi_iommu_notify_flag_changed(IOMMUMemo= ryRegion *iommu, PCI_FUNC(as->devfn)); return -EINVAL; } + + /* + * Update notifier flags for address space and the list of address spa= ces + * with registered notifiers. + */ + as->notifier_flags =3D new; + + if (old =3D=3D IOMMU_NOTIFIER_NONE) { + QLIST_INSERT_HEAD(&s->amdvi_as_with_notifiers, as, next); + } else if (new =3D=3D IOMMU_NOTIFIER_NONE) { + QLIST_REMOVE(as, next); + } + return 0; } =20 --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692267; cv=none; d=zohomail.com; s=zohoarc; b=Rj0UiHyU8EKu3HyJIFcj5K3mNS+UbD7sSGsnhSAGPO2u8LtlF8rZoxYMjVVfp9LwuXbuJtMeKBhGwKJa+r3f5QLEyGFYPPaq/09qw7NEvfO5WDp8drRkoHra0LhQO7fqpQqybYKD661uGz4Q3qdmmwykfa+Ew8wKv3x4wW3G0Fg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692267; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QCxFKVOHL0at5yB+6ueybckR1t9fum92R8jP7usSf1w=; b=f9aPPUjJ88KiXKcUEwH9l1lgcvWs+2iuzQQ+x9Y8gm6X9GTfQf4DVuF+Rgmp2QxpriB2iYu7Zss/XC1jGdnB+Y4OmDOXQhqSYiHGWMHtd9Th4d/zu8Kkr/VelF3AqwvYmJHu9un0ghWacqCq5LuOY7cW+KdBQ699ygP8pNloKAI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692267793501.3225147077346; Sun, 5 Oct 2025 12:24:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UG5-00050t-MS; Sun, 05 Oct 2025 15:19: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 1v5UFS-0002a1-QP for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFP-0006cG-Hi for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:22 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-591-scn8RFuyNw2BaCeDrmvDaw-1; Sun, 05 Oct 2025 15:18:17 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46e3e177893so22925895e9.2 for ; Sun, 05 Oct 2025 12:18:17 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8e980dsm18750958f8f.36.2025.10.05.12.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691898; 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=QCxFKVOHL0at5yB+6ueybckR1t9fum92R8jP7usSf1w=; b=RErLm0MbVQ+ceR/4kcLYnxX11QfgCl5VgnHFVHA5oli9H2XPD+XEuDYFPpyd1HoUii1+Ou oYLid6v8EHwK3cSzAHZoGqd+frr5HOQO84hLSNcS025IyCzznkZGTitoLJzMeJ5EPCSP3l WY3z0dV6hIAt3GhUzQagIsbMTLE9GjY= X-MC-Unique: scn8RFuyNw2BaCeDrmvDaw-1 X-Mimecast-MFC-AGG-ID: scn8RFuyNw2BaCeDrmvDaw_1759691896 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691896; x=1760296696; 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=QCxFKVOHL0at5yB+6ueybckR1t9fum92R8jP7usSf1w=; b=UVSOj78+dXYPLi36eeR1qplceAXBY6GLskI/5ihIkM1haNNn/ctI9XkVgrVWsXo6dM 0T1rezHKEJLPez/bhbVxQ/y5XKktrvLsXgzw9/Yzp9RuE7SpVYgiAoSgjLCiFrIdAE// e3/9Z4FeuvO4Pbtv4XZ7DFLSthVEwtwtWDzjAsqHb7Y3AuapoLrMNyWkXp0FcU52rHrw E+uJWuEkyjZdlPa0FaUxaBs+GjxFPOBSf6wxOy96AriWnVILPubsHI81GLiqdWl3GyaF D9dNmA8xD4DldxLI5UKQ4AAk8xshNql4mDlpRTxwZQn3e20JEuEgPKghBO9TOHy7+DbP NKag== X-Gm-Message-State: AOJu0YzdQqK5kN7HCukwwcIGlHM2RAKAq6CqGLb/5fudxr9kQqsBcFtW C+zyB57CHGGYVwWs1m8zl6twyoF0vcLqSnfaJG/Elz6NxivDM1NNhtiqZxw0AT8kt//8PrJyiTF 6rczNJVE7k8+1vgKXH3J2kBKg8D+8EFh/xBpGWHkKCqzDVD10AFlqHvOZiXpvds9LdGakdigAw4 MJu8WKjTaqYKsBrO38E0pieFd+gXryb6DOQw== X-Gm-Gg: ASbGncus8ZHpr/VzxwO3yU2U4UfM3Z6ahWe+Q72lf7qkYwgDIEM+QnJKHjOXM0rM2Mc cA+3mywB/q/pXmOD0LelSldPls3ZhEuqWjdQ9OsEIqw714TB2CinDc8+pViSmoYAZd4K2u4KB9L FaVQrepPcrjNoRqKvl8DtUeEW0Nwb736zZdBgtYIvpEtbQT2m1MrkLnc9EN2D+MaoMrb2u3DuUK tzr/274a8kMtbqFvUHobicS7l29A66mAcm0016HYFRjNHtFkXs2AyLc/geedIDXchAAqIOWr0ZE npLzlhzoXF+AMjUQC6HmOe6FX02PBJsnPZ69gLA= X-Received: by 2002:a05:6000:2dc8:b0:3cd:ef83:a9a1 with SMTP id ffacd0b85a97d-42567152194mr6125495f8f.20.1759691895890; Sun, 05 Oct 2025 12:18:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEW6DC+RF4gILeNWVekpqJNJ+21AFTqBaRzRGNy33JIpOzr6tk0+z+l/NsC1CwcNtBtDo4mpA== X-Received: by 2002:a05:6000:2dc8:b0:3cd:ef83:a9a1 with SMTP id ffacd0b85a97d-42567152194mr6125473f8f.20.1759691895182; Sun, 05 Oct 2025 12:18:15 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 59/75] amd_iommu: Sync shadow page tables on page invalidation 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692270513116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez When the guest issues an INVALIDATE_IOMMU_PAGES command, decode the address and size of the invalidation and sync the guest page table state with the host. This requires walking the guest page table and calling notifiers registered for address spaces matching the domain ID encoded in the command. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-11-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 82 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 8 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index d8a451b3a5..caae65c4b3 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -591,9 +591,8 @@ static uint64_t large_pte_page_size(uint64_t pte) * page table walk. This means that the DTE has valid data, but one o= f the * lower level entries in the Page Table could not be read. */ -static int __attribute__((unused)) -fetch_pte(AMDVIAddressSpace *as, hwaddr address, uint64_t dte, uint64_t *p= te, - hwaddr *page_size) +static uint64_t fetch_pte(AMDVIAddressSpace *as, hwaddr address, uint64_t = dte, + uint64_t *pte, hwaddr *page_size) { IOMMUAccessFlags perms =3D amdvi_get_perms(dte); =20 @@ -691,9 +690,9 @@ fetch_pte(AMDVIAddressSpace *as, hwaddr address, uint64= _t dte, uint64_t *pte, * notifiers to sync the shadow page tables in the host. * Must be called with a valid DTE for DMA remapping i.e. V=3D1,TV=3D1 */ -static void __attribute__((unused)) -amdvi_sync_shadow_page_table_range(AMDVIAddressSpace *as, uint64_t *dte, - hwaddr addr, uint64_t size, bool send_u= nmap) +static void amdvi_sync_shadow_page_table_range(AMDVIAddressSpace *as, + uint64_t *dte, hwaddr addr, + uint64_t size, bool send_un= map) { IOMMUTLBEvent event; =20 @@ -835,8 +834,7 @@ static gboolean amdvi_iotlb_remove_by_domid(gpointer ke= y, gpointer value, * first zero at bit 51 or larger is a request to invalidate the entire ad= dress * space. */ -static uint64_t __attribute__((unused)) -amdvi_decode_invalidation_size(hwaddr addr, uint16_t flags) +static uint64_t amdvi_decode_invalidation_size(hwaddr addr, uint16_t flags) { uint64_t size =3D AMDVI_PAGE_SIZE; uint8_t fzbit =3D 0; @@ -853,10 +851,76 @@ amdvi_decode_invalidation_size(hwaddr addr, uint16_t = flags) return size; } =20 +/* + * Synchronize the guest page tables with the shadow page tables kept in t= he + * host for the specified range. + * The invalidation command issued by the guest and intercepted by the VMM + * does not specify a device, but a domain, since all devices in the same = domain + * share the same page tables. However, vIOMMU emulation creates separate + * address spaces per device, so it is necessary to traverse the list of a= ll of + * address spaces (i.e. devices) that have notifiers registered in order to + * propagate the changes to the host page tables. + * We cannot return early from this function once a matching domain has be= en + * identified and its page tables synced (based on the fact that all devic= es in + * the same domain share the page tables). The reason is that different de= vices + * (i.e. address spaces) could have different notifiers registered, and by + * skipping address spaces that appear later on the amdvi_as_with_notifier= s list + * their notifiers (which could differ from the ones registered for the fi= rst + * device/address space) would not be invoked. + */ +static void amdvi_sync_domain(AMDVIState *s, uint16_t domid, uint64_t addr, + uint16_t flags) +{ + AMDVIAddressSpace *as; + + uint64_t size =3D amdvi_decode_invalidation_size(addr, flags); + + if (size =3D=3D AMDVI_INV_ALL_PAGES) { + addr =3D 0; /* Set start address to 0 and invalidate entire = AS */ + } else { + addr &=3D ~(size - 1); + } + + /* + * Call notifiers that have registered for each address space matching= the + * domain ID, in order to sync the guest pagetable state with the host. + */ + QLIST_FOREACH(as, &s->amdvi_as_with_notifiers, next) { + + uint64_t dte[4] =3D { 0 }; + + /* + * Retrieve the Device Table entry for the devid corresponding to = the + * current address space, and verify the DomainID matches i.e. the= page + * tables to be synced belong to devices in the domain. + */ + if (amdvi_as_to_dte(as, dte)) { + continue; + } + + /* Only need to sync the Page Tables for a matching domain */ + if (domid !=3D (dte[1] & AMDVI_DEV_DOMID_ID_MASK)) { + continue; + } + + /* + * We have determined that there is a valid Device Table Entry for= a + * device matching the DomainID in the INV_IOMMU_PAGES command iss= ued by + * the guest. Walk the guest page table to sync shadow page table. + */ + if (as->notifier_flags & IOMMU_NOTIFIER_MAP) { + /* Sync guest IOMMU mappings with host */ + amdvi_sync_shadow_page_table_range(as, &dte[0], addr, size, tr= ue); + } + } +} + /* we don't have devid - we can't remove pages by address */ static void amdvi_inval_pages(AMDVIState *s, uint64_t *cmd) { uint16_t domid =3D cpu_to_le16((uint16_t)extract64(cmd[0], 32, 16)); + uint64_t addr =3D cpu_to_le64(extract64(cmd[1], 12, 52)) << 12; + uint16_t flags =3D cpu_to_le16((uint16_t)extract64(cmd[1], 0, 3)); =20 if (extract64(cmd[0], 20, 12) || extract64(cmd[0], 48, 12) || extract64(cmd[1], 3, 9)) { @@ -866,6 +930,8 @@ static void amdvi_inval_pages(AMDVIState *s, uint64_t *= cmd) =20 g_hash_table_foreach_remove(s->iotlb, amdvi_iotlb_remove_by_domid, &domid); + + amdvi_sync_domain(s, domid, addr, flags); trace_amdvi_pages_inval(domid); } =20 --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759691993; cv=none; d=zohomail.com; s=zohoarc; b=EIugqBNWouDjJkqSclGZ/OINaHGPvG6gbS+odQ5wOn9cw0xOn9pEF1Uwj2Wqo+y94jDHqla4CWKEGetJ7nmn15O5H8vlJpihFvTqGTMiQwHUIBgPyHT25fGB3xYw+e2L+pCuS/Xmte5JBBnewz7+bfgMftHUQc0DGlHfRFEk1Fs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759691993; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CUXH9jflyEfZRN7jKCMdE7m/FyRWJE2tZCWeRtqscZ0=; b=ct7OMOgOJdd97gZpTRUY7wqb0oC53pMN8KeDQC86/AIvxZF0+TI9iDWdDA1/P0rqRrfszfvErU4GglvJjhONAGyy0z1/Efxr2j6vGiEVsIt763WFptcOutH5S+bzaEssTo3QUxVChBqDvyGSfyVHOYHJ3kIPB8p2kQAPVaqC+kw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759691993333657.5573129514131; Sun, 5 Oct 2025 12:19:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFk-0004Ja-Kp; Sun, 05 Oct 2025 15:18:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFU-0002iF-EA for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFR-0006cn-Aw for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:23 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-529-kLz9QBIgOa-MZFZR5jFpGA-1; Sun, 05 Oct 2025 15:18:19 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46eee58d405so1672535e9.1 for ; Sun, 05 Oct 2025 12:18:19 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e72343260sm123314755e9.4.2025.10.05.12.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691900; 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=CUXH9jflyEfZRN7jKCMdE7m/FyRWJE2tZCWeRtqscZ0=; b=LNlpb24t9P/VYXvSazp4RVckYnnkQXrAlzZ0/t4V6VD6SolhyAhD9gBhzOLWfrxnCHUtrS 5ZYay0Rl0irA3SlBw2kxDSqIChqz2dKWG0zjmuDhQnr75AWB8WMeI5GdfpF5qESDDOMOTr 9hLn2jgkfvtmGrAi5iLZqOra4HEBMGA= X-MC-Unique: kLz9QBIgOa-MZFZR5jFpGA-1 X-Mimecast-MFC-AGG-ID: kLz9QBIgOa-MZFZR5jFpGA_1759691898 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691898; x=1760296698; 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=CUXH9jflyEfZRN7jKCMdE7m/FyRWJE2tZCWeRtqscZ0=; b=c0hvVmaDwIAzV8DysZQX4fqGKHldvTgQ5zhI+0dQkgoAEXE4TjXd507msFNQsWKcET 24wlyZyn0y0nYbPX17AKMCkbNyowmPorpvaVjc+Vut7H8ehr5dDSz6uqSZySWp2burSN 5KqOJA2UmtU9RnRIMVEyUAOu+GPHV7e+lJPabc3rvorA3JyuLTQTa6PsKOkh3RiTxMrI dPj9LOLK1iVMRGfQqQIRuTE9zHvxapqI7+U/awkPUy5QCPxqD6Gv4Yeh0O0eAVAlU2B3 kyPKHe1MTyy8AJpPX6dwzqcn4vwecqzJDbbZgAJM5SS7fkl/C5ZuRc1cpEpug4fzxk6s 5Teg== X-Gm-Message-State: AOJu0YxR6LDLNw/Up8kJkHyX+e3yhdkHG51Xp+tzpJMqT/I8rRud65H9 gEpKtp5nqj0Zt/5tBuSbFoAp9GFrOWzgxqqArDQOws88F8j3fRnzTFvnUp7ty+YwsOX4Yuc+x5v Sk994ZkdQ+zIv3RDU8arJF+AbdNUKJHW/bJLMhzvESC7xpw1Hsy8o9xzO/SFhYg3UFm9Iozx7uC lv7TvAdD8wRyyL9XN5jFLCs0sAajHAEK8lzA== X-Gm-Gg: ASbGncv955C/jVdSH4e+5gSyyNnw1HXcJMzgpQ7IidgWaAdBX60+DgWovpVqCaD5+Xf jSzu5kPdErnIuEM1q0OSzamn3+vw6d7TOOvGyUUFKp6lTFo+ySqv0VmBxomEC2DBXzBCObSGfCk nDGzaeXdoeE+2yZGuP+lGn4DrEn3u6DRh60cC8VYwoudxs51Oud62sPlwnFP1ZPrzJssgsOaUAK nG90AVBaZcUUJU4k/NlMgdeYpTF/JI2yfEii3Sf90CxIrFOgwUrbTYtYUROksRFuJM5GyrtQ8fq AaOc99lytGPNWv8JtA5w5v4YipbRCs3RF2SoQZI= X-Received: by 2002:a05:600c:3b27:b0:46e:42aa:75b5 with SMTP id 5b1f17b1804b1-46e71101b0cmr73278055e9.4.1759691897899; Sun, 05 Oct 2025 12:18:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEtfpA5hhxEWDmlp5HokQo5GHK1ZtQNkdLE5uMaEZaw22Hzea9y3hl4qkbsYRR/KUPL93V3A== X-Received: by 2002:a05:600c:3b27:b0:46e:42aa:75b5 with SMTP id 5b1f17b1804b1-46e71101b0cmr73277845e9.4.1759691897283; Sun, 05 Oct 2025 12:18:17 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:15 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 60/75] amd_iommu: Use iova_tree records to determine large page size on UNMAP Message-ID: <95bc772592eb5560e9c78d313b118788ea6a3826.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692007750116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez Keep a record of mapped IOVA ranges per address space, using the iova_tree implementation. Besides enabling optimizations like avoiding unnecessary notifications, a record of existing mappings makes it possible to determine if a specific IOVA is mapped by the guest using a large page, and adjust the size when notifying UNMAP events. When unmapping a large page, the information in the guest PTE encoding the page size is lost, since the guest clears the PTE before issuing the invalidation command to the IOMMU. In such case, the size of the original mapping can be retrieved from the iova_tree and used to issue the UNMAP notification. Using the correct size is essential since the VFIO IOMMU Type1v2 driver in the host kernel will reject unmap requests that do not fully cover previous mappings. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-12-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 95 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 89 insertions(+), 6 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index caae65c4b3..4376e977f8 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -33,6 +33,7 @@ #include "hw/i386/apic-msidef.h" #include "hw/qdev-properties.h" #include "kvm/kvm_i386.h" +#include "qemu/iova-tree.h" =20 /* used AMD-Vi MMIO registers */ const char *amdvi_mmio_low[] =3D { @@ -71,6 +72,8 @@ struct AMDVIAddressSpace { IOMMUNotifierFlag notifier_flags; /* entry in list of Address spaces with registered notifiers */ QLIST_ENTRY(AMDVIAddressSpace) next; + /* Record DMA translation ranges */ + IOVATree *iova_tree; }; =20 /* AMDVI cache entry */ @@ -685,6 +688,75 @@ static uint64_t fetch_pte(AMDVIAddressSpace *as, hwadd= r address, uint64_t dte, return 0; } =20 +/* + * Invoke notifiers registered for the address space. Update record of map= ped + * ranges in IOVA Tree. + */ +static void amdvi_notify_iommu(AMDVIAddressSpace *as, IOMMUTLBEvent *event) +{ + IOMMUTLBEntry *entry =3D &event->entry; + + DMAMap target =3D { + .iova =3D entry->iova, + .size =3D entry->addr_mask, + .translated_addr =3D entry->translated_addr, + .perm =3D entry->perm, + }; + + /* + * Search the IOVA Tree for an existing translation for the target, an= d skip + * the notification if the mapping is already recorded. + * When the guest uses large pages, comparing against the record makes= it + * possible to determine the size of the original MAP and adjust the U= NMAP + * request to match it. This avoids failed checks against the mappings= kept + * by the VFIO kernel driver. + */ + const DMAMap *mapped =3D iova_tree_find(as->iova_tree, &target); + + if (event->type =3D=3D IOMMU_NOTIFIER_UNMAP) { + if (!mapped) { + /* No record exists of this mapping, nothing to do */ + return; + } + /* + * Adjust the size based on the original record. This is essential= to + * determine when large/contiguous pages are used, since the guest= has + * already cleared the PTE (erasing the pagesize encoded on it) be= fore + * issuing the invalidation command. + */ + if (mapped->size !=3D target.size) { + assert(mapped->size > target.size); + target.size =3D mapped->size; + /* Adjust event to invoke notifier with correct range */ + entry->addr_mask =3D mapped->size; + } + iova_tree_remove(as->iova_tree, target); + } else { /* IOMMU_NOTIFIER_MAP */ + if (mapped) { + /* + * If a mapping is present and matches the request, skip the + * notification. + */ + if (!memcmp(mapped, &target, sizeof(DMAMap))) { + return; + } else { + /* + * This should never happen unless a buggy guest OS omits = or + * sends incorrect invalidation(s). Report an error in the= event + * it does happen. + */ + error_report("Found conflicting translation. This could be= due " + "to an incorrect or missing invalidation comm= and"); + } + } + /* Record the new mapping */ + iova_tree_insert(as->iova_tree, &target); + } + + /* Invoke the notifiers registered for this address space */ + memory_region_notify_iommu(&as->iommu, 0, *event); +} + /* * Walk the guest page table for an IOVA and range and signal the register= ed * notifiers to sync the shadow page tables in the host. @@ -696,7 +768,7 @@ static void amdvi_sync_shadow_page_table_range(AMDVIAdd= ressSpace *as, { IOMMUTLBEvent event; =20 - hwaddr iova_next, page_mask, pagesize; + hwaddr page_mask, pagesize; hwaddr iova =3D addr; hwaddr end =3D iova + size - 1; =20 @@ -719,7 +791,6 @@ static void amdvi_sync_shadow_page_table_range(AMDVIAdd= ressSpace *as, /* PTE has been validated for major errors and pagesize is set */ assert(pagesize); page_mask =3D ~(pagesize - 1); - iova_next =3D (iova & page_mask) + pagesize; =20 if (ret =3D=3D -AMDVI_FR_PT_ENTRY_INV) { /* @@ -752,15 +823,26 @@ static void amdvi_sync_shadow_page_table_range(AMDVIA= ddressSpace *as, event.type =3D IOMMU_NOTIFIER_MAP; } =20 - /* Invoke the notifiers registered for this address space */ - memory_region_notify_iommu(&as->iommu, 0, event); + /* + * The following call might need to adjust event.entry.size in cas= es + * where the guest unmapped a series of large pages. + */ + amdvi_notify_iommu(as, &event); + /* + * In the special scenario where the guest is unmapping a large pa= ge, + * addr_mask has been adjusted before sending the notification. Up= date + * pagesize accordingly in order to correctly compute the next IOV= A. + */ + pagesize =3D event.entry.addr_mask + 1; =20 next: + iova &=3D ~(pagesize - 1); + /* Check for 64-bit overflow and terminate walk in such cases */ - if (iova_next < iova) { + if ((iova + pagesize) < iova) { break; } else { - iova =3D iova_next; + iova +=3D pagesize; } } } @@ -1845,6 +1927,7 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus= , void *opaque, int devfn) iommu_as[devfn]->devfn =3D (uint8_t)devfn; iommu_as[devfn]->iommu_state =3D s; iommu_as[devfn]->notifier_flags =3D IOMMU_NOTIFIER_NONE; + iommu_as[devfn]->iova_tree =3D iova_tree_new(); =20 amdvi_dev_as =3D iommu_as[devfn]; =20 --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692480; cv=none; d=zohomail.com; s=zohoarc; b=HwN0sDYizvlM0ZaUZhSkBLzh5m4LjxyAUVwlxj5yQxLTKbJQcXcSZlq1/8bUcMlVZ0qUkrHT9/o7wDH45Hmpr7oCZ2ZwU7+12wiwKIZlObInfdw8V4rR3QyGDn5nTlMF03wl4TEAx/+5ierI3t4jl35UMw2lH64bHgAUq3eE3mg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692480; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=23LWX8Qf1h5uWc6TSJ5v/9otVvLkJLt+t300V2hS7WI=; b=Uy3AUFF4S6kH0iosRSxCQDfRG2fNrC5zsswGe//4W8p+sN/UJbs3MvZK+aExNm6dTE9qFhbrAgXhfi4UmUI8oMTEddmRjXGTXdzY1mANBVcv7slMXLwbAiLFPICPEqdOe0rvVyitrVjDNZzsSJrkyZrpM2lFBUWmcD8/fdHpicg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692480541565.3140130856593; Sun, 5 Oct 2025 12:28:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFZ-00030Q-TT; Sun, 05 Oct 2025 15:18:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFX-0002mV-4p for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFU-0006dP-8y for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:26 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-655-DxQnO7wQPlWEFaN7QzBe0A-1; Sun, 05 Oct 2025 15:18:21 -0400 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-46e31191379so26935165e9.3 for ; Sun, 05 Oct 2025 12:18:21 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8e9780sm17261149f8f.29.2025.10.05.12.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691902; 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=23LWX8Qf1h5uWc6TSJ5v/9otVvLkJLt+t300V2hS7WI=; b=Bgn4n+9QhzhQLKueqb0IPqMXBDcUj+h0euq8/SUUstK0A9TLwHc/TmK1VBfXmY4qx37zXW Hqb4oh0b1gNLkT5Fmdnreg9wVofbpTsVX8iRpailPMeKlhAUpockuxdANvF6MQFa2eiQeI m9z+yhXT6RsY5UpKB06m59SyaVM9Qb4= X-MC-Unique: DxQnO7wQPlWEFaN7QzBe0A-1 X-Mimecast-MFC-AGG-ID: DxQnO7wQPlWEFaN7QzBe0A_1759691900 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691900; x=1760296700; 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=23LWX8Qf1h5uWc6TSJ5v/9otVvLkJLt+t300V2hS7WI=; b=X0e3JY8IyBCKOWdATyKmQ7JNQp/CpMPiijppL90Lgl/yYYTCYI08y4LargkiynDtO1 codSYR+E1o6FdRhWN++0QBZxQY7q0zgi1VauAVNJj7WqJmBdJb0g/WS3thX0kkypOXGL IT+EdFmZLAk50gmPHbrCHhAuKGLO1zPpyx/S/eDafLWIPJlDRA6UuAlLnw9Sldl1iiz7 PjOQwswEW6a2XQlJyoEooAgI6/e7xshsEv84lDnGChB9X8D3oYwA3zZaAyhyugD7mFp9 Nei9Mvf76m1mfH1a9d7H6brvXmgJRt1ztFUqz78JqpUs/sBEsTzp7HLYuAs9NcGEZ/b+ lkHw== X-Gm-Message-State: AOJu0YzGnpPXdfqsP0zN30T8HgLlQPZnrfKrf7SZREHUb0pzsZwLt8b/ 0zJFGITfD2pK0vzm9O/VdVSM5Gr5bwKqDTES4nrq/gbInJp4cjkqC/Du9WysnwxzHnD588+K02z 02PMigJmFHTxvHS63X2WlJeH8p3c2zvWTA8/4Incu8j/kvWkOh571RvC+XbHbvGxWxNV1cWMd33 BK7ehoLBGltZhHlPzcIjXiX51KaNGPGxq/uQ== X-Gm-Gg: ASbGnctr4tSTIeBSBIkzmkBOAS78YbHrplG5KF8ZXltwkMdHZHVNsaLFf/3K1uCpUJ+ bzRWWTFzOdK9tA8SqpKmm7SgTwCzwT9cVZdopLp78llQHDO2D0aXxb9EFC5K+Br/2KWjvcmxsVa 0LvIbpQzgQHXeFYo3TTfE3BVnU0LKMadzfD6kam+X2mGMGG+/NGPX5JM1E1WVtcUy7Y5K38mxij zfAdlGX2P5xO0g3Oo9rh7p4QyqVEqcnfRdZJsqiRjtOfQU5nj2O3ErG1XGDc7oy0/+1e9X2qxs+ EQWB5NA6mam14UZjCaEBcCuanCqNBxXhmBp1GMU= X-Received: by 2002:a05:600c:8506:b0:46e:1fb9:5497 with SMTP id 5b1f17b1804b1-46e7113f6e2mr72103915e9.18.1759691899831; Sun, 05 Oct 2025 12:18:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7+wSypRsjnnvOqhBiK7Zp4NlVB8/bPJEr1L6RKBqSEZRxSa16BQiei4vXxjYNkxZ913eWcw== X-Received: by 2002:a05:600c:8506:b0:46e:1fb9:5497 with SMTP id 5b1f17b1804b1-46e7113f6e2mr72103755e9.18.1759691899285; Sun, 05 Oct 2025 12:18:19 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:17 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 61/75] amd_iommu: Unmap all address spaces under the AMD IOMMU on reset Message-ID: <53fb70ad6219bd2b3ed17e2b87ceab722e69d5b9.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692491865116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez Support dropping all existing mappings on reset. When the guest kernel reboots it will create new ones, but other components that run before the kernel (e.g. OVMF) should not be able to use existing mappings from the previous boot. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-13-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 4376e977f8..497f18c540 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -847,6 +847,77 @@ next: } } =20 +/* + * Unmap entire range that the notifier registered for i.e. the full AS. + * + * This is seemingly technically equivalent to directly calling + * memory_region_unmap_iommu_notifier_range(), but it allows to check for + * notifier boundaries and issue notifications with ranges within those bo= unds. + */ +static void amdvi_address_space_unmap(AMDVIAddressSpace *as, IOMMUNotifier= *n) +{ + + hwaddr start =3D n->start; + hwaddr end =3D n->end; + hwaddr remain; + DMAMap map; + + assert(start <=3D end); + remain =3D end - start + 1; + + /* + * Divide the notifier range into chunks that are aligned and do not e= xceed + * the notifier boundaries. + */ + while (remain >=3D AMDVI_PAGE_SIZE) { + + IOMMUTLBEvent event; + + uint64_t mask =3D dma_aligned_pow2_mask(start, end, 64); + + event.type =3D IOMMU_NOTIFIER_UNMAP; + + IOMMUTLBEntry entry =3D { + .target_as =3D &address_space_memory, + .iova =3D start, + .translated_addr =3D 0, /* irrelevant for unmap case */ + .addr_mask =3D mask, + .perm =3D IOMMU_NONE, + }; + event.entry =3D entry; + + /* Call notifier registered for updates on this address space */ + memory_region_notify_iommu_one(n, &event); + + start +=3D mask + 1; + remain -=3D mask + 1; + } + + assert(!remain); + + map.iova =3D n->start; + map.size =3D n->end - n->start; + + iova_tree_remove(as->iova_tree, map); +} + +/* + * For all the address spaces with notifiers registered, unmap the entire = range + * the notifier registered for i.e. clear all the address spaces managed b= y the + * IOMMU. + */ +static void amdvi_address_space_unmap_all(AMDVIState *s) +{ + AMDVIAddressSpace *as; + IOMMUNotifier *n; + + QLIST_FOREACH(as, &s->amdvi_as_with_notifiers, next) { + IOMMU_NOTIFIER_FOREACH(n, &as->iommu) { + amdvi_address_space_unmap(as, n); + } + } +} + /* log error without aborting since linux seems to be using reserved bits = */ static void amdvi_inval_devtab_entry(AMDVIState *s, uint64_t *cmd) { @@ -2099,6 +2170,9 @@ static void amdvi_sysbus_reset(DeviceState *dev) =20 msi_reset(&s->pci->dev); amdvi_init(s); + + /* Discard all mappings on device reset */ + amdvi_address_space_unmap_all(s); } =20 static const VMStateDescription vmstate_amdvi_sysbus_migratable =3D { --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692421; cv=none; d=zohomail.com; s=zohoarc; b=KKVujeCSOSPvQuQIqva5zt+qy4AW3mRd6IwMGKue5GmKt78mtU3q+B8crGYzfuBJUVks57OANFt+eWifHhdpQdkKujHsoVjpxKUHVmCxKN1oawKeghyCKGlj/YRBTDaF2xY5dSDq6Hz+QA5I1g6WSIo12JHtTE20t+4HGEFtIHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692421; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Dvq3Htrv0viX4ei8ZfWqc/K5pFXyFBAcjRUr9cMuaQ4=; b=BAOB6D6mE6+Ek8SJqaTSwq/l2jyH8cOK2oYZBiX/rMIHqelgXrW7si1qrRO/MY2UHQmSgbz0SlH7XEO4+We2vF5bZpWwFSDHjdn3NBJdtCkqgCTEmPx3NrkBanl9wjUdaTrZfPuaShn5YOGzKTsDKy3SE0EkFvyDV8FJPZ7zeeA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692421021816.2963528708294; Sun, 5 Oct 2025 12:27:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFi-00042m-Vb; Sun, 05 Oct 2025 15:18: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 1v5UFY-0002pd-Qp for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFV-0006df-FO for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:27 -0400 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-528-Kug0meQwPF6_ZLLJb1cA3Q-1; Sun, 05 Oct 2025 15:18:23 -0400 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-3ee12ab7f33so2159591f8f.2 for ; Sun, 05 Oct 2025 12:18:23 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8a8542sm17441162f8f.9.2025.10.05.12.18.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691904; 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=Dvq3Htrv0viX4ei8ZfWqc/K5pFXyFBAcjRUr9cMuaQ4=; b=AwOyZXJclPSUTRap9crgLl5ZSd4Ftsr75S8auKPlAzFL1ISY13tkbreR8VL35rVq/H/cJx DYWRE3Q6l1tQmAdPh3QzAuHbrKlzNS8HemERmbk/xlG8b/oLfTOlfY2M848Nn6+q7PEW7T 7D8a3tS8vk28hLtIyM+4s0DW7ZTLD1k= X-MC-Unique: Kug0meQwPF6_ZLLJb1cA3Q-1 X-Mimecast-MFC-AGG-ID: Kug0meQwPF6_ZLLJb1cA3Q_1759691902 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691902; x=1760296702; 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=Dvq3Htrv0viX4ei8ZfWqc/K5pFXyFBAcjRUr9cMuaQ4=; b=VWTZLZiD5qhhu4ELS8htmaTMn7reb1m7MndTwJpTebBTfY3hHn1JYWR+FzbDM88HLI a9yYU68mmVy673sPdNBtHNVDC6ttCxAhq6k8AEL8J7SdxAii2lAqS5qmr2vKUkPEQ4BO IjQiM3/8eAQ2ovtqu9q0AgkVJLdymf6iKpwj8QNnwPWv8n+wFwZhsGzp6sbSJC6dZohx Hc9X5SwwXuKaw6MySgA1oNRpKU6pQHjpg7gdTTQY5DSOoi2hQO9lwRGrAtcUVG7ec7h1 t8E6HL+OcvtM3MCIRDkhFCOJYF9OOSsQaC3d7NlU9WNQp65TH5ytganwCImITKprH071 G1ug== X-Gm-Message-State: AOJu0Yz36kuKGQK/a0ZQsZUIIOjYZEOlKXYj8F2WOYalvrsASvAkcgHu EERO5v/WWe3vbmvDjAKWyz0m/Q9StWQbK9WC2ePCEYBQvrJvUIVu1bJwN0Q/cD6suK+G77ULnRm ZKgFLQ7EJaDvMYIaHMfg1ZdEBeuAZUc6oZNzzhu9/XFBneE9NuHVin0K9fyDN9L5qOqhy8WWCrK u1LpYQpXo3hCF6rbxl2QpX2AlGb2VeDGWngg== X-Gm-Gg: ASbGnct8Y4Sogkz7MvEYDoSg12ejL9JbcHsxrfpsNyDetQQNOWeVgBkrSGt80J/4asg 0cd9OPwbLO3HLm2IF53BHa/oWYno1TD0VeJvrKwwOm1YF9EbbOqgoCEZoKoHqUnEoHj+OzMMA0J ioQXQCWmEPO3s99rSzqW7V5F2YmbWXX9bYsGBQ+TLeBJH0TixAp5IknGMdJ4nQk4uYGS6zleN2J SC6A+NzUjiB4kYwjLUMmQr/cb+Q3sBpxeCbxALCNHWnd9szfNwxIZuHxt5Ydgyo+p1gV1h7nNsV PkqnpM40btwjk/HWs2BRmZ97FiPBAhLT6+5bAZU= X-Received: by 2002:a05:6000:1acb:b0:3c8:d236:26bd with SMTP id ffacd0b85a97d-42567137c0amr6933064f8f.11.1759691901792; Sun, 05 Oct 2025 12:18:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJ1n0m53fa/ZPX2yn+NfRq6JZVp0siYDgYth0kFh1N4JL3vbSVdFYEQKmrnqoDnJbhXAKFlA== X-Received: by 2002:a05:6000:1acb:b0:3c8:d236:26bd with SMTP id ffacd0b85a97d-42567137c0amr6933046f8f.11.1759691901244; Sun, 05 Oct 2025 12:18:21 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:19 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 62/75] amd_iommu: Add replay callback Message-ID: <20365b0fd2aa349f16c409638b2d99d7b478057a.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692424749116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez A replay() method is necessary to efficiently synchronize the host page tables after VFIO registers a notifier for IOMMU events. It is called to ensure that existing mappings from an IOMMU memory region are "replayed" to a specified notifier, initializing or updating the shadow page tables on the host. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-14-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 497f18c540..9027f7c054 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -918,6 +918,29 @@ static void amdvi_address_space_unmap_all(AMDVIState *= s) } } =20 +/* + * For every translation present in the IOMMU, construct IOMMUTLBEntry data + * and pass it as parameter to notifier callback. + */ +static void amdvi_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier = *n) +{ + AMDVIAddressSpace *as =3D container_of(iommu_mr, AMDVIAddressSpace, io= mmu); + uint64_t dte[4] =3D { 0 }; + + if (!(n->notifier_flags & IOMMU_NOTIFIER_MAP)) { + return; + } + + if (amdvi_as_to_dte(as, dte)) { + return; + } + + /* Dropping all mappings for the address space. Also clears the IOVA t= ree */ + amdvi_address_space_unmap(as, n); + + amdvi_sync_shadow_page_table_range(as, &dte[0], 0, UINT64_MAX, false); +} + /* log error without aborting since linux seems to be using reserved bits = */ static void amdvi_inval_devtab_entry(AMDVIState *s, uint64_t *cmd) { @@ -2364,6 +2387,7 @@ static void amdvi_iommu_memory_region_class_init(Obje= ctClass *klass, =20 imrc->translate =3D amdvi_translate; imrc->notify_flag_changed =3D amdvi_iommu_notify_flag_changed; + imrc->replay =3D amdvi_iommu_replay; } =20 static const TypeInfo amdvi_iommu_memory_region_info =3D { --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692405; cv=none; d=zohomail.com; s=zohoarc; b=k509QC88XWd+Utck94rTtbZRXlFk3Jwaka0bGlNHTpKWxY94htzVCGrGpigda4GrVAoua4IeQJNVOrD0z7TsxbaBb94MaPgQhsERkvtMZBvaKkxgNjAYq6y1r4qjhW73RaMhgkb3nXYGmN6vLu32kekSAf+qPBsTBVQVa0hlxEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692405; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7VfnG8rVkzTSwB5pyBpyj7JN89vPRfbgI61K8aW5ts8=; b=M5MJyAZWvXHS3UDx2vdxIjGoyE8PouC0kChyIfftoVEO4XLmyWJ/CP86yWrjSXel8R0cv9y/5Hg8jleI64NPeZSHffVuZxnP0FPVZP9IOQuQSUeJOuHJqbjM8R8TjsTnVMmXiCiHqDopKhqD08xHmE1ZlU7GXjLsF9WZMuBjFo4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692405966190.30405401641906; Sun, 5 Oct 2025 12:26:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UFg-0003hD-Ue; Sun, 05 Oct 2025 15:18:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFa-00036k-Fc for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18: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 1v5UFX-0006e1-G4 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:30 -0400 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-532-KiecCtItOUumD0y_oIvSlg-1; Sun, 05 Oct 2025 15:18:25 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4256fae4b46so848999f8f.0 for ; Sun, 05 Oct 2025 12:18:25 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e61a4161bsm234336385e9.16.2025.10.05.12.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691906; 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=7VfnG8rVkzTSwB5pyBpyj7JN89vPRfbgI61K8aW5ts8=; b=T6c2mqjvh/ZlvSfAPKkKmVTckjTEM9qlnfPhI67h12r091ez+nI8sdjNdTDMjcu5hY1dJz Y93W0xCHpCqDXtMwHD3XFmcmd2hO9XrTWjSiAUudojlGj2NHS2VVFj6ouFWPlHPoY3S9zq qpBlaXdGG/eEhdFOzEnUPZ0zacBFMuo= X-MC-Unique: KiecCtItOUumD0y_oIvSlg-1 X-Mimecast-MFC-AGG-ID: KiecCtItOUumD0y_oIvSlg_1759691904 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691904; x=1760296704; 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=7VfnG8rVkzTSwB5pyBpyj7JN89vPRfbgI61K8aW5ts8=; b=J6aSoA5fhIBVhTsnhUhNN3xDslUwDBrDMwBcvH6Q5g/ppmntGC3wWXGEEfEnKduMN3 NkXeQYw9PGVcUD7SXDIFE/JaLo1k5Bq4mKphr2oMqJdoBfMVBHpX8o+cmYQzfNw3wjTi dchj+dKAFeJHn69T00/p0Qa0KeGVDd7n3lLwdqpduuUcPSzaaCq1KpjpesS4BR3soA1m HFRe5aL9b6cRouPDu5spIUJLrFmV3XwsfRVyxbctgxx3f9kkiou3JHa8LguVLCl1hpNI EdBHanBMsk0qz6J+226OED+aLJzecG8P4v2MCyDku/qP9QSw89fMdpGYcJebtVJ1gd3s u2Hw== X-Gm-Message-State: AOJu0YyG9JriEOslw7J5am32JBNHxZezoYCpBJNVqXdWdflIODwaUasI DMbpJtL085/aTU4Zypyi7bmSjedFbFR/Tj1VxBeUK5RBo1yuR0hIGXj6BtfWNalb+hRRz6OmzTD pvdZYKXV+VIe/0pqLAkWIIbi5rvYls6YVd6nF/jJUaXmz5sWz0R3TIDr9QGG9DvEz64AgRs7pWt CiZlqQn/Nzma8pi/IeElWKbf7wT3leG++rnQ== X-Gm-Gg: ASbGncuMXg4qYZxiH1fSuf9jr4hJ/6ABkf/HqVt7/uZz3FWnrGl+AnTzIRrYUlCl4rC p2XfZfHkVmQCnSANmQXdV1bZLS3EPiMi/1Mi1n2sLP8Iz8dw/rHX1x3ysNu8+FAgtbjppt9IP1v pWaQCtwENTx6Jg2kSqVjJGgCKzqFHKHmvq/czwasA0slbs8uyLtaPEK1gZMq3RJ7RfN0xBsisFV 32SdQkH/rPdh34PX6TtsFoVIvY0oMzou5Ere0/dePWN3seLcxIEHoXxILn8reo4ysVMWJ3+yy57 6pE6QOMBaNGKeNSEy2kF7usDRzDhSctH6oxT+5M= X-Received: by 2002:a05:600c:64c4:b0:46d:45e:3514 with SMTP id 5b1f17b1804b1-46e7114310amr81618325e9.17.1759691903992; Sun, 05 Oct 2025 12:18:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYy9J2pPqOK7HUQemuxKAFiedY9kKOHYQvCRO2hjIuJOlpQcg9wOAEEzEGXZMHC62Z6SL8Zw== X-Received: by 2002:a05:600c:64c4:b0:46d:45e:3514 with SMTP id 5b1f17b1804b1-46e7114310amr81618115e9.17.1759691903388; Sun, 05 Oct 2025 12:18:23 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 63/75] amd_iommu: Invalidate address translations on INVALIDATE_IOMMU_ALL Message-ID: <560e604db9d55a1d7fde5a8b6de001367b8376f8.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692408485116601 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez When the kernel IOMMU driver issues an INVALIDATE_IOMMU_ALL, the address translation and interrupt remapping information must be cleared for all Device IDs and all domains. Introduce a helper to sync the shadow page table for all the address spaces with registered notifiers, which replays both MAP and UNMAP events. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-15-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 9027f7c054..d74d42b3dd 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -941,6 +941,47 @@ static void amdvi_iommu_replay(IOMMUMemoryRegion *iomm= u_mr, IOMMUNotifier *n) amdvi_sync_shadow_page_table_range(as, &dte[0], 0, UINT64_MAX, false); } =20 +static void amdvi_address_space_sync(AMDVIAddressSpace *as) +{ + IOMMUNotifier *n; + uint64_t dte[4] =3D { 0 }; + + /* If only UNMAP notifiers are registered, drop all existing mappings = */ + if (!(as->notifier_flags & IOMMU_NOTIFIER_MAP)) { + IOMMU_NOTIFIER_FOREACH(n, &as->iommu) { + /* + * Directly calling memory_region_unmap_iommu_notifier_range()= does + * not guarantee that the addr_mask eventually passed as param= eter + * to the notifier is valid. Use amdvi_address_space_unmap() w= hich + * ensures the notifier range is divided into properly aligned + * regions, and issues notifications for each one. + */ + amdvi_address_space_unmap(as, n); + } + return; + } + + if (amdvi_as_to_dte(as, dte)) { + return; + } + + amdvi_sync_shadow_page_table_range(as, &dte[0], 0, UINT64_MAX, true); +} + +/* + * This differs from the replay() method in that it issues both MAP and UN= MAP + * notifications since it is called after global invalidation events in or= der to + * re-sync all address spaces. + */ +static void amdvi_iommu_address_space_sync_all(AMDVIState *s) +{ + AMDVIAddressSpace *as; + + QLIST_FOREACH(as, &s->amdvi_as_with_notifiers, next) { + amdvi_address_space_sync(as); + } +} + /* log error without aborting since linux seems to be using reserved bits = */ static void amdvi_inval_devtab_entry(AMDVIState *s, uint64_t *cmd) { @@ -983,6 +1024,13 @@ static void amdvi_inval_all(AMDVIState *s, uint64_t *= cmd) amdvi_intremap_inval_notify_all(s, true, 0, 0); =20 amdvi_iotlb_reset(s); + + /* + * Fully replay the address space i.e. send both UNMAP and MAP events = in + * order to synchronize guest and host IO page tables tables. + */ + amdvi_iommu_address_space_sync_all(s); + trace_amdvi_all_inval(); } =20 --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692158; cv=none; d=zohomail.com; s=zohoarc; b=SNL59zp3fKRsJnSrAJwr7EJZqpCx+93wyxfA0EJjLizaSHJeQFpNdokb9ODcxjw0t66MOtpTtcsgTYpnUVLnEtkGF+/NhIFykfOUuEoO+PmykTdHfPXQMw2SXQR27kbzsxZPSLucJBJhl7lhG9aLNOTNKfGMIuWguol0CEpQUec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692158; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GAfEAfK1eJRI4y+l49JKxdN48bM3wTU5KpeG8sWwPz0=; b=O9VehJJvg/ZOFl/Mw+1OxuhheFO2LgNZHD2eCZEJZ0Auz3nwF/L5fYog9NRMaEldaIrODlD60gssKaFc+m9Lf/Zo8C3HmWHbm5oFJd2rvOeS7mMruFqPeHUYx8u+iBzpxOzMAjD9qQSCaUUENM1R/RZSMLdul8IxjYJUrJOlaso= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692158257689.6431044300735; Sun, 5 Oct 2025 12:22:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UGB-0005D3-Gl; Sun, 05 Oct 2025 15:19: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 1v5UFc-0003J0-AW for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:32 -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 1v5UFa-0006ea-40 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:31 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-1YW-cOrWOca1WXvQZoLvNQ-1; Sun, 05 Oct 2025 15:18:28 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46e3e177893so22926425e9.2 for ; Sun, 05 Oct 2025 12:18:27 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f45e9sm17826290f8f.51.2025.10.05.12.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691909; 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=GAfEAfK1eJRI4y+l49JKxdN48bM3wTU5KpeG8sWwPz0=; b=K6kxiPsL+Owij3wb/iYmeZ9wLEBUizuqm3kczLbpNk6D84oQJ43I0cuqCm+bfsa8jo1/m6 FXPiyniXvqG24Q4a9Ki9oPLvLnoQdX5PNa4TyjiloaaetnLWoANF2KpWQk7YjBtfgB1Z4f Axt0d8Q/7PhTeiYhbRUXMYrZdr+syLA= X-MC-Unique: 1YW-cOrWOca1WXvQZoLvNQ-1 X-Mimecast-MFC-AGG-ID: 1YW-cOrWOca1WXvQZoLvNQ_1759691907 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691907; x=1760296707; 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=GAfEAfK1eJRI4y+l49JKxdN48bM3wTU5KpeG8sWwPz0=; b=WuVGEwkQIPxkAWsIs81wnzSFdTufh5E5XK75BGi5NoHNcTh0tb3Xd6XPuO7YgSnWMu 1L9n1jb6nTjUxezyC7kBwRVcEFzE9rCXlyZ3fpC0+9kcxYyhRuM/5YZgP/0MKBGqGIfQ uM0BZrEoheenSGNnaowLe9bBroQL8CjWhRpd3xEPFMrRAf2OKtFaWEwtL2/W1/tRGuyq FYlzsNCD+ibLI2742/ivUvZIDBWqrBI4tNj/HRaNrxn6FabhctPa13BzIh+bOqAVS6Im tvp2zZCdcG3xqE1QbdHJ5nRRWsjL7b2QhmpQAy1RXWFG0WYU/mLUEIXpZl5IK3zEXjxy ZPKw== X-Gm-Message-State: AOJu0YzS8K5xed/2KMarbLWZM3h6CibWK7+ws3Uso6u7yzH3O2LIVs6l PQ1ZmJ8sqUsQhoyibaSaQiCNvVz37n2T7CaXQ3M3lGok+Smp8KmBsuiK+pPvV3JXZ8Xg41haMr+ JEh21ChFwieBdFg71ftpmAl9FeIyegvNlZY8bCdjAUW9LicK9owB7nI8PztnOjb+7x9rE+OhC0g zvHtDNXOlPuVoi3RcH12Xd+kbMVuv5KmTceA== X-Gm-Gg: ASbGncsC52uyjYl82Q7ABg+T2SqI848lm1YGjVOKhjFUXeXECaPJZsIVRegjpugzGdW qHNBviHXmXDk8Bwqrfds+/dCR8ygmr/KjMEeWrPAlsw6VJjdjf/poRCTYcmWxK91MhfYFH0fTbP s31DAq0qQ2Pjo0tETIlkYfdGm2pA3tc0kHnkNFKyXd6xS+yyTxC/kFRA0BoFkIGAfBVhWxiHK8b QDNVbj+OPsLy87y7LuyzTRpCfT+EmCxo+fHFFifOGxu5Cbzcji1i2A1NsMlO5SW7mG9FseESM2+ L0BwMH4VPRtWlwFw5+Qv9iWsiu6wx3L3/LwV4k0= X-Received: by 2002:a05:600c:4e0e:b0:46e:5df3:190d with SMTP id 5b1f17b1804b1-46f9d694446mr4446805e9.11.1759691906550; Sun, 05 Oct 2025 12:18:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwAiE/GhgIC5s9WAyAruzTtPbjdNa4Zo+puE0+Wr3p5V9yqU3sznEJbYynSmdoE4ZP5H6F5g== X-Received: by 2002:a05:600c:4e0e:b0:46e:5df3:190d with SMTP id 5b1f17b1804b1-46f9d694446mr4446655e9.11.1759691906014; Sun, 05 Oct 2025 12:18:26 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:23 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 64/75] amd_iommu: Toggle memory regions based on address translation mode Message-ID: <75fd28e3a754487a675a094cf9990a60437d8167.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692166931116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez Enable the appropriate memory region for an address space depending on the address translation mode selected for it. This is currently based on a generic x86 IOMMU property, and only done during the address space initialization. Extract the code into a helper and toggle the regions based on whether the specific address space is using address translation (via the newly introduced addr_translation field). Later, region activation will also be controlled by availability of DMA remapping capability (via dma-remap property to be introduced in follow up changes). Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-16-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index d74d42b3dd..67a26f5247 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -74,6 +74,8 @@ struct AMDVIAddressSpace { QLIST_ENTRY(AMDVIAddressSpace) next; /* Record DMA translation ranges */ IOVATree *iova_tree; + /* DMA address translation active */ + bool addr_translation; }; =20 /* AMDVI cache entry */ @@ -982,6 +984,23 @@ static void amdvi_iommu_address_space_sync_all(AMDVISt= ate *s) } } =20 +/* + * Toggle between address translation and passthrough modes by enabling the + * corresponding memory regions. + */ +static void amdvi_switch_address_space(AMDVIAddressSpace *amdvi_as) +{ + if (amdvi_as->addr_translation) { + /* Enabling DMA region */ + memory_region_set_enabled(&amdvi_as->iommu_nodma, false); + memory_region_set_enabled(MEMORY_REGION(&amdvi_as->iommu), true); + } else { + /* Disabling DMA region, using passthrough */ + memory_region_set_enabled(MEMORY_REGION(&amdvi_as->iommu), false); + memory_region_set_enabled(&amdvi_as->iommu_nodma, true); + } +} + /* log error without aborting since linux seems to be using reserved bits = */ static void amdvi_inval_devtab_entry(AMDVIState *s, uint64_t *cmd) { @@ -2070,6 +2089,7 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus= , void *opaque, int devfn) iommu_as[devfn]->iommu_state =3D s; iommu_as[devfn]->notifier_flags =3D IOMMU_NOTIFIER_NONE; iommu_as[devfn]->iova_tree =3D iova_tree_new(); + iommu_as[devfn]->addr_translation =3D false; =20 amdvi_dev_as =3D iommu_as[devfn]; =20 @@ -2112,8 +2132,7 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus= , void *opaque, int devfn) AMDVI_INT_ADDR_FIRST, &amdvi_dev_as->iommu_ir, 1); =20 - memory_region_set_enabled(&amdvi_dev_as->iommu_nodma, false); - memory_region_set_enabled(MEMORY_REGION(&amdvi_dev_as->iommu), tru= e); + amdvi_switch_address_space(amdvi_dev_as); } return &iommu_as[devfn]->as; } --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692029; cv=none; d=zohomail.com; s=zohoarc; b=dVWyrBDw3sNF/vb2e8FWuRMSALl0axeWyb/c9Ftg3A/chAAftk6MPZ1KxpQ0/474X2cVzI/tJ4bcVz89JFKyHXRFxa9DefiBiHSrSOeke2YOgsM0RtTfwtZrx/8NcVR7RXooAi9iqtfSTpWWbDrodZIA8oMk32GpgXgSGspbDys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692029; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cqvqByI4LKiqbM55WODj4LD+2eo55Kp0F3DJM0/qKGQ=; b=LmTJNLfMdVnClSUYL3vkdrEgONSrpD9az2prMyuS0ynQbV2hcqfaywsglUEjDGWpMzWNxCd0KNSYLt8EEZdKWSrjHsNmcFlTFAZJsVKegsXUMqsgvmnIdfrsAPkd+XQ8i8GuWe0J6FsxmpE0CS4SIQn5B0LdFSLxfvkeDmQDG9k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692029864415.0384809467456; Sun, 5 Oct 2025 12:20:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UGM-0005fs-T9; Sun, 05 Oct 2025 15:19:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFk-0004Nd-UG for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFd-0006ev-Le for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:39 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-458-yW7lBNAaP6-T4LcDL2dA9w-1; Sun, 05 Oct 2025 15:18:30 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-46e3ef2dd66so20873185e9.1 for ; Sun, 05 Oct 2025 12:18:29 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e619c396esm221391005e9.8.2025.10.05.12.18.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691912; 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=cqvqByI4LKiqbM55WODj4LD+2eo55Kp0F3DJM0/qKGQ=; b=g2Ab/zaFfLgZONTm2/OsoR8YQyqkHoX7sTVXd9Rqq745LHQwecjzcIrgBWEdbON+GpJ1T7 cVKtnA+cRdb1XAh/AaYAnCPtDJHyqM/IJx+9oXFts9v72Dr+DolNdz5q+mUlhdtd5qpY2e wsS6wb+Y4BJE31RfuPvMDFewG32y0q8= X-MC-Unique: yW7lBNAaP6-T4LcDL2dA9w-1 X-Mimecast-MFC-AGG-ID: yW7lBNAaP6-T4LcDL2dA9w_1759691909 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691908; x=1760296708; 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=cqvqByI4LKiqbM55WODj4LD+2eo55Kp0F3DJM0/qKGQ=; b=IbFz2m/4qWOtuAXamFMXOJ4zTCizfI41SvvShqWDPPDyvpwaM5XRFwNZfGE0LsCPDE 6Z8unqFR+iWu5LDxO5VN/p18ipGbBex5yki5/Qtu4e9DY46mcKZIbcdSB4zE58rzl2q2 jBaokJ0jzmtvjmuyh15Q+pm0bMHBqGXHn5tqNgAK3YDDQMg8epEmU0QqhQ1efjtHq9IN 43LD3qkeoyEl3rJssNSEzgxl/Q39lionXcOgIucy4SkND7sE6VaVO1VwgoHbbbidxxhb UWCuaAu4PqaYp6QIrlzdGLqjjPqamaxOyLl69/zHGFq9W3YA1MCFEQ7BXAguyxN7tRgx P+OA== X-Gm-Message-State: AOJu0Yz581xXs6WoIZfacO+/YtkIm+PMJ4H4bhPlprUt1YydYmgFQnVx UlZIIGOmwqCt6vnyMA2MqUrZ05xylrBNs2t1z5HRwjmFe2E/5nZXSIp+U72hUuDh2tP/JpbehG4 D0PsizE8dazvYr52PDU2MA+chFD8E4Dry1U9ycOdTmfBBKcXqMpMR5QNuymRbTTPltvAoUcAfbL tvBXBx0ssmhzZLe1kror1cpRFuYx0uxjD7vQ== X-Gm-Gg: ASbGncv/6VxskMaJ42/g/aKPFc+Tps37R9blr1uojAwRG/T5BrbTWPLPDw3ON9AR4e/ nvrt+g0jbVDLdp+Orz2KjooE5IfJGSm8yJSgsK96s+1wR1j3xu5PaqTRz39l/NrlYymZw5HDyHo 95YN3tKupKR8Rht8Qb1B61g7yncNxBA1MmtUdpi3D0ixcQEnQbyR4jP1FM6dtsWcE3pj3Pr/FSi 23455WmKTxDZoaULPDW4TRAhYy5by6f+1YS4TPn+nZ34bKecnetg+Xes1xPrJee4HER9x3nivYu P0iss46iJl/tJEXZ6AheRtYj/spAWHyRKQbNBLQ= X-Received: by 2002:a05:600d:108:20b0:46e:1a60:c995 with SMTP id 5b1f17b1804b1-46e71033bf4mr55338325e9.2.1759691908542; Sun, 05 Oct 2025 12:18:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEXM5ThzT9F3Bt0Kyl4IRRYPnCi1ex6cMqqDPYtHiGoMR9y45az16Yu2GgKAfLKMuYF8rzygg== X-Received: by 2002:a05:600d:108:20b0:46e:1a60:c995 with SMTP id 5b1f17b1804b1-46e71033bf4mr55338175e9.2.1759691907934; Sun, 05 Oct 2025 12:18:27 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:26 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 65/75] amd_iommu: Set all address spaces to use passthrough mode on reset Message-ID: <42d1e7b5d2ec3eacb121138a9b5201b0ed4ee5ae.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692033004116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez On reset, restore the default address translation mode (passthrough) for all the address spaces managed by the vIOMMU. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-17-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 67a26f5247..e9ce7b46e8 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1001,6 +1001,35 @@ static void amdvi_switch_address_space(AMDVIAddressS= pace *amdvi_as) } } =20 +/* + * For all existing address spaces managed by the IOMMU, enable/disable the + * corresponding memory regions to reset the address translation mode and + * use passthrough by default. + */ +static void amdvi_reset_address_translation_all(AMDVIState *s) +{ + AMDVIAddressSpace **iommu_as; + + for (int bus_num =3D 0; bus_num < PCI_BUS_MAX; bus_num++) { + + /* Nothing to do if there are no devices on the current bus */ + if (!s->address_spaces[bus_num]) { + continue; + } + iommu_as =3D s->address_spaces[bus_num]; + + for (int devfn =3D 0; devfn < PCI_DEVFN_MAX; devfn++) { + + if (!iommu_as[devfn]) { + continue; + } + /* Use passthrough as default mode after reset */ + iommu_as[devfn]->addr_translation =3D false; + amdvi_switch_address_space(iommu_as[devfn]); + } + } +} + /* log error without aborting since linux seems to be using reserved bits = */ static void amdvi_inval_devtab_entry(AMDVIState *s, uint64_t *cmd) { @@ -2263,6 +2292,7 @@ static void amdvi_sysbus_reset(DeviceState *dev) =20 /* Discard all mappings on device reset */ amdvi_address_space_unmap_all(s); + amdvi_reset_address_translation_all(s); } =20 static const VMStateDescription vmstate_amdvi_sysbus_migratable =3D { --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692154; cv=none; d=zohomail.com; s=zohoarc; b=PbrpiqckmpGApgXT9jA8JZgUpBEaIOEBh2NWab9G3eNMV27bw/nB7JbWw7jtV6bTGCvj8kgSKdrjv2Wbb/eQzmB5v8d4uMUjLZ+JJ/JSpSO0Rr009qewS8DEGhPcwHfwhW//xhpHWwnLqQkoZuTqSARVaiNTIzlIxvr2A/6yw7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692154; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9vjWwtD4aooS8gd5dv5Dc5knrdpDrnJ6iJ12o3b9lhw=; b=jFQuHz/aB5bcGDPairHUNTpo+23UVElw7gGRjmCPYRTJPUDawuOdSS6/UcAqK5Q7yxawkqIC1rJFYQ0/ZG6U1veg0kdL4P627x76F3y0dQjrmi1l56vkAoCeqBXs1u3+1c/QNGnoccnuyHmougX5MGWEutSODHmd+t5kfw3S2M0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692154704118.20218990683804; Sun, 5 Oct 2025 12:22:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UGV-0006Kb-Hh; Sun, 05 Oct 2025 15:19:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFi-00042y-QS for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFe-0006f0-Lv for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:38 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-253-Pojk_GhzMKOhBj9UcLsb0w-1; Sun, 05 Oct 2025 15:18:32 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e4fa584e7so16710975e9.0 for ; Sun, 05 Oct 2025 12:18:31 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e7234f547sm131260915e9.9.2025.10.05.12.18.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691913; 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=9vjWwtD4aooS8gd5dv5Dc5knrdpDrnJ6iJ12o3b9lhw=; b=cfyupdR/q/+WYyTsg2lzdcpg6l49gNYlzoWG5QNRWNR2UuONPVLilF2IDyLJImEvICP9Pm hwmgzZEYbjiNMHBVDV214zylp/5uQVz7EFvwIJOxZKadqE6FxfpdG65kX2PSebs2Sk4sxt NuKLSDelymitXYEL5k0aVngu/N8oHGw= X-MC-Unique: Pojk_GhzMKOhBj9UcLsb0w-1 X-Mimecast-MFC-AGG-ID: Pojk_GhzMKOhBj9UcLsb0w_1759691911 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691911; x=1760296711; 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=9vjWwtD4aooS8gd5dv5Dc5knrdpDrnJ6iJ12o3b9lhw=; b=BGgDlJr1/mySpOldiHZyowE/hAAg1+IJn9PGKLzqJk7au28S8diQcNIUl+xF8lqXfA bdh3bUm3xTQP+jkbGAg1Rr6xwKGYzQQbRjSh23Hl0xM/2N4nJPOtNEsLDFilK3+VYf32 wmQ+K4Q+TeP6QcfP7QmeE9Q4cEXWOB4w7daMOzZ8vh0NmtX6dT9wLzpndpvDbDmmFHeS E39Tm8puJMXqz0IBXcUi41jDBUR4uO5GpSjTNE4fRs6VLoNwwWBf0CiP4sw248tbZKde blKTbAZxX1gyirvStTIvG/O3lb9maUefRr7GRxrMRCX4siZDkVI1CJu9WKWzpy4pTPSO Ztlg== X-Gm-Message-State: AOJu0YxUOdtcTJYM5dm/gQoqa2jiSxM38ihlpo/gtsufy6UT3DakNNsc 9hf8S07HrOGUTmOG5CkG6QGMsvRHRn8IVD+qj0A/YltPLhNSkiGjv0GS4AwnYwO3kKm8M8QXQ/m 1e0VloXESmT6eLwliwypiIRWacJ8lIbVJpvVhUryeHNNC9Aq5O8GJTd12HGbg5zeAfZiABx2P09 RQBpyfQGnYl+KIsnBQG+8ZnyCKDhkomyrhow== X-Gm-Gg: ASbGnctpp20CluGYQKjF4r7416vvCQs0bjHt6PwORIYXkezOdLXVZWWNruATvSM5Ttr FWEeKYSyPdot+RI5p5RgyHIpanun8XBKZrSQEJK/sfDmFWpt5QcQW2hS8eXZQoCk8uj31fDRA/I 75KYTnNTQckFYbS925m32t2wSEjkMXoY4IGV2KwUJ3d0gofP4ZIBN+AqLR4goa+RxT+I0hua/4A eGizSN4T7zXvaOCk5iroBQfC+0UZ+gWFWQZmYI6Hbhf2k0AtSAAdjKFVCi4unVUQFxhE4DP+BzF ZA8zqWAvT8U0EThIdsObXqIS1WYvZmiy6nQiY6Y= X-Received: by 2002:a05:600c:8284:b0:46e:3d50:360e with SMTP id 5b1f17b1804b1-46e7113f799mr72600075e9.18.1759691910559; Sun, 05 Oct 2025 12:18:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEbWRKR6YeXJCG6P0qO56u3m3wTUshuNv9AD2x7fZveX9Hb3spIE2rfYB9wZySbcODm9Zr2lg== X-Received: by 2002:a05:600c:8284:b0:46e:3d50:360e with SMTP id 5b1f17b1804b1-46e7113f799mr72599875e9.18.1759691909961; Sun, 05 Oct 2025 12:18:29 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:28 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 66/75] amd_iommu: Add dma-remap property to AMD vIOMMU device Message-ID: <8a8837f903230919459c2df3c9584372fbe65312.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692158825116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez In order to enable device assignment with IOMMU protection and guest DMA address translation, IOMMU MAP notifier support is necessary to allow users like VFIO to synchronize the shadow page tables i.e. to receive notifications when the guest updates its I/O page tables and replay the mappings onto host I/O page tables. Provide a new dma-remap property to govern the ability to register for MAP notifications, effectively providing global control over the DMA address translation functionality that was implemented in previous changes. Note that DMA remapping support also requires the vIOMMU is configured with the NpCache capability, so a guest driver issues IOMMU invalidations for both map() and unmap() operations. This capability is already set by default and written to the configuration in amdvi_pci_realize() as part of AMDVI_CAPAB_FEATURES. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-18-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.h | 3 +++ hw/i386/amd_iommu.c | 24 +++++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index b51aa74368..e1354686b6 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -418,6 +418,9 @@ struct AMDVIState { /* Interrupt remapping */ bool ga_enabled; bool xtsup; + + /* DMA address translation */ + bool dma_remap; }; =20 uint64_t amdvi_extended_feature_register(AMDVIState *s); diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index e9ce7b46e8..ce5d4c3662 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -990,7 +990,9 @@ static void amdvi_iommu_address_space_sync_all(AMDVISta= te *s) */ static void amdvi_switch_address_space(AMDVIAddressSpace *amdvi_as) { - if (amdvi_as->addr_translation) { + AMDVIState *s =3D amdvi_as->iommu_state; + + if (s->dma_remap && amdvi_as->addr_translation) { /* Enabling DMA region */ memory_region_set_enabled(&amdvi_as->iommu_nodma, false); memory_region_set_enabled(MEMORY_REGION(&amdvi_as->iommu), true); @@ -2193,12 +2195,19 @@ static int amdvi_iommu_notify_flag_changed(IOMMUMem= oryRegion *iommu, AMDVIAddressSpace *as =3D container_of(iommu, AMDVIAddressSpace, iommu= ); AMDVIState *s =3D as->iommu_state; =20 - if (new & IOMMU_NOTIFIER_MAP) { - error_setg(errp, - "device %02x.%02x.%x requires iommu notifier which is n= ot " - "currently supported", as->bus_num, PCI_SLOT(as->devfn), - PCI_FUNC(as->devfn)); - return -EINVAL; + /* + * Accurate synchronization of the vIOMMU page tables required to supp= ort + * MAP notifiers is provided by the dma-remap feature. In addition, th= is + * also requires that the vIOMMU presents the NpCache capability, so a= guest + * driver issues invalidations for both map() and unmap() operations. = The + * capability is already set by default as part of AMDVI_CAPAB_FEATURE= S and + * written to the configuration in amdvi_pci_realize(). + */ + if (!s->dma_remap && (new & IOMMU_NOTIFIER_MAP)) { + error_setg_errno(errp, ENOTSUP, + "device %02x.%02x.%x requires dma-remap=3D1", + as->bus_num, PCI_SLOT(as->devfn), PCI_FUNC(as->devfn)); + return -ENOTSUP; } =20 /* @@ -2423,6 +2432,7 @@ static void amdvi_sysbus_realize(DeviceState *dev, Er= ror **errp) static const Property amdvi_properties[] =3D { DEFINE_PROP_BOOL("xtsup", AMDVIState, xtsup, false), DEFINE_PROP_STRING("pci-id", AMDVIState, pci_id), + DEFINE_PROP_BOOL("dma-remap", AMDVIState, dma_remap, false), }; =20 static const VMStateDescription vmstate_amdvi_sysbus =3D { --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692129; cv=none; d=zohomail.com; s=zohoarc; b=OVjYH7YXgOCW3hLdlpjH30wBhtEjtjrZPPgMuji2+rFk+s1GWnLwR2duhqBicBwHoCDAhGvfXOijoTt6Xdtzo+sL9a++1asQwZXdBQYzB56Mxy0wwthu4r0xoot+tnxhf/PfzHEAnXxfjRUfXgAv1r+qGD4Qm9Jv1RuR6+tGg9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692129; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=r7Zh1GmB+h9beTPga1Sxsa0PNr++51jOf+TUxOiKSc0=; b=bxpKvl2lVorP0/B7JJOj8I5SnNQHs3jJwCIo2NJqSWXC/HHxM4Q0zo9Irqr0pZqev3tnebOCw0hsfOFT88lSIIghy4X5jelJystqPWo1DYevs0G0jSAoaFoIiieLnsCsBTKokVplJMKgMDSabUBcBYBE8W0Ufu488TZLue5Cq2U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692129329931.4467247379057; Sun, 5 Oct 2025 12:22:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UGP-0005qm-IT; Sun, 05 Oct 2025 15:19: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 1v5UFl-0004UC-FD for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFi-0006fJ-1R for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:41 -0400 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-333-Wvxl2j1oPkGF_yLDZ3oNAQ-1; Sun, 05 Oct 2025 15:18:34 -0400 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-3f93db57449so1943986f8f.2 for ; Sun, 05 Oct 2025 12:18:34 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f0392sm17629852f8f.42.2025.10.05.12.18.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691916; 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=r7Zh1GmB+h9beTPga1Sxsa0PNr++51jOf+TUxOiKSc0=; b=SUZL3n8Jo4anVZXZj0BAlt7JPgxsCEcPxbuqI8Uk08M2yQAnwlaOiyfYqHMMLntP93Tyom KXb2WPUSg7+muyzB9dHjTUZ+PjpvHr/eJ2mqgmO8BWXlVygIl5jgKiuGsRM2RBPEGWbtYg tInJuIHrYaUJf7NRBoQsItC1WTwrxDg= X-MC-Unique: Wvxl2j1oPkGF_yLDZ3oNAQ-1 X-Mimecast-MFC-AGG-ID: Wvxl2j1oPkGF_yLDZ3oNAQ_1759691914 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691913; x=1760296713; 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=r7Zh1GmB+h9beTPga1Sxsa0PNr++51jOf+TUxOiKSc0=; b=i+zuuwqaMMDDahK/UFNtgxgFv3Wv43UU59KCwyEDv0hmdnPqFjJ2T/6AA784h5rOEH 4sFkINtGDCfd4Xt0J4J8L+Ge+ygIaYV59VLHvBQGpVbhLCEOQiuFUopupXJKgz1C6vSF qktTqDJg+bUX0lQdMH7sAk7/q2kdjYM4UnqZ0mL+uyrG7bp1rMyJIAaCNnrgWCulRuqL j/Xcoe2vP01BEScOWuxhzo2I+F70U+btrnrmjOi+sud6ngJPn0kkfrrDsitTe2UfVfsQ 7SJ4aFpvsu8axNDEJqB9pElYPAZg85fBGc3Hd/ZSf5px+DNcpa7YieKUlZXo42tB51i0 N20w== X-Gm-Message-State: AOJu0YzvaqEEwb7Xi2CimDMS5JhV1us0KmNoM+NtkMmr75dsZwc9eMR/ x4vs50C7EsqBo3ozXUGdxcjkAoFiuErdjv6YuAEUNJ400m3Xjv4ULwoEpBuUPGxtPDz8gruBKJu b/FAOpIyJcyaOb43UsSIGKh+/Bm3DlSVyXsPw/7X+PB8X2rbdud70H3a/+9Q+79gn9BOF4gx3xV QnD3mBqnH8uDPAn0ASPeZTvqBedEanp/Wf1A== X-Gm-Gg: ASbGnctgmSrdkkz1yCxGh8kHFQJdExeUtaHLpihu4K96hxxwi0Ywfoa0F5W4cn1QR6g p9xikTM9MaL9cDumJYfZsCPqicCfihpDwvYOkjV6ub5MgAQTDvA5pyc55N7UzTx/IfPsseUd9B8 dxw4u27PObtLOeYak7gM3lk3setPs6ET5nCHv9CJQA1qYQmAaiW4pjKG4rfEHOykjqGNtoOjYIG DVvajpA+9LK829qTRfvgwM9vuBhCg1RE3lZvni2z5eWKE/H4rRo8BaYqqeK56j1QbeyM2a2sTRN KmkEaXW+clfRkyZEMHSuVMSKn/WPkV4h6bOJQjo= X-Received: by 2002:a05:6000:2204:b0:408:5363:8266 with SMTP id ffacd0b85a97d-425671b07c1mr6599710f8f.44.1759691913227; Sun, 05 Oct 2025 12:18:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8cxAq4obRj8OFJxz7gB7jh0hMkedXPXfzEp4BqapU+YwJSQpNhn/5MQ4NMlydgu6dcYmpxw== X-Received: by 2002:a05:6000:2204:b0:408:5363:8266 with SMTP id ffacd0b85a97d-425671b07c1mr6599684f8f.44.1759691912604; Sun, 05 Oct 2025 12:18:32 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:30 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 67/75] amd_iommu: Toggle address translation mode on devtab entry invalidation Message-ID: <5670069df966ac146cc404011af23c257380368d.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692132511116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez A guest must issue an INVALIDATE_DEVTAB_ENTRY command after changing a Device Table entry (DTE) e.g. after attaching a device and setting up its DTE. When intercepting this event, determine if the DTE has been configured for paging or not, and toggle the appropriate memory regions to allow DMA address translation for the address space if needed. Requires dma-remap=3Do= n. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-19-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 122 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 120 insertions(+), 2 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index ce5d4c3662..e916dcb2be 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1032,18 +1032,136 @@ static void amdvi_reset_address_translation_all(AM= DVIState *s) } } =20 +static void enable_dma_mode(AMDVIAddressSpace *as, bool inval_current) +{ + /* + * When enabling DMA mode for the purpose of isolating guest devices on + * a failure to retrieve or invalid DTE, all existing mappings must be + * dropped. + */ + if (inval_current) { + IOMMUNotifier *n; + IOMMU_NOTIFIER_FOREACH(n, &as->iommu) { + amdvi_address_space_unmap(as, n); + } + } + + if (as->addr_translation) { + return; + } + + /* Installing DTE enabling translation, activate region */ + as->addr_translation =3D true; + amdvi_switch_address_space(as); + /* Sync shadow page tables */ + amdvi_address_space_sync(as); +} + +/* + * If paging was previously in use in the address space + * - invalidate all existing mappings + * - switch to no_dma memory region + */ +static void enable_nodma_mode(AMDVIAddressSpace *as) +{ + IOMMUNotifier *n; + + if (!as->addr_translation) { + /* passthrough is already active, nothing to do */ + return; + } + + as->addr_translation =3D false; + IOMMU_NOTIFIER_FOREACH(n, &as->iommu) { + /* Drop all mappings for the address space */ + amdvi_address_space_unmap(as, n); + } + amdvi_switch_address_space(as); +} + +/* + * A guest driver must issue the INVALIDATE_DEVTAB_ENTRY command to the IO= MMU + * after changing a Device Table entry. We can use this fact to detect whe= n a + * Device Table entry is created for a device attached to a paging domain = and + * enable the corresponding IOMMU memory region to allow for DMA translati= on if + * appropriate. + */ +static void amdvi_update_addr_translation_mode(AMDVIState *s, uint16_t dev= id) +{ + uint8_t bus_num, devfn, dte_mode; + AMDVIAddressSpace *as; + uint64_t dte[4] =3D { 0 }; + int ret; + + /* + * Convert the devid encoded in the command to a bus and devfn in + * order to retrieve the corresponding address space. + */ + bus_num =3D PCI_BUS_NUM(devid); + devfn =3D devid & 0xff; + + /* + * The main buffer of size (AMDVIAddressSpace *) * (PCI_BUS_MAX) has a= lready + * been allocated within AMDVIState, but must be careful to not access + * unallocated devfn. + */ + if (!s->address_spaces[bus_num] || !s->address_spaces[bus_num][devfn])= { + return; + } + as =3D s->address_spaces[bus_num][devfn]; + + ret =3D amdvi_as_to_dte(as, dte); + + if (!ret) { + dte_mode =3D (dte[0] >> AMDVI_DEV_MODE_RSHIFT) & AMDVI_DEV_MODE_MA= SK; + } + + switch (ret) { + case 0: + /* DTE was successfully retrieved */ + if (!dte_mode) { + enable_nodma_mode(as); /* DTE[V]=3D1 && DTE[Mode]=3D0 =3D> pas= sthrough */ + } else { + enable_dma_mode(as, false); /* Enable DMA translation */ + } + break; + case -AMDVI_FR_DTE_V: + /* DTE[V]=3D0, address is passed untranslated */ + enable_nodma_mode(as); + break; + case -AMDVI_FR_DTE_RTR_ERR: + case -AMDVI_FR_DTE_TV: + /* + * Enforce isolation by using DMA in rare scenarios where the DTE = cannot + * be retrieved or DTE[TV]=3D0. Existing mappings are dropped. + */ + enable_dma_mode(as, true); + break; + } +} + /* log error without aborting since linux seems to be using reserved bits = */ static void amdvi_inval_devtab_entry(AMDVIState *s, uint64_t *cmd) { uint16_t devid =3D cpu_to_le16((uint16_t)extract64(cmd[0], 0, 16)); =20 + trace_amdvi_devtab_inval(PCI_BUS_NUM(devid), PCI_SLOT(devid), + PCI_FUNC(devid)); + /* This command should invalidate internal caches of which there isn't= */ if (extract64(cmd[0], 16, 44) || cmd[1]) { amdvi_log_illegalcom_error(s, extract64(cmd[0], 60, 4), s->cmdbuf + s->cmdbuf_head); + return; + } + + /* + * When DMA remapping capability is enabled, check if updated DTE is s= etup + * for paging or not, and configure the corresponding memory regions. + */ + if (s->dma_remap) { + amdvi_update_addr_translation_mode(s, devid); } - trace_amdvi_devtab_inval(PCI_BUS_NUM(devid), PCI_SLOT(devid), - PCI_FUNC(devid)); } =20 static void amdvi_complete_ppr(AMDVIState *s, uint64_t *cmd) --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692409; cv=none; d=zohomail.com; s=zohoarc; b=gB0LWrbOpO10KoCadUz6mKw3LYZQlhAw32AXtGgo5u5QOMyJ/G+AhrBJs30BAvpEmHb1od+yBm6QaZpHSsJYRBZhb0DiFLVTFFSx8KY2tp9xe+ROf7UDy5P3h+wbwoUNx6g6DkbVf4Iz2TiFteQGffNsY9dk7ACj+5yFHJd5zmY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692409; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=C9WvSj244bnTQx+NCrPES38aqSUsl9JKhLvBXSEeZN0=; b=dR5CFal7qwOkrhmFcI10M4t2J7k8g/EkydIxRrh633VwuKw8/FUtf7ZmC58Ucm6KIcyufCleF9JPDMJkNH4Y7nlCG8ZfEzSmyUg1e9SxIxTzqQtHtJFRfsVFxE8VPR8QqKbehox8iu0mqfMI9+2BAC88jvEbKUl3MZ4ixck4DO0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692409060289.26376084151923; Sun, 5 Oct 2025 12:26:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UGd-0006rb-4E; Sun, 05 Oct 2025 15:19:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFu-0004qH-6N for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:51 -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 1v5UFj-0006fN-H4 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:49 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-367-coKXyuFXPp6gxs-QPOg0fQ-1; Sun, 05 Oct 2025 15:18:36 -0400 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-46e3a049abaso22009325e9.0 for ; Sun, 05 Oct 2025 12:18:36 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e7234e5fdsm125552985e9.6.2025.10.05.12.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691917; 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=C9WvSj244bnTQx+NCrPES38aqSUsl9JKhLvBXSEeZN0=; b=g7Zi+NDnSRXQzCJe+8VaigYZfhUKavB4/z9pIYOLbDRNeASY3FfEzQ+YlvJi41iyAslQ4a gM8bEeqcxJzrcLmEYuykkE5Kzm/a2uLj0ka5jcZEPJVMPXjg724HgQTyVgiZGkWGgOYI/Q Auazndq0nP0/Kb0Skbmes2eZaMw/zm4= X-MC-Unique: coKXyuFXPp6gxs-QPOg0fQ-1 X-Mimecast-MFC-AGG-ID: coKXyuFXPp6gxs-QPOg0fQ_1759691915 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691915; x=1760296715; 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=C9WvSj244bnTQx+NCrPES38aqSUsl9JKhLvBXSEeZN0=; b=TOGnKNGDkINItWfRzyQT0dD/OliibejjT1mxjISlJC5i5f6MuS47bQ3UNV/0CTPpRe 2ZSKIynPUY2MlD8H9oPMkEQEL7S013A9Rai3Ol3eZVtXlz2dIsHwK6g5g1tMX1WzFaFL Qg1RP2hd6Aby0nIlFgeUQ2hNYdPbVXq5/jHXqCLk1NuzSQVi+Yt7OhhF4qbjiFbKoxY/ RF9oanGHR1XMUuG6MibJWG9Alp5jH8A+YWssXOro8g9h3YnvFeazDK0z1+ExH/29Pxlt YoKT99JdQw/JV7D2rqOhmELQ0YUJZrEBAIfjKLi8mMLcfq0S+mw1nedLE9Ko/2ZNPSMK dxzg== X-Gm-Message-State: AOJu0Yw2+Qhllo5lRMvWvUFucFdxRf8WpqbvVHFzqwXC5Y5anaN9z7+7 tfZ1pXVVT8U7IndUBULdnK2aISqTnQhZDt0TleTl/jTZig8xaxHsc40jvRydau1QYSzcrOwecTy 6bjUTSdO0pMgber5iV7p3BKnHZCoJWHw60sFCO6PdOsULL0NZdg0DrbzFAfPdQoQZIXwbcCj4/t HGHXsnXKvm5rQcUonqAbLjquw9uiqvBOK6oQ== X-Gm-Gg: ASbGncuU6xExe1VJgzOW7LtESTA/OTg+tkQtr8g9oZ8zy3S1uIoR2cyBUoty37aFLT2 wR7aExC1lF1hW2jLwjUuBoPrTLpUs94Du8pwE4bK0dNfe0IWS7CFeYDDA/8Xn9ko8rs+WsNihAY ObIaejIKz6PV6ej0jAcdKacJmmTqcEuZObH8Y65rEznB3rCeAHTT1oEMBboEM7WVJDFB6HDQ0Kb bfXMEqR5p/mtEic0y+SyllhBaT/eo3S+Ldga3T/m0wZh5Y3wjtLtlZt08huAyFhwAJs6HGhBEad bBqAe72t09HYCmLkn0r0Ic2hI7N9H2xE2V5ZNcI= X-Received: by 2002:a05:600c:3b16:b0:46e:502c:8d6a with SMTP id 5b1f17b1804b1-46e7114e1dbmr63603545e9.25.1759691915084; Sun, 05 Oct 2025 12:18:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTDzKhbmHa3yjDHhvm5nUqNg3dWGt5UTnWw4BUbMZxvwlOHpGQ3kvdxOx6yDmz0R7ZFhRlWQ== X-Received: by 2002:a05:600c:3b16:b0:46e:502c:8d6a with SMTP id 5b1f17b1804b1-46e7114e1dbmr63603345e9.25.1759691914543; Sun, 05 Oct 2025 12:18:34 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:32 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 68/75] amd_iommu: Do not assume passthrough translation when DTE[TV]=0 Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692410558116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez The AMD I/O Virtualization Technology (IOMMU) Specification (see Table 8: V, TV, and GV Fields in Device Table Entry), specifies that a DTE with V=3D1, TV=3D0 does not contain a valid address translation information. If a request requires a table walk, the walk is terminated when this condition is encountered. Do not assume that addresses for a device with DTE[TV]=3D0 are passed through (i.e. not remapped) and instead terminate the page table walk early. Fixes: d29a09ca6842 ("hw/i386: Introduce AMD IOMMU") Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-20-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 95 +++++++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 43 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index e916dcb2be..1bda2a8ac3 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1722,51 +1722,60 @@ static void amdvi_page_walk(AMDVIAddressSpace *as, = uint64_t *dte, uint64_t pte =3D dte[0], pte_addr, page_mask; =20 /* make sure the DTE has TV =3D 1 */ - if (pte & AMDVI_DEV_TRANSLATION_VALID) { - level =3D get_pte_translation_mode(pte); - if (level >=3D 7) { - trace_amdvi_mode_invalid(level, addr); - return; - } - if (level =3D=3D 0) { - goto no_remap; - } - - /* we are at the leaf page table or page table encodes a huge page= */ - do { - pte_perms =3D amdvi_get_perms(pte); - present =3D pte & 1; - if (!present || perms !=3D (perms & pte_perms)) { - amdvi_page_fault(as->iommu_state, as->devfn, addr, perms); - trace_amdvi_page_fault(addr); - return; - } - - /* go to the next lower level */ - pte_addr =3D pte & AMDVI_DEV_PT_ROOT_MASK; - /* add offset and load pte */ - pte_addr +=3D ((addr >> (3 + 9 * level)) & 0x1FF) << 3; - pte =3D amdvi_get_pte_entry(as->iommu_state, pte_addr, as->dev= fn); - if (!pte || (pte =3D=3D (uint64_t)-1)) { - return; - } - oldlevel =3D level; - level =3D get_pte_translation_mode(pte); - } while (level > 0 && level < 7); - - if (level =3D=3D 0x7) { - page_mask =3D pte_override_page_mask(pte); - } else { - page_mask =3D pte_get_page_mask(oldlevel); - } - - /* get access permissions from pte */ - ret->iova =3D addr & page_mask; - ret->translated_addr =3D (pte & AMDVI_DEV_PT_ROOT_MASK) & page_mas= k; - ret->addr_mask =3D ~page_mask; - ret->perm =3D amdvi_get_perms(pte); + if (!(pte & AMDVI_DEV_TRANSLATION_VALID)) { + /* + * A DTE with V=3D1, TV=3D0 does not have a valid Page Table Root = Pointer. + * An IOMMU processing a request that requires a table walk termin= ates + * the walk when it encounters this condition. Do the same and ret= urn + * instead of assuming that the address is forwarded without trans= lation + * i.e. the passthrough case, as it is done for the case where DTE= [V]=3D0. + */ return; } + + level =3D get_pte_translation_mode(pte); + if (level >=3D 7) { + trace_amdvi_mode_invalid(level, addr); + return; + } + if (level =3D=3D 0) { + goto no_remap; + } + + /* we are at the leaf page table or page table encodes a huge page */ + do { + pte_perms =3D amdvi_get_perms(pte); + present =3D pte & 1; + if (!present || perms !=3D (perms & pte_perms)) { + amdvi_page_fault(as->iommu_state, as->devfn, addr, perms); + trace_amdvi_page_fault(addr); + return; + } + /* go to the next lower level */ + pte_addr =3D pte & AMDVI_DEV_PT_ROOT_MASK; + /* add offset and load pte */ + pte_addr +=3D ((addr >> (3 + 9 * level)) & 0x1FF) << 3; + pte =3D amdvi_get_pte_entry(as->iommu_state, pte_addr, as->devfn); + if (!pte) { + return; + } + oldlevel =3D level; + level =3D get_pte_translation_mode(pte); + } while (level > 0 && level < 7); + + if (level =3D=3D 0x7) { + page_mask =3D pte_override_page_mask(pte); + } else { + page_mask =3D pte_get_page_mask(oldlevel); + } + + /* get access permissions from pte */ + ret->iova =3D addr & page_mask; + ret->translated_addr =3D (pte & AMDVI_DEV_PT_ROOT_MASK) & page_mask; + ret->addr_mask =3D ~page_mask; + ret->perm =3D amdvi_get_perms(pte); + return; + no_remap: ret->iova =3D addr & AMDVI_PAGE_MASK_4K; ret->translated_addr =3D addr & AMDVI_PAGE_MASK_4K; --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692514; cv=none; d=zohomail.com; s=zohoarc; b=Q5EzoA8m1wBjXqFHJ3JLenRQnmVztl6Q9dywFAKlPSAolkMEemI5h54Z4ZTKKiozQkNP+jePEqnBmsZ1h5S5OecRS+b6juYYAl0jQXm5+v9DKcRY9z5//K3x16i2TZfP9T1u21HA2tPctmSWUj4plt9wKV4zKMbqZMk53wZBvAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692514; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=one5aMpcdf5KTSY+OWTqXXbQYegt1IKrQftjUhBs24c=; b=TdniDVYnm/udUapXu5T62Mwgo5YAXY/S2PU8WGo0VSnbxI3h/ijgjRhfPFEs15lZYYi4VjFRSKXpblalMP0Hkt8CCFAPCjuxYN6VJ1YU+CBnOzoRuDkesZLr8LnriJnp3sDbpe2QzoW7wXDWHH++ARB3ftZD/Ag8ZG9XHl1W7Jo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175969251477146.00633543541653; Sun, 5 Oct 2025 12:28:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UGZ-0006cD-MJ; Sun, 05 Oct 2025 15:19:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFt-0004pr-7s for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:50 -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 1v5UFm-0006fg-Pl for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:48 -0400 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-70-fX1WZsKlPuKnKk6qqJoZwQ-1; Sun, 05 Oct 2025 15:18:38 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3efe4fcc9ccso2224259f8f.3 for ; Sun, 05 Oct 2025 12:18:38 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f4abcsm17354316f8f.53.2025.10.05.12.18.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691920; 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=one5aMpcdf5KTSY+OWTqXXbQYegt1IKrQftjUhBs24c=; b=cILT/p6zxaFRJEK3sHK/6KK/S8LuhGN9pum9Lescfcd7sGTmQcqr/hZjvE2nGchV4NVcme 5GNR5jNISfSF8NwS6q719Cs38NRH4lODYACQFubcB5+pmMM7QIWcE17xzPI6oaxBoeQogC nngI1ovAvoWWn4opTDFO6rUnlW64V40= X-MC-Unique: fX1WZsKlPuKnKk6qqJoZwQ-1 X-Mimecast-MFC-AGG-ID: fX1WZsKlPuKnKk6qqJoZwQ_1759691918 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691917; x=1760296717; 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=one5aMpcdf5KTSY+OWTqXXbQYegt1IKrQftjUhBs24c=; b=TljJYrypd/xMPqjsfmMSperaPncd+d63EPD9b1jt7lB48SmNrr1bdoWA7ZI0l+D62S ubSe8dxPcZBIvbVUuh+voxvFK8ngom3Mb/8pwFq3dl/5YR25yDgBHWjDQNbA8j0o53F2 Yx7WqFjGAe4g6fZBrJZVs6ezein/Hziid3znerGo65JnTXqrlf1nXAsqFiNeA3XpktZb ISPVWfxDCN/9u9jNj1Dbg6LBkY4KXwR51b0ojdgIF40h2gMDgV0VT0nSeNyCWtZBMvWT k8i8DwN1wHxWME0oNBq8t5lmZLzVa17BttOGGw4bmr3P0oLcKD+iR2lBerwdhKoI8yzu TMtg== X-Gm-Message-State: AOJu0Yz1cJ33mZmOEJc7LWPnmsUGxdPQ/i8fvpbBjZaB6Kg+mKVZnEqZ 7iHJJ1WxInADuKwuqlJRR95FfE+lLxyPZaCSXt7k4DzZFYB9SWq4VGk6lBLhh4Sem0hCeypIzdN JUZlowMyBpqBxtE7jhQfLU38aMLW0quimE63qbvt48I+N+6Kn5CivDtqrxDtV1SoM02n3xYGZoa onBVr/J12OkrHlNz5tuYIoDNY8y6SS/OZDEw== X-Gm-Gg: ASbGncuZwmrUS65HXM6BlhAMZ2cNU8DKgmrgmKI1RVkJtw+JJfZV1FFzLEFfd6fJTa9 QIc7hYqGXx3x21k72A0Hnk+LbtGD2SxnsNUOjKfd93CdHFcYO5OThxoYHflQfK2BuuK8eDlOLZK S/2LIyYXC/63JQ/c6Uy3wBOoTyXjJ+ywRg6Cwm5qsbF4SX58JNV3U0xcRuR9u8PyzHvlsTOOMQ8 vshvUWTD2tDJZroZmVtBAw1HWwUkKyhfzWzSKpmygdtoIGwfBHEet/2eXxh02eGYKTvbkX/hHyA IlHXSxl+AZFmFbyphYgWsUYMeJzEARnPcUTPcvU= X-Received: by 2002:a05:6000:2212:b0:3ee:d165:2edd with SMTP id ffacd0b85a97d-4256713fe43mr6044597f8f.28.1759691917180; Sun, 05 Oct 2025 12:18:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEkbOrqWzWRnSQdIrcyW1mKsZwgVAOUEjk2e6LxwteV+8/Qn/cT39ijeAp3jRGIdUUtuCuftg== X-Received: by 2002:a05:6000:2212:b0:3ee:d165:2edd with SMTP id ffacd0b85a97d-4256713fe43mr6044576f8f.28.1759691916606; Sun, 05 Oct 2025 12:18:36 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:34 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Alejandro Jimenez , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 69/75] amd_iommu: Refactor amdvi_page_walk() to use common code for page walk 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692516516116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Alejandro Jimenez Simplify amdvi_page_walk() by making it call the fetch_pte() helper that is already in use by the shadow page synchronization code. Ensures all code uses the same page table walking algorithm. Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-21-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.c | 77 ++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 1bda2a8ac3..b6851784fb 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -513,24 +513,6 @@ static inline uint8_t get_pte_translation_mode(uint64_= t pte) return (pte >> AMDVI_DEV_MODE_RSHIFT) & AMDVI_DEV_MODE_MASK; } =20 -static inline uint64_t pte_override_page_mask(uint64_t pte) -{ - uint8_t page_mask =3D 13; - uint64_t addr =3D (pte & AMDVI_DEV_PT_ROOT_MASK) >> 12; - /* find the first zero bit */ - while (addr & 1) { - page_mask++; - addr =3D addr >> 1; - } - - return ~((1ULL << page_mask) - 1); -} - -static inline uint64_t pte_get_page_mask(uint64_t oldlevel) -{ - return ~((1UL << ((oldlevel * 9) + 3)) - 1); -} - static inline uint64_t amdvi_get_pte_entry(AMDVIState *s, uint64_t pte_add= r, uint16_t devid) { @@ -1718,11 +1700,13 @@ static void amdvi_page_walk(AMDVIAddressSpace *as, = uint64_t *dte, IOMMUTLBEntry *ret, unsigned perms, hwaddr addr) { - unsigned level, present, pte_perms, oldlevel; - uint64_t pte =3D dte[0], pte_addr, page_mask; + hwaddr page_mask, pagesize =3D 0; + uint8_t mode; + uint64_t pte; + int fetch_ret; =20 /* make sure the DTE has TV =3D 1 */ - if (!(pte & AMDVI_DEV_TRANSLATION_VALID)) { + if (!(dte[0] & AMDVI_DEV_TRANSLATION_VALID)) { /* * A DTE with V=3D1, TV=3D0 does not have a valid Page Table Root = Pointer. * An IOMMU processing a request that requires a table walk termin= ates @@ -1733,42 +1717,35 @@ static void amdvi_page_walk(AMDVIAddressSpace *as, = uint64_t *dte, return; } =20 - level =3D get_pte_translation_mode(pte); - if (level >=3D 7) { - trace_amdvi_mode_invalid(level, addr); + mode =3D get_pte_translation_mode(dte[0]); + if (mode >=3D 7) { + trace_amdvi_mode_invalid(mode, addr); return; } - if (level =3D=3D 0) { + if (mode =3D=3D 0) { goto no_remap; } =20 - /* we are at the leaf page table or page table encodes a huge page */ - do { - pte_perms =3D amdvi_get_perms(pte); - present =3D pte & 1; - if (!present || perms !=3D (perms & pte_perms)) { - amdvi_page_fault(as->iommu_state, as->devfn, addr, perms); - trace_amdvi_page_fault(addr); - return; - } - /* go to the next lower level */ - pte_addr =3D pte & AMDVI_DEV_PT_ROOT_MASK; - /* add offset and load pte */ - pte_addr +=3D ((addr >> (3 + 9 * level)) & 0x1FF) << 3; - pte =3D amdvi_get_pte_entry(as->iommu_state, pte_addr, as->devfn); - if (!pte) { - return; - } - oldlevel =3D level; - level =3D get_pte_translation_mode(pte); - } while (level > 0 && level < 7); + /* Attempt to fetch the PTE to determine if a valid mapping exists */ + fetch_ret =3D fetch_pte(as, addr, dte[0], &pte, &pagesize); =20 - if (level =3D=3D 0x7) { - page_mask =3D pte_override_page_mask(pte); - } else { - page_mask =3D pte_get_page_mask(oldlevel); + /* + * If walking the page table results in an error of any type, returns = an + * empty PTE i.e. no mapping, or the permissions do not match, return = since + * there is no translation available. + */ + if (fetch_ret < 0 || !IOMMU_PTE_PRESENT(pte) || + perms !=3D (perms & amdvi_get_perms(pte))) { + + amdvi_page_fault(as->iommu_state, as->devfn, addr, perms); + trace_amdvi_page_fault(addr); + return; } =20 + /* A valid PTE and page size has been retrieved */ + assert(pagesize); + page_mask =3D ~(pagesize - 1); + /* get access permissions from pte */ ret->iova =3D addr & page_mask; ret->translated_addr =3D (pte & AMDVI_DEV_PT_ROOT_MASK) & page_mask; @@ -1780,7 +1757,7 @@ no_remap: ret->iova =3D addr & AMDVI_PAGE_MASK_4K; ret->translated_addr =3D addr & AMDVI_PAGE_MASK_4K; ret->addr_mask =3D ~AMDVI_PAGE_MASK_4K; - ret->perm =3D amdvi_get_perms(pte); + ret->perm =3D amdvi_get_perms(dte[0]); } =20 static void amdvi_do_translate(AMDVIAddressSpace *as, hwaddr addr, --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692350; cv=none; d=zohomail.com; s=zohoarc; b=lB4zsaZj+og6ZZtUA6rM7SqQOMm3iZrGs40IqjLQ/joaC0uL6mCSq+Mm4RPmnZlvpVz7jxLrbjbgNo+ppoRECJGthFoYx8kWFhcSrzHUU+uZ7B8DfN5gzrEUr7ERuC6xPJ+kqsqt3i6dZlDqstjfQCdAuKb+QsNYOgvtC0jg9Wo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692350; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7wcSMblAe0qmcWCzx3l/Hyp9U03Fel/2vgGIAfTWdPY=; b=dSEB+uh8WFJQsFHWlWAgE26AFd1KwiFVbcHIUL9mdLamqmCJsodaauevLSDJ746o/2pIJcJb1yw+3edViSM0aXVhQLDI+BE5M6YssMfRBkHJ7IhT6kLeM7jRkXPjwDybRlbbFOtY7pXB66k5rR8KcvOgyHJ5bbc4r2hwsgoyXFk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692349988115.42370770671255; Sun, 5 Oct 2025 12:25:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UGR-00064X-Jz; Sun, 05 Oct 2025 15:19:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFr-0004pT-7P for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFo-0006fv-K9 for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:46 -0400 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-438-6iy2ltsuMpy46sDuA0B0lA-1; Sun, 05 Oct 2025 15:18:41 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-42557bdbe50so2379229f8f.1 for ; Sun, 05 Oct 2025 12:18:40 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f02a8sm17684257f8f.39.2025.10.05.12.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691922; 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=7wcSMblAe0qmcWCzx3l/Hyp9U03Fel/2vgGIAfTWdPY=; b=XD7s6vrGNz0LtZP1r6R5EEI38NnCo1rfafiAPeFWnqtGniorL5SpmtaBzER/gIwD++XA2N VGBjHfHAkl6Fl7FUHfQ4ZC2QUyK0thSHVCzpNbO3809mtXRyk9rvzLSm0uFQseeHKh/9Id sxYUKODAWtmk682QzyTKeBpNZbgxXkw= X-MC-Unique: 6iy2ltsuMpy46sDuA0B0lA-1 X-Mimecast-MFC-AGG-ID: 6iy2ltsuMpy46sDuA0B0lA_1759691920 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691919; x=1760296719; 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=7wcSMblAe0qmcWCzx3l/Hyp9U03Fel/2vgGIAfTWdPY=; b=D2qcGmU1w8j6U97+n44eXYs1pvCKHJikzYo9mJL8WUVUy+1XI65RW6suG/LeudoOb2 VUs4gO7UgP02KyaWWfdN9LaWOQIqPLcfAZ9CjjDglLFDEEPo0I0+fGBzhiLOz+YkTyse c/h8tg3wMrWSwTYipgnxNsTvWOIW19hhm2UEAL+ike1vgW1mXq2aHEWi7kfgrWVQrumS shaXQ84I6xNhqoBOzNlQ1lEKYygLT3v5f8m9ICjz4ni+4XpcIkIvVq333QSPXNCofPYN sfmIb50Wo+CA/n3pdhb75IETgMxdu0deLi6Ee95TmqqxzUlkgCF5mlIUEiCKzwAp7YXV DOqQ== X-Gm-Message-State: AOJu0Ywio7jt2zIxbnBgK/18wbEZCvo3YXzi2jAu7X63CHMl0y5DH/Zs rTbCqLkblfBVgORjit/xVuIOHzBeN0L792NVffhJh/mBVfry4PydP6RaUTcJF3atdhd7Gmu+/2w cDevXDusUQltECIRf91rm+UCtDn/W13M9VsmmBMkDV6VuJeA8SPh7aBSyGTPTVEYoVQGfhYRSI0 DjHuCAJNv3WIw18VJJw7f1UkjkYPHZXJBK9w== X-Gm-Gg: ASbGncub81sgCxh6IocRlnkTOVHa0AKaatsPVIoIv+UGG0HApPbA/ECPCQUpUdm8MFW 4OvuKB3ZtJiZ7ybodBmFRzIDL7ip1eOYngkxcQinxCIJobpwnYlAFMD9AFOxV8lLo6uCU+eqkl8 wRxtFK3a5GXTH69+cpy5kPMucTpEWjsUEemI0DzYknIgvrn/tQ4hD0ephNYz2Q50RrvCs10pv1p HBn2ISTv+kSq9YaOnI1h69NudDX4kws3Fqcue+xL5j/vrRZE8otyyywMA9xnzcCJF9yei6kuIQV GqcRbYQch67TN8SFpD0JvRPcMZ2eOkSDxjI1EYs= X-Received: by 2002:a05:6000:1447:b0:3ee:1494:27f5 with SMTP id ffacd0b85a97d-42566c15e15mr6548180f8f.13.1759691919477; Sun, 05 Oct 2025 12:18:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH4uNtgg2AwLFdm3cJ6XB1v5j+gYjK1t8WZjtoQY9LBGhEia7czDX3JWPNW8v6pW3q7K3uXsQ== X-Received: by 2002:a05:6000:1447:b0:3ee:1494:27f5 with SMTP id ffacd0b85a97d-42566c15e15mr6548155f8f.13.1759691918854; Sun, 05 Oct 2025 12:18:38 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:36 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Joao Martins , Alejandro Jimenez , Jason Wang , Yi Liu , =?utf-8?Q?Cl=C3=A9ment?= Mathieu--Drif , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 70/75] intel-iommu: Move dma_translation to x86-iommu Message-ID: <5ad0a139c307e0ac5c9c961fd7d810d7cf78e7b5.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692355949116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Joao Martins To be later reused by AMD, now that it shares similar property. Signed-off-by: Joao Martins Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-22-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- include/hw/i386/x86-iommu.h | 1 + hw/i386/intel_iommu.c | 5 ++--- hw/i386/x86-iommu.c | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/hw/i386/x86-iommu.h b/include/hw/i386/x86-iommu.h index bfd21649d0..e89f55a5c2 100644 --- a/include/hw/i386/x86-iommu.h +++ b/include/hw/i386/x86-iommu.h @@ -64,6 +64,7 @@ struct X86IOMMUState { OnOffAuto intr_supported; /* Whether vIOMMU supports IR */ bool dt_supported; /* Whether vIOMMU supports DT */ bool pt_supported; /* Whether vIOMMU supports pass-through */ + bool dma_translation; /* Whether vIOMMU supports DMA translation= */ QLIST_HEAD(, IEC_Notifier) iec_notifiers; /* IEC notify list */ }; =20 diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 2cc9bd5e45..fa2ad9c2eb 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -2704,7 +2704,7 @@ static void vtd_handle_gcmd_write(IntelIOMMUState *s) uint32_t changed =3D status ^ val; =20 trace_vtd_reg_write_gcmd(status, val); - if ((changed & VTD_GCMD_TE) && s->dma_translation) { + if ((changed & VTD_GCMD_TE) && x86_iommu->dma_translation) { /* Translation enable/disable */ vtd_handle_gcmd_te(s, val & VTD_GCMD_TE); } @@ -3947,7 +3947,6 @@ static const Property vtd_properties[] =3D { DEFINE_PROP_BOOL("snoop-control", IntelIOMMUState, snoop_control, fals= e), DEFINE_PROP_BOOL("x-pasid-mode", IntelIOMMUState, pasid, false), DEFINE_PROP_BOOL("dma-drain", IntelIOMMUState, dma_drain, true), - DEFINE_PROP_BOOL("dma-translation", IntelIOMMUState, dma_translation, = true), DEFINE_PROP_BOOL("stale-tm", IntelIOMMUState, stale_tm, false), DEFINE_PROP_BOOL("fs1gp", IntelIOMMUState, fs1gp, true), }; @@ -4665,7 +4664,7 @@ static void vtd_cap_init(IntelIOMMUState *s) if (s->dma_drain) { s->cap |=3D VTD_CAP_DRAIN; } - if (s->dma_translation) { + if (x86_iommu->dma_translation) { if (s->aw_bits >=3D VTD_HOST_AW_39BIT) { s->cap |=3D VTD_CAP_SAGAW_39bit; } diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c index d34a6849f4..c127a44bb4 100644 --- a/hw/i386/x86-iommu.c +++ b/hw/i386/x86-iommu.c @@ -130,6 +130,7 @@ static const Property x86_iommu_properties[] =3D { intr_supported, ON_OFF_AUTO_AUTO), DEFINE_PROP_BOOL("device-iotlb", X86IOMMUState, dt_supported, false), DEFINE_PROP_BOOL("pt", X86IOMMUState, pt_supported, true), + DEFINE_PROP_BOOL("dma-translation", X86IOMMUState, dma_translation, tr= ue), }; =20 static void x86_iommu_class_init(ObjectClass *klass, const void *data) --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692064; cv=none; d=zohomail.com; s=zohoarc; b=GnnJIs+RYi6kV+KG8JpE/Xass5R8oCPz6MJDBbMEz057l6JRQZQik53e6UomBl8dK1sXjKXSFKHkxAQBbHp9aF2w6TPNOGnw3aN0+y3ohMvuEScTikwB4O6yPLeDPr0zsEq3JYM9jvu/MM3nFF4JQPaxKSTe8nHfi4uy/Ld/UFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692064; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VxCiyHKYD9YBF6shEy7T0nbq5E2EJ5X5H7ThZ32/yVY=; b=dLBtkPiaH9Lm22ZhbQEP8q4svpEsEmXXPyLCX+kn/8WE7I/WZ+GCYwjw5qrfrZA3UlVmJcG2Alb/NHURYTzd/zxqGS0oFQDglN9X66oigZX7XzZALAkBTwa/lKyjZ75QIwsEZ0brwgfTi9Cowvs18eN23GncR3j9EQcLC91knGc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175969206437647.008513244252754; Sun, 5 Oct 2025 12:21:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UGV-0006Ka-HW; Sun, 05 Oct 2025 15:19:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFs-0004pl-DT for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFq-0006g6-0o for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:48 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-296-XmYMgiZVPZmKwPb_oKh32Q-1; Sun, 05 Oct 2025 15:18:43 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-46e473e577eso21448925e9.0 for ; Sun, 05 Oct 2025 12:18:43 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8e960asm17345713f8f.37.2025.10.05.12.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691925; 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=VxCiyHKYD9YBF6shEy7T0nbq5E2EJ5X5H7ThZ32/yVY=; b=bTcRG6qc7Dw5kruvysFY9myP7S+XBFhcSlx5KJq+LD9ie3txZGT/iKoZPI3U71Iyw3hzHx cY0JE0XXbWMYWKY7qkedqglpIPMonQu/NWN19PAZC6FC96Ny9XZKkBx0E0ItFmBwgW4ACK ViuGv9RYhF2nyR2Oci4ci31yXYhK9Xc= X-MC-Unique: XmYMgiZVPZmKwPb_oKh32Q-1 X-Mimecast-MFC-AGG-ID: XmYMgiZVPZmKwPb_oKh32Q_1759691922 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691922; x=1760296722; 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=VxCiyHKYD9YBF6shEy7T0nbq5E2EJ5X5H7ThZ32/yVY=; b=IeT3hvgngl8C387jiHsvAZp+ILH5ohFwAeLTQmh2leC3R82/pk0/RWqMpuxvbFl/M+ HuWSth1f3ecqlj5pkBp2pGvVIoumGhFXWoTcTRk7TC09YFuJNCJc7HuD6ja7MOd7kVfL XqhKnYUuiO3Pz75pHv6bEq8hWm94jbY2FfVy+viu4uYwy9Gf87X3+VTLKeFQBTIhn5Ot +nUts+BsFvKmj9gEOzfUvEAdwSHAgPG973pZO2Ib0szo1hcgBKTPjRXF+HENo22gARfA +bS6gr9cFts+Qe52+uuXgDfEWklO83L28XiZV1QLu1DYUSib62+IgSClLLK/TNqGAYGE SvTg== X-Gm-Message-State: AOJu0YyFG3/mPIyoc52Pgg6rnUo3Fz3dSBYqM7rcm1eP0mkGt8Q69OpM UD8GtohMETl2NNPFdbN6sZH1coxuOYeyJ+I9QShqBNcCLewuMHpwJOTZcva/BtgiRBgEmik27nx PHUYQG2LHRhe+phlo1dtjPpJVnKBXpCOsygD3mrQRSjtW+DqiQI76yqgiX2OubJx872NdzXEGam 7zM+CUZRy0Grm2kK2PgE4saKWua9XQKw6QLQ== X-Gm-Gg: ASbGncuX+gQRARk4+gcHXaxWxkWyM7jBA1loNGv/5tya48A6xeSfb5mjeac6cs5Tqny q0k/hhdEOlr0A4o+ViFvquqrgkFG9qaMfoWmXKB1ikEnXrxrP6lAnbx3SxOR0RUtUVrIsgqr8aG Z7Ga1/bX97cbQfdya6Oy0EyKKwObazP6hO7yZFFd3ZpfW2vGgH0Zxdg4CHJ0zT1k45wxPNshEfF Olzyx3A6VMND5gqLO2jjrxXSlP9wrruPMCuhSilM967udL75F0qB3F/8DOXmC7Q2Y8I38Vr3ywY tO6dejz+CF7v8d7l14HQWE/1odrYWW3YQ961hjA= X-Received: by 2002:a05:6000:2f88:b0:425:7c14:e2e8 with SMTP id ffacd0b85a97d-4257c14e303mr945356f8f.37.1759691921737; Sun, 05 Oct 2025 12:18:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG18Sjsh/St6MarFIFB7eEahBZg+EIzwimmYVYNVr0A5Sq9c+ET7pzNSNhkSFf+Q8qUAcB2jw== X-Received: by 2002:a05:6000:2f88:b0:425:7c14:e2e8 with SMTP id ffacd0b85a97d-4257c14e303mr945329f8f.37.1759691921014; Sun, 05 Oct 2025 12:18:41 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:39 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Joao Martins , Alejandro Jimenez , Igor Mammedov , Ani Sinha , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 71/75] amd_iommu: HATDis/HATS=11 support Message-ID: <51da445f5322952e6fb26b286e8aebe464c14176.1759691708.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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692075587116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Joao Martins Add a way to disable DMA translation support in AMD IOMMU by allowing to set IVHD HATDis to 1, and exposing HATS (Host Address Translation Size) as Reserved value. Signed-off-by: Joao Martins Signed-off-by: Alejandro Jimenez Reviewed-by: Michael S. Tsirkin Message-ID: <20250919213515.917111-23-alejandro.j.jimenez@oracle.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/amd_iommu.h | 1 + hw/i386/acpi-build.c | 6 +++++- hw/i386/amd_iommu.c | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/hw/i386/amd_iommu.h b/hw/i386/amd_iommu.h index e1354686b6..daf82fc85f 100644 --- a/hw/i386/amd_iommu.h +++ b/hw/i386/amd_iommu.h @@ -177,6 +177,7 @@ /* AMDVI paging mode */ #define AMDVI_GATS_MODE (2ULL << 12) #define AMDVI_HATS_MODE (2ULL << 10) +#define AMDVI_HATS_MODE_RESERVED (3ULL << 10) =20 /* Page Table format */ =20 diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 423c4959fe..9446a9f862 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1863,7 +1863,11 @@ build_amd_iommu(GArray *table_data, BIOSLinker *link= er, const char *oem_id, /* IOMMU info */ build_append_int_noprefix(table_data, 0, 2); /* IOMMU Attributes */ - build_append_int_noprefix(table_data, 0, 4); + if (!s->iommu.dma_translation) { + build_append_int_noprefix(table_data, (1UL << 0) /* HATDis */, 4); + } else { + build_append_int_noprefix(table_data, 0, 4); + } /* EFR Register Image */ build_append_int_noprefix(table_data, amdvi_extended_feature_register(s), diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index b6851784fb..378e0cb55e 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -107,6 +107,9 @@ uint64_t amdvi_extended_feature_register(AMDVIState *s) if (s->xtsup) { feature |=3D AMDVI_FEATURE_XT; } + if (!s->iommu.dma_translation) { + feature |=3D AMDVI_HATS_MODE_RESERVED; + } =20 return feature; } @@ -472,6 +475,9 @@ static inline uint64_t amdvi_get_perms(uint64_t entry) static bool amdvi_validate_dte(AMDVIState *s, uint16_t devid, uint64_t *dte) { + + uint64_t root; + if ((dte[0] & AMDVI_DTE_QUAD0_RESERVED) || (dte[1] & AMDVI_DTE_QUAD1_RESERVED) || (dte[2] & AMDVI_DTE_QUAD2_RESERVED) || @@ -482,6 +488,19 @@ static bool amdvi_validate_dte(AMDVIState *s, uint16_t= devid, return false; } =20 + /* + * 1 =3D Host Address Translation is not supported. Value in MMIO Offs= et + * 0030h[HATS] is not meaningful. A non-zero host page table root poin= ter + * in the DTE would result in an ILLEGAL_DEV_TABLE_ENTRY event. + */ + root =3D (dte[0] & AMDVI_DEV_PT_ROOT_MASK) >> 12; + if (root && !s->iommu.dma_translation) { + amdvi_log_illegaldevtab_error(s, devid, + s->devtab + + devid * AMDVI_DEVTAB_ENTRY_SIZE, 0); + return false; + } + return true; } =20 --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692330; cv=none; d=zohomail.com; s=zohoarc; b=a8AQ3ZjSJO2m0e2cZyL1vMpoGFvFeW6vbh6VwmT3u1s5aNbCZVE1FwOYelbgodjQFv0qfbtSUAHx77r0TP/QOCDdLn74qbDVUQsXC7fYx+Ec8WkH4ws3Xm0EyxJ6spjyX6BxZmU1Eh1NwwqWa9XhvNjy3uUFHpcfOsNgVvWonYs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692330; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TDyjruV7w7paGoEpfcBCyEgnLqMWCeMdqSyQl2kakFc=; b=Bq9B1Z5Oy/2tASNfZr11/A7c8Pqq1I3BQdzAK9uA/Geamws2WgUALpmVoFoYKLEXYngTqMH7NgxrXVGGyv4Gh+ZzQMxZSiM01LJHC6QmKVtemyLGL2B401R0COmGmrqTgX2phha9R2osVDzQonleNCfdlK4jyHQfgxJ4nxGKpG4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692330125703.8000704319791; Sun, 5 Oct 2025 12:25:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UGR-00063d-KL; Sun, 05 Oct 2025 15:19:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFu-0004qI-Kn for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFr-0006gZ-Qe for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:50 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-151-Zs5pcooqON6506sQawg70Q-1; Sun, 05 Oct 2025 15:18:45 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3ecdd80ea44so2980037f8f.1 for ; Sun, 05 Oct 2025 12:18:44 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e619b8507sm222807075e9.3.2025.10.05.12.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691927; 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=TDyjruV7w7paGoEpfcBCyEgnLqMWCeMdqSyQl2kakFc=; b=fFhdCdnSt0s8J7GRiQsUrqQResEulZOaPud6/DGsn02bNC3hJxgz1nT+I5+fzo/Bwt7Bh8 LY6fG5I5jM5IR46YBAhLGhiXVCgfk6kDSEXi0nLwZTV/fuVlwMtcl5QHgRa0UQJSRva4uz UBslBmwPWUOpMoPh4NpJ2nKgQ5od144= X-MC-Unique: Zs5pcooqON6506sQawg70Q-1 X-Mimecast-MFC-AGG-ID: Zs5pcooqON6506sQawg70Q_1759691924 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691924; x=1760296724; 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=TDyjruV7w7paGoEpfcBCyEgnLqMWCeMdqSyQl2kakFc=; b=XvTYyccYF0Z9curdCvwxgw3Qc7c4HT0BhRxp7H1pbCB9BoGWVHRAeJvAHv4VEHmH0S xZStiIN7c/T2/dlf36TAc0XOAi8VOi0OGMN7TZ9Q9eF4Pw6YOfRKaR4P2MscB6yA9aiy HiEO3bYwb17Xb4g5wRQFChtJVtIqzF0aU4eqgehkqenhgRG/d2/DdWk5OhigUYuf5hh4 KtZmJYbnncfbzQuLx7dDNxpnq4z+vA7tm5cKIMKh+8QrAgit17e8bRrJ68V0JaY0Bayz xxyb8BlMCak1Xh756uZ+lcKuXB4876SSSVVb8Ntu/lzK/g3MalXCRAtb71vfjrVdOFDZ 80HA== X-Gm-Message-State: AOJu0Yzo9mSz92aNOK8wDEGdUwuY0Dv84GRYuRSFCZQ1wjtKZi/FHaE8 /6+zRJ/3uDRn2+ZWD7DQpjezN2ZhKSNNI1uBYnVYXazkNf7jNFnP62m4rg73FTmp++JLdsZ1GUq acJVXaHWu11sjSDr8ryUv9o/0+RSrfoG3OPySqOv5xi0v07tvc1oilW/2qiu8wDHR5Bu6fsF6pf +bs8fkQICZ1vMKnX0SfOHDc7MeHv9dJoXtGQ== X-Gm-Gg: ASbGnctFZFG6Lp7VhE7w8xbYlvA/9F2/lhRVE7JtLLqkVTkNxxzNnZ+NU/qSjLbtLN1 REr+OPPZ48ImtTPVevIntlTIHiSUpwD1GIdvRjTEKagUtOmkkerE+LSmjOKfT167ypIFT4MiKls pdvxXCuLctipcWVsCppdCosBCgvBgjA4FEUz/FwieDQrr5aP5pMuplDLQVTUGc7eRV+/8gEy+Hf eO4Qyi00XKtxvXOdxsxoGhe6AWhH2TGNE0OQcqP23Z3HgMMBcjmLZZjPAacz00Tm7MKTdd4WJ8r bFuFF1TFf8/UZ8lZJ7bHDnF+jyVhiIPj7wwZRq8= X-Received: by 2002:a5d:4745:0:b0:425:723b:377f with SMTP id ffacd0b85a97d-425723b3c83mr2536625f8f.11.1759691923607; Sun, 05 Oct 2025 12:18:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGavaIZuPXrtSDNvT4Pbz1xuageFJjpJ8C+Nc9iPN0i0tPe+NIieVQvLiwmxBIzGnKsl80Qbg== X-Received: by 2002:a5d:4745:0:b0:425:723b:377f with SMTP id ffacd0b85a97d-425723b3c83mr2536605f8f.11.1759691923000; Sun, 05 Oct 2025 12:18:43 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:41 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Li Zhaoxin , Miao Kezhan , Richard Henderson , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Paolo Bonzini Subject: [PULL 72/75] vdpa-dev: add get_vhost() callback for vhost-vdpa device Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, 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.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692340431116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Li Zhaoxin Commit c255488d67 "virtio: add vhost support for virtio devices" added the get_vhost() function, but it did not include vhost-vdpa devices. So when I use the vdpa device and query the status of the vdpa device with the x-query-virtio-status qmp command, since vdpa does not implement vhost_get, it will cause qemu to crash. Therefore, in order to obtain the status of the virtio device under vhost-v= dpa, we need to add a vhost_get implement for the vdpa device. Co-developed-by: Miao Kezhan Signed-off-by: Miao Kezhan Signed-off-by: Li Zhaoxin Reviewed-by: Michael S. Tsirkin Message-ID: <2778f817cb6740a15ecb37927804a67288b062d1.1758860411.git.lizhao= xin04@baidu.com> Signed-off-by: Michael S. Tsirkin --- hw/virtio/vdpa-dev.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/virtio/vdpa-dev.c b/hw/virtio/vdpa-dev.c index d1da40afc8..4a7b970976 100644 --- a/hw/virtio/vdpa-dev.c +++ b/hw/virtio/vdpa-dev.c @@ -338,6 +338,12 @@ static int vhost_vdpa_device_set_status(VirtIODevice *= vdev, uint8_t status) return 0; } =20 +static struct vhost_dev *vhost_vdpa_device_get_vhost(VirtIODevice *vdev) +{ + VhostVdpaDevice *s =3D VHOST_VDPA_DEVICE(vdev); + return &s->dev; +} + static const Property vhost_vdpa_device_properties[] =3D { DEFINE_PROP_STRING("vhostdev", VhostVdpaDevice, vhostdev), DEFINE_PROP_UINT16("queue-size", VhostVdpaDevice, queue_size, 0), @@ -369,6 +375,7 @@ static void vhost_vdpa_device_class_init(ObjectClass *k= lass, const void *data) vdc->set_config =3D vhost_vdpa_device_set_config; vdc->get_features =3D vhost_vdpa_device_get_features; vdc->set_status =3D vhost_vdpa_device_set_status; + vdc->get_vhost =3D vhost_vdpa_device_get_vhost; } =20 static void vhost_vdpa_device_instance_init(Object *obj) --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692338; cv=none; d=zohomail.com; s=zohoarc; b=A2HEKHARufsggq50e2/Xfdt6k7ywkm+BR8c2BFWARss+Tj8YiTEAjUeUy+fPbdaDnqWUwkqKzC6CILvjzAd3TN6laNwqqShPbNYPOtHjvEYZCpxNu2+u2Mldf/Cs6NbIIJbnvR+xhDQzOzpxQuKKZlCDG52jZY+Yif89EH8LbRA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692338; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=obTUsxxrjlh7aQvvij2ziCsIh2EBRs8F88q8/z1GRt4=; b=KLe48vM2QouPtwOTH8zxsBngbwRLeaOSIrw4Y0IgOAUS9P2UmsKydC+fTt3Jzcq1qTt0R9OZT0gLWAE/PoWABaKbXVTVjoAzszmJbP37yiI3AXhXKb2wtztlYtCTDn1N5Io6QbvRAzRINgQ6+RH0mYhgX4K4h78o7mnHAJkYZxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692338006635.2740922220825; Sun, 5 Oct 2025 12:25:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UGT-0006Bv-5d; Sun, 05 Oct 2025 15:19: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 1v5UFv-0004qQ-Kq for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFu-0006gr-2b for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:51 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-490-b_JwMbsFN3OZvfxgeaO6Yw-1; Sun, 05 Oct 2025 15:18:47 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-46e39567579so18717225e9.0 for ; Sun, 05 Oct 2025 12:18:46 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46f9c8873f1sm22294475e9.8.2025.10.05.12.18.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691928; 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=obTUsxxrjlh7aQvvij2ziCsIh2EBRs8F88q8/z1GRt4=; b=GrUDUa4MCGRRS7T+8lfDpcS6lpVyWy5j9nuRiUgAbnA+v+RVy77tmNScIrKeSSB5ej+bB7 nwEABCtkRqJPEWe5PqRB0H+iUBEHxisGL0jJWNr0jVRvw+M+yXldTCG6PEOAkf8Lfr5usX hM8gh5MPofDAtErfPUiFCFKWkYi4oUA= X-MC-Unique: b_JwMbsFN3OZvfxgeaO6Yw-1 X-Mimecast-MFC-AGG-ID: b_JwMbsFN3OZvfxgeaO6Yw_1759691926 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691926; x=1760296726; 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=obTUsxxrjlh7aQvvij2ziCsIh2EBRs8F88q8/z1GRt4=; b=VrFm4amiGW1nPVd2U8VaClD/YPuEehO1dRbcJ3J/UW3Qc0TWhjAvgWUk5Z+BjNfhX7 E+UYZd3fzGIw13rBICaTWbjfBvWydFR8D6KLoBznd/URZOeyKGKg0wZeeVjaqOnXJ6dw +Mi+yVwnLC7KpVJMVGO4q96AyX4xBKB0GhmH7qcx659zPUiNHATdMi2LccsqteoXxBZ0 lNbIP0tDe4UaLuN0QkZ3OPakZ5Upuenqyvn+d9vD109zTZ7m17jgZNMfFKaGzkq6UMR0 4gZPYViiw4qs0Ak4YERE2ccwqOPi+MPPlrT6vAAjg2YaNebAhYC5TNlM6XXRQ/pcCr4L LpNQ== X-Gm-Message-State: AOJu0YymkHUqXeaiw7fF6LQbnnstxP6PT6c1qgvO9Xg3gyahrDuRyyd3 ovu2VW0PQWos6hiwP383fBzuI1buu92rd0QMk92KubWluvOGh679UKu/Px98W9T/LLLQC/V5HJu q722yokJBeOQMkT1qfZ3yoBCBgFyl8sj45bYH2x22lK7CvCLVGMovpEmdZtoV/pUTGi57XzO+yG WvUU7TXQOBtnYnskqRzRGG5mMcpnxryq9O9Q== X-Gm-Gg: ASbGncui32gTA0o3g6jEGQQPaSu5dwFnLeab0vp40yJxUHyZLTNKdFgH7UQJvug9ggr 59GVWOu194QcVBJa3kN8ObWP5x/K2i8srR3K1ipDMJBFR6pKr3vcJmNCXxlCYWdLvYshJFd3Z1+ Gpl8ClnDwpga4pTuLqjFbfz//yQ2uvjHyk0oVEH2UCkT3tKY04nrPjnTAj1u5ZmQDHcCuUCzh/V 3iFQJwLR/NDfFWpD+V6LEBitXZeEtEJERTlwih2LQr0IaAkPGLFBYdfC+/DUfPbtJ89HnVqU3Iv fia3HXIxN86nnIWJS82Lm0TDp+yxM/IFn7VBYLE= X-Received: by 2002:a05:600c:a319:b0:46e:74cc:42b8 with SMTP id 5b1f17b1804b1-46e74cc4609mr51037755e9.17.1759691925547; Sun, 05 Oct 2025 12:18:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE3b8UNRIUlz/l7Hjal07dfYT6s313t1JItGYWTgsWam82yO9GgutgfMoSPHevyfoVSOvDjJA== X-Received: by 2002:a05:600c:a319:b0:46e:74cc:42b8 with SMTP id 5b1f17b1804b1-46e74cc4609mr51037595e9.17.1759691925080; Sun, 05 Oct 2025 12:18:45 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:43 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhenzhong Duan , =?utf-8?Q?Cl=C3=A9ment?= Mathieu--Drif , Jason Wang , Yi Liu , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 73/75] intel_iommu: Enable Enhanced Set Root Table Pointer Support (ESRTPS) Message-ID: <3dfe95622ad5bf9dc6fb9bb0f74605aa07d2d3f7.1759691708.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692339789116600 From: Zhenzhong Duan According to VTD spec rev 4.1 section 6.6: "For implementations reporting the Enhanced Set Root Table Pointer Support (ESRTPS) field as Clear, on a 'Set Root Table Pointer' operation, software must perform a global invalidate of the context cache, PASID-cache (if applicable), and IOTLB, in that order. This is required to ensure hardware references only the remapping structures referenced by the new root table pointer and not stale cached entries. For implementations reporting the Enhanced Set Root Table Pointer Support (ESRTPS) field as Set, as part of 'Set Root Table Pointer' operation, hardware performs global invalidation on all DMA remapping translation caches and hence software is not required to perform additional invalidations" We already implemented ESRTPS capability in vtd_handle_gcmd_srtp() by calling vtd_reset_caches(), just set ESRTPS in DMAR_CAP_REG to avoid unnecessary global invalidation requests of context, PASID-cache and IOTLB from guest. This change doesn't impact migration as the content of DMAR_CAP_REG is migrated too. Signed-off-by: Zhenzhong Duan Reviewed-by: Cl=C3=A9ment Mathieu--Drif Reviewed-by: Michael S. Tsirkin Message-ID: <20250929034206.439266-2-zhenzhong.duan@intel.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu_internal.h | 1 + hw/i386/intel_iommu.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index 0d0069a612..0f6a1237e4 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -215,6 +215,7 @@ #define VTD_CAP_DRAIN_WRITE (1ULL << 54) #define VTD_CAP_DRAIN_READ (1ULL << 55) #define VTD_CAP_FS1GP (1ULL << 56) +#define VTD_CAP_ESRTPS (1ULL << 63) #define VTD_CAP_DRAIN (VTD_CAP_DRAIN_READ | VTD_CAP_DRAIN_WR= ITE) #define VTD_CAP_CM (1ULL << 7) #define VTD_PASID_ID_SHIFT 20 diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index fa2ad9c2eb..0378551038 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -4660,7 +4660,7 @@ static void vtd_cap_init(IntelIOMMUState *s) =20 s->cap =3D VTD_CAP_FRO | VTD_CAP_NFR | VTD_CAP_ND | VTD_CAP_MAMV | VTD_CAP_PSI | VTD_CAP_SLLPS | - VTD_CAP_MGAW(s->aw_bits); + VTD_CAP_ESRTPS | VTD_CAP_MGAW(s->aw_bits); if (s->dma_drain) { s->cap |=3D VTD_CAP_DRAIN; } --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692214; cv=none; d=zohomail.com; s=zohoarc; b=Mu610XxKwGt+jB/MC4F6w7iRfvLaKP8jfaZP+bL8wO/3uIzTo9Q6I7B6jFGDXzqCVce9lYLDWi4Q1ygHel821B3nqwEOCkEWJZYmA3xt8UfNEmzr6xoZ18aiwVQWGNoHya2XEx6hJ+QFnRh1kSoCeI3Gr4KUeF7s1zj1Bpc3Bew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692214; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5Fg8f/5q/T+Nvc5JsmIqdVO9saXZfQkqf6SsdokQXeo=; b=Uro+md52tBrKf6iEXsUOdAsMSbIGFZ74JGL26RByxnOySLadZQiLFmpch2WGyh5QaZmY7Dw70R6/ZpB25pfeUggDhQbPudXDuAHSjZPeXMBUA9IBcKt/izOXUkyO8DqCe6Vd9JBpovWs1mzlJpitmneZFOomZFyWLsxJofMsrTI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692214310151.8406557371818; Sun, 5 Oct 2025 12:23:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UGY-0006Wc-0a; Sun, 05 Oct 2025 15:19:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFy-0004tj-5v for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v5UFv-0006hL-Ie for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:53 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-14-jfHLh8PePD6vhj6hQ_F3pA-1; Sun, 05 Oct 2025 15:18:49 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-46e4cc8ed76so16595185e9.1 for ; Sun, 05 Oct 2025 12:18:49 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4255d8f017esm17972123f8f.47.2025.10.05.12.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691931; 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=5Fg8f/5q/T+Nvc5JsmIqdVO9saXZfQkqf6SsdokQXeo=; b=btEx6MG8ZZG9gJmDFr921roqi2oM1ZG9x6ACtX2/uxpJ2JhHQLW7BTwls20Fe5ESYRPVc2 XzKlCjF8TVXrKzn0gBBmZSm/8c8pVO7QwZjxC4Nizfz19Hu6uYwa2TKbi60QaB0LlK2LxP 9ToXUxur9jwJU4+bQTTucdaNqfY0Sps= X-MC-Unique: jfHLh8PePD6vhj6hQ_F3pA-1 X-Mimecast-MFC-AGG-ID: jfHLh8PePD6vhj6hQ_F3pA_1759691928 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691928; x=1760296728; 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=5Fg8f/5q/T+Nvc5JsmIqdVO9saXZfQkqf6SsdokQXeo=; b=jv3eI5ftoOoePbcE9Ah+CwaS26DWqawYZGAAPapx89R9iwWMa+9W39GwjUG2aQJYm5 Yj+c6fZbnYONNoSl8J8jkWv/bD2B/xxE/OZIh4g/8TgKUwXBVN+pCnZf6DrzbbUemfJh hTKcAzlOQI/ZvsC432vlR6z9SXZFEZ3sMuS3lX1yGJdVBlNvGUaFxgH0iEuNGVfaxZ0E ybaKcEb3DkufVX0qhfpGAz41P+eDHFJYtFy+u4NkPCnoX9Jvhhp3i5zWhQlWAUkR/m/s Up2mkTk5GTjQvZvFIcoipaxZHMkK+btP1tEA3a5AX7wBCvDqeGuWDPOg5zwnT4+BpHOC 36gA== X-Gm-Message-State: AOJu0Yx9BazlNAvAnd6u6wyjWoRwSrAO3vX9AXKOp+KtOnG8uutRIYQ9 sQCNL4871U5RE1nr6qnaVTgIALe+mrOvYf4ZsfJ2zsEFkLsCww/w8wnldMnLN3aprRJ5FJSj0mB LAk4a7gamVodwXXgo8EFacW8MzhVl3fgkzpaEvS0ew+SzDyGJikszgy0PT/vtQQ3rMUmjrGA1MK cAbPHKmsKkgapfIDchPLxwqGmcaTY7GGajpw== X-Gm-Gg: ASbGncvMvCLFCZ7d+sAZTL/d3/AEfxaYx3pFb5KujuFwXU8zTR6M+EfCfd8XFO8XHjb dQ5//kPZElqDPI//M8GDmbFJeAIL3QnuHT1wNvsnuvenEqiqGHMdlLjYDlCZYd6ja7A+xFvwayv ydUa+MaD+alFjpNIBmRwYz7N3rqxeC/v1GGQ9L5WxSknmwgpVC+uZ5VgUR+s06JVpoYChBEy8/5 A8GRDTEgthhuzrqUVCKP+7zFPVg6RvL0hOssgCdlCM8HAz0O/H00JJNiKo8XXRsF7Q2wNaPDW/y CSyOUgusLckyrQaEM1AQMGLr+EBl/8+VPM2mxJU= X-Received: by 2002:a05:600c:468e:b0:43c:ec4c:25b4 with SMTP id 5b1f17b1804b1-46e71102467mr68711075e9.10.1759691927837; Sun, 05 Oct 2025 12:18:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwTmvbVFdLroY3aGz4reKz3B8s5qBAydnmBV0tUrDRt4asYdmV2FjiRJDcnOU8pQuev3+2pg== X-Received: by 2002:a05:600c:468e:b0:43c:ec4c:25b4 with SMTP id 5b1f17b1804b1-46e71102467mr68710855e9.10.1759691927282; Sun, 05 Oct 2025 12:18:47 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:45 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhenzhong Duan , Jason Wang , Yi Liu , =?utf-8?Q?Cl=C3=A9ment?= Mathieu--Drif , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum Subject: [PULL 74/75] intel_iommu: Simplify caching mode check with VFIO device Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692217819116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Zhenzhong Duan In early days, we had different tricks to ensure caching-mode=3Don with VFIO device: 28cf553afe ("intel_iommu: Sanity check vfio-pci config on machine init done= ") c6cbc29d36 ("pc/q35: Disallow vfio-pci hotplug without VT-d caching mode") There is also a patch with the same purpose but for VDPA device: b8d78277c0 ("intel-iommu: fail MAP notifier without caching mode") Because without caching mode, MAP notifier won't work correctly since guest won't send IOTLB update event when it establishes new mappings in the I/O p= age tables. Now with host IOMMU device interface between VFIO and vIOMMU, we can simpli= fy first two commits above with a small check in set_iommu_device(). This also works for future IOMMUFD backed VDPA implementation which may also need cac= hing mode on. But for legacy VDPA we still need commit b8d78277c0 as it doesn't use the host IOMMU device interface. For coldplug VFIO device: qemu-system-x86_64: -device vfio-pci,host=3D0000:3b:00.0,id=3Dhostdev3,bu= s=3Droot0,iommufd=3Diommufd0: vfio 0000:3b:00.0: Failed to set vIOMMU: Devi= ce assignment is not allowed without enabling caching-mode=3Don for Intel I= OMMU. For hotplug VFIO device: if "iommu=3Doff" is configured in guest, Error: vfio 0000:3b:00.0: Failed to set vIOMMU: Device assignment is no= t allowed without enabling caching-mode=3Don for Intel IOMMU. else Error: vfio 0000:3b:00.0: memory listener initialization failed: Region= vtd-00.0-dmar: device 01.00.0 requires caching mode: Operation not support= ed The specialty for hotplug is due to the check in commit b8d78277c0 happen b= efore the check in set_iommu_device. Signed-off-by: Zhenzhong Duan Reviewed-by: Michael S. Tsirkin Message-ID: <20250929034206.439266-3-zhenzhong.duan@intel.com> Signed-off-by: Michael S. Tsirkin --- hw/i386/intel_iommu.c | 40 ++++++---------------------------------- hw/i386/pc.c | 20 -------------------- 2 files changed, 6 insertions(+), 54 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 0378551038..6a168d5107 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -87,13 +87,6 @@ struct vtd_iotlb_key { static void vtd_address_space_refresh_all(IntelIOMMUState *s); static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n); =20 -static void vtd_panic_require_caching_mode(void) -{ - error_report("We need to set caching-mode=3Don for intel-iommu to enab= le " - "device assignment with IOMMU protection."); - exit(1); -} - static void vtd_define_quad(IntelIOMMUState *s, hwaddr addr, uint64_t val, uint64_t wmask, uint64_t w1cmask) { @@ -4489,6 +4482,12 @@ static bool vtd_dev_set_iommu_device(PCIBus *bus, vo= id *opaque, int devfn, =20 assert(hiod); =20 + if (!s->caching_mode) { + error_setg(errp, "Device assignment is not allowed without enablin= g " + "caching-mode=3Don for Intel IOMMU."); + return false; + } + vtd_iommu_lock(s); =20 if (g_hash_table_lookup(s->vtd_host_iommu_dev, &key)) { @@ -5244,32 +5243,6 @@ static bool vtd_decide_config(IntelIOMMUState *s, Er= ror **errp) return true; } =20 -static int vtd_machine_done_notify_one(Object *child, void *unused) -{ - IntelIOMMUState *iommu =3D INTEL_IOMMU_DEVICE(x86_iommu_get_default()); - - /* - * We hard-coded here because vfio-pci is the only special case - * here. Let's be more elegant in the future when we can, but so - * far there seems to be no better way. - */ - if (object_dynamic_cast(child, "vfio-pci") && !iommu->caching_mode) { - vtd_panic_require_caching_mode(); - } - - return 0; -} - -static void vtd_machine_done_hook(Notifier *notifier, void *unused) -{ - object_child_foreach_recursive(object_get_root(), - vtd_machine_done_notify_one, NULL); -} - -static Notifier vtd_machine_done_notify =3D { - .notify =3D vtd_machine_done_hook, -}; - static void vtd_realize(DeviceState *dev, Error **errp) { MachineState *ms =3D MACHINE(qdev_get_machine()); @@ -5324,7 +5297,6 @@ static void vtd_realize(DeviceState *dev, Error **err= p) pci_setup_iommu(bus, &vtd_iommu_ops, dev); /* Pseudo address space under root PCI bus. */ x86ms->ioapic_as =3D vtd_host_dma_iommu(bus, s, Q35_PSEUDO_DEVFN_IOAPI= C); - qemu_add_machine_init_done_notifier(&vtd_machine_done_notify); } =20 static void vtd_class_init(ObjectClass *klass, const void *data) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index eb36d50589..34b00663f2 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1722,25 +1722,6 @@ static void pc_machine_wakeup(MachineState *machine) cpu_synchronize_all_post_reset(); } =20 -static bool pc_hotplug_allowed(MachineState *ms, DeviceState *dev, Error *= *errp) -{ - X86IOMMUState *iommu =3D x86_iommu_get_default(); - IntelIOMMUState *intel_iommu; - - if (iommu && - object_dynamic_cast((Object *)iommu, TYPE_INTEL_IOMMU_DEVICE) && - object_dynamic_cast((Object *)dev, "vfio-pci")) { - intel_iommu =3D INTEL_IOMMU_DEVICE(iommu); - if (!intel_iommu->caching_mode) { - error_setg(errp, "Device assignment is not allowed without " - "enabling caching-mode=3Don for Intel IOMMU."); - return false; - } - } - - return true; -} - static void pc_machine_class_init(ObjectClass *oc, const void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); @@ -1760,7 +1741,6 @@ static void pc_machine_class_init(ObjectClass *oc, co= nst void *data) x86mc->apic_xrupt_override =3D true; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler =3D pc_get_hotplug_handler; - mc->hotplug_allowed =3D pc_hotplug_allowed; mc->auto_enable_numa_with_memhp =3D true; mc->auto_enable_numa_with_memdev =3D true; mc->has_hotpluggable_cpus =3D true; --=20 MST From nobody Fri Nov 14 22:12:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1759692051; cv=none; d=zohomail.com; s=zohoarc; b=L6y4eKorx4YZXO0nR5R/62uokSMshOcJlBlRI93cttnQ09ywIYh+57WLxEgikw+G6XgrFgFtYBIvi7wW6RBitLeaT2bR9SGgVrFvfLIbL5B494ojYiLW46ShZtv7cKs1H/p7CWmeRcuWzCAnQnu29C469tZh0NmLb4PaBzwAyHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759692051; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ghXDZ+n9Et0LsGtFaG9r3BwQQMqcSZpR9BTBqrZEGYw=; b=e+1tUVRmy1WaHz089Rb4imsU+gCw7SbbkDSH9cG/uX7pnnPKCLgy/mLEuBPHk7kZwfeDKGDi8P0eg7DNSUNkkHIAR6t0e+mmKYntwrj3bwawfvIp09FBrFTlfA/LUvOmU+H6vrx3AlAJqO5Pz6+UcLizq2LcIk2S2rS/BNQIt8I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759692051899158.1313558612784; Sun, 5 Oct 2025 12:20:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5UGF-0005Yo-Jk; Sun, 05 Oct 2025 15:19: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 1v5UG0-00050I-2f for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:19:01 -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 1v5UFx-0006hg-Uk for qemu-devel@nongnu.org; Sun, 05 Oct 2025 15:18:55 -0400 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-556-Q2GlvWCMMZyR__UzuSS6cw-1; Sun, 05 Oct 2025 15:18:51 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3efe4fcc9ccso2224274f8f.3 for ; Sun, 05 Oct 2025 12:18:51 -0700 (PDT) Received: from redhat.com ([2a0d:6fc0:1518:6900:b69a:73e1:9698:9cd3]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e61a0204fsm225317325e9.14.2025.10.05.12.18.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Oct 2025 12:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1759691932; 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=ghXDZ+n9Et0LsGtFaG9r3BwQQMqcSZpR9BTBqrZEGYw=; b=cTQOy6d8KEfX4Abufso4KpIgZ4nFV8XRjlNSGBSjRrg0D03LCBD5kUSfrTvzobQWVA80R/ tAu+UPNSUk9W+7ELxWPO9A0B+0DdDx5Grns4ISHOF8Z0wp+Sb7X+ttFI2a2nJWJyIjOLb5 mdw28dWM1bdH28kpPLjNu6aDYdpj5Ao= X-MC-Unique: Q2GlvWCMMZyR__UzuSS6cw-1 X-Mimecast-MFC-AGG-ID: Q2GlvWCMMZyR__UzuSS6cw_1759691930 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759691930; x=1760296730; 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=ghXDZ+n9Et0LsGtFaG9r3BwQQMqcSZpR9BTBqrZEGYw=; b=VFA2p/MKaUgwJ3Yzsjh+obQnJqozRr4ZUVSWb4E1wKdPEGuVGJrG62JrLdkwSJeVaI RBwln48tCwbP2WiGCqLLbz8JbWIGhqSRgxJ+k4kw7QxLqGxFMkpPUmYggraYQyxHvDBN h1+WVqWfcV9XPBYsmuD7yDLCMurMumdwGFxW1Db54rEIYYMymHRoY5WaaL+01/cafKex LqRwrd2jv/NqksHzsDHRsF/lrnQiNscXCUu+/5D5f/PayHhXahR46bM9bq2TG1aSQigl Yb18tBZ4bnJWGt5J1d5TRZmVpjOJpZ4mtHWxY74EPJdBBwOZ4/uk+27tbMlcVuZEOfCe VUZg== X-Gm-Message-State: AOJu0YyWkF4Q0wQJPMXvej68aZW2T8eID28aCmogyjYMtb11lEm47y5i mQtQ3evXzVEEx8vGxtAUaTdODCJsMBlrpM6sPUzdP8eSn8/pdFUetr80EqcgSxMT3TchibVhJEa fBd7XALgU922O4sVVzhHIqTO7biA1ykRyPSa9x4hdavpmR+c37sYbGiPpVmT7Rr0c+kPd9/Gwm1 2VJGtshh/LGn19MktQpCEuCY8Ets05TBnZEw== X-Gm-Gg: ASbGncscNUiMCj3uZ4XMi1GSA+bVQftOeIgMYoFZkw/5BHFeO29bj9y0bAJqzvCykqf Kw3GNMOj1oFIGU/8OPFKCGkPuX3lJET3/8yIXkasLJRce6IZyWHFq+2gtB5Kwn8iUp3gWgGXtP8 SzGhm9B+4TR75Px6lhJDASfcuQp4h3C+AqMWVlYOuqR7vmZpdCU+dvS6p6rceF/oQDgzdPoyRWx PievtVIpGTk+AQMsxPRHXTqzmUx9Ck6oplZZp3e/yFxsSX37pn89iwsoHVX9amTLbpt/p2tDh/3 BAWT7NJ/1CbY5aEHALDLwS17MqKmp3E8cRNUDsw= X-Received: by 2002:a05:6000:18a6:b0:3ee:2ae2:3f34 with SMTP id ffacd0b85a97d-4256712a506mr6269172f8f.13.1759691929750; Sun, 05 Oct 2025 12:18:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBzNbQKJDOIT8Dh77yaeD0wFsFKznaKetafHFSKQ6Qrke3lsZgPmvcg1aVxZ7xK+sGtvQ9tA== X-Received: by 2002:a05:6000:18a6:b0:3ee:2ae2:3f34 with SMTP id ffacd0b85a97d-4256712a506mr6269155f8f.13.1759691929139; Sun, 05 Oct 2025 12:18:49 -0700 (PDT) Date: Sun, 5 Oct 2025 15:18:47 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Zhenzhong Duan , =?utf-8?Q?Cl=C3=A9ment?= Mathieu--Drif , Marcel Apfelbaum Subject: [PULL 75/75] pci: Fix wrong parameter passing to pci_device_get_iommu_bus_devfn() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.43, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1759692055610116600 From: Zhenzhong Duan The 2nd parameter of pci_device_get_iommu_bus_devfn() about root PCIBus backed by an IOMMU for the PCI device, the 3rd is about aliased PCIBus of the PCI device. Meanwhile the 3rd and 4th parameters are optional, pass NULL if they are not needed. Reviewed-by: Cl=C3=A9ment Mathieu--Drif Reviewed-by: Michael S. Tsirkin Message-ID: <20250929034206.439266-4-zhenzhong.duan@intel.com> Fixes: a849ff5d6f ("pci: Add a pci-level initialization function for IOMMU = notifiers") Fixes: f0f37daf8e ("pci: Add a PCI-level API for PRI") Fixes: e9b457500a ("pci: Add a pci-level API for ATS") Fixes: 042cbc9aec ("pci: Add an API to get IOMMU's min page size and virtua= l address width") Signed-off-by: Michael S. Tsirkin --- hw/pci/pci.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 4854d3d618..541e03b38c 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2964,7 +2964,7 @@ int pci_iommu_init_iotlb_notifier(PCIDevice *dev, IOM= MUNotifier *n, PCIBus *iommu_bus; int devfn; =20 - pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn); + pci_device_get_iommu_bus_devfn(dev, &iommu_bus, &bus, &devfn); if (iommu_bus && iommu_bus->iommu_ops->init_iotlb_notifier) { iommu_bus->iommu_ops->init_iotlb_notifier(bus, iommu_bus->iommu_op= aque, devfn, n, fn, opaque); @@ -3022,7 +3022,7 @@ int pci_pri_request_page(PCIDevice *dev, uint32_t pas= id, bool priv_req, return -EPERM; } =20 - pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn); + pci_device_get_iommu_bus_devfn(dev, &iommu_bus, &bus, &devfn); if (iommu_bus && iommu_bus->iommu_ops->pri_request_page) { return iommu_bus->iommu_ops->pri_request_page(bus, iommu_bus->iommu_opaq= ue, @@ -3046,7 +3046,7 @@ int pci_pri_register_notifier(PCIDevice *dev, uint32_= t pasid, return -EPERM; } =20 - pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn); + pci_device_get_iommu_bus_devfn(dev, &iommu_bus, &bus, &devfn); if (iommu_bus && iommu_bus->iommu_ops->pri_register_notifier) { iommu_bus->iommu_ops->pri_register_notifier(bus, iommu_bus->iommu_opaqu= e, @@ -3063,7 +3063,7 @@ void pci_pri_unregister_notifier(PCIDevice *dev, uint= 32_t pasid) PCIBus *iommu_bus; int devfn; =20 - pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn); + pci_device_get_iommu_bus_devfn(dev, &iommu_bus, &bus, &devfn); if (iommu_bus && iommu_bus->iommu_ops->pri_unregister_notifier) { iommu_bus->iommu_ops->pri_unregister_notifier(bus, iommu_bus->iommu_opa= que, @@ -3095,7 +3095,7 @@ ssize_t pci_ats_request_translation(PCIDevice *dev, u= int32_t pasid, return -EPERM; } =20 - pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn); + pci_device_get_iommu_bus_devfn(dev, &iommu_bus, &bus, &devfn); if (iommu_bus && iommu_bus->iommu_ops->ats_request_translation) { return iommu_bus->iommu_ops->ats_request_translation(bus, iommu_bus->iommu_opaq= ue, @@ -3119,7 +3119,7 @@ int pci_iommu_register_iotlb_notifier(PCIDevice *dev,= uint32_t pasid, return -EPERM; } =20 - pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn); + pci_device_get_iommu_bus_devfn(dev, &iommu_bus, &bus, &devfn); if (iommu_bus && iommu_bus->iommu_ops->register_iotlb_notifier) { iommu_bus->iommu_ops->register_iotlb_notifier(bus, iommu_bus->iommu_opaque, devfn, @@ -3141,7 +3141,7 @@ int pci_iommu_unregister_iotlb_notifier(PCIDevice *de= v, uint32_t pasid, return -EPERM; } =20 - pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn); + pci_device_get_iommu_bus_devfn(dev, &iommu_bus, &bus, &devfn); if (iommu_bus && iommu_bus->iommu_ops->unregister_iotlb_notifier) { iommu_bus->iommu_ops->unregister_iotlb_notifier(bus, iommu_bus->iommu_o= paque, @@ -3155,11 +3155,9 @@ int pci_iommu_unregister_iotlb_notifier(PCIDevice *d= ev, uint32_t pasid, int pci_iommu_get_iotlb_info(PCIDevice *dev, uint8_t *addr_width, uint32_t *min_page_size) { - PCIBus *bus; PCIBus *iommu_bus; - int devfn; =20 - pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn); + pci_device_get_iommu_bus_devfn(dev, &iommu_bus, NULL, NULL); if (iommu_bus && iommu_bus->iommu_ops->get_iotlb_info) { iommu_bus->iommu_ops->get_iotlb_info(iommu_bus->iommu_opaque, addr_width, min_page_size); --=20 MST