From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Alan Previn <alan.previn.teres.alexis@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t v2 02/15] Add basic PXP testing of buffer and context alloc
Date: Wed, 21 Apr 2021 06:09:59 -0400 [thread overview]
Message-ID: <YH/59zJ9UpQc0ZN3@intel.com> (raw)
In-Reply-To: <20210325054549.465386-3-alan.previn.teres.alexis@intel.com>
On Wed, Mar 24, 2021 at 10:45:36PM -0700, Alan Previn wrote:
> Test PXP capability support as well as the allocation of protected
> buffers and protected contexts.
>
> Signed-off-by: Alan Previn <alan.previn.teres.alexis@intel.com>
> ---
> tests/Makefile.sources | 3 +
> tests/i915/gem_pxp.c | 410 +++++++++++++++++++++++++++++++++++++++++
> tests/meson.build | 1 +
> 3 files changed, 414 insertions(+)
> create mode 100644 tests/i915/gem_pxp.c
>
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index 4f24fb3a..05952066 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -370,6 +370,9 @@ gem_pwrite_SOURCES = i915/gem_pwrite.c
> TESTS_progs += gem_pwrite_snooped
> gem_pwrite_snooped_SOURCES = i915/gem_pwrite_snooped.c
>
> +TESTS_progs += gem_pxp
> +gem_pxp_SOURCES = i915/gem_pxp.c
> +
> TESTS_progs += gem_read_read_speed
> gem_read_read_speed_SOURCES = i915/gem_read_read_speed.c
>
> diff --git a/tests/i915/gem_pxp.c b/tests/i915/gem_pxp.c
> new file mode 100644
> index 00000000..40a817b2
> --- /dev/null
> +++ b/tests/i915/gem_pxp.c
> @@ -0,0 +1,410 @@
> +// SPDX-License-Identifier: MIT
> +/*
> + * Copyright © 2021 Intel Corporation
> + */
> +
> +#include <sys/ioctl.h>
> +
> +#include "igt.h"
> +#include "i915/gem.h"
> +
> +IGT_TEST_DESCRIPTION("Test PXP (Protected Xe Path), which is the component "
> + "that allows the handling of protected content through "
> + "the arbitration of hardware protected sessions.");
> +
> +/* test-configs for protected buffer creation*/
^ missing space
> +#define BO_ALLOC_NO_HW_SUPPORT 1
> +#define BO_ALLOC_PROTECT_ON 2
> +#define BO_ALLOC_PROTECT_OFF 3
> +
> +/* test-configs for protected context creation*/
^ missing space
> +#define CTX_ALLOC_NO_HW_SUPPORT 1
> +#define CTX_ALLOC_RECOVER_OFF_PROTECT_OFF 2
> +#define CTX_ALLOC_RECOVER_OFF_PROTECT_ON 3
> +#define CTX_ALLOC_RECOVER_ON_PROTECT_OFF 4
> +#define CTX_ALLOC_RECOVER_ON_PROTECT_ON 5
> +#define CTX_MODIFY_PROTECTED_RECOVER_OFF_TO_ON 6
> +#define CTX_MODIFY_PROTECTED_PROTECT_ON_TO_OFF 7
> +#define CTX_MODIFY_PROTECTED_BOTHPARAMS_TO_INVALID 8
> +#define CTX_MODIFY_UNPROTECTED_BOTHPARAMS_TO_VALID 9
> +
> +static bool is_pxp_hw_supported(int i915)
> +{
> + uint32_t gen;
> +
> + gen = intel_gen(intel_get_drm_devid(i915));
> + if (!gen) {
> + igt_info("No device info found - assume no PXP support.\n");
> + return false;
> + }
> +
> + if (gen >= 12)
> + return true;
> +
> + return false;
> +}
> +
> +static uint32_t create_protected_bo(int i915, uint32_t size,
> + bool with_protected_param,
> + bool protected_is_true, int expected_return)
why do you need both with_protected_param and protected_is_true?
I searched the series and it looks like they always match, so why not simply
static uint32_t create_bo(int i915, uint32_t size, bool protected, int return_assert)
?
> +{
> + int ret;
> +
> + struct drm_i915_gem_object_param protected_param = {
> + .param = I915_OBJECT_PARAM | I915_OBJECT_PARAM_PROTECTED_CONTENT,
> + .data = 0,
> + };
> +
> + struct drm_i915_gem_create_ext_setparam setparam_protected = {
> + .base = { .name = I915_GEM_CREATE_EXT_SETPARAM },
> + .param = protected_param,
> + };
> +
> + struct drm_i915_gem_create_ext create_ext = {
> + .size = size,
> + .extensions = (uintptr_t)&setparam_protected,
> + };
> +
> + if (!with_protected_param) {
> + create_ext.extensions = 0;
> + } else {
> + if (protected_is_true) {
> + protected_param.data = 1;
> + setparam_protected.param = protected_param;
> + } else {
> + protected_param.data = 0;
> + setparam_protected.param = protected_param;
> + }
> + }
> +
> + ret = ioctl(i915, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext);
> + igt_assert_eq(ret, expected_return);
> +
> + return create_ext.handle;
> +}
> +
> +static void test_create_protected_buffer(int i915, uint32_t test_cfg)
> +{
> + uint32_t bo;
> +
> + switch (test_cfg) {
> + case BO_ALLOC_NO_HW_SUPPORT:
> + bo = create_protected_bo(i915, 4096, false, false, 0);
> + gem_close(i915, bo);
> + bo = create_protected_bo(i915, 4096, true, true, -ENODEV);
> + igt_assert_eq(bo, 0);
> + break;
> +
> + case BO_ALLOC_PROTECT_OFF:
> + bo = create_protected_bo(i915, 4096, false, false, 0);
> + gem_close(i915, bo);
> + break;
> +
> + case BO_ALLOC_PROTECT_ON:
> + bo = create_protected_bo(i915, 4096, true, true, 0);
> + gem_close(i915, bo);
> + break;
> +
> + default:
> + igt_info("Skipping unknown buffer test_cfg = %d\n", test_cfg);
> + break;
> + }
> +}
> +
> +static int create_ext_ioctl(int i915,
> + struct drm_i915_gem_context_create_ext *arg)
> +{
> + int err;
> +
> + err = 0;
> + if (igt_ioctl(i915, DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT, arg)) {
> + err = -errno;
> + igt_assume(err);
> + }
> +
> + errno = 0;
> + return err;
> +}
> +
> +static uint32_t create_protected_ctx(int i915, bool with_protected_param,
> + bool protected_is_true,
> + bool with_recoverable_param,
> + bool recoverable_is_true,
> + int expected_return)
> +{
> + int ret;
> +
> + struct drm_i915_gem_context_create_ext_setparam p_prot = {
> + .base = {
> + .name = I915_CONTEXT_CREATE_EXT_SETPARAM,
> + .next_extension = 0,
> + },
> + .param = {
> + .param = I915_CONTEXT_PARAM_PROTECTED_CONTENT,
> + .value = 0,
> + }
> + };
> + struct drm_i915_gem_context_create_ext_setparam p_norecover = {
> + .base = {
> + .name = I915_CONTEXT_CREATE_EXT_SETPARAM,
> + .next_extension = 0,
> + },
> + .param = {
> + .param = I915_CONTEXT_PARAM_RECOVERABLE,
> + .value = 0,
> + }
> + };
> + struct drm_i915_gem_context_create_ext create = {
> + .flags = I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS,
> + .extensions = 0,
> + };
> +
> + p_prot.param.value = protected_is_true;
> + p_norecover.param.value = recoverable_is_true;
> +
> + if (with_protected_param && with_recoverable_param) {
> + create.extensions = to_user_pointer(&(p_norecover.base));
> + p_norecover.base.next_extension =
> + to_user_pointer(&(p_prot.base));
> + } else if (!with_protected_param && with_recoverable_param) {
> + create.extensions = to_user_pointer(&(p_norecover.base));
> + p_norecover.base.next_extension = 0;
> + } else if (with_protected_param && !with_recoverable_param) {
> + create.extensions = to_user_pointer(&(p_prot.base));
> + p_prot.base.next_extension = 0;
> + } else if (!with_protected_param && !with_recoverable_param) {
> + create.flags = 0;
> + }
> +
> + ret = create_ext_ioctl(i915, &create);
> + igt_assert_eq(ret, expected_return);
> +
> + return create.ctx_id;
> +}
> +
> +#define CHANGE_PARAM_PROTECTED 0x0001
> +#define CHANGE_PARAM_RECOVERY 0x0002
> +static void modify_ctx_protected_param(int i915, uint32_t ctx_id,
> + uint32_t change_param_mask,
> + bool param_value, int expected_return)
> +{
> + int ret;
> +
> + struct drm_i915_gem_context_param ctx_param = {
> + .ctx_id = ctx_id,
> + .param = 0,
> + .value = 0,
> + };
> +
> + if (change_param_mask == CHANGE_PARAM_PROTECTED) {
> + ctx_param.param = I915_CONTEXT_PARAM_PROTECTED_CONTENT;
> + ctx_param.value = (int)param_value;
> + } else if (change_param_mask == CHANGE_PARAM_RECOVERY) {
> + ctx_param.param = I915_CONTEXT_PARAM_RECOVERABLE;
> + ctx_param.value = (int)param_value;
> + } else {
> + return;
> + }
> +
> + ret = ioctl(i915, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &ctx_param);
> +
> + igt_assert_eq(ret, expected_return);
> +}
> +
> +static void assert_ctx_protected_param(int i915, uint32_t ctx_id,
> + bool is_protected)
> +{
> + int ret;
> +
> + struct drm_i915_gem_context_param ctx_param = {
> + .ctx_id = ctx_id,
> + .param = I915_CONTEXT_PARAM_PROTECTED_CONTENT,
> + };
> +
> + ret = ioctl(i915, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &ctx_param);
> + igt_assert_eq(ret, 0);
> + igt_assert_eq(ctx_param.value, (int)is_protected);
> +}
> +
> +static void assert_ctx_recovery_param(int i915, uint32_t ctx_id,
> + bool is_recoverable)
> +{
> + int ret;
> +
> + struct drm_i915_gem_context_param ctx_param = {
> + .ctx_id = ctx_id,
> + .param = I915_CONTEXT_PARAM_RECOVERABLE,
> + };
> +
> + ret = ioctl(i915, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &ctx_param);
> + igt_assert_eq(ret, 0);
> + igt_assert_eq(ctx_param.value, (int)is_recoverable);
> +}
> +
> +static void test_create_protected_context(int i915, uint32_t test_cfg)
> +{
> + uint32_t ctx;
> +
> + switch (test_cfg) {
> + case CTX_ALLOC_NO_HW_SUPPORT:
> + ctx = create_protected_ctx(i915, true, true, true, false,
> + -ENODEV);
> + igt_assert_eq(ctx, 0);
> + case CTX_ALLOC_RECOVER_OFF_PROTECT_OFF:
> + ctx = create_protected_ctx(i915, true, false, true, false, 0);
> + assert_ctx_protected_param(i915, ctx, false);
> + assert_ctx_recovery_param(i915, ctx, false);
> + gem_context_destroy(i915, ctx);
> + break;
> +
> + case CTX_ALLOC_RECOVER_OFF_PROTECT_ON:
> + ctx = create_protected_ctx(i915, true, true, true, false, 0);
> + assert_ctx_protected_param(i915, ctx, true);
> + assert_ctx_recovery_param(i915, ctx, false);
> + gem_context_destroy(i915, ctx);
> + break;
> +
> + case CTX_ALLOC_RECOVER_ON_PROTECT_OFF:
> + ctx = create_protected_ctx(i915, true, false, true, true, 0);
> + assert_ctx_protected_param(i915, ctx, false);
> + assert_ctx_recovery_param(i915, ctx, true);
> + gem_context_destroy(i915, ctx);
> + break;
> +
> + case CTX_ALLOC_RECOVER_ON_PROTECT_ON:
> + ctx = create_protected_ctx(i915, true, true, true, true,
> + -EPERM);
> + igt_assert_eq(ctx, 0);
> + ctx = create_protected_ctx(i915, true, true, false, false,
> + -EPERM);
> + igt_assert_eq(ctx, 0);
> + break;
> +
> + case CTX_MODIFY_PROTECTED_RECOVER_OFF_TO_ON:
> + ctx = create_protected_ctx(i915, true, true, true, false, 0);
> + assert_ctx_protected_param(i915, ctx, true);
> + assert_ctx_recovery_param(i915, ctx, false);
> + modify_ctx_protected_param(i915, ctx, CHANGE_PARAM_RECOVERY,
> + true, -EPERM);
> + assert_ctx_recovery_param(i915, ctx, false);
> + gem_context_destroy(i915, ctx);
> + break;
> +
> + case CTX_MODIFY_PROTECTED_PROTECT_ON_TO_OFF:
> + ctx = create_protected_ctx(i915, true, true, true, false, 0);
> + assert_ctx_protected_param(i915, ctx, true);
> + assert_ctx_recovery_param(i915, ctx, false);
> + modify_ctx_protected_param(i915, ctx, CHANGE_PARAM_PROTECTED,
> + false, -EPERM);
> + assert_ctx_protected_param(i915, ctx, true);
> + assert_ctx_recovery_param(i915, ctx, false);
> + gem_context_destroy(i915, ctx);
> + break;
> +
> + case CTX_MODIFY_PROTECTED_BOTHPARAMS_TO_INVALID:
> + ctx = create_protected_ctx(i915, true, true, true, false, 0);
> + assert_ctx_protected_param(i915, ctx, true);
> + assert_ctx_recovery_param(i915, ctx, false);
> + modify_ctx_protected_param(i915, ctx, CHANGE_PARAM_RECOVERY,
> + true, -EPERM);
> + modify_ctx_protected_param(i915, ctx, CHANGE_PARAM_PROTECTED,
> + false, -EPERM);
> + assert_ctx_protected_param(i915, ctx, true);
> + assert_ctx_recovery_param(i915, ctx, false);
> + gem_context_destroy(i915, ctx);
> + break;
> +
> + case CTX_MODIFY_UNPROTECTED_BOTHPARAMS_TO_VALID:
> + ctx = create_protected_ctx(i915, false, false, false, false, 0);
> + assert_ctx_protected_param(i915, ctx, false);
> + assert_ctx_recovery_param(i915, ctx, true);
> + modify_ctx_protected_param(i915, ctx, CHANGE_PARAM_RECOVERY,
> + false, 0);
> + modify_ctx_protected_param(i915, ctx, CHANGE_PARAM_PROTECTED,
> + true, -EPERM);
> + assert_ctx_protected_param(i915, ctx, false);
> + assert_ctx_recovery_param(i915, ctx, false);
> + gem_context_destroy(i915, ctx);
> + break;
> +
> + default:
> + igt_info("Skipping unknown context test_cfg = %d\n", test_cfg);
> + break;
> + }
> +}
> +
> +igt_main
> +{
> + int i915 = -1;
> + bool pxp_supported = false;
> +
> + igt_fixture
> + {
> + i915 = drm_open_driver(DRIVER_INTEL);
> + igt_require(i915);
> + igt_require_gem(i915);
> + pxp_supported = is_pxp_hw_supported(i915);
> + }
> +
> + igt_subtest_group {
> + igt_fixture {
> + igt_require((pxp_supported == 0));
> + }
> +
> + igt_describe("Verify protected buffer on unsupported hw:");
> + igt_subtest("hw-rejects-pxp-buffer")
> + test_create_protected_buffer(i915,
> + BO_ALLOC_NO_HW_SUPPORT);
> + igt_describe("Verify protected context on unsupported hw:");
> + igt_subtest("hw-rejects-pxp-context")
> + test_create_protected_context(i915,
> + CTX_ALLOC_NO_HW_SUPPORT);
> + }
> +
> + igt_subtest_group {
> + igt_fixture {
> + igt_require(pxp_supported);
> + }
> +
> + igt_describe("Verify protected buffer on supported hw:");
> + igt_subtest("create-regular-buffer")
> + test_create_protected_buffer(i915,
> + BO_ALLOC_PROTECT_OFF);
> + igt_subtest("create-protected-buffer")
> + test_create_protected_buffer(i915, BO_ALLOC_PROTECT_ON);
> +
> + igt_describe("Verify protected context on supported hw:");
> + igt_subtest("create-regular-context-1")
> + test_create_protected_context(
> + i915, CTX_ALLOC_RECOVER_OFF_PROTECT_OFF);
> + igt_subtest("create-regular-context-2")
> + test_create_protected_context(
> + i915, CTX_ALLOC_RECOVER_ON_PROTECT_OFF);
> + igt_subtest("fail-invalid-protected-context")
> + test_create_protected_context(
> + i915, CTX_ALLOC_RECOVER_ON_PROTECT_ON);
> + igt_subtest("create-valid-protected-context")
> + test_create_protected_context(
> + i915, CTX_ALLOC_RECOVER_OFF_PROTECT_ON);
> +
> + igt_describe("Verify protected context integrity:");
> + igt_subtest("reject-modify-context-protection-on")
> + test_create_protected_context(
> + i915,
> + CTX_MODIFY_UNPROTECTED_BOTHPARAMS_TO_VALID);
> + igt_subtest("reject-modify-context-protection-off-1")
> + test_create_protected_context(
> + i915, CTX_MODIFY_PROTECTED_RECOVER_OFF_TO_ON);
> + igt_subtest("reject-modify-context-protection-off-2")
> + test_create_protected_context(
> + i915, CTX_MODIFY_PROTECTED_PROTECT_ON_TO_OFF);
> + igt_subtest("reject-modify-context-protection-off-3")
> + test_create_protected_context(
> + i915,
> + CTX_MODIFY_PROTECTED_BOTHPARAMS_TO_INVALID);
> + }
> +
> + igt_fixture {
> + close(i915);
> + }
> +}
> diff --git a/tests/meson.build b/tests/meson.build
> index 825e0183..e7144039 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -189,6 +189,7 @@ i915_progs = [
> 'gem_pread_after_blit',
> 'gem_pwrite',
> 'gem_pwrite_snooped',
> + 'gem_pxp',
> 'gem_read_read_speed',
> 'gem_readwrite',
> 'gem_reg_read',
> --
> 2.25.1
>
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2021-04-21 10:10 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-25 5:45 [igt-dev] [PATCH i-g-t v2 00/15] Introduce PXP Test Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 01/15] Sync i915_drm.h UAPI for PXP Alan Previn
2021-04-21 10:10 ` Rodrigo Vivi
2021-04-21 10:33 ` Petri Latvala
2021-04-21 20:53 ` Teres Alexis, Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 02/15] Add basic PXP testing of buffer and context alloc Alan Previn
2021-04-21 10:09 ` Rodrigo Vivi [this message]
2021-05-13 19:23 ` Teres Alexis, Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 03/15] Perform a regular 3d copy as a control checkpoint Alan Previn
2021-04-21 10:28 ` Rodrigo Vivi
2021-04-21 20:57 ` Teres Alexis, Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 04/15] Add PXP attribute support in batchbuffer and buffer_ops libs Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 05/15] Add MI_SET_APPID instruction definition Alan Previn
2021-04-21 12:30 ` Rodrigo Vivi
2021-04-21 20:58 ` Teres Alexis, Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 06/15] Enable protected session cmd in gen12_render_copyfunc Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 07/15] Add subtest to copy raw source to protected dest Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 08/15] Add test where both src and dest are protected Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 09/15] Verify PXP teardown occured through suspend-resume Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 10/15] Verify execbuf fails with stale PXP context after teardown Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 11/15] Verify execbuf fails with stale PXP buffer " Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 12/15] Verify execbuf ok with stale prot-buff and regular context Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 13/15] Ensure RESET_STAT reports invalidated protected context Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 14/15] Verify protected surfaces are dma buffer sharable Alan Previn
2021-03-25 5:45 ` [igt-dev] [PATCH i-g-t v2 15/15] tests/i915_pxp: CRC validation for display tests Alan Previn
2021-03-25 13:47 ` [igt-dev] ✓ Fi.CI.BAT: success for Introduce PXP Test (rev2) Patchwork
2021-03-25 16:46 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YH/59zJ9UpQc0ZN3@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=alan.previn.teres.alexis@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox