/*********************************************************
- * Copyright (C) 2003-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2003-2017 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#define INCLUDE_ALLOW_VMCORE
#include "includeCheck.h"
+#include "vm_basic_types.h"
+
#if defined(__cplusplus)
extern "C" {
#endif
* debugger stops it:
*/
-void Panic_SetBreakOnPanic(Bool breakOnPanic);
+typedef enum {
+ PanicBreakAction_Never,
+ PanicBreakAction_IfDebuggerAttached,
+ PanicBreakAction_Always
+} PanicBreakAction;
+
+void Panic_SetBreakAction(PanicBreakAction action);
+PanicBreakAction Panic_GetBreakAction(void);
Bool Panic_GetBreakOnPanic(void);
void Panic_BreakOnPanic(void);
void Panic_LoopOnPanic(void);
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Panic_SetBreakOnPanic --
+ *
+ * Allow the debug breakpoint on panic to be suppressed. If passed FALSE,
+ * then any subsequent Panics will not attempt to attract a debugger.
+ *
+ * Results:
+ * void.
+ *
+ * Side effects:
+ * Enables/Disables break into debugger on Panic().
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static INLINE void
+Panic_SetBreakOnPanic(Bool breakOnPanic) // IN:
+{
+ Panic_SetBreakAction(breakOnPanic ? PanicBreakAction_Always
+ : PanicBreakAction_Never);
+}
+
+
/*
* On panic, dump core; Panic is also the place where various pieces of
* back end stash information about the core dump.
/*********************************************************
- * Copyright (C) 2013,2017 VMware, Inc. All rights reserved.
+ * Copyright (C) 2013-2017 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* For the above two reasons, usage of COMPILER_*_BARRIER is now deprecated.
* _Do not add new references to COMPILER_*_BARRIER._ Instead, precisely
* document the intent of your code by using the
- * <mem access type>_<mem access type>_MEM_BARRIER family of barriers. Existing
+ * <mem_type/purpose>_<before_access_type>_BARRIER_<after_access_type>
* references to COMPILER_*_BARRIER are being slowly but surely converted,
* and when no references are left, COMPILER_*_BARRIER will be retired.
*
* Thanks for pasting this whole comment into every architecture header.
*/
+
#if defined __GNUC__
# define COMPILER_READ_BARRIER() COMPILER_MEM_BARRIER()
# define COMPILER_WRITE_BARRIER() COMPILER_MEM_BARRIER()
/*
- * (Compiler + CPU) memory barriers. These take the form of
- * <mem access type>_<mem access type>_MEM_BARRIER, where <mem access type> is
- * either LD (load), ST (store) or LDST (any).
+ * Memory barriers. These take the form of
+ *
+ * <mem_type/purpose>_<before_access_type>_BARRIER_<after_access_type>
+ *
+ * where:
+ * <mem_type/purpose> is either SMP, DMA, or MMIO.
+ * <*_access type> is either R(load), W(store) or RW(any).
*
* Above every use of these memory barriers in the code, there _must_ be a
* comment to justify the use, i.e. a comment which:
+ *
* 1) Precisely identifies which memory accesses must not be re-ordered across
* the memory barrier.
* 2) Explains why it is important that the memory accesses not be re-ordered.
* store-store (sfence) ordering, and they don't apply to normal memory.
*/
+
static INLINE void
-ST_LD_MEM_BARRIER(void)
+SMP_W_BARRIER_R(void)
{
volatile long temp;
COMPILER_MEM_BARRIER();
}
-#define LD_LD_MEM_BARRIER() COMPILER_READ_BARRIER()
-#define LD_ST_MEM_BARRIER() COMPILER_MEM_BARRIER()
-#define LD_LDST_MEM_BARRIER() COMPILER_MEM_BARRIER()
-#define ST_ST_MEM_BARRIER() COMPILER_WRITE_BARRIER()
-#define ST_LDST_MEM_BARRIER() ST_LD_MEM_BARRIER()
-#define LDST_LD_MEM_BARRIER() ST_LD_MEM_BARRIER()
-#define LDST_ST_MEM_BARRIER() COMPILER_MEM_BARRIER()
-#define LDST_LDST_MEM_BARRIER() ST_LD_MEM_BARRIER()
+#define SMP_R_BARRIER_R() COMPILER_READ_BARRIER()
+#define SMP_R_BARRIER_W() COMPILER_MEM_BARRIER()
+#define SMP_R_BARRIER_RW() COMPILER_MEM_BARRIER()
+#define SMP_W_BARRIER_W() COMPILER_WRITE_BARRIER()
+#define SMP_W_BARRIER_RW() SMP_W_BARRIER_R()
+#define SMP_RW_BARRIER_R() SMP_W_BARRIER_R()
+#define SMP_RW_BARRIER_W() COMPILER_MEM_BARRIER()
+#define SMP_RW_BARRIER_RW() SMP_W_BARRIER_R()
+
+/*
+ * Like the above, only for use with observers other than CPUs,
+ * i.e. DMA masters.
+ */
+
+#define DMA_R_BARRIER_R() SMP_R_BARRIER_R()
+#define DMA_R_BARRIER_W() SMP_R_BARRIER_W()
+#define DMA_R_BARRIER_RW() SMP_R_BARRIER_RW()
+#define DMA_W_BARRIER_R() SMP_W_BARRIER_R()
+#define DMA_W_BARRIER_W() SMP_W_BARRIER_W()
+#define DMA_W_BARRIER_RW() SMP_W_BARRIER_RW()
+#define DMA_RW_BARRIER_R() SMP_RW_BARRIER_R()
+#define DMA_RW_BARRIER_W() SMP_RW_BARRIER_W()
+#define DMA_RW_BARRIER_RW() SMP_RW_BARRIER_RW()
+
+/*
+ * And finally a set for use with MMIO accesses.
+ */
+
+#define MMIO_R_BARRIER_R() SMP_R_BARRIER_R()
+#define MMIO_R_BARRIER_W() SMP_R_BARRIER_W()
+#define MMIO_R_BARRIER_RW() SMP_R_BARRIER_RW()
+#define MMIO_W_BARRIER_R() SMP_W_BARRIER_R()
+#define MMIO_W_BARRIER_W() SMP_W_BARRIER_W()
+#define MMIO_W_BARRIER_RW() SMP_W_BARRIER_RW()
+#define MMIO_RW_BARRIER_R() SMP_RW_BARRIER_R()
+#define MMIO_RW_BARRIER_W() SMP_RW_BARRIER_W()
+#define MMIO_RW_BARRIER_RW() SMP_RW_BARRIER_RW()
+
+/* deprecated version -- going away soon */
+#define LD_LD_MEM_BARRIER() SMP_R_BARRIER_R()
+#define LD_ST_MEM_BARRIER() SMP_R_BARRIER_W()
+#define LD_LDST_MEM_BARRIER() SMP_R_BARRIER_RW()
+#define ST_LD_MEM_BARRIER() SMP_W_BARRIER_R()
+#define ST_ST_MEM_BARRIER() SMP_W_BARRIER_W()
+#define ST_LDST_MEM_BARRIER() SMP_W_BARRIER_RW()
+#define LDST_LD_MEM_BARRIER() SMP_RW_BARRIER_R()
+#define LDST_ST_MEM_BARRIER() SMP_RW_BARRIER_W()
+#define LDST_LDST_MEM_BARRIER() SMP_RW_BARRIER_RW()
#endif // _VM_BASIC_ASM_X86_COMMON_H_
/* **********************************************************
- * Copyright (C) 2007-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2007-2017 VMware, Inc. All rights reserved.
* **********************************************************/
/*
const uint8 *p = s;
const uint8 *e = p + n;
while (p < e) {
- if (*p++ == c) {
- return p;
+ if (*p == c) {
+ return p;
}
+ ++p;
}
return NULL;
}
/*********************************************************
- * Copyright (C) 2006-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2006-2017 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
#include "windowsu.h"
#endif
-typedef enum {
- PanicBreakLevel_Never,
- PanicBreakLevel_IfDebuggerAttached,
- PanicBreakLevel_Always
-} PanicBreakLevel;
-
static struct PanicState {
Bool msgPostOnPanic;
Bool coreDumpOnPanic;
Bool loopOnPanic;
int coreDumpFlags; /* Memorize for clients without init func */
- PanicBreakLevel breakOnPanic; /* XXX: should this be DEVEL only? */
+ PanicBreakAction breakOnPanic; /* XXX: should this be DEVEL only? */
char *coreDumpFile;
} panicState = { TRUE, TRUE }; /* defaults in lieu of Panic_Init() */
{
panicState.coreDumpOnPanic = Config_GetBool(TRUE, "coreDumpOnPanic");
panicState.loopOnPanic = Config_GetBool(FALSE, "panic.loopOnPanic");
- panicState.breakOnPanic = Config_GetLong(PanicBreakLevel_Never,
- "panic.breakOnPanic");
+ panicState.breakOnPanic = Config_GetLong(PanicBreakAction_Never,
+ "panic.breakOnPanic");
panicState.coreDumpFlags = Config_GetLong(0, "coreDumpFlags");
}
}
#else // Posix
switch (panicState.breakOnPanic) {
- case PanicBreakLevel_Never:
+ case PanicBreakAction_Never:
break;
- case PanicBreakLevel_IfDebuggerAttached:
+ case PanicBreakAction_IfDebuggerAttached:
{
void (*handler)(int);
handler = signal(SIGTRAP, SIG_IGN);
}
break;
default:
- case PanicBreakLevel_Always:
+ case PanicBreakAction_Always:
Warning("Panic: breaking into debugger\n");
# if defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__))
__asm__ __volatile__ ("int3");
/*
*-----------------------------------------------------------------------------
*
- * Panic_SetBreakOnPanic --
+ * Panic_SetBreakAction --
*
- * Allow the debug breakpoint on panic to be suppressed. If passed FALSE,
- * then any subsequent Panics will not attempt to attract a debugger.
+ * Allow the debug breakpoint on panic to be suppressed.
*
* Results:
* void.
*/
void
-Panic_SetBreakOnPanic(Bool breakOnPanic)
+Panic_SetBreakAction(PanicBreakAction action) // IN:
+{
+ panicState.breakOnPanic = action;
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * Panic_GetBreakAction --
+ *
+ * Return the break action that will be taken on an eventual panic.
+ *
+ * Results:
+ * The current break action.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+PanicBreakAction
+Panic_GetBreakAction(void)
{
- panicState.breakOnPanic = breakOnPanic ? PanicBreakLevel_Always
- : PanicBreakLevel_Never;
+ return panicState.breakOnPanic;
}
Bool shouldBreak = FALSE;
switch (panicState.breakOnPanic) {
- case PanicBreakLevel_Never:
+ case PanicBreakAction_Never:
break;
- case PanicBreakLevel_IfDebuggerAttached:
+ case PanicBreakAction_IfDebuggerAttached:
#ifdef _WIN32
shouldBreak = IsDebuggerPresent();
#else
#endif
break;
default:
- case PanicBreakLevel_Always:
+ case PanicBreakAction_Always:
shouldBreak = TRUE;
break;
}