Skip to content

cca: Instruction Abort and testing#3731

Open
Flgodd67 wants to merge 5 commits into
microsoft:mainfrom
Flgodd67:dev
Open

cca: Instruction Abort and testing#3731
Flgodd67 wants to merge 5 commits into
microsoft:mainfrom
Flgodd67:dev

Conversation

@Flgodd67

Copy link
Copy Markdown
Contributor
  • unit test added that causes an Instruction Abort by fetching from an address outside the PAR
  • unit test added that causes an Instruction Abort by fetching from an address with state RIPAS_EMPTY
  • unit test added that causes an Instruction Abort by fetching from an address with no permissions
  • added a HpfarEl2 structure in order to retrieve the fipa more conveniently. Added the getter function in CcaExit.
  • added ioctl in openVMM and kernel to get ipa state - hcl_rsi_ipa_state_read
  • adding a new location where the AArch64 tests can be placed: tmk/simple_tmk/src/aarch64. Keeping architecture specific code and tests grouped together
  • adding Instruction abort handling, displaying to the user the error reason with additional useful information about the plane exit
  • implementation for #[tmk_test(expected_failure)] macro. Tests marked as expected failures now pass when they fail or fault. Allows representation of intentional failure cases.

- unit test added that causes an Instruction Abort by fetching from an address
 outside the PAR
- unit test added that causes an Instruction Abort by fetching from an address
 with state RIPAS_EMPTY
- unit test added that causes an Instruction Abort by fetching from an address
 with no permissions
- added a HpfarEl2 structure in order to retrieve the fipa more conveniently.
 Added the getter function in CcaExit.
- added ioctl in openVMM and kernel to get ipa state - hcl_rsi_ipa_state_read
- adding a new location where the AArch64 tests can be placed:
 tmk/simple_tmk/src/aarch64.
 Keeping architecture specific code and tests grouped together
- adding Instruction abort handling, displaying to the user the error reason
 with additional useful information about the plane exit
- implementation for #[tmk_test(expected_failure)] macro.
 Tests marked as expected failures now pass when they fail or fault.
 Allows representation of intentional failure cases.
@Flgodd67 Flgodd67 requested a review from a team as a code owner June 12, 2026 13:47
Copilot AI review requested due to automatic review settings June 12, 2026 13:47
@github-actions github-actions Bot added the unsafe Related to unsafe code label Jun 12, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for “expected failure” tests in TMK and improves AArch64/CCA fault reporting by capturing instruction abort context (including IPA RIPAS state), while also extending AArch64 register definitions.

Changes:

  • Add a protocol/test-metadata flag (expected_failure) plumbed from TMK macros/core → protocol → VMM loader → VMM runner output.
  • Add CCA instruction-abort handling that computes FIPA, queries RIPAS state, and emits a structured fatal error.
  • Extend AArch64 definitions (HPFAR_EL2 bitfield; fix FaultStatusCode typo) and add AArch64 “expected failure” sample tests.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
vm/aarch64/aarch64defs/src/lib.rs Adds HPFAR_EL2 bitfield; fixes a FaultStatusCode typo.
tmk/tmk_vmm/src/run.rs Treats failing tests as success when marked expected_failure, and flags unexpected passes.
tmk/tmk_vmm/src/load.rs Loads expected_failure from protocol flags into TestInfo.
tmk/tmk_protocol/src/lib.rs Introduces flags in test descriptors and defines expected-failure flag constant.
tmk/tmk_macros/src/lib.rs Extends #[tmk_test] to accept expected_failure and forwards flags to core macro.
tmk/tmk_core/src/lib.rs Extends test descriptor and define_tmk_test! to carry flags.
tmk/simple_tmk/src/main.rs Adds AArch64 test module.
tmk/simple_tmk/src/aarch64/mod.rs Adds AArch64 tests marked expected_failure using global_asm fault triggers.
openhcl/virt_mshv_vtl/src/processor/cca/mod.rs Implements CCA InstructionAbort handling incl. FIPA + RIPAS state query and richer fatal errors.
openhcl/hcl/src/ioctl/cca.rs Adds RSI IPA-state-read ioctl wrapper and data struct.
openhcl/hcl/src/ioctl.rs Adds ioctl number and binding for “get IPA state”.
flowey/flowey_lib_hvlite/src/_jobs/local_install_cca_emu.rs Changes the Linux repo branch used for local CCA emu install.
Comments suppressed due to low confidence (1)

tmk/tmk_protocol/src/lib.rs:1

  • Adding a field to a #[repr(C)] protocol struct is an ABI/layout change. If older TMK binaries or VMMs might interact with newer counterparts, this needs explicit versioning/backward compatibility (e.g., a version field, using descriptor_length to gate reading flags, or placing future-proof reserved fields). As-is, mixed-version components can misinterpret layout and read incorrect data.
// Copyright (c) Microsoft Corporation.

Comment thread vm/aarch64/aarch64defs/src/lib.rs
Comment thread vm/aarch64/aarch64defs/src/lib.rs
Comment thread tmk/tmk_macros/src/lib.rs
Comment thread tmk/tmk_macros/src/lib.rs Outdated
Comment thread tmk/tmk_vmm/src/run.rs
Comment thread openhcl/virt_mshv_vtl/src/processor/cca/mod.rs
Comment thread openhcl/virt_mshv_vtl/src/processor/cca/mod.rs Outdated
Comment thread openhcl/virt_mshv_vtl/src/processor/cca/mod.rs
Comment thread openhcl/virt_mshv_vtl/src/processor/cca/mod.rs Outdated
Comment thread flowey/flowey_lib_hvlite/src/_jobs/local_install_cca_emu.rs Outdated
@Flgodd67

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree [company="Microsoft"]

@Flgodd67

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Microsoft"

Copilot AI review requested due to automatic review settings June 12, 2026 14:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

tmk/tmk_protocol/src/lib.rs:1

  • Adding flags changes the wire/ABI size of TestDescriptor64. If any existing TMK binaries or loaders assume the prior struct size, this can break enumeration/parsing. To maintain compatibility, consider introducing a versioned descriptor/header, or keeping the old descriptor and adding a new descriptor type (or a size field) so old/new producers and consumers can interoperate safely.
// Copyright (c) Microsoft Corporation.

Comment thread openhcl/virt_mshv_vtl/src/processor/cca/mod.rs
Comment thread openhcl/virt_mshv_vtl/src/processor/cca/mod.rs Outdated
Comment thread openhcl/hcl/src/ioctl.rs
Comment thread tmk/tmk_vmm/src/run.rs
Comment thread tmk/tmk_macros/src/lib.rs Outdated
Comment thread flowey/flowey_lib_hvlite/src/_jobs/local_install_cca_emu.rs Outdated
Copilot AI review requested due to automatic review settings June 12, 2026 14:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.

Comment thread openhcl/virt_mshv_vtl/src/processor/cca/mod.rs
Comment on lines +479 to +487
let mut plane_state = mshv_rsi_get_ipa_state {
fipa,
state: u64::MAX,
};
let _ = this
.ipa_state_read(GuestVtl::Vtl0, &mut plane_state)
.map_err(|_| Error::Hcl);

let reason = InstructionAbortReason::from(iss.ifsc());
Comment thread tmk/tmk_macros/src/lib.rs Outdated
GRANULE_PROTECTION_FAULT_LEVEL2 = 0b100110,
/// Valid only for instruction fault.
GRANULE_PROTECTION_FAULT_LEVE3 = 0b100111,
GRANULE_PROTECTION_FAULT_LEVEL3 = 0b100111,
Comment on lines +74 to +78
/// CCA:
#[repr(C)]
#[derive(Clone, Copy, Default)]
#[expect(missing_docs)]
pub struct mshv_rsi_get_ipa_state {
Comment on lines +218 to +226
pub fn cca_ipa_state_read(
&self,
vtl: GuestVtl,
state: &mut mshv_rsi_get_ipa_state,
) -> Result<(), Error> {
self.hcl
.rsi_get_ipa_state(vtl, state)
.map_err(|_| Error::InvalidRegisterValue)
}
@github-actions

Copy link
Copy Markdown

Comment thread tmk/tmk_protocol/src/lib.rs Outdated
Comment thread tmk/tmk_macros/src/lib.rs Outdated
let name = item.sig.ident.to_string();
let func = &item.sig.ident;

let flags = match attr.to_string().as_str() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We'll probably want this to be comma separated or something in the future to deal with multiple flags, but I think this is fine for now.

const AARCH64_ZERO_REGISTER_INDEX: u8 = 31;

#[derive(Debug, Clone, Copy)]
enum InstructionAbortReason {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should probably live in aarch64defs

Comment thread openhcl/virt_mshv_vtl/src/processor/cca/mod.rs Outdated
Copilot AI review requested due to automatic review settings June 15, 2026 13:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

tmk/tmk_protocol/src/lib.rs:1

  • The PR introduces TestFlags64, but TestDescriptor64 stores flags as a raw u64. That makes downstream usage error-prone (and already causes a compile issue in enumerate_tests). Prefer storing pub flags: TestFlags64 if it is layout-compatible for your wire format; otherwise, consider renaming to flags_bits: u64 and adding a dedicated accessor (e.g., fn flags(&self) -> TestFlags64) to centralize bit decoding.
// Copyright (c) Microsoft Corporation.

Comment thread tmk/tmk_vmm/src/load.rs
Comment on lines 176 to 180
pub struct TestInfo {
pub name: String,
pub index: u64,
pub expected_failure: bool,
}
Comment thread tmk/tmk_vmm/src/load.rs
Comment on lines 231 to 233
index: i as u64,
expected_failure: t.flags.expected_failure(),
});
Comment thread tmk/tmk_macros/src/lib.rs Outdated
Comment on lines +21 to +36
let flags = match attr.to_string().as_str() {
"" => quote! { ::tmk_protocol::TestFlags64::new() },
"expected_failure" => quote! { ::tmk_protocol::TestFlags64::new().with_expected_failure(true) },
attr => {
let msg = format!("unsupported tmk_test option: {attr}");
return quote! {
compile_error!(#msg);
#item
}
.into_token_stream()
.into();
}
};

quote! {
::tmk_core::define_tmk_test!(#name, #func);
::tmk_core::define_tmk_test!(#name, #func, #flags);
Comment on lines +479 to +487
let mut plane_state = mshv_rsi_get_ipa_state {
fipa,
state: u64::MAX,
};
let _ = this
.ipa_state_read(GuestVtl::Vtl0, &mut plane_state)
.map_err(|_| Error::Hcl);

let reason = InstructionAbortReason::from(iss.ifsc());
Comment on lines +469 to +474
if iss.fnv() {
tracing::warn!("CCA InstructionAbort: FAR_EL2 is not valid");
return Err(
dev.fatal_error(CcaUnsupportedExit::ExitReason(0).into())
);
}
// The guest Linux kernel (with cca/plane driver) hasn't been upstreamed yet, fetch it from our private repo
const PLANE0_LINUX_REPO: &str = "https://github.com/jiong-microsoft/OHCL-Linux-Kernel.git";
const PLANE0_LINUX_BRANCH: &str = "cca-dev";
const PLANE0_LINUX_BRANCH: &str = "cca-dev-ben";
Copilot AI review requested due to automatic review settings June 15, 2026 13:36
@Flgodd67 Flgodd67 force-pushed the dev branch 2 times, most recently from ca81903 to e7990bc Compare June 15, 2026 13:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 7 comments.

Comments suppressed due to low confidence (1)

tmk/tmk_core/src/lib.rs:1

  • The 2-arg define_tmk_test! arm forwards $flags as the integer literal 0, but TestDescriptor.flags is a TestFlags64. This is likely a type mismatch and will fail to compile (or silently pick an unintended conversion if one exists). Use a proper default value of the flag type (e.g., TestFlags64::new() or an explicit from_bits(0) constructor) when forwarding.
// Copyright (c) Microsoft Corporation.


mod prelude;

mod aarch64;
Comment thread openhcl/hcl/src/ioctl.rs
Comment on lines +621 to +627
// CCA: Get the RIPAS state of an ipa
ioctl_read!(
hcl_rsi_ipa_state_read,
MSHV_IOCTL,
MSHV_VTL_RSI_GET_IPA_STATE,
cca::mshv_rsi_get_ipa_state
);
Comment on lines +479 to +485
let mut plane_state = mshv_rsi_get_ipa_state {
fipa,
state: u64::MAX,
};
let _ = this
.ipa_state_read(GuestVtl::Vtl0, &mut plane_state)
.map_err(|_| Error::Hcl);
Comment on lines +469 to +474
if iss.fnv() {
tracing::warn!("CCA InstructionAbort: FAR_EL2 is not valid");
return Err(
dev.fatal_error(CcaUnsupportedExit::ExitReason(0).into())
);
}
Comment thread tmk/tmk_macros/src/lib.rs Outdated
Comment on lines +21 to +33
let flags = match attr.to_string().as_str() {
"" => quote! { ::tmk_protocol::TestFlags64::new() },
"expected_failure" => quote! { ::tmk_protocol::TestFlags64::new().with_expected_failure(true) },
attr => {
let msg = format!("unsupported tmk_test option: {attr}");
return quote! {
compile_error!(#msg);
#item
}
.into_token_stream()
.into();
}
};
Comment thread tmk/tmk_vmm/src/run.rs
Comment on lines +311 to +319
(TestResult::Failed, true) => {
tracing::info!(
target: "test",
name = test.name,
expected_failure = true,
reason = "explicit failure",
"test passed"
);
}
Comment on lines +500 to +503
let _plane = match vtl {
GuestVtl::Vtl0 => 1,
_ => return Err(HvError::InvalidVtlState),
};
Copilot AI review requested due to automatic review settings June 15, 2026 13:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 7 comments.

Comment thread tmk/tmk_core/src/lib.rs
Comment on lines 146 to +150
macro_rules! define_tmk_test {
($name:expr, $func:ident) => {
$crate::define_tmk_test!($name, $func, 0);
};
($name:expr, $func:ident, $flags:expr) => {
Comment thread tmk/tmk_macros/src/lib.rs Outdated
Comment on lines +16 to +25
pub fn tmk_test(attr: TokenStream, item: TokenStream) -> TokenStream {
let item = syn::parse_macro_input!(item as syn::ItemFn);
let name = item.sig.ident.to_string();
let func = &item.sig.ident;

let flags = match attr.to_string().as_str() {
"" => quote! { ::tmk_protocol::TestFlags64::new() },
"expected_failure" => quote! { ::tmk_protocol::TestFlags64::new().with_expected_failure(true) },
attr => {
let msg = format!("unsupported tmk_test option: {attr}");
Comment thread tmk/tmk_vmm/src/run.rs
Comment on lines +311 to +319
(TestResult::Failed, true) => {
tracing::info!(
target: "test",
name = test.name,
expected_failure = true,
reason = "explicit failure",
"test passed"
);
}
Comment on lines +469 to +487
if iss.fnv() {
tracing::warn!("CCA InstructionAbort: FAR_EL2 is not valid");
return Err(
dev.fatal_error(CcaUnsupportedExit::ExitReason(0).into())
);
}

let far = cca_exit.far_el2();
let hpfar = cca_exit.hpfar_el2();
let fipa = (hpfar.fipa() << 12) | (far & 0xfff);
let mut plane_state = mshv_rsi_get_ipa_state {
fipa,
state: u64::MAX,
};
let _ = this
.ipa_state_read(GuestVtl::Vtl0, &mut plane_state)
.map_err(|_| Error::Hcl);

let reason = InstructionAbortReason::from(iss.ifsc());
Comment on lines +217 to +226
/// Get the ipa ripas state from the RMM
pub fn cca_ipa_state_read(
&self,
vtl: GuestVtl,
state: &mut mshv_rsi_get_ipa_state,
) -> Result<(), Error> {
self.hcl
.rsi_get_ipa_state(vtl, state)
.map_err(|_| Error::InvalidRegisterValue)
}
Comment on lines +500 to +503
let _plane = match vtl {
GuestVtl::Vtl0 => 1,
_ => return Err(HvError::InvalidVtlState),
};
// The guest Linux kernel (with cca/plane driver) hasn't been upstreamed yet, fetch it from our private repo
const PLANE0_LINUX_REPO: &str = "https://github.com/jiong-microsoft/OHCL-Linux-Kernel.git";
const PLANE0_LINUX_BRANCH: &str = "cca-dev";
const PLANE0_LINUX_BRANCH: &str = "cca-dev-ben";
Copilot AI review requested due to automatic review settings June 15, 2026 14:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 7 comments.

Comment thread tmk/tmk_core/src/lib.rs
Comment on lines 146 to +150
macro_rules! define_tmk_test {
($name:expr, $func:ident) => {
$crate::define_tmk_test!($name, $func, 0);
};
($name:expr, $func:ident, $flags:expr) => {
Comment thread tmk/tmk_macros/src/lib.rs Outdated
Comment on lines +16 to +35
pub fn tmk_test(attr: TokenStream, item: TokenStream) -> TokenStream {
let item = syn::parse_macro_input!(item as syn::ItemFn);
let name = item.sig.ident.to_string();
let func = &item.sig.ident;

let flags = match attr.to_string().as_str() {
"" => quote! { ::tmk_protocol::TestFlags64::new() },
"expected_failure" => {
quote! { ::tmk_protocol::TestFlags64::new().with_expected_failure(true) }
}
attr => {
let msg = format!("unsupported tmk_test option: {attr}");
return quote! {
compile_error!(#msg);
#item
}
.into_token_stream()
.into();
}
};
Comment on lines +479 to +486
let mut plane_state = mshv_rsi_get_ipa_state {
fipa,
state: u64::MAX,
};
let _ = this
.ipa_state_read(GuestVtl::Vtl0, &mut plane_state)
.map_err(|_| Error::Hcl);

Comment on lines +469 to +478
if iss.fnv() {
tracing::warn!("CCA InstructionAbort: FAR_EL2 is not valid");
return Err(
dev.fatal_error(CcaUnsupportedExit::ExitReason(0).into())
);
}

let far = cca_exit.far_el2();
let hpfar = cca_exit.hpfar_el2();
let fipa = (hpfar.fipa() << 12) | (far & 0xfff);
Comment on lines +217 to +226
/// Get the ipa ripas state from the RMM
pub fn cca_ipa_state_read(
&self,
vtl: GuestVtl,
state: &mut mshv_rsi_get_ipa_state,
) -> Result<(), Error> {
self.hcl
.rsi_get_ipa_state(vtl, state)
.map_err(|_| Error::InvalidRegisterValue)
}
Comment thread tmk/tmk_vmm/src/run.rs
Comment on lines +311 to +319
(TestResult::Failed, true) => {
tracing::info!(
target: "test",
name = test.name,
expected_failure = true,
reason = "explicit failure",
"test passed"
);
}
Comment thread tmk/tmk_vmm/src/run.rs
Comment on lines +338 to +355
(
TestResult::Faulted {
vp_index,
reason,
regs,
},
true,
) => {
tracing::info!(
target: "test",
name = test.name,
expected_failure = true,
vp_index = vp_index.index(),
reason,
regs = format_args!("{:#x?}", regs),
"test passed"
);
}
Copilot AI review requested due to automatic review settings June 15, 2026 14:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 9 comments.

Comment thread vm/aarch64/aarch64defs/src/lib.rs Outdated
}

#[derive(Debug, Clone, Copy)]
enum InstructionAbortReason {
Comment on lines +1042 to +1044
FaultStatusCode::GRANULE_PROTECTION_FAULT_LEVEL_NEG => {
Self::GranuleProtectionFaultLevelNeg1
}
Comment on lines +187 to +195
pub struct HpfarEl2 {
#[bits(4)]
pub res0: u8,
#[bits(44)]
pub fipa: u64,
#[bits(15)]
pub res1: u32,
pub ns: bool,
}
Comment thread tmk/tmk_core/src/lib.rs
Comment on lines 146 to +150
macro_rules! define_tmk_test {
($name:expr, $func:ident) => {
$crate::define_tmk_test!($name, $func, 0);
};
($name:expr, $func:ident, $flags:expr) => {
Comment thread tmk/tmk_macros/src/lib.rs Outdated
Comment on lines +21 to +26
let flags = match attr.to_string().as_str() {
"" => quote! { ::tmk_protocol::TestFlags64::new() },
"expected_failure" => {
quote! { ::tmk_protocol::TestFlags64::new().with_expected_failure(true) }
}
attr => {
Comment on lines +377 to +382
if iss.fnv() {
tracing::warn!("CCA InstructionAbort: FAR_EL2 is not valid");
return Err(
dev.fatal_error(CcaUnsupportedExit::ExitReason(0).into())
);
}
Comment on lines +391 to +393
let _ = this
.ipa_state_read(GuestVtl::Vtl0, &mut plane_state)
.map_err(|_| Error::Hcl);
elr_el2: u64,
far_el2: u64,
fipa: u64,
fipa_state: u8,
// The guest Linux kernel (with cca/plane driver) hasn't been upstreamed yet, fetch it from our private repo
const PLANE0_LINUX_REPO: &str = "https://github.com/jiong-microsoft/OHCL-Linux-Kernel.git";
const PLANE0_LINUX_BRANCH: &str = "cca-dev";
const PLANE0_LINUX_BRANCH: &str = "cca-dev-ben";
removing warning and going straight to err in InstructionAbort match
in run_vp
Copilot AI review requested due to automatic review settings June 15, 2026 14:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

tmk/tmk_core/src/lib.rs:1

  • The 2-arg define_tmk_test! arm forwards $flags as 0, but TestDescriptor::flags is TestFlags64, so this is very likely a type mismatch at compile time (unless an explicit conversion exists). Use a TestFlags64 value as the default (e.g., TestFlags64::new() or an explicit from_bits(0) constructor) so legacy invocations compile correctly.
// Copyright (c) Microsoft Corporation.

Comment thread tmk/tmk_macros/src/lib.rs Outdated
Comment on lines +16 to +35
pub fn tmk_test(attr: TokenStream, item: TokenStream) -> TokenStream {
let item = syn::parse_macro_input!(item as syn::ItemFn);
let name = item.sig.ident.to_string();
let func = &item.sig.ident;

let flags = match attr.to_string().as_str() {
"" => quote! { ::tmk_protocol::TestFlags64::new() },
"expected_failure" => {
quote! { ::tmk_protocol::TestFlags64::new().with_expected_failure(true) }
}
attr => {
let msg = format!("unsupported tmk_test option: {attr}");
return quote! {
compile_error!(#msg);
#item
}
.into_token_stream()
.into();
}
};
Comment on lines +374 to +408
let iss = IssInstructionAbort::from_bits(esr_el2.iss());

if iss.fnv() {
tracing::warn!("CCA InstructionAbort: FAR_EL2 is not valid");
return Err(
dev.fatal_error(CcaUnsupportedExit::ExitReason(0).into())
);
}

let far = cca_exit.far_el2();
let hpfar = cca_exit.hpfar_el2();
let fipa = (hpfar.fipa() << 12) | (far & 0xfff);
let mut plane_state = mshv_rsi_get_ipa_state {
fipa,
state: u64::MAX,
};
let _ = this
.ipa_state_read(GuestVtl::Vtl0, &mut plane_state)
.map_err(|_| Error::Hcl);

let reason = InstructionAbortReason::from(iss.ifsc());
tracing::warn!(
esr_el2 = cca_exit.0.esr_el2,
elr_el2 = cca_exit.elr_el2(),
far_el2 = cca_exit.far_el2(),
fipa = fipa,
fipa_state = plane_state.state as u8,
ifsc = iss.ifsc().0,
?reason,
far_not_valid = iss.fnv(),
"CCA instruction abort"
);
return Err(dev.fatal_error(
CcaUnsupportedExit::InstructionAbort {
esr_el2: cca_exit.0.esr_el2,
Comment thread openhcl/hcl/src/ioctl.rs
Comment on lines +621 to +627
// CCA: Get the RIPAS state of an ipa
ioctl_read!(
hcl_rsi_ipa_state_read,
MSHV_IOCTL,
MSHV_VTL_RSI_GET_IPA_STATE,
cca::mshv_rsi_get_ipa_state
);
Comment on lines +217 to +226
/// Get the ipa ripas state from the RMM
pub fn cca_ipa_state_read(
&self,
vtl: GuestVtl,
state: &mut mshv_rsi_get_ipa_state,
) -> Result<(), Error> {
self.hcl
.rsi_get_ipa_state(vtl, state)
.map_err(|_| Error::InvalidRegisterValue)
}
// The guest Linux kernel (with cca/plane driver) hasn't been upstreamed yet, fetch it from our private repo
const PLANE0_LINUX_REPO: &str = "https://github.com/jiong-microsoft/OHCL-Linux-Kernel.git";
const PLANE0_LINUX_BRANCH: &str = "cca-dev";
const PLANE0_LINUX_BRANCH: &str = "cca-dev-ben";
@github-actions

Copy link
Copy Markdown

@smalis-msft

Copy link
Copy Markdown
Contributor

Looks like the test is failing, and copilot has a lot of good feedback.

Copilot AI review requested due to automatic review settings June 16, 2026 15:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 5 comments.

Comment thread tmk/tmk_core/src/lib.rs Outdated
Comment thread tmk/tmk_macros/src/lib.rs Outdated
Comment on lines +386 to +392
let mut plane_state = mshv_rsi_get_ipa_state {
fipa,
state: u64::MAX,
};
let _ = this
.ipa_state_read(GuestVtl::Vtl0, &mut plane_state)
.map_err(|_| Error::Hcl);
Comment thread openhcl/virt_mshv_vtl/src/processor/cca/mod.rs
Comment thread tmk/tmk_core/src/lib.rs Outdated
…sts can be compiled or not

making the aarch64 specific tests linux only using a cfg for now
changes to tmk_vmm test macros parsing
changes to error reporting in Instruction Abort handling
changing hcl_rsi_ipa_state_read from ioctl_read to ioctl_readwrite
Copilot AI review requested due to automatic review settings June 18, 2026 14:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 6 comments.

Comment on lines +384 to +388
fipa: 0,
fipa_state: u8::MAX,
ifsc: iss.ifsc().0,
reason: InstructionAbortReason::Unknown,
far_not_valid: iss.fnv(),
Comment thread tmk/tmk_vmm/src/run.rs
name = test.name,
expected_failure = true,
reason = "explicit failure",
"test passed"
Comment thread tmk/tmk_vmm/src/run.rs
vp_index = vp_index.index(),
reason,
regs = format_args!("{:#x?}", regs),
"test passed"
Comment on lines +188 to +191
#[bits(4)]
pub res0: u8,
#[bits(44)]
pub fipa: u64,
Comment on lines +192 to +194
#[bits(15)]
pub res1: u32,
pub ns: bool,
Comment on lines +217 to +226
/// Get the ipa ripas state from the RMM
pub fn cca_ipa_state_read(
&self,
vtl: GuestVtl,
state: &mut mshv_rsi_get_ipa_state,
) -> Result<(), Error> {
self.hcl
.rsi_get_ipa_state(vtl, state)
.map_err(|_| Error::InvalidRegisterValue)
}
@github-actions

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants