mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:07:35 +00:00
Don't use dword-by-dword memset/memcpy if the addresses are unaligned.
Also don't enable the large kmalloc catcher by default.
This commit is contained in:
parent
3ac977f50b
commit
c43903eebd
2 changed files with 10 additions and 4 deletions
|
@ -9,7 +9,8 @@ void memcpy(void *dest_ptr, const void *src_ptr, dword n)
|
||||||
{
|
{
|
||||||
dword dest = (dword)dest_ptr;
|
dword dest = (dword)dest_ptr;
|
||||||
dword src = (dword)src_ptr;
|
dword src = (dword)src_ptr;
|
||||||
if (n >= 12) {
|
// FIXME: Support starting at an unaligned address.
|
||||||
|
if (!(dest & 0x3) && !(src & 0x3) && n >= 12) {
|
||||||
size_t dwords = n / sizeof(dword);
|
size_t dwords = n / sizeof(dword);
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"rep movsl\n"
|
"rep movsl\n"
|
||||||
|
@ -36,7 +37,8 @@ void strcpy(char* dest, const char *src)
|
||||||
void* memset(void* dest_ptr, byte c, dword n)
|
void* memset(void* dest_ptr, byte c, dword n)
|
||||||
{
|
{
|
||||||
dword dest = (dword)dest_ptr;
|
dword dest = (dword)dest_ptr;
|
||||||
if (n >= 12) {
|
// FIXME: Support starting at an unaligned address.
|
||||||
|
if (!(dest & 0x3) && n >= 12) {
|
||||||
size_t dwords = n / sizeof(dword);
|
size_t dwords = n / sizeof(dword);
|
||||||
dword expanded_c = c;
|
dword expanded_c = c;
|
||||||
expanded_c <<= 8;
|
expanded_c <<= 8;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
//#define KMALLOC_DEBUG_LARGE_ALLOCATIONS
|
||||||
|
|
||||||
void kmalloc_init();
|
void kmalloc_init();
|
||||||
void* kmalloc_impl(dword size) __attribute__ ((malloc));
|
void* kmalloc_impl(dword size) __attribute__ ((malloc));
|
||||||
void* kmalloc_eternal(size_t) __attribute__ ((malloc));
|
void* kmalloc_eternal(size_t) __attribute__ ((malloc));
|
||||||
|
@ -20,8 +22,10 @@ inline void* operator new[](size_t, void* p) { return p; }
|
||||||
|
|
||||||
ALWAYS_INLINE void* kmalloc(size_t size)
|
ALWAYS_INLINE void* kmalloc(size_t size)
|
||||||
{
|
{
|
||||||
// Any kernel allocation >= 32K is very suspicious, catch them.
|
#ifdef KMALLOC_DEBUG_LARGE_ALLOCATIONS
|
||||||
if (size >= 0x8000)
|
// Any kernel allocation >= 1M is 99.9% a bug.
|
||||||
|
if (size >= 1048576)
|
||||||
asm volatile("cli;hlt");
|
asm volatile("cli;hlt");
|
||||||
|
#endif
|
||||||
return kmalloc_impl(size);
|
return kmalloc_impl(size);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue