1
2
3
4
5
6
7
8
9
10
11
12#ifndef HW_S390_PV_H
13#define HW_S390_PV_H
14
15#include "qapi/error.h"
16#include "sysemu/kvm.h"
17
18#ifdef CONFIG_KVM
19#include "cpu.h"
20#include "hw/s390x/s390-virtio-ccw.h"
21
22static inline bool s390_is_pv(void)
23{
24 static S390CcwMachineState *ccw;
25 Object *obj;
26
27 if (ccw) {
28 return ccw->pv;
29 }
30
31
32 obj = object_dynamic_cast(qdev_get_machine(),
33 TYPE_S390_CCW_MACHINE);
34 if (!obj) {
35 return false;
36 }
37 ccw = S390_CCW_MACHINE(obj);
38 return ccw->pv;
39}
40
41int s390_pv_vm_enable(void);
42void s390_pv_vm_disable(void);
43int s390_pv_set_sec_parms(uint64_t origin, uint64_t length);
44int s390_pv_unpack(uint64_t addr, uint64_t size, uint64_t tweak);
45void s390_pv_prep_reset(void);
46int s390_pv_verify(void);
47void s390_pv_unshare(void);
48void s390_pv_inject_reset_error(CPUState *cs);
49#else
50static inline bool s390_is_pv(void) { return false; }
51static inline int s390_pv_vm_enable(void) { return 0; }
52static inline void s390_pv_vm_disable(void) {}
53static inline int s390_pv_set_sec_parms(uint64_t origin, uint64_t length) { return 0; }
54static inline int s390_pv_unpack(uint64_t addr, uint64_t size, uint64_t tweak) { return 0; }
55static inline void s390_pv_prep_reset(void) {}
56static inline int s390_pv_verify(void) { return 0; }
57static inline void s390_pv_unshare(void) {}
58static inline void s390_pv_inject_reset_error(CPUState *cs) {};
59#endif
60
61int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp);
62static inline int s390_pv_init(ConfidentialGuestSupport *cgs, Error **errp)
63{
64 if (!cgs) {
65 return 0;
66 }
67 if (kvm_enabled()) {
68 return s390_pv_kvm_init(cgs, errp);
69 }
70
71 error_setg(errp, "Protected Virtualization requires KVM");
72 return -1;
73}
74
75#endif
76