* [PATCH v4 0/3] tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs
@ 2026-11-10 8:28 Lukasz Laguna
2026-11-10 8:28 ` [PATCH v4 1/3] lib/igt_sriov_device: Add helpers to get SR-IOV function name Lukasz Laguna
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Lukasz Laguna @ 2026-11-10 8:28 UTC (permalink / raw)
To: igt-dev; +Cc: marcin.bernatowicz, piotr.piorkowski
In case of SR-IOV, the VF has limited access to the registers. Let's add
tests to verify that the VF actually has access only to the allowed list
of registers, and verify that registers dedicated to VFs work properly.
Lukasz Laguna (2):
lib/igt_sriov_device: Add helpers to get SR-IOV function name
intel-ci: Block igt@xe_sriov_mmio_regs.*
Piotr Piórkowski (1):
tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs
lib/igt_sriov_device.c | 53 +++-
lib/igt_sriov_device.h | 2 +
tests/intel-ci/xe.blocklist.txt | 1 +
tests/intel/xe_sriov_mmio_regs.c | 408 +++++++++++++++++++++++++++++++
tests/meson.build | 1 +
5 files changed, 462 insertions(+), 3 deletions(-)
create mode 100644 tests/intel/xe_sriov_mmio_regs.c
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v4 1/3] lib/igt_sriov_device: Add helpers to get SR-IOV function name 2026-11-10 8:28 [PATCH v4 0/3] tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs Lukasz Laguna @ 2026-11-10 8:28 ` Lukasz Laguna 2026-11-10 9:48 ` Bernatowicz, Marcin 2026-11-10 11:42 ` Kamil Konieczny 2026-11-10 8:28 ` [PATCH v4 2/3] tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs Lukasz Laguna ` (2 subsequent siblings) 3 siblings, 2 replies; 7+ messages in thread From: Lukasz Laguna @ 2026-11-10 8:28 UTC (permalink / raw) To: igt-dev; +Cc: marcin.bernatowicz, piotr.piorkowski Introduce helpers to format SR-IOV function names in lowercase and uppercase variants. They format PF as "pf" or "PF" and VFs as "vf%u" or "VF%u" depending on the variant. Keep igt_sriov_func_str() as a compatibility wrapper around the lowercase, so existing callers continue to work while the code migrates to the new API. Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com> --- lib/igt_sriov_device.c | 53 +++++++++++++++++++++++++++++++++++++++--- lib/igt_sriov_device.h | 2 ++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/lib/igt_sriov_device.c b/lib/igt_sriov_device.c index 6c9fbdf70..de446aca1 100644 --- a/lib/igt_sriov_device.c +++ b/lib/igt_sriov_device.c @@ -54,13 +54,60 @@ const char *igt_sriov_func_str(unsigned int vf_num) { static __thread char buf[16]; - if (vf_num == 0) - return "pf"; + return igt_sriov_function_name_lower(vf_num, buf, sizeof(buf)); +} + +static const char *sriov_function_name(unsigned int vf_num, bool uppercase, + char *buf, size_t size) +{ + int ret; + + igt_assert(buf && size); + + if (vf_num) + ret = snprintf(buf, size, uppercase ? "VF%u" : "vf%u", vf_num); + else + ret = snprintf(buf, size, uppercase ? "PF" : "pf"); + + igt_assert(ret >= 0 && (size_t)ret < size); - snprintf(buf, sizeof(buf), "vf%u", vf_num); return buf; } +/** + * igt_sriov_function_name_lower - Get SR-IOV function name in lowercase + * @vf_num: VF number (1-based to identify single VF) or 0 for PF + * @buf: buffer + * @size: size of the buffer + * + * It formats the function name as "pf" when @vf_num is 0, or as "vf%u" + * when @vf_num is greater than 0. + * + * Return: formatted function name. + */ +const char *igt_sriov_function_name_lower(unsigned int vf_num, char *buf, + size_t size) +{ + return sriov_function_name(vf_num, false, buf, size); +} + +/** + * igt_sriov_function_name_upper - Get SR-IOV function name in uppercase + * @vf_num: VF number (1-based to identify single VF) or 0 for PF + * @buf: buffer + * @size: size of the buffer + * + * It formats the function name as "PF" when @vf_num is 0, or as "VF%u" + * when @vf_num is greater than 0. + * + * Return: formatted function name. + */ +const char *igt_sriov_function_name_upper(unsigned int vf_num, char *buf, + size_t size) +{ + return sriov_function_name(vf_num, true, buf, size); +} + static bool __pf_attr_get_u32(int pf, const char *attr, uint32_t *value) { int sysfs; diff --git a/lib/igt_sriov_device.h b/lib/igt_sriov_device.h index 4e4ba230a..0e94c521a 100644 --- a/lib/igt_sriov_device.h +++ b/lib/igt_sriov_device.h @@ -36,6 +36,8 @@ bool igt_sriov_device_reset_exists(int pf, unsigned int vf_num); bool igt_sriov_device_reset(int pf, unsigned int vf_num); bool intel_is_vf_device(int device); const char *igt_sriov_func_str(unsigned int vf_num); +const char *igt_sriov_function_name_lower(unsigned int vf_num, char *buf, size_t size); +const char *igt_sriov_function_name_upper(unsigned int vf_num, char *buf, size_t size); typedef void (*igt_sriov_exit_cleanup_fn)(int pf, int sig, void *user_data); void igt_sriov_install_exit_handler(int pf, igt_sriov_exit_cleanup_fn cleanup_fn, -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v4 1/3] lib/igt_sriov_device: Add helpers to get SR-IOV function name 2026-11-10 8:28 ` [PATCH v4 1/3] lib/igt_sriov_device: Add helpers to get SR-IOV function name Lukasz Laguna @ 2026-11-10 9:48 ` Bernatowicz, Marcin 2026-11-10 11:42 ` Kamil Konieczny 1 sibling, 0 replies; 7+ messages in thread From: Bernatowicz, Marcin @ 2026-11-10 9:48 UTC (permalink / raw) To: Lukasz Laguna, igt-dev; +Cc: marcin.bernatowicz, piotr.piorkowski LGTM, Reviewed-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com> On 11/10/2026 9:28 AM, Lukasz Laguna wrote: > Introduce helpers to format SR-IOV function names in lowercase and > uppercase variants. They format PF as "pf" or "PF" and VFs as "vf%u" or > "VF%u" depending on the variant. > > Keep igt_sriov_func_str() as a compatibility wrapper around the > lowercase, so existing callers continue to work while the code migrates > to the new API. > > Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com> > --- > lib/igt_sriov_device.c | 53 +++++++++++++++++++++++++++++++++++++++--- > lib/igt_sriov_device.h | 2 ++ > 2 files changed, 52 insertions(+), 3 deletions(-) > > diff --git a/lib/igt_sriov_device.c b/lib/igt_sriov_device.c > index 6c9fbdf70..de446aca1 100644 > --- a/lib/igt_sriov_device.c > +++ b/lib/igt_sriov_device.c > @@ -54,13 +54,60 @@ const char *igt_sriov_func_str(unsigned int vf_num) > { > static __thread char buf[16]; > > - if (vf_num == 0) > - return "pf"; > + return igt_sriov_function_name_lower(vf_num, buf, sizeof(buf)); > +} > + > +static const char *sriov_function_name(unsigned int vf_num, bool uppercase, > + char *buf, size_t size) > +{ > + int ret; > + > + igt_assert(buf && size); > + > + if (vf_num) > + ret = snprintf(buf, size, uppercase ? "VF%u" : "vf%u", vf_num); > + else > + ret = snprintf(buf, size, uppercase ? "PF" : "pf"); > + > + igt_assert(ret >= 0 && (size_t)ret < size); > > - snprintf(buf, sizeof(buf), "vf%u", vf_num); > return buf; > } > > +/** > + * igt_sriov_function_name_lower - Get SR-IOV function name in lowercase > + * @vf_num: VF number (1-based to identify single VF) or 0 for PF > + * @buf: buffer > + * @size: size of the buffer > + * > + * It formats the function name as "pf" when @vf_num is 0, or as "vf%u" > + * when @vf_num is greater than 0. > + * > + * Return: formatted function name. > + */ > +const char *igt_sriov_function_name_lower(unsigned int vf_num, char *buf, > + size_t size) > +{ > + return sriov_function_name(vf_num, false, buf, size); > +} > + > +/** > + * igt_sriov_function_name_upper - Get SR-IOV function name in uppercase > + * @vf_num: VF number (1-based to identify single VF) or 0 for PF > + * @buf: buffer > + * @size: size of the buffer > + * > + * It formats the function name as "PF" when @vf_num is 0, or as "VF%u" > + * when @vf_num is greater than 0. > + * > + * Return: formatted function name. > + */ > +const char *igt_sriov_function_name_upper(unsigned int vf_num, char *buf, > + size_t size) > +{ > + return sriov_function_name(vf_num, true, buf, size); > +} > + > static bool __pf_attr_get_u32(int pf, const char *attr, uint32_t *value) > { > int sysfs; > diff --git a/lib/igt_sriov_device.h b/lib/igt_sriov_device.h > index 4e4ba230a..0e94c521a 100644 > --- a/lib/igt_sriov_device.h > +++ b/lib/igt_sriov_device.h > @@ -36,6 +36,8 @@ bool igt_sriov_device_reset_exists(int pf, unsigned int vf_num); > bool igt_sriov_device_reset(int pf, unsigned int vf_num); > bool intel_is_vf_device(int device); > const char *igt_sriov_func_str(unsigned int vf_num); > +const char *igt_sriov_function_name_lower(unsigned int vf_num, char *buf, size_t size); > +const char *igt_sriov_function_name_upper(unsigned int vf_num, char *buf, size_t size); > typedef void (*igt_sriov_exit_cleanup_fn)(int pf, int sig, void *user_data); > void igt_sriov_install_exit_handler(int pf, > igt_sriov_exit_cleanup_fn cleanup_fn, ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 1/3] lib/igt_sriov_device: Add helpers to get SR-IOV function name 2026-11-10 8:28 ` [PATCH v4 1/3] lib/igt_sriov_device: Add helpers to get SR-IOV function name Lukasz Laguna 2026-11-10 9:48 ` Bernatowicz, Marcin @ 2026-11-10 11:42 ` Kamil Konieczny 1 sibling, 0 replies; 7+ messages in thread From: Kamil Konieczny @ 2026-11-10 11:42 UTC (permalink / raw) To: Lukasz Laguna; +Cc: igt-dev, marcin.bernatowicz, piotr.piorkowski Hi Lukasz, On 2026-11-10 at 09:28:36 +0100, Lukasz Laguna wrote: > Introduce helpers to format SR-IOV function names in lowercase and > uppercase variants. They format PF as "pf" or "PF" and VFs as "vf%u" or > "VF%u" depending on the variant. > > Keep igt_sriov_func_str() as a compatibility wrapper around the > lowercase, so existing callers continue to work while the code migrates > to the new API. > > Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com> > --- > lib/igt_sriov_device.c | 53 +++++++++++++++++++++++++++++++++++++++--- > lib/igt_sriov_device.h | 2 ++ > 2 files changed, 52 insertions(+), 3 deletions(-) > > diff --git a/lib/igt_sriov_device.c b/lib/igt_sriov_device.c > index 6c9fbdf70..de446aca1 100644 > --- a/lib/igt_sriov_device.c > +++ b/lib/igt_sriov_device.c > @@ -54,13 +54,60 @@ const char *igt_sriov_func_str(unsigned int vf_num) > { > static __thread char buf[16]; > > - if (vf_num == 0) > - return "pf"; > + return igt_sriov_function_name_lower(vf_num, buf, sizeof(buf)); > +} > + > +static const char *sriov_function_name(unsigned int vf_num, bool uppercase, bool param is imho unneceserry here, better to have for example two strings: static const char *sriov_function_name(unsigned int vf_num, char *pfname, char *vfname, > + char *buf, size_t size) > +{ > + int ret; > + > + igt_assert(buf && size); > + > + if (vf_num) > + ret = snprintf(buf, size, uppercase ? "VF%u" : "vf%u", vf_num); Using above: ret = snprintf(buf, size, "%s%u", vfname, vf_num); > + else > + ret = snprintf(buf, size, uppercase ? "PF" : "pf"); ret = snprintf(buf, size, "%s", pfname); > + > + igt_assert(ret >= 0 && (size_t)ret < size); > > - snprintf(buf, sizeof(buf), "vf%u", vf_num); > return buf; > } > > +/** > + * igt_sriov_function_name_lower - Get SR-IOV function name in lowercase > + * @vf_num: VF number (1-based to identify single VF) or 0 for PF > + * @buf: buffer > + * @size: size of the buffer > + * > + * It formats the function name as "pf" when @vf_num is 0, or as "vf%u" > + * when @vf_num is greater than 0. > + * > + * Return: formatted function name. > + */ > +const char *igt_sriov_function_name_lower(unsigned int vf_num, char *buf, > + size_t size) > +{ > + return sriov_function_name(vf_num, false, buf, size); imho better: return sriov_function_name(vf_num, "pf", "vf", buf, size); > +} > + > +/** > + * igt_sriov_function_name_upper - Get SR-IOV function name in uppercase > + * @vf_num: VF number (1-based to identify single VF) or 0 for PF > + * @buf: buffer > + * @size: size of the buffer > + * > + * It formats the function name as "PF" when @vf_num is 0, or as "VF%u" > + * when @vf_num is greater than 0. > + * > + * Return: formatted function name. > + */ > +const char *igt_sriov_function_name_upper(unsigned int vf_num, char *buf, > + size_t size) > +{ imho better: return sriov_function_name(vf_num, "PF", "VF", buf, size); Regards, Kamil > + return sriov_function_name(vf_num, true, buf, size); > +} > + > static bool __pf_attr_get_u32(int pf, const char *attr, uint32_t *value) > { > int sysfs; > diff --git a/lib/igt_sriov_device.h b/lib/igt_sriov_device.h > index 4e4ba230a..0e94c521a 100644 > --- a/lib/igt_sriov_device.h > +++ b/lib/igt_sriov_device.h > @@ -36,6 +36,8 @@ bool igt_sriov_device_reset_exists(int pf, unsigned int vf_num); > bool igt_sriov_device_reset(int pf, unsigned int vf_num); > bool intel_is_vf_device(int device); > const char *igt_sriov_func_str(unsigned int vf_num); > +const char *igt_sriov_function_name_lower(unsigned int vf_num, char *buf, size_t size); > +const char *igt_sriov_function_name_upper(unsigned int vf_num, char *buf, size_t size); > typedef void (*igt_sriov_exit_cleanup_fn)(int pf, int sig, void *user_data); > void igt_sriov_install_exit_handler(int pf, > igt_sriov_exit_cleanup_fn cleanup_fn, > -- > 2.43.0 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 2/3] tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs 2026-11-10 8:28 [PATCH v4 0/3] tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs Lukasz Laguna 2026-11-10 8:28 ` [PATCH v4 1/3] lib/igt_sriov_device: Add helpers to get SR-IOV function name Lukasz Laguna @ 2026-11-10 8:28 ` Lukasz Laguna 2026-11-10 8:28 ` [PATCH v4 3/3] intel-ci: Block igt@xe_sriov_mmio_regs.* Lukasz Laguna 2026-11-10 17:30 ` ✗ Fi.CI.BUILD: failure for tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs (rev5) Patchwork 3 siblings, 0 replies; 7+ messages in thread From: Lukasz Laguna @ 2026-11-10 8:28 UTC (permalink / raw) To: igt-dev; +Cc: marcin.bernatowicz, piotr.piorkowski From: Piotr Piórkowski <piotr.piorkowski@intel.com> In case of SR-IOV, the VF has limited access to the registers. Let's add tests to verify that the VF actually has access only to the allowed list of registers, and verify that registers dedicated to VFs work properly. Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com> Co-developed-by: Lukasz Laguna <lukasz.laguna@intel.com> Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com> Reviewed-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com> --- v4: - fix compilation issue --- tests/intel/xe_sriov_mmio_regs.c | 408 +++++++++++++++++++++++++++++++ tests/meson.build | 1 + 2 files changed, 409 insertions(+) create mode 100644 tests/intel/xe_sriov_mmio_regs.c diff --git a/tests/intel/xe_sriov_mmio_regs.c b/tests/intel/xe_sriov_mmio_regs.c new file mode 100644 index 000000000..121ebdea6 --- /dev/null +++ b/tests/intel/xe_sriov_mmio_regs.c @@ -0,0 +1,408 @@ +// SPDX-License-Identifier: MIT +/* + * Copyright(c) 2026 Intel Corporation. All rights reserved. + */ +#include "drmtest.h" +#include "igt_sriov_device.h" +#include "intel_chipset.h" +#include "xe/xe_mmio.h" +#include "xe/xe_query.h" + +/** + * TEST: xe_sriov_mmio_regs + * Category: Core + * Mega feature: SR-IOV + * Sub-category: MMIO + * Functionality: MMIO isolation + * Description: Checks MMIO isolation + * + * SUBTEST: vf-cap-reg + * Description: + * Verify that VF has access to VF capability register + * + * SUBTEST: vf-scratch-regs + * Description: + * Verify that VF has RW access to VF scratch registers + * + * SUBTEST: vf-scratch-regs-unique-instance + * Description: + * Verify that VF has its own instance of scratch registers + * + * SUBTEST: vf-not-allowed-regs + * Description: + * Verify that VF does not have access to restricted registers + */ + +IGT_TEST_DESCRIPTION("Xe tests for SR-IOV MMIO registers"); + +/* + * Although 8 MB is reserved for the registers, they actually use only + * the first 4 MB + */ +#define MMIO_REGS_TILE_SIZE SZ_4M + +#define VF_CAP_REG 0x1901f8 +#define MEDIA_VF_CAP_REG 0x19030C +#define IS_VF_MASK 0x1 + +#define SOFT_SCRATCH_COUNT 4 +#define SOFT_SCRATCH(n) (0x190240 + (n) * SOFT_SCRATCH_COUNT) +#define MEDIA_SOFT_SCRATCH(n) (0x190310 + (n) * SOFT_SCRATCH_COUNT) + +#define for_each_reg(reg_addr__) \ + for ((reg_addr__) = 0; \ + (reg_addr__) < (MMIO_REGS_TILE_SIZE); \ + (reg_addr__) += 0x4) + +enum reg_access_type { + NO_ACCESS_OR_UNDEFINED = 0, + RO, + RW, +}; + +struct vf_regs_allowlist { + uint32_t start; + uint32_t end; + uint32_t mask; + uint32_t expected_mask; + enum reg_access_type access_type; + bool (*requires)(int pf_fd); +}; + +static const char *stringify_reg_access_type(enum reg_access_type access_type) +{ + switch (access_type) { + case NO_ACCESS_OR_UNDEFINED: + return "NO ACCESS OR UNDEFINED"; + case RO: + return "RO"; + case RW: + return "RW"; + default: + igt_assert(0); + } + + return ""; +} + +static bool has_vf_fence(int pf_fd) +{ + uint16_t dev_id = intel_get_drm_devid(pf_fd); + + return (intel_graphics_ver(dev_id) < IP_VER(12, 10)); +} + +static bool has_memirq(int pf_fd) +{ + uint16_t dev_id = intel_get_drm_devid(pf_fd); + + return (intel_graphics_ver(dev_id) >= IP_VER(12, 50)); +} + +static bool no_memirq(int pf_fd) +{ + return !has_memirq(pf_fd); +} + +static bool has_media_regs(int pf_fd) +{ + uint16_t dev_id = intel_get_drm_devid(pf_fd); + + return (intel_graphics_ver(dev_id) >= IP_VER(12, 70)); +} + +static enum reg_access_type check_vf_reg_access(int pf_fd, uint8_t tile, + struct xe_mmio *vf_mmio, uint32_t reg) +{ + enum reg_access_type access = NO_ACCESS_OR_UNDEFINED; + uint32_t orig; + + orig = xe_mmio_tile_read32(vf_mmio, tile, reg); + if (orig != 0 && orig != ~0) + access = RO; + + xe_mmio_tile_write32(vf_mmio, tile, reg, ~orig); + if (xe_mmio_tile_read32(vf_mmio, tile, reg) != orig) + access = RW; + + xe_mmio_tile_write32(vf_mmio, tile, reg, orig); + + return access; +} + +static void vf_check_cap_reg(int pf_fd, unsigned int vf_id, uint8_t tile) +{ + enum reg_access_type access_type; + struct xe_mmio vf_mmio; + uint32_t val; + + xe_mmio_vf_access_init(pf_fd, vf_id, &vf_mmio); + + access_type = check_vf_reg_access(pf_fd, tile, &vf_mmio, VF_CAP_REG); + val = xe_mmio_tile_read32(&vf_mmio, tile, VF_CAP_REG); + + xe_mmio_access_fini(&vf_mmio); + + igt_fail_on_f(access_type != RO, "VF%u capability register should be RO. Detected: %s\n", + vf_id, stringify_reg_access_type(access_type)); + igt_fail_on_f(!(val & IS_VF_MASK), "VF%u capability register should report VF active\n", + vf_id); +} + +static bool check_scratch_regs_access(int pf_fd, uint8_t tile, struct xe_mmio *vf_mmio, bool media) +{ + bool failed = false; + uint8_t i; + + for (i = 0; i < SOFT_SCRATCH_COUNT; i++) { + uint32_t reg = media ? MEDIA_SOFT_SCRATCH(i) : SOFT_SCRATCH(i); + enum reg_access_type access_type = check_vf_reg_access(pf_fd, tile, vf_mmio, reg); + + if (access_type != RW) { + igt_warn("%s register (%#x) should be RW. Detected: %s\n", + media ? "Media scratch" : "Scratch", reg, + stringify_reg_access_type(access_type)); + failed = true; + } + } + + return failed; +} + +static void vf_check_scratch_regs(int pf_fd, unsigned int vf_id, uint8_t tile) +{ + struct xe_mmio vf_mmio; + bool failed; + + xe_mmio_vf_access_init(pf_fd, vf_id, &vf_mmio); + + failed = check_scratch_regs_access(pf_fd, tile, &vf_mmio, false); + if (xe_has_media_gt(pf_fd)) + failed |= check_scratch_regs_access(pf_fd, tile, &vf_mmio, true); + + xe_mmio_access_fini(&vf_mmio); + + igt_fail_on_f(failed, "At least one of VF%u soft scratch register is not RW.\n", vf_id); +} + +static uint32_t get_vf_regs_stride(int pf_fd) +{ + uint16_t dev_id = intel_get_drm_devid(pf_fd); + + return intel_graphics_ver(dev_id) > IP_VER(12, 0) ? 0x400 : 0x1000; +} + +static uint32_t vf_reg_to_pf(int pf_fd, unsigned int vf_id, uint32_t addr) +{ + uint32_t stride = get_vf_regs_stride(pf_fd); + + return addr + stride * vf_id; +} + +static bool check_scratch_regs_uniqueness(int pf_fd, unsigned int vf_id, uint8_t tile, + struct xe_mmio *pf_mmio, struct xe_mmio *vf_mmio, + bool media) +{ + unsigned int total_vfs = igt_sriov_get_total_vfs(pf_fd); + bool failed = false; + unsigned int i, j; + + for (i = 0; i < SOFT_SCRATCH_COUNT; i++) { + uint32_t reg = media ? MEDIA_SOFT_SCRATCH(i) : SOFT_SCRATCH(i); + uint32_t cached[total_vfs + 1]; + uint32_t write, read; + char buf[8]; + + for (j = 0; j <= total_vfs; j++) + cached[j] = xe_mmio_tile_read32(pf_mmio, tile, + vf_reg_to_pf(pf_fd, j, reg)); + + write = ~cached[vf_id]; + xe_mmio_tile_write32(vf_mmio, tile, reg, write); + igt_assert(xe_mmio_tile_read32(vf_mmio, tile, reg) == write); + + for (j = 0; j <= total_vfs; j++) { + if (j == vf_id) + continue; + + read = xe_mmio_tile_read32(pf_mmio, tile, vf_reg_to_pf(pf_fd, j, reg)); + if (read != cached[j]) { + igt_warn("Unexpected value (%#x vs %#x) of %s %sscratch register (%#x) after VF%u write (%#x) to its own register\n", + read, cached[j], igt_sriov_function_name_upper(j, buf, + sizeof(buf)), media ? "media " : "", reg, vf_id, write); + xe_mmio_tile_write32(pf_mmio, tile, vf_reg_to_pf(pf_fd, j, reg), + cached[j]); + failed = true; + } + } + + xe_mmio_tile_write32(vf_mmio, tile, reg, cached[vf_id]); + } + + return failed; +} + +static void vf_scratch_regs_unique_instance(int pf_fd, unsigned int vf_id, uint8_t tile) +{ + struct xe_mmio pf_mmio, vf_mmio; + bool failed; + + xe_mmio_vf_access_init(pf_fd, 0, &pf_mmio); + xe_mmio_vf_access_init(pf_fd, vf_id, &vf_mmio); + + failed = check_scratch_regs_uniqueness(pf_fd, vf_id, tile, &pf_mmio, &vf_mmio, false); + if (xe_has_media_gt(pf_fd)) + failed |= check_scratch_regs_uniqueness(pf_fd, vf_id, tile, &pf_mmio, &vf_mmio, + true); + + xe_mmio_access_fini(&vf_mmio); + xe_mmio_access_fini(&pf_mmio); + + igt_fail_on_f(failed, "VF%u write to scratch register changed the value of at least one other VF scratch register\n", + vf_id); +} + +/* XXX: Keep sorted */ +static const struct vf_regs_allowlist allowlist[] = { + { .start = 0x100000, .end = 0x10001c, .requires = has_vf_fence }, + { .start = 0x190010, .end = 0x190010, .requires = no_memirq }, + { .start = 0x190018, .end = 0x19001C, .requires = no_memirq }, + { .start = 0x190030, .end = 0x190048, .requires = no_memirq }, + { .start = 0x190060, .end = 0x190064, .requires = no_memirq }, + { .start = 0x190070, .end = 0x190074, .requires = no_memirq }, + { .start = 0x190090, .end = 0x190090, .requires = no_memirq }, + { .start = 0x1900a0, .end = 0x1900a0, .requires = no_memirq }, + { .start = 0x1900a8, .end = 0x1900ac, .requires = no_memirq }, + { .start = 0x1900b0, .end = 0x1900b4, .requires = no_memirq }, + { .start = 0x1900d0, .end = 0x1900d4, .requires = no_memirq }, + { .start = 0x1900e8, .end = 0x1900ec, .requires = no_memirq }, + { .start = 0x1900f0, .end = 0x1900f4, .requires = no_memirq }, + { .start = 0x190100, .end = 0x190100, .requires = no_memirq }, + { .start = 0x1901f0, .end = 0x1901f0 }, + { .start = 0x1901f8, .end = 0x1901f8 }, + { .start = 0x190240, .end = 0x19024c }, + { .start = 0x190300, .end = 0x190300 }, + { .start = 0x190304, .end = 0x190304, .requires = has_media_regs }, + { .start = 0x19030c, .end = 0x19031c, .requires = has_media_regs }, +}; + +static int addr_range_cmp(const void *addr, const void *range) +{ + if (*(uint32_t *)addr < ((const struct vf_regs_allowlist *)range)->start) + return -1; + else if (*(uint32_t *)addr > ((const struct vf_regs_allowlist *)range)->end) + return 1; + else + return 0; +} + +static bool skip_if_on_whitelist(int pf_fd, uint32_t reg_addr) +{ + struct vf_regs_allowlist *item; + + if (reg_addr < allowlist[0].start && reg_addr > allowlist[ARRAY_SIZE(allowlist) - 1].end) + return false; + + item = bsearch(®_addr, &allowlist[0], ARRAY_SIZE(allowlist), sizeof(allowlist[0]), + addr_range_cmp); + if (item) { + if (item->requires) + return (item->requires(pf_fd)) ? true : false; + else + return true; + } + + return false; +} + +static void vf_check_not_allowed_regs(int pf_fd, unsigned int vf_id, uint8_t tile) +{ + struct xe_mmio vf_mmio; + bool failed = false; + uint32_t reg; + + xe_mmio_vf_access_init(pf_fd, vf_id, &vf_mmio); + + for_each_reg(reg) { + enum reg_access_type access_type; + + if (skip_if_on_whitelist(pf_fd, reg)) + continue; + + access_type = check_vf_reg_access(pf_fd, tile, &vf_mmio, reg); + if (access_type != NO_ACCESS_OR_UNDEFINED) { + igt_warn("VF%u register (%#x) shouldn't be %s.\n", vf_id, reg, + stringify_reg_access_type(access_type)); + failed = true; + } + } + + xe_mmio_access_fini(&vf_mmio); + + igt_fail_on_f(failed, + "At least one of VF%u register, outside the allowlist, is accessible\n", + vf_id); +} + +int igt_main() +{ + bool autoprobe; + uint8_t tile; + int pf_fd; + + igt_fixture() + { + pf_fd = drm_open_driver(DRIVER_XE); + igt_require(igt_sriov_is_pf(pf_fd)); + igt_require(igt_sriov_get_enabled_vfs(pf_fd) == 0); + autoprobe = igt_sriov_is_driver_autoprobe_enabled(pf_fd); + igt_sriov_install_exit_handler(pf_fd, NULL, NULL); + + igt_sriov_disable_driver_autoprobe(pf_fd); + igt_sriov_enable_vfs(pf_fd, igt_sriov_get_total_vfs(pf_fd)); + } + + igt_describe("Verify that VF has access to VF capability register"); + igt_subtest_with_dynamic("vf-cap-reg") { + for_each_sriov_vf(pf_fd, vf_id) + xe_for_each_tile(pf_fd, tile) + igt_dynamic_f("vf%u-tile-%u", vf_id, tile) + vf_check_cap_reg(pf_fd, vf_id, tile); + } + + igt_describe("Verify that VF has RW access to VF scratch registers"); + igt_subtest_with_dynamic("vf-scratch-regs") { + for_each_sriov_vf(pf_fd, vf_id) + xe_for_each_tile(pf_fd, tile) + igt_dynamic_f("vf%u-tile-%u", vf_id, tile) + vf_check_scratch_regs(pf_fd, vf_id, tile); + } + + igt_describe("Verify that VF has its own instance of scratch registers"); + igt_subtest_with_dynamic("vf-scratch-regs-unique-instance") { + for_each_sriov_vf(pf_fd, vf_id) + xe_for_each_tile(pf_fd, tile) + igt_dynamic_f("vf%u-tile-%u", vf_id, tile) + vf_scratch_regs_unique_instance(pf_fd, vf_id, tile); + } + + igt_describe("Verify that VF does not have access to restricted registers"); + igt_subtest_with_dynamic("vf-not-allowed-regs") { + for_each_sriov_vf(pf_fd, vf_id) + xe_for_each_tile(pf_fd, tile) + igt_dynamic_f("vf%u-tile-%u", vf_id, tile) + vf_check_not_allowed_regs(pf_fd, vf_id, tile); + } + + igt_fixture() { + igt_sriov_disable_vfs(pf_fd); + /* abort to avoid execution of next tests with enabled VFs */ + igt_abort_on_f(igt_sriov_get_enabled_vfs(pf_fd) > 0, "Failed to disable VF(s)"); + autoprobe ? igt_sriov_enable_driver_autoprobe(pf_fd) : + igt_sriov_disable_driver_autoprobe(pf_fd); + igt_abort_on_f(autoprobe != igt_sriov_is_driver_autoprobe_enabled(pf_fd), + "Failed to restore sriov_drivers_autoprobe value\n"); + igt_sriov_clear_exit_handler(); + drm_close_driver(pf_fd); + } +} diff --git a/tests/meson.build b/tests/meson.build index bb8bef0f9..f0a4cef4c 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -346,6 +346,7 @@ intel_xe_progs = [ 'xe_sriov_auto_provisioning', 'xe_sriov_flr', 'xe_sriov_ggtt', + 'xe_sriov_mmio_regs', 'xe_sriov_vfio', 'xe_sriov_scheduling', 'xe_survivability', -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v4 3/3] intel-ci: Block igt@xe_sriov_mmio_regs.* 2026-11-10 8:28 [PATCH v4 0/3] tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs Lukasz Laguna 2026-11-10 8:28 ` [PATCH v4 1/3] lib/igt_sriov_device: Add helpers to get SR-IOV function name Lukasz Laguna 2026-11-10 8:28 ` [PATCH v4 2/3] tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs Lukasz Laguna @ 2026-11-10 8:28 ` Lukasz Laguna 2026-11-10 17:30 ` ✗ Fi.CI.BUILD: failure for tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs (rev5) Patchwork 3 siblings, 0 replies; 7+ messages in thread From: Lukasz Laguna @ 2026-11-10 8:28 UTC (permalink / raw) To: igt-dev; +Cc: marcin.bernatowicz, piotr.piorkowski This test is dedicated for HW checkout and it's not suited for recurring CI runs. Signed-off-by: Lukasz Laguna <lukasz.laguna@intel.com> Reviewed-by: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com> --- tests/intel-ci/xe.blocklist.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/intel-ci/xe.blocklist.txt b/tests/intel-ci/xe.blocklist.txt index c1dd3c7a8..73c580e48 100644 --- a/tests/intel-ci/xe.blocklist.txt +++ b/tests/intel-ci/xe.blocklist.txt @@ -118,6 +118,7 @@ igt@sriov_basic@bind-unbind-vf$ ################################################################## igt@sriov_pci_config.* igt@xe_sriov_ggtt.* +igt@xe_sriov_mmio_regs.* ################################################################## # Chamelium V1 HDMI receiver supports a maximum resolution # of 4K @ 30Hz. This test enforces an EDID with 4K @ 60Hz, -- 2.43.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* ✗ Fi.CI.BUILD: failure for tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs (rev5) 2026-11-10 8:28 [PATCH v4 0/3] tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs Lukasz Laguna ` (2 preceding siblings ...) 2026-11-10 8:28 ` [PATCH v4 3/3] intel-ci: Block igt@xe_sriov_mmio_regs.* Lukasz Laguna @ 2026-11-10 17:30 ` Patchwork 3 siblings, 0 replies; 7+ messages in thread From: Patchwork @ 2026-11-10 17:30 UTC (permalink / raw) To: Laguna, Lukasz; +Cc: igt-dev == Series Details == Series: tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs (rev5) URL : https://patchwork.freedesktop.org/series/172772/ State : failure == Summary == Applying: lib/igt_sriov_device: Add helpers to get SR-IOV function name Using index info to reconstruct a base tree... M lib/igt_sriov_device.c M lib/igt_sriov_device.h Falling back to patching base and 3-way merge... No changes -- Patch already applied. Applying: tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs Using index info to reconstruct a base tree... M tests/meson.build Falling back to patching base and 3-way merge... CONFLICT (add/add): Merge conflict in tests/intel/xe_sriov_mmio_regs.c Auto-merging tests/intel/xe_sriov_mmio_regs.c Patch failed at 0002 tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-11-10 17:31 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-10 8:28 [PATCH v4 0/3] tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs Lukasz Laguna 2026-11-10 8:28 ` [PATCH v4 1/3] lib/igt_sriov_device: Add helpers to get SR-IOV function name Lukasz Laguna 2026-11-10 9:48 ` Bernatowicz, Marcin 2026-11-10 11:42 ` Kamil Konieczny 2026-11-10 8:28 ` [PATCH v4 2/3] tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs Lukasz Laguna 2026-11-10 8:28 ` [PATCH v4 3/3] intel-ci: Block igt@xe_sriov_mmio_regs.* Lukasz Laguna 2026-11-10 17:30 ` ✗ Fi.CI.BUILD: failure for tests/intel/xe_sriov_mmio_regs: Add tests to verify registers on VFs (rev5) Patchwork
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox