diff mbox series

[v6,4/9] KVM: selftests: Add VMGEXIT helper

Message ID 20250203223205.36121-5-prsampat@amd.com (mailing list archive)
State New, archived
Headers show
Series Basic SEV-SNP Selftests | expand

Commit Message

Pratik R. Sampat Feb. 3, 2025, 10:32 p.m. UTC
Abstract rep vmmcall coded into the VMGEXIT helper for the sev
library.

No functional change intended.

Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
Tested-by: Srikanth Aithal <sraithal@amd.com>
Signed-off-by: Pratik R. Sampat <prsampat@amd.com>
---
v5..v6:

* Collected tags from Pankaj and Srikanth.
---
 tools/testing/selftests/kvm/include/x86/sev.h    | 2 ++
 tools/testing/selftests/kvm/x86/sev_smoke_test.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Sean Christopherson Feb. 12, 2025, 1:59 a.m. UTC | #1
On Mon, Feb 03, 2025, Pratik R. Sampat wrote:
> Abstract rep vmmcall coded into the VMGEXIT helper for the sev
> library.
> 
> No functional change intended.
> 
> Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
> Tested-by: Srikanth Aithal <sraithal@amd.com>
> Signed-off-by: Pratik R. Sampat <prsampat@amd.com>
> ---
> v5..v6:
> 
> * Collected tags from Pankaj and Srikanth.
> ---
>  tools/testing/selftests/kvm/include/x86/sev.h    | 2 ++
>  tools/testing/selftests/kvm/x86/sev_smoke_test.c | 2 +-
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/kvm/include/x86/sev.h b/tools/testing/selftests/kvm/include/x86/sev.h
> index 82c11c81a956..e7df5d0987f6 100644
> --- a/tools/testing/selftests/kvm/include/x86/sev.h
> +++ b/tools/testing/selftests/kvm/include/x86/sev.h
> @@ -27,6 +27,8 @@ enum sev_guest_state {
>  
>  #define GHCB_MSR_TERM_REQ	0x100
>  
> +#define VMGEXIT()		{ __asm__ __volatile__("rep; vmmcall"); }

Please make this a proper inline function, there's no reason to use a macro.
Pratik R. Sampat Feb. 14, 2025, 6:09 p.m. UTC | #2
On 2/11/25 7:59 PM, Sean Christopherson wrote:
> On Mon, Feb 03, 2025, Pratik R. Sampat wrote:
>> Abstract rep vmmcall coded into the VMGEXIT helper for the sev
>> library.
>>
>> No functional change intended.
>>
>> Reviewed-by: Pankaj Gupta <pankaj.gupta@amd.com>
>> Tested-by: Srikanth Aithal <sraithal@amd.com>
>> Signed-off-by: Pratik R. Sampat <prsampat@amd.com>
>> ---
>> v5..v6:
>>
>> * Collected tags from Pankaj and Srikanth.
>> ---
>>  tools/testing/selftests/kvm/include/x86/sev.h    | 2 ++
>>  tools/testing/selftests/kvm/x86/sev_smoke_test.c | 2 +-
>>  2 files changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/kvm/include/x86/sev.h b/tools/testing/selftests/kvm/include/x86/sev.h
>> index 82c11c81a956..e7df5d0987f6 100644
>> --- a/tools/testing/selftests/kvm/include/x86/sev.h
>> +++ b/tools/testing/selftests/kvm/include/x86/sev.h
>> @@ -27,6 +27,8 @@ enum sev_guest_state {
>>  
>>  #define GHCB_MSR_TERM_REQ	0x100
>>  
>> +#define VMGEXIT()		{ __asm__ __volatile__("rep; vmmcall"); }
> 
> Please make this a proper inline function, there's no reason to use a macro.

Sure, I can make this an inline function.
diff mbox series

Patch

diff --git a/tools/testing/selftests/kvm/include/x86/sev.h b/tools/testing/selftests/kvm/include/x86/sev.h
index 82c11c81a956..e7df5d0987f6 100644
--- a/tools/testing/selftests/kvm/include/x86/sev.h
+++ b/tools/testing/selftests/kvm/include/x86/sev.h
@@ -27,6 +27,8 @@  enum sev_guest_state {
 
 #define GHCB_MSR_TERM_REQ	0x100
 
+#define VMGEXIT()		{ __asm__ __volatile__("rep; vmmcall"); }
+
 void sev_vm_launch(struct kvm_vm *vm, uint32_t policy);
 void sev_vm_launch_measure(struct kvm_vm *vm, uint8_t *measurement);
 void sev_vm_launch_finish(struct kvm_vm *vm);
diff --git a/tools/testing/selftests/kvm/x86/sev_smoke_test.c b/tools/testing/selftests/kvm/x86/sev_smoke_test.c
index a1a688e75266..38f647fe55d2 100644
--- a/tools/testing/selftests/kvm/x86/sev_smoke_test.c
+++ b/tools/testing/selftests/kvm/x86/sev_smoke_test.c
@@ -27,7 +27,7 @@  static void guest_sev_es_code(void)
 	 * force "termination" to signal "done" via the GHCB MSR protocol.
 	 */
 	wrmsr(MSR_AMD64_SEV_ES_GHCB, GHCB_MSR_TERM_REQ);
-	__asm__ __volatile__("rep; vmmcall");
+	VMGEXIT();
 }
 
 static void guest_sev_code(void)