aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-01-18libc: move libc rand to separate module to speedup rebuildsYurii Shutkin
rand.c depends on a module seed define that is randomly changed every build, so moving rand.c into a separate module saves rebuild time as the rest libc stays untouched. Change-Id: Id2ebf3489e107c43c4d07048bea50b505de3d87a Test: build Bug: 319455354
2024-01-18app/timertest: Add build variable to control timer granularityAndrei Homescu
Statically linked qemu with glibc<2.29 uses a syscall for clock_gettime instead of the VDSO which makes the calls much slower. This means we need a higher timer granularity threshold on qemu. Add a new APP_TIMERTEST_MAX_CLOCK_PERIOD build variable that controls this. Bug: 285203365 Change-Id: I8ea9e476706a5fcbeb1543b3cc9557dba2ed2c28
2024-01-09kernel/vm/pmm: Fix UBSAN failures from constant typesAndrei Homescu
The pmm code defines some signed constants that are assigned to an unsigned flags field, which triggers UBSan. Fix the issue by defining the constants as unsigned. Bug: 285203365 Change-Id: I4cf3c84eb4d81980e327270a404ac3f070d06161
2024-01-03[arch][arm]: arm_reset: Don't clobber r1 - it contains bootarg1Oliver Winker
Dont clobber r1, since it contains bootarg1 - borrow r4 instead. This specifically looses the HOB address in the handover of GSA BL1 ro GSAFW. Bug: 316589528 Test: Boot GSAFW on gem5 and verify correct HOB adresse Change-Id: If1220c27bbfe9d8e8affc3f93e055ebe3c851636
2023-12-13Use LKROOT as the path to LKAndrei Homescu
LK can now be found at either external/lk or external/trusty/lk so use the LKROOT variable to locate it. Bug: 285203365 Test: Build generic-arm64-test-debug Change-Id: I5819d7026a62315c0f2e494dacc7ba2620a4dfdf
2023-12-07threadcookies: disable ints if cookie is invalidPer Larsen
The test cookie_corruption_before_exit_must_panic tries to recover after corrupting the thread cookie but may sporadically fail to do so. The issue is that calling panic, backtracing and thus calling printf may cause the thread to be put back on the runqueues if another thread holds the debug output mutex. By disabling interrupts before calling panic, we should be able to print and subsequently exit the thread without blocking. Bug: None Test: run com.android.kernel.threadtest for hundreds of iterations in emulator without crashes or hangs. Change-Id: I40a33928c277b74049ff01db39f2533ccb464549
2023-12-06Bump Trusty std to C++20Tomasz Wasilczyk
Bug: 311052584 Test: trusty/vendor/google/aosp/scripts/build.py generic-arm64-test-debug Change-Id: Ib1e919bb91a049d087b0c3aa2394cd66584f5d0f
2023-12-05Implement vdprintfTomasz Wasilczyk
Bug: 302723053 Test: build trusty in its own repo Change-Id: I8cbd2daea4d414fc3de95fd52f87226ee3261f2b
2023-11-25trusty: mmu: derive the user address space sizeMike McTernan
Bug: 313080277 Test: build.py Test: checked MMU_USER_SIZE_SHIFT == 48 for all current builds Change-Id: Id7dc4f4c46bd8c671e6c440cc0a84953523c0f29
2023-11-24trusty: SCS: make kernel support dependent on USER_SCS_SUPPORTEDMike McTernan
Split configuration for supporting kernel shadow stacks in TAs from the config option to actually build TAs with SCS enavbled. Bug: 313078398 Test: build.py Change-Id: Ifa1e527405f5ab34ff1ae8992ef3b6144f6a3cd6
2023-11-08arch: x86: Enable Rust support on x86_64Andrei Homescu
Once aosp/2785147 lands, we will have x86_64 support in the Rust compiler prebuilts. Bug: 304851081 Test: Build Trusty generic-x86_64 project Change-Id: I8e93238b979c31ef4fc5079dfec46651b6048780
2023-11-07build: build Rust kernel modulesFrances Wingerter
Bug: 304850822 Change-Id: Ic78e011fdb5e43b3b2eb615f1844c5b5d4dffa6a
2023-10-31build: add READ_CRATE_NAME macroFrances Wingerter
Each rust module needs to know MODULE_CRATE_NAME for its deps, but deps are recursively processed too late for module.mk to save it in a MODULE_$(MODULE)_CRATE_NAME variable, so we require rules.mk in crates to stick to a simple, easily-parseable format here and error out if parsing fails. Bug: 304850822 Change-Id: I5db62cced5590490703770e2fb91a1f159d290ca
2023-10-31engine.mk: add RUSTCFrances Wingerter
Change-Id: Ic348e565fd8c8ce2b7a228c8ae4abe48079a182e
2023-10-31build: use GLOBAL_KERNEL_RUSTFLAGS for kernel buildFrances Wingerter
Bug: 304850822 Change-Id: I6ab3d25ad0ba7a8c411dc4a5c1806c67308284cb
2023-10-30arch: x86: Implement copy_from_anywhereArve Hjønnevåg
Implement copy_from_anywhere so we can use it to make exception handlers more robust (based on arm64 code) Bug: 305099000 Change-Id: Ib27c3fab925b34d558277873cf98fe3a49759ec9
2023-10-30arch: x86: Call trusty_app_crash on user-space faultsArve Hjønnevåg
Also enable interrupt first. Fixes com.android.trusty.crashtest Bug: 305099000 Change-Id: If713bfad10e7e2ad35a606748295acc0683fcf16
2023-10-30arch: x86: Remove pointer to dead threadsArve Hjønnevåg
If a thread exits while fp_owner points to it the pointer needs to be cleared to prevent crashes the next time someone needs the fpu. Bug: 305099000 Change-Id: If6439dc6261e638bcbffd73bf2b926199ccd4e87
2023-10-30arch: x86: Add Interrupt Stack Table for Page Fault handlerZhong,Fangjian
Previously, Page Fault handler shares same stack with kernel context. In this case, Page Fault handler cannot work as expected when kernel stack is corrupted or misconfigured, for instance stack over flow. To ensure Page Fault handler always work as expected, separate its stack with kernel, use dedicated Interrupt Stack Table instead. Bug: 119111590 Change-Id: I1e809d07a7babbbd6e649bfbc5a7c2a96483e65d
2023-10-30trusty: add bounds check for target CPUMike McTernan
Add a check to ensure that cpu_priorty[] cannot be read out of bounds. Bug: 307727462 Test: build.py Change-Id: Id4796ecdaccf082e56aa35221f67557771c4d49e
2023-10-27build: move rustflags/crate-type logic from userspaceFrances Wingerter
We'll need this for both kernel and userspace build. Bug: 304850822 Change-Id: I655dbcfa00016cf7b39458c5634858f9da9d9158
2023-10-26arch: x86: Move exception defines to a header fileArve Hjønnevåg
Bug: 119111590 Change-Id: If4a9c2e603f0a873cfa0ef8f4ebc4b7bc1faecfe
2023-10-26dev: virtio: Fix ring full handlingArve Hjønnevåg
Fix bug where interrupt handler think a full ring was empty. Bug: 298705967 Change-Id: Id1dad4d158f216d7175629909c3dbb5d5109c315
2023-10-26dev: virtio: Use generic mb macro instead of arm specific oneArve Hjønnevåg
Bug: 298705967 Change-Id: I2d8ac5d493fbd397b1cce209792c4fc3f78d1060
2023-10-26dev: virtio: Fix build errorArve Hjønnevåg
Bug: 298705967 Change-Id: I1295c9ff397186c4b80c4c65b477d5b7d2971642
2023-10-26dev: interrupt: arm_gic: Add init checkArve Hjønnevåg
Check that gic has been initialized before allowing interrupt enable and print an error message instead of crashing. Bug: 298723092 Change-Id: Iccfa7019d94f66a636a53dfdff1f3de60c00cf01
2023-10-24arch: x86: Set U flag on all inner page directory entriesArve Hjønnevåg
mmutest maps pages into the kernel aspace with ARCH_MMU_FLAG_PERM_USER set. If the U flag is not set on all the parent page directory entires, the U bit in the last level page table is overridden and the mapping acts like a kernel mapping instead. This causes a test failure, and it makes the pages available to the kernel instead. Bug: 305099000 Change-Id: Icf83242a63473d79cccf8695d0d437dc68e85bef
2023-10-24arch: x86: Don't loop forever on instruction page faultsArve Hjønnevåg
Instead call exception_die (for kernel faults) and also fix exception_die to call panic instead of platform_halt, so kernel tests can intercept it with thread_set_flag_exit_on_panic. Bug: 305099000 Change-Id: I509adcced2bddd5e52d25d9040188eebbb7e6fd4
2023-10-24arch: x86: mmu: Reject memory mapping with unsupported flagsArve Hjønnevåg
Return ERR_NOT_SUPPORTED if arch_mmu_map is called with unsupported flags. Also fix mapping of cache type bits so ARCH_MMU_FLAG_UNCACHED_DEVICE is mapped as uncached instead of cached and undefined types with bit 1 set are interpreted as ARCH_MMU_FLAG_UNCACHED_DEVICE. Bug: 305099000 Change-Id: I724c25e39def09d7befca60f9747158f457615b9
2023-10-20arch: x86: Add execute disable support on mappingZhong,Fangjian
Execute-disable (XD) bit resides in bit 63 of Page Table Entry, if IA32_EFER.NXE bit is set, XD bit should also be set in Page Table Entry when mapping non-executable memory. Since we are using 4-KB mapping, XD bit would be set in PTE level only, and keep XD bit in PD/PDPT/PML4 untouched. Bug: 119111590 Change-Id: Icce5eeab6e7eb2e76fdf48ea7ebd6810bbd11587
2023-10-20arch: x86: Update address fetch logic in PTE of Page TableZhong,Fangjian
PTE in Page Table contains physical address to be mapped, it should not be translated to virtual address again since this address will not be used as the base address of next level in Page Table. Return address in PTE directly instead of translating to virtual address. Also, Execute-Disable (XD) bit resides in bit 63 of each level of Paging Strcture entries. In order to support non-executable mapping, XD bit of PTE will be set since currently we are using 4-KB mapping, and keep XD bit unchanged at PD/PDPT/PML4. Once non-executable mapping feature enabled, previous X86_PHYS_TO_VIRT logic would flip the XD of PTE and return incorrect architecture mmu flag when query mapping information. Return address resides in PTE can fix this potential issue. Bug: 119111590 Change-Id: I6cee1c09b3033653985440455dc777098b3dd3fd
2023-10-20arch: x86: Update custom page fault hookArve Hjønnevåg
Use relative addresses to be consistent with arm64 version and support kaslr and add header file. Bug: 305099000 Change-Id: I6438e7c54d25934ce170590f0a4555cfc82973aa
2023-10-20arch: x86: Add customized Page Fault hook supportZhong,Fangjian
Customized Page Fault hook is used to handle Page Fault exception triggered at specified location in kernel level. Target return address would be updated in this hook. Page Fault hook should be pushed into specified section: .rodata.fault_handler_table. Bug: 119111590 Change-Id: Ic2909b493c35ab0b07cfee220bfc2b77a8dc48e3
2023-10-19app:scstest: restore shadow stack after mutationPer Larsen
The test code mutates the last element of the shadow stack of kernel threads via mmutest_arch_store_uint32. Insert a second call to mmutest_arch_store_uint32 to restore the last element to its original value such that inspect_thread succeeds anew. Bug: None Test: build.py qemu-generic-arm64-test-debug \ --test boot-test:com.android.kernel.scstest Change-Id: Ib892069dd33d0f061b96f850c7b47d79022050d4
2023-10-18dev: timer: Add x86 timer supportZhong,Fangjian
Generic-x86_64 utilizes PIT timer resource for timer interrupt. PIT connects to PIC, PIC connects to Local APIC. In order to map PIT interrupt to correct interrupt vector, both PIC and Local APIC need to be initialized correctly on platform initialization stage. Interrupt vector 0x30 is defined for generic-x86_64 timer interrupt. Bug: 119111590 Change-Id: I3aa89ed418deba6c70682f7502850704ff2c1d64
2023-10-16dev: interrupt: x86_lapic: Fix PIC interrupt deliveryArve Hjønnevåg
Remap and enable PIC2 interrupts in addition to PIC1 interrupts. Also send eio signal in interrupt instead of delegating this to the handler as where the eoi needs to be sent, depends on which interrupt line it is connected to, not on the source device. Bug: 305271489 Change-Id: I4b917cb5990be6f3bf199e9c3e2ca2e6f412d2db
2023-10-14sanity check the aspace size in is_valid_vaddr()Ji Luo
the size in an initial aspace is 0, (aspace->size - 1) would cause downflow and the is_valid_vaddr() may return true in such scenario. Change-Id: I0b34ca6426536a7c05cb7d3fee026ee747c7498b Signed-off-by: Ji Luo <ji.luo@nxp.com>
2023-10-11arch: x86: Add support to enter 64-bit user spaceZhong,Fangjian
Before enter user space, syscall environment and stack for privilege change should be set up. SYSENTER instruction is used to execute a fast syscall to privilege level 0 system procedure or routine. Privilege level 0 code segment, entry point and stack pointer should be set in corresponding MSRs for SYSENTER instruction. Privilege change stack resides in RSP0 in TSS, it would be used when privilege level changes to 0 (for instance, interrupt handling when interrupt raised at user level). IRET instruction is used to perform inter-privilege change from level 0 to level 3 when above environment is ready, then processor runs at privilege level 3. Bug: 119111590 Change-Id: I060a4a12422c9c344f6f0edaa6619580665d2589
2023-10-11arch: x86: Add copy from/to user supportZhong,Fangjian
Bug: 119111590 Change-Id: I27ed2e7ad3b0d23045228abc728a4d27e4e9c794
2023-10-11kernel: vmm: Expose vmm_find_region functionZhong,Fangjian
Bug: 119111590 Change-Id: I879130874cf1b9512bf7f44a4c4e2e33f240bdac
2023-10-11kernel: vm: Add api to lock aspaceArve Hjønnevåg
Will be used by x86 user-copy functions which needs to check permissions separately from the copy Bug: 304625515 Change-Id: Ibb34bed675f3e561a8072268bed400f3ffdcfc56
2023-10-11arch: x86: Switch to 64-bit entryZhong,Fangjian
Switch entry of x86 Trusty LK from 32-bit to 64-bit. With this change, boot loader or hypervisor needs to set initialization processor environment for x86 Trusty LK to be 64-bit. Bug: 119111590 Change-Id: I394def04fb32e8276c65d4cca94ec2e593b1820d
2023-10-11lk: add init_cpu_features to linker discard listDonnie Pollitz
Bug: 291781744 Test: Builds and passes tests Change-Id: I1b4ad348beff345b697f399c000e86cedcb3c89e Signed-off-by: Donnie Pollitz <donpollitz@google.com>
2023-10-09arch: x86_64: Set elf entry point to physial addressArve Hjønnevåg
Allows booting from elf file with elf loader that expects entry point to be the physical address not the virtual address we later relocate to. Bug: 298710242 Change-Id: I1b7af6ac68ffd917f8e61281c5697adee9d22e42
2023-10-09arch: arm64: Set elf entry point to physial addressArve Hjønnevåg
Allows booting from elf file with elf loader that expects entry point to be the physical address not the virtual address we later relocate to. Bug: 298710242 Change-Id: I142d00d8abbf8fbe60f87814d4668beee45034d2
2023-10-05engine.mk: LOCAL_MAKEFILE needs to use lastwordBryan Lavrich
To get the current makefile, you need to get the last value of MAKEFILE_LIST before any include statements in the makefile. This one place was getting the whole list of makefiles. If you have an environment with one or more convenience makefiles in the "MAKEFILES" env variable, then this breaks. Bug: 279109533 Test: build with MAKEFILES set to /tmp/foo.mk Change-Id: I0feadee779c71e7ac009fdce3db50229fb8ddf0d
2023-10-04threadtest: disable flaky thread cookie testsPer Larsen
Thread cookie tests that may panic in thread_resched are flakey and need non-trivial updates to ensure correctness and reliability. Disable these tests until they can be properly fixed. Bug: 300168583 Test: build.py --test com.android.kernel.threadtest (run repeatedly) Change-Id: I0e5f37b2e412d939e7f1d107850d5f808df343ea
2023-09-29trusty:pac: correct FEAT_FPAC determination on ARMv8.xMike McTernan
There are multiple system registers and bits to check that FEAT_FPAC has been implemented. Since this feature is mandatory at ARMv9, this error was not initially seen when building for ARMv9. Bug: 261566834 Test: build.py with target at ARMv8, run com.android.kernel.pactest Change-Id: I658c238d0a11a245662235a3254dee75cc8df179
2023-09-12make/macros.mk: Fix FIND_CRATE macroAndrei Homescu
Some crates under trusty/user/base/host follow the X-rust naming convention, others are just called X. Fix the FIND_CRATE macro to check for both. Bug: 281857510 Test: presubmit Change-Id: Ic0d287b6efb5a9e27673521b6f44df861e314ef8
2023-08-24Update irq vector assert from > 32 to >= 32. 32 is a valid irq vector.Serena Zhou
Change-Id: I11127c6b4c77ad8451d7218ba562109a0de5ff03 Test: built and ran on device Bug: 297099568