From: John Hodge Date: Sat, 12 Nov 2011 04:47:41 +0000 (+0800) Subject: Kernel/x86_64 - Fixed bugs exposed by -O3 X-Git-Tag: rel0.14~109 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=3a2aebf3905bf3b7a4ea75dc2f16b215399b114a;p=tpg%2Facess2.git Kernel/x86_64 - Fixed bugs exposed by -O3 --- diff --git a/Kernel/arch/x86_64/lib.c b/Kernel/arch/x86_64/lib.c index 6ba12a48..5b9609a6 100644 --- a/Kernel/arch/x86_64/lib.c +++ b/Kernel/arch/x86_64/lib.c @@ -319,22 +319,22 @@ int memcmp(const void *__dest, const void *__src, size_t __count) void *memcpy(void *__dest, const void *__src, size_t __count) { - if( ((tVAddr)__dest & 7) != ((tVAddr)__src & 7) ) - __asm__ __volatile__ ("rep movsb" : : "D"(__dest),"S"(__src),"c"(__count)); - else { - const Uint8 *src = __src; - Uint8 *dst = __dest; - while( (tVAddr)src & 7 && __count ) { - *dst++ = *src++; + tVAddr dst = (tVAddr)__dest, src = (tVAddr)__src; + if( (dst & 7) != (src & 7) ) + { + __asm__ __volatile__ ("rep movsb" : : "D"(dst),"S"(src),"c"(__count)); + } + else + { + while( (src & 7) && __count ) { + *(char*)dst++ = *(char*)src++; __count --; } - __asm__ __volatile__ ("rep movsq" : : "D"(dst),"S"(src),"c"(__count/8)); - src += __count & ~7; - dst += __count & ~7; + __asm__ __volatile__ ("rep movsq" : "=D"(dst),"=S"(src) : "0"(dst),"1"(src),"c"(__count/8)); __count = __count & 7; while( __count-- ) - *dst++ = *src++; + *(char*)dst++ = *(char*)src++; } return __dest; } diff --git a/Kernel/arch/x86_64/mm_virt.c b/Kernel/arch/x86_64/mm_virt.c index 8b560439..aca37283 100644 --- a/Kernel/arch/x86_64/mm_virt.c +++ b/Kernel/arch/x86_64/mm_virt.c @@ -677,7 +677,7 @@ Uint MM_GetFlags(tVAddr VAddr) int MM_IsValidBuffer(tVAddr Addr, size_t Size) { int bIsUser; - int pml4, pdp, dir, tab; + Uint64 pml4, pdp, dir, tab; Size += Addr & (PAGE_SIZE-1); Addr &= ~(PAGE_SIZE-1); @@ -687,8 +687,6 @@ int MM_IsValidBuffer(tVAddr Addr, size_t Size) pdp = Addr >> 30; dir = Addr >> 21; tab = Addr >> 12; - -// Debug("Addr = %p, Size = 0x%x, dir = %i, tab = %i", Addr, Size, dir, tab); if( !(PAGEMAPLVL4(pml4) & 1) ) return 0; if( !(PAGEDIRPTR(pdp) & 1) ) return 0; @@ -889,11 +887,11 @@ tPAddr MM_Clone(void) { // Skip addresses: // 320 0xFFFFA.... - Kernel Stacks - if( i == 320 ) continue; + if( i == MM_KSTACK_BASE>>39 ) continue; // 509 0xFFFFFE0.. - Fractal mapping - if( i == 508 ) continue; + if( i == MM_FRACTAL_BASE>>39 ) continue; // 510 0xFFFFFE8.. - Temp fractal mapping - if( i == 509 ) continue; + if( i == MM_TMPFRAC_BASE>>39 ) continue; TMPMAPLVL4(i) = PAGEMAPLVL4(i); if( TMPMAPLVL4(i) & 1 )