[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 28/33] s390/kvm: Support for get/set of extended TOD-
From: |
Cornelia Huck |
Subject: |
[Qemu-devel] [PULL 28/33] s390/kvm: Support for get/set of extended TOD-Clock for guest |
Date: |
Fri, 6 Oct 2017 11:59:51 +0200 |
From: "Collin L. Walling" <address@hidden>
Provides an interface for getting and setting the guest's extended
TOD-Clock via a single ioctl to kvm. If the ioctl fails because it
is not support by kvm, then we fall back to the old style of
retrieving the clock via two ioctls.
Signed-off-by: Collin L. Walling <address@hidden>
Reviewed-by: Eric Farman <address@hidden>
Reviewed-by: Claudio Imbrenda <address@hidden>
Signed-off-by: Christian Borntraeger <address@hidden>
[split failure change from epoch index change]
Message-Id: <address@hidden>
Reviewed-by: Thomas Huth <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
[some cosmetic fixes]
---
target/s390x/cpu.c | 26 +++++++++++++++++++-------
target/s390x/kvm-stub.c | 10 ++++++++++
target/s390x/kvm.c | 33 ++++++++++++++++++++++++++++++++-
target/s390x/kvm_s390x.h | 2 ++
4 files changed, 63 insertions(+), 8 deletions(-)
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index f42e28ea25..4e1823a3e0 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -347,22 +347,34 @@ unsigned int s390_cpu_set_state(uint8_t cpu_state,
S390CPU *cpu)
int s390_get_clock(uint8_t *tod_high, uint64_t *tod_low)
{
+ int r = 0;
+
if (kvm_enabled()) {
- return kvm_s390_get_clock(tod_high, tod_low);
+ r = kvm_s390_get_clock_ext(tod_high, tod_low);
+ if (r == -ENXIO) {
+ return kvm_s390_get_clock(tod_high, tod_low);
+ }
+ } else {
+ /* Fixme TCG */
+ *tod_high = 0;
+ *tod_low = 0;
}
- /* Fixme TCG */
- *tod_high = 0;
- *tod_low = 0;
- return 0;
+
+ return r;
}
int s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
{
+ int r = 0;
+
if (kvm_enabled()) {
- return kvm_s390_set_clock(tod_high, tod_low);
+ r = kvm_s390_set_clock_ext(tod_high, tod_low);
+ if (r == -ENXIO) {
+ return kvm_s390_set_clock(tod_high, tod_low);
+ }
}
/* Fixme TCG */
- return 0;
+ return r;
}
int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit)
diff --git a/target/s390x/kvm-stub.c b/target/s390x/kvm-stub.c
index 261e1cdc44..43f02c2d69 100644
--- a/target/s390x/kvm-stub.c
+++ b/target/s390x/kvm-stub.c
@@ -68,11 +68,21 @@ int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_low)
return -ENOSYS;
}
+int kvm_s390_get_clock_ext(uint8_t *tod_high, uint64_t *tod_low)
+{
+ return -ENOSYS;
+}
+
int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
{
return -ENOSYS;
}
+int kvm_s390_set_clock_ext(uint8_t *tod_high, uint64_t *tod_low)
+{
+ return -ENOSYS;
+}
+
void kvm_s390_enable_css_support(S390CPU *cpu)
{
}
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index 7f8c6c4993..d3700fc2c2 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -646,10 +646,26 @@ int kvm_s390_get_clock(uint8_t *tod_high, uint64_t
*tod_low)
return kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attr);
}
-int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
+int kvm_s390_get_clock_ext(uint8_t *tod_high, uint64_t *tod_low)
{
int r;
+ struct kvm_s390_vm_tod_clock gtod;
+ struct kvm_device_attr attr = {
+ .group = KVM_S390_VM_TOD,
+ .attr = KVM_S390_VM_TOD_EXT,
+ .addr = (uint64_t)>od,
+ };
+
+ r = kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attr);
+ *tod_high = gtod.epoch_idx;
+ *tod_low = gtod.tod;
+ return r;
+}
+
+int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
+{
+ int r;
struct kvm_device_attr attr = {
.group = KVM_S390_VM_TOD,
.attr = KVM_S390_VM_TOD_LOW,
@@ -666,6 +682,21 @@ int kvm_s390_set_clock(uint8_t *tod_high, uint64_t
*tod_low)
return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
}
+int kvm_s390_set_clock_ext(uint8_t *tod_high, uint64_t *tod_low)
+{
+ struct kvm_s390_vm_tod_clock gtod = {
+ .epoch_idx = *tod_high,
+ .tod = *tod_low,
+ };
+ struct kvm_device_attr attr = {
+ .group = KVM_S390_VM_TOD,
+ .attr = KVM_S390_VM_TOD_EXT,
+ .addr = (uint64_t)>od,
+ };
+
+ return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
+}
+
/**
* kvm_s390_mem_op:
* @addr: the logical start address in guest memory
diff --git a/target/s390x/kvm_s390x.h b/target/s390x/kvm_s390x.h
index 2d594bd4ee..501fc5aabd 100644
--- a/target/s390x/kvm_s390x.h
+++ b/target/s390x/kvm_s390x.h
@@ -29,7 +29,9 @@ int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu);
int kvm_s390_get_ri(void);
int kvm_s390_get_gs(void);
int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);
+int kvm_s390_get_clock_ext(uint8_t *tod_high, uint64_t *tod_clock);
int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_clock);
+int kvm_s390_set_clock_ext(uint8_t *tod_high, uint64_t *tod_clock);
void kvm_s390_enable_css_support(S390CPU *cpu);
int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch,
int vq, bool assign);
--
2.13.6
- [Qemu-devel] [PULL 17/33] Revert "s390x/ccw: create s390 phb conditionally", (continued)
- [Qemu-devel] [PULL 17/33] Revert "s390x/ccw: create s390 phb conditionally", Cornelia Huck, 2017/10/06
- [Qemu-devel] [PULL 20/33] MAINTAINERS: use KVM s390x maintainers for kvm-stubs.c and kvm_s390x.h, Cornelia Huck, 2017/10/06
- [Qemu-devel] [PULL 21/33] s390x: raise CPU hotplug irq after really hotplugged, Cornelia Huck, 2017/10/06
- [Qemu-devel] [PULL 19/33] s390x/3270: handle writes of arbitrary length, Cornelia Huck, 2017/10/06
- [Qemu-devel] [PULL 22/33] s390x/cpumodel: fix max STFL(E) bit number, Cornelia Huck, 2017/10/06
- [Qemu-devel] [PULL 23/33] target/s390x: get rid of next_core_id, Cornelia Huck, 2017/10/06
- [Qemu-devel] [PULL 24/33] s390x: introduce and use S390_MAX_CPUS, Cornelia Huck, 2017/10/06
- [Qemu-devel] [PULL 27/33] s390x/css: fix css migration compat handling, Cornelia Huck, 2017/10/06
- [Qemu-devel] [PULL 25/33] s390x/tcg: make STFL store into the lowcore, Cornelia Huck, 2017/10/06
- [Qemu-devel] [PULL 26/33] s390x: sort some devices into categories, Cornelia Huck, 2017/10/06
- [Qemu-devel] [PULL 28/33] s390/kvm: Support for get/set of extended TOD-Clock for guest,
Cornelia Huck <=
- [Qemu-devel] [PULL 31/33] s390x/sclp: mark sclp-cpu-hotplug as non-usercreatable, Cornelia Huck, 2017/10/06
- [Qemu-devel] [PULL 29/33] s390/kvm: make TOD setting failures fatal for migration, Cornelia Huck, 2017/10/06
- [Qemu-devel] [PULL 30/33] s390x/sclp: Mark the sclp device with user_creatable = false, Cornelia Huck, 2017/10/06
- [Qemu-devel] [PULL 32/33] s390x/tcg: initialize machine check queue, Cornelia Huck, 2017/10/06
- [Qemu-devel] [PULL 33/33] hw/s390x: Mark the "sclpquiesce" device with user_creatable = false, Cornelia Huck, 2017/10/06
- Re: [Qemu-devel] [PULL 00/33] next batch of s390x patches, Peter Maydell, 2017/10/06