From owner-dev-commits-src-all@freebsd.org Mon Mar 8 18:36:40 2021 Return-Path: Delivered-To: dev-commits-src-all@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 AD859552A9F; Mon, 8 Mar 2021 18:36:40 +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 4DvRrS4TkPz3HZp; Mon, 8 Mar 2021 18:36:40 +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 887275AE5; Mon, 8 Mar 2021 18:36:40 +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 128IaeJq022846; Mon, 8 Mar 2021 18:36:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 128IaeQO022845; Mon, 8 Mar 2021 18:36:40 GMT (envelope-from git) Date: Mon, 8 Mar 2021 18:36:40 GMT Message-Id: <202103081836.128IaeQO022845@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Brandon Bergren Subject: git: 102e7117bcf3 - stable/13 - [PowerPC64LE] pseries: Fix input buffering logic. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bdragon X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 102e7117bcf32f9bee513f948815213575cfebd4 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Mar 2021 18:36:40 -0000 The branch stable/13 has been updated by bdragon: URL: https://cgit.FreeBSD.org/src/commit/?id=102e7117bcf32f9bee513f948815213575cfebd4 commit 102e7117bcf32f9bee513f948815213575cfebd4 Author: Brandon Bergren AuthorDate: 2021-02-25 18:55:58 +0000 Commit: Brandon Bergren CommitDate: 2021-03-08 18:35:56 +0000 [PowerPC64LE] pseries: Fix input buffering logic. In uart_phyp_get(), when the internal buffer is empty, we make a hypercall to retrieve up to 16 bytes of input data from the hypervisor. As this is specified to be returned in BE format, we need to do a 64-bit byte swap on the first and second half of the data. If the buffer being passed in was insufficient to return the fetched data, we store the remainder in the internal buffer and use it to satisfy the following calls to uart_phyp_get() until it is drained. However, in this case, we were accidentally byteswapping the internal buffer again. Move the byteswapping code to just after the hypercall so it only gets swapped when we're filling the buffer. Fixes arrow keys in qemu on pseries, among other console oddities. Sponsored by: Tag1 Consulting, Inc. (cherry picked from commit 5001c579baff78719919d79ec054207aa2938dbd) --- sys/powerpc/pseries/phyp_console.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sys/powerpc/pseries/phyp_console.c b/sys/powerpc/pseries/phyp_console.c index 84ab292dae94..484952177d51 100644 --- a/sys/powerpc/pseries/phyp_console.c +++ b/sys/powerpc/pseries/phyp_console.c @@ -295,6 +295,10 @@ uart_phyp_get(struct uart_phyp_softc *sc, void *buffer, size_t bufsize) err = phyp_pft_hcall(H_GET_TERM_CHAR, sc->vtermid, 0, 0, 0, &sc->inbuflen, &sc->phyp_inbuf.u64[0], &sc->phyp_inbuf.u64[1]); +#if BYTE_ORDER == LITTLE_ENDIAN + sc->phyp_inbuf.u64[0] = be64toh(sc->phyp_inbuf.u64[0]); + sc->phyp_inbuf.u64[1] = be64toh(sc->phyp_inbuf.u64[1]); +#endif if (err != H_SUCCESS) { uart_unlock(&sc->sc_mtx); return (-1); @@ -307,11 +311,6 @@ uart_phyp_get(struct uart_phyp_softc *sc, void *buffer, size_t bufsize) return (0); } -#if BYTE_ORDER == LITTLE_ENDIAN - sc->phyp_inbuf.u64[0] = be64toh(sc->phyp_inbuf.u64[0]); - sc->phyp_inbuf.u64[1] = be64toh(sc->phyp_inbuf.u64[1]); -#endif - if ((sc->protocol == HVTERMPROT) && (hdr == 1)) { sc->inbuflen = sc->inbuflen - 4; /* The VTERM protocol has a 4 byte header, skip it here. */