blob: 4760e65a53c3f5f8e4b21d95654e0749617e71b6 [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
Sweta Potthurid3c03432018-04-19 11:30:27 -05008
George Keishinga8b25492018-06-07 01:15:37 -05009Resource ../../lib/utils.robot
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060010Resource ../../lib/state_manager.robot
George Keishinga8b25492018-06-07 01:15:37 -050011Resource ../../lib/boot_utils.robot
12Resource ../../lib/secure_utils.robot
13Resource ../../lib/open_power_utils.robot
14Resource ../../lib/logging_utils.robot
15Resource ../../lib/openbmc_ffdc_methods.robot
Sweta Potthuri39255032018-03-28 10:12:14 -050016
George Keishinga8b25492018-06-07 01:15:37 -050017Library ../../lib/gen_misc.py
Sweta Potthurid3c03432018-04-19 11:30:27 -050018
19Suite Setup Suite Setup Execution
Sweta Potthuri39255032018-03-28 10:12:14 -050020Test Setup Test Setup Execution
21Test Teardown Test Teardown Execution
22
23*** Variables ***
24
25${security_access_bit_mask} ${0xC000000000000000}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060026# TODO: will enable this in next commit
27#${pnor_corruption_rc} SECUREBOOT::RC_ROM_VERIFY
28${pnor_corruption_rc} 0x1E07
Sweta Potthurid3c03432018-04-19 11:30:27 -050029${bmc_image_dir_path} /usr/local/share/pnor
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060030${bmc_guard_part_path} /var/lib/phosphor-software-manager/pnor/prsv/GUARD
Sweta Potthuri39255032018-03-28 10:12:14 -050031
32*** Test Cases ***
33
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060034# All the test cases requires by default jumpers to be positioned
35# between 1 & 2. If this is not met test cases would fail
36# TODO:https://github.com/openbmc/openbmc-test-automation/issues/1644
37Validate Secure Cold Boot With TPM Policy Disabled
38 [Documentation] Validate secure cold boot with TPM policy disabled.
39 [Tags] Validate_Secure_Cold_Boot_With_TPM_Policy_Disabled
Sweta Potthuri39255032018-03-28 10:12:14 -050040
41 Validate Secure Boot With TPM Policy Enabled Or Disabled ${0}
42
43
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060044Validate Secure Cold Boot With TPM Policy Enabled
45 [Documentation] Validate secure cold boot with TPM policy enabled.
46 [Tags] Validate_Secure_Cold_Boot_With_TPM_Policy_Enabled
Sweta Potthuri39255032018-03-28 10:12:14 -050047
48 Validate Secure Boot With TPM Policy Enabled Or Disabled ${1}
49
50
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060051Secure Boot Violation Using Corrupt SBE Image On Cold Boot
52 [Documentation] Secure boot violation using corrupt SBE image on cold boot.
53 [Tags] Secure_Boot_Violation_Using_Corrupt_SBE_Image_On_Cold_Boot
Sweta Potthurid3c03432018-04-19 11:30:27 -050054
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060055 Violate Secure Boot Using Corrupt Image
56 ... SBE ${pnor_corruption_rc} ${bmc_image_dir_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -050057
58
Sweta Potthuri39255032018-03-28 10:12:14 -050059*** Keywords ***
60
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060061Violate Secure Boot Using Corrupt Image
62 [Documentation] Cause secure boot violation during cold boot
63 ... with corrupted image.
64 [Arguments] ${partition} ${error_rc} ${bmc_image_dir_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -050065
Gunnar Mills7732c7e2018-08-14 11:54:24 -050066 # Description of argument(s):
Sweta Potthurid3c03432018-04-19 11:30:27 -050067 # partition The partition which is to be corrupted
68 # (e.g. "SBE", "HBI", "HBB", "HBRT", "HBBL", "OCC").
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060069 # error_rc The RC that is expected as a
Sweta Potthurid3c03432018-04-19 11:30:27 -050070 # result of the secure boot violation
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060071 # (e.g. "SECUREBOOT::RC_ROM_VERIFY").
Sweta Potthurid3c03432018-04-19 11:30:27 -050072 # bmc_image_dir_path BMC image path.
73
74 Set And Verify TPM Policy ${1}
75
76 # Descipiton:
77 # Cause a secure boot violation by copying an BMC image file to the
78 # target BMC and then starting a power on.
79 # This action should result in:
80 # 1) an error log entry
81 # 2) the system going to "Quiesced" state.
82
83 # Load corrupted image to /usr/local/share/pnor.
84 Open Connection For SCP
85 Log ${bmc_image_dir_path}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060086 Log ${error_rc}
87
Sweta Potthurid3c03432018-04-19 11:30:27 -050088 scp.Put File
89 ... ${EXEC_DIR}/data/pnor_test_data/${partition} ${bmc_image_dir_path}
90
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060091 ${error_log_path}= Catenate ${SB_LOG_DIR_PATH}/partition-corruption
92 Create Directory ${error_log_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -050093
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -060094 Set Global Variable ${error_log_path}
95 Log ${error_log_path}
96
97 # Starting a power on.
98 # TODO: Need to move to REST Power On. Needs more testing.
99 BMC Execute Command /usr/sbin/obmcutil poweron
100 Wait Until Keyword Succeeds 15 min 15 sec Error Logs Should Exist
101
Joy Onyerikwudbfe97d2019-03-11 19:44:56 -0500102 # TODO: This will be enabled little later as more tesing required
103 # Wait Until Keyword Succeeds
104 # ... 5 min 5 sec Collect Error Logs and Verify SRC ${error_rc} ${error_log_path}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600105
106 # Verify the RC 0x1E07 in the SOL logs.
107 Get And Verify Partition Corruption ${sol_log_file_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500108
109 # Remove the file from /usr/local/share/pnor/.
110 BMC Execute Command rm -rf ${bmc_image_dir_path}*
111
112 # Check if system reaches quiesce state.
113 Run Keywords
114 ... Wait Until Keyword Succeeds 3 min 5 sec Is Host Quiesced AND
115 ... Recover Quiesced Host
116
117
118Collect Error Logs and Verify SRC
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600119 [Documentation] Verify error log entry & signature description.
120 [Arguments] ${error_rc} ${log_prefix}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500121
122 # Description of argument(s):
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600123 # error_rc Error log signature description.
124 # log_prefix Log path prefix.
Sweta Potthurid3c03432018-04-19 11:30:27 -0500125
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600126 Error Logs Should Not Exist
Sweta Potthurid3c03432018-04-19 11:30:27 -0500127
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600128 Collect eSEL Log ${log_prefix}
129 ${error_log_file_path}= Catenate ${log_prefix}esel.txt
130 ${rc} ${output}= Run and Return RC and Output
131 ... grep -i ${error_rc} ${error_log_file_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500132 Should Be Equal ${rc} ${0}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600133 Should Not Be Empty ${output}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500134
Sweta Potthuri39255032018-03-28 10:12:14 -0500135Get And Verify Security Access Bit
136 [Documentation] Get and verify security access bit.
137 [Arguments] ${sol_log_file_path}
138
139 # Description of argument(s):
140 # sol_log_file_path The path to the file containing SOL data
141 # which was collected during a REST Power On.
142
143 # Sample output:
144 # 19.68481|SECURE|Security Access Bit> 0xC000000000000000
145
146 ${cmd}= Catenate
147 ... grep "Security Access Bit" ${sol_log_file_path} | awk '{ print $4 }'
148 ${rc} ${security_access_bit_str}= Run and Return RC and Output ${cmd}
149 Should Be Equal ${rc} ${0}
150 ... msg=Return code from ${cmd} not zero.
151
152 # Verify the value of "Security Access Bit".
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600153 # If fails, probable issue is Jumper position.
Sweta Potthuri39255032018-03-28 10:12:14 -0500154
155 ${security_access_bit}= Convert to Integer ${security_access_bit_str}
156 ${result}= Evaluate ${security_access_bit_mask} & ${security_access_bit}
157 Should Be Equal ${result} ${security_access_bit_mask}
158 ... msg=System is not booted in secure mode. values=False
159
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600160Get And Verify Partition Corruption
161 [Documentation] Get and verify partition corruption.
162 [Arguments] ${sol_log_file_path}
163
164 # Description of argument(s):
165 # sol_log_file_path The path to the file containing SOL data
166 # which was collected during a REST Power On.
167
168 # Sample output:
169 # 44.47498|secure|Secureboot Failure plid = 0x90000007, rc = 0x1E07
170
171 ${cmd}= Catenate
172 ... grep -i "Secureboot Failure" ${sol_log_file_path} | awk '{ print $8 }'
173 ${rc} ${corruption_rc_str}= Run and Return RC and Output ${cmd}
174 Should Be Equal ${rc} ${0}
175 ... msg=Return code from ${cmd} not zero.
176
177 # Verify the RC 0x1E07 from sol output".
178 Should Be Equal As Strings ${corruption_rc_str} ${pnor_corruption_rc}
179 ... msg=SB violation due to PNOR partition corruption not reported. values=False
180
Sweta Potthuri39255032018-03-28 10:12:14 -0500181
182Validate Secure Boot With TPM Policy Enabled Or Disabled
183 [Documentation] Validate secure boot with TPM policy enabled or disabled.
184 [Arguments] ${tpm_policy}
185
186 # Description of argument(s):
187 # tpm_policy Enable-0 or Disable-1.
188
189 Set And Verify TPM Policy ${tpm_policy}
190 REST Power On quiet=1
191 Validate Secure Boot ${sol_log_file_path}
192
193
194Validate Secure Boot
195 [Documentation] Validate secure boot.
196 [Arguments] ${sol_log_file_path}
197
198 # Description of argument(s):
199 # sol_log_file_path The path to the file containing SOL data
200 # which was collected during a REST Power On.
201
202 Get And Verify Security Access Bit ${sol_log_file_path}
203 Error Logs Should Not Exist
204 REST Verify No Gard Records
205
206
Sweta Potthurid3c03432018-04-19 11:30:27 -0500207Suite Setup Execution
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600208 [Documentation] Suite Setup Execution.
Sweta Potthurid3c03432018-04-19 11:30:27 -0500209
Sweta Potthurid3c03432018-04-19 11:30:27 -0500210 ${bmc_image_dir_path}= Add Trailing Slash ${bmc_image_dir_path}
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600211
212 ${SB_LOG_DIR_PATH}= Catenate ${EXECDIR}/SB_logs/
213 Set Suite Variable ${SB_LOG_DIR_PATH}
214
215 Create Directory ${SB_LOG_DIR_PATH}
216 Empty Directory ${SB_LOG_DIR_PATH}
Lakshminarayana R. Kammath077fbf92019-02-20 11:15:18 -0600217
Sweta Potthurid3c03432018-04-19 11:30:27 -0500218 Set Global Variable ${bmc_image_dir_path}
219 Log ${bmc_image_dir_path}
220 BMC Execute Command rm -rf ${bmc_image_dir_path}*
221
Lakshminarayana R. Kammath6c918292019-02-22 05:05:22 -0600222 Set Global Variable ${bmc_guard_part_path}
223 Log ${bmc_guard_part_path}
224 BMC Execute Command rm -rf ${bmc_guard_part_path}
Lakshminarayana R. Kammath077fbf92019-02-20 11:15:18 -0600225
Sweta Potthurid3c03432018-04-19 11:30:27 -0500226
Sweta Potthuri39255032018-03-28 10:12:14 -0500227Test Setup Execution
228 [Documentation] Test setup execution.
229
230 ${timestamp}= Get Current Date result_format=%Y%m%d%H%M%S
231 ${sol_log_file_path}= Catenate ${EXECDIR}/Secure_SOL${timestamp}
232 Start SOL Console Logging ${sol_log_file_path}
233 Set Suite Variable ${sol_log_file_path}
234
235 REST Power Off stack_mode=skip quiet=1
236 Delete Error Logs And Verify
Lakshminarayana R. Kammath077fbf92019-02-20 11:15:18 -0600237
Sweta Potthuri39255032018-03-28 10:12:14 -0500238
Sweta Potthuri39255032018-03-28 10:12:14 -0500239Test Teardown Execution
240 [Documentation] Test teardown execution.
241
242 Stop SOL Console Logging
243 Run rm -rf ${sol_log_file_path}
Sweta Potthurid3c03432018-04-19 11:30:27 -0500244
245 # Removing the corrupted file from BMC.
246 BMC Execute Command rm -rf ${bmc_image_dir_path}*