@@ -452,7 +452,7 @@ impl Queue {
452452 // This fence ensures all descriptor writes are visible before the index update is.
453453 fence ( Ordering :: Release ) ;
454454
455- self . set_next_used ( self . next_used . 0 , mem) ;
455+ self . set_used_ring_idx ( self . next_used . 0 , mem) ;
456456 Ok ( ( ) )
457457 }
458458
@@ -519,7 +519,7 @@ impl Queue {
519519 }
520520
521521 /// Helper method that writes `val` to the `avail_event` field of the used ring.
522- fn set_avail_event < M : GuestMemory > ( & mut self , val : u16 , mem : & M ) {
522+ fn set_used_ring_avail_event < M : GuestMemory > ( & mut self , val : u16 , mem : & M ) {
523523 debug_assert ! ( self . is_layout_valid( mem) ) ;
524524
525525 // Used ring has layout:
@@ -540,7 +540,7 @@ impl Queue {
540540 mem. write_obj ( val, avail_event_addr) . unwrap ( ) ;
541541 }
542542
543- fn set_next_used < M : GuestMemory > ( & mut self , val : u16 , mem : & M ) {
543+ fn set_used_ring_idx < M : GuestMemory > ( & mut self , val : u16 , mem : & M ) {
544544 debug_assert ! ( self . is_layout_valid( mem) ) ;
545545
546546 // Used ring has layout:
@@ -552,8 +552,8 @@ impl Queue {
552552 // }
553553 // We calculate offset into `idx` field.
554554 let idx_offset = std:: mem:: size_of :: < u16 > ( ) ;
555- let next_used_addr = self . used_ring . unchecked_add ( usize_to_u64 ( idx_offset) ) ;
556- mem. write_obj ( val, next_used_addr ) . unwrap ( ) ;
555+ let idx_addr = self . used_ring . unchecked_add ( usize_to_u64 ( idx_offset) ) ;
556+ mem. write_obj ( val, idx_addr ) . unwrap ( ) ;
557557 }
558558
559559 /// Try to enable notification events from the guest driver. Returns true if notifications were
@@ -588,9 +588,9 @@ impl Queue {
588588 }
589589
590590 // Set the next expected avail_idx as avail_event.
591- self . set_avail_event ( self . next_avail . 0 , mem) ;
591+ self . set_used_ring_avail_event ( self . next_avail . 0 , mem) ;
592592
593- // Make sure all subsequent reads are performed after `set_avail_event `.
593+ // Make sure all subsequent reads are performed after `set_used_ring_avail_event `.
594594 fence ( Ordering :: SeqCst ) ;
595595
596596 // If the actual avail_idx is different than next_avail one or more descriptors can still
@@ -895,14 +895,14 @@ mod verification {
895895 mod stubs {
896896 use super :: * ;
897897
898- // Calls to set_avail_event tend to cause memory to grow unboundedly during verification.
899- // The function writes to the `avail_event` of the virtio queue, which is not read
900- // from by the device. It is only intended to be used by guest. Therefore, it does not
901- // affect any device functionality (e.g. its only call site, try_enable_notification ,
902- // will behave independently of what value was written here). Thus we can stub it out
903- // with a no-op. Note that we have a separate harness for set_avail_event, to ensure
904- // the function itself is sound.
905- fn set_avail_event < M : GuestMemory > ( _self : & mut Queue , _val : u16 , _mem : & M ) {
898+ // Calls to set_used_ring_avail_event tend to cause memory to grow unboundedly during
899+ // verification. The function writes to the `avail_event` of the virtio queue, which
900+ // is not read from by the device. It is only intended to be used by guest.
901+ // Therefore, it does not affect any device functionality (e.g. its only call site,
902+ // try_enable_notification, will behave independently of what value was written
903+ // here). Thus we can stub it out with a no-op. Note that we have a separate harness
904+ // for set_used_ring_avail_event, to ensure the function itself is sound.
905+ fn set_used_ring_avail_event < M : GuestMemory > ( _self : & mut Queue , _val : u16 , _mem : & M ) {
906906 // do nothing
907907 }
908908 }
@@ -1035,10 +1035,10 @@ mod verification {
10351035
10361036 #[ kani:: proof]
10371037 #[ kani:: unwind( 0 ) ]
1038- fn verify_set_avail_event ( ) {
1038+ fn verify_set_used_ring_avail_event ( ) {
10391039 let ProofContext ( mut queue, mem) = ProofContext :: bounded_queue ( ) ;
10401040
1041- queue. set_avail_event ( kani:: any ( ) , & mem) ;
1041+ queue. set_used_ring_avail_event ( kani:: any ( ) , & mem) ;
10421042 }
10431043
10441044 #[ kani:: proof]
@@ -1084,7 +1084,7 @@ mod verification {
10841084
10851085 #[ kani:: proof]
10861086 #[ kani:: unwind( 0 ) ]
1087- #[ kani:: stub( Queue :: set_avail_event , stubs:: set_avail_event ) ]
1087+ #[ kani:: stub( Queue :: set_used_ring_avail_event , stubs:: set_used_ring_avail_event ) ]
10881088 fn verify_try_enable_notification ( ) {
10891089 let ProofContext ( mut queue, mem) = ProofContext :: bounded_queue ( ) ;
10901090
@@ -1475,17 +1475,17 @@ mod tests {
14751475 }
14761476
14771477 #[ test]
1478- fn test_set_avail_event ( ) {
1478+ fn test_set_used_ring_avail_event ( ) {
14791479 let m = & default_mem ( ) ;
14801480 let vq = VirtQueue :: new ( GuestAddress ( 0 ) , m, 16 ) ;
14811481
14821482 let mut q = vq. create_queue ( ) ;
14831483 assert_eq ! ( vq. used. event. get( ) , 0 ) ;
14841484
1485- q. set_avail_event ( 10 , m) ;
1485+ q. set_used_ring_avail_event ( 10 , m) ;
14861486 assert_eq ! ( vq. used. event. get( ) , 10 ) ;
14871487
1488- q. set_avail_event ( u16:: MAX , m) ;
1488+ q. set_used_ring_avail_event ( u16:: MAX , m) ;
14891489 assert_eq ! ( vq. used. event. get( ) , u16 :: MAX ) ;
14901490 }
14911491
0 commit comments