Changeset e12ccc5 in mainline for kernel/arch/xen32/include/mm/page.h


Ignore:
Timestamp:
2006-08-01T17:27:11Z (18 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0fbfa0d
Parents:
e386cbf
Message:

xen32: use writable page tables, cleanup mm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/xen32/include/mm/page.h

    re386cbf re12ccc5  
    4444
    4545#ifndef __ASM__
    46 #       include <arch/hypercall.h>
    4746#       define KA2PA(x) (((uintptr_t) (x)) - 0x80000000)
    4847#       define PA2KA(x) (((uintptr_t) (x)) + 0x80000000)
     
    6665#define PTL3_INDEX_ARCH(vaddr)  (((vaddr) >> 12) & 0x3ff)
    6766
    68 #define GET_PTL1_ADDRESS_ARCH(ptl0, i)          ((pte_t *)((((pte_t *)(ptl0))[(i)].frame_address) << 12))
     67#define GET_PTL1_ADDRESS_ARCH(ptl0, i)          ((pte_t *) MA2PA((((pte_t *) (ptl0))[(i)].frame_address) << 12))
    6968#define GET_PTL2_ADDRESS_ARCH(ptl1, i)          (ptl1)
    7069#define GET_PTL3_ADDRESS_ARCH(ptl2, i)          (ptl2)
    71 #define GET_FRAME_ADDRESS_ARCH(ptl3, i)         ((uintptr_t)((((pte_t *)(ptl3))[(i)].frame_address) << 12))
     70#define GET_FRAME_ADDRESS_ARCH(ptl3, i)         ((uintptr_t) MA2PA((((pte_t *) (ptl3))[(i)].frame_address) << 12))
    7271
    7372#define SET_PTL0_ADDRESS_ARCH(ptl0) { \
    7473        mmuext_op_t mmu_ext; \
     74        \
    7575        mmu_ext.cmd = MMUEXT_NEW_BASEPTR; \
    76         mmu_ext.arg1.mfn = ADDR2PFN(PA2MA(ptl0)); \
     76        mmu_ext.mfn = ADDR2PFN(PA2MA(ptl0)); \
    7777        xen_mmuext_op(&mmu_ext, 1, NULL, DOMID_SELF); \
    7878}
     79
    7980#define SET_PTL1_ADDRESS_ARCH(ptl0, i, a) { \
    8081        mmu_update_t update; \
     82        \
    8183        update.ptr = PA2MA(KA2PA(&((pte_t *) (ptl0))[(i)])); \
    82         update.val = PA2MA(a); \
     84        update.val = PA2MA(a) | 0x0003; \
    8385        xen_mmu_update(&update, 1, NULL, DOMID_SELF); \
    8486}
    8587#define SET_PTL2_ADDRESS_ARCH(ptl1, i, a)
    8688#define SET_PTL3_ADDRESS_ARCH(ptl2, i, a)
    87 #define SET_FRAME_ADDRESS_ARCH(ptl3, i, a) { \
    88         mmu_update_t update; \
    89         update.ptr = PA2MA(KA2PA(&((pte_t *) (ptl3))[(i)])); \
    90         update.val = PA2MA(a); \
    91         xen_mmu_update(&update, 1, NULL, DOMID_SELF); \
    92 }
    93 
    94 #define GET_PTL1_FLAGS_ARCH(ptl0, i)            get_pt_flags((pte_t *)(ptl0), (index_t)(i))
     89#define SET_FRAME_ADDRESS_ARCH(ptl3, i, a)      (((pte_t *) (ptl3))[(i)].frame_address = PA2MA(a) >> 12)
     90
     91#define GET_PTL1_FLAGS_ARCH(ptl0, i)            get_pt_flags((pte_t *) (ptl0), (index_t)(i))
    9592#define GET_PTL2_FLAGS_ARCH(ptl1, i)            PAGE_PRESENT
    9693#define GET_PTL3_FLAGS_ARCH(ptl2, i)            PAGE_PRESENT
    97 #define GET_FRAME_FLAGS_ARCH(ptl3, i)           get_pt_flags((pte_t *)(ptl3), (index_t)(i))
    98 
    99 #define SET_PTL1_FLAGS_ARCH(ptl0, i, x)         set_pt_flags((pte_t *)(ptl0), (index_t)(i), (x))
     94#define GET_FRAME_FLAGS_ARCH(ptl3, i)           get_pt_flags((pte_t *) (ptl3), (index_t)(i))
     95
     96#define SET_PTL1_FLAGS_ARCH(ptl0, i, x)         set_pt_flags((pte_t *) (ptl0), (index_t)(i), (x))
    10097#define SET_PTL2_FLAGS_ARCH(ptl1, i, x)
    10198#define SET_PTL3_FLAGS_ARCH(ptl2, i, x)
    102 #define SET_FRAME_FLAGS_ARCH(ptl3, i, x)        set_pt_flags((pte_t *)(ptl3), (index_t)(i), (x))
     99#define SET_FRAME_FLAGS_ARCH(ptl3, i, x)                set_pt_flags((pte_t *) (ptl3), (index_t)(i), (x))
    103100
    104101#define PTE_VALID_ARCH(p)                       (*((uint32_t *) (p)) != 0)
     
    114111#include <arch/mm/frame.h>
    115112#include <typedefs.h>
     113#include <arch/hypercall.h>
    116114
    117115/* Page fault error codes. */
     
    145143} __attribute__ ((packed));
    146144
     145typedef struct {
     146        uint64_t ptr;      /**< Machine address of PTE */
     147        union {            /**< New contents of PTE */
     148                uint64_t val;
     149                pte_t pte;
     150        };
     151} mmu_update_t;
     152
     153typedef struct {
     154        unsigned int cmd;
     155        union {
     156                unsigned long mfn;
     157                unsigned long linear_addr;
     158        };
     159        union {
     160                unsigned int nr_ents;
     161                void *vcpumask;
     162        };
     163} mmuext_op_t;
     164
     165static inline int xen_update_va_mapping(const void *va, const pte_t pte, const unsigned int flags)
     166{
     167        return hypercall4(XEN_UPDATE_VA_MAPPING, va, pte, 0, flags);
     168}
     169
     170static inline int xen_mmu_update(const mmu_update_t *req, const unsigned int count, unsigned int *success_count, domid_t domid)
     171{
     172        return hypercall4(XEN_MMU_UPDATE, req, count, success_count, domid);
     173}
     174
     175static inline int xen_mmuext_op(const mmuext_op_t *op, const unsigned int count, unsigned int *success_count, domid_t domid)
     176{
     177        return hypercall4(XEN_MMUEXT_OP, op, count, success_count, domid);
     178}
     179
    147180static inline int get_pt_flags(pte_t *pt, index_t i)
    148181{
Note: See TracChangeset for help on using the changeset viewer.