Skip to contentSkip to conversation

platform/x86/intel/pmt: Block mmap when callback is present

PATCH New Michael J. Ruhl 1 participant 1 message Sep 10

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86/intel/pmt: Block mmap when callback is present

With the introduction of the .read_telem() callback, control for access to a devices data area must be done by the callback owner.

This means that an area cannot be mmap-ed with the default PMT handler.

If the .read_telem() callback is present, do not support mmap.

Fixes 045a513040cc ("platform/x86/intel/pmt: Use PMT callbacks")
---
 drivers/platform/x86/intel/pmt/class.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/platform/x86/intel/pmt/class.c +8 -1
index d0ab8e33c62a..c25892a51180 100644
@@ -417,7 +417,14 @@ static int intel_pmt_dev_register(struct intel_pmt_entry *entry,
 	sysfs_bin_attr_init(&entry->pmt_bin_attr);
 	entry->pmt_bin_attr.attr.name = ns->name;
 	entry->pmt_bin_attr.attr.mode = 0440;
-	entry->pmt_bin_attr.mmap = intel_pmt_mmap;
+
+	/*
+	 * The read_telem callback controls access to the memory area. Block
+	 * usage if the read_telem callback is present.
+	 */
+	if (!(entry->cb && entry->cb->read_telem))
+		entry->pmt_bin_attr.mmap = intel_pmt_mmap;
+
 	entry->pmt_bin_attr.read = intel_pmt_read;
 	entry->pmt_bin_attr.size = entry->size;
 
Signature · 1 line
2.43.0