On 12/13/2017 07:08 AM, Florian Weimer wrote:
Okay, this model is really quite different from x86. Is there a
good reason for the difference?
Yes, both implementations are simple and take the "natural" behavior.
x86 changes XSAVE-controlled register values on entering a signal, so we
let them be changed (including PKRU). POWER hardware does not do this
to its PKRU-equivalent, so we do not force it to.
x86 didn't have to do this for *signals*. But, we kinda went on this
trajectory when we decided to clear/restore FPU state on
entering/exiting signals before XSAVE even existed.
FWIW, I do *not* think we have to do this for future XSAVE states. But,
if we do that, we probably need an interface for apps to tell us which
states to save/restore and which state to set upon entering a signal
handler. That's what I was trying to get you to consider instead of
just a one-off hack to fix this for pkeys.