From nobody Wed Nov 27 12:31:23 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=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1699032439; cv=none; d=zohomail.com; s=zohoarc; b=BOJGHsI3c4wJZN2ComrZUYV+t1s8Ez71ZjhPkWAbRDdCVb/S7gYIq61uPo/A01cFTn9a7uAMSbXkf5n3HS8wuE/wKhe9CmL9/z9QRr2tcyPYtbVXSoCAo3GnO5RGPjl3t35O3/ra+tujpK0wqBlfW6hyG47vP0JYaoH4lLDXH2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699032439; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VQ8U6TsWXtq1HA2j1RNZDOT7Jz4968sKn2BoxPTNcrc=; b=mPLnPHPVw6r6eyAi8LE/vIMVvSPg3UnooAiBzQZXAu8aiymyq7kz/V2TMlRwzqNzA2K5z+LYMV9sY74eZrNHhu5iNK8M/SHSfhTk9GE5jBAWTHp2JeTbXomTJG72OQ8MUFbrOEMyzAOQ8owXKG30SaoU+CteBNfbAhr8wTOm3Ik= ARC-Authentication-Results: i=1; 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 header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 169903243964017.6399029362766; Fri, 3 Nov 2023 10:27:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.627281.978208 (Exim 4.92) (envelope-from ) id 1qyxw5-0000sa-98; Fri, 03 Nov 2023 17:26:21 +0000 Received: by outflank-mailman (output) from mailman id 627281.978208; Fri, 03 Nov 2023 17:26:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qyxw5-0000sT-5q; Fri, 03 Nov 2023 17:26:21 +0000 Received: by outflank-mailman (input) for mailman id 627281; Fri, 03 Nov 2023 17:26:19 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qyxw3-0000sN-GV for xen-devel@lists.xenproject.org; Fri, 03 Nov 2023 17:26:19 +0000 Received: from esa1.hc3370-68.iphmx.com (esa1.hc3370-68.iphmx.com [216.71.145.142]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1621c9e3-7a6e-11ee-98d8-6d05b1d4d9a1; Fri, 03 Nov 2023 18:26:15 +0100 (CET) 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: 1621c9e3-7a6e-11ee-98d8-6d05b1d4d9a1 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1699032375; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=yN70GOoQktKPfAW3IF83IxnbcNK56YwJ2jVGY4KfhVk=; b=KY5Z5suq8r46jpa+02Pawk4IgTY3QXrYcPKnMdONNiVwsayDBVdYnQep 5MCkxx1HlNYO2HO9OGjE/Ek2254Jooskk2gz0vdpYnwUPTMzOfxBN/PS0 JiJ5GJNHI4WHLiNFoL5Qi1QVAZhRR7RrcYujZ4bfZL8yXFy9nQ9pzlQrb Y=; X-CSE-ConnectionGUID: 3puI7Y9fT5KL74H8rEvnbA== X-CSE-MsgGUID: ESGCXgn2QkqXPlMKtyqIYQ== Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 127951790 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.159.70 X-Policy: $RELAYED X-ThreatScanner-Verdict: Negative IronPort-Data: A9a23:gfXooKyZ7XODwkksTO16t+cpxirEfRIJ4+MujC+fZmUNrF6WrkVWz TAdXzzTbPbZYmShL9tyb4q+9hxU68OByd5mHFdv+CAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjPzOHvykTrecZkidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw/zF8EgHUMja4mtC5QVnPasT5jcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KTpW6 N1HGWEDUk2go73q4OKhZ/dqjO12eaEHPKtH0p1h5TTQDPJgSpHfWaTao9Rf2V/chOgXQ6yYP ZBAL2MyPVKfO3WjOX9OYH46tP2vnWK5dzRXpUiKrK4zy2PS0BZwwP7mN9+9ltmiHJ8KzxvB+ TOel4j/KjwhG/evxjzfy3G1ttfLuADnSZszJYTto5aGh3XMnzdOWXX6T2CTsfS/z0KzRd9bA 0gV4TY167g/8lSxSdvwVAH+p2SL1jYHQMZZGeA+7ACLy4LX7hyfC2xCSSROAPQ+vdIybSwn0 BmOhdyBLSVitaDQRX+D+7O8qzS0Ni4Ia2gYakc5oRAtuoe55ttp11SWE4clT/bdYsDJ9S/Ym CiXjXcP1rsv0O0viPmbrUrqnTSmj82cJuIq3Tk7Tl5J/ysgOt/0P9fwuQGLhRpTBNzHFAXf5 hDoj+DbvLhUU8zX/MCYaLxVROnB2hqTDNHLbbeD9bEK8C6k/zaYZZpR5j5lTKuCGp1fIWCwC KM/VBk42XOyAJdJRfUsC25JI552pZUM7Py8PhwuUvJAY4JqaCiM9zx0aEib0gjFyRZ9wfBiY c/HL5jyVh727JiLKxLvGY8gPUIDn31lmws/u7igp/hY7VZuTCHMEupUWLd/Rus48LmFsG3oz jqrDOPTk083eLSnMkHqHXs7cQhiwY4TWcqn9KS6t4erfmJbJY3WI6WNkeJ6K9w5zv09eyWh1 ijVZ3K0AWHX3RXvQThmoFg6AF8zdf6TdU4GABE= IronPort-HdrOrdr: A9a23:GT6fT6D6ScllFPHlHelW55DYdb4zR+YMi2TDt3oddfWaSKylfq GV7ZAmPHrP4gr5N0tOpTntAse9qBDnhPtICOsqTNSftWDd0QPFEGgL1+DfKlbbak/DH4BmtJ uJc8JFeaDN5VoRt7eH3OFveexQv+Vu88qT9JnjJ28Gd3AMV0n5hT0JcTpyFCdNNW97LKt8Lr WwzOxdqQGtfHwGB/7LfEXsD4D41qT2fIuNW29/OyIa X-Talos-CUID: 9a23:yBnY4WGGh5DFzFqzqmI87FM1RfF0fEGA71OPf2/oE0t3Tre8HAo= X-Talos-MUID: 9a23:6ap0tQYoaHs0LOBTmgTDrwFtMp1R4L2eMEQosokXoui1DHkl X-IronPort-AV: E=Sophos;i="6.03,273,1694750400"; d="scan'208";a="127951790" From: Ross Lagerwall To: CC: Stefano Stabellini , Anthony Perard , Paul Durrant , , Ross Lagerwall Subject: [PATCH] xen/pt: Emulate multifunction bit in header type Date: Fri, 3 Nov 2023 17:26:01 +0000 Message-ID: <20231103172601.1319375-1-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1699032441312100001 Content-Type: text/plain; charset="utf-8" The intention of the code appears to have been to unconditionally set the multifunction bit but since the emulation mask is 0x00 it has no effect. Instead, emulate the bit and set it based on the multifunction property of the PCIDevice (which can be set using QAPI). This allows making passthrough devices appear as functions in a Xen guest. Signed-off-by: Ross Lagerwall Reviewed-by: Paul Durrant --- hw/xen/xen_pt_config_init.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c index 2b8680b112fa..e6ec32e3ccd2 100644 --- a/hw/xen/xen_pt_config_init.c +++ b/hw/xen/xen_pt_config_init.c @@ -291,7 +291,10 @@ static int xen_pt_header_type_reg_init(XenPCIPassthrou= ghState *s, uint32_t *data) { /* read PCI_HEADER_TYPE */ - *data =3D reg->init_val | 0x80; + *data =3D reg->init_val; + if ((PCI_DEVICE(s)->cap_present & QEMU_PCI_CAP_MULTIFUNCTION)) { + *data |=3D PCI_HEADER_TYPE_MULTI_FUNCTION; + } return 0; } =20 @@ -676,7 +679,7 @@ static XenPTRegInfo xen_pt_emu_reg_header0[] =3D { .size =3D 1, .init_val =3D 0x00, .ro_mask =3D 0xFF, - .emu_mask =3D 0x00, + .emu_mask =3D PCI_HEADER_TYPE_MULTI_FUNCTION, .init =3D xen_pt_header_type_reg_init, .u.b.read =3D xen_pt_byte_reg_read, .u.b.write =3D xen_pt_byte_reg_write, --=20 2.41.0