hw/arm/bcm2836: Only provide "enabled-cpus" property to multicore SoCs
[qemu.git] / hw / s390x / s390-skeys-kvm.c
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 #include "qemu/osdep.h"
13 #include "hw/s390x/storage-keys.h"
14 #include "sysemu/kvm.h"
15 #include "qemu/error-report.h"
16 #include "qemu/module.h"
17
18 static int kvm_s390_skeys_enabled(S390SKeysState *ss)
19 {
20 S390SKeysClass *skeyclass = S390_SKEYS_GET_CLASS(ss);
21 uint8_t single_key;
22 int r;
23
24 r = skeyclass->get_skeys(ss, 0, 1, &single_key);
25 if (r != 0 && r != KVM_S390_GET_SKEYS_NONE) {
26 error_report("S390_GET_KEYS error %d", r);
27 }
28 return (r == 0);
29 }
30
31 static int kvm_s390_skeys_get(S390SKeysState *ss, uint64_t start_gfn,
32 uint64_t count, uint8_t *keys)
33 {
34 struct kvm_s390_skeys args = {
35 .start_gfn = start_gfn,
36 .count = count,
37 .skeydata_addr = (__u64)keys
38 };
39
40 return kvm_vm_ioctl(kvm_state, KVM_S390_GET_SKEYS, &args);
41 }
42
43 static int kvm_s390_skeys_set(S390SKeysState *ss, uint64_t start_gfn,
44 uint64_t count, uint8_t *keys)
45 {
46 struct kvm_s390_skeys args = {
47 .start_gfn = start_gfn,
48 .count = count,
49 .skeydata_addr = (__u64)keys
50 };
51
52 return kvm_vm_ioctl(kvm_state, KVM_S390_SET_SKEYS, &args);
53 }
54
55 static void kvm_s390_skeys_class_init(ObjectClass *oc, void *data)
56 {
57 S390SKeysClass *skeyclass = S390_SKEYS_CLASS(oc);
58 DeviceClass *dc = DEVICE_CLASS(oc);
59
60 skeyclass->skeys_enabled = kvm_s390_skeys_enabled;
61 skeyclass->get_skeys = kvm_s390_skeys_get;
62 skeyclass->set_skeys = kvm_s390_skeys_set;
63
64 /* Reason: Internal device (only one skeys device for the whole memory) */
65 dc->user_creatable = false;
66 }
67
68 static const TypeInfo kvm_s390_skeys_info = {
69 .name = TYPE_KVM_S390_SKEYS,
70 .parent = TYPE_S390_SKEYS,
71 .instance_size = sizeof(S390SKeysState),
72 .class_init = kvm_s390_skeys_class_init,
73 .class_size = sizeof(S390SKeysClass),
74 };
75
76 static void kvm_s390_skeys_register_types(void)
77 {
78 type_register_static(&kvm_s390_skeys_info);
79 }
80
81 type_init(kvm_s390_skeys_register_types)