#include <linux/intel_vsec.h>
#include <linux/kernel.h>
#include <linux/module.h>
+#include <linux/overflow.h>
#include <linux/pci.h>
+#include <linux/string.h>
#include <linux/types.h>
#define PMT_XA_START 0
ida_free(intel_vsec_dev->ida, intel_vsec_dev->auxdev.id);
+ kfree(intel_vsec_dev->acpi_disc);
kfree(intel_vsec_dev->resource);
kfree(intel_vsec_dev);
}
* auxiliary device driver.
*/
for (i = 0, tmp = res; i < header->num_entries; i++, tmp++) {
+ /*
+ * Skip resource mapping check for ACPI-based discovery
+ * since those tables are read from _DSD, not MMIO.
+ */
+ if (info->src == INTEL_VSEC_DISC_ACPI)
+ break;
+
tmp->start = base_addr + header->offset + i * (header->entry_size * sizeof(u32));
tmp->end = tmp->start + (header->entry_size * sizeof(u32)) - 1;
tmp->flags = IORESOURCE_MEM;
intel_vsec_dev->base_addr = info->base_addr;
intel_vsec_dev->priv_data = info->priv_data;
intel_vsec_dev->cap_id = cap_id;
+ intel_vsec_dev->src = info->src;
+
+ if (info->src == INTEL_VSEC_DISC_ACPI) {
+ size_t bytes;
+
+ if (check_mul_overflow(intel_vsec_dev->num_resources,
+ sizeof(*info->acpi_disc), &bytes))
+ return -EOVERFLOW;
+
+ intel_vsec_dev->acpi_disc = kmemdup(info->acpi_disc, bytes, GFP_KERNEL);
+ if (!intel_vsec_dev->acpi_disc)
+ return -ENOMEM;
+ }
if (header->id == VSEC_ID_SDSI)
intel_vsec_dev->ida = &intel_vsec_sdsi_ida;
struct pci_dev;
struct resource;
+enum intel_vsec_disc_source {
+ INTEL_VSEC_DISC_PCI, /* PCI, default */
+ INTEL_VSEC_DISC_ACPI, /* ACPI */
+};
+
enum intel_vsec_id {
VSEC_ID_TELEMETRY = 2,
VSEC_ID_WATCHER = 3,
* @parent: parent device in the auxbus chain
* @headers: list of headers to define the PMT client devices to create
* @deps: array of feature dependencies
+ * @acpi_disc: ACPI discovery tables, each entry is two QWORDs
+ * in little-endian format as defined by the PMT ACPI spec.
+ * Valid only when @provider == INTEL_VSEC_DISC_ACPI.
+ * @src: source of discovery table data
* @priv_data: private data, usable by parent devices, currently a callback
* @caps: bitmask of PMT capabilities for the given headers
* @quirks: bitmask of VSEC device quirks
struct device *parent;
struct intel_vsec_header **headers;
const struct vsec_feature_dependency *deps;
+ u32 (*acpi_disc)[4];
+ enum intel_vsec_disc_source src;
void *priv_data;
unsigned long caps;
unsigned long quirks;
* struct intel_vsec_device - Auxbus specific device information
* @auxdev: auxbus device struct for auxbus access
* @dev: struct device associated with the device
- * @resource: any resources shared by the parent
+ * @resource: PCI discovery resources (BAR windows), one per discovery
+ * instance. Valid only when @src == INTEL_VSEC_DISC_PCI
+ * @acpi_disc: ACPI discovery tables, each entry is two QWORDs
+ * in little-endian format as defined by the PMT ACPI spec.
+ * Valid only when @src == INTEL_VSEC_DISC_ACPI.
+ * @src: source of discovery table data
* @ida: id reference
* @num_resources: number of resources
* @id: xarray id
struct auxiliary_device auxdev;
struct device *dev;
struct resource *resource;
+ u32 (*acpi_disc)[4];
+ enum intel_vsec_disc_source src;
struct ida *ida;
int num_resources;
int id; /* xa */