HomeFreeBSD

xen: fix initialization of grant table frame array

Description

xen: fix initialization of grant table frame array

The current sizing of the array used to store grant table frames is broken, as
the calculation:

max_nr_glist_frames = (boot_max_nr_grant_frames *
                       GREFS_PER_GRANT_FRAME /
                       (PAGE_SIZE / sizeof(grant_ref_t)));

Is plain bogus, for once grant_ref_t is the type of the grant reference, but
not the entry used to store such references in the grant frames. But even if
the above calculation is switched to use grant_entry_v1_t, it would end up as:

max_nr_glist_frames = (boot_max_nr_grant_frames *
                       (PAGE_SIZE / sizeof(grant_entry_v1_t)) /
                       (PAGE_SIZE / sizeof(grant_entry_v1_t)));

Which is pointless (note GREFS_PER_GRANT_FRAME has been expanded to (PAGE_SIZE
/ sizeof(grant_entry_v1_t))).

Just use boot_max_nr_grant_frames directly to size the grant table frames
array.

Fixes: 30d1eefe3937 ("Import OS interfaces to Xen services.")
Sponsored by: Citrix Systems R&D

Details

Provenance
roygerAuthored on Nov 2 2023, 5:23 PM
Parents
rG3bbbfc8dcd36: sctp: minor clean
Branches
Unknown
Tags
Unknown