ia64/xen-unstable

changeset 5480:8f10bad91451

bitkeeper revision 1.1713.2.2 (42b2ebb7w1AbEWudFq4LvJe0d7ByxQ)

two new files for VTI patch

Signed-off-by Anthony Xu <Anthony.xu@intel.com>
Signed-off-by Eddie Dong <Eddie.dong@intel.com>
Signed-off-by Kevin Tian <Kevin.tian@intel.com>
author djm@kirby.fc.hp.com
date Fri Jun 17 15:26:47 2005 +0000 (2005-06-17)
parents 38763dfb2287
children efc42f95dc7f
files .rootkeys xen/arch/ia64/mm.c xen/arch/ia64/vmx_hypercall.c
line diff
     1.1 --- a/.rootkeys	Thu Jun 16 19:36:55 2005 +0000
     1.2 +++ b/.rootkeys	Fri Jun 17 15:26:47 2005 +0000
     1.3 @@ -1109,6 +1109,7 @@ 421098b3LYAS8xJkQiGP7tiTlyBt0Q xen/arch/
     1.4  421098b3ys5GAr4z6_H1jD33oem82g xen/arch/ia64/irq.c
     1.5  4272a8e4lavI6DrTvqaIhXeR5RuKBw xen/arch/ia64/ivt.S
     1.6  421098b3Heh72KuoVlND3CH6c0B0aA xen/arch/ia64/lib/Makefile
     1.7 +42b2eaeez20voHWlBDjrqORiNg6uhg xen/arch/ia64/mm.c
     1.8  421098b3O0MYMUsmYVFy84VV_1gFwQ xen/arch/ia64/mm_init.c
     1.9  428b9f38Gp0KcPokG9Nq5v1rGk2FkA xen/arch/ia64/mmio.c
    1.10  425ae516maKAsHBJVSzs19cdRgt3Nw xen/arch/ia64/patch/linux-2.6.11/cpumask.h
    1.11 @@ -1207,6 +1208,7 @@ 421098b6M2WhsJ_ZMzFamAQcdc5gzw xen/arch/
    1.12  428b9f38PglyXM-mJJfo19ycuQrEhw xen/arch/ia64/vlsapic.c
    1.13  428b9f38EmpBsMHL3WbOZoieteBGdQ xen/arch/ia64/vmmu.c
    1.14  428b9f38hU-X5aX0MIY3EU0Yw4PjcA xen/arch/ia64/vmx_entry.S
    1.15 +42b2eaf3YR7Sfx76IvKeqfHJiU6qXw xen/arch/ia64/vmx_hypercall.c
    1.16  428b9f38S76bWI96g7uPLmE-uAcmdg xen/arch/ia64/vmx_init.c
    1.17  428b9f385AMSyCRYBsckQClQY4ZgHA xen/arch/ia64/vmx_interrupt.c
    1.18  428b9f380IOjPmj0N6eelH-WJjl1xg xen/arch/ia64/vmx_ivt.S
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/xen/arch/ia64/mm.c	Fri Jun 17 15:26:47 2005 +0000
     2.3 @@ -0,0 +1,141 @@
     2.4 +/******************************************************************************
     2.5 + * arch/ia64/mm.c
     2.6 + * 
     2.7 + * Copyright (c) 2002-2005 K A Fraser
     2.8 + * Copyright (c) 2004 Christian Limpach
     2.9 + * Copyright (c) 2005, Intel Corporation.
    2.10 + *  Xuefei Xu (Anthony Xu) (Anthony.xu@intel.com)
    2.11 + * 
    2.12 + * This program is free software; you can redistribute it and/or modify
    2.13 + * it under the terms of the GNU General Public License as published by
    2.14 + * the Free Software Foundation; either version 2 of the License, or
    2.15 + * (at your option) any later version.
    2.16 + * 
    2.17 + * This program is distributed in the hope that it will be useful,
    2.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.20 + * GNU General Public License for more details.
    2.21 + * 
    2.22 + * You should have received a copy of the GNU General Public License
    2.23 + * along with this program; if not, write to the Free Software
    2.24 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2.25 + */
    2.26 +
    2.27 +/*
    2.28 + * A description of the x86 page table API:
    2.29 + * 
    2.30 + * Domains trap to do_mmu_update with a list of update requests.
    2.31 + * This is a list of (ptr, val) pairs, where the requested operation
    2.32 + * is *ptr = val.
    2.33 + * 
    2.34 + * Reference counting of pages:
    2.35 + * ----------------------------
    2.36 + * Each page has two refcounts: tot_count and type_count.
    2.37 + * 
    2.38 + * TOT_COUNT is the obvious reference count. It counts all uses of a
    2.39 + * physical page frame by a domain, including uses as a page directory,
    2.40 + * a page table, or simple mappings via a PTE. This count prevents a
    2.41 + * domain from releasing a frame back to the free pool when it still holds
    2.42 + * a reference to it.
    2.43 + * 
    2.44 + * TYPE_COUNT is more subtle. A frame can be put to one of three
    2.45 + * mutually-exclusive uses: it might be used as a page directory, or a
    2.46 + * page table, or it may be mapped writable by the domain [of course, a
    2.47 + * frame may not be used in any of these three ways!].
    2.48 + * So, type_count is a count of the number of times a frame is being 
    2.49 + * referred to in its current incarnation. Therefore, a page can only
    2.50 + * change its type when its type count is zero.
    2.51 + * 
    2.52 + * Pinning the page type:
    2.53 + * ----------------------
    2.54 + * The type of a page can be pinned/unpinned with the commands
    2.55 + * MMUEXT_[UN]PIN_L?_TABLE. Each page can be pinned exactly once (that is,
    2.56 + * pinning is not reference counted, so it can't be nested).
    2.57 + * This is useful to prevent a page's type count falling to zero, at which
    2.58 + * point safety checks would need to be carried out next time the count
    2.59 + * is increased again.
    2.60 + * 
    2.61 + * A further note on writable page mappings:
    2.62 + * -----------------------------------------
    2.63 + * For simplicity, the count of writable mappings for a page may not
    2.64 + * correspond to reality. The 'writable count' is incremented for every
    2.65 + * PTE which maps the page with the _PAGE_RW flag set. However, for
    2.66 + * write access to be possible the page directory entry must also have
    2.67 + * its _PAGE_RW bit set. We do not check this as it complicates the 
    2.68 + * reference counting considerably [consider the case of multiple
    2.69 + * directory entries referencing a single page table, some with the RW
    2.70 + * bit set, others not -- it starts getting a bit messy].
    2.71 + * In normal use, this simplification shouldn't be a problem.
    2.72 + * However, the logic can be added if required.
    2.73 + * 
    2.74 + * One more note on read-only page mappings:
    2.75 + * -----------------------------------------
    2.76 + * We want domains to be able to map pages for read-only access. The
    2.77 + * main reason is that page tables and directories should be readable
    2.78 + * by a domain, but it would not be safe for them to be writable.
    2.79 + * However, domains have free access to rings 1 & 2 of the Intel
    2.80 + * privilege model. In terms of page protection, these are considered
    2.81 + * to be part of 'supervisor mode'. The WP bit in CR0 controls whether
    2.82 + * read-only restrictions are respected in supervisor mode -- if the 
    2.83 + * bit is clear then any mapped page is writable.
    2.84 + * 
    2.85 + * We get round this by always setting the WP bit and disallowing 
    2.86 + * updates to it. This is very unlikely to cause a problem for guest
    2.87 + * OS's, which will generally use the WP bit to simplify copy-on-write
    2.88 + * implementation (in that case, OS wants a fault when it writes to
    2.89 + * an application-supplied buffer).
    2.90 + */
    2.91 +
    2.92 +#include <xen/config.h>
    2.93 +#include <public/xen.h>
    2.94 +#include <xen/init.h>
    2.95 +#include <xen/lib.h>
    2.96 +#include <xen/mm.h>
    2.97 +#include <xen/errno.h>
    2.98 +#include <asm/vmx_vcpu.h>
    2.99 +#include <asm/vmmu.h>
   2.100 +#include <asm/regionreg.h>
   2.101 +
   2.102 +/*
   2.103 +        uregs->ptr is virtual address
   2.104 +        uregs->val is pte value
   2.105 + */
   2.106 +#ifdef CONFIG_VTI
   2.107 +int do_mmu_update(mmu_update_t *ureqs,u64 count,u64 *pdone,u64 foreigndom)
   2.108 +{
   2.109 +    int i,cmd;
   2.110 +    u64 mfn, gpfn;
   2.111 +    VCPU *vcpu;
   2.112 +    mmu_update_t req;
   2.113 +    ia64_rr rr;
   2.114 +    thash_cb_t *hcb;
   2.115 +    thash_data_t entry={0};
   2.116 +    vcpu = current;
   2.117 +    hcb = vmx_vcpu_get_vtlb(vcpu);
   2.118 +    for ( i = 0; i < count; i++ )
   2.119 +    {
   2.120 +        copy_from_user(&req, ureqs, sizeof(req));
   2.121 +        cmd = req.ptr&3;
   2.122 +        req.ptr &= ~3;
   2.123 +        if(cmd ==MMU_NORMAL_PT_UPDATE){
   2.124 +            entry.page_flags = req.val;
   2.125 +            entry.locked = 1;
   2.126 +            entry.tc = 1;
   2.127 +            entry.cl = DSIDE_TLB;
   2.128 +            rr = vmx_vcpu_rr(vcpu, req.ptr);
   2.129 +            entry.ps = rr.ps;
   2.130 +            entry.rid = rr.rid;
   2.131 +            vtlb_insert(hcb, &entry, req.ptr);
   2.132 +        }else if(cmd == MMU_MACHPHYS_UPDATE){
   2.133 +            mfn = req.ptr >>PAGE_SHIFT;
   2.134 +            gpfn = req.val;
   2.135 +            set_machinetophys(mfn,gpfn);
   2.136 +        }else{
   2.137 +            printf("Unkown command of mmu_update:ptr: %lx,val: %lx \n",req.ptr,req.val);
   2.138 +            while(1);
   2.139 +        }
   2.140 +        ureqs ++;
   2.141 +    }
   2.142 +    return 0;
   2.143 +}
   2.144 +#endif
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/xen/arch/ia64/vmx_hypercall.c	Fri Jun 17 15:26:47 2005 +0000
     3.3 @@ -0,0 +1,186 @@
     3.4 +/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
     3.5 +/*
     3.6 + * vmx_hyparcall.c: handling hypercall from domain
     3.7 + * Copyright (c) 2005, Intel Corporation.
     3.8 + *
     3.9 + * This program is free software; you can redistribute it and/or modify it
    3.10 + * under the terms and conditions of the GNU General Public License,
    3.11 + * version 2, as published by the Free Software Foundation.
    3.12 + *
    3.13 + * This program is distributed in the hope it will be useful, but WITHOUT
    3.14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.15 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
    3.16 + * more details.
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License along with
    3.19 + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    3.20 + * Place - Suite 330, Boston, MA 02111-1307 USA.
    3.21 + *
    3.22 + *  Xuefei Xu (Anthony Xu) (Anthony.xu@intel.com)
    3.23 + */
    3.24 +
    3.25 +#include <xen/config.h>
    3.26 +#include <xen/errno.h>
    3.27 +#include <asm/vmx_vcpu.h>
    3.28 +#include <public/xen.h>
    3.29 +#include <public/event_channel.h>
    3.30 +#include <asm/vmmu.h>
    3.31 +#include <asm/tlb.h>
    3.32 +#include <asm/regionreg.h>
    3.33 +#include <asm/page.h>
    3.34 +#include <xen/mm.h>
    3.35 +
    3.36 +
    3.37 +void hyper_not_support(void)
    3.38 +{
    3.39 +    VCPU *vcpu=current;
    3.40 +    vmx_vcpu_set_gr(vcpu, 8, -1, 0);
    3.41 +    vmx_vcpu_increment_iip(vcpu);
    3.42 +}
    3.43 +
    3.44 +void hyper_mmu_update(void)
    3.45 +{
    3.46 +    VCPU *vcpu=current;
    3.47 +    u64 r32,r33,r34,r35,ret;
    3.48 +    vmx_vcpu_get_gr(vcpu,16,&r32);
    3.49 +    vmx_vcpu_get_gr(vcpu,17,&r33);
    3.50 +    vmx_vcpu_get_gr(vcpu,18,&r34);
    3.51 +    vmx_vcpu_get_gr(vcpu,19,&r35);
    3.52 +    ret=do_mmu_update((mmu_update_t*)r32,r33,r34,r35);
    3.53 +    vmx_vcpu_set_gr(vcpu, 8, ret, 0);
    3.54 +    vmx_vcpu_increment_iip(vcpu);
    3.55 +}
    3.56 +
    3.57 +void hyper_dom_mem_op(void)
    3.58 +{
    3.59 +    VCPU *vcpu=current;
    3.60 +    u64 r32,r33,r34,r35,r36;
    3.61 +    u64 ret;
    3.62 +    vmx_vcpu_get_gr(vcpu,16,&r32);
    3.63 +    vmx_vcpu_get_gr(vcpu,17,&r33);
    3.64 +    vmx_vcpu_get_gr(vcpu,18,&r34);
    3.65 +    vmx_vcpu_get_gr(vcpu,19,&r35);
    3.66 +    vmx_vcpu_get_gr(vcpu,20,&r36);
    3.67 +    ret=do_dom_mem_op(r32,(u64 *)r33,r34,r35,r36);
    3.68 +    printf("do_dom_mem return value: %lx\n", ret);
    3.69 +    vmx_vcpu_set_gr(vcpu, 8, ret, 0);
    3.70 +
    3.71 +    vmx_vcpu_increment_iip(vcpu);
    3.72 +}
    3.73 +
    3.74 +
    3.75 +void hyper_sched_op(void)
    3.76 +{
    3.77 +    VCPU *vcpu=current;
    3.78 +    u64 r32,ret;
    3.79 +    vmx_vcpu_get_gr(vcpu,16,&r32);
    3.80 +    ret=do_sched_op(r32);
    3.81 +    vmx_vcpu_set_gr(vcpu, 8, ret, 0);
    3.82 +
    3.83 +    vmx_vcpu_increment_iip(vcpu);
    3.84 +}
    3.85 +
    3.86 +void hyper_dom0_op(void)
    3.87 +{
    3.88 +    VCPU *vcpu=current;
    3.89 +    u64 r32,ret;
    3.90 +    vmx_vcpu_get_gr(vcpu,16,&r32);
    3.91 +    ret=do_dom0_op((dom0_op_t *)r32);
    3.92 +    vmx_vcpu_set_gr(vcpu, 8, ret, 0);
    3.93 +
    3.94 +    vmx_vcpu_increment_iip(vcpu);
    3.95 +}
    3.96 +
    3.97 +void hyper_event_channel_op(void)
    3.98 +{
    3.99 +    VCPU *vcpu=current;
   3.100 +    u64 r32,ret;
   3.101 +    vmx_vcpu_get_gr(vcpu,16,&r32);
   3.102 +    ret=do_event_channel_op((evtchn_op_t *)r32);
   3.103 +    vmx_vcpu_set_gr(vcpu, 8, ret, 0);
   3.104 +    vmx_vcpu_increment_iip(vcpu);
   3.105 +}
   3.106 +
   3.107 +void hyper_xen_version(void)
   3.108 +{
   3.109 +    VCPU *vcpu=current;
   3.110 +    u64 r32,ret;
   3.111 +    vmx_vcpu_get_gr(vcpu,16,&r32);
   3.112 +    ret=do_xen_version((int )r32);
   3.113 +    vmx_vcpu_set_gr(vcpu, 8, ret, 0);
   3.114 +    vmx_vcpu_increment_iip(vcpu);
   3.115 +}
   3.116 +
   3.117 +static int do_lock_page(VCPU *vcpu, u64 va, u64 lock)
   3.118 +{
   3.119 +    int i;
   3.120 +    ia64_rr rr;
   3.121 +    thash_cb_t *hcb;
   3.122 +    hcb = vmx_vcpu_get_vtlb(vcpu);
   3.123 +    rr = vmx_vcpu_rr(vcpu, va);
   3.124 +    return thash_lock_tc(hcb, va ,1U<<rr.ps, rr.rid, DSIDE_TLB, lock);
   3.125 +}
   3.126 +
   3.127 +/*
   3.128 + * Lock guest page in vTLB, so that it's not relinquished by recycle
   3.129 + * session when HV is servicing that hypercall.
   3.130 + */
   3.131 +void hyper_lock_page(void)
   3.132 +{
   3.133 +//TODO:
   3.134 +    VCPU *vcpu=current;
   3.135 +    u64 va,lock, ret;
   3.136 +    vmx_vcpu_get_gr(vcpu,16,&va);
   3.137 +    vmx_vcpu_get_gr(vcpu,17,&lock);
   3.138 +    ret=do_lock_page(vcpu, va, lock);
   3.139 +    vmx_vcpu_set_gr(vcpu, 8, ret, 0);
   3.140 +
   3.141 +    vmx_vcpu_increment_iip(vcpu);
   3.142 +}
   3.143 +
   3.144 +static int do_set_shared_page(VCPU *vcpu, u64 gpa)
   3.145 +{
   3.146 +    u64 shared_info, o_info;
   3.147 +    if(vcpu->domain!=dom0)
   3.148 +        return -EPERM;
   3.149 +    shared_info = __gpa_to_mpa(vcpu->domain, gpa);
   3.150 +    o_info = (u64)vcpu->domain->shared_info;
   3.151 +    vcpu->domain->shared_info= (shared_info_t *)__va(shared_info);
   3.152 +
   3.153 +    /* Copy existing shared info into new page */
   3.154 +    if (!o_info) {
   3.155 +	memcpy((void*)vcpu->domain->shared_info, (void*)o_info, PAGE_SIZE);
   3.156 +	/* If original page belongs to xen heap, then relinguish back
   3.157 +	 * to xen heap. Or else, leave to domain itself to decide.
   3.158 +	 */
   3.159 +	if (likely(IS_XEN_HEAP_FRAME(virt_to_page(o_info))))
   3.160 +		free_xenheap_page(o_info);
   3.161 +    }
   3.162 +    return 0;
   3.163 +}
   3.164 +
   3.165 +void hyper_set_shared_page(void)
   3.166 +{
   3.167 +    VCPU *vcpu=current;
   3.168 +    u64 gpa,ret;
   3.169 +    vmx_vcpu_get_gr(vcpu,16,&gpa);
   3.170 +
   3.171 +    ret=do_set_shared_page(vcpu, gpa);
   3.172 +    vmx_vcpu_set_gr(vcpu, 8, ret, 0);
   3.173 +
   3.174 +    vmx_vcpu_increment_iip(vcpu);
   3.175 +}
   3.176 +
   3.177 +/*
   3.178 +void hyper_grant_table_op(void)
   3.179 +{
   3.180 +    VCPU *vcpu=current;
   3.181 +    u64 r32,r33,r34,ret;
   3.182 +    vmx_vcpu_get_gr(vcpu,16,&r32);
   3.183 +    vmx_vcpu_get_gr(vcpu,17,&r33);
   3.184 +    vmx_vcpu_get_gr(vcpu,18,&r34);
   3.185 +
   3.186 +    ret=do_grant_table_op((unsigned int)r32, (void *)r33, (unsigned int)r34);
   3.187 +    vmx_vcpu_set_gr(vcpu, 8, ret, 0);
   3.188 +}
   3.189 +*/