Received: by 2002:a17:906:33ce:b0:9d0:bf65:29fa with SMTP id w14csp813473eja; Thu, 2 Nov 2023 20:19:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDHAnig5YvS8hYaII4FLH4IzIvoCE1KL1m+WF9vrAnWJJXOEN4r0lTYev662Q/g0WwbzBL X-Received: by 2002:a05:620a:1a90:b0:775:9c23:1da9 with SMTP id bl16-20020a05620a1a9000b007759c231da9mr22231626qkb.49.1698981597460; Thu, 02 Nov 2023 20:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698981597; cv=none; d=google.com; s=arc-20160816; b=aXz/mePZDgyluQB/uI++FvMstS6UfRBdoVOO6DU+Ba8wUwhRX+SFuwVDGpBgkxYEa0 2K489BJ9gVC/tgJqXXOCc+C/v7j6TmbbIhj5iKVDGmvt5vXdh/qWUTr8JABUfi4lXmc7 C+S4RsXUrM36LM1aI7mIp/MFGkhMcP8I/QgdUKJiq6f31V3h18nrlvNL8jKJdw6tJX/F nt2fzpciDa34Me8vr8Nijrk6U8bkizO9zwqQBa388zDV3oe+H/Bj+2mHlFAcrUy9OJG2 LCATFnXAdrbAKgmWxi/QPM8YgJGseGpkfcWrR4vVV3xP0m7w1hXZYVdHc+a++f+17leB nj2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KcgJ4FRc9yz2b5H8HRo0vnvqFidecDDHMaAJ2DLpido=; fh=67Hov/BsT8RxH3/kFZB7fU49Uoc12n1VmFCLNpavJ9k=; b=iUSzHrMKYznkIXYiqvD8L7786b/iRUG3pq8ntAUjZnp6ttozT+GJKZx+Hpnlk6LvLN zy7Uoz2pQJpw4IDAP5tv8hbir+b4dyibE2zy9mB+xDRW2S+O+c+ZGQN/ut4o0JFp71bj Vvv2lII9c99LouOTJTXhK95oYEbOTGAwNF/oV8TTPpfP7vQA8ttwSpCghwXpfkYYWrSo WZwM9JMjribNVbgeKIrwghXizoDvXo8rgNgOBDmMjzvcH14IsfN21a1P9A9rlWRQTuwH 2bnbHFJd2IZ3Cw2zfgVPxT4a3K0tA7dYxV4ve8jIMt6AXgAj8l/CtIVfX2k+ioF2IjUv oKsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=PhSgh4m3; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h19-20020a05620a245300b007625731b2acsi769454qkn.636.2023.11.02.20.19.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 Nov 2023 20:19:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=PhSgh4m3; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qykgt-0007xK-Ol; Thu, 02 Nov 2023 23:17:47 -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 1qykgs-0007wn-Oa for qemu-arm@nongnu.org; Thu, 02 Nov 2023 23:17:46 -0400 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qykgr-0003zb-6v for qemu-arm@nongnu.org; Thu, 02 Nov 2023 23:17:46 -0400 Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5b8f68ba4e5so1265553a12.1 for ; Thu, 02 Nov 2023 20:17:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698981462; x=1699586262; 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=KcgJ4FRc9yz2b5H8HRo0vnvqFidecDDHMaAJ2DLpido=; b=PhSgh4m3wLXExQJK7X/KmHoHefV8mYDB7w7eXk/8mufFUBYt5O9ELUnVtur7+wM5sT oM+GgN3jOZb2xZKkoqyFJiGMDRTbge5eFdr/HItVgRrHWeZQduUYe2qLBfwPXJJFZiZb XSW66CcLsfM+4sEQsAbHuN6tiUcimU2qWl2Jsnr+0BPlutQmjCjubBs6OTafX4mhk/hw HCRPV+rL19DzZnTngP9AoAlDeetjSR8YEzsk+aVwDgaw9clJBKYxmG29cO2cJ5e7FmN2 4wYCv9r8o/3zismYK246yBAxPZtSBvuPjrtgCxtYR5i7r2t4tMU5DkfjouKsOVwoZYg8 zZqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698981462; x=1699586262; 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=KcgJ4FRc9yz2b5H8HRo0vnvqFidecDDHMaAJ2DLpido=; b=owIh5/0x3+AMzIya8xUwQJBSgiNstnY9vJnRCWTEoFu3Szzk+S/FjmgUulcvQ18LXC moYY8zZ7JZP7kr9XXdkbea3A3rwYou5bysdIaY8lY72ZDSyxo3hbfnTJGdJV9/0zqF2s LNrW4u4yt3Iyq4ssE3uxXus2LJhUbg8uWRNuf3quQ/XReYcNo1PpcxmxI33+8JhUBYCq FHIJdPaec1321Y1WJHiP/PiCRcgw5aQpfbC5r0Wy3+Xp4aKc8rwYMbHpfUNzy1j7Hj5i lR+iYN3iziz394PiCXMzrfsexMVGckj5i1xlrFnCWJ4e5McXTwyJB6846mb6wFfLqiwg UAjA== X-Gm-Message-State: AOJu0YxJ1NcCkJVcD/ZSXd4OXYDBokGOaE/HyZM74GHDt6T416LRttUj EOn56sWBzjizCk/phkkNwOtY6R4Sl1u81pexl+MRKw== X-Received: by 2002:a17:90b:23c7:b0:280:1dca:f6a3 with SMTP id md7-20020a17090b23c700b002801dcaf6a3mr15187217pjb.43.1698981462660; Thu, 02 Nov 2023 20:17:42 -0700 (PDT) Received: from sunil-pc.Dlink ([106.51.188.78]) by smtp.gmail.com with ESMTPSA id y17-20020a17090aca9100b0027cf4c554dasm499971pjt.11.2023.11.02.20.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 20:17:42 -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 v7 07/13] hw/riscv/virt-acpi-build.c: Add APLIC in the MADT Date: Fri, 3 Nov 2023 08:46:43 +0530 Message-Id: <20231103031649.2769834-8-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103031649.2769834-1-sunilvl@ventanamicro.com> References: <20231103031649.2769834-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::52c; envelope-from=sunilvl@ventanamicro.com; helo=mail-pg1-x52c.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@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-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: uidK3YEfmW/i 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 Acked-by: Michael S. Tsirkin --- hw/riscv/virt-acpi-build.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 6bb21014fd..ec49c8804b 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -274,6 +274,8 @@ static void build_madt(GArray *table_data, 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; + uint64_t aplic_addr; + uint32_t gsi_base; uint8_t socket; for (socket = 0; socket < riscv_socket_count(ms); socket++) { @@ -319,6 +321,38 @@ static void build_madt(GArray *table_data, build_append_int_noprefix(table_data, IMSIC_MMIO_GROUP_MIN_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