From nobody Fri May 12 07:47:46 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QHgpp6Sf4z4BgGg; Fri, 12 May 2023 07:47:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QHgpp5Ysjz4PQS; Fri, 12 May 2023 07:47:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683877666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6R/8dr5x316NdcJ/qanNw0hax6rqRsVSJP0DntWnH5E=; b=lp275JJ42/FRCdvbY9hM1thjhzZu7prFoCmxIVBzFuba+C2b0n4xjYkt7xGy716ZkdSqf8 6sFIkixIiCrNA82P/mfT7Q6W6RgV3tW1C0v8HfumBSQ+ouy0bXjJy4Yzi+PFIRGsAitzUp 8QOAuCTsA+cvMxccv2sGezMsY5VuAEhtcAax0mgZPBLfNEdYEhmCxTW8rikfKJ5qx0vshE lp/abWwHUu+xsJftf7XLM25nq30tIP/wqiHSQ2bUt4k6pmps96arKrLtyM87bZMhl6viIH IgTC5bw9xNbseFUHmu/tgE3jc2d99IY0JjG3nxTm0ZUP5ufSwI8Wmw607Y9jfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683877666; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=6R/8dr5x316NdcJ/qanNw0hax6rqRsVSJP0DntWnH5E=; b=Dxg7RA/ucvPAjZ4Z7mVRxIJueiYIjMmCs9ThmXheT8eqLsRNGfBMn5VZMjXOlviLyyrukp 87Vnbdc7gaCAA1NllCkU0Vpb4cWGT5Ta7YTSmxLCKiYkVyeuik4aGCpJX+SmVZMHlYV805 BsB8G3HPm/IAY5HIF0ZMc9YVX/zKBhte03Ua9W7iT5rVjHxh1omUMceROan5A21ydI1I0j cFwFjOPuRKT03NqvT1bIbNJkfcwo9SFgRwNpOqCfejHVZcoo3yQK+jYhLuaRDpQh3Nxs6i YmdX2GwSaNqgc3BiHl7//25KjFtWiK/FPP5jM2lfJqe+jQGiKX9VBnsj63f4+A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683877666; a=rsa-sha256; cv=none; b=x3hSXse/LYVUZ6C/+ckwdweq3gXJZg30M2IQh5DmOxF9PF0ilr1lLHdzPjGUlcwElhkGin 9rzk+UL531MJHQise1QFAgCoouiqXC3bpewvVcH5ka0gvJjee+S7mZ78TAzhJKYr/CsHAs nGWHdlMttx+s1AQ9iIgC4vNIc8FuuHoaiV5heRuMzERI7LdbNfxlsVQDve3LueWPG5ZnCx cPFpuZaZtJREujzxAi1FLkI5gafuBn5/SuReW8Hn4npaJ0/gI5+Qr3HyaQAZFx5eoSlO2Z yBfcVbGWNRfx+8Gy0eguvLL4M0T3XArdcSVpFHKNNbey5c4QcwjMKWP5UJ0u/A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QHgpp4MrkzRk0; Fri, 12 May 2023 07:47:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34C7lk7p073300; Fri, 12 May 2023 07:47:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34C7lk3D073299; Fri, 12 May 2023 07:47:46 GMT (envelope-from git) Date: Fri, 12 May 2023 07:47:46 GMT Message-Id: <202305120747.34C7lk3D073299@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: 93cf93179c50 - main - bhyve: add helper for passthru specific mmio ranges List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: corvink X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 93cf93179c505cebbcdbeef196d523d36890ed4a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=93cf93179c505cebbcdbeef196d523d36890ed4a commit 93cf93179c505cebbcdbeef196d523d36890ed4a Author: Corvin Köhne AuthorDate: 2023-05-10 10:22:33 +0000 Commit: Corvin Köhne CommitDate: 2023-05-12 07:29:44 +0000 bhyve: add helper for passthru specific mmio ranges Intel GPUs have two special memory regions. They are called Graphics Stolen Memory and OpRegion. bhyve has to emulate both of them. In order to keep track of those special regions, add generic mmio ranges to the passthru emulation. Reviewed by: markj MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D40036 --- usr.sbin/bhyve/pci_passthru.c | 12 ++++++++++++ usr.sbin/bhyve/pci_passthru.h | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c index 054b284a2f27..0b7a0d362593 100644 --- a/usr.sbin/bhyve/pci_passthru.c +++ b/usr.sbin/bhyve/pci_passthru.c @@ -78,6 +78,8 @@ __FBSDID("$FreeBSD$"); #define MSIX_TABLE_COUNT(ctrl) (((ctrl) & PCIM_MSIXCTRL_TABLE_SIZE) + 1) #define MSIX_CAPLEN 12 +#define PASSTHRU_MMIO_MAX 2 + static int pcifd = -1; struct passthru_softc { @@ -94,6 +96,7 @@ struct passthru_softc { } psc_msix; struct pcisel psc_sel; + struct passthru_mmio_mapping psc_mmio_map[PASSTHRU_MMIO_MAX]; cfgread_handler psc_pcir_rhandler[PCI_REGMAX + 1]; cfgwrite_handler psc_pcir_whandler[PCI_REGMAX + 1]; }; @@ -660,6 +663,15 @@ done: return (error); } +struct passthru_mmio_mapping * +passthru_get_mmio(struct passthru_softc *sc, int num) +{ + assert(sc != NULL); + assert(num < PASSTHRU_MMIO_MAX); + + return (&sc->psc_mmio_map[num]); +} + struct pcisel * passthru_get_sel(struct passthru_softc *sc) { diff --git a/usr.sbin/bhyve/pci_passthru.h b/usr.sbin/bhyve/pci_passthru.h index 79578a8496c4..1ca10fa343e4 100644 --- a/usr.sbin/bhyve/pci_passthru.h +++ b/usr.sbin/bhyve/pci_passthru.h @@ -11,6 +11,14 @@ #include "pci_emul.h" +struct passthru_mmio_mapping { + vm_paddr_t gpa; /* guest physical address */ + void *gva; /* guest virtual address */ + vm_paddr_t hpa; /* host physical address */ + void *hva; /* guest virtual address */ + vm_paddr_t len; +}; + struct passthru_softc; typedef int (*cfgread_handler)(struct passthru_softc *sc, @@ -24,6 +32,8 @@ int passthru_cfgread_emulate(struct passthru_softc *sc, struct pci_devinst *pi, int coff, int bytes, uint32_t *rv); int passthru_cfgwrite_emulate(struct passthru_softc *sc, struct pci_devinst *pi, int coff, int bytes, uint32_t val); +struct passthru_mmio_mapping *passthru_get_mmio(struct passthru_softc *sc, + int num); struct pcisel *passthru_get_sel(struct passthru_softc *sc); int set_pcir_handler(struct passthru_softc *sc, int reg, int len, cfgread_handler rhandler, cfgwrite_handler whandler);