Skip to contentSkip to conversation

tests: Hypercall xen_version testing

XTF-ARM Michal Orzel 3 participants 7 messages Dec 15, 2022 – Dec 16, 2022

lore
Share & tools
lore

Michal Orzel

author Applied
#0 lore raw

Add a new test hyp-xen-version to perform functional testing of xen_version hypercall. Check the following commands (more can be added later on):
- XENVER_version,
- XENVER_extraversion,
- XENVER_compile_info,
- XENVER_changeset
- XENVER_get_features,
- passing invalid command.

For now, enable this test only for arm64.

---
This is a patch for XTF fork https://gitlab.com/xen-project/fusa/xtf
(branch xtf-arm) under which XTF on Arm port is maintained.

Pushed to xen-devel together with patches to Xen CI automation, so that it is clear what the test is doing.

---
 build/arm64/arch-tests.mk      |   2 +-
 docs/all-tests.dox             |   2 +
 tests/hyp-xen-version/Makefile |  10 ++++
 tests/hyp-xen-version/main.c   | 105 +++++++++++++++++++++++++++++++++
 4 files changed, 118 insertions(+), 1 deletion(-)
 create mode 100644 tests/hyp-xen-version/Makefile
 create mode 100644 tests/hyp-xen-version/main.c
build/arm64/arch-tests.mk +1 -1
index 1a13ba923625..c85e28bbea9e 100644
@@ -1,4 +1,4 @@
 # Supported tests by arm64
 
-# Currently only example test is supported
 TESTS := $(ROOT)/tests/example
+TESTS += $(ROOT)/tests/hyp-xen-version
docs/all-tests.dox +2 -0
index 322f078db09e..48a407593463 100644
@@ -20,6 +20,8 @@ and functionality.
 
 @subpage test-fpu-exception-emulation - FPU Exception Emulation.  Covers XSA-190.
 
+@subpage test-hyp-xen-version - Hypercall xen_version testing.
+
 @subpage test-invlpg - `invlpg` instruction behaviour.
 
 @subpage test-lbr-tsx-vmentry - Haswell and later LBR/TSX Vmentry failure test.
tests/hyp-xen-version/Makefile new file +10 -0
new file mode 100644
index 000000000000..2d7db8fa6ad9
@@ -0,0 +1,10 @@
+include $(ROOT)/build/common.mk
+
+NAME      := hyp-xen-version
+CATEGORY  := functional
+TEST-ARCH := arm64
+TEST-ENVS := $(ALL_ENVIRONMENTS)
+
+obj-perenv += main.o
+
+include $(ROOT)/build/gen.mk
tests/hyp-xen-version/main.c new file +105 -0

105 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw
Quoted 11 lines · Michal Orzel

Add a new test hyp-xen-version to perform functional testing of xen_version hypercall. Check the following commands (more can be added later on):
- XENVER_version,
- XENVER_extraversion,
- XENVER_compile_info,
- XENVER_changeset
- XENVER_get_features,
- passing invalid command.

For now, enable this test only for arm64.

What's wrong with exposing this uniformly?

Quoted 31 lines
tests/hyp-xen-version/main.c new file +28 -0
@@ -0,0 +1,105 @@
+/**
+ * @file tests/hyp-xen-version/main.c
+ * @ref test-hyp-xen-version
+ *
+ * @page test-hyp-xen-version Hypercall xen_version
+ *
+ * Functional testing of xen_version hypercall.
+ *
+ * @see tests/hyp-xen-version/main.c
+ */
+#include <xtf.h>
+
+const char test_title[] = "Hypercall xen_version testing";
+
+#define INVALID_CMD -1
+
+void test_main(void)
+{
+    int ret;
+
+    printk("Checking XENVER_version:\n");
+    {
+        /*
+        * Version is returned directly in format: ((major << 16) | minor),
+        * so no need to check the return value for an error.
+        */
+        ret = hypercall_xen_version(XENVER_version, NULL);
+        printk(" version: %u.%u\n", ret >> 16, ret & 0xFFFF);

tests/hyp-xen-version/main.c line 38

Quoted 10 lines
tests/hyp-xen-version/main.c new file +10 -0
+    }
+
+    printk("Checking XENVER_extraversion:\n");
+    {
+        xen_extraversion_t xen_ev;
+        memset(&xen_ev, 0, sizeof(xen_ev));
+
+        ret = hypercall_xen_version(XENVER_extraversion, xen_ev);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

This, ...

tests/hyp-xen-version/main.c line 50

Quoted 11 lines
tests/hyp-xen-version/main.c new file +11 -0
+        printk(" extraversion: %s\n", xen_ev);
+    }
+
+    printk("Checking XENVER_compile_info:\n");
+    {
+        xen_compile_info_t xen_ci;
+        memset(&xen_ci, 0, sizeof(xen_ci));
+
+        ret = hypercall_xen_version(XENVER_compile_info, &xen_ci);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

... this, and ...

Quoted 4 lines
tests/hyp-xen-version/main.c new file +4 -0
+        printk(" compiler:       %s\n", xen_ci.compiler);
+        printk(" compile_by:     %s\n", xen_ci.compile_by);
+        printk(" compile_domain: %s\n", xen_ci.compile_domain);
+        printk(" compile_date:   %s\n", xen_ci.compile_date);

tests/hyp-xen-version/main.c line 65

Quoted 10 lines
tests/hyp-xen-version/main.c new file +10 -0
+    }
+
+    printk("Checking XENVER_changeset:\n");
+    {
+        xen_changeset_info_t xen_cs;
+        memset(&xen_cs, 0, sizeof(xen_cs));
+
+        ret = hypercall_xen_version(XENVER_changeset, &xen_cs);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

... this can fail because of XSM denying access. (Others can of course also fail for this reason, but here possible failure is kind of "intended" - see the dummy xsm_xen_version() handling.) Therefore I would like to suggest that you also special case getting back -EPERM, resulting in e.g. just a warning instead of an error.

Jan

#2 lore raw
Quoted 11 lines · Jan Beulich
Quoted 10 lines · Michal Orzel

Add a new test hyp-xen-version to perform functional testing of xen_version hypercall. Check the following commands (more can be added later on):
- XENVER_version,
- XENVER_extraversion,
- XENVER_compile_info,
- XENVER_changeset
- XENVER_get_features,
- passing invalid command.

Quoted 3 lines
Quoted 1 line

For now, enable this test only for arm64.

What's wrong with exposing this uniformly?

Actually the tests are not arm64 specific. Michal, I think you should remove the comment above from the commit message. (What/if/when gets enabled as a test in gitlab-ci is a different matter.)

Quoted 81 lines
Quoted 31 lines
tests/hyp-xen-version/main.c new file +28 -0
@@ -0,0 +1,105 @@
+/**
+ * @file tests/hyp-xen-version/main.c
+ * @ref test-hyp-xen-version
+ *
+ * @page test-hyp-xen-version Hypercall xen_version
+ *
+ * Functional testing of xen_version hypercall.
+ *
+ * @see tests/hyp-xen-version/main.c
+ */
+#include <xtf.h>
+
+const char test_title[] = "Hypercall xen_version testing";
+
+#define INVALID_CMD -1
+
+void test_main(void)
+{
+    int ret;
+
+    printk("Checking XENVER_version:\n");
+    {
+        /*
+        * Version is returned directly in format: ((major << 16) | minor),
+        * so no need to check the return value for an error.
+        */
+        ret = hypercall_xen_version(XENVER_version, NULL);
+        printk(" version: %u.%u\n", ret >> 16, ret & 0xFFFF);

tests/hyp-xen-version/main.c line 38

Quoted 10 lines
tests/hyp-xen-version/main.c new file +10 -0
+    }
+
+    printk("Checking XENVER_extraversion:\n");
+    {
+        xen_extraversion_t xen_ev;
+        memset(&xen_ev, 0, sizeof(xen_ev));
+
+        ret = hypercall_xen_version(XENVER_extraversion, xen_ev);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

This, ...

tests/hyp-xen-version/main.c line 50

Quoted 11 lines
tests/hyp-xen-version/main.c new file +11 -0
+        printk(" extraversion: %s\n", xen_ev);
+    }
+
+    printk("Checking XENVER_compile_info:\n");
+    {
+        xen_compile_info_t xen_ci;
+        memset(&xen_ci, 0, sizeof(xen_ci));
+
+        ret = hypercall_xen_version(XENVER_compile_info, &xen_ci);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

... this, and ...

Quoted 4 lines
tests/hyp-xen-version/main.c new file +4 -0
+        printk(" compiler:       %s\n", xen_ci.compiler);
+        printk(" compile_by:     %s\n", xen_ci.compile_by);
+        printk(" compile_domain: %s\n", xen_ci.compile_domain);
+        printk(" compile_date:   %s\n", xen_ci.compile_date);

tests/hyp-xen-version/main.c line 65

Quoted 10 lines
tests/hyp-xen-version/main.c new file +10 -0
+    }
+
+    printk("Checking XENVER_changeset:\n");
+    {
+        xen_changeset_info_t xen_cs;
+        memset(&xen_cs, 0, sizeof(xen_cs));
+
+        ret = hypercall_xen_version(XENVER_changeset, &xen_cs);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

... this can fail because of XSM denying access. (Others can of course also fail for this reason, but here possible failure is kind of "intended" - see the dummy xsm_xen_version() handling.) Therefore I would like to suggest that you also special case getting back -EPERM, resulting in e.g. just a warning instead of an error.

Jan

#3 lore raw
In reply to Jan Beulich

Hi Jan,

Thanks for the feedback.

Quoted 13 lines · Jan Beulich
Quoted 10 lines · Michal Orzel

Add a new test hyp-xen-version to perform functional testing of xen_version hypercall. Check the following commands (more can be added later on):
- XENVER_version,
- XENVER_extraversion,
- XENVER_compile_info,
- XENVER_changeset
- XENVER_get_features,
- passing invalid command.

Quoted 3 lines
Quoted 1 line

For now, enable this test only for arm64.

What's wrong with exposing this uniformly?

There is nothing wrong. I can remove the ARCH restriction.

Quoted 71 lines
Quoted 32 lines
tests/hyp-xen-version/main.c new file +28 -0
@@ -0,0 +1,105 @@
+/**
+ * @file tests/hyp-xen-version/main.c
+ * @ref test-hyp-xen-version
+ *
+ * @page test-hyp-xen-version Hypercall xen_version
+ *
+ * Functional testing of xen_version hypercall.
+ *
+ * @see tests/hyp-xen-version/main.c
+ */
+#include <xtf.h>
+
+const char test_title[] = "Hypercall xen_version testing";
+
+#define INVALID_CMD -1
+
+void test_main(void)
+{
+    int ret;
+
+    printk("Checking XENVER_version:\n");
+    {
+        /*
+        * Version is returned directly in format: ((major << 16) | minor),
+        * so no need to check the return value for an error.
+        */
+        ret = hypercall_xen_version(XENVER_version, NULL);
+        printk(" version: %u.%u\n", ret >> 16, ret & 0xFFFF);

tests/hyp-xen-version/main.c line 38

Quoted 10 lines
tests/hyp-xen-version/main.c new file +10 -0
+    }
+
+    printk("Checking XENVER_extraversion:\n");
+    {
+        xen_extraversion_t xen_ev;
+        memset(&xen_ev, 0, sizeof(xen_ev));
+
+        ret = hypercall_xen_version(XENVER_extraversion, xen_ev);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

This, ...

tests/hyp-xen-version/main.c line 50

Quoted 11 lines
tests/hyp-xen-version/main.c new file +11 -0
+        printk(" extraversion: %s\n", xen_ev);
+    }
+
+    printk("Checking XENVER_compile_info:\n");
+    {
+        xen_compile_info_t xen_ci;
+        memset(&xen_ci, 0, sizeof(xen_ci));
+
+        ret = hypercall_xen_version(XENVER_compile_info, &xen_ci);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

... this, and ...

Quoted 12 lines
tests/hyp-xen-version/main.c new file +12 -0
+        printk(" compiler:       %s\n", xen_ci.compiler);
+        printk(" compile_by:     %s\n", xen_ci.compile_by);
+        printk(" compile_domain: %s\n", xen_ci.compile_domain);
+        printk(" compile_date:   %s\n", xen_ci.compile_date);
+    }
+
+    printk("Checking XENVER_changeset:\n");
+    {
+        xen_changeset_info_t xen_cs;
+        memset(&xen_cs, 0, sizeof(xen_cs));
+
+        ret = hypercall_xen_version(XENVER_changeset, &xen_cs);
Quoted 8 lines

tests/hyp-xen-version/main.c line 63

Quoted 2 lines
tests/hyp-xen-version/main.c new file +2 -0
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

... this can fail because of XSM denying access. (Others can of course also fail for this reason, but here possible failure is kind of "intended" - see the dummy xsm_xen_version() handling.) Therefore I would like to suggest that you also special case getting back -EPERM, resulting in e.g. just a warning instead of an error.

When writing a test I did make sure to check xsm_xen_version *for the operations that I covered* and my understanding is as follows:
For XENVER_version and XENVER_get_features, it returns 0 so deny is false.
For other commands I test, xsm_default_action is called with XSM_HOOK which returns 0 as well. So AFAICT nothing can result in setting deny to true.
But even in case of setting deny to true, it would just result in copying "<denied>" into the respective buffer. It would not alter the hypercall return value.

The only command causing the return value to be -EPERM in case deny is set to true is XENVER_build_id which I did not covered in my test.

Quoted 2 lines

Jan

~Michal

#4 lore raw
Quoted 80 lines · Michal Orzel
Quoted 71 lines · Jan Beulich
Quoted 31 lines · Michal Orzel
tests/hyp-xen-version/main.c new file +28 -0
@@ -0,0 +1,105 @@
+/**
+ * @file tests/hyp-xen-version/main.c
+ * @ref test-hyp-xen-version
+ *
+ * @page test-hyp-xen-version Hypercall xen_version
+ *
+ * Functional testing of xen_version hypercall.
+ *
+ * @see tests/hyp-xen-version/main.c
+ */
+#include <xtf.h>
+
+const char test_title[] = "Hypercall xen_version testing";
+
+#define INVALID_CMD -1
+
+void test_main(void)
+{
+    int ret;
+
+    printk("Checking XENVER_version:\n");
+    {
+        /*
+        * Version is returned directly in format: ((major << 16) | minor),
+        * so no need to check the return value for an error.
+        */
+        ret = hypercall_xen_version(XENVER_version, NULL);
+        printk(" version: %u.%u\n", ret >> 16, ret & 0xFFFF);

tests/hyp-xen-version/main.c line 38

Quoted 10 lines
tests/hyp-xen-version/main.c new file +10 -0
+    }
+
+    printk("Checking XENVER_extraversion:\n");
+    {
+        xen_extraversion_t xen_ev;
+        memset(&xen_ev, 0, sizeof(xen_ev));
+
+        ret = hypercall_xen_version(XENVER_extraversion, xen_ev);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

This, ...

tests/hyp-xen-version/main.c line 50

Quoted 11 lines
tests/hyp-xen-version/main.c new file +11 -0
+        printk(" extraversion: %s\n", xen_ev);
+    }
+
+    printk("Checking XENVER_compile_info:\n");
+    {
+        xen_compile_info_t xen_ci;
+        memset(&xen_ci, 0, sizeof(xen_ci));
+
+        ret = hypercall_xen_version(XENVER_compile_info, &xen_ci);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

... this, and ...

Quoted 12 lines
tests/hyp-xen-version/main.c new file +12 -0
+        printk(" compiler:       %s\n", xen_ci.compiler);
+        printk(" compile_by:     %s\n", xen_ci.compile_by);
+        printk(" compile_domain: %s\n", xen_ci.compile_domain);
+        printk(" compile_date:   %s\n", xen_ci.compile_date);
+    }
+
+    printk("Checking XENVER_changeset:\n");
+    {
+        xen_changeset_info_t xen_cs;
+        memset(&xen_cs, 0, sizeof(xen_cs));
+
+        ret = hypercall_xen_version(XENVER_changeset, &xen_cs);
Quoted 8 lines

tests/hyp-xen-version/main.c line 63

Quoted 2 lines
tests/hyp-xen-version/main.c new file +2 -0
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

... this can fail because of XSM denying access. (Others can of course also fail for this reason, but here possible failure is kind of "intended" - see the dummy xsm_xen_version() handling.) Therefore I would like to suggest that you also special case getting back -EPERM, resulting in e.g. just a warning instead of an error.

Quoted 7 lines

When writing a test I did make sure to check xsm_xen_version *for the operations that I covered* and my understanding is as follows:
For XENVER_version and XENVER_get_features, it returns 0 so deny is false.
For other commands I test, xsm_default_action is called with XSM_HOOK which returns 0 as well. So AFAICT nothing can result in setting deny to true.
But even in case of setting deny to true, it would just result in copying "<denied>" into the respective buffer. It would not alter the hypercall return value.

For dummy itself all is fine; arrangements there suggest to me though that the intention was that an actual Flask policy may be written such that some of these might actually be refused. My recollection actually is that when the distinction for the sub-ops was introduced, quite a bit of discussion happened as to what may or may not be (optionally or uniformly) be rejected.

Jan

#5 lore raw
Quoted 91 lines · Jan Beulich
Quoted 80 lines · Michal Orzel
Quoted 71 lines · Jan Beulich
Quoted 31 lines · Michal Orzel
tests/hyp-xen-version/main.c new file +28 -0
@@ -0,0 +1,105 @@
+/**
+ * @file tests/hyp-xen-version/main.c
+ * @ref test-hyp-xen-version
+ *
+ * @page test-hyp-xen-version Hypercall xen_version
+ *
+ * Functional testing of xen_version hypercall.
+ *
+ * @see tests/hyp-xen-version/main.c
+ */
+#include <xtf.h>
+
+const char test_title[] = "Hypercall xen_version testing";
+
+#define INVALID_CMD -1
+
+void test_main(void)
+{
+    int ret;
+
+    printk("Checking XENVER_version:\n");
+    {
+        /*
+        * Version is returned directly in format: ((major << 16) | minor),
+        * so no need to check the return value for an error.
+        */
+        ret = hypercall_xen_version(XENVER_version, NULL);
+        printk(" version: %u.%u\n", ret >> 16, ret & 0xFFFF);

tests/hyp-xen-version/main.c line 38

Quoted 10 lines
tests/hyp-xen-version/main.c new file +10 -0
+    }
+
+    printk("Checking XENVER_extraversion:\n");
+    {
+        xen_extraversion_t xen_ev;
+        memset(&xen_ev, 0, sizeof(xen_ev));
+
+        ret = hypercall_xen_version(XENVER_extraversion, xen_ev);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

This, ...

tests/hyp-xen-version/main.c line 50

Quoted 11 lines
tests/hyp-xen-version/main.c new file +11 -0
+        printk(" extraversion: %s\n", xen_ev);
+    }
+
+    printk("Checking XENVER_compile_info:\n");
+    {
+        xen_compile_info_t xen_ci;
+        memset(&xen_ci, 0, sizeof(xen_ci));
+
+        ret = hypercall_xen_version(XENVER_compile_info, &xen_ci);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

... this, and ...

Quoted 12 lines
tests/hyp-xen-version/main.c new file +12 -0
+        printk(" compiler:       %s\n", xen_ci.compiler);
+        printk(" compile_by:     %s\n", xen_ci.compile_by);
+        printk(" compile_domain: %s\n", xen_ci.compile_domain);
+        printk(" compile_date:   %s\n", xen_ci.compile_date);
+    }
+
+    printk("Checking XENVER_changeset:\n");
+    {
+        xen_changeset_info_t xen_cs;
+        memset(&xen_cs, 0, sizeof(xen_cs));
+
+        ret = hypercall_xen_version(XENVER_changeset, &xen_cs);
Quoted 8 lines

tests/hyp-xen-version/main.c line 63

Quoted 2 lines
tests/hyp-xen-version/main.c new file +2 -0
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

... this can fail because of XSM denying access. (Others can of course also fail for this reason, but here possible failure is kind of "intended" - see the dummy xsm_xen_version() handling.) Therefore I would like to suggest that you also special case getting back -EPERM, resulting in e.g. just a warning instead of an error.

Quoted 7 lines

When writing a test I did make sure to check xsm_xen_version *for the operations that I covered* and my understanding is as follows:
For XENVER_version and XENVER_get_features, it returns 0 so deny is false.
For other commands I test, xsm_default_action is called with XSM_HOOK which returns 0 as well. So AFAICT nothing can result in setting deny to true.
But even in case of setting deny to true, it would just result in copying "<denied>" into the respective buffer. It would not alter the hypercall return value.

Quoted 6 lines

For dummy itself all is fine; arrangements there suggest to me though that the intention was that an actual Flask policy may be written such that some of these might actually be refused. My recollection actually is that when the distinction for the sub-ops was introduced, quite a bit of discussion happened as to what may or may not be (optionally or uniformly) be rejected.

Ok but in any case, in the current xen_version implementation, it will just result in storing "<denied>". No -EPERM will be returned. So do you think it would make sense to add handling for it in the test even though it cannot be triggered?

Quoted 2 lines

Jan

~Michal

#6 lore raw
Quoted 100 lines · Michal Orzel
Quoted 91 lines · Jan Beulich
Quoted 80 lines · Michal Orzel
Quoted 71 lines · Jan Beulich
Quoted 31 lines · Michal Orzel
tests/hyp-xen-version/main.c new file +28 -0
@@ -0,0 +1,105 @@
+/**
+ * @file tests/hyp-xen-version/main.c
+ * @ref test-hyp-xen-version
+ *
+ * @page test-hyp-xen-version Hypercall xen_version
+ *
+ * Functional testing of xen_version hypercall.
+ *
+ * @see tests/hyp-xen-version/main.c
+ */
+#include <xtf.h>
+
+const char test_title[] = "Hypercall xen_version testing";
+
+#define INVALID_CMD -1
+
+void test_main(void)
+{
+    int ret;
+
+    printk("Checking XENVER_version:\n");
+    {
+        /*
+        * Version is returned directly in format: ((major << 16) | minor),
+        * so no need to check the return value for an error.
+        */
+        ret = hypercall_xen_version(XENVER_version, NULL);
+        printk(" version: %u.%u\n", ret >> 16, ret & 0xFFFF);

tests/hyp-xen-version/main.c line 38

Quoted 10 lines
tests/hyp-xen-version/main.c new file +10 -0
+    }
+
+    printk("Checking XENVER_extraversion:\n");
+    {
+        xen_extraversion_t xen_ev;
+        memset(&xen_ev, 0, sizeof(xen_ev));
+
+        ret = hypercall_xen_version(XENVER_extraversion, xen_ev);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

This, ...

tests/hyp-xen-version/main.c line 50

Quoted 11 lines
tests/hyp-xen-version/main.c new file +11 -0
+        printk(" extraversion: %s\n", xen_ev);
+    }
+
+    printk("Checking XENVER_compile_info:\n");
+    {
+        xen_compile_info_t xen_ci;
+        memset(&xen_ci, 0, sizeof(xen_ci));
+
+        ret = hypercall_xen_version(XENVER_compile_info, &xen_ci);
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

... this, and ...

Quoted 12 lines
tests/hyp-xen-version/main.c new file +12 -0
+        printk(" compiler:       %s\n", xen_ci.compiler);
+        printk(" compile_by:     %s\n", xen_ci.compile_by);
+        printk(" compile_domain: %s\n", xen_ci.compile_domain);
+        printk(" compile_date:   %s\n", xen_ci.compile_date);
+    }
+
+    printk("Checking XENVER_changeset:\n");
+    {
+        xen_changeset_info_t xen_cs;
+        memset(&xen_cs, 0, sizeof(xen_cs));
+
+        ret = hypercall_xen_version(XENVER_changeset, &xen_cs);
Quoted 8 lines

tests/hyp-xen-version/main.c line 63

Quoted 2 lines
tests/hyp-xen-version/main.c new file +2 -0
+        if ( ret < 0 )
+            return xtf_error("Error %d\n", ret);

... this can fail because of XSM denying access. (Others can of course also fail for this reason, but here possible failure is kind of "intended" - see the dummy xsm_xen_version() handling.) Therefore I would like to suggest that you also special case getting back -EPERM, resulting in e.g. just a warning instead of an error.

Quoted 7 lines

When writing a test I did make sure to check xsm_xen_version *for the operations that I covered* and my understanding is as follows:
For XENVER_version and XENVER_get_features, it returns 0 so deny is false.
For other commands I test, xsm_default_action is called with XSM_HOOK which returns 0 as well. So AFAICT nothing can result in setting deny to true.
But even in case of setting deny to true, it would just result in copying "<denied>" into the respective buffer. It would not alter the hypercall return value.

Quoted 6 lines

For dummy itself all is fine; arrangements there suggest to me though that the intention was that an actual Flask policy may be written such that some of these might actually be refused. My recollection actually is that when the distinction for the sub-ops was introduced, quite a bit of discussion happened as to what may or may not be (optionally or uniformly) be rejected.

Quoted 4 lines

Ok but in any case, in the current xen_version implementation, it will just result in storing "<denied>". No -EPERM will be returned. So do you think it would make sense to add handling for it in the test even though it cannot be triggered?

Oh, I see my mistake now. Apologies, I take back my request.

Jan