From patchwork Wed Dec 11 17:27:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 13903981 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 C2C07E77186 for ; Wed, 11 Dec 2024 17:28:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.855076.1268107 (Exim 4.92) (envelope-from ) id 1tLQVE-0007JZ-JU; Wed, 11 Dec 2024 17:28:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 855076.1268107; Wed, 11 Dec 2024 17:28:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tLQVE-0007JS-H0; Wed, 11 Dec 2024 17:28:00 +0000 Received: by outflank-mailman (input) for mailman id 855076; Wed, 11 Dec 2024 17:27:58 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tLQVC-0007JC-O3 for xen-devel@lists.xenproject.org; Wed, 11 Dec 2024 17:27:58 +0000 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [2a00:1450:4864:20::633]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 432b0522-b7e5-11ef-a0d5-8be0dac302b0; Wed, 11 Dec 2024 18:27:57 +0100 (CET) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-aa684b6d9c7so666028366b.2 for ; Wed, 11 Dec 2024 09:27:57 -0800 (PST) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa6656f306csm687297466b.61.2024.12.11.09.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 09:27:55 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 432b0522-b7e5-11ef-a0d5-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733938077; x=1734542877; darn=lists.xenproject.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=VzX0EG8we7tfVPdrZl970dxIaE2lTCTt+eDvQIAPb6U=; b=gyy4oAQ4JzDOaQWwLKl+lgiA/U8Q8LXUUB3k+NOX2+AzGor4obsc880ws+/SZNZDAZ CjHk7JwwvYS7ZqXBH/AdeLPh9BQ84EVBOPs871YkKEkrjJGgQG0r6kJPqTOLajoxGHB4 WMShlHL9zsyCRsz4f3fcx/yRwgk/mWzGW878n933DLvR/26DMVHai4eaMtA+gKtjaovn kqFSF4B/5sCdhvHTtFzYVpWJdKdaumd+vkj5FyDoOL28lK20NloDZVS+m1/r3EHy+EHM RDdyDq1NhesejWlPQSRz2Drib8YuqDyJOl8WPxSAvJLLgRU61M1yxp/eXv+sih9U/qHj ThdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733938077; x=1734542877; 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=VzX0EG8we7tfVPdrZl970dxIaE2lTCTt+eDvQIAPb6U=; b=cj0CQu1FeVaWfnAYLQBBE6usbKWNTl4RpQUyM/2Y38u+BnTkc7wftlJaO+E4tQhc7r 75axNEOpoexl8iQjczyjMEYrCnZOblZUdLtIJOtQ0eu9ZOssVpD/ArfHiFJoY2YMNpkY GIlvwex8FkSopsxgnYxM4A8wChDx4Ct0M/6KvlZxBwwIdqbQbTXHP17JXIh0K6aMprKl YifZDIdaBK4Um6k3imaLusEp6hbaxVejI/dHerTk45ad4QmpDYdfv3cJDpy4RdME+fLo +JKO4e5ghJXgnNQ2QsitFPLkvlLei0sgXHIEvx56BJc0pURemT2niyY9ZZr7z16TPxqP xK0Q== X-Gm-Message-State: AOJu0YzIBOGRUFZobMsWxtsu4jU1c0LIJZhWaOoT6iVxTnYegdOnVu35 dVsnBiSefaGQyxMTciGIe4sIi6bHCJEqHSkIdiDF4/9+28pZkCZiO1V9gYYc X-Gm-Gg: ASbGncunwMxxa4fUK3lkz8+LK3zsinGQ94NN94ZCHhP/oJ8vc1K2VvPK6SMiWdGuJlL QRc+uRvB08qwrtotwKjUh/Hm4lFJOFstMyfgEZnnFjQMjnnwsVcrpCkPKmqMiMGbkvhMcDE2+Xr Es0m7ubFxq8Xo2BrMZN0uct8NjoyzOnmr6/dhDNPlWc/t5pYdjtJcNzhcNDiVgfTVXfcgqJarh1 Qn2pI8zjQCxG7OTjxyBWJnlqb/2YrVYrKdew6gsoLvHGO1kq0IkHT8= X-Google-Smtp-Source: AGHT+IHa49oG7xF72kcIsHSUqvy7xJ4GbRUC02XLty084JogjHEMWJU8D7j8yPmTBBEzTL036/kfmg== X-Received: by 2002:a17:906:9a95:b0:aa6:6276:fe5a with SMTP id a640c23a62f3a-aa6c1ce75f7mr70820866b.43.1733938075671; Wed, 11 Dec 2024 09:27:55 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v2 1/7] xen/riscv: update layout table in config.h Date: Wed, 11 Dec 2024 18:27:45 +0100 Message-ID: X-Mailer: git-send-email 2.47.1 In-Reply-To: References: MIME-Version: 1.0 Make all upper bounds (end addresses) for areas inclusive to align with the corresponding definitions. Signed-off-by: Oleksii Kurochko --- Changes in v2: - new patch --- xen/arch/riscv/include/asm/config.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/arch/riscv/include/asm/config.h b/xen/arch/riscv/include/asm/config.h index 4954677aff..826e5c7172 100644 --- a/xen/arch/riscv/include/asm/config.h +++ b/xen/arch/riscv/include/asm/config.h @@ -41,17 +41,17 @@ * Start addr | End addr | Slot | area description * ============================================================================ * ..... L2 511 Unused - * 0xffffffffc0a00000 0xffffffffc0c00000 L2 511 Fixmap + * 0xffffffffc0a00000 0xffffffffc0bfffff L2 511 Fixmap * ..... ( 2 MB gap ) - * 0xffffffffc0400000 0xffffffffc0800000 L2 511 FDT + * 0xffffffffc0400000 0xffffffffc07fffff L2 511 FDT * ..... ( 2 MB gap ) - * 0xffffffffc0000000 0xffffffffc0200000 L2 511 Xen + * 0xffffffffc0000000 0xffffffffc01fffff L2 511 Xen * ..... L2 510 Unused - * 0x3200000000 0x7f40000000 L2 200-509 Direct map + * 0x3200000000 0x7f7fffffff L2 200-509 Direct map * ..... L2 199 Unused - * 0x30c0000000 0x31c0000000 L2 195-198 Frametable + * 0x30c0000000 0x31bfffffff L2 195-198 Frametable * ..... L2 194 Unused - * 0x3040000000 0x3080000000 L2 193 VMAP + * 0x3040000000 0x307fffffff L2 193 VMAP * ..... L2 0-192 Unused #elif RV_STAGE1_MODE == SATP_MODE_SV48 * Memory layout is the same as for SV39 in terms of slots, so only start and From patchwork Wed Dec 11 17:27:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 13903976 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 23DC4E77185 for ; Wed, 11 Dec 2024 17:28:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.855077.1268112 (Exim 4.92) (envelope-from ) id 1tLQVE-0007Lt-Sw; Wed, 11 Dec 2024 17:28:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 855077.1268112; Wed, 11 Dec 2024 17:28:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tLQVE-0007Kx-OL; Wed, 11 Dec 2024 17:28:00 +0000 Received: by outflank-mailman (input) for mailman id 855077; Wed, 11 Dec 2024 17:27:59 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tLQVD-0007J6-AS for xen-devel@lists.xenproject.org; Wed, 11 Dec 2024 17:27:59 +0000 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [2a00:1450:4864:20::634]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 436c2f1d-b7e5-11ef-99a3-01e77a169b0f; Wed, 11 Dec 2024 18:27:58 +0100 (CET) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-aa696d3901bso596135366b.1 for ; Wed, 11 Dec 2024 09:27:57 -0800 (PST) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa6656f306csm687297466b.61.2024.12.11.09.27.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 09:27:56 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 436c2f1d-b7e5-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733938077; x=1734542877; darn=lists.xenproject.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=rWBao4XqsmB8/UXiyyZSgIeWD9mc9NwUxRoYjmq47fU=; b=Z3sUBgl5Y0NBzVknFqZBALu00u6ImGBTzQarU8aWwG+JzA6qCo289cWNhFExYce+rn gKJxal/yXrpOEfG1EW7D+FqrhVzBaGKSsSjpMbVPdhQV/W2Dh9fzd9ER5HhdMmaIP5uk sXpuqqwUuyd8AMo8ldDbQRvhGTw4PeRQo+qB2JRbAeCrfbLcZuGtntu7CwRb2kblubse NTxbZah0KQbLfEJLuJvhb3C8J7sH98gZ0h1BiPkAbKNiIhuYkSLCR1q6HwUOO15a2uqz YpJzy67wEzxLAqVmddJWO7gdTbqiQqWZqWwwy0g+e3CFXgobAXaPbhzD3xS44u2Y31Hd 9UPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733938077; x=1734542877; 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=rWBao4XqsmB8/UXiyyZSgIeWD9mc9NwUxRoYjmq47fU=; b=T+E+0EVE1h/w8WnF+/hq3rCUOv8GqJo1Z2x0w/cdhvmIKBdbQx/xrJplzxUkppXoft T7mzXUM4jJj+x9Y8BfXR2pIFr0Bujv8Qnm7GpuAROmMgRxXy8UOZtLFA/9MbMqCGUcTF Bsb8z5mcDbpN/bgm3RIyIdPKgs384Fz7MtDYjpboN9WidI4MeP7gETqqZYqMNPTpO1fR UU+V/5ML7LCdAsJNULOidu8GM+8VgGEy2yzsx9eUQHmcIuEDCnrqnUsBjgl90ypcrfkH hJBFk8C0eD+seQi2yxD5vRNPg0TzNcNQcsShqPkffnxgTHw7YUAtuml21kzD8XIOqQWL W4Lw== X-Gm-Message-State: AOJu0YzgpLbIF+RiXQiK6km0vn4+S42oLYWMWLkeAd8uZqReQSGIjoYT dNBHDwPd+LZE8v0pd5R0PYf1octVpWW0KIniePGNtTrkM65+xUW95HWNiLOg X-Gm-Gg: ASbGncv36Iu8a8HZnRD0GMX82atwoPsz8K7Crc9tj1BLMtOdiiLjPGMWrRO/6DO6TWE 2iQKx4sgWhzK1PiAR7OsiHnZbBv41IZfWTRRf2FgPn+CgwCJ+JIZvnjirawIMZsVA27f7VfmiHn Vb0YDGwe726B9XP7tro+bxutI4f4mKsBBVAIE9O3hW+g7CsrrkYla1xZH6rctr/rvjHK+JJ5M3m /fPrei5DnkCuTISTLuxu5zz1GBp01bpdlqiuKxMYqZZ98T4vbSdkN4= X-Google-Smtp-Source: AGHT+IEnjYQPlyyOFaaSm0cIXgB3hbmyPLyJZAeXB6K1RN5O+yRnA+Ihrj0qpAB/P8+c5QuvlfYlKA== X-Received: by 2002:a17:907:9145:b0:aa6:966d:3f93 with SMTP id a640c23a62f3a-aa6c1b0a214mr57357066b.23.1733938076730; Wed, 11 Dec 2024 09:27:56 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v2 2/7] xen/riscv: add destroy_xen_mappings() to remove mappings in Xen page tables Date: Wed, 11 Dec 2024 18:27:46 +0100 Message-ID: X-Mailer: git-send-email 2.47.1 In-Reply-To: References: MIME-Version: 1.0 Introduce the destroy_xen_mappings() function, which removes page mappings in Xen's page tables between a start address s and an end address e. The function ensures that both s and e are page-aligned and verifies that the start address is less than or equal to the end address before calling pt_update() to invalidate the mappings. The pt_update() function is called with INVALID_MFN and PTE_VALID=0 in the flags, which tell pt_update() to remove mapping. No additional ASSERT() is required to check these arguments, as they are hardcoded in the call to pt_update() within destroy_xen_mappings(). Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in V2: - Drop ASSERT(s <= e). - Update implementation of destroy_xen_mappings() to avoid calling of pt_update() when start_addr >= end_addr and return -EINVAL. - Add Acked-by: Jan Beulich . --- xen/arch/riscv/mm.c | 6 ------ xen/arch/riscv/pt.c | 8 ++++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/xen/arch/riscv/mm.c b/xen/arch/riscv/mm.c index 9359dc7f33..f2bf279bac 100644 --- a/xen/arch/riscv/mm.c +++ b/xen/arch/riscv/mm.c @@ -360,12 +360,6 @@ int xenmem_add_to_physmap_one(struct domain *d, unsigned int space, return 0; } -int destroy_xen_mappings(unsigned long s, unsigned long e) -{ - BUG_ON("unimplemented"); - return -1; -} - void share_xen_page_with_guest(struct page_info *page, struct domain *d, enum XENSHARE_flags flags) { diff --git a/xen/arch/riscv/pt.c b/xen/arch/riscv/pt.c index d62aceb36c..86bd9ea613 100644 --- a/xen/arch/riscv/pt.c +++ b/xen/arch/riscv/pt.c @@ -421,6 +421,14 @@ int map_pages_to_xen(unsigned long virt, return pt_update(virt, mfn, nr_mfns, flags); } +int destroy_xen_mappings(unsigned long s, unsigned long e) +{ + ASSERT(IS_ALIGNED(s, PAGE_SIZE)); + ASSERT(IS_ALIGNED(e, PAGE_SIZE)); + + return ( s < e ) ? pt_update(s, INVALID_MFN, PFN_DOWN(e - s), 0) : -EINVAL; +} + int __init populate_pt_range(unsigned long virt, unsigned long nr_mfns) { return pt_update(virt, INVALID_MFN, nr_mfns, PTE_POPULATE); From patchwork Wed Dec 11 17:27:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 13903975 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 23D08E77183 for ; Wed, 11 Dec 2024 17:28:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.855079.1268138 (Exim 4.92) (envelope-from ) id 1tLQVH-00080r-FV; Wed, 11 Dec 2024 17:28:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 855079.1268138; Wed, 11 Dec 2024 17:28:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tLQVH-00080g-C5; Wed, 11 Dec 2024 17:28:03 +0000 Received: by outflank-mailman (input) for mailman id 855079; Wed, 11 Dec 2024 17:28:01 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tLQVF-0007J6-NN for xen-devel@lists.xenproject.org; Wed, 11 Dec 2024 17:28:01 +0000 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [2a00:1450:4864:20::534]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 44dbaa17-b7e5-11ef-99a3-01e77a169b0f; Wed, 11 Dec 2024 18:28:00 +0100 (CET) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5cfa1ec3b94so9628534a12.2 for ; Wed, 11 Dec 2024 09:28:00 -0800 (PST) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa6656f306csm687297466b.61.2024.12.11.09.27.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 09:27:57 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 44dbaa17-b7e5-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733938079; x=1734542879; darn=lists.xenproject.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=yBf1T7q7Qfa9RGnc2Coijh+Oa0RzeIjYcm94VV4SlJc=; b=kxV5UOgUUq817NL6EleR1nKXRcQns110WbtsBreWDiXDJWinhIcbZ/d/mmqlYiSY8S XuPBe6zMnqsfqvMzkA91s9gwunS7BWnI5JPx5TTqgZGuSQAva6EqZMzHlSJG0ZQOtxUu iozGR3V5mqrvyY2u+XZKNT3EGVRWetoul5hO4me7lK/qf5GWC1lOQWNh6oMitoWc7JXf 3wY7vLvh0umL4oMn5DMAloluUfBRpa6XTawZxCk7t9k73yGUcN9bQHMnasjBkVpUl5fH jCKR6671WNSD0+qDte/+YGJeeTW/+PjwlqqT+WsQbZnWCxGUK9jFIjoVFuspuUSrLp4y iqFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733938079; x=1734542879; 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=yBf1T7q7Qfa9RGnc2Coijh+Oa0RzeIjYcm94VV4SlJc=; b=lkNEauXyoElMpxDtiCU5FdhOryf4c9XVZNxGfNopEOsq/E82E/73PuP88J+Nm9GTI4 8yPYO9rWP8PXMoiluLiGV8S6pCq/wLSgMQ05z06Lql/pBhfhtxalXlpxGncKC5cpFcKB M1nblSGi7V4xv3qmiBKtPh4x4EQq8dngZnm9WviOD6dcfgxiYlvTNjkQDyLz8pWng0DF CHaj270tMS8cwvSMU/cQxbba/x/pHD6V1So2YT9wbe5q4Iawpc4zvyM79NSrX3hSh217 5HEzUqarf3owGBMbbbZaxi5w48Pg28L+zdsKaxO9LXZo08aIGQeixnqKO+a4VnDp8eKi iQYw== X-Gm-Message-State: AOJu0Ywik3SSnQzoMwQwk8w9vPH4lOI6lWazmfkBe05zLWIFwPN8HbQ3 MBRgUjDI2aVoWTR4Z+2x5Ou9OZKX8HOFc6zQFmi/CX7JJSxYCCR2CH+KlRaf X-Gm-Gg: ASbGncvzJcMtFVPu97VzLwHYdIGvg/MHeZwa+qSU48rkpoALrQLDbDsdg1LKvg5S+UJ yRcqsc0FPbDkHnRh4aiT7KVrZBMYThMWOMglNCnJtm0MvwMKaqCyjvEk5+WdAmz65Y4LZnLUxnt ADyGrK34GeicIDJB2B2z1ybs45R11NMOAkdYund9Vxlyj6wgaXSePpJJ7IiHRP5pHOTzI+zR6Sq +74z+crjsDYcNLAVmPMFIXz/qQentfxCLxVtILp79RlmT3F748u56Y= X-Google-Smtp-Source: AGHT+IH7cOZleyu34bvpQMa3pFX/11My/M5C5X1FUrFKP5oF4geYyx8+10k/PUjt4AmSnvyzUmK5Hg== X-Received: by 2002:a17:906:3154:b0:aa6:8fa5:f3e3 with SMTP id a640c23a62f3a-aa6c1ab62b1mr54492666b.8.1733938078530; Wed, 11 Dec 2024 09:27:58 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v2 3/7] xen/riscv: reorder includes in asm/page.h alphabetically Date: Wed, 11 Dec 2024 18:27:47 +0100 Message-ID: <2e2751c3ef25f3b1aa3a216045022e82d2ab2b30.1733937787.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: References: MIME-Version: 1.0 Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in V2: - Add Acked-by: Jan Beulich --- xen/arch/riscv/include/asm/page.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/riscv/include/asm/page.h b/xen/arch/riscv/include/asm/page.h index 91b1194b55..bf3f75e85d 100644 --- a/xen/arch/riscv/include/asm/page.h +++ b/xen/arch/riscv/include/asm/page.h @@ -5,8 +5,8 @@ #ifndef __ASSEMBLY__ -#include #include +#include #include #include From patchwork Wed Dec 11 17:27:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 13903979 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 C2C63E77188 for ; Wed, 11 Dec 2024 17:28:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.855080.1268148 (Exim 4.92) (envelope-from ) id 1tLQVI-0008Gx-MS; Wed, 11 Dec 2024 17:28:04 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 855080.1268148; Wed, 11 Dec 2024 17:28:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tLQVI-0008Gn-J1; Wed, 11 Dec 2024 17:28:04 +0000 Received: by outflank-mailman (input) for mailman id 855080; Wed, 11 Dec 2024 17:28:02 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tLQVG-0007J6-TG for xen-devel@lists.xenproject.org; Wed, 11 Dec 2024 17:28:02 +0000 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [2a00:1450:4864:20::62e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4589c99e-b7e5-11ef-99a3-01e77a169b0f; Wed, 11 Dec 2024 18:28:01 +0100 (CET) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a9f1d76dab1so1011026766b.0 for ; Wed, 11 Dec 2024 09:28:01 -0800 (PST) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa6656f306csm687297466b.61.2024.12.11.09.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 09:27:59 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4589c99e-b7e5-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733938080; x=1734542880; darn=lists.xenproject.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=kV5fnGT+IURuJB8/ySzjdk0FAfLfvbDV4kQWrHvyXVA=; b=dqXcSD42gGbIpSEY8fo7L/WBDY0yi3/qqbp0eAH7QW4fLn4TDCb0zxH/NQ51/aOPkY lYkBVAT1cHIz5z6beiFQyOqAujQb6lqb7aizduXHtmT6WaQ240U65gnNBjCl/S8rbaeN 4G0k+NB2WNLqIP5MJ7/pWkeWDQ/NU7+mnhWxqbSEVH60guKjezPzgW0nG5gK2JRFcpxS N92kbD5UaTC6FCHACAIaYH0kxJ4oAcCylS2EydAm3zma19m1KV7PbG8JQ1HaKFc1975+ qv9sULAUkty44r2mkNuu4UL0Wf1OG3KNmUEE2LB3Ajc21i+vgyTDBnewzK5GE0Y0NMmY yQhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733938080; x=1734542880; 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=kV5fnGT+IURuJB8/ySzjdk0FAfLfvbDV4kQWrHvyXVA=; b=FDICHEwAsUK2bsbqCQc7VeZozNV8auFqA2Iy2XyRDEda0Hg8tkjLMYFyX0jwYnwDmZ XKNBXd2XSEI3JwmEkDPQpYpXBwFS3WooIWHbAKHkPLXC6Lo5ROM/7XnPfsqGB1B4OECr JBPR4s0W+nP+Rff9ubMLJumVjHpM2NjtF9bQvmrIM2FRTX4nakr+IAvWxSDkCUEqqq0o yrJsPJ4yKndZVYExzDoRwx7jhkuXUa+CTfDTUnHRWZFlPmJcvazMe68bJr6MoLnzx7cl JnDPDflm5hCXeKKkmDEkv38e8b90GFL1KK/atbjw2Ep440xs2pldaqCDUbJQcuYaEZ8V /drQ== X-Gm-Message-State: AOJu0YwtJ95DRMKK6MgeK3s1jkbocK4cmFuUwlfdPCdXMXt8CtmVhFpO 6ovkQXvb4JbiITQiJiFSKxz8mHQXlDjXiwS6kPgw/nf2ByeNdp3qAG0W7cbl X-Gm-Gg: ASbGncuiHaQVzSe1DquEdfuUPw0vAn2Ryn4avEvKSN2XmS+TFIdgb21CoWeZy4pXrtJ 4m2mFUENWSBzTRor4Up9k8zP/v5f1YQ8/45pO50wDWZN7IFGHGn+xlmFyYcqeqsGej12g7eqY7o JgrESNf5UOeyb/Z93nh7T7uX5ugQVQQLvI/X5NzsVae/aqeOE4BflEFWTRYw4prbL79yp+XufKz biVpvhmK5cz6bLzq+jRTjRaswegRfNoZSOAfjVyYgYxBXg2kUeMJqA= X-Google-Smtp-Source: AGHT+IEPTLL+WUKby+ninBNWHjY1Dl2NtcLd1rZlicn1EDp6HPCuCO5wX72e+3d1olMJCiXIrwYWnA== X-Received: by 2002:a17:907:61a7:b0:aa6:715a:75b5 with SMTP id a640c23a62f3a-aa6b139781emr309980866b.46.1733938079661; Wed, 11 Dec 2024 09:27:59 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v2 4/7] xen/riscv: add {set,clear}_fixmap() functions for managing fixmap entries Date: Wed, 11 Dec 2024 18:27:48 +0100 Message-ID: <3d34dbc7a8af373b799d1e0c1c99acfa3798f37d.1733937787.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: References: MIME-Version: 1.0 Introduce set_fixmap() and clear_fixmap() functions to manage mappings in the fixmap region. The set_fixmap() function maps a 4k page ( as only L0 is expected to be updated; look at setup_fixmap_mappings() ) at a specified fixmap entry using map_pages_to_xen(), while clear_fixmap() removes the mapping from a fixmap entry by calling destroy_xen_mappings(). Both functions ensure that the operations succeed by asserting that their respective calls (map_pages_to_xen() and destroy_xen_mappings()) return 0. `BUG()` is added to trigger a failure if any issues occur during the mapping or unmapping process. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in V2: - Update the commit message. - drop local variables from {set, clear}_fixmap(); use if (... != 0) + BUG(). --- xen/arch/riscv/include/asm/fixmap.h | 5 +++++ xen/arch/riscv/pt.c | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/xen/arch/riscv/include/asm/fixmap.h b/xen/arch/riscv/include/asm/fixmap.h index 818c8ce07b..e399a15f53 100644 --- a/xen/arch/riscv/include/asm/fixmap.h +++ b/xen/arch/riscv/include/asm/fixmap.h @@ -32,6 +32,11 @@ */ extern pte_t xen_fixmap[]; +/* Map a page in a fixmap entry */ +void set_fixmap(unsigned int map, mfn_t mfn, unsigned int flags); +/* Remove a mapping from a fixmap entry */ +void clear_fixmap(unsigned int map); + #define fix_to_virt(slot) ((void *)FIXMAP_ADDR(slot)) static inline unsigned int virt_to_fix(vaddr_t vaddr) diff --git a/xen/arch/riscv/pt.c b/xen/arch/riscv/pt.c index 86bd9ea613..3407fda937 100644 --- a/xen/arch/riscv/pt.c +++ b/xen/arch/riscv/pt.c @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -433,3 +434,19 @@ int __init populate_pt_range(unsigned long virt, unsigned long nr_mfns) { return pt_update(virt, INVALID_MFN, nr_mfns, PTE_POPULATE); } + +/* Map a 4k page in a fixmap entry */ +void set_fixmap(unsigned int map, mfn_t mfn, unsigned int flags) +{ + if ( map_pages_to_xen(FIXMAP_ADDR(map), mfn, 1, flags | PTE_SMALL) != 0 ) + BUG(); +} + +/* Remove a mapping from a fixmap entry */ +void clear_fixmap(unsigned int map) +{ + if ( destroy_xen_mappings( + FIXMAP_ADDR(map), + FIXMAP_ADDR(map) + PAGE_SIZE) != 0 ) + BUG(); +} From patchwork Wed Dec 11 17:27:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 13903980 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 B96C7E77189 for ; Wed, 11 Dec 2024 17:28:17 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.855081.1268152 (Exim 4.92) (envelope-from ) id 1tLQVJ-0008KA-1X; Wed, 11 Dec 2024 17:28:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 855081.1268152; Wed, 11 Dec 2024 17:28:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tLQVI-0008J7-SV; Wed, 11 Dec 2024 17:28:04 +0000 Received: by outflank-mailman (input) for mailman id 855081; Wed, 11 Dec 2024 17:28:04 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tLQVI-0007J6-1R for xen-devel@lists.xenproject.org; Wed, 11 Dec 2024 17:28:04 +0000 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [2a00:1450:4864:20::62d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4625b698-b7e5-11ef-99a3-01e77a169b0f; Wed, 11 Dec 2024 18:28:02 +0100 (CET) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-aa69077b93fso508305166b.0 for ; Wed, 11 Dec 2024 09:28:02 -0800 (PST) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa6656f306csm687297466b.61.2024.12.11.09.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 09:28:00 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4625b698-b7e5-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733938081; x=1734542881; darn=lists.xenproject.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=QkQK8nAgFr42ZPxstS2wi6BvRdU+OOSSDhzgllibs7Q=; b=CnBFBy8PDmu0f5KK4wK2HoVVxaPtrYH/R7Agj0XV7x43R/OCsGv1L+l6GJ8BalQswk 1ZJ9CYWEpkDlKnU0syng7R/sUj7aOSYK+XjqBGxGE2iXzDeXURyN6CezvWrCEXTwMFir BdQfIIaH6/GpuMUcU2syTCGu4Vz3Vp/Nc4aFotZhEuGWTLBbM+zD0PYtD63klrk+DWJs EwvV6KWsMnJLRia/Tgrn4hk+i4pd1zqt8l69BYgxTce3+0kHlmcE6cD0a0HlK0eSQxB1 Kcw88mzoyWWKLSA2kiqTvaq06tGtDyqx3iQcua+C1mBUEeFx/qN66iXExEBjNh/vsuJ6 Fpsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733938081; x=1734542881; 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=QkQK8nAgFr42ZPxstS2wi6BvRdU+OOSSDhzgllibs7Q=; b=GZOtDCmavkM3yvJeozXxvVkqIk8lKOPIMunUS/ynxAS9eSBKwijaoGwWjwAhCHn7ji 3zkcoYtn7u48sTVpff1vMrxHJPYVY77JeX2bTQ+5J6KrR4e5Ye/4prQ49IGyuo04s5lX St6pCca2inPJxTMxlGCwbuY3UpYeBlruVHuXOBDKLulAqhOzB1YXNgm1fUdRoyqbYvCd 2Q2uNw2KLb1J/2LDOooPESo1WSMsbuwpaPnXv5rs0QHHYNq4XGYNjtsgXOGGQFuBskOf bPcYzJqwN+CI2x2M8RIoIBEvgtuC7DIREnQOLl2qVgJ350dTqbFKaaxSaBUVnsNUaLhu QxgA== X-Gm-Message-State: AOJu0YyL+IQcpoFpwp75roaGwF7xeLWJxdhJiMaPelmO7uh+pRtoDlMp 9+/T00FGpyTGIWfwvUchix9z5hbVYYu4nKFHm9oq7yD0kRfeaJKC6OXGGw0z X-Gm-Gg: ASbGncs4zYYAhF/QsOzkMjUBj4wXrW98LZgku10sH5VMHTPxTPR68tK+qTT+U33Pm6F oHeYZ7Uv3mhtpPDYiwztrPuPNwLyJTvqpqeFEAViAREiWFxibjLGqESWJW1hwg8k0kHG08jjdn2 5XOSXLbJtnK06sH1KSKKSGS0mOHVmU8xNCb9zkdDQvJja0bNtOiM48b5+DhS/KvT+z1ifbnFJvw I8y9jyuwtBStQli327FNny7gyyvFKr+jpa+0RKcYKPfUs3TbHpfpKM= X-Google-Smtp-Source: AGHT+IGfMe6zVWrtyyrEzVriIleXUcPcuX7PTitRVcZdUVKgvE14a22FQJgoZt9rNPki9KX736cIfw== X-Received: by 2002:a17:906:8a42:b0:aa6:8bb4:503b with SMTP id a640c23a62f3a-aa6c1d13240mr76327066b.55.1733938080609; Wed, 11 Dec 2024 09:28:00 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v2 5/7] xen/riscv: implement data and instruction cache operations Date: Wed, 11 Dec 2024 18:27:49 +0100 Message-ID: X-Mailer: git-send-email 2.47.1 In-Reply-To: References: MIME-Version: 1.0 Implement following cache operations: - clean_and_invalidate_dcache_va_range() - clean_dcache_va_range() - invalidate_icache() The first two functions may require support for the CMO (Cache Management Operations) extension and/or hardware-specific instructions. Currently, only QEMU is supported, which does not model cache behavior. Therefore, clean_and_invalidate_dcache_va_range() and clean_dcache_va_range() are implemented to simply return 0. For other cases, -ENOTSUPP is returned. If hardware supports CMO or hardware-specific instructions, these functions should be updated accordingly. To support current implementation of these function CONFIG_QEMU is introduced. invalidate_icache() is implemented using fence.i instruction as mentioned in the unpriv spec: The FENCE.I instruction was designed to support a wide variety of implementations. A simple implementation can flush the local instruction cache and the instruction pipeline when the FENCE.I is executed. A more complex implementation might snoop the instruction (data) cache on every data (instruction) cache miss, or use an inclusive unified private L2 cache to invalidate lines from the primary instruction cache when they are being written by a local store instruction. If instruction and data caches are kept coherent in this way, or if the memory system consists of only uncached RAMs, then just the fetch pipeline needs to be flushed at a FENCE.I. The FENCE.I instruction requires the presence of the Zifencei extension, which might not always be available. However, Xen uses the RV64G ISA, which guarantees the presence of the Zifencei extension. According to the unprivileged ISA specification (version 20240411): One goal of the RISC-V project is that it be used as a stable software development target. For this purpose, we define a combination of a base ISA (RV32I or RV64I) plus selected standard extensions (IMAFD, Zicsr, Zifencei) as a "general-purpose" ISA, and we use the abbreviation G for the IMAFDZicsr_Zifencei combination of instruction-set extensions. Set CONFIG_QEMU=y in tiny64_defconfig to have proper implemtation of clean_and_invalidate_dcache_va_range() and clean_dcache_va_range() for CI. Signed-off-by: Oleksii Kurochko --- Changes in V2: - Update the commit message and subject: - drop information about HAS_CMO; - add information about Zifencei extension; - Introdce platforms directory and CONFIG_QEMU; update implementation of data/instruction cache operations as returning 0 for CONFIG_QEMU and for others - return -ENOTSUPP. - Drop HAS_CMO config. --- xen/arch/riscv/Kconfig | 2 ++ xen/arch/riscv/configs/tiny64_defconfig | 1 + xen/arch/riscv/include/asm/page.h | 21 ++++++++++++++++++++- xen/arch/riscv/platforms/Kconfig | 5 +++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 xen/arch/riscv/platforms/Kconfig diff --git a/xen/arch/riscv/Kconfig b/xen/arch/riscv/Kconfig index 1858004676..00f329054c 100644 --- a/xen/arch/riscv/Kconfig +++ b/xen/arch/riscv/Kconfig @@ -52,6 +52,8 @@ config RISCV_ISA_C endmenu +source "arch/riscv/platforms/Kconfig" + source "common/Kconfig" source "drivers/Kconfig" diff --git a/xen/arch/riscv/configs/tiny64_defconfig b/xen/arch/riscv/configs/tiny64_defconfig index fc7a04872f..47076e357c 100644 --- a/xen/arch/riscv/configs/tiny64_defconfig +++ b/xen/arch/riscv/configs/tiny64_defconfig @@ -10,3 +10,4 @@ CONFIG_RISCV_64=y CONFIG_DEBUG=y CONFIG_DEBUG_INFO=y CONFIG_EXPERT=y +CONFIG_QEMU=y diff --git a/xen/arch/riscv/include/asm/page.h b/xen/arch/riscv/include/asm/page.h index bf3f75e85d..54c6fe6515 100644 --- a/xen/arch/riscv/include/asm/page.h +++ b/xen/arch/riscv/include/asm/page.h @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -148,9 +149,27 @@ static inline bool pte_is_mapping(pte_t p) return (p.pte & PTE_VALID) && (p.pte & PTE_ACCESS_MASK); } +static inline int clean_and_invalidate_dcache_va_range(const void *p, unsigned long size) +{ +#ifdef CONFIG_QEMU + return 0; +#else + return -EOPNOTSUPP; +#endif +} + +static inline int clean_dcache_va_range(const void *p, unsigned long size) +{ +#ifdef CONFIG_QEMU + return 0; +#else + return -EOPNOTSUPP; +#endif +} + static inline void invalidate_icache(void) { - BUG_ON("unimplemented"); + asm volatile ( "fence.i" ::: "memory" ); } #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE) diff --git a/xen/arch/riscv/platforms/Kconfig b/xen/arch/riscv/platforms/Kconfig new file mode 100644 index 0000000000..30ed938d52 --- /dev/null +++ b/xen/arch/riscv/platforms/Kconfig @@ -0,0 +1,5 @@ +config QEMU + bool "QEMU aarch virt machine support" + depends on RISCV_64 + help + Enable all the required drivers for QEMU riscv64 virt emulated machine. From patchwork Wed Dec 11 17:27:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 13903978 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 683B1E77184 for ; Wed, 11 Dec 2024 17:28:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.855082.1268168 (Exim 4.92) (envelope-from ) id 1tLQVK-0000JD-Bb; Wed, 11 Dec 2024 17:28:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 855082.1268168; Wed, 11 Dec 2024 17:28:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tLQVK-0000Hk-6i; Wed, 11 Dec 2024 17:28:06 +0000 Received: by outflank-mailman (input) for mailman id 855082; Wed, 11 Dec 2024 17:28:04 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tLQVI-0007JC-IC for xen-devel@lists.xenproject.org; Wed, 11 Dec 2024 17:28:04 +0000 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [2a00:1450:4864:20::529]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 46ee7ddc-b7e5-11ef-a0d5-8be0dac302b0; Wed, 11 Dec 2024 18:28:03 +0100 (CET) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5d414b8af7bso5464559a12.0 for ; Wed, 11 Dec 2024 09:28:03 -0800 (PST) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa6656f306csm687297466b.61.2024.12.11.09.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 09:28:01 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 46ee7ddc-b7e5-11ef-a0d5-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733938082; x=1734542882; darn=lists.xenproject.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=GWSH1TKGIXYk6lQDxdJzHqmgxJre5HbeAcdBxlqmawo=; b=bIn+98zm0J/yFYjrIpqMMy46v6pFV9B4cHanHLY3VvosZYeIixM4PBYU1auRLjj2Tb 2YomqT644EdOiyXGDoBOJFa4NlX5vm4NZBw+1lsoWHV61sc7SqydKTb3oR0STm++1JVd 4R4UuDR7XlmkNQIFTsEjy+qc8c24lpgGCD9P0faPdyYdbtds8wJr1Wx012dVRGkTPKTi mTGmw0HFhPrWj8ARfLiPtZpwNGooR/7bxNAs20kw3NrBipmVRK8NWSQ2+eOhzPiSEo4y 8DPj5EOh4enRc3eCLaWPDXSvV3Qxsv212Oaf3KQwlhVMsWZkzgMfXYCtIMVjKvLn70oI Opxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733938082; x=1734542882; 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=GWSH1TKGIXYk6lQDxdJzHqmgxJre5HbeAcdBxlqmawo=; b=BUcL4Ru6uWFdd8s8UGNi+074uqChOD4Ag6+b/sqU4frpOjzPtH0dkd9yyXKOGyxs2j W35Q0LW7/Dd6WON37S9Q1j5AwJMkC7737B42WFbmV/OewYesIBGczO+Q4J7vLhZQVeVT 7Nu5bQFHzSx4J3HVlGH0JTyfYA9RBITnUC83hIDvnyfqUaHXukThxfnBItkjFi/PjyuJ oeqQXgbrZq363m42e/hZJEAThyybM5hLUBRVaDo05D4exAaJaIYklMDpUQB11hHNKqF6 MnrELNoSrQ/9H2feUpRNUiZKIpWkxksg0WylCYEdvRG2Bh5oOPeOrhDySVqC7hw47M+Z V1FA== X-Gm-Message-State: AOJu0YySMl6+ZwY4l6vur2D3+rKUFX9T8fveKZsOPLfhB8D7rF+8tp29 0dtY/Da9OyXLJ/IKLxRIZ+NnIV5FRfc8sLy+b1Ez/dreh8JaagcKhwY0LLSN X-Gm-Gg: ASbGncsh3fjWREjcexLpcPzSLAMHLQY8UclW2CHGiuv/HBQMZPM3o1O9xEhd67j42Wz n8byqHrLoT2ptGU5m7Z1TW0Q/V51GDLq2qimWkPe5AnavegYlJ9/ndznba03P5uUZaruwLvwCBb lYAkN93mamThxSJXYzyorQDai25iJQWmplaCNjocuB/VXR+TS50kJiVn0OOyvp12Azo0PQHi9CB nGXIcFioJSxGidwDKiL4KO5xA/5AObAtwJYiLIgMAnGZfgVh2X3Dq4= X-Google-Smtp-Source: AGHT+IHbe07tD/GOgdxTxM0a2FBOELv2ZPSnPlzQYVX0S7GWmyenULQ+sfEkyhmENBGKMEnz6YDsVg== X-Received: by 2002:a17:906:3182:b0:aa6:ac9b:6824 with SMTP id a640c23a62f3a-aa6c1ae4bbemr65539266b.5.1733938081636; Wed, 11 Dec 2024 09:28:01 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v2 6/7] xen/riscv: implement prereq for DTB relocation Date: Wed, 11 Dec 2024 18:27:50 +0100 Message-ID: <2d2d6ca32aa7db490d47154530f01216651ba335.1733937787.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: References: MIME-Version: 1.0 DTB relocatin in Xen heap requires the following functions which are introduced in current patch: - xvmalloc_array() - copy_from_paddr() For internal use of xvmalloc, the functions flush_page_to_ram() and virt_to_page() are introduced. virt_to_page() is also required for free_xenheap_pages(). Signed-off-by: Oleksii Kurochko --- Changes in V2: - Drop variable directmap_virt_end. - Update ASSERT in virt_to_page() to use DIRECTMAP_VIRT_END instead of variable directmap_virt_end. - Declare local varibale v as const inside flush_page_to_ram(). - Declare copy_from_paddr() in riscv/setup.h as in the future it will be used for copying kernel in guest memory. - Code style updates for copy_from_paddr(). - Make l and s variable in copy_from_paddr() as the virables' initializers. - Drop call of clean_dcache_va_range(dst, l) in copy_from_paddr() as the necessiry of it is Arm-specific: After memcpy'ing the kernel in guest memory Arm need to flush the dcache to make sure that the data actually reaches the memory before we start executing guest code with caches disabled. RISC-V has caches always enabled thereby there is no such issue for RISC-V. - Make local variable src in copy_from_paddr() as const. - Update the commit message and subject: drop information of relocate_fdt() introduction and rename it to "prereq for DTB relocation". - Add BUG_ON() inside flush_page_to_ram() to check the return value of clean_and_invalidate_dcache_va_range(). - Move relocate_fdt() introduction to the next patch to make this patch compilable. --- xen/arch/riscv/include/asm/mm.h | 8 ++++++-- xen/arch/riscv/include/asm/page.h | 11 +++++++++-- xen/arch/riscv/include/asm/setup.h | 4 ++++ xen/arch/riscv/setup.c | 26 ++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/xen/arch/riscv/include/asm/mm.h b/xen/arch/riscv/include/asm/mm.h index 699ed23f0d..292aa48fc1 100644 --- a/xen/arch/riscv/include/asm/mm.h +++ b/xen/arch/riscv/include/asm/mm.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -148,8 +149,11 @@ static inline void *page_to_virt(const struct page_info *pg) /* Convert between Xen-heap virtual addresses and page-info structures. */ static inline struct page_info *virt_to_page(const void *v) { - BUG_ON("unimplemented"); - return NULL; + unsigned long va = (unsigned long)v; + + ASSERT((va >= DIRECTMAP_VIRT_START) && (va <= DIRECTMAP_VIRT_END)); + + return frametable_virt_start + PFN_DOWN(va - directmap_virt_start); } /* diff --git a/xen/arch/riscv/include/asm/page.h b/xen/arch/riscv/include/asm/page.h index 54c6fe6515..fbb35a6673 100644 --- a/xen/arch/riscv/include/asm/page.h +++ b/xen/arch/riscv/include/asm/page.h @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -175,10 +176,16 @@ static inline void invalidate_icache(void) #define clear_page(page) memset((void *)(page), 0, PAGE_SIZE) #define copy_page(dp, sp) memcpy(dp, sp, PAGE_SIZE) -/* TODO: Flush the dcache for an entire page. */ static inline void flush_page_to_ram(unsigned long mfn, bool sync_icache) { - BUG_ON("unimplemented"); + const void *v = map_domain_page(_mfn(mfn)); + + BUG_ON(clean_and_invalidate_dcache_va_range(v, PAGE_SIZE)); + + unmap_domain_page(v); + + if ( sync_icache ) + invalidate_icache(); } /* Write a pagetable entry. */ diff --git a/xen/arch/riscv/include/asm/setup.h b/xen/arch/riscv/include/asm/setup.h index 844a2f0ef1..c9d69cdf51 100644 --- a/xen/arch/riscv/include/asm/setup.h +++ b/xen/arch/riscv/include/asm/setup.h @@ -3,10 +3,14 @@ #ifndef ASM__RISCV__SETUP_H #define ASM__RISCV__SETUP_H +#include + #define max_init_domid (0) void setup_mm(void); +void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len); + #endif /* ASM__RISCV__SETUP_H */ /* diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index 9680332fee..bea3f27c4d 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -26,6 +27,31 @@ void arch_get_xen_caps(xen_capabilities_info_t *info) unsigned char __initdata cpu0_boot_stack[STACK_SIZE] __aligned(STACK_SIZE); +/** + * copy_from_paddr - copy data from a physical address + * @dst: destination virtual address + * @paddr: source physical address + * @len: length to copy + */ +void __init copy_from_paddr(void *dst, paddr_t paddr, unsigned long len) +{ + const void *src = (void *)FIXMAP_ADDR(FIX_MISC); + + while ( len ) + { + unsigned long s = paddr & (PAGE_SIZE - 1); + unsigned long l = min(PAGE_SIZE - s, len); + + set_fixmap(FIX_MISC, maddr_to_mfn(paddr), PAGE_HYPERVISOR_RW); + memcpy(dst, src + s, l); + clear_fixmap(FIX_MISC); + + paddr += l; + dst += l; + len -= l; + } +} + void __init noreturn start_xen(unsigned long bootcpu_id, paddr_t dtb_addr) { From patchwork Wed Dec 11 17:27:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksii Kurochko X-Patchwork-Id: 13903977 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.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 04611E77180 for ; Wed, 11 Dec 2024 17:28:15 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.855083.1268174 (Exim 4.92) (envelope-from ) id 1tLQVK-0000PG-Ph; Wed, 11 Dec 2024 17:28:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 855083.1268174; Wed, 11 Dec 2024 17:28:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tLQVK-0000OE-IB; Wed, 11 Dec 2024 17:28:06 +0000 Received: by outflank-mailman (input) for mailman id 855083; Wed, 11 Dec 2024 17:28:05 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tLQVJ-0007J6-Gk for xen-devel@lists.xenproject.org; Wed, 11 Dec 2024 17:28:05 +0000 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [2a00:1450:4864:20::62c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4722f73b-b7e5-11ef-99a3-01e77a169b0f; Wed, 11 Dec 2024 18:28:04 +0100 (CET) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-a9e8522445dso1396545366b.1 for ; Wed, 11 Dec 2024 09:28:04 -0800 (PST) Received: from fedora.. ([94.75.70.14]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aa6656f306csm687297466b.61.2024.12.11.09.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 09:28:02 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4722f73b-b7e5-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733938083; x=1734542883; darn=lists.xenproject.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=MVUeGYT1/F6OE3Cc8TjMGFB+HbFqEqO/qxv449JXpGc=; b=HCWkt8Ic8xaYwSk49tmcqrKvGfvT2dO4IUidbkqpU3s6I4vfcTAi1Bq67ITpfKa/4E BjIKQQUmXeEE86MJ+iWnkJxX+kfSl9LDWfvyrUgp89EPZHP2GpS3vg3UN7uqG9Lv+K3m ctVDK1KKpIC9eT63F0PsPLbfKzXKUKgjK3gJmFqMonf9kD7QLRWbcwQ71njFeQxYaDbO uDT4nN/qc7/zc2tfStBK5x2B4q/iwr7AZibT47U5QdGikBwH/2UpiglEipj5z+Re2phJ 3yaYt3CXrxiDbmY+srWQaaKIhCOj5LZ+CEsAlpCfJd2EQfSvZrbzcDokpmriLkxOcrui k1aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733938083; x=1734542883; 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=MVUeGYT1/F6OE3Cc8TjMGFB+HbFqEqO/qxv449JXpGc=; b=LeoXpqqSd+zlLogdX8nLJS9WS4C1V1liX/KcYz6WMQLZBAWC/ZcZnTAYLlMoejl5s1 hTr46quNkqGfwQ5wNppqXrMLBsvA2OG2HdvqJerCCZ9icN8C1TuVdBicPT0eVZbc3kEY UwdCz3EkgLJqVE2I8ONjKkA1xLi2jd1qgyfeTp3aU8kMEWUuQ0tMpdrvCiiPfE0dLZyd dLxMUR+Zzvtnj2E55oDITUx6vCtlKhO+jzrGkspnHubCr+E7SFi66637yWKBlsE+VKE9 Wgrr1Ubty2WGJaaCxp//vjiBDeGhCR2yfwKljUn6gCOzGu88huY4lB8ncEC8ESIrkgnE t3Yw== X-Gm-Message-State: AOJu0YwNbd2+5YQHJoH3OB27Fg5QZgqspm500t5ZQDFdFoBlqR7fs/WT 2VqsVDhhcsgcUe3QTx4pU/LlIiUI4cKLYf9Fub3pF75T/LdgqG7aslDYPfJk X-Gm-Gg: ASbGncscme+breO1q1yUtCmQok2Tsd8QVrDQu4WvfJ2fhoMC5a3rqOO/iPFp+IAw+EO w42vuRZGLQ2ofxRSCvjQ8KkhZwJzvu9//4sIk+VApOBpEGHuZRrxbz7wNJnCRebPzpUIb/yl3sF Rvrc4dwio3bn2/AOHInZ/8lCAsNwx00xDm0xi5vWgzBCB1hJ3XrmYU5uIyen3er2He+VBmboa6A lLLiw/nGbykaINFkljJ+q5qTMd4jqvpF2wChD5SDao2Z3/ihvvTlt8= X-Google-Smtp-Source: AGHT+IHk81CkV2ksl1MLimg86CXEDzadwLfuTlvYafnNlthU8knKAYe1HaxlGYqoNPeORU4oJS52nA== X-Received: by 2002:a17:906:3299:b0:aa6:6510:f27e with SMTP id a640c23a62f3a-aa6b115bc46mr379902766b.14.1733938082630; Wed, 11 Dec 2024 09:28:02 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Oleksii Kurochko , Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v2 7/7] xen/riscv: relocating and unflattening host device tree Date: Wed, 11 Dec 2024 18:27:51 +0100 Message-ID: <8906108d2e29637a42d5e127e393337d6b259b30.1733937787.git.oleksii.kurochko@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: References: MIME-Version: 1.0 Introduce relocate_fdt() and call it to relocate FDT to Xen heap instead of using early mapping as it is expected that discard_initial_modules() ( is supposed to call in the future ) discards the FDT boot module and remove_early_mappings() destroys the early mapping. Unflatten a device tree, creating the tree of struct device_node. It also fills the "name" and "type" pointers of the nodes so the normal device-tree walking functions can be used. Set device_tree_flattened to NULL in the case when acpi_disabled is equal to false. Signed-off-by: Oleksii Kurochko --- Changes in V2: - Move introduction of relocate_fdt() to the current patch with the following change: - use xvmalloc() instead of xmalloc_bytes() in relocate_fdt(); - Drop the check of returned fdt_size from boot_fdt_info() to be in sync with Arm and boot_fdt_info() will panic anyway if something wrong with DTB. - Update the commit message. --- xen/arch/riscv/setup.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index bea3f27c4d..fb6bbba684 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +#include #include #include #include @@ -8,6 +9,7 @@ #include #include #include +#include #include @@ -52,10 +54,24 @@ void __init copy_from_paddr(void *dst, paddr_t paddr, unsigned long len) } } +/* Relocate the FDT in Xen heap */ +static void * __init relocate_fdt(paddr_t dtb_paddr, size_t dtb_size) +{ + void *fdt = xvmalloc_array(uint8_t, dtb_size); + + if ( !fdt ) + panic("Unable to allocate memory for relocating the Device-Tree.\n"); + + copy_from_paddr(fdt, dtb_paddr, dtb_size); + + return fdt; +} + void __init noreturn start_xen(unsigned long bootcpu_id, paddr_t dtb_addr) { const char *cmdline; + size_t fdt_size; remove_identity_mapping(); @@ -80,8 +96,7 @@ void __init noreturn start_xen(unsigned long bootcpu_id, _end - _start, false) ) panic("Failed to add BOOTMOD_XEN\n"); - if ( !boot_fdt_info(device_tree_flattened, dtb_addr) ) - BUG(); + fdt_size = boot_fdt_info(device_tree_flattened, dtb_addr); cmdline = boot_fdt_cmdline(device_tree_flattened); printk("Command line: %s\n", cmdline); @@ -99,6 +114,18 @@ void __init noreturn start_xen(unsigned long bootcpu_id, */ system_state = SYS_STATE_boot; + if ( acpi_disabled ) + { + printk("Booting using Device Tree\n"); + device_tree_flattened = relocate_fdt(dtb_addr, fdt_size); + dt_unflatten_host_device_tree(); + } + else + { + device_tree_flattened = NULL; + panic("Booting using ACPI isn't supported\n"); + } + printk("All set up\n"); machine_halt();