Re: [PATCH 13/13] kdb: Add mdi, mdiW / mdiWcN commands to show iomapped memory

From: Daniel Thompson
Date: Tue Jun 18 2024 - 11:59:48 EST


On Mon, Jun 17, 2024 at 05:34:47PM -0700, Douglas Anderson wrote:
> Add commands that are like the other "md" commands but that allow you
> to read memory that's in the IO space.
>
> Signed-off-by: Douglas Anderson <dianders@xxxxxxxxxxxx>

Sorry to be the bearer of bad news but...


> ---
> <snip>
> +/*
> + * kdb_getioword
> + * Inputs:
> + * word Pointer to the word to receive the result.
> + * addr Address of the area to copy.
> + * size Size of the area.
> + * Returns:
> + * 0 for success, < 0 for error.
> + */
> +int kdb_getioword(unsigned long *word, unsigned long addr, size_t size)
> +{
> + void __iomem *mapped = ioremap(addr, size);

ioremap() is a might_sleep() function. It's unsafe to call it from the
debug trap handler.

I'm afraid I don't know a safe alternative either. Machinary such as
kmap_atomic() needs a page and iomem won't have one.


Daniel.