@@ -77,7 +77,6 @@ use vmbus_channel::bus::ParentBus;
77
77
use vmbus_channel:: bus:: RestoreResult ;
78
78
use vmbus_channel:: gpadl:: GpadlMap ;
79
79
use vmbus_channel:: gpadl_ring:: AlignedGpadlView ;
80
- use vmbus_channel:: gpadl_ring:: GpadlRingMem ;
81
80
use vmbus_core:: HvsockConnectRequest ;
82
81
use vmbus_core:: HvsockConnectResult ;
83
82
use vmbus_core:: MaxVersionInfo ;
@@ -1396,16 +1395,17 @@ impl ServerTask {
1396
1395
in_gpadl : AlignedGpadlView ,
1397
1396
guest_to_host_event : Option < & ChannelEvent > ,
1398
1397
host_to_guest_interrupt : & Interrupt ,
1399
- ) -> Result < ( ) , anyhow :: Error > {
1400
- let incoming_mem = GpadlRingMem :: new ( in_gpadl , gm ) ?;
1398
+ ) -> anyhow :: Result < ( ) > {
1399
+ let control_page = lock_gpn_with_subrange ( gm , in_gpadl . gpns ( ) [ 0 ] ) ?;
1401
1400
if let Some ( guest_to_host_event) = guest_to_host_event {
1402
- if ring:: reader_needs_signal ( & incoming_mem ) {
1401
+ if ring:: reader_needs_signal ( control_page . pages ( ) [ 0 ] ) {
1403
1402
tracelimit:: info_ratelimited!( channel = %channel. key, "waking host for incoming ring" ) ;
1404
1403
guest_to_host_event. 0 . deliver ( ) ;
1405
1404
}
1406
1405
}
1407
1406
1408
- if ring:: writer_needs_signal ( & incoming_mem) {
1407
+ let ring_size = gpadl_ring_size ( & in_gpadl) . try_into ( ) ?;
1408
+ if ring:: writer_needs_signal ( control_page. pages ( ) [ 0 ] , ring_size) {
1409
1409
tracelimit:: info_ratelimited!( channel = %channel. key, "waking guest for incoming ring" ) ;
1410
1410
host_to_guest_interrupt. deliver ( ) ;
1411
1411
}
@@ -1418,14 +1418,16 @@ impl ServerTask {
1418
1418
out_gpadl : AlignedGpadlView ,
1419
1419
guest_to_host_event : Option < & ChannelEvent > ,
1420
1420
host_to_guest_interrupt : & Interrupt ,
1421
- ) -> Result < ( ) , anyhow :: Error > {
1422
- let outgoing_mem = GpadlRingMem :: new ( out_gpadl , gm ) ?;
1423
- if ring:: reader_needs_signal ( & outgoing_mem ) {
1421
+ ) -> anyhow :: Result < ( ) > {
1422
+ let control_page = lock_gpn_with_subrange ( gm , out_gpadl . gpns ( ) [ 0 ] ) ?;
1423
+ if ring:: reader_needs_signal ( control_page . pages ( ) [ 0 ] ) {
1424
1424
tracelimit:: info_ratelimited!( channel = %channel. key, "waking guest for outgoing ring" ) ;
1425
1425
host_to_guest_interrupt. deliver ( ) ;
1426
1426
}
1427
+
1427
1428
if let Some ( guest_to_host_event) = guest_to_host_event {
1428
- if ring:: writer_needs_signal ( & outgoing_mem) {
1429
+ let ring_size = gpadl_ring_size ( & out_gpadl) . try_into ( ) ?;
1430
+ if ring:: writer_needs_signal ( control_page. pages ( ) [ 0 ] , ring_size) {
1429
1431
tracelimit:: info_ratelimited!( channel = %channel. key, "waking host for outgoing ring" ) ;
1430
1432
guest_to_host_event. 0 . deliver ( ) ;
1431
1433
}
@@ -2077,17 +2079,20 @@ fn inspect_rings(
2077
2079
fn inspect_ring ( req : inspect:: Request < ' _ > , gpadl : & AlignedGpadlView , gm : & GuestMemory ) {
2078
2080
let mut resp = req. respond ( ) ;
2079
2081
2080
- // Data size excluding the control page.
2081
- let ring_size = ( gpadl. gpns ( ) . len ( ) - 1 ) * PAGE_SIZE ;
2082
- resp. hex ( "ring_size" , ring_size) ;
2082
+ resp. hex ( "ring_size" , gpadl_ring_size ( gpadl) ) ;
2083
2083
2084
2084
// Lock just the control page. Use a subrange to allow a GuestMemory without a full mapping to
2085
2085
// create one.
2086
- if let Ok ( pages) = lock_page_with_subrange ( gm, gpadl. gpns ( ) [ 0 ] * PAGE_SIZE as u64 ) {
2086
+ if let Ok ( pages) = lock_gpn_with_subrange ( gm, gpadl. gpns ( ) [ 0 ] ) {
2087
2087
ring:: inspect_ring ( pages. pages ( ) [ 0 ] , & mut resp) ;
2088
2088
}
2089
2089
}
2090
2090
2091
+ fn gpadl_ring_size ( gpadl : & AlignedGpadlView ) -> usize {
2092
+ // Data size excluding the control page.
2093
+ ( gpadl. gpns ( ) . len ( ) - 1 ) * PAGE_SIZE
2094
+ }
2095
+
2091
2096
/// Helper to create a subrange before locking a single page.
2092
2097
///
2093
2098
/// This allows us to lock a page in a `GuestMemory` that doesn't have a full mapping, but can
@@ -2098,6 +2103,14 @@ fn lock_page_with_subrange(gm: &GuestMemory, offset: u64) -> anyhow::Result<gues
2098
2103
. lock_gpns ( false , & [ 0 ] ) ?)
2099
2104
}
2100
2105
2106
+ /// Helper to create a subrange before locking a single page from a gpn.
2107
+ ///
2108
+ /// This allows us to lock a page in a `GuestMemory` that doesn't have a full mapping, but can
2109
+ /// create one for a subrange.
2110
+ fn lock_gpn_with_subrange ( gm : & GuestMemory , gpn : u64 ) -> anyhow:: Result < guestmem:: LockedPages > {
2111
+ lock_page_with_subrange ( gm, gpn * PAGE_SIZE as u64 )
2112
+ }
2113
+
2101
2114
pub ( crate ) struct MessageSender {
2102
2115
send : mpsc:: Sender < SynicMessage > ,
2103
2116
multiclient : bool ,
0 commit comments