Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2135a6ec authored by Michael Ellerman's avatar Michael Ellerman
Browse files

Merge branch 'topic/pkey' into next

This is a branch with a mixture of mm, x86 and powerpc commits all
relating to some minor cross-arch pkeys consolidation. The x86/mm
changes have been reviewed by Ingo & Dave Hansen and the tree has been
in linux-next for some weeks without issue.
parents f1079d3a d86a4ba0
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -250,11 +250,6 @@ static inline bool arch_vma_access_permitted(struct vm_area_struct *vma,
#define thread_pkey_regs_restore(new_thread, old_thread)
#define thread_pkey_regs_init(thread)

static inline int vma_pkey(struct vm_area_struct *vma)
{
	return 0;
}

static inline u64 pte_to_hpte_pkey_bits(u64 pteflags)
{
	return 0x0UL;
+0 −13
Original line number Diff line number Diff line
@@ -15,19 +15,6 @@ DECLARE_STATIC_KEY_TRUE(pkey_disabled);
extern int pkeys_total; /* total pkeys as per device tree */
extern u32 initial_allocation_mask; /* bits set for reserved keys */

/*
 * Define these here temporarily so we're not dependent on patching linux/mm.h.
 * Once it's updated we can drop these.
 */
#ifndef VM_PKEY_BIT0
# define VM_PKEY_SHIFT	VM_HIGH_ARCH_BIT_0
# define VM_PKEY_BIT0	VM_HIGH_ARCH_0
# define VM_PKEY_BIT1	VM_HIGH_ARCH_1
# define VM_PKEY_BIT2	VM_HIGH_ARCH_2
# define VM_PKEY_BIT3	VM_HIGH_ARCH_3
# define VM_PKEY_BIT4	VM_HIGH_ARCH_4
#endif

#define ARCH_VM_PKEY_FLAGS (VM_PKEY_BIT0 | VM_PKEY_BIT1 | VM_PKEY_BIT2 | \
			    VM_PKEY_BIT3 | VM_PKEY_BIT4)

+0 −15
Original line number Diff line number Diff line
@@ -288,21 +288,6 @@ static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
		mpx_notify_unmap(mm, vma, start, end);
}

#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
static inline int vma_pkey(struct vm_area_struct *vma)
{
	unsigned long vma_pkey_mask = VM_PKEY_BIT0 | VM_PKEY_BIT1 |
				      VM_PKEY_BIT2 | VM_PKEY_BIT3;

	return (vma->vm_flags & vma_pkey_mask) >> VM_PKEY_SHIFT;
}
#else
static inline int vma_pkey(struct vm_area_struct *vma)
{
	return 0;
}
#endif

/*
 * We only want to enforce protection keys on the current process
 * because we effectively have no access to PKRU for other
+13 −0
Original line number Diff line number Diff line
@@ -7,6 +7,11 @@
extern int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
		unsigned long init_val);

static inline bool arch_pkeys_enabled(void)
{
	return boot_cpu_has(X86_FEATURE_OSPKE);
}

/*
 * Try to dedicate one of the protection keys to be used as an
 * execute-only protection key.
@@ -106,4 +111,12 @@ extern int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
		unsigned long init_val);
extern void copy_init_pkru_to_fpregs(void);

static inline int vma_pkey(struct vm_area_struct *vma)
{
	unsigned long vma_pkey_mask = VM_PKEY_BIT0 | VM_PKEY_BIT1 |
				      VM_PKEY_BIT2 | VM_PKEY_BIT3;

	return (vma->vm_flags & vma_pkey_mask) >> VM_PKEY_SHIFT;
}

#endif /*_ASM_X86_PKEYS_H */
+0 −8
Original line number Diff line number Diff line
@@ -1312,11 +1312,3 @@ static int __init register_kernel_offset_dumper(void)
	return 0;
}
__initcall(register_kernel_offset_dumper);

void arch_show_smap(struct seq_file *m, struct vm_area_struct *vma)
{
	if (!boot_cpu_has(X86_FEATURE_OSPKE))
		return;

	seq_printf(m, "ProtectionKey:  %8u\n", vma_pkey(vma));
}
Loading