@@ -142,7 +142,7 @@ bitflags::bitflags! {
142142}
143143
144144bitflags:: bitflags! {
145- #[ derive( Debug , PartialEq ) ]
145+ #[ derive( Debug , PartialEq , Clone , Copy , Default ) ]
146146 pub struct SegmentRegisterAttributeFlags : u16 {
147147 const ACCESSED = 1 << 0 ;
148148 const WRITABLE = 1 << 1 ;
@@ -166,13 +166,7 @@ pub struct HvX64SegmentRegister {
166166 pub base : u64 ,
167167 pub limit : u32 ,
168168 pub selector : u16 ,
169-
170- _attributes : u16 ,
171- // union of
172- // segment_type: 4, non_system_segment: 1,
173- // descriptor_privilege_level: 2, present: 1,
174- // reserved: 4, available: 1, _long: 1,
175- // _default: 1, granularity: 1
169+ pub attributes : SegmentRegisterAttributeFlags ,
176170}
177171
178172impl HvX64SegmentRegister {
@@ -183,9 +177,12 @@ impl HvX64SegmentRegister {
183177 }
184178 }
185179
186- #[ expect( clippy:: used_underscore_binding) ]
187- pub fn set_attributes ( & mut self , attrs : u16 ) {
188- self . _attributes = attrs;
180+ pub fn set_attributes ( & mut self , attrs : SegmentRegisterAttributeFlags ) {
181+ self . attributes = attrs;
182+ }
183+
184+ pub fn get_attributes ( & self ) -> SegmentRegisterAttributeFlags {
185+ self . attributes
189186 }
190187}
191188
@@ -259,11 +256,6 @@ impl HvInputVtl {
259256 pub fn target_vtl_value ( & self ) -> u8 {
260257 self . target_vtl ( ) as u8
261258 }
262-
263- /// Sets the target VTL from a u8 value
264- pub fn set_target_vtl_value ( & mut self , target_vtl : u8 ) {
265- self . set_target_vtl ( target_vtl. into ( ) ) ;
266- }
267259}
268260
269261#[ derive( Default , Clone , Copy ) ]
@@ -390,13 +382,6 @@ pub struct HvNestedEnlightenmentsControlFeatures {
390382 __ : B31 ,
391383}
392384
393- impl HvNestedEnlightenmentsControlFeatures {
394- /// Set direct hypercall flag from u32 (for compatibility)
395- pub fn set_direct_hypercall_u32 ( & mut self , direct_hypercall : u32 ) {
396- self . set_direct_hypercall ( direct_hypercall != 0 ) ;
397- }
398- }
399-
400385#[ bitfield]
401386#[ derive( Clone , Copy , Default ) ]
402387#[ repr( C ) ]
@@ -406,13 +391,6 @@ pub struct HvNestedEnlightenmentsControlHypercallControls {
406391 __ : B31 ,
407392}
408393
409- impl HvNestedEnlightenmentsControlHypercallControls {
410- /// Set inter partition comm flag from u32 (for compatibility)
411- pub fn set_inter_partition_comm_u32 ( & mut self , inter_partition_comm : u32 ) {
412- self . set_inter_partition_comm ( inter_partition_comm != 0 ) ;
413- }
414- }
415-
416394#[ expect( non_snake_case) ]
417395#[ derive( Default , Clone , Copy ) ]
418396#[ repr( C , packed) ]
@@ -523,16 +501,6 @@ impl HvRegisterVsmVpSecureVtlConfig {
523501 pub fn as_u64 ( & self ) -> u64 {
524502 u64:: from_le_bytes ( self . into_bytes ( ) )
525503 }
526-
527- /// Enable MBEC (for compatibility)
528- pub fn set_mbec_enabled_flag ( & mut self ) {
529- self . set_mbec_enabled ( true ) ;
530- }
531-
532- /// Enable TLB locked (for compatibility)
533- pub fn set_tlb_locked_flag ( & mut self ) {
534- self . set_tlb_locked ( true ) ;
535- }
536504}
537505
538506#[ bitfield]
@@ -565,11 +533,6 @@ impl HvRegisterVsmPartitionConfig {
565533 Self :: from_bytes ( value. to_le_bytes ( ) )
566534 }
567535
568- /// Set the default VTL protection mask from a u64 value
569- pub fn set_default_vtl_protection_mask_value ( & mut self , mask : u64 ) {
570- self . set_default_vtl_protection_mask ( ( mask as u8 ) . into ( ) ) ;
571- }
572-
573536 /// Get the default VTL protection mask as a u64 value
574537 pub fn default_vtl_protection_mask_value ( & self ) -> u64 {
575538 self . default_vtl_protection_mask ( ) as u64
@@ -756,26 +719,6 @@ impl HvSynicSint {
756719 pub fn as_uint64 ( & self ) -> u64 {
757720 u64:: from_le_bytes ( self . into_bytes ( ) )
758721 }
759-
760- /// Set vector from u64 (for compatibility)
761- pub fn set_vector_u64 ( & mut self , vector : u64 ) {
762- self . set_vector ( ( vector as u8 ) . into ( ) ) ;
763- }
764-
765- /// Set masked flag (for compatibility)
766- pub fn set_masked_flag ( & mut self ) {
767- self . set_masked ( true ) ;
768- }
769-
770- /// Set auto_eoi flag (for compatibility)
771- pub fn set_auto_eoi_flag ( & mut self ) {
772- self . set_auto_eoi ( true ) ;
773- }
774-
775- /// Set polling flag (for compatibility)
776- pub fn set_polling_flag ( & mut self ) {
777- self . set_polling ( true ) ;
778- }
779722}
780723
781724#[ derive( Default , Clone , Copy ) ]
@@ -868,31 +811,6 @@ impl HvPendingExceptionEvent {
868811 pub fn as_u64 ( & self ) -> u64 {
869812 u64:: from_le_bytes ( self . into_bytes ( ) )
870813 }
871-
872- /// Set event pending flag (for compatibility)
873- pub fn set_event_pending_flag ( & mut self ) {
874- self . set_event_pending ( true ) ;
875- }
876-
877- /// Set event type from u64 (for compatibility)
878- pub fn set_event_type_u64 ( & mut self , event_type : u64 ) {
879- self . set_event_type ( ( event_type as u8 ) . into ( ) ) ;
880- }
881-
882- /// Set deliver error code flag (for compatibility)
883- pub fn set_deliver_error_code_flag ( & mut self ) {
884- self . set_deliver_error_code ( true ) ;
885- }
886-
887- /// Set vector from u64 (for compatibility)
888- pub fn set_vector_u64 ( & mut self , vector : u64 ) {
889- self . set_vector ( ( vector as u16 ) . into ( ) ) ;
890- }
891-
892- /// Set error code from u64 (for compatibility)
893- pub fn set_error_code_u64 ( & mut self , error_code : u64 ) {
894- self . set_error_code ( ( error_code as u32 ) . into ( ) ) ;
895- }
896814}
897815
898816#[ cfg( test) ]
@@ -914,7 +832,7 @@ mod tests {
914832
915833 // Test individual field manipulation
916834 let mut vtl = HvInputVtl :: new ( ) ;
917- vtl. set_target_vtl_value ( 10 ) ;
835+ vtl. set_target_vtl ( 10_u8 . into ( ) ) ;
918836 vtl. set_use_target_vtl ( true ) ;
919837 assert_eq ! ( vtl. target_vtl_value( ) , 10 ) ;
920838 assert_eq ! ( vtl. use_target_vtl( ) , true ) ;
@@ -949,7 +867,7 @@ mod tests {
949867 assert_eq ! ( config. intercept_page( ) , true ) ;
950868
951869 // Test the 4-bit protection mask field
952- config. set_default_vtl_protection_mask_value ( 0b1010 ) ;
870+ config. set_default_vtl_protection_mask ( ( 0b1010_u8 ) . into ( ) ) ;
953871 assert_eq ! ( config. default_vtl_protection_mask_value( ) , 0b1010 ) ;
954872
955873 // Test size - should be 8 bytes (64 bits)
@@ -991,12 +909,12 @@ mod tests {
991909 features. set_direct_hypercall ( true ) ;
992910 assert_eq ! ( features. direct_hypercall( ) , true ) ;
993911
994- // Test compatibility method
912+ // Test direct method
995913 let mut features2 = HvNestedEnlightenmentsControlFeatures :: new ( ) ;
996- features2. set_direct_hypercall_u32 ( 1 ) ;
914+ features2. set_direct_hypercall ( true ) ;
997915 assert_eq ! ( features2. direct_hypercall( ) , true ) ;
998916
999- features2. set_direct_hypercall_u32 ( 0 ) ;
917+ features2. set_direct_hypercall ( false ) ;
1000918 assert_eq ! ( features2. direct_hypercall( ) , false ) ;
1001919
1002920 // Test size - should be 4 bytes (32 bits)
@@ -1017,12 +935,12 @@ mod tests {
1017935 controls. set_inter_partition_comm ( true ) ;
1018936 assert_eq ! ( controls. inter_partition_comm( ) , true ) ;
1019937
1020- // Test compatibility method
938+ // Test direct method
1021939 let mut controls2 = HvNestedEnlightenmentsControlHypercallControls :: new ( ) ;
1022- controls2. set_inter_partition_comm_u32 ( 1 ) ;
940+ controls2. set_inter_partition_comm ( true ) ;
1023941 assert_eq ! ( controls2. inter_partition_comm( ) , true ) ;
1024942
1025- controls2. set_inter_partition_comm_u32 ( 0 ) ;
943+ controls2. set_inter_partition_comm ( false ) ;
1026944 assert_eq ! ( controls2. inter_partition_comm( ) , false ) ;
1027945
1028946 // Test size - should be 4 bytes (32 bits)
@@ -1046,12 +964,12 @@ mod tests {
1046964 config. set_tlb_locked ( true ) ;
1047965 assert_eq ! ( config. tlb_locked( ) , true ) ;
1048966
1049- // Test compatibility methods
967+ // Test direct methods
1050968 let mut config2 = HvRegisterVsmVpSecureVtlConfig :: new ( ) ;
1051- config2. set_mbec_enabled_flag ( ) ;
969+ config2. set_mbec_enabled ( true ) ;
1052970 assert_eq ! ( config2. mbec_enabled( ) , true ) ;
1053971
1054- config2. set_tlb_locked_flag ( ) ;
972+ config2. set_tlb_locked ( true ) ;
1055973 assert_eq ! ( config2. tlb_locked( ) , true ) ;
1056974
1057975 // Test size - should be 8 bytes (64 bits)
@@ -1088,18 +1006,18 @@ mod tests {
10881006 sint. set_polling ( true ) ;
10891007 assert_eq ! ( sint. polling( ) , true ) ;
10901008
1091- // Test compatibility methods
1009+ // Test direct methods
10921010 let mut sint2 = HvSynicSint :: new ( ) ;
1093- sint2. set_vector_u64 ( 0xf3 ) ;
1011+ sint2. set_vector ( ( 0xf3_u8 ) . into ( ) ) ;
10941012 assert_eq ! ( sint2. vector( ) as u8 , 0xf3 ) ;
10951013
1096- sint2. set_masked_flag ( ) ;
1014+ sint2. set_masked ( true ) ;
10971015 assert_eq ! ( sint2. masked( ) , true ) ;
10981016
1099- sint2. set_auto_eoi_flag ( ) ;
1017+ sint2. set_auto_eoi ( true ) ;
11001018 assert_eq ! ( sint2. auto_eoi( ) , true ) ;
11011019
1102- sint2. set_polling_flag ( ) ;
1020+ sint2. set_polling ( true ) ;
11031021 assert_eq ! ( sint2. polling( ) , true ) ;
11041022
11051023 // Test size - should be 8 bytes (64 bits)
@@ -1140,21 +1058,21 @@ mod tests {
11401058 exception. set_error_code ( 0x87654321_u32 . into ( ) ) ; // 32 bits
11411059 assert_eq ! ( exception. error_code( ) as u32 , 0x87654321 ) ;
11421060
1143- // Test compatibility methods
1061+ // Test direct methods
11441062 let mut exception2 = HvPendingExceptionEvent :: new ( ) ;
1145- exception2. set_event_pending_flag ( ) ;
1063+ exception2. set_event_pending ( true ) ;
11461064 assert_eq ! ( exception2. event_pending( ) , true ) ;
11471065
1148- exception2. set_deliver_error_code_flag ( ) ;
1066+ exception2. set_deliver_error_code ( true ) ;
11491067 assert_eq ! ( exception2. deliver_error_code( ) , true ) ;
11501068
1151- exception2. set_event_type_u64 ( 7 ) ;
1069+ exception2. set_event_type ( ( 7_u8 ) . into ( ) ) ;
11521070 assert_eq ! ( exception2. event_type( ) as u8 , 7 ) ;
11531071
1154- exception2. set_vector_u64 ( 0xabcd ) ;
1072+ exception2. set_vector ( ( 0xabcd_u16 ) . into ( ) ) ;
11551073 assert_eq ! ( exception2. vector( ) as u16 , 0xabcd ) ;
11561074
1157- exception2. set_error_code_u64 ( 0x12345678 ) ;
1075+ exception2. set_error_code ( ( 0x12345678_u32 ) . into ( ) ) ;
11581076 assert_eq ! ( exception2. error_code( ) as u32 , 0x12345678 ) ;
11591077
11601078 // Test size - should be 8 bytes (64 bits)
0 commit comments