All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: kvm-ppc@vger.kernel.org
Subject: [PATCH 4/5] KVM: PPC: Book3S HV: Implement LPCR[AIL]=3 mode for injected interrupts
Date: Mon, 20 May 2019 00:56:58 +0000	[thread overview]
Message-ID: <20190520005659.18628-4-npiggin@gmail.com> (raw)
In-Reply-To: <20111215120322.GE20629@bloggs.ozlabs.ibm.com>

kvmppc_inject_interrupt does not implement LPCR[AIL]!=0 modes, which
can result in the guest receiving interrupts as if LPCR[AIL]=0
contrary to the ISA.

In practice, Linux guests cope with this deviation, but it should be
fixed.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kvm/book3s_hv_builtin.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c b/arch/powerpc/kvm/book3s_hv_builtin.c
index 5ae7f8359368..2453a085da86 100644
--- a/arch/powerpc/kvm/book3s_hv_builtin.c
+++ b/arch/powerpc/kvm/book3s_hv_builtin.c
@@ -797,6 +797,20 @@ void kvmppc_inject_interrupt_hv(struct kvm_vcpu *vcpu, int vec, u64 srr1_flags)
 		new_msr |= msr & MSR_TS_MASK;
 #endif
 
+#ifdef CONFIG_PPC_BOOK3S_64
+	/*
+	 * LPCR[AIL]=2 deliveries are not supported.
+	 * AIL does not apply to HMI, but it doesn't get delivered to guests.
+	 */
+	if (vec != BOOK3S_INTERRUPT_SYSTEM_RESET &&
+	    vec != BOOK3S_INTERRUPT_MACHINE_CHECK &&
+	    (vcpu->arch.vcore->lpcr & LPCR_AIL) = LPCR_AIL_3 &&
+	    (msr & (MSR_IR|MSR_DR)) = (MSR_IR|MSR_DR) ) {
+		new_msr |= MSR_IR | MSR_DR;
+		new_pc += 0xC000000000004000ULL;
+	}
+#endif
+
 	kvmppc_set_srr0(vcpu, pc);
 	kvmppc_set_srr1(vcpu, (msr & SRR1_MSR_BITS) | srr1_flags);
 	kvmppc_set_pc(vcpu, new_pc);
-- 
2.20.1

  parent reply	other threads:[~2019-05-20  0:56 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-15 12:00 [PATCH 0/5] Make use of hardware reference and change bits in HPT Paul Mackerras
2011-12-15 12:00 ` Paul Mackerras
2011-12-15 12:01 ` [PATCH 1/5] KVM: PPC: Book3S HV: Keep HPTE locked when invalidating Paul Mackerras
2011-12-15 12:01   ` Paul Mackerras
2011-12-15 12:02 ` [PATCH 2/5] KVM: PPC: Book3s HV: Maintain separate guest and host Paul Mackerras
2011-12-15 12:02   ` [PATCH 2/5] KVM: PPC: Book3s HV: Maintain separate guest and host views of R and C bits Paul Mackerras
2011-12-15 12:02 ` [PATCH 3/5] KVM: PPC: Book3S HV: Use the hardware referenced bit for kvm_age_hva Paul Mackerras
2011-12-15 12:02   ` Paul Mackerras
2011-12-15 12:03 ` [PATCH 4/5] KVM: PPC: Book3s HV: Implement get_dirty_log using Paul Mackerras
2011-12-15 12:03   ` [PATCH 4/5] KVM: PPC: Book3s HV: Implement get_dirty_log using hardware changed bit Paul Mackerras
2011-12-23 13:23   ` Alexander Graf
2011-12-23 13:23     ` Alexander Graf
2011-12-23 13:23     ` Alexander Graf
2011-12-25 23:35     ` [PATCH 4/5] KVM: PPC: Book3s HV: Implement get_dirty_log using Paul Mackerras
2011-12-25 23:35       ` [PATCH 4/5] KVM: PPC: Book3s HV: Implement get_dirty_log using hardware changed bit Paul Mackerras
2011-12-25 23:35       ` Paul Mackerras
2011-12-26  5:05       ` [PATCH 4/5] KVM: PPC: Book3s HV: Implement get_dirty_log using Takuya Yoshikawa
2011-12-26  5:05         ` [PATCH 4/5] KVM: PPC: Book3s HV: Implement get_dirty_log using hardware changed bit Takuya Yoshikawa
2011-12-26  5:05         ` Takuya Yoshikawa
2011-12-31  0:44         ` [PATCH 4/5] KVM: PPC: Book3s HV: Implement get_dirty_log using Paul Mackerras
2011-12-31  0:44           ` [PATCH 4/5] KVM: PPC: Book3s HV: Implement get_dirty_log using hardware changed bit Paul Mackerras
2011-12-31  0:44           ` Paul Mackerras
2019-05-20  0:56   ` Nicholas Piggin [this message]
2019-06-17  1:48   ` [PATCH 4/5] KVM: PPC: Book3S HV: Implement LPCR[AIL]=3 mode for injected interrupts Paul Mackerras
2011-12-15 12:04 ` [PATCH 5/5] KVM: PPC: Book3s HV: Implement H_CLEAR_REF and Paul Mackerras
2011-12-15 12:04   ` [PATCH 5/5] KVM: PPC: Book3s HV: Implement H_CLEAR_REF and H_CLEAR_MOD hcalls Paul Mackerras
2011-12-23 13:26   ` Alexander Graf
2011-12-23 13:26     ` Alexander Graf
2011-12-23 13:26     ` Alexander Graf
2011-12-23 13:36 ` [PATCH 0/5] Make use of hardware reference and change bits in HPT Alexander Graf
2011-12-23 13:36   ` 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=20190520005659.18628-4-npiggin@gmail.com \
    --to=npiggin@gmail.com \
    --cc=kvm-ppc@vger.kernel.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.