|
28 | 28 | #define NR_RESERVED_PKEYS_4K 27 /* pkey-0, pkey-1, exec-only-pkey
|
29 | 29 | and 24 other keys that cannot be
|
30 | 30 | represented in the PTE */
|
31 |
| -#define NR_RESERVED_PKEYS_64K 3 /* pkey-0, pkey-1 and exec-only-pkey */ |
| 31 | +#define NR_RESERVED_PKEYS_64K_3KEYS 3 /* PowerNV and KVM: pkey-0, |
| 32 | + pkey-1 and exec-only key */ |
| 33 | +#define NR_RESERVED_PKEYS_64K_4KEYS 4 /* PowerVM: pkey-0, pkey-1, |
| 34 | + pkey-31 and exec-only key */ |
32 | 35 | #define PKEY_BITS_PER_PKEY 2
|
33 | 36 | #define HPAGE_SIZE (1UL << 24)
|
34 | 37 | #define PAGE_SIZE (1UL << 16)
|
@@ -66,12 +69,27 @@ static inline int cpu_has_pku(void)
|
66 | 69 | return 1;
|
67 | 70 | }
|
68 | 71 |
|
| 72 | +static inline bool arch_is_powervm() |
| 73 | +{ |
| 74 | + struct stat buf; |
| 75 | + |
| 76 | + if ((stat("/sys/firmware/devicetree/base/ibm,partition-name", &buf) == 0) && |
| 77 | + (stat("/sys/firmware/devicetree/base/hmc-managed?", &buf) == 0) && |
| 78 | + (stat("/sys/firmware/devicetree/base/chosen/qemu,graphic-width", &buf) == -1) ) |
| 79 | + return true; |
| 80 | + |
| 81 | + return false; |
| 82 | +} |
| 83 | + |
69 | 84 | static inline int get_arch_reserved_keys(void)
|
70 | 85 | {
|
71 | 86 | if (sysconf(_SC_PAGESIZE) == 4096)
|
72 | 87 | return NR_RESERVED_PKEYS_4K;
|
73 | 88 | else
|
74 |
| - return NR_RESERVED_PKEYS_64K; |
| 89 | + if (arch_is_powervm()) |
| 90 | + return NR_RESERVED_PKEYS_64K_4KEYS; |
| 91 | + else |
| 92 | + return NR_RESERVED_PKEYS_64K_3KEYS; |
75 | 93 | }
|
76 | 94 |
|
77 | 95 | void expect_fault_on_read_execonly_key(void *p1, int pkey)
|
|
0 commit comments