From nobody Thu Nov 14 06:56:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1704877305; cv=none; d=zohomail.com; s=zohoarc; b=NhitvE4atp9jSHGQ8k2L/0LV8zJS8uwPkw3dVfj913nBOe5SmVXdCHf5HuhoKPQo1Rso81TZYlsqt6priiuIi1Pb3BW7rG+ByY5dycwVPTpGO8JPPmWewwZjVz53j40MuIHoTRywNsF8aoRboQ4pds9y3x8R1lmyGXHHLJlcOSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1704877305; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TDOazDiy0BxY/0d1bvNvIaPI45Jo2rUIQI/Wjcq4mcY=; b=PIgQomcA7DOxUQgUaZ/tGPku7MoCShwBKJVC0To9peLzR4zfi+CuQhvZcJQ49TYJ6X031PdBC1wvE2MjICSxzGW8pGBHpjSouxoFdgOe6RfgIeiaQ0RAve2+93MEU4o/0xOSfbbE82s1x12xlxJS9wsjWodbPQHQjM25jOvKDM4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1704877305365772.4029624000277; Wed, 10 Jan 2024 01:01:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNUQW-0003QZ-Kn; Wed, 10 Jan 2024 03:59:08 -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 1rNUQS-0003FA-07 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 03:59:05 -0500 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNUQN-0003q2-8U for qemu-devel@nongnu.org; Wed, 10 Jan 2024 03:59:03 -0500 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6dac8955af0so2105122b3a.0 for ; Wed, 10 Jan 2024 00:58:57 -0800 (PST) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id t65-20020a628144000000b006d9879ba6besm3223814pfd.170.2024.01.10.00.58.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 00:58:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704877136; x=1705481936; 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=TDOazDiy0BxY/0d1bvNvIaPI45Jo2rUIQI/Wjcq4mcY=; b=K7MgCJCoa1HI25hV7KJ3ujM58iylNBqnvjosR1k0ztc0uvJvmb5GVeyr0dHOen1NPY E2reoEIkCX27ysDYRWL2M926tRkP5m1sW1ctu1C6H0avukF9XkHkl3W1bZMwxWsYQAq1 Ecb8vviNpmyNU96F9JgnCE0e8/LYO2NNRNrADNBF2QRki1qF6wWiuLnCgmfsWv50K6bV OYH7WWkKHaatkptoHq2guyvYYzSkvQid80TI86zua38jCVUM6FlCQaBEI+h0n6e7cwAa 79WqorUhWWHjzB94erlL3wV6bVhKX4i9zrKwPVNtrMk+3qfsKJ7O2VOYsD7rde91d84e vMWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704877136; x=1705481936; 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=TDOazDiy0BxY/0d1bvNvIaPI45Jo2rUIQI/Wjcq4mcY=; b=cczDMWlhnV3yB/GfGPHPaej3hViz5cYLZc9VTE1weNF63QNuJwmMQbBdd6PfmKuf4A WX1pKs4berM1xkvK2f3Aa5XCarl82bfc3JSJ4fIzyat23JMyzg/npStUiXDYVbzH8D7Z Km3FcV1yFgWgRo69+OlQV5v0VmRwsdM7HfVPl/zlgn5lH+PxYO/f88sqSgAprSVXWT8N cmhWor3s0imXjEkOlB/bK+TP/b/0DqJX5LXBNmoHBh3RzrEZIBWZH2QArhct0NizrrGI kfLRl7ijOPO6PGdx6kmNRGkOVYBP6iAmzs6Pp/cHWR33NbkWPSPk3hXZeZaqo+DRhLiY uOcA== X-Gm-Message-State: AOJu0YyyylfAFj4N4niw1SxUnqKEw5p6WtDQ3EVp0rMnghiMiG7CmC4k IpQUBIKzh53nVVxWDsXVDo0CcQyM5CpUModk X-Google-Smtp-Source: AGHT+IGjjiCN8f9bcGuDZqNCuy9d+7Cd24LYs5bSsJPT5zyyPsXwDm46lt8XbRiUud5aX/qSCG7xrw== X-Received: by 2002:a05:6a00:2d0e:b0:6d9:8e15:e678 with SMTP id fa14-20020a056a002d0e00b006d98e15e678mr643704pfb.6.1704877135955; Wed, 10 Jan 2024 00:58:55 -0800 (PST) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Sunil V L , Daniel Henrique Barboza , Andrew Jones , Alistair Francis , "Michael S . Tsirkin" Subject: [PULL 19/65] hw/riscv/virt-acpi-build.c: Add CMO information in RHCT Date: Wed, 10 Jan 2024 18:56:47 +1000 Message-ID: <20240110085733.1607526-20-alistair.francis@wdc.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240110085733.1607526-1-alistair.francis@wdc.com> References: <20240110085733.1607526-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=alistair23@gmail.com; helo=mail-pf1-x431.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1704877307245100003 Content-Type: text/plain; charset="utf-8" From: Sunil V L 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 Reviewed-by: Andrew Jones Acked-by: Alistair Francis Acked-by: Michael S. Tsirkin Message-ID: <20231218150247.466427-9-sunilvl@ventanamicro.com> Signed-off-by: Alistair Francis --- 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 f50f022dc2..784bbffead 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -140,6 +140,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtSta= te *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, @@ -149,8 +150,8 @@ static void build_rhct(GArray *table_data, MachineState *ms =3D MACHINE(s); const CPUArchIdList *arch_ids =3D 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 =3D 0; + RISCVCPU *cpu =3D &s->soc[0].harts[0]; char *isa; =20 AcpiTable table =3D { .sig =3D "RHCT", .rev =3D 1, .oem_id =3D s->oem_= id, @@ -166,6 +167,9 @@ static void build_rhct(GArray *table_data, =20 /* ISA + N hart info */ num_rhct_nodes =3D 1 + ms->smp.cpus; + if (cpu->cfg.ext_zicbom || cpu->cfg.ext_zicboz) { + num_rhct_nodes++; + } =20 /* Number of RHCT nodes*/ build_append_int_noprefix(table_data, num_rhct_nodes, 4); @@ -177,7 +181,6 @@ static void build_rhct(GArray *table_data, isa_offset =3D table_data->len - table.table_offset; build_append_int_noprefix(table_data, 0, 2); /* Type 0 */ =20 - cpu =3D &s->soc[0].harts[0]; isa =3D riscv_isa_string(cpu); len =3D 8 + strlen(isa) + 1; aligned_len =3D (len % 2) ? (len + 1) : len; @@ -193,14 +196,59 @@ static void build_rhct(GArray *table_data, build_append_int_noprefix(table_data, 0x0, 1); /* Optional Paddi= ng */ } =20 + /* CMO node */ + if (cpu->cfg.ext_zicbom || cpu->cfg.ext_zicboz) { + cmo_offset =3D table_data->len - table.table_offset; + build_append_int_noprefix(table_data, 1, 2); /* Type */ + build_append_int_noprefix(table_data, 10, 2); /* 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_blocksiz= e), + 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_blocksiz= e), + 1); + } else { + build_append_int_noprefix(table_data, 0, 1); + } + } + /* Hart Info Node */ for (int i =3D 0; i < arch_ids->len; i++) { + len =3D 16; + int num_offsets =3D 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 offse= ts */ - 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 +=3D 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 U= ID */ + + /* Offsets */ + build_append_int_noprefix(table_data, isa_offset, 4); + if (cmo_offset) { + build_append_int_noprefix(table_data, cmo_offset, 4); + } } =20 acpi_table_end(linker, &table); --=20 2.43.0