All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] tests/gem_ctx_param: Update invalid param
@ 2017-12-15 19:01 Antonio Argenziano
  2017-12-15 19:38 ` ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Antonio Argenziano @ 2017-12-15 19:01 UTC (permalink / raw)
  To: intel-gfx

Since commit: drm/i915/scheduler: Support user-defined priorities, the
driver support an extra context param to set context's priority. Add
tests for that interface and update invalid tests.

Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Michal Winiarski <michal.winiarski@intel.com>
---
 tests/gem_ctx_param.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 76 insertions(+), 1 deletion(-)

diff --git a/tests/gem_ctx_param.c b/tests/gem_ctx_param.c
index c20ae1ee..9a222e60 100644
--- a/tests/gem_ctx_param.c
+++ b/tests/gem_ctx_param.c
@@ -25,6 +25,7 @@
  */
 
 #include "igt.h"
+#include <limits.h>
 
 IGT_TEST_DESCRIPTION("Basic test for context set/get param input validation.");
 
@@ -136,11 +137,85 @@ igt_main
 		gem_context_set_param(fd, &arg);
 	}
 
+#define MAX_PRIO 1023
+#define MIN_PRIO -MAX_PRIO
+#define DEF_PRIO 0
+
+	arg.param = I915_CONTEXT_PARAM_PRIORITY;
+
+	igt_subtest("root-set-priority") {
+		arg.ctx_id = ctx;
+		arg.size = 0;
+
+		for (int i = MIN_PRIO; i <= MAX_PRIO; i += 1023) {
+			arg.value = i;
+			gem_context_set_param(fd, &arg);
+
+			gem_context_get_param(fd, &arg);
+			igt_assert(arg.value == i); /* Verify prio was set */
+		}
+	}
+
+	igt_subtest("root-set-priority-invalid-value") {
+		int prio_levels[] = {INT_MIN, MIN_PRIO - 1, MAX_PRIO + 1, INT_MAX};
+		int old_value;
+		arg.ctx_id = ctx;
+
+		gem_context_get_param(fd, &arg);
+		old_value = arg.value;
+
+		for (int i = 0; i < (sizeof(prio_levels) / sizeof(int)); i++) {
+			arg.value = prio_levels[i];
+			igt_assert_eq(__gem_context_set_param(fd, &arg), -EINVAL);
+
+			gem_context_get_param(fd, &arg);
+			igt_assert(arg.value == old_value); /* Verify prio was not set */
+		}
+	}
+
+	igt_subtest("user-set-priority") {
+		arg.size = 0;
+
+		igt_fork(child, 1) {
+			igt_drop_root();
+			for (int i = MIN_PRIO; i <= DEF_PRIO; i += 1023) {
+				arg.value = i;
+				gem_context_set_param(fd, &arg);
+
+				gem_context_get_param(fd, &arg);
+				igt_assert(arg.value == i); /* Verify prio was set */
+			}
+		}
+
+		igt_waitchildren();
+	}
+
+	igt_subtest("user-set-priority-invalid-value") {
+		int prio_levels[] = {DEF_PRIO + 1, MAX_PRIO};
+		arg.ctx_id = ctx;
+		arg.size = 0;
+
+		igt_fork(child, 1) {
+			igt_drop_root();
+
+			for (int i = 0; i < (sizeof(prio_levels) / sizeof(int)); i++) {
+				arg.value = prio_levels[i];
+				igt_assert_eq(__gem_context_set_param(fd, &arg), -EPERM);
+
+				gem_context_get_param(fd, &arg);
+				igt_assert(arg.value == DEF_PRIO); /* Verify prio was not set */
+			}
+		}
+
+		igt_waitchildren();
+	}
+
+
 	/* NOTE: This testcase intentionally tests for the next free parameter
 	 * to catch ABI extensions. Don't "fix" this testcase without adding all
 	 * the tests for the new param first.
 	 */
-	arg.param = I915_CONTEXT_PARAM_BANNABLE + 1;
+	arg.param = I915_CONTEXT_PARAM_PRIORITY + 1;
 
 	igt_subtest("invalid-param-get") {
 		arg.ctx_id = ctx;
-- 
2.14.2

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

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

* ✓ Fi.CI.BAT: success for tests/gem_ctx_param: Update invalid param
  2017-12-15 19:01 [PATCH i-g-t] tests/gem_ctx_param: Update invalid param Antonio Argenziano
@ 2017-12-15 19:38 ` Patchwork
  2017-12-15 22:40 ` ✓ Fi.CI.IGT: " Patchwork
  2017-12-16  0:14 ` [PATCH i-g-t] " Chris Wilson
  2 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2017-12-15 19:38 UTC (permalink / raw)
  To: Antonio Argenziano; +Cc: intel-gfx

== Series Details ==

Series: tests/gem_ctx_param: Update invalid param
URL   : https://patchwork.freedesktop.org/series/35438/
State : success

== Summary ==

IGT patchset tested on top of latest successful build
c0be3310715e2f744b892c51f09e62273bcc8e57 tests/kms_frontbuffer_tracking: Correctly handle debugfs errors

with latest DRM-Tip kernel build CI_DRM_3524
d4fa2d8c0c1d drm-tip: 2017y-12m-15d-18h-22m-22s UTC integration manifest

Testlist changes:
+igt@gem_ctx_param@root-set-priority
+igt@gem_ctx_param@root-set-priority-invalid-value
+igt@gem_ctx_param@user-set-priority
+igt@gem_ctx_param@user-set-priority-invalid-value

Test gem_mmap_gtt:
        Subgroup basic-small-bo-tiledx:
                fail       -> PASS       (fi-gdg-551) fdo#102575
Test gem_sync:
        Subgroup basic-all:
                dmesg-fail -> FAIL       (fi-blb-e6850) fdo#104259
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                incomplete -> PASS       (fi-snb-2520m) fdo#103713
Test kms_psr_sink_crc:
        Subgroup psr_basic:
                pass       -> DMESG-WARN (fi-skl-6700hq) fdo#101144

fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#104259 https://bugs.freedesktop.org/show_bug.cgi?id=104259
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#101144 https://bugs.freedesktop.org/show_bug.cgi?id=101144

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:435s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:442s
fi-blb-e6850     total:288  pass:222  dwarn:1   dfail:0   fail:1   skip:64  time:389s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:507s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:278s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:495s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:498s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:490s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:470s
fi-elk-e7500     total:224  pass:163  dwarn:15  dfail:0   fail:0   skip:45 
fi-gdg-551       total:288  pass:179  dwarn:1   dfail:0   fail:0   skip:108 time:264s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:537s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:406s
fi-hsw-4770r     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:413s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:472s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:428s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:481s
fi-kbl-7560u     total:288  pass:268  dwarn:1   dfail:0   fail:0   skip:19  time:520s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:474s
fi-kbl-r         total:288  pass:260  dwarn:1   dfail:0   fail:0   skip:27  time:523s
fi-pnv-d510      total:288  pass:221  dwarn:1   dfail:0   fail:1   skip:65  time:594s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:453s
fi-skl-6600u     total:288  pass:260  dwarn:1   dfail:0   fail:0   skip:27  time:531s
fi-skl-6700hq    total:288  pass:261  dwarn:1   dfail:0   fail:0   skip:26  time:557s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:507s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:448s
fi-snb-2520m     total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:556s
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:414s
Blacklisted hosts:
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:588s
fi-cnl-y         total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:624s
fi-glk-dsi       total:288  pass:257  dwarn:0   dfail:0   fail:1   skip:30  time:489s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:509s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_688/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✓ Fi.CI.IGT: success for tests/gem_ctx_param: Update invalid param
  2017-12-15 19:01 [PATCH i-g-t] tests/gem_ctx_param: Update invalid param Antonio Argenziano
  2017-12-15 19:38 ` ✓ Fi.CI.BAT: success for " Patchwork
@ 2017-12-15 22:40 ` Patchwork
  2017-12-16  0:14 ` [PATCH i-g-t] " Chris Wilson
  2 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2017-12-15 22:40 UTC (permalink / raw)
  To: Antonio Argenziano; +Cc: intel-gfx

== Series Details ==

Series: tests/gem_ctx_param: Update invalid param
URL   : https://patchwork.freedesktop.org/series/35438/
State : success

== Summary ==

Warning: bzip CI_DRM_3524/shard-glkb6/results10.json.bz2 wasn't in correct JSON format
Test gem_ctx_param:
        Subgroup invalid-param-set:
                fail       -> PASS       (shard-snb) fdo#103107 +3
Test kms_setmode:
        Subgroup basic:
                pass       -> FAIL       (shard-hsw) fdo#99912
Test gem_eio:
        Subgroup in-flight-contexts:
                pass       -> DMESG-WARN (shard-snb) fdo#104058
Test drv_module_reload:
        Subgroup basic-reload-inject:
                pass       -> DMESG-WARN (shard-snb) fdo#102707 +1
Test pm_rc6_residency:
        Subgroup rc6-accuracy:
                skip       -> PASS       (shard-snb)
Test kms_frontbuffer_tracking:
        Subgroup fbc-1p-offscren-pri-shrfb-draw-render:
                fail       -> PASS       (shard-snb) fdo#101623 +1
Test perf:
        Subgroup blocking:
                pass       -> FAIL       (shard-hsw) fdo#102252
Test kms_flip:
        Subgroup dpms-vs-vblank-race:
                fail       -> PASS       (shard-hsw) fdo#103060
Test gem_softpin:
        Subgroup noreloc-s3:
                skip       -> PASS       (shard-snb) fdo#102365
                skip       -> PASS       (shard-hsw) fdo#103540
Test drv_selftest:
        Subgroup live_hangcheck:
                pass       -> INCOMPLETE (shard-snb) fdo#103880

fdo#103107 https://bugs.freedesktop.org/show_bug.cgi?id=103107
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
fdo#104058 https://bugs.freedesktop.org/show_bug.cgi?id=104058
fdo#102707 https://bugs.freedesktop.org/show_bug.cgi?id=102707
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#102365 https://bugs.freedesktop.org/show_bug.cgi?id=102365
fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540
fdo#103880 https://bugs.freedesktop.org/show_bug.cgi?id=103880

shard-hsw        total:2700 pass:1529 dwarn:2   dfail:0   fail:13  skip:1155 time:9349s
shard-snb        total:2698 pass:1290 dwarn:3   dfail:0   fail:14  skip:1390 time:7969s
Blacklisted hosts:
shard-kbl        total:2676 pass:1772 dwarn:5   dfail:0   fail:27  skip:871 time:10795s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_688/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t] tests/gem_ctx_param: Update invalid param
  2017-12-15 19:01 [PATCH i-g-t] tests/gem_ctx_param: Update invalid param Antonio Argenziano
  2017-12-15 19:38 ` ✓ Fi.CI.BAT: success for " Patchwork
  2017-12-15 22:40 ` ✓ Fi.CI.IGT: " Patchwork
@ 2017-12-16  0:14 ` Chris Wilson
  2017-12-18 18:15   ` Antonio Argenziano
  2 siblings, 1 reply; 6+ messages in thread
From: Chris Wilson @ 2017-12-16  0:14 UTC (permalink / raw)
  To: Antonio Argenziano, intel-gfx

Quoting Antonio Argenziano (2017-12-15 19:01:11)
> Since commit: drm/i915/scheduler: Support user-defined priorities, the
> driver support an extra context param to set context's priority. Add
> tests for that interface and update invalid tests.
> 
> Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Michal Winiarski <michal.winiarski@intel.com>
> ---
>  tests/gem_ctx_param.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 76 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/gem_ctx_param.c b/tests/gem_ctx_param.c
> index c20ae1ee..9a222e60 100644
> --- a/tests/gem_ctx_param.c
> +++ b/tests/gem_ctx_param.c
> @@ -25,6 +25,7 @@
>   */
>  
>  #include "igt.h"
> +#include <limits.h>
>  
>  IGT_TEST_DESCRIPTION("Basic test for context set/get param input validation.");
>  
> @@ -136,11 +137,85 @@ igt_main
>                 gem_context_set_param(fd, &arg);
>         }
>  
> +#define MAX_PRIO 1023
> +#define MIN_PRIO -MAX_PRIO
> +#define DEF_PRIO 0

Take these from the uapi header.

> +
> +       arg.param = I915_CONTEXT_PARAM_PRIORITY;
> +
> +       igt_subtest("root-set-priority") {
> +               arg.ctx_id = ctx;
> +               arg.size = 0;
> +

Bonus points for CAP_SYS_NICE checking.

arg.size validation checking.
arg.value > u32 (checking for overflows)

gem_context_get_param() of a new context should return DEF_PRIO

set_param on older machines returns -ENODEV

And that's not even trying to fuzz bad values beyond the sanity checks
of I915_CONTEXT_PARAM_PRIORITY.

> +               for (int i = MIN_PRIO; i <= MAX_PRIO; i += 1023) {

It's a couple of ioctls, do all 1024. Do them in a random order, trust
no one.

> +                       arg.value = i;
> +                       gem_context_set_param(fd, &arg);
> +
> +                       gem_context_get_param(fd, &arg);
> +                       igt_assert(arg.value == i); /* Verify prio was set */

igt_assert_eq(arg.value, i);

But doesn't verify the priority does anything. Just the RTT in the API,
which is a nice verification nevertheless.

> +               }
> +       }
> +
> +       igt_subtest("root-set-priority-invalid-value") {
> +               int prio_levels[] = {INT_MIN, MIN_PRIO - 1, MAX_PRIO + 1, INT_MAX};
> +               int old_value;
> +               arg.ctx_id = ctx;
> +
> +               gem_context_get_param(fd, &arg);
> +               old_value = arg.value;
> +
> +               for (int i = 0; i < (sizeof(prio_levels) / sizeof(int)); i++) {

ARRAY_SIZE(prio_levels);

> +                       arg.value = prio_levels[i];
> +                       igt_assert_eq(__gem_context_set_param(fd, &arg), -EINVAL);
> +
> +                       gem_context_get_param(fd, &arg);
> +                       igt_assert(arg.value == old_value); /* Verify prio was not set */
> +               }
> +       }
> +
> +       igt_subtest("user-set-priority") {
> +               arg.size = 0;
> +
> +               igt_fork(child, 1) {
> +                       igt_drop_root();
> +                       for (int i = MIN_PRIO; i <= DEF_PRIO; i += 1023) {
> +                               arg.value = i;
> +                               gem_context_set_param(fd, &arg);
> +
> +                               gem_context_get_param(fd, &arg);
> +                               igt_assert(arg.value == i); /* Verify prio was set */

I wonder if the CAP_SYS_NICE limit might be adjusted in the future.
Certainly preemption rules are flexible, as we haven't told anyone about
them yet.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH i-g-t] tests/gem_ctx_param: Update invalid param
  2017-12-16  0:14 ` [PATCH i-g-t] " Chris Wilson
@ 2017-12-18 18:15   ` Antonio Argenziano
  2017-12-18 20:56     ` Chris Wilson
  0 siblings, 1 reply; 6+ messages in thread
From: Antonio Argenziano @ 2017-12-18 18:15 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx



On 15/12/17 16:14, Chris Wilson wrote:
> Quoting Antonio Argenziano (2017-12-15 19:01:11)
>> Since commit: drm/i915/scheduler: Support user-defined priorities, the
>> driver support an extra context param to set context's priority. Add
>> tests for that interface and update invalid tests.
>>
>> Signed-off-by: Antonio Argenziano <antonio.argenziano@intel.com>
>> Cc: Chris Wilson <chris@chris-wilson.co.uk>
>> Cc: Michal Winiarski <michal.winiarski@intel.com>
>> ---
>>   tests/gem_ctx_param.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++-
>>   1 file changed, 76 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/gem_ctx_param.c b/tests/gem_ctx_param.c
>> index c20ae1ee..9a222e60 100644
>> --- a/tests/gem_ctx_param.c
>> +++ b/tests/gem_ctx_param.c
>> @@ -25,6 +25,7 @@
>>    */
>>   
>>   #include "igt.h"
>> +#include <limits.h>
>>   
>>   IGT_TEST_DESCRIPTION("Basic test for context set/get param input validation.");
>>   
>> @@ -136,11 +137,85 @@ igt_main
>>                  gem_context_set_param(fd, &arg);
>>          }
>>   
>> +#define MAX_PRIO 1023
>> +#define MIN_PRIO -MAX_PRIO
>> +#define DEF_PRIO 0
> 
> Take these from the uapi header.
> 
>> +
>> +       arg.param = I915_CONTEXT_PARAM_PRIORITY;
>> +
>> +       igt_subtest("root-set-priority") {
>> +               arg.ctx_id = ctx;
>> +               arg.size = 0;
>> +
> 
> Bonus points for CAP_SYS_NICE checking.
> 
> arg.size validation checking. > arg.value > u32 (checking for overflows)

What is the expectation for overflows? It looks like we only cast value 
to int.

> 
> gem_context_get_param() of a new context should return DEF_PRIO
> 
> set_param on older machines returns -ENODEV
> 
> And that's not even trying to fuzz bad values beyond the sanity checks
> of I915_CONTEXT_PARAM_PRIORITY.
> 
>> +               for (int i = MIN_PRIO; i <= MAX_PRIO; i += 1023) {
> 
> It's a couple of ioctls, do all 1024. Do them in a random order, trust
> no one.

Do we have a lib for doing that (generate a random permutation) already?

> 
>> +                       arg.value = i;
>> +                       gem_context_set_param(fd, &arg);
>> +
>> +                       gem_context_get_param(fd, &arg);
>> +                       igt_assert(arg.value == i); /* Verify prio was set */
> 
> igt_assert_eq(arg.value, i);
> 
> But doesn't verify the priority does anything. Just the RTT in the API,
> which is a nice verification nevertheless.
> 
>> +               }
>> +       }
>> +
>> +       igt_subtest("root-set-priority-invalid-value") {
>> +               int prio_levels[] = {INT_MIN, MIN_PRIO - 1, MAX_PRIO + 1, INT_MAX};
>> +               int old_value;
>> +               arg.ctx_id = ctx;
>> +
>> +               gem_context_get_param(fd, &arg);
>> +               old_value = arg.value;
>> +
>> +               for (int i = 0; i < (sizeof(prio_levels) / sizeof(int)); i++) {
> 
> ARRAY_SIZE(prio_levels);
> 
>> +                       arg.value = prio_levels[i];
>> +                       igt_assert_eq(__gem_context_set_param(fd, &arg), -EINVAL);
>> +
>> +                       gem_context_get_param(fd, &arg);
>> +                       igt_assert(arg.value == old_value); /* Verify prio was not set */
>> +               }
>> +       }
>> +
>> +       igt_subtest("user-set-priority") {
>> +               arg.size = 0;
>> +
>> +               igt_fork(child, 1) {
>> +                       igt_drop_root();
>> +                       for (int i = MIN_PRIO; i <= DEF_PRIO; i += 1023) {
>> +                               arg.value = i;
>> +                               gem_context_set_param(fd, &arg);
>> +
>> +                               gem_context_get_param(fd, &arg);
>> +                               igt_assert(arg.value == i); /* Verify prio was set */
> 
> I wonder if the CAP_SYS_NICE limit might be adjusted in the future.
> Certainly preemption rules are flexible, as we haven't told anyone about
> them yet.

I guess when the change comes we will have a new constant we could swap 
DEF_PRIO with.

-Antonio

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

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

* Re: [PATCH i-g-t] tests/gem_ctx_param: Update invalid param
  2017-12-18 18:15   ` Antonio Argenziano
@ 2017-12-18 20:56     ` Chris Wilson
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Wilson @ 2017-12-18 20:56 UTC (permalink / raw)
  To: Antonio Argenziano, intel-gfx

Quoting Antonio Argenziano (2017-12-18 18:15:35)
> 
> 
> On 15/12/17 16:14, Chris Wilson wrote:
> > Quoting Antonio Argenziano (2017-12-15 19:01:11)
> >> +       arg.param = I915_CONTEXT_PARAM_PRIORITY;
> >> +
> >> +       igt_subtest("root-set-priority") {
> >> +               arg.ctx_id = ctx;
> >> +               arg.size = 0;
> >> +
> > 
> > Bonus points for CAP_SYS_NICE checking.
> > 
> > arg.size validation checking. > arg.value > u32 (checking for overflows)
> 
> What is the expectation for overflows? It looks like we only cast value 
> to int.

That was my point. We could create 1<<32 + prio, so we really should be
failing with -EINVAL rather than setting the parameter to prio. Trust
nothing, least of all the kernel.

> > gem_context_get_param() of a new context should return DEF_PRIO
> > 
> > set_param on older machines returns -ENODEV
> > 
> > And that's not even trying to fuzz bad values beyond the sanity checks
> > of I915_CONTEXT_PARAM_PRIORITY.
> > 
> >> +               for (int i = MIN_PRIO; i <= MAX_PRIO; i += 1023) {
> > 
> > It's a couple of ioctls, do all 1024. Do them in a random order, trust
> > no one.
> 
> Do we have a lib for doing that (generate a random permutation) already?

See igt_permute_array. Maybe igt_random_array(count, prng_state).

> >> +                       arg.value = prio_levels[i];
> >> +                       igt_assert_eq(__gem_context_set_param(fd, &arg), -EINVAL);
> >> +
> >> +                       gem_context_get_param(fd, &arg);
> >> +                       igt_assert(arg.value == old_value); /* Verify prio was not set */
> >> +               }
> >> +       }
> >> +
> >> +       igt_subtest("user-set-priority") {
> >> +               arg.size = 0;
> >> +
> >> +               igt_fork(child, 1) {
> >> +                       igt_drop_root();
> >> +                       for (int i = MIN_PRIO; i <= DEF_PRIO; i += 1023) {
> >> +                               arg.value = i;
> >> +                               gem_context_set_param(fd, &arg);
> >> +
> >> +                               gem_context_get_param(fd, &arg);
> >> +                               igt_assert(arg.value == i); /* Verify prio was set */
> > 
> > I wonder if the CAP_SYS_NICE limit might be adjusted in the future.
> > Certainly preemption rules are flexible, as we haven't told anyone about
> > them yet.
> 
> I guess when the change comes we will have a new constant we could swap 
> DEF_PRIO with.

The question is whether it is ABI, as it may be changed. If its not,
don't enshrine it into law.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2017-12-18 20:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-15 19:01 [PATCH i-g-t] tests/gem_ctx_param: Update invalid param Antonio Argenziano
2017-12-15 19:38 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-12-15 22:40 ` ✓ Fi.CI.IGT: " Patchwork
2017-12-16  0:14 ` [PATCH i-g-t] " Chris Wilson
2017-12-18 18:15   ` Antonio Argenziano
2017-12-18 20:56     ` Chris Wilson

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.