Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1253133

Re: [PATCH 26/26] x86, pkeys: Documentation

From Dave Hansen <dave@sr71.net>
Newsgroups linux.kernel
Subject Re: [PATCH 26/26] x86, pkeys: Documentation
Date 2015-10-21 21:20 +0200
Message-ID <qm75v-3ST-5@gated-at.bofh.it> (permalink)
References (8 earlier) <qf20W-3Fm-23@gated-at.bofh.it> <qfcMI-29a-23@gated-at.bofh.it> <qfpqx-3sS-5@gated-at.bofh.it> <qkeXv-1Ha-15@gated-at.bofh.it> <qm6Ma-3fF-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 10/21/2015 11:55 AM, Andy Lutomirski wrote:
> On Fri, Oct 16, 2015 at 8:12 AM, Dave Hansen <dave@sr71.net> wrote:
>> On 10/03/2015 12:27 AM, Ingo Molnar wrote:
>>>  - Along similar considerations, also add a sys_pkey_query() system call to query
>>>    the mapping of a specific pkey. (returns -EBADF or so if the key is not mapped
>>>    at the moment.) This too could be vDSO accelerated in the future.
>>>
>>> I.e. something like:
>>>
>>>      unsigned long sys_pkey_alloc (unsigned long flags, unsigned long init_val)
>>>      unsigned long sys_pkey_set   (int pkey, unsigned long new_val)
>>>      unsigned long sys_pkey_get   (int pkey)
>>>      unsigned long sys_pkey_free  (int pkey)
>>
>> The pkey_set() operation is going to get a wee bit interesting with signals.
>>
>> pkey_set() will modify the _current_ context's PKRU which includes the
>> register itself and the kernel XSAVE buffer (if active).  But, since the
>> PKRU state is saved/restored with the XSAVE state, we will blow away any
>> state set during the signal.
>>
>> I _think_ the right move here is to either keep a 'shadow' version of
>> PKRU inside the kernel (for each thread) and always update the task's
>> XSAVE PKRU state when returning from a signal handler.  Or, _copy_ the
>> signal's PKRU state in to the main process's PKRU state when returning
>> from a signal.
> 
> Ick.  Or we could just declare that signals don't affect the PKRU
> state by default and mask it off in sigreturn.

Yeah, I've been messing with it in a few forms and it's pretty ugly.

I think it will be easier if we say the PKRU rights are not inherited by
signals and changes during a signal are tossed out.  Signal handlers are
special anyway and folks have to be careful writing them.

> In fact, maybe we should add a general xfeature (or whatever it's
> called these days) to the xstate in the signal context that controls
> which pieces are restored.  Then user code can tweak it if needed in
> signal handlers.

Yeah, that's probably a good idea long-term.  We're only getting more
and more things managed by XSAVE and it's going to be increasingly
interesting to glue real semantics back on top.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 26/26] x86, pkeys: Documentation Andy Lutomirski <luto@amacapital.net> - 2015-10-21 21:00 +0200
  Re: [PATCH 26/26] x86, pkeys: Documentation Dave Hansen <dave@sr71.net> - 2015-10-21 21:20 +0200
    Re: [PATCH 26/26] x86, pkeys: Documentation Andy Lutomirski <luto@amacapital.net> - 2015-10-22 01:30 +0200

csiph-web