[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] pagetable update through xc_add_mmu_update always fails



Hi,

I am trying to update pagetable entries through the interface provided
by libxc, but for now I'm far from successful. As simple demonstration
(see code below) I tried to update the first entry in a L2-table
(x86-processor without PAE and PSE enabled) with same value that is
found in this table.

#include <assert.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <xenctrl.h>
#include <sys/mman.h>
#include <xen/xen.h>

static bool update_pagetable_entry(int xc_handle, uint32_t domid,
                unsigned long pte_ma, unsigned long ma)
{
        assert(pte_ma % 4 == 0);
        xc_mmu_t *mmu = xc_init_mmu_updates(xc_handle, domid);

        if (xc_add_mmu_update(xc_handle, mmu,
                                pte_ma | MMU_NORMAL_PT_UPDATE, ma) == -1)
                return false;

        if (xc_finish_mmu_updates(xc_handle, mmu) == -1)
                return false;

        return true;
}

int main(int argc, char **argv)
{
        if (argc < 2)
                return 1;

        uint32_t domid = (uint32_t) strtoul(argv[1], NULL, 10);
        int xc_handle = xc_interface_open();
        assert(xc_handle != -1 && domid != 0);

        vcpu_guest_context_t ctxt;
        xc_vcpu_getcontext(xc_handle, domid, 0, &ctxt);
        unsigned long cr3_ma = ctxt.ctrlreg[3];

        unsigned long *l2_table = xc_map_foreign_range(xc_handle, domid,
                        XC_PAGE_SIZE, PROT_READ, cr3_ma >> XC_PAGE_SHIFT);
        assert(l2_table != NULL);

        if (!update_pagetable_entry(xc_handle, domid, cr3_ma, l2_table[0]))
                fprintf(stderr, "update failed\n");

        munmap(l2_table, XC_PAGE_SIZE);

        xc_interface_close(xc_handle);
        return 0;
}

The function update_pagetable_entry always fails. The output of the
program is "ERROR Internal error: Failure when submitting mmu updates"
and "xm dmesg" tells me the following:

(XEN) [...]/xen/include/asm/mm.h:184:d0 Error pfn 31971: rd=ffbf0100,
od=ffbd8100, caf=80000005, taf=58000002
(XEN) mm.c:500:d0 Could not get page ref for pfn 31971
(XEN) mm.c:2319:d0 Could not get page for normal update

Where pfn 31971 is the frame number of the pagetable which I tried to
update. (I use Xen-unstable from 04/04/2007)

What I am doing wrong or what I am missing? All suggestions are
appreciated.

Thanks in advance!

Stephan

Attachment: pgpzl6pfEgFQo.pgp
Description: PGP signature

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.