From: "Jan Beulich" Subject: [PATCH 3/4] ACPI: eliminate duplicate DMAR definitions Date: Mon, 12 Dec 2011 16:10:55 +0000 Message-ID: <4EE6359F0200007800067064@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part7857DD9F.1__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" Cc: Allen M Kay List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part7857DD9F.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Use their proper counterparts in include/acpi/actbl*.h instead. Signed-off-by: Jan Beulich --- a/xen/drivers/passthrough/vtd/dmar.c +++ b/xen/drivers/passthrough/vtd/dmar.c @@ -38,8 +38,8 @@ #define PREFIX VTDPREFIX "ACPI DMAR:" #define DEBUG =20 -#define MIN_SCOPE_LEN (sizeof(struct acpi_pci_path) + \ - sizeof(struct acpi_dev_scope)) +#define MIN_SCOPE_LEN (sizeof(struct acpi_dmar_device_scope) + \ + sizeof(struct acpi_dmar_pci_path)) =20 LIST_HEAD_READ_MOSTLY(acpi_drhd_units); LIST_HEAD_READ_MOSTLY(acpi_rmrr_units); @@ -247,25 +247,25 @@ int is_igd_drhd(struct acpi_drhd_unit *d * Count number of devices in device scope. Do not include PCI sub * hierarchies. */ -static int scope_device_count(void *start, void *end) +static int __init scope_device_count(const void *start, const void *end) { - struct acpi_dev_scope *scope; + const struct acpi_dmar_device_scope *scope; int count =3D 0; =20 while ( start < end ) { scope =3D start; if ( (scope->length < MIN_SCOPE_LEN) || - (scope->dev_type >=3D ACPI_DEV_ENTRY_COUNT) ) + (scope->entry_type >=3D ACPI_DMAR_SCOPE_TYPE_RESERVED) ) { dprintk(XENLOG_WARNING VTDPREFIX, "Invalid device scope.\n"); return -EINVAL; } =20 - if ( scope->dev_type =3D=3D ACPI_DEV_P2PBRIDGE || - scope->dev_type =3D=3D ACPI_DEV_ENDPOINT || - scope->dev_type =3D=3D ACPI_DEV_IOAPIC || - scope->dev_type =3D=3D ACPI_DEV_MSI_HPET ) + if ( scope->entry_type =3D=3D ACPI_DMAR_SCOPE_TYPE_BRIDGE || + scope->entry_type =3D=3D ACPI_DMAR_SCOPE_TYPE_ENDPOINT || + scope->entry_type =3D=3D ACPI_DMAR_SCOPE_TYPE_IOAPIC || + scope->entry_type =3D=3D ACPI_DMAR_SCOPE_TYPE_HPET ) count++; =20 start +=3D scope->length; @@ -276,13 +276,13 @@ static int scope_device_count(void *star =20 =20 static int __init acpi_parse_dev_scope( - void *start, void *end, void *acpi_entry, int type, u16 seg) + const void *start, const void *end, void *acpi_entry, int type, u16 = seg) { struct dmar_scope *scope =3D acpi_entry; struct acpi_ioapic_unit *acpi_ioapic_unit; - struct acpi_dev_scope *acpi_scope; + const struct acpi_dmar_device_scope *acpi_scope; u16 bus, sub_bus, sec_bus; - struct acpi_pci_path *path; + const struct acpi_dmar_pci_path *path; int depth, cnt, didx =3D 0; =20 if ( (cnt =3D scope_device_count(start, end)) < 0 ) @@ -299,10 +299,9 @@ static int __init acpi_parse_dev_scope( while ( start < end ) { acpi_scope =3D start; - path =3D (struct acpi_pci_path *)(acpi_scope + 1); - depth =3D (acpi_scope->length - sizeof(struct acpi_dev_scope)) - / sizeof(struct acpi_pci_path); - bus =3D acpi_scope->start_bus; + path =3D (const void *)(acpi_scope + 1); + depth =3D (acpi_scope->length - sizeof(*acpi_scope)) / sizeof(*pat= h); + bus =3D acpi_scope->bus; =20 while ( --depth > 0 ) { @@ -311,9 +310,9 @@ static int __init acpi_parse_dev_scope( path++; } =20 - switch ( acpi_scope->dev_type ) + switch ( acpi_scope->entry_type ) { - case ACPI_DEV_P2PBRIDGE: + case ACPI_DMAR_SCOPE_TYPE_BRIDGE: sec_bus =3D pci_conf_read8(seg, bus, path->dev, path->fn, PCI_SECONDARY_BUS); sub_bus =3D pci_conf_read8(seg, bus, path->dev, path->fn, @@ -322,18 +321,18 @@ static int __init acpi_parse_dev_scope( dprintk(VTDPREFIX, " bridge: %04x:%02x:%02x.%u start=3D%x sec=3D%x = sub=3D%x\n", seg, bus, path->dev, path->fn, - acpi_scope->start_bus, sec_bus, sub_bus); + acpi_scope->bus, sec_bus, sub_bus); =20 dmar_scope_add_buses(scope, sec_bus, sub_bus); break; =20 - case ACPI_DEV_MSI_HPET: + case ACPI_DMAR_SCOPE_TYPE_HPET: if ( iommu_verbose ) dprintk(VTDPREFIX, " MSI HPET: %04x:%02x:%02x.%u\n", seg, bus, path->dev, path->fn); break; =20 - case ACPI_DEV_ENDPOINT: + case ACPI_DMAR_SCOPE_TYPE_ENDPOINT: if ( iommu_verbose ) dprintk(VTDPREFIX, " endpoint: %04x:%02x:%02x.%u\n", seg, bus, path->dev, path->fn); @@ -349,7 +348,7 @@ static int __init acpi_parse_dev_scope( =20 break; =20 - case ACPI_DEV_IOAPIC: + case ACPI_DMAR_SCOPE_TYPE_IOAPIC: if ( iommu_verbose ) dprintk(VTDPREFIX, " IOAPIC: %04x:%02x:%02x.%u\n", seg, bus, path->dev, path->fn); @@ -360,7 +359,7 @@ static int __init acpi_parse_dev_scope( acpi_ioapic_unit =3D xmalloc(struct acpi_ioapic_unit); if ( !acpi_ioapic_unit ) return -ENOMEM; - acpi_ioapic_unit->apic_id =3D acpi_scope->enum_id; + acpi_ioapic_unit->apic_id =3D acpi_scope->enumeration_id; acpi_ioapic_unit->ioapic.bdf.bus =3D bus; acpi_ioapic_unit->ioapic.bdf.dev =3D path->dev; acpi_ioapic_unit->ioapic.bdf.func =3D path->fn; @@ -377,7 +376,7 @@ static int __init acpi_parse_dev_scope( } =20 static int __init acpi_dmar_check_length( - struct acpi_dmar_entry_header *h, unsigned int min_len) + const struct acpi_dmar_header *h, unsigned int min_len) { if ( h->length >=3D min_len ) return 0; @@ -388,9 +387,10 @@ static int __init acpi_dmar_check_length } =20 static int __init -acpi_parse_one_drhd(struct acpi_dmar_entry_header *header) +acpi_parse_one_drhd(struct acpi_dmar_header *header) { - struct acpi_table_drhd * drhd =3D (struct acpi_table_drhd *)header; + struct acpi_dmar_hardware_unit *drhd =3D + container_of(header, struct acpi_dmar_hardware_unit, header); void *dev_scope_start, *dev_scope_end; struct acpi_drhd_unit *dmaru; int ret; @@ -405,7 +405,7 @@ acpi_parse_one_drhd(struct acpi_dmar_ent =20 dmaru->address =3D drhd->address; dmaru->segment =3D drhd->segment; - dmaru->include_all =3D drhd->flags & 1; /* BIT0: INCLUDE_ALL */ + dmaru->include_all =3D drhd->flags & ACPI_DMAR_INCLUDE_ALL; INIT_LIST_HEAD(&dmaru->ioapic_list); if ( iommu_verbose ) dprintk(VTDPREFIX, " dmaru->address =3D %"PRIx64"\n", @@ -443,17 +443,20 @@ acpi_parse_one_drhd(struct acpi_dmar_ent { u8 b, d, f; unsigned int i =3D 0, invalid_cnt =3D 0; - void *p; + union { + const void *raw; + const struct acpi_dmar_device_scope *scope; + } p; =20 /* Skip checking if segment is not accessible yet. */ if ( !pci_known_segment(drhd->segment) ) i =3D UINT_MAX; =20 - for ( p =3D dev_scope_start; i < dmaru->scope.devices_cnt; - i++, p +=3D ((struct acpi_dev_scope *)p)->length ) + for ( p.raw =3D dev_scope_start; i < dmaru->scope.devices_cnt; + i++, p.raw +=3D p.scope->length ) { - if ( ((struct acpi_dev_scope *)p)->dev_type =3D=3D ACPI_DEV_IO= APIC || - ((struct acpi_dev_scope *)p)->dev_type =3D=3D ACPI_DEV_MS= I_HPET ) + if ( p.scope->entry_type =3D=3D ACPI_DMAR_SCOPE_TYPE_IOAPIC = || + p.scope->entry_type =3D=3D ACPI_DMAR_SCOPE_TYPE_HPET ) continue; =20 b =3D PCI_BUS(dmaru->scope.devices[i]); @@ -505,9 +508,10 @@ out: } =20 static int __init -acpi_parse_one_rmrr(struct acpi_dmar_entry_header *header) +acpi_parse_one_rmrr(struct acpi_dmar_header *header) { - struct acpi_table_rmrr *rmrr =3D (struct acpi_table_rmrr *)header; + struct acpi_dmar_reserved_memory *rmrr =3D + container_of(header, struct acpi_dmar_reserved_memory, header); struct acpi_rmrr_unit *rmrru; void *dev_scope_start, *dev_scope_end; u64 base_addr =3D rmrr->base_address, end_addr =3D rmrr->end_address; @@ -610,9 +614,10 @@ acpi_parse_one_rmrr(struct acpi_dmar_ent } =20 static int __init -acpi_parse_one_atsr(struct acpi_dmar_entry_header *header) +acpi_parse_one_atsr(struct acpi_dmar_header *header) { - struct acpi_table_atsr *atsr =3D (struct acpi_table_atsr *)header; + struct acpi_dmar_atsr *atsr =3D + container_of(header, struct acpi_dmar_atsr, header); struct acpi_atsr_unit *atsru; int ret; static int all_ports; @@ -626,7 +631,7 @@ acpi_parse_one_atsr(struct acpi_dmar_ent return -ENOMEM; =20 atsru->segment =3D atsr->segment; - atsru->all_ports =3D atsr->flags & 1; /* BIT0: ALL_PORTS */ + atsru->all_ports =3D atsr->flags & ACPI_DMAR_ALL_PORTS; if ( iommu_verbose ) dprintk(VTDPREFIX, " atsru->all_ports: %x\n", atsru->all_ports); @@ -660,9 +665,10 @@ acpi_parse_one_atsr(struct acpi_dmar_ent } =20 static int __init -acpi_parse_one_rhsa(struct acpi_dmar_entry_header *header) +acpi_parse_one_rhsa(struct acpi_dmar_header *header) { - struct acpi_table_rhsa *rhsa =3D (struct acpi_table_rhsa *)header; + struct acpi_dmar_rhsa *rhsa =3D + container_of(header, struct acpi_dmar_rhsa, header); struct acpi_rhsa_unit *rhsau; int ret; =20 @@ -673,7 +679,7 @@ acpi_parse_one_rhsa(struct acpi_dmar_ent if ( !rhsau ) return -ENOMEM; =20 - rhsau->address =3D rhsa->address; + rhsau->address =3D rhsa->base_address; rhsau->proximity_domain =3D rhsa->proximity_domain; list_add_tail(&rhsau->list, &acpi_rhsa_units); if ( iommu_verbose ) @@ -688,7 +694,7 @@ acpi_parse_one_rhsa(struct acpi_dmar_ent static int __init acpi_parse_dmar(struct acpi_table_header *table) { struct acpi_table_dmar *dmar; - struct acpi_dmar_entry_header *entry_header; + struct acpi_dmar_header *entry_header; u8 dmar_host_address_width; int ret =3D 0; =20 @@ -713,33 +719,32 @@ static int __init acpi_parse_dmar(struct dprintk(VTDPREFIX, "Host address width %d\n", dmar_host_address_width); =20 - entry_header =3D (struct acpi_dmar_entry_header *)(dmar + 1); + entry_header =3D (void *)(dmar + 1); while ( ((unsigned long)entry_header) < (((unsigned long)dmar) + table->length) ) { - ret =3D acpi_dmar_check_length( - entry_header, sizeof(struct acpi_dmar_entry_header)); + ret =3D acpi_dmar_check_length(entry_header, sizeof(*entry_header)= ); if ( ret ) break; =20 switch ( entry_header->type ) { - case ACPI_DMAR_DRHD: + case ACPI_DMAR_TYPE_HARDWARE_UNIT: if ( iommu_verbose ) dprintk(VTDPREFIX, "found ACPI_DMAR_DRHD:\n"); ret =3D acpi_parse_one_drhd(entry_header); break; - case ACPI_DMAR_RMRR: + case ACPI_DMAR_TYPE_RESERVED_MEMORY: if ( iommu_verbose ) dprintk(VTDPREFIX, "found ACPI_DMAR_RMRR:\n"); ret =3D acpi_parse_one_rmrr(entry_header); break; - case ACPI_DMAR_ATSR: + case ACPI_DMAR_TYPE_ATSR: if ( iommu_verbose ) dprintk(VTDPREFIX, "found ACPI_DMAR_ATSR:\n"); ret =3D acpi_parse_one_atsr(entry_header); break; - case ACPI_DMAR_RHSA: + case ACPI_DMAR_HARDWARE_AFFINITY: if ( iommu_verbose ) dprintk(VTDPREFIX, "found ACPI_DMAR_RHSA:\n"); ret =3D acpi_parse_one_rhsa(entry_header); @@ -803,21 +808,19 @@ void acpi_dmar_zap(void) =20 int platform_supports_intremap(void) { - unsigned int flags =3D 0; + unsigned int mask =3D ACPI_DMAR_INTR_REMAP; =20 - flags =3D DMAR_INTR_REMAP; - return ((dmar_flags & flags) =3D=3D DMAR_INTR_REMAP); + return (dmar_flags & mask) =3D=3D ACPI_DMAR_INTR_REMAP; } =20 #ifdef CONFIG_X86 int platform_supports_x2apic(void) { - unsigned int flags =3D 0; + unsigned int mask =3D ACPI_DMAR_INTR_REMAP | ACPI_DMAR_X2APIC_OPT_OUT;= =20 if (!cpu_has_x2apic) return 0; =20 - flags =3D DMAR_INTR_REMAP | DMAR_X2APIC_OPT_OUT; - return ((dmar_flags & flags) =3D=3D DMAR_INTR_REMAP); + return (dmar_flags & mask) =3D=3D ACPI_DMAR_INTR_REMAP; } #endif --- a/xen/drivers/passthrough/vtd/iommu.h +++ b/xen/drivers/passthrough/vtd/iommu.h @@ -22,10 +22,6 @@ =20 #include =20 -/* DMAR Flags bits */ -#define DMAR_INTR_REMAP 0x1 -#define DMAR_X2APIC_OPT_OUT 0x2 - /* * Intel IOMMU register specification per version 1.0 public spec. */ --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -49,75 +49,6 @@ enum acpi_interrupt_id { ACPI_INTERRUPT_COUNT }; =20 -/* DMA Remapping Reporting Table (DMAR) */ - -#define DMAR_FLAGS_INTR_REMAP 0x1 /* intr remap supported */ - -struct acpi_dmar_entry_header { - u16 type; - u16 length; -} __attribute__((packed)); - -enum acpi_dmar_entry_type { - ACPI_DMAR_DRHD =3D 0, - ACPI_DMAR_RMRR, - ACPI_DMAR_ATSR, - ACPI_DMAR_RHSA, - ACPI_DMAR_ENTRY_COUNT -}; - -#define DRHD_FLAGS_INCLUDE_ALL 0x1 /* drhd remaps remaining devices = */ -struct acpi_table_drhd { - struct acpi_dmar_entry_header header; - u8 flags; - u8 reserved; - u16 segment; - u64 address; /* register base address for this drhd */ -} __attribute__ ((packed)); - -struct acpi_table_rmrr { - struct acpi_dmar_entry_header header; - u16 reserved; - u16 segment; - u64 base_address; - u64 end_address; -} __attribute__ ((packed)); - -struct acpi_table_atsr { - struct acpi_dmar_entry_header header; - u8 flags; - u8 reserved; - u16 segment; -} __attribute__ ((packed)); - -struct acpi_table_rhsa { - struct acpi_dmar_entry_header header; - u32 reserved; - u64 address; /* register base address for this drhd */ - u32 proximity_domain; -} __attribute__ ((packed)); - -enum acpi_dev_scope_type { - ACPI_DEV_ENDPOINT=3D0x01, /* PCI Endpoing device */ - ACPI_DEV_P2PBRIDGE, /* PCI-PCI Bridge */ - ACPI_DEV_IOAPIC, /* IOAPIC device*/ - ACPI_DEV_MSI_HPET, /* MSI capable HPET*/ - ACPI_DEV_ENTRY_COUNT -}; - -struct acpi_dev_scope { - u8 dev_type; - u8 length; - u8 reserved[2]; - u8 enum_id; - u8 start_bus; -} __attribute__((packed)); - -struct acpi_pci_path { - u8 dev; - u8 fn; -} __attribute__((packed)); - typedef int (*acpi_madt_entry_handler) (struct acpi_subtable_header = *header, const unsigned long end); =20 typedef int (*acpi_table_handler) (struct acpi_table_header *table); --=__Part7857DD9F.1__= Content-Type: text/plain; name="acpi-duplicate-dmar-structs.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="acpi-duplicate-dmar-structs.patch" ACPI: eliminate duplicate DMAR definitions=0A=0AUse their proper counterpar= ts in include/acpi/actbl*.h instead.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/drivers/passthrough/vtd/dmar.c=0A+++ = b/xen/drivers/passthrough/vtd/dmar.c=0A@@ -38,8 +38,8 @@=0A #define PREFIX = VTDPREFIX "ACPI DMAR:"=0A #define DEBUG=0A =0A-#define MIN_SCOPE_LEN = (sizeof(struct acpi_pci_path) + \=0A- sizeof(struct = acpi_dev_scope))=0A+#define MIN_SCOPE_LEN (sizeof(struct acpi_dmar_device_s= cope) + \=0A+ sizeof(struct acpi_dmar_pci_path))=0A = =0A LIST_HEAD_READ_MOSTLY(acpi_drhd_units);=0A LIST_HEAD_READ_MOSTLY(acpi_r= mrr_units);=0A@@ -247,25 +247,25 @@ int is_igd_drhd(struct acpi_drhd_unit = *d=0A * Count number of devices in device scope. Do not include PCI = sub=0A * hierarchies.=0A */=0A-static int scope_device_count(void = *start, void *end)=0A+static int __init scope_device_count(const void = *start, const void *end)=0A {=0A- struct acpi_dev_scope *scope;=0A+ = const struct acpi_dmar_device_scope *scope;=0A int count =3D 0;=0A =0A = while ( start < end )=0A {=0A scope =3D start;=0A = if ( (scope->length < MIN_SCOPE_LEN) ||=0A- (scope->dev_type = >=3D ACPI_DEV_ENTRY_COUNT) )=0A+ (scope->entry_type >=3D = ACPI_DMAR_SCOPE_TYPE_RESERVED) )=0A {=0A dprintk(XENLOG= _WARNING VTDPREFIX, "Invalid device scope.\n");=0A return = -EINVAL;=0A }=0A =0A- if ( scope->dev_type =3D=3D ACPI_DEV_P= 2PBRIDGE ||=0A- scope->dev_type =3D=3D ACPI_DEV_ENDPOINT = ||=0A- scope->dev_type =3D=3D ACPI_DEV_IOAPIC ||=0A- = scope->dev_type =3D=3D ACPI_DEV_MSI_HPET )=0A+ if ( scope->entry_t= ype =3D=3D ACPI_DMAR_SCOPE_TYPE_BRIDGE ||=0A+ scope->entry_type= =3D=3D ACPI_DMAR_SCOPE_TYPE_ENDPOINT ||=0A+ scope->entry_type = =3D=3D ACPI_DMAR_SCOPE_TYPE_IOAPIC ||=0A+ scope->entry_type = =3D=3D ACPI_DMAR_SCOPE_TYPE_HPET )=0A count++;=0A =0A = start +=3D scope->length;=0A@@ -276,13 +276,13 @@ static int scope_device_c= ount(void *star=0A =0A =0A static int __init acpi_parse_dev_scope(=0A- = void *start, void *end, void *acpi_entry, int type, u16 seg)=0A+ const = void *start, const void *end, void *acpi_entry, int type, u16 seg)=0A {=0A = struct dmar_scope *scope =3D acpi_entry;=0A struct acpi_ioapic_unit= *acpi_ioapic_unit;=0A- struct acpi_dev_scope *acpi_scope;=0A+ const = struct acpi_dmar_device_scope *acpi_scope;=0A u16 bus, sub_bus, = sec_bus;=0A- struct acpi_pci_path *path;=0A+ const struct acpi_dmar_p= ci_path *path;=0A int depth, cnt, didx =3D 0;=0A =0A if ( (cnt =3D = scope_device_count(start, end)) < 0 )=0A@@ -299,10 +299,9 @@ static int = __init acpi_parse_dev_scope(=0A while ( start < end )=0A {=0A = acpi_scope =3D start;=0A- path =3D (struct acpi_pci_path = *)(acpi_scope + 1);=0A- depth =3D (acpi_scope->length - sizeof(struc= t acpi_dev_scope))=0A- / sizeof(struct acpi_pci_path);=0A- = bus =3D acpi_scope->start_bus;=0A+ path =3D (const void = *)(acpi_scope + 1);=0A+ depth =3D (acpi_scope->length - sizeof(*acpi= _scope)) / sizeof(*path);=0A+ bus =3D acpi_scope->bus;=0A =0A = while ( --depth > 0 )=0A {=0A@@ -311,9 +310,9 @@ static int = __init acpi_parse_dev_scope(=0A path++;=0A }=0A =0A- = switch ( acpi_scope->dev_type )=0A+ switch ( acpi_scope->entry_= type )=0A {=0A- case ACPI_DEV_P2PBRIDGE:=0A+ case = ACPI_DMAR_SCOPE_TYPE_BRIDGE:=0A sec_bus =3D pci_conf_read8(seg,= bus, path->dev, path->fn,=0A = PCI_SECONDARY_BUS);=0A sub_bus =3D pci_conf_read8(seg, bus, = path->dev, path->fn,=0A@@ -322,18 +321,18 @@ static int __init acpi_parse_d= ev_scope(=0A dprintk(VTDPREFIX,=0A = " bridge: %04x:%02x:%02x.%u start=3D%x sec=3D%x sub=3D%x\n",=0A = seg, bus, path->dev, path->fn,=0A- = acpi_scope->start_bus, sec_bus, sub_bus);=0A+ = acpi_scope->bus, sec_bus, sub_bus);=0A =0A dmar_scope_add_buses= (scope, sec_bus, sub_bus);=0A break;=0A =0A- case = ACPI_DEV_MSI_HPET:=0A+ case ACPI_DMAR_SCOPE_TYPE_HPET:=0A = if ( iommu_verbose )=0A dprintk(VTDPREFIX, " MSI HPET: = %04x:%02x:%02x.%u\n",=0A seg, bus, path->dev, = path->fn);=0A break;=0A =0A- case ACPI_DEV_ENDPOINT:=0A+= case ACPI_DMAR_SCOPE_TYPE_ENDPOINT:=0A if ( iommu_verbo= se )=0A dprintk(VTDPREFIX, " endpoint: %04x:%02x:%02x.%u\n"= ,=0A seg, bus, path->dev, path->fn);=0A@@ -349,7 = +348,7 @@ static int __init acpi_parse_dev_scope(=0A =0A = break;=0A =0A- case ACPI_DEV_IOAPIC:=0A+ case ACPI_DMAR_SCOPE= _TYPE_IOAPIC:=0A if ( iommu_verbose )=0A = dprintk(VTDPREFIX, " IOAPIC: %04x:%02x:%02x.%u\n",=0A = seg, bus, path->dev, path->fn);=0A@@ -360,7 +359,7 @@ static int __init = acpi_parse_dev_scope(=0A acpi_ioapic_unit =3D xmalloc(struc= t acpi_ioapic_unit);=0A if ( !acpi_ioapic_unit )=0A = return -ENOMEM;=0A- acpi_ioapic_unit->apic_id = =3D acpi_scope->enum_id;=0A+ acpi_ioapic_unit->apic_id =3D = acpi_scope->enumeration_id;=0A acpi_ioapic_unit->ioapic.bdf= .bus =3D bus;=0A acpi_ioapic_unit->ioapic.bdf.dev =3D = path->dev;=0A acpi_ioapic_unit->ioapic.bdf.func =3D = path->fn;=0A@@ -377,7 +376,7 @@ static int __init acpi_parse_dev_scope(=0A = }=0A =0A static int __init acpi_dmar_check_length(=0A- struct acpi_dmar_= entry_header *h, unsigned int min_len)=0A+ const struct acpi_dmar_header= *h, unsigned int min_len)=0A {=0A if ( h->length >=3D min_len )=0A = return 0;=0A@@ -388,9 +387,10 @@ static int __init acpi_dmar_check_len= gth=0A }=0A =0A static int __init=0A-acpi_parse_one_drhd(struct acpi_dmar_e= ntry_header *header)=0A+acpi_parse_one_drhd(struct acpi_dmar_header = *header)=0A {=0A- struct acpi_table_drhd * drhd =3D (struct acpi_table_d= rhd *)header;=0A+ struct acpi_dmar_hardware_unit *drhd =3D=0A+ = container_of(header, struct acpi_dmar_hardware_unit, header);=0A void = *dev_scope_start, *dev_scope_end;=0A struct acpi_drhd_unit *dmaru;=0A = int ret;=0A@@ -405,7 +405,7 @@ acpi_parse_one_drhd(struct acpi_dmar_ent= =0A =0A dmaru->address =3D drhd->address;=0A dmaru->segment =3D = drhd->segment;=0A- dmaru->include_all =3D drhd->flags & 1; /* BIT0: = INCLUDE_ALL */=0A+ dmaru->include_all =3D drhd->flags & ACPI_DMAR_INCLUD= E_ALL;=0A INIT_LIST_HEAD(&dmaru->ioapic_list);=0A if ( iommu_verbos= e )=0A dprintk(VTDPREFIX, " dmaru->address =3D %"PRIx64"\n",=0A@@ = -443,17 +443,20 @@ acpi_parse_one_drhd(struct acpi_dmar_ent=0A {=0A = u8 b, d, f;=0A unsigned int i =3D 0, invalid_cnt =3D 0;=0A- = void *p;=0A+ union {=0A+ const void *raw;=0A+ = const struct acpi_dmar_device_scope *scope;=0A+ } p;=0A =0A = /* Skip checking if segment is not accessible yet. */=0A if ( = !pci_known_segment(drhd->segment) )=0A i =3D UINT_MAX;=0A =0A- = for ( p =3D dev_scope_start; i < dmaru->scope.devices_cnt;=0A- = i++, p +=3D ((struct acpi_dev_scope *)p)->length )=0A+ for = ( p.raw =3D dev_scope_start; i < dmaru->scope.devices_cnt;=0A+ = i++, p.raw +=3D p.scope->length )=0A {=0A- if ( = ((struct acpi_dev_scope *)p)->dev_type =3D=3D ACPI_DEV_IOAPIC ||=0A- = ((struct acpi_dev_scope *)p)->dev_type =3D=3D ACPI_DEV_MSI_HPET = )=0A+ if ( p.scope->entry_type =3D=3D ACPI_DMAR_SCOPE_TYPE_IOAPI= C ||=0A+ p.scope->entry_type =3D=3D ACPI_DMAR_SCOPE_TYPE_HP= ET )=0A continue;=0A =0A b =3D PCI_BUS(dmaru->s= cope.devices[i]);=0A@@ -505,9 +508,10 @@ out:=0A }=0A =0A static int = __init=0A-acpi_parse_one_rmrr(struct acpi_dmar_entry_header *header)=0A+acp= i_parse_one_rmrr(struct acpi_dmar_header *header)=0A {=0A- struct = acpi_table_rmrr *rmrr =3D (struct acpi_table_rmrr *)header;=0A+ struct = acpi_dmar_reserved_memory *rmrr =3D=0A+ container_of(header, struct = acpi_dmar_reserved_memory, header);=0A struct acpi_rmrr_unit *rmrru;=0A= void *dev_scope_start, *dev_scope_end;=0A u64 base_addr =3D = rmrr->base_address, end_addr =3D rmrr->end_address;=0A@@ -610,9 +614,10 @@ = acpi_parse_one_rmrr(struct acpi_dmar_ent=0A }=0A =0A static int __init=0A-a= cpi_parse_one_atsr(struct acpi_dmar_entry_header *header)=0A+acpi_parse_one= _atsr(struct acpi_dmar_header *header)=0A {=0A- struct acpi_table_atsr = *atsr =3D (struct acpi_table_atsr *)header;=0A+ struct acpi_dmar_atsr = *atsr =3D=0A+ container_of(header, struct acpi_dmar_atsr, = header);=0A struct acpi_atsr_unit *atsru;=0A int ret;=0A = static int all_ports;=0A@@ -626,7 +631,7 @@ acpi_parse_one_atsr(struct = acpi_dmar_ent=0A return -ENOMEM;=0A =0A atsru->segment =3D = atsr->segment;=0A- atsru->all_ports =3D atsr->flags & 1; /* BIT0: = ALL_PORTS */=0A+ atsru->all_ports =3D atsr->flags & ACPI_DMAR_ALL_PORTS;= =0A if ( iommu_verbose )=0A dprintk(VTDPREFIX,=0A = " atsru->all_ports: %x\n", atsru->all_ports);=0A@@ -660,9 +665,10 @@ = acpi_parse_one_atsr(struct acpi_dmar_ent=0A }=0A =0A static int __init=0A-a= cpi_parse_one_rhsa(struct acpi_dmar_entry_header *header)=0A+acpi_parse_one= _rhsa(struct acpi_dmar_header *header)=0A {=0A- struct acpi_table_rhsa = *rhsa =3D (struct acpi_table_rhsa *)header;=0A+ struct acpi_dmar_rhsa = *rhsa =3D=0A+ container_of(header, struct acpi_dmar_rhsa, = header);=0A struct acpi_rhsa_unit *rhsau;=0A int ret;=0A =0A@@ = -673,7 +679,7 @@ acpi_parse_one_rhsa(struct acpi_dmar_ent=0A if ( = !rhsau )=0A return -ENOMEM;=0A =0A- rhsau->address =3D = rhsa->address;=0A+ rhsau->address =3D rhsa->base_address;=0A = rhsau->proximity_domain =3D rhsa->proximity_domain;=0A list_add_tail(&r= hsau->list, &acpi_rhsa_units);=0A if ( iommu_verbose )=0A@@ -688,7 = +694,7 @@ acpi_parse_one_rhsa(struct acpi_dmar_ent=0A static int __init = acpi_parse_dmar(struct acpi_table_header *table)=0A {=0A struct = acpi_table_dmar *dmar;=0A- struct acpi_dmar_entry_header *entry_header;= =0A+ struct acpi_dmar_header *entry_header;=0A u8 dmar_host_address_= width;=0A int ret =3D 0;=0A =0A@@ -713,33 +719,32 @@ static int __init = acpi_parse_dmar(struct=0A dprintk(VTDPREFIX, "Host address width = %d\n",=0A dmar_host_address_width);=0A =0A- entry_header= =3D (struct acpi_dmar_entry_header *)(dmar + 1);=0A+ entry_header =3D = (void *)(dmar + 1);=0A while ( ((unsigned long)entry_header) <=0A = (((unsigned long)dmar) + table->length) )=0A {=0A- ret = =3D acpi_dmar_check_length(=0A- entry_header, sizeof(struct = acpi_dmar_entry_header));=0A+ ret =3D acpi_dmar_check_length(entry_h= eader, sizeof(*entry_header));=0A if ( ret )=0A = break;=0A =0A switch ( entry_header->type )=0A {=0A- = case ACPI_DMAR_DRHD:=0A+ case ACPI_DMAR_TYPE_HARDWARE_UNIT:=0A = if ( iommu_verbose )=0A dprintk(VTDPREFIX, "found = ACPI_DMAR_DRHD:\n");=0A ret =3D acpi_parse_one_drhd(entry_heade= r);=0A break;=0A- case ACPI_DMAR_RMRR:=0A+ case = ACPI_DMAR_TYPE_RESERVED_MEMORY:=0A if ( iommu_verbose )=0A = dprintk(VTDPREFIX, "found ACPI_DMAR_RMRR:\n");=0A = ret =3D acpi_parse_one_rmrr(entry_header);=0A break;=0A- = case ACPI_DMAR_ATSR:=0A+ case ACPI_DMAR_TYPE_ATSR:=0A = if ( iommu_verbose )=0A dprintk(VTDPREFIX, "found = ACPI_DMAR_ATSR:\n");=0A ret =3D acpi_parse_one_atsr(entry_heade= r);=0A break;=0A- case ACPI_DMAR_RHSA:=0A+ case = ACPI_DMAR_HARDWARE_AFFINITY:=0A if ( iommu_verbose )=0A = dprintk(VTDPREFIX, "found ACPI_DMAR_RHSA:\n");=0A ret = =3D acpi_parse_one_rhsa(entry_header);=0A@@ -803,21 +808,19 @@ void = acpi_dmar_zap(void)=0A =0A int platform_supports_intremap(void)=0A {=0A- = unsigned int flags =3D 0;=0A+ unsigned int mask =3D ACPI_DMAR_INTR_REMA= P;=0A =0A- flags =3D DMAR_INTR_REMAP;=0A- return ((dmar_flags & = flags) =3D=3D DMAR_INTR_REMAP);=0A+ return (dmar_flags & mask) =3D=3D = ACPI_DMAR_INTR_REMAP;=0A }=0A =0A #ifdef CONFIG_X86=0A int platform_support= s_x2apic(void)=0A {=0A- unsigned int flags =3D 0;=0A+ unsigned int = mask =3D ACPI_DMAR_INTR_REMAP | ACPI_DMAR_X2APIC_OPT_OUT;=0A =0A if = (!cpu_has_x2apic)=0A return 0;=0A =0A- flags =3D DMAR_INTR_REMAP= | DMAR_X2APIC_OPT_OUT;=0A- return ((dmar_flags & flags) =3D=3D = DMAR_INTR_REMAP);=0A+ return (dmar_flags & mask) =3D=3D ACPI_DMAR_INTR_R= EMAP;=0A }=0A #endif=0A--- a/xen/drivers/passthrough/vtd/iommu.h=0A+++ = b/xen/drivers/passthrough/vtd/iommu.h=0A@@ -22,10 +22,6 @@=0A =0A #include = =0A =0A-/* DMAR Flags bits */=0A-#define DMAR_INTR_REMAP = 0x1=0A-#define DMAR_X2APIC_OPT_OUT 0x2=0A-=0A /*=0A * Intel IOMMU = register specification per version 1.0 public spec.=0A */=0A--- a/xen/incl= ude/xen/acpi.h=0A+++ b/xen/include/xen/acpi.h=0A@@ -49,75 +49,6 @@ enum = acpi_interrupt_id {=0A ACPI_INTERRUPT_COUNT=0A };=0A =0A-/* DMA Remapping = Reporting Table (DMAR) */=0A-=0A-#define DMAR_FLAGS_INTR_REMAP 0x1 = /* intr remap supported */=0A-=0A-struct acpi_dmar_entry_header {=0A- = u16 type;=0A- u16 length;=0A-} __attribute__((packed));=0A-= =0A-enum acpi_dmar_entry_type {=0A- ACPI_DMAR_DRHD =3D 0,=0A- = ACPI_DMAR_RMRR,=0A- ACPI_DMAR_ATSR,=0A- ACPI_DMAR_RHSA,=0A- = ACPI_DMAR_ENTRY_COUNT=0A-};=0A-=0A-#define DRHD_FLAGS_INCLUDE_ALL = 0x1 /* drhd remaps remaining devices */=0A-struct acpi_table_drhd = {=0A- struct acpi_dmar_entry_header header;=0A- u8 flags;=0A- = u8 reserved;=0A- u16 segment;=0A- u64 address; /* = register base address for this drhd */=0A-} __attribute__ ((packed));=0A-= =0A-struct acpi_table_rmrr {=0A- struct acpi_dmar_entry_header = header;=0A- u16 reserved;=0A- u16 segment;=0A- u64 = base_address;=0A- u64 end_address;=0A-} __attribute__ ((packed));= =0A-=0A-struct acpi_table_atsr {=0A- struct acpi_dmar_entry_header = header;=0A- u8 flags;=0A- u8 reserved;=0A- u16 = segment;=0A-} __attribute__ ((packed));=0A-=0A-struct acpi_table_rhsa = {=0A- struct acpi_dmar_entry_header header;=0A- u32 = reserved;=0A- u64 address; /* register base address for this drhd = */=0A- u32 proximity_domain;=0A-} __attribute__ ((packed));=0A-=0A-enu= m acpi_dev_scope_type {=0A- ACPI_DEV_ENDPOINT=3D0x01, /* PCI = Endpoing device */=0A- ACPI_DEV_P2PBRIDGE, /* PCI-PCI Bridge */=0A- = ACPI_DEV_IOAPIC, /* IOAPIC device*/=0A- ACPI_DEV_MSI_HPET, /* = MSI capable HPET*/=0A- ACPI_DEV_ENTRY_COUNT=0A-};=0A-=0A-struct acpi_dev_s= cope {=0A- u8 dev_type;=0A- u8 length;=0A- u8 = reserved[2];=0A- u8 enum_id;=0A- u8 start_bus;=0A-} = __attribute__((packed));=0A-=0A-struct acpi_pci_path {=0A- u8 = dev;=0A- u8 fn;=0A-} __attribute__((packed));=0A-=0A typedef = int (*acpi_madt_entry_handler) (struct acpi_subtable_header *header, const = unsigned long end);=0A =0A typedef int (*acpi_table_handler) (struct = acpi_table_header *table);=0A --=__Part7857DD9F.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__Part7857DD9F.1__=--