Re: AMD-IOMMU and problem with __init(data)?

From: Joerg Roedel
Date: Tue Sep 29 2015 - 11:07:12 EST


As expected it is no bug in the AMD IOMMU driver, but in your code.

On Wed, Sep 23, 2015 at 09:04:31PM +0200, Alexander Holler wrote:
> struct _annotated_initcall {
> initcall_t initcall;
> unsigned driver_id;
> unsigned *dependencies;
> struct device_driver *driver;
> };

This struct gets aligned on a 32 bytes boundary.

> +#define ANNOTATED_INITCALLS \
> + VMLINUX_SYMBOL(__annotated_initcall_start) = .; \
> + *(.annotated_initcall.init) \
> + VMLINUX_SYMBOL(__annotated_initcall_end) = .;

But this section does not.

> + ac = __annotated_initcall_start;
> + pr_info("ac %p ID %u\n", ac, ac->driver_id);
> + BUG_ON(ac->driver_id != 23);

So when you access __annotated_initcall_start here, you don't access the
first element of your array, but actually the zero padding before your
struct.

On my system the section was aligned on an 8 bytes boundary, which means
there were 24 bytes of padding before the symbol you try to access.



Joerg

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