From patchwork Tue Feb 25 11:49:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 11403403 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 F2F371580 for ; Tue, 25 Feb 2020 12:08:42 +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 C99B52084E for ; Tue, 25 Feb 2020 12:08:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g7YbSzmS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C99B52084E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.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]:53772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6Z0z-0004ux-VK for patchwork-qemu-devel@patchwork.kernel.org; Tue, 25 Feb 2020 07:08:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:49512) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6Ykh-0000q6-AP for qemu-devel@nongnu.org; Tue, 25 Feb 2020 06:51:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6Ykd-0007QN-Cc for qemu-devel@nongnu.org; Tue, 25 Feb 2020 06:51:51 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:37504) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j6Ykd-0007IF-48 for qemu-devel@nongnu.org; Tue, 25 Feb 2020 06:51:47 -0500 Received: by mail-wr1-x42c.google.com with SMTP id l5so10127380wrx.4 for ; Tue, 25 Feb 2020 03:51:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nYheH1M1FZDgO9rIttffb0yGCNjxEvlOTqwWzEb9bFU=; b=g7YbSzmS4EcJTeVypOFvY7+wIyOCOZtVynZB7ZXTEGHJ9uJu8H3s1rUmENFnGTtHvz pceS5U3j4st4r1x+vpV8NfRLekEt0AIiPyy4tr4+ImA3I2Xsb2TBJyFZcI+Lr68xgnOF z37BH2TCV8PkHzbYqsb92CdMlcZfpNi1m9IauagrLXzOoD8vT/x0bfLuxEr9EBiFirtu +e7UiBxGC0uDYhmgObKv+2bIWWWDkuRIazPrItkLGFGYISjSgw0Bj0KtCNASS7g6UGQl xHFxMMho4QimswgWpKMce5QxWhlOVve8KJvZmFocC89bFHp3gqe1B7vId8z5h6j3quqb +5hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=nYheH1M1FZDgO9rIttffb0yGCNjxEvlOTqwWzEb9bFU=; b=WP/JW3LvnpehAKJRYEw+s/y2+MM6OpGCUcpIjKFX+gy1IQ0rZfPyPCU3345SgUcSSB AiBc/CQSeVSvMIDV7XExwcEJ8MMyMPyI2hGg3AT26AKmv+UE9sVp5jmra023KqLqSU4h Hj4aJQAVQ4DFVP7nU1yzplYxL2ekaO5r0F/DID2xnhwNINhMyWy+ayXiPeZtc75rhXL8 rMBTOmzZffMYfG+bddro8XXjTNEkBgLt+hvDJati9ygcjaySJ1NrpwIUnKK8YqzXI6sN 03ZXNd6xLFvYjvwLAVg5XWAgn8mwg/dl7ZlcyWd96Q5LJBNLUleinhFip4qWOXU/Gi9n 6Z4w== X-Gm-Message-State: APjAAAXEikQpEDMqySS4/Zxbk94tARF6nu2VetwZocxgvCh1MTKlt1Cr ZsWCqQZClAEQ/JDOoYKtNAr6qN62 X-Google-Smtp-Source: APXvYqzWxlV3B6uJFrx5lIxry0Oin176Yx68CeIWn7EJMtMdA8f9N5/hNynNo2VNmK3O8PYsozbWYw== X-Received: by 2002:adf:f3cd:: with SMTP id g13mr74403594wrp.54.1582631505640; Tue, 25 Feb 2020 03:51:45 -0800 (PST) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id b67sm3922326wmc.38.2020.02.25.03.51.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Feb 2020 03:51:45 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 042/136] x86/microvm: use memdev for RAM Date: Tue, 25 Feb 2020 12:49:32 +0100 Message-Id: <1582631466-13880-42-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582631466-13880-1-git-send-email-pbonzini@redhat.com> References: <1582631466-13880-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c 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: Igor Mammedov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Igor Mammedov memory_region_allocate_system_memory() API is going away, so replace it with memdev allocated MemoryRegion. The later is initialized by generic code, so board only needs to opt in to memdev scheme by providing MachineClass::default_ram_id and using MachineState::ram instead of manually initializing RAM memory region. Signed-off-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20200219160953.13771-43-imammedo@redhat.com> --- hw/i386/microvm.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index d234851..38d8e51 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -167,7 +167,7 @@ static void microvm_memory_init(MicrovmMachineState *mms) { MachineState *machine = MACHINE(mms); X86MachineState *x86ms = X86_MACHINE(mms); - MemoryRegion *ram, *ram_below_4g, *ram_above_4g; + MemoryRegion *ram_below_4g, *ram_above_4g; MemoryRegion *system_memory = get_system_memory(); FWCfgState *fw_cfg; ram_addr_t lowmem; @@ -214,12 +214,8 @@ static void microvm_memory_init(MicrovmMachineState *mms) x86ms->below_4g_mem_size = machine->ram_size; } - ram = g_malloc(sizeof(*ram)); - memory_region_allocate_system_memory(ram, NULL, "microvm.ram", - machine->ram_size); - ram_below_4g = g_malloc(sizeof(*ram_below_4g)); - memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", ram, + memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", machine->ram, 0, x86ms->below_4g_mem_size); memory_region_add_subregion(system_memory, 0, ram_below_4g); @@ -227,7 +223,8 @@ static void microvm_memory_init(MicrovmMachineState *mms) if (x86ms->above_4g_mem_size > 0) { ram_above_4g = g_malloc(sizeof(*ram_above_4g)); - memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", ram, + memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", + machine->ram, x86ms->below_4g_mem_size, x86ms->above_4g_mem_size); memory_region_add_subregion(system_memory, 0x100000000ULL, @@ -502,6 +499,7 @@ static void microvm_class_init(ObjectClass *oc, void *data) mc->auto_enable_numa_with_memhp = false; mc->default_cpu_type = TARGET_DEFAULT_CPU_TYPE; mc->nvdimm_supported = false; + mc->default_ram_id = "microvm.ram"; /* Avoid relying too much on kernel components */ mc->default_kernel_irqchip_split = true;