|
| From: | Richard Henderson |
| Subject: | Re: [RFC PATCH 11/11] hw/virtio: Make vhost-vdpa.c target-agnostic to build it once |
| Date: | Tue, 23 May 2023 16:43:38 -0700 |
| User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 |
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~
| [Prev in Thread] | Current Thread | [Next in Thread] |