Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/priv-1.9' into sifive
Browse files Browse the repository at this point in the history
  • Loading branch information
terpstra committed Jul 12, 2016
2 parents a9474b8 + 9faea5d commit 3989911
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
27 changes: 12 additions & 15 deletions arch/riscv/include/asm/pgtable-bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,24 @@
*/

#define _PAGE_PRESENT (1 << 0)
#define _PAGE_TYPE (0xF << 1) /* Page type */
#define _PAGE_WRITE (1 << 1) /* Writable (subfield of TYPE field) */
#define _PAGE_ACCESSED (1 << 5) /* Set by hardware on any access */
#define _PAGE_DIRTY (1 << 6) /* Set by hardware on any write */
#define _PAGE_SOFT (1 << 7) /* Reserved for software */

#define _PAGE_TYPE_TABLE (0x00) /* Page table */
#define _PAGE_TYPE_TABLE_G (0x02) /* Page table, global mapping */
#define _PAGE_TYPE_USER_RO (0x08) /* User read-only, Kernel read-only */
#define _PAGE_TYPE_USER_RW (0x0A) /* User read-write, Kernel read-write */
#define _PAGE_TYPE_USER_RX (0x04) /* User read-execute, Kernel read-only */
#define _PAGE_TYPE_USER_RWX (0x06) /* User RWX, Kernel read-write */
#define _PAGE_TYPE_KERN_RW (0x1A) /* Kernel read-write */
#define _PAGE_READ (1 << 1) /* Readable */
#define _PAGE_WRITE (1 << 2) /* Writable */
#define _PAGE_EXEC (1 << 3) /* Executable */
#define _PAGE_USER (1 << 4) /* User */
#define _PAGE_GLOBAL (1 << 5) /* Global */
#define _PAGE_ACCESSED (1 << 6) /* Set by hardware on any access */
#define _PAGE_DIRTY (1 << 7) /* Set by hardware on any write */
#define _PAGE_SOFT (1 << 8) /* Reserved for software */

#define _PAGE_SPECIAL _PAGE_SOFT
#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_TYPE_TABLE)
#define _PAGE_TABLE _PAGE_PRESENT

#define _PAGE_PFN_SHIFT 10

/* Set of bits to preserve across pte_modify() */
#define _PAGE_CHG_MASK (~(_PAGE_PRESENT | _PAGE_TYPE))
#define _PAGE_CHG_MASK (~(unsigned long)(_PAGE_PRESENT | _PAGE_READ | \
_PAGE_WRITE | _PAGE_EXEC | \
_PAGE_USER | _PAGE_GLOBAL))

/* Advertise support for _PAGE_SPECIAL */
#define __HAVE_ARCH_PTE_SPECIAL
Expand Down
25 changes: 14 additions & 11 deletions arch/riscv/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,24 @@
#define FIRST_USER_ADDRESS 0

/* Page protection bits */
#define _PAGE_BASE (_PAGE_PRESENT | _PAGE_ACCESSED)
#define _PAGE_BASE (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_USER)

#define PAGE_NONE __pgprot(0)
#define PAGE_READ __pgprot(_PAGE_BASE | _PAGE_TYPE_USER_RO)
#define PAGE_WRITE __pgprot(_PAGE_BASE | _PAGE_TYPE_USER_RW)
#define PAGE_EXEC __pgprot(_PAGE_BASE | _PAGE_TYPE_USER_RX)
#define PAGE_WRITE_EXEC __pgprot(_PAGE_BASE | _PAGE_TYPE_USER_RWX)
#define PAGE_READ __pgprot(_PAGE_BASE | _PAGE_READ)
#define PAGE_WRITE __pgprot(_PAGE_BASE | _PAGE_READ | _PAGE_WRITE)
#define PAGE_EXEC __pgprot(_PAGE_BASE | _PAGE_EXEC)
#define PAGE_READ_EXEC __pgprot(_PAGE_BASE | _PAGE_READ | _PAGE_EXEC)
#define PAGE_WRITE_EXEC __pgprot(_PAGE_BASE | _PAGE_READ | \
_PAGE_EXEC | _PAGE_WRITE)

#define PAGE_COPY PAGE_READ
#define PAGE_COPY_EXEC PAGE_EXEC
#define PAGE_COPY_READ_EXEC PAGE_READ_EXEC
#define PAGE_SHARED PAGE_WRITE
#define PAGE_SHARED_EXEC PAGE_WRITE_EXEC

#define PAGE_KERNEL __pgprot(_PAGE_BASE | _PAGE_TYPE_KERN_RW)
#define PAGE_KERNEL __pgprot(_PAGE_READ | _PAGE_WRITE | \
_PAGE_PRESENT | _PAGE_ACCESSED)

#define swapper_pg_dir NULL

Expand All @@ -53,17 +57,17 @@
#define __P010 PAGE_COPY
#define __P011 PAGE_COPY
#define __P100 PAGE_EXEC
#define __P101 PAGE_EXEC
#define __P101 PAGE_READ_EXEC
#define __P110 PAGE_COPY_EXEC
#define __P111 PAGE_COPY_EXEC
#define __P111 PAGE_COPY_READ_EXEC

/* MAP_SHARED permissions: xwr */
#define __S000 PAGE_NONE
#define __S001 PAGE_READ
#define __S010 PAGE_SHARED
#define __S011 PAGE_SHARED
#define __S100 PAGE_EXEC
#define __S101 PAGE_EXEC
#define __S101 PAGE_READ_EXEC
#define __S110 PAGE_SHARED_EXEC
#define __S111 PAGE_SHARED_EXEC

Expand Down Expand Up @@ -191,8 +195,7 @@ static inline int pte_write(pte_t pte)
static inline int pte_huge(pte_t pte)
{
return pte_present(pte)
&& !((pte_val(pte) & _PAGE_TYPE) == _PAGE_TYPE_TABLE
|| (pte_val(pte) & _PAGE_TYPE) == _PAGE_TYPE_TABLE_G);
&& (pte_val(pte) & (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC));
}

/* static inline int pte_exec(pte_t pte) */
Expand Down

0 comments on commit 3989911

Please sign in to comment.