blob: f6609c7a91e00fd73a8b1971ab27f8147ab4a2fc [file] [log] [blame]
Sweta Potthuri39255032018-03-28 10:12:14 -05001*** Settings ***
2Documentation Secure boot related test cases.
3
Sweta Potthurid3c03432018-04-19 11:30:27 -05004# Test Parameters:
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -06005# SEL to PEL conversion:
6# https://github.com/openbmc/openbmc-test-automation/blob/master/docs/
7# openbmc_test_tools.md#converting-sels-to-readable-format
devindia54b13932019-03-20 04:38:08 -05008#
9# Definition of each partition acronyms
10# HBB: Hostboot Base
11# HBI: Hostboot Extended Image
12# HBRT: Hostboot Runtime
13# HBD: Hostboot Data
14# HBBL: Bostboot Base loader
15# SBE: Self Boot Engine
16# OCC: On Chip Controller
Sweta Potthurid3c03432018-04-19 11:30:27 -050017
George Keishinga8b25492018-06-07 01:15:37 -050018Resource ../../lib/utils.robot
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060019Resource ../../lib/state_manager.robot
George Keishinga8b25492018-06-07 01:15:37 -050020Resource ../../lib/boot_utils.robot
Lakshminarayana R. Kammatheca4dce2019-03-27 12:28:06 -050021Resource ../../lib/secureboot/secureboot.robot
George Keishinga8b25492018-06-07 01:15:37 -050022Resource ../../lib/open_power_utils.robot
23Resource ../../lib/logging_utils.robot
24Resource ../../lib/openbmc_ffdc_methods.robot
Sweta Potthuri39255032018-03-28 10:12:14 -050025
George Keishinga8b25492018-06-07 01:15:37 -050026Library ../../lib/gen_misc.py
Lakshminarayana R. Kammatheca4dce2019-03-27 12:28:06 -050027Library ../../lib/secureboot/secureboot.py
Sweta Potthurid3c03432018-04-19 11:30:27 -050028
29Suite Setup Suite Setup Execution
Sweta Potthuri39255032018-03-28 10:12:14 -050030Test Setup Test Setup Execution
31Test Teardown Test Teardown Execution
32
33*** Variables ***
34
35${security_access_bit_mask} ${0xC000000000000000}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060036# TODO: will enable this in next commit
37#${pnor_corruption_rc} SECUREBOOT::RC_ROM_VERIFY
38${pnor_corruption_rc} 0x1E07
Sweta Potthurid3c03432018-04-19 11:30:27 -050039${bmc_image_dir_path} /usr/local/share/pnor
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060040${bmc_guard_part_path} /var/lib/phosphor-software-manager/pnor/prsv/GUARD
devindia54b13932019-03-20 04:38:08 -050041${HB_PART_LIST} [HBB, HBD, HBI, HBRT, HBBL]
42${NON_HB_PART_LIST} [SBE, OCC]
43${MIXED_PART_LIST} [SBE, HBD, OCC, HBRT, HBBL]
Sweta Potthuri39255032018-03-28 10:12:14 -050044
45*** Test Cases ***
46
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060047# All the test cases requires by default jumpers to be positioned
48# between 1 & 2. If this is not met test cases would fail
49# TODO:https://github.com/openbmc/openbmc-test-automation/issues/1644
50Validate Secure Cold Boot With TPM Policy Disabled
51 [Documentation] Validate secure cold boot with TPM policy disabled.
52 [Tags] Validate_Secure_Cold_Boot_With_TPM_Policy_Disabled
Sweta Potthuri39255032018-03-28 10:12:14 -050053
54 Validate Secure Boot With TPM Policy Enabled Or Disabled ${0}
55
56
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060057Validate Secure Cold Boot With TPM Policy Enabled
58 [Documentation] Validate secure cold boot with TPM policy enabled.
59 [Tags] Validate_Secure_Cold_Boot_With_TPM_Policy_Enabled
Sweta Potthuri39255032018-03-28 10:12:14 -050060
61 Validate Secure Boot With TPM Policy Enabled Or Disabled ${1}
62
63
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060064Secure Boot Violation Using Corrupt SBE Image On Cold Boot
65 [Documentation] Secure boot violation using corrupt SBE image on cold boot.
66 [Tags] Secure_Boot_Violation_Using_Corrupt_SBE_Image_On_Cold_Boot
Sweta Potthurid3c03432018-04-19 11:30:27 -050067
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060068 Violate Secure Boot Using Corrupt Image
69 ... SBE ${pnor_corruption_rc} ${bmc_image_dir_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -050070
71
devindia54b13932019-03-20 04:38:08 -050072Secure Boot Violation Using Corrupt HBD Image On Cold Boot
73 [Documentation] Secure boot violation using corrupt HBD image on cold boot.
74 [Tags] Secure_Boot_Violation_Using_Corrupt_HBD_Image_On_Cold_Boot
75
76 Violate Secure Boot Using Corrupt Image
77 ... HBD ${pnor_corruption_rc} ${bmc_image_dir_path}
78
79Secure Boot Violation Using Corrupt HBB Image On Cold Boot
80 [Documentation] Secure boot violation using corrupt HBB image on cold boot.
81 [Tags] Secure_Boot_Violation_Using_Corrupt_HBB_Image_On_Cold_Boot
82
83 Violate Secure Boot Using Corrupt Image
84 ... HBB ${pnor_corruption_rc} ${bmc_image_dir_path}
85
86Secure Boot Violation Using Corrupt HBBL Image On Cold Boot
87 [Documentation] Secure boot violation using corrupt HBBL image on cold boot.
88 [Tags] Secure_Boot_Violation_Using_Corrupt_HBBL_Image_On_Cold_Boot
89
90 Violate Secure Boot Using Corrupt Image
91 ... HBBL ${pnor_corruption_rc} ${bmc_image_dir_path}
92
93
94Secure Boot Violation Using Corrupt HBI Image On Cold Boot
95 [Documentation] Secure boot violation using corrupt HBI image on cold boot.
96 [Tags] Secure_Boot_Violation_Using_Corrupt_HBI_Image_On_Cold_Boot
97
98 Violate Secure Boot Using Corrupt Image
99 ... HBI ${pnor_corruption_rc} ${bmc_image_dir_path}
100
101
102Secure Boot Violation Using Corrupt HBRT Image On Cold Boot
103 [Documentation] Secure boot violation using corrupt HBRT image on cold boot.
104 [Tags] Secure_Boot_Violation_Using_Corrupt_HBRT_Image_On_Cold_Boot
105
106 Violate Secure Boot Using Corrupt Image
107 ... HBRT ${pnor_corruption_rc} ${bmc_image_dir_path}
108
109
110Secure Boot Violation Using Corrupt OCC Image On Cold Boot
111 [Documentation] Secure boot violation using corrupt OCC image on cold boot.
112 [Tags] Secure_Boot_Violation_Using_Corrupt_OCC_Image_On_Cold_Boot
113
114 Violate Secure Boot Using Corrupt Image
115 ... OCC ${pnor_corruption_rc} ${bmc_image_dir_path}
116
Sweta Potthuri39255032018-03-28 10:12:14 -0500117*** Keywords ***
118
Lakshminarayana R. Kammatheca4dce2019-03-27 12:28:06 -0500119Validate Secure Boot Setup
120 [Documentation] Validates setup to make sure it's secureboot run capable.
121
122 # Check the jumper position and Security settings before moving ahead.
123 ${num_procs} ${secureboot_state} ${jumper_state}= Get Secure Boot Info
124
125 Rprint Vars secureboot_state jumper_state
126
127 Should Be True ${secureboot_state} == True and ${jumper_state} == False
128 ... msg=Jumper is on while secureboot is disabled. Put the jumpers between pins 2 and 3.
129
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600130Violate Secure Boot Using Corrupt Image
131 [Documentation] Cause secure boot violation during cold boot
132 ... with corrupted image.
133 [Arguments] ${partition} ${error_rc} ${bmc_image_dir_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500134
Gunnar Mills7732c7e2018-08-14 11:54:24 -0500135 # Description of argument(s):
Sweta Potthurid3c03432018-04-19 11:30:27 -0500136 # partition The partition which is to be corrupted
137 # (e.g. "SBE", "HBI", "HBB", "HBRT", "HBBL", "OCC").
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600138 # error_rc The RC that is expected as a
Sweta Potthurid3c03432018-04-19 11:30:27 -0500139 # result of the secure boot violation
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600140 # (e.g. "SECUREBOOT::RC_ROM_VERIFY").
Sweta Potthurid3c03432018-04-19 11:30:27 -0500141 # bmc_image_dir_path BMC image path.
142
143 Set And Verify TPM Policy ${1}
144
145 # Descipiton:
146 # Cause a secure boot violation by copying an BMC image file to the
147 # target BMC and then starting a power on.
148 # This action should result in:
149 # 1) an error log entry
150 # 2) the system going to "Quiesced" state.
151
152 # Load corrupted image to /usr/local/share/pnor.
153 Open Connection For SCP
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600154
Sweta Potthurid3c03432018-04-19 11:30:27 -0500155 scp.Put File
devindia54b13932019-03-20 04:38:08 -0500156 ... ${ENV_SB_CORRUPTED_BIN_PATH}/${partition} ${bmc_image_dir_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500157
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600158 ${error_log_path}= Catenate ${SB_LOG_DIR_PATH}/partition-corruption
159 Create Directory ${error_log_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500160
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600161 Set Global Variable ${error_log_path}
162 Log ${error_log_path}
163
164 # Starting a power on.
165 # TODO: Need to move to REST Power On. Needs more testing.
166 BMC Execute Command /usr/sbin/obmcutil poweron
167 Wait Until Keyword Succeeds 15 min 15 sec Error Logs Should Exist
168
devindia54b13932019-03-20 04:38:08 -0500169 #TODO: This will be enabled little later as more tesing required
170 #Wait Until Keyword Succeeds 5 min 5 sec
171 #... Collect Error Logs and Verify SRC ${error_rc} ${error_log_path}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600172
devindia54b13932019-03-20 04:38:08 -0500173 # Expected behavior is that the error occurs early in the boot process,
174 # therefore, no entry in the error log and nothing to decode.
175 # The 1E07 error is written to PNOR & then goes into Quiesced state.
176 # On the next valid boot, the error log will be sent to BMC &
177 # seen on SOL console
178 Run Keyword If '${partition}' in '${NON_HB_PART_LIST}'
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600179 # Verify the RC 0x1E07 in the SOL logs.
devindia54b13932019-03-20 04:38:08 -0500180 ... Get And Verify Partition Corruption ${partition} ${sol_log_file_path}
181 ... ELSE IF '${partition}' in '${HB_PART_LIST}'
182 ... Log To Console ${partition} corrupted, Going to quiesced state.
Sweta Potthurid3c03432018-04-19 11:30:27 -0500183
184 # Remove the file from /usr/local/share/pnor/.
185 BMC Execute Command rm -rf ${bmc_image_dir_path}*
186
187 # Check if system reaches quiesce state.
devindia54b13932019-03-20 04:38:08 -0500188 # Default system state will be power off at the end of the verification.
Sweta Potthurid3c03432018-04-19 11:30:27 -0500189 Run Keywords
190 ... Wait Until Keyword Succeeds 3 min 5 sec Is Host Quiesced AND
191 ... Recover Quiesced Host
192
devindia54b13932019-03-20 04:38:08 -0500193 # We will retry boot with corrupted partition removed
194 # SOL console should show previous boot fail message (1E07) on current boot
195 # HBB corruption will never get far enough to log into PNOR.
196 # so, it should be removed from consideration for this check
197 Run Keyword If '${partition}' == 'HBB'
198 ... Log To Console No more action on ${partition} corruption required.
199 ... ELSE IF '${partition}' in '[HBD, HBI, HBRT, HBBL]'
200 ... Run Keywords
201 ... REST Power On stack_mode=skip quiet=1 AND
202 ... Wait Until Keyword Succeeds 5 min 5 sec Error Logs Should Exist AND
203 ... Get And Verify Partition Corruption ${partition} ${sol_log_file_path} AND
204 ... REST Power Off stack_mode=skip quiet=1
Sweta Potthurid3c03432018-04-19 11:30:27 -0500205
206Collect Error Logs and Verify SRC
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600207 [Documentation] Verify error log entry & signature description.
208 [Arguments] ${error_rc} ${log_prefix}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500209
210 # Description of argument(s):
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600211 # error_rc Error log signature description.
212 # log_prefix Log path prefix.
Sweta Potthurid3c03432018-04-19 11:30:27 -0500213
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600214 Error Logs Should Not Exist
Sweta Potthurid3c03432018-04-19 11:30:27 -0500215
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600216 Collect eSEL Log ${log_prefix}
217 ${error_log_file_path}= Catenate ${log_prefix}esel.txt
218 ${rc} ${output}= Run and Return RC and Output
219 ... grep -i ${error_rc} ${error_log_file_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500220 Should Be Equal ${rc} ${0}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600221 Should Not Be Empty ${output}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500222
Sweta Potthuri39255032018-03-28 10:12:14 -0500223Get And Verify Security Access Bit
224 [Documentation] Get and verify security access bit.
225 [Arguments] ${sol_log_file_path}
226
227 # Description of argument(s):
228 # sol_log_file_path The path to the file containing SOL data
229 # which was collected during a REST Power On.
230
231 # Sample output:
232 # 19.68481|SECURE|Security Access Bit> 0xC000000000000000
233
234 ${cmd}= Catenate
235 ... grep "Security Access Bit" ${sol_log_file_path} | awk '{ print $4 }'
236 ${rc} ${security_access_bit_str}= Run and Return RC and Output ${cmd}
237 Should Be Equal ${rc} ${0}
238 ... msg=Return code from ${cmd} not zero.
239
240 # Verify the value of "Security Access Bit".
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600241 # If fails, probable issue is Jumper position.
Sweta Potthuri39255032018-03-28 10:12:14 -0500242
243 ${security_access_bit}= Convert to Integer ${security_access_bit_str}
244 ${result}= Evaluate ${security_access_bit_mask} & ${security_access_bit}
245 Should Be Equal ${result} ${security_access_bit_mask}
246 ... msg=System is not booted in secure mode. values=False
247
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600248Get And Verify Partition Corruption
249 [Documentation] Get and verify partition corruption.
devindia54b13932019-03-20 04:38:08 -0500250 [Arguments] ${partition} ${sol_log_file_path}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600251
252 # Description of argument(s):
devindia54b13932019-03-20 04:38:08 -0500253 # partition The partition which is to be corrupted
254 # (e.g. "SBE", "HBI", "HBB", "HBRT", "HBBL", "OCC").
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600255 # sol_log_file_path The path to the file containing SOL data
256 # which was collected during a REST Power On.
257
258 # Sample output:
259 # 44.47498|secure|Secureboot Failure plid = 0x90000007, rc = 0x1E07
devindia54b13932019-03-20 04:38:08 -0500260 # OR
261 # 14.94315|Error reported by secure (0x1E00) PLID 0x90000002
262 # 14.99659| ROM_verify() Call Failed
263 # 14.99659| ModuleId 0x03 SECUREBOOT::MOD_SECURE_ROM_VERIFY
264 # 14.99660| ReasonCode 0x1e07 SECUREBOOT::RC_ROM_VERIFY
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600265
devindia54b13932019-03-20 04:38:08 -0500266 ${cmd}= Run Keyword If '${partition}' in '${MIXED_PART_LIST}'
267 ... Catenate
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600268 ... grep -i "Secureboot Failure" ${sol_log_file_path} | awk '{ print $8 }'
devindia54b13932019-03-20 04:38:08 -0500269 ... ELSE IF '${partition}' == 'HBI'
270 ... Catenate
271 ... grep -i "ReasonCode" ${sol_log_file_path} | awk '{ print $3 }'
272
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600273 ${rc} ${corruption_rc_str}= Run and Return RC and Output ${cmd}
274 Should Be Equal ${rc} ${0}
275 ... msg=Return code from ${cmd} not zero.
276
277 # Verify the RC 0x1E07 from sol output".
devindia54b13932019-03-20 04:38:08 -0500278 Should Be Equal As Strings
279 ... ${corruption_rc_str} ${pnor_corruption_rc} ignore_case=True
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600280 ... msg=SB violation due to PNOR partition corruption not reported. values=False
281
Sweta Potthuri39255032018-03-28 10:12:14 -0500282
283Validate Secure Boot With TPM Policy Enabled Or Disabled
284 [Documentation] Validate secure boot with TPM policy enabled or disabled.
285 [Arguments] ${tpm_policy}
286
287 # Description of argument(s):
288 # tpm_policy Enable-0 or Disable-1.
289
290 Set And Verify TPM Policy ${tpm_policy}
291 REST Power On quiet=1
292 Validate Secure Boot ${sol_log_file_path}
293
294
295Validate Secure Boot
296 [Documentation] Validate secure boot.
297 [Arguments] ${sol_log_file_path}
298
299 # Description of argument(s):
300 # sol_log_file_path The path to the file containing SOL data
301 # which was collected during a REST Power On.
302
303 Get And Verify Security Access Bit ${sol_log_file_path}
304 Error Logs Should Not Exist
305 REST Verify No Gard Records
306
307
Sweta Potthurid3c03432018-04-19 11:30:27 -0500308Suite Setup Execution
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600309 [Documentation] Suite Setup Execution.
Sweta Potthurid3c03432018-04-19 11:30:27 -0500310
Sweta Potthurid3c03432018-04-19 11:30:27 -0500311 ${bmc_image_dir_path}= Add Trailing Slash ${bmc_image_dir_path}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600312
313 ${SB_LOG_DIR_PATH}= Catenate ${EXECDIR}/SB_logs/
314 Set Suite Variable ${SB_LOG_DIR_PATH}
315
316 Create Directory ${SB_LOG_DIR_PATH}
317 Empty Directory ${SB_LOG_DIR_PATH}
Lakshminarayana R. Kammath077fbf92019-02-20 11:15:18 -0600318
Sweta Potthurid3c03432018-04-19 11:30:27 -0500319 Set Global Variable ${bmc_image_dir_path}
320 Log ${bmc_image_dir_path}
321 BMC Execute Command rm -rf ${bmc_image_dir_path}*
322
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600323 Set Global Variable ${bmc_guard_part_path}
324 Log ${bmc_guard_part_path}
325 BMC Execute Command rm -rf ${bmc_guard_part_path}
Lakshminarayana R. Kammath077fbf92019-02-20 11:15:18 -0600326
devindia54b13932019-03-20 04:38:08 -0500327 # All the corrupted binaries will go in here
328 # Run this as input param
329 Should Not Be Empty ${ENV_SB_CORRUPTED_BIN_PATH}
330 Set Environment Variable PATH %{PATH}:${ENV_SB_CORRUPTED_BIN_PATH}
331
Sweta Potthurid3c03432018-04-19 11:30:27 -0500332
Sweta Potthuri39255032018-03-28 10:12:14 -0500333Test Setup Execution
334 [Documentation] Test setup execution.
335
336 ${timestamp}= Get Current Date result_format=%Y%m%d%H%M%S
337 ${sol_log_file_path}= Catenate ${EXECDIR}/Secure_SOL${timestamp}
338 Start SOL Console Logging ${sol_log_file_path}
339 Set Suite Variable ${sol_log_file_path}
340
Lakshminarayana R. Kammatheca4dce2019-03-27 12:28:06 -0500341 REST Power On stack_mode=skip quiet=1
342
343 # Validate the secureboot setup. If not met with required state then, fail.
344 Validate Secure Boot Setup
345
Sweta Potthuri39255032018-03-28 10:12:14 -0500346 REST Power Off stack_mode=skip quiet=1
347 Delete Error Logs And Verify
Lakshminarayana R. Kammath077fbf92019-02-20 11:15:18 -0600348
Sweta Potthuri39255032018-03-28 10:12:14 -0500349
Sweta Potthuri39255032018-03-28 10:12:14 -0500350Test Teardown Execution
351 [Documentation] Test teardown execution.
352
353 Stop SOL Console Logging
354 Run rm -rf ${sol_log_file_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500355
devindia54b13932019-03-20 04:38:08 -0500356 # Collect FFDC on failure
357 FFDC On Test Case Fail
358
Sweta Potthurid3c03432018-04-19 11:30:27 -0500359 # Removing the corrupted file from BMC.
360 BMC Execute Command rm -rf ${bmc_image_dir_path}*