Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: Maxim Levitsky <mlevitsk@redhat.com>, kvm@vger.kernel.org
Cc: "Andrew Jones" <drjones@redhat.com>,
	"Alexandru Elisei" <alexandru.elisei@arm.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Claudio Imbrenda" <imbrenda@linux.ibm.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Nico Boehr" <nrb@linux.ibm.com>,
	"Cathy Avery" <cavery@redhat.com>,
	"Janosch Frank" <frankja@linux.ibm.com>
Subject: Re: [kvm-unit-tests PATCH v3 15/27] svm: move some svm support functions into lib/x86/svm_lib.h
Date: Thu, 1 Dec 2022 14:59:37 +0100	[thread overview]
Message-ID: <3a3d705f-5867-5816-8545-df11b2ac8485@redhat.com> (raw)
In-Reply-To: <20221122161152.293072-16-mlevitsk@redhat.com>



Am 22/11/2022 um 17:11 schrieb Maxim Levitsky:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>  lib/x86/svm_lib.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++
>  x86/svm.c         | 36 +-------------------------------
>  x86/svm.h         | 18 ----------------
>  x86/svm_npt.c     |  1 +
>  x86/svm_tests.c   |  1 +
>  5 files changed, 56 insertions(+), 53 deletions(-)
>  create mode 100644 lib/x86/svm_lib.h
> 
> diff --git a/lib/x86/svm_lib.h b/lib/x86/svm_lib.h
> new file mode 100644
> index 00000000..04910281
> --- /dev/null
> +++ b/lib/x86/svm_lib.h
> @@ -0,0 +1,53 @@
> +#ifndef SRC_LIB_X86_SVM_LIB_H_
> +#define SRC_LIB_X86_SVM_LIB_H_
> +
> +#include <x86/svm.h>
> +#include "processor.h"
> +
> +static inline bool npt_supported(void)
> +{
> +	return this_cpu_has(X86_FEATURE_NPT);
> +}
> +
> +static inline bool vgif_supported(void)
> +{
> +	return this_cpu_has(X86_FEATURE_VGIF);
> +}
> +
> +static inline bool lbrv_supported(void)
> +{
> +	return this_cpu_has(X86_FEATURE_LBRV);
> +}
> +
> +static inline bool tsc_scale_supported(void)
> +{
> +	return this_cpu_has(X86_FEATURE_TSCRATEMSR);
> +}
> +
> +static inline bool pause_filter_supported(void)
> +{
> +	return this_cpu_has(X86_FEATURE_PAUSEFILTER);
> +}
> +
> +static inline bool pause_threshold_supported(void)
> +{
> +	return this_cpu_has(X86_FEATURE_PFTHRESHOLD);
> +}
> +
> +static inline void vmmcall(void)
> +{
> +	asm volatile ("vmmcall" : : : "memory");
> +}
> +
> +static inline void stgi(void)
> +{
> +	asm volatile ("stgi");
> +}
> +
> +static inline void clgi(void)
> +{
> +	asm volatile ("clgi");
> +}
> +
Not an expert at all on this, but sti() and cli() in patch 1 are in
processor.h and stgi (g stansd for global?) and clgi are in a different
header? What about maybe moving them together?

> +
> +#endif /* SRC_LIB_X86_SVM_LIB_H_ */
> diff --git a/x86/svm.c b/x86/svm.c
> index 0b2a1d69..8d90a242 100644
> --- a/x86/svm.c
> +++ b/x86/svm.c
> @@ -14,6 +14,7 @@
>  #include "alloc_page.h"
>  #include "isr.h"
>  #include "apic.h"
> +#include "svm_lib.h"
>  
>  /* for the nested page table*/
>  u64 *pml4e;
> @@ -54,32 +55,6 @@ bool default_supported(void)
>  	return true;
>  }
>  
> -bool vgif_supported(void)
> -{
> -	return this_cpu_has(X86_FEATURE_VGIF);
> -}
> -
> -bool lbrv_supported(void)
> -{
> -	return this_cpu_has(X86_FEATURE_LBRV);
> -}
> -
> -bool tsc_scale_supported(void)
> -{
> -	return this_cpu_has(X86_FEATURE_TSCRATEMSR);
> -}
> -
> -bool pause_filter_supported(void)
> -{
> -	return this_cpu_has(X86_FEATURE_PAUSEFILTER);
> -}
> -
> -bool pause_threshold_supported(void)
> -{
> -	return this_cpu_has(X86_FEATURE_PFTHRESHOLD);
> -}
> -
> -
>  void default_prepare(struct svm_test *test)
>  {
>  	vmcb_ident(vmcb);
> @@ -94,10 +69,6 @@ bool default_finished(struct svm_test *test)
>  	return true; /* one vmexit */
>  }
>  
> -bool npt_supported(void)
> -{
> -	return this_cpu_has(X86_FEATURE_NPT);
> -}
>  
>  int get_test_stage(struct svm_test *test)
>  {
> @@ -128,11 +99,6 @@ static void vmcb_set_seg(struct vmcb_seg *seg, u16 selector,
>  	seg->base = base;
>  }
>  
> -inline void vmmcall(void)
> -{
> -	asm volatile ("vmmcall" : : : "memory");
> -}
> -
>  static test_guest_func guest_main;
>  
>  void test_set_guest(test_guest_func func)
> diff --git a/x86/svm.h b/x86/svm.h
> index 3cd7ce8b..7cb1b898 100644
> --- a/x86/svm.h
> +++ b/x86/svm.h
> @@ -53,21 +53,14 @@ u64 *npt_get_pdpe(u64 address);
>  u64 *npt_get_pml4e(void);
>  bool smp_supported(void);
>  bool default_supported(void);
> -bool vgif_supported(void);
> -bool lbrv_supported(void);
> -bool tsc_scale_supported(void);
> -bool pause_filter_supported(void);
> -bool pause_threshold_supported(void);
>  void default_prepare(struct svm_test *test);
>  void default_prepare_gif_clear(struct svm_test *test);
>  bool default_finished(struct svm_test *test);
> -bool npt_supported(void);
>  int get_test_stage(struct svm_test *test);
>  void set_test_stage(struct svm_test *test, int s);
>  void inc_test_stage(struct svm_test *test);
>  void vmcb_ident(struct vmcb *vmcb);
>  struct regs get_regs(void);
> -void vmmcall(void);
>  int __svm_vmrun(u64 rip);
>  void __svm_bare_vmrun(void);
>  int svm_vmrun(void);
> @@ -75,17 +68,6 @@ void test_set_guest(test_guest_func func);
>  
>  extern struct vmcb *vmcb;
>  
> -static inline void stgi(void)
> -{
> -    asm volatile ("stgi");
> -}
> -
> -static inline void clgi(void)
> -{
> -    asm volatile ("clgi");
> -}
> -
> -
>  
>  #define SAVE_GPR_C                              \
>          "xchg %%rbx, regs+0x8\n\t"              \
> diff --git a/x86/svm_npt.c b/x86/svm_npt.c
> index b791f1ac..8aac0bb6 100644
> --- a/x86/svm_npt.c
> +++ b/x86/svm_npt.c
> @@ -2,6 +2,7 @@
>  #include "vm.h"
>  #include "alloc_page.h"
>  #include "vmalloc.h"
> +#include "svm_lib.h"
>  
>  static void *scratch_page;
>  
> diff --git a/x86/svm_tests.c b/x86/svm_tests.c
> index 202e9271..f86c2fa4 100644
> --- a/x86/svm_tests.c
> +++ b/x86/svm_tests.c
> @@ -12,6 +12,7 @@
>  #include "delay.h"
>  #include "x86/usermode.h"
>  #include "vmalloc.h"
> +#include "svm_lib.h"
>  
>  #define SVM_EXIT_MAX_DR_INTERCEPT 0x3f
>  
> 


  reply	other threads:[~2022-12-01 14:00 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-22 16:11 [kvm-unit-tests PATCH v3 00/27] kvm-unit-tests: set of fixes and new tests Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 01/27] x86: replace irq_{enable|disable}() with sti()/cli() Maxim Levitsky
2022-12-01 13:46   ` Emanuele Giuseppe Esposito
2022-12-06 13:55     ` Maxim Levitsky
2022-12-06 14:15       ` Emanuele Giuseppe Esposito
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 02/27] x86: introduce sti_nop() and sti_nop_cli() Maxim Levitsky
2022-12-01 13:46   ` Emanuele Giuseppe Esposito
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 03/27] x86: add few helper functions for apic local timer Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 04/27] svm: remove nop after stgi/clgi Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 05/27] svm: make svm_intr_intercept_mix_if/gif test a bit more robust Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 06/27] svm: use apic_start_timer/apic_stop_timer instead of open coding it Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 07/27] x86: Add test for #SMI during interrupt window Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 08/27] x86: Add a simple test for SYSENTER instruction Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 09/27] svm: add simple nested shutdown test Maxim Levitsky
2022-12-01 13:46   ` Emanuele Giuseppe Esposito
2022-12-06 13:56     ` Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 10/27] SVM: add two tests for exitintinto on exception Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 11/27] lib: Add random number generator Maxim Levitsky
2022-11-23  9:28   ` Claudio Imbrenda
2022-11-23 12:54     ` Andrew Jones
2022-12-06 13:57       ` Maxim Levitsky
2022-12-06 14:07     ` Maxim Levitsky
2022-12-14 10:33       ` Claudio Imbrenda
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 12/27] x86: add IPI stress test Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 13/27] svm: remove get_npt_pte extern Maxim Levitsky
2022-12-01 13:46   ` Emanuele Giuseppe Esposito
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 14/27] svm: move svm spec definitions to lib/x86/svm.h Maxim Levitsky
2022-12-01 13:54   ` Emanuele Giuseppe Esposito
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 15/27] svm: move some svm support functions into lib/x86/svm_lib.h Maxim Levitsky
2022-12-01 13:59   ` Emanuele Giuseppe Esposito [this message]
2022-12-06 14:10     ` Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 16/27] svm: move setup_svm() to svm_lib.c Maxim Levitsky
2022-12-01 16:14   ` Emanuele Giuseppe Esposito
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 17/27] svm: correctly skip if NPT not supported Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 18/27] svm: move vmcb_ident to svm_lib.c Maxim Levitsky
2022-12-01 16:18   ` Emanuele Giuseppe Esposito
2022-12-06 14:11     ` Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 19/27] svm: rewerite vm entry macros Maxim Levitsky
2022-12-02 10:14   ` Emanuele Giuseppe Esposito
2022-12-06 13:56     ` Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 20/27] svm: move v2 tests run into test_run Maxim Levitsky
2022-12-02  9:53   ` Emanuele Giuseppe Esposito
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 21/27] svm: cleanup the default_prepare Maxim Levitsky
2022-12-02  9:45   ` Emanuele Giuseppe Esposito
2022-12-06 13:56     ` Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 22/27] svm: introduce svm_vcpu Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 23/27] svm: introduce struct svm_test_context Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 24/27] svm: use svm_test_context in v2 tests Maxim Levitsky
2022-12-02 10:27   ` Emanuele Giuseppe Esposito
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 25/27] svm: move nested vcpu to test context Maxim Levitsky
2022-12-02 10:22   ` Emanuele Giuseppe Esposito
2022-12-06 14:29     ` Maxim Levitsky
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 26/27] svm: move test_guest_func " Maxim Levitsky
2022-12-02 10:28   ` Emanuele Giuseppe Esposito
2022-11-22 16:11 ` [kvm-unit-tests PATCH v3 27/27] x86: ipi_stress: add optional SVM support Maxim Levitsky
2023-06-07 23:25 ` [kvm-unit-tests PATCH v3 00/27] kvm-unit-tests: set of fixes and new tests Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3a3d705f-5867-5816-8545-df11b2ac8485@redhat.com \
    --to=eesposit@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=alexandru.elisei@arm.com \
    --cc=cavery@redhat.com \
    --cc=drjones@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=mlevitsk@redhat.com \
    --cc=nrb@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox