Skip to content

Add hvc 6 yield runtime hook#42

Merged
jserv merged 1 commit into
sysprog21:mainfrom
open-sources-port:feature/hvc6-yield
May 25, 2026
Merged

Add hvc 6 yield runtime hook#42
jserv merged 1 commit into
sysprog21:mainfrom
open-sources-port:feature/hvc6-yield

Conversation

@doanbaotrung
Copy link
Copy Markdown

@doanbaotrung doanbaotrung commented May 25, 2026

Cooperative yield request from the HVC 6 handler. When set, the current guest run loop exits after the handler returns and control is yielded back to the host.


Summary by cubic

Add a cooperative yield path for HVC 6 so the handler can request the vCPU run loop to exit and return control to the host right after it returns. Introduces a thread-local runtime hook via proc_request_hvc6_yield() that vcpu_run_loop clears before the HVC 6 handler and checks after; when set, the loop stops immediately after the handler returns.

Written for commit 42d897a. Summary will update on new commits. Review in cubic

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

@jserv jserv requested a review from Max042004 May 25, 2026 05:10
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.

Chec https://cbea.ms/git-commit/ carefully and enforce the rules accordingly.

@doanbaotrung doanbaotrung changed the title Add hvc6_yield_requested runtime hook Add hvc 6 yield runtime hook May 25, 2026
@doanbaotrung
Copy link
Copy Markdown
Author

Updated the mesage

@jserv
Copy link
Copy Markdown
Contributor

jserv commented May 25, 2026

I defer to @Max042004 for confirmation.

@Max042004
Copy link
Copy Markdown
Collaborator

Max042004 commented May 25, 2026

It may happen data race.
guest_t is shared between thread. If two thread are in the HVC 6 path together, thread B can read+clear the flag that thread A set — so B exits without having requested a yield.

@doanbaotrung
Copy link
Copy Markdown
Author

Dear @Max042004

I replaced the shared guest_t flag with a thread-local yield request.

proc_request_hvc6_yield() now sets a TLS flag on the host thread currently executing the HVC 6 handler. vcpu_run_loop() clears that TLS flag before invoking the handler and consumes it immediately after the handler returns, so concurrent HVC 6 handlers on other vCPUs cannot observe or clear this thread's request.

@Max042004
Copy link
Copy Markdown
Collaborator

  if (hvc6_yield_requested) {
- hvc6_yield_requested = false;             
  running = false;

you can consider this change. But it is fine to remain current commit.

LGTM

@doanbaotrung
Copy link
Copy Markdown
Author

Noted. Please allow me to keep it to avoids a mistake if future code ever checks the flag outside this exact handler path

@jserv jserv merged commit 1bb18e9 into sysprog21:main May 25, 2026
4 checks passed
@jserv
Copy link
Copy Markdown
Contributor

jserv commented May 25, 2026

Thank @doanbaotrung for contributing!

@doanbaotrung doanbaotrung deleted the feature/hvc6-yield branch May 25, 2026 14: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.

3 participants