53 Commits

Author SHA1 Message Date
Travis Geiselbrecht
48d331f144 [clang] fix a few warnings
Mostly dealing with comparing a pointer variable that is declared
nonnull, which I find to be a dubious warning but is pretty safe in this
case since the compiler will be more aggressive about the nullness of
the arguments.
2025-10-05 13:56:55 -07:00
Kelvin Zhang
0d8a1ec055 [app][uefi] Make allocate_pool return identity mapped memory 2024-11-06 10:12:17 -08:00
Kelvin Zhang
347db09959 [app][uefi] Place linux kernel at identity mapped virtual memory addresses 2024-11-06 10:12:17 -08: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
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
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
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
thomas
a7d2752b28 [kernel][vm] try the next arena if current is out of free pages 2022-01-26 12:16:53 -08:00
Travis Geiselbrecht
be6169820d [kernel][vm] Move the VM postheap init hook back one step
This is a cheesy solution to adding another top level hook, which really
should be done.
2021-12-27 22:24:31 -08:00
Travis Geiselbrecht
a3713e8b39 [arch][riscv] add simple support for context switching user space aspaces
Pretty inefficient but probably works well enough.
2021-04-09 02:00:57 -07:00
Travis Geiselbrecht
4edb93adde [lib][console] rename some console command types to be prefixed with console_
Some of the structures, notably 'cmd', in the lib console stuff are a
little too generically named and have collided with some other code
so prefix the names a bit more cleanly with console_

The change is largely mechanical, and folks with out of tree code can
easily switch by renaming:
cmd -> console_cmd
cmd_args -> console_cmd_args
cmd_block -> console_cmd_block
console_cmd -> console_cmd_func

Apologies if this breaks you but it should be pretty easy to fix.
2020-07-25 15:59:58 -07:00
Travis Geiselbrecht
7cc7d79e74 [pmm] add a few more convenience routines
Add a routine to just allocate a single page and a fast page for
allocating a single kvaddr page.
2020-05-10 16:51:58 -07:00
Travis Geiselbrecht
df32504748 [kernel] test run sorting some includes
No functional change.
2019-07-13 17:21:00 -07:00
Travis Geiselbrecht
6cb02526b7 [include][console] split lib/console.h into two
TL;DR most uses of lib/console.h -> lk/console_cmd.h

Move the part that lets a piece of code somewhere in the system to
define a console command from the actual lib/console api to start an
instance of the console. Move in almost every place the user of the
console command definition to the new header, lk/console_cmd.h which is
always in the include path.

Also remove most uses of testing for WITH_LIB_CONSOLE since you can
almost always just safely define it and then let the linker remove it.
2019-07-13 16:56:33 -07:00
Travis Geiselbrecht
85a50ea3f4 [kernel][license] try out using a smaller version of the license header
Replace the body of the MIT license with a reference to the LICENSE file
and a URL with the MIT license. Replaces 20 something lines with 3.

No functional change.
2019-06-19 23:28:14 -07:00
Travis Geiselbrecht
d8fa82cb91 [formatting] run everything through codestyle
Almost nothing changes here except moving braces to the same line as the
function declaration. Everything else is largely whitespace changes and
a few dangling files with tab indents.

See scripts/codestyle
2019-06-19 21:02:24 -07:00
Travis Geiselbrecht
1b7a28efb8 [include][lk] fixup lk/ include path move 2019-06-19 19:46:11 -07:00
James Zhong
089dce3a7d [kernel][vm][pmm] Bug fix in pmm
Bug fix of PAGE_ADDRESS_FROM_ARENA in pmm of vm module

Signed-off-by: James Zhong <sha8312@gmail.com>
2017-04-21 17:14:45 -07:00
Erik Corry
6d0122b98e [heap] Add API used by Dartino to get arena list 2016-03-23 21:22:39 +01:00
Travis Geiselbrecht
2a51111387 [kernel] add more controlled way to switch vmm address spaces 2016-02-23 21:07:22 -08:00
Travis Geiselbrecht
14a4c60172 [kernel][vm] get rid of external declaration of address_to_page 2016-02-16 15:25:31 -08:00
Travis Geiselbrecht
9a5cd5c529 [kernel][vm] add support for multiple user address spaces
Generically add support for more than one user address space,
attach to a thread, and context switch as thread swaps happen.

Add support for ARM and ARM64, and stub out support for x86 platforms.
2016-02-16 15:24:25 -08:00
Travis Geiselbrecht
a4ca0a6e00 [vmm] move most users of arch_mmu_query directly to vaddr_to_paddr() 2016-02-14 12:45:53 -08:00
Travis Geiselbrecht
2eb32a4369 [style] mass reformat all the non external code to 4 space indents
Ran everything through scripts/codestyle.space, which uses astyle
to generally follow K&R style.

Biggest non whitespace change is pulling brackets down on function
declarations, which I'm pretty ambivalent about, but astyle insists
on taking a stance
2016-02-14 12:24:01 -08:00
Travis Geiselbrecht
35ebee0e40 [merge] branch 'heapswitch'
This picks up the major work of allowing multiple heap implementations
and enable dlmalloc as an alternate heap to the simple existing one
(now called 'miniheap').

Also added a novm page allocator for memory management on systems too small
or missing an mmu to have a vm. Not much more than a simple bitmap allocator
that the heap pulls from. Allows for other heaps and/or users of physical
memory to coexist and span multiple banks of memory.
2015-10-20 16:53:00 -07:00
Travis Geiselbrecht
16b1b594f4 [kernel][vm] fix error handling in vmm_alloc in case it can't allocate enough physical memory 2015-10-16 16:09:08 -07:00
Travis Geiselbrecht
1193213dfd WIP get dlmalloc working with a mmap() style allocator out of the heap wrapper 2015-10-14 19:56:24 -07:00
Gurjant Kalsi
dc079d7327 [console][uart][shell] Created a crash-time shell and a polling based UART driver to use on panic. 2015-10-12 16:38:51 -07:00
Travis Geiselbrecht
6df1116275 [kernel][vmm] fix logic bug in vmm_free_aspace() 2015-09-23 18:03:29 -07:00
Travis Geiselbrecht
294ded0d57 [kernel][vmm] add support for user address spaces
Still doesn't switch between them, but allows for a separate container
of regions to be created and destroyed.
2015-09-23 17:43:37 -07:00
Travis Geiselbrecht
25cf30637f [vm] have the pmm routines return a size_t instead of uint for 64bit compatibility 2015-09-20 12:13:07 -07:00
Michael Ryleev
18192509eb [kernel][vm] Fix a bug in vm address allocator
Pass arch_mmu_flags (instead of flags) to arch_mmu_pick_spot routine.
This bug would mostly affect ARMv7 platforms with enabled support
for non-secure memory.

Change-Id: Ic97ee6d3f05528170d66ab5033b24adf1d0c514e
2015-08-24 15:47:29 -07:00
Travis Geiselbrecht
80fbfef0e1 [merge] merge branch 'master' into smp
Conflicts:
	kernel/vm/pmm.c
	platform/zynq/debug.c
	platform/zynq/platform.c
2015-03-31 15:35:13 -07:00
Michael Ryleev
210fbbde75 [kernel][vm] Add support for arch_mmu_pick_spot routine
Some architectures might have resrictions on selecting
virtual address depending on properties of particular
VM allocation. This CL allows arch to provide a hook into
virtual address allocator to handle such restictions.

Change-Id: I28e912dcf2cf260b7e6666b6a9384178e41bfa73
2015-03-19 18:01:13 -07:00
Michael Ryleev
f2eb7c75b0 [kernel][vm] Add alignment parameter to vmm_alloc_physical
Change-Id: I516402908e05b5f4b455f79c18fafd795f1f8455
2015-03-19 18:01:13 -07:00
Michael Ryleev
0071fc66eb [kernel][vm] Fixup few end of address space conditions
Change-Id: Ie105016f44d0d8579282713ce901f9c5e75ad408
Signed-off-by: Michael Ryleev <gmar@google.com>
2015-03-19 18:01:13 -07:00
Michael Ryleev
0eb6b97baf [kernel][vm] Add lock around public VMM operations
Change-Id: I873f1dc0ecf49afc790c5012b53a3679048c2a80
2015-03-19 18:01:13 -07:00
Michael Ryleev
acc1a59a07 [kernel][pmm] Add proper end of arena segment check
Change-Id: I25ac3b9bd099b51c95e138a204dc625964d97913
2015-03-19 18:01:12 -07:00
Arve Hjønnevåg
c593fc51a1 [kernel][vm] panic if mark_pages_in_use fails to find the paddr
If mark_pages_in_use fails to mark the kernel code (or data) as used,
it will get corrupted as the heap starts reusing using it.

Change-Id: I48f62bb68dcbad3268304aa2a1e63e9956128064
2015-03-19 18:01:11 -07:00
Travis Geiselbrecht
29b9061f2a [kernel][pmm] fix bug with pmm_alloc_contig when arena is exhausted
-Fixes bug where the code would walk off the end of an arena, not
detecting the case where there is no way to satisfy the request.

Change-Id: I16434f13faa6d5d76aaba5bf3c458d230e4db888
2015-03-17 17:45:57 -07:00
Arve Hjønnevåg
d0c4833b3f [kernel][vm] Fix end address checks
If the end of a range is at the end of the virtual address space,
(base + size) is 0. Use (base + size - 1) instead.

Change-Id: I7d02250d765df0ab2bd23b60ee7a484951238c58
2015-03-08 19:05:14 -07:00
Travis Geiselbrecht
ed08f12ab7 [kernel][vm] add mutex to the pmm 2015-02-16 20:41:37 -08:00
Michael Ryleev
ecca4f4aa0 [kernel][vm] Add vmm_free_region and kvaddr_to_paddr
Change-Id: Ieb7a11dcd6d7cd96bfef252b41cc7ccdd4892b8f
2014-11-04 15:30:32 -08:00
Travis Geiselbrecht
b0882ed618 [vmm] add support for allocating aligned contiguous regions
-new argument, align_pow2, will try to allocate physical and virtually
aligned pages.
2014-08-18 14:50:03 -07:00
Travis Geiselbrecht
e72c8bfede [vm] when marking boot physical pages used, make sure the address range is inclusive 2014-08-15 13:37:21 -07:00
Travis Geiselbrecht
ca20aac213 [kernel][vm] tweak the pmm_alloc_contiguous routine to take alignment in log2 2014-08-14 22:14:28 -07:00
Travis Geiselbrecht
cab6a749a8 [kernel][vm] remove extra pmm spew 2014-08-08 15:41:12 -07:00
Travis Geiselbrecht
5daec121e3 [kernel][vm] allow allocation of physical runs of memory aligned on arbitrary boundaries 2014-08-07 18:49:20 -07:00
Travis Geiselbrecht
cb41b90187 [vm] allow config space to set kernel address space size, ARM sets to top 3GB 2014-07-24 15:26:34 -07:00
Travis Geiselbrecht
e35c99d004 [kernel][vm] fix debug code to compile if console disabled 2014-07-24 02:59:24 -07:00