Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation Secure boot related test cases. |
| 3 | |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 4 | # Test Parameters: |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 5 | # 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 Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 8 | |
George Keishing | a8b2549 | 2018-06-07 01:15:37 -0500 | [diff] [blame] | 9 | Resource ../../lib/utils.robot |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 10 | Resource ../../lib/state_manager.robot |
George Keishing | a8b2549 | 2018-06-07 01:15:37 -0500 | [diff] [blame] | 11 | Resource ../../lib/boot_utils.robot |
| 12 | Resource ../../lib/secure_utils.robot |
| 13 | Resource ../../lib/open_power_utils.robot |
| 14 | Resource ../../lib/logging_utils.robot |
| 15 | Resource ../../lib/openbmc_ffdc_methods.robot |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 16 | |
George Keishing | a8b2549 | 2018-06-07 01:15:37 -0500 | [diff] [blame] | 17 | Library ../../lib/gen_misc.py |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 18 | |
| 19 | Suite Setup Suite Setup Execution |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 20 | Test Setup Test Setup Execution |
| 21 | Test Teardown Test Teardown Execution |
| 22 | |
| 23 | *** Variables *** |
| 24 | |
| 25 | ${security_access_bit_mask} ${0xC000000000000000} |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 26 | # TODO: will enable this in next commit |
| 27 | #${pnor_corruption_rc} SECUREBOOT::RC_ROM_VERIFY |
| 28 | ${pnor_corruption_rc} 0x1E07 |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 29 | ${bmc_image_dir_path} /usr/local/share/pnor |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 30 | ${bmc_guard_part_path} /var/lib/phosphor-software-manager/pnor/prsv/GUARD |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 31 | |
| 32 | *** Test Cases *** |
| 33 | |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 34 | # 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 |
| 37 | Validate 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 Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 40 | |
| 41 | Validate Secure Boot With TPM Policy Enabled Or Disabled ${0} |
| 42 | |
| 43 | |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 44 | Validate 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 Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 47 | |
| 48 | Validate Secure Boot With TPM Policy Enabled Or Disabled ${1} |
| 49 | |
| 50 | |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 51 | Secure 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 Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 54 | |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 55 | Violate Secure Boot Using Corrupt Image |
| 56 | ... SBE ${pnor_corruption_rc} ${bmc_image_dir_path} |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 57 | |
| 58 | |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 59 | *** Keywords *** |
| 60 | |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 61 | Violate 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 Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 65 | |
Gunnar Mills | 7732c7e | 2018-08-14 11:54:24 -0500 | [diff] [blame] | 66 | # Description of argument(s): |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 67 | # partition The partition which is to be corrupted |
| 68 | # (e.g. "SBE", "HBI", "HBB", "HBRT", "HBBL", "OCC"). |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 69 | # error_rc The RC that is expected as a |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 70 | # result of the secure boot violation |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 71 | # (e.g. "SECUREBOOT::RC_ROM_VERIFY"). |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 72 | # 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. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 86 | Log ${error_rc} |
| 87 | |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 88 | scp.Put File |
| 89 | ... ${EXEC_DIR}/data/pnor_test_data/${partition} ${bmc_image_dir_path} |
| 90 | |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 91 | ${error_log_path}= Catenate ${SB_LOG_DIR_PATH}/partition-corruption |
| 92 | Create Directory ${error_log_path} |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 93 | |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 94 | 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 Onyerikwu | dbfe97d | 2019-03-11 19:44:56 -0500 | [diff] [blame] | 102 | # 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. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 105 | |
| 106 | # Verify the RC 0x1E07 in the SOL logs. |
| 107 | Get And Verify Partition Corruption ${sol_log_file_path} |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 108 | |
| 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 | |
| 118 | Collect Error Logs and Verify SRC |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 119 | [Documentation] Verify error log entry & signature description. |
| 120 | [Arguments] ${error_rc} ${log_prefix} |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 121 | |
| 122 | # Description of argument(s): |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 123 | # error_rc Error log signature description. |
| 124 | # log_prefix Log path prefix. |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 125 | |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 126 | Error Logs Should Not Exist |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 127 | |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 128 | 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 Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 132 | Should Be Equal ${rc} ${0} |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 133 | Should Not Be Empty ${output} |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 134 | |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 135 | Get 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. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 153 | # If fails, probable issue is Jumper position. |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 154 | |
| 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. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 160 | Get 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 Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 181 | |
| 182 | Validate 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 | |
| 194 | Validate 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 Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 207 | Suite Setup Execution |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 208 | [Documentation] Suite Setup Execution. |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 209 | |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 210 | ${bmc_image_dir_path}= Add Trailing Slash ${bmc_image_dir_path} |
Lakshminarayana R. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 211 | |
| 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. Kammath | 077fbf9 | 2019-02-20 11:15:18 -0600 | [diff] [blame] | 217 | |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 218 | 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. Kammath | 6c91829 | 2019-02-22 05:05:22 -0600 | [diff] [blame] | 222 | 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. Kammath | 077fbf9 | 2019-02-20 11:15:18 -0600 | [diff] [blame] | 225 | |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 226 | |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 227 | Test 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. Kammath | 077fbf9 | 2019-02-20 11:15:18 -0600 | [diff] [blame] | 237 | |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 238 | |
Sweta Potthuri | 3925503 | 2018-03-28 10:12:14 -0500 | [diff] [blame] | 239 | Test Teardown Execution |
| 240 | [Documentation] Test teardown execution. |
| 241 | |
| 242 | Stop SOL Console Logging |
| 243 | Run rm -rf ${sol_log_file_path} |
Sweta Potthuri | d3c0343 | 2018-04-19 11:30:27 -0500 | [diff] [blame] | 244 | |
| 245 | # Removing the corrupted file from BMC. |
| 246 | BMC Execute Command rm -rf ${bmc_image_dir_path}* |