Skip to content

snp: inject event when ext_int is valid #1347

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

romank-msft
Copy link
Contributor

The existing implementation does debug_assert! which is not precise. The legacy HCL injects events when ext_int is valid, doesn't assert. ext_int doesn't have to be always valid when VMSA is busy.

Do event injection when ext_int is valid, don't do otherwise.

Additional value:

  • use open_enum in the existing defs,
  • add the constant for NMI,
  • replace magic numbers with constants

The cexisting implementation does `debug_assert!` which is not
precise. The legacy HCL injects events when `ext_int` is valid,
doesn't assert. `ext_int` doesn't have to be always valid when
VMSA is busy.

Do event injection when ext_int is valid, don't do otherwise.

Additional value:
* use `open_enum` in the existing defs,
* add the constant for NMI,
* replace magic numbers with constants
@romank-msft romank-msft requested a review from a team as a code owner May 12, 2025 22:31
@@ -415,6 +415,7 @@ open_enum! {
pub enum Exception: u8 {
DIVIDE_ERROR = 0x0,
DEBUG = 0x1,
NMI = 0x2,
Copy link
Member

Choose a reason for hiding this comment

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

Let's be careful here. Although NMIs use vector 2, they are not exceptions. I would leave this out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh, I see that now! Thanks!!

#[bitfield(u64)]
#[derive(IntoBytes, Immutable, KnownLayout, FromBytes, PartialEq, Eq)]
pub struct SevEventInjectInfo {
pub vector: u8,
#[bits(8)]
pub vector: Exception,
Copy link
Member

Choose a reason for hiding this comment

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

I'd leave this as u8 since this can be used to inject non-exceptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed 100%! I'll work on this more after completing more of the main quest :)

@romank-msft romank-msft marked this pull request as draft May 13, 2025 16:14
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