aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/ia64/vmx_hypercall.c
blob: 5e0d8917ebe12a063ade56578366149fa62700fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
/*
 * vmx_hyparcall.c: handling hypercall from domain
 * Copyright (c) 2005, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope 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.
 *
 *  Xuefei Xu (Anthony Xu) (Anthony.xu@intel.com)
 */

#include <xen/config.h>
#include <xen/errno.h>
#include <asm/vmx_vcpu.h>
#include <public/xen.h>
#include <public/event_channel.h>
#include <asm/vmmu.h>
#include <asm/tlb.h>
#include <asm/regionreg.h>
#include <asm/page.h>
#include <xen/mm.h>


void hyper_not_support(void)
{
    VCPU *vcpu=current;
    vmx_vcpu_set_gr(vcpu, 8, -1, 0);
    vmx_vcpu_increment_iip(vcpu);
}

void hyper_mmu_update(void)
{
    VCPU *vcpu=current;
    u64 r32,r33,r34,r35,ret;
    vmx_vcpu_get_gr(vcpu,16,&r32);
    vmx_vcpu_get_gr(vcpu,17,&r33);
    vmx_vcpu_get_gr(vcpu,18,&r34);
    vmx_vcpu_get_gr(vcpu,19,&r35);
    ret=do_mmu_update((mmu_update_t*)r32,r33,r34,r35);
    vmx_vcpu_set_gr(vcpu, 8, ret, 0);
    vmx_vcpu_increment_iip(vcpu);
}

void hyper_dom_mem_op(void)
{
    VCPU *vcpu=current;
    u64 r32,r33,r34,r35,r36;
    u64 ret;
    vmx_vcpu_get_gr(vcpu,16,&r32);
    vmx_vcpu_get_gr(vcpu,17,&r33);
    vmx_vcpu_get_gr(vcpu,18,&r34);
    vmx_vcpu_get_gr(vcpu,19,&r35);
    vmx_vcpu_get_gr(vcpu,20,&r36);
    ret=do_dom_mem_op(r32,(u64 *)r33,r34,r35,r36);
    printf("do_dom_mem return value: %lx\n", ret);
    vmx_vcpu_set_gr(vcpu, 8, ret, 0);

    vmx_vcpu_increment_iip(vcpu);
}


void hyper_sched_op(void)
{
    VCPU *vcpu=current;
    u64 r32,ret;
    vmx_vcpu_get_gr(vcpu,16,&r32);
    ret=do_sched_op(r32);
    vmx_vcpu_set_gr(vcpu, 8, ret, 0);

    vmx_vcpu_increment_iip(vcpu);
}

void hyper_dom0_op(void)
{
    VCPU *vcpu=current;
    u64 r32,ret;
    vmx_vcpu_get_gr(vcpu,16,&r32);
    ret=do_dom0_op((dom0_op_t *)r32);
    vmx_vcpu_set_gr(vcpu, 8, ret, 0);

    vmx_vcpu_increment_iip(vcpu);
}

void hyper_event_channel_op(void)
{
    VCPU *vcpu=current;
    u64 r32,ret;
    vmx_vcpu_get_gr(vcpu,16,&r32);
    ret=do_event_channel_op((evtchn_op_t *)r32);
    vmx_vcpu_set_gr(vcpu, 8, ret, 0);
    vmx_vcpu_increment_iip(vcpu);
}

void hyper_xen_version(void)
{
    VCPU *vcpu=current;
    u64 r32,ret;
    vmx_vcpu_get_gr(vcpu,16,&r32);
    ret=do_xen_version((int )r32);
    vmx_vcpu_set_gr(vcpu, 8, ret, 0);
    vmx_vcpu_increment_iip(vcpu);
}

static int do_lock_page(VCPU *vcpu, u64 va, u64 lock)
{
    int i;
    ia64_rr rr;
    thash_cb_t *hcb;
    hcb = vmx_vcpu_get_vtlb(vcpu);
    rr = vmx_vcpu_rr(vcpu, va);
    return thash_lock_tc(hcb, va ,1U<<rr.ps, rr.rid, DSIDE_TLB, lock);
}

/*
 * Lock guest page in vTLB, so that it's not relinquished by recycle
 * session when HV is servicing that hypercall.
 */
void hyper_lock_page(void)
{
//TODO:
    VCPU *vcpu=current;
    u64 va,lock, ret;
    vmx_vcpu_get_gr(vcpu,16,&va);
    vmx_vcpu_get_gr(vcpu,17,&lock);
    ret=do_lock_page(vcpu, va, lock);
    vmx_vcpu_set_gr(vcpu, 8, ret, 0);

    vmx_vcpu_increment_iip(vcpu);
}

static int do_set_shared_page(VCPU *vcpu, u64 gpa)
{
    u64 shared_info, o_info;
    if(vcpu->domain!=dom0)
        return -EPERM;
    shared_info = __gpa_to_mpa(vcpu->domain, gpa);
    o_info = (u64)vcpu->domain->shared_info;
    vcpu->domain->shared_info= (shared_info_t *)__va(shared_info);

    /* Copy existing shared info into new page */
    if (!o_info) {
	memcpy((void*)vcpu->domain->shared_info, (void*)o_info, PAGE_SIZE);
	/* If original page belongs to xen heap, then relinguish back
	 * to xen heap. Or else, leave to domain itself to decide.
	 */
	if (likely(IS_XEN_HEAP_FRAME(virt_to_page(o_info))))
		free_xenheap_page(o_info);
    }
    return 0;
}

void hyper_set_shared_page(void)
{
    VCPU *vcpu=current;
    u64 gpa,ret;
    vmx_vcpu_get_gr(vcpu,16,&gpa);

    ret=do_set_shared_page(vcpu, gpa);
    vmx_vcpu_set_gr(vcpu, 8, ret, 0);

    vmx_vcpu_increment_iip(vcpu);
}

/*
void hyper_grant_table_op(void)
{
    VCPU *vcpu=current;
    u64 r32,r33,r34,ret;
    vmx_vcpu_get_gr(vcpu,16,&r32);
    vmx_vcpu_get_gr(vcpu,17,&r33);
    vmx_vcpu_get_gr(vcpu,18,&r34);

    ret=do_grant_table_op((unsigned int)r32, (void *)r33, (unsigned int)r34);
    vmx_vcpu_set_gr(vcpu, 8, ret, 0);
}
*/