From e1b97021889e90173bfb34d3697a22b20fe4bae7 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Mon, 4 Oct 2021 22:39:51 +0000 Subject: [PATCH] nvme_fuzz: add -U option to skip IOMMU check There are many cases where we can safely run the nvme_fuzz app without having to worry about DMA corruptions - for example, any test using the TCP/RDMA/vfio-user transports against a target using an emulated backend like null or malloc. So add a -U option to skip the IOMMU check if the user so desires. Signed-off-by: Jim Harris Change-Id: Ia123b7fb49056f49e2d805c9c3d5b3169c0d589e Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9724 Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Aleksey Marchuk Reviewed-by: Tomasz Zawadzki --- test/app/fuzz/nvme_fuzz/nvme_fuzz.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/app/fuzz/nvme_fuzz/nvme_fuzz.c b/test/app/fuzz/nvme_fuzz/nvme_fuzz.c index f7ef00c87..c75ce6379 100644 --- a/test/app/fuzz/nvme_fuzz/nvme_fuzz.c +++ b/test/app/fuzz/nvme_fuzz/nvme_fuzz.c @@ -54,6 +54,7 @@ int g_runtime; int g_num_active_threads = 0; uint32_t g_admin_depth = 16; uint32_t g_io_depth = 128; +bool g_check_iommu = true; bool g_valid_ns_only = false; bool g_verbose_mode = false; @@ -713,7 +714,7 @@ begin_fuzz(void *ctx) struct spdk_nvme_ctrlr *ctrlr; int rc; - if (!spdk_iommu_is_enabled()) { + if (g_check_iommu && !spdk_iommu_is_enabled()) { /* Don't set rc to an error code here. We don't want to fail an automated test based on this. */ fprintf(stderr, "The IOMMU must be enabled to run this program to avoid unsafe memory accesses.\n"); rc = 0; @@ -783,6 +784,7 @@ This helps dig deeper into other errors besides invalid namespace.\n"); fprintf(stderr, " -S Seed value for test.\n"); fprintf(stderr, " -t Time in seconds to run the fuzz test. Only valid if -j is not specified.\n"); + fprintf(stderr, " -U Do not check if IOMMU is enabled.\n"); fprintf(stderr, " -V Enable logging of each submitted command.\n"); } @@ -833,6 +835,9 @@ nvme_fuzz_parse(int ch, char *arg) return -1; } break; + case 'U': + g_check_iommu = false; + break; case 'V': g_verbose_mode = true; break; @@ -855,7 +860,7 @@ main(int argc, char **argv) g_runtime = DEFAULT_RUNTIME; g_run = true; - if ((rc = spdk_app_parse_args(argc, argv, &opts, "aF:j:NS:t:V", NULL, nvme_fuzz_parse, + if ((rc = spdk_app_parse_args(argc, argv, &opts, "aF:j:NS:t:UV", NULL, nvme_fuzz_parse, nvme_fuzz_usage) != SPDK_APP_PARSE_ARGS_SUCCESS)) { return rc; }