feat(x86_64): Multiboot2 zone loading and virtio device fixes for Asterinas#98
Open
yydawx wants to merge 3 commits into
Open
feat(x86_64): Multiboot2 zone loading and virtio device fixes for Asterinas#98yydawx wants to merge 3 commits into
yydawx wants to merge 3 commits into
Conversation
…setup - Always set queue_sel in virtio-mmio write handler so the guest can correctly probe the number of queues by iterating queue_sel values. - Return 0 in QUEUE_NUM_MAX read handler when queue_sel is out of bounds to signal the end of the queue list. - Add NULL pointer checks after get_virt_addr() calls in virtqueue descriptor/avail/used table setup to fail gracefully. - Initialize config.blk_size to SECTOR_BSIZE (512) in virtio-blk device init to match the guest's assertion. - Return -ENOMEM on kmalloc failure in the hvisor kernel module. - Guard against NULL vdev->dev pointer in virtio_mmio_read config access. Assisted by: DeepSeek V4
- Return error codes and close file descriptors after PTY operations (posix_openpt, grantpt, unlockpt) fail during initialization. - Enable ONLCR terminal flag so newline characters are automatically translated to carriage-return plus newline. - Convert LF to CRLF in the TX handler as a fallback for environments where the PTY master does not handle ONLCR. Assisted by: DeepSeek V4
Author
|
@Solicey 同学提出的错位问题,我目前在tool这一侧做了处理,所以暂时正常了,如果后期asterinas上游修复了,我们可以去掉这部分修改。 |
Author
|
网卡这里因为asterinas的设备初始化顺序有些问题,所以我修改了部分asterinas的源码才能注册识别。我会尝试不修改asterinas就能识别到网卡,尽量减少复现成本。如果实在有必要,再向asterinas上游提交issue |
Solicey
reviewed
Jun 6, 2026
Comment on lines
+184
to
+187
| // Multiboot support (NEW) | ||
| __u64 multiboot_info_paddr; | ||
| __u32 multiboot_enabled; | ||
|
|
Contributor
There was a problem hiding this comment.
As mentioned in hvisor's pr, multiboot_info_paddr and multiboot_enabled should be put inside arch_config
Solicey
reviewed
Jun 6, 2026
Comment on lines
+191
to
+207
| // Convert \n -> \r\n for proper terminal output. | ||
| // PTY master doesn't do ONLCR; we handle it here. | ||
| for (int i = 0; i < n; i++) { | ||
| char *p = iov[i].iov_base; | ||
| size_t remain = iov[i].iov_len; | ||
| char *start = p; | ||
| char *nl; | ||
| while (remain > 0 && (nl = memchr(start, '\n', remain)) != NULL) { | ||
| size_t pre = nl - start; | ||
| if (pre > 0) | ||
| write(dev->master_fd, start, pre); | ||
| write(dev->master_fd, "\r\n", 2); | ||
| start = nl + 1; | ||
| remain -= pre + 1; | ||
| } | ||
| if (remain > 0) | ||
| write(dev->master_fd, start, remain); |
Contributor
There was a problem hiding this comment.
I recently raised a pr to Asterinas. This is basically Asterinas's problem, thus I suggest changing your local Asterinas's code instead of hvisor-tool's code.
edb13a6 to
7d67eb8
Compare
- Add multiboot_info_paddr/multiboot_enabled to x86_64 arch_zone_config - Move multiboot fields from zone_config to arch_config (x86-specific) - Load boot_filepath binary with GPA-to-HPA offset translation - Store ELF entry point in kernel_entry_gpa for bootloader - Skip kernel_entry_gpa JSON parsing when multiboot is enabled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR for Multiboot2-based zone loading (required by Asterinas) and virtio
device robustness fixes. Complements the hvisor-side PR at
yydawx/hvisor#.
Changes
Multiboot2 Zone Loading (
tools/hvisor.c,include/zone_config.h)command line, initramfs module, and optional framebuffer tags
zone_configstruct withmultiboot_info_paddrandmultiboot_enabledfields; bumpCONFIG_MAGIC_VERSIONto 0x06Virtio Device Fixes (
tools/virtio/virtio.c)queue_selon MMIO write so the guest can correctlyprobe the number of queues by iterating queue_sel values
QUEUE_NUM_MAXread when queue_sel is out of boundsget_virt_addr()in virtqueuedescriptor, avail, and used table setup
config.blk_sizetoSECTOR_BSIZE(512) to match theguest's expected block size
Console Terminal Fix (
tools/virtio/devices/console/virtio_console.c)indentation when the PTY master does not handle ONLCR
failures instead of continuing with an invalid state
Verification
combination