From patchwork Mon Feb 13 14:40:29 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: 13138515 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 22EDBC636D4 for ; Mon, 13 Feb 2023 14:42:17 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRa0i-00065c-6s; Mon, 13 Feb 2023 09:40:52 -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 1pRa0h-00064h-9p for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:40:51 -0500 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRa0f-0005RX-Ms for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:40:50 -0500 Received: by mail-pl1-x636.google.com with SMTP id k13so13759298plg.0 for ; Mon, 13 Feb 2023 06:40:49 -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=l49v2a+f6jJfyAmwBZFZU1/DlBxv+sfOE9Smp77Jgfc=; b=deLR9/BMaJM4voq1pTiWmCXuScmxuZlK57fjUvvabO9kplE5l+r7hmmiYFxIrE8dFA e2p0EvJA1+1Y0cNq0YH9EPOwEdKKDttc5+PfJI1y3jUbkqZQSYdkqYD2yNDUM+akCa/3 5nZQnfByYrbkmEQI/iLFMNvED61wnM4jhYVAAvB5Lxo6I7cKKuwgN2KJNrXW8XtckYc1 6Q+fPzkYScuFUlg3BpbK4CG1VzkRwYtoX9Q6exygyhoI71pioc7P2CKco/QtjLF4lozA sf/Alo2M+90dFaiJKiGf9GsFxwjGdSsDEsrBg9/xRLdGvLDJxtlrZSIhkPdrWKV01fzZ RNOQ== 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=l49v2a+f6jJfyAmwBZFZU1/DlBxv+sfOE9Smp77Jgfc=; b=bqiLpzWVS12dLwfda7kFFU/Aul+U7fYGQU0y9gwHDK3e0IydDai7G4kUtBETKo3F3d esqqmf/7Pdsu4iLR4+mgJvPRpBmO2BvPpRCcQ2tcnWuBDP8oReRtKzMzKBaKumKyCovI HuhnExeymyUs4p8ZO/8dPEn9WW8lDV/gdkh5sogSN7Zmts40d9JE947xE0OS+Zhw4KEb R2EH64ZVQdrSv5QGZm8VCr05ps2K0olKCLWAbdSabJiLevvkW6nXamL1AWTcbM+xyXRL /4UrimjOF7QIXebPzkhSc4Z9JsPqkYVeu4iXUWogXlPeWPRhLem1jGVSC580XDDjWEkk jtcQ== X-Gm-Message-State: AO0yUKXfAQcf4gsjJB7wPfF5HqAUsfxcHSnEkuYEvBfEEthEM6BDPlBG fLzLvjEDH3ITRMEs1pMYLYYV0Q== X-Google-Smtp-Source: AK7set8nbmRGk+3M8HTrT8fpl3qgEL4THYfYa4N6gDf4hJ5I1tTm2tSrRUoDcb62DSW6Vdb9wdYtIQ== X-Received: by 2002:a17:90b:3b49:b0:230:f96d:4bad with SMTP id ot9-20020a17090b3b4900b00230f96d4badmr9026789pjb.2.1676299248497; Mon, 13 Feb 2023 06:40:48 -0800 (PST) Received: from kerodi.Dlink ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id y23-20020a63de57000000b004fb8732a2f9sm3777757pgi.88.2023.02.13.06.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 06:40:48 -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 , Daniel Henrique Barboza , Sunil V L , Bin Meng Subject: [PATCH V2 01/10] hw/riscv/virt: Add OEM_ID and OEM_TABLE_ID fields Date: Mon, 13 Feb 2023 20:10:29 +0530 Message-Id: <20230213144038.2547584-2-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213144038.2547584-1-sunilvl@ventanamicro.com> References: <20230213144038.2547584-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=sunilvl@ventanamicro.com; helo=mail-pl1-x636.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 Reviewed-by: Andrew Jones --- 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 86c4adc0c9..fb68cf81e9 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 @@ -1504,6 +1505,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 Mon Feb 13 14:40:30 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: 13138514 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 422C0C636D4 for ; Mon, 13 Feb 2023 14:41:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRa0m-00067c-B7; Mon, 13 Feb 2023 09:40:56 -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 1pRa0k-00066i-Ks for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:40:54 -0500 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRa0j-0005S4-1h for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:40:54 -0500 Received: by mail-pj1-x1033.google.com with SMTP id d13-20020a17090ad3cd00b0023127b2d602so12394903pjw.2 for ; Mon, 13 Feb 2023 06:40:52 -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=6hwFanLgG46y9VdtBJOixXPpVviBQoYKFFHS0ZT/nyg=; b=Eq1n3mFJLK9Fx8wZkCFBhF3uAhlaerhVpk3PgECXb5IgeQ/Zx7Sx4NcXTYXcA59rB8 5cbgdhgcmay5vW5DClIIb8kaDpe76d9baVF7lQAWzLfNtXjups8/ZITaN/11/YGjs1iH 7wUofesJ2YCXBfXOll/Zi6/N47Tl8VMIkQutfdZOzADBCbzc2+GDpZyvMiOjHNAc+YXl +dvATswltdGdRyTBgI/G+Vn3qCPERFL/ZydFdeeuJ/RmA7zQoVwsD8Cp+/lsZyfiDFOI H2C0n4D6SWIiLNzjGfJjpQp71jEtmBCGD2Lnx9J8OAt7UoHC4MxXVq45GIUI6rOIOyKQ ziiA== 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=6hwFanLgG46y9VdtBJOixXPpVviBQoYKFFHS0ZT/nyg=; b=iDKayrI+PmQo8P7f067EKf1bBjA0ZHq0hC2BBQ/BkhiNJhUFO64vrvbSE1Y097kpcW BT2RkkMuQ20eqiqBUXyE5JjopQY5pKT8JGN2/qIWu+CrYyYrC/kcX9pj53p6/+M6JOhS nXJFb/WqCkqd4xJWXQJunB8xSAMZiXG2LACV4BFzr3fyqazfEPC3grv4OODtp7Ny2XXb tnGmaY5RUE7xBKZSvlZ3/hEhQwjRzroQCRVdkC220NRRIR7c1XOWUpBuAIIjJtfeb9Ll hC3aYryzQXYCdr197tnEozkqlxaJRoKBKZX/5J1tCq4hEhy6K9wihPtkk9RxGiz+dJEp kj2Q== X-Gm-Message-State: AO0yUKXxRCgljP2VuqHjRjOsoI551baDdQw5xRjKvE07xGaamyVqXWcG i62Qzd3E6Y2/32j6W5i5SU88DQ== X-Google-Smtp-Source: AK7set+AIadOMj+pHiIIBYyuT9nN1M1R/XtKJlVucYQGhc8Y/opY+Lzjf1g2Hhiux8+miLisxdFXtA== X-Received: by 2002:a05:6a21:9985:b0:b6:597f:66a1 with SMTP id ve5-20020a056a21998500b000b6597f66a1mr31194045pzb.60.1676299251546; Mon, 13 Feb 2023 06:40:51 -0800 (PST) Received: from kerodi.Dlink ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id y23-20020a63de57000000b004fb8732a2f9sm3777757pgi.88.2023.02.13.06.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 06:40:51 -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 , Daniel Henrique Barboza , Sunil V L Subject: [PATCH V2 02/10] hw/riscv/virt: Add a switch to enable/disable ACPI Date: Mon, 13 Feb 2023 20:10:30 +0530 Message-Id: <20230213144038.2547584-3-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213144038.2547584-1-sunilvl@ventanamicro.com> References: <20230213144038.2547584-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x1033.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 ACPI is enabled by default. Add a switch to turn off for testing and debug purposes. Signed-off-by: Sunil V L Reviewed-by: Andrew Jones --- hw/riscv/virt.c | 35 +++++++++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 2 ++ 2 files changed, 37 insertions(+) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index fb68cf81e9..58d3765b6d 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 @@ -1517,6 +1518,9 @@ static void virt_machine_init(MachineState *machine) static void virt_machine_instance_init(Object *obj) { + RISCVVirtState *s = RISCV_VIRT_MACHINE(obj); + + s->acpi = ON_OFF_AUTO_AUTO; } static char *virt_get_aia_guests(Object *obj, Error **errp) @@ -1591,6 +1595,32 @@ 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) +{ + RISCVVirtState *s = RISCV_VIRT_MACHINE(obj); + + 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) +{ + RISCVVirtState *s = RISCV_VIRT_MACHINE(obj); + + visit_type_OnOffAuto(v, name, &s->acpi, errp); +} + static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, DeviceState *dev) { @@ -1662,6 +1692,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 Mon Feb 13 14:40:31 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: 13138510 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 062D8C6379F for ; Mon, 13 Feb 2023 14:41:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRa0q-000692-8C; Mon, 13 Feb 2023 09:41:00 -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 1pRa0o-00068Y-E0 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:40:58 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRa0m-0005Se-2F for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:40:58 -0500 Received: by mail-pj1-x1029.google.com with SMTP id f16-20020a17090a9b1000b0023058bbd7b2so12425945pjp.0 for ; Mon, 13 Feb 2023 06:40:55 -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=O5ZHbzn8UznmI/HA0ZrfnP4iDQsCNTxYGyI26FNASvs=; b=BSo33pDSSADN9+f5he6nwOJZPK1c5IhwrUeKYv7eOcEoJe0GDmkS2z07qRvPZ89plv iZ6+hLWfCr58I073C4ph9wiAeUBD0EZTQ9FvOye/dYPTre+X79OuGIk5oumBS8ttFs3I 6bWwEA3PMrDwij6VBOG81IsytfBaLvO1uHrBIcFRulQ0sVpLXxC3gzambf1aDEm7rjlK zJMLCtjbV4CV60j0QxtIHyRxveVorx2Q1SPEXrqXXc5NXXWw6r4BK0vshUXYC20Mxbn+ k75F/nIPQmrQnojmr1RFnRoaRlWyUOBl5PoNZ47pSJaTfaBWociGpxVGzbvao+Dc0Mk8 l6jg== 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=O5ZHbzn8UznmI/HA0ZrfnP4iDQsCNTxYGyI26FNASvs=; b=kLSIz4CmZwPkdFH3By0pzCHFK9XdDh3wu0hVRFrHGUT6ugceWFnl8PkQCt2p6rMQlP r9ZtV3Pe7PJ5Z2zuxDyZz9XhgeZ0d902u0g0hi/952zdyHlkHjEGHzfzeHYt4M0AtvKP LhNSBZMfbT5t95q7aMPOsQ1nrq610Fl15x9lLdamE2n086JavixGnxht2e1R7rh78HkV 5ups1IMq3kO1y+MJwqO8xkawRc5Tgtrjx5SHAEkNvX47p0Fx3lB7tKSiZ9ymozvJ7LPH HrC4WblVRDZL7QxFc3HSDj3yFkHZeA4BFwi+BA8XonDLM7vwEGqZKJroKwSI4zve+ytH iZTA== X-Gm-Message-State: AO0yUKUEsq7B8NundpIOnIj77wvap5gP8EUT3EHX7ZmrZSJw453i22zy ng5+C/rhxVTDsmsD1uHKbQGdug== X-Google-Smtp-Source: AK7set9H5LwsLISspf9wX4l555IjcfE7kx0OLQg9coYrZQsEZCH5qLfTopJuK9oNmvsYol0sVFXzbg== X-Received: by 2002:a05:6a20:a026:b0:c3:3ea7:e318 with SMTP id p38-20020a056a20a02600b000c33ea7e318mr20379538pzj.42.1676299254786; Mon, 13 Feb 2023 06:40:54 -0800 (PST) Received: from kerodi.Dlink ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id y23-20020a63de57000000b004fb8732a2f9sm3777757pgi.88.2023.02.13.06.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 06:40:54 -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 , Daniel Henrique Barboza , Sunil V L , Bin Meng Subject: [PATCH V2 03/10] hw/riscv/virt: Add memmap pointer to RiscVVirtState Date: Mon, 13 Feb 2023 20:10:31 +0530 Message-Id: <20230213144038.2547584-4-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213144038.2547584-1-sunilvl@ventanamicro.com> References: <20230213144038.2547584-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=sunilvl@ventanamicro.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, 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 Reviewed-by: Andrew Jones --- 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 58d3765b6d..5017ba62ec 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1451,6 +1451,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 Mon Feb 13 14:40:32 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: 13138520 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 57ED5C636CC for ; Mon, 13 Feb 2023 14:43:19 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRa0t-00069m-2R; Mon, 13 Feb 2023 09:41: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 1pRa0r-00069H-AW for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:41:01 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRa0p-0005TD-39 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:41:01 -0500 Received: by mail-pj1-x1029.google.com with SMTP id mg23so5572927pjb.0 for ; Mon, 13 Feb 2023 06:40:58 -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=0eLoQ9zLWtFImYwDb8SvLj1FDC7mv1tfjr/gtA6oPLc=; b=kE18qm8l+Pg6h4tmmFsanNlsC/XjQW08AJRWRnuBOuyiw5f27i4Hs7twq22ITxJMRs JX2htEZS7TQtOQNq3CIUoY1mZ2hsoRkHrSQNOOsgYIVegsrOOLtHYr1Lh97/WwVzpcC8 6qMTVEtbqdf7wNDFJdQ4PHeI7j29NgW8FJsnOeNqXPhm4nohSqA9Yl7Ldfo/CrS9B+Ug Mc6kpJkzikaQzkyTeYM7Mhn7eL06JWPijnv0uUZ/XxP9cbMlnpuygHEdMVoH0T2/RZi4 EDy5DoN5cdFROwTGz5Lwfd1BFs7mn2zJwGWE+XLtPaifKRrYOtAV7+Fu5zYz6QCPkNPo 2dkA== 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=0eLoQ9zLWtFImYwDb8SvLj1FDC7mv1tfjr/gtA6oPLc=; b=kYRWEVBOuyOdIBhqeTJ2jcCCjJKGWNXEM/Ns2gqmfjIBqu9EMk2UTqLVW+V5eXGASm WhM5FrEKn2btKIysAG5vzszY3g/kuLEE95m2kN6m39fhGnO+/XbS/RrUVOQhRXkYtksQ T14kIPUFzNgYEGnUAFDknptQ/kfAQlFr8ABwFTwjZnjiGsrl9M3mw0VWFhgh2NuKI0Eo FNIVE+vd0GmZC37PvcOQDIBVnM1PbSXeOYz3nvKZp+bD4lOPJuuxTM19EKQYmkq7xaoT NQMSCelQWf2xtI5ED8ABppe1Egt/XU52hWRLBINeqqYeP5XNqzTEZSlukWrDdMV9ToZb 30iw== X-Gm-Message-State: AO0yUKWpQfunl43a/VoQeRVLSXlKfNmz+smYL6m5cDvlIRJfqEiWkczM rclSJ+/53fa/VCRCwRBVi/z26g== X-Google-Smtp-Source: AK7set/tMgWFsOrJeOz0RnupbsJPdS+F4szB8hZj4WwlIWne7F7c0YLVEI3UUG6kySJFEUwXvCe0Ug== X-Received: by 2002:a05:6a21:3398:b0:be:cbee:ed9d with SMTP id yy24-20020a056a21339800b000becbeeed9dmr29454408pzb.45.1676299257876; Mon, 13 Feb 2023 06:40:57 -0800 (PST) Received: from kerodi.Dlink ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id y23-20020a63de57000000b004fb8732a2f9sm3777757pgi.88.2023.02.13.06.40.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 06:40:57 -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 , Daniel Henrique Barboza , Sunil V L Subject: [PATCH V2 04/10] hw/riscv/virt: virt-acpi-build.c: Add basic ACPI tables Date: Mon, 13 Feb 2023 20:10:32 +0530 Message-Id: <20230213144038.2547584-5-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213144038.2547584-1-sunilvl@ventanamicro.com> References: <20230213144038.2547584-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=sunilvl@ventanamicro.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, 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 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 | 285 +++++++++++++++++++++++++++++++++++++ include/hw/riscv/virt.h | 1 + 2 files changed, 286 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..3c4da6c385 --- /dev/null +++ b/hw/riscv/virt-acpi-build.c @@ -0,0 +1,285 @@ +/* + * 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 *s) +{ + MachineState *ms = MACHINE(s); + 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 *s, 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, s->oem_id, s->oem_table_id); +} + +/* DSDT */ +static void +build_dsdt(GArray *table_data, BIOSLinker *linker, RISCVVirtState *s) +{ + Aml *scope, *dsdt; + const MemMapEntry *memmap = s->memmap; + AcpiTable table = { .sig = "DSDT", .rev = 2, .oem_id = s->oem_id, + .oem_table_id = s->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, s); + + 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 *s, 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, s); + + /* FADT and others pointed to by RSDT */ + acpi_add_table(table_offsets, tables_blob); + build_fadt_rev6(tables_blob, tables->linker, s, dsdt); + + acpi_add_table(table_offsets, tables_blob); + build_madt(tables_blob, tables->linker, s); + + acpi_add_table(table_offsets, tables_blob); + build_rhct(tables_blob, tables->linker, s); + + /* XSDT is pointed to by RSDP */ + xsdt = tables_blob->len; + build_xsdt(tables_blob, tables->linker, table_offsets, s->oem_id, + s->oem_table_id); + + /* RSDP is in FSEG memory, so allocate it separately */ + { + AcpiRsdpData rsdp_data = { + .revision = 2, + .oem_id = s->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); + + + /* Clean up 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 *s) +{ + AcpiBuildTables tables; + AcpiBuildState *build_state; + + build_state = g_malloc0(sizeof *build_state); + + acpi_build_tables_init(&tables); + virt_acpi_build(s, &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); + + /* + * Clean up 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 Mon Feb 13 14:40:33 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: 13138512 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 9DFF0C636D4 for ; Mon, 13 Feb 2023 14:41:41 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRa0w-0006Gh-4X; Mon, 13 Feb 2023 09:41:06 -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 1pRa0t-00069r-NX for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:41:03 -0500 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRa0s-0005TZ-8K for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:41:03 -0500 Received: by mail-pj1-x102f.google.com with SMTP id fu4-20020a17090ad18400b002341fadc370so444937pjb.1 for ; Mon, 13 Feb 2023 06:41:01 -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=+3u0RokfiHf27XjD4i6Mx9oLVxpDXWFhjR84GcrrvHM=; b=UPv4RYOOVUFFCqH6R2CFWZeZZJ5ak7b2ts0HBQkYy1ovG1d8xArloXyE+v74Lj1wpA tXoXzZ4rt9eRyjaZEf6PVds3OPawuX35jrNKPStS2F0NvNbWVRnLlRLL11hZSgeLiI6k H3+SWsCcdQvW9hRq+SyMSF55Dq/E12g7WcTJHJdnt7Tk0oDrwlqrGx4YcpJo2XeMStHZ N21qr2qJ+001RkZstpf86IT3vRxOJ4E+oytlDtmfzN1jZWX8g8rNFjFBIT417UOErGge qP/gB9IszyweyJxNGt502+G7OhrDbAoTo38NbPb6NJQBxWZK/RAZK0MMPilMLbTfzR/F +aoQ== 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=+3u0RokfiHf27XjD4i6Mx9oLVxpDXWFhjR84GcrrvHM=; b=0x/7nBpPEe3eHuqXLHB/O13jrWhDhUEUqRfDQl9WokE66lh9fcq/H4JsGsowULbE0e FCgmTEEU+AEJB3SJ5L7KtftSxJa9gw326RRQMRzCDSkJSwOQ8pmPeWte96T9ksStxtkQ /25p/OIui/LO7vtZOXxGkMjfZ6VRbuekzsadw6/JYdjk0lmqse3hMZ+0NV4qGSek7eSs ihQYiQqNBO5TW0w3cHE8WblGNJCNb2taWbf3/xj/hn3TzBlQeEoxyHV+yYOgudqzqzLA JXDwcY42+pBiMLALpjHkj+bQXUZf3m//Lar2GgmIQrz7m9Hsa2VjeM+A+uKsfvH0Qy7X SBPA== X-Gm-Message-State: AO0yUKWaOGGzBAuEwBO8pViXL96rpd+/u0rmci0XomyitrO1QLdKkh8w DVa+I32mz5Dw4dcE6A/F9DjWLQ== X-Google-Smtp-Source: AK7set9D8UV7qg4n5sPlhULf2l54VjAcJ7V3uYyXRkoYOcBy/YFitdVFOPVxvPWaTX/A3WjtoP5mnw== X-Received: by 2002:a05:6a21:6713:b0:be:ec6e:6470 with SMTP id wh19-20020a056a21671300b000beec6e6470mr18945116pzb.22.1676299260949; Mon, 13 Feb 2023 06:41:00 -0800 (PST) Received: from kerodi.Dlink ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id y23-20020a63de57000000b004fb8732a2f9sm3777757pgi.88.2023.02.13.06.40.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 06:41:00 -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 , Daniel Henrique Barboza , Sunil V L Subject: [PATCH V2 05/10] hw/riscv/virt: virt-acpi-build.c: Add RINTC in MADT Date: Mon, 13 Feb 2023 20:10:33 +0530 Message-Id: <20230213144038.2547584-6-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213144038.2547584-1-sunilvl@ventanamicro.com> References: <20230213144038.2547584-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=sunilvl@ventanamicro.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, 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 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 3c4da6c385..f54e3fb731 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -134,6 +134,43 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, RISCVVirtState *s) free_aml_allocator(); } +/* MADT */ +static void +build_madt(GArray *table_data, BIOSLinker *linker, RISCVVirtState *s) +{ + MachineState *mc = MACHINE(s); + int socket; + uint16_t base_hartid = 0; + uint32_t cpu_id = 0; + + AcpiTable table = { .sig = "APIC", .rev = 6, .oem_id = s->oem_id, + .oem_table_id = s->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 < s->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 *s, AcpiBuildTables *tables) { From patchwork Mon Feb 13 14:40:34 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: 13138513 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 73710C636CC for ; Mon, 13 Feb 2023 14:41:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRa16-0006QD-TT; Mon, 13 Feb 2023 09:41:17 -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 1pRa0x-0006M8-Ij for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:41:07 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRa0v-0005U3-Pn for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:41:07 -0500 Received: by mail-pl1-x632.google.com with SMTP id be8so13700307plb.7 for ; Mon, 13 Feb 2023 06:41:04 -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=TOOkIxFVgPXWV2ES8OUWvowBZVo0ahQSM7wWYcaITEk=; b=P8BCSC4QMMVCAigof52w7r8XrRZhwLCqoOvKkohNo4uVuwi2PX0DEUMabBNnxloC3h TKK42O9TaoCiLXaiicHdDWIE9NV72Dj7b+Av+FpSOK+trmJrPfmpf4yjBW0mDMSqRcoY 0uyP1erkERiYsvp9pTfJ6DtyKe1cJNqws8N6UzVbkVwIzo78F2IxNY/sW9lyozsnWqQb pvLCqFzmAZLWh9W5cLF5VkfsRmhlqH3U7lnH5tIdUBDWDBhTwTq3MCWRZ3v1YCOuQWZC lioEjsD0kmF9kI/5+lUjIvFGGhSIpXhuzJFv1r+pYjvi3b4UQ1j4qcqtD9JIkMqhdaAe gSGA== 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=TOOkIxFVgPXWV2ES8OUWvowBZVo0ahQSM7wWYcaITEk=; b=Sp+t+xL/RoDDsrU58TWY4ESatlDMop/h0kSrUN/UV8FrFwpwJzZ9gmkqzpEB9aDICA eI/OODy6iCBFpcWwtWIlSZuUeVTliCgsOs3D4DP3OzaUc3iiBr2ICNS+YBkpCl3LmBQ6 tbpbnh3HuLW3s5XhS5OU5Nauf6bGOHA9VtN0/LArt3eiEdYeRdB5OIJ8H7zU0k1rJzJ6 lOL7dEcUrcAFL42eXHf1YgxhtlRsdN823IxjJSFHqM0ydByKclPpbeZqxcdTDNhY8rft V1oNXqp7tdSky+XOnJv91ev3Yn3C9VOjox5ZENbDLYxEABnYlRMMjB5janrZaea8D9sh VD9Q== X-Gm-Message-State: AO0yUKXj+0VWeyY9YCoSvZLWJU7aqqBiRfGDfMki/GzRIwLLRj9V04D9 LLA93dcc+IXswFZ2tpbEIFNamw== X-Google-Smtp-Source: AK7set+u4iucazsP/I2nZW+PlAguD1NTrpkxhT2MWviWalN1qcwpb5hdmGMjD6ssqfMHb+tZUrAUGg== X-Received: by 2002:a05:6a20:699f:b0:c0:be63:75c9 with SMTP id t31-20020a056a20699f00b000c0be6375c9mr29008342pzk.43.1676299264000; Mon, 13 Feb 2023 06:41:04 -0800 (PST) Received: from kerodi.Dlink ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id y23-20020a63de57000000b004fb8732a2f9sm3777757pgi.88.2023.02.13.06.41.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 06:41:03 -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 , Daniel Henrique Barboza , Sunil V L Subject: [PATCH V2 06/10] hw/riscv/virt: virt-acpi-build.c: Add RHCT Table Date: Mon, 13 Feb 2023 20:10:34 +0530 Message-Id: <20230213144038.2547584-7-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213144038.2547584-1-sunilvl@ventanamicro.com> References: <20230213144038.2547584-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=sunilvl@ventanamicro.com; helo=mail-pl1-x632.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 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 Reviewed-by: Andrew Jones --- 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 f54e3fb731..a2054f79a8 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 @@ -85,6 +86,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 *s) +{ + MachineState *ms = MACHINE(s); + 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 = s->oem_id, + .oem_table_id = s->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 = &s->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 < s->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 Mon Feb 13 14:40:35 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: 13138519 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 13429C636CC for ; Mon, 13 Feb 2023 14:43:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRa1F-0006iN-6e; Mon, 13 Feb 2023 09:41:25 -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 1pRa0z-0006NT-E7 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:41:09 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRa0x-0005Pt-Tj for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:41:09 -0500 Received: by mail-pl1-x634.google.com with SMTP id v23so13717454plo.1 for ; Mon, 13 Feb 2023 06:41:07 -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=RgzlygJJuvY6dcow83KRw6ped9RQQR2f9ScRzTB5pLI=; b=TESWMqTtmWIBuD5doSsdP0OVG1VEj4lTMbyDmoQaAt+xGqwgfCugMKL0j6x+AG79Zv gacwIy5my4P7/rhrG4iiAYUVoesqzbtuFAtSAumkep36zvrolrsdEPuPp9CdW35mtnz3 YCSm6XEK87LxHi+Pe1clirfodxLcyPOk02lgR+rdgHnVGPPRdjmRA/P5doJp5kKY4aAt m3tCaoINp1TPUdFh09spbUOTW3WL//jE3zUeZaaHW5Dceitsomt6CNmT5LKPb2LcHOhR jtMFoDYYSjP89qjNwz+MYyoCg77Pqu60BGffgzUuol0PuTSxMRhGFUkzZi+hCtXL8URo 7YAA== 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=RgzlygJJuvY6dcow83KRw6ped9RQQR2f9ScRzTB5pLI=; b=UeDgUw9wjLk0iJ1gGk479YAcIxQxexpsc6lzNcPgccbfz9pkE78ERuChdXRqPO1cNp 7G77Onr9QeGHxaexdiViMFWkH3zcatx0WRYvcSINxMTaR512SClOrn/KhlwYKDmEz3WX pOr0Fh47zom8Vh1ETt+v/vKhgmk9FMQnSYTHjf+5XDlkxxJkRNeC/PzgxbIkhPJ72kNV VGPO4OcWBxLNag914Q6f+2iD//KU7iztaygtGNnScMSIbTzF2hTat469v4YRruJJ4dLs a5ge/53bC6o9llh3OIrNnUqBjRq/ONPkJ7CPRy6X18xes/46PGbmUrmUnJDdm0JnDjAV 4XRQ== X-Gm-Message-State: AO0yUKV/MYmmrdEaSgmjPvGx3P3zHWiKV+tIwKFJrsfnNE+GJSOlyCUN 1mJoVLAOVISN77czDYwcvYd8Pg== X-Google-Smtp-Source: AK7set/C5vjJgsDoml0IXhtFoy1ylq5WSOdPSbfDkzx9WvRqCvG/odsH12B80XvPl8hezDYSZnMnWg== X-Received: by 2002:a17:90b:4f90:b0:234:3d3:51b6 with SMTP id qe16-20020a17090b4f9000b0023403d351b6mr2963098pjb.23.1676299267282; Mon, 13 Feb 2023 06:41:07 -0800 (PST) Received: from kerodi.Dlink ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id y23-20020a63de57000000b004fb8732a2f9sm3777757pgi.88.2023.02.13.06.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 06:41:07 -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 , Daniel Henrique Barboza , Sunil V L , Bin Meng Subject: [PATCH V2 07/10] hw/riscv: meson.build: Build virt-acpi-build.c Date: Mon, 13 Feb 2023 20:10:35 +0530 Message-Id: <20230213144038.2547584-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213144038.2547584-1-sunilvl@ventanamicro.com> References: <20230213144038.2547584-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=sunilvl@ventanamicro.com; helo=mail-pl1-x634.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 Reviewed-by: Andrew Jones --- 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 Mon Feb 13 14:40:36 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: 13138516 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 1B15CC636CC for ; Mon, 13 Feb 2023 14:42:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRa1F-0006jI-AO; Mon, 13 Feb 2023 09:41:25 -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 1pRa12-0006PD-G3 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:41:13 -0500 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRa10-0005Uq-Vp for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:41:12 -0500 Received: by mail-pj1-x1034.google.com with SMTP id d2so12102605pjd.5 for ; Mon, 13 Feb 2023 06:41:10 -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=BupoAsKzkCuUQGMRjABpAZtafv55Wlzos5b537icK1M=; b=X6fJqO52WK5G21xPZlaYlw76kce6n/qWl1RmSXWhddsrWkOyc1zVXl70Pn+N5PFD4m nrCdsYsrPfcMAayCDs8AM4mCTgtLuahTQt23wGABXDF7gCXHUhs0GdDVUfxlVqmK+86f 5pEt3FoyA1bNX+HqqH8WBsCwZtmGGSl/mox+oNJtAiTYUPyOZ2hs1hJ+g2bgYKu2N7Yf qyQOc1+CeVc/Bb+FgvUWMYhcxYKNjwNX3vHC3Mj5oNBSXVbHogX6C1eln4v+Z9xyy8Rf pqhciKWJzJazrS0zfTw7VGE04KC7Pe0QdfVbaYjLesgTUh4XfNelon4tCmjPRx1oULdy dkgg== 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=BupoAsKzkCuUQGMRjABpAZtafv55Wlzos5b537icK1M=; b=e3uvyZcpcuAmUDK7hQG9NFgF0WeSJ9fzIKtsLCQYs7DL/qTXUG0r4Ts5NFqOcx/Cjp VUBOIuf8DsrT3a/D0G6c0bdtN3ySVSTPioF1nePO2kPw8r0ftKmFInjB1fTV7bpfrWiF fUaenAAur2kQy+BfjLib2dJWOba7spXgPOVNtcHyGXUFhgwaBFRjhYunMD4093Ef9PK9 xKD0WN9wg2PLHwY83GVyb10CM7N7PFCYQBBd62dJSHkpSX66J1fbftf4a5zGyR23j5p/ Zs3HM2rSuJLats96zj2S1BQLEihz3Dvdd017ECnNqjHVS7B4JJC9BnLJdb7DOtnDZDH3 VFyg== X-Gm-Message-State: AO0yUKVvnOGy1YMiSkEUm+9pArXNQrxMA543DnzA+zFDKmxXkHyCBKzh iCRy8akgN56JaT6qZocRiBl6tA== X-Google-Smtp-Source: AK7set8Zn0RuIZXDYANn9ehg4ks0QxiuDA+hYshyO6duuJfCYDODEZco22k3TmXvqOU9qi2yTLrFNg== X-Received: by 2002:a05:6a20:3d8b:b0:bc:ce49:798d with SMTP id s11-20020a056a203d8b00b000bcce49798dmr32659043pzi.41.1676299270293; Mon, 13 Feb 2023 06:41:10 -0800 (PST) Received: from kerodi.Dlink ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id y23-20020a63de57000000b004fb8732a2f9sm3777757pgi.88.2023.02.13.06.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 06:41:10 -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 , Daniel Henrique Barboza , Sunil V L Subject: [PATCH V2 08/10] hw/riscv/Kconfig: virt: Enable ACPI config option Date: Mon, 13 Feb 2023 20:10:36 +0530 Message-Id: <20230213144038.2547584-9-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213144038.2547584-1-sunilvl@ventanamicro.com> References: <20230213144038.2547584-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=sunilvl@ventanamicro.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, 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 option to build ACPI subsystem for virt machine. Signed-off-by: Sunil V L Reviewed-by: Andrew Jones --- hw/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/riscv/Kconfig b/hw/riscv/Kconfig index 4550b3b938..6528ebfa3a 100644 --- a/hw/riscv/Kconfig +++ b/hw/riscv/Kconfig @@ -44,6 +44,7 @@ config RISCV_VIRT select VIRTIO_MMIO select FW_CFG_DMA select PLATFORM_BUS + select ACPI config SHAKTI_C bool From patchwork Mon Feb 13 14:40:37 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: 13138517 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 39872C636D4 for ; Mon, 13 Feb 2023 14:42:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRa1F-0006im-8S; Mon, 13 Feb 2023 09:41:25 -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 1pRa16-0006RL-QH for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:41:17 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRa15-0005Ve-Cb for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:41:16 -0500 Received: by mail-pl1-x630.google.com with SMTP id ja21so6107826plb.13 for ; Mon, 13 Feb 2023 06:41:14 -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=L39PhdXfC8+RktTLziyz2PO6qwKRkojAvf2ARDN/TAM=; b=B2P4wBxwRJbjRSe3XH2Dr9Aw2E//SDmFQrkz8VnmUQ0knOfkFYYu/Kq3bwzaoayIbx sJwPR7D3DayCUaScw20vzaUFg5KAqcAQyvR95sGEfWD+65MphN33LxzMCpvlGtFJi4Os eyqk4kQq26C351bOWgQYkinFttYnxqCVWmZ5l7PwU53wqHhuzUQzOWuLMCS3JKDnie4N HC+//PKytHbh2U/yivM2BazU8c8MsS5HL+ElES9b4j7GvWWevnjqPNK8MJsflENpbVWW 7HGYc9E43j2n8xGKzHVdg1TywtHv2w6WM/WHin06aw57V/uAFgGF6uaBz5bca7nkyfEL nKQw== 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=L39PhdXfC8+RktTLziyz2PO6qwKRkojAvf2ARDN/TAM=; b=3/rc37AOZDeSvnd4hgmjquhPIVplC2UpOF9BEJBPZl8LGvQjGXoRvVW/hO2HDWMENk cQA9oCZPOJYs9Pq4Nlzpw+sqg2+zoXJK95KUNDC1GvJbfKDkioe906nOU2lArHxOjTXT kxjMoDgMZYnYiCVwU8jSJYXJu11+MWavhtqwS4Gn0nbRDE6Vr9q5akmn6/rWO0Wa8p0L iSzWk1Bke3DOd1sqHfVGGVEg2zzNmFkjYGhjQ73RA5RQ4r4SwrCQaCWdt1883zNHDqaj 96PsVCfIk4dhY+3cwkLx4lb+txFg6v6FnM825huEPjuEmpgV/rx9Q3JybeFapo1/njhM y+0w== X-Gm-Message-State: AO0yUKWO/Guom8JVWMYcrraojqFkqelmknMjRTG4PP1pvtUq9R5N8NSM spx9PKFnYX6geU1mrS7MnPpQNQ== X-Google-Smtp-Source: AK7set8rDmutL1lEcAC8xb2+4yOwRthmMcdRUH6Zcdm7oT6wSrF3ehlrTiF/2ObwuplT8X3htG1mdg== X-Received: by 2002:a17:903:1390:b0:19a:84db:76ed with SMTP id jx16-20020a170903139000b0019a84db76edmr6508715plb.15.1676299273529; Mon, 13 Feb 2023 06:41:13 -0800 (PST) Received: from kerodi.Dlink ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id y23-20020a63de57000000b004fb8732a2f9sm3777757pgi.88.2023.02.13.06.41.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 06:41:13 -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 , Daniel Henrique Barboza , Sunil V L , Bin Meng Subject: [PATCH V2 09/10] hw/riscv/virt.c: Initialize the ACPI tables Date: Mon, 13 Feb 2023 20:10:37 +0530 Message-Id: <20230213144038.2547584-10-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213144038.2547584-1-sunilvl@ventanamicro.com> References: <20230213144038.2547584-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=sunilvl@ventanamicro.com; helo=mail-pl1-x630.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 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 Reviewed-by: Andrew Jones --- hw/riscv/virt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index 5017ba62ec..43c201c8cf 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1316,6 +1316,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 Mon Feb 13 14:40:38 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: 13138518 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 4011FC636D4 for ; Mon, 13 Feb 2023 14:42:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRa1G-0006xm-NH; Mon, 13 Feb 2023 09:41:26 -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 1pRa1A-0006bf-U5 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:41:21 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRa18-0005W6-90 for qemu-devel@nongnu.org; Mon, 13 Feb 2023 09:41:20 -0500 Received: by mail-pl1-x62e.google.com with SMTP id m2so13704311plg.4 for ; Mon, 13 Feb 2023 06:41:17 -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=VGmMRSpWYKk+0FgEIzjc2vNeSjRQeNBhuoCePce7D9U=; b=NfEuSaOBRNvI+pFdEP6tJRyPCwkboPixT9HOGFVCiQnhI+mLDoIXQJ0KDRXeeq9QbM QqjwHY8hdfDiqRO98fufqeV7WnW0vX6hcYbCVBniKnsGlQ9MupD/SvlcEyUM1EQF1vAL EBQRh+TkD6V2aHsxtQBWKGvtnxX3BpNGRljYH0vSiSSZEOwNQElYmiJ3a7XoC06jqxQk GRMMngt7MKWmmCnmUA/0u2KxoJCwOz0b+KOHTF8N0pNH2EAsl2MvbRA3ecYkKftTXmw9 mL2iBMSnNHZD/JPLKsztUrwZ7RciHmOIl98InIGMNhgoCeCLW9+dPZS/+pyL4JkPpQsJ UYVA== 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=VGmMRSpWYKk+0FgEIzjc2vNeSjRQeNBhuoCePce7D9U=; b=LEQF/z8pTSuN+IWpw9+cuXqovr8eyAD9U4q0cLva0vr6moV0MXIIzoNEnct4gKkrrK 5351rLpnbXMuSnjnSL7ES2ksMz2Zns//PHZtslL8r+jpu88U/DMIU6q2fevJkdObxOg/ S7Gabsqu4ZO6qeyf/oH9vmXUjX+L0NnlvLcgV+aDp45SB7EGGE2B69FxxTfm8hiiPAqu 4qxm+n11PZiwFaSpTeCgXHxezjxq9hUVYaIF6XMJHduIQg+vaLQ8VhylcVZ+OHwgh/or r+6/1n8pFv/x+BmdBnLaVhKS70MsZyV6doGeFe5/OXdXKDpkmkDIjrDPF1mqaAen4SaC Dexw== X-Gm-Message-State: AO0yUKW+MNNlf0Fnn4H6mF5naBKgszcPXJMTJZmBZimkUNiUYFqQ65NS Gsj21vJ/0M3yfB1O+TQ0xNqN/5E3H+bTcS7b X-Google-Smtp-Source: AK7set/ief8OMQtIH8lSuS7i2PN/jG71h15gobFZJYOWsMfeKG4R6ZEOXvHxoeLE0qrR7F2G7dRJCg== X-Received: by 2002:a05:6a20:158f:b0:be:9fff:48d8 with SMTP id h15-20020a056a20158f00b000be9fff48d8mr28502482pzj.49.1676299276813; Mon, 13 Feb 2023 06:41:16 -0800 (PST) Received: from kerodi.Dlink ([49.206.14.226]) by smtp.gmail.com with ESMTPSA id y23-20020a63de57000000b004fb8732a2f9sm3777757pgi.88.2023.02.13.06.41.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Feb 2023 06:41:16 -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 , Daniel Henrique Barboza , Sunil V L , Bin Meng Subject: [PATCH V2 10/10] MAINTAINERS: Add entry for RISC-V ACPI Date: Mon, 13 Feb 2023 20:10:38 +0530 Message-Id: <20230213144038.2547584-11-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230213144038.2547584-1-sunilvl@ventanamicro.com> References: <20230213144038.2547584-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=sunilvl@ventanamicro.com; helo=mail-pl1-x62e.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 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 Acked-by: Alistair Francis Reviewed-by: Andrew Jones --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 847bc7f131..7fb0f1052d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1003,6 +1003,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