aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2019-09-19macros: Add containerof_null_safeArve Hjønnevåg
Move custom code in list_*_type macros into a common containerof_null_safe macro that can be used by other clients. Bug: 141330276 Change-Id: Icc4c2c5b5e192dd8e81a189903083b9d1d31a017
2019-09-18[arch][x86] Refine arch_enable_intsZhong,Fangjian
arch_enable_ints invokes STI instruction only, however, STI instruction has delayed effect, maskable interrupts remain inhibited on the instruction boundary following an execution of STI when IF=0. Add NOP instruction to ensure interrupt can be recognized successfully after arch_enable_ints is invoked. Bug: 119111590 Change-Id: I66417e7a934bdd70b386ce587383ea8f6112cec6
2019-09-18[arch][x86] Use per CPU state to maintain current threadZhong,Fangjian
Maintain current thread for each processor by using per CPU state. It ensures operation atomic. Bug: 119111590 Change-Id: Ib9621e72c53d99cc23cb49112a73cb3b5f84c60b
2019-09-18[arch][x86] Add 64-bit Task-State Segment (TSS) supportZhong,Fangjian
64-bit TSS descriptor is defined as 128 bits compared to 64 bits legacy descriptor. Low 64 bits of TSS have same definition as legacy descriptor, high 64 bits contain base address bit 63:32 of descriptor. Bug: 119111590 Change-Id: Ic9c7295b1cd8c286ba91c5358ffeb8821cea2e4f
2019-09-17[arch][x86] Add GS support for per CPU statesZhong,Fangjian
GS is used to store per CPU states. Current thread and syscall stack for each processor will be stored in per CPU states. Meanwhile, retrieving these information from per CPU states via GS makes operation atomic. Bug: 119111590 Change-Id: I65d0bbca1498b96db9270fbe9b5efdffec65c191
2019-09-16vmm: Create vmm_objArve Hjønnevåg
Create an object type that can be mapped by the vmm. This allows tracking when memory is no longer mapped so that it can be freed or returned. Currently the vmm keeps track of a pages that need to be freed when a vmm region is unmapped, but this does not work for shared memory where the physical memory could be mapped multiple times, or where the physical memory was not allocated by lk. Bug: 129788581 Change-Id: I200f7ac10448ee54b15d18784ff76011d76777df
2019-09-09vmm: Require ptr in all vmm_alloc apis.Arve Hjønnevåg
Currently the api only require a ptr value if VMM_FLAG_VALLOC_SPECIFIC is set, but we have no use case for allocating or mapping memory without knowing where it got mapped. Bug: 139700856 Change-Id: Ie03a59f095842b7f2694dc8140f8c8ef0e2772c2
2019-09-07list: Add list splice operations.Arve Hjønnevåg
Allows moving all entries from one list to another. Bug: 139901788 Change-Id: If7d9270a51f6425a4dfa0a2b99ec2bb00099930f
2019-09-06Dump load bias for unhandled faultsMatthew Maurer
If we fault in userspace, print the derandomized PC and the load bias for debugging. At this point, the process is already being killed so leaking its load bias through the logs should be a non-issue. Bug: 80146040 Change-Id: I006470aa251c58dbeea0c43637ce43142d7fe111
2019-09-06[arch][arm64][mmu] Validate paddrArve Hjønnevåg
The top bits in the pte are used for attributes. If the address passed in is too large a truncated address would be mapped with extra attribute bits set. Bug: 140628678 Change-Id: I71939bd8d49fe85df1ae2bf93e1f437d2f134c4e
2019-09-05Provide bcmp in the kernelMatthew Maurer
New Clang will call out to bcmp instead of memcmp in some situations. Providing bcmp allows us to use these newer compilers. Bug: 140579848 Change-Id: I0b1d8443e2366a8f258177516e782a26087b86a2
2019-08-26hosttests: Add kernel hosttests folder and add a listtestArve Hjønnevåg
Bug: 139900186 Change-Id: I56293bbd4e78dc780478448511d2ddd1213d0567
2019-08-14[vm] Fix ubsan overflowsArve Hjønnevåg
Bug: 129300035 Change-Id: I6c67ea047b610b497ad2856dd432873b880c234b
2019-08-07[kernel][vm] Expose vmm_find_region methodZhong,Fangjian
vmm_find_region can be used to find a region in which specified virtual address resides. Bug: 119111590 Change-Id: I9067723762419aac533adcaa49c36ab9cd573809
2019-08-05Ensure the boot time allocator is not used after startupNick Bray
Bug: 138254506 Change-Id: I9078b7d09f5e59b127532009a62d2b6115f53e7c
2019-08-05Check for errors when marking early allocated pagesNick Bray
Bug: 138254506 Change-Id: I49da196d5c94af08d25c11fc679a0c40b880c420
2019-08-05[lib][dpc] Rewrite DPC implementationMichael Ryleev
The DPC (deferred procedure call) service in LK allows to queue work that will be executed at later time in context of DPC kernel thread. This CL reanimates this service (it does not compile as is) to use on devices with small memory footprint. Bug: 134153475 Change-Id: I4dded43e6ba8a83204f51c39a8e07a47f2d0d621
2019-08-02[lib][debug] Fix UBSan issueZhong,Fangjian
Use unsigned char to replace char to avoid potential conversion overflow Bug: 119111590 Change-Id: I1d70d9acd371a8c9877ae76bfe82a74c9dac7cd9
2019-07-29Eliminate benign end-of-address-space overflows detected by UBSANNick Bray
Bug: 138254506 Change-Id: I165deef3dbf5763216b8b00fecb3345eadbaceff
2019-07-25[kernel][thread] Make idle thread overridable by platformMichael Ryleev
The primary usecase is to be able to tap into idle thread to implement power management related services. Bug: 134154381 Change-Id: I9e5f4adb7a747e67e2d20a39c9dbb03e4143ca13
2019-07-24[arm][mmu] Add missing TLB invalidateMichael Ryleev
Call TLB invalidate to purge addresses after disabling access to bottom part of address space. This would trigger immediate rather then deferred failure if any code is still running there. Bug: 134152754 Change-Id: I907826fb33ae4cdf9151be95ee8041593235a223
2019-07-17libc: Fix UBSan error when strnlen reaches the limitArve Hjønnevåg
Bug: 129300035 Change-Id: I3269092838366092c420d59995e777bcb05d5c5a
2019-07-12Randomize vmm_alloc when ASLR is onMatthew Maurer
* alloc_spot() knows how to pick a random location * vmm_find_spot() is exported for use in the ELF loader * Set ASLR=false in your makefile to disable ASLR * Still using a fixed seed LCG PRNG, which needs replacing. Bug: 80146040 Change-Id: I73bc42baed3a60ea071f2965ea2542095a634908
2019-07-12[make] Use compiler-rt instead of libgccNick Bray
libgcc does not contain all of the intrinsics that Clang may generate. Bug: 136265573 Change-Id: I8b565ead77279744ee81a339670050ae449ddeeb
2019-07-11[make] define STANDARD_ARCH_NAMENick Bray
This makes it easier to work with Clang and other tools that expect aarch64 instead of arm64, x86_64 instead of x86 or x86-64, etc. Bug: 136265573 Change-Id: If030f2495f23577f5fcdb070faa4450f1a3a289a
2019-07-01clang-format kernel/vm/vmm.cMatthew Maurer
In preparation for patching with a clang-format clean version. Also pull in .clang-format Bug: None Change-Id: Id91a172c6fba3ad06ac770b1db06d782b1016013
2019-06-28Add _MAX macros for vaddr/paddr/addr typesMatthew Maurer
Bug: 80146040 Change-Id: I527171a3204332e6c0ac323deac96642b735745e
2019-06-27[make] ensure libgcc is part of the link groupNick Bray
There is a bidirectional dependency between libgcc and libc. Bug: 136204005 Change-Id: I1d25a134a85f44ede1596d921ea7094da2888dd2
2019-06-27[arch][arm/arm64] Add ARM_MERGE_FIQ_IRQ build flagArve Hjønnevåg
Set this flag to true to work with interrupt controllers (gicv3 and gicv4) that deliver non-secure interrupts as FIQs instead of IRQs while running in secure mode. Change-Id: Iad5339314f3f2cc52bb1f78dad2bbdf4eac1c97c
2019-05-21[lib][heap][miniheap] Remove retry limit after growing heapArve Hjønnevåg
If multiple threads tries to allocate a page at the same time, retrying the allocation can fail as the heap lock is released between growing the heap and retrying the allocation. Remove the retry limit so that it will succeed if memory is still available after the other threads are done. Bug: 132652075 Change-Id: Ic62a773a49288db1f15fc52abaeaef6d7a94d770
2019-05-08Move reg.h into shared include directory.Nick Bray
It is used both in the kernel and in user space. Bug: 110161494 Change-Id: If5846681caee160deee8540d221b4c5c7e0e1255
2019-05-07[kernel][vm] Disable ubsan checkArve Hjønnevåg
Trying to map anything in the last kernel free region would trigger a panic as the check relies on an unsigned interger overflow Bug: 129300700 Change-Id: I53c4fc11e4b0d0d2d3bb359fdffe171f15d7d9b6
2019-04-22Add TLS entry for UBSan stateMatthew Maurer
We need to track this so that if a thread is already trying to report a UBSan fault, it won't retrigger the fault handler code by trying to report it. This value is thread-specific because we are only trying to prevent two UBSan handlers in the same callstack with this flag - in different threads, both handlers should report as normal. Bug: 129300035 Change-Id: If823e0ab7c3afbe72fa2d15b8e89d6b9cd6a9398
2019-04-18[lib][heap][miniheap] ensure allocations are naturally alignedNick Bray
Previously, miniheap could produce 4-byte aligned allocations on 32-bit platforms and thread_t requires 8-byte alignment. Bug: 130829217 Change-Id: I6054554f4aa5cb5224f92b2a6e4b9c29c168bb46
2019-04-18Adjust list_for_every_entry macros to avoid UBMatthew Maurer
We were doing out-of-bounds address math in order to iterate over entries. We fabricated a fake thread_t * out of our head list node, which leads to invoking containerof on a value which is not necessarily embedded in that container. UBSan caught this because the resulting thread_t * was not properly aligned. Since we are holding a pointer to the next list node, we also remove temp_entry from the API. Bug: 129300035 Change-Id: I117e043dcfd3aa8001100d7dd97e71c87e56316c
2019-04-18[dev][interrupt] Add x86 Local APIC supportZhong,Fangjian
Introduce Local APIC to handle external interrupts instead of 8259 PIC, and issue interprocessor interrupts. 8259 is used to handle external interrupt in previous lk common x86 architecture, it has ablity handle up to 15 external interrupts. 8259 is obsoleted in common x86 architecture now, Local APIC supports up to 224 usable external interrupt vectors (0 to 31 out of 0 to 255 are reserved for exception). Bug: 119111590 Change-Id: Iee5ee67788968e61568a9c0885a8f96c1d979d29
2019-04-18[arch][x86] Update exception_die handlingZhong,Fangjian
Trusty runs into deaploop when exception triggered. This is an unexpected behavior, since whole system runs into halt status. Trusty should halt platform with reason HALT_REASON_SW_PANIC, and switch back to Non-Secure world when exception triggered. Bug: 119111590 Change-Id: I600fe90012a60284451f6bbcea08ffb1fe3b3826
2019-04-18[arch][x86] Update atomic_cmpxchg implementationZhong,Fangjian
Add Clang/GCC built-in atomic function to implement atomic_cmpxchg Bug: 119111590 Change-Id: I24b17f711bf9fbaabbc14abbf896d4dad8cde722
2019-04-18[arch][x86] Update get_pfn_from_pte routineZhong,Fangjian
According to IDSM vol3 chapter 4.1.4, MAXPHYADDR is at most 52. Bit 63 indicates Exceution Disable atttribute, bits 62:59 used for Protection Key feature, bits 58:52 are ignored. In order to get valid pfn from pte, high 12 bits should be cleared. Bug: 119111590 Change-Id: I25ae6c8ba0dc218006b26db82a1abf94ffd953e6
2019-04-18[arch][x86] Update SMAP/SMEP detection and get address widthZhong,Fangjian
1. Correct SMAP/SMEP detection bits when querying from CPUID instruction. 2. Refine SMAP/SMEP detection and get address width by invoking GCC built-in __cpuid function. Bug: 119111590 Change-Id: Idc3da0f2bfa21ed4fd49cb4822296e29ed94e8fb
2019-04-18strcmp/strncmp should interpret bytes as unsignedMatthew Maurer
Bug: 129300035 Bug: 130573558 Change-Id: I4019750847897dd77351356f57831884e29fe175
2019-04-16arm32 UBSan fixupsMatthew Maurer
* Unsigned flags * Subtract from size before adding * Use memcpy to avoid an unaligned read Bug: 129300035 Change-Id: Id1656b7ca93cbd9f321ec5bb74fab5ca03136276
2019-04-16Annotate signsMatthew Maurer
Bug: 129300035 Change-Id: Ide135eb365311d49022cd395ae14f87a3545f7e2
2019-04-16Adjust alignment math for UBSanMatthew Maurer
Bug: 129300035 Change-Id: I0ac69a757074dd4326583fc16b190b73596c8be4
2019-04-11Use unsigned flagsMatthew Maurer
Bug: 129300035 Change-Id: I60ae094b44c321c95c57d74985d4f240db072e1a
2019-04-11Use functions instead of macros for alignmentMatthew Maurer
Switching ROUNDUP/ROUNDDOWN/ALIGN to static inline functions prevents the types of these values from being implicit. While I did not find any examples of it causing problems, the previous approach could cause different behavior depending on the relative types of the alignment and value to align. For example, if an unsigned literal was used in the alignment field (say 8U) you would end up dropping the high 32 bits of the pointer, since no sign extension would occur when extending the mask to the width of the pointer. This also prevents UBSan from alarming on the implicit casts that were previously performed in the macro. Change-Id: I43c94ecd0f6cce53d4a0638139f39a0e5533f407
2019-04-11USHORT_MAX -> USHRT_MAXMatthew Maurer
USHORT_MAX is not defined in limits.h, they meant to say USHRT_MAX Bug: 129300035 Change-Id: Ifdbdcd5bd582c3bb6ffca3d5212c560873db0f7d
2019-04-08[arch][x86] Use Clang's intergrated assemblerZhong,Fangjian
Use Clang's intergrated assembler to compile assembler source code Bug: 119111590 Change-Id: I2edf16898fbd2eba5bb13c10bf0f80e7b61f33d5
2019-04-08[arch][x86] replace retf with lretNick Bray
Clang's integrated assembler requires this mnemonic. Bug: 125023379 Change-Id: I1414e32cb8d65383e83f9ac48c73865ea3e71d30
2019-04-08[arch][x86] remove -gdwarf-2 compile flagNick Bray
There is no need to specify a specific debug format for x86, let alone an old format. Bug: 125023379 Change-Id: Ic4fa106fc5e11698963f938866a7c09d8f7cd7f8