Re: [PATCH 01/10] x86/iommu: Add IOMMU_INIT macros, .iommu_tablesection, and iommu_table_entry structure.

From: H. Peter Anvin
Date: Thu Aug 26 2010 - 15:49:24 EST


On 08/26/2010 11:19 AM, Sam Ravnborg wrote:
>
> So we have yet another magic section in vmlinux.lds.S
> A nice comemnt that expalins what this is used for and why
> it is discardable etc. would be nice.
>
> Lots of magic sections in same file miss this,
> but thats not an example to follwow.
>

Honestly, I think we this kind of problem -- a mergeable table -- often
enough that we should implement a generic facility for it. It obviously
has to be based on sections, but I think we could automate its creation.
The gPXE people have done that, and this is more or less a summary of
their technique.

Basically, you have a set of sections with names like:

.table.<symbol>.<priority>

... then the linker script looks something like:

.table : {
SORT_BY_NAME(.table.*)
}

use SORT_BY_NAME() in the linker script. To get the start and end
symbols, we define them as solo symbols inside sections designed to sort
first and last (written by hand into email, so adjustments may be
needed, void where prohibited):

#define TABLE(name, priority) \
__section(".table." ## name ## "." ## priority)

#define DECLARE_TABLE(type, name) \
extern type __table ## name ## _start[0]; \
extern type __table ## name ## _end[0];

#define DEFINE_TABLE(type, name) \
type __table ## name ## _start[0] TABLE(name, 0); \
type __table ## name ## _end[0] TABLE(name, 9);

Here "priority" is a digit from 1 (first) to 8 (last); 0 and 9 are used
for the capstones.

Presumably we need a few different flavors for init tables and so on,
but this would make it a generic mechanism.

-hpa
--
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/