kvm-s390.c (9ac96d759fa2de2386a4fccab80880f99d1161d2) kvm-s390.c (33d1b2729e409e8327dec2d13a9144dfa76a947c)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * hosting IBM Z kernel virtual machines (s390x)
4 *
5 * Copyright IBM Corp. 2008, 2018
6 *
7 * Author(s): Carsten Otte <cotte@de.ibm.com>
8 * Christian Borntraeger <borntraeger@de.ibm.com>

--- 1026 unchanged lines hidden (view full) ---

1035 break;
1036 default:
1037 ret = -ENXIO;
1038 break;
1039 }
1040 return ret;
1041}
1042
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * hosting IBM Z kernel virtual machines (s390x)
4 *
5 * Copyright IBM Corp. 2008, 2018
6 *
7 * Author(s): Carsten Otte <cotte@de.ibm.com>
8 * Christian Borntraeger <borntraeger@de.ibm.com>

--- 1026 unchanged lines hidden (view full) ---

1035 break;
1036 default:
1037 ret = -ENXIO;
1038 break;
1039 }
1040 return ret;
1041}
1042
1043static void kvm_s390_get_tod_clock_ext(struct kvm *kvm,
1044 struct kvm_s390_vm_tod_clock *gtod)
1043static void kvm_s390_get_tod_clock(struct kvm *kvm,
1044 struct kvm_s390_vm_tod_clock *gtod)
1045{
1046 struct kvm_s390_tod_clock_ext htod;
1047
1048 preempt_disable();
1049
1050 get_tod_clock_ext((char *)&htod);
1051
1052 gtod->tod = htod.tod + kvm->arch.epoch;
1045{
1046 struct kvm_s390_tod_clock_ext htod;
1047
1048 preempt_disable();
1049
1050 get_tod_clock_ext((char *)&htod);
1051
1052 gtod->tod = htod.tod + kvm->arch.epoch;
1053 gtod->epoch_idx = htod.epoch_idx + kvm->arch.epdx;
1053 gtod->epoch_idx = 0;
1054 if (test_kvm_facility(kvm, 139)) {
1055 gtod->epoch_idx = htod.epoch_idx + kvm->arch.epdx;
1056 if (gtod->tod < htod.tod)
1057 gtod->epoch_idx += 1;
1058 }
1054
1059
1055 if (gtod->tod < htod.tod)
1056 gtod->epoch_idx += 1;
1057
1058 preempt_enable();
1059}
1060
1061static int kvm_s390_get_tod_ext(struct kvm *kvm, struct kvm_device_attr *attr)
1062{
1063 struct kvm_s390_vm_tod_clock gtod;
1064
1065 memset(&gtod, 0, sizeof(gtod));
1060 preempt_enable();
1061}
1062
1063static int kvm_s390_get_tod_ext(struct kvm *kvm, struct kvm_device_attr *attr)
1064{
1065 struct kvm_s390_vm_tod_clock gtod;
1066
1067 memset(&gtod, 0, sizeof(gtod));
1066
1067 if (test_kvm_facility(kvm, 139))
1068 kvm_s390_get_tod_clock_ext(kvm, &gtod);
1069 else
1070 gtod.tod = kvm_s390_get_tod_clock_fast(kvm);
1071
1068 kvm_s390_get_tod_clock(kvm, &gtod);
1072 if (copy_to_user((void __user *)attr->addr, &gtod, sizeof(gtod)))
1073 return -EFAULT;
1074
1075 VM_EVENT(kvm, 3, "QUERY: TOD extension: 0x%x, TOD base: 0x%llx",
1076 gtod.epoch_idx, gtod.tod);
1077 return 0;
1078}
1079

--- 3031 unchanged lines hidden ---
1069 if (copy_to_user((void __user *)attr->addr, &gtod, sizeof(gtod)))
1070 return -EFAULT;
1071
1072 VM_EVENT(kvm, 3, "QUERY: TOD extension: 0x%x, TOD base: 0x%llx",
1073 gtod.epoch_idx, gtod.tod);
1074 return 0;
1075}
1076

--- 3031 unchanged lines hidden ---