NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/50395: Loss of characters in serial port communication between gdb and kgdb_stub



>Number:         50395
>Category:       kern
>Synopsis:       Loss of characters in serial port communication between gdb and kgdb_stub
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 02 16:10:00 +0000 2015
>Originator:     Vicente Chaves
>Release:        Netbsd7-current
>Organization:
>Environment:
NetBSD netbsd7.vbox.lab 7.99.21 NetBSD 7.99.21 (GENERIC) #1: Sat Aug 22 15:46:52 UTC 2015  vchaves%netbsd7.vbox.lab@localhost:/home/vchaves/current/amd64/sys/arch/amd64/compile/GENERIC amd64
>Description:
During a kernel debug session using the kgdb we can observe
losses that cause communication problems between the stub and the gdb remote.

This is because despite the com0 be reserved for kgdb, the port continues
generating interrupts when characters available on UART, this makes
the interrupt handler comintr() take the character before the stub.

Analyzing the problem, it seems to me that the function comenabledebugport() at com.c:380,
as suggested by the comment, should use the flag IER_ERLS to call the line break interrupt
instead of the flag IER_ERXRDY, as we can see their definitions in comreg. h

#define IER_ERLS 0x4 Enable line status interrupt
#define IER_ERXRDY 0x1 Enable receiver interrupt

Although it is not related to the above problem, it seems to me that the same mistake seems to occur also in comshutdown() at com.c:815.

After these fixes the stub can communicate seamlessly with the gdb remote.
Best regards
Vicente.
>How-To-Repeat:
Try to debug the kernel using kgdb between two vbox VM.
>Fix:
Index: sys/dev/ic/com.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/com.c,v
retrieving revision 1.336
diff -u -r1.336 com.c
--- sys/dev/ic/com.c    4 May 2015 22:59:36 -0000       1.336
+++ sys/dev/ic/com.c    2 Nov 2015 14:45:52 -0000
@@ -377,7 +377,7 @@
 {

        /* Turn on line break interrupt, set carrier. */
-       sc->sc_ier = IER_ERXRDY;
+       sc->sc_ier = IER_ERLS;
        if (sc->sc_type == COM_TYPE_PXA2x0)
                sc->sc_ier |= IER_EUART | IER_ERXTOUT;
        if (sc->sc_type == COM_TYPE_INGENIC ||
@@ -812,7 +812,7 @@

        /* Turn off interrupts. */
        if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) {
-               sc->sc_ier = IER_ERXRDY; /* interrupt on break */
+               sc->sc_ier = IER_ERLS; /* interrupt on break */
                if ((sc->sc_type == COM_TYPE_PXA2x0) ||
                    (sc->sc_type == COM_TYPE_INGENIC) ||
                    (sc->sc_type == COM_TYPE_TEGRA))



Home | Main Index | Thread Index | Old Index