From patchwork Thu Aug 22 11:08:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Corvin_K=C3=B6hne?= X-Patchwork-Id: 1975449 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass header.d=beckhoff.com header.i=@beckhoff.com header.a=ed25519-sha256 header.s=mail2022e header.b=kWR/p8E1; dkim=pass (2048-bit key; unprotected) header.d=beckhoff.com header.i=@beckhoff.com header.a=rsa-sha256 header.s=mail2022r header.b=raaLW5tc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqLT46Lm5z1ygv for ; Thu, 22 Aug 2024 21:24:40 +1000 (AEST) 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 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== 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 From: =?utf-8?q?Corvin_K=C3=B6hne?= To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= 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 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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Intel 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öhne --- 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; } - return 8; /* Assume newer is compatible */ + /* + * Unfortunately, Intel changes it's specification quite often. This makes + * it impossible to use a suitable default value for unknown devices. + */ + return -1; } typedef struct VFIOIGDQuirk { From patchwork Thu Aug 22 11:08:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Corvin_K=C3=B6hne?= X-Patchwork-Id: 1975447 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass header.d=beckhoff.com header.i=@beckhoff.com header.a=ed25519-sha256 header.s=mail2022e header.b=Z9dmkT9W; dkim=pass (2048-bit key; unprotected) header.d=beckhoff.com header.i=@beckhoff.com header.a=rsa-sha256 header.s=mail2022r header.b=FHlzjauI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqLT43hkqz1yf6 for ; Thu, 22 Aug 2024 21:24:40 +1000 (AEST) 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 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== 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 From: =?utf-8?q?Corvin_K=C3=B6hne?= To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= 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 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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We'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öhne --- 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 = igd_gen(vdev); - if (gen != 6 && gen != 8) { + if (gen == -1) { error_report("IGD device %s is unsupported in legacy mode, " "try SandyBridge or newer", vdev->vbasedev.name); return; From patchwork Thu Aug 22 11:08:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Corvin_K=C3=B6hne?= X-Patchwork-Id: 1975450 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass header.d=beckhoff.com header.i=@beckhoff.com header.a=ed25519-sha256 header.s=mail2022e header.b=Zryj9Vyx; dkim=pass (2048-bit key; unprotected) header.d=beckhoff.com header.i=@beckhoff.com header.a=rsa-sha256 header.s=mail2022r header.b=JnessnGX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqLT46M7Hz1ygy for ; Thu, 22 Aug 2024 21:24:40 +1000 (AEST) 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 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== 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 From: =?utf-8?q?Corvin_K=C3=B6hne?= To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= 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 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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Intel 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öhne --- 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; #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 later */ /* @@ -313,9 +314,13 @@ static void vfio_igd_quirk_data_write(void *opaque, hwaddr addr, */ if ((igd->index % 4 == 1) && igd->index < vfio_igd_gtt_max(vdev)) { if (gen < 8 || (igd->index % 8 == 1)) { - uint32_t base; + uint64_t base; - base = pci_get_long(vdev->pdev.config + IGD_BDSM); + if (gen < 11) { + base = pci_get_long(vdev->pdev.config + IGD_BDSM); + } else { + base = pci_get_quad(vdev->pdev.config + IGD_BDSM_GEN11); + } if (!base) { hw_error("vfio-igd: Guest attempted to program IGD GTT before " "BIOS reserved stolen memory. Unsupported BIOS?"); @@ -519,7 +524,13 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) igd = quirk->data = g_malloc0(sizeof(*igd)); igd->vdev = vdev; igd->index = ~0; - igd->bdsm = vfio_pci_read_config(&vdev->pdev, IGD_BDSM, 4); + if (gen < 11) { + igd->bdsm = vfio_pci_read_config(&vdev->pdev, IGD_BDSM, 4); + } else { + igd->bdsm = vfio_pci_read_config(&vdev->pdev, IGD_BDSM_GEN11, 4); + igd->bdsm |= + (uint64_t)vfio_pci_read_config(&vdev->pdev, IGD_BDSM_GEN11 + 4, 4) << 32; + } igd->bdsm &= ~((1 * MiB) - 1); /* 1MB aligned */ memory_region_init_io(&quirk->mem[0], OBJECT(vdev), &vfio_igd_index_quirk, @@ -577,9 +588,15 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) pci_set_long(vdev->emulated_config_bits + IGD_GMCH, ~0); /* BDSM is read-write, emulated. The BIOS needs to be able to write it */ - 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); + } /* * This IOBAR gives us access to GTTADR, which allows us to write to From patchwork Thu Aug 22 13:54:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Corvin_K=C3=B6hne?= X-Patchwork-Id: 1975527 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass header.d=beckhoff.com header.i=@beckhoff.com header.a=ed25519-sha256 header.s=mail2022e header.b=J6kz2J7H; dkim=pass (2048-bit key; unprotected) header.d=beckhoff.com header.i=@beckhoff.com header.a=rsa-sha256 header.s=mail2022r header.b=OaABsvv+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqPqz1jTDz1ybW for ; Thu, 22 Aug 2024 23:56:15 +1000 (AEST) 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 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== 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 From: =?utf-8?q?Corvin_K=C3=B6hne?= To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= 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 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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org ElkhartLake 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öhne --- 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; } /* From patchwork Thu Aug 22 13:54:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Corvin_K=C3=B6hne?= X-Patchwork-Id: 1975529 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass header.d=beckhoff.com header.i=@beckhoff.com header.a=ed25519-sha256 header.s=mail2022e header.b=ll4BqYlL; dkim=pass (2048-bit key; unprotected) header.d=beckhoff.com header.i=@beckhoff.com header.a=rsa-sha256 header.s=mail2022r header.b=JaEZc710; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqPrH68MGz1ybW for ; Thu, 22 Aug 2024 23:56:31 +1000 (AEST) 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 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== 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 From: =?utf-8?q?Corvin_K=C3=B6hne?= To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= 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 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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The stolen memory is required for the GOP (EFI) driver and the Windows 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öhne --- 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, int nr) QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); } +static int igd_get_stolen_mb(int gen, uint32_t gmch) +{ + int gms; + + if (gen < 8) { + gms = (gmch >> 3) & 0x1f; + } else { + gms = (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 = NULL; @@ -654,23 +671,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) ggms_mb = 1 << ggms_mb; } - /* - * Assume we have no GMS memory, but allow it to be overridden by device - * option (experimental). The spec doesn't actually allow zero GMS when - * when IVD (IGD VGA Disable) is clear, but the claim is that it's unused, - * so let's not waste VM memory for it. - */ - gmch &= ~((gen < 8 ? 0x1f : 0xff) << (gen < 8 ? 3 : 8)); - - if (vdev->igd_gms) { - if (vdev->igd_gms <= 0x10) { - gms_mb = vdev->igd_gms * 32; - gmch |= vdev->igd_gms << (gen < 8 ? 3 : 8); - } else { - error_report("Unsupported IGD GMS value 0x%x", vdev->igd_gms); - vdev->igd_gms = 0; - } - } + gms_mb = igd_get_stolen_mb(gen, gmch); /* * Request reserved memory for stolen memory via fw_cfg. VM firmware From patchwork Thu Aug 22 13:54:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Corvin_K=C3=B6hne?= X-Patchwork-Id: 1975522 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass header.d=beckhoff.com header.i=@beckhoff.com header.a=ed25519-sha256 header.s=mail2022e header.b=xc1CJLE5; dkim=pass (2048-bit key; unprotected) header.d=beckhoff.com header.i=@beckhoff.com header.a=rsa-sha256 header.s=mail2022r header.b=WxfFUSi9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WqPqJ6PTVz1yf6 for ; Thu, 22 Aug 2024 23:55:40 +1000 (AEST) 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 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== 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 From: =?utf-8?q?Corvin_K=C3=B6hne?= To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= 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 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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We 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/7c626ce4bae1ac14f60076d00eafe71af30450ba/arch/x86/kernel/early-quirks.c#L455-L460 Signed-off-by: Corvin Köhne --- 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 = (gmch >> 8) & 0xff; } - 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; } void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr)