<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/drivers/tty/serial/kgdboc.c, branch linux-6.9.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.9.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-6.9.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2024-05-25T14:30:55Z</updated>
<entry>
<title>serial: kgdboc: Fix NMI-safety problems from keyboard reset code</title>
<updated>2024-05-25T14:30:55Z</updated>
<author>
<name>Daniel Thompson</name>
<email>daniel.thompson@linaro.org</email>
</author>
<published>2024-04-24T14:21:41Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=4dd04367a26a48e6b0750322c0c0423a77902858'/>
<id>urn:sha1:4dd04367a26a48e6b0750322c0c0423a77902858</id>
<content type='text'>
commit b2aba15ad6f908d1a620fd97f6af5620c3639742 upstream.

Currently, when kdb is compiled with keyboard support, then we will use
schedule_work() to provoke reset of the keyboard status.  Unfortunately
schedule_work() gets called from the kgdboc post-debug-exception
handler.  That risks deadlock since schedule_work() is not NMI-safe and,
even on platforms where the NMI is not directly used for debugging, the
debug trap can have NMI-like behaviour depending on where breakpoints
are placed.

Fix this by using the irq work system, which is NMI-safe, to defer the
call to schedule_work() to a point when it is safe to call.

Reported-by: Liuye &lt;liu.yeC@h3c.com&gt;
Closes: https://lore.kernel.org/all/20240228025602.3087748-1-liu.yeC@h3c.com/
Cc: stable@vger.kernel.org
Reviewed-by: Douglas Anderson &lt;dianders@chromium.org&gt;
Acked-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Link: https://lore.kernel.org/r/20240424-kgdboc_fix_schedule_work-v2-1-50f5a490aec5@linaro.org
Signed-off-by: Daniel Thompson &lt;daniel.thompson@linaro.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>tty: serial: kgdboc: fix mutex locking order for configure_kgdboc()</title>
<updated>2023-01-16T15:44:53Z</updated>
<author>
<name>John Ogness</name>
<email>john.ogness@linutronix.de</email>
</author>
<published>2023-01-12T16:12:13Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=3ef5abd9b5c738bc6fa9a65e40331ef2cb03ad9c'/>
<id>urn:sha1:3ef5abd9b5c738bc6fa9a65e40331ef2cb03ad9c</id>
<content type='text'>
Several mutexes are taken while setting up console serial ports. In
particular, the tty_port-&gt;mutex and @console_mutex are taken:

  serial_pnp_probe
    serial8250_register_8250_port
      uart_add_one_port (locks tty_port-&gt;mutex)
        uart_configure_port
          register_console (locks @console_mutex)

In order to synchronize kgdb's tty_find_polling_driver() with
register_console(), commit 6193bc90849a ("tty: serial: kgdboc:
synchronize tty_find_polling_driver() and register_console()") takes
the @console_mutex. However, this leads to the following call chain
(with locking):

  platform_probe
    kgdboc_probe
      configure_kgdboc (locks @console_mutex)
        tty_find_polling_driver
          uart_poll_init (locks tty_port-&gt;mutex)
            uart_set_options

This is clearly deadlock potential due to the reverse lock ordering.

Since uart_set_options() requires holding @console_mutex in order to
serialize early initialization of the serial-console lock, take the
@console_mutex in uart_poll_init() instead of configure_kgdboc().

Since configure_kgdboc() was using @console_mutex for safe traversal
of the console list, change it to use the SRCU iterator instead.

Add comments to uart_set_options() kerneldoc mentioning that it
requires holding @console_mutex (aka the console_list_lock).

Fixes: 6193bc90849a ("tty: serial: kgdboc: synchronize tty_find_polling_driver() and register_console()")
Signed-off-by: John Ogness &lt;john.ogness@linutronix.de&gt;
Reviewed-by: Sergey Senozhatsky &lt;senozhatsky@chromium.org&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
[pmladek@suse.com: Export console_srcu_read_lock_is_held() to fix build kgdboc as a module.]
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20230112161213.1434854-1-john.ogness@linutronix.de
</content>
</entry>
<entry>
<title>tty: serial: kgdboc: use console_list_lock to trap exit</title>
<updated>2022-12-02T10:25:02Z</updated>
<author>
<name>John Ogness</name>
<email>john.ogness@linutronix.de</email>
</author>
<published>2022-11-16T16:21:50Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=e2b39652283685edd7e84174b10736d79063d399'/>
<id>urn:sha1:e2b39652283685edd7e84174b10736d79063d399</id>
<content type='text'>
kgdboc_earlycon_init() uses the console_lock to ensure that no consoles
are unregistered until the kgdboc_earlycon is setup. The console_list_lock
should be used instead because list synchronization responsibility will
be removed from the console_lock in a later change.

Signed-off-by: John Ogness &lt;john.ogness@linutronix.de&gt;
Reviewed-by: Daniel Thompson &lt;daniel.thompson@linaro.org&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20221116162152.193147-39-john.ogness@linutronix.de
</content>
</entry>
<entry>
<title>tty: serial: kgdboc: synchronize tty_find_polling_driver() and register_console()</title>
<updated>2022-12-02T10:25:02Z</updated>
<author>
<name>John Ogness</name>
<email>john.ogness@linutronix.de</email>
</author>
<published>2022-11-16T16:21:49Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=6193bc90849a711e3b67bc6051e1bb0254c51f2a'/>
<id>urn:sha1:6193bc90849a711e3b67bc6051e1bb0254c51f2a</id>
<content type='text'>
Calling tty_find_polling_driver() can lead to uart_set_options() being
called (via the poll_init() callback of tty_operations) to configure the
uart. But uart_set_options() can also be called by register_console()
(via the setup() callback of console).

Take the console_list_lock to synchronize against register_console() and
also use it for console list traversal. This also ensures the console list
cannot change until the polling console has been chosen.

Signed-off-by: John Ogness &lt;john.ogness@linutronix.de&gt;
Reviewed-by: Daniel Thompson &lt;daniel.thompson@linaro.org&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
Reviewed-by: Douglas Anderson &lt;dianders@chromium.org&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20221116162152.193147-38-john.ogness@linutronix.de
</content>
</entry>
<entry>
<title>tty: serial: kgdboc: use console_list_lock for list traversal</title>
<updated>2022-12-02T10:25:02Z</updated>
<author>
<name>John Ogness</name>
<email>john.ogness@linutronix.de</email>
</author>
<published>2022-11-16T16:21:48Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=66857443699b34c8c5951dd421f1c528c9554bb5'/>
<id>urn:sha1:66857443699b34c8c5951dd421f1c528c9554bb5</id>
<content type='text'>
configure_kgdboc() uses the console_lock for console list iteration. Use
the console_list_lock instead because list synchronization responsibility
will be removed from the console_lock in a later change.

The SRCU iterator could have been used here, but a later change will
relocate the locking of the console_list_lock to also provide
synchronization against register_console().

Note, the console_lock is still needed to serialize the device()
callback with other console operations.

Signed-off-by: John Ogness &lt;john.ogness@linutronix.de&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
Reviewed-by: Douglas Anderson &lt;dianders@chromium.org&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20221116162152.193147-37-john.ogness@linutronix.de
</content>
</entry>
<entry>
<title>tty: serial: kgdboc: use srcu console list iterator</title>
<updated>2022-12-02T10:25:02Z</updated>
<author>
<name>John Ogness</name>
<email>john.ogness@linutronix.de</email>
</author>
<published>2022-11-16T16:21:47Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=7e537af997748ea7a8df3f2b234a877ea9ef7791'/>
<id>urn:sha1:7e537af997748ea7a8df3f2b234a877ea9ef7791</id>
<content type='text'>
Use srcu console list iteration for safe console list traversal.
Note that this is a preparatory change for when console_lock no
longer provides synchronization for the console list.

Signed-off-by: John Ogness &lt;john.ogness@linutronix.de&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
Reviewed-by: Douglas Anderson &lt;dianders@chromium.org&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20221116162152.193147-36-john.ogness@linutronix.de
</content>
</entry>
<entry>
<title>tty: serial: kgdboc: document console_lock usage</title>
<updated>2022-12-02T10:25:00Z</updated>
<author>
<name>John Ogness</name>
<email>john.ogness@linutronix.de</email>
</author>
<published>2022-11-16T16:21:20Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=0fb413ea64603a71e19b4b15a6c5b704e3897d06'/>
<id>urn:sha1:0fb413ea64603a71e19b4b15a6c5b704e3897d06</id>
<content type='text'>
kgdboc_earlycon_init() uses the console_lock to ensure that no consoles
are unregistered until the kgdboc_earlycon is setup. This is necessary
because the trapping of the exit() callback assumes that the exit()
callback is not called before the trap is setup.

Explicitly document this non-typical console_lock usage.

Signed-off-by: John Ogness &lt;john.ogness@linutronix.de&gt;
Reviewed-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Reviewed-by: Douglas Anderson &lt;dianders@chromium.org&gt;
Reviewed-by: Daniel Thompson &lt;daniel.thompson@linaro.org&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20221116162152.193147-9-john.ogness@linutronix.de
</content>
</entry>
<entry>
<title>serial: kgdboc: Lock console list in probe function</title>
<updated>2022-12-02T10:24:59Z</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2022-11-16T16:21:13Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=9e409c4778afbbd44759e56ec4bbed839fd31909'/>
<id>urn:sha1:9e409c4778afbbd44759e56ec4bbed839fd31909</id>
<content type='text'>
Unprotected list walks are not necessarily safe.

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Signed-off-by: John Ogness &lt;john.ogness@linutronix.de&gt;
Reviewed-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Reviewed-by: Douglas Anderson &lt;dianders@chromium.org&gt;
Reviewed-by: Sergey Senozhatsky &lt;senozhatsky@chromium.org&gt;
Reviewed-by: Petr Mladek &lt;pmladek@suse.com&gt;
Reviewed-by: Daniel Thompson &lt;daniel.thompson@linaro.org&gt;
Signed-off-by: Petr Mladek &lt;pmladek@suse.com&gt;
Link: https://lore.kernel.org/r/20221116162152.193147-2-john.ogness@linutronix.de
</content>
</entry>
<entry>
<title>serial: kgdboc: Fix typo in comment</title>
<updated>2022-06-27T12:37:09Z</updated>
<author>
<name>Xiang wangx</name>
<email>wangxiang@cdjrlc.com</email>
</author>
<published>2022-06-20T10:46:53Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=ab8ba6c59d5ab4f894cd731c0b05825576d15ed1'/>
<id>urn:sha1:ab8ba6c59d5ab4f894cd731c0b05825576d15ed1</id>
<content type='text'>
Delete the redundant word 'the'.

Signed-off-by: Xiang wangx &lt;wangxiang@cdjrlc.com&gt;
Link: https://lore.kernel.org/r/20220620104653.5451-1-wangxiang@cdjrlc.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>kgdboc: fix return value of __setup handler</title>
<updated>2022-03-18T12:12:33Z</updated>
<author>
<name>Randy Dunlap</name>
<email>rdunlap@infradead.org</email>
</author>
<published>2022-03-09T03:30:18Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=ab818c7aa7544bf8d2dd4bdf68878b17a02eb332'/>
<id>urn:sha1:ab818c7aa7544bf8d2dd4bdf68878b17a02eb332</id>
<content type='text'>
__setup() handlers should return 1 to obsolete_checksetup() in
init/main.c to indicate that the boot option has been handled.
A return of 0 causes the boot option/value to be listed as an Unknown
kernel parameter and added to init's (limited) environment strings.
So return 1 from kgdboc_option_setup().

Unknown kernel command line parameters "BOOT_IMAGE=/boot/bzImage-517rc7
  kgdboc=kbd kgdbts=", will be passed to user space.

 Run /sbin/init as init process
   with arguments:
     /sbin/init
   with environment:
     HOME=/
     TERM=linux
     BOOT_IMAGE=/boot/bzImage-517rc7
     kgdboc=kbd
     kgdbts=

Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
Fixes: 1bd54d851f50 ("kgdboc: Passing ekgdboc to command line causes panic")
Fixes: f2d937f3bf00 ("consoles: polling support, kgdboc")
Cc: He Zhe &lt;zhe.he@windriver.com&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Cc: Jiri Slaby &lt;jirislaby@kernel.org&gt;
Cc: kgdb-bugreport@lists.sourceforge.net
Cc: Jason Wessel &lt;jason.wessel@windriver.com&gt;
Cc: Daniel Thompson &lt;daniel.thompson@linaro.org&gt;
Cc: Douglas Anderson &lt;dianders@chromium.org&gt;
Cc: linux-serial@vger.kernel.org
Reported-by: Igor Zhbanov &lt;i.zhbanov@omprussia.ru&gt;
Reviewed-by: Douglas Anderson &lt;dianders@chromium.org&gt;
Signed-off-by: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Link: https://lore.kernel.org/r/20220309033018.17936-1-rdunlap@infradead.org
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
