@@ -750,19 +750,14 @@ Module Type CheriMemoryImpl
750
750
let align := IMP.get.(alignof_pointer) in
751
751
(AddressValue.to_Z addr) mod (Z.of_nat align) =? 0.
752
752
753
- (** Update [capmeta] dictionary for capability [c] stored at [addr].
754
- If address is capability-aligned, then the tag and ghost state
755
- is stored. Otherwise capmeta is left unchanged. *)
753
+ (** Update [capmeta] dictionary for capability [c] stored at [addr]. *)
756
754
Definition update_capmeta
757
755
(c: C.t)
758
756
(addr: AddressValue.t)
759
757
(capmeta : AMap.M.t (bool*CapGhostState))
760
758
: AMap.M.t (bool*CapGhostState)
761
759
:=
762
- if is_pointer_algined addr
763
- then AMap.M.add addr (C.cap_is_valid c, C.get_ghost_state c) capmeta
764
- else capmeta.
765
-
760
+ AMap.M.add addr (C.cap_is_valid c, C.get_ghost_state c) capmeta.
766
761
767
762
Fixpoint repr
768
763
(fuel: nat)
@@ -797,6 +792,7 @@ Module Type CheriMemoryImpl
797
792
| CoqIntegerType.Unsigned CoqIntegerType.Intptr_t
798
793
=>
799
794
'(cb, ct) <- option2serr "int encoding error" (C.encode true c_value) ;;
795
+ sassert (is_pointer_algined addr) "unaligned pointer to cap" ;;
800
796
let capmeta := update_capmeta c_value addr capmeta in
801
797
sassert (AddressValue.to_Z addr + (Z.of_nat (length cb)) <=? AddressValue.ADDR_LIMIT) "object does not fit in address space" ;;
802
798
ret (funptrmap, capmeta, List.map (Some) cb)
@@ -816,11 +812,13 @@ Module Type CheriMemoryImpl
816
812
fp) =>
817
813
let '(funptrmap, c_value) := resolve_function_pointer funptrmap fp in
818
814
'(cb, ct) <- option2serr "valid function pointer encoding error" (C.encode true c_value) ;;
815
+ sassert (is_pointer_algined addr) "unaligned pointer to cap" ;;
819
816
let capmeta := update_capmeta c_value addr capmeta in
820
817
sassert (AddressValue.to_Z addr + (Z.of_nat (length cb)) <=? AddressValue.ADDR_LIMIT) "object does not fit in address space" ;;
821
818
ret (funptrmap, capmeta, List.map (Some) cb)
822
819
| (PVfunction (FP_invalid c_value) | PVconcrete c_value) =>
823
820
'(cb, ct) <- option2serr "pointer encoding error" (C.encode true c_value) ;;
821
+ sassert (is_pointer_algined addr) "unaligned pointer to cap" ;;
824
822
let capmeta := update_capmeta c_value addr capmeta in
825
823
sassert (AddressValue.to_Z addr + (Z.of_nat (length cb)) <=? AddressValue.ADDR_LIMIT) "object does not fit in address space" ;;
826
824
ret (funptrmap, capmeta, List.map (Some) cb)
0 commit comments