Skip to contentSkip to conversation

Monitor command: x-gpa2hva, translate guest physical address to host virtual address

PATCH In review Huang Ying 4 participants 7 messages Nov 16, 2010 – Apr 29, 2011 KVM

lore
Share & tools
lore

Huang Ying

author
#0 lore raw

PATCH 1/1 Monitor command: x-gpa2hva, translate guest physical address to host virtual address

Author: Max Asbock <[email protected]>

Add command x-gpa2hva to translate guest physical address to host virtual address. Because gpa to hva translation is not consistent, so this command is only used for debugging.

The x-gpa2hva command provides one step in a chain of translations from guest virtual to guest physical to host virtual to host physical. Host physical is then used to inject a machine check error. As a consequence the HWPOISON code on the host and the MCE injection code in qemu-kvm are exercised.

v3:

- Rename to x-gpa2hva
- Remove QMP support, because gpa2hva is not consistent

v2:

- Add QMP support

---
 hmp-commands.hx |   15 +++++++++++++++
 monitor.c       |   22 ++++++++++++++++++++++
 2 files changed, 37 insertions(+)
monitor.c +22 -0
@@ -2272,6 +2272,28 @@ static void do_inject_mce(Monitor *mon,
 }
 #endif
 
+static void do_gpa2hva_print(Monitor *mon, const QObject *data)
+{
+    QInt *qint;
+
+    qint = qobject_to_qint(data);
+    monitor_printf(mon, "0x%lx\n", (unsigned long)qint->value);
+}
+
+static int do_gpa2hva(Monitor *mon, const QDict *qdict, QObject **ret_data)
+{
+    target_phys_addr_t paddr;
+    target_phys_addr_t size = TARGET_PAGE_SIZE;
+    void *vaddr;
+
+    paddr = qdict_get_int(qdict, "addr");
+    vaddr = cpu_physical_memory_map(paddr, &size, 0);
+    cpu_physical_memory_unmap(vaddr, size, 0, 0);
+    *ret_data = qobject_from_jsonf("%ld", (unsigned long)vaddr);
+
+    return 0;
+}
+
 static int do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     const char *fdname = qdict_get_str(qdict, "fdname");
hmp-commands.hx +15 -0
@@ -293,6 +293,21 @@ Start gdbserver session (default @var{po
 ETEXI
 
     {
+        .name       = "x-gpa2hva",
+        .args_type  = "fmt:/,addr:l",
+        .params     = "/fmt addr",
+        .help       = "translate guest physical 'addr' to host virtual address, only for debugging",
+        .user_print = do_gpa2hva_print,
+        .mhandler.cmd_new = do_gpa2hva,
+    },
+
+STEXI
+@item x-gpa2hva @var{addr}
+@findex x-gpa2hva
+Translate guest physical @var{addr} to host virtual address, only for debugging.
+ETEXI
+
+    {
         .name       = "x",
         .args_type  = "fmt:/,addr:l",
         .params     = "/fmt addr",
author
#1 lore raw
Quoted 12 lines · Huang Ying

Author: Max Asbock <[email protected]>

Add command x-gpa2hva to translate guest physical address to host virtual address. Because gpa to hva translation is not consistent, so this command is only used for debugging.

The x-gpa2hva command provides one step in a chain of translations from guest virtual to guest physical to host virtual to host physical. Host physical is then used to inject a machine check error. As a consequence the HWPOISON code on the host and the MCE injection code in qemu-kvm are exercised.

Quoted 4 lines

v3:

- Rename to x-gpa2hva
- Remove QMP support, because gpa2hva is not consistent

Is this patch an acceptable solution for now? This command is useful for our testing.

Best Regards,
Huang Ying

#2 lore raw
Quoted 13 lines · Huang Ying
Quoted 12 lines · Huang Ying

Author: Max Asbock <[email protected]>

Add command x-gpa2hva to translate guest physical address to host virtual address. Because gpa to hva translation is not consistent, so this command is only used for debugging.

The x-gpa2hva command provides one step in a chain of translations from guest virtual to guest physical to host virtual to host physical. Host physical is then used to inject a machine check error. As a consequence the HWPOISON code on the host and the MCE injection code in qemu-kvm are exercised.

Quoted 7 lines
Quoted 4 lines

v3:

- Rename to x-gpa2hva
- Remove QMP support, because gpa2hva is not consistent

Is this patch an acceptable solution for now? This command is useful for our testing.

Anthony?

Quoted 9 lines

Best Regards,
Huang Ying

--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 16 lines · Marcelo Tosatti
Quoted 15 lines · Huang Ying
Quoted 14 lines · Huang Ying

Author: Max Asbock<[email protected]>

Add command x-gpa2hva to translate guest physical address to host virtual address. Because gpa to hva translation is not consistent, so this command is only used for debugging.

The x-gpa2hva command provides one step in a chain of translations from guest virtual to guest physical to host virtual to host physical. Host physical is then used to inject a machine check error. As a consequence the HWPOISON code on the host and the MCE injection code in qemu-kvm are exercised.

v3:

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

- Rename to x-gpa2hva
- Remove QMP support, because gpa2hva is not consistent

Is this patch an acceptable solution for now? This command is useful for our testing.

Anthony?

Yeah, but it should come through qemu-devel, no?

Regards,

Anthony Liguori

Quoted 10 lines
Quoted 10 lines

Best Regards,
Huang Ying

--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 20 lines · Anthony Liguori
Quoted 19 lines · Marcelo Tosatti
Quoted 18 lines · Huang Ying
Quoted 16 lines · Huang Ying

Author: Max Asbock<[email protected]>

Add command x-gpa2hva to translate guest physical address to host virtual address. Because gpa to hva translation is not consistent, so this command is only used for debugging.

The x-gpa2hva command provides one step in a chain of translations from guest virtual to guest physical to host virtual to host physical. Host physical is then used to inject a machine check error. As a consequence the HWPOISON code on the host and the MCE injection code in qemu-kvm are exercised.

v3:

- Rename to x-gpa2hva
- Remove QMP support, because gpa2hva is not consistent

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Is this patch an acceptable solution for now? This command is useful for our testing.

Anthony?

Yeah, but it should come through qemu-devel, no?

Yes, Huang Ying, can you please resend?

author
#5 lore raw
Quoted 21 lines · Marcelo Tosatti
Quoted 20 lines · Anthony Liguori
Quoted 19 lines · Marcelo Tosatti
Quoted 18 lines · Huang Ying
Quoted 16 lines · Huang Ying

Author: Max Asbock<[email protected]>

Add command x-gpa2hva to translate guest physical address to host virtual address. Because gpa to hva translation is not consistent, so this command is only used for debugging.

The x-gpa2hva command provides one step in a chain of translations from guest virtual to guest physical to host virtual to host physical. Host physical is then used to inject a machine check error. As a consequence the HWPOISON code on the host and the MCE injection code in qemu-kvm are exercised.

v3:

- Rename to x-gpa2hva
- Remove QMP support, because gpa2hva is not consistent

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Is this patch an acceptable solution for now? This command is useful for our testing.

Anthony?

Yeah, but it should come through qemu-devel, no?

Yes, Huang Ying, can you please resend?

Via QEMU git or uq/master branch of KVM git?

Best Regards,
Huang Ying

#6 lore raw
Quoted 25 lines · On Fri, 29 Apr 2011 08:30:25 +0800 Huang Ying <[email protected]> wrote:
Quoted 24 lines · Marcelo Tosatti
Quoted 23 lines · Anthony Liguori
Quoted 22 lines · Marcelo Tosatti
Quoted 20 lines · Huang Ying
Quoted 12 lines · Huang Ying

Author: Max Asbock<[email protected]>

Add command x-gpa2hva to translate guest physical address to host virtual address. Because gpa to hva translation is not consistent, so this command is only used for debugging.

The x-gpa2hva command provides one step in a chain of translations from guest virtual to guest physical to host virtual to host physical. Host physical is then used to inject a machine check error. As a consequence the HWPOISON code on the host and the MCE injection code in qemu-kvm are exercised.

Quoted 4 lines

v3:

- Rename to x-gpa2hva
- Remove QMP support, because gpa2hva is not consistent

Is this patch an acceptable solution for now? This command is useful for our testing.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Anthony?

Yeah, but it should come through qemu-devel, no?

Yes, Huang Ying, can you please resend?

Via QEMU git or uq/master branch of KVM git?

If there isn't anything qemu-kvm.git specific, it should be against qemu.git.