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

CVM: refactor ohcl/ovmm emulator for flexible register retrieval and update #482

Merged
merged 46 commits into from
Jan 16, 2025

Conversation

babayet2
Copy link
Contributor

@babayet2 babayet2 commented Dec 14, 2024

Motivation

  1. When an instruction is emulated for a CVM guest, the full guest register state is retrieved. For TDX, this dispatches an expensive TDCALL to read each segment register regardless of whether it is necessary for the emulation.
  2. The existing emulator code allowed arbitrary guest registers to be written: if the register is considered immutable, the update is silently dropped.

Changes

  • The emulator frontend no longer has a guest state struct. Instead, the frontend calls functions to read and update register state.
  • Each backend defines and implements its own register state struct. On a register read/write, the backend has the flexibility to choose whether a register should be read from this struct, or pass through directly to the backing. With the exception of segment registers for the TDX backing, the existing behavior has been preserved, e.g. reading XMM registers passes through to the backing, and GPs are read from the state struct.

@smmalis37
Copy link
Contributor

Take a look at #478 too, lets make sure we don't conflict too hard.

@smalis-msft
Copy link
Contributor

Overall this looks really nice, and a great step in the right direction. Thanks!

@babayet2
Copy link
Contributor Author

@smalis-msft rebase done. could you kick off another CI run to make sure we're green?

we're trying to get this in before the freeze, do you expect we'll need another reviewer? quick reminder, we cannot test ARM/AMD, so we'll need help on the MSFT side for that validation

@smalis-msft
Copy link
Contributor

smalis-msft commented Jan 15, 2025

CI started, a little bit more feedback posted, and I'll get started on SNP testing. We don't need another reviewer.

@smalis-msft
Copy link
Contributor

Also note that in order for this to get into 1.5 it will need to be cherry-picked to the release/2411 branch after merging, which may involve more merge conflicts.

@smalis-msft smalis-msft added the backport_2411 Change should be backported to the release/2411 branch label Jan 15, 2025
@smalis-msft smalis-msft self-assigned this Jan 15, 2025
@babayet2 babayet2 changed the title cvm: Refactor ohcl/ovmm emulator for flexible register retrieval and update CVM: refactor ohcl/ovmm emulator for flexible register retrieval and update Jan 16, 2025
@babayet2
Copy link
Contributor Author

@smalis-msft really appreciate all of the detailed and speedy reviews, they have been incredibly helpful

I think we should pass all CI gates after another run is kicked off, and tdx cvms are booting. anything else I should be doing to get this merged?

@smalis-msft
Copy link
Contributor

LGTM! I still need to some more testing but if everything looks good on my end I'll merge it.

@smalis-msft smalis-msft requested a review from a team as a code owner January 16, 2025 17:09
@smalis-msft smalis-msft enabled auto-merge (squash) January 16, 2025 17:09
@smalis-msft
Copy link
Contributor

Tested on SNP, everything looks good.

@smalis-msft smalis-msft removed the backport_2411 Change should be backported to the release/2411 branch label Jan 16, 2025
@smalis-msft
Copy link
Contributor

Given that this change is focused solely on perf, and not functionality, I'm not sure it makes sense to deal with taking such a large change to 1.5. If it's really desired though you'll need to send up a PR with it cherry-picked onto release/2411. I can test SNP on that as well.

@smalis-msft smalis-msft merged commit ae9351b into microsoft:main Jan 16, 2025
25 checks passed
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.

4 participants