From owner-dev-commits-src-main@freebsd.org Fri May 7 02:54:05 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DC38B6353DA; Fri, 7 May 2021 02:54:05 +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 4Fbw595xwpz3M2x; Fri, 7 May 2021 02:54:05 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B3C9C237F9; Fri, 7 May 2021 02:54:05 +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 1472s5Ek024764; Fri, 7 May 2021 02:54:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1472s5PU024763; Fri, 7 May 2021 02:54:05 GMT (envelope-from git) Date: Fri, 7 May 2021 02:54:05 GMT Message-Id: <202105070254.1472s5PU024763@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alfredo Dal'Ava Junior" Subject: git: fb53b42e36a9 - main - virtio-modern: fix PCI common read/write functions on big endian targets MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: alfredo X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fb53b42e36a9745d0a33821175a962c7a15eeeaa Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 May 2021 02:54:05 -0000 The branch main has been updated by alfredo: URL: https://cgit.FreeBSD.org/src/commit/?id=fb53b42e36a9745d0a33821175a962c7a15eeeaa commit fb53b42e36a9745d0a33821175a962c7a15eeeaa Author: Alfredo Dal'Ava Junior AuthorDate: 2021-05-07 05:40:35 +0000 Commit: Alfredo Dal'Ava Junior CommitDate: 2021-05-07 05:40:35 +0000 virtio-modern: fix PCI common read/write functions on big endian targets Virtio modern has the common data organized in little endian, but on powerpc64 BE it was reading and writing in the wrong endian. Submitted by: Leonardo Bianconi Reviewed by: bryanv, alfredo Sponsored by: Eldorado Research Institute (eldorado.org.br) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D28947 --- sys/dev/virtio/pci/virtio_pci_modern.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/dev/virtio/pci/virtio_pci_modern.c b/sys/dev/virtio/pci/virtio_pci_modern.c index 7029d2ff76ce..33fdebf19402 100644 --- a/sys/dev/virtio/pci/virtio_pci_modern.c +++ b/sys/dev/virtio/pci/virtio_pci_modern.c @@ -1315,13 +1315,15 @@ vtpci_modern_read_common_1(struct vtpci_modern_softc *sc, bus_size_t off) static uint16_t vtpci_modern_read_common_2(struct vtpci_modern_softc *sc, bus_size_t off) { - return (bus_read_2(&sc->vtpci_common_res_map.vtrm_map, off)); + return virtio_htog16(true, + bus_read_2(&sc->vtpci_common_res_map.vtrm_map, off)); } static uint32_t vtpci_modern_read_common_4(struct vtpci_modern_softc *sc, bus_size_t off) { - return (bus_read_4(&sc->vtpci_common_res_map.vtrm_map, off)); + return virtio_htog32(true, + bus_read_4(&sc->vtpci_common_res_map.vtrm_map, off)); } static void @@ -1335,14 +1337,16 @@ static void vtpci_modern_write_common_2(struct vtpci_modern_softc *sc, bus_size_t off, uint16_t val) { - bus_write_2(&sc->vtpci_common_res_map.vtrm_map, off, val); + bus_write_2(&sc->vtpci_common_res_map.vtrm_map, + off, virtio_gtoh16(true, val)); } static void vtpci_modern_write_common_4(struct vtpci_modern_softc *sc, bus_size_t off, uint32_t val) { - bus_write_4(&sc->vtpci_common_res_map.vtrm_map, off, val); + bus_write_4(&sc->vtpci_common_res_map.vtrm_map, + off, virtio_gtoh32(true, val)); } static void