Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARM physical heap: exclude all identity-mapped memory #2087

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion klib/cloud_azure.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ typedef struct azure {
vector extensions;
struct spinlock lock;
boolean goalstate_pending;
boolean goalstate_print_errors;
boolean provisioned;
} *azure;

Expand Down Expand Up @@ -75,9 +76,11 @@ closure_func_basic(timer_handler, void, az_report_th,
if (is_ok(s)) {
az->goalstate_pending = true;
} else {
msg_err("%s error %v", func_ss, s);
if (az->goalstate_print_errors)
msg_err("%s error %v", func_ss, s);
timm_dealloc(s);
}
az->goalstate_print_errors = true;
}

static void az_report_status(azure az)
Expand Down Expand Up @@ -563,6 +566,9 @@ boolean azure_cloud_init(heap h)
spin_lock_init(&az->lock);
az->container_id_len = az->instance_id_len = 0;
az->goalstate_pending = az->provisioned = false;
/* Do not print error messages if the Azure Wire Server is unreachable just after instance
* startup (a few seconds may elapse before the network interface acquires a DHCP address). */
az->goalstate_print_errors = false;
az_status_upload_init(az);
init_timer(&az->report_timer);
register_timer(kernel_timers, &az->report_timer, CLOCK_ID_MONOTONIC, seconds(2), false,
Expand Down
12 changes: 3 additions & 9 deletions platform/virt/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,17 @@ static u64 get_memory_size(void *dtb)
return range_span(r);
}

extern void *START, *END;
extern void *START;
void init_physical_heap(void)
{
init_debug("init_physical_heap\n");
u64 kernel_size = pad(u64_from_pointer(&END) -
u64_from_pointer(&START), PAGESIZE);

init_debug("init_setup_stack: kernel size ");
init_debug_u64(kernel_size);

if (boot_params.mem_map.map) {
u64 map_base = u64_from_pointer(boot_params.mem_map.map);
u64 map_size = pad((map_base & PAGEMASK) + boot_params.mem_map.map_size, PAGESIZE);
map_base &= ~PAGEMASK;
/* map_base has been identity-mapped in ueft_rt_init_virt() */
range reserved = irange(DEVICETREE_BLOB_BASE + kernel_phys_offset,
KERNEL_PHYS + kernel_size + kernel_phys_offset);
range reserved = irangel(PHYSMEM_BASE + kernel_phys_offset, INIT_IDENTITY_SIZE);
u64 base = 0;
uefi_mem_map_iterate(&boot_params.mem_map,
stack_closure(get_bootstrap_base, reserved, &base));
Expand All @@ -179,7 +173,7 @@ void init_physical_heap(void)
add_heap_range_internal(remainder, 0);
unmap(map_base, map_size);
} else {
u64 base = KERNEL_PHYS + kernel_size;
u64 base = PHYSMEM_BASE + INIT_IDENTITY_SIZE;
u64 end = PHYSMEM_BASE + get_memory_size(pointer_from_u64(DEVICETREE_BLOB_BASE));
map(BOOTSTRAP_BASE, base, BOOTSTRAP_SIZE, pageflags_writable(pageflags_memory()));
base += BOOTSTRAP_SIZE;
Expand Down