Merge tag 'kvm-s390-next-5.15-1' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / arch / s390 / kvm / kvm-s390.c
index e144c80..1053c14 100644 (file)
 #define VCPU_IRQS_MAX_BUF (sizeof(struct kvm_s390_irq) * \
                           (KVM_MAX_VCPUS + LOCAL_IRQS))
 
-struct kvm_stats_debugfs_item debugfs_entries[] = {
-       VCPU_STAT("userspace_handled", exit_userspace),
-       VCPU_STAT("exit_null", exit_null),
-       VCPU_STAT("pfault_sync", pfault_sync),
-       VCPU_STAT("exit_validity", exit_validity),
-       VCPU_STAT("exit_stop_request", exit_stop_request),
-       VCPU_STAT("exit_external_request", exit_external_request),
-       VCPU_STAT("exit_io_request", exit_io_request),
-       VCPU_STAT("exit_external_interrupt", exit_external_interrupt),
-       VCPU_STAT("exit_instruction", exit_instruction),
-       VCPU_STAT("exit_pei", exit_pei),
-       VCPU_STAT("exit_program_interruption", exit_program_interruption),
-       VCPU_STAT("exit_instr_and_program_int", exit_instr_and_program),
-       VCPU_STAT("exit_operation_exception", exit_operation_exception),
-       VCPU_STAT("halt_successful_poll", halt_successful_poll),
-       VCPU_STAT("halt_attempted_poll", halt_attempted_poll),
-       VCPU_STAT("halt_poll_invalid", halt_poll_invalid),
-       VCPU_STAT("halt_no_poll_steal", halt_no_poll_steal),
-       VCPU_STAT("halt_wakeup", halt_wakeup),
-       VCPU_STAT("halt_poll_success_ns", halt_poll_success_ns),
-       VCPU_STAT("halt_poll_fail_ns", halt_poll_fail_ns),
-       VCPU_STAT("instruction_lctlg", instruction_lctlg),
-       VCPU_STAT("instruction_lctl", instruction_lctl),
-       VCPU_STAT("instruction_stctl", instruction_stctl),
-       VCPU_STAT("instruction_stctg", instruction_stctg),
-       VCPU_STAT("deliver_ckc", deliver_ckc),
-       VCPU_STAT("deliver_cputm", deliver_cputm),
-       VCPU_STAT("deliver_emergency_signal", deliver_emergency_signal),
-       VCPU_STAT("deliver_external_call", deliver_external_call),
-       VCPU_STAT("deliver_service_signal", deliver_service_signal),
-       VCPU_STAT("deliver_virtio", deliver_virtio),
-       VCPU_STAT("deliver_stop_signal", deliver_stop_signal),
-       VCPU_STAT("deliver_prefix_signal", deliver_prefix_signal),
-       VCPU_STAT("deliver_restart_signal", deliver_restart_signal),
-       VCPU_STAT("deliver_program", deliver_program),
-       VCPU_STAT("deliver_io", deliver_io),
-       VCPU_STAT("deliver_machine_check", deliver_machine_check),
-       VCPU_STAT("exit_wait_state", exit_wait_state),
-       VCPU_STAT("inject_ckc", inject_ckc),
-       VCPU_STAT("inject_cputm", inject_cputm),
-       VCPU_STAT("inject_external_call", inject_external_call),
-       VM_STAT("inject_float_mchk", inject_float_mchk),
-       VCPU_STAT("inject_emergency_signal", inject_emergency_signal),
-       VM_STAT("inject_io", inject_io),
-       VCPU_STAT("inject_mchk", inject_mchk),
-       VM_STAT("inject_pfault_done", inject_pfault_done),
-       VCPU_STAT("inject_program", inject_program),
-       VCPU_STAT("inject_restart", inject_restart),
-       VM_STAT("inject_service_signal", inject_service_signal),
-       VCPU_STAT("inject_set_prefix", inject_set_prefix),
-       VCPU_STAT("inject_stop_signal", inject_stop_signal),
-       VCPU_STAT("inject_pfault_init", inject_pfault_init),
-       VM_STAT("inject_virtio", inject_virtio),
-       VCPU_STAT("instruction_epsw", instruction_epsw),
-       VCPU_STAT("instruction_gs", instruction_gs),
-       VCPU_STAT("instruction_io_other", instruction_io_other),
-       VCPU_STAT("instruction_lpsw", instruction_lpsw),
-       VCPU_STAT("instruction_lpswe", instruction_lpswe),
-       VCPU_STAT("instruction_pfmf", instruction_pfmf),
-       VCPU_STAT("instruction_ptff", instruction_ptff),
-       VCPU_STAT("instruction_stidp", instruction_stidp),
-       VCPU_STAT("instruction_sck", instruction_sck),
-       VCPU_STAT("instruction_sckpf", instruction_sckpf),
-       VCPU_STAT("instruction_spx", instruction_spx),
-       VCPU_STAT("instruction_stpx", instruction_stpx),
-       VCPU_STAT("instruction_stap", instruction_stap),
-       VCPU_STAT("instruction_iske", instruction_iske),
-       VCPU_STAT("instruction_ri", instruction_ri),
-       VCPU_STAT("instruction_rrbe", instruction_rrbe),
-       VCPU_STAT("instruction_sske", instruction_sske),
-       VCPU_STAT("instruction_ipte_interlock", instruction_ipte_interlock),
-       VCPU_STAT("instruction_essa", instruction_essa),
-       VCPU_STAT("instruction_stsi", instruction_stsi),
-       VCPU_STAT("instruction_stfl", instruction_stfl),
-       VCPU_STAT("instruction_tb", instruction_tb),
-       VCPU_STAT("instruction_tpi", instruction_tpi),
-       VCPU_STAT("instruction_tprot", instruction_tprot),
-       VCPU_STAT("instruction_tsch", instruction_tsch),
-       VCPU_STAT("instruction_sthyi", instruction_sthyi),
-       VCPU_STAT("instruction_sie", instruction_sie),
-       VCPU_STAT("instruction_sigp_sense", instruction_sigp_sense),
-       VCPU_STAT("instruction_sigp_sense_running", instruction_sigp_sense_running),
-       VCPU_STAT("instruction_sigp_external_call", instruction_sigp_external_call),
-       VCPU_STAT("instruction_sigp_emergency", instruction_sigp_emergency),
-       VCPU_STAT("instruction_sigp_cond_emergency", instruction_sigp_cond_emergency),
-       VCPU_STAT("instruction_sigp_start", instruction_sigp_start),
-       VCPU_STAT("instruction_sigp_stop", instruction_sigp_stop),
-       VCPU_STAT("instruction_sigp_stop_store_status", instruction_sigp_stop_store_status),
-       VCPU_STAT("instruction_sigp_store_status", instruction_sigp_store_status),
-       VCPU_STAT("instruction_sigp_store_adtl_status", instruction_sigp_store_adtl_status),
-       VCPU_STAT("instruction_sigp_set_arch", instruction_sigp_arch),
-       VCPU_STAT("instruction_sigp_set_prefix", instruction_sigp_prefix),
-       VCPU_STAT("instruction_sigp_restart", instruction_sigp_restart),
-       VCPU_STAT("instruction_sigp_cpu_reset", instruction_sigp_cpu_reset),
-       VCPU_STAT("instruction_sigp_init_cpu_reset", instruction_sigp_init_cpu_reset),
-       VCPU_STAT("instruction_sigp_unknown", instruction_sigp_unknown),
-       VCPU_STAT("instruction_diag_10", diagnose_10),
-       VCPU_STAT("instruction_diag_44", diagnose_44),
-       VCPU_STAT("instruction_diag_9c", diagnose_9c),
-       VCPU_STAT("diag_9c_ignored", diagnose_9c_ignored),
-       VCPU_STAT("diag_9c_forward", diagnose_9c_forward),
-       VCPU_STAT("instruction_diag_258", diagnose_258),
-       VCPU_STAT("instruction_diag_308", diagnose_308),
-       VCPU_STAT("instruction_diag_500", diagnose_500),
-       VCPU_STAT("instruction_diag_other", diagnose_other),
-       { NULL }
+const struct _kvm_stats_desc kvm_vm_stats_desc[] = {
+       KVM_GENERIC_VM_STATS(),
+       STATS_DESC_COUNTER(VM, inject_io),
+       STATS_DESC_COUNTER(VM, inject_float_mchk),
+       STATS_DESC_COUNTER(VM, inject_pfault_done),
+       STATS_DESC_COUNTER(VM, inject_service_signal),
+       STATS_DESC_COUNTER(VM, inject_virtio)
+};
+
+const struct kvm_stats_header kvm_vm_stats_header = {
+       .name_size = KVM_STATS_NAME_SIZE,
+       .num_desc = ARRAY_SIZE(kvm_vm_stats_desc),
+       .id_offset = sizeof(struct kvm_stats_header),
+       .desc_offset = sizeof(struct kvm_stats_header) + KVM_STATS_NAME_SIZE,
+       .data_offset = sizeof(struct kvm_stats_header) + KVM_STATS_NAME_SIZE +
+                      sizeof(kvm_vm_stats_desc),
+};
+
+const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {
+       KVM_GENERIC_VCPU_STATS(),
+       STATS_DESC_COUNTER(VCPU, exit_userspace),
+       STATS_DESC_COUNTER(VCPU, exit_null),
+       STATS_DESC_COUNTER(VCPU, exit_external_request),
+       STATS_DESC_COUNTER(VCPU, exit_io_request),
+       STATS_DESC_COUNTER(VCPU, exit_external_interrupt),
+       STATS_DESC_COUNTER(VCPU, exit_stop_request),
+       STATS_DESC_COUNTER(VCPU, exit_validity),
+       STATS_DESC_COUNTER(VCPU, exit_instruction),
+       STATS_DESC_COUNTER(VCPU, exit_pei),
+       STATS_DESC_COUNTER(VCPU, halt_no_poll_steal),
+       STATS_DESC_COUNTER(VCPU, instruction_lctl),
+       STATS_DESC_COUNTER(VCPU, instruction_lctlg),
+       STATS_DESC_COUNTER(VCPU, instruction_stctl),
+       STATS_DESC_COUNTER(VCPU, instruction_stctg),
+       STATS_DESC_COUNTER(VCPU, exit_program_interruption),
+       STATS_DESC_COUNTER(VCPU, exit_instr_and_program),
+       STATS_DESC_COUNTER(VCPU, exit_operation_exception),
+       STATS_DESC_COUNTER(VCPU, deliver_ckc),
+       STATS_DESC_COUNTER(VCPU, deliver_cputm),
+       STATS_DESC_COUNTER(VCPU, deliver_external_call),
+       STATS_DESC_COUNTER(VCPU, deliver_emergency_signal),
+       STATS_DESC_COUNTER(VCPU, deliver_service_signal),
+       STATS_DESC_COUNTER(VCPU, deliver_virtio),
+       STATS_DESC_COUNTER(VCPU, deliver_stop_signal),
+       STATS_DESC_COUNTER(VCPU, deliver_prefix_signal),
+       STATS_DESC_COUNTER(VCPU, deliver_restart_signal),
+       STATS_DESC_COUNTER(VCPU, deliver_program),
+       STATS_DESC_COUNTER(VCPU, deliver_io),
+       STATS_DESC_COUNTER(VCPU, deliver_machine_check),
+       STATS_DESC_COUNTER(VCPU, exit_wait_state),
+       STATS_DESC_COUNTER(VCPU, inject_ckc),
+       STATS_DESC_COUNTER(VCPU, inject_cputm),
+       STATS_DESC_COUNTER(VCPU, inject_external_call),
+       STATS_DESC_COUNTER(VCPU, inject_emergency_signal),
+       STATS_DESC_COUNTER(VCPU, inject_mchk),
+       STATS_DESC_COUNTER(VCPU, inject_pfault_init),
+       STATS_DESC_COUNTER(VCPU, inject_program),
+       STATS_DESC_COUNTER(VCPU, inject_restart),
+       STATS_DESC_COUNTER(VCPU, inject_set_prefix),
+       STATS_DESC_COUNTER(VCPU, inject_stop_signal),
+       STATS_DESC_COUNTER(VCPU, instruction_epsw),
+       STATS_DESC_COUNTER(VCPU, instruction_gs),
+       STATS_DESC_COUNTER(VCPU, instruction_io_other),
+       STATS_DESC_COUNTER(VCPU, instruction_lpsw),
+       STATS_DESC_COUNTER(VCPU, instruction_lpswe),
+       STATS_DESC_COUNTER(VCPU, instruction_pfmf),
+       STATS_DESC_COUNTER(VCPU, instruction_ptff),
+       STATS_DESC_COUNTER(VCPU, instruction_sck),
+       STATS_DESC_COUNTER(VCPU, instruction_sckpf),
+       STATS_DESC_COUNTER(VCPU, instruction_stidp),
+       STATS_DESC_COUNTER(VCPU, instruction_spx),
+       STATS_DESC_COUNTER(VCPU, instruction_stpx),
+       STATS_DESC_COUNTER(VCPU, instruction_stap),
+       STATS_DESC_COUNTER(VCPU, instruction_iske),
+       STATS_DESC_COUNTER(VCPU, instruction_ri),
+       STATS_DESC_COUNTER(VCPU, instruction_rrbe),
+       STATS_DESC_COUNTER(VCPU, instruction_sske),
+       STATS_DESC_COUNTER(VCPU, instruction_ipte_interlock),
+       STATS_DESC_COUNTER(VCPU, instruction_stsi),
+       STATS_DESC_COUNTER(VCPU, instruction_stfl),
+       STATS_DESC_COUNTER(VCPU, instruction_tb),
+       STATS_DESC_COUNTER(VCPU, instruction_tpi),
+       STATS_DESC_COUNTER(VCPU, instruction_tprot),
+       STATS_DESC_COUNTER(VCPU, instruction_tsch),
+       STATS_DESC_COUNTER(VCPU, instruction_sie),
+       STATS_DESC_COUNTER(VCPU, instruction_essa),
+       STATS_DESC_COUNTER(VCPU, instruction_sthyi),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_sense),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_sense_running),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_external_call),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_emergency),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_cond_emergency),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_start),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_stop),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_stop_store_status),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_store_status),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_store_adtl_status),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_arch),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_prefix),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_restart),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_init_cpu_reset),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_cpu_reset),
+       STATS_DESC_COUNTER(VCPU, instruction_sigp_unknown),
+       STATS_DESC_COUNTER(VCPU, instruction_diagnose_10),
+       STATS_DESC_COUNTER(VCPU, instruction_diagnose_44),
+       STATS_DESC_COUNTER(VCPU, instruction_diagnose_9c),
+       STATS_DESC_COUNTER(VCPU, diag_9c_ignored),
+       STATS_DESC_COUNTER(VCPU, diag_9c_forward),
+       STATS_DESC_COUNTER(VCPU, instruction_diagnose_258),
+       STATS_DESC_COUNTER(VCPU, instruction_diagnose_308),
+       STATS_DESC_COUNTER(VCPU, instruction_diagnose_500),
+       STATS_DESC_COUNTER(VCPU, instruction_diagnose_other),
+       STATS_DESC_COUNTER(VCPU, pfault_sync)
+};
+
+const struct kvm_stats_header kvm_vcpu_stats_header = {
+       .name_size = KVM_STATS_NAME_SIZE,
+       .num_desc = ARRAY_SIZE(kvm_vcpu_stats_desc),
+       .id_offset = sizeof(struct kvm_stats_header),
+       .desc_offset = sizeof(struct kvm_stats_header) + KVM_STATS_NAME_SIZE,
+       .data_offset = sizeof(struct kvm_stats_header) + KVM_STATS_NAME_SIZE +
+                      sizeof(kvm_vcpu_stats_desc),
 };
 
 /* allow nested virtualization in KVM (if enabled by user space) */
@@ -214,7 +230,7 @@ static unsigned long kvm_s390_fac_size(void)
        BUILD_BUG_ON(SIZE_INTERNAL > S390_ARCH_FAC_MASK_SIZE_U64);
        BUILD_BUG_ON(SIZE_INTERNAL > S390_ARCH_FAC_LIST_SIZE_U64);
        BUILD_BUG_ON(SIZE_INTERNAL * sizeof(unsigned long) >
-               sizeof(S390_lowcore.stfle_fac_list));
+               sizeof(stfle_fac_list));
 
        return SIZE_INTERNAL;
 }
@@ -1462,8 +1478,8 @@ static int kvm_s390_get_machine(struct kvm *kvm, struct kvm_device_attr *attr)
        mach->ibc = sclp.ibc;
        memcpy(&mach->fac_mask, kvm->arch.model.fac_mask,
               S390_ARCH_FAC_LIST_SIZE_BYTE);
-       memcpy((unsigned long *)&mach->fac_list, S390_lowcore.stfle_fac_list,
-              sizeof(S390_lowcore.stfle_fac_list));
+       memcpy((unsigned long *)&mach->fac_list, stfle_fac_list,
+              sizeof(stfle_fac_list));
        VM_EVENT(kvm, 3, "GET: host ibc:  0x%4.4x, host cpuid:  0x%16.16llx",
                 kvm->arch.model.ibc,
                 kvm->arch.model.cpuid);
@@ -1933,7 +1949,7 @@ out:
 static int gfn_to_memslot_approx(struct kvm_memslots *slots, gfn_t gfn)
 {
        int start = 0, end = slots->used_slots;
-       int slot = atomic_read(&slots->lru_slot);
+       int slot = atomic_read(&slots->last_used_slot);
        struct kvm_memory_slot *memslots = slots->memslots;
 
        if (gfn >= memslots[slot].base_gfn &&
@@ -1954,7 +1970,7 @@ static int gfn_to_memslot_approx(struct kvm_memslots *slots, gfn_t gfn)
 
        if (gfn >= memslots[start].base_gfn &&
            gfn < memslots[start].base_gfn + memslots[start].npages) {
-               atomic_set(&slots->lru_slot, start);
+               atomic_set(&slots->last_used_slot, start);
        }
 
        return start;
@@ -2687,10 +2703,10 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
        kvm->arch.model.fac_list = kvm->arch.sie_page2->fac_list;
 
        for (i = 0; i < kvm_s390_fac_size(); i++) {
-               kvm->arch.model.fac_mask[i] = S390_lowcore.stfle_fac_list[i] &
+               kvm->arch.model.fac_mask[i] = stfle_fac_list[i] &
                                              (kvm_s390_fac_base[i] |
                                               kvm_s390_fac_ext[i]);
-               kvm->arch.model.fac_list[i] = S390_lowcore.stfle_fac_list[i] &
+               kvm->arch.model.fac_list[i] = stfle_fac_list[i] &
                                              kvm_s390_fac_base[i];
        }
        kvm->arch.model.subfuncs = kvm_s390_available_subfunc;
@@ -5061,7 +5077,7 @@ static int __init kvm_s390_init(void)
 
        for (i = 0; i < 16; i++)
                kvm_s390_fac_base[i] |=
-                       S390_lowcore.stfle_fac_list[i] & nonhyp_mask(i);
+                       stfle_fac_list[i] & nonhyp_mask(i);
 
        return kvm_init(NULL, sizeof(struct kvm_vcpu), 0, THIS_MODULE);
 }