summaryrefslogtreecommitdiffstats
path: root/target/s390x/kvm.c
diff options
context:
space:
mode:
Diffstat (limited to 'target/s390x/kvm.c')
-rw-r--r--target/s390x/kvm.c76
1 files changed, 54 insertions, 22 deletions
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index c4c5791d27..d07763ff2c 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -29,6 +29,8 @@
#include "qemu-common.h"
#include "cpu.h"
+#include "internal.h"
+#include "kvm_s390x.h"
#include "qemu/error-report.h"
#include "qemu/timer.h"
#include "sysemu/sysemu.h"
@@ -145,7 +147,7 @@ static int active_cmma;
static void *legacy_s390_alloc(size_t size, uint64_t *align);
-static int kvm_s390_query_mem_limit(KVMState *s, uint64_t *memory_limit)
+static int kvm_s390_query_mem_limit(uint64_t *memory_limit)
{
struct kvm_device_attr attr = {
.group = KVM_S390_VM_MEM_CTRL,
@@ -153,10 +155,10 @@ static int kvm_s390_query_mem_limit(KVMState *s, uint64_t *memory_limit)
.addr = (uint64_t) memory_limit,
};
- return kvm_vm_ioctl(s, KVM_GET_DEVICE_ATTR, &attr);
+ return kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attr);
}
-int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit, uint64_t *hw_limit)
+int kvm_s390_set_mem_limit(uint64_t new_limit, uint64_t *hw_limit)
{
int rc;
@@ -166,18 +168,18 @@ int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit, uint64_t *hw_limit)
.addr = (uint64_t) &new_limit,
};
- if (!kvm_vm_check_mem_attr(s, KVM_S390_VM_MEM_LIMIT_SIZE)) {
+ if (!kvm_vm_check_mem_attr(kvm_state, KVM_S390_VM_MEM_LIMIT_SIZE)) {
return 0;
}
- rc = kvm_s390_query_mem_limit(s, hw_limit);
+ rc = kvm_s390_query_mem_limit(hw_limit);
if (rc) {
return rc;
} else if (*hw_limit < new_limit) {
return -E2BIG;
}
- return kvm_vm_ioctl(s, KVM_SET_DEVICE_ATTR, &attr);
+ return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
}
int kvm_s390_cmma_active(void)
@@ -1191,7 +1193,11 @@ static int kvm_clp_service_call(S390CPU *cpu, struct kvm_run *run)
{
uint8_t r2 = (run->s390_sieic.ipb & 0x000f0000) >> 16;
- return clp_service_call(cpu, r2);
+ if (s390_has_feat(S390_FEAT_ZPCI)) {
+ return clp_service_call(cpu, r2);
+ } else {
+ return -1;
+ }
}
static int kvm_pcilg_service_call(S390CPU *cpu, struct kvm_run *run)
@@ -1199,7 +1205,11 @@ static int kvm_pcilg_service_call(S390CPU *cpu, struct kvm_run *run)
uint8_t r1 = (run->s390_sieic.ipb & 0x00f00000) >> 20;
uint8_t r2 = (run->s390_sieic.ipb & 0x000f0000) >> 16;
- return pcilg_service_call(cpu, r1, r2);
+ if (s390_has_feat(S390_FEAT_ZPCI)) {
+ return pcilg_service_call(cpu, r1, r2);
+ } else {
+ return -1;
+ }
}
static int kvm_pcistg_service_call(S390CPU *cpu, struct kvm_run *run)
@@ -1207,7 +1217,11 @@ static int kvm_pcistg_service_call(S390CPU *cpu, struct kvm_run *run)
uint8_t r1 = (run->s390_sieic.ipb & 0x00f00000) >> 20;
uint8_t r2 = (run->s390_sieic.ipb & 0x000f0000) >> 16;
- return pcistg_service_call(cpu, r1, r2);
+ if (s390_has_feat(S390_FEAT_ZPCI)) {
+ return pcistg_service_call(cpu, r1, r2);
+ } else {
+ return -1;
+ }
}
static int kvm_stpcifc_service_call(S390CPU *cpu, struct kvm_run *run)
@@ -1216,10 +1230,14 @@ static int kvm_stpcifc_service_call(S390CPU *cpu, struct kvm_run *run)
uint64_t fiba;
uint8_t ar;
- cpu_synchronize_state(CPU(cpu));
- fiba = get_base_disp_rxy(cpu, run, &ar);
+ if (s390_has_feat(S390_FEAT_ZPCI)) {
+ cpu_synchronize_state(CPU(cpu));
+ fiba = get_base_disp_rxy(cpu, run, &ar);
- return stpcifc_service_call(cpu, r1, fiba, ar);
+ return stpcifc_service_call(cpu, r1, fiba, ar);
+ } else {
+ return -1;
+ }
}
static int kvm_sic_service_call(S390CPU *cpu, struct kvm_run *run)
@@ -1247,7 +1265,11 @@ static int kvm_rpcit_service_call(S390CPU *cpu, struct kvm_run *run)
uint8_t r1 = (run->s390_sieic.ipb & 0x00f00000) >> 20;
uint8_t r2 = (run->s390_sieic.ipb & 0x000f0000) >> 16;
- return rpcit_service_call(cpu, r1, r2);
+ if (s390_has_feat(S390_FEAT_ZPCI)) {
+ return rpcit_service_call(cpu, r1, r2);
+ } else {
+ return -1;
+ }
}
static int kvm_pcistb_service_call(S390CPU *cpu, struct kvm_run *run)
@@ -1257,10 +1279,14 @@ static int kvm_pcistb_service_call(S390CPU *cpu, struct kvm_run *run)
uint64_t gaddr;
uint8_t ar;
- cpu_synchronize_state(CPU(cpu));
- gaddr = get_base_disp_rsy(cpu, run, &ar);
+ if (s390_has_feat(S390_FEAT_ZPCI)) {
+ cpu_synchronize_state(CPU(cpu));
+ gaddr = get_base_disp_rsy(cpu, run, &ar);
- return pcistb_service_call(cpu, r1, r3, gaddr, ar);
+ return pcistb_service_call(cpu, r1, r3, gaddr, ar);
+ } else {
+ return -1;
+ }
}
static int kvm_mpcifc_service_call(S390CPU *cpu, struct kvm_run *run)
@@ -1269,10 +1295,14 @@ static int kvm_mpcifc_service_call(S390CPU *cpu, struct kvm_run *run)
uint64_t fiba;
uint8_t ar;
- cpu_synchronize_state(CPU(cpu));
- fiba = get_base_disp_rxy(cpu, run, &ar);
+ if (s390_has_feat(S390_FEAT_ZPCI)) {
+ cpu_synchronize_state(CPU(cpu));
+ fiba = get_base_disp_rxy(cpu, run, &ar);
- return mpcifc_service_call(cpu, r1, fiba, ar);
+ return mpcifc_service_call(cpu, r1, fiba, ar);
+ } else {
+ return -1;
+ }
}
static int handle_b9(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)
@@ -2289,9 +2319,9 @@ int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch,
return kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD, &kick);
}
-int kvm_s390_get_memslot_count(KVMState *s)
+int kvm_s390_get_memslot_count(void)
{
- return kvm_check_extension(s, KVM_CAP_NR_MEMSLOTS);
+ return kvm_check_extension(kvm_state, KVM_CAP_NR_MEMSLOTS);
}
int kvm_s390_get_ri(void)
@@ -2662,7 +2692,9 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp)
}
/* We emulate a zPCI bus and AEN, therefore we don't need HW support */
- set_bit(S390_FEAT_ZPCI, model->features);
+ if (pci_available) {
+ set_bit(S390_FEAT_ZPCI, model->features);
+ }
set_bit(S390_FEAT_ADAPTER_EVENT_NOTIFICATION, model->features);
if (s390_known_cpu_type(cpu_type)) {