git: 5e09c5a1ed66 - main - bhyve: use correct size to map the OpRegion

From: Corvin Köhne <corvink_at_FreeBSD.org>
Date: Tue, 04 Jun 2024 07:11:13 UTC
The branch main has been updated by corvink:

URL: https://cgit.FreeBSD.org/src/commit/?id=5e09c5a1ed66f58c499884ebf44e1633be195578

commit 5e09c5a1ed66f58c499884ebf44e1633be195578
Author:     Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2023-12-18 12:44:04 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2024-06-04 07:08:34 +0000

    bhyve: use correct size to map the OpRegion
    
    We're already converting the size reported by the OpRegion header from
    kilobytes to bytes. We don't have to do that twice when mapping the OpRegion.
    
    Reviewed by:            markj
    MFC after:              1 week
    Sponsored by:           Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D45334
---
 usr.sbin/bhyve/amd64/pci_gvt-d.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/bhyve/amd64/pci_gvt-d.c b/usr.sbin/bhyve/amd64/pci_gvt-d.c
index dfcd6a8f68c8..95f9066498d6 100644
--- a/usr.sbin/bhyve/amd64/pci_gvt-d.c
+++ b/usr.sbin/bhyve/amd64/pci_gvt-d.c
@@ -222,8 +222,8 @@ gvt_d_setup_opregion(struct pci_devinst *const pi)
 	opregion->len = header->size * KB;
 	munmap(header, sizeof(*header));
 
-	opregion->hva = mmap(NULL, opregion->len * KB, PROT_READ, MAP_SHARED,
-	    memfd, opregion->hpa);
+	opregion->hva = mmap(NULL, opregion->len, PROT_READ, MAP_SHARED, memfd,
+	    opregion->hpa);
 	if (opregion->hva == MAP_FAILED) {
 		warn("%s: Unable to map host OpRegion", __func__);
 		close(memfd);