Check that typed item fits on UTCB, issue #248
Check that there is enough room for a typed item on the UTCB. Otherwise deny to add the item and return false. Enable explicitly a return unused warning to get the right attention.
This commit is contained in:
parent
0c2adf7ddd
commit
9ebbf9c9f2
|
@ -403,7 +403,8 @@ namespace Nova {
|
||||||
*
|
*
|
||||||
* \param exception true to append the item to an exception reply
|
* \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 kern_pd = false,
|
||||||
bool update_guest_pt = false)
|
bool update_guest_pt = false)
|
||||||
{
|
{
|
||||||
|
@ -411,6 +412,12 @@ namespace Nova {
|
||||||
items += 1 << 16;
|
items += 1 << 16;
|
||||||
Item *item = reinterpret_cast<Item *>(this) + (PAGE_SIZE_BYTE / sizeof(struct Item)) - (items >> 16);
|
Item *item = reinterpret_cast<Item *>(this) + (PAGE_SIZE_BYTE / sizeof(struct Item)) - (items >> 16);
|
||||||
|
|
||||||
|
/* check that there is enough space left on UTCB */
|
||||||
|
if (msg + msg_words() >= reinterpret_cast<mword_t *>(item)) {
|
||||||
|
items -= 1 << 16;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* map from hypervisor or current pd */
|
/* map from hypervisor or current pd */
|
||||||
unsigned h = kern_pd ? (1 << 11) : 0;
|
unsigned h = kern_pd ? (1 << 11) : 0;
|
||||||
|
|
||||||
|
@ -420,6 +427,7 @@ namespace Nova {
|
||||||
item->hotspot = crd.hotspot(sel_hotspot) | g | h | 1;
|
item->hotspot = crd.hotspot(sel_hotspot) | g | h | 1;
|
||||||
item->crd = crd.value();
|
item->crd = crd.value();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mword_t mtd_value() const { return static_cast<Mtd>(mtd).value(); }
|
mword_t mtd_value() const { return static_cast<Mtd>(mtd).value(); }
|
||||||
|
|
Loading…
Reference in New Issue