From owner-svn-src-head@freebsd.org Fri Mar 29 16:30:20 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80664156E05D; Fri, 29 Mar 2019 16:30:20 +0000 (UTC) (envelope-from bde@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 210B76D018; Fri, 29 Mar 2019 16:30:20 +0000 (UTC) (envelope-from bde@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 EBB741554; Fri, 29 Mar 2019 16:30:19 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x2TGUJaB013567; Fri, 29 Mar 2019 16:30:19 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x2TGUJuI013566; Fri, 29 Mar 2019 16:30:19 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201903291630.x2TGUJuI013566@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Fri, 29 Mar 2019 16:30:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r345698 - head/lib/libvgl X-SVN-Group: head X-SVN-Commit-Author: bde X-SVN-Commit-Paths: head/lib/libvgl X-SVN-Commit-Revision: 345698 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 210B76D018 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.96)[-0.959,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Mar 2019 16:30:20 -0000 Author: bde Date: Fri Mar 29 16:30:19 2019 New Revision: 345698 URL: https://svnweb.freebsd.org/changeset/base/345698 Log: Fix restoring to graphics modes in VGLEnd(). Correct restoring was only attempted for mode 258 (800x600x4 P). (This was the only useful graphics mode supported in the kernel until 10-15 years ago, and is still the only one explicitly documented in the man page). The comment says that it is the geometry (subscreen size) that is restored, but it seems to only be necessary to restore the font size, with the geometry only needed since it is set by the same ioctl. The font size was not restored for this mode, but was forced to 16. For other graphics modes, the font size was clobbered to 0. This confuses but doesn't crash the kernel (font size 0 gives null text). This confuses and crashes vidcontrol. The only way to recover was to use vidcontrol to set the mode to any text mode on the way back to the original graphics mode. vidcontrol gets this wrong in the opposite way when backing out of changes after an error. It restores the font size correctly, but forces the geometry to the full screen size. Modified: head/lib/libvgl/main.c Modified: head/lib/libvgl/main.c ============================================================================== --- head/lib/libvgl/main.c Fri Mar 29 16:05:30 2019 (r345697) +++ head/lib/libvgl/main.c Fri Mar 29 16:30:19 2019 (r345698) @@ -61,12 +61,14 @@ static int VGLAbortPending; static int VGLOnDisplay; static unsigned int VGLCurWindow; static int VGLInitDone = 0; +static video_info_t VGLOldModeInfo; static vid_info_t VGLOldVInfo; void VGLEnd() { struct vt_mode smode; + int size[3]; if (!VGLInitDone) return; @@ -81,18 +83,15 @@ struct vt_mode smode; munmap(VGLMem, VGLAdpInfo.va_window_size); } - if (VGLOldMode >= M_VESA_BASE) { - /* ugly, but necessary */ + if (VGLOldMode >= M_VESA_BASE) ioctl(0, _IO('V', VGLOldMode - M_VESA_BASE), 0); - if (VGLOldMode == M_VESA_800x600) { - int size[3]; - size[0] = VGLOldVInfo.mv_csz; - size[1] = VGLOldVInfo.mv_rsz; - size[2] = 16; - ioctl(0, KDRASTER, size); - } - } else { + else ioctl(0, _IO('S', VGLOldMode), 0); + if (VGLOldModeInfo.vi_flags & V_INFO_GRAPHICS) { + size[0] = VGLOldVInfo.mv_csz; + size[1] = VGLOldVInfo.mv_rsz; + size[2] = VGLOldVInfo.font_size;; + ioctl(0, KDRASTER, size); } ioctl(0, KDDISABIO, 0); ioctl(0, KDSETMODE, KD_TEXT); @@ -165,12 +164,13 @@ VGLInit(int mode) if (ioctl(0, CONS_MODEINFO, &VGLModeInfo)) /* FBIO_MODEINFO */ return -1; - /* If current mode is VESA_800x600 then save its geometry to restore later */ - if ((VGLOldMode >= M_VESA_BASE) && (VGLOldMode == M_VESA_800x600)) { - VGLOldVInfo.size = sizeof(VGLOldVInfo); - if (ioctl(0, CONS_GETINFO, &VGLOldVInfo)) - return -1; - } + /* Save info for old mode to restore font size if old mode is graphics. */ + VGLOldModeInfo.vi_mode = VGLOldMode; + if (ioctl(0, CONS_MODEINFO, &VGLOldModeInfo)) + return -1; + VGLOldVInfo.size = sizeof(VGLOldVInfo); + if (ioctl(0, CONS_GETINFO, &VGLOldVInfo)) + return -1; VGLDisplay = (VGLBitmap *)malloc(sizeof(VGLBitmap)); if (VGLDisplay == NULL)