-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Bootloader work #10
Comments
Hi!
Thanks for your amazing work!
There is another hacker who succeeded in patching the kernel and qemu, and
boot the kernel on qemu.
Please check the details
https://twitter.com/Xim24689559/status/1645435639985324032
There are some extra build steps to do, including the serial, the page
table etc.
Thanks again for your work on the bootloader!
Best regards
Inoki
…On Thu, Jun 29, 2023, 18:28 NSG650 ***@***.***> wrote:
Hey! I stumbled across your repo and managed to build XNU successfully
however I have issues booting it. I have a little bit of experience with
ARM64 and managed to patch limine
<https://github.com/limine-bootloader/limine> to load and run the kernel.
However it crashes at arm_init basically after setting up the page tables
and jumping into C code. You seemed like the guy who might know what went
wrong so opening the issue here. Really sorry if I disturbed you or
approached the wrong person and REALLY sorry I am opening this issue this
late.
You can find the patches I made here
<https://gist.github.com/NSG650/16b61d8db84cbc48588da4b7130beb83>
Thank you in advance!
—
Reply to this email directly, view it on GitHub
<#10>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB7NEBBKTJYUQA4LG7JWJALXNWUKHANCNFSM6AAAAAAZYX72M4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Hey! Thanks for replying. I have tried the new kernel configs and it finally uses virtual memory at last!. However it fails to jump into uint64_t phys_base = kernel_buffer;
uint64_t virt_base = low_addr_temp;
boot_arguments->Revision = kBootArgsRevision2;
boot_arguments->Version = kBootArgsVersion2;
boot_arguments->physBase = phys_base;
boot_arguments->virtBase = virt_base;
boot_arguments->memSize = size;
boot_arguments->memSizeActual = 0;
boot_arguments->topOfKernelData = boot_arguments->physBase + boot_arguments->memSize; I am passing these as my arguments arguments. Thanks in advance Edit: I have also looked into the qemu fork used and it would jump elsewhere instead. |
Hey again! I looked in deeper and found out what went wrong.
So after changing my code to this uint64_t phys_base = kernel_buffer;
uint64_t virt_base = 0xfffffff000000000 + kernel_buffer; it worked. It crashes elsewhere. I will look into that now but now it finally jumps into Thank you again. |
Hello again, I am extremely sorry if I am being annoying now. The kernel makes it to
There is no UART output as well. Please help me out whenever you are free. Thanks in advance |
Hey there! It has been a long time but I have managed to get XNU booting with this fork of u-boot and a one line patch to chenguokai's kernel! I will try it out on real hardware soon. Here is the patch that was done // in osfmk/arm64/arm_vm_init.c:2070
#if XNU_MONITOR
for (vm_offset_t cur = (vm_offset_t)pmap_stacks_start; cur < (vm_offset_t)pmap_stacks_end; cur += ARM_PGBYTES) {
arm_vm_map(cpu_tte, cur, ARM_PTE_EMPTY);
}
#endif
PE_slide_devicetree(gVirtBase - gPhysBase); // Added because the 1:1 physical mappings are gone and we don't want to continue accessing those addresses
pmap_bootstrap(dynamic_memory_begin);
disable_preemption();
/*
* Initialize l3 page table pages :
* cover this address range:
* 2MB + FrameBuffer size + 10MB for each 256MB segment
*/ |
Thanks very much! That's really impressive and a great work! I am also looking forward to running on my configured Raspi3 with JTAG, and to seeing what to do next. However, I didn't get much time working on it... Looking forward to it! Maybe you can also publish it somewhere on HackerNews, I will definitely give my upvote 🎉🎉🎉 |
Finally published the blog. Theres a guide on how you can get it up and running. This was over all fun and learnt alot about ARM64 and XNU. |
@NSG650 I also saw your blog, and I didn't use a custom QEMU, was this required?
|
No I did not use a custom qemu build I just used the arch provided qemu package. For the framebuffer I just added these lines in the code for the bootxnu command. struct udevice *vid_device = NULL;
struct video_priv *vid_priv = NULL;
int ret = uclass_first_device_err(UCLASS_VIDEO, &vid_device);
if (ret == 0) {
vid_priv = dev_get_uclass_priv(vid_device);
}
if (vid_priv) {
boot_args->video_information.base_addr = vid_priv->fb;
boot_args->video_information.display = 0;
boot_args->video_information.bytes_per_row = (vid_priv->fb_size) / vid_priv->ysize;
boot_args->video_information.width = vid_priv->xsize;
boot_args->video_information.height = vid_priv->ysize;
boot_args->video_information.depth = (1 << vid_priv->bpix);
printf("## Using framebuffer %s\n", vid_priv->vidconsole_drv_name);
printf("boot_args->video_information.base_addr: 0x%p\n", boot_args->video_information.base_addr);
printf("boot_args->video_information.display: %d\n", boot_args->video_information.display);
printf("boot_args->video_information.bytes_per_row: %d\n", boot_args->video_information.bytes_per_row);
printf("boot_args->video_information.width: %d\n", boot_args->video_information.width);
printf("boot_args->video_information.height: %d\n", boot_args->video_information.height);
printf("boot_args->video_information.depth: %d\n", boot_args->video_information.depth);
} around here |
Hi there. I wanted to see if I could get this to work with the latest u-boot and possibly a x86_64 version of the XNU kernel. I see there is a prebuilt |
I didn't create the file. I ripped it out from chenguokai's attempt. Chenguokai generated the dtb using this compiler and one of the jsons found here. As for an x86_64 kernel I can't provide you one right now sadly. I was going to work on porting the bootxnu command to the newer u boot version but then got busy with school lol. |
Actually I got it to work with u-boot 2022 with some mods, if anyone cares |
Oh ok, thanks. I think the swift code may work on a linux machine but it needs a fork of the unmaintained SwiftyJSON library. In terms of the x86_64 kernel, I can probably get one from a macos VM with https://github.com/notAperson535/OneClick-macOS-Simple-KVM. I'll document this later once I have something working 🚀 Edit: If I try to boot the latest u-boot for x86_64 with updated patches it seems to boot loop with the last message being |
Is there a reason you need the lastest U-Boot, other than the frame buffer on QEMU? I did https://github.com/CE1CECL/u-boot/tree/ce1cecl to do that |
Thanks! I applied your changes via https://github.com/u-boot/u-boot/compare/master...CE1CECL:u-boot:ce1cecl.patch and removing the MAINTAINERS change temporarily to resolve conflicts. I also had to modify bootxnu.c to make it work on x86_64 (removing the asm/system.h header unless CONFIG_ARM64 is defined). |
Hi there, how are all doing? |
Hey! I stumbled across your repo and managed to build XNU successfully however I have issues booting it. I have a little bit of experience with ARM64 and managed to patch limine to load and run the kernel. However it crashes at
arm_init
basically after setting up the page tables and jumping into C code. You seemed like the guy who might know what went wrong so opening the issue here. Really sorry if I disturbed you or approached the wrong person and REALLY sorry I am opening this issue this late.You can find the patches I made here
Thank you in advance!
The text was updated successfully, but these errors were encountered: