Problems with debugging I/O port access in kdb on i386

Martin Wilck (Martin.Wilck@fujitsu-siemens.com)
Mon, 18 Mar 2002 19:23:45 +0100 (CET)


Hi Keith, everybody,

I have encountered the following problems with kdb 2.1 (2.4.18)
when trying to catch I/O port accesses in kdb (both can probably be fixed
easily):

1. This code in kdb/kdb_bp.c:

if (kdba_verify_rw(addr, sizeof(kdb_machinst_t))) {
kdb_printf("Invalid address for breakpoint, ignoring bp command\n");
return(0);
}

forbids to set I/O breakpoints on low ports (e.g. 0x20), because the
address check done by kdba_verify_rw is valid for memory addresses
only. AFAICS, no check whatsoever is necessary for I/O port addresses.

I would submit a patch for this, but the address check must be
postponed after the architecture-dependent parsing, and the information
whether this is an I/O port breakpoint must be passed to the checking
code. I don't know what implications that may have for the
other architectures.

2. The DE flag in the CR4 register must be set (for CPUs that have it)
in order to use I/O breakpoints at all. Otherwise they will be simply
ignored by the CPU.

Thus, a line like

if (cpu_has_de)
set_in_cr4 (X86_CR4_DE);

must be put in kdba_init().
That may not suffice because cpu_init() (kernel/setup.c) clears the DE
bit for each CPU, I don't know which one is called first.

Again, I do not oversee all possible implications, so I do not submit a
patch.

As a hack, I inserted the above line in kdba_installdbreg() after the
line

dr7 |= DR7_GE;

This works fine, I can now trap the I/O accesses I want.

Cheers,
Martin

-- 
Martin Wilck                Phone: +49 5251 8 15113
Fujitsu Siemens Computers   Fax:   +49 5251 8 20409
Heinz-Nixdorf-Ring 1	    mailto:Martin.Wilck@Fujitsu-Siemens.com
D-33106 Paderborn           http://www.fujitsu-siemens.com/primergy

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/