Jeremy Fitzhardinge wrote: > Zachary Amsden wrote: >> I would actually very much prefer not to have EAX, EDX, ECX clobbered >> by these calls at all. There are four performance critical calls >> that are interrupt related - and we should implement them entirely in >> assembler, with the hope of inlining them someday. We go to some >> effort not to clobber anything except for condition codes in our >> implementation. > > OK. I was talking about all the calls in general, but the more > performance-critical ones can definitely get special treatment. The calls in general, I think should be C-like in their properties - having EAX, EDX, ECX for local use, and clobbering flags and memory implicitly by nature of being a (non-pure) function call. > >> If I understand correctly, the Xen implementation clobbers ESI? Why >> is that? > > It needs a temp for address calculation, and it turns out that ESI is > unused in entry.S (or at least at all the points it's needed). So > there's nothing deeply architectural about the choice; we just need a > scratch register here. ECX or EDX would work as well (though perhaps > it would require more work in entry.S), if you can cope with > clobbering a single register. I would highly recommend using ECX or EDX. The choice of ESI being unused is really arbitrary, and it makes it incredibly difficult to try to express passing a VCPU data reference in ESI (that is what it is used for, right?) to a C function. In several places, entry.S calls out to C code and expects EAX, EDX, and ECX to come back clobbered, so there are wide windows there in which the registers are not live, whereas the code could quite reasonably expect ESI to be preserved across those boundaries. > > So ss:SHARED(foo) is per-CPU data? Or would you do something else in > the SMP case? Yes, we have per-CPU mappings at fixed addresses. And this code may be called when running on unknown data segments, hence the required %ss segment override (SS must always be flat inside of our paravirt guests, but for these performance critical calls which are in assembler, we don't make the same assumption for data segments). Zach