kernel: change peek to return number of characters left rather than 0/-1

This commit is contained in:
aiju 2018-12-11 09:17:44 +00:00
parent cc066d8130
commit a6517fb498
5 changed files with 3 additions and 7 deletions

View file

@ -513,13 +513,13 @@ TEXT _wrmsrinst(SB), $0
/* fault-proof memcpy */
TEXT peek(SB), $0
MOVL $0, AX /* AX set to -1 if traped */
MOVL src+0(FP), SI
MOVL dst+4(FP), DI
MOVL cnt+8(FP), CX
CLD
TEXT _peekinst(SB), $0
REP; MOVSB
MOVL CX, AX
RET
/*

View file

@ -481,7 +481,6 @@ trap(Ureg* ureg)
}
} else if(pc == _peekinst){
if(vno == VectorGPF){
ureg->ax = -1;
ureg->pc += 2;
return;
}
@ -722,7 +721,6 @@ fault386(Ureg* ureg, void*)
{
extern void _peekinst(void);
if((void(*)(void))ureg->pc == _peekinst){
ureg->ax = -1;
ureg->pc += 2;
return;
}

View file

@ -451,13 +451,13 @@ TEXT _wrmsrinst(SB), $0
/* fault-proof memcpy */
TEXT peek(SB), 1, $-4
MOVQ $0, AX
MOVQ RARG, SI
MOVQ dst+8(FP), DI
MOVL cnt+16(FP), CX
CLD
TEXT _peekinst(SB), $0
REP; MOVSB
MOVL CX, AX
RET

View file

@ -451,7 +451,6 @@ trap(Ureg *ureg)
}
} else if(pc == _peekinst){
if(vno == VectorGPF){
ureg->ax = -1;
ureg->pc += 2;
return;
}
@ -683,7 +682,6 @@ faultamd64(Ureg* ureg, void*)
extern void _peekinst(void);
if((void(*)(void))ureg->pc == _peekinst){
ureg->ax = -1;
ureg->pc += 2;
return;
}

View file

@ -529,5 +529,5 @@ dtpeek(uvlong addr, void *buf, int len)
if(len == 0) return 0;
if(a != addr || a > -(uintptr)len || len < 0) return -1;
if(up == nil || up->privatemem || a >= KZERO) return -1;
return peek((void *)a, buf, len);
return peek((void *)a, buf, len) > 0 ? -1 : 0;
}