From patchwork Wed Aug 28 13:43:22 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: 13781293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AFF54C54FAA for ; Wed, 28 Aug 2024 13:45:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjIxU-0004JS-5r; Wed, 28 Aug 2024 09:43:36 -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 1sjIxS-0004H4-Sb for qemu-devel@nongnu.org; Wed, 28 Aug 2024 09:43:34 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sjIxR-0002Kd-8f for qemu-devel@nongnu.org; Wed, 28 Aug 2024 09:43:34 -0400 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a86859e2fc0so840300466b.3 for ; Wed, 28 Aug 2024 06:43:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724852611; x=1725457411; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ExlkdrUtqEM387e5iz5EaHb4pSvHH/3TmSRHTIVr1OA=; b=UKVgkspKrSQVXTokaAHxwVUUniC4EQSL9/yYagzZIB/kE1nke2MSCTSiEa2O/a8NmP kTi7L3voIedNNj5Xhil1W5OqydgAg2qO9G7yirdAS+cypbxPbEm0WgDH3vDko4NO3Gel EnDgj/3tU8KAB8vNUU4oTksGUSotEE6omAzLCArkVM/Tt4AH1ndU7Xqn2ddJel2eWdBv P0AdupRb9wCD+Hk0hMxNX01E+BV0T3YNFIR0isDcTcW36Pd50ieVufhkj9xLUkAC0Wt6 7VcYmoD+LBLYuwI7rnPhpNqaPSDonj/B5pYSlcN5mOuBlVSwVhJTopoZrZJsuXobOY2C 5Sdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724852611; x=1725457411; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ExlkdrUtqEM387e5iz5EaHb4pSvHH/3TmSRHTIVr1OA=; b=ffbkk5qkTA2crG6SJTOhUuRBpQo4f5YrZequkj4bTy0v3kXxtVgUbqkRIWU0yYdRFC ISHC+YmdojADEYxb+4k1M+t89Xg+Wiohf4E9hVLtOx7/v31UjBTfNBOvTp+CQCZV/4+9 5Wh85WInLyFJwQI0VX7D+7ZAbhgnBEDFwyBZNRrs9f2TZYuQ7FM/EaeGwcIcAIhrVWxa dC05M7kMBVjwTIyaApIz35ElS1afZHT+R+DeR0odvwEGeUFGeey6uRQCu3YUxbN5QDEp Gts/rZTuWcJwmRucLlL0Q3a4bQC0PS1n88nRRa5LThODlJeqckM53EODiDe/TfAKN2oT OyrA== X-Gm-Message-State: AOJu0YwRZE8k+NU67cYSwzTr4lAOMjJUCPmg/I0U7so5mkmllLHQ9rhf SgtKUtKqHkE4lOyAeoItEOZVJlmvRPPFKhM272EFchAefifiZxutGu2FHw== X-Google-Smtp-Source: AGHT+IG5QKGb2A4nf2DMokKwMOF5ql0N8b75+qDSQ/os7/zk9J+PuVQ4q0aIT6o4l0cTNE9Aa8luog== X-Received: by 2002:a17:907:7e93:b0:a80:f81c:fd75 with SMTP id a640c23a62f3a-a870a5d443amr175009866b.0.1724852610989; Wed, 28 Aug 2024 06:43:30 -0700 (PDT) Received: from corvink-nb.beckhoff.com ([195.226.174.194]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a88a48d4a39sm32606766b.12.2024.08.28.06.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 06:43:30 -0700 (PDT) From: " =?utf-8?q?Corvin_K=C3=B6hne?= " X-Google-Original-From: =?utf-8?q?Corvin_K=C3=B6hne?= To: qemu-devel@nongnu.org, c.koehne@beckhoff.com Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Alex Williamson Subject: [PATCH v3 1/7] vfio/igd: return an invalid generation for unknown devices Date: Wed, 28 Aug 2024 15:43:22 +0200 Message-ID: <20240828134328.94528-2-c.koehne@beckhoff.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240828134328.94528-1-c.koehne@beckhoff.com> References: <20240828134328.94528-1-c.koehne@beckhoff.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=corvin.koehne@gmail.com; helo=mail-ej1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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 Wed Aug 28 13:43:23 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: 13781295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0C799C54FAA for ; Wed, 28 Aug 2024 13:45:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjIxj-0005HF-5n; Wed, 28 Aug 2024 09:43:51 -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 1sjIxh-00059W-4U for qemu-devel@nongnu.org; Wed, 28 Aug 2024 09:43:49 -0400 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sjIxS-0002Kf-0H for qemu-devel@nongnu.org; Wed, 28 Aug 2024 09:43:48 -0400 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a8696e9bd24so730146666b.0 for ; Wed, 28 Aug 2024 06:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724852612; x=1725457412; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mC/R0iUzS3U5dDJtHLFRDcpd8CGk4MJdW7/QshJswmQ=; b=Q/yYljDuIrM8CNfSdyGDq+BBqmNI2ZuyhEnOrWekekncpr2TTL2TUYiPoeEs4UJFYp gh4BDIF6UGmvgXPwE8iN3YvopvqyhHSiTkaR6bsPXB6ySocq2GQjAD3DvJvGObClgXfa 3oB8vcVY/zvkkocZglt9DFQEUbIRcCe1vZFWtannsd1q6oAVCEwEMCecNlgjDlx7zHYz hG9N2JRznz1xWDN2zyNwU/Av7soPBp4V+JjpPaycVgBBrQMJmiRE8EcaaCpSItOZRn2h YoCTrdSslT5fIZm0GdXWjdZHnLaTuQ06s1ShH0y2EtMRt4TSkQR1yxm6rL7G8d+uMF3E qz8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724852612; x=1725457412; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mC/R0iUzS3U5dDJtHLFRDcpd8CGk4MJdW7/QshJswmQ=; b=pBkJA3TNucLaaESmw5qksgue8nCe2x741Y8oOYeLi4luxUh0eEZpM94US+EYAKryUk kU2rd9Cp44NDrX+IdoG8Nr50w7U+IVZgbZkOwL/e9aMdGuXGA1hIjt3q69lt0YM1XbGe meTdWoCwE8DVL6aeqdYqruVHPC5ZWh+G8H8EvxXQrNLr0wL2T/doYe8JcG5KAxPiNPCj pp4prdJ9Up0RS/C8V+4GuktAFeH/iyfkMn1YaBp1ESEYLZ5vsfjwuizm+6/GHTj20Mnr qRUIbwWyE/lbhkUpMxKydbqZTyzmjggNBKNkpP7Z07DTo0xntzAXFSFyZCxc6SUn8IAY tpVQ== X-Gm-Message-State: AOJu0Yya92smulEuuBXh6uLBG1VdouJLLeLZYmeJBzfNxQjJpxrRh0XL 3BueKkpf55/OxkFYZpjQxbYExr01dCr4dYfcLacNJ0UMYJNvGAiXkPZJ3A== X-Google-Smtp-Source: AGHT+IFl5ufe5lc5+AxSZc8renlRAcaLlu3Iy1RYSE9OjabX+cYGde14Gw07caU9xhilCcw7teCDOQ== X-Received: by 2002:a17:907:6d25:b0:a80:7ce0:8b2a with SMTP id a640c23a62f3a-a870a9b9a42mr154156666b.19.1724852612007; Wed, 28 Aug 2024 06:43:32 -0700 (PDT) Received: from corvink-nb.beckhoff.com ([195.226.174.194]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a88a48d4a39sm32606766b.12.2024.08.28.06.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 06:43:31 -0700 (PDT) From: " =?utf-8?q?Corvin_K=C3=B6hne?= " X-Google-Original-From: =?utf-8?q?Corvin_K=C3=B6hne?= To: qemu-devel@nongnu.org, c.koehne@beckhoff.com Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Alex Williamson Subject: [PATCH v3 2/7] vfio/igd: support legacy mode for all known generations Date: Wed, 28 Aug 2024 15:43:23 +0200 Message-ID: <20240828134328.94528-3-c.koehne@beckhoff.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240828134328.94528-1-c.koehne@beckhoff.com> References: <20240828134328.94528-1-c.koehne@beckhoff.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=corvin.koehne@gmail.com; helo=mail-ej1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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 Wed Aug 28 13:43:24 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: 13781292 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 742AFC54FAA for ; Wed, 28 Aug 2024 13:45:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjIxW-0004So-H1; Wed, 28 Aug 2024 09:43:38 -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 1sjIxU-0004Mo-V7 for qemu-devel@nongnu.org; Wed, 28 Aug 2024 09:43:36 -0400 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sjIxT-0002Kr-9f for qemu-devel@nongnu.org; Wed, 28 Aug 2024 09:43:36 -0400 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a86acbaddb4so626340566b.1 for ; Wed, 28 Aug 2024 06:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724852613; x=1725457413; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qxXaT5Ge9ysYGoLxhhM7szMpSqkvt89S9Abd0b/m8pw=; b=LeHcZdFHC6TBjKH1DBNVz9C8/Pikg04Rz6ojz900inRfS9rSVKsgKzxLRnBhReo2dt iW/zOQz+0l0KZY8kbgAVPg4jh8qz9vE9q/hdhmQlwnqZOxMi3hTTFEUCAt98XEKMUj+o M2OBFehuGVNRaE3Od2RCkKmcZVsIYA5HzQ0QZJmkQEkpNAOA8deIl4oOYuC/lGOb/h1M FZ4JT5IEpw5JBMZQ25KzKGB+gGWQp40wTdpdEx/KbGHvwWbXVfBDewUfF1+BbxGTJ6QX dA9bosRjUDlmbVupb1vVKbUpOaKoF0/xaHoCUy8U0hKf72LsGAt2IJAvjyZ0d0OEeyJX AyBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724852613; x=1725457413; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qxXaT5Ge9ysYGoLxhhM7szMpSqkvt89S9Abd0b/m8pw=; b=GBE1eZNSvxIYlnVw8iFduitRdAnfcNtMGimc2E4cIOWGz5Rr20tZIPsoYaIPRsTgjO gJV2b1gInmQIBGf/JBFG6UXV25rQAnSf2kSrb4WzhUicxABE+C3V7ylekQpIU5kN0ApE cHAg4vxQg9N4TlvSccQndbT6tX4qlmx+CfmzvMNJTpl8zrVSrdZXeOogmmc/A3ZiMD8G MZJpLTa4ws6ca1Zeos+IFwMpe+q4z0eC6ubHHJk/Gt4XA0OcJPJK660MuEB+gI88FEAW MtLbIX/00NnGbN5opeuNxfZesR2RXPi5choSnp0MbMgB8qNm2RmgBOaJb0gzpgjq4jxL 9Lkg== X-Gm-Message-State: AOJu0YyTctBQmWFkspmvDYDcwX1Ohu8At9wwkAzMNcXqBl4fJ1/YC2gB 8/vv4uNWQuk4i2Jb72d6N8kX/7ZDTLZunA5ahxjnXMMDVx7tqwdLAtrtWg== X-Google-Smtp-Source: AGHT+IFBPL2h5aQ6nvjqF7BTB97SHmXxrdyU3doFhRkRnApjgalJnNaGNhC0vnl3utyq0YVakP+y6w== X-Received: by 2002:a17:907:7290:b0:a86:fa3d:e984 with SMTP id a640c23a62f3a-a870a9b4a93mr150040166b.20.1724852613026; Wed, 28 Aug 2024 06:43:33 -0700 (PDT) Received: from corvink-nb.beckhoff.com ([195.226.174.194]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a88a48d4a39sm32606766b.12.2024.08.28.06.43.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 06:43:32 -0700 (PDT) From: " =?utf-8?q?Corvin_K=C3=B6hne?= " X-Google-Original-From: =?utf-8?q?Corvin_K=C3=B6hne?= To: qemu-devel@nongnu.org, c.koehne@beckhoff.com Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Alex Williamson Subject: [PATCH v3 3/7] vfio/igd: use new BDSM register location and size for gen 11 and later Date: Wed, 28 Aug 2024 15:43:24 +0200 Message-ID: <20240828134328.94528-4-c.koehne@beckhoff.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240828134328.94528-1-c.koehne@beckhoff.com> References: <20240828134328.94528-1-c.koehne@beckhoff.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=corvin.koehne@gmail.com; helo=mail-ej1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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 Wed Aug 28 13:43:25 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: 13781290 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37315C54FC6 for ; Wed, 28 Aug 2024 13:45:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjIxY-0004al-F1; Wed, 28 Aug 2024 09:43:40 -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 1sjIxW-0004Sp-FE for qemu-devel@nongnu.org; Wed, 28 Aug 2024 09:43:38 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sjIxU-0002L2-09 for qemu-devel@nongnu.org; Wed, 28 Aug 2024 09:43:38 -0400 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-a7a9cf7d3f3so848061466b.1 for ; Wed, 28 Aug 2024 06:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724852614; x=1725457414; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S24Cu87hiavAh3YpQ1XUPV/o+dTV1fpam6g83n2N1PE=; b=Lcf3VtwHRgLhLAVxRrnQdMYvmXircceCembhUmcPPELUgiVZQkhzvDNj9FiYExz72/ 7I9nMbdapoVt4Go8D/2UE3PCcvtJ+/L/yzgwMn0IFJ7uaAIRx2LbtIF6lfUyU89cHjyw nEq5cCiMXmMpWCruqmKhtJ2n8VPqEW567Vock3KIB0NY4sH/7/Dk6y3etQ9AR25K1WBT hHZe1b2QvN6SSSKPeuOsr2SzHCld+vtt2X+fcrCqHeqKzbXcbukcsjOWcY9bAqr0CVg9 12QZ5oi0B3HiJA5Wkh6LNJVPpVbH64t7uMIUApLKnsZahSzS63eCvBOQZlCyDUO1MvJw y2sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724852614; x=1725457414; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S24Cu87hiavAh3YpQ1XUPV/o+dTV1fpam6g83n2N1PE=; b=HV2HC9LJbvQJ/cca1TBVpnQq8UgU+D5AmehCNNq/Egfm1Iym1w6E6PlBzz4YwUFCM9 Z++gMqDv2Bf9lRA38V7MeVVhm+D7BAkUXLAcrPyxF41u0u8eebguigLRLqBieRAFhJUB oihm/mDpzyvpRIJyWyOwtacQ7GB011BrU1OyTokgySJ0rhO3KQEfIoWgmhul9Rs97YQi ge+4rpRfvvm59HruweIo6W4wREoIyVQoGLu7fCxwM3Kw0cOPexiCVgVldTBCzmIrNBEL fPMSa+82e1ukKthJRoSacK0rZlg71QPj1U53KmRys6p8WzMPoQo0sweQwc2yxae+aYRk HW2w== X-Gm-Message-State: AOJu0Yw0QoIIjTG5FuaZ+Oz6cmtMBxTEemR+bndiZBGDZ6ZAvPpvxx7p JE+6beLhow/SV3TJQdRTh2x+kABHG1/ENJgGWK2QttAgdJSoQT05IFBkfw== X-Google-Smtp-Source: AGHT+IER2+9LL0wxMrJMVeiaYQLr2EJ0YHl47+/aSchUcxXFr/SICZewqVjIZUdbOew1jEzPGBVyWg== X-Received: by 2002:a17:906:f5a9:b0:a86:963f:ea8d with SMTP id a640c23a62f3a-a86a54df8demr1308454166b.64.1724852613861; Wed, 28 Aug 2024 06:43:33 -0700 (PDT) Received: from corvink-nb.beckhoff.com ([195.226.174.194]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a88a48d4a39sm32606766b.12.2024.08.28.06.43.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 06:43:33 -0700 (PDT) From: " =?utf-8?q?Corvin_K=C3=B6hne?= " X-Google-Original-From: =?utf-8?q?Corvin_K=C3=B6hne?= To: qemu-devel@nongnu.org, c.koehne@beckhoff.com Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Alex Williamson Subject: [PATCH v3 4/7] vfio/igd: add new bar0 quirk to emulate BDSM mirror Date: Wed, 28 Aug 2024 15:43:25 +0200 Message-ID: <20240828134328.94528-5-c.koehne@beckhoff.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240828134328.94528-1-c.koehne@beckhoff.com> References: <20240828134328.94528-1-c.koehne@beckhoff.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=corvin.koehne@gmail.com; helo=mail-ej1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The 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/5c351bee0f6ae46250eefc07f44b4a31e770f3cf/devicemodel/hw/pci/passthrough.c#L650-L653 Signed-off-by: Corvin Köhne --- v2: * omit unnecessary leXX_to_cpu calls * make use of IGD_BDSM_MMIO_OFFSET define hw/vfio/igd.c | 98 ++++++++++++++++++++++++++++++++++++++++++++ hw/vfio/pci-quirks.c | 1 + hw/vfio/pci.h | 1 + 3 files changed, 100 insertions(+) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 0b6533bbf7..0d68c6a451 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -374,6 +374,104 @@ static const MemoryRegionOps vfio_igd_index_quirk = { .endianness = DEVICE_LITTLE_ENDIAN, }; +#define IGD_BDSM_MMIO_OFFSET 0x1080C0 + +static uint64_t vfio_igd_quirk_bdsm_read(void *opaque, + hwaddr addr, unsigned size) +{ + VFIOPCIDevice *vdev = opaque; + uint64_t offset; + + offset = IGD_BDSM_GEN11 + addr; + + switch (size) { + case 1: + return pci_get_byte(vdev->pdev.config + offset); + case 2: + return pci_get_word(vdev->pdev.config + offset); + case 4: + return pci_get_long(vdev->pdev.config + offset); + case 8: + return 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 = opaque; + uint64_t offset; + + offset = 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 = { + .read = vfio_igd_quirk_bdsm_read, + .write = vfio_igd_quirk_bdsm_write, + .endianness = 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 != 0 || + &vdev->pdev != 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 mirrored + * into MMIO space and read from MMIO space by the Windows driver. + */ + gen = igd_gen(vdev); + if (gen < 11) { + return; + } + + quirk = vfio_quirk_alloc(1); + quirk->data = vdev; + + memory_region_init_io(&quirk->mem[0], OBJECT(vdev), &vfio_igd_bdsm_quirk, + vdev, "vfio-igd-bdsm-quirk", 8); + memory_region_add_subregion_overlap(vdev->bars[0].region.mem, + IGD_BDSM_MMIO_OFFSET, &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 = 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); extern const PropertyInfo qdev_prop_nv_gpudirect_clique; From patchwork Wed Aug 28 13:43: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: 13781291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3339EC54FB3 for ; Wed, 28 Aug 2024 13:45:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjIxX-0004YB-Pz; Wed, 28 Aug 2024 09:43:39 -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 1sjIxW-0004RJ-4a for qemu-devel@nongnu.org; Wed, 28 Aug 2024 09:43:38 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sjIxU-0002LA-Hf for qemu-devel@nongnu.org; Wed, 28 Aug 2024 09:43:37 -0400 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-5beb6ea9ed6so7317398a12.1 for ; Wed, 28 Aug 2024 06:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724852615; x=1725457415; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k1Wxn4ztcsSpgPNwkQzBp5z/GYAcrxDMGZtIkBFIolE=; b=SZHiHS1P4PRrBLheYrGCrtWwVaLXlELsW/MYZrCTvTPBlb5lgJQHvgNkNzNE+m8LtD gCz1ToxXDShQZhWwNc70dDjw93JyeuuIBCrUusmsZxOVb5viagVNjiyQYHaQjFgdqjoZ jw4EFjhUrPXf8lIh5l+r8Ra4QQx5LAcVfbSH1k7ilX0aMZ9156GLhGvNfnQvTpb9aFJ1 R+RbQjEk2N5zPicHqJiyGVH4pDS/fcFxajoCzPGvSoV8qx8xfoFdqHK3SjCZkXHg+jNX ZfEFt6xVkZatgGpcpgTA6QgwGcf/IVdYsykE+6mT2S6joB9gB6dLmUv3z/DinuZp4xVf Sdbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724852615; x=1725457415; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k1Wxn4ztcsSpgPNwkQzBp5z/GYAcrxDMGZtIkBFIolE=; b=KXpWCXEdclj4kofWyDMoJ13gNlj1UOIHs9oAAOzTbDOU/YiddkqXTbkOnWanxptIV0 LfYp6HNwK2WmUkVbJDbmYCObqhabE93P0noaoV+mZ2qIIu5FnE/dNHNvWzkmlGHUkYFX eYn6Af/6GuAwrj4v/Pf6uym3M9vwfmpU17CQL/htsWN9GUp7nkp9L/07OF+/+qHZUq1z Z46I2WWKN/+ioI+X5AozPLy+0ZhCX/F0Vvr2e2jwA77/ZHI4wZZGBLgdkt7AB7fq5nOx yiZB3aDFIvtDTURaTKhYVE/IhZoH/w6M+EjD8i6w42BwsRd4JxxID1rUxvuW0X09qsg6 l7Wg== X-Gm-Message-State: AOJu0Yy3JAzUJSxSZ79Q8hvoNtNylgQ7O4XfHrb+qcD1TDvvuH9TY7oY jfDOZQ4K7fTjHbImB/nOPy7DFwABVzli0SR9eeZ3STRTIj0zelmTOuZuWg== X-Google-Smtp-Source: AGHT+IFIq0m7iVk4g3lUrpPJAI2qlO1wt2qk860rXKrsGobCTPeGLMggLSwjht8zoeTHwVb1AGkTuQ== X-Received: by 2002:a17:907:d3d1:b0:a86:721d:3021 with SMTP id a640c23a62f3a-a870a99137dmr164617766b.24.1724852614604; Wed, 28 Aug 2024 06:43:34 -0700 (PDT) Received: from corvink-nb.beckhoff.com ([195.226.174.194]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a88a48d4a39sm32606766b.12.2024.08.28.06.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 06:43:34 -0700 (PDT) From: " =?utf-8?q?Corvin_K=C3=B6hne?= " X-Google-Original-From: =?utf-8?q?Corvin_K=C3=B6hne?= To: qemu-devel@nongnu.org, c.koehne@beckhoff.com Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Alex Williamson Subject: [PATCH v3 5/7] vfio/igd: add ID's for ElkhartLake and TigerLake Date: Wed, 28 Aug 2024 15:43:26 +0200 Message-ID: <20240828134328.94528-6-c.koehne@beckhoff.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240828134328.94528-1-c.koehne@beckhoff.com> References: <20240828134328.94528-1-c.koehne@beckhoff.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=corvin.koehne@gmail.com; helo=mail-ed1-x531.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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 0d68c6a451..8a41b16421 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 Wed Aug 28 13:43: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: 13781297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 634ECC54FAA for ; Wed, 28 Aug 2024 13:45:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjIxZ-0004cz-1E; Wed, 28 Aug 2024 09:43:41 -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 1sjIxX-0004VL-4C for qemu-devel@nongnu.org; Wed, 28 Aug 2024 09:43:39 -0400 Received: from mail-ej1-x62a.google.com ([2a00:1450:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sjIxV-0002LF-Cr for qemu-devel@nongnu.org; Wed, 28 Aug 2024 09:43:38 -0400 Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a86984e035aso799579666b.2 for ; Wed, 28 Aug 2024 06:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724852615; x=1725457415; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t8g77ehzEy248A4F2VhK7RQfykf/Tq4WF/xnD5jpRvc=; b=SPPhNs8x2bZ34kp3UvwjR9WfH92iQmOjjc9XCYKLyKxw8cD3NeYQfbgtrIUa+GoVPF 8zCvlwRUr33iA4+MRqL4x/NjZ51zTLV32BgLSXinstEHV+1oI8z6n/rIkOnX5d2qvVh8 PkKkFW8mHLOf/7HNJ9L+OtS/BRSwyLz4mEpi8r9WxU+3+BK0RVTWtw0YyK9xPQYuEYma nqtK/70D08lsk0gXqwKX7+IM05RgyyZ7moc1tKSq+r+CfnF0dKrz+zdrfPb6xuNtZ6Kf QnsLRTb/NT4NjywJ4EHYlacYiRdv3UqYd4N8W7C6AZ1gqDdJyqzBmJpJ6nYE/Uq8n6uJ kVSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724852615; x=1725457415; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t8g77ehzEy248A4F2VhK7RQfykf/Tq4WF/xnD5jpRvc=; b=P+iYR6GjXN6ZwTvjk48qrc3hb0YmtC0jCY9829S55pfZtyy1DaW+DxbdhMVnSJwhqt Y7+oTNX6XwEAcVmDhjAqiKC2W6Kq/HsMX2eUaITdrPkbGELEXGI1FVfTxAbWEx+3QhDW 173XZ3MUZWhA7OyJidEkJieS39ccVbeIBEuGWXxcFagVx/YHiltFmJ9P59NsOCvIJJ5Q 5sGNnazV2eXVFODRfDpM0KVVgwrlbWXdrZYQc9K/rPF21P5ruQY4D9i+WouT7priiFoJ qSpNzu48ntszKPGKZzx9ucCyDYxqhza70L8yaDuFnrG7uGwvLz9BUkm+tPVMDGcUKEXj hhWA== X-Gm-Message-State: AOJu0YxzQif0BDHCkIkFefDpRzFBZqPLUpIt/t42+DlngKWxzrrnr0MH T4fS7SkalXH1V/LYqPRmDisdJVRifHowz/4Lb18GSjZKIUz74x/lLXqpVA== X-Google-Smtp-Source: AGHT+IGJ7gCPuyXg0FpikzRhJ3YLr3wHeMpfgB2pDAxDllzGkiZduwXvSNfIp6F2cDCneylUEbvcXg== X-Received: by 2002:a17:907:f1cd:b0:a86:743e:7a08 with SMTP id a640c23a62f3a-a870aa17258mr149849966b.31.1724852615379; Wed, 28 Aug 2024 06:43:35 -0700 (PDT) Received: from corvink-nb.beckhoff.com ([195.226.174.194]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a88a48d4a39sm32606766b.12.2024.08.28.06.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 06:43:35 -0700 (PDT) From: " =?utf-8?q?Corvin_K=C3=B6hne?= " X-Google-Original-From: =?utf-8?q?Corvin_K=C3=B6hne?= To: qemu-devel@nongnu.org, c.koehne@beckhoff.com Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Alex Williamson Subject: [PATCH v3 6/7] vfio/igd: don't set stolen memory size to zero Date: Wed, 28 Aug 2024 15:43:27 +0200 Message-ID: <20240828134328.94528-7-c.koehne@beckhoff.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240828134328.94528-1-c.koehne@beckhoff.com> References: <20240828134328.94528-1-c.koehne@beckhoff.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62a; envelope-from=corvin.koehne@gmail.com; helo=mail-ej1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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 8a41b16421..0751c43eae 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -478,6 +478,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; @@ -655,23 +672,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 Wed Aug 28 13:43: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: 13781296 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5426EC54FC6 for ; Wed, 28 Aug 2024 13:45:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sjIxb-0004lT-4r; Wed, 28 Aug 2024 09:43:43 -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 1sjIxY-0004aA-8j for qemu-devel@nongnu.org; Wed, 28 Aug 2024 09:43:40 -0400 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sjIxW-0002LS-Kt for qemu-devel@nongnu.org; Wed, 28 Aug 2024 09:43:40 -0400 Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-5343617fdddso10161062e87.0 for ; Wed, 28 Aug 2024 06:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724852616; x=1725457416; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TioKTDrezjGBN9Jcmp/sTjzMEyHQIz8aegXHEzpJf9U=; b=SkPP/0NWh0ECHQSIp7SMA48UjzmUGJPsQ4RHZ2LG9O1urKGDlVaWWsLfUBkBNoaCNu ojRaEx+wGSj7IgqygZmszpmOxx7XeD815PB0eEk3SvZbnTQl2NGkIwFDXzPBm+tp4L9C y5jhvWBVQumlmwAyC3om9MpcvkEZmClVytlzvLl6LeKGnQt7vXucAmFhU75JlAg9FASC I0T2JnMcV/lgEF9PheSSoRY0JzajHZmvziJSPpdicxcY/oe75PQLhpuG8vATz8WNoZeg Vkx7Znj0nf6rv19Jef75iUA/HFvf6FR6dhTMOzIPNPDzLLMxdBirNOlzD1FqQC2a1jP4 OGxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724852616; x=1725457416; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TioKTDrezjGBN9Jcmp/sTjzMEyHQIz8aegXHEzpJf9U=; b=bD8VoAOhZs6e8ZYssu9wcvWSAHA0dW9GEWJYStUXC03nZlkjG+TcykqdeHTu1JwAk1 CLkjDcJbTqRikeK89Ticup3HNzxldGqB3bBmOInvgCuaGtcn9LWFzeVyQsyGluKiOJf7 1U0bREzeIbYAPxq/kz6AS295HTeLoVw2TsGgSgIk0+l9/6bPqmPMWZ+EXRyQvHZ/Cyuy h5193ubp6VYZuSHrWCu0DCvLHgtY4zDp1U7geoj39DW0WR4b/zSeFJicyc5Nb/b4HTC2 zJyZx7V9KguNjZt+n6e6ZZS9fAwSRPO9quCjF/QVIyIoiy1wzRrGxlBQBUeJKxx6Xn1P cZyQ== X-Gm-Message-State: AOJu0YwP2Kh2qcm/BXqVxQYkLDzRUAr6KlGdW/84HWw/gV8eCqy8TK2Y AwAORzLhdD8WzXbiyHf4U4TkGtec/cr/YSJ8hjbVQYXRxdXrQh5pZlVpWA== X-Google-Smtp-Source: AGHT+IF6uYwPlwAVSOYp/jnB/u4VZiluvymBfHayhPGIX1WJhZlJmPVjLiWwB4VkBfQ/V1qQzE/FQw== X-Received: by 2002:a05:6512:10d6:b0:533:483f:9562 with SMTP id 2adb3069b0e04-5343887e18fmr13902110e87.42.1724852616307; Wed, 28 Aug 2024 06:43:36 -0700 (PDT) Received: from corvink-nb.beckhoff.com ([195.226.174.194]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a88a48d4a39sm32606766b.12.2024.08.28.06.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 06:43:35 -0700 (PDT) From: " =?utf-8?q?Corvin_K=C3=B6hne?= " X-Google-Original-From: =?utf-8?q?Corvin_K=C3=B6hne?= To: qemu-devel@nongnu.org, c.koehne@beckhoff.com Cc: =?utf-8?q?C=C3=A9dric_Le_Goater?= , Alex Williamson Subject: [PATCH v3 7/7] vfio/igd: correctly calculate stolen memory size for gen 9 and later Date: Wed, 28 Aug 2024 15:43:28 +0200 Message-ID: <20240828134328.94528-8-c.koehne@beckhoff.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240828134328.94528-1-c.koehne@beckhoff.com> References: <20240828134328.94528-1-c.koehne@beckhoff.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=corvin.koehne@gmail.com; helo=mail-lf1-x12c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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 0751c43eae..a95d441f68 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -488,11 +488,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)