hw/virtio: Propagate page_mask to vhost_vdpa_section_end()

Propagate TARGET_PAGE_MASK (see the previous commit for
rationale).

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230710094931.84402-3-philmd@linaro.org>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Philippe Mathieu-Daudé 2023-07-10 11:49:27 +02:00 committed by Michael S. Tsirkin
parent 961d60e934
commit 8b1a8884c6

View File

@ -31,11 +31,12 @@
* Return one past the end of the end of section. Be careful with uint64_t
* conversions!
*/
static Int128 vhost_vdpa_section_end(const MemoryRegionSection *section)
static Int128 vhost_vdpa_section_end(const MemoryRegionSection *section,
int page_mask)
{
Int128 llend = int128_make64(section->offset_within_address_space);
llend = int128_add(llend, section->size);
llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK));
llend = int128_and(llend, int128_exts64(page_mask));
return llend;
}
@ -69,7 +70,7 @@ static bool vhost_vdpa_listener_skipped_section(MemoryRegionSection *section,
*/
if (!memory_region_is_iommu(section->mr)) {
llend = vhost_vdpa_section_end(section);
llend = vhost_vdpa_section_end(section, page_mask);
if (int128_gt(llend, int128_make64(iova_max))) {
error_report("RAM section out of device range (max=0x%" PRIx64
", end addr=0x%" PRIx64 ")",
@ -331,7 +332,7 @@ static void vhost_vdpa_listener_region_add(MemoryListener *listener,
}
iova = TARGET_PAGE_ALIGN(section->offset_within_address_space);
llend = vhost_vdpa_section_end(section);
llend = vhost_vdpa_section_end(section, TARGET_PAGE_MASK);
if (int128_ge(int128_make64(iova), llend)) {
return;
}
@ -415,7 +416,7 @@ static void vhost_vdpa_listener_region_del(MemoryListener *listener,
}
iova = TARGET_PAGE_ALIGN(section->offset_within_address_space);
llend = vhost_vdpa_section_end(section);
llend = vhost_vdpa_section_end(section, TARGET_PAGE_MASK);
trace_vhost_vdpa_listener_region_del(v, iova,
int128_get64(int128_sub(llend, int128_one())));