• 阅读笔记---第三章 Xen信息页


    1、文件/xen/include/public/xen.h

    2、第一个数据结构:启动信息页strat_info,启动信息页是GuestOS内核启动时,由Xen映射到GusetOS内存空间的一个物理页面,其中包含了GuestOS内核启动所需要的所有信息。代码如下:

    #define MAX_GUEST_CMDLINE 1024
    typedef struct start_info {
        /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME.    */
        char magic[32];             /* "xen-<version>-<platform>".            */
        unsigned long nr_pages;     /* Total pages allocated to this domain.  */
        unsigned long shared_info;  /* MACHINE address of shared info struct. */
        uint32_t flags;             /* SIF_xxx flags.                         */
        unsigned long store_mfn;    /* MACHINE page number of shared page. 用于和XenStore通信的共享内存页面的机器页号。*/
        uint32_t store_evtchn;      /* Event channel for store communication. 用于和XenStore通信服务的事件通道端口号。*/
        unsigned long console_mfn;  /* MACHINE address of console page.       */
        uint32_t console_evtchn;    /* Event channel for console messages.    */
        unsigned int store_mfn_gref;  /* to make store_mfn -kcr */
        /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME).     */
        unsigned long pt_base;      /* VIRTUAL address of page directory.     */
        unsigned long nr_pt_frames; /* Number of bootstrap p.t. frames.       */
        unsigned long mfn_list;     /* VIRTUAL address of page-frame list.    */
        unsigned long mod_start;    /* VIRTUAL address of pre-loaded module.  */
        unsigned long mod_len;      /* Size (bytes) of pre-loaded module.     */
        int8_t cmd_line[MAX_GUEST_CMDLINE];
        unsigned long min_mfn;      /* min mfn (min_page in xen)              */
    } start_info_t;
    
    关键解读:
    (1)store_mfn和store_etchn与设备XenStore相关,由页号和事件通道端口号组成的(mfn,evtchn)键值对共同确定了属于某一Domain的XenStore设备,这种形式在Xen系统中应用广泛。

    (2)在Xen系统中,只有XenStore和console这两种设备是在启动信息页定义的,其他设备(块设备、网络设备等)都是通过XenStore来定义。

    3、第二个重要数据结构:shared_info,共享信息页

    启动信息页只在Domain启动或者恢复的时候才能发挥作用,也只能在这个时候被更新;与之不同,共享信息页在整个过程中都发挥作用,且能够在整个运行过程中被动态新。能够被Xen和GuestOS同时访问,用来在Xen和GuestOS之间共享和传递信息。

            共享信息页主要收集:VCPU状态信息、时钟信息和事件通道(虚拟中断)状态信息等。

    struct shared_info {
        struct vcpu_info vcpu_info[XEN_LEGACY_MAX_VCPUS];  /* VCPU信息结构体数组 */
    
        xen_ulong_t evtchn_pending[sizeof(xen_ulong_t) * 8]; /* 事件通道pending */
        xen_ulong_t evtchn_mask[sizeof(xen_ulong_t) * 8];   /* 事件通道掩码*/
    
    
        /*
         * Wallclock time: updated only by control software. Guests should base
         * their gettimeofday() syscall on this wallclock-base value.
         */
        uint32_t wc_version;      /* Version counter: see vcpu_time_info_t. */
        uint32_t wc_sec;          /* Secs  00:00:00 UTC, Jan 1, 1970.  */
        uint32_t wc_nsec;         /* Nsecs 00:00:00 UTC, Jan 1, 1970.  */
    
    
        struct arch_shared_info arch; /* VCPU体系结构信息*/
    
    
    };
    

    关键点:

    (1)在Xen系统中,每个事件通道都有一对(pending,mask)标志位与之相对应。如过在x86平台下,每个Domain分配的事件通道个数为:(unsign long) * (sizeof(unsigned long)) * 8 = 1024。 evtchn_pending数组中的pending标志位表示与其对应的事件通道中有未处理的事件:只能Xen设置,GuestOS清除;evtchn_mask数组中的mask标识未用来屏蔽该事件通道的通知,只能有GuestOS进行更新。

    (2)arch_shared_info结构提目前定义于/xen/include/arch-x86/xen.h,这一点改进非常好,因为这样就将不同平台的支持隔离开来,相应的对arm平台的支持文件就可以放在/xen/include/arch-arm/下了。这是linux kernel中通用的做法。

  • 相关阅读:
    如何让xcode自动检查内存泄露
    Property's synthesized getter follows Cocoa naming convention for returning
    Warning: The Copy Bundle Resources build phase contains this target's Info.plist file 'Info
    iPhone开发过程中调试多次Release问题 message sent to deallocated
    委托 详解
    UINavigationController 、UINavigationBar 、UINavigationItem 超清晰直观详解(扩展)
    代码书写规范(摸索、试行)
    简述 IOS中的LazyLoad思想
    UIImageView 详解
    20140413 科技脉搏-风平浪静,默默成长
  • 原文地址:https://www.cnblogs.com/javaadu/p/11742665.html
Copyright © 2020-2023  润新知