From owner-freebsd-current@freebsd.org Thu Mar 30 18:53:26 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CC96DD26AEB for ; Thu, 30 Mar 2017 18:53:26 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id B1F356E2 for ; Thu, 30 Mar 2017 18:53:26 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: by mailman.ysv.freebsd.org (Postfix) id B1351D26AEA; Thu, 30 Mar 2017 18:53:26 +0000 (UTC) Delivered-To: current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AF3BDD26AE9 for ; Thu, 30 Mar 2017 18:53:26 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail109.syd.optusnet.com.au (mail109.syd.optusnet.com.au [211.29.132.80]) by mx1.freebsd.org (Postfix) with ESMTP id 558816E1; Thu, 30 Mar 2017 18:53:25 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c122-106-153-191.carlnfd1.nsw.optusnet.com.au [122.106.153.191]) by mail109.syd.optusnet.com.au (Postfix) with ESMTPS id 8ABC2D607D1; Fri, 31 Mar 2017 05:53:23 +1100 (AEDT) Date: Fri, 31 Mar 2017 05:53:22 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Andrey Chernov cc: Bruce Evans , "Ngie Cooper (yaneurabeya)" , avg@freebsd.org, bde@freebsd.org, current@freebsd.org Subject: Re: New syscons bugs: shutdown -r doesn't execute rc.d sequence and others In-Reply-To: Message-ID: <20170331042950.F840@besplex.bde.org> References: <7d5bbbf0-6908-185c-2ee0-29e0a4f60591@freebsd.org> <5587c798-d36c-9074-1060-30e206db5571@freebsd.org> <69af07a7-ec8f-9b7f-8b93-9ba148f30fec@freebsd.org> <8C24D1BA-1607-4C19-BA38-39256E82C7AF@gmail.com> <51045bee-a626-efb3-4b1e-0c3d36abb1ab@freebsd.org> <20170329132927.U882@besplex.bde.org> <20170330150449.R1061@besplex.bde.org> <3534bbeb-9f73-4e37-8f89-c05dd9f89f8c@freebsd.org> <20170330183716.W1655@besplex.bde.org> <4085b441-74ee-796f-adc0-713dfc198b03@freebsd.org> <1772f54a-4268-577a-8e7f-abce929d39c8@freebsd.org> <20170331015718.X3330@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=AYLBJzfG c=1 sm=1 tr=0 a=Tj3pCpwHnMupdyZSltBt7Q==:117 a=Tj3pCpwHnMupdyZSltBt7Q==:17 a=kj9zAlcOel0A:10 a=bHFY8iiebgpokPJhGwoA:9 a=CjuIK1q_8ugA:10 X-Mailman-Approved-At: Thu, 30 Mar 2017 19:11:06 +0000 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Mar 2017 18:53:26 -0000 On Thu, 30 Mar 2017, Andrey Chernov wrote: > On 30.03.2017 18:13, Bruce Evans wrote: >> On Thu, 30 Mar 2017, Andrey Chernov wrote: >>> ... >>> Finally I have good news and bad news with today's -current: >>> >>> 1) It seems your latest commit r316136 fix premature reboot issue. >> >> Now I need to know how that helped. Do you used a non-default mode? > > Perhaps it isn't really helped, but just hide the problem, changing some > another race time parameters. > I use 80x30 text mode on all screens. I think it was the sizing. The non-updated mode is 80x25, so the row address can be out of bounds in the teken layer. >>> 2) I still can't enter KDB using Ctrl-Alt-ESC, while booting, after >>> booting, after login and while shutdown - nothing happens. >>> boot -d enters KDB normally, but the keyboard sequence handler is >>> broken, not boot -d. >> >> Try "~b". > > What? It just prints \n, new csh prompt and ~b This takes ALT_BREAK_TO_DEBUGGER. >> It is an old bug that Ctrl-Alt-ESC (and Ctrl-PrtScr) GENERIC is even more broken than I remembered. It doesn't even have ALT_BREAK_TO_DEBUGGER. In old versions, this didn't affect the syscons key. The key was controlled by the SC_DISABLE_DDBKEY option so defaulted to enabled. There was no tunable or sysctl to change the default. Serial consoles had a BREAK_TO_DEBUGGER option to control entering the debugger on a serial line break. This was not per-device or even per-driver. Things were broken by conflating serial line BREAKs with entering the debugger using a breakpoint instruction. Now there are many sysctls and tunable,s but the basic enable is the conflated BREAK_TO_DEBUGGER. This now gives the default setting for entering kdb using a breakpoint instruction. Syscons calls the function kdb_break() which calls kdb_enter() which does the breakpoint instruction. Arches that don't have such an instruction must have a virtual one. The default setting can be modified using a tunable or sysctl. So to have a chance of the syscons debugger keys working, you first have to configure this setting, using either: - BREAK_TO_DEBUGGER in static config file. This is documented in ddb(4), but only for its unbroken meaning for serial consoles - tunable debug.kdb.break_to_debugger. This seems to be undocumented - sysctl debug.kdb.break_to_debugger. This is documented in ddb(4), but only as equivalent to the unbroken BREAK_TO_DEBUGGER. You have to set the variable using 1 or more of these knobs if you want the syscons and vt debugger keys to work, but this also enables debugger entry for serial line breaks and thus breaks the reason for existence of the unbroken BREAK_TO_DEBUGGER option. Normally you don't want to enter the debugger for serial line breaks, since then unplugging the cable or noise on the cable may enter the debugger, and the option exists to enable the entry for the rare cases where it is safe. Next there are the sysctl and vt knobs to set, but these have correct defaults so are enabled automatically. SC_DISABLE_DDBKEY is now named SC_DISABLE_KDBKEY. It always disabled not only the key, but the code to enable it. It actually controls 2 keys and 1 sequence of keys. When it is not configured, the Ctrl-PtrScr and Ctrl-Alt-ESC keys are enabled by default. This can be changed by a sysctl but not by a tunable. The sysctl is confusingly named with "kbd" (keyboard) in its name, while the configu option has KDB (kerel debugger) in its name. The variable for this also controls the sequences of keys which are more than ddb keys and are controlled by the ALT_BREAK_TO_DEBUGGER option and its knobs. vt doesn't have a static config knob to enable the enables. It has a tunable as well as a sysctl. This sysctl only controls the keys, not key sequences. (There may be more than 2 debugger keys. keymap allows any key to be a debugger key.) syscons and/or vt also have knobs to control halt, poweroff, reboot and panic, bug not suspend. Many of these are defeated by the sequences enabled by ALT_BREAK_TO_DEBUGGER. This is a larger bug in vt. In vt, ALT_BREAK_TO_DEBUGGER is limited by the sysctl for the kdb keys. If kdb entry is allowed, then there is no point in disallowing anything since anything can be done using kdb if it has a backend. This complexity is not enough to give enough control. The control should be per-device. You might have 1 secure console and 1 insecure console. Then enable kdb on at most the secure console. Or 1 remote serial console with a good cable and serial console with a bad cable. Then enable kdb entry for serial line breaks on at most the one with the good cable. With per-device control, the 6 knobs for controlling entry at the kdb level would be sillier, but at least 1 knowb is needed there to prevent all ddb use. > Ctrl-PrtScr does nothing too. > >> But I think the misconfiguration is the >> same for vt. > > No, Ctrl-Alt-ESC works for vt at every phase of the system lifecycle. My point it that it is easy to misconfigure the maze of knobs. However, since sc used to work and vt still works, you must have something like BREAK_TO_DEBUGGER configured, so they should both work. > I use Russian keymap for syscons, but Ctrl, Alt, ESC of course are not > remapped. I surely remember it works for syscons long time ago. I didn't change this, except for th usb keyboard some keys near or equal to Ctrl-PrtScr were broken and I fixed them. I normally use that instead of Ctrl-Alt-Esc. I also rarely enable BREAK_TO_DEBUGGER even for systems that don't have a serial console, but enable the sysctl dynamically on systems where this is safe. This gives the annoying behaviour that the syscons keys don't work until late in the boot, so I have to type ~b. Bruce