From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Kevin Tian <kevin.tian@intel.com>,
Jan Beulich <jbeulich@suse.com>,
Jun Nakajima <jun.nakajima@intel.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v11 1/09] xen/x86: set the vPMU interface based on the presence of a lapic
Date: Fri, 11 Dec 2015 11:17:15 +0100 [thread overview]
Message-ID: <1449829035-967-1-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <AADFC41AFE54684AB9EE6CBC0274A5D15F741F96@SHSMSX101.ccr.corp.intel.com>
Instead of choosing the interface to expose to guests based on the guest
type, do it based on whether the guest has an emulated local apic or not.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Cc: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
Cc: Jun Nakajima <jun.nakajima@intel.com>
Cc: Kevin Tian <kevin.tian@intel.com>
---
Changes since v10:
- Remove the is_hvm_cpu from the VMX/SVM vPMU initialization code, just
checking for has_vlapic is enough.
Changes since v8:
- Don't add the xenpmu hypercalls to the HVM hypercall table (yet).
- Add Jan Beulich Acked-by.
Changes since v7:
- Merge vpmu work from Boris.
Changes since v6:
- Major rework of the approach.
- Drop Andrew Cooper Acked-by.
Changes since v4:
- Add Andrew Cooper Acked-by.
---
xen/arch/x86/cpu/vpmu.c | 11 ++++++-----
xen/arch/x86/cpu/vpmu_amd.c | 6 +++---
xen/arch/x86/cpu/vpmu_intel.c | 6 +++---
xen/arch/x86/hvm/svm/svm.c | 2 +-
xen/arch/x86/hvm/vmx/vmx.c | 2 +-
5 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/xen/arch/x86/cpu/vpmu.c b/xen/arch/x86/cpu/vpmu.c
index d870dcc..4856e98 100644
--- a/xen/arch/x86/cpu/vpmu.c
+++ b/xen/arch/x86/cpu/vpmu.c
@@ -94,7 +94,7 @@ void vpmu_lvtpc_update(uint32_t val)
vpmu->hw_lapic_lvtpc = PMU_APIC_VECTOR | (val & APIC_LVT_MASKED);
/* Postpone APIC updates for PV(H) guests if PMU interrupt is pending */
- if ( is_hvm_vcpu(curr) || !vpmu->xenpmu_data ||
+ if ( has_vlapic(curr->domain) || !vpmu->xenpmu_data ||
!vpmu_is_set(vpmu, VPMU_CACHED) )
apic_write(APIC_LVTPC, vpmu->hw_lapic_lvtpc);
}
@@ -129,7 +129,7 @@ int vpmu_do_msr(unsigned int msr, uint64_t *msr_content,
* and since do_wr/rdmsr may load VPMU context we should save
* (and unload) it again.
*/
- if ( !is_hvm_vcpu(curr) && vpmu->xenpmu_data &&
+ if ( !has_vlapic(curr->domain) && vpmu->xenpmu_data &&
vpmu_is_set(vpmu, VPMU_CACHED) )
{
vpmu_set(vpmu, VPMU_CONTEXT_SAVE);
@@ -184,7 +184,7 @@ void vpmu_do_interrupt(struct cpu_user_regs *regs)
return;
/* PV(H) guest */
- if ( !is_hvm_vcpu(sampling) || (vpmu_mode & XENPMU_MODE_ALL) )
+ if ( !has_vlapic(sampling->domain) || (vpmu_mode & XENPMU_MODE_ALL) )
{
const struct cpu_user_regs *cur_regs;
uint64_t *flags = &vpmu->xenpmu_data->pmu.pmu_flags;
@@ -411,7 +411,8 @@ int vpmu_load(struct vcpu *v, bool_t from_guest)
/* Only when PMU is counting, we load PMU context immediately. */
if ( !vpmu_is_set(vpmu, VPMU_RUNNING) ||
- (!is_hvm_vcpu(vpmu_vcpu(vpmu)) && vpmu_is_set(vpmu, VPMU_CACHED)) )
+ (!has_vlapic(vpmu_vcpu(vpmu)->domain) &&
+ vpmu_is_set(vpmu, VPMU_CACHED)) )
return 0;
if ( vpmu->arch_vpmu_ops && vpmu->arch_vpmu_ops->arch_vpmu_load )
@@ -637,7 +638,7 @@ long do_xenpmu_op(unsigned int op, XEN_GUEST_HANDLE_PARAM(xen_pmu_params_t) arg)
struct xen_pmu_data *xenpmu_data;
struct vpmu_struct *vpmu;
- if ( !opt_vpmu_enabled )
+ if ( !opt_vpmu_enabled || has_vlapic(current->domain) )
return -EOPNOTSUPP;
ret = xsm_pmu_op(XSM_OTHER, current->domain, op);
diff --git a/xen/arch/x86/cpu/vpmu_amd.c b/xen/arch/x86/cpu/vpmu_amd.c
index 04da81a..990e6f3 100644
--- a/xen/arch/x86/cpu/vpmu_amd.c
+++ b/xen/arch/x86/cpu/vpmu_amd.c
@@ -238,7 +238,7 @@ static int amd_vpmu_load(struct vcpu *v, bool_t from_guest)
bool_t is_running = 0;
struct xen_pmu_amd_ctxt *guest_ctxt = &vpmu->xenpmu_data->pmu.c.amd;
- ASSERT(!is_hvm_vcpu(v));
+ ASSERT(!has_vlapic(v->domain));
ctxt = vpmu->context;
ctrl_regs = vpmu_reg_pointer(ctxt, ctrls);
@@ -314,7 +314,7 @@ static int amd_vpmu_save(struct vcpu *v, bool_t to_guest)
{
struct xen_pmu_amd_ctxt *guest_ctxt, *ctxt;
- ASSERT(!is_hvm_vcpu(v));
+ ASSERT(!has_vlapic(v->domain));
ctxt = vpmu->context;
guest_ctxt = &vpmu->xenpmu_data->pmu.c.amd;
memcpy(&guest_ctxt->regs[0], &ctxt->regs[0], regs_sz);
@@ -525,7 +525,7 @@ int svm_vpmu_initialise(struct vcpu *v)
vpmu->context = ctxt;
vpmu->priv_context = NULL;
- if ( !is_hvm_vcpu(v) )
+ if ( !has_vlapic(v->domain) )
{
/* Copy register offsets to shared area */
ASSERT(vpmu->xenpmu_data);
diff --git a/xen/arch/x86/cpu/vpmu_intel.c b/xen/arch/x86/cpu/vpmu_intel.c
index d5ea7fe..d5fde80 100644
--- a/xen/arch/x86/cpu/vpmu_intel.c
+++ b/xen/arch/x86/cpu/vpmu_intel.c
@@ -336,7 +336,7 @@ static int core2_vpmu_save(struct vcpu *v, bool_t to_guest)
if ( to_guest )
{
- ASSERT(!is_hvm_vcpu(v));
+ ASSERT(!has_vlapic(v->domain));
memcpy((void *)(&vpmu->xenpmu_data->pmu.c.intel) + regs_off,
vpmu->context + regs_off, regs_sz);
}
@@ -441,7 +441,7 @@ static int core2_vpmu_load(struct vcpu *v, bool_t from_guest)
{
int ret;
- ASSERT(!is_hvm_vcpu(v));
+ ASSERT(!has_vlapic(v->domain));
memcpy(vpmu->context + regs_off,
(void *)&v->arch.vpmu.xenpmu_data->pmu.c.intel + regs_off,
@@ -501,7 +501,7 @@ static int core2_vpmu_alloc_resource(struct vcpu *v)
vpmu->context = core2_vpmu_cxt;
vpmu->priv_context = p;
- if ( !is_hvm_vcpu(v) )
+ if ( !has_vlapic(v->domain) )
{
/* Copy fixed/arch register offsets to shared area */
ASSERT(vpmu->xenpmu_data);
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 9415fb1..067bc4d 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -1167,7 +1167,7 @@ static int svm_vcpu_initialise(struct vcpu *v)
}
/* PVH's VPMU is initialized via hypercall */
- if ( is_hvm_vcpu(v) )
+ if ( has_vlapic(v->domain) )
vpmu_initialise(v);
svm_guest_osvw_init(v);
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 2581e97..2af0780 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -148,7 +148,7 @@ static int vmx_vcpu_initialise(struct vcpu *v)
}
/* PVH's VPMU is initialized via hypercall */
- if ( is_hvm_vcpu(v) )
+ if ( has_vlapic(v->domain) )
vpmu_initialise(v);
vmx_install_vlapic_mapping(v);
--
1.9.5 (Apple Git-50.3)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2015-12-11 10:19 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-07 16:48 [PATCH v10 0/9] Introduce HVM without dm and new boot ABI Roger Pau Monne
2015-12-07 16:48 ` [PATCH v10 1/9] xen/x86: set the vPMU interface based on the presence of a lapic Roger Pau Monne
2015-12-07 17:04 ` Jan Beulich
2015-12-09 10:18 ` Roger Pau Monné
2015-12-11 7:52 ` Tian, Kevin
2015-12-11 7:51 ` Tian, Kevin
2015-12-11 9:15 ` Jan Beulich
2015-12-11 9:31 ` Roger Pau Monné
2015-12-11 10:17 ` Roger Pau Monne [this message]
2015-12-15 7:39 ` [PATCH v11 1/09] " Tian, Kevin
2015-12-07 16:48 ` [PATCH v10 2/9] xen/x86: allow disabling all emulated devices inside of Xen Roger Pau Monne
2015-12-07 16:48 ` [PATCH v10 3/9] libxc: allow creating domains without emulated devices Roger Pau Monne
2016-02-01 7:17 ` Olaf Hering
2016-02-02 11:33 ` [PATCH] libxc: fix uninitialised usage of rc in meminit_hvm Roger Pau Monne
2016-02-02 12:37 ` Wei Liu
2016-02-03 10:30 ` Ian Campbell
2016-02-03 10:42 ` Wei Liu
2016-02-03 10:44 ` Roger Pau Monné
2016-02-03 10:54 ` Ian Campbell
2016-02-03 13:21 ` [PATCH v2] " Roger Pau Monne
2016-02-04 16:20 ` Ian Campbell
2015-12-07 16:48 ` [PATCH v10 4/9] x86/hvm: loosen up the ASSERT in hvm_cr4_guest_reserved_bits and hvm_efer_valid Roger Pau Monne
2015-12-07 16:56 ` Andrew Cooper
2015-12-08 8:28 ` Jan Beulich
2015-12-08 11:37 ` Andrew Cooper
2015-12-08 12:54 ` Jan Beulich
2015-12-08 14:43 ` Andrew Cooper
2015-12-09 8:25 ` Jan Beulich
2015-12-07 16:48 ` [PATCH v10 5/9] xen/x86: allow HVM guests to use hypercalls to bring up vCPUs Roger Pau Monne
2015-12-08 17:08 ` Ian Campbell
2015-12-10 16:53 ` Jan Beulich
2015-12-10 17:18 ` Roger Pau Monné
2015-12-10 17:23 ` Jan Beulich
2015-12-07 16:48 ` [PATCH v10 6/9] libxc/xen: introduce a start info structure for HVMlite guests Roger Pau Monne
2015-12-07 16:48 ` [PATCH v10 7/9] libxc: switch xc_dom_elfloader to be used with HVMlite domains Roger Pau Monne
2015-12-07 16:48 ` [PATCH v10 8/9] libxl: allow the creation of HVM domains without a device model Roger Pau Monne
2015-12-07 16:48 ` [PATCH v10 9/9] libxl: add support for migrating HVM guests " Roger Pau Monne
2015-12-15 13:21 ` [PATCH v10 0/9] Introduce HVM without dm and new boot ABI Jan Beulich
2015-12-15 15:08 ` Ian Campbell
2015-12-15 15:11 ` Ian Campbell
2015-12-15 15:52 ` Roger Pau Monné
2015-12-15 15:58 ` Ian Campbell
2015-12-15 16:16 ` Roger Pau Monné
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=1449829035-967-1-git-send-email-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=Aravind.Gopalakrishnan@amd.com \
--cc=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=jbeulich@suse.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=xen-devel@lists.xenproject.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).