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 E2346C71153 for ; Thu, 24 Aug 2023 14:31:51 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZBMz-0000sQ-Tf; Thu, 24 Aug 2023 10:31:33 -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 1qZBMh-0000jF-FD for qemu-riscv@nongnu.org; Thu, 24 Aug 2023 10:31:21 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qZBMc-0000cf-Rp for qemu-riscv@nongnu.org; Thu, 24 Aug 2023 10:31:15 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-1c11d53221cso4379175fac.2 for ; Thu, 24 Aug 2023 07:31:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1692887468; x=1693492268; 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=B5+BaRlBRy5bPDb4Aaw8BiXjcvWHQUGu5EpqrdlQcQI=; b=N2skZMS7fko2g5SXkImd0oPbI+wPcBSWYD2SyfhbbQYXqyMFPSO1Caka4zZ3nUnV9U SWYSkkHSpif5I21tadfnAcW9oKtROBNJiIjx4nNt0tU61mZMTJYMvAly43c4kky3ktvX O7mcsRLnQofNpFTVFOFpERJERmxSac4EPyYbLOQC+0CN8ZqjG2nyFG4ByPSB0EcHs5h2 Ks9n9BCVyz7s0DDWpfTAtWLYkWHvJRasllYW+GnIjaqCp47FQB+4mJisBJJMQl4tZKFP UBafgJmCnApR9NOaUpfM6YyHr53kgBKYURnbwHP4H+9KfA83Th5Kn4GjSvtdI5C+clzk 8Ltw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692887468; x=1693492268; 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=B5+BaRlBRy5bPDb4Aaw8BiXjcvWHQUGu5EpqrdlQcQI=; b=O6UCwGTAvMrym3qTgCUzGrZ2OPMBZmjSbDRw0VjkIsFafppsgN35ld4tHvFzYomC0v 5a3FTK3oLLLrlGhFTrn0NduL9cHePH+L95a1ZQmYCGCieZCzgUF+0zObgcZD2zvbvMI8 Z5T5DvHQidc7UNX6FwvBDi/J7u5l5zrQRarPWzA/AFv+oEjtzJIzsQeF8+t31hrWIYFC 85jZEw4FUCMNCwTTwEI0cwSkp1Olda1yPE8HdnTfnS4A/Ik2pNmuq9pUZCw5uv53pYtV FqYTyUv2Re/BwhTbQJ3Z1Njtmj4q3T8iURtUHtEIVsamQ+I5scdt6fFj1YqhurtUzsEB ak2w== X-Gm-Message-State: AOJu0YzTRbuD5LASh2eWjinNLnsc0PjzwJHcUNKyp+UnWO2HWzf02muW w2BZhYAZddq8S1vohEOTt6bJ3w== X-Google-Smtp-Source: AGHT+IGR0nbqcu/K7N4+uYX2nWEqFtzdwFqMaAPX3Em7EN3elLAvmpvHoB0eDf2/55QajBu31roxFA== X-Received: by 2002:a05:6870:315:b0:1b4:7191:6d62 with SMTP id m21-20020a056870031500b001b471916d62mr18876488oaf.35.1692887468507; Thu, 24 Aug 2023 07:31:08 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.191.205]) by smtp.gmail.com with ESMTPSA id n6-20020a17090a2bc600b00262fc3d911esm1666864pje.28.2023.08.24.07.30.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 07:31:04 -0700 (PDT) From: Sunil V L To: qemu-arm@nongnu.org, qemu-devel@nongnu.org, qemu-riscv@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 v2 06/12] hw/riscv/virt-acpi-build.c: Add APLIC in the MADT Date: Thu, 24 Aug 2023 19:59:36 +0530 Message-Id: <20230824142942.3983650-7-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230824142942.3983650-1-sunilvl@ventanamicro.com> References: <20230824142942.3983650-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2001:4860:4864:20::2f; envelope-from=sunilvl@ventanamicro.com; helo=mail-oa1-x2f.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-riscv@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-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org Sender: qemu-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org 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 --- 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 = MACHINE_GET_CLASS(s); MachineState *ms = MACHINE(s); const CPUArchIdList *arch_ids = 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 = 0; @@ -341,6 +341,38 @@ static void build_madt(GArray *table_data, build_append_int_noprefix(table_data, group_index_shift, 1); } + if (s->aia_type != VIRT_AIA_TYPE_NONE) { + /* APLICs */ + for (socket = 0; socket < riscv_socket_count(ms); socket++) { + aplic_addr = s->memmap[VIRT_APLIC_S].base + + s->memmap[VIRT_APLIC_S].size * socket; + gsi_base = 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 == 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); } -- 2.39.2