|
From: Julian S. <js...@ac...> - 2006-08-25 10:13:28
|
---------- Forwarded Message ---------- Subject: Re: FYI: Valgrind 3.2 port to FreeBSD Date: Thursday 24 August 2006 04:24 From: Peter Wemm <pe...@we...> To: Julian Seward <js...@ac...> Cc: Nicholas Nethercote <nj...@cs...> On Wednesday 21 June 2006 19:20, Julian Seward wrote: [..] > > SfMayBlock [...] > > I guess I better explain this .. > > Because V only ever allows one thread to run at once, we need to be > careful when doing syscalls on behalf of the client. Suppose a > thread wants to do something harmless like getpid(); we can safely > just do a getpid and hand the result to the client. This is what > happens if SfMayBlock is not set; you can follow the logic in > syswrap-main.c. > > However, if we're doing something which might block, like read(), > then more care is needed. The assembly helper is then necessary. > It changes the host's signal mask to the guest signal mask, drops > the big lock which serialises the threads, and does the syscall. If > it should block that's fine, some other thread can now run. > Basically all the screwing around with what-the-program-counter-is > (which is very complex, took me ages to understand, this is Jeremy > Fitzhardinge's magic) deals with the case where, as a result of > switching signal masks, a signal is now delivered. > > The SfMayBlock case is the general case and always safe. The > shortcut just-do-the-syscall-directly version is an optimisation used > for syscalls we're sure won't block and for which (get getpid) the > overhead of messing with signal masks etc is a bit silly. > > You unfortunately need to implement the general case (eventually); > but to get started you could just hardwire the syswrap-main logic to > use the shortcut scheme for now. FWIW, I finally got this sorted out today. I've got async mode syscalls working at last. You don't want to know what unspeakable evil I had to do in the machine dependent code. I'm familiar with that kind program counter magic - I've done similar things in the FreeBSD kernel before. I've got signals about 90% working now too, if only I can track down what the heck I've done to corrupt the stack with sigreturn(). The last 10% is probably going to cause more hair loss though. FreeBSD has no sa_restorer field in its sigact records. I haven't figured out why Linux needs this on non-ppc64 yet, so I don't yet know if I'm in trouble or not. It looks like it isn't going to be a problem though. -- Peter Wemm - pe...@we...; peter@FreeBSD.org; pe...@ya... "All of this is for nothing if we don't go to the stars" - JMS/B5 ------------------------------------------------------- |