mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
fixed small page handling
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@160 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
2a29ca73c9
commit
d418c81eff
1 changed files with 17 additions and 6 deletions
|
@ -61,13 +61,18 @@ int target_mprotect(unsigned long start, unsigned long len, int prot)
|
||||||
for(addr = host_start; addr < start; addr += TARGET_PAGE_SIZE) {
|
for(addr = host_start; addr < start; addr += TARGET_PAGE_SIZE) {
|
||||||
prot1 |= page_get_flags(addr);
|
prot1 |= page_get_flags(addr);
|
||||||
}
|
}
|
||||||
|
if (host_end == host_start + host_page_size) {
|
||||||
|
for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {
|
||||||
|
prot1 |= page_get_flags(addr);
|
||||||
|
}
|
||||||
|
end = host_end;
|
||||||
|
}
|
||||||
ret = mprotect((void *)host_start, host_page_size, prot1 & PAGE_BITS);
|
ret = mprotect((void *)host_start, host_page_size, prot1 & PAGE_BITS);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
host_start += host_page_size;
|
host_start += host_page_size;
|
||||||
}
|
}
|
||||||
if (end < host_end) {
|
if (end < host_end) {
|
||||||
/* handle host page containing end (can be the same as first page) */
|
|
||||||
prot1 = prot;
|
prot1 = prot;
|
||||||
for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {
|
for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {
|
||||||
prot1 |= page_get_flags(addr);
|
prot1 |= page_get_flags(addr);
|
||||||
|
@ -85,7 +90,6 @@ int target_mprotect(unsigned long start, unsigned long len, int prot)
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
page_set_flags(start, start + len, prot | PAGE_VALID);
|
page_set_flags(start, start + len, prot | PAGE_VALID);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -311,11 +315,16 @@ int target_munmap(unsigned long start, unsigned long len)
|
||||||
for(addr = host_start; addr < start; addr += TARGET_PAGE_SIZE) {
|
for(addr = host_start; addr < start; addr += TARGET_PAGE_SIZE) {
|
||||||
prot |= page_get_flags(addr);
|
prot |= page_get_flags(addr);
|
||||||
}
|
}
|
||||||
|
if (host_end == host_start + host_page_size) {
|
||||||
|
for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {
|
||||||
|
prot |= page_get_flags(addr);
|
||||||
|
}
|
||||||
|
end = host_end;
|
||||||
|
}
|
||||||
if (prot != 0)
|
if (prot != 0)
|
||||||
host_start += host_page_size;
|
host_start += host_page_size;
|
||||||
}
|
}
|
||||||
if (end < host_end) {
|
if (end < host_end) {
|
||||||
/* handle host page containing end (can be the same as first page) */
|
|
||||||
prot = 0;
|
prot = 0;
|
||||||
for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {
|
for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) {
|
||||||
prot |= page_get_flags(addr);
|
prot |= page_get_flags(addr);
|
||||||
|
@ -360,11 +369,13 @@ int target_msync(unsigned long start, unsigned long len, int flags)
|
||||||
if (start & ~TARGET_PAGE_MASK)
|
if (start & ~TARGET_PAGE_MASK)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
len = TARGET_PAGE_ALIGN(len);
|
len = TARGET_PAGE_ALIGN(len);
|
||||||
if (len == 0)
|
|
||||||
return 0;
|
|
||||||
end = start + len;
|
end = start + len;
|
||||||
|
if (end < start)
|
||||||
|
return -EINVAL;
|
||||||
|
if (end == start)
|
||||||
|
return 0;
|
||||||
|
|
||||||
start &= host_page_mask;
|
start &= host_page_mask;
|
||||||
return msync((void *)start, len, flags);
|
return msync((void *)start, end - start, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue