Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e591cb7 authored by Michael Ellerman's avatar Michael Ellerman Committed by Alexander Graf
Browse files

KVM: PPC: Book3S: Add infrastructure to implement kernel-side RTAS calls



For pseries machine emulation, in order to move the interrupt
controller code to the kernel, we need to intercept some RTAS
calls in the kernel itself.  This adds an infrastructure to allow
in-kernel handlers to be registered for RTAS services by name.
A new ioctl, KVM_PPC_RTAS_DEFINE_TOKEN, then allows userspace to
associate token values with those service names.  Then, when the
guest requests an RTAS service with one of those token values, it
will be handled by the relevant in-kernel handler rather than being
passed up to userspace as at present.

Signed-off-by: default avatarMichael Ellerman <michael@ellerman.id.au>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
[agraf: fix warning]
Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
parent 91194919
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -2341,6 +2341,25 @@ and distributor interface, the ioctl must be called after calling
KVM_CREATE_IRQCHIP, but before calling KVM_RUN on any of the VCPUs.  Calling
this ioctl twice for any of the base addresses will return -EEXIST.

4.82 KVM_PPC_RTAS_DEFINE_TOKEN

Capability: KVM_CAP_PPC_RTAS
Architectures: ppc
Type: vm ioctl
Parameters: struct kvm_rtas_token_args
Returns: 0 on success, -1 on error

Defines a token value for a RTAS (Run Time Abstraction Services)
service in order to allow it to be handled in the kernel.  The
argument struct gives the name of the service, which must be the name
of a service that has a kernel-side implementation.  If the token
value is non-zero, it will be associated with that service, and
subsequent RTAS calls by the guest specifying that token will be
handled by the kernel.  If the token value is 0, then any token
associated with the service will be forgotten, and subsequent RTAS
calls by the guest for that service will be passed to userspace to be
handled.


5. The kvm_run structure
------------------------
+3 −0
Original line number Diff line number Diff line
@@ -270,6 +270,9 @@
#define H_SET_MODE		0x31C
#define MAX_HCALL_OPCODE	H_SET_MODE

/* Platform specific hcalls, used by KVM */
#define H_RTAS			0xf000

#ifndef __ASSEMBLY__

/**
+1 −0
Original line number Diff line number Diff line
@@ -259,6 +259,7 @@ struct kvm_arch {
#endif /* CONFIG_KVM_BOOK3S_64_HV */
#ifdef CONFIG_PPC_BOOK3S_64
	struct list_head spapr_tce_tables;
	struct list_head rtas_tokens;
#endif
#ifdef CONFIG_KVM_MPIC
	struct openpic *mpic;
+4 −0
Original line number Diff line number Diff line
@@ -166,6 +166,10 @@ extern int kvm_vm_ioctl_get_htab_fd(struct kvm *kvm, struct kvm_get_htab_fd *);

int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq);

extern int kvm_vm_ioctl_rtas_define_token(struct kvm *kvm, void __user *argp);
extern int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu);
extern void kvmppc_rtas_tokens_free(struct kvm *kvm);

/*
 * Cuts out inst bits with ordering according to spec.
 * That means the leftmost bit is zero. All given bits are included.
+6 −0
Original line number Diff line number Diff line
@@ -324,6 +324,12 @@ struct kvm_allocate_rma {
	__u64 rma_size;
};

/* for KVM_CAP_PPC_RTAS */
struct kvm_rtas_token_args {
	char name[120];
	__u64 token;	/* Use a token of 0 to undefine a mapping */
};

struct kvm_book3e_206_tlb_entry {
	__u32 mas8;
	__u32 mas1;
Loading