| .. | .. |
|---|
| 2 | 2 | /* |
|---|
| 3 | 3 | * definition for kvm on s390 |
|---|
| 4 | 4 | * |
|---|
| 5 | | - * Copyright IBM Corp. 2008, 2009 |
|---|
| 5 | + * Copyright IBM Corp. 2008, 2020 |
|---|
| 6 | 6 | * |
|---|
| 7 | 7 | * Author(s): Carsten Otte <cotte@de.ibm.com> |
|---|
| 8 | 8 | * Christian Borntraeger <borntraeger@de.ibm.com> |
|---|
| .. | .. |
|---|
| 15 | 15 | #include <linux/hrtimer.h> |
|---|
| 16 | 16 | #include <linux/kvm.h> |
|---|
| 17 | 17 | #include <linux/kvm_host.h> |
|---|
| 18 | +#include <linux/lockdep.h> |
|---|
| 18 | 19 | #include <asm/facility.h> |
|---|
| 19 | 20 | #include <asm/processor.h> |
|---|
| 20 | 21 | #include <asm/sclp.h> |
|---|
| .. | .. |
|---|
| 25 | 26 | #define IS_ITDB_VALID(vcpu) ((*(char *)vcpu->arch.sie_block->itdba == TDB_FORMAT1)) |
|---|
| 26 | 27 | |
|---|
| 27 | 28 | extern debug_info_t *kvm_s390_dbf; |
|---|
| 29 | +extern debug_info_t *kvm_s390_dbf_uv; |
|---|
| 30 | + |
|---|
| 31 | +#define KVM_UV_EVENT(d_kvm, d_loglevel, d_string, d_args...)\ |
|---|
| 32 | +do { \ |
|---|
| 33 | + debug_sprintf_event((d_kvm)->arch.dbf, d_loglevel, d_string "\n", \ |
|---|
| 34 | + d_args); \ |
|---|
| 35 | + debug_sprintf_event(kvm_s390_dbf_uv, d_loglevel, \ |
|---|
| 36 | + "%d: " d_string "\n", (d_kvm)->userspace_pid, \ |
|---|
| 37 | + d_args); \ |
|---|
| 38 | +} while (0) |
|---|
| 39 | + |
|---|
| 28 | 40 | #define KVM_EVENT(d_loglevel, d_string, d_args...)\ |
|---|
| 29 | 41 | do { \ |
|---|
| 30 | 42 | debug_sprintf_event(kvm_s390_dbf, d_loglevel, d_string "\n", \ |
|---|
| .. | .. |
|---|
| 67 | 79 | |
|---|
| 68 | 80 | static inline int is_vcpu_idle(struct kvm_vcpu *vcpu) |
|---|
| 69 | 81 | { |
|---|
| 70 | | - return test_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.float_int.idle_mask); |
|---|
| 82 | + return test_bit(kvm_vcpu_get_idx(vcpu), vcpu->kvm->arch.idle_mask); |
|---|
| 71 | 83 | } |
|---|
| 72 | 84 | |
|---|
| 73 | 85 | static inline int kvm_is_ucontrol(struct kvm *kvm) |
|---|
| .. | .. |
|---|
| 196 | 208 | return kvm->arch.user_cpu_state_ctrl != 0; |
|---|
| 197 | 209 | } |
|---|
| 198 | 210 | |
|---|
| 211 | +/* implemented in pv.c */ |
|---|
| 212 | +int kvm_s390_pv_destroy_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc); |
|---|
| 213 | +int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc); |
|---|
| 214 | +int kvm_s390_pv_deinit_vm(struct kvm *kvm, u16 *rc, u16 *rrc); |
|---|
| 215 | +int kvm_s390_pv_init_vm(struct kvm *kvm, u16 *rc, u16 *rrc); |
|---|
| 216 | +int kvm_s390_pv_set_sec_parms(struct kvm *kvm, void *hdr, u64 length, u16 *rc, |
|---|
| 217 | + u16 *rrc); |
|---|
| 218 | +int kvm_s390_pv_unpack(struct kvm *kvm, unsigned long addr, unsigned long size, |
|---|
| 219 | + unsigned long tweak, u16 *rc, u16 *rrc); |
|---|
| 220 | +int kvm_s390_pv_set_cpu_state(struct kvm_vcpu *vcpu, u8 state); |
|---|
| 221 | + |
|---|
| 222 | +static inline u64 kvm_s390_pv_get_handle(struct kvm *kvm) |
|---|
| 223 | +{ |
|---|
| 224 | + return kvm->arch.pv.handle; |
|---|
| 225 | +} |
|---|
| 226 | + |
|---|
| 227 | +static inline u64 kvm_s390_pv_cpu_get_handle(struct kvm_vcpu *vcpu) |
|---|
| 228 | +{ |
|---|
| 229 | + return vcpu->arch.pv.handle; |
|---|
| 230 | +} |
|---|
| 231 | + |
|---|
| 232 | +static inline bool kvm_s390_pv_is_protected(struct kvm *kvm) |
|---|
| 233 | +{ |
|---|
| 234 | + lockdep_assert_held(&kvm->lock); |
|---|
| 235 | + return !!kvm_s390_pv_get_handle(kvm); |
|---|
| 236 | +} |
|---|
| 237 | + |
|---|
| 238 | +static inline bool kvm_s390_pv_cpu_is_protected(struct kvm_vcpu *vcpu) |
|---|
| 239 | +{ |
|---|
| 240 | + lockdep_assert_held(&vcpu->mutex); |
|---|
| 241 | + return !!kvm_s390_pv_cpu_get_handle(vcpu); |
|---|
| 242 | +} |
|---|
| 243 | + |
|---|
| 199 | 244 | /* implemented in interrupt.c */ |
|---|
| 200 | 245 | int kvm_s390_handle_wait(struct kvm_vcpu *vcpu); |
|---|
| 201 | 246 | void kvm_s390_vcpu_wakeup(struct kvm_vcpu *vcpu); |
|---|
| .. | .. |
|---|
| 281 | 326 | int kvm_s390_handle_sigp_pei(struct kvm_vcpu *vcpu); |
|---|
| 282 | 327 | |
|---|
| 283 | 328 | /* implemented in kvm-s390.c */ |
|---|
| 284 | | -void kvm_s390_set_tod_clock(struct kvm *kvm, |
|---|
| 285 | | - const struct kvm_s390_vm_tod_clock *gtod); |
|---|
| 329 | +int kvm_s390_try_set_tod_clock(struct kvm *kvm, const struct kvm_s390_vm_tod_clock *gtod); |
|---|
| 286 | 330 | long kvm_arch_fault_in_page(struct kvm_vcpu *vcpu, gpa_t gpa, int writable); |
|---|
| 287 | 331 | int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long addr); |
|---|
| 288 | 332 | int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr); |
|---|
| 289 | | -void kvm_s390_vcpu_start(struct kvm_vcpu *vcpu); |
|---|
| 290 | | -void kvm_s390_vcpu_stop(struct kvm_vcpu *vcpu); |
|---|
| 333 | +int kvm_s390_vcpu_start(struct kvm_vcpu *vcpu); |
|---|
| 334 | +int kvm_s390_vcpu_stop(struct kvm_vcpu *vcpu); |
|---|
| 291 | 335 | void kvm_s390_vcpu_block(struct kvm_vcpu *vcpu); |
|---|
| 292 | 336 | void kvm_s390_vcpu_unblock(struct kvm_vcpu *vcpu); |
|---|
| 337 | +bool kvm_s390_vcpu_sie_inhibited(struct kvm_vcpu *vcpu); |
|---|
| 293 | 338 | void exit_sie(struct kvm_vcpu *vcpu); |
|---|
| 294 | 339 | void kvm_s390_sync_request(int req, struct kvm_vcpu *vcpu); |
|---|
| 295 | 340 | int kvm_s390_vcpu_setup_cmma(struct kvm_vcpu *vcpu); |
|---|
| .. | .. |
|---|
| 381 | 426 | void kvm_s390_gisa_init(struct kvm *kvm); |
|---|
| 382 | 427 | void kvm_s390_gisa_clear(struct kvm *kvm); |
|---|
| 383 | 428 | void kvm_s390_gisa_destroy(struct kvm *kvm); |
|---|
| 429 | +int kvm_s390_gib_init(u8 nisc); |
|---|
| 430 | +void kvm_s390_gib_destroy(void); |
|---|
| 384 | 431 | |
|---|
| 385 | 432 | /* implemented in guestdbg.c */ |
|---|
| 386 | 433 | void kvm_s390_backup_guest_per_regs(struct kvm_vcpu *vcpu); |
|---|