-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Xudong Hao <[email protected]>
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
- tdx_seam_module: | ||
type = tdx_seam_module | ||
virt_test_type = qemu | ||
vm_accelerator = kvm | ||
machine_type_extra_params = "kernel-irqchip=split" | ||
vm_secure_guest_type = tdx | ||
# Don't create/remove guest images | ||
force_create_image = no | ||
remove_image = no | ||
start_vm = no | ||
# Stop VM after testing | ||
kill_vm = yes | ||
shell_prompt = "^\[.*\][\#\$]\s*$" | ||
vga = std | ||
auto_cpu_model = "no" | ||
cpu_model = host | ||
read_cmd = "cat /sys/module/kvm_intel/parameters/%s" | ||
rdmsr_cmd = "rdmsr 0xfe --bitfield 15:15" | ||
tdx_module_pattern = "tdx: module initialized" | ||
tdx_negative_pattern = "No TDX module loaded by BIOS" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Dec. 2024 - Xudong Hao - creation | ||
|
||
import re | ||
|
||
from avocado.utils import process, cpu | ||
|
||
|
||
def run(test, params, env): | ||
""" | ||
TDX module test: | ||
1. Check host TDX capability | ||
2. Check TDX module load status | ||
:param test: QEMU test object | ||
:param params: Dictionary with the test parameters | ||
:param env: Dictionary with test environment. | ||
""" | ||
if cpu.get_cpu_vendor_name() != 'intel': | ||
test.cancel("This test is supposed to run on Intel host") | ||
|
||
rdmsr_cmd = params["rdmsr_cmd"] | ||
if process.getoutput(rdmsr_cmd) != "1": | ||
test.fail("Platform does not support TDX-SEAM") | ||
|
||
read_cmd = params["read_cmd"] | ||
tdx_value = process.getoutput(read_cmd % "tdx") | ||
if tdx_value != "Y": | ||
test.fail("TDX is not supported in KVM") | ||
|
||
module_pattern = params["tdx_module_pattern"] | ||
negative_pattern = params["tdx_negative_pattern"] | ||
dmesg = process.system_output("dmesg") | ||
module_str = re.findall(r'%s' % module_pattern, dmesg.decode('utf-8')) | ||
negative_str = re.findall(r'%s' % negative_pattern, dmesg.decode('utf-8')) | ||
if negative_str or not module_str: | ||
test.fail("TDX module isn't initialized") |