From patchwork Thu May 2 05:12:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sia Jee Heng X-Patchwork-Id: 13651296 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 13323C4345F for ; Thu, 2 May 2024 05:14:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s2OlF-0000vz-JF; Thu, 02 May 2024 01:13:37 -0400 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 1s2Oko-0000m0-0j; Thu, 02 May 2024 01:13:11 -0400 Received: from mail-bjschn02on2070a.outbound.protection.partner.outlook.cn ([2406:e500:4440:2::70a] helo=CHN02-BJS-obe.outbound.protection.partner.outlook.cn) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2Okm-0005U9-3X; Thu, 02 May 2024 01:13:09 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AFQm/Tlrlc/VZMnfcZuUdGoLKT4Ns7L3fpQA4BKwRNl5AZrEG+1xSbu340pWMg/eK0L8R/hYLkvKzW+D2yJRzmFz8NPMljSG6LDFIYYTuGJsI+eFIAOfXzO9gBH4rrC2F/myj1X0x2yJSNSaczx00yQhgJPkONXaaEvPFNCDJUMwMmlHNMnbV6ilPeuzopRS7fMBPb7U+zdgqOwq5sfOMmubWqJkRJR0xmHzpndOnnD8M5Coj7/QcDcfY+8SC2JN2ggU3Srob/rpgNDo4FXolOwY5Ia8WAMj4KYxft+hGf5ka+++VVVgJF/GIOzz3HwafwmjlSYk8aFvlpLMdJiv3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gjaKTnKHpMrtN+U8R/RWEPVJl/v8Zgl5EuDYGGTZTkA=; b=U4IHc1BH8Ur4uLl1JG6/m4ebb5vnCZeF74auibXvYBxjVI+r7f/S38tShMtj2WeqA7VKkFAv2EWQqw1k8k8S+bqf0kCtwxzJ0lDekmDfhzumkFzu7rDJdEncuYBHNqJBh3TFsXEy9W40wD3X+iIwXXcfQezuPThCl6Z8RrpEmrrHjPs2a0lZxiB1mCkppcWN70hVzP0iJ8yZJWNk53dQeasaYevxempERzPEQ4B2kKYQVihA3/6xSJeuDg7TYZbNBAedx3M0+WvS2DvOUGrtolgxYC5+JuHAFrPcAzQi99Nk2SNhBXiWITqUzUIjpS+KMXgrzn7Eb/BPFOeY5ilIaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from NT0PR01MB1278.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:12::10) by NT0PR01MB0973.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.33; Thu, 2 May 2024 05:12:58 +0000 Received: from NT0PR01MB1278.CHNPR01.prod.partner.outlook.cn ([fe80::e604:661e:e939:4c87]) by NT0PR01MB1278.CHNPR01.prod.partner.outlook.cn ([fe80::e604:661e:e939:4c87%4]) with mapi id 15.20.7472.044; Thu, 2 May 2024 05:12:58 +0000 From: Sia Jee Heng To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: mst@redhat.com, imammedo@redhat.com, anisinha@redhat.com, peter.maydell@linaro.org, jeeheng.sia@starfivetech.com, shannon.zhaosl@gmail.com, sunilvl@ventanamicro.com, palmer@dabbelt.com, alistair.francis@wdc.com, bin.meng@windriver.com, liwei1518@gmail.com, dbarboza@ventanamicro.com, zhiwei_liu@linux.alibaba.com Subject: [PATCH v1 2/2] hw/acpi: Upgrade ACPI SPCR table to support SPCR table version 4 format Date: Wed, 1 May 2024 22:12:33 -0700 Message-Id: <20240502051233.50749-3-jeeheng.sia@starfivetech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240502051233.50749-1-jeeheng.sia@starfivetech.com> References: <20240502051233.50749-1-jeeheng.sia@starfivetech.com> X-ClientProxiedBy: BJXPR01CA0051.CHNPR01.prod.partner.outlook.cn (2406:e500:c211:12::18) To NT0PR01MB1278.CHNPR01.prod.partner.outlook.cn (2406:e500:c510:12::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: NT0PR01MB1278:EE_|NT0PR01MB0973:EE_ X-MS-Office365-Filtering-Correlation-Id: df62c320-8a2d-46c7-9767-08dc6a668821 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P/ruCM3suRXKgsLeBTR7NyoEKFVIQHWjRj1Xpt6wfJ+pIlS7MjpptJoHgHhzgPdTEVPvPoqD54mcnbkRFmC/4TDnTBhyU5oSM/xMknscqirBdmHHb0sT9BC1u6otjBfbXM95ajs1xz/Y3BtE0us/iRu74Ikg96Kcvd/2773bXzl17d5dDd8e2UhP5Pc+M12BlVN2hVbwP6uw+jqvLE71TwWnq9dmDGhXKjTWMQT8y36eIRr8z4FmXLD7QL4xNwsWKoR5isdaM2TLQzEhAVLNwLA5/H2L5Fu3fT9yTwSzAYCew35cc+6wlXdPKOhB9dX+VB0BMATpHE+i/TiGd+2yUC831s1PLC9VETrtmry47rh62XAIU7wmYZOPkGNG+ab+9FP7f98zLqv5HU32Ssv5MJmQ5o4EiA6UQ4erMmxT8snGjArWD+omHa7pSeGsHjpqjJUW9auZmKBhn/ltbLbSxvwPhycKHaVZEBq7Jxp7wUyM/rYXHcsN++KlFxGuu+nEO72KQOnohCqtf+Q6h88U4RQBRNWgRDDH1s0ueRS0L2LDz3ioHmts44NIQzSms3+pHUMj/Rip5bJSODNkUApTJNIpWXofkF7rkwRVHQuz9sGXaDDST+q+/Cg7c8fKhCeg X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:NT0PR01MB1278.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(7416005)(41320700004)(366007)(52116005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YZcpJuVcWmXseYGbaVKFD+KG4BymYPKn+0hZJ1jGns+sS+/J/So/+oaSwL/JNsruAJuZnBQr9uiynRICLfGnO4mHIYswcbYB1E2L0xwVQhhWgc2jkiQwVv+E254MnfcsiFhXhePIOy+mHZ6BZ+eaPKBIcv86WCFQ/liQvasmfqK1NPPuiMktbhkv/YwM8wKiOelI/3zbNeMjl63CJCziEXnOXyKmBbo8vbj+RU8pfPGb66cBhRXTRG+TRmH4La3en1UbniSjeG4PRwf6foBT3n8h7QmBFuHVl5g0kPtY9Xpft7syGdkVTVp4Z7XwivuBj9pg8b4IYJeTMEhtle9gWQLjTctEKfEm6q1CJKR42mzX56AcUSRQGxlcsLT/Lx33QbaKqiQfyWSMOhoZP33Ae28eAadnGesq8PRhJrf/xMiOdlCDdeBxNTTm9UuN9d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OT2ORRXXXYWgVu9EecbIgRg/ShTUDlKEEj9J93KxO6LRaRuwNMq5eKUAMqZ/5cRNwEAB4+BUK2HBGpxqgnX/bKl+KJeY5SVxK+/D/BFRg== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: df62c320-8a2d-46c7-9767-08dc6a668821 X-MS-Exchange-CrossTenant-AuthSource: NT0PR01MB1278.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 May 2024 05:12:58.4556 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: upNA0P/+MavvV7JEnN3dqRFvItqpykP0bvJfH2aFb1GmImUgUGT2FBls2mZznVNvq2WvNoeKiV1JzkwPjofFymltAORtA2a78T5IbTJ+ybM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: NT0PR01MB0973 Received-SPF: pass client-ip=2406:e500:4440:2::70a; envelope-from=jeeheng.sia@starfivetech.com; helo=CHN02-BJS-obe.outbound.protection.partner.outlook.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-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 Update the SPCR table to accommodate the SPCR Table version 4 [1]. The SPCR table has been modified to adhere to the version 4 format [2]. [1]: https://learn.microsoft.com/en-us/windows-hardware/drivers/serports/serial-port-console-redirection-table [2]: https://github.com/acpica/acpica/pull/931 Signed-off-by: Sia Jee Heng --- hw/acpi/aml-build.c | 14 +++++++++++--- hw/arm/virt-acpi-build.c | 10 ++++++++-- hw/riscv/virt-acpi-build.c | 10 ++++++++-- include/hw/acpi/acpi-defs.h | 7 +++++-- include/hw/acpi/aml-build.h | 2 +- 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 6d4517cfbe..7c43573eef 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1996,7 +1996,7 @@ static void build_processor_hierarchy_node(GArray *tbl, uint32_t flags, void build_spcr(GArray *table_data, BIOSLinker *linker, const AcpiSpcrData *f, const uint8_t rev, - const char *oem_id, const char *oem_table_id) + const char *oem_id, const char *oem_table_id, const char *name) { AcpiTable table = { .sig = "SPCR", .rev = rev, .oem_id = oem_id, .oem_table_id = oem_table_id }; @@ -2042,8 +2042,16 @@ void build_spcr(GArray *table_data, BIOSLinker *linker, build_append_int_noprefix(table_data, f->pci_flags, 4); /* PCI Segment */ build_append_int_noprefix(table_data, f->pci_segment, 1); - /* Reserved */ - build_append_int_noprefix(table_data, 0, 4); + /* UartClkFreq */ + build_append_int_noprefix(table_data, f->uart_clk_freq, 4); + /* PreciseBaudrate */ + build_append_int_noprefix(table_data, f->precise_baudrate, 4); + /* NameSpaceStringLength */ + build_append_int_noprefix(table_data, f->namespace_string_length, 2); + /* NameSpaceStringOffset */ + build_append_int_noprefix(table_data, f->namespace_string_offset, 2); + /* NamespaceString[] */ + g_array_append_vals(table_data, name, f->namespace_string_length); acpi_table_end(linker, &table); } diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index c3ccfef026..fc7b0176ed 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -429,11 +429,12 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) /* * Serial Port Console Redirection Table (SPCR) - * Rev: 1.07 + * Rev: 1.10 */ static void spcr_setup(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { + const char name[] = "."; AcpiSpcrData serial = { .interface_type = 3, /* ARM PL011 UART */ .base_addr.id = AML_AS_SYSTEM_MEMORY, @@ -457,9 +458,14 @@ spcr_setup(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) .pci_function = 0, .pci_flags = 0, .pci_segment = 0, + .uart_clk_freq = 0, + .precise_baudrate = 0, + .namespace_string_length = sizeof(name), + .namespace_string_offset = 88, }; - build_spcr(table_data, linker, &serial, 2, vms->oem_id, vms->oem_table_id); + build_spcr(table_data, linker, &serial, 4, vms->oem_id, vms->oem_table_id, + name); } /* diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 0925528160..5712211847 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -176,12 +176,13 @@ acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, /* * Serial Port Console Redirection Table (SPCR) - * Rev: 1.07 + * Rev: 1.10 */ static void spcr_setup(GArray *table_data, BIOSLinker *linker, RISCVVirtState *s) { + const char name[] = "."; AcpiSpcrData serial = { .interface_type = 0, /* 16550 compatible */ .base_addr.id = AML_AS_SYSTEM_MEMORY, @@ -205,9 +206,14 @@ spcr_setup(GArray *table_data, BIOSLinker *linker, RISCVVirtState *s) .pci_function = 0, .pci_flags = 0, .pci_segment = 0, + .uart_clk_freq = 0, + .precise_baudrate = 0, + .namespace_string_length = sizeof(name), + .namespace_string_offset = 88, }; - build_spcr(table_data, linker, &serial, 2, s->oem_id, s->oem_table_id); + build_spcr(table_data, linker, &serial, 4, s->oem_id, s->oem_table_id, + name); } /* RHCT Node[N] starts at offset 56 */ diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 0e6e82b339..2e6e341998 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -112,7 +112,6 @@ typedef struct AcpiSpcrData { uint8_t flow_control; uint8_t terminal_type; uint8_t language; - uint8_t reserved1; uint16_t pci_device_id; /* Must be 0xffff if not PCI device */ uint16_t pci_vendor_id; /* Must be 0xffff if not PCI device */ uint8_t pci_bus; @@ -120,7 +119,11 @@ typedef struct AcpiSpcrData { uint8_t pci_function; uint32_t pci_flags; uint8_t pci_segment; - uint32_t reserved2; + uint32_t uart_clk_freq; + uint32_t precise_baudrate; + uint32_t namespace_string_length; + uint32_t namespace_string_offset; + char namespace_string[]; } AcpiSpcrData; #define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0) diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index a3784155cb..68c0f2dbee 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -500,5 +500,5 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog, void build_spcr(GArray *table_data, BIOSLinker *linker, const AcpiSpcrData *f, const uint8_t rev, - const char *oem_id, const char *oem_table_id); + const char *oem_id, const char *oem_table_id, const char *name); #endif