./memoryconfig (or $CHERI_MEMORY_CONFIG), describes how the hardware should be simulated.
Individual simulated hardware periperals are built as shared libraries; The simulator will use dlopen()
to load the libraries; Any module specific options are passed to the module at load-time.
C-like syntax in the configuration file.
module
statement to load the simulated device module.
device
blocks to declare devices by declaring a class
.
class
selects the simulated device type.addr
) and length (length
) must be specified;irq
, class-specific parameters (sockets types, file paths, etc.)ifdef
ifndef
can use getenv
to set options.
// configure example
module ../../cherilibs/trunk/peripherals/dram.so
module ../../cherilibs/trunk/peripherals/ethercap.so
module ../../cherilibs/trunk/peripherals/uart.so
device "dram0" {
class dram;
addr 0x0;
length 0x40000000;
};
ifdef "CHERI_KERNEL" device "kernel" {
class dram;
addr 0x100000;
length 0xff00000;
option path getenv "CHERI_KERNEL";
option type "mmap";
option cow "yes";
};
ifdef "CHERI_SDCARD" device "sdcard0" {
class sdcard;
addr 0x7f008000;
length 0x400;
option path getenv "CHERI_SDCARD";
option readonly "yes";
};
ifndef "CHERI_CONSOLE_SOCKET" device "uart0" {
class uart;
addr 0x7f000000;
length 0x20;
irq 0;
option type "stdio";
}
ifdef "CHERI_CONSOLE_SOCKET" device "uart0" {
class uart;
addr 0x7f000000;
length 0x20;
irq 0;
option type "socket";
option path getenv "CHERI_CONSOLE_SOCKET";
}
sim
: the simulator binary.
mem64.hex
: the physical memory image loaded into the simulator; used to populate memory contents for BRAM; the one generated from sw
contain a small interactive test suite that communicates via a simulated serial I/O hooked up to the simulator’s standard input and output streams.
To run the simulator, we need a mem64.hex
file in the current working directory. Can copy one from a software build such as cheri/trunk/sw
or simboot
; alternatively, the test
target will build the simulator and then run the test suite with suitable options.
Arguments:
+debug
: all debug information (debug, debug2, trace)
+xxxx
: for use by debug2(“xxxx”, display/actions…)
+trace
:
+cTrace
:
+regDump
:
TODO: testing infra & result analysis
Before run: build the simulator under cheri/trunk
To run:
make test
in cheritest/trunk will run the test suiteTwo categories of tests:
raw_
.memcpy
.test_
.init.s
framework to setup the stack, dump register state on completion, and terminate the simulator.test
function.test
terminates.test_
as high-level testtest_raw
as low-level testTEST_FILES
var in Makefile; can use subset such as TEST_ALU_FILES
TESTDIRS
in MakefileDefault no attributes: expected to work on any processor that compiles with mips r4000 isa.
make verilog COP1=1 ./sim
The BERI verilog build will generate a set of Verilog files in the ip/ directory, with mkTopAxi.v containing the top level module.
Terasic directory: cheri/trunk/boards/terasic_de4
build targets:
build_fpga
reports for critical warningsbuild_fpga
reports for errors.Communication with external I/O devices, such as NICs, is accomplished via a blend of memory mapped I/O, interrupts, and (eventually) DMA.
BERI processor and operating system stack supports a variety of peripherals ranging from Altera “soft” cores, such as the JTAG UART and SD Card IP cores, to “hard” peripherals provided by Terasic on its DE4 development board.
BERI HW refrence (2015 UCAM-CL-TR-868) describes available peripherals and their configuration on the Avalon system-on-chip bus as configured in the BERI reference designs.
BERI and FreeBSD support a number of Altera “soft” IP cores on Terasic tPad and DE4 platforms.
Two ‘soft’ peripheral devices:
the count
device. A memory-mapped register that is incremented on every read(intended for cache testing)
soft core for DE4 Multitouch LCD. A memory-mapped interface to the LCD panel, contains support for a pixel frame and a VGA-like text frame buffer suitable for use as a system console.
mtl_dclk
). A dual clock FIFO between this module and the MTL_Framebuffer_Flash.fontrom.mif
)mtl_test_small.c
is an example which drives the MTL-LCD using a NIOS for some helper functions, and so on.HDMI Chip Configuration via I2C
HDMI_Driver
support multiple resolutions.
two read-only 32-bit registers.
Errors to build:
sim sim.dtb sim.so: $(BUILD_DIR_SIM)/sim $(BUILD_DIR_SIM)/sim.so $(BUILD_DIR_SIM)/sim.dtb FORCE
rm -f sim sim.dtb sim.so
ln -s $(BUILD_DIR_SIM)/sim sim
ln -s $(BUILD_DIR_SIM)/sim.dtb sim.dtb
ln -s $(BUILD_DIR_SIM)/sim.so sim.so
$(BUILD_DIR_SIM)/sim $(BUILD_DIR_SIM)/sim.so: $(BSV_FILES) $(PISM_LIB) $(EXTRA_LINK)
rm -f $(CHERILIBS_DIR)/MEM.bo
mkdir -p $(BUILD_DIR_SIM)
CXXFLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 MAKEFLAGS= $(BSC) $(BSC_SIM_FLAGS) $(BSC_SIM_LIBS) -simdir $(BUILD_DIR_SIM) -bdir $(BUILD_DIR_SIM) -u -sim $(BLUESPEC_FLAGS) $(BLUESPEC_SIM_FLAGS)-show-schedule $(SIM_BSV_TOPLEVEL)
CXXFLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 MAKEFLAGS= $(BSC) $(BSC_SIM_FLAGS) $(BSC_SIM_LIBS) -sim -e $(SIM_TOPLEVEL_MODULE) -simdir $(BUILD_DIR_SIM) -bdir $(BUILD_DIR_SIM) -o $(BUILD_DIR_SIM)/sim $(BUILD_DIR_SIM)/*.ba $(EXTRA_LINK)
$(BUILD_DIR_SIM)/sim.dtb: $(BUILD_DIR_SIM)/sim.dts
dtc -O dtb -o $@ -b 0 $<
BERI (without CHERI extension) pipeline:
BERI with CHERI coprocessor extension:
2014-isca paper:
Note: cap coprocessor is tightly coupled with the Execute and Memory Access stages of the pipeline. PCC is validated in the Execute stage to simplify both forwarding and instruction address calculation.
2012-deconflating paper:
TODO
Reference 2
Reference 1 reference ↩
Reference 1 reference ↩
Reference 1 Coprocessor 0: system control, MMU Coprocessor 1: FPU. Coprocessor 2: CHERI capability feature. Smaller caches motivated by the performance trade-offs in the FPGA substrate, which provides comparatively high-speed main memory, as well as a desire for simpilicity. Features omitted from MIPS 4000 ISA: only 64-bit, no 32-bit addressing support; only big endian support; no variable-endian features; BERI is usually configured as a single-core, single-threaded processor; Multiprocessor (BERI1) and multithreading (BERI2) are experimental.
TODOs cpu instructions; l2cache; icache; dcache; tagCache; init done; compilation passed. Q&A Memory partitioned in ? see MultiLevelTagLookup.bsv. Possible bugs Bursts is 8 or 4? From TagController.bsv: peekMemResponse: one tagCache response is used for all bursts (frame as index), but the tagCache response only contain tags for 4 flits data’s tags. But somewhere says burst can be up to 8? Does dCache/iCache calls the tag controller?
If you could revise
the fundmental principles of
computer system design
to improve security...
... what would you change?