From nobody Sat Apr 27 16:33:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1656236886886957.3316690868138; Sun, 26 Jun 2022 02:48:06 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.356071.584080 (Exim 4.92) (envelope-from ) id 1o5Orp-0008Pz-AD; Sun, 26 Jun 2022 09:47:45 +0000 Received: by outflank-mailman (output) from mailman id 356071.584080; Sun, 26 Jun 2022 09:47:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o5Orp-0008Ps-7Y; Sun, 26 Jun 2022 09:47:45 +0000 Received: by outflank-mailman (input) for mailman id 356071; Sun, 26 Jun 2022 09:47:44 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o5Oro-0008Pg-JA for xen-devel@lists.xenproject.org; Sun, 26 Jun 2022 09:47:44 +0000 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [2a00:1450:4864:20::62b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 05b43fd0-f535-11ec-b725-ed86ccbb4733; Sun, 26 Jun 2022 11:47:43 +0200 (CEST) Received: by mail-ej1-x62b.google.com with SMTP id pk21so13245534ejb.2 for ; Sun, 26 Jun 2022 02:47:42 -0700 (PDT) Received: from localhost.localdomain (dynamic-078-055-174-013.78.55.pool.telefonica.de. [78.55.174.13]) by smtp.gmail.com with ESMTPSA id t4-20020a17090605c400b00706242d297fsm3504752ejt.212.2022.06.26.02.47.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jun 2022 02:47:41 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 05b43fd0-f535-11ec-b725-ed86ccbb4733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8y1YigI7ttxs3tTld6DKvzpRpRRmju3jx/o0m9Wy9os=; b=pCD3TQyytOn6s8CgipMMRlMe8ipJcM/lIt7qDuGLUPIXeg+yWx4ZdloptdUVNTKaDd sIqtC44UFMxDUCcPpiTrv/DTyFcxvk14BVhRcpSdhEXoaf908w64RBTvxNgIDr4RrQ+A qDHr74I4ghmr96AdkqiCMd+wk7vx9jqomIqAHyHMSFhdEvknJijiil+FPfF99ISYxHqD dxrbvGTN3OF/WlTnvJ/82NPHYogw5Rh3UyRYTonV0et257btT/LL3q1q00H1Vb6HENGr B58hlzz3kx3m7E0zYwSsRIvtuKla1CQeAPPct1v6EAPf4hH3zdy3eMn4TTSbjKGM1GgT gqvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8y1YigI7ttxs3tTld6DKvzpRpRRmju3jx/o0m9Wy9os=; b=k6A3N3CZoC7bUtV3EClLFpfGIJjPUs/3XJj+jh938e1yEudPIcSKraRB0dNvFCauJi 1hZbWxvGLy6oUluWEhUc8GZv2f1n+6E5TS8XYYSD1nFHKAK/b87C9bJqiAehPLX6Tpc4 j0K5VkHVRxSWNq1FPiahUb46MbR3r0DZ4++F3gIf2zZHUkvI2TMwoea3FEDsU66C2I6J HB9gQC/xKeOW7kCrSDpOkf390K1DVY4/kK2wt8w5URhcnFCs2uzCXGrd45ID3iYSrGZ5 hA6KTYt4rmqiQySra7YEnh/eir0TneYzRi1XZODI7R3Be0xM7RFG72WE7AulY+Th4u3E FMag== X-Gm-Message-State: AJIora9hEx/r1iCVzd2wXYkJDydFkBw9xWVxV+nBI3TbcAKPD+bhcXsZ OCpRMudY9iUua+Ladw4DviE= X-Google-Smtp-Source: AGRyM1v6iTzO4uMHp2vLzEWX53KPy01bIP+vC0hI0N/lRCRouLltezCBvCVoffSlli5cWMnSFE53BA== X-Received: by 2002:a17:907:968a:b0:722:e508:fc15 with SMTP id hd10-20020a170907968a00b00722e508fc15mr7614907ejc.188.1656236861608; Sun, 26 Jun 2022 02:47:41 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Richard Henderson , xen-devel@lists.xenproject.org, qemu-trivial@nongnu.org, Eduardo Habkost , Marcel Apfelbaum , Stefano Stabellini , Paolo Bonzini , "Michael S. Tsirkin" , Anthony Perard , Paul Durrant , Bernhard Beschow Subject: [PATCH 1/2] hw/i386/xen/xen-hvm: Allow for stubbing xen_set_pci_link_route() Date: Sun, 26 Jun 2022 11:46:55 +0200 Message-Id: <20220626094656.15673-2-shentey@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220626094656.15673-1-shentey@gmail.com> References: <20220626094656.15673-1-shentey@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1656236887917100002 Content-Type: text/plain; charset="utf-8" The only user of xen_set_pci_link_route() is xen_piix_pci_write_config_client() which implements PIIX-specific logic in the xen namespace. This makes xen-hvm depend on PIIX which could be avoided if xen_piix_pci_write_config_client() was implemented in PIIX. In order to do this, xen_set_pci_link_route() needs to be stubbable which this patch addresses. Signed-off-by: Bernhard Beschow Reviewed-by: Paul Durrant --- hw/i386/xen/xen-hvm.c | 7 ++++++- include/hw/xen/xen.h | 1 + include/hw/xen/xen_common.h | 6 ------ stubs/xen-hw-stub.c | 5 +++++ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 0731f70410..204fda7949 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -161,11 +161,16 @@ void xen_piix_pci_write_config_client(uint32_t addres= s, uint32_t val, int len) } v &=3D 0xf; if (((address + i) >=3D PIIX_PIRQCA) && ((address + i) <=3D PIIX_P= IRQCD)) { - xen_set_pci_link_route(xen_domid, address + i - PIIX_PIRQCA, v= ); + xen_set_pci_link_route(address + i - PIIX_PIRQCA, v); } } } =20 +int xen_set_pci_link_route(uint8_t link, uint8_t irq) +{ + return xendevicemodel_set_pci_link_route(xen_dmod, xen_domid, link, ir= q); +} + int xen_is_pirq_msi(uint32_t msi_data) { /* If vector is 0, the msi is remapped into a pirq, passed as diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index 0f9962b1c1..13bffaef53 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -21,6 +21,7 @@ extern enum xen_mode xen_mode; extern bool xen_domid_restrict; =20 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num); +int xen_set_pci_link_route(uint8_t link, uint8_t irq); void xen_piix3_set_irq(void *opaque, int irq_num, int level); void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int = len); void xen_hvm_inject_msi(uint64_t addr, uint32_t data); diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h index 179741ff79..77ce17d8a4 100644 --- a/include/hw/xen/xen_common.h +++ b/include/hw/xen/xen_common.h @@ -316,12 +316,6 @@ static inline int xen_set_pci_intx_level(domid_t domid= , uint16_t segment, device, intx, level); } =20 -static inline int xen_set_pci_link_route(domid_t domid, uint8_t link, - uint8_t irq) -{ - return xendevicemodel_set_pci_link_route(xen_dmod, domid, link, irq); -} - static inline int xen_inject_msi(domid_t domid, uint64_t msi_addr, uint32_t msi_data) { diff --git a/stubs/xen-hw-stub.c b/stubs/xen-hw-stub.c index 15f3921a76..743967623f 100644 --- a/stubs/xen-hw-stub.c +++ b/stubs/xen-hw-stub.c @@ -23,6 +23,11 @@ void xen_piix_pci_write_config_client(uint32_t address, = uint32_t val, int len) { } =20 +int xen_set_pci_link_route(uint8_t link, uint8_t irq) +{ + return -1; +} + void xen_hvm_inject_msi(uint64_t addr, uint32_t data) { } --=20 2.36.1 From nobody Sat Apr 27 16:33:46 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1656236888281409.170375985968; Sun, 26 Jun 2022 02:48:08 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.356072.584091 (Exim 4.92) (envelope-from ) id 1o5Orq-0000Er-Gg; Sun, 26 Jun 2022 09:47:46 +0000 Received: by outflank-mailman (output) from mailman id 356072.584091; Sun, 26 Jun 2022 09:47:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o5Orq-0000Ej-Dv; Sun, 26 Jun 2022 09:47:46 +0000 Received: by outflank-mailman (input) for mailman id 356072; Sun, 26 Jun 2022 09:47:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1o5Orp-0008Pg-Aa for xen-devel@lists.xenproject.org; Sun, 26 Jun 2022 09:47:45 +0000 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [2a00:1450:4864:20::62f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 06577fdf-f535-11ec-b725-ed86ccbb4733; Sun, 26 Jun 2022 11:47:43 +0200 (CEST) Received: by mail-ej1-x62f.google.com with SMTP id u15so13171799ejc.10 for ; Sun, 26 Jun 2022 02:47:43 -0700 (PDT) Received: from localhost.localdomain (dynamic-078-055-174-013.78.55.pool.telefonica.de. [78.55.174.13]) by smtp.gmail.com with ESMTPSA id t4-20020a17090605c400b00706242d297fsm3504752ejt.212.2022.06.26.02.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jun 2022 02:47:42 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 06577fdf-f535-11ec-b725-ed86ccbb4733 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GE5xBWjtG9WBcqQI8QpdzBg3P6kzmtE86vK5W8A22FE=; b=a4377qvEOvu3e1RTfuQHxJNPGsEaFzLBzKYodFBIEb2E1GNijJZcTVwGr5bD9befZ0 JpJaEMJNHnDTjVdJnoPxuQPvBYdl9U6yXsj9p2qGi79fPrVYpM3QAmOAT2ppnrTn0D3P U7JQCpBP09rFtCwCEL0pih2PVJ2uPi3Hbay6sEHcBhdodIs8k+DLz/JFcavfnOjaCg17 nESFOkVfPHUvWU2OMNEkN4gb5Lus7Eu0GK6ro3W5Ebh/44PCoV4lrM6ld8wJpZmpvSfJ jbiSB0EdpEEM1cZpiH8vVpw1KfH+YF5T11FlSFr2nPntX8U9XqUDtbFLv7Q2NZyfB0VR /YEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GE5xBWjtG9WBcqQI8QpdzBg3P6kzmtE86vK5W8A22FE=; b=rTUrnQJsuzDgxkwP41lEUy+j/0GHyTEx7eYijco+Pud1vzL8ZDHs42qKwCnlYmfHRt 7s8B59lzn6hYfvOsAX155rs4gVxIuoGCrNyKwOC9VnkR7WRV8/hzG6+wOMO1WiQHlGHr Pqc5Rpt2eCw+JJzscVIDhZiOR8HfOFKaluh4nUmQqBZcZNqe31hTegHLjvWVBZ/1GWXO Q2FF2hsGz1ThfFjcDL/DIsbvJxSy20JMXKGtaJtEOMvHJnRAbdCm3du2oIBH7ltBFxLS Aj6gRgJBGYnr1on03FkVzv3MfU1XEVObt6x89AXmNlGfsHG6kV9FVZ/axb136lk4t7vk OeXA== X-Gm-Message-State: AJIora+nTMfccD7NnbWrAG8rEKRvXIe9JDqRr2ZW719b2gThRlYg0JBg cVh6cWRr/LrNEmupO3qSHOU= X-Google-Smtp-Source: AGRyM1u8/kthGc0kpB9GQ15WfHOOb7ssiu2IAI5tCBcbMUyhhCKcEeCpk68TInH1f8s1P+3vxGqdmg== X-Received: by 2002:a17:906:b05a:b0:718:cc6b:61e0 with SMTP id bj26-20020a170906b05a00b00718cc6b61e0mr7378413ejb.501.1656236862769; Sun, 26 Jun 2022 02:47:42 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Richard Henderson , xen-devel@lists.xenproject.org, qemu-trivial@nongnu.org, Eduardo Habkost , Marcel Apfelbaum , Stefano Stabellini , Paolo Bonzini , "Michael S. Tsirkin" , Anthony Perard , Paul Durrant , Bernhard Beschow Subject: [PATCH 2/2] hw/i386/xen/xen-hvm: Inline xen_piix_pci_write_config_client() and remove it Date: Sun, 26 Jun 2022 11:46:56 +0200 Message-Id: <20220626094656.15673-3-shentey@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220626094656.15673-1-shentey@gmail.com> References: <20220626094656.15673-1-shentey@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1656236889594100005 Content-Type: text/plain; charset="utf-8" xen_piix_pci_write_config_client() is implemented in the xen sub tree and uses PIIX constants internally, thus creating a direct dependency on PIIX. Now that xen_set_pci_link_route() is stubbable, the logic of xen_piix_pci_write_config_client() can be moved to PIIX which resolves the dependency. Signed-off-by: Bernhard Beschow Acked-by: Michael S. Tsirkin Reviewed-by: Paul Durrant --- hw/i386/xen/xen-hvm.c | 18 ------------------ hw/isa/piix3.c | 15 ++++++++++++++- include/hw/xen/xen.h | 1 - stubs/xen-hw-stub.c | 4 ---- 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 204fda7949..e4293d6d66 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -15,7 +15,6 @@ #include "hw/pci/pci.h" #include "hw/pci/pci_host.h" #include "hw/i386/pc.h" -#include "hw/southbridge/piix.h" #include "hw/irq.h" #include "hw/hw.h" #include "hw/i386/apic-msidef.h" @@ -149,23 +148,6 @@ void xen_piix3_set_irq(void *opaque, int irq_num, int = level) irq_num & 3, level); } =20 -void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int = len) -{ - int i; - - /* Scan for updates to PCI link routes (0x60-0x63). */ - for (i =3D 0; i < len; i++) { - uint8_t v =3D (val >> (8 * i)) & 0xff; - if (v & 0x80) { - v =3D 0; - } - v &=3D 0xf; - if (((address + i) >=3D PIIX_PIRQCA) && ((address + i) <=3D PIIX_P= IRQCD)) { - xen_set_pci_link_route(address + i - PIIX_PIRQCA, v); - } - } -} - int xen_set_pci_link_route(uint8_t link, uint8_t irq) { return xendevicemodel_set_pci_link_route(xen_dmod, xen_domid, link, ir= q); diff --git a/hw/isa/piix3.c b/hw/isa/piix3.c index 6388558f92..48f9ab1096 100644 --- a/hw/isa/piix3.c +++ b/hw/isa/piix3.c @@ -138,7 +138,20 @@ static void piix3_write_config(PCIDevice *dev, static void piix3_write_config_xen(PCIDevice *dev, uint32_t address, uint32_t val, int len) { - xen_piix_pci_write_config_client(address, val, len); + int i; + + /* Scan for updates to PCI link routes (0x60-0x63). */ + for (i =3D 0; i < len; i++) { + uint8_t v =3D (val >> (8 * i)) & 0xff; + if (v & 0x80) { + v =3D 0; + } + v &=3D 0xf; + if (((address + i) >=3D PIIX_PIRQCA) && ((address + i) <=3D PIIX_P= IRQCD)) { + xen_set_pci_link_route(address + i - PIIX_PIRQCA, v); + } + } + piix3_write_config(dev, address, val, len); } =20 diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index 13bffaef53..afdf9c436a 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -23,7 +23,6 @@ extern bool xen_domid_restrict; int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num); int xen_set_pci_link_route(uint8_t link, uint8_t irq); void xen_piix3_set_irq(void *opaque, int irq_num, int level); -void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int = len); void xen_hvm_inject_msi(uint64_t addr, uint32_t data); int xen_is_pirq_msi(uint32_t msi_data); =20 diff --git a/stubs/xen-hw-stub.c b/stubs/xen-hw-stub.c index 743967623f..34a22f2ad7 100644 --- a/stubs/xen-hw-stub.c +++ b/stubs/xen-hw-stub.c @@ -19,10 +19,6 @@ void xen_piix3_set_irq(void *opaque, int irq_num, int le= vel) { } =20 -void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int = len) -{ -} - int xen_set_pci_link_route(uint8_t link, uint8_t irq) { return -1; --=20 2.36.1