From patchwork Thu Feb 2 04:52:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13125299 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 1C28FC05027 for ; Thu, 2 Feb 2023 04:55:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNRaX-0004Qt-BM; Wed, 01 Feb 2023 23:52:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNRaO-0004OH-Dp for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:37 -0500 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNRaM-0001CL-19 for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:35 -0500 Received: by mail-pj1-x1035.google.com with SMTP id m11so861498pji.0 for ; Wed, 01 Feb 2023 20:52:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vkbdYSdTPAunD7cPLxq7KYAERY/Wq71c7F7Rn6sHgkM=; b=fg6kq5z/gbMFstiS9vd+MpqA6TXfLy3ZCY0SKqkT8T6sBVxXeyJWIPCk5v3uUC6qwA d0MISL7T+NtzNEA0Jd5Xin3UyB33To7OPXHCuBYc21jAiEcQVBNbD8aRwDzMnnlpaAOe 2l/YPq8TZF7DO+dsNrJGeXq226EfHVxbQlA9cEecmHZNE87k4I6nVVavgRRy/ClaWlHu 42lgfz5FOSylu/WMsufb7V64ntVkbSOvvOFhSsT5uIUSONB5EIOyMmgLXUvuR37nfLEW Aqj1e1FKepzne/CRbMHU/UTq/vGkfXDYeNhX7feBT6cNUNOZnQyv6V8wX1CXgeNuCNC2 xkUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vkbdYSdTPAunD7cPLxq7KYAERY/Wq71c7F7Rn6sHgkM=; b=hcqg8pa8Zz1NTOEFzXsRA7TjkkEYOxzUEhitU+LjGqqLQPYrgJz2qLSX0Cix0ZvHzj zg03YI3YOBWISdqPwk6frFLX5M4TIT1KzM7XZhQ2KCO+FNDhjHFcXVmAhqwzBhkwqshq 3owi7GF4o7UYBRAzNkUv7O0syJwrrwTapNRjfTPekULr8FkA1gpXyznLobx15jvM0w5Z WBZE7L3bkRG3QkoqNb47KxMxwQwGNO1IQf3KrX86UuvmR+5IScljXK+4w8rjjdfMfVH3 TdO6roTiVpaQNit8b2hGn28Ke0ylRiYcBCTZPOX38CaEqu4qbDEJ9KCATXWJyndQQ1VI sDkg== X-Gm-Message-State: AO0yUKXl5SoQKAF4sdq+bbob5ZLQKs2SOM+rvGgRMu0rDPadFuelz/HF qiRTkF2cbqHs1QZ47DSpMvpvDw== X-Google-Smtp-Source: AK7set8/vfPsKeFuytlbV/xCbo1GyWt9cj1LAVaYxFz9rA1U9zKvyjd1+zOzOr3a4kZ51Cqg/JKtRQ== X-Received: by 2002:a17:902:e742:b0:196:7103:259f with SMTP id p2-20020a170902e74200b001967103259fmr6567627plf.7.1675313552705; Wed, 01 Feb 2023 20:52:32 -0800 (PST) Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id w10-20020a170902d70a00b001965540395fsm11222265ply.105.2023.02.01.20.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 20:52:32 -0800 (PST) From: Sunil V L To: Palmer Dabbelt , Alistair Francis , Bin Meng Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Andrew Jones , Anup Patel , Atish Kumar Patra , Sunil V L Subject: [PATCH 01/10] hw/riscv/virt: Add OEM_ID and OEM_TABLE_ID fields Date: Thu, 2 Feb 2023 10:22:14 +0530 Message-Id: <20230202045223.2594627-2-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230202045223.2594627-1-sunilvl@ventanamicro.com> References: <20230202045223.2594627-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x1035.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, 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.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org ACPI needs OEM_ID and OEM_TABLE_ID for the machine. Add these fields in the RISCVVirtState structure and initialize with default values. Signed-off-by: Sunil V L Reviewed-by: Bin Meng Acked-by: Alistair Francis --- hw/riscv/virt.c | 4 ++++ include/hw/riscv/virt.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index a061151a6f..7ad9fda20c 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -49,6 +49,7 @@ #include "hw/pci/pci.h" #include "hw/pci-host/gpex.h" #include "hw/display/ramfb.h" +#include "hw/acpi/aml-build.h" /* * The virt machine physical address space used by some of the devices @@ -1512,6 +1513,9 @@ static void virt_machine_init(MachineState *machine) } virt_flash_map(s, system_memory); + s->oem_id = g_strndup(ACPI_BUILD_APPNAME6, 6); + s->oem_table_id = g_strndup(ACPI_BUILD_APPNAME8, 8); + /* create device tree */ create_fdt(s, memmap); diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index b3d26135c0..6c7885bf89 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -56,6 +56,8 @@ struct RISCVVirtState { bool have_aclint; RISCVVirtAIAType aia_type; int aia_guests; + char *oem_id; + char *oem_table_id; }; enum { From patchwork Thu Feb 2 04:52:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13125292 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 891C4C61DA4 for ; Thu, 2 Feb 2023 04:53:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNRaU-0004Pu-Oq; Wed, 01 Feb 2023 23:52:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNRaQ-0004Om-Fy for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:39 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNRaO-0001Cj-Tx for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:38 -0500 Received: by mail-pj1-x102c.google.com with SMTP id j5so803087pjn.5 for ; Wed, 01 Feb 2023 20:52:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=psDfltxj5Ers806tup7ZzDpU09NdsTTfAuvz4bp4HA0=; b=G65PAHTUhps7Obo7ZgapY3i2ciMQks8KFdklGRdbzZ3Pl4PvHhmDHmaskbkA9UIELG BccRsOGDvJ93S2uwVQFlVltKDoYlE/1F370HrSNKAvmwxYWMbowY7nV4VDqYAX3CCf7M YZ3Pc5V1buAjHILpGHptfDCTscMWQRGNdTsWj7LIPp49rtnTRhkbnFmBTEwsKHKxp+H2 WNK4qiU/xJzbaAvEx8x/GVuuWJ8CuaZT2teBt9S62RXu/0kMH2TjMig2nHsvaeicR6aO MnaU0MJHXu5UMxhhYB/DtHxLjPX2HSddBV4NGs9PLnwlCX1RVG2RwU2J0Vgvr8htTHgt Behg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=psDfltxj5Ers806tup7ZzDpU09NdsTTfAuvz4bp4HA0=; b=1gWpRjcFMaAlKp8zAQA5VaWOU0lWiNzU86cmmPbxWFx5JGb3hVpYBIg9VRMNbRUsIZ 7gO07S38hAKRqcriWAgWsTKgDrrq3czeN64YzV1GsqE0ZV/g4Y6VBnv/JMBii0MjRHJY HziqTiuIi6zWqIRn6GMcoY6pLOCXVFfR6N/ydXuplZQ7LQj/m056SGuGkYHyFz0hi5Hr Fe5dinv83ACPFajPzLwMVSCDURPdLS0jsewVixtV+75tOsYoeUmJ4IHJS4Lsm0M3l34a g90VsAs/XQA8OPPSpo1qqiJ9EYbqYBe1RHF2Mdd73Frwujb2dchy26C3+8BuVPI9nMVH Rebw== X-Gm-Message-State: AO0yUKWVfXevsJz1Vb61IjRsaj9kxxkMTesTSjmt7t6bbjeBIa+1F8J+ Ii7ItphxEL2J5EanzDpjBVx3Vw== X-Google-Smtp-Source: AK7set9m9Ndjq4NbB3ZRj5wAEgJBf5bhVWMxI8WP8xizj78WufxHBcGDp3zOGzvVZVaPa+vX6ZghGQ== X-Received: by 2002:a17:902:f28d:b0:194:d5ec:9be6 with SMTP id k13-20020a170902f28d00b00194d5ec9be6mr4626134plc.23.1675313555604; Wed, 01 Feb 2023 20:52:35 -0800 (PST) Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id w10-20020a170902d70a00b001965540395fsm11222265ply.105.2023.02.01.20.52.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 20:52:35 -0800 (PST) From: Sunil V L To: Palmer Dabbelt , Alistair Francis , Bin Meng Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Andrew Jones , Anup Patel , Atish Kumar Patra , Sunil V L Subject: [PATCH 02/10] hw/riscv/virt: Add a switch to enable/disable ACPI Date: Thu, 2 Feb 2023 10:22:15 +0530 Message-Id: <20230202045223.2594627-3-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230202045223.2594627-1-sunilvl@ventanamicro.com> References: <20230202045223.2594627-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x102c.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, 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.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org ACPI is optional. So, add a switch to toggle. Signed-off-by: Sunil V L --- hw/riscv/virt.c | 38 ++++++++++++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 2 ++ 2 files changed, 40 insertions(+) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 7ad9fda20c..84962962ff 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -50,6 +50,7 @@ #include "hw/pci-host/gpex.h" #include "hw/display/ramfb.h" #include "hw/acpi/aml-build.h" +#include "qapi/qapi-visit-common.h" /* * The virt machine physical address space used by some of the devices @@ -1525,6 +1526,10 @@ static void virt_machine_init(MachineState *machine) static void virt_machine_instance_init(Object *obj) { + MachineState *ms = MACHINE(obj); + RISCVVirtState *s = RISCV_VIRT_MACHINE(ms); + + s->acpi = ON_OFF_AUTO_OFF; } static char *virt_get_aia_guests(Object *obj, Error **errp) @@ -1601,6 +1606,34 @@ static void virt_set_aclint(Object *obj, bool value, Error **errp) s->have_aclint = value; } +bool virt_is_acpi_enabled(RISCVVirtState *s) +{ + if (s->acpi == ON_OFF_AUTO_OFF) { + return false; + } + return true; +} + +static void virt_get_acpi(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + MachineState *ms = MACHINE(obj); + RISCVVirtState *s = RISCV_VIRT_MACHINE(ms); + + OnOffAuto acpi = s->acpi; + + visit_type_OnOffAuto(v, name, &acpi, errp); +} + +static void virt_set_acpi(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + MachineState *ms = MACHINE(obj); + RISCVVirtState *s = RISCV_VIRT_MACHINE(ms); + + visit_type_OnOffAuto(v, name, &s->acpi, errp); +} + static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, DeviceState *dev) { @@ -1672,6 +1705,11 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) sprintf(str, "Set number of guest MMIO pages for AIA IMSIC. Valid value " "should be between 0 and %d.", VIRT_IRQCHIP_MAX_GUESTS); object_class_property_set_description(oc, "aia-guests", str); + object_class_property_add(oc, "acpi", "OnOffAuto", + virt_get_acpi, virt_set_acpi, + NULL, NULL); + object_class_property_set_description(oc, "acpi", + "Enable ACPI"); } static const TypeInfo virt_machine_typeinfo = { diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index 6c7885bf89..62efebaa32 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -58,6 +58,7 @@ struct RISCVVirtState { int aia_guests; char *oem_id; char *oem_table_id; + OnOffAuto acpi; }; enum { @@ -123,4 +124,5 @@ enum { #define FDT_APLIC_INT_MAP_WIDTH (FDT_PCI_ADDR_CELLS + FDT_PCI_INT_CELLS + \ 1 + FDT_APLIC_INT_CELLS) +bool virt_is_acpi_enabled(RISCVVirtState *s); #endif From patchwork Thu Feb 2 04:52:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13125295 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4C484C05027 for ; Thu, 2 Feb 2023 04:54:01 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNRaX-0004Qv-Ry; Wed, 01 Feb 2023 23:52:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNRaT-0004PL-DF for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:41 -0500 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNRaR-0001DG-Ne for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:41 -0500 Received: by mail-pj1-x102e.google.com with SMTP id l4-20020a17090a850400b0023013402671so4427874pjn.5 for ; Wed, 01 Feb 2023 20:52:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0OK5MGUXpJ5dOBb1EDkd0/AV6RjPH0TTmkyNQ2mOQJc=; b=B+xjeku/YqMxE+yptWNKXY8r8cmeAzXoTTbQJV7acmbHdNZWM6IvigDzGKlUnKTY2I 4dZZvILiYtbOAtC+epEf1jK9w9FEdoiILwRMHOA+Wec/ep9vL+wxTOuJaOq0mHVsA591 lKRbuDiV5jOERzYbhvqNaYL5BI85ASoysAmVgN5loXp+lZJ9/WZyyRXi4Eyq0Ts2u66Z eGhThikcvUsfmcZSRb/g1whyXTf9X2PSO6lBQURSBxM9o6UE2k6+fv6wMCmHxnrc+iDf Ogs4YmZfG8pD6LmUSyMrkwjJKqFgqMDzA17DYqakiYU+4jj7vFumMoeD8sOIl2/mZMxr YVWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0OK5MGUXpJ5dOBb1EDkd0/AV6RjPH0TTmkyNQ2mOQJc=; b=GaxdBy/Qr8h/hxU6l0fQTd5hyZ1WSoNPMZIKud9isqxjPKWt6Y6AnDrXqoHk2zbFIE 2gsZ/sxT2dVI4ez5ZngsWQ2o3+7at+W33PbH8JI+xVzNtnlbzh67KpZnVodZSUDZ8DVj 2iXbL7hFhA5Lq7GIqeXDUAHdIkQLm4xNQsq+CQB9WnEm8Cec8kZGfm1NlJ7SAFKhyAKb /+SFDoFXJwCsPLkVK8bchOREhchPobDKdJ7HwFD6BsBBmAUUpPGHE+pobMUSbsYTDq+G g8upwwxC7c5bDCzi4o9AjgEQYBD82IHd0xfKRfZM9XKrcIw81pKg3QKpHChGHGKiddIq KziA== X-Gm-Message-State: AO0yUKXhKR8+UxCPbB5cKXpiewJdBH8oDQUMB639XXZz29iWoCN1yBuI 2tYIu9889FWd4Yb3KBv/rsS/rg== X-Google-Smtp-Source: AK7set9F4HIcfMVzailtXxZNiDgapKPjYwbZriRoksG5Qr+wNiihM04E4DXl7IIPD/XtFazciSAA/Q== X-Received: by 2002:a17:902:cf49:b0:192:b2d3:4fc8 with SMTP id e9-20020a170902cf4900b00192b2d34fc8mr3818150plg.1.1675313558487; Wed, 01 Feb 2023 20:52:38 -0800 (PST) Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id w10-20020a170902d70a00b001965540395fsm11222265ply.105.2023.02.01.20.52.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 20:52:38 -0800 (PST) From: Sunil V L To: Palmer Dabbelt , Alistair Francis , Bin Meng Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Andrew Jones , Anup Patel , Atish Kumar Patra , Sunil V L Subject: [PATCH 03/10] hw/riscv/virt: Add memmap pointer to RiscVVirtState Date: Thu, 2 Feb 2023 10:22:16 +0530 Message-Id: <20230202045223.2594627-4-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230202045223.2594627-1-sunilvl@ventanamicro.com> References: <20230202045223.2594627-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x102e.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org memmap needs to be exported outside of virt.c so that modules like acpi can use it. Hence, add a pointer field in RiscVVirtState structure and initialize it with the memorymap. Signed-off-by: Sunil V L Reviewed-by: Bin Meng Acked-by: Alistair Francis --- hw/riscv/virt.c | 2 ++ include/hw/riscv/virt.h | 1 + 2 files changed, 3 insertions(+) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 84962962ff..26caea59ff 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1459,6 +1459,8 @@ static void virt_machine_init(MachineState *machine) ROUND_UP(virt_high_pcie_memmap.base, virt_high_pcie_memmap.size); } + s->memmap = virt_memmap; + /* register system main memory (actual RAM) */ memory_region_add_subregion(system_memory, memmap[VIRT_DRAM].base, machine->ram); diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index 62efebaa32..379501edcc 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -59,6 +59,7 @@ struct RISCVVirtState { char *oem_id; char *oem_table_id; OnOffAuto acpi; + const MemMapEntry *memmap; }; enum { From patchwork Thu Feb 2 04:52:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13125297 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id F28F0C61DA4 for ; Thu, 2 Feb 2023 04:54:33 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNRag-0004TR-Cf; Wed, 01 Feb 2023 23:52:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNRaX-0004Qw-QJ for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:45 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNRaV-0001Di-Lt for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:45 -0500 Received: by mail-pj1-x1032.google.com with SMTP id on9-20020a17090b1d0900b002300a96b358so716340pjb.1 for ; Wed, 01 Feb 2023 20:52:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ij+/4XIsIRS0Ry3Sro+Ml/1ObEh0E1nx5A7AhPbzzIM=; b=RBBHzyPjVRKWeRVCQ6qvAc7kWoQf8d/lclVHkOqDIGwZs9s8N4wSDp4Xl/LBVfQjwS D3Tg4AzUqArQvozXudTuJdQBvZUQGFWUk4bLZPJrv6WSWHnxvgjUEyfbYjDJRV19LG9a 0UUzmh9KFQrn4+hNlxqkMOGEdqVu3BOlgF8aJ72FMDMYvoWmWB9QD4JRHwfJnscZrb+b H2JQHVu2XE0hjzxt2JWs84xJQIfAYQVMfIPGLMSnIewIXpoPxD4TDRV/g6qLHSWvHrwH wqH3njnfli1dJlWYWQ3W5ENRb+BGQQpOfpryXzj67KsazvbYrIYde8pQbmlHAyvfn0FZ dcsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ij+/4XIsIRS0Ry3Sro+Ml/1ObEh0E1nx5A7AhPbzzIM=; b=JL1vzGYa9bHGLGazCQgVuVqf9XrpdpXrumGGBXqz9jzXNl8cCdfKdUqZrRKlZ2EITi xSMmfi6SiHdvP+HLoJPo0ZCY08gg79OvPER6ww0lbG3W1vzE8UdhLgixhlE81pPPP7V+ 5nsPEzrqZG/uWMWbExQwvcKDq60ZzgtwRgZTkpsuDJ3TfVdScjz9wj68r1NnOR+ZNRl2 3m7Kyuca5pnWD84mD5wWhvfIhdog4tfrDwHw933zZ9vnPZs7V3gkx4mo/go619cyx2gD +RhXl7Y+7Z2sBEBu/0/VHAZZy12UgZExff0DLrSHoXDkpexDAw4J8da9yLwf8rKKTnnh XUAg== X-Gm-Message-State: AO0yUKVhahgRsobliWkT9B3fKft/AstwaF8SUviOtVEZC3Sp8aJCY7Yp fN+TH3GooGg5eQ8wBaFV4/QUDQ== X-Google-Smtp-Source: AK7set/ka64+wO82dKQbzmtEQGrkflNlMg3UFBUSslRmJvFsn4XWuT2FuWdC+5bQJfZK/VT1w4iOKw== X-Received: by 2002:a17:902:e1d2:b0:194:9de0:bed1 with SMTP id t18-20020a170902e1d200b001949de0bed1mr4015866pla.32.1675313561322; Wed, 01 Feb 2023 20:52:41 -0800 (PST) Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id w10-20020a170902d70a00b001965540395fsm11222265ply.105.2023.02.01.20.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 20:52:41 -0800 (PST) From: Sunil V L To: Palmer Dabbelt , Alistair Francis , Bin Meng Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Andrew Jones , Anup Patel , Atish Kumar Patra , Sunil V L Subject: [PATCH 04/10] hw/riscv/virt: virt-acpi-build.c: Add basic ACPI tables Date: Thu, 2 Feb 2023 10:22:17 +0530 Message-Id: <20230202045223.2594627-5-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230202045223.2594627-1-sunilvl@ventanamicro.com> References: <20230202045223.2594627-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x1032.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, 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.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add few basic ACPI tables and DSDT with few devices in a new file virt-acpi-build.c. These are mostly leveraged from arm64. Signed-off-by: Sunil V L --- hw/riscv/virt-acpi-build.c | 292 +++++++++++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 1 + 2 files changed, 293 insertions(+) create mode 100644 hw/riscv/virt-acpi-build.c diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c new file mode 100644 index 0000000000..0410b955bd --- /dev/null +++ b/hw/riscv/virt-acpi-build.c @@ -0,0 +1,292 @@ +/* + * Support for generating ACPI tables and passing them to Guests + * + * RISC-V virt ACPI generation + * + * Copyright (C) 2008-2010 Kevin O'Connor + * Copyright (C) 2006 Fabrice Bellard + * Copyright (C) 2013 Red Hat Inc + * Copyright (c) 2015 HUAWEI TECHNOLOGIES CO.,LTD. + * Copyright (C) 2021-2023 Ventana Micro Systems Inc + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License along + * with this program; if not, see . + */ + +#include "qemu/osdep.h" +#include "hw/acpi/acpi-defs.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/aml-build.h" +#include "hw/riscv/virt.h" +#include "hw/riscv/numa.h" +#include "hw/acpi/pci.h" +#include "hw/acpi/utils.h" +#include "sysemu/reset.h" +#include "hw/pci-host/gpex.h" +#include "qapi/error.h" +#include "migration/vmstate.h" + +#define ACPI_BUILD_TABLE_SIZE 0x20000 + +typedef struct AcpiBuildState { + /* Copy of table in RAM (for patching). */ + MemoryRegion *table_mr; + MemoryRegion *rsdp_mr; + MemoryRegion *linker_mr; + /* Is table patched? */ + bool patched; +} AcpiBuildState; + +static void +acpi_align_size(GArray *blob, unsigned align) +{ + /* + * Align size to multiple of given size. This reduces the chance + * we need to change size in the future (breaking cross version migration). + */ + g_array_set_size(blob, ROUND_UP(acpi_data_len(blob), align)); +} + +static void +acpi_dsdt_add_cpus(Aml *scope, RISCVVirtState *vms) +{ + MachineState *ms = MACHINE(vms); + uint16_t i; + + + for (i = 0; i < ms->smp.cpus; i++) { + Aml *dev = aml_device("C%.03X", i); + aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0007"))); + aml_append(dev, aml_name_decl("_UID", aml_int(i))); + aml_append(scope, dev); + } +} + +static void +acpi_dsdt_add_fw_cfg(Aml *scope, const MemMapEntry *fw_cfg_memmap) +{ + Aml *dev = aml_device("FWCF"); + aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002"))); + /* device present, functioning, decoding, not shown in UI */ + aml_append(dev, aml_name_decl("_STA", aml_int(0xB))); + aml_append(dev, aml_name_decl("_CCA", aml_int(1))); + + Aml *crs = aml_resource_template(); + aml_append(crs, aml_memory32_fixed(fw_cfg_memmap->base, + fw_cfg_memmap->size, AML_READ_WRITE)); + aml_append(dev, aml_name_decl("_CRS", crs)); + aml_append(scope, dev); +} + +/* FADT */ +static void +build_fadt_rev6(GArray *table_data, BIOSLinker *linker, + RISCVVirtState *vms, unsigned dsdt_tbl_offset) +{ + /* ACPI v5.1 */ + AcpiFadtData fadt = { + .rev = 6, + .minor_ver = 0, + .flags = 1 << ACPI_FADT_F_HW_REDUCED_ACPI, + .xdsdt_tbl_offset = &dsdt_tbl_offset, + }; + + build_fadt(table_data, linker, &fadt, vms->oem_id, vms->oem_table_id); +} + +/* DSDT */ +static void +build_dsdt(GArray *table_data, BIOSLinker *linker, RISCVVirtState *vms) +{ + Aml *scope, *dsdt; + const MemMapEntry *memmap = vms->memmap; + AcpiTable table = { .sig = "DSDT", .rev = 2, .oem_id = vms->oem_id, + .oem_table_id = vms->oem_table_id }; + + + acpi_table_begin(&table, table_data); + dsdt = init_aml_allocator(); + + /* + * When booting the VM with UEFI, UEFI takes ownership of the RTC hardware. + * While UEFI can use libfdt to disable the RTC device node in the DTB that + * it passes to the OS, it cannot modify AML. Therefore, we won't generate + * the RTC ACPI device at all when using UEFI. + */ + scope = aml_scope("\\_SB"); + acpi_dsdt_add_cpus(scope, vms); + + acpi_dsdt_add_fw_cfg(scope, &memmap[VIRT_FW_CFG]); + + aml_append(dsdt, scope); + + /* copy AML table into ACPI tables blob and patch header there */ + g_array_append_vals(table_data, dsdt->buf->data, dsdt->buf->len); + + acpi_table_end(linker, &table); + free_aml_allocator(); +} + +static void +virt_acpi_build(RISCVVirtState *vms, AcpiBuildTables *tables) +{ + GArray *table_offsets; + unsigned dsdt, xsdt; + GArray *tables_blob = tables->table_data; + + table_offsets = g_array_new(false, true, + sizeof(uint32_t)); + + bios_linker_loader_alloc(tables->linker, + ACPI_BUILD_TABLE_FILE, tables_blob, + 64, false); + + /* DSDT is pointed to by FADT */ + dsdt = tables_blob->len; + build_dsdt(tables_blob, tables->linker, vms); + + /* FADT and others pointed to by RSDT */ + acpi_add_table(table_offsets, tables_blob); + build_fadt_rev6(tables_blob, tables->linker, vms, dsdt); + + acpi_add_table(table_offsets, tables_blob); + build_madt(tables_blob, tables->linker, vms); + + acpi_add_table(table_offsets, tables_blob); + build_rhct(tables_blob, tables->linker, vms); + + /* XSDT is pointed to by RSDP */ + xsdt = tables_blob->len; + build_xsdt(tables_blob, tables->linker, table_offsets, vms->oem_id, + vms->oem_table_id); + + /* RSDP is in FSEG memory, so allocate it separately */ + { + AcpiRsdpData rsdp_data = { + .revision = 2, + .oem_id = vms->oem_id, + .xsdt_tbl_offset = &xsdt, + .rsdt_tbl_offset = NULL, + }; + build_rsdp(tables->rsdp, tables->linker, &rsdp_data); + } + + /* + * The align size is 128, warn if 64k is not enough therefore + * the align size could be resized. + */ + if (tables_blob->len > ACPI_BUILD_TABLE_SIZE / 2) { + warn_report("ACPI table size %u exceeds %d bytes," + " migration may not work", + tables_blob->len, ACPI_BUILD_TABLE_SIZE / 2); + error_printf("Try removing CPUs, NUMA nodes, memory slots" + " or PCI bridges."); + } + acpi_align_size(tables_blob, ACPI_BUILD_TABLE_SIZE); + + + /* Cleanup memory that's no longer used. */ + g_array_free(table_offsets, true); +} + +static void +acpi_ram_update(MemoryRegion *mr, GArray *data) +{ + uint32_t size = acpi_data_len(data); + + /* + * Make sure RAM size is correct - in case it got changed + * e.g. by migration + */ + memory_region_ram_resize(mr, size, &error_abort); + + memcpy(memory_region_get_ram_ptr(mr), data->data, size); + memory_region_set_dirty(mr, 0, size); +} + +static void +virt_acpi_build_update(void *build_opaque) +{ + AcpiBuildState *build_state = build_opaque; + AcpiBuildTables tables; + + /* No state to update or already patched? Nothing to do. */ + if (!build_state || build_state->patched) { + return; + } + build_state->patched = true; + + acpi_build_tables_init(&tables); + + virt_acpi_build(RISCV_VIRT_MACHINE(qdev_get_machine()), &tables); + + acpi_ram_update(build_state->table_mr, tables.table_data); + acpi_ram_update(build_state->rsdp_mr, tables.rsdp); + acpi_ram_update(build_state->linker_mr, tables.linker->cmd_blob); + + acpi_build_tables_cleanup(&tables, true); +} + +static void +virt_acpi_build_reset(void *build_opaque) +{ + AcpiBuildState *build_state = build_opaque; + build_state->patched = false; +} + +static const VMStateDescription vmstate_virt_acpi_build = { + .name = "virt_acpi_build", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_BOOL(patched, AcpiBuildState), + VMSTATE_END_OF_LIST() + }, +}; + +void +virt_acpi_setup(RISCVVirtState *vms) +{ + AcpiBuildTables tables; + AcpiBuildState *build_state; + + build_state = g_malloc0(sizeof *build_state); + + acpi_build_tables_init(&tables); + virt_acpi_build(vms, &tables); + + /* Now expose it all to Guest */ + build_state->table_mr = acpi_add_rom_blob(virt_acpi_build_update, + build_state, tables.table_data, + ACPI_BUILD_TABLE_FILE); + assert(build_state->table_mr != NULL); + + build_state->linker_mr = acpi_add_rom_blob(virt_acpi_build_update, + build_state, + tables.linker->cmd_blob, + ACPI_BUILD_LOADER_FILE); + + build_state->rsdp_mr = acpi_add_rom_blob(virt_acpi_build_update, + build_state, tables.rsdp, + ACPI_BUILD_RSDP_FILE); + + qemu_register_reset(virt_acpi_build_reset, build_state); + virt_acpi_build_reset(build_state); + vmstate_register(NULL, 0, &vmstate_virt_acpi_build, build_state); + + /* + * Cleanup tables but don't free the memory: we track it + * in build_state. + */ + acpi_build_tables_cleanup(&tables, false); +} diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h index 379501edcc..e5c474b26e 100644 --- a/include/hw/riscv/virt.h +++ b/include/hw/riscv/virt.h @@ -126,4 +126,5 @@ enum { 1 + FDT_APLIC_INT_CELLS) bool virt_is_acpi_enabled(RISCVVirtState *s); +void virt_acpi_setup(RISCVVirtState *vms); #endif From patchwork Thu Feb 2 04:52:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13125290 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id E2432C61DA4 for ; Thu, 2 Feb 2023 04:53:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNRak-0004ah-TZ; Wed, 01 Feb 2023 23:52:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNRaZ-0004RA-2W for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:47 -0500 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNRaX-0001E1-Is for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:46 -0500 Received: by mail-pj1-x102a.google.com with SMTP id f16-20020a17090a9b1000b0023058bbd7b2so90818pjp.0 for ; Wed, 01 Feb 2023 20:52:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qbhV7ZtkZcHXjWUQc3+IGI4C3Mx+0jb5hp/aNqWZgQI=; b=Sy5QlpnSQnP2+JGVKM95/4MAUblym/1Xy0CScIqSO/Kn4S1n3GLyF/YIZL7bRlOfaW W6zzsrEtUlX6IgRUWFMNOe5mXHuEMIn932HAbPTkvp5YQ4m2tyRLpRMZbG8GAtbE1GXm LuEXMFOpNP7UNQssvXuM43cMnq/ztiyIGua96dSlb+x6n1dSKHONs94h1QgpI8xSKc4O Pfvwgbc+E5RU14DrW+WZwu7vCOk+XhVloYVbRQg3OX7KiVH9V0q0w5120Te9P5S5pjqA 6U/b5RwQ5pInYwkcsbvzLcG6Hm7wBYwhhw7N49cZip3Su35TqANxXmRiglcpAKc0f1Hu vcWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qbhV7ZtkZcHXjWUQc3+IGI4C3Mx+0jb5hp/aNqWZgQI=; b=ynspXec6s6Hk4+Tk8/qmCfSIuZT/XRutMCT3sB1KKlqctDQVRPCSRMU8VahAmF9Bhb IwAdL8q7yCVraHJ8dZYfn3lcBSo5kLuciZ1lpCl74D9gRI7bIdH0DCTiftmVKjjEauI8 PX3pQMH3ESFwEpSpnqGucxeAoHpIzmH47OnZpW/tcwg+63tWHxXqagDkUsZ4KaThrwQY pnLmhlIkr9r08MJXJ/XzFcacgDj//BUlVastqhZs9mm3sSXaYuJneDdKNIhHG02pRAF4 hftESrM08dOyQYQ/u2jA3JnH3ZCr9B1v46GxYlJ34y1U/Nd3YFywwWF3VGXGHQAPP1/u 8AOw== X-Gm-Message-State: AO0yUKWlQxS4MYNEOUSbVTxMFERStO16OA9si2Ki31kAUAwKCtddHDJi MAvhxDthJbtw5dS5201mwWBIbA== X-Google-Smtp-Source: AK7set8iiIYu+Ql4j1HOjO/G09WeFbTrU64fLl1exlANlsyeYgnMM/huf35ElG1ILU+nzvcRuwU+og== X-Received: by 2002:a17:902:e883:b0:198:a49b:9f20 with SMTP id w3-20020a170902e88300b00198a49b9f20mr6771326plg.56.1675313564179; Wed, 01 Feb 2023 20:52:44 -0800 (PST) Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id w10-20020a170902d70a00b001965540395fsm11222265ply.105.2023.02.01.20.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 20:52:43 -0800 (PST) From: Sunil V L To: Palmer Dabbelt , Alistair Francis , Bin Meng Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Andrew Jones , Anup Patel , Atish Kumar Patra , Sunil V L Subject: [PATCH 05/10] hw/riscv/virt: virt-acpi-build.c: Add RINTC in MADT Date: Thu, 2 Feb 2023 10:22:18 +0530 Message-Id: <20230202045223.2594627-6-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230202045223.2594627-1-sunilvl@ventanamicro.com> References: <20230202045223.2594627-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x102a.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, 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.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add Multiple APIC Description Table (MADT) with the INTC structure for each cpu. Signed-off-by: Sunil V L Acked-by: Alistair Francis --- hw/riscv/virt-acpi-build.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 0410b955bd..2f65f1e2e5 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -137,6 +137,43 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, RISCVVirtState *vms) free_aml_allocator(); } +/* MADT */ +static void +build_madt(GArray *table_data, BIOSLinker *linker, RISCVVirtState *vms) +{ + MachineState *mc = MACHINE(vms); + int socket; + uint16_t base_hartid = 0; + uint32_t cpu_id = 0; + + AcpiTable table = { .sig = "APIC", .rev = 6, .oem_id = vms->oem_id, + .oem_table_id = vms->oem_table_id }; + + acpi_table_begin(&table, table_data); + /* Local Interrupt Controller Address */ + build_append_int_noprefix(table_data, 0, 4); + build_append_int_noprefix(table_data, 0, 4); /* MADT Flags */ + + /* RISC-V Local INTC structures per HART */ + for (socket = 0; socket < riscv_socket_count(mc); socket++) { + base_hartid = riscv_socket_first_hartid(mc, socket); + + for (int i = 0; i < vms->soc[socket].num_harts; i++) { + build_append_int_noprefix(table_data, 0x18, 1); /* Type */ + build_append_int_noprefix(table_data, 20, 1); /* Length */ + build_append_int_noprefix(table_data, 1, 1); /* Version */ + build_append_int_noprefix(table_data, 0, 1); /* Reserved */ + build_append_int_noprefix(table_data, 1, 4); /* Flags */ + build_append_int_noprefix(table_data, + (base_hartid + i), 8); /* hartid */ + build_append_int_noprefix(table_data, cpu_id, 4); /* ACPI ID */ + cpu_id++; + } + } + + acpi_table_end(linker, &table); +} + static void virt_acpi_build(RISCVVirtState *vms, AcpiBuildTables *tables) { From patchwork Thu Feb 2 04:52:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13125296 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 47DA4C63797 for ; Thu, 2 Feb 2023 04:54:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNRao-0004gw-4k; Wed, 01 Feb 2023 23:53:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNRab-0004Sj-UP for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:52 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNRaa-0001Em-74 for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:49 -0500 Received: by mail-pj1-x1032.google.com with SMTP id ha3-20020a17090af3c300b00230222051a6so711686pjb.2 for ; Wed, 01 Feb 2023 20:52:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xnHKZ5LhaBWpW9NwjdW0SuQ4r9YMLuHVjxY2bCFQzEo=; b=K3d/bj7+Q8AZoZMpcFT7YSbCtfxXMIQ2ex7v7CEVM3jV0MbBv702mwDW3JyrKcXRWV Bb48MIoekKezWBr+UZ+McfRZK2spIJBWSMkslaAIWfrg4OsSCA6ldqWCnU9TUAuTv8yw Nb6bEkQW+CjYJlnmuyIateRvOnF30TBm7S/6gG0YZ1Ke8l5Q6kSz8D8y+mqSd03MwGd6 a3NSuPayCbz4wmPQ+JQPYim6Se8BvWXxrrP+pWXkiKJr7Ii88ljYZYA1+h0I5B+bsy0g TLW+ayZ1orhGBpbSiOI0xjaaKG9R0HTKDE+9ZHEYZ4qgydrlSU8g/iUm2ezbFl66chZ2 b9Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xnHKZ5LhaBWpW9NwjdW0SuQ4r9YMLuHVjxY2bCFQzEo=; b=XePl1kz/6HiuoOwznFfLIsRVJheUsZSm+NuxtiZ2JV0WYO1wdT7UYYeiTsqhy3knf9 ZytAC9d7eZaIivaen4J292EVx46Xvycd+pk2bmAsvjQcKaF7LHZsftSo6KYvCmyGGn3K NOQdS74rVGZCrQ1rVCfIDMBJdk65Fg8l/x++qKDBijvfv+O78OVpsQzJfF1GktaVeOH+ ly460/iVFFNG+5NXNstBLDnZOQmYeXoQEQccLF0gq1Ixwc8niz9PqW+JCZdkmjwMstB9 gF19f8SjUwxgYSTX6n/576c1t3h+juuHHc9wQMSm3HvXnbyu131pDl37ME7mxDVA63vv d/rQ== X-Gm-Message-State: AO0yUKVgTOmejpcDitkT5zgQaRd7aQqNyF+X5l/D4iK0wSP5vLkErmXJ AqCcvmyCX/g/B3pTZ8RHbliA2Q== X-Google-Smtp-Source: AK7set9RIJ39pMfz3KLhS3QfUDb01Fl6jUStDTO82VAIrocIM8xgn9P8P0UCMmihGbk1oMXo48hSXw== X-Received: by 2002:a17:902:e551:b0:196:2143:5eff with SMTP id n17-20020a170902e55100b0019621435effmr6138108plf.24.1675313567079; Wed, 01 Feb 2023 20:52:47 -0800 (PST) Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id w10-20020a170902d70a00b001965540395fsm11222265ply.105.2023.02.01.20.52.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 20:52:46 -0800 (PST) From: Sunil V L To: Palmer Dabbelt , Alistair Francis , Bin Meng Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Andrew Jones , Anup Patel , Atish Kumar Patra , Sunil V L Subject: [PATCH 06/10] hw/riscv/virt: virt-acpi-build.c: Add RHCT Table Date: Thu, 2 Feb 2023 10:22:19 +0530 Message-Id: <20230202045223.2594627-7-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230202045223.2594627-1-sunilvl@ventanamicro.com> References: <20230202045223.2594627-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x1032.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, 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.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org RISC-V ACPI platforms need to provide RISC-V Hart Capabilities Table (RHCT). Add this to the ACPI tables. Signed-off-by: Sunil V L --- hw/riscv/virt-acpi-build.c | 62 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 2f65f1e2e5..b04f179cb5 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -35,6 +35,7 @@ #include "hw/pci-host/gpex.h" #include "qapi/error.h" #include "migration/vmstate.h" +#include "hw/intc/riscv_aclint.h" #define ACPI_BUILD_TABLE_SIZE 0x20000 @@ -88,6 +89,67 @@ acpi_dsdt_add_fw_cfg(Aml *scope, const MemMapEntry *fw_cfg_memmap) aml_append(scope, dev); } +#define RHCT_NODE_ARRAY_OFFSET 56 +static void +build_rhct(GArray *table_data, BIOSLinker *linker, RISCVVirtState *vms) +{ + MachineState *ms = MACHINE(vms); + uint32_t acpi_proc_id = 0; + int i, socket; + RISCVCPU *cpu; + char *isa; + size_t len, aligned_len; + uint32_t isa_offset, num_rhct_nodes; + + AcpiTable table = { .sig = "RHCT", .rev = 1, .oem_id = vms->oem_id, + .oem_table_id = vms->oem_table_id }; + + acpi_table_begin(&table, table_data); + + build_append_int_noprefix(table_data, 0x0, 4); /* Reserved */ + build_append_int_noprefix(table_data, + RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ, 8); + + /* ISA + N hart info */ + num_rhct_nodes = 1 + ms->smp.cpus; + build_append_int_noprefix(table_data, num_rhct_nodes, 4); + build_append_int_noprefix(table_data, RHCT_NODE_ARRAY_OFFSET, 4); + + /* ISA string node */ + isa_offset = table_data->len - table.table_offset; + build_append_int_noprefix(table_data, 0, 2); /* Type 0*/ + + cpu = &vms->soc[0].harts[0]; + isa = riscv_isa_string(cpu); + len = 8 + strlen(isa) + 1; + aligned_len = (len % 2) ? (len + 1) : len; + + build_append_int_noprefix(table_data, aligned_len, 2); /* Total length */ + build_append_int_noprefix(table_data, 0x1, 2); /* Revision */ + + /* ISA string length including NUL */ + build_append_int_noprefix(table_data, strlen(isa) + 1, 2); + g_array_append_vals(table_data, isa, strlen(isa) + 1); /* ISA string */ + + if (aligned_len != len) { + build_append_int_noprefix(table_data, 0x0, 1); /* pad */ + } + + for (socket = 0; socket < riscv_socket_count(ms); socket++) { + for (i = 0; i < vms->soc[socket].num_harts; i++) { + build_append_int_noprefix(table_data, 0xFFFF, 2); /* Type */ + build_append_int_noprefix(table_data, 16, 2); /* Length */ + build_append_int_noprefix(table_data, 0x1, 2); /* Revision */ + build_append_int_noprefix(table_data, 1, 2); /* number of offsets */ + build_append_int_noprefix(table_data, acpi_proc_id, 4); /* UID */ + build_append_int_noprefix(table_data, isa_offset, 4); + acpi_proc_id++; + } + } + + acpi_table_end(linker, &table); +} + /* FADT */ static void build_fadt_rev6(GArray *table_data, BIOSLinker *linker, From patchwork Thu Feb 2 04:52:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13125291 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id F3B3CC63797 for ; Thu, 2 Feb 2023 04:53:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNRak-0004aJ-Mg; Wed, 01 Feb 2023 23:52:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNRae-0004TL-Qh for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:53 -0500 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNRac-0001CM-OH for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:52 -0500 Received: by mail-pj1-x1036.google.com with SMTP id pj3so834985pjb.1 for ; Wed, 01 Feb 2023 20:52:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+y+HqzRrl7TJ/ysQrK68jIu5s7bSfbhBZtrr7+F62XE=; b=pqxyJ0Nry8FFf22TFbBWY9LpWZvLgCQY7otUTwMQiuhBHGA/magZ/wuoYbs8oWxe1V BSOMSiHbyCeVfFMATI624d6goQCpaqekvPZwBOUCZCzmnopZ1yQSRfinY8Khi66UaREI WcowntmIgK9LUlPTLZaWL3Jr1FCcCaYw0KZkwl+XyrvtRK3sxSLQaxZd6txFSFhmUJSU 2HPM0oxvUaeIpxqB4pU8LPfy3kRvtuYH4zobmR4PsO+HbrcPejp1kAV6xPkpWRJWn4dW lwMGkrsOJrsoXjFYnk6vEbEm7u0ma/4XNeyc+PYPjjJ7px0vf8J8Oq4GzdmXhQRI8Re0 73pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+y+HqzRrl7TJ/ysQrK68jIu5s7bSfbhBZtrr7+F62XE=; b=8AyCPh2DlJ2+iVoLVHZtsuo83hmC+9IqrMqSTJB+P5a1jFVN4LRZ43uHRia4MbX+er 69CwrQR4dUKN9dbIHyOxTpmuVBzS7AhMcK1k5re5x+Y4l2C/ROflIV7jRLeaADoGUKdz N3bGeEatjF7fvwZ/wMuxdH2mHZrYAY18aHLwwG0n/75t0AY5lJNBC4smKBbHmUZeKrRG IpR9PvwaP6n92uq96dYUf5wNGde2tDHrIS+W/SXqr0LmEcTxbkTQVjUnMvBdXbNYWsDw Ibpmrak9kirpzOTbWHb6dwLS8n5gF/CCxeK/QwI4XlLh3AO9iLbQURGItWM7n5L2nj5C nsag== X-Gm-Message-State: AO0yUKWLnCz1NimkABmVlqGK3X2Ao+e/usD3+WZr48eQmmIPUj2qUp8v wvIbBnzTAse7cEI4YXxCzho05Q== X-Google-Smtp-Source: AK7set8EUJ8Ig84w77zRqm+zQfMalfcNsQ/DczaJTFR73EIIaKldiMTzhC2yGPAjtgIIMwP+3sBPdA== X-Received: by 2002:a17:902:c702:b0:196:64bf:ed86 with SMTP id p2-20020a170902c70200b0019664bfed86mr4456435plp.62.1675313570139; Wed, 01 Feb 2023 20:52:50 -0800 (PST) Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id w10-20020a170902d70a00b001965540395fsm11222265ply.105.2023.02.01.20.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 20:52:49 -0800 (PST) From: Sunil V L To: Palmer Dabbelt , Alistair Francis , Bin Meng Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Andrew Jones , Anup Patel , Atish Kumar Patra , Sunil V L Subject: [PATCH 07/10] hw/riscv: meson.build: Build virt-acpi-build.c Date: Thu, 2 Feb 2023 10:22:20 +0530 Message-Id: <20230202045223.2594627-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230202045223.2594627-1-sunilvl@ventanamicro.com> References: <20230202045223.2594627-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x1036.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, 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.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org ACPI functions are defined in new file virt-acpi-build.c. Enable it to be built as part of virt machine if CONFIG_ACPI is set. Signed-off-by: Sunil V L Reviewed-by: Bin Meng --- hw/riscv/meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/riscv/meson.build b/hw/riscv/meson.build index ab6cae57ea..2f7ee81be3 100644 --- a/hw/riscv/meson.build +++ b/hw/riscv/meson.build @@ -9,5 +9,6 @@ riscv_ss.add(when: 'CONFIG_SIFIVE_E', if_true: files('sifive_e.c')) riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u.c')) riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('spike.c')) riscv_ss.add(when: 'CONFIG_MICROCHIP_PFSOC', if_true: files('microchip_pfsoc.c')) +riscv_ss.add(when: 'CONFIG_ACPI', if_true: files('virt-acpi-build.c')) hw_arch += {'riscv': riscv_ss} From patchwork Thu Feb 2 04:52:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13125298 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A6915C61DA4 for ; Thu, 2 Feb 2023 04:54:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNRap-0004jJ-Im; Wed, 01 Feb 2023 23:53:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNRah-0004Vz-2F for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:55 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNRaf-0001Em-Lc for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:54 -0500 Received: by mail-pj1-x1032.google.com with SMTP id ha3-20020a17090af3c300b00230222051a6so711855pjb.2 for ; Wed, 01 Feb 2023 20:52:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nqWGZjBcQvINY4Peoi2bS5ONYkVu6Qdy2fHeFgiLlfU=; b=HVzfsICWONk06qyzuo4jLrKFXAt3Q0EpTOhN2X7MLJNsga0bJG7omtxG8xJc4vmdqD In9ECBv3OmpjS5hqozzL7pc1A8Bv0+ThIT42B+um0YcxbzCj3PXzw84vd7Cr4XGAvuY0 RE3+umoQ8n/v2+gj2wXR6Bgmj6wluTstesg1jHc93RxhU1al4whjLlXrphrBFd7v2dRG vEniQap9gi0+fHsN0n1VjP+EA8LELaocoEl5sdSzkkA+/0IpL5k297qcq2ZACUc/5u38 8XMavs6amei8OMSA5gODNpMNx/F0L1+EWINOTx8xPD5dS56Vait/Hkz6rYHl9Wu1OLgJ IEoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nqWGZjBcQvINY4Peoi2bS5ONYkVu6Qdy2fHeFgiLlfU=; b=7da6dS4FIwnC3cNwdaFJqlo9COPqRduz7ZiEI5oToWGjRoaLzZA36kgaCfqOcHGX1O pfJMDiOlU8d7KdT8MW/m67GQDDY1Q2SyfO29pjy8eTPkShH7Edy6HCdc6wPK7sbDW+nU YC2JJjvlqGAW6qYCXAv9jFChoV+/ch3tLyfOKDLB9nHDFKlV8L7jQzp+VM2yQLplYOfi s3YsgTaqbytpdKZVU5I18E/LdgxCC46/YqC9UVrQ8Uu3pd6YOuWit8P3eDC6kfuBi0mq fgyrzgNwH9TH1SkiiMM0/+Cery+5G5bAv0gy/QXK1/yQfymIJXr/zdHpi+/CNQXJmEtg vkgg== X-Gm-Message-State: AO0yUKXnLNsomcUR4xNpUhaqyW3eou95B5b0fI/Omy6zSouL6g7mqWQ4 o8Ucy5ZSCnZCrnPv46edOHUh3g== X-Google-Smtp-Source: AK7set8slXyFaxXdVD/8wTD0he7lwiJjPTlPuDORy5poORwsoURlFJvUFRkoJGhK53MFHWJLS1rJJw== X-Received: by 2002:a17:903:ca:b0:196:4e75:c933 with SMTP id x10-20020a17090300ca00b001964e75c933mr4284197plc.13.1675313573014; Wed, 01 Feb 2023 20:52:53 -0800 (PST) Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id w10-20020a170902d70a00b001965540395fsm11222265ply.105.2023.02.01.20.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 20:52:52 -0800 (PST) From: Sunil V L To: Palmer Dabbelt , Alistair Francis , Bin Meng Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Andrew Jones , Anup Patel , Atish Kumar Patra , Sunil V L Subject: [PATCH 08/10] hw/riscv/Kconfig: virt: Enable ACPI config options Date: Thu, 2 Feb 2023 10:22:21 +0530 Message-Id: <20230202045223.2594627-9-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230202045223.2594627-1-sunilvl@ventanamicro.com> References: <20230202045223.2594627-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x1032.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, 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.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org Enable ACPI related config options to build ACPI subsystem for virt machine. Signed-off-by: Sunil V L --- hw/riscv/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index 4550b3b938..92b1a9eb64 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -44,6 +44,9 @@ config RISCV_VIRT select VIRTIO_MMIO select FW_CFG_DMA select PLATFORM_BUS + select ACPI + select ACPI_HW_REDUCED + select ACPI_PCI config SHAKTI_C bool From patchwork Thu Feb 2 04:52:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13125294 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 85956C05027 for ; Thu, 2 Feb 2023 04:53:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNRan-0004f2-21; Wed, 01 Feb 2023 23:53:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNRak-0004aI-KP for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:58 -0500 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNRai-0001E1-IZ for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:52:58 -0500 Received: by mail-pj1-x102a.google.com with SMTP id f16-20020a17090a9b1000b0023058bbd7b2so91165pjp.0 for ; Wed, 01 Feb 2023 20:52:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+msI053tZobQNVJtzCxF6v86dIC0lUYPfhn8cOFSkx0=; b=aMGVUNhvHN7KngElz7SWuGceTACHtKGOeI/S7XTrctzSBt78dJisV7Ex93WhL5VfRH /nJK2QHpvU3ppSC/e9kYXU87kjksDXXO1bAp8T8MuxcWbAvJ+ZVgOOXixfu3lVYkuuqI a0PrBlGqPfZYCHi90JCehyrE+DSgFPnsT9nrkl+1p9IXK44WF++LPWwqW92lC7kL/5sn vnbWnwJKMpKFXI3Q4UWzN5I320AaJkiRj2r/ssPcPIssRXtiFWoyxJG87zzn+2MvVd4d i0P8tQcZU8pvKkDiHpmxGgXGRDEWHdpYFsb/iGgmKgWlvuPTnIW9cbLiwWiXPNh+9JKP Nwlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+msI053tZobQNVJtzCxF6v86dIC0lUYPfhn8cOFSkx0=; b=kGF3QJATSgKd//bIMPwo+yXOb/BDLxNcGVkFC1+J5Y0LZYeDCuMf0sH4IDUC/fiawI uEt+T0JIfi35uIIKWMSpM1aMIrrd1QjGhYHXBvi8NMdrxqOh7KDqXUN450ex1ImggYac V40ZE9uI0xlMgPxigYmqyejS2Un3b3m69uFyzJkTPQTChPq1waHYXanh1R8/T6XiuIFl Qjz7QbwlkLZccgEHn6ag4PEbcXt/HtOgAuTn8WnzLODm5VP/CL66X2gnKeQQezld0sVR hSU1yjDHJQFWIOGjwUVUPdFaIakaarGz44M3SwdP1x9l8gyRl9GDhvBMSIPdaQreqdaP TaMw== X-Gm-Message-State: AO0yUKWJTXVh9Of6lTI71OuEiFWEtKcZP7EobrL8akaF0tBTDi6U8NVx k38VWZfr+N81p3ZFDdeENyz/Fw== X-Google-Smtp-Source: AK7set+sEjsPSf8KuXVWCIFZkdBrnSZhUlRKblyI19isDMOlKTG8Av2gctlDgw58d7Lwm3Dj72oa9Q== X-Received: by 2002:a17:902:e385:b0:194:6c1b:e5cc with SMTP id g5-20020a170902e38500b001946c1be5ccmr4284126ple.38.1675313575882; Wed, 01 Feb 2023 20:52:55 -0800 (PST) Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id w10-20020a170902d70a00b001965540395fsm11222265ply.105.2023.02.01.20.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 20:52:55 -0800 (PST) From: Sunil V L To: Palmer Dabbelt , Alistair Francis , Bin Meng Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Andrew Jones , Anup Patel , Atish Kumar Patra , Sunil V L Subject: [PATCH 09/10] hw/riscv/virt.c: Initialize the ACPI tables Date: Thu, 2 Feb 2023 10:22:22 +0530 Message-Id: <20230202045223.2594627-10-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230202045223.2594627-1-sunilvl@ventanamicro.com> References: <20230202045223.2594627-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x102a.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, 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.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org When the "acpi=on", ACPI tables need to be added. Detect the option and initialize the ACPI tables. Signed-off-by: Sunil V L Reviewed-by: Bin Meng --- hw/riscv/virt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 26caea59ff..f1f5612c69 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1324,6 +1324,10 @@ static void virt_machine_done(Notifier *notifier, void *data) if (kvm_enabled()) { riscv_setup_direct_kernel(kernel_entry, fdt_load_addr); } + + if (virt_is_acpi_enabled(s)) { + virt_acpi_setup(s); + } } static void virt_machine_init(MachineState *machine) From patchwork Thu Feb 2 04:52:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil V L X-Patchwork-Id: 13125293 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 9F975C61DA4 for ; Thu, 2 Feb 2023 04:53:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNRaq-0004jZ-3o; Wed, 01 Feb 2023 23:53:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pNRan-0004g3-GU for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:53:01 -0500 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pNRam-0001Em-4S for qemu-devel@nongnu.org; Wed, 01 Feb 2023 23:53:01 -0500 Received: by mail-pj1-x1032.google.com with SMTP id ha3-20020a17090af3c300b00230222051a6so712015pjb.2 for ; Wed, 01 Feb 2023 20:52:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wrl2m89lEAGIfGV2TcX0lvKgQ/GFCS1PkOc8cAsKOcc=; b=ENJfSqyiOs/xHzNdrpDyYW9VuaECJ7Uja1X/i4u3UmwN6392J4ofxvJGBK3Q2Bc1TQ xAVpMI0qFu6HeVbFNSSiGgJ/JuvbsQ16Q8+p9/h0E3AsgdQX2pk7RI++y6oYG5gi46XK OV2NVEJckBOl70YtsBLV9Qeyi20tYlHR43KXIT05rydsFe7s3XYBlCW5B7NV2PTNVIP8 rnKXFQCsH6rRI6WWN5oa7hHrUfDuH+hm4ISz10KJDm9hnao5SZPzK97tEbraeewmi2eP xdAHhWi3mK7DO5WVxKHklu7jKfJS0pnv0IiNvdBT7QRQRIPYhaoF4bj2E7Xtyu8qcVri ElsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wrl2m89lEAGIfGV2TcX0lvKgQ/GFCS1PkOc8cAsKOcc=; b=8DHIK36pf7WjjvDCkwlTPkPE97F/NE3lphv9ffOqDe4nOoNp+j+ZnKJ3guTxC71/dp pbC1WCQ8h6p15xoY0fr808ch0wYig6zbV8NsGtuolugWswfJhQQd3zpPiWWzmilBQzL0 04a27EsN2rFmEkyMyS5wq2WZuHsFbheX657wLMH5znTrqSRuFhG8SgYSctGlmJHnCwe5 ZV/GviT8eheWd0WqqubGyK3Hu0giqCuRR2uYaWyOduBcCWVBhrt0xEhsnopU6pECOfME /DP70X6SCjcZEYFK6e5fgFWAVTOTk10oOBj3hfFSMTwSIAnlIWNKRyx/nC4mSlheDcHC iLzg== X-Gm-Message-State: AO0yUKWMJdDb7eI5qnR/gcHZblQzpjnWUbSQ0zTNWC8W2E8xx7iqp7MQ IbtqoMBHx+NEx8Un0Iv7s9fOmQ== X-Google-Smtp-Source: AK7set/SKWOrh0KM5OPBb1hZHg3TX3DeVNCwuDrZZWJzw5ilP0TO+0tBrPd0Wn0mmbumPwt4BkTUfw== X-Received: by 2002:a17:902:e192:b0:196:4e0d:7eb5 with SMTP id y18-20020a170902e19200b001964e0d7eb5mr4038272pla.35.1675313578860; Wed, 01 Feb 2023 20:52:58 -0800 (PST) Received: from localhost.localdomain ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id w10-20020a170902d70a00b001965540395fsm11222265ply.105.2023.02.01.20.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 20:52:58 -0800 (PST) From: Sunil V L To: Palmer Dabbelt , Alistair Francis , Bin Meng Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Andrew Jones , Anup Patel , Atish Kumar Patra , Sunil V L Subject: [PATCH 10/10] MAINTAINERS: Add entry for RISC-V ACPI Date: Thu, 2 Feb 2023 10:22:23 +0530 Message-Id: <20230202045223.2594627-11-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20230202045223.2594627-1-sunilvl@ventanamicro.com> References: <20230202045223.2594627-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x1032.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, 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.29 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-bounces+qemu-devel=archiver.kernel.org@nongnu.org RISC-V ACPI related functionality for virt machine is added in virt-acpi-build.c. Add the maintainer entry. Signed-off-by: Sunil V L Reviewed-by: Bin Meng Reviewed-by: Alistair Francis --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index c581c11a64..23fcaaf54a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -995,6 +995,12 @@ L: qemu-arm@nongnu.org S: Maintained F: hw/arm/virt-acpi-build.c +RISC-V ACPI Subsystem +M: Sunil V L +L: qemu-riscv@nongnu.org +S: Maintained +F: hw/riscv/virt-acpi-build.c + STM32F100 M: Alexandre Iooss L: qemu-arm@nongnu.org