On 5/23/23 09:36, Philippe Mathieu-Daudé wrote:
@@ -321,13 +321,13 @@ static void vhost_vdpa_listener_region_add(MemoryListener
*listener,
return;
}
- if (unlikely((section->offset_within_address_space & ~TARGET_PAGE_MASK) !=
- (section->offset_within_region & ~TARGET_PAGE_MASK))) {
+ if (unlikely((section->offset_within_address_space &
~qemu_target_page_mask()) !=
+ (section->offset_within_region & ~qemu_target_page_mask()))) {
error_report("%s received unaligned region", __func__);
return;
}
- iova = TARGET_PAGE_ALIGN(section->offset_within_address_space);
+ iova = qemu_target_page_align(section->offset_within_address_space);
llend = vhost_vdpa_section_end(section);
if (int128_ge(int128_make64(iova), llend)) {
return;
I'm not keen on using 3 function calls to get one constant.
This could be
int page_size = qemu_target_page_size();
int page_mask = page_size - 1;
if (section->foo & page_mask) { ...
iova = ROUND_UP(section->bar, page_size);
Also in vhost_vdpa_listener_region_del.
This then removes the only uses of qemu_target_page_align, so you don't need to add that
either.
r~