> vp_modern_set_extended_features() currently writes all four 32-bit
> driver feature registers.  Selecting and writing each register requires
> two MMIO accesses, and each access may cause a VM exit when Linux runs as
> a guest.
> 
> The virtio core resets a device before feature negotiation.  Resetting
> clears all driver feature registers, so the initial finalization only
> needs to write through the highest nonzero register.  A typical modern
> device uses bits 0..63 and therefore saves four MMIO accesses, or up to
> four VM exits, during each feature negotiation.  Devices using a feature
> in bits 64..95 save two.
> 
> A driver's validate callback may remove features and cause a second
> finalization without another reset.  Track how many registers the
> previous finalization wrote and cover at least that range on the next
> call, writing zero where needed to clear a removed feature.
> 
> Signed-off-by: Peng Hao <[email protected]>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1


Reply via email to