debuggers.hg

view xen/include/asm-x86/div64.h @ 22855:1d1eec7e1fb4

xl: Perform minimal validation of virtual disk file while parsing config file

This patch performs some very basic validation on the virtual disk
file passed through the config file. This validation ensures that we
don't go too far with the initialization like spawn qemu and more
while there could be some potentially fundamental issues.

[ Patch fixed up to work with PHYSTYPE_EMPTY 22808:6ec61438713a -iwj ]

Signed-off-by: Kamala Narasimhan <kamala.narasimhan@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Kamala Narasimhan <kamala.narasimhan@gmail.com>
date Tue Jan 25 18:09:49 2011 +0000 (2011-01-25)
parents 5ccf8bbf8628
children
line source
1 #ifndef __I386_DIV64
2 #define __I386_DIV64
4 #include <xen/types.h>
6 #if BITS_PER_LONG == 64
8 #define do_div(n,base) ({ \
9 uint32_t __base = (base); \
10 uint32_t __rem; \
11 __rem = ((uint64_t)(n)) % __base; \
12 (n) = ((uint64_t)(n)) / __base; \
13 __rem; \
14 })
16 #else
18 /*
19 * do_div() is NOT a C function. It wants to return
20 * two values (the quotient and the remainder), but
21 * since that doesn't work very well in C, what it
22 * does is:
23 *
24 * - modifies the 64-bit dividend _in_place_
25 * - returns the 32-bit remainder
26 *
27 * This ends up being the most efficient "calling
28 * convention" on x86.
29 */
30 #define do_div(n,base) ({ \
31 unsigned long __upper, __low, __high, __mod, __base; \
32 __base = (base); \
33 asm ( "" : "=a" (__low), "=d" (__high) : "A" (n) ); \
34 __upper = __high; \
35 if ( __high ) \
36 { \
37 __upper = __high % (__base); \
38 __high = __high / (__base); \
39 } \
40 asm ( "divl %2" \
41 : "=a" (__low), "=d" (__mod) \
42 : "rm" (__base), "0" (__low), "1" (__upper) ); \
43 asm ( "" : "=A" (n) : "a" (__low), "d" (__high) ); \
44 __mod; \
45 })
47 #endif
49 #endif