Patchwork [RFC,05/10] KVM: PPC: Book3S HV: Add handler for HV facility unavailable

login
register
mail settings
Submitter Paul Mackerras
Date Sept. 6, 2013, 3:54 a.m.
Message ID <20130906035439.GR29710@iris.ozlabs.ibm.com>
Download mbox | patch
Permalink /patch/273045/
State New
Headers show

Comments

Paul Mackerras - Sept. 6, 2013, 3:54 a.m.
From: Michael Ellerman <michael@ellerman.id.au>

At present this should never happen, since the host kernel sets
HFSCR to allow access to all facilities.  It's better to be prepared
to handle it cleanly if it does ever happen, though.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
---
 arch/powerpc/include/asm/kvm_asm.h | 1 +
 arch/powerpc/kvm/book3s_hv.c       | 9 +++++++++
 2 files changed, 10 insertions(+)
Alexander Graf - Nov. 4, 2013, 12:48 p.m.
On 06.09.2013, at 05:54, Paul Mackerras <paulus@samba.org> wrote:

> From: Michael Ellerman <michael@ellerman.id.au>
> 
> At present this should never happen, since the host kernel sets
> HFSCR to allow access to all facilities.  It's better to be prepared
> to handle it cleanly if it does ever happen, though.
> 
> Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
> Signed-off-by: Paul Mackerras <paulus@samba.org>
> ---
> arch/powerpc/include/asm/kvm_asm.h | 1 +
> arch/powerpc/kvm/book3s_hv.c       | 9 +++++++++
> 2 files changed, 10 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/kvm_asm.h b/arch/powerpc/include/asm/kvm_asm.h
> index 851bac7..f6401eb 100644
> --- a/arch/powerpc/include/asm/kvm_asm.h
> +++ b/arch/powerpc/include/asm/kvm_asm.h
> @@ -99,6 +99,7 @@
> #define BOOK3S_INTERRUPT_PERFMON	0xf00
> #define BOOK3S_INTERRUPT_ALTIVEC	0xf20
> #define BOOK3S_INTERRUPT_VSX		0xf40
> +#define BOOK3S_INTERRUPT_H_FAC_UNAVAIL	0xf80
> 
> #define BOOK3S_IRQPRIO_SYSTEM_RESET		0
> #define BOOK3S_IRQPRIO_DATA_SEGMENT		1
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 724daa5..da8619e 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -704,6 +704,15 @@ static int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
> 		kvmppc_core_queue_program(vcpu, 0x80000);
> 		r = RESUME_GUEST;
> 		break;
> +	/*
> +	 * This occurs if the guest (kernel or userspace), does something that
> +	 * is prohibited by HFSCR.  We just generate a program interrupt to
> +	 * the guest.
> +	 */
> +	case BOOK3S_INTERRUPT_H_FAC_UNAVAIL:
> +		kvmppc_core_queue_program(vcpu, 0x80000);

Would be nice to have a name for that bit.


Alex

> +		r = RESUME_GUEST;
> +		break;
> 	default:
> 		kvmppc_dump_regs(vcpu);
> 		printk(KERN_EMERG "trap=0x%x | pc=0x%lx | msr=0x%llx\n",
> -- 
> 1.8.4.rc3
> 

--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/arch/powerpc/include/asm/kvm_asm.h b/arch/powerpc/include/asm/kvm_asm.h
index 851bac7..f6401eb 100644
--- a/arch/powerpc/include/asm/kvm_asm.h
+++ b/arch/powerpc/include/asm/kvm_asm.h
@@ -99,6 +99,7 @@ 
 #define BOOK3S_INTERRUPT_PERFMON	0xf00
 #define BOOK3S_INTERRUPT_ALTIVEC	0xf20
 #define BOOK3S_INTERRUPT_VSX		0xf40
+#define BOOK3S_INTERRUPT_H_FAC_UNAVAIL	0xf80
 
 #define BOOK3S_IRQPRIO_SYSTEM_RESET		0
 #define BOOK3S_IRQPRIO_DATA_SEGMENT		1
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 724daa5..da8619e 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -704,6 +704,15 @@  static int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
 		kvmppc_core_queue_program(vcpu, 0x80000);
 		r = RESUME_GUEST;
 		break;
+	/*
+	 * This occurs if the guest (kernel or userspace), does something that
+	 * is prohibited by HFSCR.  We just generate a program interrupt to
+	 * the guest.
+	 */
+	case BOOK3S_INTERRUPT_H_FAC_UNAVAIL:
+		kvmppc_core_queue_program(vcpu, 0x80000);
+		r = RESUME_GUEST;
+		break;
 	default:
 		kvmppc_dump_regs(vcpu);
 		printk(KERN_EMERG "trap=0x%x | pc=0x%lx | msr=0x%llx\n",