x86: rename LARGE_PAGE_SIZE to PMD_PAGE_SIZE
[safe/jmp/linux-2.6] / arch / x86 / mm / pageattr.c
1 /*
2  * Copyright 2002 Andi Kleen, SuSE Labs.
3  * Thanks to Ben LaHaise for precious feedback.
4  */
5 #include <linux/highmem.h>
6 #include <linux/bootmem.h>
7 #include <linux/module.h>
8 #include <linux/sched.h>
9 #include <linux/slab.h>
10 #include <linux/mm.h>
11
12 #include <asm/e820.h>
13 #include <asm/processor.h>
14 #include <asm/tlbflush.h>
15 #include <asm/sections.h>
16 #include <asm/uaccess.h>
17 #include <asm/pgalloc.h>
18
19 struct cpa_data {
20         unsigned long   vaddr;
21         pgprot_t        mask_set;
22         pgprot_t        mask_clr;
23         int             numpages;
24         int             flushtlb;
25 };
26
27 enum {
28         CPA_NO_SPLIT = 0,
29         CPA_SPLIT,
30 };
31
32 static inline int
33 within(unsigned long addr, unsigned long start, unsigned long end)
34 {
35         return addr >= start && addr < end;
36 }
37
38 /*
39  * Flushing functions
40  */
41
42 /**
43  * clflush_cache_range - flush a cache range with clflush
44  * @addr:       virtual start address
45  * @size:       number of bytes to flush
46  *
47  * clflush is an unordered instruction which needs fencing with mfence
48  * to avoid ordering issues.
49  */
50 void clflush_cache_range(void *vaddr, unsigned int size)
51 {
52         void *vend = vaddr + size - 1;
53
54         mb();
55
56         for (; vaddr < vend; vaddr += boot_cpu_data.x86_clflush_size)
57                 clflush(vaddr);
58         /*
59          * Flush any possible final partial cacheline:
60          */
61         clflush(vend);
62
63         mb();
64 }
65
66 static void __cpa_flush_all(void *arg)
67 {
68         unsigned long cache = (unsigned long)arg;
69
70         /*
71          * Flush all to work around Errata in early athlons regarding
72          * large page flushing.
73          */
74         __flush_tlb_all();
75
76         if (cache && boot_cpu_data.x86_model >= 4)
77                 wbinvd();
78 }
79
80 static void cpa_flush_all(unsigned long cache)
81 {
82         BUG_ON(irqs_disabled());
83
84         on_each_cpu(__cpa_flush_all, (void *) cache, 1, 1);
85 }
86
87 static void __cpa_flush_range(void *arg)
88 {
89         /*
90          * We could optimize that further and do individual per page
91          * tlb invalidates for a low number of pages. Caveat: we must
92          * flush the high aliases on 64bit as well.
93          */
94         __flush_tlb_all();
95 }
96
97 static void cpa_flush_range(unsigned long start, int numpages, int cache)
98 {
99         unsigned int i, level;
100         unsigned long addr;
101
102         BUG_ON(irqs_disabled());
103         WARN_ON(PAGE_ALIGN(start) != start);
104
105         on_each_cpu(__cpa_flush_range, NULL, 1, 1);
106
107         if (!cache)
108                 return;
109
110         /*
111          * We only need to flush on one CPU,
112          * clflush is a MESI-coherent instruction that
113          * will cause all other CPUs to flush the same
114          * cachelines:
115          */
116         for (i = 0, addr = start; i < numpages; i++, addr += PAGE_SIZE) {
117                 pte_t *pte = lookup_address(addr, &level);
118
119                 /*
120                  * Only flush present addresses:
121                  */
122                 if (pte && pte_present(*pte))
123                         clflush_cache_range((void *) addr, PAGE_SIZE);
124         }
125 }
126
127 #define HIGH_MAP_START  __START_KERNEL_map
128 #define HIGH_MAP_END    (__START_KERNEL_map + KERNEL_TEXT_SIZE)
129
130
131 /*
132  * Converts a virtual address to a X86-64 highmap address
133  */
134 static unsigned long virt_to_highmap(void *address)
135 {
136 #ifdef CONFIG_X86_64
137         return __pa((unsigned long)address) + HIGH_MAP_START - phys_base;
138 #else
139         return (unsigned long)address;
140 #endif
141 }
142
143 /*
144  * Certain areas of memory on x86 require very specific protection flags,
145  * for example the BIOS area or kernel text. Callers don't always get this
146  * right (again, ioremap() on BIOS memory is not uncommon) so this function
147  * checks and fixes these known static required protection bits.
148  */
149 static inline pgprot_t static_protections(pgprot_t prot, unsigned long address)
150 {
151         pgprot_t forbidden = __pgprot(0);
152
153         /*
154          * The BIOS area between 640k and 1Mb needs to be executable for
155          * PCI BIOS based config access (CONFIG_PCI_GOBIOS) support.
156          */
157         if (within(__pa(address), BIOS_BEGIN, BIOS_END))
158                 pgprot_val(forbidden) |= _PAGE_NX;
159
160         /*
161          * The kernel text needs to be executable for obvious reasons
162          * Does not cover __inittext since that is gone later on
163          */
164         if (within(address, (unsigned long)_text, (unsigned long)_etext))
165                 pgprot_val(forbidden) |= _PAGE_NX;
166         /*
167          * Do the same for the x86-64 high kernel mapping
168          */
169         if (within(address, virt_to_highmap(_text), virt_to_highmap(_etext)))
170                 pgprot_val(forbidden) |= _PAGE_NX;
171
172
173 #ifdef CONFIG_DEBUG_RODATA
174         /* The .rodata section needs to be read-only */
175         if (within(address, (unsigned long)__start_rodata,
176                                 (unsigned long)__end_rodata))
177                 pgprot_val(forbidden) |= _PAGE_RW;
178         /*
179          * Do the same for the x86-64 high kernel mapping
180          */
181         if (within(address, virt_to_highmap(__start_rodata),
182                                 virt_to_highmap(__end_rodata)))
183                 pgprot_val(forbidden) |= _PAGE_RW;
184 #endif
185
186         prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
187
188         return prot;
189 }
190
191 /*
192  * Lookup the page table entry for a virtual address. Return a pointer
193  * to the entry and the level of the mapping.
194  *
195  * Note: We return pud and pmd either when the entry is marked large
196  * or when the present bit is not set. Otherwise we would return a
197  * pointer to a nonexisting mapping.
198  */
199 pte_t *lookup_address(unsigned long address, int *level)
200 {
201         pgd_t *pgd = pgd_offset_k(address);
202         pud_t *pud;
203         pmd_t *pmd;
204
205         *level = PG_LEVEL_NONE;
206
207         if (pgd_none(*pgd))
208                 return NULL;
209         pud = pud_offset(pgd, address);
210         if (pud_none(*pud))
211                 return NULL;
212         pmd = pmd_offset(pud, address);
213         if (pmd_none(*pmd))
214                 return NULL;
215
216         *level = PG_LEVEL_2M;
217         if (pmd_large(*pmd) || !pmd_present(*pmd))
218                 return (pte_t *)pmd;
219
220         *level = PG_LEVEL_4K;
221         return pte_offset_kernel(pmd, address);
222 }
223
224 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
225 {
226         /* change init_mm */
227         set_pte_atomic(kpte, pte);
228 #ifdef CONFIG_X86_32
229         if (!SHARED_KERNEL_PMD) {
230                 struct page *page;
231
232                 list_for_each_entry(page, &pgd_list, lru) {
233                         pgd_t *pgd;
234                         pud_t *pud;
235                         pmd_t *pmd;
236
237                         pgd = (pgd_t *)page_address(page) + pgd_index(address);
238                         pud = pud_offset(pgd, address);
239                         pmd = pmd_offset(pud, address);
240                         set_pte_atomic((pte_t *)pmd, pte);
241                 }
242         }
243 #endif
244 }
245
246 static int try_preserve_large_page(pte_t *kpte, unsigned long address,
247                                    struct cpa_data *cpa)
248 {
249         unsigned long nextpage_addr, numpages, pmask, psize, flags;
250         pte_t new_pte, old_pte, *tmp;
251         pgprot_t old_prot, new_prot;
252         int level, res = CPA_SPLIT;
253
254         /*
255          * An Athlon 64 X2 showed hard hangs if we tried to preserve
256          * largepages and changed the PSE entry from RW to RO.
257          *
258          * As AMD CPUs have a long series of erratas in this area,
259          * (and none of the known ones seem to explain this hang),
260          * disable this code until the hang can be debugged:
261          */
262         if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
263                 return res;
264
265         spin_lock_irqsave(&pgd_lock, flags);
266         /*
267          * Check for races, another CPU might have split this page
268          * up already:
269          */
270         tmp = lookup_address(address, &level);
271         if (tmp != kpte)
272                 goto out_unlock;
273
274         switch (level) {
275         case PG_LEVEL_2M:
276                 psize = PMD_PAGE_SIZE;
277                 pmask = PMD_PAGE_MASK;
278                 break;
279         case PG_LEVEL_1G:
280         default:
281                 res = -EINVAL;
282                 goto out_unlock;
283         }
284
285         /*
286          * Calculate the number of pages, which fit into this large
287          * page starting at address:
288          */
289         nextpage_addr = (address + psize) & pmask;
290         numpages = (nextpage_addr - address) >> PAGE_SHIFT;
291         if (numpages < cpa->numpages)
292                 cpa->numpages = numpages;
293
294         /*
295          * We are safe now. Check whether the new pgprot is the same:
296          */
297         old_pte = *kpte;
298         old_prot = new_prot = pte_pgprot(old_pte);
299
300         pgprot_val(new_prot) &= ~pgprot_val(cpa->mask_clr);
301         pgprot_val(new_prot) |= pgprot_val(cpa->mask_set);
302         new_prot = static_protections(new_prot, address);
303
304         /*
305          * If there are no changes, return. maxpages has been updated
306          * above:
307          */
308         if (pgprot_val(new_prot) == pgprot_val(old_prot)) {
309                 res = CPA_NO_SPLIT;
310                 goto out_unlock;
311         }
312
313         /*
314          * We need to change the attributes. Check, whether we can
315          * change the large page in one go. We request a split, when
316          * the address is not aligned and the number of pages is
317          * smaller than the number of pages in the large page. Note
318          * that we limited the number of possible pages already to
319          * the number of pages in the large page.
320          */
321         if (address == (nextpage_addr - psize) && cpa->numpages == numpages) {
322                 /*
323                  * The address is aligned and the number of pages
324                  * covers the full page.
325                  */
326                 new_pte = pfn_pte(pte_pfn(old_pte), canon_pgprot(new_prot));
327                 __set_pmd_pte(kpte, address, new_pte);
328                 cpa->flushtlb = 1;
329                 res = CPA_NO_SPLIT;
330         }
331
332 out_unlock:
333         spin_unlock_irqrestore(&pgd_lock, flags);
334         return res;
335 }
336
337 static int split_large_page(pte_t *kpte, unsigned long address)
338 {
339         pgprot_t ref_prot = pte_pgprot(pte_clrhuge(*kpte));
340         gfp_t gfp_flags = GFP_KERNEL;
341         unsigned long flags, addr, pfn;
342         pte_t *pbase, *tmp;
343         struct page *base;
344         unsigned int i, level;
345
346 #ifdef CONFIG_DEBUG_PAGEALLOC
347         gfp_flags = __GFP_HIGH | __GFP_NOFAIL | __GFP_NOWARN;
348         gfp_flags = GFP_ATOMIC | __GFP_NOWARN;
349 #endif
350         base = alloc_pages(gfp_flags, 0);
351         if (!base)
352                 return -ENOMEM;
353
354         spin_lock_irqsave(&pgd_lock, flags);
355         /*
356          * Check for races, another CPU might have split this page
357          * up for us already:
358          */
359         tmp = lookup_address(address, &level);
360         if (tmp != kpte) {
361                 WARN_ON_ONCE(1);
362                 goto out_unlock;
363         }
364
365         address = __pa(address);
366         addr = address & PMD_PAGE_MASK;
367         pbase = (pte_t *)page_address(base);
368 #ifdef CONFIG_X86_32
369         paravirt_alloc_pt(&init_mm, page_to_pfn(base));
370 #endif
371
372         /*
373          * Get the target pfn from the original entry:
374          */
375         pfn = pte_pfn(*kpte);
376         for (i = 0; i < PTRS_PER_PTE; i++, pfn++)
377                 set_pte(&pbase[i], pfn_pte(pfn, ref_prot));
378
379         /*
380          * Install the new, split up pagetable. Important detail here:
381          *
382          * On Intel the NX bit of all levels must be cleared to make a
383          * page executable. See section 4.13.2 of Intel 64 and IA-32
384          * Architectures Software Developer's Manual).
385          */
386         ref_prot = pte_pgprot(pte_mkexec(pte_clrhuge(*kpte)));
387         __set_pmd_pte(kpte, address, mk_pte(base, ref_prot));
388         base = NULL;
389
390 out_unlock:
391         spin_unlock_irqrestore(&pgd_lock, flags);
392
393         if (base)
394                 __free_pages(base, 0);
395
396         return 0;
397 }
398
399 static int __change_page_attr(unsigned long address, struct cpa_data *cpa)
400 {
401         struct page *kpte_page;
402         int level, res;
403         pte_t *kpte;
404
405 repeat:
406         kpte = lookup_address(address, &level);
407         if (!kpte)
408                 return -EINVAL;
409
410         kpte_page = virt_to_page(kpte);
411         BUG_ON(PageLRU(kpte_page));
412         BUG_ON(PageCompound(kpte_page));
413
414         if (level == PG_LEVEL_4K) {
415                 pte_t new_pte, old_pte = *kpte;
416                 pgprot_t new_prot = pte_pgprot(old_pte);
417
418                 if(!pte_val(old_pte)) {
419                         printk(KERN_WARNING "CPA: called for zero pte. "
420                                "vaddr = %lx cpa->vaddr = %lx\n", address,
421                                 cpa->vaddr);
422                         WARN_ON(1);
423                         return -EINVAL;
424                 }
425
426                 pgprot_val(new_prot) &= ~pgprot_val(cpa->mask_clr);
427                 pgprot_val(new_prot) |= pgprot_val(cpa->mask_set);
428
429                 new_prot = static_protections(new_prot, address);
430
431                 /*
432                  * We need to keep the pfn from the existing PTE,
433                  * after all we're only going to change it's attributes
434                  * not the memory it points to
435                  */
436                 new_pte = pfn_pte(pte_pfn(old_pte), canon_pgprot(new_prot));
437
438                 /*
439                  * Do we really change anything ?
440                  */
441                 if (pte_val(old_pte) != pte_val(new_pte)) {
442                         set_pte_atomic(kpte, new_pte);
443                         cpa->flushtlb = 1;
444                 }
445                 cpa->numpages = 1;
446                 return 0;
447         }
448
449         /*
450          * Check, whether we can keep the large page intact
451          * and just change the pte:
452          */
453         res = try_preserve_large_page(kpte, address, cpa);
454         if (res < 0)
455                 return res;
456
457         /*
458          * When the range fits into the existing large page,
459          * return. cp->numpages and cpa->tlbflush have been updated in
460          * try_large_page:
461          */
462         if (res == CPA_NO_SPLIT)
463                 return 0;
464
465         /*
466          * We have to split the large page:
467          */
468         res = split_large_page(kpte, address);
469         if (res)
470                 return res;
471         cpa->flushtlb = 1;
472         goto repeat;
473 }
474
475 /**
476  * change_page_attr_addr - Change page table attributes in linear mapping
477  * @address: Virtual address in linear mapping.
478  * @prot:    New page table attribute (PAGE_*)
479  *
480  * Change page attributes of a page in the direct mapping. This is a variant
481  * of change_page_attr() that also works on memory holes that do not have
482  * mem_map entry (pfn_valid() is false).
483  *
484  * See change_page_attr() documentation for more details.
485  *
486  * Modules and drivers should use the set_memory_* APIs instead.
487  */
488
489 static int change_page_attr_addr(struct cpa_data *cpa)
490 {
491         int err;
492         unsigned long address = cpa->vaddr;
493
494 #ifdef CONFIG_X86_64
495         unsigned long phys_addr = __pa(address);
496
497         /*
498          * If we are inside the high mapped kernel range, then we
499          * fixup the low mapping first. __va() returns the virtual
500          * address in the linear mapping:
501          */
502         if (within(address, HIGH_MAP_START, HIGH_MAP_END))
503                 address = (unsigned long) __va(phys_addr);
504 #endif
505
506         err = __change_page_attr(address, cpa);
507         if (err)
508                 return err;
509
510 #ifdef CONFIG_X86_64
511         /*
512          * If the physical address is inside the kernel map, we need
513          * to touch the high mapped kernel as well:
514          */
515         if (within(phys_addr, 0, KERNEL_TEXT_SIZE)) {
516                 /*
517                  * Calc the high mapping address. See __phys_addr()
518                  * for the non obvious details.
519                  *
520                  * Note that NX and other required permissions are
521                  * checked in static_protections().
522                  */
523                 address = phys_addr + HIGH_MAP_START - phys_base;
524
525                 /*
526                  * Our high aliases are imprecise, because we check
527                  * everything between 0 and KERNEL_TEXT_SIZE, so do
528                  * not propagate lookup failures back to users:
529                  */
530                 __change_page_attr(address, cpa);
531         }
532 #endif
533         return err;
534 }
535
536 static int __change_page_attr_set_clr(struct cpa_data *cpa)
537 {
538         int ret, numpages = cpa->numpages;
539
540         while (numpages) {
541                 /*
542                  * Store the remaining nr of pages for the large page
543                  * preservation check.
544                  */
545                 cpa->numpages = numpages;
546                 ret = change_page_attr_addr(cpa);
547                 if (ret)
548                         return ret;
549
550                 /*
551                  * Adjust the number of pages with the result of the
552                  * CPA operation. Either a large page has been
553                  * preserved or a single page update happened.
554                  */
555                 BUG_ON(cpa->numpages > numpages);
556                 numpages -= cpa->numpages;
557                 cpa->vaddr += cpa->numpages * PAGE_SIZE;
558         }
559         return 0;
560 }
561
562 static inline int cache_attr(pgprot_t attr)
563 {
564         return pgprot_val(attr) &
565                 (_PAGE_PAT | _PAGE_PAT_LARGE | _PAGE_PWT | _PAGE_PCD);
566 }
567
568 static int change_page_attr_set_clr(unsigned long addr, int numpages,
569                                     pgprot_t mask_set, pgprot_t mask_clr)
570 {
571         struct cpa_data cpa;
572         int ret, cache;
573
574         /*
575          * Check, if we are requested to change a not supported
576          * feature:
577          */
578         mask_set = canon_pgprot(mask_set);
579         mask_clr = canon_pgprot(mask_clr);
580         if (!pgprot_val(mask_set) && !pgprot_val(mask_clr))
581                 return 0;
582
583         cpa.vaddr = addr;
584         cpa.numpages = numpages;
585         cpa.mask_set = mask_set;
586         cpa.mask_clr = mask_clr;
587         cpa.flushtlb = 0;
588
589         ret = __change_page_attr_set_clr(&cpa);
590
591         /*
592          * Check whether we really changed something:
593          */
594         if (!cpa.flushtlb)
595                 return ret;
596
597         /*
598          * No need to flush, when we did not set any of the caching
599          * attributes:
600          */
601         cache = cache_attr(mask_set);
602
603         /*
604          * On success we use clflush, when the CPU supports it to
605          * avoid the wbindv. If the CPU does not support it and in the
606          * error case we fall back to cpa_flush_all (which uses
607          * wbindv):
608          */
609         if (!ret && cpu_has_clflush)
610                 cpa_flush_range(addr, numpages, cache);
611         else
612                 cpa_flush_all(cache);
613
614         return ret;
615 }
616
617 static inline int change_page_attr_set(unsigned long addr, int numpages,
618                                        pgprot_t mask)
619 {
620         return change_page_attr_set_clr(addr, numpages, mask, __pgprot(0));
621 }
622
623 static inline int change_page_attr_clear(unsigned long addr, int numpages,
624                                          pgprot_t mask)
625 {
626         return change_page_attr_set_clr(addr, numpages, __pgprot(0), mask);
627 }
628
629 int set_memory_uc(unsigned long addr, int numpages)
630 {
631         return change_page_attr_set(addr, numpages,
632                                     __pgprot(_PAGE_PCD | _PAGE_PWT));
633 }
634 EXPORT_SYMBOL(set_memory_uc);
635
636 int set_memory_wb(unsigned long addr, int numpages)
637 {
638         return change_page_attr_clear(addr, numpages,
639                                       __pgprot(_PAGE_PCD | _PAGE_PWT));
640 }
641 EXPORT_SYMBOL(set_memory_wb);
642
643 int set_memory_x(unsigned long addr, int numpages)
644 {
645         return change_page_attr_clear(addr, numpages, __pgprot(_PAGE_NX));
646 }
647 EXPORT_SYMBOL(set_memory_x);
648
649 int set_memory_nx(unsigned long addr, int numpages)
650 {
651         return change_page_attr_set(addr, numpages, __pgprot(_PAGE_NX));
652 }
653 EXPORT_SYMBOL(set_memory_nx);
654
655 int set_memory_ro(unsigned long addr, int numpages)
656 {
657         return change_page_attr_clear(addr, numpages, __pgprot(_PAGE_RW));
658 }
659
660 int set_memory_rw(unsigned long addr, int numpages)
661 {
662         return change_page_attr_set(addr, numpages, __pgprot(_PAGE_RW));
663 }
664
665 int set_memory_np(unsigned long addr, int numpages)
666 {
667         return change_page_attr_clear(addr, numpages, __pgprot(_PAGE_PRESENT));
668 }
669
670 int set_pages_uc(struct page *page, int numpages)
671 {
672         unsigned long addr = (unsigned long)page_address(page);
673
674         return set_memory_uc(addr, numpages);
675 }
676 EXPORT_SYMBOL(set_pages_uc);
677
678 int set_pages_wb(struct page *page, int numpages)
679 {
680         unsigned long addr = (unsigned long)page_address(page);
681
682         return set_memory_wb(addr, numpages);
683 }
684 EXPORT_SYMBOL(set_pages_wb);
685
686 int set_pages_x(struct page *page, int numpages)
687 {
688         unsigned long addr = (unsigned long)page_address(page);
689
690         return set_memory_x(addr, numpages);
691 }
692 EXPORT_SYMBOL(set_pages_x);
693
694 int set_pages_nx(struct page *page, int numpages)
695 {
696         unsigned long addr = (unsigned long)page_address(page);
697
698         return set_memory_nx(addr, numpages);
699 }
700 EXPORT_SYMBOL(set_pages_nx);
701
702 int set_pages_ro(struct page *page, int numpages)
703 {
704         unsigned long addr = (unsigned long)page_address(page);
705
706         return set_memory_ro(addr, numpages);
707 }
708
709 int set_pages_rw(struct page *page, int numpages)
710 {
711         unsigned long addr = (unsigned long)page_address(page);
712
713         return set_memory_rw(addr, numpages);
714 }
715
716 #ifdef CONFIG_DEBUG_PAGEALLOC
717
718 static int __set_pages_p(struct page *page, int numpages)
719 {
720         struct cpa_data cpa = { .vaddr = (unsigned long) page_address(page),
721                                 .numpages = numpages,
722                                 .mask_set = __pgprot(_PAGE_PRESENT | _PAGE_RW),
723                                 .mask_clr = __pgprot(0)};
724
725         return __change_page_attr_set_clr(&cpa);
726 }
727
728 static int __set_pages_np(struct page *page, int numpages)
729 {
730         struct cpa_data cpa = { .vaddr = (unsigned long) page_address(page),
731                                 .numpages = numpages,
732                                 .mask_set = __pgprot(0),
733                                 .mask_clr = __pgprot(_PAGE_PRESENT | _PAGE_RW)};
734
735         return __change_page_attr_set_clr(&cpa);
736 }
737
738 void kernel_map_pages(struct page *page, int numpages, int enable)
739 {
740         if (PageHighMem(page))
741                 return;
742         if (!enable) {
743                 debug_check_no_locks_freed(page_address(page),
744                                            numpages * PAGE_SIZE);
745         }
746
747         /*
748          * If page allocator is not up yet then do not call c_p_a():
749          */
750         if (!debug_pagealloc_enabled)
751                 return;
752
753         /*
754          * The return value is ignored - the calls cannot fail,
755          * large pages are disabled at boot time:
756          */
757         if (enable)
758                 __set_pages_p(page, numpages);
759         else
760                 __set_pages_np(page, numpages);
761
762         /*
763          * We should perform an IPI and flush all tlbs,
764          * but that can deadlock->flush only current cpu:
765          */
766         __flush_tlb_all();
767 }
768 #endif
769
770 /*
771  * The testcases use internal knowledge of the implementation that shouldn't
772  * be exposed to the rest of the kernel. Include these directly here.
773  */
774 #ifdef CONFIG_CPA_DEBUG
775 #include "pageattr-test.c"
776 #endif