From nobody Sat May 11 15:03:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=raptorengineering.com ARC-Seal: i=1; a=rsa-sha256; t=1710454591; cv=none; d=zohomail.com; s=zohoarc; b=Xpm5hOAWhlxCIhJDbM4L3JwGzMoyAyEKtWjwpd8ugbeMlWOLG+eycYOMY44MuWTwKJGcsoEsew5hmEqFu1x4rNgkv5H3XxoUgKC8sSzBB4LF5E6/IMKUoi9ZxuRPpuGQC+6BxBdyEUQT2gzV2vYeTLHg0y5BwiizeEQDJ3w48WA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710454591; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sYFuyPzI+hrrFJYLQ4ibI3REmlE1nCAfT4TkBNcqNYs=; b=Iw6U6simAnySdU43FJp6WYLC6LhYsxpjjhUUQv2R2da45blS2CrJjhPzQ/dOlwBbo/GSkymEGhzXOhTVpMdU+VEFO4Gcmv59QMyju35G5bkA2WVjH8ze9Nx9D78H6+yUR75rGJ2ootR3KHtWN7HJn9K7C49TVAUbYfE6aJvXaeg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17104545917561009.0518379212375; Thu, 14 Mar 2024 15:16:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.693513.1081703 (Exim 4.92) (envelope-from ) id 1rktMx-0000pe-4k; Thu, 14 Mar 2024 22:16:11 +0000 Received: by outflank-mailman (output) from mailman id 693513.1081703; Thu, 14 Mar 2024 22:16:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rktMx-0000pV-1L; Thu, 14 Mar 2024 22:16:11 +0000 Received: by outflank-mailman (input) for mailman id 693513; Thu, 14 Mar 2024 22:16:09 +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 1rktMv-0000X2-2B for xen-devel@lists.xenproject.org; Thu, 14 Mar 2024 22:16:09 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6fbee253-e250-11ee-a1ee-f123f15fe8a2; Thu, 14 Mar 2024 23:16:00 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 1B23E8285446; Thu, 14 Mar 2024 17:15:59 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 5HM8izUN8lnN; Thu, 14 Mar 2024 17:15:58 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 5C43A828673E; Thu, 14 Mar 2024 17:15:58 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id OKrLz0-b-UO0; Thu, 14 Mar 2024 17:15:58 -0500 (CDT) Received: from raptor-ewks-026.lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id D68AF828543D; Thu, 14 Mar 2024 17:15:57 -0500 (CDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 6fbee253-e250-11ee-a1ee-f123f15fe8a2 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com 5C43A828673E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1710454558; bh=sYFuyPzI+hrrFJYLQ4ibI3REmlE1nCAfT4TkBNcqNYs=; h=From:To:Date:Message-Id:MIME-Version; b=RzrlIuYuVGBybpl9EcDNGgjX4G+3zxrBCmEfVoQ+tXsIRSp6xvp1tTfgjU2Mphebl wOz25CGw3W98rVsls2QkzQofvLspPhBrHFzm7vYT6J1R6U04H25UnsfmeEqcwkPdFt R35HGpFCKaHBDAmduVRBT1P3SqR8dkBwcA4CP+tg= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: tpearson@raptorengineering.com, Jan Beulich , Shawn Anastasio , Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v3 1/9] EFI: Introduce inline stub for efi_enabled on !X86 && !ARM Date: Thu, 14 Mar 2024 17:15:39 -0500 Message-Id: <39069a589f9c4dc0db9b01b7412c1a99bea55f37.1710443965.git.sanastasio@raptorengineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @raptorengineering.com) X-ZM-MESSAGEID: 1710454592243100005 Content-Type: text/plain; charset="utf-8" On architectures with no EFI support, define an inline stub implementation of efi_enabled in efi.h that always returns false. Suggested-by: Jan Beulich Signed-off-by: Shawn Anastasio Acked-by: Julien Grall --- xen/include/xen/efi.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xen/include/xen/efi.h b/xen/include/xen/efi.h index 942d2e9491..160804e294 100644 --- a/xen/include/xen/efi.h +++ b/xen/include/xen/efi.h @@ -31,7 +31,15 @@ union compat_pf_efi_info; struct xenpf_efi_runtime_call; struct compat_pf_efi_runtime_call; =20 +#if defined(CONFIG_X86) || defined(CONFIG_ARM) bool efi_enabled(unsigned int feature); +#else +static inline bool efi_enabled(unsigned int feature) +{ + return false; +} +#endif + void efi_init_memory(void); bool efi_boot_mem_unused(unsigned long *start, unsigned long *end); bool efi_rs_using_pgtables(void); --=20 2.30.2 From nobody Sat May 11 15:03:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=raptorengineering.com ARC-Seal: i=1; a=rsa-sha256; t=1710454591; cv=none; d=zohomail.com; s=zohoarc; b=GJxSVM+Ek/Rh2rIuuTacUMdhL0H8H6589Lgy8yOoOlrI9OK5yEH+reOVWkI+Nmdtv3VDx/XuOLjxH88DJxZtHP5vIqnS1Ak26csprbbClhMmh257gUH+ntgACt13Glio5IFvfO6Y5gD99L7GFHjhh1cxwvNvkfr8rLXlTmaj9Q8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710454591; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WG1KE8M9PlKZmebhXqBSnvpa7eeG1otWt/lFqFW0d9Y=; b=aUaaXzs3LWZRWUz2Xs6Qo+C84+YNkejMNg980F1Rzrx6nXRXlm9TSRdvOz4T4eci0nheELN+/e3SAgj2Ke7FuDMjHR7s3Cxe4XQ0Fz/Sr7JZ248vEbaCnbyuieQsdLYRBDyTjJQLsyR5CddPbAJSLtoIrvxc26Qxa9UOt4TpKOA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1710454591533839.5730865609914; Thu, 14 Mar 2024 15:16:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.693516.1081732 (Exim 4.92) (envelope-from ) id 1rktMz-0001XE-JG; Thu, 14 Mar 2024 22:16:13 +0000 Received: by outflank-mailman (output) from mailman id 693516.1081732; Thu, 14 Mar 2024 22:16:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rktMz-0001VZ-D0; Thu, 14 Mar 2024 22:16:13 +0000 Received: by outflank-mailman (input) for mailman id 693516; Thu, 14 Mar 2024 22:16:11 +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 1rktMx-0000X2-NM for xen-devel@lists.xenproject.org; Thu, 14 Mar 2024 22:16:11 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6fe46582-e250-11ee-a1ee-f123f15fe8a2; Thu, 14 Mar 2024 23:16:00 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 744238285564; Thu, 14 Mar 2024 17:15:59 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id UdD9ZEYWtjvs; Thu, 14 Mar 2024 17:15:58 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id C9F65828543D; Thu, 14 Mar 2024 17:15:58 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id cyxb2cIHxSnA; Thu, 14 Mar 2024 17:15:58 -0500 (CDT) Received: from raptor-ewks-026.lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id 59AF78285564; Thu, 14 Mar 2024 17:15:58 -0500 (CDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 6fe46582-e250-11ee-a1ee-f123f15fe8a2 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com C9F65828543D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1710454558; bh=WG1KE8M9PlKZmebhXqBSnvpa7eeG1otWt/lFqFW0d9Y=; h=From:To:Date:Message-Id:MIME-Version; b=QdMUGUkCD+q3TmBTdELez63waXReD0+ItPQ79RX5QY1KVhCQIReBKI4zu55IQBuKb JGLOT/a0fn19U8QfHHXqDq5C5aGKq6qBvclRdkyENdNkL1UTPMFoFlixWxvXAh4SM9 LFNtDX8ur+NgPeR+KknSxUn2PyfhoKT+41VMBkW8= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: tpearson@raptorengineering.com, Jan Beulich , Shawn Anastasio , Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu Subject: [PATCH v3 2/9] xen/asm-generic: Introduce generic acpi.h Date: Thu, 14 Mar 2024 17:15:40 -0500 Message-Id: <794e46b16475c0b4f482cdc8560ebb2f37875715.1710443965.git.sanastasio@raptorengineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @raptorengineering.com) X-ZM-MESSAGEID: 1710454592247100006 Content-Type: text/plain; charset="utf-8" Introduce a generic acpi.h header that provides the required definitions to allow files including xen/acpi.h to be compiled. The definitions were largely derived from the !CONFIG_ACPI parts of ARM's acpi.h. Signed-off-by: Shawn Anastasio --- xen/arch/ppc/include/asm/Makefile | 1 + xen/include/asm-generic/acpi.h | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 xen/include/asm-generic/acpi.h diff --git a/xen/arch/ppc/include/asm/Makefile b/xen/arch/ppc/include/asm/M= akefile index ced02e26ed..a4faa0f2aa 100644 --- a/xen/arch/ppc/include/asm/Makefile +++ b/xen/arch/ppc/include/asm/Makefile @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only +generic-y +=3D acpi.h generic-y +=3D altp2m.h generic-y +=3D device.h generic-y +=3D div64.h diff --git a/xen/include/asm-generic/acpi.h b/xen/include/asm-generic/acpi.h new file mode 100644 index 0000000000..ae9ed83ba8 --- /dev/null +++ b/xen/include/asm-generic/acpi.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GENERIC_ACPI_H +#define __ASM_GENERIC_ACPI_H + +#include +#include + +#ifdef CONFIG_ACPI +#error "asm-generic acpi.h can't be used with CONFIG_ACPI set" +#endif + +#define COMPILER_DEPENDENT_INT64 int64_t +#define COMPILER_DEPENDENT_UINT64 uint64_t +#define ACPI_MAP_MEM_ATTR PAGE_HYPERVISOR + +#define acpi_disabled (true) +#define disable_acpi() +#define enable_acpi() + +#endif /* __ASM_GENERIC_ACPI_H */ --=20 2.30.2 From nobody Sat May 11 15:03:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=raptorengineering.com ARC-Seal: i=1; a=rsa-sha256; t=1710454588; cv=none; d=zohomail.com; s=zohoarc; b=ifE7BstIqud027IlFdPUwQOohKfIjOE5CXuk9eSJcVBzHKoTGg+f/cfTCfzGeqQIBS27RQVbEH1XnbjmLh7fFbtsOxtmniouHGrurP/lqbGFqEa65YGqqiW4XK9JP+TbkxK1mFe4f9hun4MOLhjmkUxj0eHKJMCXpNabjLkAD4E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710454588; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XvBjwwSLExGOWxlieVRFHyENhmyN7ighTk2ZoHF8cvc=; b=bdUlgeCKPfoNrX80wHPptASYroUIm36SzWSz6TkqEX5irT1wILHpHBH+OATFyGGI0cfY0ZNzPWNvkdHNamTryv+M2sdrjM3RWvlnA0R/URhPJaCQhisrcH7wiccJXAFe93ecNonkOcMmTYWgQH7U3dw2gWcuz5eYEWKfl2i+GsQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1710454588232692.7645724359177; Thu, 14 Mar 2024 15:16:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.693514.1081709 (Exim 4.92) (envelope-from ) id 1rktMx-0000uH-JT; Thu, 14 Mar 2024 22:16:11 +0000 Received: by outflank-mailman (output) from mailman id 693514.1081709; Thu, 14 Mar 2024 22:16:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rktMx-0000tu-Bs; Thu, 14 Mar 2024 22:16:11 +0000 Received: by outflank-mailman (input) for mailman id 693514; Thu, 14 Mar 2024 22:16:09 +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 1rktMv-0000X2-NA for xen-devel@lists.xenproject.org; Thu, 14 Mar 2024 22:16:09 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6fe7b67b-e250-11ee-a1ee-f123f15fe8a2; Thu, 14 Mar 2024 23:16:00 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 88409828543D; Thu, 14 Mar 2024 17:15:59 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id In-F3fzw0PDH; Thu, 14 Mar 2024 17:15:59 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 24B9F8286CAE; Thu, 14 Mar 2024 17:15:59 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 6m4HiXoewgMk; Thu, 14 Mar 2024 17:15:59 -0500 (CDT) Received: from raptor-ewks-026.lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id C418182869D5; Thu, 14 Mar 2024 17:15:58 -0500 (CDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 6fe7b67b-e250-11ee-a1ee-f123f15fe8a2 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com 24B9F8286CAE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1710454559; bh=XvBjwwSLExGOWxlieVRFHyENhmyN7ighTk2ZoHF8cvc=; h=From:To:Date:Message-Id:MIME-Version; b=kzYlWCFu8fsxDTKu4dg75848JNYpHBKKuXv1BDVBx0LGLdqcqWDBYB1gzTRaT9kbQ xMy88qpLIRHHxLYrXEzTv7r6sEmtfIAvNeU3XdXv3krFY5J3q/2wSzrT7uMJ9geHKq 6l4U2CvGyXA3Ext0MzkTDP6tq3DnYpXXBKd9G7G4= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: tpearson@raptorengineering.com, Jan Beulich , Shawn Anastasio Subject: [PATCH v3 3/9] xen/ppc: Introduce stub asm/static-shmem.h Date: Thu, 14 Mar 2024 17:15:41 -0500 Message-Id: <0cf8286269a1c5cdc63e2c19d832a4923cd14f39.1710443965.git.sanastasio@raptorengineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @raptorengineering.com) X-ZM-MESSAGEID: 1710454590419100003 Content-Type: text/plain; charset="utf-8" Required for bootfdt.c to build. Signed-off-by: Shawn Anastasio --- xen/arch/ppc/include/asm/static-shmem.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 xen/arch/ppc/include/asm/static-shmem.h diff --git a/xen/arch/ppc/include/asm/static-shmem.h b/xen/arch/ppc/include= /asm/static-shmem.h new file mode 100644 index 0000000000..84370d6e6c --- /dev/null +++ b/xen/arch/ppc/include/asm/static-shmem.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __ASM_PPC_STATIC_SHMEM_H__ +#define __ASM_PPC_STATIC_SHMEM_H__ + +static inline int process_shm_node(const void *fdt, int node, + uint32_t address_cells, uint32_t size_c= ells) +{ + return -EINVAL; +} + +#endif /* __ASM_PPC_STATIC_SHMEM_H__ */ --=20 2.30.2 From nobody Sat May 11 15:03:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=raptorengineering.com ARC-Seal: i=1; a=rsa-sha256; t=1710454588; cv=none; d=zohomail.com; s=zohoarc; b=lM7j5uejjkU06Oi/nS2E2bTxlyT3mjy4qDSe+vQzCTPr4NjFfsH7Y42X5f+To2lbwcFt42P2sJmxxnQV/LJmEN/XU4qnykBJ5ugZJRnOTWSJWcqwPxMEJUdbaHAZJQzV3Ea6Q5lQglM+qWQb9zL6MpRVEIFNCoT5+vFFyh1mpyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710454588; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LiAKCYohOpMozP7U6Dsl0j+g+b4qIs2c8DEzGA/uNbQ=; b=IGQKis1x8nsLAuxh6UFv2vRSVqsd3LnYKY7niBgjhNxvo+ofcYIgq769ycWq91mWASXz2oB87fY4tkwpqqOeXLAJKWdYhUEUEhXrjvwN3Bly/VC8OP9Jr20qlVuQyE46wdIrZMVZD3mp9zb/z2O+TKAQXzzDbhMaYZIkEAAeeL0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1710454588389436.98378554090584; Thu, 14 Mar 2024 15:16:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.693510.1081667 (Exim 4.92) (envelope-from ) id 1rktMt-0008KG-6T; Thu, 14 Mar 2024 22:16:07 +0000 Received: by outflank-mailman (output) from mailman id 693510.1081667; Thu, 14 Mar 2024 22:16:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rktMt-0008JI-1K; Thu, 14 Mar 2024 22:16:07 +0000 Received: by outflank-mailman (input) for mailman id 693510; Thu, 14 Mar 2024 22:16:05 +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 1rktMr-0008HV-Pk for xen-devel@lists.xenproject.org; Thu, 14 Mar 2024 22:16:05 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 70a72db8-e250-11ee-afdd-a90da7624cb6; Thu, 14 Mar 2024 23:16:01 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 7F2158286790; Thu, 14 Mar 2024 17:16:00 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id lUNMd4vATcAF; Thu, 14 Mar 2024 17:15:59 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 7D6408286C9A; Thu, 14 Mar 2024 17:15:59 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 3BlC2zDAPcW5; Thu, 14 Mar 2024 17:15:59 -0500 (CDT) Received: from raptor-ewks-026.lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id 2772A8286CAF; Thu, 14 Mar 2024 17:15:59 -0500 (CDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 70a72db8-e250-11ee-afdd-a90da7624cb6 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com 7D6408286C9A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1710454559; bh=LiAKCYohOpMozP7U6Dsl0j+g+b4qIs2c8DEzGA/uNbQ=; h=From:To:Date:Message-Id:MIME-Version; b=BXJv/7q3k8aoRXt8CcNdxAo60Mdn4rgHGOGC/TZnxhnwptCitLxly2ReHBqfRbxzM A0oZP7nHS47sPMomAD4+TPUVeEhIBokOCw7yihj9AykjBkZ7w/8RwSnyoDhU5VnCZG KJ4rV4UQWNbfQSPuGAe7ceFijdvP/BEpvL7TwvJ8= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: tpearson@raptorengineering.com, Jan Beulich , Shawn Anastasio Subject: [PATCH v3 4/9] xen/ppc: Update setup.h with required definitions for bootfdt Date: Thu, 14 Mar 2024 17:15:42 -0500 Message-Id: <2c14419bd9fbd5307fe4d5b079a9927e4d3ec9fc.1710443965.git.sanastasio@raptorengineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @raptorengineering.com) X-ZM-MESSAGEID: 1710454590373100001 Content-Type: text/plain; charset="utf-8" Add the definitions used by ARM's bootfdt.c, which will be moved into xen/common in a later patch, to PPC's setup.h. Signed-off-by: Shawn Anastasio --- xen/arch/ppc/include/asm/setup.h | 112 +++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/xen/arch/ppc/include/asm/setup.h b/xen/arch/ppc/include/asm/se= tup.h index e4f64879b6..1b2d29c5b6 100644 --- a/xen/arch/ppc/include/asm/setup.h +++ b/xen/arch/ppc/include/asm/setup.h @@ -3,4 +3,116 @@ =20 #define max_init_domid (0) =20 +#include +#include +#include + +#define MIN_FDT_ALIGN 8 +#define MAX_FDT_SIZE SZ_2M + +#define NR_MEM_BANKS 256 + +#define MAX_MODULES 32 /* Current maximum useful modules */ + +typedef enum { + BOOTMOD_XEN, + BOOTMOD_FDT, + BOOTMOD_KERNEL, + BOOTMOD_RAMDISK, + BOOTMOD_XSM, + BOOTMOD_GUEST_DTB, + BOOTMOD_UNKNOWN +} bootmodule_kind; + +enum membank_type { + /* + * The MEMBANK_DEFAULT type refers to either reserved memory for the + * device/firmware (when the bank is in 'reserved_mem') or any RAM (wh= en + * the bank is in 'mem'). + */ + MEMBANK_DEFAULT, + /* + * The MEMBANK_STATIC_DOMAIN type is used to indicate whether the memo= ry + * bank is bound to a static Xen domain. It is only valid when the bank + * is in reserved_mem. + */ + MEMBANK_STATIC_DOMAIN, + /* + * The MEMBANK_STATIC_HEAP type is used to indicate whether the memory + * bank is reserved as static heap. It is only valid when the bank is + * in reserved_mem. + */ + MEMBANK_STATIC_HEAP, +}; + +/* Indicates the maximum number of characters(\0 included) for shm_id */ +#define MAX_SHM_ID_LENGTH 16 + +struct membank { + paddr_t start; + paddr_t size; + enum membank_type type; +}; + +struct meminfo { + unsigned int nr_banks; + struct membank bank[NR_MEM_BANKS]; +}; + +/* + * The domU flag is set for kernels and ramdisks of "xen,domain" nodes. + * The purpose of the domU flag is to avoid getting confused in + * kernel_probe, where we try to guess which is the dom0 kernel and + * initrd to be compatible with all versions of the multiboot spec. + */ +#define BOOTMOD_MAX_CMDLINE 1024 +struct bootmodule { + bootmodule_kind kind; + bool domU; + paddr_t start; + paddr_t size; +}; + +/* DT_MAX_NAME is the node name max length according the DT spec */ +#define DT_MAX_NAME 41 +struct bootcmdline { + bootmodule_kind kind; + bool domU; + paddr_t start; + char dt_name[DT_MAX_NAME]; + char cmdline[BOOTMOD_MAX_CMDLINE]; +}; + +struct bootmodules { + int nr_mods; + struct bootmodule module[MAX_MODULES]; +}; + +struct bootcmdlines { + unsigned int nr_mods; + struct bootcmdline cmdline[MAX_MODULES]; +}; + +struct bootinfo { + struct meminfo mem; + struct meminfo reserved_mem; + struct bootmodules modules; + struct bootcmdlines cmdlines; + bool static_heap; +}; + +extern struct bootinfo bootinfo; + +/* + * bootinfo.c + */ +bool check_reserved_regions_overlap(paddr_t region_start, paddr_t region_s= ize); +struct bootmodule *add_boot_module(bootmodule_kind kind, + paddr_t start, paddr_t size, bool domU); +void add_boot_cmdline(const char *name, const char *cmdline, + bootmodule_kind kind, paddr_t start, bool domU); +const char *boot_module_kind_as_string(bootmodule_kind kind); +struct bootcmdline *boot_cmdline_find_by_kind(bootmodule_kind kind); +void populate_boot_allocator(void); + #endif /* __ASM_PPC_SETUP_H__ */ --=20 2.30.2 From nobody Sat May 11 15:03:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=raptorengineering.com ARC-Seal: i=1; a=rsa-sha256; t=1710454603; cv=none; d=zohomail.com; s=zohoarc; b=NADYFc1+42vEGnq/3nn0za/v/pnZkS65mS/VEfJYng7xfKda19NY9BeptUE+wShgoJMHnUsMRTiMqx59g+dSWknGjT5I+sFqhwD/5opQ50udbR/3ucis+IRuHr4VvZO48cbe6um7gA0ux+M36iYOU74pRAvJoZ5WNOARVN6yWoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710454603; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qU6fRQlVfTPmaXGICHyYeZAo/sfzg+/2MQ1+Rm907mk=; b=axhTz+aXE55ZB+55Awj9Mm0AAeb14G+zh4ZNVsMXVm0B6ImxQdpZtu5af+5faikP2L/6/jF8e42zvNB5I4oXQAoSs97NxANs8e/VgToZSkhijm6L+NSfjWRcy2NAkMLd+/m/yrAD24IKt8scPoZ03Db2nmuasEmmdu/5GJ4ChDk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1710454603317806.9897318031979; Thu, 14 Mar 2024 15:16:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.693518.1081751 (Exim 4.92) (envelope-from ) id 1rktN1-000244-CJ; Thu, 14 Mar 2024 22:16:15 +0000 Received: by outflank-mailman (output) from mailman id 693518.1081751; Thu, 14 Mar 2024 22:16:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rktN1-00023V-5F; Thu, 14 Mar 2024 22:16:15 +0000 Received: by outflank-mailman (input) for mailman id 693518; Thu, 14 Mar 2024 22:16:14 +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 1rktMz-0000X2-NV for xen-devel@lists.xenproject.org; Thu, 14 Mar 2024 22:16:13 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 72f8547a-e250-11ee-a1ee-f123f15fe8a2; Thu, 14 Mar 2024 23:16:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 9C3FC8286CF5; Thu, 14 Mar 2024 17:16:02 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id czhFb6PbTxxG; Thu, 14 Mar 2024 17:16:00 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 3628B8286CAE; Thu, 14 Mar 2024 17:16:00 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id JtVqs41vqD3h; Thu, 14 Mar 2024 17:15:59 -0500 (CDT) Received: from raptor-ewks-026.lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id 6F11E8286790; Thu, 14 Mar 2024 17:15:59 -0500 (CDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 72f8547a-e250-11ee-a1ee-f123f15fe8a2 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com 3628B8286CAE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1710454560; bh=qU6fRQlVfTPmaXGICHyYeZAo/sfzg+/2MQ1+Rm907mk=; h=From:To:Date:Message-Id:MIME-Version; b=DeL4d2CDd0M/SK+9HBrLrwb2I5xooKHCerbnsnnHjy8vIIw2fPpaX9YCoHH5Ht1RF 3Da9+0ozUElYTvPsSD2KZKzfHP+6x6c0CfYMlGOinAKhoZFWxx4jBpXk9mWgRs8U3H Jzgm1VS/VCPW/HQy3yDXxhxMIOm9jZwWDYFVfcuo= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: tpearson@raptorengineering.com, Jan Beulich , Shawn Anastasio , Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk , "Daniel P. Smith" Subject: [PATCH v3 5/9] xen/device-tree: Move Arm's setup.c bootinfo functions to common Date: Thu, 14 Mar 2024 17:15:43 -0500 Message-Id: <039524d4157dddb2faf6887739a727f6e993b53f.1710443965.git.sanastasio@raptorengineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @raptorengineering.com) X-ZM-MESSAGEID: 1710454604402100001 Content-Type: text/plain; charset="utf-8" Arm's setup.c contains a collection of functions for parsing memory map and other boot information from a device tree. Since these routines are generally useful on any architecture that supports device tree booting, move them into xen/common/device-tree. Suggested-by: Julien Grall Signed-off-by: Shawn Anastasio --- MAINTAINERS | 1 + xen/arch/arm/setup.c | 419 -------------------------- xen/common/Makefile | 1 + xen/common/device-tree/Makefile | 1 + xen/common/device-tree/bootinfo.c | 469 ++++++++++++++++++++++++++++++ 5 files changed, 472 insertions(+), 419 deletions(-) create mode 100644 xen/common/device-tree/Makefile create mode 100644 xen/common/device-tree/bootinfo.c diff --git a/MAINTAINERS b/MAINTAINERS index 56a6932037..e85fbe6737 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -301,6 +301,7 @@ M: Stefano Stabellini M: Julien Grall S: Supported F: xen/common/libfdt/ +F: xen/common/device-tree/setup.c F: xen/common/device_tree.c F: xen/common/dt-overlay.c F: xen/include/xen/libfdt/ diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 424744ad5e..e60184f583 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -48,8 +48,6 @@ #include #include =20 -struct bootinfo __initdata bootinfo; - /* * Sanitized version of cpuinfo containing only features available on all * cores (only on arm64 as there is no sanitization support on arm32). @@ -203,309 +201,6 @@ static void __init processor_id(void) processor_setup(); } =20 -static void __init dt_unreserved_regions(paddr_t s, paddr_t e, - void (*cb)(paddr_t ps, paddr_t pe= ), - unsigned int first) -{ - unsigned int i, nr; - int rc; - - rc =3D fdt_num_mem_rsv(device_tree_flattened); - if ( rc < 0 ) - panic("Unable to retrieve the number of reserved regions (rc=3D%d)= \n", - rc); - - nr =3D rc; - - for ( i =3D first; i < nr ; i++ ) - { - paddr_t r_s, r_e; - - if ( fdt_get_mem_rsv_paddr(device_tree_flattened, i, &r_s, &r_e ) = < 0 ) - /* If we can't read it, pretend it doesn't exist... */ - continue; - - r_e +=3D r_s; /* fdt_get_mem_rsv_paddr returns length */ - - if ( s < r_e && r_s < e ) - { - dt_unreserved_regions(r_e, e, cb, i+1); - dt_unreserved_regions(s, r_s, cb, i+1); - return; - } - } - - /* - * i is the current bootmodule we are evaluating across all possible - * kinds. - * - * When retrieving the corresponding reserved-memory addresses - * below, we need to index the bootinfo.reserved_mem bank starting - * from 0, and only counting the reserved-memory modules. Hence, - * we need to use i - nr. - */ - for ( ; i - nr < bootinfo.reserved_mem.nr_banks; i++ ) - { - paddr_t r_s =3D bootinfo.reserved_mem.bank[i - nr].start; - paddr_t r_e =3D r_s + bootinfo.reserved_mem.bank[i - nr].size; - - if ( s < r_e && r_s < e ) - { - dt_unreserved_regions(r_e, e, cb, i + 1); - dt_unreserved_regions(s, r_s, cb, i + 1); - return; - } - } - - cb(s, e); -} - -/* - * TODO: '*_end' could be 0 if the bank/region is at the end of the physic= al - * address space. This is for now not handled as it requires more rework. - */ -static bool __init meminfo_overlap_check(struct meminfo *meminfo, - paddr_t region_start, - paddr_t region_size) -{ - paddr_t bank_start =3D INVALID_PADDR, bank_end =3D 0; - paddr_t region_end =3D region_start + region_size; - unsigned int i, bank_num =3D meminfo->nr_banks; - - for ( i =3D 0; i < bank_num; i++ ) - { - bank_start =3D meminfo->bank[i].start; - bank_end =3D bank_start + meminfo->bank[i].size; - - if ( region_end <=3D bank_start || region_start >=3D bank_end ) - continue; - else - { - printk("Region: [%#"PRIpaddr", %#"PRIpaddr") overlapping with = bank[%u]: [%#"PRIpaddr", %#"PRIpaddr")\n", - region_start, region_end, i, bank_start, bank_end); - return true; - } - } - - return false; -} - -/* - * TODO: '*_end' could be 0 if the module/region is at the end of the phys= ical - * address space. This is for now not handled as it requires more rework. - */ -static bool __init bootmodules_overlap_check(struct bootmodules *bootmodul= es, - paddr_t region_start, - paddr_t region_size) -{ - paddr_t mod_start =3D INVALID_PADDR, mod_end =3D 0; - paddr_t region_end =3D region_start + region_size; - unsigned int i, mod_num =3D bootmodules->nr_mods; - - for ( i =3D 0; i < mod_num; i++ ) - { - mod_start =3D bootmodules->module[i].start; - mod_end =3D mod_start + bootmodules->module[i].size; - - if ( region_end <=3D mod_start || region_start >=3D mod_end ) - continue; - else - { - printk("Region: [%#"PRIpaddr", %#"PRIpaddr") overlapping with = mod[%u]: [%#"PRIpaddr", %#"PRIpaddr")\n", - region_start, region_end, i, mod_start, mod_end); - return true; - } - } - - return false; -} - -void __init fw_unreserved_regions(paddr_t s, paddr_t e, - void (*cb)(paddr_t ps, paddr_t pe), - unsigned int first) -{ - if ( acpi_disabled ) - dt_unreserved_regions(s, e, cb, first); - else - cb(s, e); -} - -/* - * Given an input physical address range, check if this range is overlappi= ng - * with the existing reserved memory regions defined in bootinfo. - * Return true if the input physical address range is overlapping with any - * existing reserved memory regions, otherwise false. - */ -bool __init check_reserved_regions_overlap(paddr_t region_start, - paddr_t region_size) -{ - /* Check if input region is overlapping with bootinfo.reserved_mem ban= ks */ - if ( meminfo_overlap_check(&bootinfo.reserved_mem, - region_start, region_size) ) - return true; - - /* Check if input region is overlapping with bootmodules */ - if ( bootmodules_overlap_check(&bootinfo.modules, - region_start, region_size) ) - return true; - -#ifdef CONFIG_ACPI - /* Check if input region is overlapping with ACPI EfiACPIReclaimMemory= */ - if ( meminfo_overlap_check(&bootinfo.acpi, region_start, region_size) ) - return true; -#endif - - return false; -} - -struct bootmodule __init *add_boot_module(bootmodule_kind kind, - paddr_t start, paddr_t size, - bool domU) -{ - struct bootmodules *mods =3D &bootinfo.modules; - struct bootmodule *mod; - unsigned int i; - - if ( mods->nr_mods =3D=3D MAX_MODULES ) - { - printk("Ignoring %s boot module at %"PRIpaddr"-%"PRIpaddr" (too ma= ny)\n", - boot_module_kind_as_string(kind), start, start + size); - return NULL; - } - - if ( check_reserved_regions_overlap(start, size) ) - return NULL; - - for ( i =3D 0 ; i < mods->nr_mods ; i++ ) - { - mod =3D &mods->module[i]; - if ( mod->kind =3D=3D kind && mod->start =3D=3D start ) - { - if ( !domU ) - mod->domU =3D false; - return mod; - } - } - - mod =3D &mods->module[mods->nr_mods++]; - mod->kind =3D kind; - mod->start =3D start; - mod->size =3D size; - mod->domU =3D domU; - - return mod; -} - -/* - * boot_module_find_by_kind can only be used to return Xen modules (e.g - * XSM, DTB) or Dom0 modules. This is not suitable for looking up guest - * modules. - */ -struct bootmodule * __init boot_module_find_by_kind(bootmodule_kind kind) -{ - struct bootmodules *mods =3D &bootinfo.modules; - struct bootmodule *mod; - int i; - for (i =3D 0 ; i < mods->nr_mods ; i++ ) - { - mod =3D &mods->module[i]; - if ( mod->kind =3D=3D kind && !mod->domU ) - return mod; - } - return NULL; -} - -void __init add_boot_cmdline(const char *name, const char *cmdline, - bootmodule_kind kind, paddr_t start, bool dom= U) -{ - struct bootcmdlines *cmds =3D &bootinfo.cmdlines; - struct bootcmdline *cmd; - - if ( cmds->nr_mods =3D=3D MAX_MODULES ) - { - printk("Ignoring %s cmdline (too many)\n", name); - return; - } - - cmd =3D &cmds->cmdline[cmds->nr_mods++]; - cmd->kind =3D kind; - cmd->domU =3D domU; - cmd->start =3D start; - - ASSERT(strlen(name) <=3D DT_MAX_NAME); - safe_strcpy(cmd->dt_name, name); - - if ( strlen(cmdline) > BOOTMOD_MAX_CMDLINE ) - panic("module %s command line too long\n", name); - safe_strcpy(cmd->cmdline, cmdline); -} - -/* - * boot_cmdline_find_by_kind can only be used to return Xen modules (e.g - * XSM, DTB) or Dom0 modules. This is not suitable for looking up guest - * modules. - */ -struct bootcmdline * __init boot_cmdline_find_by_kind(bootmodule_kind kind) -{ - struct bootcmdlines *cmds =3D &bootinfo.cmdlines; - struct bootcmdline *cmd; - int i; - - for ( i =3D 0 ; i < cmds->nr_mods ; i++ ) - { - cmd =3D &cmds->cmdline[i]; - if ( cmd->kind =3D=3D kind && !cmd->domU ) - return cmd; - } - return NULL; -} - -struct bootcmdline * __init boot_cmdline_find_by_name(const char *name) -{ - struct bootcmdlines *mods =3D &bootinfo.cmdlines; - struct bootcmdline *mod; - unsigned int i; - - for (i =3D 0 ; i < mods->nr_mods ; i++ ) - { - mod =3D &mods->cmdline[i]; - if ( strcmp(mod->dt_name, name) =3D=3D 0 ) - return mod; - } - return NULL; -} - -struct bootmodule * __init boot_module_find_by_addr_and_kind(bootmodule_ki= nd kind, - paddr_t start) -{ - struct bootmodules *mods =3D &bootinfo.modules; - struct bootmodule *mod; - unsigned int i; - - for (i =3D 0 ; i < mods->nr_mods ; i++ ) - { - mod =3D &mods->module[i]; - if ( mod->kind =3D=3D kind && mod->start =3D=3D start ) - return mod; - } - return NULL; -} - -const char * __init boot_module_kind_as_string(bootmodule_kind kind) -{ - switch ( kind ) - { - case BOOTMOD_XEN: return "Xen"; - case BOOTMOD_FDT: return "Device Tree"; - case BOOTMOD_KERNEL: return "Kernel"; - case BOOTMOD_RAMDISK: return "Ramdisk"; - case BOOTMOD_XSM: return "XSM"; - case BOOTMOD_GUEST_DTB: return "DTB"; - case BOOTMOD_UNKNOWN: return "Unknown"; - default: BUG(); - } -} - void __init discard_initial_modules(void) { struct bootmodules *mi =3D &bootinfo.modules; @@ -544,40 +239,6 @@ static void * __init relocate_fdt(paddr_t dtb_paddr, s= ize_t dtb_size) return fdt; } =20 -/* - * Return the end of the non-module region starting at s. In other - * words return s the start of the next modules after s. - * - * On input *end is the end of the region which should be considered - * and it is updated to reflect the end of the module, clipped to the - * end of the region if it would run over. - */ -static paddr_t __init next_module(paddr_t s, paddr_t *end) -{ - struct bootmodules *mi =3D &bootinfo.modules; - paddr_t lowest =3D ~(paddr_t)0; - int i; - - for ( i =3D 0; i < mi->nr_mods; i++ ) - { - paddr_t mod_s =3D mi->module[i].start; - paddr_t mod_e =3D mod_s + mi->module[i].size; - - if ( !mi->module[i].size ) - continue; - - if ( mod_s < s ) - continue; - if ( mod_s > lowest ) - continue; - if ( mod_s > *end ) - continue; - lowest =3D mod_s; - *end =3D min(*end, mod_e); - } - return lowest; -} - void __init init_pdx(void) { paddr_t bank_start, bank_size, bank_end; @@ -622,86 +283,6 @@ void __init init_pdx(void) } } =20 -/* - * Populate the boot allocator. - * If a static heap was not provided by the admin, all the RAM but the - * following regions will be added: - * - Modules (e.g., Xen, Kernel) - * - Reserved regions - * - Xenheap (arm32 only) - * If a static heap was provided by the admin, populate the boot - * allocator with the corresponding regions only, but with Xenheap excluded - * on arm32. - */ -void __init populate_boot_allocator(void) -{ - unsigned int i; - const struct meminfo *banks =3D &bootinfo.mem; - paddr_t s, e; - - if ( bootinfo.static_heap ) - { - for ( i =3D 0 ; i < bootinfo.reserved_mem.nr_banks; i++ ) - { - if ( bootinfo.reserved_mem.bank[i].type !=3D MEMBANK_STATIC_HE= AP ) - continue; - - s =3D bootinfo.reserved_mem.bank[i].start; - e =3D s + bootinfo.reserved_mem.bank[i].size; -#ifdef CONFIG_ARM_32 - /* Avoid the xenheap, note that the xenheap cannot across a ba= nk */ - if ( s <=3D mfn_to_maddr(directmap_mfn_start) && - e >=3D mfn_to_maddr(directmap_mfn_end) ) - { - init_boot_pages(s, mfn_to_maddr(directmap_mfn_start)); - init_boot_pages(mfn_to_maddr(directmap_mfn_end), e); - } - else -#endif - init_boot_pages(s, e); - } - - return; - } - - for ( i =3D 0; i < banks->nr_banks; i++ ) - { - const struct membank *bank =3D &banks->bank[i]; - paddr_t bank_end =3D bank->start + bank->size; - - s =3D bank->start; - while ( s < bank_end ) - { - paddr_t n =3D bank_end; - - e =3D next_module(s, &n); - - if ( e =3D=3D ~(paddr_t)0 ) - e =3D n =3D bank_end; - - /* - * Module in a RAM bank other than the one which we are - * not dealing with here. - */ - if ( e > bank_end ) - e =3D bank_end; - -#ifdef CONFIG_ARM_32 - /* Avoid the xenheap */ - if ( s < mfn_to_maddr(directmap_mfn_end) && - mfn_to_maddr(directmap_mfn_start) < e ) - { - e =3D mfn_to_maddr(directmap_mfn_start); - n =3D mfn_to_maddr(directmap_mfn_end); - } -#endif - - fw_unreserved_regions(s, e, init_boot_pages, 0); - s =3D n; - } - } -} - size_t __read_mostly dcache_line_bytes; =20 /* C entry point for boot CPU */ diff --git a/xen/common/Makefile b/xen/common/Makefile index e5eee19a85..3a39dd35f2 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -76,6 +76,7 @@ obj-$(CONFIG_UBSAN) +=3D ubsan/ =20 obj-$(CONFIG_NEEDS_LIBELF) +=3D libelf/ obj-$(CONFIG_HAS_DEVICE_TREE) +=3D libfdt/ +obj-$(CONFIG_HAS_DEVICE_TREE) +=3D device-tree/ =20 CONF_FILE :=3D $(if $(patsubst /%,,$(KCONFIG_CONFIG)),$(objtree)/)$(KCONFI= G_CONFIG) $(obj)/config.gz: $(CONF_FILE) diff --git a/xen/common/device-tree/Makefile b/xen/common/device-tree/Makef= ile new file mode 100644 index 0000000000..c97b2bd88c --- /dev/null +++ b/xen/common/device-tree/Makefile @@ -0,0 +1 @@ +obj-y +=3D bootinfo.o diff --git a/xen/common/device-tree/bootinfo.c b/xen/common/device-tree/boo= tinfo.c new file mode 100644 index 0000000000..a6c0fe7917 --- /dev/null +++ b/xen/common/device-tree/bootinfo.c @@ -0,0 +1,469 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Derived from $xen/arch/arm/setup.c. + * + * Early device tree parsing and bookkeeping routines. + * + * Tim Deegan + * Copyright (c) 2011 Citrix Systems. + * Copyright (c) 2024 Raptor Engineering LLC + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct bootinfo __initdata bootinfo; + +const char * __init boot_module_kind_as_string(bootmodule_kind kind) +{ + switch ( kind ) + { + case BOOTMOD_XEN: return "Xen"; + case BOOTMOD_FDT: return "Device Tree"; + case BOOTMOD_KERNEL: return "Kernel"; + case BOOTMOD_RAMDISK: return "Ramdisk"; + case BOOTMOD_XSM: return "XSM"; + case BOOTMOD_GUEST_DTB: return "DTB"; + case BOOTMOD_UNKNOWN: return "Unknown"; + default: BUG(); + } +} + +static void __init dt_unreserved_regions(paddr_t s, paddr_t e, + void (*cb)(paddr_t ps, paddr_t pe= ), + unsigned int first) +{ + unsigned int i, nr; + int rc; + + rc =3D fdt_num_mem_rsv(device_tree_flattened); + if ( rc < 0 ) + panic("Unable to retrieve the number of reserved regions (rc=3D%d)= \n", + rc); + + nr =3D rc; + + for ( i =3D first; i < nr ; i++ ) + { + paddr_t r_s, r_e; + + if ( fdt_get_mem_rsv_paddr(device_tree_flattened, i, &r_s, &r_e ) = < 0 ) + /* If we can't read it, pretend it doesn't exist... */ + continue; + + r_e +=3D r_s; /* fdt_get_mem_rsv_paddr returns length */ + + if ( s < r_e && r_s < e ) + { + dt_unreserved_regions(r_e, e, cb, i+1); + dt_unreserved_regions(s, r_s, cb, i+1); + return; + } + } + + /* + * i is the current bootmodule we are evaluating across all possible + * kinds. + * + * When retrieving the corresponding reserved-memory addresses + * below, we need to index the bootinfo.reserved_mem bank starting + * from 0, and only counting the reserved-memory modules. Hence, + * we need to use i - nr. + */ + for ( ; i - nr < bootinfo.reserved_mem.nr_banks; i++ ) + { + paddr_t r_s =3D bootinfo.reserved_mem.bank[i - nr].start; + paddr_t r_e =3D r_s + bootinfo.reserved_mem.bank[i - nr].size; + + if ( s < r_e && r_s < e ) + { + dt_unreserved_regions(r_e, e, cb, i + 1); + dt_unreserved_regions(s, r_s, cb, i + 1); + return; + } + } + + cb(s, e); +} + +/* + * TODO: '*_end' could be 0 if the bank/region is at the end of the physic= al + * address space. This is for now not handled as it requires more rework. + */ +static bool __init meminfo_overlap_check(struct meminfo *meminfo, + paddr_t region_start, + paddr_t region_size) +{ + paddr_t bank_start =3D INVALID_PADDR, bank_end =3D 0; + paddr_t region_end =3D region_start + region_size; + unsigned int i, bank_num =3D meminfo->nr_banks; + + for ( i =3D 0; i < bank_num; i++ ) + { + bank_start =3D meminfo->bank[i].start; + bank_end =3D bank_start + meminfo->bank[i].size; + + if ( region_end <=3D bank_start || region_start >=3D bank_end ) + continue; + else + { + printk("Region: [%#"PRIpaddr", %#"PRIpaddr") overlapping with = bank[%u]: [%#"PRIpaddr", %#"PRIpaddr")\n", + region_start, region_end, i, bank_start, bank_end); + return true; + } + } + + return false; +} + +/* + * TODO: '*_end' could be 0 if the module/region is at the end of the phys= ical + * address space. This is for now not handled as it requires more rework. + */ +static bool __init bootmodules_overlap_check(struct bootmodules *bootmodul= es, + paddr_t region_start, + paddr_t region_size) +{ + paddr_t mod_start =3D INVALID_PADDR, mod_end =3D 0; + paddr_t region_end =3D region_start + region_size; + unsigned int i, mod_num =3D bootmodules->nr_mods; + + for ( i =3D 0; i < mod_num; i++ ) + { + mod_start =3D bootmodules->module[i].start; + mod_end =3D mod_start + bootmodules->module[i].size; + + if ( region_end <=3D mod_start || region_start >=3D mod_end ) + continue; + else + { + printk("Region: [%#"PRIpaddr", %#"PRIpaddr") overlapping with = mod[%u]: [%#"PRIpaddr", %#"PRIpaddr")\n", + region_start, region_end, i, mod_start, mod_end); + return true; + } + } + + return false; +} + +void __init fw_unreserved_regions(paddr_t s, paddr_t e, + void (*cb)(paddr_t ps, paddr_t pe), + unsigned int first) +{ + if ( acpi_disabled ) + dt_unreserved_regions(s, e, cb, first); + else + cb(s, e); +} + +/* + * Given an input physical address range, check if this range is overlappi= ng + * with the existing reserved memory regions defined in bootinfo. + * Return true if the input physical address range is overlapping with any + * existing reserved memory regions, otherwise false. + */ +bool __init check_reserved_regions_overlap(paddr_t region_start, + paddr_t region_size) +{ + /* Check if input region is overlapping with bootinfo.reserved_mem ban= ks */ + if ( meminfo_overlap_check(&bootinfo.reserved_mem, + region_start, region_size) ) + return true; + + /* Check if input region is overlapping with bootmodules */ + if ( bootmodules_overlap_check(&bootinfo.modules, + region_start, region_size) ) + return true; + +#ifdef CONFIG_ACPI + /* Check if input region is overlapping with ACPI EfiACPIReclaimMemory= */ + if ( meminfo_overlap_check(&bootinfo.acpi, region_start, region_size) ) + return true; +#endif + + return false; +} + +struct bootmodule __init *add_boot_module(bootmodule_kind kind, + paddr_t start, paddr_t size, + bool domU) +{ + struct bootmodules *mods =3D &bootinfo.modules; + struct bootmodule *mod; + unsigned int i; + + if ( mods->nr_mods =3D=3D MAX_MODULES ) + { + printk("Ignoring %s boot module at %"PRIpaddr"-%"PRIpaddr" (too ma= ny)\n", + boot_module_kind_as_string(kind), start, start + size); + return NULL; + } + + if ( check_reserved_regions_overlap(start, size) ) + return NULL; + + for ( i =3D 0 ; i < mods->nr_mods ; i++ ) + { + mod =3D &mods->module[i]; + if ( mod->kind =3D=3D kind && mod->start =3D=3D start ) + { + if ( !domU ) + mod->domU =3D false; + return mod; + } + } + + mod =3D &mods->module[mods->nr_mods++]; + mod->kind =3D kind; + mod->start =3D start; + mod->size =3D size; + mod->domU =3D domU; + + return mod; +} + +/* + * boot_module_find_by_kind can only be used to return Xen modules (e.g + * XSM, DTB) or Dom0 modules. This is not suitable for looking up guest + * modules. + */ +struct bootmodule * __init boot_module_find_by_kind(bootmodule_kind kind) +{ + struct bootmodules *mods =3D &bootinfo.modules; + struct bootmodule *mod; + int i; + for (i =3D 0 ; i < mods->nr_mods ; i++ ) + { + mod =3D &mods->module[i]; + if ( mod->kind =3D=3D kind && !mod->domU ) + return mod; + } + return NULL; +} + +void __init add_boot_cmdline(const char *name, const char *cmdline, + bootmodule_kind kind, paddr_t start, bool dom= U) +{ + struct bootcmdlines *cmds =3D &bootinfo.cmdlines; + struct bootcmdline *cmd; + + if ( cmds->nr_mods =3D=3D MAX_MODULES ) + { + printk("Ignoring %s cmdline (too many)\n", name); + return; + } + + cmd =3D &cmds->cmdline[cmds->nr_mods++]; + cmd->kind =3D kind; + cmd->domU =3D domU; + cmd->start =3D start; + + ASSERT(strlen(name) <=3D DT_MAX_NAME); + safe_strcpy(cmd->dt_name, name); + + if ( strlen(cmdline) > BOOTMOD_MAX_CMDLINE ) + panic("module %s command line too long\n", name); + safe_strcpy(cmd->cmdline, cmdline); +} + +/* + * boot_cmdline_find_by_kind can only be used to return Xen modules (e.g + * XSM, DTB) or Dom0 modules. This is not suitable for looking up guest + * modules. + */ +struct bootcmdline * __init boot_cmdline_find_by_kind(bootmodule_kind kind) +{ + struct bootcmdlines *cmds =3D &bootinfo.cmdlines; + struct bootcmdline *cmd; + int i; + + for ( i =3D 0 ; i < cmds->nr_mods ; i++ ) + { + cmd =3D &cmds->cmdline[i]; + if ( cmd->kind =3D=3D kind && !cmd->domU ) + return cmd; + } + return NULL; +} + +struct bootcmdline * __init boot_cmdline_find_by_name(const char *name) +{ + struct bootcmdlines *mods =3D &bootinfo.cmdlines; + struct bootcmdline *mod; + unsigned int i; + + for (i =3D 0 ; i < mods->nr_mods ; i++ ) + { + mod =3D &mods->cmdline[i]; + if ( strcmp(mod->dt_name, name) =3D=3D 0 ) + return mod; + } + return NULL; +} + +struct bootmodule * __init boot_module_find_by_addr_and_kind(bootmodule_ki= nd kind, + paddr_t start) +{ + struct bootmodules *mods =3D &bootinfo.modules; + struct bootmodule *mod; + unsigned int i; + + for (i =3D 0 ; i < mods->nr_mods ; i++ ) + { + mod =3D &mods->module[i]; + if ( mod->kind =3D=3D kind && mod->start =3D=3D start ) + return mod; + } + return NULL; +} + +/* + * Return the end of the non-module region starting at s. In other + * words return s the start of the next modules after s. + * + * On input *end is the end of the region which should be considered + * and it is updated to reflect the end of the module, clipped to the + * end of the region if it would run over. + */ +static paddr_t __init next_module(paddr_t s, paddr_t *end) +{ + struct bootmodules *mi =3D &bootinfo.modules; + paddr_t lowest =3D ~(paddr_t)0; + int i; + + for ( i =3D 0; i < mi->nr_mods; i++ ) + { + paddr_t mod_s =3D mi->module[i].start; + paddr_t mod_e =3D mod_s + mi->module[i].size; + + if ( !mi->module[i].size ) + continue; + + if ( mod_s < s ) + continue; + if ( mod_s > lowest ) + continue; + if ( mod_s > *end ) + continue; + lowest =3D mod_s; + *end =3D min(*end, mod_e); + } + return lowest; +} + +/* + * Populate the boot allocator. + * If a static heap was not provided by the admin, all the RAM but the + * following regions will be added: + * - Modules (e.g., Xen, Kernel) + * - Reserved regions + * - Xenheap (arm32 only) + * If a static heap was provided by the admin, populate the boot + * allocator with the corresponding regions only, but with Xenheap excluded + * on arm32. + */ +void __init populate_boot_allocator(void) +{ + unsigned int i; + const struct meminfo *banks =3D &bootinfo.mem; + paddr_t s, e; + + if ( bootinfo.static_heap ) + { + for ( i =3D 0 ; i < bootinfo.reserved_mem.nr_banks; i++ ) + { + if ( bootinfo.reserved_mem.bank[i].type !=3D MEMBANK_STATIC_HE= AP ) + continue; + + s =3D bootinfo.reserved_mem.bank[i].start; + e =3D s + bootinfo.reserved_mem.bank[i].size; +#ifdef CONFIG_ARM_32 + /* Avoid the xenheap, note that the xenheap cannot across a ba= nk */ + if ( s <=3D mfn_to_maddr(directmap_mfn_start) && + e >=3D mfn_to_maddr(directmap_mfn_end) ) + { + init_boot_pages(s, mfn_to_maddr(directmap_mfn_start)); + init_boot_pages(mfn_to_maddr(directmap_mfn_end), e); + } + else +#endif + init_boot_pages(s, e); + } + + return; + } + + for ( i =3D 0; i < banks->nr_banks; i++ ) + { + const struct membank *bank =3D &banks->bank[i]; + paddr_t bank_end =3D bank->start + bank->size; + + s =3D bank->start; + while ( s < bank_end ) + { + paddr_t n =3D bank_end; + + e =3D next_module(s, &n); + + if ( e =3D=3D ~(paddr_t)0 ) + e =3D n =3D bank_end; + + /* + * Module in a RAM bank other than the one which we are + * not dealing with here. + */ + if ( e > bank_end ) + e =3D bank_end; + +#ifdef CONFIG_ARM_32 + /* Avoid the xenheap */ + if ( s < mfn_to_maddr(directmap_mfn_end) && + mfn_to_maddr(directmap_mfn_start) < e ) + { + e =3D mfn_to_maddr(directmap_mfn_start); + n =3D mfn_to_maddr(directmap_mfn_end); + } +#endif + + fw_unreserved_regions(s, e, init_boot_pages, 0); + s =3D n; + } + } +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.30.2 From nobody Sat May 11 15:03:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=raptorengineering.com ARC-Seal: i=1; a=rsa-sha256; t=1710454595; cv=none; d=zohomail.com; s=zohoarc; b=OmPlc96upgvo6nfUelT4lb0PBLecuDCtAaHwOOdRxAe6qppLI8Bmos6oBfJ2ByijT2WsUTj+w5ul60uivqirP7TYAT3x7EE/4HgwXPnnOctvpK4bU9ooli9Qjx7O56I1iUZd0a3PEBgecfSPjNljvPsaz4260B98xUdLp1VH8Aw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710454595; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MDQ4qX1cZClSO+Sy5SemqANFOXF/LtmGjUBuy5sUWoI=; b=YizMh7CfCt39YzZAWcjtwQswzK+baFnYOcu94hjNeT+qCEB47Fl+TEolh0TnZz2ZTd0KEud9+UszT1WHa6OLruDuR99ahHVTznH5Vqxl1uw3Z5GDheps0LXuRT/3tewumNbTgcdrR3twIROEaND1l3UAuRXjtz2euB2iJW6d4P0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1710454595182913.5039709681892; Thu, 14 Mar 2024 15:16:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.693515.1081713 (Exim 4.92) (envelope-from ) id 1rktMx-0000yK-Sv; Thu, 14 Mar 2024 22:16:11 +0000 Received: by outflank-mailman (output) from mailman id 693515.1081713; Thu, 14 Mar 2024 22:16:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rktMx-0000wR-Me; Thu, 14 Mar 2024 22:16:11 +0000 Received: by outflank-mailman (input) for mailman id 693515; Thu, 14 Mar 2024 22:16:10 +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 1rktMw-0000X2-NE for xen-devel@lists.xenproject.org; Thu, 14 Mar 2024 22:16:10 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 72db41df-e250-11ee-a1ee-f123f15fe8a2; Thu, 14 Mar 2024 23:16:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id A5F1C8286CAF; Thu, 14 Mar 2024 17:16:01 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id tDgj889x-TCk; Thu, 14 Mar 2024 17:16:01 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id F1AAE828673E; Thu, 14 Mar 2024 17:16:00 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Ekesbb3plJdX; Thu, 14 Mar 2024 17:16:00 -0500 (CDT) Received: from raptor-ewks-026.lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id 214678286CAF; Thu, 14 Mar 2024 17:16:00 -0500 (CDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 72db41df-e250-11ee-a1ee-f123f15fe8a2 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com F1AAE828673E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1710454561; bh=MDQ4qX1cZClSO+Sy5SemqANFOXF/LtmGjUBuy5sUWoI=; h=From:To:Date:Message-Id:MIME-Version; b=ViEnf6+rfF6+CQ43NWAtk16nUwQnLpNd9AHxGAbH51+3DDm96kWYULgFqvzEiAuNW xMrmDMWWLbs6I/zpmaaoQH5vh6EiZgfBUYgQGI6OUOVDa11VLvih0jM/RNUAlfJmFM XHUnFR9879uXfHp92MjtFv4vlayklRSQ4L+ogEy4= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: tpearson@raptorengineering.com, Jan Beulich , Shawn Anastasio , Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH v3 6/9] xen/common: Move Arm's bootfdt.c to common Date: Thu, 14 Mar 2024 17:15:44 -0500 Message-Id: <908ea2d9bccf0b3455119cfd9af0597aee005fe8.1710443965.git.sanastasio@raptorengineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @raptorengineering.com) X-ZM-MESSAGEID: 1710454596235100007 Content-Type: text/plain; charset="utf-8" Move Arm's bootfdt.c to xen/common so that it can be used by other device tree architectures like PPC and RISCV. Suggested-by: Julien Grall Signed-off-by: Shawn Anastasio Acked-by: Julien Grall --- Changes in v2: - Drop #if defined(CONFIG_ARM_EFI) now that efi_enabled is stubbed MAINTAINERS | 1 + xen/arch/arm/Makefile | 1 - xen/common/device-tree/Makefile | 1 + xen/{arch/arm =3D> common/device-tree}/bootfdt.c | 0 4 files changed, 2 insertions(+), 1 deletion(-) rename xen/{arch/arm =3D> common/device-tree}/bootfdt.c (100%) diff --git a/MAINTAINERS b/MAINTAINERS index e85fbe6737..20fdec9ffa 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -251,6 +251,7 @@ S: Supported L: xen-devel@lists.xenproject.org F: docs/misc/arm/ F: xen/arch/arm/ +F: xen/common/device-tree/bootfdt.c F: xen/drivers/char/arm-uart.c F: xen/drivers/char/cadence-uart.c F: xen/drivers/char/exynos4210-uart.c diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 7b1350e2ef..9e1548378c 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -10,7 +10,6 @@ obj-$(CONFIG_TEE) +=3D tee/ obj-$(CONFIG_HAS_VPCI) +=3D vpci.o obj-$(CONFIG_HAS_ALTERNATIVE) +=3D alternative.o -obj-y +=3D bootfdt.init.o obj-y +=3D cpuerrata.o obj-y +=3D cpufeature.o obj-y +=3D decode.o diff --git a/xen/common/device-tree/Makefile b/xen/common/device-tree/Makef= ile index c97b2bd88c..fa5beafd65 100644 --- a/xen/common/device-tree/Makefile +++ b/xen/common/device-tree/Makefile @@ -1 +1,2 @@ +obj-y +=3D bootfdt.init.o obj-y +=3D bootinfo.o diff --git a/xen/arch/arm/bootfdt.c b/xen/common/device-tree/bootfdt.c similarity index 100% rename from xen/arch/arm/bootfdt.c rename to xen/common/device-tree/bootfdt.c -- 2.30.2 From nobody Sat May 11 15:03:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=raptorengineering.com ARC-Seal: i=1; a=rsa-sha256; t=1710454592; cv=none; d=zohomail.com; s=zohoarc; b=E7VyzFyn05qUKpC2xqAAE+NdvQusGRMiikQCwgNQWTlO7QhBrSlSmXNT4KMv2DS8dfERdatT456aPcRMBb22iKYQ0j8pXs+iaEkov9J2MRLx2nC2rJiMQUUB0DqtuZfPRBmMbse3CKi6ZKGQDkF7yT3cIPlR8fKEUFq5IJ7OcIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710454592; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ImWiIfCHbaewHCZffKSjHa8JvgXFPUKjK9FnpBwpojM=; b=OSiqvhrexroQGFIovjkGNbK9KqIMUomhUXj2vIwuv7f90TMa2QnG/BV9F5p4s8U3YYoxxVWbpEptwSXhu/zt0zPEWTFdaGMW5uKsLATDpAQjsuYqwM+lGNFoxOTa1IUYxxazZClN5WrLaYwFaH9BZTgnuPOnOvFb4BpaHpC5zaA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1710454592600967.0628708938123; Thu, 14 Mar 2024 15:16:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.693511.1081676 (Exim 4.92) (envelope-from ) id 1rktMt-0008WI-Kw; Thu, 14 Mar 2024 22:16:07 +0000 Received: by outflank-mailman (output) from mailman id 693511.1081676; Thu, 14 Mar 2024 22:16:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rktMt-0008UV-Gf; Thu, 14 Mar 2024 22:16:07 +0000 Received: by outflank-mailman (input) for mailman id 693511; Thu, 14 Mar 2024 22:16:06 +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 1rktMs-0008HV-Q3 for xen-devel@lists.xenproject.org; Thu, 14 Mar 2024 22:16:06 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 72dc1d32-e250-11ee-afdd-a90da7624cb6; Thu, 14 Mar 2024 23:16:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id F1101828673E; Thu, 14 Mar 2024 17:16:01 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id PsppJZOTuu59; Thu, 14 Mar 2024 17:16:01 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 3AF578286A4B; Thu, 14 Mar 2024 17:16:01 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id tgjB4xl8g7Ku; Thu, 14 Mar 2024 17:16:01 -0500 (CDT) Received: from raptor-ewks-026.lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id BA7988286CDC; Thu, 14 Mar 2024 17:16:00 -0500 (CDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 72dc1d32-e250-11ee-afdd-a90da7624cb6 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com 3AF578286A4B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1710454561; bh=ImWiIfCHbaewHCZffKSjHa8JvgXFPUKjK9FnpBwpojM=; h=From:To:Date:Message-Id:MIME-Version; b=gaVilxusz+uoUP3SZd87R5ePrtO3uSDmeGW6+2ItIMFg5fe9LIdtDsfPPX29ELf36 jezQawQXoEsi4jiOmdrPxkZlJJrcUpBs2BMjIamka1RRn0gmW4mv5+HaT+KdoHkFFP NQY7f8pC6SCN2L+EhqCCqpNs6dimIFGQjmE0YEtY= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: tpearson@raptorengineering.com, Jan Beulich , Shawn Anastasio , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Volodymyr Babchuk Subject: [PATCH v3 7/9] xen/ppc: Enable bootfdt and boot allocator Date: Thu, 14 Mar 2024 17:15:45 -0500 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @raptorengineering.com) X-ZM-MESSAGEID: 1710454595102100002 Content-Type: text/plain; charset="utf-8" Enable usage of bootfdt for populating the boot info struct from the firmware-provided device tree. Also enable the Xen boot page allocator. Includes minor changes to bootfdt.c's boot_fdt_info() to tolerate the scenario in which the FDT overlaps a reserved memory region, as is the case on PPC when booted directly from skiboot. Signed-off-by: Shawn Anastasio --- xen/arch/ppc/include/asm/setup.h | 5 +++++ xen/arch/ppc/setup.c | 21 ++++++++++++++++++++- xen/common/device-tree/bootfdt.c | 11 +++++++++-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/xen/arch/ppc/include/asm/setup.h b/xen/arch/ppc/include/asm/se= tup.h index 1b2d29c5b6..fe27f61fc3 100644 --- a/xen/arch/ppc/include/asm/setup.h +++ b/xen/arch/ppc/include/asm/setup.h @@ -115,4 +115,9 @@ const char *boot_module_kind_as_string(bootmodule_kind = kind); struct bootcmdline *boot_cmdline_find_by_kind(bootmodule_kind kind); void populate_boot_allocator(void); =20 +/* + * bootfdt.c + */ +size_t boot_fdt_info(const void *fdt, paddr_t paddr); + #endif /* __ASM_PPC_SETUP_H__ */ diff --git a/xen/arch/ppc/setup.c b/xen/arch/ppc/setup.c index 101bdd8bb6..946167a56f 100644 --- a/xen/arch/ppc/setup.c +++ b/xen/arch/ppc/setup.c @@ -1,12 +1,14 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ #include #include +#include #include #include #include #include #include #include +#include =20 /* Xen stack for bringing up the first CPU. */ unsigned char __initdata cpu0_boot_stack[STACK_SIZE] __aligned(STACK_SIZE); @@ -24,6 +26,9 @@ void __init noreturn start_xen(unsigned long r3, unsigned= long r4, unsigned long r5, unsigned long r6, unsigned long r7) { + void *boot_fdt; + struct bootmodule *xen_bootmodule; + if ( r5 ) { /* Unsupported OpenFirmware boot protocol */ @@ -32,11 +37,25 @@ void __init noreturn start_xen(unsigned long r3, unsign= ed long r4, else { /* kexec boot protocol */ - boot_opal_init((void *)r3); + boot_fdt =3D (void *)r3; + boot_opal_init(boot_fdt); } =20 setup_exceptions(); =20 + device_tree_flattened =3D boot_fdt; + boot_fdt_info(boot_fdt, r3); + + /* + * Xen relocates itself at the ppc64 entrypoint, so we need to manuall= y mark + * the kernel module. + */ + xen_bootmodule =3D add_boot_module(BOOTMOD_XEN, __pa(_start), + PAGE_ALIGN(__pa(_end)), false); + BUG_ON(!xen_bootmodule); + + populate_boot_allocator(); + setup_initial_pagetables(); =20 early_printk("Hello, ppc64le!\n"); diff --git a/xen/common/device-tree/bootfdt.c b/xen/common/device-tree/boot= fdt.c index 35dbdf3384..1985648b31 100644 --- a/xen/common/device-tree/bootfdt.c +++ b/xen/common/device-tree/bootfdt.c @@ -543,12 +543,19 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t = paddr) if ( ret < 0 ) panic("No valid device tree\n"); =20 - add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), false); - ret =3D device_tree_for_each_node(fdt, 0, early_scan_node, NULL); if ( ret ) panic("Early FDT parsing failed (%d)\n", ret); =20 + /* + * Add module for the FDT itself after the device tree has been parsed= . This + * is required on ppc64le where the device tree passed to Xen may have= been + * allocated by skiboot, in which case it will exist within a reserved + * region and this call will fail. This is fine, however, since either= way + * the allocator will know not to step on the device tree. + */ + add_boot_module(BOOTMOD_FDT, paddr, fdt_totalsize(fdt), false); + /* * On Arm64 setup_directmap_mappings() expects to be called with the l= owest * bank in memory first. There is no requirement that the DT will prov= ide --=20 2.30.2 From nobody Sat May 11 15:03:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=raptorengineering.com ARC-Seal: i=1; a=rsa-sha256; t=1710454592; cv=none; d=zohomail.com; s=zohoarc; b=YR6OQQ0FbB4y4HcwibwyyFJ1GlEk2EqrJujCtu0R2Swm2UEA19WvEnjQ0WQICk+0vAzKhl0TexeeKfYXlkUGK8FvnrvxA/5ZjmOD7XCQBjm6yayq3Yuy+OUOjgQuy2qhUekabGZmaRPI/SaGWeICm3mkH1hfvEol/0r3jBrCSyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710454592; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dt6YNGcjC+/2CTbftddRfgPKz9WX5uH4sC7NdpXR/zg=; b=X8R7dLuCqM8kVphg4CH3Jxbpilx2kPVuDAccJyt4uNcFsoxabqT191PPCUtTEjuL0kCu71XGE0udDaDwCTEGNFySbVbpKvwqGjtfh7FxZg2ldf/ZSee51GzVdSzoZQPWDFF99xMP3QXrvyHOELEJVRmEw5gi8LeGpKVKTmaSAlE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1710454592371249.71431012705966; Thu, 14 Mar 2024 15:16:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.693517.1081738 (Exim 4.92) (envelope-from ) id 1rktN0-0001f9-35; Thu, 14 Mar 2024 22:16:14 +0000 Received: by outflank-mailman (output) from mailman id 693517.1081738; Thu, 14 Mar 2024 22:16:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rktMz-0001d3-RY; Thu, 14 Mar 2024 22:16:13 +0000 Received: by outflank-mailman (input) for mailman id 693517; Thu, 14 Mar 2024 22:16:12 +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 1rktMy-0000X2-NO for xen-devel@lists.xenproject.org; Thu, 14 Mar 2024 22:16:12 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 72f8a9cb-e250-11ee-a1ee-f123f15fe8a2; Thu, 14 Mar 2024 23:16:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 36AE48286A4B; Thu, 14 Mar 2024 17:16:02 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id n9bwzI00_r5F; Thu, 14 Mar 2024 17:16:01 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 81C7A8286D0A; Thu, 14 Mar 2024 17:16:01 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id pFHCcpG6XIBN; Thu, 14 Mar 2024 17:16:01 -0500 (CDT) Received: from raptor-ewks-026.lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id 319138286CAF; Thu, 14 Mar 2024 17:16:01 -0500 (CDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 72f8a9cb-e250-11ee-a1ee-f123f15fe8a2 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com 81C7A8286D0A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1710454561; bh=dt6YNGcjC+/2CTbftddRfgPKz9WX5uH4sC7NdpXR/zg=; h=From:To:Date:Message-Id:MIME-Version; b=Z2UNifXzecjQuuILvfxWVzbh6HVrO3/il7j/lFSgu0kAdSFhgjbxGI+ipe1qXPV7/ BUgYeJv5JFNmYJXheZFCIRup4mpXh3T6k0ikrhIk9rDXkH6P/5CH0dnLA7JasCw/GH H7NjdrNE+ydC3wG1UjVBSJYX0DHOG5029obWFytI= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: tpearson@raptorengineering.com, Jan Beulich , Shawn Anastasio Subject: [PATCH v3 8/9] xen/ppc: mm-radix: Replace debug printing code with printk Date: Thu, 14 Mar 2024 17:15:46 -0500 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @raptorengineering.com) X-ZM-MESSAGEID: 1710454595096100001 Content-Type: text/plain; charset="utf-8" Now that we have common code building, there's no need to keep the old itoa64+debug print function in mm-radix.c Signed-off-by: Shawn Anastasio Reviewed-by: Jan Beulich --- Changes in v2: - Use CONFIG_DEBUG instead of NDEBUG xen/arch/ppc/mm-radix.c | 58 +++++++++-------------------------------- 1 file changed, 12 insertions(+), 46 deletions(-) diff --git a/xen/arch/ppc/mm-radix.c b/xen/arch/ppc/mm-radix.c index daa411a6fa..ab5a10695c 100644 --- a/xen/arch/ppc/mm-radix.c +++ b/xen/arch/ppc/mm-radix.c @@ -15,6 +15,12 @@ void enable_mmu(void); +#ifdef CONFIG_DEBUG +#define radix_dprintk(msg, ...) printk(XENLOG_DEBUG msg, ## __VA_ARGS__) +#else +#define radix_dprintk(...) +#endif + #define INITIAL_LVL1_PD_COUNT 1 #define INITIAL_LVL2_LVL3_PD_COUNT 2 #define INITIAL_LVL4_PT_COUNT 256 @@ -80,45 +86,6 @@ static __init struct lvl4_pt *lvl4_pt_pool_alloc(void) return &initial_lvl4_pt_pool[initial_lvl4_pt_pool_used++]; } -#ifndef NDEBUG -/* TODO: Remove once we get common/ building */ -static char *__init itoa64_hex(uint64_t val, char *out_buf, size_t buf_len) -{ - uint64_t cur; - size_t i =3D buf_len - 1; - - /* Null terminate buffer */ - out_buf[i] =3D '\0'; - - /* Add digits in reverse */ - cur =3D val; - while ( cur && i > 0 ) - { - out_buf[--i] =3D "0123456789ABCDEF"[cur % 16]; - cur /=3D 16; - } - - /* Pad to 16 digits */ - while ( i > 0 ) - out_buf[--i] =3D '0'; - - return out_buf + i; -} -#endif - -static void __init radix_dprint(uint64_t addr, const char *msg) -{ -#ifndef NDEBUG - char buf[sizeof("DEADBEEFCAFEBABA")]; - char *addr_s =3D itoa64_hex(addr, buf, sizeof(buf)); - - early_printk("(0x"); - early_printk(addr_s); - early_printk(") "); - early_printk(msg); -#endif -} - static void __init setup_initial_mapping(struct lvl1_pd *lvl1, vaddr_t map_start, vaddr_t map_end, @@ -186,27 +153,26 @@ static void __init setup_initial_mapping(struct lvl1_= pd *lvl1, unsigned long paddr =3D (page_addr - map_start) + phys_base; unsigned long flags; - radix_dprint(paddr, "being mapped to "); - radix_dprint(page_addr, "!\n"); + radix_dprintk("%016lx being mapped to %016lx\n", paddr, page_a= ddr); if ( is_kernel_text(page_addr) || is_kernel_inittext(page_addr= ) ) { - radix_dprint(page_addr, "being marked as TEXT (RX)\n"); + radix_dprintk("%016lx being marked as TEXT (RX)\n", page_a= ddr); flags =3D PTE_XEN_RX; } else if ( is_kernel_rodata(page_addr) ) { - radix_dprint(page_addr, "being marked as RODATA (RO)\n"); + radix_dprintk("%016lx being marked as RODATA (RO)\n", page= _addr); flags =3D PTE_XEN_RO; } else { - radix_dprint(page_addr, "being marked as DEFAULT (RW)\n"); + radix_dprintk("%016lx being marked as DEFAULT (RW)\n", pag= e_addr); flags =3D PTE_XEN_RW; } *pte =3D paddr_to_pte(paddr, flags); - radix_dprint(paddr_to_pte(paddr, flags).pte, - "is result of PTE map!\n"); + radix_dprintk("%016lx is the result of PTE map\n", + paddr_to_pte(paddr, flags).pte); } else { -- 2.30.2 From nobody Sat May 11 15:03:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=raptorengineering.com ARC-Seal: i=1; a=rsa-sha256; t=1710454593; cv=none; d=zohomail.com; s=zohoarc; b=Lyg7rkYFeQW0Qo9PL8VQB4xihRnw+FAv+tLRcPAUXjOZtrZpiQYxSziGP4HXh6yW4mxIJ9UK6yYFW36AzK/IW5LhTq36YdNM7PXwi8bEmx/VnnC8AL+nIf01C0xGPUuf0bPa+PGFo/+ehXWi8770X4M38FXFv6+JbxzreCXLkwQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710454593; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=50skhtpwMDcPgIfs73jJDeuj0sPH24wFUgn3url2ebE=; b=O4iB9hY8OQ8bILp6yqNKlcKhsE4INWQobIUMgN/QtXmxTdtC385HiXg6Z3rlj/me1yrO3SrTKWDtEtR4jy8HIsge4KOPkFEIqQIzPCVe7Sxroq9Kkcps0912N3Kpe7HexBa8ekAMW6R8imLWlihvxzt1O5ZlhMCJ7qpbfEYkaUE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1710454593158718.25244334277; Thu, 14 Mar 2024 15:16:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.693512.1081693 (Exim 4.92) (envelope-from ) id 1rktMu-0000YZ-UB; Thu, 14 Mar 2024 22:16:08 +0000 Received: by outflank-mailman (output) from mailman id 693512.1081693; Thu, 14 Mar 2024 22:16:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rktMu-0000YS-QR; Thu, 14 Mar 2024 22:16:08 +0000 Received: by outflank-mailman (input) for mailman id 693512; Thu, 14 Mar 2024 22:16:07 +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 1rktMt-0008HV-QM for xen-devel@lists.xenproject.org; Thu, 14 Mar 2024 22:16:07 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 73c560cc-e250-11ee-afdd-a90da7624cb6; Thu, 14 Mar 2024 23:16:06 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id D4A238286CAE; Thu, 14 Mar 2024 17:16:02 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id fRK23-8nHYBk; Thu, 14 Mar 2024 17:16:01 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id CE62282856F3; Thu, 14 Mar 2024 17:16:01 -0500 (CDT) Received: from mail.rptsys.com ([127.0.0.1]) by localhost (vali.starlink.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id hpv1Dl9dC7ym; Thu, 14 Mar 2024 17:16:01 -0500 (CDT) Received: from raptor-ewks-026.lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id 7BFCD8286CF5; Thu, 14 Mar 2024 17:16:01 -0500 (CDT) X-Outflank-Mailman: Message body and most headers restored to incoming version 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: 73c560cc-e250-11ee-afdd-a90da7624cb6 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com CE62282856F3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1710454561; bh=50skhtpwMDcPgIfs73jJDeuj0sPH24wFUgn3url2ebE=; h=From:To:Date:Message-Id:MIME-Version; b=HegyX1oSVMwtUNjRNeC/Ndr2pHrhOiPCBnaXSqIkETPn5Ga0mSU6IEE1xA7AhONlP RT5JniJbhoE0iqXpRxTZ7+lSqz5wCd7g0sHj0QHgg443v7rkiRHHvknPMFzNkds1A3 F0dD1d7C1/WQetnGLLjF08gB+VDatfCIpf67ixPc= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: tpearson@raptorengineering.com, Jan Beulich , Shawn Anastasio Subject: [PATCH v3 9/9] xen/ppc: mm-radix: Allocate all paging structures at runtime Date: Thu, 14 Mar 2024 17:15:47 -0500 Message-Id: <00f22a6a08451614179219fd430539fbb1e6e8cf.1710443965.git.sanastasio@raptorengineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @raptorengineering.com) X-ZM-MESSAGEID: 1710454595122100003 Content-Type: text/plain; charset="utf-8" In the initial mm-radix implementation, the in-memory partition and process tables required to configure the MMU, as well as the page tables themselves were all allocated statically since the boot allocator was not yet available. Now that it is, allocate these structures at runtime and bump the size of the Process Table to its maximum supported value (on POWER9). Signed-off-by: Shawn Anastasio --- Changes in v2: - Drop all static allocation and use boot allocator for page tables too xen/arch/ppc/mm-radix.c | 227 +++++++++++++++++++++------------------- 1 file changed, 119 insertions(+), 108 deletions(-) diff --git a/xen/arch/ppc/mm-radix.c b/xen/arch/ppc/mm-radix.c index ab5a10695c..edae41e0be 100644 --- a/xen/arch/ppc/mm-radix.c +++ b/xen/arch/ppc/mm-radix.c @@ -21,69 +21,101 @@ void enable_mmu(void); #define radix_dprintk(...) #endif -#define INITIAL_LVL1_PD_COUNT 1 -#define INITIAL_LVL2_LVL3_PD_COUNT 2 -#define INITIAL_LVL4_PT_COUNT 256 - -static size_t __initdata initial_lvl1_pd_pool_used; -static struct lvl1_pd initial_lvl1_pd_pool[INITIAL_LVL1_PD_COUNT]; - -static size_t __initdata initial_lvl2_lvl3_pd_pool_used; -static struct lvl2_pd initial_lvl2_lvl3_pd_pool[INITIAL_LVL2_LVL3_PD_COUNT= ]; - -static size_t __initdata initial_lvl4_pt_pool_used; -static struct lvl4_pt initial_lvl4_pt_pool[INITIAL_LVL4_PT_COUNT]; - -/* Only reserve minimum Partition and Process tables */ #define PATB_SIZE_LOG2 16 /* Only supported partition table size on POWER9= */ #define PATB_SIZE (1UL << PATB_SIZE_LOG2) -#define PRTB_SIZE_LOG2 12 +#define PRTB_SIZE_LOG2 24 /* Maximum process table size on POWER9 */ #define PRTB_SIZE (1UL << PRTB_SIZE_LOG2) -static struct patb_entry - __aligned(PATB_SIZE) initial_patb[PATB_SIZE / sizeof(struct patb_entry= )]; +static struct patb_entry *initial_patb; +static struct prtb_entry *initial_prtb; -static struct prtb_entry - __aligned(PRTB_SIZE) initial_prtb[PRTB_SIZE / sizeof(struct prtb_entry= )]; +static mfn_t __initdata min_alloc_mfn =3D {-1}; +static mfn_t __initdata max_alloc_mfn =3D {0}; -static __init struct lvl1_pd *lvl1_pd_pool_alloc(void) +/* + * A thin wrapper for alloc_boot_pages that keeps track of the maximum and + * minimum mfns that have been allocated. This information is used by + * setup_initial_mapping to include the allocated pages in the initial + * page mapping. + */ +static mfn_t __init initial_page_alloc(unsigned long nr_pfns, + unsigned long pfn_align) { - if ( initial_lvl1_pd_pool_used >=3D INITIAL_LVL1_PD_COUNT ) - { - early_printk("Ran out of space for LVL1 PD!\n"); - die(); - } + mfn_t mfn_first, mfn_last; - return &initial_lvl1_pd_pool[initial_lvl1_pd_pool_used++]; -} + mfn_first =3D alloc_boot_pages(nr_pfns, pfn_align); + mfn_last =3D _mfn(mfn_x(mfn_first) + nr_pfns - 1); -static __init struct lvl2_pd *lvl2_pd_pool_alloc(void) -{ - if ( initial_lvl2_lvl3_pd_pool_used >=3D INITIAL_LVL2_LVL3_PD_COUNT ) - { - early_printk("Ran out of space for LVL2/3 PD!\n"); - die(); - } + min_alloc_mfn =3D _mfn(min(mfn_x(min_alloc_mfn), mfn_x(mfn_first))); + max_alloc_mfn =3D _mfn(max(mfn_x(max_alloc_mfn), mfn_x(mfn_last))); - return &initial_lvl2_lvl3_pd_pool[initial_lvl2_lvl3_pd_pool_used++]; + return mfn_first; } -static __init struct lvl3_pd *lvl3_pd_pool_alloc(void) +static __init void *initial_pd_pt_alloc(void) { - BUILD_BUG_ON(sizeof(struct lvl3_pd) !=3D sizeof(struct lvl2_pd)); + BUILD_BUG_ON(sizeof(struct lvl1_pd) > PAGE_SIZE); + BUILD_BUG_ON(sizeof(struct lvl2_pd) > PAGE_SIZE); + BUILD_BUG_ON(sizeof(struct lvl3_pd) > PAGE_SIZE); + BUILD_BUG_ON(sizeof(struct lvl4_pt) > PAGE_SIZE); - return (struct lvl3_pd *) lvl2_pd_pool_alloc(); + return __va(mfn_to_maddr(initial_page_alloc(1, 1))); } -static __init struct lvl4_pt *lvl4_pt_pool_alloc(void) +static void map_page_initial(struct lvl1_pd *lvl1, vaddr_t virt, paddr_t p= hys, + unsigned long flags) { - if ( initial_lvl4_pt_pool_used >=3D INITIAL_LVL4_PT_COUNT ) + struct lvl2_pd *lvl2; + struct lvl3_pd *lvl3; + struct lvl4_pt *lvl4; + pde_t *pde; + pte_t *pte; + + /* Allocate LVL 2 PD if necessary */ + pde =3D pt_entry(lvl1, virt); + if ( !pde_is_valid(*pde) ) { - early_printk("Ran out of space for LVL4 PT!\n"); - die(); + lvl2 =3D initial_pd_pt_alloc(); + *pde =3D paddr_to_pde(__pa(lvl2), PDE_VALID, + XEN_PT_ENTRIES_LOG2_LVL_2); + } + else + lvl2 =3D __va(pde_to_paddr(*pde)); + + /* Allocate LVL 3 PD if necessary */ + pde =3D pt_entry(lvl2, virt); + if ( !pde_is_valid(*pde) ) + { + lvl3 =3D initial_pd_pt_alloc(); + *pde =3D paddr_to_pde(__pa(lvl3), PDE_VALID, + XEN_PT_ENTRIES_LOG2_LVL_3); + } + else + lvl3 =3D __va(pde_to_paddr(*pde)); + + /* Allocate LVL 4 PT if necessary */ + pde =3D pt_entry(lvl3, virt); + if ( !pde_is_valid(*pde) ) + { + lvl4 =3D initial_pd_pt_alloc(); + *pde =3D paddr_to_pde(__pa(lvl4), PDE_VALID, + XEN_PT_ENTRIES_LOG2_LVL_4); } + else + lvl4 =3D __va(pde_to_paddr(*pde)); - return &initial_lvl4_pt_pool[initial_lvl4_pt_pool_used++]; + /* Finally, create PTE in LVL 4 PT */ + pte =3D pt_entry(lvl4, virt); + if ( !pte_is_valid(*pte) ) + { + radix_dprintk("%016lx being mapped to %016lx\n", phys, virt); + *pte =3D paddr_to_pte(phys, flags); + } + else + { + early_printk("BUG: Tried to create PTE for already-mapped page!"); + die(); + } } static void __init setup_initial_mapping(struct lvl1_pd *lvl1, @@ -92,6 +124,7 @@ static void __init setup_initial_mapping(struct lvl1_pd = *lvl1, paddr_t phys_base) { uint64_t page_addr; + mfn_t previous_max_alloc_mfn; if ( map_start & ~PAGE_MASK ) { @@ -105,81 +138,47 @@ static void __init setup_initial_mapping(struct lvl1_= pd *lvl1, die(); } + /* Identity map Xen itself */ for ( page_addr =3D map_start; page_addr < map_end; page_addr +=3D PAG= E_SIZE ) { - struct lvl2_pd *lvl2; - struct lvl3_pd *lvl3; - struct lvl4_pt *lvl4; - pde_t *pde; - pte_t *pte; - - /* Allocate LVL 2 PD if necessary */ - pde =3D pt_entry(lvl1, page_addr); - if ( !pde_is_valid(*pde) ) - { - lvl2 =3D lvl2_pd_pool_alloc(); - *pde =3D paddr_to_pde(__pa(lvl2), PDE_VALID, - XEN_PT_ENTRIES_LOG2_LVL_2); - } - else - lvl2 =3D __va(pde_to_paddr(*pde)); + unsigned long flags; - /* Allocate LVL 3 PD if necessary */ - pde =3D pt_entry(lvl2, page_addr); - if ( !pde_is_valid(*pde) ) + if ( is_kernel_text(page_addr) || is_kernel_inittext(page_addr) ) { - lvl3 =3D lvl3_pd_pool_alloc(); - *pde =3D paddr_to_pde(__pa(lvl3), PDE_VALID, - XEN_PT_ENTRIES_LOG2_LVL_3); + radix_dprintk("%016lx being marked as TEXT (RX)\n", page_addr); + flags =3D PTE_XEN_RX; } - else - lvl3 =3D __va(pde_to_paddr(*pde)); - - /* Allocate LVL 4 PT if necessary */ - pde =3D pt_entry(lvl3, page_addr); - if ( !pde_is_valid(*pde) ) + else if ( is_kernel_rodata(page_addr) ) { - lvl4 =3D lvl4_pt_pool_alloc(); - *pde =3D paddr_to_pde(__pa(lvl4), PDE_VALID, - XEN_PT_ENTRIES_LOG2_LVL_4); + radix_dprintk("%016lx being marked as RODATA (RO)\n", page_add= r); + flags =3D PTE_XEN_RO; } else - lvl4 =3D __va(pde_to_paddr(*pde)); - - /* Finally, create PTE in LVL 4 PT */ - pte =3D pt_entry(lvl4, page_addr); - if ( !pte_is_valid(*pte) ) { - unsigned long paddr =3D (page_addr - map_start) + phys_base; - unsigned long flags; - - radix_dprintk("%016lx being mapped to %016lx\n", paddr, page_a= ddr); - if ( is_kernel_text(page_addr) || is_kernel_inittext(page_addr= ) ) - { - radix_dprintk("%016lx being marked as TEXT (RX)\n", page_a= ddr); - flags =3D PTE_XEN_RX; - } - else if ( is_kernel_rodata(page_addr) ) - { - radix_dprintk("%016lx being marked as RODATA (RO)\n", page= _addr); - flags =3D PTE_XEN_RO; - } - else - { - radix_dprintk("%016lx being marked as DEFAULT (RW)\n", pag= e_addr); - flags =3D PTE_XEN_RW; - } - - *pte =3D paddr_to_pte(paddr, flags); - radix_dprintk("%016lx is the result of PTE map\n", - paddr_to_pte(paddr, flags).pte); - } - else - { - early_printk("BUG: Tried to create PTE for already-mapped page= !"); - die(); + radix_dprintk("%016lx being marked as DEFAULT (RW)\n", page_ad= dr); + flags =3D PTE_XEN_RW; } + + map_page_initial(lvl1, page_addr, (page_addr - map_start) + phys_b= ase, flags); + } + + previous_max_alloc_mfn =3D max_alloc_mfn; + + /* + * Identity map all pages we've allocated for paging structures. This = act + * itself will allocate more pages, so continue until we've mapped from + * `max_alloc_mfn` down to `min_alloc_mfn`. This assumes that the heap= grows + * downwards, which matches the behavior of alloc_boot_pages. + */ + for ( page_addr =3D (vaddr_t)__va(mfn_to_maddr(max_alloc_mfn)); + mfn_to_maddr(min_alloc_mfn) <=3D __pa(page_addr); + page_addr -=3D PAGE_SIZE) + { + map_page_initial(lvl1, page_addr, __pa(page_addr), PTE_XEN_RW); } + + if ( mfn_x(previous_max_alloc_mfn) !=3D mfn_x(max_alloc_mfn) ) + panic("Early page heap unexpectedly grew upwards\n"); } static void __init setup_partition_table(struct lvl1_pd *root) @@ -208,9 +207,21 @@ static void __init setup_process_table(struct lvl1_pd = *root) void __init setup_initial_pagetables(void) { - struct lvl1_pd *root =3D lvl1_pd_pool_alloc(); + struct lvl1_pd *root; unsigned long lpcr; + mfn_t patb_mfn, prtb_mfn; + + /* Allocate mfns for in-memory tables using the boot allocator */ + prtb_mfn =3D initial_page_alloc(PRTB_SIZE / PAGE_SIZE, + 1 << (PRTB_SIZE_LOG2 - PAGE_SHIFT)); + patb_mfn =3D initial_page_alloc(PATB_SIZE / PAGE_SIZE, + 1 << (PATB_SIZE_LOG2 - PAGE_SHIFT)); + + initial_patb =3D __va(mfn_to_maddr(patb_mfn)); + initial_prtb =3D __va(mfn_to_maddr(prtb_mfn)); + /* Allocate and create page tables */ + root =3D initial_pd_pt_alloc(); setup_initial_mapping(root, (vaddr_t)_start, (vaddr_t)_end, __pa(_star= t)); /* Enable Radix mode in LPCR */ -- 2.30.2