aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kvm/book3s_rtas.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-04-17 16:30:26 -0400
committerAlexander Graf <agraf@suse.de>2013-04-26 14:27:30 -0400
commitbc5ad3f3701116e7db57268e6f89010ec714697e (patch)
tree21a00d1213598eab4dc0ae3fb03bb7ba3344185a /arch/powerpc/kvm/book3s_rtas.c
parent8e591cb7204739efa8e15967ea334eb367039dde (diff)
KVM: PPC: Book3S: Add kernel emulation for the XICS interrupt controller
This adds in-kernel emulation of the XICS (eXternal Interrupt Controller Specification) interrupt controller specified by PAPR, for both HV and PR KVM guests. The XICS emulation supports up to 1048560 interrupt sources. Interrupt source numbers below 16 are reserved; 0 is used to mean no interrupt and 2 is used for IPIs. Internally these are represented in blocks of 1024, called ICS (interrupt controller source) entities, but that is not visible to userspace. Each vcpu gets one ICP (interrupt controller presentation) entity, used to store the per-vcpu state such as vcpu priority, pending interrupt state, IPI request, etc. This does not include any API or any way to connect vcpus to their ICP state; that will be added in later patches. This is based on an initial implementation by Michael Ellerman <michael@ellerman.id.au> reworked by Benjamin Herrenschmidt and Paul Mackerras. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org> [agraf: fix typo, add dependency on !KVM_MPIC] Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kvm/book3s_rtas.c')
-rw-r--r--arch/powerpc/kvm/book3s_rtas.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/arch/powerpc/kvm/book3s_rtas.c b/arch/powerpc/kvm/book3s_rtas.c
index 6ad7050eb67d..77f9aa5f4ba5 100644
--- a/arch/powerpc/kvm/book3s_rtas.c
+++ b/arch/powerpc/kvm/book3s_rtas.c
@@ -17,13 +17,65 @@
17#include <asm/hvcall.h> 17#include <asm/hvcall.h>
18#include <asm/rtas.h> 18#include <asm/rtas.h>
19 19
20#ifdef CONFIG_KVM_XICS
21static void kvm_rtas_set_xive(struct kvm_vcpu *vcpu, struct rtas_args *args)
22{
23 u32 irq, server, priority;
24 int rc;
25
26 if (args->nargs != 3 || args->nret != 1) {
27 rc = -3;
28 goto out;
29 }
30
31 irq = args->args[0];
32 server = args->args[1];
33 priority = args->args[2];
34
35 rc = kvmppc_xics_set_xive(vcpu->kvm, irq, server, priority);
36 if (rc)
37 rc = -3;
38out:
39 args->rets[0] = rc;
40}
41
42static void kvm_rtas_get_xive(struct kvm_vcpu *vcpu, struct rtas_args *args)
43{
44 u32 irq, server, priority;
45 int rc;
46
47 if (args->nargs != 1 || args->nret != 3) {
48 rc = -3;
49 goto out;
50 }
51
52 irq = args->args[0];
53
54 server = priority = 0;
55 rc = kvmppc_xics_get_xive(vcpu->kvm, irq, &server, &priority);
56 if (rc) {
57 rc = -3;
58 goto out;
59 }
60
61 args->rets[1] = server;
62 args->rets[2] = priority;
63out:
64 args->rets[0] = rc;
65}
66#endif /* CONFIG_KVM_XICS */
20 67
21struct rtas_handler { 68struct rtas_handler {
22 void (*handler)(struct kvm_vcpu *vcpu, struct rtas_args *args); 69 void (*handler)(struct kvm_vcpu *vcpu, struct rtas_args *args);
23 char *name; 70 char *name;
24}; 71};
25 72
26static struct rtas_handler rtas_handlers[] = { }; 73static struct rtas_handler rtas_handlers[] = {
74#ifdef CONFIG_KVM_XICS
75 { .name = "ibm,set-xive", .handler = kvm_rtas_set_xive },
76 { .name = "ibm,get-xive", .handler = kvm_rtas_get_xive },
77#endif
78};
27 79
28struct rtas_token_definition { 80struct rtas_token_definition {
29 struct list_head list; 81 struct list_head list;