mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

In future we intend to change the vm_flags_t type, so it isn't correct for architecture and driver code to assume it is unsigned long. Correct this assumption across the board. Overall, this patch does not introduce any functional change. Link: https://lkml.kernel.org/r/b6eb1894abc5555ece80bb08af5c022ef780c8bc.1750274467.git.lorenzo.stoakes@oracle.com Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Christian Brauner <brauner@kernel.org> Reviewed-by: Vlastimil Babka <vbabka@suse.cz> Reviewed-by: Oscar Salvador <osalvador@suse.de> Reviewed-by: Pedro Falcato <pfalcato@suse.de> Acked-by: Catalin Marinas <catalin.marinas@arm.com> [arm64] Acked-by: Zi Yan <ziy@nvidia.com> Acked-by: David Hildenbrand <david@redhat.com> Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Cc: Jann Horn <jannh@google.com> Cc: Kees Cook <kees@kernel.org> Cc: Liam R. Howlett <Liam.Howlett@oracle.com> Cc: Jan Kara <jack@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
91 lines
2.3 KiB
C
91 lines
2.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __SPARC_MMAN_H__
|
|
#define __SPARC_MMAN_H__
|
|
|
|
#include <uapi/asm/mman.h>
|
|
|
|
#ifndef __ASSEMBLY__
|
|
#define arch_mmap_check(addr,len,flags) sparc_mmap_check(addr,len)
|
|
int sparc_mmap_check(unsigned long addr, unsigned long len);
|
|
|
|
#ifdef CONFIG_SPARC64
|
|
#include <asm/adi_64.h>
|
|
|
|
static inline void ipi_set_tstate_mcde(void *arg)
|
|
{
|
|
struct mm_struct *mm = arg;
|
|
|
|
/* Set TSTATE_MCDE for the task using address map that ADI has been
|
|
* enabled on if the task is running. If not, it will be set
|
|
* automatically at the next context switch
|
|
*/
|
|
if (current->mm == mm) {
|
|
struct pt_regs *regs;
|
|
|
|
regs = task_pt_regs(current);
|
|
regs->tstate |= TSTATE_MCDE;
|
|
}
|
|
}
|
|
|
|
#define arch_calc_vm_prot_bits(prot, pkey) sparc_calc_vm_prot_bits(prot)
|
|
static inline vm_flags_t sparc_calc_vm_prot_bits(unsigned long prot)
|
|
{
|
|
if (adi_capable() && (prot & PROT_ADI)) {
|
|
struct pt_regs *regs;
|
|
|
|
if (!current->mm->context.adi) {
|
|
regs = task_pt_regs(current);
|
|
regs->tstate |= TSTATE_MCDE;
|
|
current->mm->context.adi = true;
|
|
on_each_cpu_mask(mm_cpumask(current->mm),
|
|
ipi_set_tstate_mcde, current->mm, 0);
|
|
}
|
|
return VM_SPARC_ADI;
|
|
} else {
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
#define arch_validate_prot(prot, addr) sparc_validate_prot(prot, addr)
|
|
static inline int sparc_validate_prot(unsigned long prot, unsigned long addr)
|
|
{
|
|
if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_ADI))
|
|
return 0;
|
|
return 1;
|
|
}
|
|
|
|
#define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags)
|
|
/* arch_validate_flags() - Ensure combination of flags is valid for a
|
|
* VMA.
|
|
*/
|
|
static inline bool arch_validate_flags(vm_flags_t vm_flags)
|
|
{
|
|
/* If ADI is being enabled on this VMA, check for ADI
|
|
* capability on the platform and ensure VMA is suitable
|
|
* for ADI
|
|
*/
|
|
if (vm_flags & VM_SPARC_ADI) {
|
|
if (!adi_capable())
|
|
return false;
|
|
|
|
/* ADI can not be enabled on PFN mapped pages */
|
|
if (vm_flags & (VM_PFNMAP | VM_MIXEDMAP))
|
|
return false;
|
|
|
|
/* Mergeable pages can become unmergeable
|
|
* if ADI is enabled on them even if they
|
|
* have identical data on them. This can be
|
|
* because ADI enabled pages with identical
|
|
* data may still not have identical ADI
|
|
* tags on them. Disallow ADI on mergeable
|
|
* pages.
|
|
*/
|
|
if (vm_flags & VM_MERGEABLE)
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
#endif /* CONFIG_SPARC64 */
|
|
|
|
#endif /* __ASSEMBLY__ */
|
|
#endif /* __SPARC_MMAN_H__ */
|