[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v4 15/20] sev: add DEBUG_DECRYPT command
From: |
Brijesh Singh |
Subject: |
[Qemu-devel] [RFC PATCH v4 15/20] sev: add DEBUG_DECRYPT command |
Date: |
Wed, 8 Mar 2017 15:53:49 -0500 |
User-agent: |
StGit/0.17.1-dirty |
The command is used to decrypt a page of guest memory for debug.
The command will be used by qemu monitor dump and gdbserver to access
the guest memory for debug purposes. A typical usage look like:
cpu_physical_memory_rw_debug
cpu_physical_memory_rw_debug_internal
sev_debug_decrypt
Signed-off-by: Brijesh Singh <address@hidden>
---
sev.c | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/sev.c b/sev.c
index d32391e..f8d822d 100644
--- a/sev.c
+++ b/sev.c
@@ -320,6 +320,36 @@ err_1:
}
static int
+sev_debug_decrypt(SEVState *s, uint8_t *dst, const uint8_t *src, uint32_t len)
+{
+ int ret, error;
+ struct kvm_sev_dbg *dbg;
+
+ if (!s) {
+ return 1;
+ }
+
+ dbg = g_malloc0(sizeof(*dbg));
+ if (!dbg) {
+ return 1;
+ }
+
+ dbg->src_addr = (unsigned long)src;
+ dbg->dst_addr = (unsigned long)dst;
+ dbg->length = len;
+
+ ret = sev_ioctl(KVM_SEV_DBG_DECRYPT, dbg, &error);
+ if (ret) {
+ fprintf(stderr, "failed DBG_DECRYPT %d (%#x)\n", ret, error);
+ goto err;
+ }
+
+err:
+ g_free(dbg);
+ return ret;
+}
+
+static int
sev_mem_write(uint8_t *dst, const uint8_t *src, uint32_t len, MemTxAttrs attrs)
{
SEVState *s = kvm_memcrypt_get_handle();
@@ -335,7 +365,11 @@ sev_mem_write(uint8_t *dst, const uint8_t *src, uint32_t
len, MemTxAttrs attrs)
static int
sev_mem_read(uint8_t *dst, const uint8_t *src, uint32_t len, MemTxAttrs attrs)
{
- return 0;
+ SEVState *s = kvm_memcrypt_get_handle();
+
+ assert(attrs.debug);
+
+ return sev_debug_decrypt(s, dst, src, len);
}
void *
- Re: [Qemu-devel] [RFC PATCH v4 09/20] hmp: display memory encryption support in 'info kvm', (continued)
- [Qemu-devel] [RFC PATCH v4 12/20] SEV: add GUEST_STATUS command, Brijesh Singh, 2017/03/08
- [Qemu-devel] [RFC PATCH v4 14/20] sev: add LAUNCH_FINISH command, Brijesh Singh, 2017/03/08
- [Qemu-devel] [RFC PATCH v4 18/20] target/i386: add cpuid Fn8000_001f, Brijesh Singh, 2017/03/08
- [Qemu-devel] [RFC PATCH v4 16/20] sev: add DEBUG_ENCRYPT command, Brijesh Singh, 2017/03/08
- Re: [Qemu-devel] [RFC PATCH v4 00/20] x86: Secure Encrypted Virtualization (AMD), Eduardo Habkost, 2017/03/08
- [Qemu-devel] [RFC PATCH v4 07/20] kvm: add memory encryption api support, Brijesh Singh, 2017/03/08
- [Qemu-devel] [RFC PATCH v4 15/20] sev: add DEBUG_DECRYPT command,
Brijesh Singh <=
- [Qemu-devel] [RFC PATCH v4 17/20] target/i386: encrypt bios rom when memory encryption is enabled, Brijesh Singh, 2017/03/08
- [Qemu-devel] [RFC PATCH v4 20/20] migration: disable save/restore and migration when SEV is active, Brijesh Singh, 2017/03/08
- [Qemu-devel] [RFC PATCH v4 19/20] target/i386: clear memory encryption bit when walking SEV guest page table, Brijesh Singh, 2017/03/08
- Re: [Qemu-devel] [RFC PATCH v4 00/20] x86: Secure Encrypted Virtualization (AMD), no-reply, 2017/03/08