From f69350e8bd250ce3dea0adebec93089e4776b10e Mon Sep 17 00:00:00 2001 From: Matthew Rosato Date: Thu, 21 Jul 2022 10:16:54 -0400 Subject: [PATCH] ap_tools/ap-check: reject start for control domains without usage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When configuring a vfio-ap device, specifying only control domains without any usage domains results in a useless configuration in that both adapters and usage domains are required to make cryptographic resources available to the guest. Without that, the control domains are useless. While the kernel allows this, let's reject this combination with a message. Suggested-by: Boris Fiuczynski Reviewed-by: Boris Fiuczynski Reviewed-by: Tony Krowiak Signed-off-by: Matthew Rosato Signed-off-by: Jan Höppner --- ap_tools/ap-check.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ap_tools/ap-check.c b/ap_tools/ap-check.c index bf649040..eddccd0e 100644 --- a/ap_tools/ap-check.c +++ b/ap_tools/ap-check.c @@ -685,6 +685,14 @@ static int ap_check_handle_start(struct ap_check_anchor *anc) goto out; } + /* Ensure device with control domains also has usage domains */ + if (util_list_is_empty(anc->dev->domains) && + !util_list_is_empty(anc->dev->controls)) { + fprintf(stderr, "At least one usage domain must be specified\n"); + rc = -1; + goto out; + } + /* Check against all other active vfio-ap devices */ rc = check_other_mdevs_sysfs(anc); /* Check against the system sysfs values for apmask/aqmask */