- if (grant)
- {
- if (mapdb->valid_address(s_phys))
- if (EXPECT_FALSE(!mapdb->grant(mapdb_frame, sender_mapping,
- to_id, rcv_addr)))
- {
- // Error -- remove mapping again.
- to->v_delete(rcv_addr, i_size);
-
- // may fail due to quota limits
- condition = L4_error::Map_failed;
- break;
- }
-
- from->v_delete(snd_addr.trunc(s_size), s_size);
- need_tlb_flush = true;
- }
- else if (status == SPACE::Insert_ok)
- {
- assert_kdb (!doing_upgrade);
-
- if (mapdb->valid_address(s_phys)
- && !mapdb->insert(mapdb_frame, sender_mapping,
- to_id, rcv_addr,
- i_phys, i_size))
- {
- // Error -- remove mapping again.
- to->v_delete(rcv_addr, i_size);
-
- // XXX This is not race-free as the mapping could have
- // been used in the mean-time, but we do not care.
- condition = L4_error::Map_failed;
- break;
- }
- }
-
- if (SPACE::Need_xcpu_tlb_flush && SPACE::Need_insert_tlb_flush)
- need_xcpu_tlb_flush = true;
-
- break;
-
- case SPACE::Insert_err_nomem:
- condition = L4_error::Map_failed;
- break;
-
- case SPACE::Insert_err_exists:
- WARN("map (%s) skipping area (%p/%lx): " L4_PTR_FMT
- " -> %p/%lx: " L4_PTR_FMT "(%lx)", SPACE::name,
- from_id, Kobject_dbg::pointer_to_id(from_id), snd_addr.value(),
- to_id, Kobject_dbg::pointer_to_id(to_id), rcv_addr.value(), i_size.value());
- // Do not flag an error here -- because according to L4
- // semantics, it isn't.
- break;
- }
+ if (grant)
+ {
+ if (mapdb->valid_address(SPACE::to_pfn(s_phys))
+ && EXPECT_FALSE(!mapdb->grant(mapdb_frame, sender_mapping,
+ to_id, SPACE::to_pfn(rcv_addr))))
+ {
+ // Error -- remove mapping again.
+ to->v_delete(rcv_addr, i_order, L4_fpage::Rights::FULL());
+ to_needs_tlb_flush = true;
+
+ // may fail due to quota limits
+ condition = L4_error::Map_failed;
+ break;
+ }
+
+ from->v_delete(SPACE::page_address(snd_addr, s_order), s_order, L4_fpage::Rights::FULL());
+ from_needs_tlb_flush = true;
+ }
+ else if (status == SPACE::Insert_ok)
+ {
+ if (mapdb->valid_address(SPACE::to_pfn(s_phys))
+ && !mapdb->insert(mapdb_frame, sender_mapping,
+ to_id, SPACE::to_pfn(rcv_addr),
+ SPACE::to_pfn(i_phys), SPACE::to_pcnt(i_order)))
+ {
+ // Error -- remove mapping again.
+ to->v_delete(rcv_addr, i_order, L4_fpage::Rights::FULL());
+ to_needs_tlb_flush = true;
+
+ // XXX This is not race-free as the mapping could have
+ // been used in the mean-time, but we do not care.
+ condition = L4_error::Map_failed;
+ break;
+ }
+ }
+
+ if (SPACE::Need_xcpu_tlb_flush && SPACE::Need_insert_tlb_flush)
+ need_xcpu_tlb_flush = true;
+
+ {
+ V_pfc super_offset = SPACE::subpage_offset(snd_addr, i_order);
+ if (super_offset != V_pfc(0))
+ // Just use OR here because i_phys may already contain
+ // the offset. (As is on ARM)
+ i_phys = SPACE::subpage_address(i_phys, super_offset);
+ }
+
+ break;
+
+ case SPACE::Insert_err_nomem:
+ condition = L4_error::Map_failed;
+ break;
+
+ case SPACE::Insert_err_exists:
+ WARN("map (%s) skipping area (%p/%lx): " L4_PTR_FMT
+ " -> %p/%lx: " L4_PTR_FMT "(%lx)", SPACE::name,
+ from_id, Kobject_dbg::pointer_to_id(from_id),
+ (unsigned long)cxx::int_value<V_pfn>(snd_addr),
+ to_id, Kobject_dbg::pointer_to_id(to_id),
+ (unsigned long)cxx::int_value<V_pfn>(rcv_addr),
+ (unsigned long)cxx::int_value<V_pfc>(i_size));
+ // Do not flag an error here -- because according to L4
+ // semantics, it isn't.
+ break;
+ }