diff options
| author | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-03-07 09:42:35 -0500 |
|---|---|---|
| committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-03-07 09:42:35 -0500 |
| commit | 3ba4cea21901d90d703b52e4a806fbafa86037a6 (patch) | |
| tree | b556d880492a783861a39c8197e35d56ac4c77f9 /arch/x86 | |
| parent | a2e6177c931793b4ffb30e722fce6fc7aaff9fa5 (diff) | |
| parent | 8e781f65423c2e8e65a56972ba996b6c01a5ef3e (diff) | |
Merge branch 'for-rmk/perf' of git://git.kernel.org/pub/scm/linux/kernel/git/will/linux into devel-stable
* Support for Qualcomm Krait processors (run perf on your phone!)
* Support for Cortex-A12 (run perf stat on your FPGA!)
* Support for perf_sample_event_took, allowing us to automatically decrease
the sample rate if we can't handle the PMU interrupts quickly enough
(run perf record on your FPGA!).
As part of the Krait support, we also gain support for PPI generation by
the PMU.
Diffstat (limited to 'arch/x86')
| -rw-r--r-- | arch/x86/include/asm/efi.h | 2 | ||||
| -rw-r--r-- | arch/x86/include/asm/pgtable.h | 14 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/common.c | 7 | ||||
| -rw-r--r-- | arch/x86/kernel/ftrace.c | 83 | ||||
| -rw-r--r-- | arch/x86/kernel/tsc.c | 4 | ||||
| -rw-r--r-- | arch/x86/mm/fault.c | 14 | ||||
| -rw-r--r-- | arch/x86/platform/efi/efi-bgrt.c | 2 | ||||
| -rw-r--r-- | arch/x86/platform/efi/efi.c | 5 | ||||
| -rw-r--r-- | arch/x86/platform/efi/efi_32.c | 6 | ||||
| -rw-r--r-- | arch/x86/platform/efi/efi_64.c | 9 | ||||
| -rw-r--r-- | arch/x86/xen/mmu.c | 4 |
11 files changed, 98 insertions, 52 deletions
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 3b978c472d08..3d6b9f81cc68 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h | |||
| @@ -132,6 +132,8 @@ extern void __init efi_map_region_fixed(efi_memory_desc_t *md); | |||
| 132 | extern void efi_sync_low_kernel_mappings(void); | 132 | extern void efi_sync_low_kernel_mappings(void); |
| 133 | extern void efi_setup_page_tables(void); | 133 | extern void efi_setup_page_tables(void); |
| 134 | extern void __init old_map_region(efi_memory_desc_t *md); | 134 | extern void __init old_map_region(efi_memory_desc_t *md); |
| 135 | extern void __init runtime_code_page_mkexec(void); | ||
| 136 | extern void __init efi_runtime_mkexec(void); | ||
| 135 | 137 | ||
| 136 | struct efi_setup_data { | 138 | struct efi_setup_data { |
| 137 | u64 fw_vendor; | 139 | u64 fw_vendor; |
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index bbc8b12fa443..5ad38ad07890 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h | |||
| @@ -445,10 +445,20 @@ static inline int pte_same(pte_t a, pte_t b) | |||
| 445 | return a.pte == b.pte; | 445 | return a.pte == b.pte; |
| 446 | } | 446 | } |
| 447 | 447 | ||
| 448 | static inline int pteval_present(pteval_t pteval) | ||
| 449 | { | ||
| 450 | /* | ||
| 451 | * Yes Linus, _PAGE_PROTNONE == _PAGE_NUMA. Expressing it this | ||
| 452 | * way clearly states that the intent is that protnone and numa | ||
| 453 | * hinting ptes are considered present for the purposes of | ||
| 454 | * pagetable operations like zapping, protection changes, gup etc. | ||
| 455 | */ | ||
| 456 | return pteval & (_PAGE_PRESENT | _PAGE_PROTNONE | _PAGE_NUMA); | ||
| 457 | } | ||
| 458 | |||
| 448 | static inline int pte_present(pte_t a) | 459 | static inline int pte_present(pte_t a) |
| 449 | { | 460 | { |
| 450 | return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE | | 461 | return pteval_present(pte_flags(a)); |
| 451 | _PAGE_NUMA); | ||
| 452 | } | 462 | } |
| 453 | 463 | ||
| 454 | #define pte_accessible pte_accessible | 464 | #define pte_accessible pte_accessible |
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 24b6fd10625a..8e28bf2fc3ef 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
| @@ -284,8 +284,13 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c) | |||
| 284 | raw_local_save_flags(eflags); | 284 | raw_local_save_flags(eflags); |
| 285 | BUG_ON(eflags & X86_EFLAGS_AC); | 285 | BUG_ON(eflags & X86_EFLAGS_AC); |
| 286 | 286 | ||
| 287 | if (cpu_has(c, X86_FEATURE_SMAP)) | 287 | if (cpu_has(c, X86_FEATURE_SMAP)) { |
| 288 | #ifdef CONFIG_X86_SMAP | ||
| 288 | set_in_cr4(X86_CR4_SMAP); | 289 | set_in_cr4(X86_CR4_SMAP); |
| 290 | #else | ||
| 291 | clear_in_cr4(X86_CR4_SMAP); | ||
| 292 | #endif | ||
| 293 | } | ||
| 289 | } | 294 | } |
| 290 | 295 | ||
| 291 | /* | 296 | /* |
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index d4bdd253fea7..e6253195a301 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c | |||
| @@ -77,8 +77,7 @@ within(unsigned long addr, unsigned long start, unsigned long end) | |||
| 77 | return addr >= start && addr < end; | 77 | return addr >= start && addr < end; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | static int | 80 | static unsigned long text_ip_addr(unsigned long ip) |
| 81 | do_ftrace_mod_code(unsigned long ip, const void *new_code) | ||
| 82 | { | 81 | { |
| 83 | /* | 82 | /* |
| 84 | * On x86_64, kernel text mappings are mapped read-only with | 83 | * On x86_64, kernel text mappings are mapped read-only with |
| @@ -91,7 +90,7 @@ do_ftrace_mod_code(unsigned long ip, const void *new_code) | |||
| 91 | if (within(ip, (unsigned long)_text, (unsigned long)_etext)) | 90 | if (within(ip, (unsigned long)_text, (unsigned long)_etext)) |
| 92 | ip = (unsigned long)__va(__pa_symbol(ip)); | 91 | ip = (unsigned long)__va(__pa_symbol(ip)); |
| 93 | 92 | ||
| 94 | return probe_kernel_write((void *)ip, new_code, MCOUNT_INSN_SIZE); | 93 | return ip; |
| 95 | } | 94 | } |
| 96 | 95 | ||
| 97 | static const unsigned char *ftrace_nop_replace(void) | 96 | static const unsigned char *ftrace_nop_replace(void) |
| @@ -123,8 +122,10 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code, | |||
| 123 | if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0) | 122 | if (memcmp(replaced, old_code, MCOUNT_INSN_SIZE) != 0) |
| 124 | return -EINVAL; | 123 | return -EINVAL; |
| 125 | 124 | ||
| 125 | ip = text_ip_addr(ip); | ||
| 126 | |||
| 126 | /* replace the text with the new text */ | 127 | /* replace the text with the new text */ |
| 127 | if (do_ftrace_mod_code(ip, new_code)) | 128 | if (probe_kernel_write((void *)ip, new_code, MCOUNT_INSN_SIZE)) |
| 128 | return -EPERM; | 129 | return -EPERM; |
| 129 | 130 | ||
| 130 | sync_core(); | 131 | sync_core(); |
| @@ -221,37 +222,51 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, | |||
| 221 | return -EINVAL; | 222 | return -EINVAL; |
| 222 | } | 223 | } |
| 223 | 224 | ||
| 224 | int ftrace_update_ftrace_func(ftrace_func_t func) | 225 | static unsigned long ftrace_update_func; |
| 226 | |||
| 227 | static int update_ftrace_func(unsigned long ip, void *new) | ||
| 225 | { | 228 | { |
| 226 | unsigned long ip = (unsigned long)(&ftrace_call); | 229 | unsigned char old[MCOUNT_INSN_SIZE]; |
| 227 | unsigned char old[MCOUNT_INSN_SIZE], *new; | ||
| 228 | int ret; | 230 | int ret; |
| 229 | 231 | ||
| 230 | memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE); | 232 | memcpy(old, (void *)ip, MCOUNT_INSN_SIZE); |
| 231 | new = ftrace_call_replace(ip, (unsigned long)func); | 233 | |
| 234 | ftrace_update_func = ip; | ||
| 235 | /* Make sure the breakpoints see the ftrace_update_func update */ | ||
| 236 | smp_wmb(); | ||
| 232 | 237 | ||
| 233 | /* See comment above by declaration of modifying_ftrace_code */ | 238 | /* See comment above by declaration of modifying_ftrace_code */ |
| 234 | atomic_inc(&modifying_ftrace_code); | 239 | atomic_inc(&modifying_ftrace_code); |
| 235 | 240 | ||
| 236 | ret = ftrace_modify_code(ip, old, new); | 241 | ret = ftrace_modify_code(ip, old, new); |
| 237 | 242 | ||
| 243 | atomic_dec(&modifying_ftrace_code); | ||
| 244 | |||
| 245 | return ret; | ||
| 246 | } | ||
| 247 | |||
| 248 | int ftrace_update_ftrace_func(ftrace_func_t func) | ||
| 249 | { | ||
| 250 | unsigned long ip = (unsigned long)(&ftrace_call); | ||
| 251 | unsigned char *new; | ||
| 252 | int ret; | ||
| 253 | |||
| 254 | new = ftrace_call_replace(ip, (unsigned long)func); | ||
| 255 | ret = update_ftrace_func(ip, new); | ||
| 256 | |||
| 238 | /* Also update the regs callback function */ | 257 | /* Also update the regs callback function */ |
| 239 | if (!ret) { | 258 | if (!ret) { |
| 240 | ip = (unsigned long)(&ftrace_regs_call); | 259 | ip = (unsigned long)(&ftrace_regs_call); |
| 241 | memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE); | ||
| 242 | new = ftrace_call_replace(ip, (unsigned long)func); | 260 | new = ftrace_call_replace(ip, (unsigned long)func); |
| 243 | ret = ftrace_modify_code(ip, old, new); | 261 | ret = update_ftrace_func(ip, new); |
| 244 | } | 262 | } |
| 245 | 263 | ||
| 246 | atomic_dec(&modifying_ftrace_code); | ||
| 247 | |||
| 248 | return ret; | 264 | return ret; |
| 249 | } | 265 | } |
| 250 | 266 | ||
| 251 | static int is_ftrace_caller(unsigned long ip) | 267 | static int is_ftrace_caller(unsigned long ip) |
| 252 | { | 268 | { |
| 253 | if (ip == (unsigned long)(&ftrace_call) || | 269 | if (ip == ftrace_update_func) |
| 254 | ip == (unsigned long)(&ftrace_regs_call)) | ||
| 255 | return 1; | 270 | return 1; |
| 256 | 271 | ||
| 257 | return 0; | 272 | return 0; |
| @@ -677,45 +692,41 @@ int __init ftrace_dyn_arch_init(void *data) | |||
| 677 | #ifdef CONFIG_DYNAMIC_FTRACE | 692 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 678 | extern void ftrace_graph_call(void); | 693 | extern void ftrace_graph_call(void); |
| 679 | 694 | ||
| 680 | static int ftrace_mod_jmp(unsigned long ip, | 695 | static unsigned char *ftrace_jmp_replace(unsigned long ip, unsigned long addr) |
| 681 | int old_offset, int new_offset) | ||
| 682 | { | 696 | { |
| 683 | unsigned char code[MCOUNT_INSN_SIZE]; | 697 | static union ftrace_code_union calc; |
| 684 | 698 | ||
| 685 | if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE)) | 699 | /* Jmp not a call (ignore the .e8) */ |
| 686 | return -EFAULT; | 700 | calc.e8 = 0xe9; |
| 701 | calc.offset = ftrace_calc_offset(ip + MCOUNT_INSN_SIZE, addr); | ||
| 687 | 702 | ||
| 688 | if (code[0] != 0xe9 || old_offset != *(int *)(&code[1])) | 703 | /* |
| 689 | return -EINVAL; | 704 | * ftrace external locks synchronize the access to the static variable. |
| 705 | */ | ||
| 706 | return calc.code; | ||
| 707 | } | ||
| 690 | 708 | ||
| 691 | *(int *)(&code[1]) = new_offset; | 709 | static int ftrace_mod_jmp(unsigned long ip, void *func) |
| 710 | { | ||
| 711 | unsigned char *new; | ||
| 692 | 712 | ||
| 693 | if (do_ftrace_mod_code(ip, &code)) | 713 | new = ftrace_jmp_replace(ip, (unsigned long)func); |
| 694 | return -EPERM; | ||
| 695 | 714 | ||
| 696 | return 0; | 715 | return update_ftrace_func(ip, new); |
| 697 | } | 716 | } |
| 698 | 717 | ||
| 699 | int ftrace_enable_ftrace_graph_caller(void) | 718 | int ftrace_enable_ftrace_graph_caller(void) |
| 700 | { | 719 | { |
| 701 | unsigned long ip = (unsigned long)(&ftrace_graph_call); | 720 | unsigned long ip = (unsigned long)(&ftrace_graph_call); |
| 702 | int old_offset, new_offset; | ||
| 703 | 721 | ||
| 704 | old_offset = (unsigned long)(&ftrace_stub) - (ip + MCOUNT_INSN_SIZE); | 722 | return ftrace_mod_jmp(ip, &ftrace_graph_caller); |
| 705 | new_offset = (unsigned long)(&ftrace_graph_caller) - (ip + MCOUNT_INSN_SIZE); | ||
| 706 | |||
| 707 | return ftrace_mod_jmp(ip, old_offset, new_offset); | ||
| 708 | } | 723 | } |
| 709 | 724 | ||
| 710 | int ftrace_disable_ftrace_graph_caller(void) | 725 | int ftrace_disable_ftrace_graph_caller(void) |
| 711 | { | 726 | { |
| 712 | unsigned long ip = (unsigned long)(&ftrace_graph_call); | 727 | unsigned long ip = (unsigned long)(&ftrace_graph_call); |
| 713 | int old_offset, new_offset; | ||
| 714 | |||
| 715 | old_offset = (unsigned long)(&ftrace_graph_caller) - (ip + MCOUNT_INSN_SIZE); | ||
| 716 | new_offset = (unsigned long)(&ftrace_stub) - (ip + MCOUNT_INSN_SIZE); | ||
| 717 | 728 | ||
| 718 | return ftrace_mod_jmp(ip, old_offset, new_offset); | 729 | return ftrace_mod_jmp(ip, &ftrace_stub); |
| 719 | } | 730 | } |
| 720 | 731 | ||
| 721 | #endif /* !CONFIG_DYNAMIC_FTRACE */ | 732 | #endif /* !CONFIG_DYNAMIC_FTRACE */ |
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 19e5adb49a27..acb3b606613e 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c | |||
| @@ -209,7 +209,7 @@ static inline unsigned long long cycles_2_ns(unsigned long long cyc) | |||
| 209 | * dance when its actually needed. | 209 | * dance when its actually needed. |
| 210 | */ | 210 | */ |
| 211 | 211 | ||
| 212 | preempt_disable(); | 212 | preempt_disable_notrace(); |
| 213 | data = this_cpu_read(cyc2ns.head); | 213 | data = this_cpu_read(cyc2ns.head); |
| 214 | tail = this_cpu_read(cyc2ns.tail); | 214 | tail = this_cpu_read(cyc2ns.tail); |
| 215 | 215 | ||
| @@ -229,7 +229,7 @@ static inline unsigned long long cycles_2_ns(unsigned long long cyc) | |||
| 229 | if (!--data->__count) | 229 | if (!--data->__count) |
| 230 | this_cpu_write(cyc2ns.tail, data); | 230 | this_cpu_write(cyc2ns.tail, data); |
| 231 | } | 231 | } |
| 232 | preempt_enable(); | 232 | preempt_enable_notrace(); |
| 233 | 233 | ||
| 234 | return ns; | 234 | return ns; |
| 235 | } | 235 | } |
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 9d591c895803..6dea040cc3a1 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c | |||
| @@ -1001,6 +1001,12 @@ static int fault_in_kernel_space(unsigned long address) | |||
| 1001 | 1001 | ||
| 1002 | static inline bool smap_violation(int error_code, struct pt_regs *regs) | 1002 | static inline bool smap_violation(int error_code, struct pt_regs *regs) |
| 1003 | { | 1003 | { |
| 1004 | if (!IS_ENABLED(CONFIG_X86_SMAP)) | ||
| 1005 | return false; | ||
| 1006 | |||
| 1007 | if (!static_cpu_has(X86_FEATURE_SMAP)) | ||
| 1008 | return false; | ||
| 1009 | |||
| 1004 | if (error_code & PF_USER) | 1010 | if (error_code & PF_USER) |
| 1005 | return false; | 1011 | return false; |
| 1006 | 1012 | ||
| @@ -1087,11 +1093,9 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code) | |||
| 1087 | if (unlikely(error_code & PF_RSVD)) | 1093 | if (unlikely(error_code & PF_RSVD)) |
| 1088 | pgtable_bad(regs, error_code, address); | 1094 | pgtable_bad(regs, error_code, address); |
| 1089 | 1095 | ||
| 1090 | if (static_cpu_has(X86_FEATURE_SMAP)) { | 1096 | if (unlikely(smap_violation(error_code, regs))) { |
| 1091 | if (unlikely(smap_violation(error_code, regs))) { | 1097 | bad_area_nosemaphore(regs, error_code, address); |
| 1092 | bad_area_nosemaphore(regs, error_code, address); | 1098 | return; |
| 1093 | return; | ||
| 1094 | } | ||
| 1095 | } | 1099 | } |
| 1096 | 1100 | ||
| 1097 | /* | 1101 | /* |
diff --git a/arch/x86/platform/efi/efi-bgrt.c b/arch/x86/platform/efi/efi-bgrt.c index 4df9591eadad..f15103dff4b4 100644 --- a/arch/x86/platform/efi/efi-bgrt.c +++ b/arch/x86/platform/efi/efi-bgrt.c | |||
| @@ -42,7 +42,7 @@ void __init efi_bgrt_init(void) | |||
| 42 | 42 | ||
| 43 | if (bgrt_tab->header.length < sizeof(*bgrt_tab)) | 43 | if (bgrt_tab->header.length < sizeof(*bgrt_tab)) |
| 44 | return; | 44 | return; |
| 45 | if (bgrt_tab->version != 1) | 45 | if (bgrt_tab->version != 1 || bgrt_tab->status != 1) |
| 46 | return; | 46 | return; |
| 47 | if (bgrt_tab->image_type != 0 || !bgrt_tab->image_address) | 47 | if (bgrt_tab->image_type != 0 || !bgrt_tab->image_address) |
| 48 | return; | 48 | return; |
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index d62ec87a2b26..1a201ac7cef8 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c | |||
| @@ -792,7 +792,7 @@ void __init efi_set_executable(efi_memory_desc_t *md, bool executable) | |||
| 792 | set_memory_nx(addr, npages); | 792 | set_memory_nx(addr, npages); |
| 793 | } | 793 | } |
| 794 | 794 | ||
| 795 | static void __init runtime_code_page_mkexec(void) | 795 | void __init runtime_code_page_mkexec(void) |
| 796 | { | 796 | { |
| 797 | efi_memory_desc_t *md; | 797 | efi_memory_desc_t *md; |
| 798 | void *p; | 798 | void *p; |
| @@ -1069,8 +1069,7 @@ void __init efi_enter_virtual_mode(void) | |||
| 1069 | efi.update_capsule = virt_efi_update_capsule; | 1069 | efi.update_capsule = virt_efi_update_capsule; |
| 1070 | efi.query_capsule_caps = virt_efi_query_capsule_caps; | 1070 | efi.query_capsule_caps = virt_efi_query_capsule_caps; |
| 1071 | 1071 | ||
| 1072 | if (efi_enabled(EFI_OLD_MEMMAP) && (__supported_pte_mask & _PAGE_NX)) | 1072 | efi_runtime_mkexec(); |
| 1073 | runtime_code_page_mkexec(); | ||
| 1074 | 1073 | ||
| 1075 | kfree(new_memmap); | 1074 | kfree(new_memmap); |
| 1076 | 1075 | ||
diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c index 249b183cf417..0b74cdf7f816 100644 --- a/arch/x86/platform/efi/efi_32.c +++ b/arch/x86/platform/efi/efi_32.c | |||
| @@ -77,3 +77,9 @@ void efi_call_phys_epilog(void) | |||
| 77 | 77 | ||
| 78 | local_irq_restore(efi_rt_eflags); | 78 | local_irq_restore(efi_rt_eflags); |
| 79 | } | 79 | } |
| 80 | |||
| 81 | void __init efi_runtime_mkexec(void) | ||
| 82 | { | ||
| 83 | if (__supported_pte_mask & _PAGE_NX) | ||
| 84 | runtime_code_page_mkexec(); | ||
| 85 | } | ||
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index 6284f158a47d..0c2a234fef1e 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c | |||
| @@ -233,3 +233,12 @@ void __init parse_efi_setup(u64 phys_addr, u32 data_len) | |||
| 233 | { | 233 | { |
| 234 | efi_setup = phys_addr + sizeof(struct setup_data); | 234 | efi_setup = phys_addr + sizeof(struct setup_data); |
| 235 | } | 235 | } |
| 236 | |||
| 237 | void __init efi_runtime_mkexec(void) | ||
| 238 | { | ||
| 239 | if (!efi_enabled(EFI_OLD_MEMMAP)) | ||
| 240 | return; | ||
| 241 | |||
| 242 | if (__supported_pte_mask & _PAGE_NX) | ||
| 243 | runtime_code_page_mkexec(); | ||
| 244 | } | ||
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index 2423ef04ffea..256282e7888b 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c | |||
| @@ -365,7 +365,7 @@ void xen_ptep_modify_prot_commit(struct mm_struct *mm, unsigned long addr, | |||
| 365 | /* Assume pteval_t is equivalent to all the other *val_t types. */ | 365 | /* Assume pteval_t is equivalent to all the other *val_t types. */ |
| 366 | static pteval_t pte_mfn_to_pfn(pteval_t val) | 366 | static pteval_t pte_mfn_to_pfn(pteval_t val) |
| 367 | { | 367 | { |
| 368 | if (val & _PAGE_PRESENT) { | 368 | if (pteval_present(val)) { |
| 369 | unsigned long mfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT; | 369 | unsigned long mfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT; |
| 370 | unsigned long pfn = mfn_to_pfn(mfn); | 370 | unsigned long pfn = mfn_to_pfn(mfn); |
| 371 | 371 | ||
| @@ -381,7 +381,7 @@ static pteval_t pte_mfn_to_pfn(pteval_t val) | |||
| 381 | 381 | ||
| 382 | static pteval_t pte_pfn_to_mfn(pteval_t val) | 382 | static pteval_t pte_pfn_to_mfn(pteval_t val) |
| 383 | { | 383 | { |
| 384 | if (val & _PAGE_PRESENT) { | 384 | if (pteval_present(val)) { |
| 385 | unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT; | 385 | unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT; |
| 386 | pteval_t flags = val & PTE_FLAGS_MASK; | 386 | pteval_t flags = val & PTE_FLAGS_MASK; |
| 387 | unsigned long mfn; | 387 | unsigned long mfn; |
