diff mbox

[RFC,05/14] xen: vmx: Disable the 2M/1G superpage when SPP enabled

Message ID f036c2e9a6d81670d22edfc3b872773fc5ea3d6c.1508397860.git.yi.z.zhang@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Zhang, Yi Oct. 19, 2017, 8:11 a.m. UTC
From: Zhang Yi Z <yi.z.zhang@linux.intel.com>

Current we only support Sub-page Protection on the 4k
page table.

Signed-off-by: Zhang Yi Z <yi.z.zhang@linux.intel.com>
---
 xen/arch/x86/hvm/vmx/vmx.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Tamas K Lengyel Oct. 19, 2017, 6:17 p.m. UTC | #1
On Thu, Oct 19, 2017 at 2:11 AM, Zhang Yi <yi.z.zhang@linux.intel.com> wrote:
> From: Zhang Yi Z <yi.z.zhang@linux.intel.com>
>
> Current we only support Sub-page Protection on the 4k
> page table.
>
> Signed-off-by: Zhang Yi Z <yi.z.zhang@linux.intel.com>
> ---
>  xen/arch/x86/hvm/vmx/vmx.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index 04ae0d6..a4c24bb 100644
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> +++ b/xen/arch/x86/hvm/vmx/vmx.c
> @@ -2497,6 +2497,12 @@ const struct hvm_function_table * __init start_vmx(void)
>          vmx_function_table.get_guest_bndcfgs = vmx_get_guest_bndcfgs;
>      }
>
> +    if ( cpu_has_vmx_ept_spp )

I think this really only ought to happen if the command-line option
has also been enabled.

> +    {
> +        vmx_function_table.hap_capabilities &= ~HVM_HAP_SUPERPAGE_2MB;
> +        vmx_function_table.hap_capabilities &= ~HVM_HAP_SUPERPAGE_1GB;
> +    }
> +
>      setup_vmcs_dump();
>
>      lbr_tsx_fixup_check();
> --
> 2.7.4
Zhang, Yi Oct. 20, 2017, 8:44 a.m. UTC | #2
On 2017-10-19 at 12:17:12 -0600, Tamas K Lengyel wrote:
> On Thu, Oct 19, 2017 at 2:11 AM, Zhang Yi <yi.z.zhang@linux.intel.com> wrote:
> > From: Zhang Yi Z <yi.z.zhang@linux.intel.com>
> >
> > Current we only support Sub-page Protection on the 4k
> > page table.
> >
> > Signed-off-by: Zhang Yi Z <yi.z.zhang@linux.intel.com>
> > ---
> >  xen/arch/x86/hvm/vmx/vmx.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> > index 04ae0d6..a4c24bb 100644
> > --- a/xen/arch/x86/hvm/vmx/vmx.c
> > +++ b/xen/arch/x86/hvm/vmx/vmx.c
> > @@ -2497,6 +2497,12 @@ const struct hvm_function_table * __init start_vmx(void)
> >          vmx_function_table.get_guest_bndcfgs = vmx_get_guest_bndcfgs;
> >      }
> >
> > +    if ( cpu_has_vmx_ept_spp )
> 
> I think this really only ought to happen if the command-line option
> has also been enabled.

Sorry, didn't catch your point, the command line option opt_hap_2m and
opt_hap_1G was enable by default, I need to  disable the supper page
when spp feature enabled. Did you mean that if we enable 2M/1G by
command-line we couldn't disable it here? yes, it is, I will improve
this logic. Thank you Tamas.

> 
> > +    {
> > +        vmx_function_table.hap_capabilities &= ~HVM_HAP_SUPERPAGE_2MB;
> > +        vmx_function_table.hap_capabilities &= ~HVM_HAP_SUPERPAGE_1GB;
> > +    }
> > +
> >      setup_vmcs_dump();
> >
> >      lbr_tsx_fixup_check();
> > --
> > 2.7.4
Tamas K Lengyel Oct. 24, 2017, 5:43 p.m. UTC | #3
On Fri, Oct 20, 2017 at 2:44 AM, Yi Zhang <yi.z.zhang@linux.intel.com> wrote:
> On 2017-10-19 at 12:17:12 -0600, Tamas K Lengyel wrote:
>> On Thu, Oct 19, 2017 at 2:11 AM, Zhang Yi <yi.z.zhang@linux.intel.com> wrote:
>> > From: Zhang Yi Z <yi.z.zhang@linux.intel.com>
>> >
>> > Current we only support Sub-page Protection on the 4k
>> > page table.
>> >
>> > Signed-off-by: Zhang Yi Z <yi.z.zhang@linux.intel.com>
>> > ---
>> >  xen/arch/x86/hvm/vmx/vmx.c | 6 ++++++
>> >  1 file changed, 6 insertions(+)
>> >
>> > diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
>> > index 04ae0d6..a4c24bb 100644
>> > --- a/xen/arch/x86/hvm/vmx/vmx.c
>> > +++ b/xen/arch/x86/hvm/vmx/vmx.c
>> > @@ -2497,6 +2497,12 @@ const struct hvm_function_table * __init start_vmx(void)
>> >          vmx_function_table.get_guest_bndcfgs = vmx_get_guest_bndcfgs;
>> >      }
>> >
>> > +    if ( cpu_has_vmx_ept_spp )
>>
>> I think this really only ought to happen if the command-line option
>> has also been enabled.
>
> Sorry, didn't catch your point, the command line option opt_hap_2m and
> opt_hap_1G was enable by default, I need to  disable the supper page
> when spp feature enabled. Did you mean that if we enable 2M/1G by
> command-line we couldn't disable it here? yes, it is, I will improve
> this logic. Thank you Tamas.

I meant that right now "cpu_has_vmx_ept_spp" looks like just checks
whether the CPU supports SPP, not whether the command-line option was
set to enable it. If the command line option is not set (or
specifically disables SPP) then the large pages shouldn't get
disabled.

>
>>
>> > +    {
>> > +        vmx_function_table.hap_capabilities &= ~HVM_HAP_SUPERPAGE_2MB;
>> > +        vmx_function_table.hap_capabilities &= ~HVM_HAP_SUPERPAGE_1GB;
>> > +    }
>> > +
>> >      setup_vmcs_dump();
>> >
>> >      lbr_tsx_fixup_check();
>> > --
>> > 2.7.4
Tamas K Lengyel Oct. 25, 2017, 3:12 p.m. UTC | #4
On Wed, Oct 25, 2017 at 9:32 AM, Yi Zhang <yi.z.zhang@linux.intel.com> wrote:
> On 2017-10-24 at 11:43:45 -0600, Tamas K Lengyel wrote:
>> On Fri, Oct 20, 2017 at 2:44 AM, Yi Zhang <yi.z.zhang@linux.intel.com> wrote:
>> > On 2017-10-19 at 12:17:12 -0600, Tamas K Lengyel wrote:
>> >> On Thu, Oct 19, 2017 at 2:11 AM, Zhang Yi <yi.z.zhang@linux.intel.com> wrote:
>> >> > From: Zhang Yi Z <yi.z.zhang@linux.intel.com>
>> >> >
>> >> > Current we only support Sub-page Protection on the 4k
>> >> > page table.
>> >> >
>> >> > Signed-off-by: Zhang Yi Z <yi.z.zhang@linux.intel.com>
>> >> > ---
>> >> >  xen/arch/x86/hvm/vmx/vmx.c | 6 ++++++
>> >> >  1 file changed, 6 insertions(+)
>> >> >
>> >> > diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
>> >> > index 04ae0d6..a4c24bb 100644
>> >> > --- a/xen/arch/x86/hvm/vmx/vmx.c
>> >> > +++ b/xen/arch/x86/hvm/vmx/vmx.c
>> >> > @@ -2497,6 +2497,12 @@ const struct hvm_function_table * __init start_vmx(void)
>> >> >          vmx_function_table.get_guest_bndcfgs = vmx_get_guest_bndcfgs;
>> >> >      }
>> >> >
>> >> > +    if ( cpu_has_vmx_ept_spp )
>> >>
>> >> I think this really only ought to happen if the command-line option
>> >> has also been enabled.
>> >
>> > Sorry, didn't catch your point, the command line option opt_hap_2m and
>> > opt_hap_1G was enable by default, I need to  disable the supper page
>> > when spp feature enabled. Did you mean that if we enable 2M/1G by
>> > command-line we couldn't disable it here? yes, it is, I will improve
>> > this logic. Thank you Tamas.
>>
>> I meant that right now "cpu_has_vmx_ept_spp" looks like just checks
>> whether the CPU supports SPP, not whether the command-line option was
>> set to enable it. If the command line option is not set (or
>> specifically disables SPP) then the large pages shouldn't get
>> disabled.
>>
>
> In patch 02/14, if we didn't set spp_enable, we will not set the spp cap
> in vmx_secondary_exec_control, so cp_has_vmx_ept_spp flag will set when
> hardware has spp cap and xen cmdlline passed the parameter "spp_enable=1"

OK, thanks, I missed that.

>
>> >
>> >>
>> >> > +    {
>> >> > +        vmx_function_table.hap_capabilities &= ~HVM_HAP_SUPERPAGE_2MB;
>> >> > +        vmx_function_table.hap_capabilities &= ~HVM_HAP_SUPERPAGE_1GB;
>> >> > +    }
>> >> > +
>> >> >      setup_vmcs_dump();
>> >> >
>> >> >      lbr_tsx_fixup_check();
>> >> > --
>> >> > 2.7.4
Zhang, Yi Oct. 25, 2017, 3:32 p.m. UTC | #5
On 2017-10-24 at 11:43:45 -0600, Tamas K Lengyel wrote:
> On Fri, Oct 20, 2017 at 2:44 AM, Yi Zhang <yi.z.zhang@linux.intel.com> wrote:
> > On 2017-10-19 at 12:17:12 -0600, Tamas K Lengyel wrote:
> >> On Thu, Oct 19, 2017 at 2:11 AM, Zhang Yi <yi.z.zhang@linux.intel.com> wrote:
> >> > From: Zhang Yi Z <yi.z.zhang@linux.intel.com>
> >> >
> >> > Current we only support Sub-page Protection on the 4k
> >> > page table.
> >> >
> >> > Signed-off-by: Zhang Yi Z <yi.z.zhang@linux.intel.com>
> >> > ---
> >> >  xen/arch/x86/hvm/vmx/vmx.c | 6 ++++++
> >> >  1 file changed, 6 insertions(+)
> >> >
> >> > diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> >> > index 04ae0d6..a4c24bb 100644
> >> > --- a/xen/arch/x86/hvm/vmx/vmx.c
> >> > +++ b/xen/arch/x86/hvm/vmx/vmx.c
> >> > @@ -2497,6 +2497,12 @@ const struct hvm_function_table * __init start_vmx(void)
> >> >          vmx_function_table.get_guest_bndcfgs = vmx_get_guest_bndcfgs;
> >> >      }
> >> >
> >> > +    if ( cpu_has_vmx_ept_spp )
> >>
> >> I think this really only ought to happen if the command-line option
> >> has also been enabled.
> >
> > Sorry, didn't catch your point, the command line option opt_hap_2m and
> > opt_hap_1G was enable by default, I need to  disable the supper page
> > when spp feature enabled. Did you mean that if we enable 2M/1G by
> > command-line we couldn't disable it here? yes, it is, I will improve
> > this logic. Thank you Tamas.
> 
> I meant that right now "cpu_has_vmx_ept_spp" looks like just checks
> whether the CPU supports SPP, not whether the command-line option was
> set to enable it. If the command line option is not set (or
> specifically disables SPP) then the large pages shouldn't get
> disabled.
> 

In patch 02/14, if we didn't set spp_enable, we will not set the spp cap 
in vmx_secondary_exec_control, so cp_has_vmx_ept_spp flag will set when 
hardware has spp cap and xen cmdlline passed the parameter "spp_enable=1"

> >
> >>
> >> > +    {
> >> > +        vmx_function_table.hap_capabilities &= ~HVM_HAP_SUPERPAGE_2MB;
> >> > +        vmx_function_table.hap_capabilities &= ~HVM_HAP_SUPERPAGE_1GB;
> >> > +    }
> >> > +
> >> >      setup_vmcs_dump();
> >> >
> >> >      lbr_tsx_fixup_check();
> >> > --
> >> > 2.7.4
diff mbox

Patch

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 04ae0d6..a4c24bb 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2497,6 +2497,12 @@  const struct hvm_function_table * __init start_vmx(void)
         vmx_function_table.get_guest_bndcfgs = vmx_get_guest_bndcfgs;
     }
 
+    if ( cpu_has_vmx_ept_spp )
+    {
+        vmx_function_table.hap_capabilities &= ~HVM_HAP_SUPERPAGE_2MB;
+        vmx_function_table.hap_capabilities &= ~HVM_HAP_SUPERPAGE_1GB;
+    }
+
     setup_vmcs_dump();
 
     lbr_tsx_fixup_check();