Add helpers for enabling kvm capabilities and convert the existing
s390x and ppc users to use them. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAABAgAGBQJTYP89AAoJEN7Pa5PG8C+vUfMQAKK+UnRTpwWXfZNk1XqdV5Mh enVYA0tAICNLAXDeZy3mWjj5Es2xgNxvAQ1QHAXzaVZqRB6KXwYgko2uadWedHon lZWvuWQfYWiKVQug7AU0+/mlZvSgBJEs4gw6l9Z5Ik0q/7y/8jXjlEqZ9WaaQ+Kg D3JRRqghalmDSmVlhFjNkRSxBO3CjZkeyVs4rCZH97blLaioMkrz/u02wvt15sX5 RX+25bvq9wgjT1NAuYYKfEBtikE7fb8AR1Et3GMEWDYqrgPfMDJft3/L0gMDvDQk qO1BWwXy76PEgxl56fDURZhDfRFsWDLv8j3NaZ+Gu8EkLvOgNNlFHKuEshIIqRII XC48jAiXJlSPo/Nk4DSsN32phLCSAcniwGov0X8R2Q5PxKGL2RNaOGpx/veBj34p 4TVOqEYaC6flYOTSPikFpaEe4C5E6CzFzkaaYJ8yKDaOG0kqkYkxMlbwG+cIUwjK fr5AgwjZS4FpgrsNU1p2/b8rqYB9QYu6PMb8mGOF1zCjvbN4tQwInJO8uri8i78Y +mPZ9nNCcjEmxjwaGIy9PYqZFgkPSe40t7793osP9NJTCp9RHaQTZ2AWNjontsO9 8Pjnqq6WCtcigZKjqSI3Oak61rcCxRqOd2LcLNaWSvvonokl3QtH6yXwxK6ekVfM Eqy1m+/HnpEtZ4ZWVelI =4kuj -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/cohuck/tags/kvm_cap_helpers' into staging Add helpers for enabling kvm capabilities and convert the existing s390x and ppc users to use them. # gpg: Signature made Wed 30 Apr 2014 14:48:45 BST using RSA key ID C6F02FAF # gpg: Can't check signature: public key not found * remotes/cohuck/tags/kvm_cap_helpers: ppc: use kvm_vcpu_enable_cap() s390x: use kvm_vcpu_enable_cap() kvm: add kvm_{vm,vcpu}_enable_cap Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
c090c10dc4
@ -234,13 +234,9 @@ static void kvm_openpic_realize(DeviceState *dev, Error **errp)
|
||||
int kvm_openpic_connect_vcpu(DeviceState *d, CPUState *cs)
|
||||
{
|
||||
KVMOpenPICState *opp = KVM_OPENPIC(d);
|
||||
struct kvm_enable_cap encap = {};
|
||||
|
||||
encap.cap = KVM_CAP_IRQ_MPIC;
|
||||
encap.args[0] = opp->fd;
|
||||
encap.args[1] = kvm_arch_vcpu_id(cs);
|
||||
|
||||
return kvm_vcpu_ioctl(cs, KVM_ENABLE_CAP, &encap);
|
||||
return kvm_vcpu_enable_cap(cs, KVM_CAP_IRQ_MPIC, 0, opp->fd,
|
||||
kvm_arch_vcpu_id(cs));
|
||||
}
|
||||
|
||||
static Property kvm_openpic_properties[] = {
|
||||
|
@ -331,15 +331,11 @@ static void xics_kvm_cpu_setup(XICSState *icp, PowerPCCPU *cpu)
|
||||
|
||||
if (icpkvm->kernel_xics_fd != -1) {
|
||||
int ret;
|
||||
struct kvm_enable_cap xics_enable_cap = {
|
||||
.cap = KVM_CAP_IRQ_XICS,
|
||||
.flags = 0,
|
||||
.args = {icpkvm->kernel_xics_fd, kvm_arch_vcpu_id(cs), 0, 0},
|
||||
};
|
||||
|
||||
ss->cs = cs;
|
||||
|
||||
ret = kvm_vcpu_ioctl(ss->cs, KVM_ENABLE_CAP, &xics_enable_cap);
|
||||
ret = kvm_vcpu_enable_cap(cs, KVM_CAP_IRQ_XICS, 0,
|
||||
icpkvm->kernel_xics_fd, kvm_arch_vcpu_id(cs));
|
||||
if (ret < 0) {
|
||||
error_report("Unable to connect CPU%ld to kernel XICS: %s",
|
||||
kvm_arch_vcpu_id(cs), strerror(errno));
|
||||
|
@ -294,6 +294,36 @@ bool kvm_arch_stop_on_emulation_error(CPUState *cpu);
|
||||
|
||||
int kvm_check_extension(KVMState *s, unsigned int extension);
|
||||
|
||||
#define kvm_vm_enable_cap(s, capability, cap_flags, ...) \
|
||||
({ \
|
||||
struct kvm_enable_cap cap = { \
|
||||
.cap = capability, \
|
||||
.flags = cap_flags, \
|
||||
}; \
|
||||
uint64_t args_tmp[] = { __VA_ARGS__ }; \
|
||||
int i; \
|
||||
for (i = 0; i < ARRAY_SIZE(args_tmp) && \
|
||||
i < ARRAY_SIZE(cap.args); i++) { \
|
||||
cap.args[i] = args_tmp[i]; \
|
||||
} \
|
||||
kvm_vm_ioctl(s, KVM_ENABLE_CAP, &cap); \
|
||||
})
|
||||
|
||||
#define kvm_vcpu_enable_cap(cpu, capability, cap_flags, ...) \
|
||||
({ \
|
||||
struct kvm_enable_cap cap = { \
|
||||
.cap = capability, \
|
||||
.flags = cap_flags, \
|
||||
}; \
|
||||
uint64_t args_tmp[] = { __VA_ARGS__ }; \
|
||||
int i; \
|
||||
for (i = 0; i < ARRAY_SIZE(args_tmp) && \
|
||||
i < ARRAY_SIZE(cap.args); i++) { \
|
||||
cap.args[i] = args_tmp[i]; \
|
||||
} \
|
||||
kvm_vcpu_ioctl(cpu, KVM_ENABLE_CAP, &cap); \
|
||||
})
|
||||
|
||||
uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function,
|
||||
uint32_t index, int reg);
|
||||
|
||||
|
@ -151,7 +151,6 @@ static int kvm_booke206_tlb_init(PowerPCCPU *cpu)
|
||||
CPUState *cs = CPU(cpu);
|
||||
struct kvm_book3e_206_tlb_params params = {};
|
||||
struct kvm_config_tlb cfg = {};
|
||||
struct kvm_enable_cap encap = {};
|
||||
unsigned int entries = 0;
|
||||
int ret, i;
|
||||
|
||||
@ -178,10 +177,7 @@ static int kvm_booke206_tlb_init(PowerPCCPU *cpu)
|
||||
cfg.params = (uintptr_t)¶ms;
|
||||
cfg.mmu_type = KVM_MMU_FSL_BOOKE_NOHV;
|
||||
|
||||
encap.cap = KVM_CAP_SW_TLB;
|
||||
encap.args[0] = (uintptr_t)&cfg;
|
||||
|
||||
ret = kvm_vcpu_ioctl(cs, KVM_ENABLE_CAP, &encap);
|
||||
ret = kvm_vcpu_enable_cap(cs, KVM_CAP_SW_TLB, 0, (uintptr_t)&cfg);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "%s: couldn't enable KVM_CAP_SW_TLB: %s\n",
|
||||
__func__, strerror(-ret));
|
||||
@ -1292,7 +1288,6 @@ int kvmppc_set_tcr(PowerPCCPU *cpu)
|
||||
int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu)
|
||||
{
|
||||
CPUState *cs = CPU(cpu);
|
||||
struct kvm_enable_cap encap = {};
|
||||
int ret;
|
||||
|
||||
if (!kvm_enabled()) {
|
||||
@ -1304,8 +1299,7 @@ int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu)
|
||||
return -1;
|
||||
}
|
||||
|
||||
encap.cap = KVM_CAP_PPC_BOOKE_WATCHDOG;
|
||||
ret = kvm_vcpu_ioctl(cs, KVM_ENABLE_CAP, &encap);
|
||||
ret = kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_BOOKE_WATCHDOG, 0);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "%s: couldn't enable KVM_CAP_PPC_BOOKE_WATCHDOG: %s\n",
|
||||
__func__, strerror(-ret));
|
||||
@ -1505,12 +1499,9 @@ int kvmppc_get_hypercall(CPUPPCState *env, uint8_t *buf, int buf_len)
|
||||
void kvmppc_set_papr(PowerPCCPU *cpu)
|
||||
{
|
||||
CPUState *cs = CPU(cpu);
|
||||
struct kvm_enable_cap cap = {};
|
||||
int ret;
|
||||
|
||||
cap.cap = KVM_CAP_PPC_PAPR;
|
||||
ret = kvm_vcpu_ioctl(cs, KVM_ENABLE_CAP, &cap);
|
||||
|
||||
ret = kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_PAPR, 0);
|
||||
if (ret) {
|
||||
cpu_abort(cs, "This KVM version does not support PAPR\n");
|
||||
}
|
||||
@ -1523,13 +1514,9 @@ void kvmppc_set_papr(PowerPCCPU *cpu)
|
||||
void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
|
||||
{
|
||||
CPUState *cs = CPU(cpu);
|
||||
struct kvm_enable_cap cap = {};
|
||||
int ret;
|
||||
|
||||
cap.cap = KVM_CAP_PPC_EPR;
|
||||
cap.args[0] = mpic_proxy;
|
||||
ret = kvm_vcpu_ioctl(cs, KVM_ENABLE_CAP, &cap);
|
||||
|
||||
ret = kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_EPR, 0, mpic_proxy);
|
||||
if (ret && mpic_proxy) {
|
||||
cpu_abort(cs, "This KVM version does not support EPR\n");
|
||||
}
|
||||
|
@ -929,12 +929,10 @@ void kvm_s390_crw_mchk(S390CPU *cpu)
|
||||
|
||||
void kvm_s390_enable_css_support(S390CPU *cpu)
|
||||
{
|
||||
struct kvm_enable_cap cap = {};
|
||||
int r;
|
||||
|
||||
/* Activate host kernel channel subsystem support. */
|
||||
cap.cap = KVM_CAP_S390_CSS_SUPPORT;
|
||||
r = kvm_vcpu_ioctl(CPU(cpu), KVM_ENABLE_CAP, &cap);
|
||||
r = kvm_vcpu_enable_cap(CPU(cpu), KVM_CAP_S390_CSS_SUPPORT, 0);
|
||||
assert(r == 0);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user