diff options
author | Brijesh Singh <brijesh.singh@amd.com> | 2018-03-08 06:48:44 -0600 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2018-03-13 12:04:03 +0100 |
commit | b20e37801fc4a94ba40737541710c29c923e1c48 (patch) | |
tree | 73b9eef1e98a0c135097088ffca638645e0b454f /accel/kvm/kvm-all.c | |
parent | 9b02f7bf8515961624ba0454209f39748dae4d88 (diff) | |
download | qemu-b20e37801fc4a94ba40737541710c29c923e1c48.zip qemu-b20e37801fc4a94ba40737541710c29c923e1c48.tar.gz qemu-b20e37801fc4a94ba40737541710c29c923e1c48.tar.bz2 |
kvm: add memory encryption context
Split from a patch by Brijesh Singh (brijesh.singh@amd.com).
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Diffstat (limited to 'accel/kvm/kvm-all.c')
-rw-r--r-- | accel/kvm/kvm-all.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index b91fcb7..e0e43fd 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -38,6 +38,7 @@ #include "qemu/event_notifier.h" #include "trace.h" #include "hw/irq.h" +#include "sysemu/sev.h" #include "hw/boards.h" @@ -103,6 +104,9 @@ struct KVMState #endif KVMMemoryListener memory_listener; QLIST_HEAD(, KVMParkedVcpu) kvm_parked_vcpus; + + /* memory encryption */ + void *memcrypt_handle; }; KVMState *kvm_state; @@ -138,6 +142,15 @@ int kvm_get_max_memslots(void) return s->nr_slots; } +bool kvm_memcrypt_enabled(void) +{ + if (kvm_state && kvm_state->memcrypt_handle) { + return true; + } + + return false; +} + static KVMSlot *kvm_get_free_slot(KVMMemoryListener *kml) { KVMState *s = kvm_state; @@ -1636,6 +1649,18 @@ static int kvm_init(MachineState *ms) kvm_state = s; + /* + * if memory encryption object is specified then initialize the memory + * encryption context. + */ + if (ms->memory_encryption) { + kvm_state->memcrypt_handle = sev_guest_init(ms->memory_encryption); + if (!kvm_state->memcrypt_handle) { + ret = -1; + goto err; + } + } + ret = kvm_arch_init(ms, s); if (ret < 0) { goto err; |