@@ -52,6 +52,7 @@
#include "exec/memory-internal.h"
//#define DEBUG_SUBPAGE
+/* #define DEBUG_PHYS_PAGE_SET */
#if !defined(CONFIG_USER_ONLY)
static int in_migration;
@@ -204,6 +205,16 @@ static void phys_page_set(AddressSpaceDispatch *d,
hwaddr index, hwaddr nb,
uint16_t leaf)
{
+ if (nb && (index + nb - 1) >= TARGET_PHYS_MAX_ADDR) {
+#ifdef DEBUG_PHYS_PAGE_SET
+ printf("%s: page table corruption: page address " TARGET_FMT_plx
+ " > max supported address %llx\n", __func__, (index + nb - 1),
+ TARGET_PHYS_MAX_ADDR);
+#endif
+ /* at least don't corrupt the page tables */
+ return;
+ }
+
/* Wildly overreserve - it doesn't matter much. */
phys_map_node_reserve(3 * P_L2_LEVELS);