2 * (C) Copyright 2007-2011 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
4 * This file is released under the GPLv2. See the COPYING file for more
16 * saved registers for guests
18 * NOTE: some registers are saved in the SIE control block!
28 * These states mirror those described in chapter 4 of SA22-7832-06
40 struct list_head list
;
48 /* the SIE control block is picky about alignment */
51 struct guest_regs regs
;
54 enum virt_cpustate state
;
57 struct list_head int_io
[8]; /* I/O interrupts */
61 struct device
*dev
; /* the real device */
63 struct spool_file
*wlines
;
64 struct spool_file
*rlines
;
70 struct task
*task
; /* the virtual CPU task */
71 struct user
*directory
; /* the directory information */
73 struct virt_cons console
; /* the console */
74 struct virt_cons
*con
; /* convenience pointer to the
76 int print_ts
; /* print timestamps */
78 struct list_head guest_pages
; /* list of guest pages */
79 struct list_head virt_devs
; /* list of guest virtual devs */
80 struct list_head online_users
; /* list of online users */
82 struct address_space as
; /* the guest storage */
85 /*****************************************************************************/
86 /* Guest exception queuing */
89 PROG_OPERAND
= 0x0001,
98 extern void queue_prog_exception(struct virt_sys
*sys
, enum PROG_EXCEPTION type
, u64 param
);
99 extern void queue_io_interrupt(struct virt_sys
*sys
, u32 ssid
, u32 param
, u32 a
, u32 isc
);
101 /*****************************************************************************/
102 /* Guest register reading & address calculation */
104 static inline u64
__guest_gpr(struct virt_cpu
*cpu
, int gpr
)
106 u64 ret
= cpu
->regs
.gpr
[gpr
];
108 if (!(atomic_read(&cpu
->sie_cb
.cpuflags
) & CPUSTAT_ZARCH
))
109 ret
&= 0xffffffffULL
;
114 static inline u64
__guest_addr(struct virt_cpu
*cpu
, u64 disp
, int x
, int b
)
118 switch((cpu
->sie_cb
.gpsw
.ea
<< 1) | cpu
->sie_cb
.gpsw
.ba
) {
134 (x
? __guest_gpr(cpu
, x
) : 0) +
135 (b
? __guest_gpr(cpu
, b
) : 0)) & mask
;
138 /*****************************************************************************/
139 /* SIE Interception Param parsing & instruction decode */
141 #define IP_TO_RAW(sie) ((((u64)(sie).ipa) << 32) | ((u64)(sie).ipb))
143 static inline u64
RAW_S_1(struct virt_cpu
*cpu
)
145 u64 raw
= IP_TO_RAW(cpu
->sie_cb
);
147 return __guest_addr(cpu
,
153 /*****************************************************************************/
154 /* All the different ways to reset the system */
155 extern void guest_power_on_reset(struct virt_sys
*sys
);
156 extern void guest_system_reset_normal(struct virt_sys
*sys
);
157 extern void guest_system_reset_clear(struct virt_sys
*sys
);
158 extern void guest_load_normal(struct virt_sys
*sys
);
159 extern void guest_load_clear(struct virt_sys
*sys
);
161 extern void run_guest(struct virt_sys
*sys
);
162 extern void handle_interception(struct virt_sys
*sys
);
164 extern int handle_instruction(struct virt_sys
*sys
);
165 extern int handle_instruction_priv(struct virt_sys
*sys
);
167 typedef int (*intercept_handler_t
)(struct virt_sys
*sys
);