Skip to content

Add translated embedder syscall hook#69

Open
doanbaotrung wants to merge 1 commit into
sysprog21:mainfrom
open-sources-port:feature/x86_64-guest-counterpart-AArch64-hvc6
Open

Add translated embedder syscall hook#69
doanbaotrung wants to merge 1 commit into
sysprog21:mainfrom
open-sources-port:feature/x86_64-guest-counterpart-AArch64-hvc6

Conversation

@doanbaotrung
Copy link
Copy Markdown

@doanbaotrung doanbaotrung commented Jun 4, 2026

Translated x86_64 guests cannot issue the AArch64 HVC instruction used by the existing embedder extension ABI. This prevents those guests from using embedder-provided services such as the graphics bridge.

Add a private elfuse pseudo-syscall as the translated guest counterpart to HVC 6. The syscall keeps the existing hvc6_handler ABI instead of adding a second embedder callback path, so native and translated guests can share the same dispatch logic.

Use syscall number 999 as an internal ABI value between the translated guest shim and elfuse. This is not a Linux syscall number. It is chosen outside the current generic Linux syscall range to avoid colliding with normal guest syscalls, but it is not reserved by Linux and must remain private to elfuse.

If no embedder handler is registered, dispatch falls back to normal syscall handling.


Summary by cubic

Adds a private elfuse pseudo-syscall so translated x86_64 guests can call the embedder ABI equivalent to AArch64 HVC 6, enabling features like the graphics bridge. Reuses the existing hvc6_handler so native and translated guests share the same dispatch.

  • New Features
    • Introduces ELFUSE_NR_EMBEDDER_HVC6 (999) as a private pseudo-syscall; not a Linux syscall.
    • Build sets the number in mk/config.mk and passes -DELFUSE_NR_EMBEDDER_HVC6=$(ELFUSE_NR_EMBEDDER_HVC6), allowing overrides.
    • Syscall hook: if a handler is registered, reads X0 (call id) and X1 (GVA of uint64_t args[8]); on read failure returns -EFAULT; else calls hvc6_handler. If no handler, falls back to normal syscall handling.

Written for commit 262954b. Summary will update on new commits.

Review in cubic

cubic-dev-ai[bot]

This comment was marked as resolved.

@doanbaotrung doanbaotrung force-pushed the feature/x86_64-guest-counterpart-AArch64-hvc6 branch from 8d14f8a to 388b41f Compare June 4, 2026 15:35
@doanbaotrung
Copy link
Copy Markdown
Author

Hi @Max042004
Please help to review this

jserv

This comment was marked as outdated.

@doanbaotrung doanbaotrung changed the title Intercept a custom system call number (999) as the x86_64 guest counterpart Intercept a custom system call number 999 as the x86_64 guest counterpart Jun 5, 2026
@doanbaotrung doanbaotrung changed the title Intercept a custom system call number 999 as the x86_64 guest counterpart Intercept a custom system call as the x86_64 guest counterpart Jun 5, 2026
@doanbaotrung doanbaotrung requested a review from jserv June 5, 2026 03:02
@doanbaotrung doanbaotrung changed the title Intercept a custom system call as the x86_64 guest counterpart Intercept x86_64 embedder syscalls Jun 5, 2026
@sysprog21 sysprog21 deleted a comment from doanbaotrung Jun 5, 2026
Comment thread src/syscall/syscall.c Outdated
@doanbaotrung doanbaotrung force-pushed the feature/x86_64-guest-counterpart-AArch64-hvc6 branch 2 times, most recently from ba57d4e to a9ff5d7 Compare June 5, 2026 04:31
@doanbaotrung doanbaotrung requested a review from jserv June 5, 2026 04:44
Copy link
Copy Markdown
Contributor

@jserv jserv left a comment

Choose a reason for hiding this comment

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

Check https://cbea.ms/git-commit/ carefully and enforce the rules for informative git commit messages.
You MUST address the motivations and considerations.

@doanbaotrung doanbaotrung force-pushed the feature/x86_64-guest-counterpart-AArch64-hvc6 branch from a9ff5d7 to 645a6e4 Compare June 5, 2026 08:47
@doanbaotrung doanbaotrung changed the title Intercept x86_64 embedder syscalls Add translated embedder syscall hook Jun 5, 2026
@doanbaotrung doanbaotrung force-pushed the feature/x86_64-guest-counterpart-AArch64-hvc6 branch from 645a6e4 to 18ae471 Compare June 5, 2026 08:54
Comment thread src/syscall/abi.h Outdated
Translated x86_64 guests cannot issue the AArch64 HVC instruction used by the existing embedder extension ABI. This prevents those guests from using embedder-provided services such as the graphics bridge.

Add a private elfuse pseudo-syscall as the translated guest counterpart to HVC 6. The syscall keeps the existing hvc6_handler ABI instead of adding a second embedder callback path, so native and translated guests can share the same dispatch logic.

Use syscall number 999 as an internal ABI value between the translated guest shim and elfuse. This is not a Linux syscall number. It is chosen outside the current generic Linux syscall range to avoid colliding with normal guest syscalls, but it is not reserved by Linux and must remain private to elfuse.

If no embedder handler is registered, dispatch falls back to normal syscall handling.
@doanbaotrung doanbaotrung force-pushed the feature/x86_64-guest-counterpart-AArch64-hvc6 branch from 18ae471 to 262954b Compare June 5, 2026 09:39
@sysprog21 sysprog21 deleted a comment from doanbaotrung Jun 5, 2026
@jserv jserv requested a review from Max042004 June 5, 2026 09:50
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 this pull request may close these issues.

2 participants