diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-11-28 11:09:38 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2021-11-28 11:44:16 +0100 |
commit | 7bb961dfd808df26b9245c999b8cb4e897439019 (patch) | |
tree | 5e88b52b7b837f99840105df57a1c48eecf1e7f3 /device | |
parent | bca8c004cec8971d48b8411b0592f5ee6fb57bf6 (diff) | |
download | gnumach-7bb961dfd808df26b9245c999b8cb4e897439019.tar.gz gnumach-7bb961dfd808df26b9245c999b8cb4e897439019.tar.bz2 gnumach-7bb961dfd808df26b9245c999b8cb4e897439019.zip |
Fix rejecting the mapping of some pages
The memmmap method may reject some offsets (because it falls in non-device
ranges), so device_map_page has to notice this and report the error.
device_pager_data_request then has to notice as well and report.
Diffstat (limited to 'device')
-rw-r--r-- | device/dev_pager.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/device/dev_pager.c b/device/dev_pager.c index 066be462..cd41fee4 100644 --- a/device/dev_pager.c +++ b/device/dev_pager.c @@ -416,6 +416,7 @@ kern_return_t device_pager_data_request( vm_prot_t protection_required) { dev_pager_t ds; + kern_return_t ret; if (device_pager_debug) printf("(device_pager)data_request: pager=%p, offset=0x%lx, length=0x%lx\n", @@ -440,9 +441,18 @@ kern_return_t device_pager_data_request( return (KERN_SUCCESS); } - vm_object_page_map(object, - offset, length, - device_map_page, (void *)ds); + ret = vm_object_page_map(object, + offset, length, + device_map_page, (void *)ds); + + if (ret != KERN_SUCCESS) { + (void) r_memory_object_data_error(pager_request, + offset, length, + ret); + vm_object_deallocate(object); + dev_pager_deallocate(ds); + return (KERN_SUCCESS); + } vm_object_deallocate(object); } @@ -510,12 +520,16 @@ vm_offset_t device_map_page( vm_offset_t offset) { dev_pager_t ds = (dev_pager_t) dsp; - - return pmap_phys_address( + vm_offset_t pagenum = (*(ds->device->dev_ops->d_mmap)) (ds->device->dev_number, ds->offset + offset, - ds->prot)); + ds->prot); + + if (pagenum == -1) + return vm_page_fictitious_addr; + + return pmap_phys_address(pagenum); } kern_return_t device_pager_init_pager( |