xref: /qemu/target/s390x/machine.c (revision 18ff949474cfbba892fdc34aa6ed7558afc78c5c)
1ef1df130SThomas Huth /*
2ef1df130SThomas Huth  * S390x machine definitions and functions
3ef1df130SThomas Huth  *
4ef1df130SThomas Huth  * Copyright IBM Corp. 2014
5ef1df130SThomas Huth  *
6ef1df130SThomas Huth  * Authors:
7ef1df130SThomas Huth  *   Thomas Huth <thuth@linux.vnet.ibm.com>
8ef1df130SThomas Huth  *   Christian Borntraeger <borntraeger@de.ibm.com>
9ef1df130SThomas Huth  *   Jason J. Herne <jjherne@us.ibm.com>
10ef1df130SThomas Huth  *
11ef1df130SThomas Huth  * This work is free software; you can redistribute it and/or modify
12ef1df130SThomas Huth  * it under the terms of the GNU General Public License as published
13ef1df130SThomas Huth  * by the Free Software Foundation; either version 2 of the License,
14ef1df130SThomas Huth  * or (at your option) any later version.
15ef1df130SThomas Huth  */
16ef1df130SThomas Huth 
17ef1df130SThomas Huth #include "hw/hw.h"
18ef1df130SThomas Huth #include "cpu.h"
19ef1df130SThomas Huth #include "sysemu/kvm.h"
20ef1df130SThomas Huth 
21ef1df130SThomas Huth static int cpu_post_load(void *opaque, int version_id)
22ef1df130SThomas Huth {
23ef1df130SThomas Huth     S390CPU *cpu = opaque;
24ef1df130SThomas Huth 
25ef1df130SThomas Huth     /*
26ef1df130SThomas Huth      * As the cpu state is pushed to kvm via kvm_set_mp_state rather
27ef1df130SThomas Huth      * than via cpu_synchronize_state, we need update kvm here.
28ef1df130SThomas Huth      */
29ef1df130SThomas Huth     if (kvm_enabled()) {
30ef1df130SThomas Huth         kvm_s390_set_cpu_state(cpu, cpu->env.cpu_state);
31ef1df130SThomas Huth     }
32ef1df130SThomas Huth 
33ef1df130SThomas Huth     return 0;
34ef1df130SThomas Huth }
35ef1df130SThomas Huth 
36ef1df130SThomas Huth const VMStateDescription vmstate_s390_cpu = {
37ef1df130SThomas Huth     .name = "cpu",
38ef1df130SThomas Huth     .post_load = cpu_post_load,
3918ff9494SDavid Hildenbrand     .version_id = 2,
4018ff9494SDavid Hildenbrand     .minimum_version_id = 2,
41ef1df130SThomas Huth     .fields      = (VMStateField[]) {
42ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[0].ll, S390CPU),
43ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[1].ll, S390CPU),
44ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[2].ll, S390CPU),
45ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[3].ll, S390CPU),
46ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[4].ll, S390CPU),
47ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[5].ll, S390CPU),
48ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[6].ll, S390CPU),
49ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[7].ll, S390CPU),
50ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[8].ll, S390CPU),
51ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[9].ll, S390CPU),
52ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[10].ll, S390CPU),
53ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[11].ll, S390CPU),
54ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[12].ll, S390CPU),
55ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[13].ll, S390CPU),
56ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[14].ll, S390CPU),
57ef1df130SThomas Huth         VMSTATE_UINT64(env.fregs[15].ll, S390CPU),
58ef1df130SThomas Huth         VMSTATE_UINT64_ARRAY(env.regs, S390CPU, 16),
59ef1df130SThomas Huth         VMSTATE_UINT64(env.psw.mask, S390CPU),
60ef1df130SThomas Huth         VMSTATE_UINT64(env.psw.addr, S390CPU),
61ef1df130SThomas Huth         VMSTATE_UINT64(env.psa, S390CPU),
62ef1df130SThomas Huth         VMSTATE_UINT32(env.fpc, S390CPU),
63ef1df130SThomas Huth         VMSTATE_UINT32(env.todpr, S390CPU),
64ef1df130SThomas Huth         VMSTATE_UINT64(env.pfault_token, S390CPU),
65ef1df130SThomas Huth         VMSTATE_UINT64(env.pfault_compare, S390CPU),
66ef1df130SThomas Huth         VMSTATE_UINT64(env.pfault_select, S390CPU),
67ef1df130SThomas Huth         VMSTATE_UINT64(env.cputm, S390CPU),
68ef1df130SThomas Huth         VMSTATE_UINT64(env.ckc, S390CPU),
69ef1df130SThomas Huth         VMSTATE_UINT64(env.gbea, S390CPU),
70ef1df130SThomas Huth         VMSTATE_UINT64(env.pp, S390CPU),
71ef1df130SThomas Huth         VMSTATE_UINT32_ARRAY(env.aregs, S390CPU, 16),
72ef1df130SThomas Huth         VMSTATE_UINT64_ARRAY(env.cregs, S390CPU, 16),
73ef1df130SThomas Huth         VMSTATE_UINT8(env.cpu_state, S390CPU),
7418ff9494SDavid Hildenbrand         VMSTATE_UINT8(env.sigp_order, S390CPU),
75ef1df130SThomas Huth         VMSTATE_END_OF_LIST()
76ef1df130SThomas Huth      },
77ef1df130SThomas Huth };
78