All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/guc: Document that the ads blob entries only lie within the first page
@ 2017-03-16 10:55 Chris Wilson
  2017-03-16 10:58 ` Chris Wilson
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Chris Wilson @ 2017-03-16 10:55 UTC (permalink / raw)
  To: intel-gfx

guc_addon_create() makes the assumption that it need only kmap the
initial page in order to write all of the configuration data used by the
guc. Confusingly it also allocates many scratch pages in the same vma
and passes that to the guc. Reassure the reader that all is well with a
BUILD_BUG_ON() that we do not access outside of the kmapped page.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Oscar Mateo <oscar.mateo@intel.com>
Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 drivers/gpu/drm/i915/i915_guc_submission.c | 5 +++++
 drivers/gpu/drm/i915/i915_utils.h          | 1 +
 2 files changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
index 97726fcb1230..91d7ab0df0cd 100644
--- a/drivers/gpu/drm/i915/i915_guc_submission.c
+++ b/drivers/gpu/drm/i915/i915_guc_submission.c
@@ -888,13 +888,16 @@ static void guc_addon_create(struct intel_guc *guc)
 		guc->ads_vma = vma;
 	}
 
+	/* First members are assumed to be in a single page */
 	page = i915_vma_first_page(vma);
 	blob = kmap(page);
 
 	/* GuC scheduling policies */
+	BUILD_BUG_ON(ptr_offset_end(blob, policies) > PAGE_SIZE);
 	guc_policies_init(&blob->policies);
 
 	/* MMIO reg state */
+	BUILD_BUG_ON(ptr_offset_end(blob, reg_state) > PAGE_SIZE);
 	for_each_engine(engine, dev_priv, id) {
 		blob->reg_state.mmio_white_list[engine->guc_id].mmio_start =
 			engine->mmio_base + GUC_MMIO_WHITE_LIST_START;
@@ -903,6 +906,8 @@ static void guc_addon_create(struct intel_guc *guc)
 		blob->reg_state.mmio_white_list[engine->guc_id].count = 0;
 	}
 
+	BUILD_BUG_ON(ptr_offset_end(blob, reg_state) > PAGE_SIZE);
+
 	/*
 	 * The GuC requires a "Golden Context" when it reinitialises
 	 * engines after a reset. Here we use the Render ring default
diff --git a/drivers/gpu/drm/i915/i915_utils.h b/drivers/gpu/drm/i915/i915_utils.h
index 94a3a3299910..2976bf9d94b4 100644
--- a/drivers/gpu/drm/i915/i915_utils.h
+++ b/drivers/gpu/drm/i915/i915_utils.h
@@ -67,6 +67,7 @@
 	((typeof(ptr))((unsigned long)(ptr) | (bits)))
 
 #define ptr_offset(ptr, member) offsetof(typeof(*(ptr)), member)
+#define ptr_offset_end(ptr, member) offsetofend(typeof(*(ptr)), member)
 
 #define fetch_and_zero(ptr) ({						\
 	typeof(*ptr) __T = *(ptr);					\
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-03-16 14:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-16 10:55 [PATCH] drm/i915/guc: Document that the ads blob entries only lie within the first page Chris Wilson
2017-03-16 10:58 ` Chris Wilson
2017-03-16 11:06   ` Michal Wajdeczko
2017-03-16 11:18     ` Chris Wilson
2017-03-16 11:25       ` Michal Wajdeczko
2017-03-16 11:41 ` [PATCH v2] " Chris Wilson
2017-03-16 12:31   ` Michal Wajdeczko
2017-03-16 14:28     ` Joonas Lahtinen
2017-03-16 11:42 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-03-16 11:59 ` ✗ Fi.CI.BAT: failure for drm/i915/guc: Document that the ads blob entries only lie within the first page (rev2) Patchwork

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.