Skip to content

Conversation

balajimc55
Copy link

@balajimc55 balajimc55 commented Nov 22, 2024

pub vtl_ret_action_size: u32,
pub flags: u32,
pub scan_proxy_irr: u8,
pub scan_device_irr: u8,
Copy link
Member

Choose a reason for hiding this comment

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

we'd want these in the tdx specific portion of the struct, i think.

/// Update vtl0 device interrupt map
pub fn set_device_irr_map(&self, remapped_vector: u8, target_vector: u8) {
// update target(vtl0) to remaped(vtl2) vector mapping
let device_irr_remapped_vector = unsafe { &*(addr_of!(self.device_irr_target_to_remapped_vector[target_vector as usize]).cast::<AtomicU8>()) };
Copy link
Member

Choose a reason for hiding this comment

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

this unsafe will not fly - either declare it as atomic u8 upfront or we may need a different kind of data structure if we do expect multiple vps to access this, which is possible

Copy link
Author

Choose a reason for hiding this comment

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

Agreed. do you have any suggestions on where the vector mapping information can be stored? Currently I am storing it in the Hcl struct.

We want to write to this structure from the intercept routine for retarget_interrupt hypercall but this does not have mutable access to Hcl structure.

Copy link
Member

Choose a reason for hiding this comment

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

this is shared partition wide, right? let me think about it.

Copy link
Author

Choose a reason for hiding this comment

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

Correct. It is partition wide. Update to the struct is needed only during device initialization but needs to be read during every device interrupt delivery.

Copy link
Member

Choose a reason for hiding this comment

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

Is there a way we can reuse the mechanisms for proxy_irr filtering, or would that not work? As long as we update the mapping table on each CPU before we issue the retarget hypercall, we should be fine right?

@github-actions github-actions bot added the Guide label Jan 28, 2025
@balajimc55 balajimc55 force-pushed the vtl0-iommu-posted-interrupt-relay branch from 3428524 to 74f9200 Compare January 28, 2025 20:41
//
// This improves performance for VTL0 owned devices by avoiding exits to VMM for device
// interrupt delivery.
let use_posted_redirection = match isolation {
Copy link
Member

Choose a reason for hiding this comment

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

i thought we read the enlightenments already somewhere else?

Copy link
Author

Choose a reason for hiding this comment

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

I found only one other query to read the hv enlightenment cpuid leaf, I pushed a cleanup that combines both queries to a single cpuid call.

entry,
redirected_vector,
multicast,
target_processors,
Copy link
Member

Choose a reason for hiding this comment

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

do we need to tell the kernel which processors are going to get this interrupt, or will the mapping table be global?

Copy link
Author

Choose a reason for hiding this comment

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

The mapping table (maintained in kernel) is only for VTL2 vector to VTL0 vector translation and that doesn't need to be processor specific.
Tagging @ricardon for any opens on kernel changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, the table is global.

@chris-oo
Copy link
Member

Can you rebase this change onto the latest main so I can review again?

@balajimc55
Copy link
Author

Can you rebase this change onto the latest main so I can review again?

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants