qemu中的内存地址打印范围 [英] Print range of memory addresses in qemu

查看:391
本文介绍了qemu中的内存地址打印范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是qemu开发的新手.我想在将内存分配给虚拟机时打印涉及的相应地址.

I am new to qemu development. I wanted to print the corresponding addresses involved when a memory has been assigned to a virtual machine.

例如,当我调用以下命令时

For example, when i invoke the following command

qemu-system-i386 ubuntu.img -m 1G

qemu-system-i386 ubuntu.img -m 1G

我需要能够打印所涉及的虚拟地址和物理地址.就像上面涉及的1G内存一样:

I need to be able to print the virtual addresses and physical addresses involved. Like above 1G memory involved:

访客虚拟地址= 0x12345678 ..至0x87654321 ..

Guest Virtual Addr = 0x12345678..to 0x87654321..

来宾物理地址= 0x23456781 ..至0x74536733 ..(如果我的理解正确的话,这是映射到主机虚拟内存的地址.)

Guest Physical Addr = 0x23456781..to 0x74536733..(This is the one that gets mapped to host virtual memory if my understanding is right).

注意: 以上数字仅供参考.

Note: Above numbers are just for explanation.

查看qemu的源代码时,我发现无论我们在此处的命令中提及的大小是多少,它都被分配为| ram_addr_t |的一部分.堵塞.但是我无法找到如何找到此尺寸的偏移量的方法.请在这方面尽早帮助我.

When I looked into the source code of qemu, I see that this size whatever we are mentioning in the command here is assigned as a part of |ram_addr_t| block. But I am not able to find as how to proceed to find the offset for this size.Kindly help me in this regard at the earliest.

推荐答案

基于上述内容,我认为您要执行的操作不是将访客虚拟地址映射到访客物理地址(根据帖子),但访客物理地址改为主机虚拟地址.

Based on the above, I think what you want to do is not map guest virtual address to guest physical address (per the post), but guest physical address to host virtual address.

来宾物理和来宾虚拟之间的映射(主要)由来宾OS控制.如果您确实要查看从物理到虚拟客户机之间的关系,那将是特定于目标的.一些qemu目标甚至没有这样的映射(平面地址空间).

The mapping between guest physical and guest virtual is (mostly) controlled by the guest OS. If you are really are trying to look at guest physical to guest virtual, that will be target specific. Some qemu targets do not even have such a mapping (flat address space).

我将从查看memory.cmemory_mapping.c的来源开始.

I would start by looking at the source for memory.c and memory_mapping.c.

以下是exec.c的摘录,该摘录将目标从目标(来宾)虚拟地址转换为目标物理地址,并在那里处理内存.那是您需要的吗?

Below is an excerpt from exec.c which converts a target a target (guest) virtual address into a target physical address, and manipulates memory there. Is that what you needed?

int cpu_memory_rw_debug(CPUState *cpu, target_ulong addr,
                        uint8_t *buf, int len, int is_write)
{
    int l;
    hwaddr phys_addr;
    target_ulong page;

    while (len > 0) {
        page = addr & TARGET_PAGE_MASK;
        phys_addr = cpu_get_phys_page_debug(cpu, page);
        /* if no physical page mapped, return an error */
        if (phys_addr == -1)
            return -1;
        l = (page + TARGET_PAGE_SIZE) - addr;
        if (l > len)
            l = len;
        phys_addr += (addr & ~TARGET_PAGE_MASK);
        if (is_write) {
            cpu_physical_memory_write_rom(cpu->as, phys_addr, buf, l);
        } else {
            address_space_rw(cpu->as, phys_addr, buf, l, 0);
        }
        len -= l;
        buf += l;
        addr += l;
    }
    return 0;

最后,我认为您可能会在qemu IRC频道上获得比这里更多的帮助.

Finally, I think you might get more help on the qemu IRC channel than here.

这篇关于qemu中的内存地址打印范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆