diff for duplicates of <87d18fw9it.fsf@linux.vnet.ibm.com> diff --git a/a/1.txt b/N1/1.txt index 3d4e448..3879f8b 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -35,304 +35,3 @@ he would break it up and merge it into the other patches. -- Thiago Jung Bauermann IBM Linux Technology Center - - -From f6e73e67d325c4a1952c375072ca35156a9f2042 Mon Sep 17 00:00:00 2001 -From: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com> -Date: Mon, 31 Jul 2017 20:22:59 -0300 -Subject: [PATCH] powerpc: Cache protection key registers in - __execute_only_pkey - -Pass around a struct with the contents of AMR, IAMR and AMOR, as well as -flags indicating whether those fields hold valid values and whether they -should be committed back to the registers. - -Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com> ---- - arch/powerpc/include/asm/pkeys.h | 18 ++++-- - arch/powerpc/mm/pkeys.c | 120 +++++++++++++++++++++++++++++---------- - 2 files changed, 104 insertions(+), 34 deletions(-) - -diff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h -index e61ed6c332db..66f15dbc5855 100644 ---- a/arch/powerpc/include/asm/pkeys.h -+++ b/arch/powerpc/include/asm/pkeys.h -@@ -129,12 +129,15 @@ static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey) - mm_set_pkey_is_allocated(mm, pkey)); - } - --extern void __arch_activate_pkey(int pkey); -+struct pkey_regs_cache; -+ -+extern void __arch_activate_pkey(int pkey, struct pkey_regs_cache *regs); - extern void __arch_deactivate_pkey(int pkey); - /* - * Returns a positive, 5-bit key on success, or -1 on failure. - */ --static inline int mm_pkey_alloc(struct mm_struct *mm) -+static inline int __mm_pkey_alloc(struct mm_struct *mm, -+ struct pkey_regs_cache *regs) - { - /* - * Note: this is the one and only place we make sure -@@ -162,10 +165,15 @@ static inline int mm_pkey_alloc(struct mm_struct *mm) - * enable the key in the hardware - */ - if (ret > 0) -- __arch_activate_pkey(ret); -+ __arch_activate_pkey(ret, regs); - return ret; - } - -+static inline int mm_pkey_alloc(struct mm_struct *mm) -+{ -+ return __mm_pkey_alloc(mm, NULL); -+} -+ - static inline int mm_pkey_free(struct mm_struct *mm, int pkey) - { - if (!pkey_inited) -@@ -206,13 +214,13 @@ static inline int arch_override_mprotect_pkey(struct vm_area_struct *vma, - } - - extern int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey, -- unsigned long init_val); -+ unsigned long init_val, struct pkey_regs_cache *regs); - static inline int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, - unsigned long init_val) - { - if (!pkey_inited) - return -EINVAL; -- return __arch_set_user_pkey_access(tsk, pkey, init_val); -+ return __arch_set_user_pkey_access(tsk, pkey, init_val, NULL); - } - - static inline bool arch_pkeys_enabled(void) -diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c -index 1424c79f45f6..718ea23f8184 100644 ---- a/arch/powerpc/mm/pkeys.c -+++ b/arch/powerpc/mm/pkeys.c -@@ -22,52 +22,92 @@ u32 initial_allocation_mask; /* bits set for reserved keys */ - #define PKEY_REG_BITS (sizeof(u64)*8) - #define pkeyshift(pkey) (PKEY_REG_BITS - ((pkey+1) * AMR_BITS_PER_PKEY)) - --static bool is_pkey_enabled(int pkey) -+/* -+ * The registers controlling memory protection keys are expensive to access, so -+ * we want to cache their values in code paths that might need to use them more -+ * than once. -+ */ -+struct pkey_regs_cache { -+ u64 amr; -+ u64 iamr; -+ u64 uamor; -+ -+ bool amr_valid; -+ bool iamr_valid; -+ bool uamor_valid; -+ -+ bool write_amr; -+ bool write_iamr; -+ bool write_uamor; -+}; -+ -+static bool is_pkey_enabled(int pkey, struct pkey_regs_cache *regs) - { -- return !!(read_uamor() & (0x3ul << pkeyshift(pkey))); -+ u64 uamor = (regs && regs->uamor_valid) ? regs->uamor : read_uamor(); -+ return !!(uamor & (0x3ul << pkeyshift(pkey))); - } - --static inline void init_amr(int pkey, u8 init_bits) -+static inline void init_amr(int pkey, u8 init_bits, -+ struct pkey_regs_cache *regs) - { - u64 new_amr_bits = (((u64)init_bits & 0x3UL) << pkeyshift(pkey)); -- u64 old_amr = read_amr() & ~((u64)(0x3ul) << pkeyshift(pkey)); -+ u64 amr = (regs && regs->amr_valid) ? regs->amr : read_amr(); -+ -+ amr = (amr & ~((u64)(0x3ul) << pkeyshift(pkey))) | new_amr_bits; - -- write_amr(old_amr | new_amr_bits); -+ if (regs) { -+ regs->amr = amr; -+ regs->amr_valid = regs->write_amr = true; -+ } else -+ write_amr(amr); - } - --static inline void init_iamr(int pkey, u8 init_bits) -+static inline void init_iamr(int pkey, u8 init_bits, -+ struct pkey_regs_cache *regs) - { - u64 new_iamr_bits = (((u64)init_bits & 0x3UL) << pkeyshift(pkey)); -- u64 old_iamr = read_iamr() & ~((u64)(0x3ul) << pkeyshift(pkey)); -+ u64 iamr = (regs && regs->iamr_valid) ? regs->iamr : read_iamr(); - -- write_iamr(old_iamr | new_iamr_bits); -+ iamr = (iamr & ~((u64)(0x3ul) << pkeyshift(pkey))) | new_iamr_bits; -+ -+ if (regs) { -+ regs->iamr = iamr; -+ regs->iamr_valid = regs->write_iamr = true; -+ } else -+ write_iamr(iamr); - } - --static void pkey_status_change(int pkey, bool enable) -+static void pkey_status_change(int pkey, bool enable, -+ struct pkey_regs_cache *regs) - { -- u64 old_uamor; -+ u64 uamor; - - /* reset the AMR and IAMR bits for this key */ -- init_amr(pkey, 0x0); -- init_iamr(pkey, 0x0); -+ init_amr(pkey, 0x0, regs); -+ init_iamr(pkey, 0x0, regs); - - /* enable/disable key */ -- old_uamor = read_uamor(); -+ uamor = (regs && regs->uamor_valid) ? regs->uamor : read_uamor(); - if (enable) -- old_uamor |= (0x3ul << pkeyshift(pkey)); -+ uamor |= (0x3ul << pkeyshift(pkey)); - else -- old_uamor &= ~(0x3ul << pkeyshift(pkey)); -- write_uamor(old_uamor); -+ uamor &= ~(0x3ul << pkeyshift(pkey)); -+ -+ if (regs) { -+ regs->uamor = uamor; -+ regs->uamor_valid = regs->write_uamor = true; -+ } else -+ write_uamor(uamor); - } - --void __arch_activate_pkey(int pkey) -+void __arch_activate_pkey(int pkey, struct pkey_regs_cache *regs) - { -- pkey_status_change(pkey, true); -+ pkey_status_change(pkey, true, regs); - } - - void __arch_deactivate_pkey(int pkey) - { -- pkey_status_change(pkey, false); -+ pkey_status_change(pkey, false, NULL); - } - - /* -@@ -75,12 +115,12 @@ void __arch_deactivate_pkey(int pkey) - * for @pkey to that specified in @init_val. - */ - int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey, -- unsigned long init_val) -+ unsigned long init_val, struct pkey_regs_cache *regs) - { - u64 new_amr_bits = 0x0ul; - u64 new_iamr_bits = 0x0ul; - -- if (!is_pkey_enabled(pkey)) -+ if (!is_pkey_enabled(pkey, regs)) - return -EINVAL; - - /* Set the bits we need in AMR: */ -@@ -89,23 +129,37 @@ int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey, - else if (init_val & PKEY_DISABLE_WRITE) - new_amr_bits |= AMR_WR_BIT; - -- init_amr(pkey, new_amr_bits); -+ init_amr(pkey, new_amr_bits, regs); - - if ((init_val & PKEY_DISABLE_EXECUTE)) - new_iamr_bits |= IAMR_EX_BIT; - -- init_iamr(pkey, new_iamr_bits); -+ init_iamr(pkey, new_iamr_bits, regs); - return 0; - } - --static inline bool pkey_allows_readwrite(int pkey) -+static inline bool pkey_allows_readwrite(int pkey, struct pkey_regs_cache *regs) - { - int pkey_shift = pkeyshift(pkey); -+ u64 uamor = (regs && regs->uamor_valid) ? regs->uamor : read_uamor(); -+ u64 amr; - -- if (!(read_uamor() & (0x3UL << pkey_shift))) -+ if (regs && !regs->uamor_valid) { -+ regs->uamor = uamor; -+ regs->uamor_valid = true; -+ } -+ -+ if (!(uamor & (0x3UL << pkey_shift))) - return true; - -- return !(read_amr() & ((AMR_RD_BIT|AMR_WR_BIT) << pkey_shift)); -+ amr = (regs && regs->amr_valid) ? regs->amr : read_amr(); -+ -+ if (regs && !regs->amr_valid) { -+ regs->amr = amr; -+ regs->amr_valid = true; -+ } -+ -+ return !(amr & ((AMR_RD_BIT|AMR_WR_BIT) << pkey_shift)); - } - - int __execute_only_pkey(struct mm_struct *mm) -@@ -113,11 +167,12 @@ 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; -+ struct pkey_regs_cache regs = { 0 }; - - /* 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); -+ execute_only_pkey = __mm_pkey_alloc(mm, ®s); - if (execute_only_pkey < 0) - return -1; - need_to_set_mm_pkey = true; -@@ -131,7 +186,7 @@ int __execute_only_pkey(struct mm_struct *mm) - * ourselves. - */ - if (!need_to_set_mm_pkey && -- !pkey_allows_readwrite(execute_only_pkey)) -+ !pkey_allows_readwrite(execute_only_pkey, ®s)) - return execute_only_pkey; - - /* -@@ -139,7 +194,7 @@ int __execute_only_pkey(struct mm_struct *mm) - * other than execution. - */ - ret = __arch_set_user_pkey_access(current, execute_only_pkey, -- (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE)); -+ (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE), ®s); - /* - * If the AMR-set operation failed somehow, just return - * 0 and effectively disable execute-only support. -@@ -149,6 +204,13 @@ int __execute_only_pkey(struct mm_struct *mm) - return -1; - } - -+ if (regs.write_amr) -+ write_amr(regs.amr); -+ if (regs.write_iamr) -+ write_iamr(regs.iamr); -+ if (regs.write_uamor) -+ write_uamor(regs.uamor); -+ - /* 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; --- -2.13.0 - --- -To unsubscribe, send a message with 'unsubscribe linux-mm' in -the body to majordomo@kvack.org. For more info on Linux MM, -see: http://www.linux-mm.org/ . -Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> diff --git a/a/content_digest b/N1/content_digest index 06e1221..16b3983 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -61,307 +61,6 @@ "\n" "-- \n" "Thiago Jung Bauermann\n" - "IBM Linux Technology Center\n" - "\n" - "\n" - "From f6e73e67d325c4a1952c375072ca35156a9f2042 Mon Sep 17 00:00:00 2001\n" - "From: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>\n" - "Date: Mon, 31 Jul 2017 20:22:59 -0300\n" - "Subject: [PATCH] powerpc: Cache protection key registers in\n" - " __execute_only_pkey\n" - "\n" - "Pass around a struct with the contents of AMR, IAMR and AMOR, as well as\n" - "flags indicating whether those fields hold valid values and whether they\n" - "should be committed back to the registers.\n" - "\n" - "Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>\n" - "---\n" - " arch/powerpc/include/asm/pkeys.h | 18 ++++--\n" - " arch/powerpc/mm/pkeys.c | 120 +++++++++++++++++++++++++++++----------\n" - " 2 files changed, 104 insertions(+), 34 deletions(-)\n" - "\n" - "diff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h\n" - "index e61ed6c332db..66f15dbc5855 100644\n" - "--- a/arch/powerpc/include/asm/pkeys.h\n" - "+++ b/arch/powerpc/include/asm/pkeys.h\n" - "@@ -129,12 +129,15 @@ static inline bool mm_pkey_is_allocated(struct mm_struct *mm, int pkey)\n" - " \t\tmm_set_pkey_is_allocated(mm, pkey));\n" - " }\n" - " \n" - "-extern void __arch_activate_pkey(int pkey);\n" - "+struct pkey_regs_cache;\n" - "+\n" - "+extern void __arch_activate_pkey(int pkey, struct pkey_regs_cache *regs);\n" - " extern void __arch_deactivate_pkey(int pkey);\n" - " /*\n" - " * Returns a positive, 5-bit key on success, or -1 on failure.\n" - " */\n" - "-static inline int mm_pkey_alloc(struct mm_struct *mm)\n" - "+static inline int __mm_pkey_alloc(struct mm_struct *mm,\n" - "+\t\t\t\t struct pkey_regs_cache *regs)\n" - " {\n" - " \t/*\n" - " \t * Note: this is the one and only place we make sure\n" - "@@ -162,10 +165,15 @@ static inline int mm_pkey_alloc(struct mm_struct *mm)\n" - " \t * enable the key in the hardware\n" - " \t */\n" - " \tif (ret > 0)\n" - "-\t\t__arch_activate_pkey(ret);\n" - "+\t\t__arch_activate_pkey(ret, regs);\n" - " \treturn ret;\n" - " }\n" - " \n" - "+static inline int mm_pkey_alloc(struct mm_struct *mm)\n" - "+{\n" - "+\treturn __mm_pkey_alloc(mm, NULL);\n" - "+}\n" - "+\n" - " static inline int mm_pkey_free(struct mm_struct *mm, int pkey)\n" - " {\n" - " \tif (!pkey_inited)\n" - "@@ -206,13 +214,13 @@ static inline int arch_override_mprotect_pkey(struct vm_area_struct *vma,\n" - " }\n" - " \n" - " extern int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,\n" - "-\t\tunsigned long init_val);\n" - "+\t\tunsigned long init_val, struct pkey_regs_cache *regs);\n" - " static inline int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,\n" - " \t\tunsigned long init_val)\n" - " {\n" - " \tif (!pkey_inited)\n" - " \t\treturn -EINVAL;\n" - "-\treturn __arch_set_user_pkey_access(tsk, pkey, init_val);\n" - "+\treturn __arch_set_user_pkey_access(tsk, pkey, init_val, NULL);\n" - " }\n" - " \n" - " static inline bool arch_pkeys_enabled(void)\n" - "diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c\n" - "index 1424c79f45f6..718ea23f8184 100644\n" - "--- a/arch/powerpc/mm/pkeys.c\n" - "+++ b/arch/powerpc/mm/pkeys.c\n" - "@@ -22,52 +22,92 @@ u32 initial_allocation_mask;\t/* bits set for reserved keys */\n" - " #define PKEY_REG_BITS (sizeof(u64)*8)\n" - " #define pkeyshift(pkey) (PKEY_REG_BITS - ((pkey+1) * AMR_BITS_PER_PKEY))\n" - " \n" - "-static bool is_pkey_enabled(int pkey)\n" - "+/*\n" - "+ * The registers controlling memory protection keys are expensive to access, so\n" - "+ * we want to cache their values in code paths that might need to use them more\n" - "+ * than once.\n" - "+ */\n" - "+struct pkey_regs_cache {\n" - "+\tu64 amr;\n" - "+\tu64 iamr;\n" - "+\tu64 uamor;\n" - "+\n" - "+\tbool amr_valid;\n" - "+\tbool iamr_valid;\n" - "+\tbool uamor_valid;\n" - "+\n" - "+\tbool write_amr;\n" - "+\tbool write_iamr;\n" - "+\tbool write_uamor;\n" - "+};\n" - "+\n" - "+static bool is_pkey_enabled(int pkey, struct pkey_regs_cache *regs)\n" - " {\n" - "-\treturn !!(read_uamor() & (0x3ul << pkeyshift(pkey)));\n" - "+\tu64 uamor = (regs && regs->uamor_valid) ? regs->uamor : read_uamor();\n" - "+\treturn !!(uamor & (0x3ul << pkeyshift(pkey)));\n" - " }\n" - " \n" - "-static inline void init_amr(int pkey, u8 init_bits)\n" - "+static inline void init_amr(int pkey, u8 init_bits,\n" - "+\t\t\t struct pkey_regs_cache *regs)\n" - " {\n" - " \tu64 new_amr_bits = (((u64)init_bits & 0x3UL) << pkeyshift(pkey));\n" - "-\tu64 old_amr = read_amr() & ~((u64)(0x3ul) << pkeyshift(pkey));\n" - "+\tu64 amr = (regs && regs->amr_valid) ? regs->amr : read_amr();\n" - "+\n" - "+\tamr = (amr & ~((u64)(0x3ul) << pkeyshift(pkey))) | new_amr_bits;\n" - " \n" - "-\twrite_amr(old_amr | new_amr_bits);\n" - "+\tif (regs) {\n" - "+\t\tregs->amr = amr;\n" - "+\t\tregs->amr_valid = regs->write_amr = true;\n" - "+\t} else\n" - "+\t\twrite_amr(amr);\n" - " }\n" - " \n" - "-static inline void init_iamr(int pkey, u8 init_bits)\n" - "+static inline void init_iamr(int pkey, u8 init_bits,\n" - "+\t\t\t struct pkey_regs_cache *regs)\n" - " {\n" - " \tu64 new_iamr_bits = (((u64)init_bits & 0x3UL) << pkeyshift(pkey));\n" - "-\tu64 old_iamr = read_iamr() & ~((u64)(0x3ul) << pkeyshift(pkey));\n" - "+\tu64 iamr = (regs && regs->iamr_valid) ? regs->iamr : read_iamr();\n" - " \n" - "-\twrite_iamr(old_iamr | new_iamr_bits);\n" - "+\tiamr = (iamr & ~((u64)(0x3ul) << pkeyshift(pkey))) | new_iamr_bits;\n" - "+\n" - "+\tif (regs) {\n" - "+\t\tregs->iamr = iamr;\n" - "+\t\tregs->iamr_valid = regs->write_iamr = true;\n" - "+\t} else\n" - "+\t\twrite_iamr(iamr);\n" - " }\n" - " \n" - "-static void pkey_status_change(int pkey, bool enable)\n" - "+static void pkey_status_change(int pkey, bool enable,\n" - "+\t\t\t struct pkey_regs_cache *regs)\n" - " {\n" - "-\tu64 old_uamor;\n" - "+\tu64 uamor;\n" - " \n" - " \t/* reset the AMR and IAMR bits for this key */\n" - "-\tinit_amr(pkey, 0x0);\n" - "-\tinit_iamr(pkey, 0x0);\n" - "+\tinit_amr(pkey, 0x0, regs);\n" - "+\tinit_iamr(pkey, 0x0, regs);\n" - " \n" - " \t/* enable/disable key */\n" - "-\told_uamor = read_uamor();\n" - "+\tuamor = (regs && regs->uamor_valid) ? regs->uamor : read_uamor();\n" - " \tif (enable)\n" - "-\t\told_uamor |= (0x3ul << pkeyshift(pkey));\n" - "+\t\tuamor |= (0x3ul << pkeyshift(pkey));\n" - " \telse\n" - "-\t\told_uamor &= ~(0x3ul << pkeyshift(pkey));\n" - "-\twrite_uamor(old_uamor);\n" - "+\t\tuamor &= ~(0x3ul << pkeyshift(pkey));\n" - "+\n" - "+\tif (regs) {\n" - "+\t\tregs->uamor = uamor;\n" - "+\t\tregs->uamor_valid = regs->write_uamor = true;\n" - "+\t} else\n" - "+\t\twrite_uamor(uamor);\n" - " }\n" - " \n" - "-void __arch_activate_pkey(int pkey)\n" - "+void __arch_activate_pkey(int pkey, struct pkey_regs_cache *regs)\n" - " {\n" - "-\tpkey_status_change(pkey, true);\n" - "+\tpkey_status_change(pkey, true, regs);\n" - " }\n" - " \n" - " void __arch_deactivate_pkey(int pkey)\n" - " {\n" - "-\tpkey_status_change(pkey, false);\n" - "+\tpkey_status_change(pkey, false, NULL);\n" - " }\n" - " \n" - " /*\n" - "@@ -75,12 +115,12 @@ void __arch_deactivate_pkey(int pkey)\n" - " * for @pkey to that specified in @init_val.\n" - " */\n" - " int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,\n" - "-\t\tunsigned long init_val)\n" - "+\t\tunsigned long init_val, struct pkey_regs_cache *regs)\n" - " {\n" - " \tu64 new_amr_bits = 0x0ul;\n" - " \tu64 new_iamr_bits = 0x0ul;\n" - " \n" - "-\tif (!is_pkey_enabled(pkey))\n" - "+\tif (!is_pkey_enabled(pkey, regs))\n" - " \t\treturn -EINVAL;\n" - " \n" - " \t/* Set the bits we need in AMR: */\n" - "@@ -89,23 +129,37 @@ int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,\n" - " \telse if (init_val & PKEY_DISABLE_WRITE)\n" - " \t\tnew_amr_bits |= AMR_WR_BIT;\n" - " \n" - "-\tinit_amr(pkey, new_amr_bits);\n" - "+\tinit_amr(pkey, new_amr_bits, regs);\n" - " \n" - " \tif ((init_val & PKEY_DISABLE_EXECUTE))\n" - " \t\tnew_iamr_bits |= IAMR_EX_BIT;\n" - " \n" - "-\tinit_iamr(pkey, new_iamr_bits);\n" - "+\tinit_iamr(pkey, new_iamr_bits, regs);\n" - " \treturn 0;\n" - " }\n" - " \n" - "-static inline bool pkey_allows_readwrite(int pkey)\n" - "+static inline bool pkey_allows_readwrite(int pkey, struct pkey_regs_cache *regs)\n" - " {\n" - " \tint pkey_shift = pkeyshift(pkey);\n" - "+\tu64 uamor = (regs && regs->uamor_valid) ? regs->uamor : read_uamor();\n" - "+\tu64 amr;\n" - " \n" - "-\tif (!(read_uamor() & (0x3UL << pkey_shift)))\n" - "+\tif (regs && !regs->uamor_valid) {\n" - "+\t\tregs->uamor = uamor;\n" - "+\t\tregs->uamor_valid = true;\n" - "+\t}\n" - "+\n" - "+\tif (!(uamor & (0x3UL << pkey_shift)))\n" - " \t\treturn true;\n" - " \n" - "-\treturn !(read_amr() & ((AMR_RD_BIT|AMR_WR_BIT) << pkey_shift));\n" - "+\tamr = (regs && regs->amr_valid) ? regs->amr : read_amr();\n" - "+\n" - "+\tif (regs && !regs->amr_valid) {\n" - "+\t\tregs->amr = amr;\n" - "+\t\tregs->amr_valid = true;\n" - "+\t}\n" - "+\n" - "+\treturn !(amr & ((AMR_RD_BIT|AMR_WR_BIT) << pkey_shift));\n" - " }\n" - " \n" - " int __execute_only_pkey(struct mm_struct *mm)\n" - "@@ -113,11 +167,12 @@ int __execute_only_pkey(struct mm_struct *mm)\n" - " \tbool need_to_set_mm_pkey = false;\n" - " \tint execute_only_pkey = mm->context.execute_only_pkey;\n" - " \tint ret;\n" - "+\tstruct pkey_regs_cache regs = { 0 };\n" - " \n" - " \t/* Do we need to assign a pkey for mm's execute-only maps? */\n" - " \tif (execute_only_pkey == -1) {\n" - " \t\t/* Go allocate one to use, which might fail */\n" - "-\t\texecute_only_pkey = mm_pkey_alloc(mm);\n" - "+\t\texecute_only_pkey = __mm_pkey_alloc(mm, ®s);\n" - " \t\tif (execute_only_pkey < 0)\n" - " \t\t\treturn -1;\n" - " \t\tneed_to_set_mm_pkey = true;\n" - "@@ -131,7 +186,7 @@ int __execute_only_pkey(struct mm_struct *mm)\n" - " \t * ourselves.\n" - " \t */\n" - " \tif (!need_to_set_mm_pkey &&\n" - "-\t !pkey_allows_readwrite(execute_only_pkey))\n" - "+\t !pkey_allows_readwrite(execute_only_pkey, ®s))\n" - " \t\treturn execute_only_pkey;\n" - " \n" - " \t/*\n" - "@@ -139,7 +194,7 @@ int __execute_only_pkey(struct mm_struct *mm)\n" - " \t * other than execution.\n" - " \t */\n" - " \tret = __arch_set_user_pkey_access(current, execute_only_pkey,\n" - "-\t\t\t(PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE));\n" - "+\t\t\t(PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE), ®s);\n" - " \t/*\n" - " \t * If the AMR-set operation failed somehow, just return\n" - " \t * 0 and effectively disable execute-only support.\n" - "@@ -149,6 +204,13 @@ int __execute_only_pkey(struct mm_struct *mm)\n" - " \t\treturn -1;\n" - " \t}\n" - " \n" - "+\tif (regs.write_amr)\n" - "+\t\twrite_amr(regs.amr);\n" - "+\tif (regs.write_iamr)\n" - "+\t\twrite_iamr(regs.iamr);\n" - "+\tif (regs.write_uamor)\n" - "+\t\twrite_uamor(regs.uamor);\n" - "+\n" - " \t/* We got one, store it and use it from here on out */\n" - " \tif (need_to_set_mm_pkey)\n" - " \t\tmm->context.execute_only_pkey = execute_only_pkey;\n" - "-- \n" - "2.13.0\n" - "\n" - "--\n" - "To unsubscribe, send a message with 'unsubscribe linux-mm' in\n" - "the body to majordomo@kvack.org. For more info on Linux MM,\n" - "see: http://www.linux-mm.org/ .\n" - "Don't email: <a href=mailto:\"dont@kvack.org\"> email@kvack.org </a>" + IBM Linux Technology Center -903b03a10f1e1d4984cc8bac53b3f4f1bfee20184c51e1bb07a96f04082d7934 +bb8dc629deb58f8d61c251d1ec2a1a74597e3c6ec333f5379d92f1994602b55e
diff --git a/a/1.txt b/N2/1.txt index 3d4e448..d5d8067 100644 --- a/a/1.txt +++ b/N2/1.txt @@ -37,7 +37,7 @@ Thiago Jung Bauermann IBM Linux Technology Center -From f6e73e67d325c4a1952c375072ca35156a9f2042 Mon Sep 17 00:00:00 2001 +>From f6e73e67d325c4a1952c375072ca35156a9f2042 Mon Sep 17 00:00:00 2001 From: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com> Date: Mon, 31 Jul 2017 20:22:59 -0300 Subject: [PATCH] powerpc: Cache protection key registers in @@ -330,9 +330,3 @@ index 1424c79f45f6..718ea23f8184 100644 mm->context.execute_only_pkey = execute_only_pkey; -- 2.13.0 - --- -To unsubscribe, send a message with 'unsubscribe linux-mm' in -the body to majordomo@kvack.org. For more info on Linux MM, -see: http://www.linux-mm.org/ . -Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> diff --git a/a/content_digest b/N2/content_digest index 06e1221..032b97b 100644 --- a/a/content_digest +++ b/N2/content_digest @@ -64,7 +64,7 @@ "IBM Linux Technology Center\n" "\n" "\n" - "From f6e73e67d325c4a1952c375072ca35156a9f2042 Mon Sep 17 00:00:00 2001\n" + ">From f6e73e67d325c4a1952c375072ca35156a9f2042 Mon Sep 17 00:00:00 2001\n" "From: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>\n" "Date: Mon, 31 Jul 2017 20:22:59 -0300\n" "Subject: [PATCH] powerpc: Cache protection key registers in\n" @@ -356,12 +356,6 @@ " \tif (need_to_set_mm_pkey)\n" " \t\tmm->context.execute_only_pkey = execute_only_pkey;\n" "-- \n" - "2.13.0\n" - "\n" - "--\n" - "To unsubscribe, send a message with 'unsubscribe linux-mm' in\n" - "the body to majordomo@kvack.org. For more info on Linux MM,\n" - "see: http://www.linux-mm.org/ .\n" - "Don't email: <a href=mailto:\"dont@kvack.org\"> email@kvack.org </a>" + 2.13.0 -903b03a10f1e1d4984cc8bac53b3f4f1bfee20184c51e1bb07a96f04082d7934 +9a4d73f92b1315eedcea05ebe07f56741a459ef424d07fdb79f823b8c981120a
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.