/*********************************************************
- * Copyright (c) 1998-2019, 2021-2022 VMware, Inc. All rights reserved.
+ * Copyright (c) 1998-2025 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* 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
* that this is acceptable.
*/
-#if defined VMM && defined ULM
-#error "VMM and ULM cannot be defined at the same time."
+#if (defined VMM && defined ULM) || \
+ (defined VMM && defined GLM) || \
+ (defined GLM && defined ULM)
+#error "Only one of { VMM, ULM, GLM } can be defined during build."
#endif
#if defined ULM && !defined USERLEVEL
* so it uses generic functions.
*/
-#if !defined VMM || \
+#if (!defined VMM && !defined GLM) || \
defined BINARY_CHECKER || defined COREQUERY || defined DECODER || \
defined DIS16 || defined FROBOS || defined TRAPAPI_APP || \
defined VMM_LINKER || defined VMSS2CORE
#define ASSERT_NOT_IMPLEMENTED(cond) \
ASSERT_IFNOT(cond, NOT_IMPLEMENTED())
-#if defined VMKPANIC || defined VMM
+#if defined VMKPANIC || defined VMM || defined GLM
# define NOT_IMPLEMENTED() _ASSERT_PANIC_NORETURN(AssertNotImplemented, "")
#else
# define NOT_IMPLEMENTED() _ASSERT_PANIC(AssertNotImplemented, "")
#endif
-#if defined VMM
+#if defined VMM || defined GLM
# define NOT_IMPLEMENTED_BUG(bug) \
_ASSERT_PANIC_BUG_NORETURN(bug, AssertNotImplemented, "")
#else
*
* On debug builds, NOT_REACHED is a Panic with a fixed string.
*/
-#if defined VMKPANIC || defined VMM
+#if defined VMKPANIC || defined VMM || defined GLM
# define NOT_REACHED() _ASSERT_PANIC_NORETURN(AssertNotReached, "")
#else
# define NOT_REACHED() _ASSERT_PANIC(AssertNotReached, "")
* compiler is known to support it.
*/
-# if defined VMKPANIC || defined VMM || defined ULM_ESX
+# if defined VMKPANIC || defined VMM || defined GLM || defined ULM_ESX
# undef NOT_REACHED
# define NOT_REACHED() __builtin_unreachable()
# elif defined ULM_WIN
/*********************************************************
- * Copyright (c) 1998-2024 Broadcom. All Rights Reserved.
+ * Copyright (c) 1998-2025 Broadcom. All Rights Reserved.
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* This program is free software; you can redistribute it and/or modify it
{
uint32 value;
-#if defined VMM || defined VM_ARM_64 || defined VMKERNEL || defined VMKERNEL_MODULE
+#if defined VMM || defined GLM || \
+ defined VM_ARM_64 || defined VMKERNEL || defined VMKERNEL_MODULE
ASSERT(((uintptr_t)var % 4) == 0);
#endif
Atomic_Write32(Atomic_uint32 *var, // OUT
uint32 val) // IN
{
-#if defined VMM || defined VM_ARM_64 || defined VMKERNEL || defined VMKERNEL_MODULE
+#if defined VMM || defined GLM || \
+ defined VM_ARM_64 || defined VMKERNEL || defined VMKERNEL_MODULE
ASSERT(((uintptr_t)var % 4) == 0);
#endif
uint64 value;
#endif
-#if defined VMM || defined VM_ARM_64 || defined VMKERNEL || defined VMKERNEL_MODULE
+#if defined VMM || defined GLM || \
+ defined VM_ARM_64 || defined VMKERNEL || defined VMKERNEL_MODULE
ASSERT((uintptr_t)var % 8 == 0);
#endif
Atomic_Write64(Atomic_uint64 *var, // OUT
uint64 val) // IN
{
-#if defined VMM || defined VM_ARM_64 || defined VMKERNEL || defined VMKERNEL_MODULE
+#if defined VMM || defined GLM || \
+ defined VM_ARM_64 || defined VMKERNEL || defined VMKERNEL_MODULE
ASSERT((uintptr_t)var % 8 == 0);
#endif
{
uint16 value;
-#if defined VMM || defined VM_ARM_64 || defined VMKERNEL || \
- defined VMKERNEL_MODULE
+#if defined VMM || defined GLM || \
+ defined VM_ARM_64 || defined VMKERNEL || defined VMKERNEL_MODULE
ASSERT((uintptr_t)var % 2 == 0);
#endif
Atomic_Write16(Atomic_uint16 *var, // OUT:
uint16 val) // IN:
{
-#if defined VMM || defined VM_ARM_64 || defined VMKERNEL || \
- defined VMKERNEL_MODULE
+#if defined VMM || defined GLM || \
+ defined VM_ARM_64 || defined VMKERNEL || defined VMKERNEL_MODULE
ASSERT((uintptr_t)var % 2 == 0);
#endif
/*********************************************************
- * Copyright (C) 1998-2023 VMware, Inc. All rights reserved.
+ * Copyright (c) 1998-2025 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* 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
* constraints.
*
*/
-#if (defined(VMM) || defined(VMKERNEL) || defined(FROBOS) || defined(ULM))
+#if defined(VMM) || defined(GLM) || \
+ defined(VMKERNEL) || defined(FROBOS) || defined(ULM)
static INLINE Bool
xtest(void)
{
* fxrstor, on both AMD Opteron and Intel Core CPUs.
*/
#if defined(__GNUC__)
-static INLINE void
+static INLINE void
FXSAVE_ES1(void *save)
{
__asm__ __volatile__ ("fxsave %0\n" : "=m" (*(uint8 *)save) : : "memory");
}
-static INLINE void
+static INLINE void
FXRSTOR_ES1(const void *load)
{
__asm__ __volatile__ ("fxrstor %0\n"
: : "m" (*(const uint8 *)load) : "memory");
}
-static INLINE void
+static INLINE void
FXRSTOR_AMD_ES0(const void *load)
{
uint64 dummy = 0;
- __asm__ __volatile__
+ __asm__ __volatile__
("fnstsw %%ax \n" // Grab x87 ES bit
"bt $7,%%ax \n" // Test ES bit
"jnc 1f \n" // Jump if ES=0
"fildl %0 \n" // Dummy Load from "safe address" changes all
// x87 exception pointers.
"fxrstor %1 \n"
- :
+ :
: "m" (dummy), "m" (*(const uint8 *)load)
: "ax", "memory");
}
* The pointer passed in must be 64-byte aligned.
* See above comment for more information.
*/
-#if defined(__GNUC__) && (defined(VMM) || defined(VMKERNEL) || defined(FROBOS))
+#if defined(__GNUC__) && (defined(VMM) || defined(GLM) || \
+ defined(VMKERNEL) || defined(FROBOS))
-static INLINE void
+static INLINE void
XSAVE_ES1(void *save, uint64 mask)
{
__asm__ __volatile__ (
: "memory");
}
-static INLINE void
+static INLINE void
XSAVEOPT_ES1(void *save, uint64 mask)
{
__asm__ __volatile__ (
: "memory");
}
-static INLINE void
+static INLINE void
XRSTOR_ES1(const void *load, uint64 mask)
{
__asm__ __volatile__ (
: "memory");
}
-static INLINE void
+static INLINE void
XRSTOR_AMD_ES0(const void *load, uint64 mask)
{
uint64 dummy = 0;
- __asm__ __volatile__
+ __asm__ __volatile__
("fnstsw %%ax \n" // Grab x87 ES bit
"bt $7,%%ax \n" // Test ES bit
"jnc 1f \n" // Jump if ES=0
*
* Unsigned integer by fixed point multiplication, with rounding:
* result = floor(multiplicand * multiplier * 2**(-shift) + 0.5)
- *
+ *
* Unsigned 64-bit integer multiplicand.
* Unsigned 32-bit fixed point multiplier, represented as
* (multiplier, shift), where shift < 64.
uint64 result;
uint32 tmp1, tmp2;
// ASSERT(shift >= 0 && shift < 64);
-
+
__asm__("mov %%eax, %2\n\t" // Save lo(multiplicand)
"mov %%edx, %%eax\n\t" // Get hi(multiplicand)
"mull %4\n\t" // p2 = hi(multiplicand) * multiplier
*
* Signed integer by fixed point multiplication, with rounding:
* result = floor(multiplicand * multiplier * 2**(-shift) + 0.5)
- *
+ *
* Signed 64-bit integer multiplicand.
* Unsigned 32-bit fixed point multiplier, represented as
* (multiplier, shift), where shift < 64.
Muls64x32s64(int64 multiplicand, uint32 multiplier, uint32 shift)
{
//ASSERT(shift >= 0 && shift < 64);
-
+
__asm {
mov eax, DWORD PTR [multiplicand+4] // Get hi(multiplicand)
test eax, eax // Check sign of multiplicand
/*********************************************************
- * Copyright (C) 1998-2023 VMware, Inc. All rights reserved.
+ * Copyright (c) 1998-2025 Broadcom. All Rights Reserved.
+ * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* 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
* fxrstor, on both AMD Opteron and Intel Core CPUs.
*/
-#if defined(VMM) || defined(VMKERNEL) || defined(FROBOS) || defined(ULM)
+#if defined(VMM) || defined(GLM) || defined(VMKERNEL) || \
+ defined(FROBOS) || defined(ULM)
static INLINE void
FXSAVE_ES1(void *save)
{
* constraints.
*
*/
-#if (defined(VMM) || defined(VMKERNEL) || defined(FROBOS) || defined(ULM))
+#if (defined(VMM) || defined(GLM) || defined(VMKERNEL) || \
+ defined(FROBOS) || defined(ULM))
static INLINE Bool
xtest(void)
{
#define VMK_HAS_VMM_ONLY(...)
#endif
-#if defined VMM || defined VMK_HAS_VMM
+#if defined VMM || defined GLM || defined VMK_HAS_VMM
/* Structure field only used to support the VMM (as opposed to the ULM). */
#define VMM_ONLY_FIELD(name) name
#else
#define ULM_ONLY(x)
#endif
-#if defined(VMM) || defined(ULM)
+#if defined(VMM) || defined(GLM) || defined(ULM)
#define MONITOR_ONLY(x) x
#else
#define MONITOR_ONLY(x)
#endif
-#if defined(VMM) || defined(VMKERNEL)
+#if defined(VMM) || defined(GLM) || defined(VMKERNEL)
#define USER_ONLY(x)
#else
#define USER_ONLY(x) x
* - VMM does not have POSIX headers
* - Windows <sys/types.h> does not define ssize_t
*/
-#if defined(VMKERNEL) || defined(VMM)
+#if defined(VMKERNEL) || defined(VMM) || defined(GLM)
/* Guard against FreeBSD <sys/types.h> collison. */
# if !defined(_SIZE_T_DEFINED) && !defined(_SIZE_T)
# define _SIZE_T_DEFINED
typedef uint128 UReg128;
#endif
-#if (defined(VMM) || defined(COREQUERY) || defined(EXTDECODER) || \
- defined (VMKERNEL) || defined (VMKBOOT) || defined (ULM)) && \
- !defined (FROBOS) || defined (VSAN_USERLEVEL)
+#if (defined(VMM) || defined(GLM) || defined(COREQUERY) || \
+ defined(EXTDECODER) || defined(VMKERNEL) || defined(VMKBOOT) || \
+ defined(ULM)) && !defined(FROBOS) || defined(VSAN_USERLEVEL)
typedef Reg64 Reg;
typedef UReg64 UReg;
#endif
* Use them like this: Log("%#" FMTLA "x\n", laddr)
*/
-#if defined(VMM) || defined(FROBOS64) || vm_x86_64 || vm_arm_64 || defined __APPLE__
+#if defined(VMM) || defined(GLM) || defined(FROBOS64) || \
+ vm_x86_64 || vm_arm_64 || defined __APPLE__
# define FMTLA "l"
# define FMTVA "l"
# define FMTVPN "l"
* and loop optimization just as an arithmetic operator would be.
*/
-#if defined(__GNUC__) && (defined(VMM) || defined (VMKERNEL))
+#if defined(__GNUC__) && (defined(VMM) || defined(GLM) || defined(VMKERNEL))
#define SIDE_EFFECT_FREE __attribute__((__pure__))
#else
#define SIDE_EFFECT_FREE
* memory.
*/
-#if defined(__GNUC__) && (defined(VMM) || defined (VMKERNEL))
+#if defined(__GNUC__) && (defined(VMM) || defined(GLM) || defined(VMKERNEL))
#define CONST_FUNCTION __attribute__((__const__))
#else
#define CONST_FUNCTION