From nobody Wed Nov 27 13:54:17 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 ARC-Seal: i=1; a=rsa-sha256; t=1698672193; cv=none; d=zohomail.com; s=zohoarc; b=WmP9CtLjxIQNvAJZG2Hy5ks0gi2hQO56TRiisdUxiws6RssRwXJ76MwzAMD1h8qcuKTmkO58WOSO+tF6ciim9BibjnxX1CPOr9uRUVKj6BrPybxskMLDtxIAgkdrOKjHDXOit+oLcJVqEhChaOTrLBxujz3KyU/y+PMrlj11Zig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698672193; 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=lzd9k5/CD1oNzlnmX2QaajQiTVa0bxHlOZSqRvYA0jA=; b=bwlyRGLPWx7xYnP7kCHIFm7nqpNKcnzuFx9Jk3gYnr8ZUH2qoRVkWUA1hnc55cssOGn7skV4gkJ2b1i/wdMxcvMeaScEe2h1FapYX4DI7uYkU1C7X3WEg7Jzy7/89D+4xs5tAptrJZPacigjvNMJMHLzPAWKGf6cvNOVo68EavA= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698672193643416.95367183925873; Mon, 30 Oct 2023 06:23:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxSDX-00078I-DH; Mon, 30 Oct 2023 09:22:07 -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 1qxSDJ-0006vM-SG for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:55 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxSD6-0002sX-PY for qemu-devel@nongnu.org; Mon, 30 Oct 2023 09:21:53 -0400 Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-28003daaaa6so3333090a91.0 for ; Mon, 30 Oct 2023 06:21:39 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id 15-20020a17090a000f00b0027ced921e80sm8122412pja.38.2023.10.30.06.21.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:21:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698672099; x=1699276899; 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=lzd9k5/CD1oNzlnmX2QaajQiTVa0bxHlOZSqRvYA0jA=; b=lQQ4C7c3mRreoQkkHleTHMuw2zAwPWQzNo7UISTq9me0V6Dn4Pym9AFkavbuTypNEe dlcgdHUpxilD0BFCl8AImV+D3hiyrVQ+XgIcNnk+HAn6/QVuAVzgXL/K24O3ZS87wDYw /ohm7u/4nholELax1VGMPr57Plwnu8BQ2+kR+QrPmCimB+3lzBle0rI3lVEQ9uq0xpD+ uQp8hbWWHAhOkxthyq71E8ubTIsGDcupZxcCkMDZayxdKIyiGVVKQ0Bv9m92bo5AswIS nPNBpbVew7tsWsYkzX7jvCnuavWpMWT2fVqMwT93mwyr2URd3+zGvjzXJMnFxlsl8rB7 3rsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698672099; x=1699276899; 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=lzd9k5/CD1oNzlnmX2QaajQiTVa0bxHlOZSqRvYA0jA=; b=bGFaxMVnKqQUeWU+Bzw1mypWw96frZV7iP4Z0MFU23XEuNIKb+lUkyopDgvl9xaCZM 8EULNTyJBMxEWM7V92Abc4IGat4VmJgwQzByyOchxVREnPNIP9oCwnGiqInGvIuMwc5+ tm0IxJmA2f6zcibZPRn1XKSz/0695na38ZXvyRorkzBU/ZCUyY7teQ/IG3nE7IjhBlpK jsI5E0C2wFtf437YS2Vyr4xk/Z2bhzDc1wwnISHAgDUKTntm7z1g3wpTSLazEp9IcBxE S1Nce7GMmyI+Wj2jP8Tm6jk0hXIz3LN7uUmCFKfokboJvPa+9S1fcByZWbFmR4XHSUp4 oHrQ== X-Gm-Message-State: AOJu0Yy6tTcCUanEjKMYCq6/38X3uBBnwBNkh1ffDCear09fnLwR16YW JpZeH28z9ylTXZBuy8iF0Nd4cQ== X-Google-Smtp-Source: AGHT+IG96CFMPuZ4Y3n82YU8KOu7zNFWK4ESAx9dtVW5+uhXsKe8Ov5tQog9/m+WSVVJG8RvJIMU8A== X-Received: by 2002:a17:90a:53c7:b0:27d:63c:34f2 with SMTP id y65-20020a17090a53c700b0027d063c34f2mr8674243pjh.41.1698672098656; Mon, 30 Oct 2023 06:21:38 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Peter Maydell , Shannon Zhao , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Anup Patel , Atish Kumar Patra , Haibo Xu , Sunil V L , Andrew Jones Subject: [PATCH v5 05/13] hw/riscv/virt-acpi-build.c: Add AIA support in RINTC Date: Mon, 30 Oct 2023 18:50:50 +0530 Message-Id: <20231030132058.763556-6-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231030132058.763556-1-sunilvl@ventanamicro.com> References: <20231030132058.763556-1-sunilvl@ventanamicro.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::1030; envelope-from=sunilvl@ventanamicro.com; helo=mail-pj1-x1030.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, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1698672195686100003 Content-Type: text/plain; charset="utf-8" Update the RINTC structure in MADT with AIA related fields. Signed-off-by: Sunil V L Reviewed-by: Daniel Henrique Barboza Acked-by: Alistair Francis Reviewed-by: Andrew Jones --- hw/riscv/virt-acpi-build.c | 43 ++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index d8772c2821..3f9536356e 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -38,6 +38,7 @@ #include "hw/intc/riscv_aclint.h" =20 #define ACPI_BUILD_TABLE_SIZE 0x20000 +#define ACPI_BUILD_INTC_ID(socket, index) ((socket << 24) | (index)) =20 typedef struct AcpiBuildState { /* Copy of table in RAM (for patching) */ @@ -59,17 +60,50 @@ static void acpi_align_size(GArray *blob, unsigned alig= n) =20 static void riscv_acpi_madt_add_rintc(uint32_t uid, const CPUArchIdList *arch_ids, - GArray *entry) + GArray *entry, + RISCVVirtState *s) { + uint8_t guest_index_bits =3D imsic_num_bits(s->aia_guests + 1); uint64_t hart_id =3D arch_ids->cpus[uid].arch_id; + uint32_t imsic_size, local_cpu_id, socket_id; + uint64_t imsic_socket_addr, imsic_addr; + MachineState *ms =3D MACHINE(s); =20 + socket_id =3D arch_ids->cpus[uid].props.node_id; + local_cpu_id =3D (arch_ids->cpus[uid].arch_id - + riscv_socket_first_hartid(ms, socket_id)) % + riscv_socket_hart_count(ms, socket_id); + imsic_socket_addr =3D s->memmap[VIRT_IMSIC_S].base + + (socket_id * VIRT_IMSIC_GROUP_MAX_SIZE); + imsic_size =3D IMSIC_HART_SIZE(guest_index_bits); + imsic_addr =3D imsic_socket_addr + local_cpu_id * imsic_size; build_append_int_noprefix(entry, 0x18, 1); /* Type */ - build_append_int_noprefix(entry, 20, 1); /* Length */ + build_append_int_noprefix(entry, 36, 1); /* Length */ build_append_int_noprefix(entry, 1, 1); /* Version */ build_append_int_noprefix(entry, 0, 1); /* Reserved */ build_append_int_noprefix(entry, 0x1, 4); /* Flags */ build_append_int_noprefix(entry, hart_id, 8); /* Hart ID */ build_append_int_noprefix(entry, uid, 4); /* ACPI Processor UID= */ + /* External Interrupt Controller ID */ + if (s->aia_type =3D=3D VIRT_AIA_TYPE_APLIC) { + build_append_int_noprefix(entry, + ACPI_BUILD_INTC_ID( + arch_ids->cpus[uid].props.node_id, + local_cpu_id), + 4); + } else { + build_append_int_noprefix(entry, 0, 4); + } + + if (s->aia_type =3D=3D VIRT_AIA_TYPE_APLIC_IMSIC) { + /* IMSIC Base address */ + build_append_int_noprefix(entry, imsic_addr, 8); + /* IMSIC Size */ + build_append_int_noprefix(entry, imsic_size, 4); + } else { + build_append_int_noprefix(entry, 0, 8); + build_append_int_noprefix(entry, 0, 4); + } } =20 static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtState *s) @@ -88,7 +122,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtStat= e *s) aml_int(arch_ids->cpus[i].arch_id))); =20 /* build _MAT object */ - riscv_acpi_madt_add_rintc(i, arch_ids, madt_buf); + riscv_acpi_madt_add_rintc(i, arch_ids, madt_buf, s); aml_append(dev, aml_name_decl("_MAT", aml_buffer(madt_buf->len, (uint8_t *)madt_buf->data))); @@ -227,6 +261,7 @@ static void build_dsdt(GArray *table_data, * 5.2.12 Multiple APIC Description Table (MADT) * REF: https://github.com/riscv-non-isa/riscv-acpi/issues/15 * https://drive.google.com/file/d/1R6k4MshhN3WTT-hwqAquu5nX6xSEqK2l/= view + * https://drive.google.com/file/d/1oMGPyOD58JaPgMl1pKasT-VKsIKia7zR/= view */ static void build_madt(GArray *table_data, BIOSLinker *linker, @@ -246,7 +281,7 @@ static void build_madt(GArray *table_data, =20 /* RISC-V Local INTC structures per HART */ for (int i =3D 0; i < arch_ids->len; i++) { - riscv_acpi_madt_add_rintc(i, arch_ids, table_data); + riscv_acpi_madt_add_rintc(i, arch_ids, table_data, s); } =20 acpi_table_end(linker, &table); --=20 2.39.2