From: Wan Zongshun <vincent.wan-5C7GfCeVMHo@public.gmane.org>
To: Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Ray Huang <ray.huang-5C7GfCeVMHo@public.gmane.org>,
Borislav Petkov <bp-l3A5Bk7waGM@public.gmane.org>
Subject: [PATCH V3 2/9] iommu/amd: Modify ivhd_header structure to support type 11h and 40h
Date: Fri, 1 Apr 2016 09:05:58 -0400 [thread overview]
Message-ID: <1459515965-2865-3-git-send-email-vincent.wan@amd.com> (raw)
In-Reply-To: <1459515965-2865-1-git-send-email-vincent.wan-5C7GfCeVMHo@public.gmane.org>
From: Suravee Suthikulpanit <Suravee.Suthikulpanit-5C7GfCeVMHo@public.gmane.org>
This patch modifies the existing struct ivhd_header,
which currently only support IVHD type 0x10, to add
new fields from IVHD type 11h and 40h.
It also modifies the pointer calculation to allow
support for IVHD type 11h and 40h
Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit-5C7GfCeVMHo@public.gmane.org>
---
drivers/iommu/amd_iommu_init.c | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index dff1e01..22e078b 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -398,6 +398,22 @@ static void __init iommu_unmap_mmio_space(struct amd_iommu *iommu)
release_mem_region(iommu->mmio_phys, iommu->mmio_phys_end);
}
+static inline u32 get_ivhd_header_size(struct ivhd_header *h)
+{
+ u32 size = 0;
+
+ switch (h->type) {
+ case 0x10:
+ size = 24;
+ break;
+ case 0x11:
+ case 0x40:
+ size = 40;
+ break;
+ }
+ return size;
+}
+
/****************************************************************************
*
* The functions below belong to the first pass of AMD IOMMU ACPI table
@@ -424,7 +440,14 @@ static int __init find_last_devid_from_ivhd(struct ivhd_header *h)
u8 *p = (void *)h, *end = (void *)h;
struct ivhd_entry *dev;
- p += sizeof(*h);
+ u32 ivhd_size = get_ivhd_header_size(h);
+
+ if (!ivhd_size) {
+ pr_err("AMD-Vi: Unsupported IVHD type %#x\n", h->type);
+ return -EINVAL;
+ }
+
+ p += ivhd_size;
end += h->length;
while (p < end) {
@@ -789,6 +812,7 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
u32 dev_i, ext_flags = 0;
bool alias = false;
struct ivhd_entry *e;
+ u32 ivhd_size;
int ret;
@@ -804,7 +828,14 @@ static int __init init_iommu_from_acpi(struct amd_iommu *iommu,
/*
* Done. Now parse the device entries
*/
- p += sizeof(struct ivhd_header);
+ ivhd_size = get_ivhd_header_size(h);
+ if (!ivhd_size) {
+ pr_err("AMD-Vi: Unsupported IVHD type %#x\n", h->type);
+ return -EINVAL;
+ }
+
+ p += ivhd_size;
+
end += h->length;
--
1.9.1
next prev parent reply other threads:[~2016-04-01 13:05 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-01 13:05 [PATCH V3 0/9] iommu/amd: enable ACPI hardware ID device support Wan Zongshun
2016-04-01 13:05 ` [PATCH V3 3/9] iommu/amd: Use the most comprehensive IVHD type that the driver can support Wan Zongshun
[not found] ` <1459515965-2865-1-git-send-email-vincent.wan-5C7GfCeVMHo@public.gmane.org>
2016-04-01 13:05 ` [PATCH V3 1/9] iommu/amd: Adding Extended Feature Register check for PC support Wan Zongshun
2016-04-01 13:05 ` Wan Zongshun [this message]
2016-04-01 13:06 ` [PATCH V3 4/9] iommu/amd: Add new map for storing IVHD dev entry type HID Wan Zongshun
2016-04-01 13:06 ` [PATCH V3 5/9] iommu/amd: Introduces ivrs_acpihid kernel parameter Wan Zongshun
2016-04-01 13:06 ` [PATCH V3 6/9] iommu/amd: Make call-sites of get_device_id aware of its return value Wan Zongshun
2016-04-01 13:06 ` [PATCH V3 7/9] iommu/amd: Add iommu support for ACPI HID devices Wan Zongshun
2016-04-01 13:06 ` [PATCH V3 8/9] iommu/amd: Manage iommu_group " Wan Zongshun
2016-04-01 13:06 ` [PATCH V3 9/9] iommu/amd: Set AMD iommu callbacks for amba bus Wan Zongshun
2016-04-07 11:30 ` [PATCH V3 0/9] iommu/amd: enable ACPI hardware ID device support Joerg Roedel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1459515965-2865-3-git-send-email-vincent.wan@amd.com \
--to=vincent.wan-5c7gfcevmho@public.gmane.org \
--cc=bp-l3A5Bk7waGM@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ray.huang-5C7GfCeVMHo@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox