aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
4 daysuse common python toolchainHEADmastermainDmitrii Merkurev
Bug: 291553072 Test: ./tools/bazel run //lk:qemu_riscv64_dist Change-Id: I2a3f2948769db8fa3cf196c6350c980b9c1f33fd Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
2023-12-18add bazel targets to build riscv and arm64 lkDmitrii Merkurev
Bug: 291553072 Change-Id: I902b835860241e258aea907aaf5daa8ad42f1e12 Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
2023-11-27Merge 11.2023 lk upstream masterDmitrii Merkurev
Bug: 291553072 Change-Id: I41c563c43e0da26d28f33ef39ef059d66b8fceb8 Signed-off-by: Dmitrii Merkurev <dimorinny@google.com>
2023-11-14Empty committempInna Palant
2023-11-04[libc][string] fix strncpy potential buffer overflowCody Wong
The wrong placement of the increment for index `i` causes an unexpected behavior, which the `strncpy` writes an extra '\0'. For example: The `src` string is "abc". The buffer size of `dest` is 5. When we call `strncpy(dest, src, 5)`, the first `for` loop copies the characters, 'a', 'b', and 'c', to the `dest[0:2]`. In the 4th iteration, however, the `for` loop breaks due to the termination of `src` whereas the value of `i` stays 3. At the moment, it has copied 4 bytes, including the '\0' of `src`. In the second `for` loop, we have `i = 3` and `count = 5`, so the loop copies two more '\0' to the `dest`. As a result, the `strncpy` copies 6 bytes to the `dest` buffer, leading to buffer overflow. Fix the issue by increasing the index `i` before every copy. Signed-off-by: Cody Wong <codycswong@google.com>
2023-10-15[github][ci] switch to gcc 13.2.0 for the default build compilerTravis Geiselbrecht
2023-10-15[platform][jh7110] Tweak logic to find the FDT from the uimageTravis Geiselbrecht
2023-10-15[lib][fdtwalk] add code to skip a cpu if disabledTravis Geiselbrecht
Some RISC-V cpus come up disabled, skip enumerating them.
2023-09-25[arch][arm64] Fix mmu_unmap issue when FEAT_TTL is implementedMichael Shavit
Precisely set bits [55:22] of the vaddress in bits [43:0] for the vae1is and vaee1is TLBI commands. On platforms where FEAT_TLL is implemented, bits [47:44] of the command accept a TTL parameter which can optionally be set to hint the translation table level containing the address being invalidated. Implementations aren't architecturally required to perform the invalidation if the hint is incorrect however. Invalidations may therefore fail with the current implementation if the vaddress has bits set in [58:55]. This is notably an issue on ARM fastmodels which doesn't perform the invalidation when the TTL parameter is incorrect.
2023-06-21[github] Merge pull request #380 from arichardson/add-clang-ciTravis Geiselbrecht
Allow building RISCV64 and x86_64 with clang and add a Clang CI job
2023-06-21Fix typo in endif commentMatt Schulte
2023-06-08[ci] Add 64-bit RISC-V to Clang CIAlex Richardson
2023-06-08[riscv] Workaround for undef-weak symbol relocations with clang+lldAlex Richardson
When building with clang -mcmodel=medany and linking with ld.lld, we get out-of-range relocation errors for undefined __start_<section> symbols since 0 cannot be represented as a PC-relative offset). This is not a problem with ld.bfd since ld.bfd rewrites the instructions to avoid the out-of-range PC-relative relocation. For now, the simplest workaround is to build with -fpie -mcmodel=medany (thus indirecting these symbols via the GOT). This will be done automatically once clang includes https://reviews.llvm.org/D107280. Without this change I get the following linker errors: ld.lld: error: dev/driver.c:21:(.text+0x1E): relocation R_RISCV_PCREL_HI20 out of range: -524295 is not in [-524288, 524287]; references __start_devices See https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/126 and https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/201.
2023-06-08[make] Add a COMPILER_TYPE variableAlex Richardson
This can be used to change compiler flags for GCC vs Clang.
2023-06-08[riscv] Disable linker relaxations when linking with ld.lldAlex Richardson
We have to compile RISC-V code with -mno-relax when linking with ld.lld since ld.lld does not yet support RISC-V linker relaxations. Without this change, linking with ld.lld results in many errors such as: `relocation R_RISCV_ALIGN requires unimplemented linker relaxation`. This support was implemented as part of LLVM 15, but to support older versions of ld.lld we add the flag unconditionally for now.
2023-06-08[make] Set LINKER_TYPE to lld when building with ld.lldAlex Richardson
This will be needed in a follow-up commit to disable linker relaxations for RISC-V since ld.ldd does not support them yet.
2023-06-08[riscv][clang] Use a CSR name instead of a numeric expressionAlex Richardson
Clang's assembler rejects expressions containing e.g. (1u << N) in the assembler. Instead using numeric expressions for per-privilege level CSRs, we can prepend `m` or `s`. This also lets the compiler assign the CSR encoding instead of having to hardcode it in the source code.
2023-06-07[ci] Add pc-x86-64-test to the Clang CI jobAlex Richardson
2023-06-07[x86][clang] Allow clang to evaluate isr_stub_lenAlex Richardson
The current code results in `error: invalid reassignment of non-absolute variable 'isr_stub_start'`. Use a numbered label instead (as that can be reassigned) and reference the last occurrence using the b suffix.
2023-06-07[x86][clang] Make return mnemonic compatible with clangAlex Richardson
GCC appears to accept the Intel retf syntax in AT&T mode but clang is stricter and requires use of lret.
2023-06-07[make] Build with -ffreestandingAlex Richardson
We should build with -ffreestanding since we are building an OS kernel and cannot rely on all hosted environment functionality being present. Specifically this fixes a compilation error with clang caused by the the #include_next <limits.h>: ``` In file included from target/pc-x86/config.c:9: In file included from dev/include/dev/driver.h:10: In file included from lib/libc/include/sys/types.h:10: In file included from lib/libc/include/limits.h:5: In file included from /usr/lib/llvm-15/lib/clang/15.0.7/include/limits.h:21: /usr/include/limits.h:26:10: fatal error: 'bits/libc-header-start.h' file not found #include <bits/libc-header-start.h> ``` The flag fixes this issue by ensuring that __STDC_HOSTED__ is no longer set to 1, so Clang's limits.h will not try to include the host system one.
2023-06-07[ci] Add a LLVM toolchain CI configuration fileAlex Richardson
This only builds a subset of all targets for now since the remaining ones (32-bit targets) would require libgcc/compiler-rt for the 64-bit integer and/or double-precision float helper functions. Currently, only aarch64 targets build with clang, but with follow-up this can be extended to include x86_64 and RISCV64.
2023-06-07Don't notify IRC on pushes to forksAlexander Richardson
2023-06-01[make][engine] make the setting of toolchain variables conditionalTravis Geiselbrecht
CC, LD, etc was already settable by the environment, but not by local.mk, since they were assigned in engine.mk as :=. Change the set to be conditional to fix this.
2023-06-01[clang][arm64] Disable -Wasm-operand-widths warningAlex Richardson
Clang incorrectly diagnoses msr operations as need a 64-bit operand even if the underlying register is actually 32 bits. Silence this warning. There are quite a few occurrences of this warning so I opted to add the -Wno-flag instead of wrapping all callsites in `#pragma clang diagnostic ignored -Wasm-operand-widths`.
2023-06-01[make][clang] Do not add unsupported warning flagsAlex Richardson
Currently, clang does not support the -Wno-nonnull-compare and -Wmaybe-uninitialized warning flags so this adds lots of unknown warning flag output for each compile job when not using GCC. This commit adds a makefile macro to check for supported warning flags and only adds them if the compiler actually supports them.
2023-06-01[make] Fix linker invocation to be compatible with ld.lldAlex Richardson
The LLD linker does not allow joined short arguments, so split -dT <script> into -d -T <script>.
2023-06-01[arm64] Allow assembling with clangAlex Richardson
Clang does not accept this .if condition since phys_offset is a register alias and not an absolute expression. We can keep these two instructions here if the argument is zero since the result will be the same. Additionally, this macro is only called once and always passes a non-zero argument. If more calls are added in the future and avoiding these two instructions just before a loop is really important, we could use `.ifnc \phys_offset,0` instead, but that looks rather obscure to me.
2023-06-01[clang][compiler.h] Expose a few more macros for ClangAlex Richardson
Clang sets the defines for GCC 4.2.1, so we have to check __clang__ for these macros in addition to the GCC version.
2023-06-01[clang] Avoid a nested function in heap_wrapper.cAlex Richardson
This GCC extension is not supported by clang and in this case is not necessary. Move the function to the top level to avoid the syntax error.
2023-06-01Fix CVE-2004-0230Akansh
Applied patch for CVE-2004-0230 in tcp_in.c which prevents RST Spoofing Attack (Denial of Service).
2023-06-01[kernel][thread] Track per-thread scheduling statisticsAaron Odell
Track per-thread runtime, last scheduled time, and count of times scheduled. Query via existing threadstats CLI.
2023-06-01[arch][arm-m][systick] Update for monotonicityAaron Odell
Update arm-m systick current_time() and current_time_hires() to advance monotonically even when interrupts are disabled. Previous implementation relied on the systick exception triggering immediately when the counter wrapped and incrementing the current_ticks count. But if called when interrutps are disabled, then the systick has not had a chance to trigger and increment the count, but the counter has already wrapped around. This would result in the current_time() value moving backwards. The implementation in this commit is as follows: - Access to the systick val csr is always done in conjunction with a check of the COUNTFLAG bit, which indicates counter reaching zero. - The global current_ticks count is incremented immediately when wrap around is detected via COUNTFLAG, rather than waiting for the systick exception to run. - The check of the counter value, COUNTFLAG bit, and current_ticks global count are always done in a critical section to avoid race conditions between current_time and the systick handler. - The critical section and workarounds are consolidated into a helper function shared by current_time() and current_time_hires() to atomically get the tick count and the cycles since the last tick. The effect should be that current_time() always returns an accurate monotonically increasing value, regardless of interrupt enablement or not.
2023-06-01[scripts][python] Move a few more scripts from python2 to python3Travis Geiselbrecht
Turns out they were already python3 safe, so just switch to requested version over.
2023-05-20[arch][x86] Change the cache line size to 64 bytesPedro Falcato
All remotely modern x86 CPUs use 64-byte cache lines. Change CACHE_LINE to reflect this.
2023-04-23[arch][arm-m] Add Cortex M55 supportAaron Odell
Add the Cortex M55 as a supported target.
2023-04-23[inc][utils] Add a utils.h for miscellaneous helpersAaron Odell
Add a utils.h file containing miscellaneous convenience helpers.
2023-04-23[lib][debugcommands] Add panic commandAaron Odell
Add a simple command to generate a test panic.
2023-04-23[libc][string] Add strcasecmp supportAaron Odell
Add strcasecmp() for case insensitive string compares. There is no ISO standard function for this purpose but strcasecmp() is POSIX standard.
2023-04-23[lib][debugcommands] Add commands to display current timeAaron Odell
Add debug commands "time" and "timeh" to display current_time() and current_time_hires() respectively.
2023-04-23[lib][console] Add an unsigned long long to console_cmd_argsAaron Odell
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[scripts][buildall] Propogate logged error status through pipe teeAaron Odell
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[arm64][clang] Silence a register size mismatch warningAlex Richardson
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[clang] Silence unused private member warningAlex Richardson
We could also remove this variable, but it seems best to keep it to retain the same struct layout.
2023-04-23[float_test_vec] Fix -Wdouble-promotion warningsAlex Richardson
2023-04-23[benchmarks] Fix -Wdouble-promotion warningsAlex Richardson
2023-04-23[benchmarks] Use volatile variables in bench_sincosAlex Richardson
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[clang] Fix -Wformat warningsAlex Richardson
Use %hx for uint16_t instead of %hhx.
2023-04-23[libc] Fix -Wincompatible-library-redeclaration for strerrorAlex Richardson
Return a char * instead of a const char * to silence this Clang warning.
2023-04-23[dlmalloc] Fix -Wnull-pointer-arithmeticAlex Richardson
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]`