qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] target/i386: Raise the highest index value used for any VMCS encoding
@ 2024-07-24  8:08 Lei Wang
  2024-07-24 15:02 ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Lei Wang @ 2024-07-24  8:08 UTC (permalink / raw)
  To: Paolo Bonzini, Marcelo Tosatti, Xin Li; +Cc: qemu-devel, kvm, Lei Wang

Because the index value of the VMCS field encoding of Secondary VM-exit
controls, 0x44, is larger than any existing index value, raise the highest
index value used for any VMCS encoding to 0x44.

Because the index value of the VMCS field encoding of FRED injected-event
data (one of the newly added VMCS fields for FRED transitions), 0x52, is
larger than any existing index value, raise the highest index value used
for any VMCS encoding to 0x52.

Co-developed-by: Xin Li <xin3.li@intel.com>
Signed-off-by: Xin Li <xin3.li@intel.com>
Signed-off-by: Lei Wang <lei4.wang@intel.com>
---
 target/i386/cpu.h     | 1 +
 target/i386/kvm/kvm.c | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index c6cc035df3..5604cc2994 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1192,6 +1192,7 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cpu, FeatureWord w);
 #define VMX_VM_EXIT_PT_CONCEAL_PIP                  0x01000000
 #define VMX_VM_EXIT_CLEAR_IA32_RTIT_CTL             0x02000000
 #define VMX_VM_EXIT_LOAD_IA32_PKRS                  0x20000000
+#define VMX_VM_EXIT_ACTIVATE_SECONDARY_CONTROLS     0x80000000
 
 #define VMX_VM_ENTRY_LOAD_DEBUG_CONTROLS            0x00000004
 #define VMX_VM_ENTRY_IA32E_MODE                     0x00000200
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index b4aab9a410..7c8cb16675 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -3694,7 +3694,14 @@ static void kvm_msr_entry_add_vmx(X86CPU *cpu, FeatureWordArray f)
     kvm_msr_entry_add(cpu, MSR_IA32_VMX_CR4_FIXED0,
                       CR4_VMXE_MASK);
 
-    if (f[FEAT_VMX_SECONDARY_CTLS] & VMX_SECONDARY_EXEC_TSC_SCALING) {
+    if (f[FEAT_7_1_EAX] & CPUID_7_1_EAX_FRED) {
+        /* FRED injected-event data (0x2052).  */
+        kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x52);
+    } else if (f[FEAT_VMX_EXIT_CTLS] &
+               VMX_VM_EXIT_ACTIVATE_SECONDARY_CONTROLS) {
+        /* Secondary VM-exit controls (0x2044).  */
+        kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x44);
+    } else if (f[FEAT_VMX_SECONDARY_CTLS] & VMX_SECONDARY_EXEC_TSC_SCALING) {
         /* TSC multiplier (0x2032).  */
         kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x32);
     } else {
-- 
2.39.3



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] target/i386: Raise the highest index value used for any VMCS encoding
  2024-07-24  8:08 [PATCH] target/i386: Raise the highest index value used for any VMCS encoding Lei Wang
@ 2024-07-24 15:02 ` Paolo Bonzini
  2024-07-26  1:12   ` Li, Xin3
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2024-07-24 15:02 UTC (permalink / raw)
  To: Lei Wang; +Cc: Marcelo Tosatti, Xin Li, qemu-devel, kvm

On Wed, Jul 24, 2024 at 10:09 AM Lei Wang <lei4.wang@intel.com> wrote:
> Because the index value of the VMCS field encoding of Secondary VM-exit
> controls, 0x44, is larger than any existing index value, raise the highest
> index value used for any VMCS encoding to 0x44.
>
> Because the index value of the VMCS field encoding of FRED injected-event
> data (one of the newly added VMCS fields for FRED transitions), 0x52, is
> larger than any existing index value, raise the highest index value used
> for any VMCS encoding to 0x52.

Hi, can you put together a complete series that includes all that's
needed for nested FRED support?

Thanks,

Paolo

> Co-developed-by: Xin Li <xin3.li@intel.com>
> Signed-off-by: Xin Li <xin3.li@intel.com>
> Signed-off-by: Lei Wang <lei4.wang@intel.com>
> ---
>  target/i386/cpu.h     | 1 +
>  target/i386/kvm/kvm.c | 9 ++++++++-
>  2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index c6cc035df3..5604cc2994 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -1192,6 +1192,7 @@ uint64_t x86_cpu_get_supported_feature_word(X86CPU *cpu, FeatureWord w);
>  #define VMX_VM_EXIT_PT_CONCEAL_PIP                  0x01000000
>  #define VMX_VM_EXIT_CLEAR_IA32_RTIT_CTL             0x02000000
>  #define VMX_VM_EXIT_LOAD_IA32_PKRS                  0x20000000
> +#define VMX_VM_EXIT_ACTIVATE_SECONDARY_CONTROLS     0x80000000
>
>  #define VMX_VM_ENTRY_LOAD_DEBUG_CONTROLS            0x00000004
>  #define VMX_VM_ENTRY_IA32E_MODE                     0x00000200
> diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
> index b4aab9a410..7c8cb16675 100644
> --- a/target/i386/kvm/kvm.c
> +++ b/target/i386/kvm/kvm.c
> @@ -3694,7 +3694,14 @@ static void kvm_msr_entry_add_vmx(X86CPU *cpu, FeatureWordArray f)
>      kvm_msr_entry_add(cpu, MSR_IA32_VMX_CR4_FIXED0,
>                        CR4_VMXE_MASK);
>
> -    if (f[FEAT_VMX_SECONDARY_CTLS] & VMX_SECONDARY_EXEC_TSC_SCALING) {
> +    if (f[FEAT_7_1_EAX] & CPUID_7_1_EAX_FRED) {
> +        /* FRED injected-event data (0x2052).  */
> +        kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x52);
> +    } else if (f[FEAT_VMX_EXIT_CTLS] &
> +               VMX_VM_EXIT_ACTIVATE_SECONDARY_CONTROLS) {
> +        /* Secondary VM-exit controls (0x2044).  */
> +        kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x44);
> +    } else if (f[FEAT_VMX_SECONDARY_CTLS] & VMX_SECONDARY_EXEC_TSC_SCALING) {
>          /* TSC multiplier (0x2032).  */
>          kvm_msr_entry_add(cpu, MSR_IA32_VMX_VMCS_ENUM, 0x32);
>      } else {
> --
> 2.39.3
>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] target/i386: Raise the highest index value used for any VMCS encoding
  2024-07-24 15:02 ` Paolo Bonzini
@ 2024-07-26  1:12   ` Li, Xin3
  2024-07-26 17:17     ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Li, Xin3 @ 2024-07-26  1:12 UTC (permalink / raw)
  To: Paolo Bonzini, Wang, Lei4
  Cc: Marcelo Tosatti, qemu-devel@nongnu.org, kvm@vger.kernel.org

> On Wed, Jul 24, 2024 at 10:09 AM Lei Wang <lei4.wang@intel.com> wrote:
> > Because the index value of the VMCS field encoding of Secondary
> > VM-exit controls, 0x44, is larger than any existing index value, raise
> > the highest index value used for any VMCS encoding to 0x44.
> >
> > Because the index value of the VMCS field encoding of FRED
> > injected-event data (one of the newly added VMCS fields for FRED
> > transitions), 0x52, is larger than any existing index value, raise the
> > highest index value used for any VMCS encoding to 0x52.
> 
> Hi, can you put together a complete series that includes all that's needed for
> nested FRED support?
> 

We can do it.

Just to be clear, this patch is not needed to enable nested FRED, but to
fix the following vmx test in kvm-unit-tests, otherwise we get:
    FAIL: VMX_VMCS_ENUM.MAX_INDEX expected: 29, actual: 19

Thanks!
    Xin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] target/i386: Raise the highest index value used for any VMCS encoding
  2024-07-26  1:12   ` Li, Xin3
@ 2024-07-26 17:17     ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2024-07-26 17:17 UTC (permalink / raw)
  To: Li, Xin3
  Cc: Wang, Lei4, Marcelo Tosatti, qemu-devel@nongnu.org,
	kvm@vger.kernel.org

On Fri, Jul 26, 2024 at 3:12 AM Li, Xin3 <xin3.li@intel.com> wrote:
> > Hi, can you put together a complete series that includes all that's needed for
> > nested FRED support?
>
> We can do it.
>
> Just to be clear, this patch is not needed to enable nested FRED, but to
> fix the following vmx test in kvm-unit-tests, otherwise we get:
>     FAIL: VMX_VMCS_ENUM.MAX_INDEX expected: 29, actual: 19

But neither bit is defined without nested FRED (and failures if you
use -cpu host,migratable=no are expected).

Paolo



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-07-26 17:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-24  8:08 [PATCH] target/i386: Raise the highest index value used for any VMCS encoding Lei Wang
2024-07-24 15:02 ` Paolo Bonzini
2024-07-26  1:12   ` Li, Xin3
2024-07-26 17:17     ` Paolo Bonzini

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).