Received: from eggs.gnu.org ([2001:4830:134:3::10]:39482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bK9M2-0008VP-Er for qemu-devel@nongnu.org; Mon, 04 Jul 2016 15:16:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bK9Ly-0003SI-7p for qemu-devel@nongnu.org; Mon, 04 Jul 2016 15:16:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55254) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bK9Ly-0003SC-2A for qemu-devel@nongnu.org; Mon, 04 Jul 2016 15:16:22 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B1AFEC05B1CA for ; Mon, 4 Jul 2016 19:16:21 +0000 (UTC) From: "Dr. David Alan Gilbert (git)" Date: Mon, 4 Jul 2016 20:16:09 +0100 Message-Id: <1467659769-15900-7-git-send-email-dgilbert@redhat.com> In-Reply-To: <1467659769-15900-1-git-send-email-dgilbert@redhat.com> References: <1467659769-15900-1-git-send-email-dgilbert@redhat.com> Subject: [Qemu-devel] [PATCH v2 6/6] x86: Add sanity checks on phys_bits List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, pbonzini@redhat.com, ehabkost@redhat.com, marcel@redhat.com, mst@redhat.com, kraxel@redhat.com From: "Dr. David Alan Gilbert" Add some sanity checks on the phys-bits setting now that the user can set it. a) That it's in a sane range (52..32) b) Warn if it mismatches the host and isn't the old default. Signed-off-by: Dr. David Alan Gilbert --- target-i386/cpu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index e15abea..5402002 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2985,6 +2985,19 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) /* The user asked for us to use the host physical bits */ cpu->phys_bits = host_phys_bits; + } else if (cpu->phys_bits > 52 || cpu->phys_bits < 32) { + error_setg(errp, "phys_bits should be between 32 and 52 or 0 to" + " use host size (but is %u)", cpu->phys_bits); + return; + } + /* Print a warning if the user set it to a value that's not the + * host value; ignore the magic value 40 because it may well just + * be the old machine type. + */ + if (cpu->phys_bits != host_phys_bits && cpu->phys_bits != 40) { + fprintf(stderr, "Warning: Host physical bits (%u)" + " does not match phys_bits (%u)\n", + host_phys_bits, cpu->phys_bits); } } else { /* For 32 bit systems don't use the user set value, but keep -- 2.7.4