Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added tests/host_sb/__init__.py
Empty file.
Binary file added tests/host_sb/data/test_hypercall_filter
Binary file not shown.
35 changes: 35 additions & 0 deletions tests/host_sb/test_hypercall_filter.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this test go into tests/xen or is it better as a separate component?

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import pathlib

import pytest

from lib.host import Host

# Requirements:
# - one XCP-ng host (--host) >= 9.0
# - Host Secureboot enforcement must be enabled

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the case, you should verify it with a fixture. Optionally, also check if the Secure Boot keys etc. are in place.


def test_hypercall_filter(host: Host):

"""
Verify the Xen privcmd hypercall filter.

The helper binary performs a collection of safe hypercalls and verifies
that:
* allowed read-only hypercalls succeed
* invalid guest pointers are rejected with -EFAULT
* forbidden operations are rejected by the filter
* unknown operations return the expected error

The helper exits with status 0 iff every check passes.
"""

state = host.ssh("mokutil --sb-state", simple_output=True)
if "SecureBoot enabled" not in state:
pytest.skip("Secure Boot is disabled")

local_binary = pathlib.Path(__file__).parent / "data" / "test_hypercall_filter"
remote_binary = "/tmp/test_hypercall_filter"
Comment on lines +30 to +31

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth discussing a better way to produce and host this sort of test binaries. At least, this test should link to the relevant tool repo.


host.scp(str(local_binary), remote_binary)
host.ssh(f"chmod +x {remote_binary}")
host.ssh(remote_binary)
Loading