Received: by 2002:a17:906:cf90:b0:9bd:85f7:2662 with SMTP id um16csp514442ejb; Thu, 19 Oct 2023 06:29:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGna7oUBcPQhlTSnwqziwnpU6DKOUQRE1peG4tgVqaoJKQtrIGxtpQ60XKnAOm7sgVzfc8a X-Received: by 2002:a05:6214:c2c:b0:65d:475a:a2f6 with SMTP id a12-20020a0562140c2c00b0065d475aa2f6mr1986116qvd.40.1697722144117; Thu, 19 Oct 2023 06:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697722144; cv=none; d=google.com; s=arc-20160816; b=1IkfmcRGTXZmO+oQyTDSQtneQhixO0nOrE3rdwUnOlxuf3ax9I6uL99r4atnaFMfrB IK2UNCLDcij80Qujw4zaRC4TbASNJgNag4MIKd9SMG8ibxdNOApowtrlLPJ57iQt21xk masXuh4Opdt+StgDaw1RQTeiNo+NyK9pbP3ez7H703enssh/5rpLWBC6WzgnDVJhmiQu Hbige2ec9DCO33YmiF/ZkRmwDZJtoBr8qrTV5NLoXwQ3FhMpCOhbiR2dPo4I8NNVGA0P /RH8A973toELEeRi2GH2WwHHyJuZLEdUx1FO3yYyFOf7sOxjhWc+L7pWC1DmpgCKd/Ta OzFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=U2S2mAMAT2NXR4ff7L+HAIRQxvaz06Y9HVtr0fxiVgU=; fh=qS7HOACB/fnzOG4UkP/DQwrsj+RVK26yEZmW8KA6D/k=; b=1Cmj9gS4GASPB5TmFbmpekUtHUTSInkwV4oYk4HdeZtdPOjH1ZBJX9T2WoLw7KCGGo fQa7uwqyH/sABy98igN4SNEoqCKAvlFRmlUnBLu3UY0vTJ8hLxH1W783OjrivJTCwDCY EdFa13P6NQPWA9C3g95teovfeGJj9Z+c1bj+1gEpzVPdzfoU3TECAbzcjm6kD05ros0q G9avFz1Z9TagR0CnGe3/Hm+zfpUQ+1ZYvKv0maGunBLxWdRGkT84EkDoefzKBypLQk6t 3mTGfC4DsVfMRT3aSH462JD2ttOdF3eIFOgjzva6/01KltFMwbqn0mZcqQ8Qim9nBK6T 9pKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=A72JR6GN; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id eu18-20020ad44f52000000b0066d05425799si1504144qvb.371.2023.10.19.06.29.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 06:29:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=A72JR6GN; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtT4T-0004FK-6Y; Thu, 19 Oct 2023 09:28:17 -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 1qtT4R-0004Bh-4b for qemu-arm@nongnu.org; Thu, 19 Oct 2023 09:28:15 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtT4P-00071V-6E for qemu-arm@nongnu.org; Thu, 19 Oct 2023 09:28:14 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-6b20a48522fso5470765b3a.1 for ; Thu, 19 Oct 2023 06:28:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1697722092; x=1698326892; darn=nongnu.org; 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=U2S2mAMAT2NXR4ff7L+HAIRQxvaz06Y9HVtr0fxiVgU=; b=A72JR6GNg4xxUtJnxFc7AdJUA0cobQdPumNElUOVt4FeGfWc7SiRFW3skjx07W5RU4 cJdJqEssm/PG7hDFU4elsdXIRXJ38TkATlCToYuxmsfmP33LxLGf7eV9HGG4eld2nnul mNs/Dk4Qw1SOR5jOX9zZ7qr2333Hcc+hi1xe5oRzs8mm0mnOizE1QX/y+6kMmiFnzgXq 8XvvHWW8pfQtSE0IjoC977wKuRiysMF2yECoEpCJl2KwGLzZ2QDJk5q5FWEn1gdfQrhc jYrJWTjYIOJk41fEr9NOMZbiQnG+J1MxnK+uZkI5PJSFwp/GfwjjEkguBkDZs6aWuYLI 2gFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697722092; x=1698326892; 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=U2S2mAMAT2NXR4ff7L+HAIRQxvaz06Y9HVtr0fxiVgU=; b=M3iPW7yORzdJFb6xneoYNYp8w0xAHLlge1aHxGF4P6dWUEp+TrmOW06IahvVcgfn4V cxtH2y3za8m4P+YhOyC0TC1FNvc/rksZdUUgTRCSG4U1ZWmsrrkRL5aQj1I7JeyrLGW+ ReUOCGVsrd/hyjK7xz72UwOxQQWTNaEE/qc8Y5vR5PK8GGY6r2GBgdUPijYlMvFWPt83 uhnCfdEBEQp/GWhONm/EJUshm0SnHzjHcvkufh89BIXCShel5AyLZFjQG70Np/oQTAAC Ivc9/HFhfC4bxIPm0H9iFAFfxtv1kwVQYmd4S7lBoAxMmNHp2ByzlPJ+6pmAzkQlB8Da Q8+Q== X-Gm-Message-State: AOJu0YyAy016DUua1fKKY7X6r0pxF4Jhy4yBtGcKd3OER1dh/I+67CJ2 SPjhcKz85/Yp/8m6SB1NoKDhGw== X-Received: by 2002:a05:6a00:23c4:b0:6b7:b42f:e438 with SMTP id g4-20020a056a0023c400b006b7b42fe438mr2358686pfc.8.1697722091244; Thu, 19 Oct 2023 06:28:11 -0700 (PDT) Received: from sunil-laptop.dc1.ventanamicro.com ([2409:4071:6e8b:3a98:dd76:4e82:7da6:44ab]) by smtp.gmail.com with ESMTPSA id f11-20020a056a00228b00b0068feb378b89sm5273113pfe.171.2023.10.19.06.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 06:28:10 -0700 (PDT) From: Sunil V L To: qemu-riscv@nongnu.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Shannon Zhao , Peter Maydell , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Andrew Jones , Atish Kumar Patra , Haibo Xu , Sunil V L Subject: [PATCH v3 07/12] hw/riscv/virt-acpi-build.c: Add CMO information in RHCT Date: Thu, 19 Oct 2023 18:56:43 +0530 Message-Id: <20231019132648.23703-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231019132648.23703-1-sunilvl@ventanamicro.com> References: <20231019132648.23703-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::429; envelope-from=sunilvl@ventanamicro.com; helo=mail-pf1-x429.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-arm@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-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: YxrpQ3mWgZji When CMO related extensions like Zicboz, Zicbom and Zicbop are enabled, the block size for those extensions need to be communicated via CMO node in RHCT. Add CMO node in RHCT if any of those CMO extensions are detected. Signed-off-by: Sunil V L Reviewed-by: Daniel Henrique Barboza --- hw/riscv/virt-acpi-build.c | 64 +++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 8 deletions(-) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 8fa358d034..bf47eef792 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -147,6 +147,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtState *s) * 5.2.36 RISC-V Hart Capabilities Table (RHCT) * REF: https://github.com/riscv-non-isa/riscv-acpi/issues/16 * https://drive.google.com/file/d/1nP3nFiH4jkPMp6COOxP6123DCZKR-tia/view + * https://drive.google.com/file/d/1sKbOa8m1UZw1JkquZYe3F1zQBN1xXsaf/view */ static void build_rhct(GArray *table_data, BIOSLinker *linker, @@ -156,8 +157,8 @@ static void build_rhct(GArray *table_data, MachineState *ms = MACHINE(s); const CPUArchIdList *arch_ids = mc->possible_cpu_arch_ids(ms); size_t len, aligned_len; - uint32_t isa_offset, num_rhct_nodes; - RISCVCPU *cpu; + uint32_t isa_offset, num_rhct_nodes, cmo_offset = 0; + RISCVCPU *cpu = &s->soc[0].harts[0]; char *isa; AcpiTable table = { .sig = "RHCT", .rev = 1, .oem_id = s->oem_id, @@ -173,6 +174,9 @@ static void build_rhct(GArray *table_data, /* ISA + N hart info */ num_rhct_nodes = 1 + ms->smp.cpus; + if (cpu->cfg.ext_zicbom || cpu->cfg.ext_zicboz) { + num_rhct_nodes++; + } /* Number of RHCT nodes*/ build_append_int_noprefix(table_data, num_rhct_nodes, 4); @@ -184,7 +188,6 @@ static void build_rhct(GArray *table_data, 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; @@ -200,14 +203,59 @@ static void build_rhct(GArray *table_data, build_append_int_noprefix(table_data, 0x0, 1); /* Optional Padding */ } + /* CMO node */ + if (cpu->cfg.ext_zicbom || cpu->cfg.ext_zicboz) { + cmo_offset = table_data->len - table.table_offset; + build_append_int_noprefix(table_data, 1, 2); /* Type */ + build_append_int_noprefix(table_data, 10, 2); /* Total Length */ + build_append_int_noprefix(table_data, 0x1, 2); /* Revision */ + build_append_int_noprefix(table_data, 0, 1); /* Reserved */ + + /* CBOM block size */ + if (cpu->cfg.cbom_blocksize) { + build_append_int_noprefix(table_data, + __builtin_ctz(cpu->cfg.cbom_blocksize), + 1); + } else { + build_append_int_noprefix(table_data, 0, 1); + } + + /* CBOP block size */ + build_append_int_noprefix(table_data, 0, 1); + + /* CBOZ block size */ + if (cpu->cfg.cboz_blocksize) { + build_append_int_noprefix(table_data, + __builtin_ctz(cpu->cfg.cboz_blocksize), + 1); + } else { + build_append_int_noprefix(table_data, 0, 1); + } + } + /* Hart Info Node */ for (int i = 0; i < arch_ids->len; i++) { + len = 16; + int num_offsets = 1; 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, i, 4); /* ACPI Processor UID */ - build_append_int_noprefix(table_data, isa_offset, 4); /* Offsets[0] */ + + /* Length */ + if (cmo_offset) { + len += 4; + num_offsets++; + } + + build_append_int_noprefix(table_data, len, 2); + build_append_int_noprefix(table_data, 0x1, 2); /* Revision */ + /* Number of offsets */ + build_append_int_noprefix(table_data, num_offsets, 2); + build_append_int_noprefix(table_data, i, 4); /* ACPI Processor UID */ + + /* Offsets */ + build_append_int_noprefix(table_data, isa_offset, 4); + if (cmo_offset) { + build_append_int_noprefix(table_data, cmo_offset, 4); + } } acpi_table_end(linker, &table); -- 2.34.1