Skip to contentSkip to conversation

lib/intel_batchbuffer: Add secure batch buffer flushing on ring

PATCH In review Antonio Argenziano 2 participants 3 messages Feb 28, 2017 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 lib/intel_batchbuffer: Add secure batch buffer flushing on ring

Added functions for flushing a batch buffer as privileged.

---
 lib/intel_batchbuffer.c | 45 +++++++++++++++++++++++++++++++++++++++++----
 lib/intel_batchbuffer.h |  4 +++-
 2 files changed, 44 insertions(+), 5 deletions(-)
lib/intel_batchbuffer.c +41 -4
index f1353901..38ce3b69 100644
@@ -158,15 +158,35 @@ flush_on_ring_common(struct intel_batchbuffer *batch, int ring)
 }
 
 /**
- * intel_batchbuffer_flush_on_ring:
+ * intel_batchbuffer_flush_on_ring_secure:
  * @batch: batchbuffer object
  * @ring: execbuf ring flag
  *
  * Submits the batch for execution on @ring.
  */
 void
-intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int ring)
+intel_batchbuffer_flush_on_ring_secure(struct intel_batchbuffer *batch, int ring)
+{
+    int flags = 0;
+
+	flags |= ring;
+	flags |= I915_EXEC_SECURE;
+
+    intel_batchbuffer_flush_on_ring(batch, flags);
+
+}
+
+/**
+ * intel_batchbuffer_flush_on_ring:
+ * @batch: batchbuffer object
+ * @flags: execbuf ring flag, plus additional submission flags
+ *
+ * Submits the batch for execution on the engine set in @flags.
+ */
+void
+intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int flags)
 {
+    int ring = flags & I915_EXEC_RING_MASK;
 	unsigned int used = flush_on_ring_common(batch, ring);
 	drm_intel_context *ctx;
 
@@ -179,9 +199,10 @@ intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int ring)
 
 	/* XXX bad kernel API */
 	ctx = batch->ctx;
-	if (ring != I915_EXEC_RENDER)
+	if ((ring) != I915_EXEC_RENDER)
 		ctx = NULL;
-	do_or_die(drm_intel_gem_bo_context_exec(batch->bo, ctx, used, ring));
+
+	do_or_die(drm_intel_gem_bo_context_exec(batch->bo, ctx, used, flags));
 
 	intel_batchbuffer_reset(batch);
 }
@@ -224,6 +245,22 @@ intel_batchbuffer_flush_with_context(struct intel_batchbuffer *batch,
 }
 
 /**
+ * intel_batchbuffer_flush_secure:
+ * @batch: batchbuffer object
+ *
+ * Submits the batch, as a secure batch, for execution on the blitter engine,
+ * selecting the right ring depending upon the hardware platform.
+ */
+void
+intel_batchbuffer_flush_secure(struct intel_batchbuffer *batch)
+{
+	int ring = 0;
+	if (HAS_BLT_RING(batch->devid))
+		ring = I915_EXEC_BLT;
+	intel_batchbuffer_flush_on_ring_secure(batch, ring);
+}
+
+/**
  * intel_batchbuffer_flush:
  * @batch: batchbuffer object
  *
lib/intel_batchbuffer.h +3 -1
index 869747db..0ed2055a 100644
@@ -35,7 +35,9 @@ void intel_batchbuffer_free(struct intel_batchbuffer *batch);
 
 
 void intel_batchbuffer_flush(struct intel_batchbuffer *batch);
-void intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int ring);
+void intel_batchbuffer_flush_secure(struct intel_batchbuffer *batch);
+void intel_batchbuffer_flush_on_ring(struct intel_batchbuffer *batch, int flags);
+void intel_batchbuffer_flush_on_ring_secure(struct intel_batchbuffer *batch, int ring);
 void intel_batchbuffer_flush_with_context(struct intel_batchbuffer *batch,
 					  drm_intel_context *context);
 
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/2 tests/gem_bad_address: Fix store address

The test purpose is to write at an invalid GTT location. To do so, the store instruction used in the test has been updated to use the correct value and extra unneeded flags have been removed. The batch buffer is also sent as privileged now.

---
 tests/gem_bad_address.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
tests/gem_bad_address.c +10 -6
index a970dfa4..720ab24d 100644
@@ -38,22 +38,26 @@
 #include "drm.h"
 #include "intel_bufmgr.h"
 
+/*
+    The intent of this test is to try write an area of memory that is outside
+    the currently allowed boundary of the GTT. To do so it will use a batch
+    buffer that will run on Blitter engine as a privileged batch.
+*/
+
 static drm_intel_bufmgr *bufmgr;
 struct intel_batchbuffer *batch;
 
-#define BAD_GTT_DEST ((512*1024*1024)) /* past end of aperture */
-
 static void
 bad_store(void)
 {
 	BEGIN_BATCH(4, 0);
-	OUT_BATCH(MI_STORE_DWORD_IMM | MI_MEM_VIRTUAL | 1 << 21);
-	OUT_BATCH(0);
-	OUT_BATCH(BAD_GTT_DEST);
+	OUT_BATCH(MI_STORE_DWORD_IMM | MI_MEM_VIRTUAL );
+	OUT_BATCH(0); // lower part of the address (first 4 GByte = GTT size)
+	OUT_BATCH(0x1); //Higher part of the address (>GTT size)
 	OUT_BATCH(0xdeadbeef);
 	ADVANCE_BATCH();
 
-	intel_batchbuffer_flush(batch);
+	intel_batchbuffer_flush_secure(batch);
 }
 
 igt_simple_main
Signature · 6 lines
2.11.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Re: [PATCH i-g-t 2/2] tests/gem_bad_address: Fix store address

Quoted 4 lines · Antonio Argenziano

The test purpose is to write at an invalid GTT location. To do so, the store instruction used in the test has been updated to use the correct value and extra unneeded flags have been removed. The batch buffer is also sent as privileged now.

Delete it.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx