debuggers.hg

view xen/include/asm-x86/msr.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 2762b6d3149c
children
line source
1 #ifndef __ASM_MSR_H
2 #define __ASM_MSR_H
4 #include "msr-index.h"
6 #ifndef __ASSEMBLY__
8 #include <xen/types.h>
9 #include <xen/percpu.h>
10 #include <xen/errno.h>
11 #include <asm/asm_defns.h>
13 #define rdmsr(msr,val1,val2) \
14 __asm__ __volatile__("rdmsr" \
15 : "=a" (val1), "=d" (val2) \
16 : "c" (msr))
18 #define rdmsrl(msr,val) do { unsigned long a__,b__; \
19 __asm__ __volatile__("rdmsr" \
20 : "=a" (a__), "=d" (b__) \
21 : "c" (msr)); \
22 val = a__ | ((u64)b__<<32); \
23 } while(0);
25 #define wrmsr(msr,val1,val2) \
26 __asm__ __volatile__("wrmsr" \
27 : /* no outputs */ \
28 : "c" (msr), "a" (val1), "d" (val2))
30 static inline void wrmsrl(unsigned int msr, __u64 val)
31 {
32 __u32 lo, hi;
33 lo = (__u32)val;
34 hi = (__u32)(val >> 32);
35 wrmsr(msr, lo, hi);
36 }
38 /* rdmsr with exception handling */
39 #define rdmsr_safe(msr,val) ({\
40 int _rc; \
41 uint32_t lo, hi; \
42 __asm__ __volatile__( \
43 "1: rdmsr\n2:\n" \
44 ".section .fixup,\"ax\"\n" \
45 "3: xorl %0,%0\n; xorl %1,%1\n" \
46 " movl %5,%2\n; jmp 2b\n" \
47 ".previous\n" \
48 _ASM_EXTABLE(1b, 3b) \
49 : "=a" (lo), "=d" (hi), "=&r" (_rc) \
50 : "c" (msr), "2" (0), "i" (-EFAULT)); \
51 val = lo | ((uint64_t)hi << 32); \
52 _rc; })
54 /* wrmsr with exception handling */
55 static inline int wrmsr_safe(unsigned int msr, uint64_t val)
56 {
57 int _rc;
58 uint32_t lo, hi;
59 lo = (uint32_t)val;
60 hi = (uint32_t)(val >> 32);
62 __asm__ __volatile__(
63 "1: wrmsr\n2:\n"
64 ".section .fixup,\"ax\"\n"
65 "3: movl %5,%0\n; jmp 2b\n"
66 ".previous\n"
67 _ASM_EXTABLE(1b, 3b)
68 : "=&r" (_rc)
69 : "c" (msr), "a" (lo), "d" (hi), "0" (0), "i" (-EFAULT));
70 return _rc;
71 }
73 #define rdtsc(low,high) \
74 __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
76 #define rdtscl(low) \
77 __asm__ __volatile__("rdtsc" : "=a" (low) : : "edx")
79 #if defined(__i386__)
80 #define rdtscll(val) \
81 __asm__ __volatile__("rdtsc" : "=A" (val))
82 #elif defined(__x86_64__)
83 #define rdtscll(val) do { \
84 unsigned int a,d; \
85 asm volatile("rdtsc" : "=a" (a), "=d" (d)); \
86 (val) = ((unsigned long)a) | (((unsigned long)d)<<32); \
87 } while(0)
88 #endif
90 #define write_tsc(val) wrmsrl(MSR_IA32_TSC, val)
92 #define write_rdtscp_aux(val) wrmsr(MSR_TSC_AUX, (val), 0)
94 #define rdpmc(counter,low,high) \
95 __asm__ __volatile__("rdpmc" \
96 : "=a" (low), "=d" (high) \
97 : "c" (counter))
100 DECLARE_PER_CPU(u64, efer);
101 u64 read_efer(void);
102 void write_efer(u64 val);
104 DECLARE_PER_CPU(u32, ler_msr);
106 #endif /* !__ASSEMBLY__ */
108 #endif /* __ASM_MSR_H */