From owner-svn-src-all@freebsd.org Fri Nov 29 11:34:12 2019 Return-Path: Delivered-To: svn-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 7F4D11ACF5B; Fri, 29 Nov 2019 11:34:12 +0000 (UTC) (envelope-from luporl@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47PXTc2p5Wz3Jv4; Fri, 29 Nov 2019 11:34:12 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 434B8D8DF; Fri, 29 Nov 2019 11:34:12 +0000 (UTC) (envelope-from luporl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xATBYCgP000164; Fri, 29 Nov 2019 11:34:12 GMT (envelope-from luporl@FreeBSD.org) Received: (from luporl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xATBYCH5000163; Fri, 29 Nov 2019 11:34:12 GMT (envelope-from luporl@FreeBSD.org) Message-Id: <201911291134.xATBYCH5000163@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: luporl set sender to luporl@FreeBSD.org using -f From: Leandro Lupori Date: Fri, 29 Nov 2019 11:34:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355209 - head/sys/powerpc/pseries X-SVN-Group: head X-SVN-Commit-Author: luporl X-SVN-Commit-Paths: head/sys/powerpc/pseries X-SVN-Commit-Revision: 355209 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Nov 2019 11:34:12 -0000 Author: luporl Date: Fri Nov 29 11:34:11 2019 New Revision: 355209 URL: https://svnweb.freebsd.org/changeset/base/355209 Log: [PPC] Remove extra \0 char inserted on vty by QEMU Since version 2.11.0, QEMU became bug-compatible with PowerVM's vty implementation, by inserting a \0 after every \r going to the guest. Guests are expected to workaround this issue by removing every \0 immediately following a \r. Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D22171 Modified: head/sys/powerpc/pseries/phyp_console.c Modified: head/sys/powerpc/pseries/phyp_console.c ============================================================================== --- head/sys/powerpc/pseries/phyp_console.c Fri Nov 29 06:25:07 2019 (r355208) +++ head/sys/powerpc/pseries/phyp_console.c Fri Nov 29 11:34:11 2019 (r355209) @@ -287,6 +287,7 @@ uart_phyp_get(struct uart_phyp_softc *sc, void *buffer { int err; int hdr = 0; + uint64_t i, j; uart_lock(&sc->sc_mtx); if (sc->inbuflen == 0) { @@ -297,7 +298,7 @@ uart_phyp_get(struct uart_phyp_softc *sc, void *buffer uart_unlock(&sc->sc_mtx); return (-1); } - hdr = 1; + hdr = 1; } if (sc->inbuflen == 0) { @@ -305,15 +306,35 @@ uart_phyp_get(struct uart_phyp_softc *sc, void *buffer return (0); } - if (bufsize > sc->inbuflen) - bufsize = sc->inbuflen; - if ((sc->protocol == HVTERMPROT) && (hdr == 1)) { sc->inbuflen = sc->inbuflen - 4; /* The VTERM protocol has a 4 byte header, skip it here. */ memmove(&sc->phyp_inbuf.str[0], &sc->phyp_inbuf.str[4], sc->inbuflen); } + + /* + * Since version 2.11.0, QEMU became bug-compatible with + * PowerVM's vty implementation, by inserting a \0 after + * every \r going to the guest. Guests are expected to + * workaround this issue by removing every \0 immediately + * following a \r. + */ + if (hdr == 1) { + for (i = 0, j = 0; i < sc->inbuflen; i++, j++) { + if (i > j) + sc->phyp_inbuf.str[j] = sc->phyp_inbuf.str[i]; + + if (sc->phyp_inbuf.str[i] == '\r' && + i < sc->inbuflen - 1 && + sc->phyp_inbuf.str[i + 1] == '\0') + i++; + } + sc->inbuflen -= i - j; + } + + if (bufsize > sc->inbuflen) + bufsize = sc->inbuflen; memcpy(buffer, sc->phyp_inbuf.str, bufsize); sc->inbuflen -= bufsize;