Skip to content

Commit 8519b16

Browse files
committed
Update SNP guest attestation
1. Update SEV-SNP testcase and config to support snpguest tool installation from source. 2. Enhance CPU model detection for broader platform support. 3. Update SNP policy values, add a debug policy variant 4. Improve error handling in the testcase script. 5. Rename snp_basic_config.py and snp_basic_config.cfg to snp_attestation.py and snp_attestation.cfg for clarity. Signed-off-by: Srikanth Aithal <[email protected]>
1 parent ee733c5 commit 8519b16

File tree

2 files changed

+36
-11
lines changed

2 files changed

+36
-11
lines changed

qemu/tests/cfg/snp_basic_config.cfg renamed to qemu/tests/cfg/snp_attestation.cfg

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
- snp_basic_config:
2-
type = snp_basic_config
1+
- snp_attestation:
2+
type = snp_attestation
33
only Linux
44
kill_vm = yes
55
login_timeout = 240
66
start_vm = no
77
image_snapshot = yes
88
mem = 8192
99
smp = 8
10+
required_qemu = [9.1.0, )
1011
vm_secure_guest_type = snp
1112
vm_sev_reduced_phys_bits = 1
1213
vm_sev_cbitpos = 51
@@ -16,10 +17,14 @@
1617
module_status = Y y 1
1718
snp_guest_check = "journalctl|grep -i -w snp"
1819
guest_tool_install = "dnf install -y snpguest"
20+
snpguest_sourcebuild = 1
1921
attestation_script = regular_attestation_workflow.sh
22+
snpguest_install_script = snpguest_install.sh
2023
guest_dir = /home
2124
guest_cmd = ${guest_dir}/${attestation_script}
2225
host_script = sev-snp/${attestation_script}
26+
snpguest_buildcmd = "${guest_dir}/${snpguest_install_script} --repo https://github.com/virtee/snpguest.git --tag v0.9.1"
27+
snpguest_build_location = sev-snp/${snpguest_install_script}
2328
variants:
2429
- policy_default:
2530
snp_policy = 196608
@@ -29,5 +34,9 @@
2934
vm_secure_guest_object_options = "policy=${snp_policy}"
3035
- policy_singlesocket:
3136
socket_count_cmd = 'lscpu |grep Socket|head -1 | cut -d ":" -f 2 | tr -d " "'
32-
snp_policy = 77824
37+
snp_policy = 1245184
38+
vm_secure_guest_object_options = "policy=${snp_policy}"
39+
- policy_singlesocket_debug:
40+
socket_count_cmd = 'lscpu |grep Socket|head -1 | cut -d ":" -f 2 | tr -d " "'
41+
snp_policy = 1769472
3342
vm_secure_guest_object_options = "policy=${snp_policy}"

qemu/tests/snp_basic_config.py renamed to qemu/tests/snp_attestation.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,22 @@ def run(test, params, env):
3636
if int(process.getoutput(socket_count_cmd, shell=True)) != 1:
3737
test.cancel("Host cpu has more than 1 socket, skip the case.")
3838

39-
family_id = cpu.get_family()
40-
model_id = cpu.get_model()
41-
dict_cpu = {"251": "milan", "2517": "genoa", "2617": "turin"}
42-
key = str(family_id) + str(model_id)
43-
host_cpu_model = dict_cpu.get(key, "unknown")
44-
39+
family_id = int(cpu.get_family())
40+
model_id = int(cpu.get_model())
41+
dict_cpu = {
42+
"milan": [25, 0, 15],
43+
"genoa": [25, 16, 31],
44+
"bergamo": [25, 160, 175],
45+
"turin": [26, 0, 31],
46+
}
47+
host_cpu_model = None
48+
for platform, values in dict_cpu.items():
49+
if values[0] == family_id:
50+
if model_id >= values[1] and model_id <= values[2]:
51+
host_cpu_model = platform
52+
if not host_cpu_model:
53+
test.cancel("Unsupported paltform. Requires milan or above.")
54+
test.log.info("Detected platform: %s", host_cpu_model)
4555
vm_name = params["main_vm"]
4656
vm = env.get_vm(vm_name)
4757
vm.create()
@@ -67,14 +77,20 @@ def run(test, params, env):
6777
host_file = os.path.join(deps_dir, host_script)
6878
try:
6979
vm.copy_files_to(host_file, guest_dir)
70-
session.cmd_output(params["guest_tool_install"], timeout=240)
80+
if params.get("snpguest_sourcebuild", "0") == "1":
81+
snpguest_build_location = params["snpguest_build_location"]
82+
install_snpguest = os.path.join(deps_dir, snpguest_build_location)
83+
vm.copy_files_to(install_snpguest, guest_dir)
84+
session.cmd_output(params["snpguest_buildcmd"], timeout=360)
85+
else:
86+
session.cmd_output(params["guest_tool_install"], timeout=240)
7187
session.cmd_output("chmod 755 %s" % guest_cmd)
7288
except Exception as e:
7389
test.fail("Guest test preperation fail: %s" % str(e))
7490
guest_cmd = guest_cmd + " " + host_cpu_model
7591
s = session.cmd_status(guest_cmd, timeout=360)
7692
if s:
77-
test.fail("Guest script error")
93+
test.fail("Guest script error, check the session logs for further details")
7894
finally:
7995
session.close()
8096
vm.destroy()

0 commit comments

Comments
 (0)