diff --git a/base-nova/include/nova/syscall-generic.h b/base-nova/include/nova/syscall-generic.h index 52b2645f9..8eefef099 100644 --- a/base-nova/include/nova/syscall-generic.h +++ b/base-nova/include/nova/syscall-generic.h @@ -403,7 +403,8 @@ namespace Nova { * * \param exception true to append the item to an exception reply */ - void append_item(Crd crd, mword_t sel_hotspot, + __attribute__((warn_unused_result)) + bool append_item(Crd crd, mword_t sel_hotspot, bool kern_pd = false, bool update_guest_pt = false) { @@ -411,6 +412,12 @@ namespace Nova { items += 1 << 16; Item *item = reinterpret_cast(this) + (PAGE_SIZE_BYTE / sizeof(struct Item)) - (items >> 16); + /* check that there is enough space left on UTCB */ + if (msg + msg_words() >= reinterpret_cast(item)) { + items -= 1 << 16; + return false; + } + /* map from hypervisor or current pd */ unsigned h = kern_pd ? (1 << 11) : 0; @@ -420,6 +427,7 @@ namespace Nova { item->hotspot = crd.hotspot(sel_hotspot) | g | h | 1; item->crd = crd.value(); + return true; } mword_t mtd_value() const { return static_cast(mtd).value(); }