From nobody Fri Apr 3 22:21:23 2026 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=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1774274666; cv=none; d=zohomail.com; s=zohoarc; b=frz+WbAjyKHkBpycu5ODtTKrRDvra1J+BP0PdEcoSoisbs1Wp8YSxadPvxrQjn70QoYGrjDJawCNNGTcSLRPd3o8BAKKjC+VAx5iWumKkShVTn7CPWY5D1oB4pDQ5gno16fV9X5WmbrFGCm7tdS2W/m4PHeptQgG1VxTjDDMKZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774274666; h=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=DLb4Xz56FicxDJh1EcJd2k8Rmdkqnc0+6TN1HYuGNCw=; b=eUuTidwGgupwDugjqGhx2tdrKga9Qp4dseBB7+opxYROOHbApC//8bdd2Sa7U1jCy4iDn2N5nOD04GPia5WhqfomSJ/WClhTlL43WLqFwkxBt2Am95+6L7bivXscCgIGe+NiI/22qlm8yL0TfXpplvEzlwQgV7tflA3XVClQRy0= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1774274666439983.7785932289405; Mon, 23 Mar 2026 07:04:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w4foR-0008V3-9c; Mon, 23 Mar 2026 09:59:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w4fnz-0008FH-7a for qemu-devel@nongnu.org; Mon, 23 Mar 2026 09:58:57 -0400 Received: from linux.microsoft.com ([13.77.154.182]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w4fnx-0006q3-2I for qemu-devel@nongnu.org; Mon, 23 Mar 2026 09:58:54 -0400 Received: from DESKTOP-TUU1E5L.localdomain (unknown [167.220.208.76]) by linux.microsoft.com (Postfix) with ESMTPSA id 49F1920B7001; Mon, 23 Mar 2026 06:58:49 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 49F1920B7001 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1774274332; bh=DLb4Xz56FicxDJh1EcJd2k8Rmdkqnc0+6TN1HYuGNCw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bNpHuoI0CjuyVef9jXpvTbtEeEGAcU8V6+voQWSnxvzYoYAe1H/VJIzj8oOayT3f3 6rghs2smdRVgvJmDwsQjzOTF+NA6k+okOLNQG2Rv7LPFCp1wzNKwmDJ+LzwXbEKvp1 WSASlAQ7AyQKpktO6WM7d7hUo2JyWSUh2o98P9VQ= From: Magnus Kulke To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Wei Liu , Richard Henderson , Marcelo Tosatti , Marcel Apfelbaum , Wei Liu , Alex Williamson , Paolo Bonzini , Zhao Liu , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Magnus Kulke , Magnus Kulke , "Michael S. Tsirkin" Subject: [RFC 09/32] accel/mshv: update s->irq_routes in update_msi_route Date: Mon, 23 Mar 2026 14:57:49 +0100 Message-Id: <20260323135812.383509-10-magnuskulke@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260323135812.383509-1-magnuskulke@linux.microsoft.com> References: <20260323135812.383509-1-magnuskulke@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=13.77.154.182; envelope-from=magnuskulke@linux.microsoft.com; helo=linux.microsoft.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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: qemu development 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 @linux.microsoft.com) X-ZM-MESSAGEID: 1774274669337154100 Content-Type: text/plain; charset="utf-8" The state's irq_routes field will be updated when an irqchip's gsi is requested to be updated with a new dest/vector. The old set_msi_routing() fn is redundant and can be removed. Signed-off-by: Magnus Kulke --- accel/mshv/irq.c | 87 +++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 49 deletions(-) diff --git a/accel/mshv/irq.c b/accel/mshv/irq.c index 9d6bdde27a..b5a047b367 100644 --- a/accel/mshv/irq.c +++ b/accel/mshv/irq.c @@ -36,52 +36,6 @@ void mshv_init_msicontrol(void) msi_control->updated =3D false; } =20 -static int set_msi_routing(uint32_t gsi, uint64_t addr, uint32_t data) -{ - struct mshv_user_irq_entry *entry; - uint32_t high_addr =3D addr >> 32; - uint32_t low_addr =3D addr & 0xFFFFFFFF; - GHashTable *gsi_routes; - - trace_mshv_set_msi_routing(gsi, addr, data); - - if (gsi >=3D MSHV_MAX_MSI_ROUTES) { - error_report("gsi >=3D MSHV_MAX_MSI_ROUTES"); - return -1; - } - - assert(msi_control); - - WITH_QEMU_LOCK_GUARD(&msi_control_mutex) { - gsi_routes =3D msi_control->gsi_routes; - entry =3D g_hash_table_lookup(gsi_routes, GINT_TO_POINTER(gsi)); - - if (entry - && entry->address_hi =3D=3D high_addr - && entry->address_lo =3D=3D low_addr - && entry->data =3D=3D data) - { - /* nothing to update */ - return 0; - } - - /* free old entry */ - g_free(entry); - - /* create new entry */ - entry =3D g_new0(struct mshv_user_irq_entry, 1); - entry->gsi =3D gsi; - entry->address_hi =3D high_addr; - entry->address_lo =3D low_addr; - entry->data =3D data; - - g_hash_table_insert(gsi_routes, GINT_TO_POINTER(gsi), entry); - msi_control->updated =3D true; - } - - return 0; -} - static int add_msi_routing(uint64_t addr, uint32_t data) { struct mshv_user_irq_entry *route_entry; @@ -370,16 +324,51 @@ void mshv_irqchip_release_virq(int virq) remove_msi_routing(virq); } =20 +static int update_routing_entry(MshvState *s, + struct mshv_user_irq_entry *new_entry) +{ + struct mshv_user_irq_entry *entry; + int n; + + for (n =3D 0; n < s->irq_routes->nr; n++) { + entry =3D &s->irq_routes->entries[n]; + if (entry->gsi !=3D new_entry->gsi) { + continue; + } + + if (!memcmp(entry, new_entry, sizeof *entry)) { + return 0; + } + + *entry =3D *new_entry; + + return 0; + } + + return -ESRCH; +} + int mshv_irqchip_update_msi_route(int virq, MSIMessage msg, PCIDevice *dev) { + uint32_t addr_hi =3D msg.address >> 32; + uint32_t addr_lo =3D msg.address & 0xFFFFFFFF; + uint32_t data =3D le32_to_cpu(msg.data); + struct mshv_user_irq_entry entry =3D { + .gsi =3D virq, + .address_hi =3D addr_hi, + .address_lo =3D addr_lo, + .data =3D data, + }; int ret; =20 - ret =3D set_msi_routing(virq, msg.address, le32_to_cpu(msg.data)); + ret =3D update_routing_entry(mshv_state, &entry); if (ret < 0) { - error_report("Failed to set msi routing"); - return -1; + error_report("Failed to set msi routing for gsi %d", virq); + abort(); } =20 + trace_mshv_set_msi_routing(virq, msg.address, data); + return 0; } =20 --=20 2.34.1