* Re: [PATCH v3 1/3] selftests: KVM: Replace get_gdt/idt_base() by get_gdt/idt()
@ 2020-02-05 1:41 linmiaohe
0 siblings, 0 replies; 3+ messages in thread
From: linmiaohe @ 2020-02-05 1:41 UTC (permalink / raw)
To: Eric Auger
Cc: thuth, drjones, wei.huang2, eric.auger.pro, linux-kernel, kvm,
pbonzini, vkuznets
Eric Auger <eric.auger@redhat.com> writes:
> get_gdt_base() and get_idt_base() only return the base address of the descriptor tables. Soon we will need to get the size as well.
> Change the prototype of those functions so that they return the whole desc_ptr struct instead of the address field.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
Looks good for me. Thanks.
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3 0/3] selftests: KVM: AMD Nested SVM test infrastructure
@ 2020-02-04 15:00 Eric Auger
2020-02-04 15:00 ` [PATCH v3 1/3] selftests: KVM: Replace get_gdt/idt_base() by get_gdt/idt() Eric Auger
0 siblings, 1 reply; 3+ messages in thread
From: Eric Auger @ 2020-02-04 15:00 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, linux-kernel, kvm, pbonzini, vkuznets
Cc: thuth, drjones, wei.huang2
Add the basic infrastructure needed to test AMD nested SVM.
Also add a first basic vmcall test.
Best regards
Eric
This series can be found at:
https://github.com/eauger/linux/tree/v5.5-amd-svm-v3
History:
v2 -> v3:
- Took into account Vitaly's comment:
- added "selftests: KVM: Replace get_gdt/idt_base() by
get_gdt/idt()"
- svm.h now is a copy of arch/x86/include/asm/svm.h
- avoid duplicates
v1 -> v2:
- split into 2 patches
- remove the infrastructure to run low-level sub-tests and only
keep vmmcall's one.
- move struct regs into processor.h
- force vmcb_gpa into rax in run_guest()
Eric Auger (3):
selftests: KVM: Replace get_gdt/idt_base() by get_gdt/idt()
selftests: KVM: AMD Nested test infrastructure
selftests: KVM: SVM: Add vmcall test
tools/testing/selftests/kvm/Makefile | 3 +-
.../selftests/kvm/include/x86_64/processor.h | 28 +-
.../selftests/kvm/include/x86_64/svm.h | 297 ++++++++++++++++++
.../selftests/kvm/include/x86_64/svm_util.h | 36 +++
tools/testing/selftests/kvm/lib/x86_64/svm.c | 159 ++++++++++
tools/testing/selftests/kvm/lib/x86_64/vmx.c | 6 +-
.../selftests/kvm/x86_64/svm_vmcall_test.c | 85 +++++
7 files changed, 606 insertions(+), 8 deletions(-)
create mode 100644 tools/testing/selftests/kvm/include/x86_64/svm.h
create mode 100644 tools/testing/selftests/kvm/include/x86_64/svm_util.h
create mode 100644 tools/testing/selftests/kvm/lib/x86_64/svm.c
create mode 100644 tools/testing/selftests/kvm/x86_64/svm_vmcall_test.c
--
2.20.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v3 1/3] selftests: KVM: Replace get_gdt/idt_base() by get_gdt/idt()
2020-02-04 15:00 [PATCH v3 0/3] selftests: KVM: AMD Nested SVM test infrastructure Eric Auger
@ 2020-02-04 15:00 ` Eric Auger
2020-02-04 15:44 ` Vitaly Kuznetsov
0 siblings, 1 reply; 3+ messages in thread
From: Eric Auger @ 2020-02-04 15:00 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, linux-kernel, kvm, pbonzini, vkuznets
Cc: thuth, drjones, wei.huang2
get_gdt_base() and get_idt_base() only return the base address
of the descriptor tables. Soon we will need to get the size as well.
Change the prototype of those functions so that they return
the whole desc_ptr struct instead of the address field.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
tools/testing/selftests/kvm/include/x86_64/processor.h | 8 ++++----
tools/testing/selftests/kvm/lib/x86_64/vmx.c | 6 +++---
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h
index aa6451b3f740..6f7fffaea2e8 100644
--- a/tools/testing/selftests/kvm/include/x86_64/processor.h
+++ b/tools/testing/selftests/kvm/include/x86_64/processor.h
@@ -220,20 +220,20 @@ static inline void set_cr4(uint64_t val)
__asm__ __volatile__("mov %0, %%cr4" : : "r" (val) : "memory");
}
-static inline uint64_t get_gdt_base(void)
+static inline struct desc_ptr get_gdt(void)
{
struct desc_ptr gdt;
__asm__ __volatile__("sgdt %[gdt]"
: /* output */ [gdt]"=m"(gdt));
- return gdt.address;
+ return gdt;
}
-static inline uint64_t get_idt_base(void)
+static inline struct desc_ptr get_idt(void)
{
struct desc_ptr idt;
__asm__ __volatile__("sidt %[idt]"
: /* output */ [idt]"=m"(idt));
- return idt.address;
+ return idt;
}
#define SET_XMM(__var, __xmm) \
diff --git a/tools/testing/selftests/kvm/lib/x86_64/vmx.c b/tools/testing/selftests/kvm/lib/x86_64/vmx.c
index 85064baf5e97..7aaa99ca4dbc 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/vmx.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/vmx.c
@@ -288,9 +288,9 @@ static inline void init_vmcs_host_state(void)
vmwrite(HOST_FS_BASE, rdmsr(MSR_FS_BASE));
vmwrite(HOST_GS_BASE, rdmsr(MSR_GS_BASE));
vmwrite(HOST_TR_BASE,
- get_desc64_base((struct desc64 *)(get_gdt_base() + get_tr())));
- vmwrite(HOST_GDTR_BASE, get_gdt_base());
- vmwrite(HOST_IDTR_BASE, get_idt_base());
+ get_desc64_base((struct desc64 *)(get_gdt().address + get_tr())));
+ vmwrite(HOST_GDTR_BASE, get_gdt().address);
+ vmwrite(HOST_IDTR_BASE, get_idt().address);
vmwrite(HOST_IA32_SYSENTER_ESP, rdmsr(MSR_IA32_SYSENTER_ESP));
vmwrite(HOST_IA32_SYSENTER_EIP, rdmsr(MSR_IA32_SYSENTER_EIP));
}
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3 1/3] selftests: KVM: Replace get_gdt/idt_base() by get_gdt/idt()
2020-02-04 15:00 ` [PATCH v3 1/3] selftests: KVM: Replace get_gdt/idt_base() by get_gdt/idt() Eric Auger
@ 2020-02-04 15:44 ` Vitaly Kuznetsov
0 siblings, 0 replies; 3+ messages in thread
From: Vitaly Kuznetsov @ 2020-02-04 15:44 UTC (permalink / raw)
To: Eric Auger
Cc: thuth, drjones, wei.huang2, eric.auger.pro, eric.auger,
linux-kernel, kvm, pbonzini
Eric Auger <eric.auger@redhat.com> writes:
> get_gdt_base() and get_idt_base() only return the base address
> of the descriptor tables. Soon we will need to get the size as well.
> Change the prototype of those functions so that they return
> the whole desc_ptr struct instead of the address field.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> tools/testing/selftests/kvm/include/x86_64/processor.h | 8 ++++----
> tools/testing/selftests/kvm/lib/x86_64/vmx.c | 6 +++---
> 2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h
> index aa6451b3f740..6f7fffaea2e8 100644
> --- a/tools/testing/selftests/kvm/include/x86_64/processor.h
> +++ b/tools/testing/selftests/kvm/include/x86_64/processor.h
> @@ -220,20 +220,20 @@ static inline void set_cr4(uint64_t val)
> __asm__ __volatile__("mov %0, %%cr4" : : "r" (val) : "memory");
> }
>
> -static inline uint64_t get_gdt_base(void)
> +static inline struct desc_ptr get_gdt(void)
> {
> struct desc_ptr gdt;
> __asm__ __volatile__("sgdt %[gdt]"
> : /* output */ [gdt]"=m"(gdt));
> - return gdt.address;
> + return gdt;
> }
>
> -static inline uint64_t get_idt_base(void)
> +static inline struct desc_ptr get_idt(void)
> {
> struct desc_ptr idt;
> __asm__ __volatile__("sidt %[idt]"
> : /* output */ [idt]"=m"(idt));
> - return idt.address;
> + return idt;
> }
>
> #define SET_XMM(__var, __xmm) \
> diff --git a/tools/testing/selftests/kvm/lib/x86_64/vmx.c b/tools/testing/selftests/kvm/lib/x86_64/vmx.c
> index 85064baf5e97..7aaa99ca4dbc 100644
> --- a/tools/testing/selftests/kvm/lib/x86_64/vmx.c
> +++ b/tools/testing/selftests/kvm/lib/x86_64/vmx.c
> @@ -288,9 +288,9 @@ static inline void init_vmcs_host_state(void)
> vmwrite(HOST_FS_BASE, rdmsr(MSR_FS_BASE));
> vmwrite(HOST_GS_BASE, rdmsr(MSR_GS_BASE));
> vmwrite(HOST_TR_BASE,
> - get_desc64_base((struct desc64 *)(get_gdt_base() + get_tr())));
> - vmwrite(HOST_GDTR_BASE, get_gdt_base());
> - vmwrite(HOST_IDTR_BASE, get_idt_base());
> + get_desc64_base((struct desc64 *)(get_gdt().address + get_tr())));
> + vmwrite(HOST_GDTR_BASE, get_gdt().address);
> + vmwrite(HOST_IDTR_BASE, get_idt().address);
> vmwrite(HOST_IA32_SYSENTER_ESP, rdmsr(MSR_IA32_SYSENTER_ESP));
> vmwrite(HOST_IA32_SYSENTER_EIP, rdmsr(MSR_IA32_SYSENTER_EIP));
> }
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
--
Vitaly
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-05 1:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-05 1:41 [PATCH v3 1/3] selftests: KVM: Replace get_gdt/idt_base() by get_gdt/idt() linmiaohe
-- strict thread matches above, loose matches on Subject: below --
2020-02-04 15:00 [PATCH v3 0/3] selftests: KVM: AMD Nested SVM test infrastructure Eric Auger
2020-02-04 15:00 ` [PATCH v3 1/3] selftests: KVM: Replace get_gdt/idt_base() by get_gdt/idt() Eric Auger
2020-02-04 15:44 ` Vitaly Kuznetsov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).