From nobody Wed Nov 27 15:55:00 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=1698264883; cv=none; d=zohomail.com; s=zohoarc; b=AJlPrWukUkTUXhyvWKhRoajKbjO1mU3E5j6UZ/Er1ustcmVPCZd0lmvxMElZGUlVcueDjAbmon3jDnghPxuJollBo1eZF9SBHlE9F0Q1fPUSxxoRt/OJb0eQQ0WXxR98ibYrPggpVaUJuSm3Ud4TAHwcuwY6sR9LzteKcr4KlzA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698264883; 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=O6IAf6+/HERuXVB+FMyQAmQG1ZucRS16VlyBmkfaEHk=; b=BBk5x8znod41NHJCcSc6bDcy//vUGEZKEwXyRSO5u8Vg5QjV0sPwLoKK4jhXJW+Dv9bkamCQAR/rOQOt+yoeWlUywAwvt/LDXhME94MCXxfwMpdWPEVyiiZj7Jf8VIVWvAlBiRkNs8yZBNSW2rMjvR+Ierg7HTm9hKeKHN0C3PI= 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 1698264883412709.9245658744702; Wed, 25 Oct 2023 13:14:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvkAl-0007c8-RM; Wed, 25 Oct 2023 16:08:11 -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 1qvkAi-0007WW-VH for qemu-devel@nongnu.org; Wed, 25 Oct 2023 16:08:09 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qvkAh-0003VF-2G for qemu-devel@nongnu.org; Wed, 25 Oct 2023 16:08:08 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6b9af7d41d2so137979b3a.0 for ; Wed, 25 Oct 2023 13:08:06 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id f1-20020aa79681000000b0068fe7c4148fsm9696768pfk.57.2023.10.25.13.07.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 13:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698264486; x=1698869286; 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=O6IAf6+/HERuXVB+FMyQAmQG1ZucRS16VlyBmkfaEHk=; b=aUu+hBjsV/4hsfGflkWtorz+zx4gNFTU8NC30f9l+u0ToI8vhrtIRDNpMdmPw1apdv yqA6XWvVjAZLwS1zCzpktd9PjUdGmYr+13g2V+7xUeO7m035gY5prpj8EtvVZTLLJ2sR hdGlh8Cig5IH41iapdxMi0rXsnOfdhWR/Xv66qjuVBZmNBzQnGCinhkxnKbgP+gIjRA+ 5d6jH4kmAhwjXHOKOp6UG84aBwiepZiXr07AZDT1w03mgrVfPNh9CJSafKk/KtuM0Ztq BPGMDfzNddQiyy8o//q085HoL0gY7hxGBtVTUhToV4kce1ZSz41SgIsAVnPKDaa89qYm eYrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698264486; x=1698869286; 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=O6IAf6+/HERuXVB+FMyQAmQG1ZucRS16VlyBmkfaEHk=; b=Yj5QuPrQpvHpqQduv7YTwEFAmVp4Q0De5mYRT+38hR1zBdwJluifmMxGyN+ntCS9mU BHgY6FLzTcNQHkOhu52wXmrjlgw3tdgtW8gEkdclkhuvkTSMUU+e8Zen2OU6tscrXnMh HwQ/HIcVQGY+SaYB2l0kdPZP22c7H2SBEKynVbZuxOISB1zs44Uu1xIThcD7m0ry68iY jw3Q0kRR/qqYDGvqZWMe7bD9/hmWqVtittHr8D0LPlyEIno3cr5Y3OsUSKg8bbyyJ162 fJTaTc177Os/YUKoh1t68dbw3bW7wMKntNDKDqFN8AjR0+hxwM7xXQ0XBRG4kyTt17rL bjdA== X-Gm-Message-State: AOJu0Yxiob7jjjIBf+yBoV+4PW0rYp80THNXQYR6dLkpSrQuPFfqS979 58RsdDggG9xgrHuInArxNskg8g== X-Google-Smtp-Source: AGHT+IFDGk19g29Kx9uqKLjf6KTJXcCwnIWoX8lCbmWscA3Nz0HPuY414ALzRaqii1Kfmx9xHaoTKA== X-Received: by 2002:a05:6a20:a108:b0:13d:df16:cf29 with SMTP id q8-20020a056a20a10800b0013ddf16cf29mr7055792pzk.15.1698264485882; Wed, 25 Oct 2023 13:08:05 -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 v4 07/13] hw/riscv/virt-acpi-build.c: Add APLIC in the MADT Date: Thu, 26 Oct 2023 01:37:07 +0530 Message-Id: <20231025200713.580814-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231025200713.580814-1-sunilvl@ventanamicro.com> References: <20231025200713.580814-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::42b; envelope-from=sunilvl@ventanamicro.com; helo=mail-pf1-x42b.google.com X-Spam_score_int: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1698264883667100001 Content-Type: text/plain; charset="utf-8" Add APLIC structures for each socket in the MADT when system is configured with APLIC as the external wired interrupt controller. Signed-off-by: Sunil V L Reviewed-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Acked-by: Alistair Francis --- hw/riscv/virt-acpi-build.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 7f1a370e54..8fa358d034 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -277,9 +277,9 @@ static void build_madt(GArray *table_data, MachineClass *mc =3D MACHINE_GET_CLASS(s); MachineState *ms =3D MACHINE(s); const CPUArchIdList *arch_ids =3D mc->possible_cpu_arch_ids(ms); - uint64_t imsic_socket_addr, imsic_addr; + uint64_t imsic_socket_addr, imsic_addr, aplic_addr; + uint32_t imsic_size, gsi_base; uint8_t guest_index_bits; - uint32_t imsic_size; uint32_t local_cpu_id, socket_id; uint8_t hart_index_bits, group_index_bits, group_index_shift; uint16_t imsic_max_hart_per_socket =3D 0; @@ -341,6 +341,38 @@ static void build_madt(GArray *table_data, build_append_int_noprefix(table_data, group_index_shift, 1); } =20 + if (s->aia_type !=3D VIRT_AIA_TYPE_NONE) { + /* APLICs */ + for (socket =3D 0; socket < riscv_socket_count(ms); socket++) { + aplic_addr =3D s->memmap[VIRT_APLIC_S].base + + s->memmap[VIRT_APLIC_S].size * socket; + gsi_base =3D VIRT_IRQCHIP_NUM_SOURCES * socket; + build_append_int_noprefix(table_data, 0x1A, 1); /* Type */ + build_append_int_noprefix(table_data, 36, 1); /* Length */ + build_append_int_noprefix(table_data, 1, 1); /* Version = */ + build_append_int_noprefix(table_data, socket, 1); /* APLIC ID= */ + build_append_int_noprefix(table_data, 0, 4); /* Flags */ + build_append_int_noprefix(table_data, 0, 8); /* Hardware= ID */ + /* Number of IDCs */ + if (s->aia_type =3D=3D VIRT_AIA_TYPE_APLIC) { + build_append_int_noprefix(table_data, + s->soc[socket].num_harts, + 2); + } else { + build_append_int_noprefix(table_data, 0, 2); + } + /* Total External Interrupt Sources Supported */ + build_append_int_noprefix(table_data, VIRT_IRQCHIP_NUM_SOURCES= , 2); + /* Global System Interrupt Base */ + build_append_int_noprefix(table_data, gsi_base, 4); + /* APLIC Address */ + build_append_int_noprefix(table_data, aplic_addr, 8); + /* APLIC size */ + build_append_int_noprefix(table_data, + s->memmap[VIRT_APLIC_S].size, 4); + } + } + acpi_table_end(linker, &table); } =20 --=20 2.39.2