From patchwork Tue May 28 20:48:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 1106559 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45D5ZB0291z9s55 for ; Wed, 29 May 2019 06:49:52 +1000 (AEST) Received: from localhost ([127.0.0.1]:42566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVj2a-00028E-Tz for incoming@patchwork.ozlabs.org; Tue, 28 May 2019 16:49:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:56962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVj1d-0001i5-0H for qemu-devel@nongnu.org; Tue, 28 May 2019 16:48:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVj1b-0008ER-UF for qemu-devel@nongnu.org; Tue, 28 May 2019 16:48:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34106) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hVj1b-0008CQ-MB for qemu-devel@nongnu.org; Tue, 28 May 2019 16:48:47 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A14513E2B9; Tue, 28 May 2019 20:48:46 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65EF560C47; Tue, 28 May 2019 20:48:42 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3E5AF16E1A; Tue, 28 May 2019 22:48:41 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 28 May 2019 22:48:38 +0200 Message-Id: <20190528204838.21568-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 28 May 2019 20:48:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] q35: split memory at 2G 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: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , =?utf-8?b?TMOhc3psw7Mgw4lyc2Vr?= , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Original q35 behavior was to split memory 2.75 GB, leaving space for the mmconfig bar at 0xb000000 and pci I/O window starting at 0xc0000000. Note: Those machine types have been removed from the qemu codebase meanwhile because they could not be live-migrated so there was little value in keeping them around. With the effort to allow for gigabyte-alignment of guest memory that behavior was changed: The split was moved to 2G, but only in case the memory didn't fit below 2.75 GB. So today the address space between 2G and 2,75G is not used for guest memory in typical use cases, where the guest memory sized at a power of two or a gigabyte number. But if you configure your guest with some odd amout of memory (such as 2.5G) the address space is used. This patch removes that oddity for 4.1+ machine types. The memory is splitted at 2G no matter what. Cc: László Érsek Signed-off-by: Gerd Hoffmann Acked-by: Laszlo Ersek --- include/hw/i386/pc.h | 1 + hw/i386/pc.c | 1 + hw/i386/pc_q35.c | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 43df7230a22b..d88179a3b21e 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -120,6 +120,7 @@ typedef struct PCMachineClass { /* RAM / address space compat: */ bool gigabyte_align; + bool gigabyte_split; bool has_reserved_memory; bool enforce_aligned_dimm; bool broken_reserved_end; diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2632b73f800b..828eeb36e398 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -2719,6 +2719,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) pcmc->smbios_defaults = true; pcmc->smbios_uuid_encoded = true; pcmc->gigabyte_align = true; + pcmc->gigabyte_split = true; pcmc->has_reserved_memory = true; pcmc->kvmclock_enabled = true; pcmc->enforce_aligned_dimm = true; diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 37dd350511a9..266671a9d544 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -143,8 +143,10 @@ static void pc_q35_init(MachineState *machine) * If it doesn't, we need to split it in chunks below and above 4G. * In any case, try to make sure that guest addresses aligned at * 1G boundaries get mapped to host addresses aligned at 1G boundaries. + * + * qemu 4.1+ machines: split at 2G unconditionally (gigabyte_split = true) */ - if (machine->ram_size >= 0xb0000000) { + if (machine->ram_size >= 0xb0000000 || pcmc->gigabyte_split) { lowmem = 0x80000000; } else { lowmem = 0xb0000000; @@ -376,8 +378,11 @@ DEFINE_Q35_MACHINE(v4_1, "pc-q35-4.1", NULL, static void pc_q35_4_0_machine_options(MachineClass *m) { + PCMachineClass *pcmc = PC_MACHINE_CLASS(m); + pc_q35_4_1_machine_options(m); m->alias = NULL; + pcmc->gigabyte_split = false; compat_props_add(m->compat_props, hw_compat_4_0, hw_compat_4_0_len); compat_props_add(m->compat_props, pc_compat_4_0, pc_compat_4_0_len); }