From patchwork Tue Mar 3 00:41:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 11416915 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6450114B4 for ; Tue, 3 Mar 2020 00:43:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EC85024673 for ; Tue, 3 Mar 2020 00:43:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=flygoat.com header.i=jiaxun.yang@flygoat.com header.b="a9dUN8cI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC85024673 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=flygoat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:40222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j8veL-0007Oh-Lu for patchwork-qemu-devel@patchwork.kernel.org; Mon, 02 Mar 2020 19:43:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44190) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j8vdr-0006xU-F9 for qemu-devel@nongnu.org; Mon, 02 Mar 2020 19:42:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j8vdq-0002dQ-9T for qemu-devel@nongnu.org; Mon, 02 Mar 2020 19:42:35 -0500 Received: from sender3-op-o12.zoho.com.cn ([124.251.121.243]:17994) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j8vdp-0002Zr-Hu for qemu-devel@nongnu.org; Mon, 02 Mar 2020 19:42:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1583196117; s=mail; d=flygoat.com; i=jiaxun.yang@flygoat.com; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=ip62UxsLoBVBHDGOYwMikMPn9kC1/8udU8YlQmWN06Y=; b=a9dUN8cIVHJr93jwpvRPcnrQ9cGXVEwlfXY6VfviBvYPxEyR9EzOqw6VhBQwtoM1 BNJyWC8ocuhwrNFSKLvf8XbR4u5BLjVwJr+HLcDQg6Isx8DOi86ghyUJhdldDZsFFv1 QGgB2WA9t91tcKLDuVyvaibMXdKAqKAO7O5nz0x4= Received: from localhost.localdomain (39.155.141.144 [39.155.141.144]) by mx.zoho.com.cn with SMTPS id 1583196112368648.408430311324; Tue, 3 Mar 2020 08:41:52 +0800 (CST) From: Jiaxun Yang To: qemu-devel@nongnu.org Message-ID: <20200303004137.1099502-1-jiaxun.yang@flygoat.com> Subject: [PATCH v1] mips/mips_malta: Allow more than 2G RAM Date: Tue, 3 Mar 2020 08:41:37 +0800 X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200228032613.1049955-1-jiaxun.yang@flygoat.com> References: <20200228032613.1049955-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 X-ZohoCNMailClient: External X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 124.251.121.243 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: imammedo@redhat.com, philmd@redhat.com, Jiaxun Yang , amarkovic@wavecomp.com, Yunqiang Su Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" When malta is coupled with MIPS64 cpu which have 64bit address space, it is possible to have more than 2G RAM. So we removed ram_size check and overwrite memory layout for these targets. Signed-off-by: Jiaxun Yang Suggested-by: Yunqiang Su --- v1: Do not overwrite cmdline when we don't have highmem. --- hw/mips/mips_malta.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index 6e7ba9235d..4267958f35 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -98,7 +98,8 @@ typedef struct { } MaltaState; static struct _loaderparams { - int ram_size, ram_low_size; + unsigned int ram_low_size; + ram_addr_t ram_size; const char *kernel_filename; const char *kernel_cmdline; const char *initrd_filename; @@ -1023,6 +1024,7 @@ static int64_t load_kernel(void) { int64_t kernel_entry, kernel_high, initrd_size; long kernel_size; + char mem_cmdline[128]; ram_addr_t initrd_offset; int big_endian; uint32_t *prom_buf; @@ -1099,20 +1101,33 @@ static int64_t load_kernel(void) prom_buf = g_malloc(prom_size); prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_filename); + + memset(&mem_cmdline[0], 0, sizeof(mem_cmdline)); + if (loaderparams.ram_size > 0x10000000) { + /* + * Always use cmdline to overwrite mem layout + * as kernel may reject large emesize. + */ + sprintf(&mem_cmdline[0], + "mem=0x10000000@0x00000000 mem=0x%" PRIx64 "@0x90000000", + loaderparams.ram_size - 0x10000000); + } + if (initrd_size > 0) { prom_set(prom_buf, prom_index++, - "rd_start=0x%" PRIx64 " rd_size=%" PRId64 " %s", - xlate_to_kseg0(NULL, initrd_offset), + "%s rd_start=0x%" PRIx64 " rd_size=%" PRId64 " %s", + &mem_cmdline[0], xlate_to_kseg0(NULL, initrd_offset), initrd_size, loaderparams.kernel_cmdline); } else { - prom_set(prom_buf, prom_index++, "%s", loaderparams.kernel_cmdline); + prom_set(prom_buf, prom_index++, "%s %s", &mem_cmdline[0], + loaderparams.kernel_cmdline); } prom_set(prom_buf, prom_index++, "memsize"); prom_set(prom_buf, prom_index++, "%u", loaderparams.ram_low_size); prom_set(prom_buf, prom_index++, "ememsize"); - prom_set(prom_buf, prom_index++, "%u", loaderparams.ram_size); + prom_set(prom_buf, prom_index++, "%lu", loaderparams.ram_size); prom_set(prom_buf, prom_index++, "modetty0"); prom_set(prom_buf, prom_index++, "38400n8r"); @@ -1253,12 +1268,14 @@ void mips_malta_init(MachineState *machine) /* create CPU */ mips_create_cpu(machine, s, &cbus_irq, &i8259_irq); - /* allocate RAM */ +#ifdef TARGET_MIPS32 + /* MIPS32 won't accept more than 2GiB RAM due to limited address space */ if (ram_size > 2 * GiB) { error_report("Too much memory for this machine: %" PRId64 "MB," " maximum 2048MB", ram_size / MiB); exit(1); } +#endif /* register RAM at high address where it is undisturbed by IO */ memory_region_add_subregion(system_memory, 0x80000000, machine->ram);