Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] The test silently returns 0 (PASS) if no SEV VM types are offered by 
KVM, masking the lack of test coverage.
--

--- Patch [1]: [RFC PATCH 01/11] KVM: selftests: sev_smoke_test: Only run VM 
types the host offers ---
commit c4fa8ea2868d0892d394adecf158fe07893c3980
Author: David Woodhouse <[email protected]>

KVM: selftests: sev_smoke_test: Only run VM types the host offers

sev_smoke_test is updated to gate the plain SEV subtest on KVM_CAP_VM_TYPES,
preventing the test from aborting when all SEV ASIDs are assigned to SEV-SNP.
This ensures the test runs only the VM types the host actually offers.

> diff --git a/tools/testing/selftests/kvm/x86/sev_smoke_test.c 
> b/tools/testing/selftests/kvm/x86/sev_smoke_test.c
> index 6b2cbe2a90b7c..bf27b6187afac 100644
> --- a/tools/testing/selftests/kvm/x86/sev_smoke_test.c
> +++ b/tools/testing/selftests/kvm/x86/sev_smoke_test.c
> @@ -247,7 +247,14 @@ int main(int argc, char *argv[])
>  {
>       TEST_REQUIRE(kvm_cpu_has(X86_FEATURE_SEV));
>  
> -     test_sev_smoke(guest_sev_code, KVM_X86_SEV_VM, 0);
> +     /*
> +      * Only exercise VM types the host actually offers.  CPUID reporting
> +      * SEV does not guarantee KVM offers the SEV VM type: when all SEV
> +      * ASIDs are assigned to SEV-SNP, KVM_X86_SEV_VM is unavailable even
> +      * though X86_FEATURE_SEV is set.  Gate every type on KVM_CAP_VM_TYPES.
> +      */
> +     if (kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SEV_VM))
> +             test_sev_smoke(guest_sev_code, KVM_X86_SEV_VM, 0);

[Severity: Medium]
Does this code silently return 0 (PASS) if the host offers no SEV VM types?

If none of the KVM_CAP_VM_TYPES conditions evaluate to true, the program will
fall through to return 0. This masks a lack of test coverage by falsely
indicating a successful test run, rather than properly skipping the test.

>  
>       if (kvm_check_cap(KVM_CAP_VM_TYPES) & BIT(KVM_X86_SEV_ES_VM))
>               test_sev_smoke(guest_sev_es_code, KVM_X86_SEV_ES_VM, 
> SEV_POLICY_ES);

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/f09647f427565c1789a6979470045aab78661563.1784194290.git.d...@amazon.co.uk?part=1

Reply via email to