From: David H. <dho...@re...> - 2000-11-23 16:50:29
|
> user code to emulate unaligned accesses, which can be written as someone > actually found a userspace programs that needs them. We have the code anyway to fix up kernel accesses. > user -> kernel -> user shouldn't be significantly slower than > user -> kernel -> SIGBUS handler -> user Surely it should be somewhat faster. > I think you're wrong. there are many insns the kernel doesn't use (which > your patch doesn't emulate either), and the kernel version needs to validate > every pointer it dereferences. All the instructions emulated in my patch can be produced by gcc (there aren't that many really, it's just that delay slots complicate matters). The multiply from memory is admittedly one I don't emulate, but I don't think that's likely to occur - but I could be wrong. Furthermore, the hard part of pointer validation is handled by the MMU, and so incurs minimal penalty. The unfortunate part is that gcc can't handle two different exits from an asm statement, and so it can't be made to goto a label somewhere else in the function upon faulting. > It never passes it back to userspace. it generates a segv for userspace. > it is a system call return value, and there is no system call directly > involved here. Indeed... it's entirely internal > use "1". use SIGSEGV directly. use any other random value as long as it > makes sense as a constant. EFAULT doesn't. Actually, EFAULT just means "Bad Address" doesn't it? > > > It just means your comment is wrong. > /* Argh. Fault on the instruction itself. > This should never happen non-SMP > */ > > > No... The comment says that the "if" fires if the attempt to read the > > Yes. It can happen on UP systems. No, I don't think it should. I discussed it with David Woodhouse who actually wrote the comment, and he pointed out that the only reason we should ever fault there is if on an SMP system, another CPU unmapped the page at an inconvenient time. If the page wasn't there in the first place, then we'll not come in through do_address_error() since there wasn't an unaligned access (as the CPU won't have been able to read the instruction to see if it was an unaligned access). David Howells |