Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=159.226.251.81 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795571075; b=eWttxHOOK5gUUKBNV+caD55ZjSc1NeXQneutofXkm+YbyKSIQE02OEd+ISArpGkm5qXc boMFOFk99Fkyiuy9jdlmn2byNXwtp2HXM/WsLOAlDxxf3pcs2b1apyuAEqQV/iMpHg8y/ MSl+tZoOS6feOHe7YwAPcW1dGG16T/vPXrkbLlUwWzii1QCqar3b4wm1zVGljCPhlYK7j FtCCH3q7ogdBqrcwGFomlg1VkxK7XQGWkvND0RrZqUonvEv2vFP5W2gLCOaC+T6+t9Hea S05Vn7Klb4gzSSXBD9EKTzBBoImXWS44GNcgAZTOUG8hx5Or58G9tzmQvsys8hA3K6g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795571075; h=DMARC-Filter:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: X-CM-TRANSID:X-Coremail-Antispam:X-Originating-IP:X-CM-SenderInfo; bh=A+/F+EwP6gEMu0jRCxTda03GH84HVKp/PE6q27DJ7A0=; b=F2hiQswdcvwj8etBJO+ggWsZQ8YM2PoPi46LwMo3/CvditVWRJM4sShgD4gS+5qf7pYx wjH1ftBoQ4kZO05DgV2RWpciXn2PGwXv5jMSHdfcM162AQ6MLqX+gx8S6oeD8JzqLzXx6 ghRypJJaBG5+3KwX21k2nGZEaOK0aYUknCBWZSOooDAfMxrIhanmBkHHOoZ5XuOS2Fca7 rZMrkS4s8IpTX+NO9XJduV4+mCskU2l0rt5baH4VAyn4T8eqvkb893Te650/N+yrHCe/Y vDBnr8erIOWpe1Bz6XBY5WVrzwkYEYYDKzkIazOSjHzucDCgc9e33OqoY8cDx7Jhdww== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.remote-ip=159.226.251.81 Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 778A4606A327 for ; Wed, 25 Nov 2026 01:44:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 778A4606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from localhost (unknown [122.194.100.240]) by APP-03 (Coremail) with SMTP id rQCowAC3vI15PQZrptm8AQ--.779S2; Wed, 25 Nov 2026 09:44:25 +0800 (CST) From: Xiang W To: kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Cc: andrew.jones@linux.dev, Xiang W , pbonzini@redhat.com, thuth@redhat.com Subject: [kvm-unit-tests PATCH v3 1/9] riscv: Initialize the ACPI RSDP from the EFI system table Date: Wed, 25 Nov 2026 09:44:01 +0800 Message-ID: <20261125014409.79852-2-wangxiang@iscas.ac.cn> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261125014409.79852-1-wangxiang@iscas.ac.cn> References: <20261125014409.79852-1-wangxiang@iscas.ac.cn> X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:rQCowAC3vI15PQZrptm8AQ--.779S2 X-Coremail-Antispam: 1UD129KBjvJXoW7uFy3Ar45Wr47Jr4fKFyUKFg_yoW8CFyUpa yYyFW5GrW8GrWxJ3sayr1jk343Ar4SgFy7J397Aan8Aa15ZrWDZF1kta4avF13XFyrta1Y qan29ryrWan0y3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvG14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxV WxJr0_GcWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2Wl Yx0E2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbV WUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc7CjxVAaw2AF wI0_JF0_Jw1lc2xSY4AK67AK6w4l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjfUYHqcUUUUU X-CM-SenderInfo: pzdqw5pldqwq5lvft2wodfhubq/ On EFI boots without a DT, ACPI table lookup needs a valid RSDP. Fetch the ACPI 2.0 table from the EFI configuration table and register it with set_efi_rsdp() before cpu_init() and timer_get_frequency(). The RSDP lives in EFI_ACPI_RECLAIM_MEMORY, which the RISC-V allocator does not reuse, so there is no need to copy it aside. Signed-off-by: Xiang W --- lib/riscv/setup.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/riscv/setup.c b/lib/riscv/setup.c index a30aa0c4..8c22120d 100644 --- a/lib/riscv/setup.c +++ b/lib/riscv/setup.c @@ -226,10 +226,31 @@ void setup(const void *fdt, phys_addr_t freemem_start) #ifdef CONFIG_EFI #include +#include extern unsigned long exception_vectors; extern unsigned long boot_hartid; +static efi_status_t setup_rsdp(efi_bootinfo_t *efi_bootinfo __unused) +{ + efi_status_t status; + struct acpi_table_rsdp *rsdp; + + /* + * RSDP resides in an EFI_ACPI_RECLAIM_MEMORY region, which is not used + * by kvm-unit-tests RISC-V memory allocator. So it is not necessary to + * copy the data structure to another memory region to prevent + * unintentional overwrite. + */ + status = efi_get_system_config_table(ACPI_20_TABLE_GUID, (void **)&rsdp); + if (status != EFI_SUCCESS) + return status; + + set_efi_rsdp(rsdp); + + return EFI_SUCCESS; +} + static efi_status_t efi_mem_init(efi_bootinfo_t *efi_bootinfo) { struct mem_region *freemem_mr = NULL, *code, *data; @@ -273,6 +294,14 @@ efi_status_t setup_efi(efi_bootinfo_t *efi_bootinfo) return status; } + if (!dt_available()) { + status = setup_rsdp(efi_bootinfo); + if (status != EFI_SUCCESS) { + printf("Cannot find RSDP in EFI system table\n"); + return status; + } + } + cpu_init(); timer_get_frequency(); thread_info_init(); -- 2.47.3