@@ -1431,7 +1431,7 @@ impl MshvHvcall {
1431
1431
/// Get a single VP register for the given VTL via hypercall. Only a select
1432
1432
/// set of registers are supported; others will cause a panic.
1433
1433
#[ cfg( guest_arch = "x86_64" ) ]
1434
- pub fn get_vp_register_for_vtl (
1434
+ fn get_vp_register_for_vtl (
1435
1435
& self ,
1436
1436
vtl : HvInputVtl ,
1437
1437
name : HvX64RegisterName ,
@@ -1473,7 +1473,7 @@ impl MshvHvcall {
1473
1473
/// Get a single VP register for the given VTL via hypercall. Only a select
1474
1474
/// set of registers are supported; others will cause a panic.
1475
1475
#[ cfg( guest_arch = "aarch64" ) ]
1476
- pub fn get_vp_register_for_vtl (
1476
+ fn get_vp_register_for_vtl (
1477
1477
& self ,
1478
1478
vtl : HvInputVtl ,
1479
1479
name : HvArm64RegisterName ,
@@ -1796,9 +1796,7 @@ impl<'a, T: Backing<'a>> ProcessorRunner<'a, T> {
1796
1796
actions. flush ( ) ;
1797
1797
}
1798
1798
}
1799
- }
1800
1799
1801
- impl < ' a , T : Backing < ' a > > ProcessorRunner < ' a , T > {
1802
1800
// Registers that are shared between VTLs need to be handled by the kernel
1803
1801
// as they may require special handling there. set_reg and get_reg will
1804
1802
// handle these registers using a dedicated ioctl, instead of the general-
@@ -1865,7 +1863,7 @@ impl<'a, T: Backing<'a>> ProcessorRunner<'a, T> {
1865
1863
Ok ( ( ) )
1866
1864
}
1867
1865
1868
- fn get_reg ( & mut self , vtl : GuestVtl , regs : & mut [ HvRegisterAssoc ] ) -> Result < ( ) , Error > {
1866
+ fn get_reg ( & mut self , vtl : Vtl , regs : & mut [ HvRegisterAssoc ] ) -> Result < ( ) , Error > {
1869
1867
if regs. is_empty ( ) {
1870
1868
return Ok ( ( ) ) ;
1871
1869
}
@@ -2040,9 +2038,7 @@ impl<'a, T: Backing<'a>> ProcessorRunner<'a, T> {
2040
2038
pub fn is_sidecar ( & self ) -> bool {
2041
2039
self . sidecar . is_some ( )
2042
2040
}
2043
- }
2044
2041
2045
- impl < ' a , T : Backing < ' a > > ProcessorRunner < ' a , T > {
2046
2042
fn get_vp_registers_inner < R : Copy + Into < HvRegisterName > > (
2047
2043
& mut self ,
2048
2044
vtl : GuestVtl ,
@@ -2065,7 +2061,7 @@ impl<'a, T: Backing<'a>> ProcessorRunner<'a, T> {
2065
2061
}
2066
2062
}
2067
2063
2068
- self . get_reg ( vtl, & mut assoc) ?;
2064
+ self . get_reg ( vtl. into ( ) , & mut assoc) ?;
2069
2065
for ( & i, assoc) in offset. iter ( ) . zip ( & assoc) {
2070
2066
values[ i] = assoc. value ;
2071
2067
}
@@ -2087,6 +2083,24 @@ impl<'a, T: Backing<'a>> ProcessorRunner<'a, T> {
2087
2083
Ok ( value[ 0 ] )
2088
2084
}
2089
2085
2086
+ /// Get the following register on the current VP for VTL 2.
2087
+ ///
2088
+ /// This will fail for registers that are in the mmapped CPU context, i.e.
2089
+ /// registers that are shared between VTL0 and VTL2.
2090
+ pub fn get_vp_vtl2_register (
2091
+ & mut self ,
2092
+ #[ cfg( guest_arch = "x86_64" ) ] name : HvX64RegisterName ,
2093
+ #[ cfg( guest_arch = "aarch64" ) ] name : HvArm64RegisterName ,
2094
+ ) -> Result < HvRegisterValue , Error > {
2095
+ let mut assoc = [ HvRegisterAssoc {
2096
+ name : name. into ( ) ,
2097
+ pad : Default :: default ( ) ,
2098
+ value : FromZeros :: new_zeroed ( ) ,
2099
+ } ] ;
2100
+ self . get_reg ( Vtl :: Vtl2 , & mut assoc) ?;
2101
+ Ok ( assoc[ 0 ] . value )
2102
+ }
2103
+
2090
2104
/// Get the following VP registers on the current VP.
2091
2105
///
2092
2106
/// # Panics
@@ -2565,7 +2579,7 @@ impl Hcl {
2565
2579
/// Get a single VP register for the given VTL via hypercall. Only a select
2566
2580
/// set of registers are supported; others will cause a panic.
2567
2581
#[ cfg( guest_arch = "x86_64" ) ]
2568
- pub fn get_vp_register (
2582
+ fn get_vp_register (
2569
2583
& self ,
2570
2584
name : impl Into < HvX64RegisterName > ,
2571
2585
vtl : HvInputVtl ,
@@ -2576,7 +2590,7 @@ impl Hcl {
2576
2590
/// Get a single VP register for the given VTL via hypercall. Only a select
2577
2591
/// set of registers are supported; others will cause a panic.
2578
2592
#[ cfg( guest_arch = "aarch64" ) ]
2579
- pub fn get_vp_register (
2593
+ fn get_vp_register (
2580
2594
& self ,
2581
2595
name : impl Into < HvArm64RegisterName > ,
2582
2596
vtl : HvInputVtl ,
@@ -2933,6 +2947,37 @@ impl Hcl {
2933
2947
) )
2934
2948
}
2935
2949
2950
+ /// Get the [`hvdef::HvRegisterVsmPartitionStatus`] register
2951
+ pub fn get_vsm_partition_status ( & self ) -> Result < hvdef:: HvRegisterVsmPartitionStatus , Error > {
2952
+ Ok ( hvdef:: HvRegisterVsmPartitionStatus :: from (
2953
+ self . get_vp_register (
2954
+ HvAllArchRegisterName :: VsmPartitionStatus ,
2955
+ HvInputVtl :: CURRENT_VTL ,
2956
+ ) ?
2957
+ . as_u64 ( ) ,
2958
+ ) )
2959
+ }
2960
+
2961
+ #[ cfg( guest_arch = "aarch64" ) ]
2962
+ /// Get the [`hvdef::HvPartitionPrivilege`] register
2963
+ pub fn get_privileges_and_features_info ( & self ) -> Result < hvdef:: HvPartitionPrivilege , Error > {
2964
+ Ok ( hvdef:: HvPartitionPrivilege :: from (
2965
+ self . get_vp_register (
2966
+ HvArm64RegisterName :: PrivilegesAndFeaturesInfo ,
2967
+ HvInputVtl :: CURRENT_VTL ,
2968
+ ) ?
2969
+ . as_u64 ( ) ,
2970
+ ) )
2971
+ }
2972
+
2973
+ /// Get the [`hvdef::hypercall::HvGuestOsId`] register for the given VTL.
2974
+ pub fn get_guest_os_id ( & self , vtl : Vtl ) -> Result < hvdef:: hypercall:: HvGuestOsId , Error > {
2975
+ Ok ( hvdef:: hypercall:: HvGuestOsId :: from (
2976
+ self . get_vp_register ( HvAllArchRegisterName :: GuestOsId , vtl. into ( ) ) ?
2977
+ . as_u64 ( ) ,
2978
+ ) )
2979
+ }
2980
+
2936
2981
/// Configure guest VSM.
2937
2982
/// The only configuration attribute currently supported is changing the maximum number of
2938
2983
/// guest-visible virtual trust levels for the partition. (VTL 1)
0 commit comments