Rename "SafeFunction" macro to "NoSecurityAnalysis"

This commit is contained in:
EnderIce2
2024-02-04 04:31:30 +02:00
parent 11221b205a
commit b0575ba4f2
31 changed files with 157 additions and 156 deletions

View File

@ -139,7 +139,7 @@ namespace CPU
/**
* @brief Pause the CPU
*/
SafeFunction static __always_inline inline void Pause(bool Loop = false)
nsa static __always_inline inline void Pause(bool Loop = false)
{
do
{
@ -154,7 +154,7 @@ namespace CPU
/**
* @brief Stop the CPU (infinite loop)
*/
SafeFunction __noreturn __used inline void Stop()
nsa __noreturn __used inline void Stop()
{
#if defined(a86)
asmv("CPUStopLoop:\n"
@ -174,7 +174,7 @@ namespace CPU
/**
* @brief Halt the CPU
*/
SafeFunction static __always_inline inline void Halt(bool Loop = false)
nsa static __always_inline inline void Halt(bool Loop = false)
{
do
{
@ -444,7 +444,7 @@ namespace CPU
#endif
}
SafeFunction static inline void lgdt(void *gdt)
nsa static inline void lgdt(void *gdt)
{
#ifdef a32
asmv("lgdt (%0)"
@ -455,7 +455,7 @@ namespace CPU
#endif
}
SafeFunction static inline void lidt(void *idt)
nsa static inline void lidt(void *idt)
{
#ifdef a32
asmv("lidt (%0)"
@ -466,7 +466,7 @@ namespace CPU
#endif
}
SafeFunction static inline void ltr(uint16_t Segment)
nsa static inline void ltr(uint16_t Segment)
{
#ifdef a32
asmv("ltr %0"
@ -477,7 +477,7 @@ namespace CPU
#endif
}
SafeFunction static inline void invlpg(void *Address)
nsa static inline void invlpg(void *Address)
{
#ifdef a32
asmv("invlpg (%0)"
@ -489,7 +489,7 @@ namespace CPU
#endif
}
SafeFunction static inline void fxsave(void *FXSaveArea)
nsa static inline void fxsave(void *FXSaveArea)
{
#ifdef a32
if (!FXSaveArea)
@ -504,7 +504,7 @@ namespace CPU
#endif
}
SafeFunction static inline void fxrstor(void *FXRstorArea)
nsa static inline void fxrstor(void *FXRstorArea)
{
#ifdef a32
if (!FXRstorArea)
@ -831,7 +831,7 @@ namespace CPU
uint8_t xmm[16][16];
} __packed __aligned(16);
SafeFunction static inline void lgdt(void *gdt)
nsa static inline void lgdt(void *gdt)
{
#ifdef a64
asmv("lgdt (%0)"
@ -840,7 +840,7 @@ namespace CPU
#endif
}
SafeFunction static inline void lidt(void *idt)
nsa static inline void lidt(void *idt)
{
#ifdef a64
asmv("lidt (%0)"
@ -849,7 +849,7 @@ namespace CPU
#endif
}
SafeFunction static inline void ltr(uint16_t Segment)
nsa static inline void ltr(uint16_t Segment)
{
#ifdef a64
asmv("ltr %0"
@ -858,7 +858,7 @@ namespace CPU
#endif
}
SafeFunction static inline void invlpg(void *Address)
nsa static inline void invlpg(void *Address)
{
#ifdef a64
asmv("invlpg (%0)"
@ -877,7 +877,7 @@ namespace CPU
* @param ecx ECX
* @param edx EDX
*/
SafeFunction static inline void cpuid(uint32_t Function, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
nsa static inline void cpuid(uint32_t Function, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
{
#ifdef a64
asmv("cpuid"
@ -893,14 +893,14 @@ namespace CPU
*
* @return uint32_t
*/
SafeFunction static inline uint32_t GetHighestLeaf()
nsa static inline uint32_t GetHighestLeaf()
{
uint32_t eax, ebx, ecx, edx;
cpuid(0x0, &eax, &ebx, &ecx, &edx);
return eax;
}
SafeFunction static inline void fxsave(void *FXSaveArea)
nsa static inline void fxsave(void *FXSaveArea)
{
#ifdef a64
if (!FXSaveArea || FXSaveArea >= (char *)0xfffffffffffff000)
@ -913,7 +913,7 @@ namespace CPU
#endif
}
SafeFunction static inline void fxrstor(void *FXRstorArea)
nsa static inline void fxrstor(void *FXRstorArea)
{
#ifdef a64
if (!FXRstorArea || FXRstorArea >= (char *)0xfffffffffffff000)

View File

@ -24,7 +24,7 @@ namespace CPU
{
namespace MemBar
{
SafeFunction static inline void Barrier()
nsa static inline void Barrier()
{
#if defined(a86)
asmv("" ::
@ -35,7 +35,7 @@ namespace CPU
#endif
}
SafeFunction static inline void Fence()
nsa static inline void Fence()
{
#if defined(a86)
asmv("mfence" ::
@ -46,7 +46,7 @@ namespace CPU
#endif
}
SafeFunction static inline void StoreFence()
nsa static inline void StoreFence()
{
#if defined(a86)
asmv("sfence" ::
@ -57,7 +57,7 @@ namespace CPU
#endif
}
SafeFunction static inline void LoadFence()
nsa static inline void LoadFence()
{
#if defined(a86)
asmv("lfence" ::

View File

@ -152,7 +152,7 @@ namespace CPU
uint32_t raw;
} CR8;
#if defined(a32)
SafeFunction static inline CR0 readcr0()
nsa static inline CR0 readcr0()
{
uint32_t Result = 0;
asmv("mov %%cr0, %[Result]"
@ -160,7 +160,7 @@ namespace CPU
return (CR0){.raw = Result};
}
SafeFunction static inline CR2 readcr2()
nsa static inline CR2 readcr2()
{
uint32_t Result = 0;
asmv("mov %%cr2, %[Result]"
@ -168,7 +168,7 @@ namespace CPU
return (CR2){.raw = Result};
}
SafeFunction static inline CR3 readcr3()
nsa static inline CR3 readcr3()
{
uint32_t Result = 0;
asmv("mov %%cr3, %[Result]"
@ -176,7 +176,7 @@ namespace CPU
return (CR3){.raw = Result};
}
SafeFunction static inline CR4 readcr4()
nsa static inline CR4 readcr4()
{
uint32_t Result = 0;
asmv("mov %%cr4, %[Result]"
@ -184,7 +184,7 @@ namespace CPU
return (CR4){.raw = Result};
}
SafeFunction static inline CR8 readcr8()
nsa static inline CR8 readcr8()
{
uint32_t Result = 0;
asmv("mov %%cr8, %[Result]"
@ -192,7 +192,7 @@ namespace CPU
return (CR8){.raw = Result};
}
SafeFunction static inline void writecr0(CR0 ControlRegister)
nsa static inline void writecr0(CR0 ControlRegister)
{
asmv("mov %[ControlRegister], %%cr0"
:
@ -200,7 +200,7 @@ namespace CPU
: "memory");
}
SafeFunction static inline void writecr2(CR2 ControlRegister)
nsa static inline void writecr2(CR2 ControlRegister)
{
asmv("mov %[ControlRegister], %%cr2"
:
@ -208,7 +208,7 @@ namespace CPU
: "memory");
}
SafeFunction static inline void writecr3(CR3 ControlRegister)
nsa static inline void writecr3(CR3 ControlRegister)
{
asmv("mov %[ControlRegister], %%cr3"
:
@ -216,7 +216,7 @@ namespace CPU
: "memory");
}
SafeFunction static inline void writecr4(CR4 ControlRegister)
nsa static inline void writecr4(CR4 ControlRegister)
{
asmv("mov %[ControlRegister], %%cr4"
:
@ -224,7 +224,7 @@ namespace CPU
: "memory");
}
SafeFunction static inline void writecr8(CR8 ControlRegister)
nsa static inline void writecr8(CR8 ControlRegister)
{
asmv("mov %[ControlRegister], %%cr8"
:

View File

@ -401,7 +401,7 @@ namespace CPU
};
#if defined(a32)
SafeFunction static inline uint64_t rdmsr(uint32_t msr)
nsa static inline uint64_t rdmsr(uint32_t msr)
{
uint32_t Low, High;
asmv("rdmsr"
@ -411,7 +411,7 @@ namespace CPU
return ((uint64_t)Low) | (((uint64_t)High) << 32);
}
SafeFunction static inline void wrmsr(uint32_t msr, uint64_t Value)
nsa static inline void wrmsr(uint32_t msr, uint64_t Value)
{
uint32_t Low = (uint32_t)Value, High = (uint32_t)(Value >> 32);
asmv("wrmsr"

View File

@ -190,7 +190,7 @@ namespace CPU
} XCR0;
#if defined(a64)
SafeFunction static inline CR0 readcr0()
nsa static inline CR0 readcr0()
{
uint64_t Result = 0;
asmv("mov %%cr0, %[Result]"
@ -198,7 +198,7 @@ namespace CPU
return (CR0){.raw = Result};
}
SafeFunction static inline CR2 readcr2()
nsa static inline CR2 readcr2()
{
uint64_t Result = 0;
asmv("mov %%cr2, %[Result]"
@ -206,7 +206,7 @@ namespace CPU
return (CR2){.raw = Result};
}
SafeFunction static inline CR3 readcr3()
nsa static inline CR3 readcr3()
{
uint64_t Result = 0;
asmv("mov %%cr3, %[Result]"
@ -214,7 +214,7 @@ namespace CPU
return (CR3){.raw = Result};
}
SafeFunction static inline CR4 readcr4()
nsa static inline CR4 readcr4()
{
uint64_t Result = 0;
asmv("mov %%cr4, %[Result]"
@ -222,7 +222,7 @@ namespace CPU
return (CR4){.raw = Result};
}
SafeFunction static inline CR8 readcr8()
nsa static inline CR8 readcr8()
{
uint64_t Result = 0;
asmv("mov %%cr8, %[Result]"
@ -230,7 +230,7 @@ namespace CPU
return (CR8){.raw = Result};
}
SafeFunction static inline XCR0 readxcr0()
nsa static inline XCR0 readxcr0()
{
uint64_t Result = 0;
asmv("xgetbv"
@ -240,7 +240,7 @@ namespace CPU
return (XCR0){.raw = Result};
}
SafeFunction static inline void writecr0(CR0 ControlRegister)
nsa static inline void writecr0(CR0 ControlRegister)
{
asmv("mov %[ControlRegister], %%cr0"
:
@ -248,7 +248,7 @@ namespace CPU
: "memory");
}
SafeFunction static inline void writecr2(CR2 ControlRegister)
nsa static inline void writecr2(CR2 ControlRegister)
{
asmv("mov %[ControlRegister], %%cr2"
:
@ -256,7 +256,7 @@ namespace CPU
: "memory");
}
SafeFunction static inline void writecr3(CR3 ControlRegister)
nsa static inline void writecr3(CR3 ControlRegister)
{
asmv("mov %[ControlRegister], %%cr3"
:
@ -264,7 +264,7 @@ namespace CPU
: "memory");
}
SafeFunction static inline void writecr4(CR4 ControlRegister)
nsa static inline void writecr4(CR4 ControlRegister)
{
asmv("mov %[ControlRegister], %%cr4"
:
@ -272,7 +272,7 @@ namespace CPU
: "memory");
}
SafeFunction static inline void writecr8(CR8 ControlRegister)
nsa static inline void writecr8(CR8 ControlRegister)
{
asmv("mov %[ControlRegister], %%cr8"
:
@ -280,7 +280,7 @@ namespace CPU
: "memory");
}
SafeFunction static inline void writexcr0(XCR0 ControlRegister)
nsa static inline void writexcr0(XCR0 ControlRegister)
{
asmv("xsetbv"
:

View File

@ -402,7 +402,7 @@ namespace CPU
};
#if defined(a64)
SafeFunction static inline uint64_t rdmsr(uint32_t msr)
nsa static inline uint64_t rdmsr(uint32_t msr)
{
uint32_t Low, High;
asmv("rdmsr"
@ -412,7 +412,7 @@ namespace CPU
return ((uint64_t)Low) | (((uint64_t)High) << 32);
}
SafeFunction static inline void wrmsr(uint32_t msr, uint64_t Value)
nsa static inline void wrmsr(uint32_t msr, uint64_t Value)
{
uint32_t Low = s_cst(uint32_t, Value), High = s_cst(uint32_t, Value >> 32);
asmv("wrmsr"

View File

@ -413,7 +413,8 @@ typedef uint48_t uint_fast48_t;
#define PUBLIC __visibility("default")
#define PRIVATE __visibility("hidden")
#define SafeFunction __no_stack_protector __no_sanitize_address __no_sanitize_undefined __no_address_safety_analysis __no_sanitize_thread
#define NoSecurityAnalysis __no_stack_protector __no_sanitize_address __no_sanitize_undefined __no_address_safety_analysis __no_sanitize_thread
#define nsa NoSecurityAnalysis
#define NIF __no_instrument_function

View File

@ -69,7 +69,7 @@ namespace UniversalAsynchronousReceiverTransmitter
* @brief Get the Registered Port object
* @return SerialPorts
*/
SafeFunction NIF SerialPorts GetRegisteredPort() { return this->Port; }
nsa NIF SerialPorts GetRegisteredPort() { return this->Port; }
/**
* @brief Called when a character is sent.