Commit 3bf9be40 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin

vhost: correctly set bits of dirty pages

Fix two bugs in dirty page logging:
When counting pages we should increase address by 1 instead of
VHOST_PAGE_SIZE. Make log_write() correctly process requests
that cross pages with write_address not starting at page boundary.
Reported-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent a290aec8
...@@ -885,6 +885,7 @@ static int log_write(void __user *log_base, ...@@ -885,6 +885,7 @@ static int log_write(void __user *log_base,
int r; int r;
if (!write_length) if (!write_length)
return 0; return 0;
write_length += write_address % VHOST_PAGE_SIZE;
write_address /= VHOST_PAGE_SIZE; write_address /= VHOST_PAGE_SIZE;
for (;;) { for (;;) {
u64 base = (u64)(unsigned long)log_base; u64 base = (u64)(unsigned long)log_base;
...@@ -898,7 +899,7 @@ static int log_write(void __user *log_base, ...@@ -898,7 +899,7 @@ static int log_write(void __user *log_base,
if (write_length <= VHOST_PAGE_SIZE) if (write_length <= VHOST_PAGE_SIZE)
break; break;
write_length -= VHOST_PAGE_SIZE; write_length -= VHOST_PAGE_SIZE;
write_address += VHOST_PAGE_SIZE; write_address += 1;
} }
return r; return r;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment