From patchwork Mon Oct 18 15:38:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12567357 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B62EAC433EF for ; Mon, 18 Oct 2021 15:42:19 +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 804AE60F36 for ; Mon, 18 Oct 2021 15:42:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 804AE60F36 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:48542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcUmH-0005m7-Tt for qemu-devel@archiver.kernel.org; Mon, 18 Oct 2021 11:42:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcUim-0001Oj-Fn; Mon, 18 Oct 2021 11:38:40 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:36479) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcUik-0006ik-Qw; Mon, 18 Oct 2021 11:38:40 -0400 Received: by mail-pj1-x1030.google.com with SMTP id qe4-20020a17090b4f8400b0019f663cfcd1so14770714pjb.1; Mon, 18 Oct 2021 08:38:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=bdgU6R5z57CuzHRXOdezfTsYjzZveMmJhy0dWnL8+fU=; b=pd/fHVUCNRy5mnBz7nai8gWdHInmi6v8d6OgVt+DppLr2r/zHlYH35GUjwmDYD83XM GWkPyAWIW5aZ2+38/Xdn9/PBr1qWUSujqwEAzRvzJXNS04DcV4wYaPGepuzapgMf8J7/ xmDIMknWBjZ/tUIRoyhNq3hxQcR7CMamli17jGbUbGgcP6j0z+QM/RAjcq0PohF0uCYh Uz/OI2Irubole/WejcjKGdkxU54fL0BIVnjan+0qgp5S9MLoi+++zKA4NaAjnzLS3VCL 0JTqZyVZHLndZr8R+/zhwWfrPRDPedQedVN3a0C4gG6f1wFKu0IOwKAP+8pTKY74DwWz AIJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=bdgU6R5z57CuzHRXOdezfTsYjzZveMmJhy0dWnL8+fU=; b=shgBcXAmnWGd2a2jxnL2EYJv2HvDUXVe8Pr2Na3dWMoIs0SBZcLbUCVOgu7NwGWIxq Ah0axSFkQBbw3ixfo7iN5f8ZV3uNEHkCq/ruYTfNLaHqtkJl1oLx+Adjc4HjMk0fovnI 71NmZ/NS+vVBTlyMxxP+qYhiN2uRc9wamGn3TXUuyi5hRP+wQgULaLbuiCVNhiKkPG+q lyFwa2p8xIJgZRRtrPGclGwPKCuP0cI2fVpNXZT+CexjpKPgo5tZrGUvxRG4KFYkkoBj KAyfDV+qyz+TYR1U8zo0Owj4SJULppYl+/9pyzTeu0GTNEGlxLb0SV1cTXSma+/XLcM9 jsuw== X-Gm-Message-State: AOAM530qx16x+SroUvJJAduC18ujOq19/62jthm2fJuuz6yOkdiA/u1W QIEUV/rpw0l3lJv0WlEYUm0= X-Google-Smtp-Source: ABdhPJyHDp152DIA0R/I1Mvzy1njp0joHt0kYbPsb96Hnk93/qupR+7ynuIzhD4AK7y4jvtL6nNZZA== X-Received: by 2002:a17:90a:4509:: with SMTP id u9mr49273381pjg.79.1634571517054; Mon, 18 Oct 2021 08:38:37 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id a30sm13899649pfr.64.2021.10.18.08.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 08:38:36 -0700 (PDT) From: Bin Meng To: Alistair Francis , Igor Mammedov , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH 1/6] hw/riscv: microchip_pfsoc: Use MachineState::ram and MachineClass::default_ram_id Date: Mon, 18 Oct 2021 23:38:24 +0800 Message-Id: <20211018153829.24382-1-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1030.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Using memory_region_init_ram(), which can't possibly handle vhost-user, and can't work as expected with '-numa node,memdev' options. Use MachineState::ram instead of manually initializing RAM memory region, as well as by providing MachineClass::default_ram_id to opt in to memdev scheme. Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé --- hw/riscv/microchip_pfsoc.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/riscv/microchip_pfsoc.c b/hw/riscv/microchip_pfsoc.c index e475b6d511..f10f55b488 100644 --- a/hw/riscv/microchip_pfsoc.c +++ b/hw/riscv/microchip_pfsoc.c @@ -459,7 +459,6 @@ static void microchip_icicle_kit_machine_init(MachineState *machine) const MemMapEntry *memmap = microchip_pfsoc_memmap; MicrochipIcicleKitState *s = MICROCHIP_ICICLE_KIT_MACHINE(machine); MemoryRegion *system_memory = get_system_memory(); - MemoryRegion *mem_low = g_new(MemoryRegion, 1); MemoryRegion *mem_low_alias = g_new(MemoryRegion, 1); MemoryRegion *mem_high = g_new(MemoryRegion, 1); MemoryRegion *mem_high_alias = g_new(MemoryRegion, 1); @@ -486,16 +485,13 @@ static void microchip_icicle_kit_machine_init(MachineState *machine) qdev_realize(DEVICE(&s->soc), NULL, &error_abort); /* Register RAM */ - memory_region_init_ram(mem_low, NULL, "microchip.icicle.kit.ram_low", - memmap[MICROCHIP_PFSOC_DRAM_LO].size, - &error_fatal); memory_region_init_alias(mem_low_alias, NULL, "microchip.icicle.kit.ram_low.alias", - mem_low, 0, + machine->ram, 0, memmap[MICROCHIP_PFSOC_DRAM_LO_ALIAS].size); memory_region_add_subregion(system_memory, memmap[MICROCHIP_PFSOC_DRAM_LO].base, - mem_low); + machine->ram); memory_region_add_subregion(system_memory, memmap[MICROCHIP_PFSOC_DRAM_LO_ALIAS].base, mem_low_alias); @@ -606,6 +602,7 @@ static void microchip_icicle_kit_machine_class_init(ObjectClass *oc, void *data) MICROCHIP_PFSOC_COMPUTE_CPU_COUNT; mc->min_cpus = MICROCHIP_PFSOC_MANAGEMENT_CPU_COUNT + 1; mc->default_cpus = mc->min_cpus; + mc->default_ram_id = "microchip.icicle.kit.ram_low"; /* * Map 513 MiB high memory, the mimimum required high memory size, because From patchwork Mon Oct 18 15:38:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12567359 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2128EC433EF for ; Mon, 18 Oct 2021 15:45:33 +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 BA3FA60EFE for ; Mon, 18 Oct 2021 15:45:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BA3FA60EFE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:54122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcUpP-00015X-Fm for qemu-devel@archiver.kernel.org; Mon, 18 Oct 2021 11:45:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcUio-0001TX-Jz; Mon, 18 Oct 2021 11:38:42 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:36695) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcUin-0006r7-2H; Mon, 18 Oct 2021 11:38:42 -0400 Received: by mail-pg1-x534.google.com with SMTP id 75so16650161pga.3; Mon, 18 Oct 2021 08:38:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=71nxyaPHNGZHuralusOsP6ey6dz0RCECflgf9KIk7mU=; b=GYXONXgpNcLY4vONm3X662C2LUYGmbWDzv2Zbqz9hUy7ksknOZtAOvoCJYp+7izuUw hVzNoUPT788Vz022HknWLknph8uQMeYmeI+ZQHLPgRoGXXyFq+H1oCXGjWWVD0mtAPjN G2XmzLe3FsfN6WKcbje/XrHuPuf+O3/4Qu5HergwItIZFGOqjLGteCOt9qm42eYT8kOJ 58bRBIr4QpuU6lGnZ6UGQZvYUY7KrRtNjcgHBNAkrKCqUa/k9/beJ3720uS2SuDGQrs1 dOlyM+ftaBOiYHGsLkU89Z7JbyzemVFvuVcJT791ub+tBoBhi4dLodawikERnkZzeWrG YikQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=71nxyaPHNGZHuralusOsP6ey6dz0RCECflgf9KIk7mU=; b=GivBsYLs4UmZ3fIy55KKhKih288rT1vz5RMO5GRODrntClZTo8vERuDc/RAAbmc1kt Lq7njqSIhPLCmKyYQZuf3Uj5VZqYsIGxRaHMZLu4H6E4AmsR+mIj7oIpLDjdZMm7aSpF byvGlHdBJXC6YBkggwmV6N6X0nd5nTawWjnGk2jj7jZcjmk9IiwWlaxOBtkdUmsTYc5R Xzz6oPdUVnfc2/IL+cR2uXL76GzRIXDlQnbCsbiRpzrQuGprz34FHJDQdeIQMQ3cDf2M lWCFujpFrJEd22nRxATG31z6lBtB3DY7IBbryS5NvKp9Nbe3iVYYNYlqrUiEY3HUMA/Y y4qA== X-Gm-Message-State: AOAM530D1Jk0xp6yQrFyS7Y9Ts3P7dNmmE9qRT9+n7tKuVVKiTDPbbs9 jGwS4ehiy4zmzoqymrYl/Y0= X-Google-Smtp-Source: ABdhPJwwnWcesdA5hOIjwcV15MIEaixDmY4k35BZ69TDyMytF4Jj8uzANsCL2IkkcYazQwKQitH7NA== X-Received: by 2002:a05:6a00:214d:b0:44d:35e9:4ce2 with SMTP id o13-20020a056a00214d00b0044d35e94ce2mr29655621pfk.13.1634571519003; Mon, 18 Oct 2021 08:38:39 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id a30sm13899649pfr.64.2021.10.18.08.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 08:38:38 -0700 (PDT) From: Bin Meng To: Alistair Francis , Igor Mammedov , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH 2/6] hw/riscv: opentitan: Use MachineState::ram and MachineClass::default_ram_id Date: Mon, 18 Oct 2021 23:38:25 +0800 Message-Id: <20211018153829.24382-2-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018153829.24382-1-bmeng.cn@gmail.com> References: <20211018153829.24382-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=bmeng.cn@gmail.com; helo=mail-pg1-x534.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Using memory_region_init_ram(), which can't possibly handle vhost-user, and can't work as expected with '-numa node,memdev' options. Use MachineState::ram instead of manually initializing RAM memory region, as well as by providing MachineClass::default_ram_id to opt in to memdev scheme. Signed-off-by: Bin Meng --- hw/riscv/opentitan.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/riscv/opentitan.c b/hw/riscv/opentitan.c index 9803ae6d70..c356293d29 100644 --- a/hw/riscv/opentitan.c +++ b/hw/riscv/opentitan.c @@ -67,17 +67,14 @@ static void opentitan_board_init(MachineState *machine) const MemMapEntry *memmap = ibex_memmap; OpenTitanState *s = g_new0(OpenTitanState, 1); MemoryRegion *sys_mem = get_system_memory(); - MemoryRegion *main_mem = g_new(MemoryRegion, 1); /* Initialize SoC */ object_initialize_child(OBJECT(machine), "soc", &s->soc, TYPE_RISCV_IBEX_SOC); qdev_realize(DEVICE(&s->soc), NULL, &error_abort); - memory_region_init_ram(main_mem, NULL, "riscv.lowrisc.ibex.ram", - memmap[IBEX_DEV_RAM].size, &error_fatal); memory_region_add_subregion(sys_mem, - memmap[IBEX_DEV_RAM].base, main_mem); + memmap[IBEX_DEV_RAM].base, machine->ram); if (machine->firmware) { riscv_load_firmware(machine->firmware, memmap[IBEX_DEV_RAM].base, NULL); @@ -95,6 +92,7 @@ static void opentitan_machine_init(MachineClass *mc) mc->init = opentitan_board_init; mc->max_cpus = 1; mc->default_cpu_type = TYPE_RISCV_CPU_IBEX; + mc->default_ram_id = "riscv.lowrisc.ibex.ram"; } DEFINE_MACHINE("opentitan", opentitan_machine_init) From patchwork Mon Oct 18 15:38:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12567363 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D68CC433EF for ; Mon, 18 Oct 2021 15:48:50 +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 4D02560F8F for ; Mon, 18 Oct 2021 15:48:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4D02560F8F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:58490 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcUsb-0004HX-8r for qemu-devel@archiver.kernel.org; Mon, 18 Oct 2021 11:48:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcUiq-0001ZB-Mf; Mon, 18 Oct 2021 11:38:44 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:50764) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcUio-00071M-TO; Mon, 18 Oct 2021 11:38:44 -0400 Received: by mail-pj1-x1034.google.com with SMTP id gn3so6970627pjb.0; Mon, 18 Oct 2021 08:38:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Xk5tZcB4gES1RHjvLAPIsV7P9s8Id8pMPfTjwDZZico=; b=f5hZt3Njr/aLlAQoJ7OdV3U4uT0XWMBceZjlrTz/me1MsPaWaYzkYnVb9mtmlVTQyo c93p6Q26pdeYtjQkTJAhC4jDN/peCxJcGO7OR7CLykYB1UMBXEltG1Pb+GveKgCYBxQi 5kAc2PFehI5ZIyqhTUccprUquechSXTB4E+9i5XVcyndufze6XpuXp7jerOaux5hBQMD oACjtBqwjOePA1MVfkRe+9dP5y62Uztc5sxwZfn8NFbbKQ/itN0JjBwCQdOXitUVYeXg XCEKCEfkTxrqyAczpOUzqVtlmvNgM+unabNyLOK7bcsDCcdITiLXk+oBlrWrS/eoE890 Im/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Xk5tZcB4gES1RHjvLAPIsV7P9s8Id8pMPfTjwDZZico=; b=P0k9HaMg02UkvN75IGPiAmQkKYEvkcFHzaU2w32UpIKlkD28aCx1CvNeFItYa6jVHw ue8RSGCEWd3JDzn+P7N8+VenUPBLWjr+4raSDcOGmupqVJc0VtVOVp0u6CfjKHIEIL/T 0EGkVCGXMqIsKlNoW0EaLQ1SB1yI2Y8vvJmy6I1Pu5LCnRJAn9BE/a7hfsL2UTr/amy+ c2ibHvTQmITOAO4TsPRHaXr49SgXN8yXOfukp0M+L4CJwDGJ6lVZtv7VLL78OyXzCoQT 7cRqHiDA1tEkk0CzL+/Pf0aXzyW9++NsPn/OkJ38PmzZJMqPJm8TyUQ2tv9ESNTs0u06 emLg== X-Gm-Message-State: AOAM5312OlbnUhUaZnIkExHJc8bWW92j1srql+rjCs8jTsd1mmbiekg5 xZvtB97wwOqo/b5pCDYHl7kFrmfMRl4= X-Google-Smtp-Source: ABdhPJyvphSGdWdPvYQ7zJ5fgJHWdzW5QW9+hibYWyz7upasvaxoqYoo3WNfjQT7koy8ZuH05vyDkw== X-Received: by 2002:a17:90a:4dc6:: with SMTP id r6mr48473374pjl.5.1634571520941; Mon, 18 Oct 2021 08:38:40 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id a30sm13899649pfr.64.2021.10.18.08.38.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 08:38:40 -0700 (PDT) From: Bin Meng To: Alistair Francis , Igor Mammedov , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH 3/6] hw/riscv: shakti_c: Use MachineState::ram and MachineClass::default_ram_id Date: Mon, 18 Oct 2021 23:38:26 +0800 Message-Id: <20211018153829.24382-3-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018153829.24382-1-bmeng.cn@gmail.com> References: <20211018153829.24382-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1034.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Using memory_region_init_ram(), which can't possibly handle vhost-user, and can't work as expected with '-numa node,memdev' options. Use MachineState::ram instead of manually initializing RAM memory region, as well as by providing MachineClass::default_ram_id to opt in to memdev scheme. Signed-off-by: Bin Meng Reviewed-by: Igor Mammedov --- hw/riscv/shakti_c.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/riscv/shakti_c.c b/hw/riscv/shakti_c.c index d7d1f91fa5..90e2cf609f 100644 --- a/hw/riscv/shakti_c.c +++ b/hw/riscv/shakti_c.c @@ -45,7 +45,6 @@ static void shakti_c_machine_state_init(MachineState *mstate) { ShaktiCMachineState *sms = RISCV_SHAKTI_MACHINE(mstate); MemoryRegion *system_memory = get_system_memory(); - MemoryRegion *main_mem = g_new(MemoryRegion, 1); /* Allow only Shakti C CPU for this platform */ if (strcmp(mstate->cpu_type, TYPE_RISCV_CPU_SHAKTI_C) != 0) { @@ -59,11 +58,9 @@ static void shakti_c_machine_state_init(MachineState *mstate) qdev_realize(DEVICE(&sms->soc), NULL, &error_abort); /* register RAM */ - memory_region_init_ram(main_mem, NULL, "riscv.shakti.c.ram", - mstate->ram_size, &error_fatal); memory_region_add_subregion(system_memory, shakti_c_memmap[SHAKTI_C_RAM].base, - main_mem); + mstate->ram); /* ROM reset vector */ riscv_setup_rom_reset_vec(mstate, &sms->soc.cpus, @@ -88,6 +85,7 @@ static void shakti_c_machine_class_init(ObjectClass *klass, void *data) mc->desc = "RISC-V Board compatible with Shakti SDK"; mc->init = shakti_c_machine_state_init; mc->default_cpu_type = TYPE_RISCV_CPU_SHAKTI_C; + mc->default_ram_id = "riscv.shakti.c.ram"; } static const TypeInfo shakti_c_machine_type_info = { From patchwork Mon Oct 18 15:38:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12567355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB896C433F5 for ; Mon, 18 Oct 2021 15:41:28 +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 70B2260F44 for ; Mon, 18 Oct 2021 15:41:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 70B2260F44 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:46790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcUlT-0004aH-HL for qemu-devel@archiver.kernel.org; Mon, 18 Oct 2021 11:41:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcUit-0001g2-Am; Mon, 18 Oct 2021 11:38:47 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:42781) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcUiq-00075U-Ir; Mon, 18 Oct 2021 11:38:47 -0400 Received: by mail-pj1-x1029.google.com with SMTP id nn3-20020a17090b38c300b001a03bb6c4ebso268459pjb.1; Mon, 18 Oct 2021 08:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=lV+aLeVSqXPlal1y7APPh6mTOPbkMZ+BIaiDrhI+Vow=; b=YOlrHII3YNTZWQ2FjJlObwbHgo9qn0TRMsEUqhO1Cpn3e+DFPgWsjVSHTxv5xvPrkr HVT+XixdGyUiAezzhchRdPqPYfIsvqBiDoA8gg/JJiuDIXtEgGMeiQmE+/TKY4UZ97v6 CQjk+pcb6gQSlFKjolQB5QostNAeCw2HxVXc5q4VLQpbQtSu0i3S09k5YrU0uRjei/Eb r/Y62sFcB3weWFxyZJleiKJqqnl4I5wC5NADXS0N7FBl9rHnoLA2hKTRQf5JuxthMORy 2cD04+ywKCR/2Iyr1pds+IRBnXTHk9tXKbLrlEm+4Hm040EntPkDw8+mRaW3w52vT9fB 9faQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lV+aLeVSqXPlal1y7APPh6mTOPbkMZ+BIaiDrhI+Vow=; b=eJob1rU9ymydgFHY650stwnIrqdEdhboA42iU94jjIBbIIGDL+/ffHMX9PaEw+j5aI ZQwrguyIrA0fFjtwn4QQ+c0Er+YE0iMgTzx9P6aB/h0g68zNOzeGyvG611cwB7YqNIqu +8jwfIPzemkTU5TnSSpqGah0HsiqxAOCnLbpGA2a/TtoMyZQj3FTr3vwpUAkwHIgh1VL GdGx7OQPY5ooIvJEkYvz3dj6kB84Izbr2dJWsNPWPhLrv1JnTFF7VzpLCRgEJKgImZfl kEvpZXYIpk8sWur/Zo3jO2BNn0cx264a8s7LV40iYJxD8xW8NkhSfBZG0PS/Ip/ZibUv NymQ== X-Gm-Message-State: AOAM530DcrzSjos6659qaKRVwg8V2jOsGlB0iKnGyjiUNaxqHJWPaQiB FiRBYqXMWwwJLELG7KxgO0w= X-Google-Smtp-Source: ABdhPJyVu+41rSRH4eqACYdOvtX4MHvNgabsj1PloH4/jZqgxNbosKAz+3btAl/Jo4wh2N4k+tO8Mg== X-Received: by 2002:a17:902:d353:b0:13f:a15d:3d71 with SMTP id l19-20020a170902d35300b0013fa15d3d71mr14900023plk.77.1634571522915; Mon, 18 Oct 2021 08:38:42 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id a30sm13899649pfr.64.2021.10.18.08.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 08:38:42 -0700 (PDT) From: Bin Meng To: Alistair Francis , Igor Mammedov , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH 4/6] hw/riscv: sifive_e: Use MachineState::ram and MachineClass::default_ram_id Date: Mon, 18 Oct 2021 23:38:27 +0800 Message-Id: <20211018153829.24382-4-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018153829.24382-1-bmeng.cn@gmail.com> References: <20211018153829.24382-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x1029.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Using memory_region_init_ram(), which can't possibly handle vhost-user, and can't work as expected with '-numa node,memdev' options. Use MachineState::ram instead of manually initializing RAM memory region, as well as by providing MachineClass::default_ram_id to opt in to memdev scheme. Signed-off-by: Bin Meng --- hw/riscv/sifive_e.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c index 6e95ea5896..caae860664 100644 --- a/hw/riscv/sifive_e.c +++ b/hw/riscv/sifive_e.c @@ -75,7 +75,6 @@ static void sifive_e_machine_init(MachineState *machine) SiFiveEState *s = RISCV_E_MACHINE(machine); MemoryRegion *sys_mem = get_system_memory(); - MemoryRegion *main_mem = g_new(MemoryRegion, 1); int i; /* Initialize SoC */ @@ -83,10 +82,8 @@ static void sifive_e_machine_init(MachineState *machine) qdev_realize(DEVICE(&s->soc), NULL, &error_abort); /* Data Tightly Integrated Memory */ - memory_region_init_ram(main_mem, NULL, "riscv.sifive.e.ram", - memmap[SIFIVE_E_DEV_DTIM].size, &error_fatal); memory_region_add_subregion(sys_mem, - memmap[SIFIVE_E_DEV_DTIM].base, main_mem); + memmap[SIFIVE_E_DEV_DTIM].base, machine->ram); /* Mask ROM reset vector */ uint32_t reset_vec[4]; @@ -142,6 +139,7 @@ static void sifive_e_machine_class_init(ObjectClass *oc, void *data) mc->init = sifive_e_machine_init; mc->max_cpus = 1; mc->default_cpu_type = SIFIVE_E_CPU; + mc->default_ram_id = "riscv.sifive.e.ram"; object_class_property_add_bool(oc, "revb", sifive_e_machine_get_revb, sifive_e_machine_set_revb); From patchwork Mon Oct 18 15:38:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12567353 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA1AFC433FE for ; Mon, 18 Oct 2021 15:41:21 +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 3C2B360F8F for ; Mon, 18 Oct 2021 15:41:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3C2B360F8F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:46546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcUlL-0004Nd-6Y for qemu-devel@archiver.kernel.org; Mon, 18 Oct 2021 11:41:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51334) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcUiv-0001jj-A7; Mon, 18 Oct 2021 11:38:49 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]:51844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcUis-00077j-La; Mon, 18 Oct 2021 11:38:49 -0400 Received: by mail-pj1-x102d.google.com with SMTP id kk10so12522409pjb.1; Mon, 18 Oct 2021 08:38:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=fOcPWRV3PRZa0OEMByLvfqr4EjTKYJQhTu4tEYjQoNc=; b=bH99UXiQuOunuMo6E5HYlm+i22oo1n0kQJBPQLXghlrMIa1WX2jtEd74MJArkVggP+ iIGg5Y9ZZe1dRijZDpb/nFMml4dOiY6TxYNAdb3/62rPQnUhf9Rrk838l1em16X9mCSI rgHWtLHldDTixHDAVYUB2DyRaehgSWZgeP5pyFQl4Kr0OKPQ7TQBxAIkwQfsQBd9IzKy 4hC2xMae7xEEqTkEbG59k+m9nnPN9geDxcJo9Lph/yWxRiT2I128QsrHvbSBzvp//tfB OY+E84yJCnmM+QbtregRPmOUCd7HEfwS8WsZDDKkB6p0bb3EX1DMIm4Yx1xZ1wgjumGp Yfaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fOcPWRV3PRZa0OEMByLvfqr4EjTKYJQhTu4tEYjQoNc=; b=H0N/6jkAAT+V671Vei1dAjX3Et4CC1/sU0QdjbZYVqeAnFVoH5iWG9kjs4mrMWiDQR 3ZvSfA17cB1BkWSJMQUIvTgfgHKxvabNGeYNCjUUcQ6HvdgG5DnFyJNesxcWFfeSvEhE 4yDwxYGa+ZNVYQjAnPS2qOEsFUbXOw4p/QxrQUap7k0RLqS1YiduXtEy8xQQQ0HxWxgc OneEuHM67BaPLqbJqSjfLZXmNrHLaOKpbRR9pPYpnGjidnXtLp3+W4Dv1gypl9zAIGk0 +z3oOvok3wmgCnY41FC4XpOoXH0BGXpr1INd7We6yl6jmoHeZrE4WklmopTGkvKCWjWh OJ2g== X-Gm-Message-State: AOAM532tqFuwD30HyTjhHCj7FPYcZZQXAAPpkjdaORqeu5/I86OGYnqY kHhBBJHzJtTE+1WxqLA0GU4= X-Google-Smtp-Source: ABdhPJxCfueAE1N8IjVoK5E1unFdTPhOACOkJCxpz3+agTHEkGRt9FMzgduIJwaMG7trzaccbqTGJw== X-Received: by 2002:a17:90a:62ca:: with SMTP id k10mr34121344pjs.38.1634571524865; Mon, 18 Oct 2021 08:38:44 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id a30sm13899649pfr.64.2021.10.18.08.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 08:38:44 -0700 (PDT) From: Bin Meng To: Alistair Francis , Igor Mammedov , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH 5/6] hw/riscv: sifive_u: Use MachineState::ram and MachineClass::default_ram_id Date: Mon, 18 Oct 2021 23:38:28 +0800 Message-Id: <20211018153829.24382-5-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018153829.24382-1-bmeng.cn@gmail.com> References: <20211018153829.24382-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Using memory_region_init_ram(), which can't possibly handle vhost-user, and can't work as expected with '-numa node,memdev' options. Use MachineState::ram instead of manually initializing RAM memory region, as well as by providing MachineClass::default_ram_id to opt in to memdev scheme. Signed-off-by: Bin Meng Reviewed-by: Igor Mammedov --- hw/riscv/sifive_u.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index fc5790b8ce..0217006c27 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -528,7 +528,6 @@ static void sifive_u_machine_init(MachineState *machine) const MemMapEntry *memmap = sifive_u_memmap; SiFiveUState *s = RISCV_U_MACHINE(machine); MemoryRegion *system_memory = get_system_memory(); - MemoryRegion *main_mem = g_new(MemoryRegion, 1); MemoryRegion *flash0 = g_new(MemoryRegion, 1); target_ulong start_addr = memmap[SIFIVE_U_DEV_DRAM].base; target_ulong firmware_end_addr, kernel_start_addr; @@ -549,10 +548,8 @@ static void sifive_u_machine_init(MachineState *machine) qdev_realize(DEVICE(&s->soc), NULL, &error_abort); /* register RAM */ - memory_region_init_ram(main_mem, NULL, "riscv.sifive.u.ram", - machine->ram_size, &error_fatal); memory_region_add_subregion(system_memory, memmap[SIFIVE_U_DEV_DRAM].base, - main_mem); + machine->ram); /* register QSPI0 Flash */ memory_region_init_ram(flash0, NULL, "riscv.sifive.u.flash0", @@ -748,6 +745,7 @@ static void sifive_u_machine_class_init(ObjectClass *oc, void *data) mc->min_cpus = SIFIVE_U_MANAGEMENT_CPU_COUNT + 1; mc->default_cpu_type = SIFIVE_U_CPU; mc->default_cpus = mc->min_cpus; + mc->default_ram_id = "riscv.sifive.u.ram"; object_class_property_add_bool(oc, "start-in-flash", sifive_u_machine_get_start_in_flash, From patchwork Mon Oct 18 15:38:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 12567365 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49AD4C433EF for ; Mon, 18 Oct 2021 15:51:11 +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 10BB960F93 for ; Mon, 18 Oct 2021 15:51:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 10BB960F93 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:60978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcUus-0006Gz-3V for qemu-devel@archiver.kernel.org; Mon, 18 Oct 2021 11:51:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51346) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcUj0-0001ze-Eb; Mon, 18 Oct 2021 11:38:54 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]:42787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcUiv-0007BE-MM; Mon, 18 Oct 2021 11:38:54 -0400 Received: by mail-pj1-x102f.google.com with SMTP id nn3-20020a17090b38c300b001a03bb6c4ebso268621pjb.1; Mon, 18 Oct 2021 08:38:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=qDWxU5X18UexLcxgTJj2qUaxj382cCI3tPFP3fZWboY=; b=bo76mUsxKmQzM6FKmdAlB0+/dJD17R666si2mqhTqWxcddzaD3eC9NyRAbk59yZajE 2Sn25lWpBcOXMR0Ej15tpxZRYpWhLH40jBBqkD05jmQBZcIstkgOqA3wnSQUdW6o3Ick 41JoiPUPrwwLWXODGKkfO0Jxd86zlqFlr5MrEmqusQn6a9LBPlgCTMRCflLl0wFVT3Tk 94yQD3BkNKt7TWFXNlaHX3Q7exK697FpBAPtes5MpASwyQWC0T4sN8rpEnnJ+6rxWC4O 2oKbgjfRtFp4DOS7hZjMy/Lwy5lmIkzRZYcYGZZ1CxNN+dm5QqUrtETRxuyl6I5hQP6m QcHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qDWxU5X18UexLcxgTJj2qUaxj382cCI3tPFP3fZWboY=; b=z9cb9JYiyr0HEqGkWUjg/LHoqwHrSjz4sI4/dOKBooUEbiBNWrhjlbxkn9gM634fSd pNcq8K10130Kug0HpJPQqt+oi47T2ZFlMfEl4mkfFgOD1OlXlHMtZNRHJ2ryj3oyUfkQ /htzfrTJjVHkIfX6dzBWx4ljh+wUvmnBrSyZndrVpbbV0cc2dqDTGFDVYXkCjhQK5Gt5 rVylG80aLGWd9aMbQGDKnC5hZVhzsBKn5MM+KisyyXoUYL7WH7banrEOZw9n2zunwPFm a7mqTwGuiwWM1vCIiOsXuOEUgIlAqrGeuoPS7ZXyaVn9DKeTa0hXjn3vCf8WYHEztOKE fyFg== X-Gm-Message-State: AOAM531Q8RzI56M5GGNNtOn3313XGhEQ/Vpxi0hL2MdXn1+yAn8twewt IyJKGADShZ/iiQJ7lG4cA2Q= X-Google-Smtp-Source: ABdhPJwbe/S81w8FF7cfV6XE3iBOkT6FWGMXmaT/qrhzXYxZ6ALy6Oxk2FiSvPZywyLafYY/OGsuYw== X-Received: by 2002:a17:90a:2:: with SMTP id 2mr49039345pja.77.1634571526823; Mon, 18 Oct 2021 08:38:46 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id a30sm13899649pfr.64.2021.10.18.08.38.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Oct 2021 08:38:46 -0700 (PDT) From: Bin Meng To: Alistair Francis , Igor Mammedov , qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH 6/6] hw/riscv: spike: Use MachineState::ram and MachineClass::default_ram_id Date: Mon, 18 Oct 2021 23:38:29 +0800 Message-Id: <20211018153829.24382-6-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018153829.24382-1-bmeng.cn@gmail.com> References: <20211018153829.24382-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=bmeng.cn@gmail.com; helo=mail-pj1-x102f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Using memory_region_init_ram(), which can't possibly handle vhost-user, and can't work as expected with '-numa node,memdev' options. Use MachineState::ram instead of manually initializing RAM memory region, as well as by providing MachineClass::default_ram_id to opt in to memdev scheme. Signed-off-by: Bin Meng Reviewed-by: Igor Mammedov --- hw/riscv/spike.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c index 79ae355ae2..288d69cd9f 100644 --- a/hw/riscv/spike.c +++ b/hw/riscv/spike.c @@ -180,7 +180,6 @@ static void spike_board_init(MachineState *machine) const MemMapEntry *memmap = spike_memmap; SpikeState *s = SPIKE_MACHINE(machine); MemoryRegion *system_memory = get_system_memory(); - MemoryRegion *main_mem = g_new(MemoryRegion, 1); MemoryRegion *mask_rom = g_new(MemoryRegion, 1); target_ulong firmware_end_addr, kernel_start_addr; uint32_t fdt_load_addr; @@ -239,10 +238,8 @@ static void spike_board_init(MachineState *machine) } /* register system main memory (actual RAM) */ - memory_region_init_ram(main_mem, NULL, "riscv.spike.ram", - machine->ram_size, &error_fatal); memory_region_add_subregion(system_memory, memmap[SPIKE_DRAM].base, - main_mem); + machine->ram); /* create device tree */ create_fdt(s, memmap, machine->ram_size, machine->kernel_cmdline, @@ -326,6 +323,7 @@ static void spike_machine_class_init(ObjectClass *oc, void *data) mc->cpu_index_to_instance_props = riscv_numa_cpu_index_to_props; mc->get_default_cpu_node_id = riscv_numa_get_default_cpu_node_id; mc->numa_mem_supported = true; + mc->default_ram_id = "riscv.spike.ram"; } static const TypeInfo spike_machine_typeinfo = {