Skip to content

fix(whp): respect IO port access size in IoPortAccess exit handler#1387

Merged
jprendes merged 1 commit intohyperlight-dev:mainfrom
danbugs:fix/whp-io-access-size
Apr 17, 2026
Merged

fix(whp): respect IO port access size in IoPortAccess exit handler#1387
jprendes merged 1 commit intohyperlight-dev:mainfrom
danbugs:fix/whp-io-access-size

Conversation

@danbugs
Copy link
Copy Markdown
Contributor

@danbugs danbugs commented Apr 17, 2026

Summary

  • The WHP IoPortAccess exit handler was returning the full 8 bytes of RAX regardless of the guest's operand width
  • For outb (1-byte writes like serial console output), this produced 8 bytes per character, resulting in garbled multi-byte sequences in the host output
  • Fix: extract AccessSize from IoPortAccess.AccessInfo (bits 1..3) and truncate the returned data vec to the actual operand width (1 for outb, 2 for outw, 4 for outl)

@danbugs danbugs added the kind/bugfix For PRs that fix bugs label Apr 17, 2026
@danbugs danbugs force-pushed the fix/whp-io-access-size branch 2 times, most recently from b95ed3c to 3602124 Compare April 17, 2026 07:25
@dblnz dblnz force-pushed the fix/whp-io-access-size branch from 3602124 to be24b8b Compare April 17, 2026 08:44
jprendes
jprendes previously approved these changes Apr 17, 2026
Copy link
Copy Markdown
Contributor

@jprendes jprendes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

The WHP IoPortAccess exit handler was returning the full 8 bytes of
RAX regardless of the guest's operand width. For outb (1-byte writes
like serial port console output), this produced 8 bytes per character,
resulting in garbled multi-byte sequences in the host's eprint! output.

Extract AccessSize from IoPortAccess.AccessInfo (bits 1..3) and
truncate the returned data vec to the actual operand width (1 for
outb, 2 for outw, 4 for outl).

Signed-off-by: danbugs <danilochiarlone@gmail.com>
@jprendes jprendes enabled auto-merge (squash) April 17, 2026 12:24
@jprendes jprendes merged commit 2b803de into hyperlight-dev:main Apr 17, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bugfix For PRs that fix bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants