From patchwork Wed Jan 10 08:56:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 13515774 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 812B4C3DA6E for ; Wed, 10 Jan 2024 09:00:11 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rNUQG-0002Zk-GW; Wed, 10 Jan 2024 03:58:52 -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 1rNUQE-0002Q1-VL for qemu-devel@nongnu.org; Wed, 10 Jan 2024 03:58:51 -0500 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rNUQD-0003ln-31 for qemu-devel@nongnu.org; Wed, 10 Jan 2024 03:58:50 -0500 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6d9bee259c5so2355205b3a.1 for ; Wed, 10 Jan 2024 00:58:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704877127; x=1705481927; 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=He34LkJl4AJd2A963fk475Yh9IYcKbrbCDrb1QCOhHs=; b=Lrz/yZJP2JHq4tE3A+YR0+rjbmMfj+j/k+G8BaLbXhn9dtoyzHUxhg/SPpS+9Wp8lT 1IHRTV70W2iVD51k18azhztWOoXIWduFPs6beWW0nyaMm4L+qHpfpwm3Q2Hcewrnmoyv wu9j3Gr52tI6ABTDFER4W2tX2T2Ia61GvzuPXpEqjp/2j7umrQDuKA68wf0TR8oTReWD qFlDOJqPbEveRUluP1KCwgIokhngWBP6vm7emIEq+/tQx/vG7J/tcZ+pz65liGlDRcji rXt6g7luuDAW8NIuwBTJ17YAAsU01tZJ+peWXng1mpsb0uXHcVVX+Eurijwag70lbrdP 4uaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704877127; x=1705481927; 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=He34LkJl4AJd2A963fk475Yh9IYcKbrbCDrb1QCOhHs=; b=pPqqmH8T5IVbS0t1J8rSVEbFdPgSWM69OSy2E8WZ0FAsLj/v72BiUPUKIuM0MJRUED emOy+9at26Z1SmAz8pDAU4DEPGPUHX6CWZdoD7C0DL9DuckdtHMk0dXe+WbxujRrzNiY CPbSr+nj95wSNe0iU3gkVQ4rjF+EMAvL1lNeTmQtnFW2DoP483S+d4nhcDnC3Wrl+YVJ XA/EzsLe0oa3gqBuEuTBVIauwg6xmlOCImAjmmsYfShTVMc7J2pJdN8ps+Z59oa4XMlo 16dJzzV/0ypF9Y+2UbG8XItXNWt8JeUJmaT9qLfgj43elVLbvVCl6/plO2HHdbadN45K Uagw== X-Gm-Message-State: AOJu0Yxo0Eb3wi1vwBET0eoQU/Y52a2EFbdMx6odb3i9TAB1wz114/YJ j6IWK2BiTzkcSim2TQwhyvhiwuPlijxyhmS3 X-Google-Smtp-Source: AGHT+IH1flwlqEs7ooe43RU5sPDl8Ksj96VTgoZ7PwmXD58QNAskj1DD/m10yTMwrY0NvITqhG77Sw== X-Received: by 2002:a62:e916:0:b0:6da:84ae:c209 with SMTP id j22-20020a62e916000000b006da84aec209mr553526pfh.45.1704877127336; Wed, 10 Jan 2024 00:58:47 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 00:58:46 -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 17/65] hw/riscv/virt-acpi-build.c: Add IMSIC in the MADT Date: Wed, 10 Jan 2024 18:56:45 +1000 Message-ID: <20240110085733.1607526-18-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 Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=alistair23@gmail.com; helo=mail-pf1-x433.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Sunil V L Add IMSIC structure in MADT when IMSIC is configured. 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-7-sunilvl@ventanamicro.com> Signed-off-by: Alistair Francis --- hw/riscv/virt-acpi-build.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 8f61fd63eb..32b5795f09 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -270,6 +270,19 @@ static void build_madt(GArray *table_data, MachineClass *mc = MACHINE_GET_CLASS(s); MachineState *ms = MACHINE(s); const CPUArchIdList *arch_ids = mc->possible_cpu_arch_ids(ms); + uint8_t group_index_bits = imsic_num_bits(riscv_socket_count(ms)); + uint8_t guest_index_bits = imsic_num_bits(s->aia_guests + 1); + uint16_t imsic_max_hart_per_socket = 0; + uint8_t hart_index_bits; + uint8_t socket; + + for (socket = 0; socket < riscv_socket_count(ms); socket++) { + if (imsic_max_hart_per_socket < s->soc[socket].num_harts) { + imsic_max_hart_per_socket = s->soc[socket].num_harts; + } + } + + hart_index_bits = imsic_num_bits(imsic_max_hart_per_socket); AcpiTable table = { .sig = "APIC", .rev = 6, .oem_id = s->oem_id, .oem_table_id = s->oem_table_id }; @@ -284,6 +297,28 @@ static void build_madt(GArray *table_data, riscv_acpi_madt_add_rintc(i, arch_ids, table_data, s); } + /* IMSIC */ + if (s->aia_type == VIRT_AIA_TYPE_APLIC_IMSIC) { + /* IMSIC */ + build_append_int_noprefix(table_data, 0x19, 1); /* Type */ + build_append_int_noprefix(table_data, 16, 1); /* Length */ + build_append_int_noprefix(table_data, 1, 1); /* Version */ + build_append_int_noprefix(table_data, 0, 1); /* Reserved */ + build_append_int_noprefix(table_data, 0, 4); /* Flags */ + /* Number of supervisor mode Interrupt Identities */ + build_append_int_noprefix(table_data, VIRT_IRQCHIP_NUM_MSIS, 2); + /* Number of guest mode Interrupt Identities */ + build_append_int_noprefix(table_data, VIRT_IRQCHIP_NUM_MSIS, 2); + /* Guest Index Bits */ + build_append_int_noprefix(table_data, guest_index_bits, 1); + /* Hart Index Bits */ + build_append_int_noprefix(table_data, hart_index_bits, 1); + /* Group Index Bits */ + build_append_int_noprefix(table_data, group_index_bits, 1); + /* Group Index Shift */ + build_append_int_noprefix(table_data, IMSIC_MMIO_GROUP_MIN_SHIFT, 1); + } + acpi_table_end(linker, &table); }