From nobody Fri Apr 4 03:43:05 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1741716880; cv=none; d=zohomail.com; s=zohoarc; b=BeK+bN4dhBsg9WGi5pm42AgIQcHx97acH2DSa+nDmdlXSSrSn4D4cbR05g8WE17vqvMhemRVmQNeGQLXyhE2SbXmn7gOMEYpnoT41nBTEm5YF1ou6ko2wTjSuYVJnqMX/XvCDRLGFjwRiuhNd+7qhcKJm6BQNQVguSu6D9wiv4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741716880; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=uDRX9dJnA++kbf/4kTExorK6AdwGd4kW4HXvCyMqRTs=; b=XFW9wdmbDRFaANVI+ObJl2/WCxulC4ACfmmiQ7IJQZQgVBIRzeAPDRt3e7uv81pFwx7DsHjVeFO62jWGI+4pEt0qMlsEBXTWIsF3qhL+tf7gqOH6UmB+DnB7TYnV026W/tVtX6J1ftFZ66evLTmng7nf5bx64KTijvnhm39y05U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1741716880312247.13850591211235; Tue, 11 Mar 2025 11:14:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ts472-0006j2-K6; Tue, 11 Mar 2025 14:13:56 -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 1ts470-0006hE-Oh for qemu-devel@nongnu.org; Tue, 11 Mar 2025 14:13:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ts46t-0006eY-GK for qemu-devel@nongnu.org; Tue, 11 Mar 2025 14:13:53 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-83-wRS2OE6cOZGVIhbQqL4VHA-1; Tue, 11 Mar 2025 14:13:41 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8D24818004A9; Tue, 11 Mar 2025 18:13:39 +0000 (UTC) Received: from corto.redhat.com (unknown [10.44.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F124F1828A93; Tue, 11 Mar 2025 18:13:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741716826; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uDRX9dJnA++kbf/4kTExorK6AdwGd4kW4HXvCyMqRTs=; b=hoSaxr3p7VO2iJ8R1WBGmPfIJBaVUmJjPW6yREGuGJ1HgNE44dVyEgX+XM4gLxc46sCZVw /2h41ceIVoi7H3bmVzn/1hDt4VioG3U7q10HbIV90Yg5LqEXmpQhpSfFPNOQ4Yf137oHQY CraWXUO5zEqH31J9GGCNHpnikTjAzGg= X-MC-Unique: wRS2OE6cOZGVIhbQqL4VHA-1 X-Mimecast-MFC-AGG-ID: wRS2OE6cOZGVIhbQqL4VHA_1741716820 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: qemu-devel@nongnu.org Cc: Alex Williamson , Tomita Moeko , =?UTF-8?q?Corvin=20K=C3=B6hne?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PULL 02/21] vfio/igd: Do not include GTT stolen size in etc/igd-bdsm-size Date: Tue, 11 Mar 2025 19:13:09 +0100 Message-ID: <20250311181328.1200431-3-clg@redhat.com> In-Reply-To: <20250311181328.1200431-1-clg@redhat.com> References: <20250311181328.1200431-1-clg@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1741716882619019000 From: Tomita Moeko Though GTT Stolen Memory (GSM) is right below Data Stolen Memory (DSM) in host address space, direct access to GSM is prohibited, and it is not mapped to guest address space. Both host and guest accesses GSM indirectly through the second half of MMIO BAR0 (GTTMMADR). Guest firmware only need to reserve a memory region for DSM and program the BDSM register with the base address of that region, that's actually what both SeaBIOS[1] and IgdAssignmentDxe does now. [1] https://gitlab.com/qemu-project/seabios/-/blob/1.12-stable/src/fw/pciin= it.c#L319-332 Signed-off-by: Tomita Moeko Reviewed-by: Alex Williamson Tested-by: Alex Williamson Reviewed-by: Corvin K=C3=B6hne Link: https://lore.kernel.org/qemu-devel/20250306180131.32970-3-tomitamoeko= @gmail.com Signed-off-by: C=C3=A9dric Le Goater --- hw/vfio/igd.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/hw/vfio/igd.c b/hw/vfio/igd.c index ca3a32f4f2b8a01d5c82225a0354c2e9ce1bb3b2..dda4c7bb5df8bd056c3e06eae38= 533da7586c6c9 100644 --- a/hw/vfio/igd.c +++ b/hw/vfio/igd.c @@ -112,28 +112,8 @@ static int igd_gen(VFIOPCIDevice *vdev) =20 #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 =3D (gmch >> IGD_GMCH_GEN6_GGMS_SHIFT) & IGD_GMCH_GEN6_GGMS_M= ASK; - } else { - ggms =3D (gmch >> IGD_GMCH_GEN8_GGMS_SHIFT) & IGD_GMCH_GEN8_GGMS_M= ASK; - if (ggms !=3D 0) { - ggms =3D 1ULL << ggms; - } - } - - return ggms * MiB; -} =20 static uint64_t igd_stolen_memory_size(int gen, uint32_t gmch) { @@ -367,7 +347,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) g_autofree struct vfio_region_info *lpc =3D NULL; PCIDevice *lpc_bridge; int ret, gen; - uint64_t ggms_size, gms_size; + uint64_t gms_size; uint64_t *bdsm_size; uint32_t gmch; Error *err =3D NULL; @@ -527,7 +507,6 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) } } =20 - ggms_size =3D igd_gtt_memory_size(gen, gmch); gms_size =3D igd_stolen_memory_size(gen, gmch); =20 /* @@ -539,7 +518,7 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) * config offset 0x5C. */ bdsm_size =3D g_malloc(sizeof(*bdsm_size)); - *bdsm_size =3D cpu_to_le64(ggms_size + gms_size); + *bdsm_size =3D cpu_to_le64(gms_size); fw_cfg_add_file(fw_cfg_find(), "etc/igd-bdsm-size", bdsm_size, sizeof(*bdsm_size)); =20 @@ -559,6 +538,5 @@ void vfio_probe_igd_bar4_quirk(VFIOPCIDevice *vdev, int= nr) pci_set_quad(vdev->emulated_config_bits + IGD_BDSM_GEN11, ~0); } =20 - trace_vfio_pci_igd_bdsm_enabled(vdev->vbasedev.name, - (ggms_size + gms_size) / MiB); + trace_vfio_pci_igd_bdsm_enabled(vdev->vbasedev.name, (gms_size / MiB)); } --=20 2.48.1