public inbox for kvm-ppc@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: kvm-ppc@vger.kernel.org
Cc: kvm@vger.kernel.org
Subject: [PATCH 20/56] KVM: PPC: e500mc: add load inst fixup
Date: Thu, 15 Mar 2012 12:10:49 +0000	[thread overview]
Message-ID: <1331813485-14722-21-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1331813485-14722-1-git-send-email-agraf@suse.de>

There's always a chance we're unable to read a guest instruction. The guest
could have its TLB mapped execute-, but not readable, something odd happens
and our TLB gets flushed. So it's a good idea to be prepared for that case
and have a fallback that allows us to fix things up in that case.

Add fixup code that keeps guest code from potentially crashing our host kernel.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/powerpc/kvm/bookehv_interrupts.S |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/kvm/bookehv_interrupts.S b/arch/powerpc/kvm/bookehv_interrupts.S
index 63023ae..e9e7350 100644
--- a/arch/powerpc/kvm/bookehv_interrupts.S
+++ b/arch/powerpc/kvm/bookehv_interrupts.S
@@ -28,6 +28,7 @@
 #include <asm/asm-compat.h>
 #include <asm/asm-offsets.h>
 #include <asm/bitsperlong.h>
+#include <asm/thread_info.h>
 
 #include "../kernel/head_booke.h" /* for THREAD_NORMSAVE() */
 
@@ -171,9 +172,36 @@
 	PPC_STL	r30, VCPU_GPR(r30)(r4)
 	PPC_STL	r31, VCPU_GPR(r31)(r4)
 	mtspr	SPRN_EPLC, r8
+
+	/* disable preemption, so we are sure we hit the fixup handler */
+#ifdef CONFIG_PPC64
+	clrrdi	r8,r1,THREAD_SHIFT
+#else
+	rlwinm	r8,r1,0,0,31-THREAD_SHIFT       /* current thread_info */
+#endif
+	li	r7, 1
+	stw	r7, TI_PREEMPT(r8)
+
 	isync
-	lwepx	r9, 0, r5
+
+	/*
+	 * In case the read goes wrong, we catch it and write an invalid value
+	 * in LAST_INST instead.
+	 */
+1:	lwepx	r9, 0, r5
+2:
+.section .fixup, "ax"
+3:	li	r9, KVM_INST_FETCH_FAILED
+	b	2b
+.previous
+.section __ex_table,"a"
+	PPC_LONG_ALIGN
+	PPC_LONG 1b,3b
+.previous
+
 	mtspr	SPRN_EPLC, r3
+	li	r7, 0
+	stw	r7, TI_PREEMPT(r8)
 	stw	r9, VCPU_LAST_INST(r4)
 	.endif
 
-- 
1.6.0.2


  parent reply	other threads:[~2012-03-15 12:10 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-15 12:10 [PULL 00/56] ppc patch queue 2012-03-15 Alexander Graf
2012-03-15 12:10 ` [PATCH 01/56] KVM: PPC: Book3s_32: Fix compile error Alexander Graf
2012-03-15 12:10 ` [PATCH 02/56] powerpc/booke: Set CPU_FTR_DEBUG_LVL_EXC on 32-bit Alexander Graf
2012-03-15 12:10 ` [PATCH 03/56] powerpc/e500: split CPU_FTRS_ALWAYS/CPU_FTRS_POSSIBLE Alexander Graf
2012-03-15 12:10 ` [PATCH 04/56] KVM: PPC: factor out lpid allocator from book3s_64_mmu_hv Alexander Graf
2012-03-15 12:10 ` [PATCH 05/56] KVM: PPC: booke: add booke-level vcpu load/put Alexander Graf
2012-03-15 12:10 ` [PATCH 06/56] KVM: PPC: booke: Move vm core init/destroy out of booke.c Alexander Graf
2012-03-15 12:10 ` [PATCH 07/56] KVM: PPC: e500: rename e500_tlb.h to e500.h Alexander Graf
2012-03-15 12:10 ` [PATCH 08/56] KVM: PPC: e500: merge <asm/kvm_e500.h> into arch/powerpc/kvm/e500.h Alexander Graf
2012-03-15 12:10 ` [PATCH 09/56] KVM: PPC: e500: clean up arch/powerpc/kvm/e500.h Alexander Graf
2012-03-15 12:10 ` [PATCH 10/56] KVM: PPC: e500: refactor core-specific TLB code Alexander Graf
2012-03-15 12:10 ` [PATCH 11/56] KVM: PPC: e500: Track TLB1 entries with a bitmap Alexander Graf
2012-03-15 12:10 ` [PATCH 12/56] KVM: PPC: e500: emulate tlbilx Alexander Graf
2012-03-15 12:10 ` [PATCH 13/56] powerpc/booke: Provide exception macros with interrupt name Alexander Graf
2012-03-15 12:10 ` [PATCH 14/56] KVM: PPC: booke: category E.HV (GS-mode) support Alexander Graf
2012-03-15 12:10 ` [PATCH 15/56] KVM: PPC: booke: standard PPC floating point support Alexander Graf
2012-03-15 12:10 ` [PATCH 16/56] KVM: PPC: e500mc support Alexander Graf
2012-03-15 12:10 ` [PATCH 17/56] KVM: PPC: e500mc: Add doorbell emulation support Alexander Graf
2012-03-15 12:10 ` [PATCH 18/56] KVM: PPC: e500mc: implicitly set MSR_GS Alexander Graf
2012-03-15 12:10 ` [PATCH 19/56] KVM: PPC: e500mc: Move r1/r2 restoration very early Alexander Graf
2012-03-15 12:10 ` Alexander Graf [this message]
2012-03-15 12:10 ` [PATCH 21/56] KVM: PPC: rename CONFIG_KVM_E500 -> CONFIG_KVM_E500V2 Alexander Graf
2012-03-15 12:10 ` [PATCH 22/56] KVM: PPC: make e500v2 kvm and e500mc cpu mutually exclusive Alexander Graf
2012-03-15 12:10 ` [PATCH 23/56] KVM: PPC: booke: remove leftover debugging Alexander Graf
2012-03-15 12:10 ` [PATCH 24/56] KVM: PPC: booke: deliver program int on emulation failure Alexander Graf
2012-03-15 12:10 ` [PATCH 25/56] KVM: PPC: booke: rework rescheduling checks Alexander Graf
2012-03-15 12:10 ` [PATCH 26/56] KVM: PPC: booke: BOOKE_IRQPRIO_MAX is n+1 Alexander Graf
2012-03-15 12:10 ` [PATCH 27/56] KVM: PPC: bookehv: fix exit timing Alexander Graf
2012-03-15 12:10 ` [PATCH 28/56] KVM: PPC: bookehv: remove negation for CONFIG_64BIT Alexander Graf
2012-03-15 12:10 ` [PATCH 29/56] KVM: PPC: bookehv: remove SET_VCPU Alexander Graf
2012-03-15 12:10 ` [PATCH 30/56] KVM: PPC: bookehv: disable MAS register updates early Alexander Graf
2012-03-15 12:11 ` [PATCH 31/56] KVM: PPC: bookehv: add comment about shadow_msr Alexander Graf
2012-03-15 12:11 ` [PATCH 32/56] KVM: PPC: booke: Readd debug abort code for machine check Alexander Graf
2012-03-15 12:11 ` [PATCH 33/56] KVM: PPC: booke: add GS documentation for program interrupt Alexander Graf
2012-03-15 12:11 ` [PATCH 34/56] KVM: PPC: bookehv: remove unused code Alexander Graf
2012-03-15 12:11 ` [PATCH 35/56] KVM: PPC: e500: fix typo in tlb code Alexander Graf
2012-03-15 12:11 ` [PATCH 36/56] KVM: PPC: booke: Support perfmon interrupts Alexander Graf
2012-03-15 12:11 ` [PATCH 37/56] KVM: PPC: booke: expose good state on irq reinject Alexander Graf
2012-03-15 12:11 ` [PATCH 38/56] KVM: PPC: booke: Reinject performance monitor interrupts Alexander Graf
2012-03-15 12:11 ` [PATCH 39/56] KVM: PPC: Booke: only prepare to enter when we enter Alexander Graf
2012-03-15 12:11 ` [PATCH 40/56] KVM: PPC: Book3s: PR: Add SPAPR H_BULK_REMOVE support Alexander Graf
2012-03-15 12:11 ` [PATCH 41/56] KVM: PPC: Book3S HV: Fix kvm_alloc_linear in case where no linears exist Alexander Graf
2012-03-15 12:11 ` [PATCH 42/56] KVM: PPC: Book3S HV: Save and restore CR in __kvmppc_vcore_entry Alexander Graf
2012-03-15 12:11 ` [PATCH 43/56] KVM: PPC: Save/Restore CR over vcpu_run Alexander Graf
2012-03-15 12:11 ` [PATCH 44/56] KVM: PPC: Book3S HV: Make secondary threads more robust against stray IPIs Alexander Graf
2012-03-15 12:11 ` [PATCH 45/56] KVM: PPC: Book3S HV: Make virtual processor area registration more robust Alexander Graf
2012-03-15 12:11 ` [PATCH 46/56] KVM: PPC: Book3S HV: Report stolen time to guest through dispatch trace log Alexander Graf
2012-03-15 12:11 ` [PATCH 47/56] Restore guest CR after exit timing calculation Alexander Graf
2012-03-15 12:11 ` [PATCH 48/56] KVM: PPC: Book 3S: Fix compilation for !HV configs Alexander Graf
2012-03-15 12:11 ` [PATCH 49/56] KVM: PPC: Work around POWER7 DABR corruption problem Alexander Graf
2012-03-15 12:11 ` [PATCH 50/56] KVM: PPC: Pass EA to updating emulation ops Alexander Graf
2012-03-15 12:11 ` [PATCH 51/56] KVM: PPC: Book3S: Compile fix for ppc32 in HIOR Alexander Graf
2012-03-15 12:11 ` [PATCH 52/56] KVM: PPC: Emulate tw and td instructions Alexander Graf
2012-03-15 12:11 ` [PATCH 53/56] KVM: PPC: Book3s: PR: Add HV traps so we can run in HV=1 mode on p7 Alexander Graf
2012-03-15 12:11 ` [PATCH 54/56] KVM: PPC: Book3S: PR: Fix preemption Alexander Graf
2012-03-15 12:11 ` [PATCH 55/56] KVM: PPC: Ignore unhalt request from kvm_vcpu_block Alexander Graf
2012-03-15 12:11 ` [PATCH 56/56] powerpc/kvm: Fix magic page vs. 32-bit RTAS on ppc64 Alexander Graf
2012-03-20 14:47 ` [PULL 00/56] ppc patch queue 2012-03-15 Avi Kivity

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=1331813485-14722-21-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox