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

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: H. Peter Anvin
Date: Thursday, August 26, 2010 - 12:48 pm

On 08/26/2010 11:19 AM, Sam Ravnborg wrote:

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
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[RFC PATCH v2] Modularize IOMMUs detection/init for X86, Konrad Rzeszutek Wilk, (Thu Aug 26, 10:57 am)
[PATCH 01/10] x86/iommu: Add IOMMU_INIT macros, .iommu_tab ..., Konrad Rzeszutek Wilk, (Thu Aug 26, 10:57 am)
[PATCH 02/10] x86/iommu: Make all IOMMU's detection routin ..., Konrad Rzeszutek Wilk, (Thu Aug 26, 10:57 am)
[PATCH 08/10] x86/GART/AMD-VI: Make AMD GART and IOMMU use ..., Konrad Rzeszutek Wilk, (Thu Aug 26, 10:58 am)
[PATCH 09/10] x86/VT-d: Make Intel VT-d IOMMU use IOMMU_IN ..., Konrad Rzeszutek Wilk, (Thu Aug 26, 10:58 am)
[PATCH 10/10] x86/iommu: Utilize the IOMMU_INIT macros fun ..., Konrad Rzeszutek Wilk, (Thu Aug 26, 10:58 am)
Re: [PATCH 01/10] x86/iommu: Add IOMMU_INIT macros, .iommu ..., H. Peter Anvin, (Thu Aug 26, 12:48 pm)
[tip:x86/iommu] x86, iommu: Add IOMMU_INIT macros, .iommu_ ..., tip-bot for Konrad R ..., (Thu Aug 26, 4:27 pm)
[tip:x86/iommu] x86, iommu: Make all IOMMU's detection rou ..., tip-bot for Konrad R ..., (Thu Aug 26, 4:28 pm)
[tip:x86/iommu] x86, GART/AMD-VI: Make AMD GART and IOMMU ..., tip-bot for Konrad R ..., (Thu Aug 26, 4:30 pm)
[tip:x86/iommu] x86, VT-d: Make Intel VT-d IOMMU use IOMMU ..., tip-bot for Konrad R ..., (Thu Aug 26, 4:30 pm)
[tip:x86/iommu] x86, iommu: Utilize the IOMMU_INIT macros ..., tip-bot for Konrad R ..., (Thu Aug 26, 4:31 pm)
Re: [PATCH 01/10] x86/iommu: Add IOMMU_INIT macros, .iommu ..., Konrad Rzeszutek Wilk, (Fri Aug 27, 7:38 am)
[PATCH] x86: Adding comments about .iommu_table and its ne ..., Konrad Rzeszutek Wilk, (Fri Aug 27, 11:19 am)
[tip:x86/iommu] x86, doc: Adding comments about .iommu_tab ..., tip-bot for Konrad R ..., (Fri Aug 27, 6:54 pm)
Re: [PATCH 09/10] x86/VT-d: Make Intel VT-d IOMMU use IOMM ..., Konrad Rzeszutek Wilk, (Tue Sep 7, 12:07 pm)