xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Mohit Gambhir <mohit.gambhir@oracle.com>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Jan Beulich <JBeulich@suse.com>
Cc: kevin.tian@intel.com, jun.nakajima@intel.com, xen-devel@lists.xen.org
Subject: Re: [PATCH] x86/vpmu_intel: Fix hypervisor crash by catching wrmsr fault
Date: Mon, 24 Apr 2017 14:49:00 -0400	[thread overview]
Message-ID: <24e755d6-b701-1141-4fef-a998183dd8b7@oracle.com> (raw)
In-Reply-To: <4c116835-0124-3506-8d7e-ad903116816c@oracle.com>



On 04/24/2017 12:00 PM, Boris Ostrovsky wrote:
>> Also, from the description in the SDM, PC flag bit it seems very
>> disruptive to me.
>> SDM says that if the bit is set then the processor toggles the PMi pin
>> (generating a performance monitoring interrupt?)
>> every time the event occurs. So if we program the counter to count
>> "unhaulted core cycles", and set PC flag bit
>> it will generate an interrupts every cycle!?
> I checked how Linux treats this bit and there is this interesting commit:
>
>
> commit a7b9d2ccc3d86303ee9314612d301966e04011c7
> Author: Gleb Natapov <gleb@redhat.com>
> Date:   Sun Feb 26 16:55:40 2012 +0200
>
>      KVM: PMU: warn when pin control is set in eventsel msr
>     
>      Print warning once if pin control bit is set in eventsel msr since
>      emulation does not support it yet.
>     
>      Signed-off-by: Gleb Natapov <gleb@redhat.com>
>      Signed-off-by: Avi Kivity <avi@redhat.com>
>
> diff --git a/arch/x86/include/asm/perf_event.h
> b/arch/x86/include/asm/perf_event.h
> index 096c975..f1f7182 100644
> --- a/arch/x86/include/asm/perf_event.h
> +++ b/arch/x86/include/asm/perf_event.h
> @@ -23,6 +23,7 @@
>   #define ARCH_PERFMON_EVENTSEL_USR                      (1ULL << 16)
>   #define ARCH_PERFMON_EVENTSEL_OS                       (1ULL << 17)
>   #define ARCH_PERFMON_EVENTSEL_EDGE                     (1ULL << 18)
> +#define ARCH_PERFMON_EVENTSEL_PIN_CONTROL              (1ULL << 19)
>   #define ARCH_PERFMON_EVENTSEL_INT                      (1ULL << 20)
>   #define ARCH_PERFMON_EVENTSEL_ANY                      (1ULL << 21)
>   #define ARCH_PERFMON_EVENTSEL_ENABLE                   (1ULL << 22)
> diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
> index 3e48c1d..6af9a54 100644
> --- a/arch/x86/kvm/pmu.c
> +++ b/arch/x86/kvm/pmu.c
> @@ -210,6 +210,9 @@ static void reprogram_gp_counter(struct kvm_pmc
> *pmc, u64 eventsel)
>          unsigned config, type = PERF_TYPE_RAW;
>          u8 event_select, unit_mask;
>   
> +       if (eventsel & ARCH_PERFMON_EVENTSEL_PIN_CONTROL)
> +               printk_once("kvm pmu: pin control bit is ignored\n");
> +
>          pmc->eventsel = eventsel;
>   
>          stop_counter(pmc);

Given that we know this now, will it makes sense to go with solution 1 
in my cover letter for this patch -

" 1. Mask the PC bit in the VPMU so as to not allow any writes to it from guests
on any Intel machine. "

But even then the question remains whether we should return an error when user tries to
set this bit or should we just silently mask it the way KVM does?

Mohit


>
>
> -boris
>


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

  reply	other threads:[~2017-04-24 18:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-20 17:49 [PATCH] Fix hypervisor crash when writing to VPMU MSR Mohit Gambhir
2017-04-20 17:49 ` [PATCH] x86/vpmu_intel: Fix hypervisor crash by catching wrmsr fault Mohit Gambhir
2017-04-21  7:14   ` Jan Beulich
2017-04-24 15:44     ` Mohit Gambhir
2017-04-24 16:00       ` Boris Ostrovsky
2017-04-24 18:49         ` Mohit Gambhir [this message]
2017-04-24 16:04       ` Jan Beulich

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=24e755d6-b701-1141-4fef-a998183dd8b7@oracle.com \
    --to=mohit.gambhir@oracle.com \
    --cc=JBeulich@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=xen-devel@lists.xen.org \
    /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;
as well as URLs for NNTP newsgroup(s).