Subversion Repositories Kolibri OS

Rev

Rev 5270 | Rev 6934 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5270 Rev 6082
Line 17... Line 17...
17
 
17
 
18
#ifndef __ASSEMBLY__
18
#ifndef __ASSEMBLY__
Line 19... Line 19...
19
#include 
19
#include 
-
 
20
 
-
 
21
void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd);
-
 
22
void ptdump_walk_pgd_level_checkwx(void);
-
 
23
 
-
 
24
#ifdef CONFIG_DEBUG_WX
-
 
25
#define debug_checkwx() ptdump_walk_pgd_level_checkwx()
-
 
26
#else
Line 20... Line 27...
20
 
27
#define debug_checkwx() do { } while (0)
21
void ptdump_walk_pgd_level(struct seq_file *m, pgd_t *pgd);
28
#endif
22
 
29
 
23
/*
30
/*
Line 113... Line 120...
113
static inline int pte_write(pte_t pte)
120
static inline int pte_write(pte_t pte)
114
{
121
{
115
	return pte_flags(pte) & _PAGE_RW;
122
	return pte_flags(pte) & _PAGE_RW;
116
}
123
}
Line 117... Line -...
117
 
-
 
118
static inline int pte_file(pte_t pte)
-
 
119
{
-
 
120
	return pte_flags(pte) & _PAGE_FILE;
-
 
121
}
-
 
122
 
124
 
123
static inline int pte_huge(pte_t pte)
125
static inline int pte_huge(pte_t pte)
124
{
126
{
125
	return pte_flags(pte) & _PAGE_PSE;
127
	return pte_flags(pte) & _PAGE_PSE;
Line 135... Line 137...
135
	return !(pte_flags(pte) & _PAGE_NX);
137
	return !(pte_flags(pte) & _PAGE_NX);
136
}
138
}
Line 137... Line 139...
137
 
139
 
138
static inline int pte_special(pte_t pte)
140
static inline int pte_special(pte_t pte)
139
{
-
 
140
	/*
-
 
141
	 * See CONFIG_NUMA_BALANCING pte_numa in include/asm-generic/pgtable.h.
-
 
142
	 * On x86 we have _PAGE_BIT_NUMA == _PAGE_BIT_GLOBAL+1 ==
-
 
143
	 * __PAGE_BIT_SOFTW1 == _PAGE_BIT_SPECIAL.
-
 
144
	 */
141
{
145
	return (pte_flags(pte) & _PAGE_SPECIAL) &&
-
 
146
		(pte_flags(pte) & (_PAGE_PRESENT|_PAGE_PROTNONE));
142
	return pte_flags(pte) & _PAGE_SPECIAL;
Line 147... Line 143...
147
}
143
}
148
 
144
 
149
static inline unsigned long pte_pfn(pte_t pte)
145
static inline unsigned long pte_pfn(pte_t pte)
150
{
146
{
Line 151... Line 147...
151
	return (pte_val(pte) & PTE_PFN_MASK) >> PAGE_SHIFT;
147
	return (pte_val(pte) & PTE_PFN_MASK) >> PAGE_SHIFT;
152
}
148
}
153
 
149
 
154
static inline unsigned long pmd_pfn(pmd_t pmd)
150
static inline unsigned long pmd_pfn(pmd_t pmd)
Line 155... Line 151...
155
{
151
{
156
	return (pmd_val(pmd) & PTE_PFN_MASK) >> PAGE_SHIFT;
152
	return (pmd_val(pmd) & pmd_pfn_mask(pmd)) >> PAGE_SHIFT;
157
}
153
}
158
 
154
 
Line 159... Line 155...
159
static inline unsigned long pud_pfn(pud_t pud)
155
static inline unsigned long pud_pfn(pud_t pud)
Line 160... Line 156...
160
{
156
{
Line 303... Line 299...
303
	return pmd_set_flags(pmd, _PAGE_RW);
299
	return pmd_set_flags(pmd, _PAGE_RW);
304
}
300
}
Line 305... Line 301...
305
 
301
 
306
static inline pmd_t pmd_mknotpresent(pmd_t pmd)
302
static inline pmd_t pmd_mknotpresent(pmd_t pmd)
307
{
303
{
308
	return pmd_clear_flags(pmd, _PAGE_PRESENT);
304
	return pmd_clear_flags(pmd, _PAGE_PRESENT | _PAGE_PROTNONE);
Line 309... Line 305...
309
}
305
}
310
 
306
 
311
#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
307
#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
Line 327... Line 323...
327
static inline pmd_t pmd_mksoft_dirty(pmd_t pmd)
323
static inline pmd_t pmd_mksoft_dirty(pmd_t pmd)
328
{
324
{
329
	return pmd_set_flags(pmd, _PAGE_SOFT_DIRTY);
325
	return pmd_set_flags(pmd, _PAGE_SOFT_DIRTY);
330
}
326
}
Line 331... Line 327...
331
 
327
 
332
static inline pte_t pte_file_clear_soft_dirty(pte_t pte)
328
static inline pte_t pte_clear_soft_dirty(pte_t pte)
333
{
329
{
334
	return pte_clear_flags(pte, _PAGE_SOFT_DIRTY);
330
	return pte_clear_flags(pte, _PAGE_SOFT_DIRTY);
Line 335... Line 331...
335
}
331
}
336
 
332
 
337
static inline pte_t pte_file_mksoft_dirty(pte_t pte)
333
static inline pmd_t pmd_clear_soft_dirty(pmd_t pmd)
338
{
-
 
339
	return pte_set_flags(pte, _PAGE_SOFT_DIRTY);
-
 
340
}
-
 
341
 
-
 
342
static inline int pte_file_soft_dirty(pte_t pte)
-
 
343
{
334
{
Line 344... Line 335...
344
	return pte_flags(pte) & _PAGE_SOFT_DIRTY;
335
	return pmd_clear_flags(pmd, _PAGE_SOFT_DIRTY);
Line 345... Line 336...
345
}
336
}
Line 403... Line 394...
403
	pgprotval_t preservebits = pgprot_val(oldprot) & _PAGE_CHG_MASK;
394
	pgprotval_t preservebits = pgprot_val(oldprot) & _PAGE_CHG_MASK;
404
	pgprotval_t addbits = pgprot_val(newprot);
395
	pgprotval_t addbits = pgprot_val(newprot);
405
	return __pgprot(preservebits | addbits);
396
	return __pgprot(preservebits | addbits);
406
}
397
}
Line 407... Line 398...
407
 
398
 
-
 
399
#define pte_pgprot(x) __pgprot(pte_flags(x))
-
 
400
#define pmd_pgprot(x) __pgprot(pmd_flags(x))
Line 408... Line 401...
408
#define pte_pgprot(x) __pgprot(pte_flags(x) & PTE_FLAGS_MASK)
401
#define pud_pgprot(x) __pgprot(pud_flags(x))
Line 409... Line 402...
409
 
402
 
410
#define canon_pgprot(p) __pgprot(massage_pgprot(p))
403
#define canon_pgprot(p) __pgprot(massage_pgprot(p))
Line 422... Line 415...
422
	/*
415
	/*
423
	 * Certain new memtypes are not allowed with certain
416
	 * Certain new memtypes are not allowed with certain
424
	 * requested memtype:
417
	 * requested memtype:
425
	 * - request is uncached, return cannot be write-back
418
	 * - request is uncached, return cannot be write-back
426
	 * - request is write-combine, return cannot be write-back
419
	 * - request is write-combine, return cannot be write-back
-
 
420
	 * - request is write-through, return cannot be write-back
-
 
421
	 * - request is write-through, return cannot be write-combine
427
	 */
422
	 */
428
	if ((pcm == _PAGE_CACHE_MODE_UC_MINUS &&
423
	if ((pcm == _PAGE_CACHE_MODE_UC_MINUS &&
429
	     new_pcm == _PAGE_CACHE_MODE_WB) ||
424
	     new_pcm == _PAGE_CACHE_MODE_WB) ||
430
	    (pcm == _PAGE_CACHE_MODE_WC &&
425
	    (pcm == _PAGE_CACHE_MODE_WC &&
-
 
426
	     new_pcm == _PAGE_CACHE_MODE_WB) ||
-
 
427
	    (pcm == _PAGE_CACHE_MODE_WT &&
-
 
428
	     new_pcm == _PAGE_CACHE_MODE_WB) ||
-
 
429
	    (pcm == _PAGE_CACHE_MODE_WT &&
431
	     new_pcm == _PAGE_CACHE_MODE_WB)) {
430
	     new_pcm == _PAGE_CACHE_MODE_WC)) {
432
		return 0;
431
		return 0;
433
	}
432
	}
Line 434... Line 433...
434
 
433
 
435
	return 1;
434
	return 1;
Line 461... Line 460...
461
	return a.pte == b.pte;
460
	return a.pte == b.pte;
462
}
461
}
Line 463... Line 462...
463
 
462
 
464
static inline int pte_present(pte_t a)
463
static inline int pte_present(pte_t a)
465
{
-
 
466
	return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE |
-
 
467
			       _PAGE_NUMA);
-
 
468
}
-
 
469
 
-
 
470
#define pte_present_nonuma pte_present_nonuma
-
 
471
static inline int pte_present_nonuma(pte_t a)
-
 
472
{
464
{
473
	return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE);
465
	return pte_flags(a) & (_PAGE_PRESENT | _PAGE_PROTNONE);
Line 474... Line 466...
474
}
466
}
475
 
467
 
476
#define pte_accessible pte_accessible
468
#define pte_accessible pte_accessible
477
static inline bool pte_accessible(struct mm_struct *mm, pte_t a)
469
static inline bool pte_accessible(struct mm_struct *mm, pte_t a)
478
{
470
{
Line 479... Line 471...
479
	if (pte_flags(a) & _PAGE_PRESENT)
471
	if (pte_flags(a) & _PAGE_PRESENT)
480
		return true;
472
		return true;
481
 
473
 
Line 482... Line 474...
482
	if ((pte_flags(a) & (_PAGE_PROTNONE | _PAGE_NUMA)) &&
474
	if ((pte_flags(a) & _PAGE_PROTNONE) &&
483
			mm_tlb_flush_pending(mm))
475
			mm_tlb_flush_pending(mm))
Line 497... Line 489...
497
	 * Checking for _PAGE_PSE is needed too because
489
	 * Checking for _PAGE_PSE is needed too because
498
	 * split_huge_page will temporarily clear the present bit (but
490
	 * split_huge_page will temporarily clear the present bit (but
499
	 * the _PAGE_PSE flag will remain set at all times while the
491
	 * the _PAGE_PSE flag will remain set at all times while the
500
	 * _PAGE_PRESENT bit is clear).
492
	 * _PAGE_PRESENT bit is clear).
501
	 */
493
	 */
502
	return pmd_flags(pmd) & (_PAGE_PRESENT | _PAGE_PROTNONE | _PAGE_PSE |
494
	return pmd_flags(pmd) & (_PAGE_PRESENT | _PAGE_PROTNONE | _PAGE_PSE);
503
				 _PAGE_NUMA);
-
 
504
}
495
}
Line -... Line 496...
-
 
496
 
-
 
497
#ifdef CONFIG_NUMA_BALANCING
-
 
498
/*
-
 
499
 * These work without NUMA balancing but the kernel does not care. See the
-
 
500
 * comment in include/asm-generic/pgtable.h
-
 
501
 */
-
 
502
static inline int pte_protnone(pte_t pte)
-
 
503
{
-
 
504
	return (pte_flags(pte) & (_PAGE_PROTNONE | _PAGE_PRESENT))
-
 
505
		== _PAGE_PROTNONE;
-
 
506
}
-
 
507
 
-
 
508
static inline int pmd_protnone(pmd_t pmd)
-
 
509
{
-
 
510
	return (pmd_flags(pmd) & (_PAGE_PROTNONE | _PAGE_PRESENT))
-
 
511
		== _PAGE_PROTNONE;
-
 
512
}
-
 
513
#endif /* CONFIG_NUMA_BALANCING */
505
 
514
 
506
static inline int pmd_none(pmd_t pmd)
515
static inline int pmd_none(pmd_t pmd)
507
{
516
{
508
	/* Only check low word on 32-bit platforms, since it might be
517
	/* Only check low word on 32-bit platforms, since it might be
509
	   out of sync with upper half. */
518
	   out of sync with upper half. */
510
	return (unsigned long)native_pmd_val(pmd) == 0;
519
	return (unsigned long)native_pmd_val(pmd) == 0;
Line 511... Line 520...
511
}
520
}
512
 
521
 
513
static inline unsigned long pmd_page_vaddr(pmd_t pmd)
522
static inline unsigned long pmd_page_vaddr(pmd_t pmd)
514
{
523
{
Line 515... Line 524...
515
	return (unsigned long)__va(pmd_val(pmd) & PTE_PFN_MASK);
524
	return (unsigned long)__va(pmd_val(pmd) & pmd_pfn_mask(pmd));
516
}
525
}
517
 
526
 
518
/*
527
/*
-
 
528
 * Currently stuck as a macro due to indirect forward reference to
519
 * Currently stuck as a macro due to indirect forward reference to
529
 * linux/mmzone.h's __section_mem_map_addr() definition:
Line 520... Line 530...
520
 * linux/mmzone.h's __section_mem_map_addr() definition:
530
 */
521
 */
531
#define pmd_page(pmd)		\
522
#define pmd_page(pmd)	pfn_to_page((pmd_val(pmd) & PTE_PFN_MASK) >> PAGE_SHIFT)
532
	pfn_to_page((pmd_val(pmd) & pmd_pfn_mask(pmd)) >> PAGE_SHIFT)
523
 
533
 
Line 557... Line 567...
557
	return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
567
	return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
558
}
568
}
Line 559... Line 569...
559
 
569
 
560
static inline int pmd_bad(pmd_t pmd)
570
static inline int pmd_bad(pmd_t pmd)
561
{
-
 
562
#ifdef CONFIG_NUMA_BALANCING
-
 
563
	/* pmd_numa check */
-
 
564
	if ((pmd_flags(pmd) & (_PAGE_NUMA|_PAGE_PRESENT)) == _PAGE_NUMA)
-
 
565
		return 0;
-
 
566
#endif
571
{
567
	return (pmd_flags(pmd) & ~_PAGE_USER) != _KERNPG_TABLE;
572
	return (pmd_flags(pmd) & ~_PAGE_USER) != _KERNPG_TABLE;
Line 568... Line 573...
568
}
573
}
569
 
574
 
570
static inline unsigned long pages_to_mb(unsigned long npg)
575
static inline unsigned long pages_to_mb(unsigned long npg)
571
{
576
{
Line 572... Line 577...
572
	return npg >> (20 - PAGE_SHIFT);
577
	return npg >> (20 - PAGE_SHIFT);
573
}
578
}
574
 
579
 
575
#if PAGETABLE_LEVELS > 2
580
#if CONFIG_PGTABLE_LEVELS > 2
576
static inline int pud_none(pud_t pud)
581
static inline int pud_none(pud_t pud)
Line 583... Line 588...
583
	return pud_flags(pud) & _PAGE_PRESENT;
588
	return pud_flags(pud) & _PAGE_PRESENT;
584
}
589
}
Line 585... Line 590...
585
 
590
 
586
static inline unsigned long pud_page_vaddr(pud_t pud)
591
static inline unsigned long pud_page_vaddr(pud_t pud)
587
{
592
{
588
	return (unsigned long)__va((unsigned long)pud_val(pud) & PTE_PFN_MASK);
593
	return (unsigned long)__va(pud_val(pud) & pud_pfn_mask(pud));
Line 589... Line 594...
589
}
594
}
590
 
595
 
591
/*
596
/*
592
 * Currently stuck as a macro due to indirect forward reference to
597
 * Currently stuck as a macro due to indirect forward reference to
-
 
598
 * linux/mmzone.h's __section_mem_map_addr() definition:
593
 * linux/mmzone.h's __section_mem_map_addr() definition:
599
 */
Line 594... Line 600...
594
 */
600
#define pud_page(pud)		\
595
#define pud_page(pud)		pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
601
	pfn_to_page((pud_val(pud) & pud_pfn_mask(pud)) >> PAGE_SHIFT)
596
 
602
 
597
/* Find an entry in the second-level page table.. */
603
/* Find an entry in the second-level page table.. */
Line 613... Line 619...
613
#else
619
#else
614
static inline int pud_large(pud_t pud)
620
static inline int pud_large(pud_t pud)
615
{
621
{
616
	return 0;
622
	return 0;
617
}
623
}
618
#endif	/* PAGETABLE_LEVELS > 2 */
624
#endif	/* CONFIG_PGTABLE_LEVELS > 2 */
Line 619... Line 625...
619
 
625
 
620
#if PAGETABLE_LEVELS > 3
626
#if CONFIG_PGTABLE_LEVELS > 3
621
static inline int pgd_present(pgd_t pgd)
627
static inline int pgd_present(pgd_t pgd)
622
{
628
{
623
	return pgd_flags(pgd) & _PAGE_PRESENT;
629
	return pgd_flags(pgd) & _PAGE_PRESENT;
Line 652... Line 658...
652
 
658
 
653
static inline int pgd_none(pgd_t pgd)
659
static inline int pgd_none(pgd_t pgd)
654
{
660
{
655
	return !native_pgd_val(pgd);
661
	return !native_pgd_val(pgd);
656
}
662
}
Line 657... Line 663...
657
#endif	/* PAGETABLE_LEVELS > 3 */
663
#endif	/* CONFIG_PGTABLE_LEVELS > 3 */
Line 658... Line 664...
658
 
664
 
659
#endif	/* __ASSEMBLY__ */
665
#endif	/* __ASSEMBLY__ */
Line 818... Line 824...
818
static inline int pmd_write(pmd_t pmd)
824
static inline int pmd_write(pmd_t pmd)
819
{
825
{
820
	return pmd_flags(pmd) & _PAGE_RW;
826
	return pmd_flags(pmd) & _PAGE_RW;
821
}
827
}
Line 822... Line 828...
822
 
828
 
823
#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
829
#define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
824
static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm, unsigned long addr,
830
static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, unsigned long addr,
825
				       pmd_t *pmdp)
831
				       pmd_t *pmdp)
826
{
832
{
827
	pmd_t pmd = native_pmdp_get_and_clear(pmdp);
833
	pmd_t pmd = native_pmdp_get_and_clear(pmdp);
828
	pmd_update(mm, addr, pmdp);
834
	pmd_update(mm, addr, pmdp);
Line 880... Line 886...
880
}
886
}
Line 881... Line 887...
881
 
887
 
882
#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
888
#ifdef CONFIG_HAVE_ARCH_SOFT_DIRTY
883
static inline pte_t pte_swp_mksoft_dirty(pte_t pte)
889
static inline pte_t pte_swp_mksoft_dirty(pte_t pte)
884
{
-
 
885
	VM_BUG_ON(pte_present_nonuma(pte));
890
{
886
	return pte_set_flags(pte, _PAGE_SWP_SOFT_DIRTY);
891
	return pte_set_flags(pte, _PAGE_SWP_SOFT_DIRTY);
Line 887... Line 892...
887
}
892
}
888
 
893
 
889
static inline int pte_swp_soft_dirty(pte_t pte)
-
 
890
{
894
static inline int pte_swp_soft_dirty(pte_t pte)
891
	VM_BUG_ON(pte_present_nonuma(pte));
895
{
Line 892... Line 896...
892
	return pte_flags(pte) & _PAGE_SWP_SOFT_DIRTY;
896
	return pte_flags(pte) & _PAGE_SWP_SOFT_DIRTY;
893
}
897
}
894
 
-
 
895
static inline pte_t pte_swp_clear_soft_dirty(pte_t pte)
898
 
896
{
899
static inline pte_t pte_swp_clear_soft_dirty(pte_t pte)
897
	VM_BUG_ON(pte_present_nonuma(pte));
900
{
Line 898... Line 901...
898
	return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY);
901
	return pte_clear_flags(pte, _PAGE_SWP_SOFT_DIRTY);