[PATCH v3 0/9] SEV Kernel Selftests

2024-09-05 Thread Pratik R. Sampat
rface to manually flag protected/encrypted ranges KVM: selftests: Add a CoCo-specific test for KVM_PRE_FAULT_MEMORY Pratik R. Sampat (7): KVM: selftests: Decouple SEV ioctls from asserts KVM: selftests: Add a basic SNP smoke test KVM: selftests: Add SNP to shutdown testing KVM: self

[PATCH v3 1/9] KVM: selftests: Decouple SEV ioctls from asserts

2024-09-05 Thread Pratik R. Sampat
Add variants of sev, sev-es launch path that return the status of the ioctl call instead of asserting for success. This enables both positive and negative testing of the path. No functional impact intended. Signed-off-by: Pratik R. Sampat Tested-by: Peter Gonda Tested-by: Srikanth Aithal

[PATCH v3 2/9] KVM: selftests: Add a basic SNP smoke test

2024-09-05 Thread Pratik R. Sampat
of the type KVM_EXIT_SYSTEM_EVENT. Also, decouple policy and type and require functions to provide both such that there is no assumption regarding the type using policy. Signed-off-by: Pratik R. Sampat Tested-by: Peter Gonda Tested-by: Srikanth Aithal --- .../selftests/kvm/include/x86_64

[PATCH v3 3/9] KVM: selftests: Add SNP to shutdown testing

2024-09-05 Thread Pratik R. Sampat
Parameterize the shutdown test to include the SEV-SNP VM type Signed-off-by: Pratik R. Sampat Tested-by: Peter Gonda Tested-by: Srikanth Aithal --- tools/testing/selftests/kvm/x86_64/sev_smoke_test.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/testing

[PATCH v3 4/9] KVM: selftests: SEV IOCTL test

2024-09-05 Thread Pratik R. Sampat
Introduce tests for sev and sev-es ioctl that exercises the boot path of launch, update and finish on an invalid policy. Signed-off-by: Pratik R. Sampat Tested-by: Peter Gonda Tested-by: Srikanth Aithal --- .../selftests/kvm/x86_64/sev_smoke_test.c | 84 +++ 1 file changed

[PATCH v3 5/9] KVM: selftests: SNP IOCTL test

2024-09-05 Thread Pratik R. Sampat
Introduce testing of SNP ioctl calls. Tests attributes such as flags, page types, and policies in various combinations along the SNP launch path. Signed-off-by: Pratik R. Sampat Tested-by: Peter Gonda Tested-by: Srikanth Aithal --- .../testing/selftests/kvm/include/kvm_util.h | 11

[PATCH v3 6/9] KVM: selftests: SEV-SNP test for KVM_SEV_INIT2

2024-09-05 Thread Pratik R. Sampat
Add SEV-SNP VM type to exercise the KVM_SEV_INIT2 call. Also ensure that SNP case is skipped for scenarios where CPUID supports it but KVM does not so that a failure is not reported for such cases. Signed-off-by: Pratik R. Sampat Tested-by: Peter Gonda Tested-by: Srikanth Aithal

[PATCH v3 7/9] KVM: selftests: Add interface to manually flag protected/encrypted ranges

2024-09-05 Thread Pratik R. Sampat
l Roth Signed-off-by: Pratik R. Sampat Tested-by: Peter Gonda Tested-by: Srikanth Aithal --- .../testing/selftests/kvm/include/kvm_util.h | 2 + tools/testing/selftests/kvm/lib/kvm_util.c| 45 +-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/tools/t

[PATCH v3 8/9] KVM: selftests: Add a CoCo-specific test for KVM_PRE_FAULT_MEMORY

2024-09-05 Thread Pratik R. Sampat
SEV, SEV-ES, and SNP. Since there's a reasonable chance that TDX could extend this for similar testing of TDX, give it a "coco-" prefix rather than an SEV-specific one. Signed-off-by: Michael Roth Co-developed-by: Pratik R. Sampat Signed-off-by: Pratik R. Sampat Tested-by: Peter G

[PATCH v3 9/9] KVM: selftests: Interleave fallocate for KVM_PRE_FAULT_MEMORY

2024-09-05 Thread Pratik R. Sampat
statuses. Signed-off-by: Pratik R. Sampat Tested-by: Peter Gonda Tested-by: Srikanth Aithal --- .../kvm/x86_64/coco_pre_fault_memory_test.c | 121 +- 1 file changed, 114 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/coco_pre_fault_memory_test.c b

Re: [PATCH v3 1/9] KVM: selftests: Decouple SEV ioctls from asserts

2024-10-21 Thread Pratik R. Sampat
Hi Sean, On 10/14/2024 5:18 PM, Sean Christopherson wrote: > On Thu, Sep 05, 2024, Pratik R. Sampat wrote: >> +static inline int __sev_launch_update_data(struct kvm_vm *vm, vm_paddr_t >> gpa, >> + uint64_t hva, uint64_t size)

Re: [PATCH v3 2/9] KVM: selftests: Add a basic SNP smoke test

2024-10-21 Thread Pratik R. Sampat
Hi Sean, Thank you for your comments. ... >> .../selftests/kvm/include/x86_64/processor.h | 1 + >> .../selftests/kvm/include/x86_64/sev.h| 54 +++- >> tools/testing/selftests/kvm/lib/kvm_util.c| 8 +- >> .../selftests/kvm/lib/x86_64/processor.c | 6 +- >> tools/test

Re: [PATCH v3 0/9] SEV Kernel Selftests

2024-10-21 Thread Pratik R. Sampat
Hi Sean, On 10/14/2024 5:23 PM, Sean Christopherson wrote: > On Thu, Sep 05, 2024, Pratik R. Sampat wrote: >> This series primarily introduces SEV-SNP test for the kernel selftest >> framework. It tests boot, ioctl, pre fault, and fallocate in various >> combinations to exerc

Re: [PATCH v3 7/9] KVM: selftests: Add interface to manually flag protected/encrypted ranges

2024-10-21 Thread Pratik R. Sampat
Hi Sean, On 10/14/2024 5:58 PM, Sean Christopherson wrote: > On Thu, Sep 05, 2024, Pratik R. Sampat wrote: >> From: Michael Roth >> >> For SEV and SNP, currently __vm_phy_pages_alloc() handles setting the >> region->protected_phy_pages bitmap to mark that the r

Re: [PATCH v3 2/9] KVM: selftests: Add a basic SNP smoke test

2024-10-28 Thread Pratik R. Sampat
Hi Sean, On 10/28/2024 12:55 PM, Sean Christopherson wrote: > On Mon, Oct 21, 2024, Pratik R. Sampat wrote: >>>> + test_sev(guest_sev_es_code, KVM_X86_SEV_ES_VM, SEV_POLICY_ES); >>>> >>>>test_sev_es_shutdown(); >>>

Re: [PATCH v3 2/9] KVM: selftests: Add a basic SNP smoke test

2024-11-04 Thread Pratik R. Sampat
On 11/4/2024 5:47 PM, Sean Christopherson wrote: > On Mon, Nov 04, 2024, Pratik R. Sampat wrote: >> >> >> On 10/31/2024 11:27 AM, Sean Christopherson wrote: >>> On Thu, Oct 31, 2024, Pratik R. Sampat wrote: >>>> Hi Sean, >>>> >>>&g

Re: [PATCH v3 2/9] KVM: selftests: Add a basic SNP smoke test

2024-11-04 Thread Pratik R. Sampat
On 10/31/2024 11:27 AM, Sean Christopherson wrote: > On Thu, Oct 31, 2024, Pratik R. Sampat wrote: >> Hi Sean, >> >> On 10/30/2024 12:57 PM, Sean Christopherson wrote: >>> On Wed, Oct 30, 2024, Pratik R. Sampat wrote: >>>> On 10/30/2024 8:46 AM, Se

Re: [PATCH v3 2/9] KVM: selftests: Add a basic SNP smoke test

2024-10-30 Thread Pratik R. Sampat
Hi Sean, On 10/30/2024 8:46 AM, Sean Christopherson wrote: > On Mon, Oct 28, 2024, Pratik R. Sampat wro4te: >> On 10/28/2024 12:55 PM, Sean Christopherson wrote: >>> On Mon, Oct 21, 2024, Pratik R. Sampat wrote: >>>>>> +

Re: [PATCH v3 2/9] KVM: selftests: Add a basic SNP smoke test

2024-10-31 Thread Pratik R. Sampat
Hi Sean, On 10/30/2024 12:57 PM, Sean Christopherson wrote: > On Wed, Oct 30, 2024, Pratik R. Sampat wrote: >> On 10/30/2024 8:46 AM, Sean Christopherson wrote: >>> +/* Minimum firmware version required for the SEV-SNP support */ >>> +#define SNP_FW_REQ

[PATCH v4 4/8] KVM: selftests: Introduce SEV VM type check

2024-11-14 Thread Pratik R. Sampat
In preparation for SNP, declutter the vm type check by introducing a SEV-SNP VM type check as well a transitive set of helper functions. The SNP VM type is the subset of SEV-ES. Similarly, the SEV-ES and SNP types are subset of the SEV VM type check. Signed-off-by: Pratik R. Sampat

[PATCH v4 3/8] KVM: selftests: Add VMGEXIT helper

2024-11-14 Thread Pratik R. Sampat
Abstract rep vmmcall coded into the VMGEXIT helper for the sev library. No functional change intended. Signed-off-by: Pratik R. Sampat --- tools/testing/selftests/kvm/include/x86_64/sev.h| 2 ++ tools/testing/selftests/kvm/x86_64/sev_smoke_test.c | 2 +- 2 files changed, 3 insertions(+), 1

[PATCH v4 7/8] KVM: selftests: Abstractions for SEV to decouple policy from type

2024-11-14 Thread Pratik R. Sampat
In preparation for SNP, cleanup the smoke test to decouple deriving type from policy. Introduce, wrappers for SEV and SEV-ES types to abstract the parametrized launch tests calls and reduce verbosity. No functional change intended. Signed-off-by: Pratik R. Sampat --- .../selftests/kvm/x86_64

[PATCH v4 6/8] KVM: selftests: Force GUEST_MEMFD flag for SNP VM type

2024-11-14 Thread Pratik R. Sampat
Force the SEV-SNP VM type to set the KVM_MEM_GUEST_MEMFD flag for the creation of private memslots. Signed-off-by: Pratik R. Sampat --- tools/testing/selftests/kvm/lib/kvm_util.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/lib

[PATCH v4 8/8] KVM: selftests: Add a basic SEV-SNP smoke test

2024-11-14 Thread Pratik R. Sampat
of the type KVM_EXIT_SYSTEM_EVENT. Signed-off-by: Pratik R. Sampat --- .../selftests/kvm/x86_64/sev_smoke_test.c | 42 +++ 1 file changed, 42 insertions(+) diff --git a/tools/testing/selftests/kvm/x86_64/sev_smoke_test.c b/tools/testing/selftests/kvm/x86_64/sev_smoke_test.c

[PATCH v4 1/8] KVM: SEV: Disable SEV-SNP on FW validation failure

2024-11-14 Thread Pratik R. Sampat
: Add initial SEV-SNP support") Signed-off-by: Pratik R. Sampat --- arch/x86/kvm/svm/sev.c | 4 +++- drivers/crypto/ccp/sev-dev.c | 6 ++ include/linux/psp-sev.h | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/s

[PATCH v4 5/8] KVM: selftests: Add library support for interacting with SNP

2024-11-14 Thread Pratik R. Sampat
Extend the SEV library to include support for SNP ioctl() wrappers, which aid in launching and interacting with a SEV-SNP guest. Signed-off-by: Pratik R. Sampat --- .../selftests/kvm/include/x86_64/sev.h| 49 ++- tools/testing/selftests/kvm/lib/x86_64/sev.c | 81

[PATCH v4 0/8] Basic SEV-SNP Selftests

2024-11-14 Thread Pratik R. Sampat
/20240905124107.6954-1-pratikrajesh.sam...@amd.com/ 1. Remove the assignments for the prefault and fallocate test type enums. 2. Fix error message for sev launch measure and finish. 3. Collect tested-by tags [Peter, Srikanth] Any feedback/review is highly appreciated! Pratik R. Sampat (8): KVM: SEV: Disable

[PATCH v4 2/8] KVM: selftests: SEV-SNP test for KVM_SEV_INIT2

2024-11-14 Thread Pratik R. Sampat
Add the X86_FEATURE_SNP CPU feature to the architectural definition for the SEV-SNP VM type to exercise the KVM_SEV_INIT2 call. Ensure that the SNP test is skipped in scenarios where CPUID supports it but KVM does not, so that a failure is not reported in such cases. Signed-off-by: Pratik R

[PATCH v8 07/10] KVM: selftests: Add library support for interacting with SNP

2025-03-05 Thread Pratik R. Sampat
Extend the SEV library to include support for SNP ioctl() wrappers, which aid in launching and interacting with a SEV-SNP guest. Signed-off-by: Pratik R. Sampat --- arch/x86/include/uapi/asm/kvm.h | 1 + tools/arch/x86/include/uapi/asm/kvm.h | 1 + tools/testing

[PATCH v8 03/10] KVM: selftests: Add vmgexit helper

2025-03-05 Thread Pratik R. Sampat
Abstract rep vmmcall coded into the vmgexit helper for the sev library. No functional change intended. Signed-off-by: Pratik R. Sampat --- tools/testing/selftests/kvm/include/x86/sev.h| 5 + tools/testing/selftests/kvm/x86/sev_smoke_test.c | 2 +- 2 files changed, 6 insertions(+), 1

[PATCH v8 06/10] KVM: selftests: Introduce SEV VM type check

2025-03-05 Thread Pratik R. Sampat
In preparation for SNP, declutter the vm type check by introducing a SEV-SNP VM type check as well as a transitive set of helper functions. The SNP VM type is the subset of SEV-ES. Similarly, the SEV-ES and SNP types are subset of the SEV VM type check. Signed-off-by: Pratik R. Sampat

[PATCH v8 08/10] KVM: selftests: Force GUEST_MEMFD flag for SNP VM type

2025-03-05 Thread Pratik R. Sampat
Force the SEV-SNP VM type to set the KVM_MEM_GUEST_MEMFD flag for the creation of private memslots. Signed-off-by: Pratik R. Sampat --- tools/testing/selftests/kvm/lib/kvm_util.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/lib

[PATCH v8 05/10] KVM: selftests: Replace assert() with TEST_ASSERT_EQ()

2025-03-05 Thread Pratik R. Sampat
For SEV tests, assert() failures on VM type or fd do not provide sufficient error reporting. Replace assert() with TEST_ASSERT_EQ() to obtain more detailed information on the assertion condition failure, including the call stack. Signed-off-by: Pratik R. Sampat --- tools/testing/selftests/kvm

[PATCH v8 00/10] Basic SEV-SNP Selftests

2025-03-05 Thread Pratik R. Sampat
or sev launch measure and finish. * Collect tested-by tags [Peter, Srikanth] Pratik R. Sampat (10): KVM: SEV: Disable SEV-SNP support on initialization failure KVM: selftests: SEV-SNP test for KVM_SEV_INIT2 KVM: selftests: Add vmgexit helper KVM: selftests: Add SMT control state helper

[PATCH v8 02/10] KVM: selftests: SEV-SNP test for KVM_SEV_INIT2

2025-03-05 Thread Pratik R. Sampat
Dadhania Signed-off-by: Pratik R. Sampat --- tools/testing/selftests/kvm/include/x86/processor.h | 1 + tools/testing/selftests/kvm/x86/sev_init2_tests.c | 13 + 2 files changed, 14 insertions(+) diff --git a/tools/testing/selftests/kvm/include/x86/processor.h b/tools/testing

[PATCH v8 01/10] KVM: SEV: Disable SEV-SNP support on initialization failure

2025-03-05 Thread Pratik R. Sampat
additional condition to determine support for SEV-SNP. Fixes: 1dfe571c12cf ("KVM: SEV: Add initial SEV-SNP support") Suggested-by: Sean Christopherson Signed-off-by: Pratik R. Sampat --- v7..v8: * Avoid exporting yet another API from CCP. Instead query SNP_PLATFORM_STATUS to get the c

[PATCH v8 09/10] KVM: selftests: Abstractions for SEV to decouple policy from type

2025-03-05 Thread Pratik R. Sampat
In preparation for SNP, cleanup the smoke test to decouple deriving type from policy. This enables us to reuse existing interfaces as well as deduplicate the test calls that are called for SEV and SEV-ES. No functional change intended. Signed-off-by: Pratik R. Sampat --- .../selftests/kvm/x86

[PATCH v8 04/10] KVM: selftests: Add SMT control state helper

2025-03-05 Thread Pratik R. Sampat
: Pratik R. Sampat --- .../testing/selftests/kvm/include/kvm_util.h | 35 +++ .../testing/selftests/kvm/x86/hyperv_cpuid.c | 19 -- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm

[PATCH v8 10/10] KVM: selftests: Add a basic SEV-SNP smoke test

2025-03-05 Thread Pratik R. Sampat
of the type KVM_EXIT_SYSTEM_EVENT. Signed-off-by: Pratik R. Sampat --- .../selftests/kvm/x86/sev_smoke_test.c| 25 +-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/x86/sev_smoke_test.c b/tools/testing/selftests/kvm/x86