Changes in 4.9.206 ASoC: compress: fix unsigned integer overflow check ASoC: kirkwood: fix external clock probe defer clk: samsung: exynos5420: Preserve PLL configuration during suspend/resume reset: fix reset_control_ops kerneldoc comment clk: at91: avoid sleeping early net: fec: add missed clk_disable_unprepare in remove can: peak_usb: report bus recovery as well can: c_can: D_CAN: c_can_chip_config(): perform a sofware reset on open watchdog: meson: Fix the wrong value of left time scripts/gdb: fix debugging modules compiled with hot/cold partitioning mac80211: fix station inactive_time shortly after boot block: drbd: remove a stray unlock in __drbd_send_protocol() pwm: bcm-iproc: Prevent unloading the driver module while in use scsi: lpfc: Fix dif and first burst use in write commands ARM: debug-imx: only define DEBUG_IMX_UART_PORT if needed ARM: dts: imx53-voipac-dmm-668: Fix memory node duplication parisc: Fix serio address output parisc: Fix HP SDC hpa address output arm64: mm: Prevent mismatched 52-bit VA support arm64: smp: Handle errors reported by the firmware PM / AVS: SmartReflex: NULL check before some freeing functions is not needed ARM: ks8695: fix section mismatch warning ACPI / LPSS: Ignore acpi_device_fix_up_power() return value crypto: user - support incremental algorithm dumps mwifiex: fix potential NULL dereference and use after free mwifiex: debugfs: correct histogram spacing, formatting rtl818x: fix potential use after free xfs: require both realtime inodes to mount ubi: Put MTD device after it is not used ubi: Do not drop UBI device reference before using microblaze: adjust the help to the real behavior microblaze: move "... is ready" messages to arch/microblaze/Makefile gpiolib: Fix return value of gpio_to_desc() stub if !GPIOLIB VSOCK: bind to random port for VMADDR_PORT_ANY mtd: rawnand: sunxi: Write pageprog related opcodes to WCMD_SET btrfs: only track ref_heads in delayed_ref_updates HID: intel-ish-hid: fixes incorrect error handling xen/pciback: Check dev_data before using it pinctrl: xway: fix gpio-hog related boot issues net/mlx5: Continue driver initialization despite debugfs failure KVM: s390: unregister debug feature on failing arch init pinctrl: sh-pfc: sh7264: Fix PFCR3 and PFCR0 register configuration pinctrl: sh-pfc: sh7734: Fix shifted values in IPSR10 HID: doc: fix wrong data structure reference for UHID_OUTPUT dm flakey: Properly corrupt multi-page bios. gfs2: take jdata unstuff into account in do_grow xfs: Align compat attrlist_by_handle with native implementation. xfs: Fix bulkstat compat ioctls on x32 userspace. IB/qib: Fix an error code in qib_sdma_verbs_send() powerpc/book3s/32: fix number of bats in p/v_block_mapped() powerpc/xmon: fix dump_segments() drivers/regulator: fix a missing check of return value serial: max310x: Fix tx_empty() callback openrisc: Fix broken paths to arch/or32 RDMA/srp: Propagate ib_post_send() failures to the SCSI mid-layer scsi: qla2xxx: deadlock by configfs_depend_item scsi: csiostor: fix incorrect dma device in case of vport ath6kl: Only use match sets when firmware supports it ath6kl: Fix off by one error in scan completion powerpc/prom: fix early DEBUG messages powerpc/mm: Make NULL pointer deferences explicit on bad page faults. powerpc/44x/bamboo: Fix PCI range vfio/spapr_tce: Get rid of possible infinite loop powerpc/powernv/eeh/npu: Fix uninitialized variables in opal_pci_eeh_freeze_status drbd: ignore "all zero" peer volume sizes in handshake drbd: reject attach of unsuitable uuids even if connected drbd: do not block when adjusting "disk-options" while IO is frozen drbd: fix print_st_err()'s prototype to match the definition regulator: tps65910: fix a missing check of return value powerpc/83xx: handle machine check caused by watchdog timer powerpc/pseries: Fix node leak in update_lmb_associativity_index() crypto: mxc-scc - fix build warnings on ARM64 pwm: clps711x: Fix period calculation net/net_namespace: Check the return value of register_pernet_subsys() um: Make GCOV depend on !KCOV net: stmicro: fix a missing check of clk_prepare net: dsa: bcm_sf2: Propagate error value from mdio_write atl1e: checking the status of atl1e_write_phy_reg tipc: fix a missing check of genlmsg_put net/wan/fsl_ucc_hdlc: Avoid double free in ucc_hdlc_probe() ocfs2: clear journal dirty flag after shutdown journal vmscan: return NODE_RECLAIM_NOSCAN in node_reclaim() when CONFIG_NUMA is n lib/genalloc.c: fix allocation of aligned buffer from non-aligned chunk lib/genalloc.c: use vzalloc_node() to allocate the bitmap drivers/base/platform.c: kmemleak ignore a known leak lib/genalloc.c: include vmalloc.h mtd: Check add_mtd_device() ret code tipc: fix memory leak in tipc_nl_compat_publ_dump net/core/neighbour: tell kmemleak about hash tables net/core/neighbour: fix kmemleak minimal reference count for hash tables sfc: suppress duplicate nvmem partition types in efx_ef10_mtd_probe ip_tunnel: Make none-tunnel-dst tunnel port work with lwtunnel decnet: fix DN_IFREQ_SIZE tipc: fix skb may be leaky in tipc_link_input sfc: initialise found bitmap in efx_ef10_mtd_probe net: fix possible overflow in __sk_mem_raise_allocated() sctp: don't compare hb_timer expire date before starting it net: dev: Use unsigned integer as an argument to left-shift iommu/amd: Fix NULL dereference bug in match_hid_uid scsi: libsas: Support SATA PHY connection rate unmatch fixing during discovery ACPI / APEI: Switch estatus pool to use vmalloc memory scsi: libsas: Check SMP PHY control function result powerpc/pseries/dlpar: Fix a missing check in dlpar_parse_cc_property() mtd: Remove a debug trace in mtdpart.c mm, gup: add missing refcount overflow checks on x86 and s390 clk: at91: fix update bit maps on CFG_MOR write staging: rtl8192e: fix potential use after free USB: serial: ftdi_sio: add device IDs for U-Blox C099-F9P mei: bus: prefix device names on bus with the bus name media: v4l2-ctrl: fix flags for DO_WHITE_BALANCE net: macb: fix error format in dev_err() pwm: Clear chip_data in pwm_put() media: atmel: atmel-isc: fix asd memory allocation macvlan: schedule bc_work even if error openvswitch: fix flow command message size slip: Fix use-after-free Read in slip_open openvswitch: drop unneeded BUG_ON() in ovs_flow_cmd_build_info() openvswitch: remove another BUG_ON() tipc: fix link name length check sctp: cache netns in sctp_ep_common net: sched: fix `tc -s class show` no bstats on class with nolock subqueues HID: core: check whether Usage Page item is after Usage ID items hwrng: stm32 - fix unbalanced pm_runtime_enable platform/x86: hp-wmi: Fix ACPI errors caused by too small buffer net: fec: fix clock count mis-match Linux 4.9.206 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
290 lines
8.4 KiB
C
290 lines
8.4 KiB
C
/*
|
|
* This file contains the routines for handling the MMU on those
|
|
* PowerPC implementations where the MMU substantially follows the
|
|
* architecture specification. This includes the 6xx, 7xx, 7xxx,
|
|
* and 8260 implementations but excludes the 8xx and 4xx.
|
|
* -- paulus
|
|
*
|
|
* Derived from arch/ppc/mm/init.c:
|
|
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
|
|
*
|
|
* Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au)
|
|
* and Cort Dougan (PReP) (cort@cs.nmt.edu)
|
|
* Copyright (C) 1996 Paul Mackerras
|
|
*
|
|
* Derived from "arch/i386/mm/init.c"
|
|
* Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version
|
|
* 2 of the License, or (at your option) any later version.
|
|
*
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/init.h>
|
|
#include <linux/highmem.h>
|
|
#include <linux/memblock.h>
|
|
|
|
#include <asm/prom.h>
|
|
#include <asm/mmu.h>
|
|
#include <asm/machdep.h>
|
|
|
|
#include "mmu_decl.h"
|
|
|
|
struct hash_pte *Hash, *Hash_end;
|
|
unsigned long Hash_size, Hash_mask;
|
|
unsigned long _SDR1;
|
|
|
|
struct ppc_bat BATS[8][2]; /* 8 pairs of IBAT, DBAT */
|
|
|
|
struct batrange { /* stores address ranges mapped by BATs */
|
|
unsigned long start;
|
|
unsigned long limit;
|
|
phys_addr_t phys;
|
|
} bat_addrs[8];
|
|
|
|
/*
|
|
* Return PA for this VA if it is mapped by a BAT, or 0
|
|
*/
|
|
phys_addr_t v_block_mapped(unsigned long va)
|
|
{
|
|
int b;
|
|
for (b = 0; b < ARRAY_SIZE(bat_addrs); ++b)
|
|
if (va >= bat_addrs[b].start && va < bat_addrs[b].limit)
|
|
return bat_addrs[b].phys + (va - bat_addrs[b].start);
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* Return VA for a given PA or 0 if not mapped
|
|
*/
|
|
unsigned long p_block_mapped(phys_addr_t pa)
|
|
{
|
|
int b;
|
|
for (b = 0; b < ARRAY_SIZE(bat_addrs); ++b)
|
|
if (pa >= bat_addrs[b].phys
|
|
&& pa < (bat_addrs[b].limit-bat_addrs[b].start)
|
|
+bat_addrs[b].phys)
|
|
return bat_addrs[b].start+(pa-bat_addrs[b].phys);
|
|
return 0;
|
|
}
|
|
|
|
unsigned long __init mmu_mapin_ram(unsigned long top)
|
|
{
|
|
unsigned long tot, bl, done;
|
|
unsigned long max_size = (256<<20);
|
|
|
|
if (__map_without_bats) {
|
|
printk(KERN_DEBUG "RAM mapped without BATs\n");
|
|
return 0;
|
|
}
|
|
|
|
/* Set up BAT2 and if necessary BAT3 to cover RAM. */
|
|
|
|
/* Make sure we don't map a block larger than the
|
|
smallest alignment of the physical address. */
|
|
tot = top;
|
|
for (bl = 128<<10; bl < max_size; bl <<= 1) {
|
|
if (bl * 2 > tot)
|
|
break;
|
|
}
|
|
|
|
setbat(2, PAGE_OFFSET, 0, bl, PAGE_KERNEL_X);
|
|
done = (unsigned long)bat_addrs[2].limit - PAGE_OFFSET + 1;
|
|
if ((done < tot) && !bat_addrs[3].limit) {
|
|
/* use BAT3 to cover a bit more */
|
|
tot -= done;
|
|
for (bl = 128<<10; bl < max_size; bl <<= 1)
|
|
if (bl * 2 > tot)
|
|
break;
|
|
setbat(3, PAGE_OFFSET+done, done, bl, PAGE_KERNEL_X);
|
|
done = (unsigned long)bat_addrs[3].limit - PAGE_OFFSET + 1;
|
|
}
|
|
|
|
return done;
|
|
}
|
|
|
|
/*
|
|
* Set up one of the I/D BAT (block address translation) register pairs.
|
|
* The parameters are not checked; in particular size must be a power
|
|
* of 2 between 128k and 256M.
|
|
*/
|
|
void __init setbat(int index, unsigned long virt, phys_addr_t phys,
|
|
unsigned int size, pgprot_t prot)
|
|
{
|
|
unsigned int bl;
|
|
int wimgxpp;
|
|
struct ppc_bat *bat = BATS[index];
|
|
unsigned long flags = pgprot_val(prot);
|
|
|
|
if ((flags & _PAGE_NO_CACHE) ||
|
|
(cpu_has_feature(CPU_FTR_NEED_COHERENT) == 0))
|
|
flags &= ~_PAGE_COHERENT;
|
|
|
|
bl = (size >> 17) - 1;
|
|
if (PVR_VER(mfspr(SPRN_PVR)) != 1) {
|
|
/* 603, 604, etc. */
|
|
/* Do DBAT first */
|
|
wimgxpp = flags & (_PAGE_WRITETHRU | _PAGE_NO_CACHE
|
|
| _PAGE_COHERENT | _PAGE_GUARDED);
|
|
wimgxpp |= (flags & _PAGE_RW)? BPP_RW: BPP_RX;
|
|
bat[1].batu = virt | (bl << 2) | 2; /* Vs=1, Vp=0 */
|
|
bat[1].batl = BAT_PHYS_ADDR(phys) | wimgxpp;
|
|
if (flags & _PAGE_USER)
|
|
bat[1].batu |= 1; /* Vp = 1 */
|
|
if (flags & _PAGE_GUARDED) {
|
|
/* G bit must be zero in IBATs */
|
|
bat[0].batu = bat[0].batl = 0;
|
|
} else {
|
|
/* make IBAT same as DBAT */
|
|
bat[0] = bat[1];
|
|
}
|
|
} else {
|
|
/* 601 cpu */
|
|
if (bl > BL_8M)
|
|
bl = BL_8M;
|
|
wimgxpp = flags & (_PAGE_WRITETHRU | _PAGE_NO_CACHE
|
|
| _PAGE_COHERENT);
|
|
wimgxpp |= (flags & _PAGE_RW)?
|
|
((flags & _PAGE_USER)? PP_RWRW: PP_RWXX): PP_RXRX;
|
|
bat->batu = virt | wimgxpp | 4; /* Ks=0, Ku=1 */
|
|
bat->batl = phys | bl | 0x40; /* V=1 */
|
|
}
|
|
|
|
bat_addrs[index].start = virt;
|
|
bat_addrs[index].limit = virt + ((bl + 1) << 17) - 1;
|
|
bat_addrs[index].phys = phys;
|
|
}
|
|
|
|
/*
|
|
* Preload a translation in the hash table
|
|
*/
|
|
void hash_preload(struct mm_struct *mm, unsigned long ea,
|
|
unsigned long access, unsigned long trap)
|
|
{
|
|
pmd_t *pmd;
|
|
|
|
if (Hash == 0)
|
|
return;
|
|
pmd = pmd_offset(pud_offset(pgd_offset(mm, ea), ea), ea);
|
|
if (!pmd_none(*pmd))
|
|
add_hash_page(mm->context.id, ea, pmd_val(*pmd));
|
|
}
|
|
|
|
/*
|
|
* Initialize the hash table and patch the instructions in hashtable.S.
|
|
*/
|
|
void __init MMU_init_hw(void)
|
|
{
|
|
unsigned int hmask, mb, mb2;
|
|
unsigned int n_hpteg, lg_n_hpteg;
|
|
|
|
extern unsigned int hash_page_patch_A[];
|
|
extern unsigned int hash_page_patch_B[], hash_page_patch_C[];
|
|
extern unsigned int hash_page[];
|
|
extern unsigned int flush_hash_patch_A[], flush_hash_patch_B[];
|
|
|
|
if (!mmu_has_feature(MMU_FTR_HPTE_TABLE)) {
|
|
/*
|
|
* Put a blr (procedure return) instruction at the
|
|
* start of hash_page, since we can still get DSI
|
|
* exceptions on a 603.
|
|
*/
|
|
hash_page[0] = 0x4e800020;
|
|
flush_icache_range((unsigned long) &hash_page[0],
|
|
(unsigned long) &hash_page[1]);
|
|
return;
|
|
}
|
|
|
|
if ( ppc_md.progress ) ppc_md.progress("hash:enter", 0x105);
|
|
|
|
#define LG_HPTEG_SIZE 6 /* 64 bytes per HPTEG */
|
|
#define SDR1_LOW_BITS ((n_hpteg - 1) >> 10)
|
|
#define MIN_N_HPTEG 1024 /* min 64kB hash table */
|
|
|
|
/*
|
|
* Allow 1 HPTE (1/8 HPTEG) for each page of memory.
|
|
* This is less than the recommended amount, but then
|
|
* Linux ain't AIX.
|
|
*/
|
|
n_hpteg = total_memory / (PAGE_SIZE * 8);
|
|
if (n_hpteg < MIN_N_HPTEG)
|
|
n_hpteg = MIN_N_HPTEG;
|
|
lg_n_hpteg = __ilog2(n_hpteg);
|
|
if (n_hpteg & (n_hpteg - 1)) {
|
|
++lg_n_hpteg; /* round up if not power of 2 */
|
|
n_hpteg = 1 << lg_n_hpteg;
|
|
}
|
|
Hash_size = n_hpteg << LG_HPTEG_SIZE;
|
|
|
|
/*
|
|
* Find some memory for the hash table.
|
|
*/
|
|
if ( ppc_md.progress ) ppc_md.progress("hash:find piece", 0x322);
|
|
Hash = __va(memblock_alloc(Hash_size, Hash_size));
|
|
memset(Hash, 0, Hash_size);
|
|
_SDR1 = __pa(Hash) | SDR1_LOW_BITS;
|
|
|
|
Hash_end = (struct hash_pte *) ((unsigned long)Hash + Hash_size);
|
|
|
|
printk("Total memory = %lldMB; using %ldkB for hash table (at %p)\n",
|
|
(unsigned long long)(total_memory >> 20), Hash_size >> 10, Hash);
|
|
|
|
|
|
/*
|
|
* Patch up the instructions in hashtable.S:create_hpte
|
|
*/
|
|
if ( ppc_md.progress ) ppc_md.progress("hash:patch", 0x345);
|
|
Hash_mask = n_hpteg - 1;
|
|
hmask = Hash_mask >> (16 - LG_HPTEG_SIZE);
|
|
mb2 = mb = 32 - LG_HPTEG_SIZE - lg_n_hpteg;
|
|
if (lg_n_hpteg > 16)
|
|
mb2 = 16 - LG_HPTEG_SIZE;
|
|
|
|
hash_page_patch_A[0] = (hash_page_patch_A[0] & ~0xffff)
|
|
| ((unsigned int)(Hash) >> 16);
|
|
hash_page_patch_A[1] = (hash_page_patch_A[1] & ~0x7c0) | (mb << 6);
|
|
hash_page_patch_A[2] = (hash_page_patch_A[2] & ~0x7c0) | (mb2 << 6);
|
|
hash_page_patch_B[0] = (hash_page_patch_B[0] & ~0xffff) | hmask;
|
|
hash_page_patch_C[0] = (hash_page_patch_C[0] & ~0xffff) | hmask;
|
|
|
|
/*
|
|
* Ensure that the locations we've patched have been written
|
|
* out from the data cache and invalidated in the instruction
|
|
* cache, on those machines with split caches.
|
|
*/
|
|
flush_icache_range((unsigned long) &hash_page_patch_A[0],
|
|
(unsigned long) &hash_page_patch_C[1]);
|
|
|
|
/*
|
|
* Patch up the instructions in hashtable.S:flush_hash_page
|
|
*/
|
|
flush_hash_patch_A[0] = (flush_hash_patch_A[0] & ~0xffff)
|
|
| ((unsigned int)(Hash) >> 16);
|
|
flush_hash_patch_A[1] = (flush_hash_patch_A[1] & ~0x7c0) | (mb << 6);
|
|
flush_hash_patch_A[2] = (flush_hash_patch_A[2] & ~0x7c0) | (mb2 << 6);
|
|
flush_hash_patch_B[0] = (flush_hash_patch_B[0] & ~0xffff) | hmask;
|
|
flush_icache_range((unsigned long) &flush_hash_patch_A[0],
|
|
(unsigned long) &flush_hash_patch_B[1]);
|
|
|
|
if ( ppc_md.progress ) ppc_md.progress("hash:done", 0x205);
|
|
}
|
|
|
|
void setup_initial_memory_limit(phys_addr_t first_memblock_base,
|
|
phys_addr_t first_memblock_size)
|
|
{
|
|
/* We don't currently support the first MEMBLOCK not mapping 0
|
|
* physical on those processors
|
|
*/
|
|
BUG_ON(first_memblock_base != 0);
|
|
|
|
/* 601 can only access 16MB at the moment */
|
|
if (PVR_VER(mfspr(SPRN_PVR)) == 1)
|
|
memblock_set_current_limit(min_t(u64, first_memblock_size, 0x01000000));
|
|
else /* Anything else has 256M mapped */
|
|
memblock_set_current_limit(min_t(u64, first_memblock_size, 0x10000000));
|
|
}
|