ia64/xen-unstable

view xen/common/multicall.c @ 10570:8dc4af3f192c

[IA64] Implement and use DOM0_DOMAIN_STEUP.

DOM0_GETMEMLIST now reads ptes and use gpfn.
Domain builder reworked: calls DOMAIN_SETUP, setup start_info page.
SAL data are now in domain memory.
is_vti field added in domain.arch.
Many cleanups (indentation, static, warnings).

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Wed Jul 05 09:28:32 2006 -0600 (2006-07-05)
parents 4e1b8be54311
children 5fc926b58609
line source
1 /******************************************************************************
2 * multicall.c
3 */
5 #include <xen/config.h>
6 #include <xen/types.h>
7 #include <xen/lib.h>
8 #include <xen/mm.h>
9 #include <xen/perfc.h>
10 #include <xen/sched.h>
11 #include <xen/event.h>
12 #include <xen/multicall.h>
13 #include <xen/guest_access.h>
14 #include <asm/current.h>
15 #include <asm/hardirq.h>
17 struct mc_state mc_state[NR_CPUS];
19 long
20 do_multicall(
21 XEN_GUEST_HANDLE(multicall_entry_t) call_list, unsigned int nr_calls)
22 {
23 struct mc_state *mcs = &mc_state[smp_processor_id()];
24 unsigned int i;
26 if ( unlikely(__test_and_set_bit(_MCSF_in_multicall, &mcs->flags)) )
27 {
28 DPRINTK("Multicall reentry is disallowed.\n");
29 return -EINVAL;
30 }
32 if ( unlikely(!guest_handle_okay(call_list, nr_calls)) )
33 goto fault;
35 for ( i = 0; i < nr_calls; i++ )
36 {
37 if ( hypercall_preempt_check() )
38 goto preempted;
40 if ( unlikely(__copy_from_guest(&mcs->call, call_list, 1)) )
41 goto fault;
43 do_multicall_call(&mcs->call);
45 #ifndef NDEBUG
46 {
47 /*
48 * Deliberately corrupt the contents of the multicall structure.
49 * The caller must depend only on the 'result' field on return.
50 */
51 struct multicall_entry corrupt;
52 memset(&corrupt, 0xAA, sizeof(corrupt));
53 (void)__copy_to_guest(call_list, &corrupt, 1);
54 }
55 #endif
57 if ( unlikely(__copy_field_to_guest(call_list, &mcs->call, result)) )
58 goto fault;
60 if ( test_bit(_MCSF_call_preempted, &mcs->flags) )
61 {
62 /* Copy the sub-call continuation. */
63 (void)__copy_to_guest(call_list, &mcs->call, 1);
64 goto preempted;
65 }
67 guest_handle_add_offset(call_list, 1);
68 }
70 mcs->flags = 0;
71 return 0;
73 fault:
74 mcs->flags = 0;
75 return -EFAULT;
77 preempted:
78 mcs->flags = 0;
79 return hypercall_create_continuation(
80 __HYPERVISOR_multicall, "hi", call_list, nr_calls-i);
81 }
83 /*
84 * Local variables:
85 * mode: C
86 * c-set-style: "BSD"
87 * c-basic-offset: 4
88 * tab-width: 4
89 * indent-tabs-mode: nil
90 * End:
91 */