debuggers.hg

view xen/include/asm-x86/debugger.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 2846fd19945c
children 700ac6445812
line source
1 /******************************************************************************
2 * asm/debugger.h
3 *
4 * Generic hooks into arch-dependent Xen.
5 *
6 * Each debugger should define two functions here:
7 *
8 * 1. debugger_trap_entry():
9 * Called at start of any synchronous fault or trap, before any other work
10 * is done. The idea is that if your debugger deliberately caused the trap
11 * (e.g. to implement breakpoints or data watchpoints) then you can take
12 * appropriate action and return a non-zero value to cause early exit from
13 * the trap function.
14 *
15 * 2. debugger_trap_fatal():
16 * Called when Xen is about to give up and crash. Typically you will use this
17 * hook to drop into a debug session. It can also be used to hook off
18 * deliberately caused traps (which you then handle and return non-zero).
19 *
20 * 3. debugger_trap_immediate():
21 * Called if we want to drop into a debugger now. This is essentially the
22 * same as debugger_trap_fatal, except that we use the current register state
23 * rather than the state which was in effect when we took the trap.
24 * For example: if we're dying because of an unhandled exception, we call
25 * debugger_trap_fatal; if we're dying because of a panic() we call
26 * debugger_trap_immediate().
27 */
29 #ifndef __X86_DEBUGGER_H__
30 #define __X86_DEBUGGER_H__
32 #include <xen/sched.h>
33 #include <asm/regs.h>
34 #include <asm/processor.h>
36 /* The main trap handlers use these helper macros which include early bail. */
37 #define DEBUGGER_trap_entry(_v, _r) \
38 if ( debugger_trap_entry(_v, _r) ) return;
39 #define DEBUGGER_trap_fatal(_v, _r) \
40 if ( debugger_trap_fatal(_v, _r) ) return;
42 #if defined(CRASH_DEBUG)
44 #include <xen/gdbstub.h>
46 static inline int debugger_trap_fatal(
47 unsigned int vector, struct cpu_user_regs *regs)
48 {
49 int rc = __trap_to_gdb(regs, vector);
50 return ((rc == 0) || (vector == TRAP_int3));
51 }
53 /* Int3 is a trivial way to gather cpu_user_regs context. */
54 #define debugger_trap_immediate() __asm__ __volatile__ ( "int3" );
56 #else
58 #define debugger_trap_fatal(v, r) (0)
59 #define debugger_trap_immediate() ((void)0)
61 #endif
63 static inline int debugger_trap_entry(
64 unsigned int vector, struct cpu_user_regs *regs)
65 {
66 struct vcpu *v = current;
68 if ( guest_kernel_mode(v, regs) && v->domain->debugger_attached &&
69 ((vector == TRAP_int3) || (vector == TRAP_debug)) )
70 {
71 if ( vector != TRAP_debug ) /* domain pause is good enough */
72 current->arch.gdbsx_vcpu_event = vector;
73 domain_pause_for_debugger();
74 return 1;
75 }
77 return 0;
78 }
80 #endif /* __X86_DEBUGGER_H__ */