From nobody Sun Nov 24 09:52:07 2024 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=beckhoff.com ARC-Seal: i=1; a=rsa-sha256; t=1724325879; cv=none; d=zohomail.com; s=zohoarc; b=S5ls/k9WR4R2svkHen8zGAQlKtTJQOnCNzlfnxoyD5uOO7vcF0fJ4sqXKQbIK5BjJpNh6Q6FefVdxEUj2hWN9ubismpsN8vRWDfzx6NFPZ4Z1K0Gq2FP65osO8syhCkiZPgIhCyw6NXxjC6lruqnQT5h5Tp89k5ZofzOC07tOiA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724325879; 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=dw5PZHWoP2rzADIQR+kXL/3fIW9nweVv3qfNfRdXkvc=; b=Jahx5b0EHc43U6g5ZTaNoUbdVyXwnlHf0uRAnlTfcu7lb37HTJ+TWqgljPU5kLxGCu4cN2CvOa4YY+vAVcW6/VOdOrKVReGPqGbtSlu83fCu4P/Kjv/tJy23qeaUkwMbeKEA5BtgOZLDzWywqbMcK5Fsa22hl9AeI38b8EBXhj4= 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 1724325879961873.0390245440577; Thu, 22 Aug 2024 04:24:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sh5v3-00081r-3k; Thu, 22 Aug 2024 07:23:57 -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 1sh5uz-000800-4C for qemu-devel@nongnu.org; Thu, 22 Aug 2024 07:23:53 -0400 Received: from netsrv01.beckhoff.com ([62.159.14.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sh5ux-00035I-1A for qemu-devel@nongnu.org; Thu, 22 Aug 2024 07:23:52 -0400 Received: from 172.17.5.170 by netsrv01.beckhoff.com (Tls12, Aes256, Sha384, DiffieHellmanEllipticKey384); Thu, 22 Aug 2024 11:18:47 GMT Received: from corvink-nb.c.koehne.headscale.beckhoff.dev (172.17.61.20) by ex04.beckhoff.com (172.17.5.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 22 Aug 2024 13:18:45 +0200 DKIM-Signature: v=1; c=relaxed/relaxed; d=beckhoff.com; s=mail2022e; t=1724325527; bh=dw5PZHWoP2rzADIQR+kXL/3fIW9nweVv3qfNfRdXkvc=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=ed25519-sha256; b= kWR/p8E1onAwPsiJOGVZ2nb3lzu9tDs0Jl6BPeTJ9eEY7mU0gqdX9VUwfb1NPJi3WTKzD7r79Ld45HIj85ITDw== DKIM-Signature: v=1; c=relaxed/relaxed; d=beckhoff.com; s=mail2022r; t=1724325527; bh=dw5PZHWoP2rzADIQR+kXL/3fIW9nweVv3qfNfRdXkvc=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=rsa-sha256; b= raaLW5tcWy3JgbPEVhV5nGgClqjRMdNehdkTUOu3GTqIgsDGswEV6v7wTAr2IVRaUcAy4ibqF+TOGe45Vhyq/Gxp0+SS7sbtevda9JgW+3/9FlT5+w8x9RFU+7AjgD7k4FbPfOlR2CwGSLtt4NOBWKkQgbwExSqzJXZwHPEh1OTjjNPP6jvBPmjXys1DtGR8kl/XUVDnqmxDwzPy6VTS6SNN0AG0UxKIP41ZoSl1usGUzH2yGQitTCU6RoFf98LBaXbudLQyyhi/Y1MKI0qMP8O5Tp88q5XP+mSh8UJrkm0f915L198d+tS7IMSnAVtffw/Rh4icSL2/Fa0jPBUx2w== From: =?UTF-8?q?Corvin=20K=C3=B6hne?= To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 1/7] vfio/igd: return an invalid generation for unknown devices Date: Thu, 22 Aug 2024 13:08:26 +0200 Message-ID: <20240822111819.34306-2-c.koehne@beckhoff.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240822111819.34306-1-c.koehne@beckhoff.com> References: <20240822111819.34306-1-c.koehne@beckhoff.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [172.17.61.20] X-ClientProxiedBy: ex01.beckhoff.com (172.17.2.168) To ex04.beckhoff.com (172.17.5.170) X-OLX-Disclaimer: EX04.BECKHOFF.COM 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=62.159.14.10; envelope-from=C.Koehne@beckhoff.com; helo=netsrv01.beckhoff.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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 @beckhoff.com) X-ZM-MESSAGEID: 1724325881738116600 Content-Type: text/plain; charset="utf-8" =EF=BB=BFIntel changes it's specification quite often e.g. the location and= size of the BDSM register has change for gen 11 devices and later. This causes our emulation to fail on those devices. So, it's impossible for us to use a suitable default value for unknown devices. Instead of returning a random generation value and hoping that everthing works fine, we should verify that different devices are working and add them to our list of known devices. Signed-off-by: Corvin K=C3=B6hne --- hw/vfio/igd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index d320d032a7..650a323dda 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -90,7 +90,11 @@ static int igd_gen(VFIOPCIDevice *vdev) return 8; } =20 - return 8; /* Assume newer is compatible */ + /* + * Unfortunately, Intel changes it's specification quite often. This m= akes + * it impossible to use a suitable default value for unknown devices. + */ + return -1; } =20 typedef struct VFIOIGDQuirk { --=20 2.46.0 This email contains confidential information. If you have received it in er= ror, you must not read, use, copy or pass on this e-mail or its attachments= . If you have received the e-mail in error, please inform me immediately by= reply e-mail and then delete this e-mail from your system. Thank you =20 Diese E-Mail enth=C3=A4lt vertrauliche Informationen. Sollten Sie sie irrt= =C3=BCmlich erhalten haben, d=C3=BCrfen Sie diese E-Mail oder ihre Anh=C3= =A4nge nicht lesen, verwenden, kopieren oder weitergeben. Sollten Sie die M= ail versehentlich erhalten haben, teilen Sie mir dies bitte umgehend per An= twort-E-Mail mit und l=C3=B6schen Sie diese E-Mail dann aus Ihrem System. V= ielen Dank Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Bec= khoff Registered office: Verl, Germany | Register court: Guetersloh HRA 7075 From nobody Sun Nov 24 09:52:07 2024 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=beckhoff.com ARC-Seal: i=1; a=rsa-sha256; t=1724325879; cv=none; d=zohomail.com; s=zohoarc; b=NmQQa+VQgH6oNZzI//jTzNKvSWq9fYZB4g32Sf7sKoGIBBX/Q2tkBqGPr0eq56oau0PSNwzBXMQ86tphnnbjMZj7KO6McO/uOj1/bI7xtQP5tl836oG0f57IAo8i9yYhnStQjux6cI46aetLhQ4mHJqM2YPk27F8lxIEtI2WZrg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724325879; 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=AWbZyhEyhRSnXlYcrTmec6OE0eilRfZnjfvknaWGikc=; b=PhXqPAXodnBf8ci7N8xFCpmD+LaWsKn/L1YxCKPZ9p0ak9NkeJLZGqrSamhA7JYmcRaV1j/irapLIvS155tnitDbmcQxFzmdbX9SZLzM0fwptX8hgaa878IXCGuJUuUmMKtTRbVAHihpA7Ehw4f3TN85coxsqI5774JgsSzXggM= 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 1724325879699213.00776412006508; Thu, 22 Aug 2024 04:24:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sh5v6-00088r-9c; Thu, 22 Aug 2024 07:24:00 -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 1sh5v1-000811-ED for qemu-devel@nongnu.org; Thu, 22 Aug 2024 07:23:55 -0400 Received: from netsrv01.beckhoff.com ([62.159.14.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sh5uz-00035I-L8 for qemu-devel@nongnu.org; Thu, 22 Aug 2024 07:23:55 -0400 Received: from 172.17.5.170 by netsrv01.beckhoff.com (Tls12, Aes256, Sha384, DiffieHellmanEllipticKey384); Thu, 22 Aug 2024 11:18:47 GMT Received: from corvink-nb.c.koehne.headscale.beckhoff.dev (172.17.61.20) by ex04.beckhoff.com (172.17.5.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 22 Aug 2024 13:18:45 +0200 DKIM-Signature: v=1; c=relaxed/relaxed; d=beckhoff.com; s=mail2022e; t=1724325527; bh=AWbZyhEyhRSnXlYcrTmec6OE0eilRfZnjfvknaWGikc=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=ed25519-sha256; b= Z9dmkT9WkwrOCkEd48M54Ukez3tvQaKBftghlKrE4316v8W6h95JB/7u40f+2PhAr3KxuFgrEKh0WdxlLDpoBQ== DKIM-Signature: v=1; c=relaxed/relaxed; d=beckhoff.com; s=mail2022r; t=1724325527; bh=AWbZyhEyhRSnXlYcrTmec6OE0eilRfZnjfvknaWGikc=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=rsa-sha256; b= FHlzjauIl3Lc2nGih3lK2Ew1LhnAYXvoje45y2t0gWCF5sPwARqLOi8x58cNlFfLY98C7XvZk/raIU62oeWvYPYTMm6JRTCz/vmQ2meuqWbXcSUKQc3rueZP75JlFh6WyosIXdR04BSxM3mhCoBQqMIqQKfuQ84A8myEHdNjZHlBJv+vSBnqeqFskLaHSEmzUzds1Sfn6QIUpUeZL2Q0zOzy9J3aA34cz6RPoX0q3h4APMIlViIiud+wzg1IreOlmkUP9vZEvypfT7RyXS4CIAw40wmFBt8xnY5pEJb9m0WuPS01DKCCqsLi0c8SN5B8eBc/VUMmEjaspTDOR2+8Eg== From: =?UTF-8?q?Corvin=20K=C3=B6hne?= To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 2/7] vfio/igd: support legacy mode for all known generations Date: Thu, 22 Aug 2024 13:08:27 +0200 Message-ID: <20240822111819.34306-3-c.koehne@beckhoff.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240822111819.34306-1-c.koehne@beckhoff.com> References: <20240822111819.34306-1-c.koehne@beckhoff.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [172.17.61.20] X-ClientProxiedBy: ex01.beckhoff.com (172.17.2.168) To ex04.beckhoff.com (172.17.5.170) X-OLX-Disclaimer: EX04.BECKHOFF.COM 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=62.159.14.10; envelope-from=C.Koehne@beckhoff.com; helo=netsrv01.beckhoff.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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 @beckhoff.com) X-ZM-MESSAGEID: 1724325881827116600 Content-Type: text/plain; charset="utf-8" =EF=BB=BFWe're soon going to add support for legacy mode to ElkhartLake and TigerLake devices. Those are gen 11 and 12 devices. At the moment, all devices identified by our igd_gen function do support legacy mode. This won't change when adding our new devices of gen 11 and 12. Therefore, it makes more sense to accept legacy mode for all known devices instead of maintaining a long list of known good generations. If we add a new generation to igd_gen which doesn't support legacy mode for some reason, it'll be easy to advance the check to reject legacy mode for this specific generation. Signed-off-by: Corvin K=C3=B6hne --- hw/vfio/igd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 650a323dda..d5e57656a8 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -416,7 +416,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) * devices maintain compatibility with generation 8. */ gen =3D igd_gen(vdev); - if (gen !=3D 6 && gen !=3D 8) { + if (gen =3D=3D -1) { error_report("IGD device %s is unsupported in legacy mode, " "try SandyBridge or newer", vdev->vbasedev.name); return; --=20 2.46.0 This email contains confidential information. If you have received it in er= ror, you must not read, use, copy or pass on this e-mail or its attachments= . If you have received the e-mail in error, please inform me immediately by= reply e-mail and then delete this e-mail from your system. Thank you =20 Diese E-Mail enth=C3=A4lt vertrauliche Informationen. Sollten Sie sie irrt= =C3=BCmlich erhalten haben, d=C3=BCrfen Sie diese E-Mail oder ihre Anh=C3= =A4nge nicht lesen, verwenden, kopieren oder weitergeben. Sollten Sie die M= ail versehentlich erhalten haben, teilen Sie mir dies bitte umgehend per An= twort-E-Mail mit und l=C3=B6schen Sie diese E-Mail dann aus Ihrem System. V= ielen Dank Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Bec= khoff Registered office: Verl, Germany | Register court: Guetersloh HRA 7075 From nobody Sun Nov 24 09:52:07 2024 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=beckhoff.com ARC-Seal: i=1; a=rsa-sha256; t=1724325880; cv=none; d=zohomail.com; s=zohoarc; b=e9piJUDm0LWLk5GeHBLAxjebD6TzWBvRJJjh929Uam+z1SiyU89wUApJ10WP1joKvAKatkXOwcY6zmZiBYos8kNXDUanHnAtEJQgXBWIJu1gsu0NCQdRQBt/H5e78yLz6szr+stoUcd+kH2eM1UakVC+aVOzVE6uHdYszixhXDg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724325880; 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=7yYl05lZacMAh3tZlu2XKHEwlxzsHcRZiBDxfb3o9dE=; b=QuDzpfYt9V026lrprr3V0orkHgzFNukOdTjvOx/dom11LgNa+ZEJu8z9aN9ZfbJp68KltCeE7+lB2mrjKabWzOugYqj2tHd8h0IptyXmekWdtISJLruUwwMV1VNzc7cze/PSvMbxxFiEHFX3Mc4543hPqY6jcCS2WQPe6cXMzrE= 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 1724325880066540.428591333084; Thu, 22 Aug 2024 04:24:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sh5v7-0008Lc-U3; Thu, 22 Aug 2024 07:24: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 1sh5v2-00081q-NY for qemu-devel@nongnu.org; Thu, 22 Aug 2024 07:23:56 -0400 Received: from netsrv01.beckhoff.com ([62.159.14.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sh5v0-00035m-E4 for qemu-devel@nongnu.org; Thu, 22 Aug 2024 07:23:56 -0400 Received: from 172.17.5.170 by netsrv01.beckhoff.com (Tls12, Aes256, Sha384, DiffieHellmanEllipticKey384); Thu, 22 Aug 2024 11:18:48 GMT Received: from corvink-nb.c.koehne.headscale.beckhoff.dev (172.17.61.20) by ex04.beckhoff.com (172.17.5.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 22 Aug 2024 13:18:45 +0200 DKIM-Signature: v=1; c=relaxed/relaxed; d=beckhoff.com; s=mail2022e; t=1724325528; bh=7yYl05lZacMAh3tZlu2XKHEwlxzsHcRZiBDxfb3o9dE=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=ed25519-sha256; b= Zryj9VyxiMxrTqpJPCgGKXAOTZ7WGiQcbOQRSdVzs6ktjwv9fC+/x4lCenqvjaivIVn4ioT/BOJZW3S4qGJMCw== DKIM-Signature: v=1; c=relaxed/relaxed; d=beckhoff.com; s=mail2022r; t=1724325528; bh=7yYl05lZacMAh3tZlu2XKHEwlxzsHcRZiBDxfb3o9dE=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=rsa-sha256; b= JnessnGXxQLupbFF5mUsnvSIX3XnqKKhR5rejxSkAyGQXkBJYHfRsK0Hc6Xvk7G5qsLcNybjppIoxa0PCoO+PEaJ/gjP35V3etC/SWssO1pqlpxe0cqDRXyrJIYIQVArFpFIP9RlbWtEQbUhXwPXC86kKeRuPxdlxnzngyBgjUF1xzcmiPRi2sqJOrgoHg2twWtKUb/aJudrVLGTWXM7XlXiVJA/z/5D2u/NHAFGfAjUGG/Ba2TFNUfRwXwAPTAiyRfObFlzv62mg8XwOLCojyybXwWi2OHdMOFNkOQiLmK/Oh/Bq14vH/5o06vF3JOoFXHBy9JdowYsdYNu/OwEGw== From: =?UTF-8?q?Corvin=20K=C3=B6hne?= To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 3/7] vfio/igd: use new BDSM register location and size for gen 11 and later Date: Thu, 22 Aug 2024 13:08:28 +0200 Message-ID: <20240822111819.34306-4-c.koehne@beckhoff.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240822111819.34306-1-c.koehne@beckhoff.com> References: <20240822111819.34306-1-c.koehne@beckhoff.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [172.17.61.20] X-ClientProxiedBy: ex01.beckhoff.com (172.17.2.168) To ex04.beckhoff.com (172.17.5.170) X-OLX-Disclaimer: EX04.BECKHOFF.COM 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=62.159.14.10; envelope-from=C.Koehne@beckhoff.com; helo=netsrv01.beckhoff.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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 @beckhoff.com) X-ZM-MESSAGEID: 1724325881733116600 Content-Type: text/plain; charset="utf-8" =EF=BB=BFIntel changed the location and size of the BDSM register for gen 11 devices and later. We have to adjust our emulation for these devices to properly support them. Signed-off-by: Corvin K=C3=B6hne --- hw/vfio/igd.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index d5e57656a8..0b6533bbf7 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -100,11 +100,12 @@ static int igd_gen(VFIOPCIDevice *vdev) typedef struct VFIOIGDQuirk { struct VFIOPCIDevice *vdev; uint32_t index; - uint32_t bdsm; + uint64_t bdsm; } VFIOIGDQuirk; =20 #define IGD_GMCH 0x50 /* Graphics Control Register */ #define IGD_BDSM 0x5c /* Base Data of Stolen Memory */ +#define IGD_BDSM_GEN11 0xc0 /* Base Data of Stolen Memory of gen 11 and la= ter */ =20 =20 /* @@ -313,9 +314,13 @@ static void vfio_igd_quirk_data_write(void *opaque, hw= addr addr, */ if ((igd->index % 4 =3D=3D 1) && igd->index < vfio_igd_gtt_max(vdev)) { if (gen < 8 || (igd->index % 8 =3D=3D 1)) { - uint32_t base; + uint64_t base; =20 - base =3D pci_get_long(vdev->pdev.config + IGD_BDSM); + if (gen < 11) { + base =3D pci_get_long(vdev->pdev.config + IGD_BDSM); + } else { + base =3D pci_get_quad(vdev->pdev.config + IGD_BDSM_GEN11); + } if (!base) { hw_error("vfio-igd: Guest attempted to program IGD GTT bef= ore " "BIOS reserved stolen memory. Unsupported BIOS?"= ); @@ -519,7 +524,13 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, in= t nr) igd =3D quirk->data =3D g_malloc0(sizeof(*igd)); igd->vdev =3D vdev; igd->index =3D ~0; - igd->bdsm =3D vfio_pci_read_config(&vdev->pdev, IGD_BDSM, 4); + if (gen < 11) { + igd->bdsm =3D vfio_pci_read_config(&vdev->pdev, IGD_BDSM, 4); + } else { + igd->bdsm =3D vfio_pci_read_config(&vdev->pdev, IGD_BDSM_GEN11, 4); + igd->bdsm |=3D + (uint64_t)vfio_pci_read_config(&vdev->pdev, IGD_BDSM_GEN11 + 4= , 4) << 32; + } igd->bdsm &=3D ~((1 * MiB) - 1); /* 1MB aligned */ =20 memory_region_init_io(&quirk->mem[0], OBJECT(vdev), &vfio_igd_index_qu= irk, @@ -577,9 +588,15 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, in= t nr) pci_set_long(vdev->emulated_config_bits + IGD_GMCH, ~0); =20 /* BDSM is read-write, emulated. The BIOS needs to be able to write i= t */ - pci_set_long(vdev->pdev.config + IGD_BDSM, 0); - pci_set_long(vdev->pdev.wmask + IGD_BDSM, ~0); - pci_set_long(vdev->emulated_config_bits + IGD_BDSM, ~0); + if (gen < 11) { + pci_set_long(vdev->pdev.config + IGD_BDSM, 0); + pci_set_long(vdev->pdev.wmask + IGD_BDSM, ~0); + pci_set_long(vdev->emulated_config_bits + IGD_BDSM, ~0); + } else { + pci_set_quad(vdev->pdev.config + IGD_BDSM_GEN11, 0); + pci_set_quad(vdev->pdev.wmask + IGD_BDSM_GEN11, ~0); + pci_set_quad(vdev->emulated_config_bits + IGD_BDSM_GEN11, ~0); + } =20 /* * This IOBAR gives us access to GTTADR, which allows us to write to --=20 2.46.0 This email contains confidential information. If you have received it in er= ror, you must not read, use, copy or pass on this e-mail or its attachments= . If you have received the e-mail in error, please inform me immediately by= reply e-mail and then delete this e-mail from your system. Thank you =20 Diese E-Mail enth=C3=A4lt vertrauliche Informationen. Sollten Sie sie irrt= =C3=BCmlich erhalten haben, d=C3=BCrfen Sie diese E-Mail oder ihre Anh=C3= =A4nge nicht lesen, verwenden, kopieren oder weitergeben. Sollten Sie die M= ail versehentlich erhalten haben, teilen Sie mir dies bitte umgehend per An= twort-E-Mail mit und l=C3=B6schen Sie diese E-Mail dann aus Ihrem System. V= ielen Dank Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Bec= khoff Registered office: Verl, Germany | Register court: Guetersloh HRA 7075 From nobody Sun Nov 24 09:52:07 2024 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=beckhoff.com ARC-Seal: i=1; a=rsa-sha256; t=1724325879; cv=none; d=zohomail.com; s=zohoarc; b=Enx+B3Gtu4yYzgZ8F/s6IhtjTkNEzFe23Ziwd78v9pK1sgj2/ehnItiOxaU2+wSBI1IXnGC/OjMuLDug6KwS6ACYZLCNOlW8RLnnanhpQn/YCqGDf5EpeNmTBYixFLec2sY6RWfekqEIJwL7tglFKcPncTbbR+YGY61Nl6o/ZYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724325879; 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=51g5v0YASy9hVByXKdNTFlH8GhBPc80zGQ+RejMqEuw=; b=bzy3IdldMtSbhbre6X/vdp1vTDGsLkt9TxW6vWgnEGnbqHJaFGoJGA7j4ngGRuk4J/e2ZHEPpCLNzqtRXXifjuSLlhGU/YGWf0JCnKm5Ki9inllCkU73bUk8teMVAdpvLxS7pk9ki9jeGHeif4cgLEwcsE18yZ5+yj+1Ex0L6uA= 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 1724325879509594.8777091247533; Thu, 22 Aug 2024 04:24:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sh5v4-00083f-Qb; Thu, 22 Aug 2024 07:23:58 -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 1sh5v2-00081N-Fk for qemu-devel@nongnu.org; Thu, 22 Aug 2024 07:23:56 -0400 Received: from netsrv01.beckhoff.com ([62.159.14.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sh5v0-00035l-Dt for qemu-devel@nongnu.org; Thu, 22 Aug 2024 07:23:56 -0400 Received: from 172.17.5.170 by netsrv01.beckhoff.com (Tls12, Aes256, Sha384, DiffieHellmanEllipticKey384); Thu, 22 Aug 2024 11:18:48 GMT Received: from corvink-nb.c.koehne.headscale.beckhoff.dev (172.17.61.20) by ex04.beckhoff.com (172.17.5.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 22 Aug 2024 13:18:45 +0200 DKIM-Signature: v=1; c=relaxed/relaxed; d=beckhoff.com; s=mail2022e; t=1724325528; bh=51g5v0YASy9hVByXKdNTFlH8GhBPc80zGQ+RejMqEuw=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=ed25519-sha256; b= CuceMlyIjYx0zPQVCeHdeftVUpQOBQRgciV1ZO9PHRP0WG6WbJkkOhpXYfwZKdeZ/tvJn6oO+YiDSa3hhMa8Dw== DKIM-Signature: v=1; c=relaxed/relaxed; d=beckhoff.com; s=mail2022r; t=1724325528; bh=51g5v0YASy9hVByXKdNTFlH8GhBPc80zGQ+RejMqEuw=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=rsa-sha256; b= F1Zs27GyFHZwvmD0vTgKtIS0O0mw2deg8VviA59jHLKG+MwF8KwhsqgoLnCbU7WKmaOc8EbOddg4knK7+26P4ib38Fn7CnRnk2SaIJOV1r90f5sUax52wGcWhfxf6m1MuEf7Ov5ZC30XUuU6xw/Sv++jUCCNUPRHEUEogdcGmtOZkY3msmK4UUVcALWFIFGUSC+jA4Wt6dasT79TuYzVM+fOSTsc3PYVuRXllYcUCH+ToUcMvSj/2s7+iDKIsiVQpFlvFPcjgptNb6XTXSGMEd8CR+EDbjePS/ti9aIQtEgKOApdb9ovzC9IKhWjuSLRVQnPbNm+TVTvOaRcRfcaPA== From: =?UTF-8?q?Corvin=20K=C3=B6hne?= To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 4/7] vfio/igd: add new bar0 quirk to emulate BDSM mirror Date: Thu, 22 Aug 2024 13:08:29 +0200 Message-ID: <20240822111819.34306-5-c.koehne@beckhoff.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240822111819.34306-1-c.koehne@beckhoff.com> References: <20240822111819.34306-1-c.koehne@beckhoff.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [172.17.61.20] X-ClientProxiedBy: ex01.beckhoff.com (172.17.2.168) To ex04.beckhoff.com (172.17.5.170) X-OLX-Disclaimer: EX04.BECKHOFF.COM 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=62.159.14.10; envelope-from=C.Koehne@beckhoff.com; helo=netsrv01.beckhoff.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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 @beckhoff.com) X-ZM-MESSAGEID: 1724325880249116600 Content-Type: text/plain; charset="utf-8" =EF=BB=BFThe BDSM register is mirrored into MMIO space at least for gen 11 = and later devices. Unfortunately, the Windows driver reads the register value from MMIO space instead of PCI config space for those devices [1]. Therefore, we either have to keep a 1:1 mapping for the host and guest address or we have to emulate the MMIO register too. Using the igd in legacy mode is already hard due to it's many constraints. Keeping a 1:1 mapping may not work in all cases and makes it even harder to use. An MMIO emulation has to trap the whole MMIO page. This makes accesses to this page slower compared to using second level address translation. Nevertheless, it doesn't have any constraints and I haven't noticed any performance degradation yet making it a better solution. [1] https://github.com/projectacrn/acrn-hypervisor/blob/5c351bee0f6ae46250e= efc07f44b4a31e770f3cf/devicemodel/hw/pci/passthrough.c#L650-L653 Signed-off-by: Corvin K=C3=B6hne --- hw/vfio/igd.c | 97 ++++++++++++++++++++++++++++++++++++++++++++ hw/vfio/pci-quirks.c | 1 + hw/vfio/pci.h | 1 + 3 files changed, 99 insertions(+) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 0b6533bbf7..863b58565e 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -374,6 +374,103 @@ static const MemoryRegionOps vfio_igd_index_quirk =3D= { .endianness =3D DEVICE_LITTLE_ENDIAN, }; =20 +#define IGD_BDSM_MMIO_OFFSET 0x1080C0 + +static uint64_t vfio_igd_quirk_bdsm_read(void *opaque, + hwaddr addr, unsigned size) +{ + VFIOPCIDevice *vdev =3D opaque; + uint64_t offset; + + offset =3D IGD_BDSM_GEN11 + addr; + + switch (size) { + case 1: + return pci_get_byte(vdev->pdev.config + offset); + case 2: + return le16_to_cpu(pci_get_word(vdev->pdev.config + offset)); + case 4: + return le32_to_cpu(pci_get_long(vdev->pdev.config + offset)); + case 8: + return le64_to_cpu(pci_get_quad(vdev->pdev.config + offset)); + default: + hw_error("igd: unsupported read size, %u bytes", size); + break; + } + + return 0; +} + +static void vfio_igd_quirk_bdsm_write(void *opaque, hwaddr addr, + uint64_t data, unsigned size) +{ + VFIOPCIDevice *vdev =3D opaque; + uint64_t offset; + + offset =3D IGD_BDSM_GEN11 + addr; + + switch (size) { + case 1: + pci_set_byte(vdev->pdev.config + offset, data); + break; + case 2: + pci_set_word(vdev->pdev.config + offset, data); + break; + case 4: + pci_set_long(vdev->pdev.config + offset, data); + break; + case 8: + pci_set_quad(vdev->pdev.config + offset, data); + break; + default: + hw_error("igd: unsupported read size, %u bytes", size); + break; + } +} + +static const MemoryRegionOps vfio_igd_bdsm_quirk =3D { + .read =3D vfio_igd_quirk_bdsm_read, + .write =3D vfio_igd_quirk_bdsm_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, +}; + +void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) +{ + VFIOQuirk *quirk; + int gen; + + /* + * This must be an Intel VGA device at address 00:02.0 for us to even + * consider enabling legacy mode. Some driver have dependencies on the= PCI + * bus address. + */ + if (!vfio_pci_is(vdev, PCI_VENDOR_ID_INTEL, PCI_ANY_ID) || + !vfio_is_vga(vdev) || nr !=3D 0 || + &vdev->pdev !=3D pci_find_device(pci_device_root_bus(&vdev->pdev), + 0, PCI_DEVFN(0x2, 0))) { + return; + } + + /* + * Only on IGD devices of gen 11 and above, the BDSM register is mirro= red + * into MMIO space and read from MMIO space by the Windows driver. + */ + gen =3D igd_gen(vdev); + if (gen < 11) { + return; + } + + quirk =3D vfio_quirk_alloc(1); + quirk->data =3D vdev; + + memory_region_init_io(&quirk->mem[0], OBJECT(vdev), &vfio_igd_bdsm_qui= rk, + vdev, "vfio-igd-bdsm-quirk", 8); + memory_region_add_subregion_overlap(vdev->bars[0].region.mem, 0x1080C0, + &quirk->mem[0], 1); + + QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); +} + void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) { g_autofree struct vfio_region_info *rom =3D NULL; diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c index 39dae72497..d37f722cce 100644 --- a/hw/vfio/pci-quirks.c +++ b/hw/vfio/pci-quirks.c @@ -1259,6 +1259,7 @@ void vfio_bar_quirk_setup(VFIOPCIDevice *vdev, int nr) vfio_probe_nvidia_bar0_quirk(vdev, nr); vfio_probe_rtl8168_bar2_quirk(vdev, nr); #ifdef CONFIG_VFIO_IGD + vfio_probe_igd_bar0_quirk(vdev, nr); vfio_probe_igd_bar4_quirk(vdev, nr); #endif } diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index bf67df2fbc..5ad090a229 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -215,6 +215,7 @@ void vfio_setup_resetfn_quirk(VFIOPCIDevice *vdev); bool vfio_add_virt_caps(VFIOPCIDevice *vdev, Error **errp); void vfio_quirk_reset(VFIOPCIDevice *vdev); VFIOQuirk *vfio_quirk_alloc(int nr_mem); +void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr); void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr); =20 extern const PropertyInfo qdev_prop_nv_gpudirect_clique; --=20 2.46.0 This email contains confidential information. If you have received it in er= ror, you must not read, use, copy or pass on this e-mail or its attachments= . If you have received the e-mail in error, please inform me immediately by= reply e-mail and then delete this e-mail from your system. Thank you =20 Diese E-Mail enth=C3=A4lt vertrauliche Informationen. Sollten Sie sie irrt= =C3=BCmlich erhalten haben, d=C3=BCrfen Sie diese E-Mail oder ihre Anh=C3= =A4nge nicht lesen, verwenden, kopieren oder weitergeben. Sollten Sie die M= ail versehentlich erhalten haben, teilen Sie mir dies bitte umgehend per An= twort-E-Mail mit und l=C3=B6schen Sie diese E-Mail dann aus Ihrem System. V= ielen Dank Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Bec= khoff Registered office: Verl, Germany | Register court: Guetersloh HRA 7075 From nobody Sun Nov 24 09:52:07 2024 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=beckhoff.com ARC-Seal: i=1; a=rsa-sha256; t=1724334974; cv=none; d=zohomail.com; s=zohoarc; b=KPmBPIBIPQ26anEhF3X1hzR3BnhIerlsRZuho3FAYtPGWWa+/DLSBbBPNiryYI2Jy4WFzhdY54ad6mrLQv82DkgrHQrWTW51L5UoXZi/A6VAX//dV40fgSLHnKlyD2kW8oeDZlDE7v72RjYobMdzuJUeE9bH8h/5DTdQ8ZVrs9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724334974; 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=ObKhh5ctOrQTCNzAWvBPR008LcANC1kNYVDOEchZxFY=; b=EMDT+XOOWgYwMhQoGgNBfC324jtrjTxSyBWD/ReaxETxBViWH5uTYltoHswOeAH8xcatClRfe9kMeLIo3pS4NXTTiBwIBirfbKf80WF6nQWHUX9A5ETAjp2iTCS+N3/nyiUmqK4GHQwol/pPIk1TwW7awL4V2Xk2GWc4ywsgkR4= 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 1724334974511950.9970330842566; Thu, 22 Aug 2024 06:56:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sh8HH-0002DX-CK; Thu, 22 Aug 2024 09:55: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 1sh8HF-00025S-I5 for qemu-devel@nongnu.org; Thu, 22 Aug 2024 09:55:01 -0400 Received: from netsrv01.beckhoff.com ([62.159.14.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sh8H8-0002ap-OI for qemu-devel@nongnu.org; Thu, 22 Aug 2024 09:55:01 -0400 Received: from 172.17.5.170 by netsrv01.beckhoff.com (Tls12, Aes256, Sha384, DiffieHellmanEllipticKey384); Thu, 22 Aug 2024 13:54:52 GMT Received: from corvink-nb.c.koehne.headscale.beckhoff.dev (172.17.61.20) by ex04.beckhoff.com (172.17.5.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 22 Aug 2024 15:54:50 +0200 DKIM-Signature: v=1; c=relaxed/relaxed; d=beckhoff.com; s=mail2022e; t=1724334892; bh=ObKhh5ctOrQTCNzAWvBPR008LcANC1kNYVDOEchZxFY=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=ed25519-sha256; b= J6kz2J7HZkLZofhLCF6cc1w95UwHRpSFjk7zXSdXOftTJROUdQC+/gg4wTCeEaG9BErXLKQ++tVROI6oXb8ICg== DKIM-Signature: v=1; c=relaxed/relaxed; d=beckhoff.com; s=mail2022r; t=1724334892; bh=ObKhh5ctOrQTCNzAWvBPR008LcANC1kNYVDOEchZxFY=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=rsa-sha256; b= OaABsvv+duGFbQyGkISYsSIDiYrX54nIt9nC5NridEctBeoHVBLVRgiLHkvShwhAUOGHmyb2KUn8x6la4/jtPlvyQZ76rRiIDGq5Zeyl9HVj0gkt27Z7O6t+RgtQQhZ/xQYFLvU+jE/kbE2hZ6RwYMInLAY1s3cK6HX0VwtnW7/ZNWaJjac6h/mjQLTDw7Z/M8UpBdmo2QVEPeOZxGXjfow4CSfB7RuJhDqR8P87/Es6r2h+uSTrl86AadTJd8EEq0RcwqS2Op5f8ixB6J707GqMJsHBjlzedj1kDgZmTHus0Wy7Su5serQdZDeS8nLqrVVeI9b19vBXnJtcYL+hBA== From: =?UTF-8?q?Corvin=20K=C3=B6hne?= To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 5/7] vfio/igd: add ID's for ElkhartLake and TigerLake Date: Thu, 22 Aug 2024 15:54:14 +0200 Message-ID: <20240822135420.58849-5-c.koehne@beckhoff.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240822111819.34306-1-c.koehne@beckhoff.com> References: <20240822111819.34306-1-c.koehne@beckhoff.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [172.17.61.20] X-ClientProxiedBy: ex04.beckhoff.com (172.17.5.170) To ex04.beckhoff.com (172.17.5.170) X-OLX-Disclaimer: EX04.BECKHOFF.COM 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=62.159.14.10; envelope-from=C.Koehne@beckhoff.com; helo=netsrv01.beckhoff.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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 @beckhoff.com) X-ZM-MESSAGEID: 1724334975547116600 Content-Type: text/plain; charset="utf-8" =EF=BB=BFElkhartLake and TigerLake devices were tested in legacy mode with = Linux and Windows VMs. Both are working properly. It's likely that other Intel GPUs of gen 11 and 12 like IceLake device are working too. However, we're only adding known good devices for now. Signed-off-by: Corvin K=C3=B6hne --- hw/vfio/igd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 863b58565e..84b0ec3139 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -88,6 +88,12 @@ static int igd_gen(VFIOPCIDevice *vdev) case 0x2200: case 0x5900: return 8; + /* ElkhartLake */ + case 0x4500: + return 11; + /* TigerLake */ + case 0x9A00: + return 12; } =20 /* --=20 2.46.0 This email contains confidential information. If you have received it in er= ror, you must not read, use, copy or pass on this e-mail or its attachments= . If you have received the e-mail in error, please inform me immediately by= reply e-mail and then delete this e-mail from your system. Thank you =20 Diese E-Mail enth=C3=A4lt vertrauliche Informationen. Sollten Sie sie irrt= =C3=BCmlich erhalten haben, d=C3=BCrfen Sie diese E-Mail oder ihre Anh=C3= =A4nge nicht lesen, verwenden, kopieren oder weitergeben. Sollten Sie die M= ail versehentlich erhalten haben, teilen Sie mir dies bitte umgehend per An= twort-E-Mail mit und l=C3=B6schen Sie diese E-Mail dann aus Ihrem System. V= ielen Dank Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Bec= khoff Registered office: Verl, Germany | Register court: Guetersloh HRA 7075 From nobody Sun Nov 24 09:52:07 2024 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=beckhoff.com ARC-Seal: i=1; a=rsa-sha256; t=1724334991; cv=none; d=zohomail.com; s=zohoarc; b=Tb0u+USFys4J1tIdbokDimBIhI46qUSj/LLkMFUpRw/uot0cRPtigFGAufOXkwMaegXv/nmrG0B1ttiM5MSddrhiIbSl/XAv8uavTaiqPDOT0xelpPpPiojHEXSfP1WxgGPlQcyNQ8rdZig8O9oqLOZmkzQckebR9QU6U4NQQXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724334991; 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=vZpI2KX970FCkxh4TIH5tOCE+9k5HnXqH3orDbOlCUg=; b=oHoGJtqo66FP0DGPfzZEhW69/9f64X4er1fok7OG1aBJmv40OAhkBDhT367bEdYGmBRaKPSiffR/+se8JodH9BmvAXfY1nKa6zoAIotPQS9TaH9YYwsIgeXkHoxmHH7NhqGAXY1Lkr72BymiHOqv77Tth5qI106IZyORjiRLHkY= 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 1724334991083910.708936893143; Thu, 22 Aug 2024 06:56:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sh8HI-0002GM-1q; Thu, 22 Aug 2024 09:55: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 1sh8HF-000278-S0 for qemu-devel@nongnu.org; Thu, 22 Aug 2024 09:55:01 -0400 Received: from netsrv01.beckhoff.com ([62.159.14.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sh8H8-0002aq-Na for qemu-devel@nongnu.org; Thu, 22 Aug 2024 09:55:01 -0400 Received: from 172.17.5.170 by netsrv01.beckhoff.com (Tls12, Aes256, Sha384, DiffieHellmanEllipticKey384); Thu, 22 Aug 2024 13:54:52 GMT Received: from corvink-nb.c.koehne.headscale.beckhoff.dev (172.17.61.20) by ex04.beckhoff.com (172.17.5.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 22 Aug 2024 15:54:50 +0200 DKIM-Signature: v=1; c=relaxed/relaxed; d=beckhoff.com; s=mail2022e; t=1724334892; bh=vZpI2KX970FCkxh4TIH5tOCE+9k5HnXqH3orDbOlCUg=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=ed25519-sha256; b= ll4BqYlLqTjnTIpoEMlnysz2Hh/5mf/bEGRFUesyLXYBAZmQcbMIFfMcFsryXiCuIVjM+ZuPu1wvIguszRGpBQ== DKIM-Signature: v=1; c=relaxed/relaxed; d=beckhoff.com; s=mail2022r; t=1724334892; bh=vZpI2KX970FCkxh4TIH5tOCE+9k5HnXqH3orDbOlCUg=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=rsa-sha256; b= JaEZc710jg0Zx6A6IciK7U5NAC1EWre9ETzGNZ/9WsVcYyBci6ZQfIgkAeTQF5ZkkNSRkOfS4wE0XtS/b78D7eWrF6QfmBfHuWqV7Q7UNGCv/1mv4fckEfpD7sw0PlFI5ruyLxQlJfkwJ4vr3Q3/tSbfLzrvXWSRsbuBC6KHVfFzhgjEWqohOnRqKwffIkMk3pnMO0j98t77bM/d8T8NlrwbFModFDpJDPbfKjcdKS+Y2e+E0dI11n+Oqlm+/KQyu2LA0ghx9uYH+HdYazqVvYy+dUByTn7AQwY1mMLh7A7r0GX2KMqgam1NiD0CRZeEE5XjdWkIZBfH5ssN8D4QEQ== From: =?UTF-8?q?Corvin=20K=C3=B6hne?= To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 6/7] vfio/igd: don't set stolen memory size to zero Date: Thu, 22 Aug 2024 15:54:15 +0200 Message-ID: <20240822135420.58849-6-c.koehne@beckhoff.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240822111819.34306-1-c.koehne@beckhoff.com> References: <20240822111819.34306-1-c.koehne@beckhoff.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [172.17.61.20] X-ClientProxiedBy: ex04.beckhoff.com (172.17.5.170) To ex04.beckhoff.com (172.17.5.170) X-OLX-Disclaimer: EX04.BECKHOFF.COM 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=62.159.14.10; envelope-from=C.Koehne@beckhoff.com; helo=netsrv01.beckhoff.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-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 @beckhoff.com) X-ZM-MESSAGEID: 1724334991603116600 Content-Type: text/plain; charset="utf-8" =EF=BB=BFThe stolen memory is required for the GOP (EFI) driver and the Win= dows driver. While the GOP driver seems to work with any stolen memory size, the Windows driver will crash if the size doesn't match the size allocated by the host BIOS. For that reason, it doesn't make sense to overwrite the stolen memory size. It's true that this wastes some VM memory. In the worst case, the stolen memory can take up more than a GB. However, that's uncommon. Additionally, it's likely that a bunch of RAM is assigned to VMs making use of GPU passthrough. Signed-off-by: Corvin K=C3=B6hne --- hw/vfio/igd.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 84b0ec3139..122432e6a6 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -477,6 +477,23 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, in= t nr) QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); } =20 +static int igd_get_stolen_mb(int gen, uint32_t gmch) +{ + int gms; + + if (gen < 8) { + gms =3D (gmch >> 3) & 0x1f; + } else { + gms =3D (gmch >> 8) & 0xff; + } + + if (gms > 0x10) { + error_report("Unsupported IGD GMS value 0x%x", gms); + return 0; + } + return gms * 32; +} + void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) { g_autofree struct vfio_region_info *rom =3D NULL; @@ -654,23 +671,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, in= t nr) ggms_mb =3D 1 << ggms_mb; } =20 - /* - * Assume we have no GMS memory, but allow it to be overridden by devi= ce - * option (experimental). The spec doesn't actually allow zero GMS wh= en - * when IVD (IGD VGA Disable) is clear, but the claim is that it's unu= sed, - * so let's not waste VM memory for it. - */ - gmch &=3D ~((gen < 8 ? 0x1f : 0xff) << (gen < 8 ? 3 : 8)); - - if (vdev->igd_gms) { - if (vdev->igd_gms <=3D 0x10) { - gms_mb =3D vdev->igd_gms * 32; - gmch |=3D vdev->igd_gms << (gen < 8 ? 3 : 8); - } else { - error_report("Unsupported IGD GMS value 0x%x", vdev->igd_gms); - vdev->igd_gms =3D 0; - } - } + gms_mb =3D igd_get_stolen_mb(gen, gmch); =20 /* * Request reserved memory for stolen memory via fw_cfg. VM firmware --=20 2.46.0 This email contains confidential information. If you have received it in er= ror, you must not read, use, copy or pass on this e-mail or its attachments= . If you have received the e-mail in error, please inform me immediately by= reply e-mail and then delete this e-mail from your system. Thank you =20 Diese E-Mail enth=C3=A4lt vertrauliche Informationen. Sollten Sie sie irrt= =C3=BCmlich erhalten haben, d=C3=BCrfen Sie diese E-Mail oder ihre Anh=C3= =A4nge nicht lesen, verwenden, kopieren oder weitergeben. Sollten Sie die M= ail versehentlich erhalten haben, teilen Sie mir dies bitte umgehend per An= twort-E-Mail mit und l=C3=B6schen Sie diese E-Mail dann aus Ihrem System. V= ielen Dank Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Bec= khoff Registered office: Verl, Germany | Register court: Guetersloh HRA 7075 From nobody Sun Nov 24 09:52:07 2024 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=beckhoff.com ARC-Seal: i=1; a=rsa-sha256; t=1724334940; cv=none; d=zohomail.com; s=zohoarc; b=Nx4CLpGYWBICVQN7UjNIP4fbB620w2QLqC02NLkVBPxVPdNoMwdlRUbZpytVB4UC2pS1G21KV5Z5QxSMAjBrc84bE/enwQYz7VeTFy4E4yfHdnY5EPcbwqpZ60v4xYKhJ81V9hRjtxd4l1/XERafs+wLvaCwsC2EiTFVp8iy06U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724334940; 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=d/oIKbgF+x1vzJ0O29d6n+1kiRF+USqgvvZ8Zv6x47M=; b=dGQq9JY0rTJLdqA7ZQ7NSHFvd+ZHfnku7zj29zGCj/VDMzm6jknbyyBigMbAARufRvvlEmLywkAU6sldjOy7q9DNaSgIc0cY61pdoOZ/6AV5a3odk3gsZOTF+q0Q43Ef3t7q3CdkD0h/eqqnQ0fwYtQ/oswZ8Jqbe3TWmnRFWTM= 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 1724334939987268.1521557193955; Thu, 22 Aug 2024 06:55:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sh8HF-00026w-UY; Thu, 22 Aug 2024 09:55: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 1sh8HE-00020T-Cj for qemu-devel@nongnu.org; Thu, 22 Aug 2024 09:55:00 -0400 Received: from netsrv01.beckhoff.com ([62.159.14.10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sh8H8-0002au-Nh for qemu-devel@nongnu.org; Thu, 22 Aug 2024 09:55:00 -0400 Received: from 172.17.5.170 by netsrv01.beckhoff.com (Tls12, Aes256, Sha384, DiffieHellmanEllipticKey384); Thu, 22 Aug 2024 13:54:53 GMT Received: from corvink-nb.c.koehne.headscale.beckhoff.dev (172.17.61.20) by ex04.beckhoff.com (172.17.5.170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Thu, 22 Aug 2024 15:54:50 +0200 DKIM-Signature: v=1; c=relaxed/relaxed; d=beckhoff.com; s=mail2022e; t=1724334893; bh=d/oIKbgF+x1vzJ0O29d6n+1kiRF+USqgvvZ8Zv6x47M=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=ed25519-sha256; b= xc1CJLE5vOWYcqapPneyywVp7LYbWlzH9PT0qGJR7xow1zauX0sJ0EqbZTCbJJgKHKqsTM1Mx/o1ehixzVe3DA== DKIM-Signature: v=1; c=relaxed/relaxed; d=beckhoff.com; s=mail2022r; t=1724334893; bh=d/oIKbgF+x1vzJ0O29d6n+1kiRF+USqgvvZ8Zv6x47M=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=rsa-sha256; b= WxfFUSi9TEcqaIIw/4qnuQ6LBj5GGKFHC5WtYo39J7WtKFrVWFBtXZTY2Ki8qJvwN6fJNAsgHq3Vq+PEFFMt1udXcEsWKkzTeS+GC0jZYkQtW+iadba5BbXO3PRZezFlHbKK7DpgcRNkk29FdP/+4T1mwGDoskRfAw6muZ4xx5qI8KervgpgPSauII+fB7xJfwzUoBgDwShjlu0yzxAvNJUMKpo6acRrD1qwgR7BhfaKXI4zK6yCxL3YGtXC20iN2+7Sv+Z5rubOgnzociD7gK/2BktIYMt5TDJnaJMUILXhQ2NXsHKiVBXkUbAmCmnVQrzAwdHmrtK3DKPxhRuVUg== From: =?UTF-8?q?Corvin=20K=C3=B6hne?= To: CC: Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH 7/7] vfio/igd: correctly calculate stolen memory size for gen 9 and later Date: Thu, 22 Aug 2024 15:54:16 +0200 Message-ID: <20240822135420.58849-7-c.koehne@beckhoff.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240822111819.34306-1-c.koehne@beckhoff.com> References: <20240822111819.34306-1-c.koehne@beckhoff.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [172.17.61.20] X-ClientProxiedBy: ex04.beckhoff.com (172.17.5.170) To ex04.beckhoff.com (172.17.5.170) X-OLX-Disclaimer: EX04.BECKHOFF.COM 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=62.159.14.10; envelope-from=C.Koehne@beckhoff.com; helo=netsrv01.beckhoff.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, 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 @beckhoff.com) X-ZM-MESSAGEID: 1724334941754116600 Content-Type: text/plain; charset="utf-8" =EF=BB=BFWe have to update the calculation of the stolen memory size because we've seen devices using values of 0xf0 and above for the graphics mode select field. The new calculation was taken from the linux kernel [1]. [1] https://github.com/torvalds/linux/blob/7c626ce4bae1ac14f60076d00eafe71a= f30450ba/arch/x86/kernel/early-quirks.c#L455-L460 Signed-off-by: Corvin K=C3=B6hne --- hw/vfio/igd.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 122432e6a6..70c60fe7bc 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -487,11 +487,18 @@ static int igd_get_stolen_mb(int gen, uint32_t gmch) gms =3D (gmch >> 8) & 0xff; } =20 - if (gms > 0x10) { - error_report("Unsupported IGD GMS value 0x%x", gms); - return 0; + if (gen < 9) { + if (gms > 0x10) { + error_report("Unsupported IGD GMS value 0x%x", gms); + return 0; + } + return gms * 32; + } else { + if (gms < 0xf0) + return gms * 32; + else + return gms * 4 + 4; } - return gms * 32; } =20 void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) --=20 2.46.0 This email contains confidential information. If you have received it in er= ror, you must not read, use, copy or pass on this e-mail or its attachments= . If you have received the e-mail in error, please inform me immediately by= reply e-mail and then delete this e-mail from your system. Thank you =20 Diese E-Mail enth=C3=A4lt vertrauliche Informationen. Sollten Sie sie irrt= =C3=BCmlich erhalten haben, d=C3=BCrfen Sie diese E-Mail oder ihre Anh=C3= =A4nge nicht lesen, verwenden, kopieren oder weitergeben. Sollten Sie die M= ail versehentlich erhalten haben, teilen Sie mir dies bitte umgehend per An= twort-E-Mail mit und l=C3=B6schen Sie diese E-Mail dann aus Ihrem System. V= ielen Dank Beckhoff Automation GmbH & Co. KG | Managing Director: Dipl. Phys. Hans Bec= khoff Registered office: Verl, Germany | Register court: Guetersloh HRA 7075