Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102898719
D17424.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D17424.diff
View Options
Index: head/sys/arm/arm/pl310.c
===================================================================
--- head/sys/arm/arm/pl310.c
+++ head/sys/arm/arm/pl310.c
@@ -168,27 +168,34 @@
{
uint32_t v;
+ printf("%s\n", __func__);
KASSERT(which_reg == PL310_TAG_RAM_CTRL ||
which_reg == PL310_DATA_RAM_CTRL,
("bad pl310 ram latency register address"));
+ printf("%s\n", __func__);
v = pl310_read4(sc, which_reg);
+ printf("%s\n", __func__);
if (setup != 0) {
KASSERT(setup <= 8, ("bad pl310 setup latency: %d", setup));
v &= ~RAM_CTRL_SETUP_MASK;
v |= (setup - 1) << RAM_CTRL_SETUP_SHIFT;
}
+ printf("%s\n", __func__);
if (read != 0) {
KASSERT(read <= 8, ("bad pl310 read latency: %d", read));
v &= ~RAM_CTRL_READ_MASK;
v |= (read - 1) << RAM_CTRL_READ_SHIFT;
}
+ printf("%s\n", __func__);
if (write != 0) {
KASSERT(write <= 8, ("bad pl310 write latency: %d", write));
v &= ~RAM_CTRL_WRITE_MASK;
v |= (write - 1) << RAM_CTRL_WRITE_SHIFT;
}
+ printf("%s wr\n", __func__);
pl310_write4(sc, which_reg, v);
+ printf("%s done\n", __func__);
}
static int
@@ -482,6 +489,8 @@
uint32_t cache_id, debug_ctrl;
phandle_t node;
+ printf("%s\n", __func__);
+
sc->sc_dev = dev;
rid = 0;
sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
@@ -489,6 +498,8 @@
if (sc->sc_mem_res == NULL)
panic("%s: Cannot map registers", device_get_name(dev));
+ printf("%s\n", __func__);
+
/* Allocate an IRQ resource */
rid = 0;
sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
@@ -497,10 +508,16 @@
device_printf(dev, "cannot allocate IRQ, not using interrupt\n");
}
+ printf("%s: mtx init\n", __func__);
pl310_softc = sc;
mtx_init(&sc->sc_mtx, "pl310lock", NULL, MTX_SPIN);
+ printf("%s: pl310_read4\n", __func__);
+ printf("%s: pl310_read4\n", __func__);
+ printf("%s: pl310_read4\n", __func__);
+
cache_id = pl310_read4(sc, PL310_CACHE_ID);
+ printf("%s\n", __func__);
sc->sc_rtl_revision = (cache_id >> CACHE_ID_RELEASE_SHIFT) &
CACHE_ID_RELEASE_MASK;
device_printf(dev, "Part number: 0x%x, release: 0x%x\n",
Index: head/sys/arm/conf/GENERIC
===================================================================
--- head/sys/arm/conf/GENERIC
+++ head/sys/arm/conf/GENERIC
@@ -36,6 +36,7 @@
files "../allwinner/a33/files.a33"
files "../allwinner/a83t/files.a83t"
files "../allwinner/h3/files.h3"
+files "../altera/socfpga/files.socfpga"
files "../broadcom/bcm2835/files.bcm2836"
files "../broadcom/bcm2835/files.bcm283x"
files "../freescale/imx/files.imx6"
@@ -56,6 +57,8 @@
options SOC_ALLWINNER_A83T
options SOC_ALLWINNER_H2PLUS
options SOC_ALLWINNER_H3
+options SOC_ALTERA_ARRIA10
+options SOC_ALTERA_CYCLONE5
options SOC_BCM2836
options SOC_MV_ARMADA38X
options SOC_MV_ARMADAXP
@@ -89,10 +92,15 @@
device generic_timer
device mpcore_timer
+# DMA support
+device xdma
+device pl330
+
# MMC/SD/SDIO Card slot support
device sdhci # SD controller
device mmc # mmc/sd bus
device mmcsd # mmc/sd flash cards
+device dwmmc
# ATA controllers
device ahci # AHCI-compatible SATA controllers
@@ -169,7 +177,9 @@
device spibus
device spigen
device bcm2835_spi
+device cqspi # Cadence Quad SPI Flash Controller
device ti_spi
+device n25q # n25q Quad SPI Flash
# ADC support
device ti_adc
Index: head/sys/arm/conf/GENERIC-MMCCAM
===================================================================
--- head/sys/arm/conf/GENERIC-MMCCAM
+++ head/sys/arm/conf/GENERIC-MMCCAM
@@ -20,3 +20,6 @@
nodevice mmc
nodevice mmcsd
+
+# dwmmc_altera.c fails to build
+nodevice dwmmc
Index: head/sys/arm/conf/SOCDK
===================================================================
--- head/sys/arm/conf/SOCDK
+++ head/sys/arm/conf/SOCDK
@@ -20,7 +20,7 @@
#NO_UNIVERSE
-include "SOCFPGA"
+include "GENERIC"
ident SOCDK
options ROOTDEVNAME=\"ufs:/dev/mmcsd0s4\"
Index: head/sys/dts/arm/socfpga_arria10_socdk_sdmmc.dts
===================================================================
--- head/sys/dts/arm/socfpga_arria10_socdk_sdmmc.dts
+++ head/sys/dts/arm/socfpga_arria10_socdk_sdmmc.dts
@@ -61,6 +61,10 @@
};
};
+&L2 {
+ status = "disabled";
+};
+
&uart1 {
clock-frequency = < 50000000 >;
};
Index: head/sys/riscv/include/pmap.h
===================================================================
--- head/sys/riscv/include/pmap.h
+++ head/sys/riscv/include/pmap.h
@@ -153,6 +153,8 @@
#define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list))
+int pmap_fault_fixup(pmap_t, vm_offset_t, vm_prot_t);
+
#endif /* _KERNEL */
#endif /* !LOCORE */
Index: head/sys/riscv/include/pte.h
===================================================================
--- head/sys/riscv/include/pte.h
+++ head/sys/riscv/include/pte.h
@@ -1,6 +1,6 @@
/*-
* Copyright (c) 2014 Andrew Turner
- * Copyright (c) 2015-2016 Ruslan Bukin <br@bsdpad.com>
+ * Copyright (c) 2015-2018 Ruslan Bukin <br@bsdpad.com>
* All rights reserved.
*
* Portions of this software were developed by SRI International and the
@@ -65,7 +65,7 @@
#define Ln_ENTRIES (1 << 9)
#define Ln_ADDR_MASK (Ln_ENTRIES - 1)
-/* Bits 9:7 are reserved for software */
+/* Bits 9:8 are reserved for software */
#define PTE_SW_MANAGED (1 << 9)
#define PTE_SW_WIRED (1 << 8)
#define PTE_D (1 << 7) /* Dirty */
@@ -78,6 +78,7 @@
#define PTE_V (1 << 0) /* Valid */
#define PTE_RWX (PTE_R | PTE_W | PTE_X)
#define PTE_RX (PTE_R | PTE_X)
+#define PTE_KERN (PTE_V | PTE_RWX | PTE_A | PTE_D)
#define PTE_PPN0_S 10
#define PTE_PPN1_S 19
Index: head/sys/riscv/riscv/locore.S
===================================================================
--- head/sys/riscv/riscv/locore.S
+++ head/sys/riscv/riscv/locore.S
@@ -94,7 +94,7 @@
add t3, t4, t2
li t5, 0
2:
- li t0, (PTE_V | PTE_RWX | PTE_D)
+ li t0, (PTE_KERN)
slli t2, t4, PTE_PPN1_S /* << PTE_PPN1_S */
or t5, t0, t2
sd t5, (s1) /* Store PTE entry to position */
@@ -126,7 +126,7 @@
mv s2, s11
srli s2, s2, PAGE_SHIFT
- li t0, (PTE_V | PTE_RWX | PTE_D)
+ li t0, (PTE_KERN)
slli t2, s2, PTE_PPN0_S /* << PTE_PPN0_S */
or t0, t0, t2
Index: head/sys/riscv/riscv/pmap.c
===================================================================
--- head/sys/riscv/riscv/pmap.c
+++ head/sys/riscv/riscv/pmap.c
@@ -15,7 +15,7 @@
* All rights reserved.
* Copyright (c) 2014 The FreeBSD Foundation
* All rights reserved.
- * Copyright (c) 2015-2017 Ruslan Bukin <br@bsdpad.com>
+ * Copyright (c) 2015-2018 Ruslan Bukin <br@bsdpad.com>
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
@@ -487,7 +487,7 @@
/* superpages */
pn = (pa / PAGE_SIZE);
- entry = (PTE_V | PTE_RWX);
+ entry = PTE_KERN;
entry |= (pn << PTE_PPN0_S);
pmap_load_store(&l1[l1_slot], entry);
}
@@ -965,7 +965,7 @@
KASSERT(l3 != NULL, ("Invalid page table, va: 0x%lx", va));
pn = (pa / PAGE_SIZE);
- entry = (PTE_V | PTE_RWX);
+ entry = PTE_KERN;
entry |= (pn << PTE_PPN0_S);
pmap_load_store(l3, entry);
@@ -1063,7 +1063,7 @@
pn = (pa / PAGE_SIZE);
l3 = pmap_l3(kernel_pmap, va);
- entry = (PTE_V | PTE_RWX);
+ entry = PTE_KERN;
entry |= (pn << PTE_PPN0_S);
pmap_load_store(l3, entry);
@@ -1465,7 +1465,8 @@
continue; /* try again */
}
l2 = pmap_l1_to_l2(l1, kernel_vm_end);
- if ((pmap_load(l2) & PTE_A) != 0) {
+ if ((pmap_load(l2) & PTE_V) != 0 &&
+ (pmap_load(l2) & PTE_RWX) == 0) {
kernel_vm_end = (kernel_vm_end + L2_SIZE) & ~L2_OFFSET;
if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) {
kernel_vm_end = vm_map_max(kernel_map);
@@ -2008,6 +2009,41 @@
PMAP_UNLOCK(pmap);
}
+int
+pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
+{
+ pt_entry_t orig_l3;
+ pt_entry_t new_l3;
+ pt_entry_t *l3;
+
+ l3 = pmap_l3(pmap, va);
+ if (l3 == NULL)
+ return (0);
+
+ orig_l3 = pmap_load(l3);
+ if ((orig_l3 & PTE_V) == 0 ||
+ ((prot & VM_PROT_WRITE) != 0 && (orig_l3 & PTE_W) == 0) ||
+ ((prot & VM_PROT_READ) != 0 && (orig_l3 & PTE_R) == 0))
+ return (0);
+
+ new_l3 = orig_l3 | PTE_A;
+ if ((prot & VM_PROT_WRITE) != 0)
+ new_l3 |= PTE_D;
+
+ if (orig_l3 != new_l3) {
+ pmap_load_store(l3, new_l3);
+ pmap_invalidate_page(pmap, va);
+ return (1);
+ }
+
+ /*
+ * XXX: This case should never happen since it means
+ * the PTE shouldn't have resulted in a fault.
+ */
+
+ return (0);
+}
+
/*
* Insert the given physical page (p) at
* the specified virtual address (v) in the
@@ -2415,8 +2451,7 @@
pa = VM_PAGE_TO_PHYS(m);
pn = (pa / PAGE_SIZE);
- /* RISCVTODO: check permissions */
- entry = (PTE_V | PTE_RWX);
+ entry = (PTE_V | PTE_R | PTE_X);
entry |= (pn << PTE_PPN0_S);
/*
Index: head/sys/riscv/riscv/trap.c
===================================================================
--- head/sys/riscv/riscv/trap.c
+++ head/sys/riscv/riscv/trap.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2015-2017 Ruslan Bukin <br@bsdpad.com>
+ * Copyright (c) 2015-2018 Ruslan Bukin <br@bsdpad.com>
* All rights reserved.
*
* Portions of this software were developed by SRI International and the
@@ -212,6 +212,9 @@
ftype = (VM_PROT_READ);
}
+ if (pmap_fault_fixup(map->pmap, va, ftype))
+ goto done;
+
if (map != kernel_map) {
/*
* Keep swapout from messing with us during this
@@ -256,6 +259,7 @@
}
}
+done:
if (lower)
userret(td, frame);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 19, 11:47 AM (22 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14715951
Default Alt Text
D17424.diff (9 KB)
Attached To
Mode
D17424: Support for 2nd scheme of PTE A and D bits management
Attached
Detach File
Event Timeline
Log In to Comment