blob: f670043c352bf250c93bbb7172bb91c63bb71624 [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
21Resource ../../lib/secure_utils.robot
22Resource ../../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
Sweta Potthurid3c03432018-04-19 11:30:27 -050027
28Suite Setup Suite Setup Execution
Sweta Potthuri39255032018-03-28 10:12:14 -050029Test Setup Test Setup Execution
30Test Teardown Test Teardown Execution
31
32*** Variables ***
33
34${security_access_bit_mask} ${0xC000000000000000}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060035# TODO: will enable this in next commit
36#${pnor_corruption_rc} SECUREBOOT::RC_ROM_VERIFY
37${pnor_corruption_rc} 0x1E07
Sweta Potthurid3c03432018-04-19 11:30:27 -050038${bmc_image_dir_path} /usr/local/share/pnor
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060039${bmc_guard_part_path} /var/lib/phosphor-software-manager/pnor/prsv/GUARD
devindia54b13932019-03-20 04:38:08 -050040${HB_PART_LIST} [HBB, HBD, HBI, HBRT, HBBL]
41${NON_HB_PART_LIST} [SBE, OCC]
42${MIXED_PART_LIST} [SBE, HBD, OCC, HBRT, HBBL]
Sweta Potthuri39255032018-03-28 10:12:14 -050043
44*** Test Cases ***
45
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060046# All the test cases requires by default jumpers to be positioned
47# between 1 & 2. If this is not met test cases would fail
48# TODO:https://github.com/openbmc/openbmc-test-automation/issues/1644
49Validate Secure Cold Boot With TPM Policy Disabled
50 [Documentation] Validate secure cold boot with TPM policy disabled.
51 [Tags] Validate_Secure_Cold_Boot_With_TPM_Policy_Disabled
Sweta Potthuri39255032018-03-28 10:12:14 -050052
53 Validate Secure Boot With TPM Policy Enabled Or Disabled ${0}
54
55
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060056Validate Secure Cold Boot With TPM Policy Enabled
57 [Documentation] Validate secure cold boot with TPM policy enabled.
58 [Tags] Validate_Secure_Cold_Boot_With_TPM_Policy_Enabled
Sweta Potthuri39255032018-03-28 10:12:14 -050059
60 Validate Secure Boot With TPM Policy Enabled Or Disabled ${1}
61
62
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060063Secure Boot Violation Using Corrupt SBE Image On Cold Boot
64 [Documentation] Secure boot violation using corrupt SBE image on cold boot.
65 [Tags] Secure_Boot_Violation_Using_Corrupt_SBE_Image_On_Cold_Boot
Sweta Potthurid3c03432018-04-19 11:30:27 -050066
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060067 Violate Secure Boot Using Corrupt Image
68 ... SBE ${pnor_corruption_rc} ${bmc_image_dir_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -050069
70
devindia54b13932019-03-20 04:38:08 -050071Secure Boot Violation Using Corrupt HBD Image On Cold Boot
72 [Documentation] Secure boot violation using corrupt HBD image on cold boot.
73 [Tags] Secure_Boot_Violation_Using_Corrupt_HBD_Image_On_Cold_Boot
74
75 Violate Secure Boot Using Corrupt Image
76 ... HBD ${pnor_corruption_rc} ${bmc_image_dir_path}
77
78Secure Boot Violation Using Corrupt HBB Image On Cold Boot
79 [Documentation] Secure boot violation using corrupt HBB image on cold boot.
80 [Tags] Secure_Boot_Violation_Using_Corrupt_HBB_Image_On_Cold_Boot
81
82 Violate Secure Boot Using Corrupt Image
83 ... HBB ${pnor_corruption_rc} ${bmc_image_dir_path}
84
85Secure Boot Violation Using Corrupt HBBL Image On Cold Boot
86 [Documentation] Secure boot violation using corrupt HBBL image on cold boot.
87 [Tags] Secure_Boot_Violation_Using_Corrupt_HBBL_Image_On_Cold_Boot
88
89 Violate Secure Boot Using Corrupt Image
90 ... HBBL ${pnor_corruption_rc} ${bmc_image_dir_path}
91
92
93Secure Boot Violation Using Corrupt HBI Image On Cold Boot
94 [Documentation] Secure boot violation using corrupt HBI image on cold boot.
95 [Tags] Secure_Boot_Violation_Using_Corrupt_HBI_Image_On_Cold_Boot
96
97 Violate Secure Boot Using Corrupt Image
98 ... HBI ${pnor_corruption_rc} ${bmc_image_dir_path}
99
100
101Secure Boot Violation Using Corrupt HBRT Image On Cold Boot
102 [Documentation] Secure boot violation using corrupt HBRT image on cold boot.
103 [Tags] Secure_Boot_Violation_Using_Corrupt_HBRT_Image_On_Cold_Boot
104
105 Violate Secure Boot Using Corrupt Image
106 ... HBRT ${pnor_corruption_rc} ${bmc_image_dir_path}
107
108
109Secure Boot Violation Using Corrupt OCC Image On Cold Boot
110 [Documentation] Secure boot violation using corrupt OCC image on cold boot.
111 [Tags] Secure_Boot_Violation_Using_Corrupt_OCC_Image_On_Cold_Boot
112
113 Violate Secure Boot Using Corrupt Image
114 ... OCC ${pnor_corruption_rc} ${bmc_image_dir_path}
115
Sweta Potthuri39255032018-03-28 10:12:14 -0500116*** Keywords ***
117
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600118Violate Secure Boot Using Corrupt Image
119 [Documentation] Cause secure boot violation during cold boot
120 ... with corrupted image.
121 [Arguments] ${partition} ${error_rc} ${bmc_image_dir_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500122
Gunnar Mills7732c7e2018-08-14 11:54:24 -0500123 # Description of argument(s):
Sweta Potthurid3c03432018-04-19 11:30:27 -0500124 # partition The partition which is to be corrupted
125 # (e.g. "SBE", "HBI", "HBB", "HBRT", "HBBL", "OCC").
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600126 # error_rc The RC that is expected as a
Sweta Potthurid3c03432018-04-19 11:30:27 -0500127 # result of the secure boot violation
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600128 # (e.g. "SECUREBOOT::RC_ROM_VERIFY").
Sweta Potthurid3c03432018-04-19 11:30:27 -0500129 # bmc_image_dir_path BMC image path.
130
131 Set And Verify TPM Policy ${1}
132
133 # Descipiton:
134 # Cause a secure boot violation by copying an BMC image file to the
135 # target BMC and then starting a power on.
136 # This action should result in:
137 # 1) an error log entry
138 # 2) the system going to "Quiesced" state.
139
140 # Load corrupted image to /usr/local/share/pnor.
141 Open Connection For SCP
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600142
Sweta Potthurid3c03432018-04-19 11:30:27 -0500143 scp.Put File
devindia54b13932019-03-20 04:38:08 -0500144 ... ${ENV_SB_CORRUPTED_BIN_PATH}/${partition} ${bmc_image_dir_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500145
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600146 ${error_log_path}= Catenate ${SB_LOG_DIR_PATH}/partition-corruption
147 Create Directory ${error_log_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500148
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600149 Set Global Variable ${error_log_path}
150 Log ${error_log_path}
151
152 # Starting a power on.
153 # TODO: Need to move to REST Power On. Needs more testing.
154 BMC Execute Command /usr/sbin/obmcutil poweron
155 Wait Until Keyword Succeeds 15 min 15 sec Error Logs Should Exist
156
devindia54b13932019-03-20 04:38:08 -0500157 #TODO: This will be enabled little later as more tesing required
158 #Wait Until Keyword Succeeds 5 min 5 sec
159 #... Collect Error Logs and Verify SRC ${error_rc} ${error_log_path}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600160
devindia54b13932019-03-20 04:38:08 -0500161 # Expected behavior is that the error occurs early in the boot process,
162 # therefore, no entry in the error log and nothing to decode.
163 # The 1E07 error is written to PNOR & then goes into Quiesced state.
164 # On the next valid boot, the error log will be sent to BMC &
165 # seen on SOL console
166 Run Keyword If '${partition}' in '${NON_HB_PART_LIST}'
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600167 # Verify the RC 0x1E07 in the SOL logs.
devindia54b13932019-03-20 04:38:08 -0500168 ... Get And Verify Partition Corruption ${partition} ${sol_log_file_path}
169 ... ELSE IF '${partition}' in '${HB_PART_LIST}'
170 ... Log To Console ${partition} corrupted, Going to quiesced state.
Sweta Potthurid3c03432018-04-19 11:30:27 -0500171
172 # Remove the file from /usr/local/share/pnor/.
173 BMC Execute Command rm -rf ${bmc_image_dir_path}*
174
175 # Check if system reaches quiesce state.
devindia54b13932019-03-20 04:38:08 -0500176 # Default system state will be power off at the end of the verification.
Sweta Potthurid3c03432018-04-19 11:30:27 -0500177 Run Keywords
178 ... Wait Until Keyword Succeeds 3 min 5 sec Is Host Quiesced AND
179 ... Recover Quiesced Host
180
devindia54b13932019-03-20 04:38:08 -0500181 # We will retry boot with corrupted partition removed
182 # SOL console should show previous boot fail message (1E07) on current boot
183 # HBB corruption will never get far enough to log into PNOR.
184 # so, it should be removed from consideration for this check
185 Run Keyword If '${partition}' == 'HBB'
186 ... Log To Console No more action on ${partition} corruption required.
187 ... ELSE IF '${partition}' in '[HBD, HBI, HBRT, HBBL]'
188 ... Run Keywords
189 ... REST Power On stack_mode=skip quiet=1 AND
190 ... Wait Until Keyword Succeeds 5 min 5 sec Error Logs Should Exist AND
191 ... Get And Verify Partition Corruption ${partition} ${sol_log_file_path} AND
192 ... REST Power Off stack_mode=skip quiet=1
Sweta Potthurid3c03432018-04-19 11:30:27 -0500193
194Collect Error Logs and Verify SRC
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600195 [Documentation] Verify error log entry & signature description.
196 [Arguments] ${error_rc} ${log_prefix}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500197
198 # Description of argument(s):
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600199 # error_rc Error log signature description.
200 # log_prefix Log path prefix.
Sweta Potthurid3c03432018-04-19 11:30:27 -0500201
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600202 Error Logs Should Not Exist
Sweta Potthurid3c03432018-04-19 11:30:27 -0500203
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600204 Collect eSEL Log ${log_prefix}
205 ${error_log_file_path}= Catenate ${log_prefix}esel.txt
206 ${rc} ${output}= Run and Return RC and Output
207 ... grep -i ${error_rc} ${error_log_file_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500208 Should Be Equal ${rc} ${0}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600209 Should Not Be Empty ${output}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500210
Sweta Potthuri39255032018-03-28 10:12:14 -0500211Get And Verify Security Access Bit
212 [Documentation] Get and verify security access bit.
213 [Arguments] ${sol_log_file_path}
214
215 # Description of argument(s):
216 # sol_log_file_path The path to the file containing SOL data
217 # which was collected during a REST Power On.
218
219 # Sample output:
220 # 19.68481|SECURE|Security Access Bit> 0xC000000000000000
221
222 ${cmd}= Catenate
223 ... grep "Security Access Bit" ${sol_log_file_path} | awk '{ print $4 }'
224 ${rc} ${security_access_bit_str}= Run and Return RC and Output ${cmd}
225 Should Be Equal ${rc} ${0}
226 ... msg=Return code from ${cmd} not zero.
227
228 # Verify the value of "Security Access Bit".
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600229 # If fails, probable issue is Jumper position.
Sweta Potthuri39255032018-03-28 10:12:14 -0500230
231 ${security_access_bit}= Convert to Integer ${security_access_bit_str}
232 ${result}= Evaluate ${security_access_bit_mask} & ${security_access_bit}
233 Should Be Equal ${result} ${security_access_bit_mask}
234 ... msg=System is not booted in secure mode. values=False
235
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600236Get And Verify Partition Corruption
237 [Documentation] Get and verify partition corruption.
devindia54b13932019-03-20 04:38:08 -0500238 [Arguments] ${partition} ${sol_log_file_path}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600239
240 # Description of argument(s):
devindia54b13932019-03-20 04:38:08 -0500241 # partition The partition which is to be corrupted
242 # (e.g. "SBE", "HBI", "HBB", "HBRT", "HBBL", "OCC").
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600243 # sol_log_file_path The path to the file containing SOL data
244 # which was collected during a REST Power On.
245
246 # Sample output:
247 # 44.47498|secure|Secureboot Failure plid = 0x90000007, rc = 0x1E07
devindia54b13932019-03-20 04:38:08 -0500248 # OR
249 # 14.94315|Error reported by secure (0x1E00) PLID 0x90000002
250 # 14.99659| ROM_verify() Call Failed
251 # 14.99659| ModuleId 0x03 SECUREBOOT::MOD_SECURE_ROM_VERIFY
252 # 14.99660| ReasonCode 0x1e07 SECUREBOOT::RC_ROM_VERIFY
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600253
devindia54b13932019-03-20 04:38:08 -0500254 ${cmd}= Run Keyword If '${partition}' in '${MIXED_PART_LIST}'
255 ... Catenate
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600256 ... grep -i "Secureboot Failure" ${sol_log_file_path} | awk '{ print $8 }'
devindia54b13932019-03-20 04:38:08 -0500257 ... ELSE IF '${partition}' == 'HBI'
258 ... Catenate
259 ... grep -i "ReasonCode" ${sol_log_file_path} | awk '{ print $3 }'
260
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600261 ${rc} ${corruption_rc_str}= Run and Return RC and Output ${cmd}
262 Should Be Equal ${rc} ${0}
263 ... msg=Return code from ${cmd} not zero.
264
265 # Verify the RC 0x1E07 from sol output".
devindia54b13932019-03-20 04:38:08 -0500266 Should Be Equal As Strings
267 ... ${corruption_rc_str} ${pnor_corruption_rc} ignore_case=True
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600268 ... msg=SB violation due to PNOR partition corruption not reported. values=False
269
Sweta Potthuri39255032018-03-28 10:12:14 -0500270
271Validate Secure Boot With TPM Policy Enabled Or Disabled
272 [Documentation] Validate secure boot with TPM policy enabled or disabled.
273 [Arguments] ${tpm_policy}
274
275 # Description of argument(s):
276 # tpm_policy Enable-0 or Disable-1.
277
278 Set And Verify TPM Policy ${tpm_policy}
279 REST Power On quiet=1
280 Validate Secure Boot ${sol_log_file_path}
281
282
283Validate Secure Boot
284 [Documentation] Validate secure boot.
285 [Arguments] ${sol_log_file_path}
286
287 # Description of argument(s):
288 # sol_log_file_path The path to the file containing SOL data
289 # which was collected during a REST Power On.
290
291 Get And Verify Security Access Bit ${sol_log_file_path}
292 Error Logs Should Not Exist
293 REST Verify No Gard Records
294
295
Sweta Potthurid3c03432018-04-19 11:30:27 -0500296Suite Setup Execution
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600297 [Documentation] Suite Setup Execution.
Sweta Potthurid3c03432018-04-19 11:30:27 -0500298
Sweta Potthurid3c03432018-04-19 11:30:27 -0500299 ${bmc_image_dir_path}= Add Trailing Slash ${bmc_image_dir_path}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600300
301 ${SB_LOG_DIR_PATH}= Catenate ${EXECDIR}/SB_logs/
302 Set Suite Variable ${SB_LOG_DIR_PATH}
303
304 Create Directory ${SB_LOG_DIR_PATH}
305 Empty Directory ${SB_LOG_DIR_PATH}
Lakshminarayana R. Kammath077fbf92019-02-20 11:15:18 -0600306
Sweta Potthurid3c03432018-04-19 11:30:27 -0500307 Set Global Variable ${bmc_image_dir_path}
308 Log ${bmc_image_dir_path}
309 BMC Execute Command rm -rf ${bmc_image_dir_path}*
310
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600311 Set Global Variable ${bmc_guard_part_path}
312 Log ${bmc_guard_part_path}
313 BMC Execute Command rm -rf ${bmc_guard_part_path}
Lakshminarayana R. Kammath077fbf92019-02-20 11:15:18 -0600314
devindia54b13932019-03-20 04:38:08 -0500315 # All the corrupted binaries will go in here
316 # Run this as input param
317 Should Not Be Empty ${ENV_SB_CORRUPTED_BIN_PATH}
318 Set Environment Variable PATH %{PATH}:${ENV_SB_CORRUPTED_BIN_PATH}
319
Sweta Potthurid3c03432018-04-19 11:30:27 -0500320
Sweta Potthuri39255032018-03-28 10:12:14 -0500321Test Setup Execution
322 [Documentation] Test setup execution.
323
324 ${timestamp}= Get Current Date result_format=%Y%m%d%H%M%S
325 ${sol_log_file_path}= Catenate ${EXECDIR}/Secure_SOL${timestamp}
326 Start SOL Console Logging ${sol_log_file_path}
327 Set Suite Variable ${sol_log_file_path}
328
329 REST Power Off stack_mode=skip quiet=1
330 Delete Error Logs And Verify
Lakshminarayana R. Kammath077fbf92019-02-20 11:15:18 -0600331
Sweta Potthuri39255032018-03-28 10:12:14 -0500332
Sweta Potthuri39255032018-03-28 10:12:14 -0500333Test Teardown Execution
334 [Documentation] Test teardown execution.
335
336 Stop SOL Console Logging
337 Run rm -rf ${sol_log_file_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500338
devindia54b13932019-03-20 04:38:08 -0500339 # Collect FFDC on failure
340 FFDC On Test Case Fail
341
Sweta Potthurid3c03432018-04-19 11:30:27 -0500342 # Removing the corrupted file from BMC.
343 BMC Execute Command rm -rf ${bmc_image_dir_path}*