From: Alexander Graf <agraf@suse.de>
To: Scott Wood <scottwood@freescale.com>
Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 3/6] KVM: PPC: booke: Check for MSR[WE] in prepare_to_enter
Date: Mon, 14 Nov 2011 13:13:51 +0000 [thread overview]
Message-ID: <4EC1140F.3000307@suse.de> (raw)
In-Reply-To: <20111109002325.GC6132@schlenkerla.am.freescale.net>
On 11/09/2011 01:23 AM, Scott Wood wrote:
> This prevents us from inappropriately blocking in a KVM_SET_REGS
> ioctl -- the MSR[WE] will take effect when the guest is next entered.
>
> It also causes SRR1[WE] to be set when we enter the guest's interrupt
> handler, which is what e500 hardware is documented to do.
>
> Signed-off-by: Scott Wood<scottwood@freescale.com>
> ---
> arch/powerpc/kvm/booke.c | 28 ++++++++++++++++++----------
> 1 files changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> index feaefc4..557f028 100644
> --- a/arch/powerpc/kvm/booke.c
> +++ b/arch/powerpc/kvm/booke.c
> @@ -124,12 +124,6 @@ void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr)
> vcpu->arch.shared->msr = new_msr;
>
> kvmppc_mmu_msr_notify(vcpu, old_msr);
> -
> - if (vcpu->arch.shared->msr& MSR_WE) {
> - kvm_vcpu_block(vcpu);
> - kvmppc_set_exit_type(vcpu, EMULATED_MTMSRWE_EXITS);
> - };
> -
> kvmppc_vcpu_sync_spe(vcpu);
> }
>
> @@ -288,15 +282,12 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu,
> return allowed;
> }
>
> -/* Check pending exceptions and deliver one, if possible. */
> -void kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu)
> +static void kvmppc_core_check_exceptions(struct kvm_vcpu *vcpu)
> {
> unsigned long *pending =&vcpu->arch.pending_exceptions;
> unsigned long old_pending = vcpu->arch.pending_exceptions;
> unsigned int priority;
>
> - WARN_ON_ONCE(!irqs_disabled());
> -
> priority = __ffs(*pending);
> while (priority<= BOOKE_IRQPRIO_MAX) {
> if (kvmppc_booke_irqprio_deliver(vcpu, priority))
> @@ -314,6 +305,23 @@ void kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu)
> vcpu->arch.shared->int_pending = 0;
> }
>
> +/* Check pending exceptions and deliver one, if possible. */
> +void kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu)
> +{
> + WARN_ON_ONCE(!irqs_disabled());
> +
> + kvmppc_core_check_exceptions(vcpu);
> +
> + if (vcpu->arch.shared->msr& MSR_WE) {
> + local_irq_enable();
> + kvm_vcpu_block(vcpu);
> + local_irq_disable();
Hrm. This specific irq enable/disable part isn't pretty but I can't
think of a cleaner way either. Unless you move it out of the prepare
function, since I don't see a way it could race with an interrupt.
> +
> + kvmppc_set_exit_type(vcpu, EMULATED_MTMSRWE_EXITS);
> + kvmppc_core_check_exceptions(vcpu);
Shouldn't
if (msr & MSR_WE) {
...
}
core_check_exceptions(vcpu);
work just as well?
WARNING: multiple messages have this Message-ID (diff)
From: Alexander Graf <agraf@suse.de>
To: Scott Wood <scottwood@freescale.com>
Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Subject: Re: [PATCH 3/6] KVM: PPC: booke: Check for MSR[WE] in prepare_to_enter
Date: Mon, 14 Nov 2011 14:13:51 +0100 [thread overview]
Message-ID: <4EC1140F.3000307@suse.de> (raw)
In-Reply-To: <20111109002325.GC6132@schlenkerla.am.freescale.net>
On 11/09/2011 01:23 AM, Scott Wood wrote:
> This prevents us from inappropriately blocking in a KVM_SET_REGS
> ioctl -- the MSR[WE] will take effect when the guest is next entered.
>
> It also causes SRR1[WE] to be set when we enter the guest's interrupt
> handler, which is what e500 hardware is documented to do.
>
> Signed-off-by: Scott Wood<scottwood@freescale.com>
> ---
> arch/powerpc/kvm/booke.c | 28 ++++++++++++++++++----------
> 1 files changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> index feaefc4..557f028 100644
> --- a/arch/powerpc/kvm/booke.c
> +++ b/arch/powerpc/kvm/booke.c
> @@ -124,12 +124,6 @@ void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr)
> vcpu->arch.shared->msr = new_msr;
>
> kvmppc_mmu_msr_notify(vcpu, old_msr);
> -
> - if (vcpu->arch.shared->msr& MSR_WE) {
> - kvm_vcpu_block(vcpu);
> - kvmppc_set_exit_type(vcpu, EMULATED_MTMSRWE_EXITS);
> - };
> -
> kvmppc_vcpu_sync_spe(vcpu);
> }
>
> @@ -288,15 +282,12 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu,
> return allowed;
> }
>
> -/* Check pending exceptions and deliver one, if possible. */
> -void kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu)
> +static void kvmppc_core_check_exceptions(struct kvm_vcpu *vcpu)
> {
> unsigned long *pending =&vcpu->arch.pending_exceptions;
> unsigned long old_pending = vcpu->arch.pending_exceptions;
> unsigned int priority;
>
> - WARN_ON_ONCE(!irqs_disabled());
> -
> priority = __ffs(*pending);
> while (priority<= BOOKE_IRQPRIO_MAX) {
> if (kvmppc_booke_irqprio_deliver(vcpu, priority))
> @@ -314,6 +305,23 @@ void kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu)
> vcpu->arch.shared->int_pending = 0;
> }
>
> +/* Check pending exceptions and deliver one, if possible. */
> +void kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu)
> +{
> + WARN_ON_ONCE(!irqs_disabled());
> +
> + kvmppc_core_check_exceptions(vcpu);
> +
> + if (vcpu->arch.shared->msr& MSR_WE) {
> + local_irq_enable();
> + kvm_vcpu_block(vcpu);
> + local_irq_disable();
Hrm. This specific irq enable/disable part isn't pretty but I can't
think of a cleaner way either. Unless you move it out of the prepare
function, since I don't see a way it could race with an interrupt.
> +
> + kvmppc_set_exit_type(vcpu, EMULATED_MTMSRWE_EXITS);
> + kvmppc_core_check_exceptions(vcpu);
Shouldn't
if (msr & MSR_WE) {
...
}
core_check_exceptions(vcpu);
work just as well?
next prev parent reply other threads:[~2011-11-14 13:13 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-09 0:22 [PATCH 0/6] KVM: PPC: mostly booke: race and idle fixes, paravirt Scott Wood
2011-11-09 0:22 ` Scott Wood
2011-11-09 0:23 ` [PATCH 1/6] KVM: PPC: Rename deliver_interrupts to prepare_to_enter Scott Wood
2011-11-09 0:23 ` Scott Wood
2011-11-09 0:23 ` [PATCH 2/6] KVM: PPC: Move prepare_to_enter call site into subarch Scott Wood
2011-11-09 0:23 ` [PATCH 2/6] KVM: PPC: Move prepare_to_enter call site into subarch code Scott Wood
2011-11-09 0:23 ` [PATCH 3/6] KVM: PPC: booke: Check for MSR[WE] in prepare_to_enter Scott Wood
2011-11-09 0:23 ` Scott Wood
2011-11-14 13:13 ` Alexander Graf [this message]
2011-11-14 13:13 ` Alexander Graf
2011-11-14 17:22 ` Scott Wood
2011-11-14 17:22 ` Scott Wood
2011-11-14 18:01 ` Alexander Graf
2011-11-14 18:01 ` Alexander Graf
2011-11-14 18:56 ` Scott Wood
2011-11-14 18:56 ` Scott Wood
2011-11-09 0:23 ` [PATCH 4/6] KVM: PPC: booke: Fix int_pending calculation for MSR[EE] Scott Wood
2011-11-09 0:23 ` [PATCH 4/6] KVM: PPC: booke: Fix int_pending calculation for MSR[EE] paravirt Scott Wood
2011-11-09 0:23 ` [PATCH 5/6] KVM: PPC: booke: Paravirtualize wrtee Scott Wood
2011-11-09 0:23 ` Scott Wood
2011-11-09 0:23 ` [PATCH 6/6] KVM: PPC: Paravirtualize SPRG4-7, ESR, PIR, MASn Scott Wood
2011-11-09 0:23 ` Scott Wood
2011-11-18 13:12 ` [PATCH 0/6] KVM: PPC: mostly booke: race and idle fixes, paravirt Alexander Graf
2011-11-18 13:12 ` Alexander Graf
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=4EC1140F.3000307@suse.de \
--to=agraf@suse.de \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=scottwood@freescale.com \
/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.