xref: /qemu/include/hw/s390x/storage-keys.h (revision 0efe406cac8a4d9f0b52eada4c6c2a768fe4b7d2)
1 /*
2  * s390 storage key device
3  *
4  * Copyright 2015 IBM Corp.
5  * Author(s): Jason J. Herne <jjherne@linux.vnet.ibm.com>
6  *
7  * This work is licensed under the terms of the GNU GPL, version 2 or (at
8  * your option) any later version. See the COPYING file in the top-level
9  * directory.
10  */
11 
12 #ifndef __S390_STORAGE_KEYS_H
13 #define __S390_STORAGE_KEYS_H
14 
15 #include <hw/qdev.h>
16 
17 #define TYPE_S390_SKEYS "s390-skeys"
18 #define S390_SKEYS(obj) \
19     OBJECT_CHECK(S390SKeysState, (obj), TYPE_S390_SKEYS)
20 
21 typedef struct S390SKeysState {
22     DeviceState parent_obj;
23 
24 } S390SKeysState;
25 
26 #define S390_SKEYS_CLASS(klass) \
27     OBJECT_CLASS_CHECK(S390SKeysClass, (klass), TYPE_S390_SKEYS)
28 #define S390_SKEYS_GET_CLASS(obj) \
29     OBJECT_GET_CLASS(S390SKeysClass, (obj), TYPE_S390_SKEYS)
30 
31 typedef struct S390SKeysClass {
32     DeviceClass parent_class;
33     int (*skeys_enabled)(S390SKeysState *ks);
34     int (*get_skeys)(S390SKeysState *ks, uint64_t start_gfn, uint64_t count,
35                      uint8_t *keys);
36     int (*set_skeys)(S390SKeysState *ks, uint64_t start_gfn, uint64_t count,
37                      uint8_t *keys);
38 } S390SKeysClass;
39 
40 #define TYPE_KVM_S390_SKEYS "s390-skeys-kvm"
41 #define TYPE_QEMU_S390_SKEYS "s390-skeys-qemu"
42 #define QEMU_S390_SKEYS(obj) \
43     OBJECT_CHECK(QEMUS390SKeysState, (obj), TYPE_QEMU_S390_SKEYS)
44 
45 typedef struct QEMUS390SKeysState {
46     S390SKeysState parent_obj;
47     uint8_t *keydata;
48     uint32_t key_count;
49 } QEMUS390SKeysState;
50 
51 void s390_skeys_init(void);
52 
53 S390SKeysState *s390_get_skeys_device(void);
54 
55 #endif /* __S390_STORAGE_KEYS_H */
56