aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/vm_object.h
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2018-12-02 13:16:46 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2018-12-02 13:16:46 +0000
commit10d9120c44480b6ce02f9b37ee8c0724c358ee65 (patch)
treedbb60cc69e3a5a79548344e70143beb7b50dde8b /sys/vm/vm_object.h
parent200bf72793d1e5ed73f9198cc8160b6ee80e46dc (diff)
downloadsrc-10d9120c44480b6ce02f9b37ee8c0724c358ee65.tar.gz
src-10d9120c44480b6ce02f9b37ee8c0724c358ee65.zip
Change the vm_ooffset_t type to unsigned.
The type represents byte offset in the vm_object_t data space, which does not span negative offsets in FreeBSD VM. The change matches byte offset signess with the unsignedness of the vm_pindex_t which represents the type of the page indexes in the objects. This allows to remove the UOFF_TO_IDX() macro which was used when we have to forcibly interpret the type as unsigned anyway. Also it fixes a lot of implicit bugs in the device drivers d_mmap methods. Reviewed by: alc, markj (previous version) Tested by: pho MFC after: 2 weeks Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/head/; revision=341398
Diffstat (limited to 'sys/vm/vm_object.h')
-rw-r--r--sys/vm/vm_object.h11
1 files changed, 2 insertions, 9 deletions
diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h
index fb1fa1f365ca..89aea522374e 100644
--- a/sys/vm/vm_object.h
+++ b/sys/vm/vm_object.h
@@ -196,20 +196,13 @@ struct vm_object {
/*
* Helpers to perform conversion between vm_object page indexes and offsets.
* IDX_TO_OFF() converts an index into an offset.
- * OFF_TO_IDX() converts an offset into an index. Since offsets are signed
- * by default, the sign propagation in OFF_TO_IDX(), when applied to
- * negative offsets, is intentional and returns a vm_object page index
- * that cannot be created by a userspace mapping.
- * UOFF_TO_IDX() treats the offset as an unsigned value and converts it
- * into an index accordingly. Use it only when the full range of offset
- * values are allowed. Currently, this only applies to device mappings.
+ * OFF_TO_IDX() converts an offset into an index.
* OBJ_MAX_SIZE specifies the maximum page index corresponding to the
* maximum unsigned offset.
*/
#define IDX_TO_OFF(idx) (((vm_ooffset_t)(idx)) << PAGE_SHIFT)
#define OFF_TO_IDX(off) ((vm_pindex_t)(((vm_ooffset_t)(off)) >> PAGE_SHIFT))
-#define UOFF_TO_IDX(off) (((vm_pindex_t)(off)) >> PAGE_SHIFT)
-#define OBJ_MAX_SIZE (UOFF_TO_IDX(UINT64_MAX) + 1)
+#define OBJ_MAX_SIZE (OFF_TO_IDX(UINT64_MAX) + 1)
#ifdef _KERNEL