Skip to content

Commit

Permalink
shellcheck Changes: Added few changes to remove issues from shellcheck
Browse files Browse the repository at this point in the history
Signed-off-by: Harika <[email protected]>
  • Loading branch information
LakshmiSaiHarika committed Aug 2, 2024
1 parent 5f99f1e commit 4ba7408
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions tools/snp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ verify_snp_host() {

verify_if_host_is_snp_capable() {
# Get the host cpuid eax
local host_cpuid_eax=$(cpuid -1 -r -l 0x8000001f | grep -oE "eax=[[:alnum:]]+ " | cut -c5- | tr -d '[:space:]')
local host_cpuid_eax
host_cpuid_eax=$(cpuid -1 -r -l 0x8000001f | grep -oE "eax=[[:alnum:]]+ " | cut -c5- | tr -d '[:space:]')

# Bit 0 indicates support for SME status
local sme_bit=1
Expand Down Expand Up @@ -212,7 +213,7 @@ verify_if_host_is_snp_capable() {
for key in "${!all_actual_results[@]}";
do
# echo "$key, value: ${languages[$key]} ${entries[$key]}";
if [[ ${all_actual_results[$key]} != ${results_to_match[$key]} ]]; then
if [[ ${all_actual_results[$key]} != "${results_to_match[$key]}" ]]; then
echo "$key support is not found on the host, processor swap supporting $key feature is required";
echo "$key current bit value is: ${all_actual_results[$key]}"
hardware_support=0
Expand Down Expand Up @@ -924,14 +925,15 @@ verify_guest_snp_bit_status_from_msr() {
ssh_guest_command "sudo modprobe msr"

# Get the guest (MSR_AMD64_SEV) value
local guest_msr_read=$(ssh_guest_command "sudo rdmsr -p 0 0xc0010131")
local guest_msr_read
guest_msr_read=$(ssh_guest_command "sudo rdmsr -p 0 0xc0010131")
guest_msr_read=$(echo "$guest_msr_read" | tr -d '\r' | bc)

# Bit 0 indicates support for Guest SEV feature
local sev_bit=1
sev_status=$((guest_msr_read & sev_bit))



# Bit 1 indicates support for Guest SEV-ES feature
local sev_es_bit=2
sev_es_status=$((guest_msr_read & sev_es_bit))
Expand All @@ -958,7 +960,7 @@ verify_guest_snp_bit_status_from_msr() {
local all_active_guest_sev_features=1
for key in "${!all_actual_results[@]}";
do
if [[ ${all_actual_results[$key]} != ${results_to_match[$key]} ]]; then
if [[ ${all_actual_results[$key]} != "${results_to_match[$key]}" ]]; then
echo "$key feature is not active on the guest";
all_active_guest_sev_features=0
fi
Expand Down

0 comments on commit 4ba7408

Please sign in to comment.