From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46433) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeN5r-0003pP-If for qemu-devel@nongnu.org; Thu, 07 Nov 2013 05:45:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VeN5l-0000Eb-EZ for qemu-devel@nongnu.org; Thu, 07 Nov 2013 05:45:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31911) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeN5l-0000EU-6X for qemu-devel@nongnu.org; Thu, 07 Nov 2013 05:45:37 -0500 From: Marcel Apfelbaum Date: Thu, 7 Nov 2013 12:41:22 +0200 Message-Id: <1383820884-29596-7-git-send-email-marcel.a@redhat.com> In-Reply-To: <1383820884-29596-1-git-send-email-marcel.a@redhat.com> References: <1383820884-29596-1-git-send-email-marcel.a@redhat.com> Subject: [Qemu-devel] [PATCH for-1.7 v2 6/8] exec: don't ignore high address bits on set List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, ehabkost@redhat.com, mst@redhat.com, jan.kiszka@siemens.com, agraf@suse.de, lcapitulino@redhat.com, aliguori@amazon.com, pbonzini@redhat.com, afaerber@suse.de From: "Michael S. Tsirkin" We should never add pages outside target address space, we had such bugs in the past so add debug message to catch that quickly if we do, otherwise at least don't corrupt the page tables. Signed-off-by: Michael S. Tsirkin Signed-off-by: Marcel Apfelbaum --- exec.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/exec.c b/exec.c index aeeaf00..6c3196f 100644 --- a/exec.c +++ b/exec.c @@ -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); -- 1.8.3.1