Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8192206d authored by Ingo Molnar's avatar Ingo Molnar
Browse files

x86: change cpa to pfn based



change CPA to pfn based.

Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 687c4825
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -3,6 +3,7 @@
 * Thanks to Ben LaHaise for precious feedback.
 * Thanks to Ben LaHaise for precious feedback.
 */
 */
#include <linux/highmem.h>
#include <linux/highmem.h>
#include <linux/bootmem.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/slab.h>
@@ -144,13 +145,15 @@ static int split_large_page(pte_t *kpte, unsigned long address)
}
}


static int
static int
__change_page_attr(unsigned long address, struct page *page, pgprot_t prot)
__change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot)
{
{
	struct page *kpte_page;
	struct page *kpte_page;
	int level, err = 0;
	int level, err = 0;
	pte_t *kpte;
	pte_t *kpte;


	BUG_ON(PageHighMem(page));
#ifdef CONFIG_X86_32
	BUG_ON(pfn > max_low_pfn);
#endif


repeat:
repeat:
	kpte = lookup_address(address, &level);
	kpte = lookup_address(address, &level);
@@ -164,7 +167,7 @@ __change_page_attr(unsigned long address, struct page *page, pgprot_t prot)
	prot = check_exec(prot, address);
	prot = check_exec(prot, address);


	if (level == PG_LEVEL_4K) {
	if (level == PG_LEVEL_4K) {
		set_pte_atomic(kpte, mk_pte(page, canon_pgprot(prot)));
		set_pte_atomic(kpte, pfn_pte(pfn, canon_pgprot(prot)));
	} else {
	} else {
		err = split_large_page(kpte, address);
		err = split_large_page(kpte, address);
		if (!err)
		if (!err)
@@ -203,7 +206,7 @@ int change_page_attr_addr(unsigned long address, int numpages, pgprot_t prot)
		unsigned long pfn = __pa(address) >> PAGE_SHIFT;
		unsigned long pfn = __pa(address) >> PAGE_SHIFT;


		if (!kernel_map || pte_present(pfn_pte(0, prot))) {
		if (!kernel_map || pte_present(pfn_pte(0, prot))) {
			err = __change_page_attr(address, pfn_to_page(pfn), prot);
			err = __change_page_attr(address, pfn, prot);
			if (err)
			if (err)
				break;
				break;
		}
		}
@@ -219,7 +222,7 @@ int change_page_attr_addr(unsigned long address, int numpages, pgprot_t prot)
			addr2 = __START_KERNEL_map + __pa(address);
			addr2 = __START_KERNEL_map + __pa(address);
			/* Make sure the kernel mappings stay executable */
			/* Make sure the kernel mappings stay executable */
			prot2 = pte_pgprot(pte_mkexec(pfn_pte(0, prot)));
			prot2 = pte_pgprot(pte_mkexec(pfn_pte(0, prot)));
			err = __change_page_attr(addr2, pfn_to_page(pfn), prot2);
			err = __change_page_attr(addr2, pfn, prot2);
		}
		}
#endif
#endif
	}
	}