mirror of
https://github.com/reactos/reactos.git
synced 2026-06-01 17:00:51 +08:00
[NTOSKRNL] Fix GCC 13 stringop-overflow warnings regarding KiNtVdmState
GCC 13 thinks that a global 'const PULONG' that is initialized to a non-NULL value points to an object that is "likely at address zero".
- Turn the macros that cause the issue into inline functions and wrap them with a GCC diagnostic pragma to silence the warning
- Use KiNtVdmState in vdm/vdmexec.c
- Remove the (duplicated) VdmState macro
In function '_InterlockedAnd',
inlined from 'KiVdmOpcodePOPF' at C:/ReactOS/reactos/ntoskrnl/ke/i386/v86vdm.c:164:5:
C:/ReactOS/reactos/sdk/include/vcruntime/mingw32/intrin_x86.h:245:16: error: '__sync_fetch_and_and_4' writing 4 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=]
245 | return __sync_fetch_and_and(value, mask);
| ^~~~~~~~~~~~~~~~~~~~
In function 'KiVdmOpcodePOPF':
cc1.exe: note: destination object is likely at address zero
This commit is contained in:
@@ -196,6 +196,11 @@ typedef union _KTRAP_EXIT_SKIP_BITS
|
||||
#define PFX_FLAG_REPNE 0x00020000
|
||||
#define PFX_FLAG_REP 0x00040000
|
||||
|
||||
//
|
||||
// VDM State Pointer
|
||||
//
|
||||
extern const PULONG KiNtVdmState;
|
||||
|
||||
//
|
||||
// VDM Helper Macros
|
||||
//
|
||||
@@ -218,8 +223,22 @@ typedef union _KTRAP_EXIT_SKIP_BITS
|
||||
// more time, this way we don't redefine ALL opcode handlers to have 3 parameters,
|
||||
// which would be forcing stack usage in all other scenarios.
|
||||
//
|
||||
#define KiVdmSetVdmEFlags(x) InterlockedOr((PLONG)KiNtVdmState, (x));
|
||||
#define KiVdmClearVdmEFlags(x) InterlockedAnd((PLONG)KiNtVdmState, ~(x))
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstringop-overflow"
|
||||
#endif
|
||||
FORCEINLINE ULONG KiVdmSetVdmEFlags(ULONG EFlags)
|
||||
{
|
||||
return InterlockedOr((PLONG)KiNtVdmState, EFlags);
|
||||
}
|
||||
FORCEINLINE ULONG KiVdmClearVdmEFlags(ULONG EFlags)
|
||||
{
|
||||
return InterlockedAnd((PLONG)KiNtVdmState, ~EFlags);
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#define KiCallVdmHandler(x) KiVdmOpcode##x(TrapFrame, Flags)
|
||||
#define KiCallVdmPrefixHandler(x) KiVdmOpcodePrefix(TrapFrame, Flags | x)
|
||||
#define KiVdmUnhandledOpcode(x) \
|
||||
|
||||
@@ -42,12 +42,6 @@
|
||||
//
|
||||
#define TRAMPOLINE_BOP 0xFEC4C4
|
||||
|
||||
//
|
||||
// VDM State Pointer
|
||||
//
|
||||
#define VdmState \
|
||||
(PULONG)FIXED_NTVDMSTATE_LINEAR_PC_AT
|
||||
|
||||
//
|
||||
// VDM Event Types
|
||||
//
|
||||
|
||||
@@ -652,7 +652,7 @@ Ke386CallBios(IN ULONG Int,
|
||||
VdmTib->Size = sizeof(VDM_TIB);
|
||||
|
||||
/* Set a blank VDM state */
|
||||
*VdmState = 0;
|
||||
*KiNtVdmState = 0;
|
||||
|
||||
/* Copy the context */
|
||||
RtlCopyMemory(&VdmTib->VdmContext, Context, ContextSize);
|
||||
|
||||
@@ -193,7 +193,7 @@ VdmpStartExecution(VOID)
|
||||
Interrupts = (BOOLEAN)(VdmTib->VdmContext.EFlags & EFLAGS_INTERRUPT_MASK);
|
||||
|
||||
/* We don't support full VDM yet, this shouldn't happen */
|
||||
ASSERT(*VdmState == 0);
|
||||
ASSERT(*KiNtVdmState == 0);
|
||||
ASSERT(VdmTib->VdmContext.EFlags & EFLAGS_V86_MASK);
|
||||
|
||||
/* Check if VME is supported and V86 mode was enabled */
|
||||
@@ -219,12 +219,12 @@ VdmpStartExecution(VOID)
|
||||
if (VdmTib->VdmContext.EFlags & EFLAGS_INTERRUPT_MASK)
|
||||
{
|
||||
/* Enable them as well */
|
||||
InterlockedOr((PLONG)VdmState, EFLAGS_INTERRUPT_MASK);
|
||||
InterlockedOr((PLONG)KiNtVdmState, EFLAGS_INTERRUPT_MASK);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Disable them */
|
||||
InterlockedAnd((PLONG)VdmState, ~EFLAGS_INTERRUPT_MASK);
|
||||
InterlockedAnd((PLONG)KiNtVdmState, ~EFLAGS_INTERRUPT_MASK);
|
||||
}
|
||||
|
||||
/* Enable the interrupt flag */
|
||||
@@ -300,7 +300,7 @@ VdmEndExecution(IN PKTRAP_FRAME TrapFrame,
|
||||
{
|
||||
/* Set the EFLAGS based on our software copy of EFLAGS */
|
||||
VdmTib->VdmContext.EFlags = (VdmTib->VdmContext.EFlags & ~EFLAGS_INTERRUPT_MASK) |
|
||||
(*VdmState & EFLAGS_INTERRUPT_MASK);
|
||||
(*KiNtVdmState & EFLAGS_INTERRUPT_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user