Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * highmem.c: virtual kernel memory mappings for high memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * PowerPC version, stolen from the i386 version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Used in CONFIG_HIGHMEM systems for memory pages which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * are not addressable by direct kernel virtual addresses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  * Copyright (C) 1999 Gerhard Wichert, Siemens AG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)  *		      Gerhard.Wichert@pdb.siemens.de
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  * Redesigned the x86 32-bit VM architecture to deal with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  * up to 16 Terrabyte physical memory. With current x86 CPUs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)  * we now support up to 64 Gigabytes physical RAM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  * Reworked for PowerPC by various contributors. Moved from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  * highmem.h by Benjamin Herrenschmidt (c) 2009 IBM Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/highmem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) void *kmap_atomic_high_prot(struct page *page, pgprot_t prot)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	unsigned long vaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	int idx, type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	type = kmap_atomic_idx_push();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	idx = type + KM_TYPE_NR*smp_processor_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	WARN_ON(IS_ENABLED(CONFIG_DEBUG_HIGHMEM) && !pte_none(*(kmap_pte - idx)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	__set_pte_at(&init_mm, vaddr, kmap_pte-idx, mk_pte(page, prot), 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	local_flush_tlb_page(NULL, vaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	return (void*) vaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) EXPORT_SYMBOL(kmap_atomic_high_prot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) void kunmap_atomic_high(void *kvaddr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	if (vaddr < __fix_to_virt(FIX_KMAP_END))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	if (IS_ENABLED(CONFIG_DEBUG_HIGHMEM)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 		int type = kmap_atomic_idx();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 		unsigned int idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		idx = type + KM_TYPE_NR * smp_processor_id();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 		WARN_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 		 * force other mappings to Oops if they'll try to access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 		 * this pte without first remap it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 		pte_clear(&init_mm, vaddr, kmap_pte-idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 		local_flush_tlb_page(NULL, vaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	kmap_atomic_idx_pop();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) EXPORT_SYMBOL(kunmap_atomic_high);