From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: keir@xen.org, jbeulich@suse.com, xen-devel@lists.xen.org
Subject: Re: [PATCH for 4.5] x86/VPMU: Clear last_vcpu when destroying VPMU
Date: Sat, 13 Dec 2014 14:08:08 -0500 [thread overview]
Message-ID: <20141213190808.GA2842@laptop.dumpdata.com> (raw)
In-Reply-To: <1418419248-2863-1-git-send-email-boris.ostrovsky@oracle.com>
On Fri, Dec 12, 2014 at 04:20:48PM -0500, Boris Ostrovsky wrote:
> We need to make sure that last_vcpu is not pointing to VCPU whose
> VPMU is being destroyed. Otherwise we may try dereference it in
> the future, when VCPU is gone.
>
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Release-Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> ---
> xen/arch/x86/hvm/vpmu.c | 22 ++++++++++++++++++++++
> 1 files changed, 22 insertions(+), 0 deletions(-)
>
> This needs to be backported to 4.3 and 4.4 as well
>
> diff --git a/xen/arch/x86/hvm/vpmu.c b/xen/arch/x86/hvm/vpmu.c
> index 1df74c2..6d39680 100644
> --- a/xen/arch/x86/hvm/vpmu.c
> +++ b/xen/arch/x86/hvm/vpmu.c
> @@ -247,10 +247,32 @@ void vpmu_initialise(struct vcpu *v)
> }
> }
>
> +static void vpmu_clear_last(void *arg)
> +{
> + struct vcpu *v = (struct vcpu *)arg;
> +
> + if ( this_cpu(last_vcpu) == v )
> + this_cpu(last_vcpu) = NULL;
> +}
> +
> void vpmu_destroy(struct vcpu *v)
> {
> struct vpmu_struct *vpmu = vcpu_vpmu(v);
>
> + if ( vpmu_is_set(vpmu, VPMU_CONTEXT_ALLOCATED) )
> + {
> + /* Need to clear last_vcpu in case it points to v */
> + if ( vpmu->last_pcpu != smp_processor_id() )
> + on_selected_cpus(cpumask_of(vpmu->last_pcpu),
> + vpmu_clear_last, (void *)v, 1);
> + else
> + {
> + local_irq_disable();
> + vpmu_clear_last((void *)v);
> + local_irq_enable();
> + }
> + }
> +
> if ( vpmu->arch_vpmu_ops && vpmu->arch_vpmu_ops->arch_vpmu_destroy )
> vpmu->arch_vpmu_ops->arch_vpmu_destroy(v);
> }
> --
> 1.7.1
>
next prev parent reply other threads:[~2014-12-13 19:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-12 21:20 [PATCH for 4.5] x86/VPMU: Clear last_vcpu when destroying VPMU Boris Ostrovsky
2014-12-13 19:08 ` Konrad Rzeszutek Wilk [this message]
2014-12-13 20:51 ` Boris Ostrovsky
2014-12-15 10:07 ` Jan Beulich
2014-12-15 17:15 ` Boris Ostrovsky
2014-12-16 8:07 ` 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=20141213190808.GA2842@laptop.dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=boris.ostrovsky@oracle.com \
--cc=jbeulich@suse.com \
--cc=keir@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.