Skip to contentSkip to conversation

drm/i915: Add OACONTROL to the command parser register whitelist.

PATCH Superseded Kenneth Graunke 7 participants 26 messages Mar 26, 2014 – May 16, 2014

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

PATCH 1/1 drm/i915: Add OACONTROL to the command parser register whitelist.

Mesa needs to be able to write OACONTROL in order to expose the Observability Architecture's performance counters via OpenGL.

---
 drivers/gpu/drm/i915/i915_cmd_parser.c | 1 +
 drivers/gpu/drm/i915/i915_reg.h        | 2 ++
 2 files changed, 3 insertions(+)

This patch needs to go before

commit 6d42f94084b8c69813d7ecd0466c33fe561bf127
Author: Brad Volkin <[email protected]>
Date: Tue Feb 18 10:15:57 2014 -0800

drm/i915: Enable command parsing by default

in whatever branch gets submitted to Dave Airlie. Or, that commit needs to be reverted. Otherwise, every OpenGL program will abort. Examples of programs that abort include GNOME, KDE, Firefox, and glxgears.

drivers/gpu/drm/i915/i915_cmd_parser.c +1 -0
index bae7c2f..d4a50b9 100644
@@ -415,6 +415,7 @@ static const u32 gen7_render_regs[] = {
 	GEN7_SO_WRITE_OFFSET(1),
 	GEN7_SO_WRITE_OFFSET(2),
 	GEN7_SO_WRITE_OFFSET(3),
+	OACONTROL,
 };
 
 static const u32 gen7_blt_regs[] = {
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 9f9e2b7..0ebc20d 100644
@@ -427,6 +427,8 @@
 /* There are the 4 64-bit counter registers, one for each stream output */
 #define GEN7_SO_NUM_PRIMS_WRITTEN(n) (0x5200 + (n) * 8)
 
+#define OACONTROL 0x2360
+
 #define _GEN7_PIPEA_DE_LOAD_SL	0x70068
 #define _GEN7_PIPEB_DE_LOAD_SL	0x71068
 #define GEN7_PIPE_DE_LOAD_SL(pipe) _PIPE(pipe, \
Signature · 1 line
1.9.0
#1 lore raw
Quoted 4 lines · Kenneth Graunke

Mesa needs to be able to write OACONTROL in order to expose the Observability Architecture's performance counters via OpenGL.

Thanks a lot for quickly tracking this down. Now when we've talked about OA a little while ago we concluded that mesa should clear OACONTROL again before the batch ends to make sure that userspace can't unduly observe other processes. So I think it'd be worth to keep track of this with a flag (set when OACONTROL is != 0 and reset when the batch loads 0). Also we need to make sure that userspace sets the right OACONTROL modes (not the one which streams into a global gtt buffer essentially). So some additional work required.

I've added a FIXME comment to the code.

Brad, can you please look into this, including the corresponding i-g-t which tries to enable OA but doesn't disable it and one which tries to enable it in the continuous mode (which writes to gtt)? Ken's previous mails has the cmds mesa emits.

Thanks, Daniel

Quoted 49 lines
---
 drivers/gpu/drm/i915/i915_cmd_parser.c | 1 +
 drivers/gpu/drm/i915/i915_reg.h        | 2 ++
 2 files changed, 3 insertions(+)

This patch needs to go before

commit 6d42f94084b8c69813d7ecd0466c33fe561bf127
Author: Brad Volkin <[email protected]>
Date: Tue Feb 18 10:15:57 2014 -0800

drm/i915: Enable command parsing by default

in whatever branch gets submitted to Dave Airlie. Or, that commit needs to be reverted. Otherwise, every OpenGL program will abort. Examples of programs that abort include GNOME, KDE, Firefox, and glxgears.

drivers/gpu/drm/i915/i915_cmd_parser.c +1 -0
index bae7c2f..d4a50b9 100644
@@ -415,6 +415,7 @@ static const u32 gen7_render_regs[] = {
 	GEN7_SO_WRITE_OFFSET(1),
 	GEN7_SO_WRITE_OFFSET(2),
 	GEN7_SO_WRITE_OFFSET(3),
+	OACONTROL,
 };
 
 static const u32 gen7_blt_regs[] = {
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 9f9e2b7..0ebc20d 100644
@@ -427,6 +427,8 @@
 /* There are the 4 64-bit counter registers, one for each stream output */
 #define GEN7_SO_NUM_PRIMS_WRITTEN(n) (0x5200 + (n) * 8)
 
+#define OACONTROL 0x2360
+
 #define _GEN7_PIPEA_DE_LOAD_SL	0x70068
 #define _GEN7_PIPEB_DE_LOAD_SL	0x71068
 #define GEN7_PIPE_DE_LOAD_SL(pipe) _PIPE(pipe, \
Signature · 6 lines
1.9.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#2 lore raw
Quoted 6 lines · Daniel Vetter
Quoted 4 lines · Kenneth Graunke

Mesa needs to be able to write OACONTROL in order to expose the Observability Architecture's performance counters via OpenGL.

Quoted 8 lines

Thanks a lot for quickly tracking this down. Now when we've talked about OA a little while ago we concluded that mesa should clear OACONTROL again before the batch ends to make sure that userspace can't unduly observe other processes. So I think it'd be worth to keep track of this with a flag (set when OACONTROL is != 0 and reset when the batch loads 0). Also we need to make sure that userspace sets the right OACONTROL modes (not the one which streams into a global gtt buffer essentially). So some additional work required.

Ok, I'll look into this. And apologies for not catching it myself.

If we have to do additional checks on fields within the registers then I suppose we'll need to limit those registers to MI_LOAD_REGISTER_IMM. That might require separate whitelists for MI_LOAD_REGISTER_IMM/MEM. Not the end of the world, but certainly some additional complexity.

For the resetting check, are there other registers in the current list that should have this tracking? If so, is 0 the reset value in all cases?

Let me know if there is anything in the works that would require additional registers or different uses of any registers.

Thanks,
Brad

Quoted 63 lines

I've added a FIXME comment to the code.

Brad, can you please look into this, including the corresponding i-g-t which tries to enable OA but doesn't disable it and one which tries to enable it in the continuous mode (which writes to gtt)? Ken's previous mails has the cmds mesa emits.

Thanks, Daniel

Quoted 49 lines
---
 drivers/gpu/drm/i915/i915_cmd_parser.c | 1 +
 drivers/gpu/drm/i915/i915_reg.h        | 2 ++
 2 files changed, 3 insertions(+)

This patch needs to go before

commit 6d42f94084b8c69813d7ecd0466c33fe561bf127
Author: Brad Volkin <[email protected]>
Date: Tue Feb 18 10:15:57 2014 -0800

drm/i915: Enable command parsing by default

in whatever branch gets submitted to Dave Airlie. Or, that commit needs to be reverted. Otherwise, every OpenGL program will abort. Examples of programs that abort include GNOME, KDE, Firefox, and glxgears.

drivers/gpu/drm/i915/i915_cmd_parser.c +1 -0
index bae7c2f..d4a50b9 100644
@@ -415,6 +415,7 @@ static const u32 gen7_render_regs[] = {
 	GEN7_SO_WRITE_OFFSET(1),
 	GEN7_SO_WRITE_OFFSET(2),
 	GEN7_SO_WRITE_OFFSET(3),
+	OACONTROL,
 };
 
 static const u32 gen7_blt_regs[] = {
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 9f9e2b7..0ebc20d 100644
@@ -427,6 +427,8 @@
 /* There are the 4 64-bit counter registers, one for each stream output */
 #define GEN7_SO_NUM_PRIMS_WRITTEN(n) (0x5200 + (n) * 8)
 
+#define OACONTROL 0x2360
+
 #define _GEN7_PIPEA_DE_LOAD_SL	0x70068
 #define _GEN7_PIPEB_DE_LOAD_SL	0x71068
 #define GEN7_PIPE_DE_LOAD_SL(pipe) _PIPE(pipe, \
Signature · 6 lines
1.9.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#3 lore raw
Quoted 23 lines · Bradley D
Quoted 6 lines · Daniel Vetter
Quoted 4 lines · Kenneth Graunke

Mesa needs to be able to write OACONTROL in order to expose the Observability Architecture's performance counters via OpenGL.

Quoted 8 lines

Thanks a lot for quickly tracking this down. Now when we've talked about OA a little while ago we concluded that mesa should clear OACONTROL again before the batch ends to make sure that userspace can't unduly observe other processes. So I think it'd be worth to keep track of this with a flag (set when OACONTROL is != 0 and reset when the batch loads 0). Also we need to make sure that userspace sets the right OACONTROL modes (not the one which streams into a global gtt buffer essentially). So some additional work required.

Ok, I'll look into this. And apologies for not catching it myself.

If we have to do additional checks on fields within the registers then I suppose we'll need to limit those registers to MI_LOAD_REGISTER_IMM. That might require separate whitelists for MI_LOAD_REGISTER_IMM/MEM. Not the end of the world, but certainly some additional complexity.

Quoted 5 lines

For the resetting check, are there other registers in the current list that should have this tracking? If so, is 0 the reset value in all cases?

Let me know if there is anything in the works that would require additional registers or different uses of any registers.

Afaik there's no other register we want to reset again. I think all other register we might want to clear are already part of hw contexts, so no chance to leak stuff (e.g. the streamout registers and a end-of-pipe counters). Ken might know of something I've missed.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#4 lore raw
Quoted 27 lines · Daniel Vetter
Quoted 26 lines · Bradley D
Quoted 6 lines · Daniel Vetter
Quoted 4 lines · Kenneth Graunke

Mesa needs to be able to write OACONTROL in order to expose the Observability Architecture's performance counters via OpenGL.

Quoted 8 lines

Thanks a lot for quickly tracking this down. Now when we've talked about OA a little while ago we concluded that mesa should clear OACONTROL again before the batch ends to make sure that userspace can't unduly observe other processes. So I think it'd be worth to keep track of this with a flag (set when OACONTROL is != 0 and reset when the batch loads 0). Also we need to make sure that userspace sets the right OACONTROL modes (not the one which streams into a global gtt buffer essentially). So some additional work required.

Ok, I'll look into this. And apologies for not catching it myself.

If we have to do additional checks on fields within the registers then I suppose we'll need to limit those registers to MI_LOAD_REGISTER_IMM. That might require separate whitelists for MI_LOAD_REGISTER_IMM/MEM. Not the end of the world, but certainly some additional complexity.

For the resetting check, are there other registers in the current list that should have this tracking? If so, is 0 the reset value in all cases?

Quoted 8 lines
Quoted 2 lines

Let me know if there is anything in the works that would require additional registers or different uses of any registers.

Afaik there's no other register we want to reset again. I think all other register we might want to clear are already part of hw contexts, so no chance to leak stuff (e.g. the streamout registers and a end-of-pipe counters). Ken might know of something I've missed.
-Daniel

Right, I think it's just OACONTROL. I don't think there's a need to filter particular values.

I don't really buy the snooping problem, though...just because I leave OACONTROL set doesn't mean I'll get useful data. Another context might clobber it, and empirically the numbers seem to reset across RC6 anyway.
So in actuality, they're likely to get bogus data.

Even if they did somehow miraculously get decent values, it basically gives information akin to 'top', which is unprivileged on every system I've ever used.

The other alternative is to have the kernel write OACONTROL to 0 after any batch that alters it. Then the kernel wouldn't need to care what userspace does with it. (I think Daniel preferred having userspace reset it, though.)

--Ken

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw
Quoted 31 lines · Kenneth Graunke
Quoted 30 lines · Daniel Vetter
Quoted 28 lines · Bradley D
Quoted 6 lines · Daniel Vetter
Quoted 4 lines · Kenneth Graunke

Mesa needs to be able to write OACONTROL in order to expose the Observability Architecture's performance counters via OpenGL.

Quoted 8 lines

Thanks a lot for quickly tracking this down. Now when we've talked about OA a little while ago we concluded that mesa should clear OACONTROL again before the batch ends to make sure that userspace can't unduly observe other processes. So I think it'd be worth to keep track of this with a flag (set when OACONTROL is != 0 and reset when the batch loads 0). Also we need to make sure that userspace sets the right OACONTROL modes (not the one which streams into a global gtt buffer essentially). So some additional work required.

Ok, I'll look into this. And apologies for not catching it myself.

If we have to do additional checks on fields within the registers then I suppose we'll need to limit those registers to MI_LOAD_REGISTER_IMM. That might require separate whitelists for MI_LOAD_REGISTER_IMM/MEM. Not the end of the world, but certainly some additional complexity.

For the resetting check, are there other registers in the current list that should have this tracking? If so, is 0 the reset value in all cases?

Let me know if there is anything in the works that would require additional registers or different uses of any registers.

Quoted 8 lines
Quoted 5 lines

Afaik there's no other register we want to reset again. I think all other register we might want to clear are already part of hw contexts, so no chance to leak stuff (e.g. the streamout registers and a end-of-pipe counters). Ken might know of something I've missed.
-Daniel

Right, I think it's just OACONTROL. I don't think there's a need to filter particular values.

Sorry, I don't follow you here. Can you clarify what you mean r.e. filtering?

Quoted 9 lines

I don't really buy the snooping problem, though...just because I leave OACONTROL set doesn't mean I'll get useful data. Another context might clobber it, and empirically the numbers seem to reset across RC6 anyway.
So in actuality, they're likely to get bogus data.

Even if they did somehow miraculously get decent values, it basically gives information akin to 'top', which is unprivileged on every system I've ever used.

I tend to agree with this assesment. The data doesn't seem particularly sensitive. Also, I assume this data is similar in nature to what you can already get from graphics perf tools, right?

Thanks,
Brad

Quoted 8 lines

The other alternative is to have the kernel write OACONTROL to 0 after any batch that alters it. Then the kernel wouldn't need to care what userspace does with it. (I think Daniel preferred having userspace reset it, though.)

--Ken

#6 lore raw
Quoted 49 lines · Bradley D
Quoted 31 lines · Kenneth Graunke
Quoted 30 lines · Daniel Vetter
Quoted 28 lines · Bradley D
Quoted 6 lines · Daniel Vetter
Quoted 4 lines · Kenneth Graunke

Mesa needs to be able to write OACONTROL in order to expose the Observability Architecture's performance counters via OpenGL.

Quoted 8 lines

Thanks a lot for quickly tracking this down. Now when we've talked about OA a little while ago we concluded that mesa should clear OACONTROL again before the batch ends to make sure that userspace can't unduly observe other processes. So I think it'd be worth to keep track of this with a flag (set when OACONTROL is != 0 and reset when the batch loads 0). Also we need to make sure that userspace sets the right OACONTROL modes (not the one which streams into a global gtt buffer essentially). So some additional work required.

Ok, I'll look into this. And apologies for not catching it myself.

If we have to do additional checks on fields within the registers then I suppose we'll need to limit those registers to MI_LOAD_REGISTER_IMM. That might require separate whitelists for MI_LOAD_REGISTER_IMM/MEM. Not the end of the world, but certainly some additional complexity.

For the resetting check, are there other registers in the current list that should have this tracking? If so, is 0 the reset value in all cases?

Let me know if there is anything in the works that would require additional registers or different uses of any registers.

Quoted 8 lines
Quoted 5 lines

Afaik there's no other register we want to reset again. I think all other register we might want to clear are already part of hw contexts, so no chance to leak stuff (e.g. the streamout registers and a end-of-pipe counters). Ken might know of something I've missed.
-Daniel

Right, I think it's just OACONTROL. I don't think there's a need to filter particular values.

Sorry, I don't follow you here. Can you clarify what you mean r.e. filtering?

Quoted 6 lines

I don't really buy the snooping problem, though...just because I leave OACONTROL set doesn't mean I'll get useful data. Another context might clobber it, and empirically the numbers seem to reset across RC6 anyway.
So in actuality, they're likely to get bogus data.

Quoted 7 lines
Quoted 3 lines

Even if they did somehow miraculously get decent values, it basically gives information akin to 'top', which is unprivileged on every system I've ever used.

I tend to agree with this assesment. The data doesn't seem particularly sensitive. Also, I assume this data is similar in nature to what you can already get from graphics perf tools, right?

I've thought perf is priviledged ... And I've looked at the trigger based stuff again in Bspec and it looks like by default that's all disabled, so even when batches enable the timer nothing should happen. -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#7 lore raw
In reply to Volkin, Bradley D
Quoted 38 lines · Bradley D
Quoted 37 lines · Kenneth Graunke
Quoted 35 lines · Daniel Vetter
Quoted 23 lines · Bradley D
Quoted 6 lines · Daniel Vetter
Quoted 4 lines · Kenneth Graunke

Mesa needs to be able to write OACONTROL in order to expose the Observability Architecture's performance counters via OpenGL.

Quoted 8 lines

Thanks a lot for quickly tracking this down. Now when we've talked about OA a little while ago we concluded that mesa should clear OACONTROL again before the batch ends to make sure that userspace can't unduly observe other processes. So I think it'd be worth to keep track of this with a flag (set when OACONTROL is != 0 and reset when the batch loads 0). Also we need to make sure that userspace sets the right OACONTROL modes (not the one which streams into a global gtt buffer essentially). So some additional work required.

Ok, I'll look into this. And apologies for not catching it myself.

If we have to do additional checks on fields within the registers then I suppose we'll need to limit those registers to MI_LOAD_REGISTER_IMM. That might require separate whitelists for MI_LOAD_REGISTER_IMM/MEM. Not the end of the world, but certainly some additional complexity.

Quoted 5 lines

For the resetting check, are there other registers in the current list that should have this tracking? If so, is 0 the reset value in all cases?

Let me know if there is anything in the works that would require additional registers or different uses of any registers.

Afaik there's no other register we want to reset again. I think all other register we might want to clear are already part of hw contexts, so no chance to leak stuff (e.g. the streamout registers and a end-of-pipe counters). Ken might know of something I've missed.
-Daniel

Quoted 4 lines
Quoted 2 lines

Right, I think it's just OACONTROL. I don't think there's a need to filter particular values.

Sorry, I don't follow you here. Can you clarify what you mean r.e. filtering?

Oh, I meant I don't think we need to do additional checks on "fields within the registers" (to quote your email) or restrict the values we can write to the registers. Just the ability to write the whole register to any arbitrary value should be sufficient.

Thanks Brad!

--Ken

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw
In reply to Volkin, Bradley D
Quoted 49 lines · Bradley D
Quoted 31 lines · Kenneth Graunke
Quoted 30 lines · Daniel Vetter
Quoted 28 lines · Bradley D
Quoted 6 lines · Daniel Vetter
Quoted 4 lines · Kenneth Graunke

Mesa needs to be able to write OACONTROL in order to expose the Observability Architecture's performance counters via OpenGL.

Quoted 8 lines

Thanks a lot for quickly tracking this down. Now when we've talked about OA a little while ago we concluded that mesa should clear OACONTROL again before the batch ends to make sure that userspace can't unduly observe other processes. So I think it'd be worth to keep track of this with a flag (set when OACONTROL is != 0 and reset when the batch loads 0). Also we need to make sure that userspace sets the right OACONTROL modes (not the one which streams into a global gtt buffer essentially). So some additional work required.

Ok, I'll look into this. And apologies for not catching it myself.

If we have to do additional checks on fields within the registers then I suppose we'll need to limit those registers to MI_LOAD_REGISTER_IMM. That might require separate whitelists for MI_LOAD_REGISTER_IMM/MEM. Not the end of the world, but certainly some additional complexity.

For the resetting check, are there other registers in the current list that should have this tracking? If so, is 0 the reset value in all cases?

Let me know if there is anything in the works that would require additional registers or different uses of any registers.

Quoted 8 lines
Quoted 5 lines

Afaik there's no other register we want to reset again. I think all other register we might want to clear are already part of hw contexts, so no chance to leak stuff (e.g. the streamout registers and a end-of-pipe counters). Ken might know of something I've missed.
-Daniel

Right, I think it's just OACONTROL. I don't think there's a need to filter particular values.

Sorry, I don't follow you here. Can you clarify what you mean r.e. filtering?

Quoted 6 lines

I don't really buy the snooping problem, though...just because I leave OACONTROL set doesn't mean I'll get useful data. Another context might clobber it, and empirically the numbers seem to reset across RC6 anyway.
So in actuality, they're likely to get bogus data.

Quoted 7 lines
Quoted 3 lines

Even if they did somehow miraculously get decent values, it basically gives information akin to 'top', which is unprivileged on every system I've ever used.

I tend to agree with this assesment. The data doesn't seem particularly sensitive. Also, I assume this data is similar in nature to what you can already get from graphics perf tools, right?

Another one that blows is igt/gen7_forcewake_mt. Not sure yet whether it's an issue with the test or the checker:

https://bugs.freedesktop.org/show_bug.cgi?id=76670

Cheers, Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#9 lore raw

[snip]

Quoted 4 lines · Daniel Vetter

Another one that blows is igt/gen7_forcewake_mt. Not sure yet whether it's an issue with the test or the checker:

https://bugs.freedesktop.org/show_bug.cgi?id=76670

For this one, the parser rejects an MI_STORE_REGISTER_MEM with the GGTT bit set. We don't currently allow that, even from master. It sounds like there might be released versions of the ddx that do this as well. If that's the case, or if there are other situations where tests, etc rely on being able to do whatever they want when setting the I915_DISPATCH_SECURE flag, then I think we might as well stop parsing secure batches and let them go through as before.

Thanks,
Brad

Quoted 6 lines

Cheers, Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#10 lore raw
Quoted 6 lines · Bradley D
Quoted 4 lines · Daniel Vetter

Another one that blows is igt/gen7_forcewake_mt. Not sure yet whether it's an issue with the test or the checker:

https://bugs.freedesktop.org/show_bug.cgi?id=76670

Quoted 7 lines

For this one, the parser rejects an MI_STORE_REGISTER_MEM with the GGTT bit set. We don't currently allow that, even from master. It sounds like there might be released versions of the ddx that do this as well. If that's the case, or if there are other situations where tests, etc rely on being able to do whatever they want when setting the I915_DISPATCH_SECURE flag, then I think we might as well stop parsing secure batches and let them go through as before.

Well for the testcase I think we can just add the missing flag. If there's indeed shipping userspace out there which is getting these flags wrong then I think we need to silently upgrade them when copying the cmds over to the 2nd batch. But I guess until that need is really established we can hope we don't need this.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#11 lore raw
Quoted 16 lines · Daniel Vetter
Quoted 6 lines · Bradley D
Quoted 4 lines · Daniel Vetter

Another one that blows is igt/gen7_forcewake_mt. Not sure yet whether it's an issue with the test or the checker:

https://bugs.freedesktop.org/show_bug.cgi?id=76670

Quoted 7 lines

For this one, the parser rejects an MI_STORE_REGISTER_MEM with the GGTT bit set. We don't currently allow that, even from master. It sounds like there might be released versions of the ddx that do this as well. If that's the case, or if there are other situations where tests, etc rely on being able to do whatever they want when setting the I915_DISPATCH_SECURE flag, then I think we might as well stop parsing secure batches and let them go through as before.

Quoted 6 lines

Well for the testcase I think we can just add the missing flag. If there's indeed shipping userspace out there which is getting these flags wrong then I think we need to silently upgrade them when copying the cmds over to the 2nd batch. But I guess until that need is really established we can hope we don't need this.
-Daniel

Why are we parsing batches with I915_EXEC_SECURE at all? Secure batches are only issued from trusted code which is guaranteed to be running as root. I don't see any benefit to scanning those batches, and there's definitely overhead.

I mean, sure, it may be reasonable in the short term as a way to test the command parser, but I certainly hope we don't *ship* that.

--Ken

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#12 lore raw
Quoted 7 lines · Kenneth Graunke

Why are we parsing batches with I915_EXEC_SECURE at all? Secure batches are only issued from trusted code which is guaranteed to be running as root. I don't see any benefit to scanning those batches, and there's definitely overhead.

I mean, sure, it may be reasonable in the short term as a way to test the command parser, but I certainly hope we don't *ship* that.

Everyone runs X as root, but I kinda want X to also be able to run as non-root. The cmd parser has a special list of drm master register lists which should allow this, but if we just bypass the cmd parser for all normal X installs we'll have 0 test coverage on this. Which means broken like hell.

Hence I actually intend to ship this, yes. Chris doesn't like it either really. -Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#13 lore raw
Quoted 9 lines · Daniel Vetter
Quoted 7 lines · Kenneth Graunke

Why are we parsing batches with I915_EXEC_SECURE at all? Secure batches are only issued from trusted code which is guaranteed to be running as root. I don't see any benefit to scanning those batches, and there's definitely overhead.

I mean, sure, it may be reasonable in the short term as a way to test the command parser, but I certainly hope we don't *ship* that.

Quoted 8 lines

Everyone runs X as root, but I kinda want X to also be able to run as non-root. The cmd parser has a special list of drm master register lists which should allow this, but if we just bypass the cmd parser for all normal X installs we'll have 0 test coverage on this. Which means broken like hell.

Hence I actually intend to ship this, yes. Chris doesn't like it either really. -Daniel

Seriously? Hurt performance on every user's system just so you can test things? That a classic case of the tail wagging the dog.

Why not make a i915.enable_cmd_parser=2 value which enables it all the time and use that when running igt? Clearly being able to test this is valuable, but enabling it universally is *not* OK.

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#14 lore raw
Quoted 19 lines · On Thu, 27 Mar 2014 16:22:44 -0700 Kenneth Graunke <[email protected]>…
Quoted 9 lines · Daniel Vetter
Quoted 7 lines · Kenneth Graunke

Why are we parsing batches with I915_EXEC_SECURE at all? Secure batches are only issued from trusted code which is guaranteed to be running as root. I don't see any benefit to scanning those batches, and there's definitely overhead.

I mean, sure, it may be reasonable in the short term as a way to test the command parser, but I certainly hope we don't *ship* that.

Quoted 8 lines

Everyone runs X as root, but I kinda want X to also be able to run as non-root. The cmd parser has a special list of drm master register lists which should allow this, but if we just bypass the cmd parser for all normal X installs we'll have 0 test coverage on this. Which means broken like hell.

Hence I actually intend to ship this, yes. Chris doesn't like it either really. -Daniel

Quoted 6 lines

Seriously? Hurt performance on every user's system just so you can test things? That a classic case of the tail wagging the dog.

Why not make a i915.enable_cmd_parser=2 value which enables it all the time and use that when running igt? Clearly being able to test this is valuable, but enabling it universally is *not* OK.

Daniel, I'm not sure what you mean by 0 coverage. Surely DRI clients count for something? And X shouldn't be submitting all its batches with the secure bit set, right? If so, we ought to fix that and only use it for ones where it's necessary (e.g. wait events or similar). I agree with Ken and Chris here.

Chris?

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#15 lore raw
Quoted 29 lines · Jesse Barnes
Quoted 19 lines · On Thu, 27 Mar 2014 16:22:44 -0700 Kenneth Graunke <[email protected]>…
Quoted 9 lines · Daniel Vetter
Quoted 7 lines · Kenneth Graunke

Why are we parsing batches with I915_EXEC_SECURE at all? Secure batches are only issued from trusted code which is guaranteed to be running as root. I don't see any benefit to scanning those batches, and there's definitely overhead.

I mean, sure, it may be reasonable in the short term as a way to test the command parser, but I certainly hope we don't *ship* that.

Quoted 8 lines

Everyone runs X as root, but I kinda want X to also be able to run as non-root. The cmd parser has a special list of drm master register lists which should allow this, but if we just bypass the cmd parser for all normal X installs we'll have 0 test coverage on this. Which means broken like hell.

Hence I actually intend to ship this, yes. Chris doesn't like it either really. -Daniel

Quoted 6 lines

Seriously? Hurt performance on every user's system just so you can test things? That a classic case of the tail wagging the dog.

Why not make a i915.enable_cmd_parser=2 value which enables it all the time and use that when running igt? Clearly being able to test this is valuable, but enabling it universally is *not* OK.

Quoted 7 lines

Daniel, I'm not sure what you mean by 0 coverage. Surely DRI clients count for something? And X shouldn't be submitting all its batches with the secure bit set, right? If so, we ought to fix that and only use it for ones where it's necessary (e.g. wait events or similar). I agree with Ken and Chris here.

Chris?

We haven't even fixed the major regression from enabling FBC. What's another massive slowdown?

Yes, X only sets the secure bit when it pokes the display registers, and those registers should be privileged even with a cmd parser in place (which they are).

Daniel's argument presumes that we haven't been patching out the cmd parser all this time anyway.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#16 lore raw
Quoted 36 lines · On Fri, 16 May 2014 20:20:50 +0100 Chris Wilson <[email protected]>…
Quoted 35 lines · Jesse Barnes
Quoted 19 lines · On Thu, 27 Mar 2014 16:22:44 -0700 Kenneth Graunke <[email protected]>…
Quoted 9 lines · Daniel Vetter
Quoted 7 lines · Kenneth Graunke

Why are we parsing batches with I915_EXEC_SECURE at all? Secure batches are only issued from trusted code which is guaranteed to be running as root. I don't see any benefit to scanning those batches, and there's definitely overhead.

I mean, sure, it may be reasonable in the short term as a way to test the command parser, but I certainly hope we don't *ship* that.

Quoted 8 lines

Everyone runs X as root, but I kinda want X to also be able to run as non-root. The cmd parser has a special list of drm master register lists which should allow this, but if we just bypass the cmd parser for all normal X installs we'll have 0 test coverage on this. Which means broken like hell.

Hence I actually intend to ship this, yes. Chris doesn't like it either really. -Daniel

Quoted 6 lines

Seriously? Hurt performance on every user's system just so you can test things? That a classic case of the tail wagging the dog.

Why not make a i915.enable_cmd_parser=2 value which enables it all the time and use that when running igt? Clearly being able to test this is valuable, but enabling it universally is *not* OK.

Daniel, I'm not sure what you mean by 0 coverage. Surely DRI clients count for something? And X shouldn't be submitting all its batches with the secure bit set, right? If so, we ought to fix that and only use it for ones where it's necessary (e.g. wait events or similar). I agree with Ken and Chris here.

Quoted 4 lines
Quoted 1 line

Chris?

We haven't even fixed the major regression from enabling FBC. What's another massive slowdown?

I thought you had that fixed in the X driver by avoiding front buffer rendering altogether. If that's the case we just need an ioctl to opt out of front buffer tracking, right? Presumably that flag would follow the current DRM_MASTER process...

Quoted 6 lines

Yes, X only sets the secure bit when it pokes the display registers, and those registers should be privileged even with a cmd parser in place (which they are).

Daniel's argument presumes that we haven't been patching out the cmd parser all this time anyway.

Yeah I know we have some perf issues as it is; it would be nice if the overhead were so minimal that it didn't matter. But just on principle, scanning secure buffers seems wrong, and I'm trying to understand why Daniel would want it.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#17 lore raw
Quoted 9 lines · Jesse Barnes
Quoted 2 lines · On Fri, 16 May 2014 20:20:50 +0100 Chris Wilson <[email protected]>…

We haven't even fixed the major regression from enabling FBC. What's another massive slowdown?

I thought you had that fixed in the X driver by avoiding front buffer rendering altogether. If that's the case we just need an ioctl to opt out of front buffer tracking, right? Presumably that flag would follow the current DRM_MASTER process...

No. All rendering triggers FBC updates. Ville has patches to fix the majority of that with only nuking FBC when front buffer rendering. (Note that games aren't usually affected by this because FBC is disabled by pageflipping.) The overhead could probably be reduced further by periodic nuking the FBC like (ideally) PSR. And yes X can avoid front buffer rendering altogether. The remaining challenge is to know when to enable it (the kernel doesn't give us any information about FBC or PSR after setting a mode) and when not, i.e. there is already a pageflipping compositor. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#18 lore raw
Quoted 11 lines · On Fri, 16 May 2014 20:49:30 +0100 Chris Wilson <[email protected]>…
Quoted 9 lines · Jesse Barnes
Quoted 2 lines · On Fri, 16 May 2014 20:20:50 +0100 Chris Wilson <[email protected]>…

We haven't even fixed the major regression from enabling FBC. What's another massive slowdown?

I thought you had that fixed in the X driver by avoiding front buffer rendering altogether. If that's the case we just need an ioctl to opt out of front buffer tracking, right? Presumably that flag would follow the current DRM_MASTER process...

Quoted 8 lines

No. All rendering triggers FBC updates. Ville has patches to fix the majority of that with only nuking FBC when front buffer rendering. (Note that games aren't usually affected by this because FBC is disabled by pageflipping.) The overhead could probably be reduced further by periodic nuking the FBC like (ideally) PSR. And yes X can avoid front buffer rendering altogether. The remaining challenge is to know when to enable it (the kernel doesn't give us any information about FBC or PSR after setting a mode) and when not, i.e. there is already a pageflipping compositor.

I thought there was a control bit for when the nuke occurred? If not, yeah I guess we have to go with a sw approach...

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#19 lore raw
In reply to Jesse Barnes
Quoted 6 lines · On Fri, 16 May 2014 12:34:08 -0700 Jesse Barnes <[email protected]>…
Quoted 4 lines · On Fri, 16 May 2014 20:20:50 +0100 Chris Wilson <[email protected]>…

Yes, X only sets the secure bit when it pokes the display registers, and those registers should be privileged even with a cmd parser in place (which they are).

Quoted 7 lines
Quoted 2 lines

Daniel's argument presumes that we haven't been patching out the cmd parser all this time anyway.

Yeah I know we have some perf issues as it is; it would be nice if the overhead were so minimal that it didn't matter. But just on principle, scanning secure buffers seems wrong, and I'm trying to understand why Daniel would want it.

Ok Daniel explained on IRC that we actually have a special whitelist for the secure batch case. The idea is to allow a DRM_MASTER to submit secure batches, but still prevent a local root exploit. I suppose that means preventing access to most commands and registers, but allowing a few extra things like wait events and display register updates.

I suppose it's not entirely unreasonable, but it does add complexity to the scanner and overhead to all users; not sure it's worth it.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#20 lore raw
Quoted 17 lines · Jesse Barnes
Quoted 6 lines · On Fri, 16 May 2014 12:34:08 -0700 Jesse Barnes <[email protected]>…
Quoted 4 lines · On Fri, 16 May 2014 20:20:50 +0100 Chris Wilson <[email protected]>…

Yes, X only sets the secure bit when it pokes the display registers, and those registers should be privileged even with a cmd parser in place (which they are).

Quoted 7 lines
Quoted 2 lines

Daniel's argument presumes that we haven't been patching out the cmd parser all this time anyway.

Yeah I know we have some perf issues as it is; it would be nice if the overhead were so minimal that it didn't matter. But just on principle, scanning secure buffers seems wrong, and I'm trying to understand why Daniel would want it.

Quoted 5 lines

Ok Daniel explained on IRC that we actually have a special whitelist for the secure batch case. The idea is to allow a DRM_MASTER to submit secure batches, but still prevent a local root exploit. I suppose that means preventing access to most commands and registers, but allowing a few extra things like wait events and display register updates.

Just to clarify further: the additional register whitelist and commands are only based on DRM_MASTER. Setting I915_EXEC_SECURE is not required. So I suppose we could stop scanning batches that have I915_EXEC_SECURE and userspace could stop sending such batches when the parser is fully enabled.

Brad

Quoted 10 lines

I suppose it's not entirely unreasonable, but it does add complexity to the scanner and overhead to all users; not sure it's worth it.

Signature · 5 lines
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#21 lore raw
Quoted 24 lines · Bradley D
Quoted 17 lines · Jesse Barnes
Quoted 6 lines · On Fri, 16 May 2014 12:34:08 -0700 Jesse Barnes <[email protected]>…
Quoted 4 lines · On Fri, 16 May 2014 20:20:50 +0100 Chris Wilson <[email protected]>…

Yes, X only sets the secure bit when it pokes the display registers, and those registers should be privileged even with a cmd parser in place (which they are).

Quoted 7 lines
Quoted 2 lines

Daniel's argument presumes that we haven't been patching out the cmd parser all this time anyway.

Yeah I know we have some perf issues as it is; it would be nice if the overhead were so minimal that it didn't matter. But just on principle, scanning secure buffers seems wrong, and I'm trying to understand why Daniel would want it.

Quoted 5 lines

Ok Daniel explained on IRC that we actually have a special whitelist for the secure batch case. The idea is to allow a DRM_MASTER to submit secure batches, but still prevent a local root exploit. I suppose that means preventing access to most commands and registers, but allowing a few extra things like wait events and display register updates.

Quoted 4 lines

Just to clarify further: the additional register whitelist and commands are only based on DRM_MASTER. Setting I915_EXEC_SECURE is not required. So I suppose we could stop scanning batches that have I915_EXEC_SECURE and userspace could stop sending such batches when the parser is fully enabled.

Ah ok, yeah that's another option, but now I understand where Daniel is coming from with testing, since that's not how the current X driver behaves.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
#22 lore raw
In reply to Daniel Vetter
Quoted 16 lines · Daniel Vetter
Quoted 6 lines · Bradley D
Quoted 4 lines · Daniel Vetter

Another one that blows is igt/gen7_forcewake_mt. Not sure yet whether it's an issue with the test or the checker:

https://bugs.freedesktop.org/show_bug.cgi?id=76670

Quoted 7 lines

For this one, the parser rejects an MI_STORE_REGISTER_MEM with the GGTT bit set. We don't currently allow that, even from master. It sounds like there might be released versions of the ddx that do this as well. If that's the case, or if there are other situations where tests, etc rely on being able to do whatever they want when setting the I915_DISPATCH_SECURE flag, then I think we might as well stop parsing secure batches and let them go through as before.

Quoted 1 line

Well for the testcase I think we can just add the missing flag. If

Which flag are you referring to here? Or are you just generally trying to say "modify the test to not break the rules"?

Quoted 4 lines

there's indeed shipping userspace out there which is getting these flags wrong then I think we need to silently upgrade them when copying the cmds over to the 2nd batch. But I guess until that need is really established we can hope we don't need this.

Chris, can you clarify whether shipping ddx sets GGTT bits this way?

Thanks,
Brad

Quoted 5 lines

-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#23 lore raw
Quoted 22 lines · Bradley D
Quoted 16 lines · Daniel Vetter
Quoted 6 lines · Bradley D
Quoted 4 lines · Daniel Vetter

Another one that blows is igt/gen7_forcewake_mt. Not sure yet whether it's an issue with the test or the checker:

https://bugs.freedesktop.org/show_bug.cgi?id=76670

Quoted 7 lines

For this one, the parser rejects an MI_STORE_REGISTER_MEM with the GGTT bit set. We don't currently allow that, even from master. It sounds like there might be released versions of the ddx that do this as well. If that's the case, or if there are other situations where tests, etc rely on being able to do whatever they want when setting the I915_DISPATCH_SECURE flag, then I think we might as well stop parsing secure batches and let them go through as before.

Quoted 1 line

Well for the testcase I think we can just add the missing flag. If

Which flag are you referring to here? Or are you just generally trying to say "modify the test to not break the rules"?

Quoted 6 lines
Quoted 4 lines

there's indeed shipping userspace out there which is getting these flags wrong then I think we need to silently upgrade them when copying the cmds over to the 2nd batch. But I guess until that need is really established we can hope we don't need this.

Chris, can you clarify whether shipping ddx sets GGTT bits this way?

There have been no point releases with SRM (as far as I can remember) as no bug reporter said that they made any difference to their hangs. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
maintainer
#24 lore raw
In reply to Kenneth Graunke
Quoted 26 lines · Kenneth Graunke

Mesa needs to be able to write OACONTROL in order to expose the Observability Architecture's performance counters via OpenGL.

---
 drivers/gpu/drm/i915/i915_cmd_parser.c | 1 +
 drivers/gpu/drm/i915/i915_reg.h        | 2 ++
 2 files changed, 3 insertions(+)

This patch needs to go before

commit 6d42f94084b8c69813d7ecd0466c33fe561bf127
Author: Brad Volkin <[email protected]>
Date: Tue Feb 18 10:15:57 2014 -0800

drm/i915: Enable command parsing by default

in whatever branch gets submitted to Dave Airlie. Or, that commit needs to be reverted. Otherwise, every OpenGL program will abort. Examples of programs that abort include GNOME, KDE, Firefox, and glxgears.

drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
index bae7c2f..d4a50b9 100644

drivers/gpu/drm/i915/i915_cmd_parser.c static const u32 gen7_render_regs[] = { · line 418

Quoted 4 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +1 -0
@@ -415,6 +415,7 @@ static const u32 gen7_render_regs[] = {
 	GEN7_SO_WRITE_OFFSET(1),
 	GEN7_SO_WRITE_OFFSET(2),
 	GEN7_SO_WRITE_OFFSET(3),
+	OACONTROL,

Comment above gen7_render_regs array:

* Register whitelists, sorted by increasing register offset.

You'll get a DRM_ERROR for this.

Daniel, naughty naughty for pushing this already!

BR,
Jani.

Quoted 23 lines
drivers/gpu/drm/i915/i915_cmd_parser.c +0 -0
 };
 
 static const u32 gen7_blt_regs[] = {
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 9f9e2b7..0ebc20d 100644
@@ -427,6 +427,8 @@
 /* There are the 4 64-bit counter registers, one for each stream output */
 #define GEN7_SO_NUM_PRIMS_WRITTEN(n) (0x5200 + (n) * 8)
 
+#define OACONTROL 0x2360
+
 #define _GEN7_PIPEA_DE_LOAD_SL	0x70068
 #define _GEN7_PIPEB_DE_LOAD_SL	0x71068
 #define GEN7_PIPE_DE_LOAD_SL(pipe) _PIPE(pipe, \
Signature · 6 lines
1.9.0

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
#25 lore raw

PATCH v2 1/1 drm/i915: Add OACONTROL to the command parser register whitelist.

Mesa needs to be able to write OACONTROL in order to expose the Observability Architecture's performance counters via OpenGL.

v2: Insert in proper sorted order (caught by Jani Nikula).

---
 drivers/gpu/drm/i915/i915_cmd_parser.c | 1 +
 drivers/gpu/drm/i915/i915_reg.h        | 2 ++
 2 files changed, 3 insertions(+)

Sorry, totally missed that. Thanks for catching that, Jani.

drivers/gpu/drm/i915/i915_cmd_parser.c +1 -0
index bae7c2f..1cd8d3a 100644
@@ -407,6 +407,7 @@ static const u32 gen7_render_regs[] = {
 	REG64(CL_PRIMITIVES_COUNT),
 	REG64(PS_INVOCATION_COUNT),
 	REG64(PS_DEPTH_COUNT),
+	OACONTROL,
 	REG64(GEN7_SO_NUM_PRIMS_WRITTEN(0)),
 	REG64(GEN7_SO_NUM_PRIMS_WRITTEN(1)),
 	REG64(GEN7_SO_NUM_PRIMS_WRITTEN(2)),
drivers/gpu/drm/i915/i915_reg.h +2 -0
index 9f9e2b7..0ebc20d 100644
@@ -427,6 +427,8 @@
 /* There are the 4 64-bit counter registers, one for each stream output */
 #define GEN7_SO_NUM_PRIMS_WRITTEN(n) (0x5200 + (n) * 8)
 
+#define OACONTROL 0x2360
+
 #define _GEN7_PIPEA_DE_LOAD_SL	0x70068
 #define _GEN7_PIPEB_DE_LOAD_SL	0x71068
 #define GEN7_PIPE_DE_LOAD_SL(pipe) _PIPE(pipe, \
Signature · 1 line
1.9.0