From patchwork Fri Dec 6 12:27:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13897131 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 5B770E77173 for ; Fri, 6 Dec 2024 12:29:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJXRD-0005vn-4N; Fri, 06 Dec 2024 07:28:03 -0500 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 1tJXRB-0005vE-GH for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:01 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJXR9-00040n-NZ for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:01 -0500 Received: by mail-pg1-x543.google.com with SMTP id 41be03b00d2f7-7ea8de14848so1519834a12.2 for ; Fri, 06 Dec 2024 04:27:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733488078; x=1734092878; 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=UCFppN4wAZK14wOe4SWzJCCX/Db2Lt6zBXlKLoRhMX4=; b=D0G7KueDeKUk3rOb3r+fJjGeP58DVKPAHYCAzgdu1igLA3GF9pgT+pL0y6cxuItQ7c LbB1TWhEXmN9BmDuK/sxAOKHm2X7g9CenJz/rqGphYiB1OKXLmL9VbzZBUdxrZo+vFQG PCzQ1EJLZ6i8NugTy9hqiGi7kADSvs4DB91sQ6KCtLjLN34mdqPhx4w61jtHZobd24s3 hh1I38dAh2btonWyCI7sPazFhXNdTg6OfNyZqvmZqGUzhDXxt5js+KtOUlJAWS2ZbB30 NkegFbZvcGHBG66Ev0aixj6gIXg+aDVYDYDf6ciN16fNsCAy5l4p2D/cWL2uDSLjHM1d kRzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733488078; x=1734092878; 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=UCFppN4wAZK14wOe4SWzJCCX/Db2Lt6zBXlKLoRhMX4=; b=cIL+cqHDq98w4vIMGADw69YZ0d5W424ABmJdJH7PhkYqS4iA/SfEe5Es6eCL41MHsL 2YGv+/HaNfw5Ddfr6Y/dDUCff7Eigxw+KAEkC04WcuXga03mmjxswJya4hPttFa+1GV6 SJsakkHVfP+Ivbq4T340tHQzusXugqrSTRtpZ6ykbCUCCC19+IKwsmo1EFY7j/WWIOZ/ MoPuJkm3R2dih/U2OTyn5+dxttG3J7WaaFJcqBtEUPNlttM8IR+F9lVok+J4QQ38542j 5KQ/XSWaCbtySbOfssVW+Kgtn63Dht7B4O9FTopFeATeGYIKOK8//cqVRyq/7YpkNphl 4VPg== X-Gm-Message-State: AOJu0YxmoGzkcdkDbKzbzN4Zg3pyzMviKbxWT4468pYyCAjA9vKW5rCS P99s1rG6K50kNZuphxpdAcElTJ7ihP46d0676XcUmGP4dT+hjggp8X1ZrU5+6Q== X-Gm-Gg: ASbGncsN4cp7yO+QFT85er+8wcuiZqYHwkOiFqVbS2vrhWbwWQ1HGYQQZ1JbbP2vtqs MgcwGDgJPUbT4tjW82YEb4fnXMngpvqmc1+ZBJ662wBhu+eplQpyUWf+RLsh2BZ5W1D4iLGPDKB NBKH7lfOANBfFHb+3HsTK4D9OrKAGswr+cg0x5qAbuIhb3mWHOlLn+SaDB5aWX9BZ0dnGhn0+ZG xhV9UAVRsqtFt7JqkHjcA+8Sdo7212DKpr1iifCHk86pFG1+A5LYZ85wQ== X-Google-Smtp-Source: AGHT+IHTqkestPcILl8ajPIZnHE76q78Vur6R7bcMCSLVLp3vFNrJPb6EWBjRkEAYYnb8hXsKBSAAQ== X-Received: by 2002:a05:6a20:a104:b0:1e0:ca1c:8581 with SMTP id adf61e73a8af0-1e1870c975dmr4673936637.21.1733488078128; Fri, 06 Dec 2024 04:27:58 -0800 (PST) Received: from kotori-desktop.lan ([58.38.120.33]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd15710123sm2579866a12.49.2024.12.06.04.27.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 04:27:57 -0800 (PST) From: Tomita Moeko To: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= Cc: qemu-devel@nongnu.org, =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v4 01/10] vfio/igd: fix GTT stolen memory size calculation for gen 8+ Date: Fri, 6 Dec 2024 20:27:39 +0800 Message-ID: <20241206122749.9893-2-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206122749.9893-1-tomitamoeko@gmail.com> References: <20241206122749.9893-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=tomitamoeko@gmail.com; helo=mail-pg1-x543.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 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 On gen 8 and later devices, the GTT stolen memory size when GGMS equals 0 is 0 (no preallocated memory) rather than 1MB [1]. [1] 3.1.13, 5th Generation Intel Core Processor Family Datasheet Vol. 2 https://www.intel.com/content/www/us/en/content-details/330835 Fixes: c4c45e943e51 ("vfio/pci: Intel graphics legacy mode assignment") Reported-By: Alex Williamson Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 4047f4f071..73ed1ec8e6 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -268,7 +268,7 @@ static int vfio_igd_gtt_max(VFIOPCIDevice *vdev) gmch = vfio_pci_read_config(&vdev->pdev, IGD_GMCH, sizeof(gmch)); ggms = (gmch >> (gen < 8 ? 8 : 6)) & 0x3; - if (gen > 6) { + if (gen > 6 && ggms != 0) { ggms = 1 << ggms; } @@ -678,7 +678,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) /* Determine the size of stolen memory needed for GTT */ ggms_mb = (gmch >> (gen < 8 ? 8 : 6)) & 0x3; - if (gen > 6) { + if (gen > 6 && ggms_mb != 0) { ggms_mb = 1 << ggms_mb; } From patchwork Fri Dec 6 12:27:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13897148 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 9E12EE7717B for ; Fri, 6 Dec 2024 12:33:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJXRI-0005wa-25; Fri, 06 Dec 2024 07:28:08 -0500 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 1tJXRD-0005w3-En for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:03 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJXRB-00041H-NK for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:02 -0500 Received: by mail-pg1-x544.google.com with SMTP id 41be03b00d2f7-7fc8f0598cdso2457879a12.1 for ; Fri, 06 Dec 2024 04:28:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733488080; x=1734092880; 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=bhIrThlkutEtVHP85kOO3RvGh84lj/zvtAYPVdYZ2YE=; b=CfvUoFejQS4B/08LTohEVVac9Omeo/CB3LLX7dRwDFFlrICx03Ndr4FnIHlMIGJIOZ haW1yB3yQzfLqDGTWmJ8LdDNRdGoSsar6/kCkgFMOy+kLMOaPEcGpkYq8+9SMKP9yXpt 2TPlyz6qspmi3pFhrPGXdxBl10R5pN9jOjXxdQRGe+TdOSaa4sRyN2DIH9+wkrHg98zR qGyPCUm65gYBAw22vwSn9O/NkhUUK0ciwzSWfTYjIPMVeX1cnNGNWPhOBLKB2fyzKIXw EMWrFeC+DGNgUHLp/c7LTiCOtKvoshhovNTfmu03DBJP/miOW8HwQRwUqWavgDo6kQ1V X8rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733488080; x=1734092880; 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=bhIrThlkutEtVHP85kOO3RvGh84lj/zvtAYPVdYZ2YE=; b=MHUjtpG/AsIQKHI09KYrlYNdXHjKkgqqOe5u+rsgJdZXHy55uhhpnigBN+RBIgd9fg 9GLibBITyKwuN9ewHpgT7R4hDny+Y09JTQP1KKhyKSDUSK3LpR+oY5zY5WY6+6nshK74 wcsZoxEntfJnkVYmtBP1EOCf5iEvK2xWnfUvQJvLbBo0plQWM/6G8xvnqHjHhGWGtMgG 10JlABDvzavX02uAqZ90FDuX0+KucuGNWPTNWZIi/kS8Vya89oQhAXG6pDWu01TtBom6 +0AFjJ6apFuHp/9dbxs0t4qyFtBUOHC6xWksz0y3Oi94ne5b8i3+W/F+mvzfoNry0XG7 4v4w== X-Gm-Message-State: AOJu0YwwTbesM2YUmvM4j3arN7GagGmtG1RUFK/uClBUQbf6e7IReO7s rkBvGFeacv9224BJzNST2NEulBLwuntZe54xGA7Jr0uwCj4glRk= X-Gm-Gg: ASbGncsakJd+g8pPGVXpgRCuK2DANSSOP+P4N4UZJNg25fWZ9kmypeS6drkV74LI5N7 eYWE8EC6QMgoFqxrwG0en2Fev7BoByhyvC8ppVL+9D9ILOstMIwHXZ5HPcPOUIWtnZ7XmoFwIU0 JBtdW88fOyQu0lMqcEtXmOoBwiH8VZ/0kqDe1lQ2tXx5N0C25uFVJNIg4zIdq04y9hUHnLn1XrS +GOzECmgHZ7Bteha+ulqgyllfYJ2I8MxQldH+iqCh4teodFPXShggBVkg== X-Google-Smtp-Source: AGHT+IH8Qyc65xY1MGfV/+jM0YE3H69rEV7PTkQNx8+hqDRClYm+5KbRHEI8fphq1VTqEXscp/V2jQ== X-Received: by 2002:a05:6a20:258a:b0:1e0:d0b9:9a90 with SMTP id adf61e73a8af0-1e17d3a210fmr12350637637.13.1733488080300; Fri, 06 Dec 2024 04:28:00 -0800 (PST) Received: from kotori-desktop.lan ([58.38.120.33]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd15710123sm2579866a12.49.2024.12.06.04.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 04:27:59 -0800 (PST) From: Tomita Moeko To: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= Cc: qemu-devel@nongnu.org, =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v4 02/10] vfio/igd: remove unsupported device ids Date: Fri, 6 Dec 2024 20:27:40 +0800 Message-ID: <20241206122749.9893-3-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206122749.9893-1-tomitamoeko@gmail.com> References: <20241206122749.9893-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=tomitamoeko@gmail.com; helo=mail-pg1-x544.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 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 Since e433f208973f ("vfio/igd: return an invalid generation for unknown devices"), the default return of igd_gen() was changed to unsupported. There is no need to filter out those unsupported devices. Reviewed-by: Alex Williamson Reviewed-by: Corvin Köhne Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 73ed1ec8e6..059ed56439 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -64,16 +64,6 @@ static int igd_gen(VFIOPCIDevice *vdev) } switch (vdev->device_id & 0xff00) { - /* Old, untested, unavailable, unknown */ - case 0x0000: - case 0x2500: - case 0x2700: - case 0x2900: - case 0x2a00: - case 0x2e00: - case 0x3500: - case 0xa000: - return -1; /* SandyBridge, IvyBridge, ValleyView, Haswell */ case 0x0100: case 0x0400: From patchwork Fri Dec 6 12:27:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13897133 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 AD0ECE7717D for ; Fri, 6 Dec 2024 12:29:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJXRM-0005x0-DT; Fri, 06 Dec 2024 07:28:13 -0500 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 1tJXRF-0005wZ-QX for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:07 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJXRE-00041Y-38 for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:05 -0500 Received: by mail-pg1-x542.google.com with SMTP id 41be03b00d2f7-7fd23d9160dso930705a12.2 for ; Fri, 06 Dec 2024 04:28:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733488083; x=1734092883; 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=yCr1Si5UmdcLC4IV56KLZI508jQrygzNhxY3gT6chl4=; b=mFXTnM3/MwT1HzpLG45V1C/ta/b6UGDKoBqqSEya11Owl7dfr42HEeB6wIQgFDJqEu KEtONb+VqlDwwIm4/K4fcEZ6A//hwKzqEI+wr8dwNKIvZmZBRJYefnVd9crzSY/C2S5t lDcuMxnsOryZqJF3jsAtlX5Mg9lWKEsxoEwTEsBpNYxq2QtuoBJqT5L+ThOmW7kDJI1r VSpva2zun6I/fcZSoFk4WJVv1Fk574un3hF9OMfyk12IZC/qa4/lMOG/Mha+ph0D8Y3v m15RMZZnOuJPgpZjQcPCqrVuQS59kEwum7ziAaFdUZVOK4EGKcSQ9a6NhZqQQIQc8LT7 aUYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733488083; x=1734092883; 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=yCr1Si5UmdcLC4IV56KLZI508jQrygzNhxY3gT6chl4=; b=SQ3uNieA+2dTIW7DggA26fsxiXhFOAKkZ9jaMRgx0XzyOAwCGUsSoiH/xaSxM4Ea23 JXoo0DwiUnnmwKiTlDw2F3RJgPDuqoYP/DVbxO0XpHBi7nNCDRXu2FY1vNT61B3HWZzU JfGSOXIAw/D0zqfwtXPaUzObTMKBZIRlYCogcW4D1T2E5HNzjL2w6ZaXYbVMXEtR0TGY JTWIyL9eFZ1WaA4t7RjCddeOoLEJ/Ua54F6RPPRlo/RCnEUhZbLcTofPMRAURV1W8PEI Gn98tEsr1rUR93aoembPi5ViLaruUw/q07OEcX5A0d45Yus+HyWualH4GJ/mQmcUPend K4Pw== X-Gm-Message-State: AOJu0YwqgWZ3iRy/Ux+UdTkF+kO2nDYgj3IPq4DNI4kRrGlKMlg+97Iq KIABqKGu8Z+OJvMP2qDfwXKXh4v23xOPA19DrHLK7biohdlEIG0= X-Gm-Gg: ASbGnctfpFsZd6Mghjx8hemoNQNyTCuo8BuKr1CLV+Xfdr0OYlFDFK6RlQBfi4xAlBV agOjLfoAGv0eV5B108pvdee16hJ+7CjRUtZoh3zUdLs8uKEAPI8EeBt3MU+/ni8gzaB9q+6w2HE /LVTwHqQPacheOBP5e22kmciPOps0xdSEHzZGDPruwL4vXauf8QifDzz+mjibssbd4yiy6b4HuT 8DOPXqFlqeLr8cwoKxKv9s0HfzdmW/TbccOAVwqS/B4qfkOG12IJ2w8nA== X-Google-Smtp-Source: AGHT+IGZ/H8CQLg0JG+d4G+cGZgkcqsDPjr7UG3EqVLXEihxm4XSJquwabTpAOYvJIQ30SVdp/GkkQ== X-Received: by 2002:a05:6a21:99a2:b0:1e0:de01:4407 with SMTP id adf61e73a8af0-1e18713703cmr5172849637.37.1733488082773; Fri, 06 Dec 2024 04:28:02 -0800 (PST) Received: from kotori-desktop.lan ([58.38.120.33]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd15710123sm2579866a12.49.2024.12.06.04.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 04:28:02 -0800 (PST) From: Tomita Moeko To: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= Cc: qemu-devel@nongnu.org, =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v4 03/10] vfio/igd: align generation with i915 kernel driver Date: Fri, 6 Dec 2024 20:27:41 +0800 Message-ID: <20241206122749.9893-4-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206122749.9893-1-tomitamoeko@gmail.com> References: <20241206122749.9893-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::542; envelope-from=tomitamoeko@gmail.com; helo=mail-pg1-x542.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 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 Define the igd device generations according to i915 kernel driver to avoid confusion, and adjust comment placement to clearly reflect the relationship between ids and devices. The condition of how GTT stolen memory size is calculated is changed accordingly as GGMS is in multiple of 2 starting from gen 8. Reviewed-by: Corvin Köhne Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 059ed56439..09bd4e5383 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -59,33 +59,34 @@ */ static int igd_gen(VFIOPCIDevice *vdev) { - if ((vdev->device_id & 0xfff) == 0xa84) { - return 8; /* Broxton */ + /* + * Device IDs for Broxton/Apollo Lake are 0x0a84, 0x1a84, 0x1a85, 0x5a84 + * and 0x5a85, match bit 11:1 here + * Prefix 0x0a is taken by Haswell, this rule should be matched first. + */ + if ((vdev->device_id & 0xffe) == 0xa84) { + return 9; } switch (vdev->device_id & 0xff00) { - /* SandyBridge, IvyBridge, ValleyView, Haswell */ - case 0x0100: - case 0x0400: - case 0x0a00: - case 0x0c00: - case 0x0d00: - case 0x0f00: + case 0x0100: /* SandyBridge, IvyBridge */ return 6; - /* BroadWell, CherryView, SkyLake, KabyLake */ - case 0x1600: - case 0x1900: - case 0x2200: - case 0x5900: + case 0x0400: /* Haswell */ + case 0x0a00: /* Haswell */ + case 0x0c00: /* Haswell */ + case 0x0d00: /* Haswell */ + case 0x0f00: /* Valleyview/Bay Trail */ + return 7; + case 0x1600: /* Broadwell */ + case 0x2200: /* Cherryview */ return 8; - /* CoffeeLake */ - case 0x3e00: + case 0x1900: /* Skylake */ + case 0x5900: /* Kaby Lake */ + case 0x3e00: /* Coffee Lake */ return 9; - /* ElkhartLake */ - case 0x4500: + case 0x4500: /* Elkhart Lake */ return 11; - /* TigerLake */ - case 0x9A00: + case 0x9A00: /* Tiger Lake */ return 12; } @@ -258,7 +259,7 @@ static int vfio_igd_gtt_max(VFIOPCIDevice *vdev) gmch = vfio_pci_read_config(&vdev->pdev, IGD_GMCH, sizeof(gmch)); ggms = (gmch >> (gen < 8 ? 8 : 6)) & 0x3; - if (gen > 6 && ggms != 0) { + if (gen >= 8 && ggms != 0) { ggms = 1 << ggms; } @@ -668,7 +669,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) /* Determine the size of stolen memory needed for GTT */ ggms_mb = (gmch >> (gen < 8 ? 8 : 6)) & 0x3; - if (gen > 6 && ggms_mb != 0) { + if (gen >= 8 && ggms_mb != 0) { ggms_mb = 1 << ggms_mb; } From patchwork Fri Dec 6 12:27:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13897139 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 1D1E4E77173 for ; Fri, 6 Dec 2024 12:31:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJXRR-0005zD-0Y; Fri, 06 Dec 2024 07:28:17 -0500 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 1tJXRL-0005x9-EM for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:12 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJXRI-00042A-6j for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:09 -0500 Received: by mail-pg1-x544.google.com with SMTP id 41be03b00d2f7-7fc8f0598cdso2457924a12.1 for ; Fri, 06 Dec 2024 04:28:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733488085; x=1734092885; 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=Lx7mWSlMFt3UwBpDPHAXwsNgtKvBMAr06837vMU0kv4=; b=F0QCOFyV04CDdEMSH3kE+Onr64JkIsGjLYpltCCihWqcS6hSOj9M8Ixg+fne3wxdhO /IPXir7CT+h/TCRfXddDf4hn5UMdMT05x9qQafrPpuR4Vt+iy23h0iwgwRNduvYqJ/p2 /BsIyX4P+t0nxDBQW7uYcbKUPF4ptDzyPvnSGefZrcHihBXYgcWTseDlbknuQgIbowd/ aY7SdfRgOujDs/f+Pbie1wADIKy3e6cTXxU8haZ/SdEkNlBkEBcyLOyEjYbBz4ruMjHk V/VbLtPf26M0feVHWg2GfVcbsqM5jHwt+TClKu5rguQn7uySTaY5lLsLjUiVq6YNysQ9 QCzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733488085; x=1734092885; 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=Lx7mWSlMFt3UwBpDPHAXwsNgtKvBMAr06837vMU0kv4=; b=pKrIeIo35//ZuHCyDxAInMb7W6bc5iUB3Ce+GdVG8jITbSlGa0sCAxR5e23bctHEyG 1gDIAnbSn9js+lg7qvzuLOzdmsVmcceuKrqGm3/5o5VN8qo4ProMKeyTFoaf3AiZBi3a d1w/vgJC/9ettGs+lNGt261B2TyQeG4bo9S2pB0TbrYRHBk+WZRthqA/r5bwzY1NH3B4 ECZUBqtdmbRjcF5f9U+vh6NLKnMmZSBsZSaSOZyib37LuDF2FWUPU4VAVomEj6Dko5ZD Tfw6ZSnmdGXNHUyNRplfUpQiLs0cseM/lFJPUnVDnaHGSi+2PCC+z7zTFCQXiJymLF2Q Y2cA== X-Gm-Message-State: AOJu0YygXHD/VSr6Oj2ckmf7oGB12IpPL8NXsisASiVg0SHfjwH4MJqL 7MxjmqHn0/E+3RMHK8wNfV1YPtJldH49xSLvyfplEi15qbSaH4njq2pfZnYDdw== X-Gm-Gg: ASbGncuFZyhji1bF4aeO/teX/dfJtVCbGOXDqlUYi/1o2+obxYMLcJeZeoLCJ0ifUF/ PjSX7Ba48lqRejek6yNjUza+MZ3d8gSsIKR3TvMjBeSW1EGqCHHrFL8KUBOa0MB6Pq3N4KS+G3i hzbh6dW90JQtTL/k0UlP5zy4VrUy/kELsU6oEAqXZGfdgnvyZyEMRffepTsE4IfxAa3CbDxFaE0 lNcX3ibKsbH8fePVMVsQ4iIHF8QR427veg3/gZTPVblJLvAPn6urfddVQ== X-Google-Smtp-Source: AGHT+IEwmYTTt6eziYeyTfkkB9ABUTiABB7zcs9qx5iq5RlulCu5wAHWU6WnG4X0dLegN6wV0MLbig== X-Received: by 2002:a05:6a21:6d98:b0:1e1:6b0a:c26d with SMTP id adf61e73a8af0-1e186c50de8mr4469807637.18.1733488085203; Fri, 06 Dec 2024 04:28:05 -0800 (PST) Received: from kotori-desktop.lan ([58.38.120.33]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd15710123sm2579866a12.49.2024.12.06.04.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 04:28:04 -0800 (PST) From: Tomita Moeko To: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= Cc: qemu-devel@nongnu.org, =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v4 04/10] vfio/igd: canonicalize memory size calculations Date: Fri, 6 Dec 2024 20:27:42 +0800 Message-ID: <20241206122749.9893-5-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206122749.9893-1-tomitamoeko@gmail.com> References: <20241206122749.9893-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=tomitamoeko@gmail.com; helo=mail-pg1-x544.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 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 Add helper functions igd_gtt_memory_size() and igd_stolen_size() for calculating GTT stolen memory and Data stolen memory size in bytes, and use macros to replace the hardware-related magic numbers for better readability. Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 101 ++++++++++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 44 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 09bd4e5383..e231865d72 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -107,6 +107,53 @@ typedef struct VFIOIGDQuirk { #define IGD_BDSM 0x5c /* Base Data of Stolen Memory */ #define IGD_BDSM_GEN11 0xc0 /* Base Data of Stolen Memory of gen 11 and later */ +#define IGD_GMCH_GEN6_GMS_SHIFT 3 /* SNB_GMCH in i915 */ +#define IGD_GMCH_GEN6_GMS_MASK 0x1f +#define IGD_GMCH_GEN6_GGMS_SHIFT 8 +#define IGD_GMCH_GEN6_GGMS_MASK 0x3 +#define IGD_GMCH_GEN8_GMS_SHIFT 8 /* BDW_GMCH in i915 */ +#define IGD_GMCH_GEN8_GMS_MASK 0xff +#define IGD_GMCH_GEN8_GGMS_SHIFT 6 +#define IGD_GMCH_GEN8_GGMS_MASK 0x3 + +static uint64_t igd_gtt_memory_size(int gen, uint16_t gmch) +{ + uint64_t ggms; + + if (gen < 8) { + ggms = (gmch >> IGD_GMCH_GEN6_GGMS_SHIFT) & IGD_GMCH_GEN6_GGMS_MASK; + } else { + ggms = (gmch >> IGD_GMCH_GEN8_GGMS_SHIFT) & IGD_GMCH_GEN8_GGMS_MASK; + if (ggms != 0) { + ggms = 1 << ggms; + } + } + + return ggms * MiB; +} + +static uint64_t igd_stolen_memory_size(int gen, uint32_t gmch) +{ + uint64_t gms; + + if (gen < 8) { + gms = (gmch >> IGD_GMCH_GEN6_GMS_SHIFT) & IGD_GMCH_GEN6_GMS_MASK; + } else { + gms = (gmch >> IGD_GMCH_GEN8_GMS_SHIFT) & IGD_GMCH_GEN8_GMS_MASK; + } + + if (gen < 9) { + return gms * 32 * MiB; + } else { + if (gms < 0xf0) { + return gms * 32 * MiB; + } else { + return (gms - 0xf0 + 1) * 4 * MiB; + } + } + + return 0; +} /* * The rather short list of registers that we copy from the host devices. @@ -255,17 +302,10 @@ static int vfio_pci_igd_lpc_init(VFIOPCIDevice *vdev, static int vfio_igd_gtt_max(VFIOPCIDevice *vdev) { uint32_t gmch = vfio_pci_read_config(&vdev->pdev, IGD_GMCH, sizeof(gmch)); - int ggms, gen = igd_gen(vdev); - - gmch = vfio_pci_read_config(&vdev->pdev, IGD_GMCH, sizeof(gmch)); - ggms = (gmch >> (gen < 8 ? 8 : 6)) & 0x3; - if (gen >= 8 && ggms != 0) { - ggms = 1 << ggms; - } - - ggms *= MiB; + int gen = igd_gen(vdev); + uint64_t ggms_size = igd_gtt_memory_size(gen, gmch); - return (ggms / (4 * KiB)) * (gen < 8 ? 4 : 8); + return (ggms_size / (4 * KiB)) * (gen < 8 ? 4 : 8); } /* @@ -472,30 +512,6 @@ 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 (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 - 0xf0) * 4 + 4; - } -} - void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) { g_autofree struct vfio_region_info *rom = NULL; @@ -505,7 +521,8 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) VFIOQuirk *quirk; VFIOIGDQuirk *igd; PCIDevice *lpc_bridge; - int i, ret, ggms_mb, gms_mb = 0, gen; + int i, ret, gen; + uint64_t ggms_size, gms_size; uint64_t *bdsm_size; uint32_t gmch; uint16_t cmd_orig, cmd; @@ -667,13 +684,8 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); - /* Determine the size of stolen memory needed for GTT */ - ggms_mb = (gmch >> (gen < 8 ? 8 : 6)) & 0x3; - if (gen >= 8 && ggms_mb != 0) { - ggms_mb = 1 << ggms_mb; - } - - gms_mb = igd_get_stolen_mb(gen, gmch); + ggms_size = igd_gtt_memory_size(gen, gmch); + gms_size = igd_stolen_memory_size(gen, gmch); /* * Request reserved memory for stolen memory via fw_cfg. VM firmware @@ -684,7 +696,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) * config offset 0x5C. */ bdsm_size = g_malloc(sizeof(*bdsm_size)); - *bdsm_size = cpu_to_le64((ggms_mb + gms_mb) * MiB); + *bdsm_size = cpu_to_le64(ggms_size + gms_size); fw_cfg_add_file(fw_cfg_find(), "etc/igd-bdsm-size", bdsm_size, sizeof(*bdsm_size)); @@ -735,5 +747,6 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) vdev->vbasedev.name); } - trace_vfio_pci_igd_bdsm_enabled(vdev->vbasedev.name, ggms_mb + gms_mb); + trace_vfio_pci_igd_bdsm_enabled(vdev->vbasedev.name, + (ggms_size + gms_size) / MiB); } From patchwork Fri Dec 6 12:27:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13897169 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 CD349E77179 for ; Fri, 6 Dec 2024 12:34:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJXRi-00066Y-I9; Fri, 06 Dec 2024 07:28:34 -0500 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 1tJXRO-0005xt-Vw for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:15 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJXRK-00042r-2C for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:14 -0500 Received: by mail-pg1-x544.google.com with SMTP id 41be03b00d2f7-7fd10cd5b1aso1474796a12.2 for ; Fri, 06 Dec 2024 04:28:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733488088; x=1734092888; 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=DxafhFvYtf9jVszuSh+7ZDIex2hyUu5Kz37u7+ddEIU=; b=gKwc0Vn9hQRZLk6xeq/wU3gufiyejGsFufTyiTlU+W7k0YdR/GeHE4Zx52wSpgr8Sb P97phAt7BxEHe8uiGC+BLKLAsQExS4v1iP9Dn7NmTvz45IMmbBOwUSW7SdQusifSojKp pDFxm0GcCsfpanwTsVprILM98U3GdlriBMn43xtKlWkbKN2XVWiHfoR5lx4lwt3pP/Sy mFFfzwXtRrMmDoNa1PGPgD+Sx+kQDIweUCG+3d/z4IS+jG4yEIkvGI95vuSO7BkXhhsy tTXnJApPLe5DWZ0m5ECSewaL5Bzyv5ZQ6CjSQIH9SgdiswD6d03TfdZHlP1pgStmdLwv G5Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733488088; x=1734092888; 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=DxafhFvYtf9jVszuSh+7ZDIex2hyUu5Kz37u7+ddEIU=; b=niX4i05++tAH76OGg4tD/QI+rtSSAV00EjkaVYrK0ZlxhYruK9zo86W/FN3LqtxLTK 1UhvGxuVHY5MumHSupK6jUGH7/eFQZrWPUkSrQNKGlApuHJ8yq7pmPmBo9LSe1MBaMCS qj5f8HqRX8VGM8DVvtGmDPhPU4PdEOHk9GGVJtIdHZlElp83K4LXaoN5aFjLxKhnv3xc z3AWiprD3H+C03D1gmzxAxjmT4XQhTDMgOL93Rqt52NTOrCR+d6pJ2TJRwCg9DpxrT3X 91s0nRxt/c/V4tWQ0LP8n3TexHAU+Z7YzbkfrnpFxQAD7DBNjnO3iQB511f6PecQGxmD xIjw== X-Gm-Message-State: AOJu0YyZjSjR9LMrWA0dCuhVA5y1uf6v2WX3G8+nq5PubclC2ZS3zVJb Ol/d7EZSuGzo/SU4hJ5tB22Y07HyuoBKl/w41Uyrpvynbjs6STo0fc4j03a/Lw== X-Gm-Gg: ASbGncuDVG6pW60WZgYW1AIz7yRoStLXDbxM61C/RLMPRBlfVTu2on735+B7gKEv9DT wguHqACdbQ2kGKRKpGA1lVbtTMJCMkYi6l5nVSXvf1HmPv3EUfxI73qlUA5akbzVKCRT2Q4i6Vc +ot4ZuH5WpFMS2ME2xigB94TqW/taofUAQwIBghnUXq2mEKxn++ntAQhZ74F3RV76i0tA6QBMNT 2V49EbW60FShMFv5DWGgXVkt7tERoWRWU6MM7FdCboR2ivULwNI4tbKiQ== X-Google-Smtp-Source: AGHT+IFboRv/tvwJGafGbOiwKYEloWs5nD03RcrHhJJsi8BS7hfjcv/Pgu3dXM1wG0lkDiuTFfuaPQ== X-Received: by 2002:a05:6a20:8408:b0:1db:daab:2ae7 with SMTP id adf61e73a8af0-1e1870c44c9mr4568666637.19.1733488087947; Fri, 06 Dec 2024 04:28:07 -0800 (PST) Received: from kotori-desktop.lan ([58.38.120.33]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd15710123sm2579866a12.49.2024.12.06.04.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 04:28:07 -0800 (PST) From: Tomita Moeko To: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= Cc: qemu-devel@nongnu.org, =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v4 05/10] vfio/igd: add Gemini Lake and Comet Lake device ids Date: Fri, 6 Dec 2024 20:27:43 +0800 Message-ID: <20241206122749.9893-6-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206122749.9893-1-tomitamoeko@gmail.com> References: <20241206122749.9893-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=tomitamoeko@gmail.com; helo=mail-pg1-x544.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 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 Both Gemini Lake and Comet Lake are gen 9 devices. Many user reports on internet shows legacy mode of igd passthrough works as qemu treats them as gen 8 devices by default before e433f208973f ("vfio/igd: return an invalid generation for unknown devices"). Reviewed-by: Corvin Köhne Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index e231865d72..ed236f443a 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -81,8 +81,10 @@ static int igd_gen(VFIOPCIDevice *vdev) case 0x2200: /* Cherryview */ return 8; case 0x1900: /* Skylake */ + case 0x3100: /* Gemini Lake */ case 0x5900: /* Kaby Lake */ case 0x3e00: /* Coffee Lake */ + case 0x9B00: /* Comet Lake */ return 9; case 0x4500: /* Elkhart Lake */ return 11; From patchwork Fri Dec 6 12:27:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13897135 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 A1CA7E77173 for ; Fri, 6 Dec 2024 12:29:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJXSD-0006Yn-Pk; Fri, 06 Dec 2024 07:29:06 -0500 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 1tJXRP-0005zE-NX for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:15 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJXRM-00043V-QG for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:15 -0500 Received: by mail-pg1-x544.google.com with SMTP id 41be03b00d2f7-7fd2ff40782so78539a12.2 for ; Fri, 06 Dec 2024 04:28:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733488090; x=1734092890; 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=u6IjMTOhbbtnbKyiu9odYQrXzvjL175+vD8tdZJb7kU=; b=gq20P4ik3aaOwfIhD0bWMDiR7Zz5hVfS4KanQyn2vZOg4pJMVtcDmweajgN+gIl9rA atn+TmUbrj+AumauDIxIF4zSaD1YGqgbnvsxiGbC2H72zIgBTmb6o2lXpGzMfOCJDlwQ fFC77YwtGpfGKzCaAm1NpTqD95IRGikzjVPG3KiEXjMIWJh2z66Ylrn6v8GUEn8nvdGn Ou9vHj3ixsXq+umNOyg4pdRSX10FjR5DDqF1L/yuY30RdO5L6sXCTxCc8HL6p0wbbS6O bwm2FWisvxksoDPZXzLQ0uzCoVhKMe8DoeRuqYQbdz0xTDrzwgQ7aXu6u/OFwjP2H69b GR1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733488090; x=1734092890; 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=u6IjMTOhbbtnbKyiu9odYQrXzvjL175+vD8tdZJb7kU=; b=KjxYiBAsGggTsfHA+1lbCVcZ88ZIPBYrhUk3IzEyuRtt2xPDjCRIgUWlVzQcOKl93l cbtZlOjhwcC97wfxQKpy46k0fX1ub84OXviB5g1rMyu8thN3IiR8VB1OCkfUjKcVJ2lX +ivT0YNZuJw1xrunTCiiYaZXIZme1xzcrAAZEFdDEFUAOcTf6l/bO0NY/WCKKZ3wvXel e+SZQxyfqUq6GOQb0Cb7HNgn8ojyAdNmXN4b7VfL4OdygI+NL9sdl4VBNwrZQ1FrdfQQ tTk+3hndGVHCrEt+xDSlvMvS4WzXhFg+FthI90L/ZMZerkrKrstRXx7RnAKgbHzF4LOJ BWEg== X-Gm-Message-State: AOJu0Yy0GksFvyzsF3tLLZGddC5XTvrbp1rYEaZAz45jDcwOgqoh1IVD hQVQzN/wVbpFOIWwWJNCHtDyM+CmmgaKcdcFSyWiVeeh3ZuOQl4fjaWXlwpzkw== X-Gm-Gg: ASbGnctp+ZlvhEgLKTCVsUgro7QFD5FLOnz2OmOQ0jASGtqKA2cFrvhJMJbbULDyDA4 xh9P8MjP5/jQMLil3/8faDEE2t0HM8v8mImNBKdmb/RQzuXwyexwgEehfmk22bSEv70L00/oStI SjyqfpmyppiJSheYSuUpRwyT81AzuoM/L361kTgcG5SRqNSxXkceCq+ZmouOroCDbIQB94f+3zz RDLlVjJUxnJh3H3ZmYuGuPVOPbsWG7ei457AHifYES2BiseQ/79P3yZ1A== X-Google-Smtp-Source: AGHT+IHEGMXAG5oagoQTnTA103gm5+sZAl7xZs3LnjkUVjThmPcaRjOp1zyxC0RMDyPTgnX5b1xDkA== X-Received: by 2002:a05:6a20:7f9a:b0:1e0:dc34:2e7d with SMTP id adf61e73a8af0-1e1870aea52mr4908449637.5.1733488090069; Fri, 06 Dec 2024 04:28:10 -0800 (PST) Received: from kotori-desktop.lan ([58.38.120.33]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd15710123sm2579866a12.49.2024.12.06.04.28.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 04:28:09 -0800 (PST) From: Tomita Moeko To: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= Cc: qemu-devel@nongnu.org, =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v4 06/10] vfio/igd: add Alder/Raptor/Rocket/Ice/Jasper Lake device ids Date: Fri, 6 Dec 2024 20:27:44 +0800 Message-ID: <20241206122749.9893-7-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206122749.9893-1-tomitamoeko@gmail.com> References: <20241206122749.9893-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=tomitamoeko@gmail.com; helo=mail-pg1-x544.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 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 All gen 11 and 12 igd devices have 64 bit BDSM register at 0xC0 in its config space, add them to the list to support igd passthrough on Alder/ Raptor/Rocket/Ice/Jasper Lake platforms. Tested legacy mode of igd passthrough works properly on both linux and windows guests with AlderLake-S GT1 (8086:4680). Reviewed-by: Corvin Köhne Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index ed236f443a..49b6547776 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -86,9 +86,14 @@ static int igd_gen(VFIOPCIDevice *vdev) case 0x3e00: /* Coffee Lake */ case 0x9B00: /* Comet Lake */ return 9; + case 0x8A00: /* Ice Lake */ case 0x4500: /* Elkhart Lake */ + case 0x4E00: /* Jasper Lake */ return 11; case 0x9A00: /* Tiger Lake */ + case 0x4C00: /* Rocket Lake */ + case 0x4600: /* Alder Lake */ + case 0xA700: /* Raptor Lake */ return 12; } From patchwork Fri Dec 6 12:27:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13897144 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 0A2AFE7717B for ; Fri, 6 Dec 2024 12:32:32 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJXSK-0007Cs-NE; Fri, 06 Dec 2024 07:29:12 -0500 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 1tJXRR-000607-Hx for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:17 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJXRN-00044B-TN for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:16 -0500 Received: by mail-pg1-x543.google.com with SMTP id 41be03b00d2f7-7e6d04f74faso1418400a12.1 for ; Fri, 06 Dec 2024 04:28:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733488092; x=1734092892; 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=DbyhL467kLFoNyl59lj+CqWMKUpCY5M1py2Usy4VavY=; b=IIo3F1XipzVPKoQU7L3/CXHmYs4GRU4hq8RDGfobATi4GGnYp2ZEOnRyJK8vGeFFR4 VaQUhZRlPId4Xj+3sJCC6mRS1Z/JTurpfgcFdaHjoOIILlDgNkPMeOXi4zVQg/sjbCuT TliT4WSoSDr6oj380aKBUR6Scf5nS85VwF9NSTnTEwrzJGqE1l712rzVsUqsjRBwvtuT 91VEu/fBXSzxgWIqlq+/fM2rNtJHfNgE6GbWwK6rbufhI/L3pgacX/9MAzpSCHoSEYGk +3SVem0zYqPNvg9WwHKDUvnWvC8+LaXQwT8qiPjaodALUe3PbM21HtS9AJvi8G1oBlDI AfRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733488092; x=1734092892; 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=DbyhL467kLFoNyl59lj+CqWMKUpCY5M1py2Usy4VavY=; b=W3H669w60dbGAax0gfT1TKLGt1P52JdHXJjlN308F3jlFZPpXwsn3Tfx+z0D4DS6u6 ZhiZgx8BvW6E0UD6fiiGR4wrdids854SILZIMMCKO1yx/IN72MzkrHmxIZ97f9T3TAeW 4I2BGB0OoqHWp9K7pZkbNmIc0pncSCJWHx5c38SYpoxEQFC8DujMpPMa1Q5GxzpAyouc REXI7p6w0JuWceBCfjfxr8zrhMtEb6Z2B2jZmpwJxd3NKQyQvx1CA9HW3A6PH4LARlSG uA+MlfV6vpgz/AidAKWYoFBNfy7NO+EvndUX0yLydvrUUUN0ecLPM/hKPTHSji1PJTLn Breg== X-Gm-Message-State: AOJu0Yzbw8Lc381HqFSgsSZTuA66L2hhvDhvqcsZ46mPAc5neDflNcvG XWRzMfnLnDhBr3eY7vJojiCUsVvWYRnuGsJQJ8Fs6PvbHZWyju4= X-Gm-Gg: ASbGncuavLAfUdz4BLYFL5rCjXWHE39rTDG8gfxzrOG+fXRCGSCFrbc9rOwXDVX8PQK I0Vh08fdC3FZBQlmCVWFYoh3GfgdC+f1Rvbybfa7invAwlibDxR7jk57ZEWrspfC00fXPR39Os+ ckF2i7QMhlpR5M79bQ1wE96tcdInTOLQCju7jq/dMVEtStGsJUjjk0nipLx6aWmFywnXqshRk32 vOthN5iaD9YcgrZFHtJxIsAv4Ltp9Q09oBt/JtAZRaJ03FxO1Hg4/r42Q== X-Google-Smtp-Source: AGHT+IHsa5HWvav2cpVUakpvjSeMJk2vdddGmxJ7TKhFYDXJjteWN7/lkHX2hBlcultZsrKnIwc5cA== X-Received: by 2002:a17:90a:2ca3:b0:2ef:2980:4411 with SMTP id 98e67ed59e1d1-2ef41c0db62mr11259048a91.9.1733488092525; Fri, 06 Dec 2024 04:28:12 -0800 (PST) Received: from kotori-desktop.lan ([58.38.120.33]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd15710123sm2579866a12.49.2024.12.06.04.28.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 04:28:12 -0800 (PST) From: Tomita Moeko To: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= Cc: qemu-devel@nongnu.org, =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v4 07/10] vfio/igd: add macro for declaring mirrored registers Date: Fri, 6 Dec 2024 20:27:45 +0800 Message-ID: <20241206122749.9893-8-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206122749.9893-1-tomitamoeko@gmail.com> References: <20241206122749.9893-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::543; envelope-from=tomitamoeko@gmail.com; helo=mail-pg1-x543.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 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 igd devices have multipe registers mirroring mmio address and pci config space, more than a single BDSM register. To support this, the read/write functions are made common and a macro is defined to simplify the declaration of MemoryRegionOps. Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 60 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 49b6547776..18d159aa8e 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -421,16 +421,9 @@ 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) +static uint64_t vfio_igd_pci_config_read(VFIOPCIDevice *vdev, uint64_t offset, + 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); @@ -441,21 +434,17 @@ static uint64_t vfio_igd_quirk_bdsm_read(void *opaque, case 8: return pci_get_quad(vdev->pdev.config + offset); default: - hw_error("igd: unsupported read size, %u bytes", size); + hw_error("igd: unsupported pci config read at %lx, size %u", + offset, size); break; } return 0; } -static void vfio_igd_quirk_bdsm_write(void *opaque, hwaddr addr, - uint64_t data, unsigned size) +static void vfio_igd_pci_config_write(VFIOPCIDevice *vdev, uint64_t offset, + 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); @@ -470,17 +459,39 @@ static void vfio_igd_quirk_bdsm_write(void *opaque, hwaddr addr, pci_set_quad(vdev->pdev.config + offset, data); break; default: - hw_error("igd: unsupported read size, %u bytes", size); + hw_error("igd: unsupported pci config write at %lx, size %u", + offset, 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, +#define VFIO_IGD_QUIRK_MIRROR_REG(reg, name) \ +static uint64_t vfio_igd_quirk_read_##name(void *opaque, \ + hwaddr addr, unsigned size) \ +{ \ + VFIOPCIDevice *vdev = opaque; \ + \ + return vfio_igd_pci_config_read(vdev, reg + addr, size); \ +} \ + \ +static void vfio_igd_quirk_write_##name(void *opaque, hwaddr addr, \ + uint64_t data, unsigned size) \ +{ \ + VFIOPCIDevice *vdev = opaque; \ + \ + vfio_igd_pci_config_write(vdev, reg + addr, data, size); \ +} \ + \ +static const MemoryRegionOps vfio_igd_quirk_mirror_##name = { \ + .read = vfio_igd_quirk_read_##name, \ + .write = vfio_igd_quirk_write_##name, \ + .endianness = DEVICE_LITTLE_ENDIAN, \ }; +VFIO_IGD_QUIRK_MIRROR_REG(IGD_BDSM_GEN11, bdsm) + +#define IGD_BDSM_MMIO_OFFSET 0x1080C0 + void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) { VFIOQuirk *quirk; @@ -510,8 +521,9 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) 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_init_io(&quirk->mem[0], OBJECT(vdev), + &vfio_igd_quirk_mirror_bdsm, vdev, + "vfio-igd-bdsm-quirk", 8); memory_region_add_subregion_overlap(vdev->bars[0].region.mem, IGD_BDSM_MMIO_OFFSET, &quirk->mem[0], 1); From patchwork Fri Dec 6 12:27:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13897167 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 BD45AE7717D for ; Fri, 6 Dec 2024 12:34:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJXSI-00071W-Db; Fri, 06 Dec 2024 07:29:10 -0500 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 1tJXRT-00061k-4c for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:19 -0500 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJXRR-00046L-93 for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:18 -0500 Received: by mail-oi1-x243.google.com with SMTP id 5614622812f47-3eb0fbb0f62so690153b6e.3 for ; Fri, 06 Dec 2024 04:28:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733488095; x=1734092895; 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=Afev6en4kR+CrZleuto4wB3x+yzqkCFox++dU9LzUsA=; b=P23Rfi9xhNG28NJr6zpJIchfXK1aaJETWfDhv56f8vbq7+TJsI1FWd5oNbv1ukZ8/j voypnwV2lPNqKkCoZdwOKkEFJWJpLUbE6uF5jRL3nxUBCopdsXuPyEIuN2KInu5wgDoD lCKLw2n4YWPJ+WHMnk+tdGAB3Eg/3GITmdlCfr2QzlvsgoEEI4s7uz4Vkm7WCGN+m10X luxmAVimAL5WBiNUgo9y98g11gCMMJeg2FfgrjyakT/GhZOGf9blU+1aVvve37gVbDuc GB6okAHwTQke8PT85MZZFmC6MzolMdLHo7DzqHrIUwpjcv5RQIxhJpZwpTfEZn9/YPYM nzlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733488095; x=1734092895; 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=Afev6en4kR+CrZleuto4wB3x+yzqkCFox++dU9LzUsA=; b=DdN9U9cMlXIG9mmNj2lKcsoqcdobL/LlFKgRgK9M1tPfQlY/ygZ8I28PIvWwoOx2bn Odw59VETJxqEBMJxZ4PRVsMmtTCj1sd3IjW1LgXrxeyCvKGzedBZBmpQkzM7g89/47N/ xRi7x6tghYLhCGYWZytDicOjFw+H8/G22HkueeVIJiYPLHUa/ci32qkrJQWOgLKkabjG 7PtJ8whW6OFqzoMcC4ykdbDFnOyhNT8WEtXlkvy/skXWbpYqsX8jm4vuBWZPEFPEEXOI sCduiKtudlXpPTNmffO8DsF46vdrjhjiYN32SdbfyywgvMjX0HazE1acOKZqFpQNYdO/ cqdw== X-Gm-Message-State: AOJu0YxQgTDmYNxquQ8ulgcF+3ZlJolQEroxTjoeGuHCtiaUlYuTWh2M GEY8H9dqYCKgOb0ShfiJ3zslwjrtDhI3+w9PLJzw4wWxsIbptzo= X-Gm-Gg: ASbGnct2iM6oJ0N5cJ6i3F13T5Q9sfqu3+Lfsa2mGb3fnUNrkMtYmELS4mi2GemQe4x fQsM/C/+MWflAt3G+s0RFeXhvZkhC7IJL09BWxYnHDnt5Ju3GEat4xI/R4uip06POzzAVWtso6p C2KB8/ET/p/rSYI7CRZP4bF1yQfroP0I82Rk9XITdschK2RLEj9bs3Hi9lvaiwZ8UYmACfcbvqt 7pPS5TvqHvjpMDPkQW76uRGEsXSiK/DWP5xeGrFJMjvF1F9+TpyORhn4A== X-Google-Smtp-Source: AGHT+IHuxfKktEOhdP2DbkvOOWn4bYe36TVICO/Y+sH28rjw0ZW2IimGhbngnzJ+0elPz1osV4s1mg== X-Received: by 2002:a05:6808:3c90:b0:3e7:b9be:5267 with SMTP id 5614622812f47-3eb19c1fff6mr2703917b6e.6.1733488095379; Fri, 06 Dec 2024 04:28:15 -0800 (PST) Received: from kotori-desktop.lan ([58.38.120.33]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd15710123sm2579866a12.49.2024.12.06.04.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 04:28:15 -0800 (PST) From: Tomita Moeko To: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= Cc: qemu-devel@nongnu.org, =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v4 08/10] vfio/igd: emulate GGC register in mmio bar0 Date: Fri, 6 Dec 2024 20:27:46 +0800 Message-ID: <20241206122749.9893-9-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206122749.9893-1-tomitamoeko@gmail.com> References: <20241206122749.9893-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::243; envelope-from=tomitamoeko@gmail.com; helo=mail-oi1-x243.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 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 GGC register at 0x50 of pci config space is a mirror of the same register at 0x108040 of mmio bar0 [1]. i915 driver also reads that register from mmio bar0 instead of config space. As GGC is programmed and emulated by qemu, the mmio address should also be emulated, in the same way of BDSM register. [1] 4.1.28, 12th Generation Intel Core Processors Datasheet Volume 2 https://www.intel.com/content/www/us/en/content-details/655259 Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 18d159aa8e..12e0553e83 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -488,8 +488,10 @@ static const MemoryRegionOps vfio_igd_quirk_mirror_##name = { \ .endianness = DEVICE_LITTLE_ENDIAN, \ }; +VFIO_IGD_QUIRK_MIRROR_REG(IGD_GMCH, ggc) VFIO_IGD_QUIRK_MIRROR_REG(IGD_BDSM_GEN11, bdsm) +#define IGD_GGC_MMIO_OFFSET 0x108040 #define IGD_BDSM_MMIO_OFFSET 0x1080C0 void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) @@ -518,14 +520,21 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) return; } - quirk = vfio_quirk_alloc(1); + quirk = vfio_quirk_alloc(2); quirk->data = vdev; memory_region_init_io(&quirk->mem[0], OBJECT(vdev), + &vfio_igd_quirk_mirror_ggc, vdev, + "vfio-igd-ggc-quirk", 2); + memory_region_add_subregion_overlap(vdev->bars[0].region.mem, + IGD_GGC_MMIO_OFFSET, &quirk->mem[0], + 1); + + memory_region_init_io(&quirk->mem[1], OBJECT(vdev), &vfio_igd_quirk_mirror_bdsm, vdev, "vfio-igd-bdsm-quirk", 8); memory_region_add_subregion_overlap(vdev->bars[0].region.mem, - IGD_BDSM_MMIO_OFFSET, &quirk->mem[0], + IGD_BDSM_MMIO_OFFSET, &quirk->mem[1], 1); QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); From patchwork Fri Dec 6 12:27:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13897165 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 AD84AE7717E for ; Fri, 6 Dec 2024 12:34:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJXSM-0007Jf-3F; Fri, 06 Dec 2024 07:29:14 -0500 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 1tJXRW-00062i-Bw for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:23 -0500 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJXRT-000477-Oe for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:21 -0500 Received: by mail-pf1-x442.google.com with SMTP id d2e1a72fcca58-7252b7326f4so1694189b3a.2 for ; Fri, 06 Dec 2024 04:28:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733488098; x=1734092898; 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=pJksUVkEtwEudvlxsC5f5lHQl1QlNlGKcBR7V40Y6N8=; b=cF2v5Xyuc6dD8QzfIZOTUE/qBd7zTizmRF90WS6G6r5vmLWGnRNNRRdaPpFkjN2t65 5Ndi+y195fy08eO0Jgqqd6Me0WEPSZccPegAhWHbVF+5zw8QZLO/SQ9uTQjpDvYYLbHw jMufCXm+7TqL+A7xX/gsWbFdeOCMGsMxqVdO9RYJ6BbH3S2G9MbAh6w15C6a+HVrtZ4R iFo5lmDDAKyOZPefXHgKxiAYL41jFZ/t7lIEZSYl7Mnliw/oAQ31Aa8ULg/sUpFEDurD wsSuh54NdSJXaJZEj2QA4B3j0jFHPvXd3y/EHKrmXhGIevRhXmPzxh8uiykaH2yyX32h pzvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733488098; x=1734092898; 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=pJksUVkEtwEudvlxsC5f5lHQl1QlNlGKcBR7V40Y6N8=; b=PMTuncABVAOZzo8K7+icTCV47pR/zYuyFPPY3Cy9bleM9cCqbjQm2C/H+4c3qlYfHt bT8vso7koYnfDMH4N6UTKnF1Ag0qbfN30MC+1A65qMuhEsnkP73QO+OZ0gfmBzyDv8BR g4tY+p1PW3R1DmeGH1WhnDAB53YsIWcO4YdyHa6mNTQ7pUj4dvt5Ny4Cybrll22mdPlh LoY5cJmxnNb1U4aka977kdQViyhy4eCLjsDvfOb6rw6uEK+B1y79xwD9J/ZTTxT6ByY0 fT8cEO9S3QexbJO3k0r7wrOxPCp5L5qwOxDh4vAIAsNacpmO3n8SuxYrT92IPFanGw/o QpSA== X-Gm-Message-State: AOJu0YwMC3hMkpTZKG+wJn0POopXVELNdhye1IrRABtVD4u2CKAXkSl0 SFTJuloHFzMt+GLYVsNezVbptQzilD5522B74zHcO3KIOxOHxxQ= X-Gm-Gg: ASbGncuAcIDB/LWFHbkw7etrX/8NPWo5SkId2/SJhbNIXdiHCKfH3Dt773z2F0Y5BRY TcA3RTkxU9VpsHoqssj51rUjck74zWgoQXPgMqWazDp3bUjNftY1dUlQl9XIc7SihF6IbApPPAI rOS1SqMF3AxysfzF2QIknNJvp9mfDEpVMgWyh6Hj8GMBMDsWY4ZuX0v8l/L5G2L0j/W91aravop qDSr++aWycRfalYwRTzg2eN1UWu+mQE2HSIEaAhxo1P7+MNB0CimK3SwA== X-Google-Smtp-Source: AGHT+IFR5YiU72D3L7D+7WF+NcaK+QXd/DKpK5EVePqLoxZlsQ1jzzgi7Y6gXOyfUn4YuZJYddc/LA== X-Received: by 2002:a05:6a00:b46:b0:71e:1722:d019 with SMTP id d2e1a72fcca58-725b81f81a2mr4462054b3a.22.1733488098280; Fri, 06 Dec 2024 04:28:18 -0800 (PST) Received: from kotori-desktop.lan ([58.38.120.33]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd15710123sm2579866a12.49.2024.12.06.04.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 04:28:17 -0800 (PST) From: Tomita Moeko To: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= Cc: qemu-devel@nongnu.org, =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v4 09/10] vfio/igd: emulate BDSM in mmio bar0 for gen 6-10 devices Date: Fri, 6 Dec 2024 20:27:47 +0800 Message-ID: <20241206122749.9893-10-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206122749.9893-1-tomitamoeko@gmail.com> References: <20241206122749.9893-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::442; envelope-from=tomitamoeko@gmail.com; helo=mail-pf1-x442.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 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 A recent commit in i915 driver [1] claims the BDSM register at 0x1080c0 of mmio bar0 has been there since gen 6. Mirror this register to the 32 bit BDSM register at 0x5c in pci config space for gen6-10 devices. [1] https://patchwork.freedesktop.org/patch/msgid/20240202224340.30647-7-ville.syrjala@linux.intel.com Reviewed-by: Corvin Köhne Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 12e0553e83..73c06bbf64 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -489,7 +489,8 @@ static const MemoryRegionOps vfio_igd_quirk_mirror_##name = { \ }; VFIO_IGD_QUIRK_MIRROR_REG(IGD_GMCH, ggc) -VFIO_IGD_QUIRK_MIRROR_REG(IGD_BDSM_GEN11, bdsm) +VFIO_IGD_QUIRK_MIRROR_REG(IGD_BDSM, bdsm) +VFIO_IGD_QUIRK_MIRROR_REG(IGD_BDSM_GEN11, bdsm64) #define IGD_GGC_MMIO_OFFSET 0x108040 #define IGD_BDSM_MMIO_OFFSET 0x1080C0 @@ -516,7 +517,7 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) * into MMIO space and read from MMIO space by the Windows driver. */ gen = igd_gen(vdev); - if (gen < 11) { + if (gen < 6) { return; } @@ -530,12 +531,21 @@ void vfio_probe_igd_bar0_quirk(VFIOPCIDevice *vdev, int nr) IGD_GGC_MMIO_OFFSET, &quirk->mem[0], 1); - memory_region_init_io(&quirk->mem[1], OBJECT(vdev), - &vfio_igd_quirk_mirror_bdsm, vdev, - "vfio-igd-bdsm-quirk", 8); - memory_region_add_subregion_overlap(vdev->bars[0].region.mem, - IGD_BDSM_MMIO_OFFSET, &quirk->mem[1], - 1); + if (gen < 11) { + memory_region_init_io(&quirk->mem[1], OBJECT(vdev), + &vfio_igd_quirk_mirror_bdsm, vdev, + "vfio-igd-bdsm-quirk", 4); + memory_region_add_subregion_overlap(vdev->bars[0].region.mem, + IGD_BDSM_MMIO_OFFSET, + &quirk->mem[1], 1); + } else { + memory_region_init_io(&quirk->mem[1], OBJECT(vdev), + &vfio_igd_quirk_mirror_bdsm64, vdev, + "vfio-igd-bdsm-quirk", 8); + memory_region_add_subregion_overlap(vdev->bars[0].region.mem, + IGD_BDSM_MMIO_OFFSET, + &quirk->mem[1], 1); + } QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); } From patchwork Fri Dec 6 12:27:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomita Moeko X-Patchwork-Id: 13897141 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 DC346E7717B for ; Fri, 6 Dec 2024 12:31:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJXSS-0007oR-87; Fri, 06 Dec 2024 07:29:20 -0500 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 1tJXRX-00062n-MJ for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:25 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJXRW-00047J-54 for qemu-devel@nongnu.org; Fri, 06 Dec 2024 07:28:23 -0500 Received: by mail-pg1-x544.google.com with SMTP id 41be03b00d2f7-7f43259d220so1366380a12.3 for ; Fri, 06 Dec 2024 04:28:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733488100; x=1734092900; 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=DMVtNuBqtIXXm2C24hwxrJtPRQT47P73SaeeHd2lWK4=; b=NQctH7kvEmWVFI7CeCVq1+j/WvAumC9T7WQerc2CEU2SCFZuEFSOfSp/67kc84nHsu k9Y9CzY7t56QSTbbmeowAnutOZv225IA2HmF5Ly+ELEQbx+HJdAXtq6FYS1oeZsdsI1+ 4/Vfp1DY2/stPIcMtD5+4V1AnzuYXfXI+UfP/NCcvT3IBZQ9dGsshkVzeGfuXu+ft3+y qrPBpyK10x2TMHT0RwG+5MuXEvZjIQZzzx40TNNl+/DiFf6WvSh8GpRVrE4koC/CKOGf nhCgHzLjwNhYXOUcwMf/6wdR0YC//f7tqQitlkXIFVKcgFJcBWBVO3QtQiAIWULMTWiq 63IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733488100; x=1734092900; 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=DMVtNuBqtIXXm2C24hwxrJtPRQT47P73SaeeHd2lWK4=; b=IfB/PVVzYbTz8GRld+W92YqhjGgWsTGnItCV4j/k0DUVBCvdnNXphMQnImJUbmjJRn pb0m1DM/4T/Aqa9PZHkBtPuRmaIMXBylDblggXdcyNkrbCqBeXJH5IKiOOzXMu/Cw0zV tfHlKQrKkoebcdqBfyPWNRJeguVhEmNT5McbIH/UCA9UuD5TxSDfZgMrnjf3UX+HnXX5 65YXAh2Txb3PSutqgd0fihMHyZehrpx2KeJBDnJheRyqFpe+rKuPap90yrOKt2X0PXhn OPwQkpqNYu2inK7EBERtYTN6KynnHILGxtsYud0/WiMT+S36eF5AWTMIGNqKAcZQNIzd SYug== X-Gm-Message-State: AOJu0YzGDJOMXMKGRn7LjPKWS+B5x6WEdMk8mB+El2PtaIh/JAcV0rBP ummvX6cPd8L7lM1k2BX0Ra98ViRRij0phhi4/6gw+VbPgzdiREM= X-Gm-Gg: ASbGncusGFVxO75zCRKuve0QUF8O6SCVjLqFaAf0EhGylnFJkbAjfXhT6IjT2Xxgy+Y X7BCzCR/wNuj4NfYe5bcvHHQIxKD6wvp5cZwgF+HEdew5cFI9pgIaqP8K0mShmIISPUTLZuUi7q E+L5nKXSZC6V4OQ3xfTEdaxoZuXv83F1FqEVr2A0BhZGoHhaa8X9JGtc6UCvRqr4+C12j9QpZ4O i6WCM96rSgPOjfzcdjjle+/wxop1eiJSwEHPPCF4W0/voMPhOCOgHdKtQ== X-Google-Smtp-Source: AGHT+IFdzu6UBx6uy8wj9XCQFmYeHr/v0kMEdPLe1RtkivWLvxnhflrseuRRC/x5+4679b0O8esaog== X-Received: by 2002:a05:6a20:4324:b0:1e0:dbc6:8647 with SMTP id adf61e73a8af0-1e1870ad665mr3957896637.1.1733488100421; Fri, 06 Dec 2024 04:28:20 -0800 (PST) Received: from kotori-desktop.lan ([58.38.120.33]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7fd15710123sm2579866a12.49.2024.12.06.04.28.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2024 04:28:20 -0800 (PST) From: Tomita Moeko To: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= Cc: qemu-devel@nongnu.org, =?utf-8?q?Corvin_K=C3=B6hne?= , Tomita Moeko Subject: [PATCH v4 10/10] vfio/igd: add x-igd-gms option back to set DSM region size for guest Date: Fri, 6 Dec 2024 20:27:48 +0800 Message-ID: <20241206122749.9893-11-tomitamoeko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206122749.9893-1-tomitamoeko@gmail.com> References: <20241206122749.9893-1-tomitamoeko@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=tomitamoeko@gmail.com; helo=mail-pg1-x544.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 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 DSM region is likely to store framebuffer in Windows, a small DSM region may cause display issues (e.g. half of the screen is black). Since 971ca22f041b ("vfio/igd: don't set stolen memory size to zero"), the x-igd-gms option was functionally removed, QEMU uses host's original value, which is determined by DVMT Pre-Allocated option in Intel FSP of host bios. However, some vendors do not expose this config item to users. In such cases, x-igd-gms option can be used to manually set the data stolen memory size for guest. So this commit brings this option back, keeping its old behavior. When it is not specified, QEMU uses host's value. When DVMT Pre-Allocated option is available in host BIOS, user should set DSM region size there instead of using x-igd-gms option. Signed-off-by: Tomita Moeko --- hw/vfio/igd.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index 73c06bbf64..b0fef90240 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -14,6 +14,7 @@ #include "qemu/units.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "qapi/qmp/qerror.h" #include "hw/hw.h" #include "hw/nvram/fw_cfg.h" #include "pci.h" @@ -722,6 +723,31 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int nr) QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next); + /* + * Allow user to override dsm size using x-igd-gms option, in multiples of + * 32MiB. This option should only be used when the desired size cannot be + * set from DVMT Pre-Allocated option in host BIOS. + */ + if (vdev->igd_gms) { + if (gen < 8) { + if (vdev->igd_gms <= 0x10) { + gmch &= ~(IGD_GMCH_GEN6_GMS_MASK << IGD_GMCH_GEN6_GMS_SHIFT); + gmch |= vdev->igd_gms << IGD_GMCH_GEN6_GMS_SHIFT; + } else { + error_report(QERR_INVALID_PARAMETER_VALUE, + "x-igd-gms", "0~0x10"); + } + } else { + if (vdev->igd_gms <= 0x40) { + gmch &= ~(IGD_GMCH_GEN8_GMS_MASK << IGD_GMCH_GEN8_GMS_SHIFT); + gmch |= vdev->igd_gms << IGD_GMCH_GEN8_GMS_SHIFT; + } else { + error_report(QERR_INVALID_PARAMETER_VALUE, + "x-igd-gms", "0~0x40"); + } + } + } + ggms_size = igd_gtt_memory_size(gen, gmch); gms_size = igd_stolen_memory_size(gen, gmch);