@@ -36,18 +36,36 @@ 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 ()
4858 vm .verify_alive ()
4959 session = vm .wait_for_login (timeout = timeout )
5060 verify_dmesg ()
61+ # Check for /dev/sev-guest inside the guest
62+ test .log .info ("Checking for SNP attestation support in guest" )
63+ rc_code = session .cmd_status ("ls /dev/sev-guest" )
64+ if rc_code :
65+ test .cancel (
66+ "Error: Unable to open /dev/sev-guest. Guest kernel support for "
67+ "SNP attestation is missing."
68+ )
5169 vm_policy = vm .params .get_numeric ("snp_policy" )
5270 guest_check_cmd = params ["snp_guest_check" ]
5371 sev_guest_info = vm .monitor .query_sev ()
@@ -67,14 +85,20 @@ def run(test, params, env):
6785 host_file = os .path .join (deps_dir , host_script )
6886 try :
6987 vm .copy_files_to (host_file , guest_dir )
70- session .cmd_output (params ["guest_tool_install" ], timeout = 240 )
88+ if params .get ("snpguest_sourcebuild" , "0" ) == "1" :
89+ snpguest_build_location = params ["snpguest_build_location" ]
90+ install_snpguest = os .path .join (deps_dir , snpguest_build_location )
91+ vm .copy_files_to (install_snpguest , guest_dir )
92+ session .cmd_output (params ["snpguest_buildcmd" ], timeout = 360 )
93+ else :
94+ session .cmd_output (params ["guest_tool_install" ], timeout = 240 )
7195 session .cmd_output ("chmod 755 %s" % guest_cmd )
7296 except Exception as e :
7397 test .fail ("Guest test preperation fail: %s" % str (e ))
7498 guest_cmd = guest_cmd + " " + host_cpu_model
7599 s = session .cmd_status (guest_cmd , timeout = 360 )
76100 if s :
77- test .fail ("Guest script error" )
101+ test .fail ("Guest script error, check the session logs for further details " )
78102 finally :
79103 session .close ()
80104 vm .destroy ()
0 commit comments