⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 paging.h

📁 xen虚拟机源代码安装包
💻 H
📖 第 1 页 / 共 2 页
字号:
/****************************************************************************** * include/asm-x86/paging.h * * Common interface for paging support * Copyright (c) 2007 Advanced Micro Devices (Wei Huang)  * Parts of this code are Copyright (c) 2006 by XenSource Inc. * Parts of this code are Copyright (c) 2006 by Michael A Fetterman * Parts based on earlier work by Michael A Fetterman, Ian Pratt et al. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#ifndef _XEN_PAGING_H#define _XEN_PAGING_H#include <xen/mm.h>#include <public/domctl.h>#include <xen/sched.h>#include <xen/perfc.h>#include <xen/domain_page.h>#include <asm/flushtlb.h>#include <asm/domain.h>/***************************************************************************** * Macros to tell which paging mode a domain is in */#define PG_SH_shift    20#define PG_HAP_shift   21/* We're in one of the shadow modes */#define PG_SH_enable   (1U << PG_SH_shift)#define PG_HAP_enable  (1U << PG_HAP_shift)/* common paging mode bits */#define PG_mode_shift  10 /* Refcounts based on shadow tables instead of guest tables */#define PG_refcounts   (XEN_DOMCTL_SHADOW_ENABLE_REFCOUNT << PG_mode_shift)/* Enable log dirty mode */#define PG_log_dirty   (XEN_DOMCTL_SHADOW_ENABLE_LOG_DIRTY << PG_mode_shift)/* Xen does p2m translation, not guest */#define PG_translate   (XEN_DOMCTL_SHADOW_ENABLE_TRANSLATE << PG_mode_shift)/* Xen does not steal address space from the domain for its own booking; * requires VT or similar mechanisms */#define PG_external    (XEN_DOMCTL_SHADOW_ENABLE_EXTERNAL << PG_mode_shift)#define paging_mode_enabled(_d)   ((_d)->arch.paging.mode)#define paging_mode_shadow(_d)    ((_d)->arch.paging.mode & PG_SH_enable)#define paging_mode_hap(_d)       ((_d)->arch.paging.mode & PG_HAP_enable)#define paging_mode_refcounts(_d) ((_d)->arch.paging.mode & PG_refcounts)#define paging_mode_log_dirty(_d) ((_d)->arch.paging.mode & PG_log_dirty)#define paging_mode_translate(_d) ((_d)->arch.paging.mode & PG_translate)#define paging_mode_external(_d)  ((_d)->arch.paging.mode & PG_external)/* flags used for paging debug */#define PAGING_DEBUG_LOGDIRTY 0/***************************************************************************** * Mode-specific entry points into the shadow code.   * * These shouldn't be used directly by callers; rather use the functions * below which will indirect through this table as appropriate. */struct sh_emulate_ctxt;struct shadow_paging_mode {    void          (*detach_old_tables     )(struct vcpu *v);    int           (*x86_emulate_write     )(struct vcpu *v, unsigned long va,                                            void *src, u32 bytes,                                            struct sh_emulate_ctxt *sh_ctxt);    int           (*x86_emulate_cmpxchg   )(struct vcpu *v, unsigned long va,                                            unsigned long old,                                             unsigned long new,                                            unsigned int bytes,                                            struct sh_emulate_ctxt *sh_ctxt);#ifdef __i386__    int           (*x86_emulate_cmpxchg8b )(struct vcpu *v, unsigned long va,                                            unsigned long old_lo,                                             unsigned long old_hi,                                             unsigned long new_lo,                                            unsigned long new_hi,                                            struct sh_emulate_ctxt *sh_ctxt);#endif    mfn_t         (*make_monitor_table    )(struct vcpu *v);    void          (*destroy_monitor_table )(struct vcpu *v, mfn_t mmfn);    int           (*guess_wrmap           )(struct vcpu *v,                                             unsigned long vaddr, mfn_t gmfn);    /* For outsiders to tell what mode we're in */    unsigned int shadow_levels;};/************************************************//*        common paging interface               *//************************************************/struct paging_mode {    int           (*page_fault            )(struct vcpu *v, unsigned long va,                                            struct cpu_user_regs *regs);    int           (*invlpg                )(struct vcpu *v, unsigned long va);    unsigned long (*gva_to_gfn            )(struct vcpu *v, unsigned long va,                                            uint32_t *pfec);    void          (*update_cr3            )(struct vcpu *v, int do_locking);    void          (*update_paging_modes   )(struct vcpu *v);    void          (*write_p2m_entry       )(struct vcpu *v, unsigned long gfn,                                            l1_pgentry_t *p, mfn_t table_mfn,                                             l1_pgentry_t new,                                             unsigned int level);    int           (*write_guest_entry     )(struct vcpu *v, intpte_t *p,                                            intpte_t new, mfn_t gmfn);    int           (*cmpxchg_guest_entry   )(struct vcpu *v, intpte_t *p,                                            intpte_t *old, intpte_t new,                                            mfn_t gmfn);    void *        (*guest_map_l1e         )(struct vcpu *v, unsigned long va,                                            unsigned long *gl1mfn);    void          (*guest_get_eff_l1e     )(struct vcpu *v, unsigned long va,                                            void *eff_l1e);    unsigned int guest_levels;    /* paging support extension */    struct shadow_paging_mode shadow;};/***************************************************************************** * Log dirty code *//* allocate log dirty bitmap resource for recording dirty pages */int paging_alloc_log_dirty_bitmap(struct domain *d);/* free log dirty bitmap resource */void paging_free_log_dirty_bitmap(struct domain *d);/* enable log dirty */int paging_log_dirty_enable(struct domain *d);/* disable log dirty */int paging_log_dirty_disable(struct domain *d);/* log dirty initialization */void paging_log_dirty_init(struct domain *d,                           int  (*enable_log_dirty)(struct domain *d),                           int  (*disable_log_dirty)(struct domain *d),                           void (*clean_dirty_bitmap)(struct domain *d));/* mark a page as dirty */void paging_mark_dirty(struct domain *d, unsigned long guest_mfn);/* * Log-dirty radix tree indexing: *   All tree nodes are PAGE_SIZE bytes, mapped on-demand. *   Leaf nodes are simple bitmaps; 1 bit per guest pfn. *   Interior nodes are arrays of LOGDIRTY_NODE_ENTRIES mfns. * TODO: Dynamic radix tree height. Most guests will only need 2 levels. *       The fourth level is basically unusable on 32-bit Xen. * TODO2: Abstract out the radix-tree mechanics? */#define LOGDIRTY_NODE_ENTRIES (1 << PAGETABLE_ORDER)#define L1_LOGDIRTY_IDX(pfn) ((pfn) & ((1 << (PAGE_SHIFT+3)) - 1))#define L2_LOGDIRTY_IDX(pfn) (((pfn) >> (PAGE_SHIFT+3)) & \                              (LOGDIRTY_NODE_ENTRIES-1))#define L3_LOGDIRTY_IDX(pfn) (((pfn) >> (PAGE_SHIFT+3+PAGETABLE_ORDER)) & \                              (LOGDIRTY_NODE_ENTRIES-1))#if BITS_PER_LONG == 64#define L4_LOGDIRTY_IDX(pfn) (((pfn) >> (PAGE_SHIFT+3+PAGETABLE_ORDER*2)) & \                              (LOGDIRTY_NODE_ENTRIES-1))#else#define L4_LOGDIRTY_IDX(pfn) 0#endif/***************************************************************************** * Entry points into the paging-assistance code *//* Initialize the paging resource for vcpu struct. It is called by * vcpu_initialise() in domain.c */void paging_vcpu_init(struct vcpu *v);/* Set up the paging-assistance-specific parts of a domain struct at * start of day.  Called for every domain from arch_domain_create() */int paging_domain_init(struct domain *d);/* Handler for paging-control ops: operations from user-space to enable * and disable ephemeral shadow modes (test mode and log-dirty mode) and * manipulate the log-dirty bitmap. */int paging_domctl(struct domain *d, xen_domctl_shadow_op_t *sc,                  XEN_GUEST_HANDLE(void) u_domctl);/* Call when destroying a domain */void paging_teardown(struct domain *d);/* Call once all of the references to the domain have gone away */void paging_final_teardown(struct domain *d);/* Enable an arbitrary paging-assistance mode.  Call once at domain * creation. */int paging_enable(struct domain *d, u32 mode);/* Page fault handler

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -