Skip to content
Permalink
Browse files
arch: Move page table config macros out of #ifndef __ASSEMBLY__ con…
…dition

Move page table configuration macros like `P4D_SHIFT` out of
`#ifndef __ASSEMBLY__` condition, so that they can be used by assembly
code or linker scripts.  For example, the `TEXT_CFI_JT` macro in
`include/asm-generic/vmlinux.lds.h` needs `PMD_SIZE` when Clang CFI is
enabled.

Signed-off-by: Wende Tan <twd2.me@gmail.com>
  • Loading branch information
twd2 authored and intel-lab-lkp committed Jul 20, 2021
1 parent 82a1c67 commit 65ec31db75ded2f0754aa4153d9aa8bbc7ac9f96
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
@@ -2,17 +2,19 @@
#ifndef _PGTABLE_NOP4D_H
#define _PGTABLE_NOP4D_H

#ifndef __ASSEMBLY__
#include <linux/const.h>

#define __PAGETABLE_P4D_FOLDED 1

typedef struct { pgd_t pgd; } p4d_t;

#define P4D_SHIFT PGDIR_SHIFT
#define PTRS_PER_P4D 1
#define P4D_SIZE (1UL << P4D_SHIFT)
#define P4D_SIZE (_UL(1) << P4D_SHIFT)
#define P4D_MASK (~(P4D_SIZE-1))

#ifndef __ASSEMBLY__

typedef struct { pgd_t pgd; } p4d_t;

/*
* The "pgd_xxx()" functions here are trivial for a folded two-level
* setup: the p4d is never bad, and a p4d always exists (as it's folded
@@ -2,26 +2,27 @@
#ifndef _PGTABLE_NOPMD_H
#define _PGTABLE_NOPMD_H

#ifndef __ASSEMBLY__

#include <asm-generic/pgtable-nopud.h>

struct mm_struct;
#include <linux/const.h>

#define __PAGETABLE_PMD_FOLDED 1

#define PMD_SHIFT PUD_SHIFT
#define PTRS_PER_PMD 1
#define PMD_SIZE (_UL(1) << PMD_SHIFT)
#define PMD_MASK (~(PMD_SIZE-1))

#ifndef __ASSEMBLY__

struct mm_struct;

/*
* Having the pmd type consist of a pud gets the size right, and allows
* us to conceptually access the pud entry that this pmd is folded into
* without casting.
*/
typedef struct { pud_t pud; } pmd_t;

#define PMD_SHIFT PUD_SHIFT
#define PTRS_PER_PMD 1
#define PMD_SIZE (1UL << PMD_SHIFT)
#define PMD_MASK (~(PMD_SIZE-1))

/*
* The "pud_xxx()" functions here are trivial for a folded two-level
* setup: the pmd is never bad, and a pmd always exists (as it's folded
@@ -2,24 +2,25 @@
#ifndef _PGTABLE_NOPUD_H
#define _PGTABLE_NOPUD_H

#ifndef __ASSEMBLY__

#include <asm-generic/pgtable-nop4d.h>
#include <linux/const.h>

#define __PAGETABLE_PUD_FOLDED 1

#define PUD_SHIFT P4D_SHIFT
#define PTRS_PER_PUD 1
#define PUD_SIZE (_UL(1) << PUD_SHIFT)
#define PUD_MASK (~(PUD_SIZE-1))

#ifndef __ASSEMBLY__

/*
* Having the pud type consist of a p4d gets the size right, and allows
* us to conceptually access the p4d entry that this pud is folded into
* without casting.
*/
typedef struct { p4d_t p4d; } pud_t;

#define PUD_SHIFT P4D_SHIFT
#define PTRS_PER_PUD 1
#define PUD_SIZE (1UL << PUD_SHIFT)
#define PUD_MASK (~(PUD_SIZE-1))

/*
* The "p4d_xxx()" functions here are trivial for a folded two-level
* setup: the pud is never bad, and a pud always exists (as it's folded

0 comments on commit 65ec31d

Please sign in to comment.