Commit Graph

2671 Commits

Author SHA1 Message Date
Pedro Falcato
67a5104d23 [arch][x86] Change the cache line size to 64 bytes
All remotely modern x86 CPUs use 64-byte cache lines. Change CACHE_LINE
to reflect this.
2023-05-20 17:46:24 -07:00
Aaron Odell
431e409c78 [arch][arm-m] Add Cortex M55 support
Add the Cortex M55 as a supported target.
2023-04-23 17:37:18 -07:00
Aaron Odell
9165714702 [inc][utils] Add a utils.h for miscellaneous helpers
Add a utils.h file containing miscellaneous convenience helpers.
2023-04-23 17:35:03 -07:00
Aaron Odell
8fc673fe4a [lib][debugcommands] Add panic command
Add a simple command to generate a test panic.
2023-04-23 17:34:57 -07:00
Aaron Odell
9ba1f165cd [libc][string] Add strcasecmp support
Add strcasecmp() for case insensitive string compares. There is no ISO
standard function for this purpose but strcasecmp() is POSIX standard.
2023-04-23 17:34:54 -07:00
Aaron Odell
9ac5708eb5 [lib][debugcommands] Add commands to display current time
Add debug commands "time" and "timeh" to display current_time() and
current_time_hires() respectively.
2023-04-23 17:34:51 -07:00
Aaron Odell
af844a2ff6 [lib][console] Add an unsigned long long to console_cmd_args
Add and populate an unsigned long long element in the console_cmd_args
struct. This enables handling of 64 bit values on 32 bit targets.
2023-04-23 17:34:49 -07:00
Aaron Odell
47c8b9a711 [scripts][buildall] Propogate logged error status through pipe tee
In the non-QUIET case, the log function pipes output to the tee command.
Without the pipefail option, if a make command fails, but the tee exits
succesfully, the overall status is 0 and the failed project doesn't get
added to the FAILED list and reported. Adding the pipefail option
propagates the make failure appropriately and adds the target to the
FAILED list.
2023-04-23 17:34:45 -07:00
Alex Richardson
6bbdcd5a09 [arm64][clang] Silence a register size mismatch warning
Even though we only need 32 bits here, clang warns that we should be
using a "w" register in the inline assembly (which is not legal with
mrs/msr). Silence the warning by declaring the value as unsigned long.

(cherry picked from commit a0de5d88dfc67b3ba34c0455b1619e12e6cfccae)
2023-04-23 17:23:31 -07:00
Alex Richardson
6b29ec9223 [clang] Silence unused private member warning
We could also remove this variable, but it seems best to keep it to
retain the same struct layout.
2023-04-23 17:23:31 -07:00
Alex Richardson
b8ae41a295 [float_test_vec] Fix -Wdouble-promotion warnings 2023-04-23 17:23:31 -07:00
Alex Richardson
8f3537d7b8 [benchmarks] Fix -Wdouble-promotion warnings 2023-04-23 17:23:31 -07:00
Alex Richardson
00f7060ba9 [benchmarks] Use volatile variables in bench_sincos
In addition to fixing -Wdouble-promition issues in bench_sincos, this also
ensures that the compiler can't replace the calls to sin/cos/sqrt with a
compile-time constant.
2023-04-23 17:23:31 -07:00
Alex Richardson
99bf8f9c41 [clang] Fix -Wformat warnings
Use %hx for uint16_t instead of %hhx.
2023-04-23 17:23:31 -07:00
Alex Richardson
7c7612225a [libc] Fix -Wincompatible-library-redeclaration for strerror
Return a char * instead of a const char * to silence this Clang warning.
2023-04-23 17:23:31 -07:00
Alex Richardson
7b12b201fd [dlmalloc] Fix -Wnull-pointer-arithmetic
Arithmetic on a NULL pointer is undefined behaviour and could be used by
the compiler to optimize out the arithmetic. Use the integer expansion of
chunk2mem(0) instead to silence this warning:
`arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension [-Wnull-pointer-arithmetic]`
2023-04-23 17:23:31 -07:00
Travis Geiselbrecht
a1eb850079 [target][visionfive2] set the time base properly
Seems to be running at 4Mhz according to the device tree.
2023-03-09 23:20:18 -08:00
Travis Geiselbrecht
7c2c8d8e56 [dev][interrupt][riscv_plic] merge now 3 implementations of the same plic driver into one
Move a copy of the PLIC driver out of one of the platforms and make the
setup of the interrupt controller a bit more dynamic.
2023-03-09 23:09:32 -08:00
Travis Geiselbrecht
c66ad44efa WIP [target][visionfive2] Add initial support for a VisionFive 2 RISC-V board
Still TODO:
-Set the timer rate properly
-Fix nonzero based hart secondary cpu boot
-Try to parse the device tree for some information
2023-03-06 01:06:27 -08:00
Pedro Falcato
ca633e2cb2 [ubsan] Improve printing of value in shift_out_of_bounds
Print it according to the type information we're given.
2023-02-18 23:13:23 -08:00
Pedro Falcato
36fd884faa [ubsan] Fix minor copy-paste bugs
Two handlers accidentally had the wrong prototype, called the wrong
thing and/or had the wrong name.

Should only affect divrem_overflow_abort, negate_overflow_abort.
2023-02-18 23:13:23 -08:00
Pedro Falcato
34d1bf4e42 [github][CI] Add UBSAN variants to CI 2023-02-18 16:47:16 -08:00
Pedro Falcato
8ebbcea5ed [ubsan] Add UBSAN implementation
Add an UBSAN implementation and a new UBSAN switch to the make build.
The implementation is taken from Onyx and handles most of the cases
that should be needed for a kernel build. Floating point and fancy
C++ CFI features are not supported yet.

To build with UBSAN, pass UBSAN=1 to make such as:
PROJECT=pc-x86-64-test make -jN UBSAN=1
2023-02-18 16:47:16 -08:00
Pedro Falcato
bf2e94c2f8 [minip] Fix undefined behavior in mac_addr_copy
There was a possibly unaligned store in mac_addr_copy.
Replace it with a memcpy call that should generate equivalent,
well defined code.
2023-02-18 16:47:16 -08:00
Travis Geiselbrecht
81d6014493 [arch][riscv] Add more defines and optimize fpu context switch
Add a few more #defines for the status register
Tweak the FPU context switch to not rewrite the entire status register,
      which may not be a generally safe thing to do.
2023-02-18 16:39:45 -08:00
Travis Geiselbrecht
92505637e8 [app][tests][float] generally spiff up the test
Still doesn't seem to work right on some arches, will need
to debug whats going on.
2023-02-18 16:39:13 -08:00
Travis Geiselbrecht
3dd8a32e92 [arch][riscv] a few small tweaks
Updated comment regarding clobbers on the SBI call.
Tweak a boot time print of SBI version.
Add a commented out line to the do-qemuriscv to assist in dumping future
device trees.
2023-02-18 14:42:59 -08:00
Travis Geiselbrecht
415096a2bf [external][lib][fdt] update libfdt to newest version
Update libfdt from https://github.com/dgibson/dtc at revision
73590342fc85ca207ca1e6cbc110179873a96962

Source is verbatim except moving headers into an include directory added
to the path.

Using 2-clause BSD option.
2023-01-15 19:02:30 -08:00
Pedro Falcato
93a8b45ada [bus][pci] Clarify device::assign_resource
The previous XXX comments were unnecessary as the spec defines the
bottom 3 bits as being hardwired and read-only.
2023-01-15 18:35:49 -08:00
Pedro Falcato
3b4dade91f [bus][pci] Disable IO and mem decoding around BAR enumeration
Disable IO and mem decoding around BAR enumation as described in the PCI
Local Bus specification. This behavior should be safer when messing
around BARs for BAR lengths.
2023-01-15 18:35:49 -08:00
Travis Geiselbrecht
91d0a5f7d1 [lib][fdtwalk] add routine to find and parse /reserved-memory node
Add logic to the riscv virt platform to properly mark off memory
claimed by OpenSBI.
2022-12-17 17:12:35 -08:00
Travis Geiselbrecht
2d561b4fcf [platform][qemu-virt-riscv] seems the first 512K are now used by opensbi 1.1
Looks like this is described in /reserved_memory/mmode_resv@<address> as
patched by opensbi on top of the existing qemu provided dtb.

Future patch should parse this instead of hard coding it.
2022-12-17 00:57:37 -08:00
gvk51
8b1335ea7e [lib][debugcommands] sanity check address is mapped before display/modify
Accessing un-mapped address/address-range results in data abort. Ensure
the address and all the pages in the requested range are mapped. Mapping
is checked at page size, also adjusts the stop address to the nearest valid
address mapped.
2022-11-03 00:04:30 -07:00
Travis Geiselbrecht
bcfad25587 [arch][x86][mmu] update how mmu code accesses physical pages
Move the mmu_initial_mapping from platform into arch/x86. For this
architecture the default mappings are basically hard coded in arch/x86
anyway, so move ownership of this data there, closer to where it's
actually initialized.
Update the 32 and 64bit paging code to properly use the paddr_to_kvaddr
and vice versa routines.
Update to allocate page tables directly from the pmm instead of the heap
(on 32bit code).
2022-11-02 23:48:49 -07:00
Travis Geiselbrecht
7742bd021b [arch][x86] general cleanup
Clean up the x86.h file a bit with how constants are defined
Switch rdtsc to builtin
Added all of the known bits for the main CR registers.
Move the invlpg macro over to the common header.
Update comments in start.S
2022-11-02 23:02:24 -07:00
Travis Geiselbrecht
0d0568612a [lib][acpi_lite] update to use the VMM to map acpi tables in
The old method assumed that all of the tables were mapped within the
kmap area of the kernel. This basically works on 64bit machines but on a
32bit x86 its entirely likely the ACPI tables are at higher physical
addresses that can be reached, which is currently limited to 1GB.

By using the VM it means it can individually map the headers and each
individual table.
2022-11-02 21:44:15 -07:00
Travis Geiselbrecht
7ddde308a3 [arch][x86][mmu] fix unmap routines to actually work
also additionally invlpg the address.
2022-11-02 02:09:46 -07:00
Travis Geiselbrecht
b990ad7999 [dev][net][e1000] just added a few comments with device ids
Was fiddling with making it work on i219 based e1000s, which was not
easily fruitful. However, may as well check in some comments with some
ids.
2022-11-02 00:28:36 -07:00
Travis Geiselbrecht
2367686854 [make] add a way for a module to opt into additional warnings
Move -Wmissing-declarations and -Wmissing-prototypes into this bucket.
Opt in most of the core top level modules in the system. More to follow.
2022-10-23 23:16:48 -07:00
Travis Geiselbrecht
4ce2e6a35d [libc] fix a warning squelch for some locally defined routines 2022-10-23 23:03:17 -07:00
Travis Geiselbrecht
7017a8fff9 [arch][mmu] add another routine to query if the arch supports user aspaces
Trim the arch mmu unit tests accordingly.

Should probably switch this to a #define, but it's possible some of
these queries could be dynamically detected (XN for example). May
revisit at some point.
2022-10-23 22:40:00 -07:00
Chintan Pandya
550256d6bc kernel: vm: Fix incorrect argument passing in 'vm map' test
vm map takes arg 3 as virtual address. And same needs
to be passed to retrieve aspace. Fix this by passing
right arg.

Test: Ran 'vm map' test
        ] vm map 0xc0000000 0xffff000ff0000000 1 0x0
        arch_mmu_map returns 0

Signed-off-by: Chintan Pandya <chintanpandya@google.com>
2022-10-23 21:40:18 -07:00
Travis Geiselbrecht
ee880bad58 [ci][gcc] update main toolchain to gcc 12.2.0 2022-10-23 21:26:04 -07:00
Travis Geiselbrecht
45e864d0c6 [ci] update github cache to v3 2022-10-23 21:25:12 -07:00
Travis Geiselbrecht
8cc5b06eeb [ci] update github checkout action to v3 2022-10-23 21:25:12 -07:00
Travis Geiselbrecht
5377fcbd12 [kernel][vm] add error handling with failed arch mmu mappings
In the 3 places in the upper VMM where it calls arch_mmu_map, try to
gracefully handle errors by unwinding the region creation.
2022-10-23 21:02:22 -07:00
Travis Geiselbrecht
2e81bfd55f [arch][x86] remove an extra printf left in the x86 mmu code 2022-10-23 21:00:15 -07:00
Travis Geiselbrecht
08b3238952 [arch][x86] clean up of mmu code
-Large cleanup of both the 32 and 64bit mmu code. Still the same general
flow but tighten up usage of mixing physical addresses with virtual
addresses.
-Remove the PAE code path from 32bit mmu, which was unused.
2022-10-23 20:37:33 -07:00
Travis Geiselbrecht
611bd1cba0 [bus][pci] ask for 4MB alignment when mapping the ecam
This helps any architecture that might have a better chance with using
large pages.
2022-10-21 23:47:47 -07:00
Travis Geiselbrecht
3a6b43cb32 [arch][mmu][tests] slight tweaks 2022-10-21 01:35:28 -07:00