Skip to content

Commit

Permalink
Add TDX with EPT disable test case
Browse files Browse the repository at this point in the history
TDVM should be not launched while disable EPT

Signed-off-by: Xudong Hao <[email protected]>
  • Loading branch information
xhao22 committed Jun 7, 2024
1 parent ca365c9 commit 9494eb3
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
17 changes: 17 additions & 0 deletions KVM/qemu/td_disable_ept.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- td_disable_ept:
virt_test_type = qemu
type = td_disable_ept
vm_accelerator = kvm
machine_type_extra_params = "kernel-irqchip=split"
vm_secure_guest_type = tdx
start_vm = no
vga = std
auto_cpu_model = "no"
cpu_model = host
xfail = "yes"
expected_status = 'N'
default_status = 'Y'
parameter_name = 'ept'
pre_command = 'modprobe -r kvm_intel && modprobe kvm_intel ${parameter_name}=${expected_status}'
post_command = 'modprobe -r kvm_intel && modprobe kvm_intel ${parameter_name}=${default_status}'
check_status_cmd = 'cat /sys/module/kvm_intel/parameters/${parameter_name}'
43 changes: 43 additions & 0 deletions KVM/qemu/tests/td_disable_ept.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/python3

# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2024 Intel Corporation

# Author: Xudong Hao <[email protected]>
#
# History: Jun. 2024 - Xudong Hao - creation
from avocado.utils import process

from virttest import env_process


def run(test, params, env):
"""
Boot TD after disable ept:
1) Disable ept
2) Boot up TDVM
3) TDVM can not be lanuch as expect
:param test: QEMU test object
:param params: Dictionary with the test parameters
:param env: Dictionary with test environment
"""
xfail = False
if (params.get("xfail") is not None) and (params.get("xfail") == "yes"):
xfail = True

output = process.getoutput(params["check_status_cmd"])
if output != params["expected_status"]:
test.fail("Disable %s failed" % params["parameter_name"])

params["start_vm"] = 'yes'
has_error = False
try:
env_process.preprocess_vm(test, params, env, params["main_vm"])
except:
has_error = True
if xfail is False:
raise

if (has_error is False) and (xfail is True):
test.fail("Test was expected to fail, but it didn't")

0 comments on commit 9494eb3

Please sign in to comment.