Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Aug 2023 07:41:50 GMT
From:      Corvin =?utf-8?Q?K=C3=B6hne?= <corvink@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 6d037b69ee62 - stable/13 - bhyve: emulate graphics stolen memory register
Message-ID:  <202308180741.37I7fo81066827@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by corvink:

URL: https://cgit.FreeBSD.org/src/commit/?id=6d037b69ee623ffee05864d6f01712c875409be0

commit 6d037b69ee623ffee05864d6f01712c875409be0
Author:     Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2023-05-11 09:18:56 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2023-08-18 07:32:07 +0000

    bhyve: emulate graphics stolen memory register
    
    This register contains a host physical address. This address is
    meaningless for the guest. We have to emulate it and set it to a valid
    guest physical address.
    
    Reviewed by:            markj
    MFC after:              1 week
    Sponsored by:           Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D40060
    
    (cherry picked from commit d9fa7c113df254b237e5a573d0567eb686e5fcde)
---
 usr.sbin/bhyve/pci_gvt-d.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/usr.sbin/bhyve/pci_gvt-d.c b/usr.sbin/bhyve/pci_gvt-d.c
index 9c5b0906ec29..3109bc06be82 100644
--- a/usr.sbin/bhyve/pci_gvt-d.c
+++ b/usr.sbin/bhyve/pci_gvt-d.c
@@ -23,6 +23,8 @@
 
 #define PCI_VENDOR_INTEL 0x8086
 
+#define PCIR_BDSM 0x5C /* Base of Data Stolen Memory register */
+
 #define PCIM_BDSM_GSM_ALIGNMENT \
 	0x00100000 /* Graphics Stolen Memory is 1 MB aligned */
 
@@ -96,6 +98,7 @@ gvt_d_setup_gsm(struct pci_devinst *const pi)
 	struct passthru_softc *sc;
 	struct passthru_mmio_mapping *gsm;
 	size_t sysctl_len;
+	uint32_t bdsm;
 	int error;
 
 	sc = pi->pi_arg;
@@ -156,7 +159,12 @@ gvt_d_setup_gsm(struct pci_devinst *const pi)
 		    "Warning: Unable to reuse host address of Graphics Stolen Memory. GPU passthrough might not work properly.");
 	}
 
-	return (0);
+	bdsm = read_config(passthru_get_sel(sc), PCIR_BDSM, 4);
+	pci_set_cfgdata32(pi, PCIR_BDSM,
+	    gsm->gpa | (bdsm & (PCIM_BDSM_GSM_ALIGNMENT - 1)));
+
+	return (set_pcir_handler(sc, PCIR_BDSM, 4, passthru_cfgread_emulate,
+	    passthru_cfgwrite_emulate));
 }
 
 static int



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202308180741.37I7fo81066827>