Fix userspace clone by clobbering all variables on clone
This commit is contained in:
parent
ce50faf7ca
commit
dc87afd2ac
|
@ -126,7 +126,16 @@ macro_rules! interrupt_error {
|
|||
}
|
||||
|
||||
// Push scratch registers
|
||||
asm!("push rax
|
||||
asm!("xchg bx, bx
|
||||
pop rax # Error
|
||||
pop rbx # RIP
|
||||
pop rcx # CS
|
||||
pop rdx # RFLAGS
|
||||
pop rsi # RSP
|
||||
pop rdi # SS
|
||||
cli
|
||||
hlt
|
||||
push rax
|
||||
push rcx
|
||||
push rdx
|
||||
push rdi
|
||||
|
|
|
@ -115,8 +115,8 @@ vesa:
|
|||
.minx dw 640
|
||||
.miny dw 480
|
||||
.required:
|
||||
.requiredx dw 0 ;1024 ;USE THESE WITH CAUTION
|
||||
.requiredy dw 0 ;768
|
||||
.requiredx dw 1024 ;USE THESE WITH CAUTION
|
||||
.requiredy dw 768
|
||||
.requiredmode dw 0
|
||||
|
||||
.modeok db ": Is this OK?(y/n)",10,13,0
|
||||
|
|
|
@ -82,10 +82,6 @@ pub fn clone(flags: usize, stack_base: usize) -> Result<usize> {
|
|||
pid = context.id;
|
||||
}
|
||||
|
||||
println!("Clone {}", pid);
|
||||
|
||||
unsafe { asm!("xchg bx, bx" : : : : "intel", "volatile"); }
|
||||
|
||||
unsafe { context::switch(); }
|
||||
|
||||
Ok(pid)
|
||||
|
|
|
@ -110,7 +110,7 @@ pub fn chdir(path: &str) -> Result<usize> {
|
|||
}
|
||||
|
||||
pub unsafe fn clone(flags: usize) -> Result<usize> {
|
||||
syscall1(SYS_CLONE, flags)
|
||||
syscall1_clobber(SYS_CLONE, flags)
|
||||
}
|
||||
|
||||
pub fn close(fd: usize) -> Result<usize> {
|
||||
|
|
|
@ -20,6 +20,17 @@ pub unsafe fn syscall1(mut a: usize, b: usize) -> Result<usize> {
|
|||
Error::demux(a)
|
||||
}
|
||||
|
||||
// Clobbers all registers - special for clone
|
||||
pub unsafe fn syscall1_clobber(mut a: usize, b: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={eax}"(a)
|
||||
: "{eax}"(a), "{ebx}"(b)
|
||||
: "memory", "ebx", "ecx", "edx", "esi", "edi"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={eax}"(a)
|
||||
|
|
|
@ -20,6 +20,17 @@ pub unsafe fn syscall1(mut a: usize, b: usize) -> Result<usize> {
|
|||
Error::demux(a)
|
||||
}
|
||||
|
||||
// Clobbers all registers - special for clone
|
||||
pub unsafe fn syscall1_clobber(mut a: usize, b: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={rax}"(a)
|
||||
: "{rax}"(a), "{rbx}"(b)
|
||||
: "memory", "rbx", "rcx", "rdx", "rsi", "rdi", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"
|
||||
: "intel", "volatile");
|
||||
|
||||
Error::demux(a)
|
||||
}
|
||||
|
||||
pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result<usize> {
|
||||
asm!("int 0x80"
|
||||
: "={rax}"(a)
|
||||
|
|
Loading…
Reference in a new issue