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

[BUG]: Unable to start when memory exceeds 27647 #17

Closed
BlackHole1 opened this issue Nov 4, 2024 · 11 comments · Fixed by #19
Closed

[BUG]: Unable to start when memory exceeds 27647 #17

BlackHole1 opened this issue Nov 4, 2024 · 11 comments · Fixed by #19

Comments

@BlackHole1
Copy link

After testing, when the --memory value is greater than 27647, krun will fail to start. The error is as follows:

Error: unable to begin running krun workload
@BlackHole1
Copy link
Author

BlackHole1 commented Nov 4, 2024

(27647 + 1) * 1024 * 1024 = 28,991,029,248

Image

Memory max value is (27 GiB - 1M). Is this expected?

@tylerfanelli
Copy link
Member

This is dependent on the system you're running on, no? 27GiB of RAM is no small amount. How much RAM is on the system you're running with?

@BlackHole1
Copy link
Author

@tylerfanelli Sorry. I forgot to add my system information.

System: Darwin Arm64 (M3)
Memory: 36GB

Image

@slp
Copy link
Collaborator

slp commented Nov 4, 2024

Works fine here with arbitrarily large memory sizes, even larger than the host's RAM (the memory for the guest is not preallocated). Could you please build krunkit with #18 and re-run your test with --krun-log-level 5?

@BlackHole1
Copy link
Author

@slp Okay, I'll give it a try now.

@BlackHole1
Copy link
Author

LOG:

[2024-11-04T11:10:40Z DEBUG vmm::macos::vstate] Guest memory host_addr=0x104d44000 guest_addr=0 len=8000000
[2024-11-04T11:10:40Z DEBUG vmm::macos::vstate] Guest memory host_addr=0x300000000 guest_addr=40000000 len=6c0000000
[2024-11-04T11:10:40Z DEBUG vmm::macos::vstate] Guest memory host_addr=0x7000000000 guest_addr=740000000 len=900000000
[2024-11-04T11:10:40Z ERROR krun] Building the microVM failed: Internal(Vm(SetUserMemoryRegion(MemoryMap)))
Error: unable to begin running krun workload

@BlackHole1
Copy link
Author

I found that orbstack also encountered a similar issue, but since it is closed-source software, I am not sure how it was fixed: orbstack/orbstack#1178

@BlackHole1
Copy link
Author

I added some logs to libkrun/hvf/src/lib.rs#L201 and found that the return value of hv_vm_map is: HV_BAD_ARGUMENT.

Image

HV_BAD_ARGUMENT: https://developer.apple.com/documentation/hypervisor/1585168-hypervisor_errors/hv_bad_argument

slp added a commit to slp/krunkit that referenced this issue Nov 4, 2024
Automatically adjust VRAM so VRAM+RAM doesn't exceed the space
available in a 36 bit IPA, accounting for the start address and
rounding in libkrun, which sets an upper limit of ~62GiB.

Also, reject a memory configuration larger than 60 GiB to ensure
we leave some room for VRAM.

Fixes: containers#17

Signed-off-by: Sergio Lopez <[email protected]>
@slp
Copy link
Collaborator

slp commented Nov 4, 2024

Could you please give #19 a try? I think it should work with arbitrary memory configurations, even ones exceeding the memory available on the host (with the upper bound of 60 GiB).

@BlackHole1
Copy link
Author

@slp It worked! Thanks!

tylerfanelli pushed a commit that referenced this issue Nov 5, 2024
Automatically adjust VRAM so VRAM+RAM doesn't exceed the space
available in a 36 bit IPA, accounting for the start address and
rounding in libkrun, which sets an upper limit of ~62GiB.

Also, reject a memory configuration larger than 60 GiB to ensure
we leave some room for VRAM.

Fixes: #17

Signed-off-by: Sergio Lopez <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants