From: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
To: xen-devel@lists.xen.org
Cc: kevin.tian@intel.com, JBeulich@suse.com,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
andrew.cooper3@citrix.com, tim@xen.org,
Aravind.Gopalakrishnan@amd.com, jun.nakajima@intel.com,
dgdegra@tycho.nsa.gov, suravee.suthikulpanit@amd.com
Subject: Re: [PATCH v19 12/14] x86/VPMU: Merge vpmu_rdmsr and vpmu_wrmsr
Date: Wed, 25 Mar 2015 13:23:56 +0100 [thread overview]
Message-ID: <2189557.TCUq0WKC1f@amur> (raw)
In-Reply-To: <2613093.GJGiy2F2se@amur>
Am Mittwoch 25 März 2015, 09:29:14 schrieb Dietmar Hahn:
> Am Dienstag 17 März 2015, 10:54:09 schrieb Boris Ostrovsky:
> > The two routines share most of their logic.
> >
> > Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> > ---
> > Changes in v19:
> > * const-ified arch_vpmu_ops in vpmu_do_wrmsr
> > * non-changes:
> > - kept 'current' as a non-initializer to avoid unnecessary initialization
> > in the (common) non-VPMU case
> > - kept 'nop' label since there are multiple dissimilar cases that can cause
> > a non-emulation of VPMU access
> >
> > xen/arch/x86/hvm/vpmu.c | 76 +++++++++++++++++-------------------------
> > xen/include/asm-x86/hvm/vpmu.h | 14 ++++++--
> > 2 files changed, 42 insertions(+), 48 deletions(-)
> >
> > diff --git a/xen/arch/x86/hvm/vpmu.c b/xen/arch/x86/hvm/vpmu.c
> > index c287d8b..beed956 100644
> > --- a/xen/arch/x86/hvm/vpmu.c
> > +++ b/xen/arch/x86/hvm/vpmu.c
> > @@ -103,63 +103,47 @@ void vpmu_lvtpc_update(uint32_t val)
> > apic_write(APIC_LVTPC, vpmu->hw_lapic_lvtpc);
> > }
> >
> > -int vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content, uint64_t supported)
> > +int vpmu_do_msr(unsigned int msr, uint64_t *msr_content,
> > + uint64_t supported, bool_t is_write)
> > {
> > - struct vcpu *curr = current;
> > + struct vcpu *curr;
> > struct vpmu_struct *vpmu;
> > + const struct arch_vpmu_ops *ops;
>
> What is this const useful for in this small function?
Sorry for the question and for the noise I already got it!
>
> Reviewed-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
>
> Dietmar.
>
> > + int ret = 0;
> >
> > if ( vpmu_mode == XENPMU_MODE_OFF )
> > - return 0;
> > + goto nop;
> >
> > + curr = current;
> > vpmu = vcpu_vpmu(curr);
> > - if ( vpmu->arch_vpmu_ops && vpmu->arch_vpmu_ops->do_wrmsr )
> > - {
> > - int ret = vpmu->arch_vpmu_ops->do_wrmsr(msr, msr_content, supported);
> > -
> > - /*
> > - * We may have received a PMU interrupt during WRMSR handling
> > - * and since do_wrmsr may load VPMU context we should save
> > - * (and unload) it again.
> > - */
> > - if ( !is_hvm_vcpu(curr) && vpmu->xenpmu_data &&
> > - (vpmu->xenpmu_data->pmu.pmu_flags & PMU_CACHED) )
> > - {
> > - vpmu_set(vpmu, VPMU_CONTEXT_SAVE);
> > - vpmu->arch_vpmu_ops->arch_vpmu_save(curr);
> > - vpmu_reset(vpmu, VPMU_CONTEXT_SAVE | VPMU_CONTEXT_LOADED);
> > - }
> > - return ret;
> > - }
> > -
> > - return 0;
> > -}
> > -
> > -int vpmu_do_rdmsr(unsigned int msr, uint64_t *msr_content)
> > -{
> > - struct vcpu *curr = current;
> > - struct vpmu_struct *vpmu;
> > + ops = vpmu->arch_vpmu_ops;
> > + if ( !ops )
> > + goto nop;
> > +
> > + if ( is_write && ops->do_wrmsr )
> > + ret = ops->do_wrmsr(msr, *msr_content, supported);
> > + else if ( !is_write && ops->do_rdmsr )
> > + ret = ops->do_rdmsr(msr, msr_content);
> > + else
> > + goto nop;
> >
> > - if ( vpmu_mode == XENPMU_MODE_OFF )
> > + /*
> > + * We may have received a PMU interrupt while handling MSR access
> > + * and since do_wr/rdmsr may load VPMU context we should save
> > + * (and unload) it again.
> > + */
> > + if ( !is_hvm_vcpu(curr) &&
> > + vpmu->xenpmu_data && (vpmu->xenpmu_data->pmu.pmu_flags & PMU_CACHED) )
> > {
> > - *msr_content = 0;
> > - return 0;
> > + vpmu_set(vpmu, VPMU_CONTEXT_SAVE);
> > + ops->arch_vpmu_save(curr);
> > + vpmu_reset(vpmu, VPMU_CONTEXT_SAVE | VPMU_CONTEXT_LOADED);
> > }
> >
> > - vpmu = vcpu_vpmu(curr);
> > - if ( vpmu->arch_vpmu_ops && vpmu->arch_vpmu_ops->do_rdmsr )
> > - {
> > - int ret = vpmu->arch_vpmu_ops->do_rdmsr(msr, msr_content);
> > + return ret;
> >
> > - if ( !is_hvm_vcpu(curr) && vpmu->xenpmu_data &&
> > - (vpmu->xenpmu_data->pmu.pmu_flags & PMU_CACHED) )
> > - {
> > - vpmu_set(vpmu, VPMU_CONTEXT_SAVE);
> > - vpmu->arch_vpmu_ops->arch_vpmu_save(curr);
> > - vpmu_reset(vpmu, VPMU_CONTEXT_SAVE | VPMU_CONTEXT_LOADED);
> > - }
> > - return ret;
> > - }
> > - else
> > + nop:
> > + if ( !is_write )
> > *msr_content = 0;
> >
> > return 0;
> > diff --git a/xen/include/asm-x86/hvm/vpmu.h b/xen/include/asm-x86/hvm/vpmu.h
> > index 642a4b7..63851a7 100644
> > --- a/xen/include/asm-x86/hvm/vpmu.h
> > +++ b/xen/include/asm-x86/hvm/vpmu.h
> > @@ -99,8 +99,8 @@ static inline bool_t vpmu_are_all_set(const struct vpmu_struct *vpmu,
> > }
> >
> > void vpmu_lvtpc_update(uint32_t val);
> > -int vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content, uint64_t supported);
> > -int vpmu_do_rdmsr(unsigned int msr, uint64_t *msr_content);
> > +int vpmu_do_msr(unsigned int msr, uint64_t *msr_content,
> > + uint64_t supported, bool_t is_write);
> > void vpmu_do_interrupt(struct cpu_user_regs *regs);
> > void vpmu_do_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
> > unsigned int *ecx, unsigned int *edx);
> > @@ -110,6 +110,16 @@ void vpmu_save(struct vcpu *v);
> > void vpmu_load(struct vcpu *v);
> > void vpmu_dump(struct vcpu *v);
> >
> > +static inline int vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content,
> > + uint64_t supported)
> > +{
> > + return vpmu_do_msr(msr, &msr_content, supported, 1);
> > +}
> > +static inline int vpmu_do_rdmsr(unsigned int msr, uint64_t *msr_content)
> > +{
> > + return vpmu_do_msr(msr, msr_content, 0, 0);
> > +}
> > +
> > extern int acquire_pmu_ownership(int pmu_ownership);
> > extern void release_pmu_ownership(int pmu_ownership);
> >
> >
>
>
--
Company details: http://ts.fujitsu.com/imprint.html
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2015-03-25 12:23 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-17 14:53 [PATCH v19 00/14] x86/PMU: Xen PMU PV(H) support Boris Ostrovsky
2015-03-17 14:53 ` [PATCH v19 01/14] x86/VPMU: VPMU should not exist when vpmu_initialise() is called Boris Ostrovsky
2015-03-19 8:43 ` Dietmar Hahn
2015-03-17 14:53 ` [PATCH v19 02/14] common/symbols: Export hypervisor symbols to privileged guest Boris Ostrovsky
2015-03-17 14:54 ` [PATCH v19 03/14] x86/VPMU: Add public xenpmu.h Boris Ostrovsky
2015-03-17 14:54 ` [PATCH v19 04/14] x86/VPMU: Make vpmu not HVM-specific Boris Ostrovsky
2015-03-17 14:54 ` [PATCH v19 05/14] x86/VPMU: Interface for setting PMU mode and flags Boris Ostrovsky
2015-03-19 13:12 ` Dietmar Hahn
2015-03-19 13:28 ` Jan Beulich
2015-03-19 13:49 ` Dietmar Hahn
2015-03-24 13:56 ` Jan Beulich
2015-03-17 14:54 ` [PATCH v19 06/14] x86/VPMU: Initialize VPMUs with __initcall Boris Ostrovsky
2015-03-17 14:54 ` [PATCH v19 07/14] x86/VPMU: Initialize PMU for PV(H) guests Boris Ostrovsky
2015-03-24 14:08 ` Jan Beulich
2015-03-24 15:06 ` Boris Ostrovsky
2015-03-17 14:54 ` [PATCH v19 08/14] x86/VPMU: Save VPMU state for PV guests during context switch Boris Ostrovsky
2015-03-24 14:15 ` Jan Beulich
2015-03-17 14:54 ` [PATCH v19 09/14] x86/VPMU: When handling MSR accesses, leave fault injection to callers Boris Ostrovsky
2015-03-17 14:54 ` [PATCH v19 10/14] x86/VPMU: Add support for PMU register handling on PV guests Boris Ostrovsky
2015-03-17 14:54 ` [PATCH v19 11/14] x86/VPMU: Handle PMU interrupts for " Boris Ostrovsky
2015-03-24 14:28 ` Jan Beulich
2015-03-24 15:13 ` Boris Ostrovsky
2015-03-24 15:36 ` Jan Beulich
2015-03-24 15:47 ` Boris Ostrovsky
2015-03-24 16:03 ` Jan Beulich
2015-03-17 14:54 ` [PATCH v19 12/14] x86/VPMU: Merge vpmu_rdmsr and vpmu_wrmsr Boris Ostrovsky
2015-03-25 8:29 ` Dietmar Hahn
2015-03-25 12:23 ` Dietmar Hahn [this message]
2015-03-25 16:52 ` Jan Beulich
2015-03-17 14:54 ` [PATCH v19 13/14] x86/VPMU: Add privileged PMU mode Boris Ostrovsky
2015-03-25 12:25 ` Dietmar Hahn
2015-03-25 16:57 ` Jan Beulich
2015-03-17 14:54 ` [PATCH v19 14/14] x86/VPMU: Move VPMU files up from hvm/ directory Boris Ostrovsky
2015-03-19 14:32 ` [PATCH v19 00/14] x86/PMU: Xen PMU PV(H) support Dietmar Hahn
2015-03-19 16:03 ` Boris Ostrovsky
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=2189557.TCUq0WKC1f@amur \
--to=dietmar.hahn@ts.fujitsu.com \
--cc=Aravind.Gopalakrishnan@amd.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=tim@xen.org \
--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 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.