Commit 5c5063ac authored by Ma Wupeng's avatar Ma Wupeng Committed by Wupeng Ma
Browse files

arm64: mm: Introduce VM_PBHA_BIT0 to enable pbha bit0 for single vma

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I7ZC0H



--------------------------------

Introduce VM_PBHA_BIT0 to enable pbha bit0 for single vma.

Signed-off-by: default avatarMa Wupeng <mawupeng1@huawei.com>
parent 0a411b39
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1694,6 +1694,7 @@ config ARM64_CNP
config ARM64_PBHA
	bool "Enable support for Page Based Hardware Attributes (PBHA)"
	default n
	select ARCH_USES_HIGH_VMA_FLAGS
	help
	  Page Based Hardware Attributes (PBHA) allow the SoC hardware to
	  change behaviour depending on which mapping was used to access
+10 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
#include <linux/compiler.h>
#include <linux/types.h>
#include <uapi/asm/mman.h>
#include <linux/pbha.h>

static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
	unsigned long pkey __always_unused)
@@ -17,6 +18,9 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
	if (system_supports_mte() && (prot & PROT_MTE))
		ret |= VM_MTE;

	if (system_support_pbha_bit0() && (prot & PROT_PBHA_BIT0))
		ret |= VM_PBHA_BIT0;

	return ret;
}
#define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
@@ -55,6 +59,9 @@ static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
	if (vm_flags & VM_MTE)
		prot |= PTE_ATTRINDX(MT_NORMAL_TAGGED);

	if (vm_flags & VM_PBHA_BIT0)
		prot |= PROT_PBHA_BIT0;  /* select PBHA BIT 0 for pbha */

	return __pgprot(prot);
}
#define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags)
@@ -70,6 +77,9 @@ static inline bool arch_validate_prot(unsigned long prot,
	if (system_supports_mte())
		supported |= PROT_MTE;

	if (system_support_pbha_bit0())
		supported |= PROT_PBHA_BIT0;

	return (prot & ~supported) == 0;
}
#define arch_validate_prot(prot, addr) arch_validate_prot(prot, addr)
+1 −0
Original line number Diff line number Diff line
@@ -6,5 +6,6 @@

#define PROT_BTI	0x10		/* BTI guarded page */
#define PROT_MTE	0x20		/* Normal Tagged mapping */
#define PROT_PBHA_BIT0	0x40		/* PBHA 59 bit */

#endif /* ! _UAPI__ASM_MMAN_H */
+3 −0
Original line number Diff line number Diff line
@@ -670,6 +670,9 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma)
		[ilog2(VM_MTE)]		= "mt",
		[ilog2(VM_MTE_ALLOWED)]	= "",
#endif
#ifdef CONFIG_ARM64_PBHA
		[ilog2(VM_PBHA_BIT0)]	= "p0",
#endif
#ifdef CONFIG_ARCH_HAS_PKEYS
		/* These come out via ProtectionKey: */
		[ilog2(VM_PKEY_BIT0)]	= "",
+6 −0
Original line number Diff line number Diff line
@@ -392,6 +392,12 @@ extern unsigned int kobjsize(const void *objp);
# define VM_SHARE_POOL VM_NONE
#endif

#if defined(CONFIG_ARM64_PBHA)
# define VM_PBHA_BIT0	VM_HIGH_ARCH_2	/* Page Base Hardware Attributes 4 bit*/
#else
# define VM_PBHA_BIT0	VM_NONE
#endif

#ifndef VM_GROWSUP
# define VM_GROWSUP	VM_NONE
#endif
Loading