* [kvm-unit-tests PATCH] x86: vmx_tests: pml: Skip PML test if it's not enabled in underlying
@ 2021-07-25 2:24 Robert Hoo
2021-07-27 0:20 ` Sean Christopherson
0 siblings, 1 reply; 3+ messages in thread
From: Robert Hoo @ 2021-07-25 2:24 UTC (permalink / raw)
To: kvm, bsd; +Cc: Robert Hoo
PML in VM depends on "enable PML" in VM-execution control, check this
before vmwrite to PMLADDR, because this field doesn't exist if PML is
disabled in VM-execution control.
Signed-off-by: Robert Hoo <robert.hu@linux.intel.com>
---
x86/vmx_tests.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 4f712eb..8663112 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -1502,13 +1502,16 @@ static int pml_init(struct vmcs *vmcs)
return VMX_TEST_EXIT;
}
+ ctrl_cpu = vmcs_read(CPU_EXEC_CTRL1) & CPU_PML;
+ if (!ctrl_cpu) {
+ printf("\tPML is not enabled\n");
+ return VMX_TEST_EXIT;
+ }
+
pml_log = alloc_page();
vmcs_write(PMLADDR, (u64)pml_log);
vmcs_write(GUEST_PML_INDEX, PML_INDEX - 1);
- ctrl_cpu = vmcs_read(CPU_EXEC_CTRL1) | CPU_PML;
- vmcs_write(CPU_EXEC_CTRL1, ctrl_cpu);
-
return VMX_TEST_START;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [kvm-unit-tests PATCH] x86: vmx_tests: pml: Skip PML test if it's not enabled in underlying
2021-07-25 2:24 [kvm-unit-tests PATCH] x86: vmx_tests: pml: Skip PML test if it's not enabled in underlying Robert Hoo
@ 2021-07-27 0:20 ` Sean Christopherson
2021-07-27 3:12 ` Robert Hoo
0 siblings, 1 reply; 3+ messages in thread
From: Sean Christopherson @ 2021-07-27 0:20 UTC (permalink / raw)
To: Robert Hoo; +Cc: kvm, bsd
On Sun, Jul 25, 2021, Robert Hoo wrote:
> PML in VM depends on "enable PML" in VM-execution control, check this
> before vmwrite to PMLADDR, because this field doesn't exist if PML is
> disabled in VM-execution control.
No, the field doesn't exist if the CPU doesn't support PML. Whether or not PML
is enabled in the execution controls is irrelevant. pml_init() checks for both
secondary execution controls and PML support (with bad indentation).
if (!(ctrl_cpu_rev[0].clr & CPU_SECONDARY) ||
!(ctrl_cpu_rev[1].clr & CPU_PML)) {
printf("\tPML is not supported");
return VMX_TEST_EXIT;
}
pml_log = alloc_page();
vmcs_write(PMLADDR, (u64)pml_log);
vmcs_write(GUEST_PML_INDEX, PML_INDEX - 1);
> Signed-off-by: Robert Hoo <robert.hu@linux.intel.com>
> ---
> x86/vmx_tests.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index 4f712eb..8663112 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -1502,13 +1502,16 @@ static int pml_init(struct vmcs *vmcs)
> return VMX_TEST_EXIT;
> }
>
> + ctrl_cpu = vmcs_read(CPU_EXEC_CTRL1) & CPU_PML;
> + if (!ctrl_cpu) {
> + printf("\tPML is not enabled\n");
> + return VMX_TEST_EXIT;
> + }
> +
> pml_log = alloc_page();
> vmcs_write(PMLADDR, (u64)pml_log);
> vmcs_write(GUEST_PML_INDEX, PML_INDEX - 1);
>
> - ctrl_cpu = vmcs_read(CPU_EXEC_CTRL1) | CPU_PML;
> - vmcs_write(CPU_EXEC_CTRL1, ctrl_cpu);
> -
> return VMX_TEST_START;
> }
>
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [kvm-unit-tests PATCH] x86: vmx_tests: pml: Skip PML test if it's not enabled in underlying
2021-07-27 0:20 ` Sean Christopherson
@ 2021-07-27 3:12 ` Robert Hoo
0 siblings, 0 replies; 3+ messages in thread
From: Robert Hoo @ 2021-07-27 3:12 UTC (permalink / raw)
To: Sean Christopherson; +Cc: kvm, bsd
On Tue, 2021-07-27 at 00:20 +0000, Sean Christopherson wrote:
> On Sun, Jul 25, 2021, Robert Hoo wrote:
> > PML in VM depends on "enable PML" in VM-execution control, check
> > this
> > before vmwrite to PMLADDR, because this field doesn't exist if PML
> > is
> > disabled in VM-execution control.
>
> No, the field doesn't exist if the CPU doesn't support PML. Whether
> or not PML
> is enabled in the execution controls is irrelevant.
Right, Thanks Sean.
> pml_init() checks for both
> secondary execution controls and PML support (with bad indentation).
>
> if (!(ctrl_cpu_rev[0].clr & CPU_SECONDARY) ||
> !(ctrl_cpu_rev[1].clr & CPU_PML)) {
> printf("\tPML is not supported");
> return VMX_TEST_EXIT;
> }
>
> pml_log = alloc_page();
> vmcs_write(PMLADDR, (u64)pml_log);
> vmcs_write(GUEST_PML_INDEX, PML_INDEX - 1);
>
> > Signed-off-by: Robert Hoo <robert.hu@linux.intel.com>
> > ---
> > x86/vmx_tests.c | 9 ++++++---
> > 1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> > index 4f712eb..8663112 100644
> > --- a/x86/vmx_tests.c
> > +++ b/x86/vmx_tests.c
> > @@ -1502,13 +1502,16 @@ static int pml_init(struct vmcs *vmcs)
> > return VMX_TEST_EXIT;
> > }
> >
> > + ctrl_cpu = vmcs_read(CPU_EXEC_CTRL1) & CPU_PML;
> > + if (!ctrl_cpu) {
> > + printf("\tPML is not enabled\n");
> > + return VMX_TEST_EXIT;
> > + }
> > +
> > pml_log = alloc_page();
> > vmcs_write(PMLADDR, (u64)pml_log);
> > vmcs_write(GUEST_PML_INDEX, PML_INDEX - 1);
> >
> > - ctrl_cpu = vmcs_read(CPU_EXEC_CTRL1) | CPU_PML;
> > - vmcs_write(CPU_EXEC_CTRL1, ctrl_cpu);
> > -
> > return VMX_TEST_START;
> > }
> >
> > --
> > 1.8.3.1
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-27 3:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-25 2:24 [kvm-unit-tests PATCH] x86: vmx_tests: pml: Skip PML test if it's not enabled in underlying Robert Hoo
2021-07-27 0:20 ` Sean Christopherson
2021-07-27 3:12 ` Robert Hoo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.