From: Thiago Jung Bauermann <bauerman@linux.ibm.com>
To: Ram Pai <linuxram@us.ibm.com>
Cc: mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org,
dave.hansen@intel.com, aneesh.kumar@linux.vnet.ibm.com,
bsingharora@gmail.com, hbabu@us.ibm.com, mhocko@kernel.org,
bauerman@linux.vnet.ibm.com, Ulrich.Weigand@de.ibm.com,
fweimer@redhat.com, luto@kernel.org, msuchanek@suse.de
Subject: Re: [PATCH v2 4/6] powerpc/pkeys: Preallocate execute-only key
Date: Fri, 29 Jun 2018 00:02:46 -0300 [thread overview]
Message-ID: <87efgqxpk9.fsf@morokweng.localdomain> (raw)
In-Reply-To: <1528936144-6696-5-git-send-email-linuxram@us.ibm.com>
Hello,
My understanding is that this patch isn't upstream yet and it's not too
late for bikeshedding. Please ignore if this is not the case.
Ram Pai <linuxram@us.ibm.com> writes:
> @@ -326,48 +330,7 @@ static inline bool pkey_allows_readwrite(int pkey)
>
> int __execute_only_pkey(struct mm_struct *mm)
> {
> - bool need_to_set_mm_pkey = false;
> - int execute_only_pkey = mm->context.execute_only_pkey;
> - int ret;
> -
> - /* Do we need to assign a pkey for mm's execute-only maps? */
> - if (execute_only_pkey == -1) {
> - /* Go allocate one to use, which might fail */
> - execute_only_pkey = mm_pkey_alloc(mm);
> - if (execute_only_pkey < 0)
> - return -1;
> - need_to_set_mm_pkey = true;
> - }
> -
> - /*
> - * We do not want to go through the relatively costly dance to set AMR
> - * if we do not need to. Check it first and assume that if the
> - * execute-only pkey is readwrite-disabled than we do not have to set it
> - * ourselves.
> - */
> - if (!need_to_set_mm_pkey && !pkey_allows_readwrite(execute_only_pkey))
> - return execute_only_pkey;
> -
> - /*
> - * Set up AMR so that it denies access for everything other than
> - * execution.
> - */
> - ret = __arch_set_user_pkey_access(current, execute_only_pkey,
> - PKEY_DISABLE_ACCESS |
> - PKEY_DISABLE_WRITE);
> - /*
> - * If the AMR-set operation failed somehow, just return 0 and
> - * effectively disable execute-only support.
> - */
> - if (ret) {
> - mm_pkey_free(mm, execute_only_pkey);
> - return -1;
> - }
> -
> - /* We got one, store it and use it from here on out */
> - if (need_to_set_mm_pkey)
> - mm->context.execute_only_pkey = execute_only_pkey;
> - return execute_only_pkey;
> + return mm->context.execute_only_pkey;
> }
There's no reason to have a separate __execute_only_pkey() function
anymore. Its single line can go directly in execute_only_pkey(), defined
in <asm/pkeys.h>.
--
Thiago Jung Bauermann
IBM Linux Technology Center
next prev parent reply other threads:[~2018-06-29 3:03 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-14 0:28 [PATCH v2 0/6] powerpc/pkeys: fixes to pkeys Ram Pai
2018-06-14 0:28 ` [PATCH v2 1/6] powerpc/pkeys: Enable all user-allocatable pkeys at init Ram Pai
2018-06-19 12:39 ` Michael Ellerman
2018-06-19 14:25 ` Ram Pai
2018-06-21 4:14 ` Michael Ellerman
2018-06-21 17:24 ` Ram Pai
2018-06-14 0:29 ` [PATCH v2 2/6] powerpc/pkeys: Save the pkey registers before fork Ram Pai
2018-06-19 12:39 ` Michael Ellerman
2018-06-19 14:28 ` Ram Pai
2018-06-21 4:13 ` Michael Ellerman
2018-06-21 17:35 ` Ram Pai
2018-06-14 0:29 ` [PATCH v2 3/6] powerpc/pkeys: fix calculation of total pkeys Ram Pai
2018-06-19 12:40 ` Michael Ellerman
2018-06-14 0:29 ` [PATCH v2 4/6] powerpc/pkeys: Preallocate execute-only key Ram Pai
2018-06-19 12:40 ` Michael Ellerman
2018-06-19 16:38 ` Ram Pai
2018-06-21 0:28 ` Michael Ellerman
2018-06-29 3:02 ` Thiago Jung Bauermann [this message]
2018-06-14 0:29 ` [PATCH v2 5/6] powerpc/pkeys: make protection key 0 less special Ram Pai
2018-06-19 12:40 ` Michael Ellerman
2018-06-19 16:34 ` Ram Pai
2018-06-14 0:29 ` [PATCH v2 6/6] powerpc/pkeys: Deny read/write/execute by default Ram Pai
2018-06-19 12:39 ` Michael Ellerman
2018-06-19 13:19 ` Florian Weimer
2018-06-19 16:31 ` Ram Pai
2018-06-14 12:15 ` [PATCH v2 0/6] powerpc/pkeys: fixes to pkeys Florian Weimer
2018-06-19 12:40 ` Michael Ellerman
2018-06-20 15:08 ` Florian Weimer
2018-06-21 10:28 ` Michael Ellerman
2018-06-21 18:10 ` Ram Pai
2018-06-23 15:02 ` Michael Ellerman
2018-06-25 17:06 ` Ram Pai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87efgqxpk9.fsf@morokweng.localdomain \
--to=bauerman@linux.ibm.com \
--cc=Ulrich.Weigand@de.ibm.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=bauerman@linux.vnet.ibm.com \
--cc=bsingharora@gmail.com \
--cc=dave.hansen@intel.com \
--cc=fweimer@redhat.com \
--cc=hbabu@us.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=linuxram@us.ibm.com \
--cc=luto@kernel.org \
--cc=mhocko@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=msuchanek@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox