tests/resource: Verify that Xen can deal with invalid resource type
PATCH 1/1 tests/resource: Verify that Xen can deal with invalid resource type
From: Oleksandr Tyshchenko <[email protected]>
The sign of the presence of a corresponding bugfix is an error returned on querying the size of an unknown for Xen resource type.
---
Refer https://patchew.org/Xen/[email protected]/
Current patch should go in with Xen fix from the link above.
1. w/ fix in Xen:
+ ./tests/resource/test-resourceXENMEM_acquire_resource tests
Test x86 PV
Created d1
Test grant table
(XEN) [ 8.702293] common/grant_table.c:1909:d0v1 Expanding d1 grant table from 1 to 32 frames
(XEN) [ 8.704499] common/grant_table.c:1909:d0v1 Expanding d1 grant table from 32 to 40 frames
Test x86 PVH
Created d2
Test grant table
(XEN) [ 8.717210] common/grant_table.c:1909:d0v1 Expanding d2 grant table from 1 to 32 frames
(XEN) [ 8.719477] common/grant_table.c:1909:d0v1 Expanding d2 grant table from 32 to 40 frames
[ ok ]
[ ok ]
Welcome to Alpine Linux 3.18
Kernel 6.1.19 on an x86_64 (/dev/hvc0)
2. w/o fix in Xen:
+ ./tests/resource/test-resource XENMEM_acquire_resource tests
Test x86 PV(XEN) [ 9.839691] common/grant_table.c:1909:d0v0 Expanding d0 grant table from 1 to 2 frames
Created d1
Test grant table
(XEN) [ 9.846621] common/grant_table.c:1909:d0v1 Expanding d1 grant table from 1 to 32 frames
(XEN) [ 9.848796] common/grant_table.c:1909:d0v1 Expanding d1 grant table from 32 to 40 frames
Fail: Expected error on an invalid resource type, got success
Test x86 PVH
Created d2
Test grant table
(XEN) [ 9.865235] common/grant_table.c:1909:d0v1 Expanding d2 grant table from 1 to 32 frames
(XEN) [ 9.867403] common/grant_table.c:1909:d0v1 Expanding d2 grant table from 32 to 40 frames
Fail: Expected error on an invalid resource type, got success
* Execution of "/etc/local.d/xen.start" failed.
[ !! ]
[ !! ]
Welcome to Alpine Linux 3.18
Kernel 6.1.19 on an x86_64 (/dev/hvc0)
---
--- tools/tests/resource/test-resource.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
tools/tests/resource/test-resource.c +11 -0
@@ -123,6 +123,17 @@ static void test_gnttab(uint32_t domid, unsigned int nr_frames,fail (" Fail: Managed to map gnttab v2 status frames in v1 mode\n" );xenforeignmemory_unmap_resource (fh, res); } + +/* +* While at it, verify that an attempt to query the size of an unknown +* for Xen resource type fails. +*/ + rc =xenforeignmemory_resource_size ( + fh, domid,3 ,0 , &size); + +/* Check that Xen rejected the resource type. */ +if ( !rc ) +fail (" Fail: Expected error on an invalid resource type, got success\n" ); }static void test_domain_configurations (void )
Signature · 1 line
2.34.1
Quoted 60 lines · Oleksandr Tyshchenko
From: Oleksandr Tyshchenko <[email protected]>
The sign of the presence of a corresponding bugfix is an error returned on querying the size of an unknown for Xen resource type.
Signed-off-by Oleksandr Tyshchenko <[email protected]>---
Refer https://patchew.org/Xen/[email protected]/
Current patch should go in with Xen fix from the link above.1. w/ fix in Xen:
+ ./tests/resource/test-resource
XENMEM_acquire_resourcetests
Test x86 PV
Created d1
Test grant table
(XEN) [ 8.702293] common/grant_table.c:1909:d0v1 Expanding d1 grant table from 1 to 32 frames
(XEN) [ 8.704499] common/grant_table.c:1909:d0v1 Expanding d1 grant table from 32 to 40 frames
Test x86 PVH
Created d2
Test grant table
(XEN) [ 8.717210] common/grant_table.c:1909:d0v1 Expanding d2 grant table from 1 to 32 frames
(XEN) [ 8.719477] common/grant_table.c:1909:d0v1 Expanding d2 grant table from 32 to 40 frames
[ ok ]
[ ok ]
Welcome to Alpine Linux 3.18
Kernel 6.1.19 on anx86_64(/dev/hvc0)2. w/o fix in Xen:
+ ./tests/resource/test-resource
XENMEM_acquire_resourcetests
Test x86 PV(XEN) [ 9.839691] common/grant_table.c:1909:d0v0 Expanding d0 grant table from 1 to 2 frames
Created d1
Test grant table
(XEN) [ 9.846621] common/grant_table.c:1909:d0v1 Expanding d1 grant table from 1 to 32 frames
(XEN) [ 9.848796] common/grant_table.c:1909:d0v1 Expanding d1 grant table from 32 to 40 frames
Fail: Expected error on an invalid resource type, got success
Test x86 PVH
Created d2
Test grant table
(XEN) [ 9.865235] common/grant_table.c:1909:d0v1 Expanding d2 grant table from 1 to 32 frames
(XEN) [ 9.867403] common/grant_table.c:1909:d0v1 Expanding d2 grant table from 32 to 40 frames
Fail: Expected error on an invalid resource type, got success
* Execution of "/etc/local.d/xen.start" failed.
[ !! ]
[ !! ]
Welcome to Alpine Linux 3.18
Kernel 6.1.19 on anx86_64(/dev/hvc0)
------ tools/tests/resource/test-resource.c | 11 +++++++++++ 1 file changed, 11 insertions(+)tools/tests/resource/test-resource.c +0
-0
tools/tests/resource/test-resource.c static void test_gnttab(uint32_t domid, unsigned int nr_frames, · line 129
Quoted 7 lines
tools/tests/resource/test-resource.c +4
-0@@ -123,6 +123,17 @@ static void test_gnttab(uint32_t domid, unsigned int nr_frames,fail (" Fail: Managed to map gnttab v2 status frames in v1 mode\n" );xenforeignmemory_unmap_resource (fh, res); } + +/* +* While at it, verify that an attempt to query the size of an unknown +* for Xen resource type fails.
"If this check starts failing, you've find the right place to test your addition to the Acquire Resource infrastructure."
Or something suitable. There needs to be a hint of why 3 was picked here, and part of this sentence will show up in the context of the patch bumping 3 to 4, which also helps remind reviewers to ask if a change isn't somewhere in the submitted series.
Anyway, LGTM now.
Personally, I'd merge this into the bugfix patch. This improved test wants backporting along with the fix, and the end result is still only 3 hunks.
Then, I'd suggest posting the combined result for-4.20 (cc Oleksii). It's not a major bug, but it's also a very simple and low risk fix too.
~Andrew
tools/tests/resource/test-resource.c static void test_gnttab(uint32_t domid, unsigned int nr_frames, · line 132
Quoted 3 lines
tools/tests/resource/test-resource.c +3
-0+*/ + rc =xenforeignmemory_resource_size ( + fh, domid,3 ,0 , &size);
P.S. Now it's simple, fold this back into 1 line. It causes an extra line of the comment to be visible in context.
On 17.02.25 23:09, Andrew Cooper wrote:
Hello.
Quoted 72 lines · Oleksandr Tyshchenko
Quoted 60 lines
From: Oleksandr Tyshchenko <[email protected]>
The sign of the presence of a corresponding bugfix is an error returned on querying the size of an unknown for Xen resource type.
Signed-off-by Oleksandr Tyshchenko <[email protected]>---
Refer https://patchew.org/Xen/[email protected]/
Current patch should go in with Xen fix from the link above.1. w/ fix in Xen:
+ ./tests/resource/test-resource
XENMEM_acquire_resourcetests
Test x86 PV
Created d1
Test grant table
(XEN) [ 8.702293] common/grant_table.c:1909:d0v1 Expanding d1 grant table from 1 to 32 frames
(XEN) [ 8.704499] common/grant_table.c:1909:d0v1 Expanding d1 grant table from 32 to 40 frames
Test x86 PVH
Created d2
Test grant table
(XEN) [ 8.717210] common/grant_table.c:1909:d0v1 Expanding d2 grant table from 1 to 32 frames
(XEN) [ 8.719477] common/grant_table.c:1909:d0v1 Expanding d2 grant table from 32 to 40 frames
[ ok ]
[ ok ]
Welcome to Alpine Linux 3.18
Kernel 6.1.19 on anx86_64(/dev/hvc0)2. w/o fix in Xen:
+ ./tests/resource/test-resource
XENMEM_acquire_resourcetests
Test x86 PV(XEN) [ 9.839691] common/grant_table.c:1909:d0v0 Expanding d0 grant table from 1 to 2 frames
Created d1
Test grant table
(XEN) [ 9.846621] common/grant_table.c:1909:d0v1 Expanding d1 grant table from 1 to 32 frames
(XEN) [ 9.848796] common/grant_table.c:1909:d0v1 Expanding d1 grant table from 32 to 40 frames
Fail: Expected error on an invalid resource type, got success
Test x86 PVH
Created d2
Test grant table
(XEN) [ 9.865235] common/grant_table.c:1909:d0v1 Expanding d2 grant table from 1 to 32 frames
(XEN) [ 9.867403] common/grant_table.c:1909:d0v1 Expanding d2 grant table from 32 to 40 frames
Fail: Expected error on an invalid resource type, got success
* Execution of "/etc/local.d/xen.start" failed.
[ !! ]
[ !! ]
Welcome to Alpine Linux 3.18
Kernel 6.1.19 on anx86_64(/dev/hvc0)
------ tools/tests/resource/test-resource.c | 11 +++++++++++ 1 file changed, 11 insertions(+)tools/tests/resource/test-resource.c +0
-0tools/tests/resource/test-resource.c static void test_gnttab(uint32_t domid, unsigned int nr_frames, · line 129
Quoted 7 lines
tools/tests/resource/test-resource.c +4
-0@@ -123,6 +123,17 @@ static void test_gnttab(uint32_t domid, unsigned int nr_frames,fail (" Fail: Managed to map gnttab v2 status frames in v1 mode\n" );xenforeignmemory_unmap_resource (fh, res); } + +/* +* While at it, verify that an attempt to query the size of an unknown +* for Xen resource type fails. "If this check starts failing, you've find the right place to test your addition to the Acquire Resource infrastructure."
Quoted 6 lines
Or something suitable. There needs to be a hint of why 3 was picked here, and part of this sentence will show up in the context of the patch bumping 3 to 4, which also helps remind reviewers to ask if a change isn't somewhere in the submitted series.
Anyway, LGTM now.
Thanks
Quoted 8 lines
Personally, I'd merge this into the bugfix patch. This improved test wants backporting along with the fix, and the end result is still only 3 hunks.
Then, I'd suggest posting the combined result for-4.20 (cc Oleksii). It's not a major bug, but it's also a very simple and low risk fix too.
Quoted 8 lines
~Andrew
tools/tests/resource/test-resource.c static void test_gnttab(uint32_t domid, unsigned int nr_frames, · line 132
Quoted 3 lines
tools/tests/resource/test-resource.c +3
-0+*/ + rc =xenforeignmemory_resource_size ( + fh, domid,3 ,0 , &size);P.S. Now it's simple, fold this back into 1 line. It causes an extra line of the comment to be visible in context.
I agree with the comments.