ia64/xen-unstable

view xen/common/multicall.c @ 9776:72f9c751d3ea

Replace &foo[0] with foo where the latter seems cleaner
(which is usually, and particularly when its an argument
to one of the bitops functions).

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Apr 19 18:32:20 2006 +0100 (2006-04-19)
parents 53b0dc1cb1db
children 4e1b8be54311
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 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 */