[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 2/3] x86/vpmu: Disable VPMU if guest's CPUID indicates no PMU support



> From: Boris Ostrovsky [mailto:boris.ostrovsky@xxxxxxxxxx]
> Sent: Saturday, February 18, 2017 1:40 AM
> 
> When toolstack overrides CPUID leaf 0xa values (on Intel processors)
> VPMU should not be available to the guest.

only when override with an invalid version?

otherwise ok to me. Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>

> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
> ---
> * New in v2
> 
>  xen/arch/x86/cpu/vpmu_intel.c |  4 ++++
>  xen/arch/x86/domctl.c         | 14 ++++++++++++++
>  2 files changed, 18 insertions(+)
> 
> diff --git a/xen/arch/x86/cpu/vpmu_intel.c b/xen/arch/x86/cpu/vpmu_intel.c
> index 16e5afb..051bf85 100644
> --- a/xen/arch/x86/cpu/vpmu_intel.c
> +++ b/xen/arch/x86/cpu/vpmu_intel.c
> @@ -884,6 +884,10 @@ int vmx_vpmu_initialise(struct vcpu *v)
>      if ( vpmu_mode == XENPMU_MODE_OFF )
>          return 0;
> 
> +    if ( MASK_EXTR(v->domain->arch.cpuid->basic.raw[0xa].a,
> +                   PMU_VERSION_MASK) == 0 )
> +        return -EINVAL;
> +
>      if ( (arch_pmc_cnt + fixed_pmc_cnt) == 0 )
>          return -EINVAL;
> 
> diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
> index 8e5259f..cbcc207 100644
> --- a/xen/arch/x86/domctl.c
> +++ b/xen/arch/x86/domctl.c
> @@ -253,6 +253,20 @@ static int update_domain_cpuid_info(struct domain *d,
>          }
>          break;
> 
> +    case 0xa:
> +        if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
> +            break;
> +
> +        /* If PMU version is invalid then the guest doesn't have VPMU */
> +        if ( MASK_EXTR(leaf.a, 0xff) == 0 )
> +        {
> +            struct vcpu *v;
> +
> +            for_each_vcpu( d, v )
> +                vpmu_destroy(v);
> +        }
> +        break;
> +
>      case 0xd:
>          if ( ctl->input[1] != 1 )
>              break;
> --
> 1.8.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.