From patchwork Fri Oct 28 14:59:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 688481 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t57Pc4TYwz9sdn for ; Sat, 29 Oct 2016 02:45:24 +1100 (AEDT) Received: from localhost ([::1]:49921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c09LO-0002HZ-3Q for incoming@patchwork.ozlabs.org; Fri, 28 Oct 2016 11:45:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c08dA-0004YG-95 for qemu-devel@nongnu.org; Fri, 28 Oct 2016 10:59:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c08d8-0005O5-Bv for qemu-devel@nongnu.org; Fri, 28 Oct 2016 10:59:40 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:47447) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c08d8-0005K7-1O for qemu-devel@nongnu.org; Fri, 28 Oct 2016 10:59:38 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1c08cx-0005kc-D2 for qemu-devel@nongnu.org; Fri, 28 Oct 2016 15:59:27 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 28 Oct 2016 15:59:19 +0100 Message-Id: <1477666764-19403-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477666764-19403-1-git-send-email-peter.maydell@linaro.org> References: <1477666764-19403-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 4/9] versatilepb: do not run if user asks for more than 256MB RAM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jean-Christophe Dubois The versatilepb physical address space layout only has a 256MB region for RAM before the devices. Without a guard on the amount of RAM requested by the user we would happily create a RAM area that overlapped with the devices, resulting in very confusing behaviour (typically a guest crash). Report the problem to the user if they try to request more RAM than the board can handle (as we do already for some other board models). Signed-off-by: Jean-Christophe Dubois Message-id: 20161025093711.17407-1-jcd@tribudubois.net [PMM: tidied up commit message, comments. Use error_report() rather than fprintf(stderr, ...).] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/arm/versatilepb.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c index 8ae5392..7b5cb36 100644 --- a/hw/arm/versatilepb.c +++ b/hw/arm/versatilepb.c @@ -198,6 +198,15 @@ static void versatile_init(MachineState *machine, int board_id) int done_smc = 0; DriveInfo *dinfo; + if (machine->ram_size > 0x10000000) { + /* Device starting at address 0x10000000, + * and memory cannot overlap with devices. + * Refuse to run rather than behaving very confusingly. + */ + error_report("versatilepb: memory size must not exceed 256MB"); + exit(1); + } + if (!machine->cpu_model) { machine->cpu_model = "arm926"; }