From nobody Sat May 18 12:05:12 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=1702608787; cv=none; d=zohomail.com; s=zohoarc; b=c7RrUE+d46VLSten9+DR+Si7wzp4EbWWvR2yE/DWcuv512SloFSWP+UKdk+nKM/5v7RgZxdj/qprMzhhY3sPeBQktqNlgSdUSAGGlf5xPu0X3CN6tCFPYPx9QM5LWj3U6SDEn4767sNmqz+o0Fbs89dBQH9SNxtFbOswt+85KQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702608787; 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=A+G8Y/mAKwwr+YfqhBvn2P9VeSV+LGNGsCJ+HQ4NXzE=; b=aLCZIpQ2gKxAV8xLALztxl5pfkGEM691DByr/tWT7G/aN40Ci31ZF8VMFNtbTRE9yfUz2b0Bla4FBuvnWy4hdLRsQEa3MD1v5TO9bfpDN6h7xzTt+tiFVmnPnYUyyEbVJi9AwSCPEb0JaRjJEUusZ/FS/qERMrKL5aAwsZqhiM4= 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 1702608787846957.6655889234361; Thu, 14 Dec 2023 18:53:07 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654837.1022278 (Exim 4.92) (envelope-from ) id 1rDyJi-0003rZ-J4; Fri, 15 Dec 2023 02:52:46 +0000 Received: by outflank-mailman (output) from mailman id 654837.1022278; Fri, 15 Dec 2023 02:52:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDyJi-0003rI-FB; Fri, 15 Dec 2023 02:52:46 +0000 Received: by outflank-mailman (input) for mailman id 654837; Fri, 15 Dec 2023 02:52:44 +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 1rDyJg-0003SX-Ke for xen-devel@lists.xenproject.org; Fri, 15 Dec 2023 02:52:44 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 04116fc3-9af5-11ee-9b0f-b553b5be7939; Fri, 15 Dec 2023 03:52:42 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id AAB288285463; Thu, 14 Dec 2023 20:52:41 -0600 (CST) 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 SN6EouxCpzyy; Thu, 14 Dec 2023 20:52:41 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 0BDBE8286129; Thu, 14 Dec 2023 20:52:41 -0600 (CST) 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 Dw2MKnTmA0Dd; Thu, 14 Dec 2023 20:52:40 -0600 (CST) Received: from raptor-ewks-026.2lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id AB05D8285AE9; Thu, 14 Dec 2023 20:52:40 -0600 (CST) 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: 04116fc3-9af5-11ee-9b0f-b553b5be7939 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com 0BDBE8286129 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1702608761; bh=A+G8Y/mAKwwr+YfqhBvn2P9VeSV+LGNGsCJ+HQ4NXzE=; h=From:To:Date:Message-Id:MIME-Version; b=RNjC36g1Zwt5bABtXwyRXUrFADTeu2GyXlZh8G/cOfRuohZ7q/6KoC4A4axhjqA9c nT+qGICCqdGia9B4M1B9cLa4sbwvA0oE0irLmwGyCjsp7OAAWpe23CgwflBJNOlF0E sioJsuzlDE3OOeDITyC5UGf/hE76UTpEVVwrwgN0= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: Timothy Pearson , Jan Beulich , Shawn Anastasio Subject: [PATCH v2 1/7] xen/asm-generic: Introduce generic static-shmem.h Date: Thu, 14 Dec 2023 20:43:56 -0600 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: 1702608789955100002 Content-Type: text/plain; charset="utf-8" Introduce static-shmem.h to asm-generic as a prerequisite for moving ARM's bootfdt.c into xen/common. Signed-off-by: Shawn Anastasio --- xen/arch/ppc/include/asm/Makefile | 1 + xen/include/asm-generic/static-shmem.h | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 xen/include/asm-generic/static-shmem.h diff --git a/xen/arch/ppc/include/asm/Makefile b/xen/arch/ppc/include/asm/M= akefile index 2da995bb2f..a711cfa856 100644 --- a/xen/arch/ppc/include/asm/Makefile +++ b/xen/arch/ppc/include/asm/Makefile @@ -6,4 +6,5 @@ generic-y +=3D iocap.h generic-y +=3D paging.h generic-y +=3D percpu.h generic-y +=3D random.h +generic-y +=3D static-shmem.h generic-y +=3D vm_event.h diff --git a/xen/include/asm-generic/static-shmem.h b/xen/include/asm-gener= ic/static-shmem.h new file mode 100644 index 0000000000..d45c44a419 --- /dev/null +++ b/xen/include/asm-generic/static-shmem.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __ASM_GENERIC_STATIC_SHMEM_H__ +#define __ASM_GENERIC_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_GENERIC_STATIC_SHMEM_H__ */ --=20 2.30.2 From nobody Sat May 18 12:05:12 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=1702608782; cv=none; d=zohomail.com; s=zohoarc; b=YxfiJM3of3nCSuejjdnpXcUFaw8sheb3nxc52W3KTzNtqdOvU+Gpsfh92ujc3JI2EJ0n0HyjeYihOFIyyglAGhwla0dzNK12XURoMnqXx7Umt2oguTNkm9bfaiHeooPfHYA2uVoLa1WULTqLn8LUJhOMKIf+gfQvgaKSsgW77rE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702608782; 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=xuXZQRjjBFlAEEWI2+xfJ/TIf6aMhn0vjL1+nXTvXR8=; b=FstRemJ9H3n18FFL+gRqMe6tb/P9uWxDsZN2YDwVt4YWB/WehU//qUsq6v0wiW6kKuWWD/Au9GBX8SKmqOVPE1QAzo1vcSmK9GKXF3hpoBUPEw7LBlIKV8jNNGkkUeRKmt7SU5a7Bimp4AVipR+7sBDB7mSIVFvhIUfaTfPRL2I= 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 1702608782575306.9765888810033; Thu, 14 Dec 2023 18:53:02 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654836.1022267 (Exim 4.92) (envelope-from ) id 1rDyJh-0003b8-8S; Fri, 15 Dec 2023 02:52:45 +0000 Received: by outflank-mailman (output) from mailman id 654836.1022267; Fri, 15 Dec 2023 02:52:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDyJh-0003b1-5l; Fri, 15 Dec 2023 02:52:45 +0000 Received: by outflank-mailman (input) for mailman id 654836; Fri, 15 Dec 2023 02:52:44 +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 1rDyJg-0002yh-1y for xen-devel@lists.xenproject.org; Fri, 15 Dec 2023 02:52:44 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 046989a9-9af5-11ee-98ea-6d05b1d4d9a1; Fri, 15 Dec 2023 03:52:43 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 797D682867CE; Thu, 14 Dec 2023 20:52:42 -0600 (CST) 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 n4h2h6g4EhV5; Thu, 14 Dec 2023 20:52:41 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 6DED582867CC; Thu, 14 Dec 2023 20:52:41 -0600 (CST) 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 t9I7Qbp6PaBD; Thu, 14 Dec 2023 20:52:41 -0600 (CST) Received: from raptor-ewks-026.2lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id 0B5508285463; Thu, 14 Dec 2023 20:52:41 -0600 (CST) 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: 046989a9-9af5-11ee-98ea-6d05b1d4d9a1 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com 6DED582867CC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1702608761; bh=xuXZQRjjBFlAEEWI2+xfJ/TIf6aMhn0vjL1+nXTvXR8=; h=From:To:Date:Message-Id:MIME-Version; b=g0aLQ9Rq6c1615MM3uO5YF0hpHgZtrd24SJlVYziAR4XGHZqmB/0Fq+9ZiEDBKdYB TzLzP3aP1ISCSw+VWL6lasRWnv/I3ktJQy07hDcCWKmtFOmKrHsomMqaZ0F6Efg1hk C1BLNvjKDJXPYSIzbTG0YCNrbeHE8x/VXwgrptLA= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: Timothy Pearson , Jan Beulich , Shawn Anastasio Subject: [PATCH v2 2/7] xen/asm-generic: Introduce generic setup.h Date: Thu, 14 Dec 2023 20:43:57 -0600 Message-Id: <1e4f48d753871bf61de3af97a3009e069d25d01e.1702607884.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: 1702608783939100001 Content-Type: text/plain; charset="utf-8" Introduce setup.h to asm-generic based off of ARM's to define all stubs necessary to compile bootfdt.c Signed-off-by: Shawn Anastasio --- xen/arch/ppc/include/asm/Makefile | 1 + xen/arch/ppc/include/asm/setup.h | 6 -- xen/include/asm-generic/setup.h | 148 ++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 6 deletions(-) delete mode 100644 xen/arch/ppc/include/asm/setup.h create mode 100644 xen/include/asm-generic/setup.h diff --git a/xen/arch/ppc/include/asm/Makefile b/xen/arch/ppc/include/asm/M= akefile index a711cfa856..7167661f86 100644 --- a/xen/arch/ppc/include/asm/Makefile +++ b/xen/arch/ppc/include/asm/Makefile @@ -6,5 +6,6 @@ generic-y +=3D iocap.h generic-y +=3D paging.h generic-y +=3D percpu.h generic-y +=3D random.h +generic-y +=3D setup.h generic-y +=3D static-shmem.h generic-y +=3D vm_event.h diff --git a/xen/arch/ppc/include/asm/setup.h b/xen/arch/ppc/include/asm/se= tup.h deleted file mode 100644 index e4f64879b6..0000000000 --- a/xen/arch/ppc/include/asm/setup.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __ASM_PPC_SETUP_H__ -#define __ASM_PPC_SETUP_H__ - -#define max_init_domid (0) - -#endif /* __ASM_PPC_SETUP_H__ */ diff --git a/xen/include/asm-generic/setup.h b/xen/include/asm-generic/setu= p.h new file mode 100644 index 0000000000..0262ad49f9 --- /dev/null +++ b/xen/include/asm-generic/setup.h @@ -0,0 +1,148 @@ +#ifndef __ASM_GENERIC_SETUP_H__ +#define __ASM_GENERIC_SETUP_H__ + +#define max_init_domid (0) + +#include + +#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; + +/* + * setup.c + */ + +static inline bool check_reserved_regions_overlap(paddr_t region_start, + paddr_t region_size) +{ + /* Not implemented on GENERIC */ + BUG(); +} + +static inline struct bootmodule *add_boot_module(bootmodule_kind kind, + paddr_t start, paddr_t si= ze, + bool domU) +{ + /* Not implemented on GENERIC */ + BUG(); +} + +static inline void add_boot_cmdline(const char *name, const char *cmdline, + bootmodule_kind kind, paddr_t start, + bool domU) +{ + /* Not implemented on GENERIC */ + BUG(); +} + +static inline const char *boot_module_kind_as_string(bootmodule_kind kind) +{ + /* Not implemented on GENERIC */ + BUG(); +} + +static inline struct bootcmdline *boot_cmdline_find_by_kind( + bootmodule_kind kind) +{ + /* Not implemented on GENERIC */ + BUG(); +} + +#endif /* __ASM_GENERIC_SETUP_H__ */ --=20 2.30.2 From nobody Sat May 18 12:05:12 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=1702608787; cv=none; d=zohomail.com; s=zohoarc; b=nVQd9hE+yYnJgJzQHpesHTWZ16v8njWZNilUgXgFa3Fg9JNPHnwHw7tQwIsHMXZa70K9e58jslKa2KZIuFT4okVbOYvkMWIZwq9QPmkxgHsRYmgA0pbd8fULf4iDrEZgaZMwpgcpyxl5c0EEo4T2sJk1+aPTSGwSvGon/besezI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702608787; 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=1DibHtcfh6jkTS269svt4kmE2LEah8edNOuQ9qxlV+s=; b=kY9hE2V7DHpqB9BlNbJFQ0oDkbalAiiq8ahZXQ0P/TBhDFeWETF4Kf90ysIpurfhukABf4q3WXszwb4vi6eSf9fCwVgRu7NUKJmLviddL1WvqI5pex0aFub+xSnG8ngQvChX28Aum2wCseAXOLbU/JgDGrI96bpMSuurHgZ1scI= 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 1702608787544426.9488742514295; Thu, 14 Dec 2023 18:53:07 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654838.1022283 (Exim 4.92) (envelope-from ) id 1rDyJi-0003tF-VJ; Fri, 15 Dec 2023 02:52:46 +0000 Received: by outflank-mailman (output) from mailman id 654838.1022283; Fri, 15 Dec 2023 02:52:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDyJi-0003sb-OH; Fri, 15 Dec 2023 02:52:46 +0000 Received: by outflank-mailman (input) for mailman id 654838; Fri, 15 Dec 2023 02:52:45 +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 1rDyJh-0002yh-9g for xen-devel@lists.xenproject.org; Fri, 15 Dec 2023 02:52:45 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 0514dcdf-9af5-11ee-98ea-6d05b1d4d9a1; Fri, 15 Dec 2023 03:52:44 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 8CB878285558; Thu, 14 Dec 2023 20:52:43 -0600 (CST) 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 6BPePTQqDQM2; Thu, 14 Dec 2023 20:52:42 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id E70A78286129; Thu, 14 Dec 2023 20:52:41 -0600 (CST) 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 7y2vHdqhNRYr; Thu, 14 Dec 2023 20:52:41 -0600 (CST) Received: from raptor-ewks-026.2lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id 560CE8286790; Thu, 14 Dec 2023 20:52:41 -0600 (CST) 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: 0514dcdf-9af5-11ee-98ea-6d05b1d4d9a1 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com E70A78286129 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1702608761; bh=1DibHtcfh6jkTS269svt4kmE2LEah8edNOuQ9qxlV+s=; h=From:To:Date:Message-Id:MIME-Version; b=uJ6J6of4YCWZ2BvZaBL42Zh0KGb+aS3r7OPWFmBNtTCNdvcnahgouNKeSv7eW0ozq VBXLk3LeAj8szrkuI5r76Dq/RQtRttaZqj1Fnog43orLBoLQMbCfmQFzTtuigW2HnO qbcnOAMEQn8OCxKio8Bc3GTNEmzZkOhXwxwr8N5I= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: Timothy Pearson , Jan Beulich , Shawn Anastasio , Julien Grall Subject: [PATCH v2 3/7] xen/common: Move Arm's bootfdt to common Date: Thu, 14 Dec 2023 20:43:58 -0600 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: 1702608787887100001 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. Only a minor change to conditionalize a call to a function only available on EFI-supporting targets was made to the code itself. Suggested-by: Julien Grall Signed-off-by: Shawn Anastasio Acked-by: Julien Grall --- xen/arch/arm/Makefile | 1 - xen/common/Makefile | 1 + xen/common/device-tree/Makefile | 1 + xen/{arch/arm =3D> common/device-tree}/bootfdt.c | 15 +++++++++------ 4 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 xen/common/device-tree/Makefile rename xen/{arch/arm =3D> common/device-tree}/bootfdt.c (98%) diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 33c677672f..64fdf84170 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 =20 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/Makefile b/xen/common/Makefile index 69d6aa626c..6e175626d5 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -77,6 +77,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..66c2500df9 --- /dev/null +++ b/xen/common/device-tree/Makefile @@ -0,0 +1 @@ +obj-y +=3D bootfdt.init.o diff --git a/xen/arch/arm/bootfdt.c b/xen/common/device-tree/bootfdt.c similarity index 98% rename from xen/arch/arm/bootfdt.c rename to xen/common/device-tree/bootfdt.c index f496a8cf94..ae9fa1e3d6 100644 --- a/xen/arch/arm/bootfdt.c +++ b/xen/common/device-tree/bootfdt.c @@ -431,12 +431,15 @@ static int __init early_scan_node(const void *fdt, { int rc =3D 0; =20 - /* - * If Xen has been booted via UEFI, the memory banks are - * populated. So we should skip the parsing. - */ - if ( !efi_enabled(EFI_BOOT) && - device_tree_node_matches(fdt, node, "memory") ) + if ( device_tree_node_matches(fdt, node, "memory") ) +#if defined(CONFIG_ARM_EFI) + /* + * If Xen has been booted via UEFI, the memory banks are + * populated. So we should skip the parsing. + */ + if ( efi_enabled(EFI_BOOT) ) + return rc; +#endif rc =3D process_memory_node(fdt, node, name, depth, address_cells, size_cells, &bootinfo.mem); else if ( depth =3D=3D 1 && !dt_node_cmp(name, "reserved-memory") ) --=20 2.30.2 From nobody Sat May 18 12:05:12 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=1702608789; cv=none; d=zohomail.com; s=zohoarc; b=Zso33GCikE0cV1CSYd6eTIdlr7dylRyolbnyOCY8wx9BekBHz9Z3EYPxJ+BJb2L/hpGVAbr3r1+oP0fw5HKqhJgCkHGtynZe3swhittsFQRis+NPI838P4wTE3Rs2o6F3DaCXNrn9vCMJzd96reOGe7F6hM+aMC3QYviyDjewbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702608789; 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=Abuhdt8ZljNVI1itjtnL52V9CIwnwao7c1+uXWvjbAk=; b=RxbMfagkD5fwPRC4Z1joH2EL8Usj+xa4B3B/TW7NVztKgRV5FcLwTB2F2ykYU/TPMOcy5w0m6LYC8jARFpbpygbzEOTnc4kI6hoTWQXHeVAh4mkqvDVmXAGJ9MmMIrTn1H5fLB5wM01c4PH1CgkWMkPQBJ/7Ufd8ZzDaU64u53Q= 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 1702608789654277.93064375295194; Thu, 14 Dec 2023 18:53:09 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654839.1022289 (Exim 4.92) (envelope-from ) id 1rDyJj-00041I-EJ; Fri, 15 Dec 2023 02:52:47 +0000 Received: by outflank-mailman (output) from mailman id 654839.1022289; Fri, 15 Dec 2023 02:52:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDyJj-00040J-55; Fri, 15 Dec 2023 02:52:47 +0000 Received: by outflank-mailman (input) for mailman id 654839; Fri, 15 Dec 2023 02:52:46 +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 1rDyJi-0003SX-8s for xen-devel@lists.xenproject.org; Fri, 15 Dec 2023 02:52:46 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 055090b1-9af5-11ee-9b0f-b553b5be7939; Fri, 15 Dec 2023 03:52:44 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id DC6CA82867CC; Thu, 14 Dec 2023 20:52:43 -0600 (CST) 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 hr1Mi86VvOGp; Thu, 14 Dec 2023 20:52:42 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 4A5DC8286790; Thu, 14 Dec 2023 20:52:42 -0600 (CST) 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 kFWfp9NhR9_k; Thu, 14 Dec 2023 20:52:42 -0600 (CST) Received: from raptor-ewks-026.2lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id EBAC282867CE; Thu, 14 Dec 2023 20:52:41 -0600 (CST) 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: 055090b1-9af5-11ee-9b0f-b553b5be7939 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com 4A5DC8286790 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1702608762; bh=Abuhdt8ZljNVI1itjtnL52V9CIwnwao7c1+uXWvjbAk=; h=From:To:Date:Message-Id:MIME-Version; b=CU4MRvuqVnzdeeXxGSnwZpyYynd8karBdYPlpkyNpnMM25lItLZv/ehjmWjsVN8QU 7EUoBnvtsL/2lBvUi3Z7OmgceOjH8JKCBPD5xi8XeeRrMPHnjPkSQCYM2dKlkdH4ip k1wYpTcWTehLvNZxtSzUdDbTQxK8jk1sYeMRWVvs= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: Timothy Pearson , Jan Beulich , Shawn Anastasio Subject: [PATCH v2 4/7] xen/device-tree: Fix bootfdt.c to tolerate 0 reserved regions Date: Thu, 14 Dec 2023 20:43:59 -0600 Message-Id: <1c6f0f94f4ea2b773f960d88bd02e2168ac28abb.1702607884.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: 1702608789952100001 Content-Type: text/plain; charset="utf-8" The early_print_info routine in bootfdt.c incorrectly stores the result of a call to fdt_num_mem_rsv() in an unsigned int, which results in the negative error code being interpreted incorrectly in a subsequent loop in the case where the device tree does not contain any memory reserve map entries. Signed-off-by: Shawn Anastasio --- xen/common/device-tree/bootfdt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xen/common/device-tree/bootfdt.c b/xen/common/device-tree/boot= fdt.c index ae9fa1e3d6..796ac01c18 100644 --- a/xen/common/device-tree/bootfdt.c +++ b/xen/common/device-tree/bootfdt.c @@ -466,7 +466,8 @@ static void __init early_print_info(void) struct meminfo *mem_resv =3D &bootinfo.reserved_mem; struct bootmodules *mods =3D &bootinfo.modules; struct bootcmdlines *cmds =3D &bootinfo.cmdlines; - unsigned int i, j, nr_rsvd; + unsigned int i, j; + int nr_rsvd; =20 for ( i =3D 0; i < mi->nr_banks; i++ ) printk("RAM: %"PRIpaddr" - %"PRIpaddr"\n", @@ -481,7 +482,7 @@ static void __init early_print_info(void) boot_module_kind_as_string(mods->module[i].kind)); =20 nr_rsvd =3D fdt_num_mem_rsv(device_tree_flattened); - for ( i =3D 0; i < nr_rsvd; i++ ) + for ( i =3D 0; nr_rsvd > 0 && i < nr_rsvd; i++ ) { paddr_t s, e; =20 --=20 2.30.2 From nobody Sat May 18 12:05:12 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=1702608797; cv=none; d=zohomail.com; s=zohoarc; b=XWo1ujBX8RnLsXQ4G5SMji6f+5JgEtuaJA7UlGduwybKL64tJjUoPVUaSag8IT3/wl6x6Zt5NBYVqvFfCh7xBLDVYdDulshyynZhGw5+axwtgmfL1PBVuGemaXQpLBKOccTmnxqKcGea/U7rxi1lwXWB6Nk1oQ1Li3Fyo3oBg/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702608797; 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=3Xu8/TjCiVl92nD/llN9P4dPFGZtJ2QZdU92pz36pYM=; b=VMGiTwcAYLmqXboQbMCdXmi7zU6UqJF8ii5SHPvxGYsJOTDcmTeZ5xy/usAiJf43hdJK25B/tOuPKtF/mqvK/25UKzDVCglVIn+4idC/aB9rmBlC4Vkg5gqhb9WjU/rg/E/xpWC6InXNypU4UK+CZD2DXEUzR7OZmyC4xrVD/bs= 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 1702608797291297.2411796018041; Thu, 14 Dec 2023 18:53:17 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654842.1022314 (Exim 4.92) (envelope-from ) id 1rDyJl-0004cg-NX; Fri, 15 Dec 2023 02:52:49 +0000 Received: by outflank-mailman (output) from mailman id 654842.1022314; Fri, 15 Dec 2023 02:52:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDyJl-0004aU-9p; Fri, 15 Dec 2023 02:52:49 +0000 Received: by outflank-mailman (input) for mailman id 654842; Fri, 15 Dec 2023 02:52:48 +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 1rDyJk-0003SX-0U for xen-devel@lists.xenproject.org; Fri, 15 Dec 2023 02:52:48 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 061f4984-9af5-11ee-9b0f-b553b5be7939; Fri, 15 Dec 2023 03:52:46 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 45D8D8285558; Thu, 14 Dec 2023 20:52:45 -0600 (CST) 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 yuWOP8qUYRU7; Thu, 14 Dec 2023 20:52:43 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id CA45E8286129; Thu, 14 Dec 2023 20:52:43 -0600 (CST) 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 xn56w4kR2ohd; Thu, 14 Dec 2023 20:52:42 -0600 (CST) Received: from raptor-ewks-026.2lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id 5084F828681E; Thu, 14 Dec 2023 20:52:42 -0600 (CST) 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: 061f4984-9af5-11ee-9b0f-b553b5be7939 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com CA45E8286129 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1702608763; bh=3Xu8/TjCiVl92nD/llN9P4dPFGZtJ2QZdU92pz36pYM=; h=From:To:Date:Message-Id:MIME-Version; b=uyU20zW6m5aTv0JL3JQKQdyQ3ZEscKEtx/l4PeeC8JYmUU62Pj2YQ+/7JZm/TChh9 cHQgAwQ7f4Rp55d70fiReLcQIDACi9C1wqA3dyUnj3wM5NiWj2TTz/w7zoCy88Dt4U FaDivOUHuU3syEyLX0+dPnwhsa05clvUSVviA2X4= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: Timothy Pearson , Jan Beulich , Shawn Anastasio Subject: [PATCH v2 5/7] xen/ppc: Enable bootfdt and boot allocator Date: Thu, 14 Dec 2023 20:44:00 -0600 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: 1702608798005100001 Content-Type: text/plain; charset="utf-8" Move PPC off the asm-generic setup.h and 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. Also includes a minor change to record Xen's correct position on PPC where Xen relocates itself to at the entrypoint. Signed-off-by: Shawn Anastasio --- xen/arch/ppc/include/asm/Makefile | 1 - xen/arch/ppc/include/asm/setup.h | 123 +++++++++++++ xen/arch/ppc/setup.c | 289 +++++++++++++++++++++++++++++- xen/common/device-tree/bootfdt.c | 25 ++- 4 files changed, 434 insertions(+), 4 deletions(-) create mode 100644 xen/arch/ppc/include/asm/setup.h diff --git a/xen/arch/ppc/include/asm/Makefile b/xen/arch/ppc/include/asm/M= akefile index 7167661f86..a711cfa856 100644 --- a/xen/arch/ppc/include/asm/Makefile +++ b/xen/arch/ppc/include/asm/Makefile @@ -6,6 +6,5 @@ generic-y +=3D iocap.h generic-y +=3D paging.h generic-y +=3D percpu.h generic-y +=3D random.h -generic-y +=3D setup.h generic-y +=3D static-shmem.h generic-y +=3D vm_event.h diff --git a/xen/arch/ppc/include/asm/setup.h b/xen/arch/ppc/include/asm/se= tup.h new file mode 100644 index 0000000000..c0f700fc07 --- /dev/null +++ b/xen/arch/ppc/include/asm/setup.h @@ -0,0 +1,123 @@ +#ifndef __ASM_PPC_SETUP_H__ +#define __ASM_PPC_SETUP_H__ + +#define max_init_domid (0) + +#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; + +/* + * setup.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 * __init boot_cmdline_find_by_kind(bootmodule_kind kind= ); + +/* + * 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..143f2e449e 100644 --- a/xen/arch/ppc/setup.c +++ b/xen/arch/ppc/setup.c @@ -1,16 +1,296 @@ /* 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); =20 +struct bootinfo __initdata bootinfo; + +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); +} + +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; +} + +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"; + default: BUG(); + } +} + +/* + * 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_star= t, + region_end, i, mod_start, mod_end); + return true; + } + } + + return false; +} + +/* + * 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_sta= rt, + region_end, i, bank_start, bank_end); + return true; + } + } + + return false; +} + +/* + * 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; + + return false; +} + +/* + * 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; +} + +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; + + for ( i =3D 0 ; i < bootinfo.reserved_mem.nr_banks; i++ ) + { + paddr_t r_s =3D bootinfo.reserved_mem.bank[i].start; + paddr_t r_e =3D r_s + bootinfo.reserved_mem.bank[i].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); +} + +/* + * 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; +} + +/* + * Populate the boot allocator. Based on arch/arm/setup.c's + * populate_boot_allocator. + * All RAM but the following regions will be added to the boot allocator: + * - Modules (e.g., Xen, Kernel) + * - Reserved regions + */ +static void __init populate_boot_allocator(void) +{ + unsigned int i; + const struct meminfo *banks =3D &bootinfo.mem; + paddr_t s, e; + + 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; + + dt_unreserved_regions(s, e, init_boot_pages, 0); + + s =3D n; + } + } +} + void setup_exceptions(void) { unsigned long lpcr; @@ -24,6 +304,8 @@ void __init noreturn start_xen(unsigned long r3, unsigne= d long r4, unsigned long r5, unsigned long r6, unsigned long r7) { + void *boot_fdt; + if ( r5 ) { /* Unsupported OpenFirmware boot protocol */ @@ -32,11 +314,16 @@ void __init noreturn start_xen(unsigned long r3, unsig= ned 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 + boot_fdt_info(boot_fdt, r3); + + 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 796ac01c18..7ddfcc7e2a 100644 --- a/xen/common/device-tree/bootfdt.c +++ b/xen/common/device-tree/bootfdt.c @@ -543,12 +543,33 @@ 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((void *)fdt, 0, early_scan_node, NUL= L); 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); + + /* + * Xen relocates itself at the ppc64 entrypoint, so we need to manuall= y mark + * the kernel module. + */ + if ( IS_ENABLED(CONFIG_PPC64) ) { + paddr_t xen_start, xen_end; + + xen_start =3D __pa(_start); + xen_end =3D PAGE_ALIGN(__pa(_end)); + if ( !add_boot_module(BOOTMOD_XEN, xen_start, xen_end, false) ) + panic("Xen overlaps reserved memory! %016lx - %016lx\n", xen_s= tart, + xen_end); + } + /* * 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 18 12:05:12 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=1702608788; cv=none; d=zohomail.com; s=zohoarc; b=DJ3V7Qc4K1kamSaURAYcqJDWg5pldYyrDWnafThufLjaYjbvjDuKiXK1CPFtqkBvv0t9Rc00pQCI6qZQLedqO7MFL8FxgZaYDt7tuPf9YYUoDwdss47dJka1pMLF05Vzf8IBsbFO8knR/qHAY/yKAldvxh390YciU2hAHYyoJyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702608788; 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=PTGVv84Ek2dEZO/cpvmXSIJIyqcsMRVxyQ3qXqyT7ic=; b=cixEgLSUaySxbgmBvH+RCPdzcs21U7It/Ygih3iKIAfuZHKyBtKOk5Wde+T59DjD+ATNcHXLRUKEH64qMx1BE7STlqkFLBoxzIe95axhdrmREwS9nVNyQ7Q6ptnxxh7AKO3geV79BJ7ji4dPhHEO5yWPNQx9NsrbZyh3xh8u/uQ= 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 1702608788380387.6711871680727; Thu, 14 Dec 2023 18:53:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654841.1022303 (Exim 4.92) (envelope-from ) id 1rDyJk-0004Or-Ll; Fri, 15 Dec 2023 02:52:48 +0000 Received: by outflank-mailman (output) from mailman id 654841.1022303; Fri, 15 Dec 2023 02:52:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDyJk-0004Ld-Gz; Fri, 15 Dec 2023 02:52:48 +0000 Received: by outflank-mailman (input) for mailman id 654841; Fri, 15 Dec 2023 02:52:46 +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 1rDyJi-0003SX-Fr for xen-devel@lists.xenproject.org; Fri, 15 Dec 2023 02:52:46 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 05535a5c-9af5-11ee-9b0f-b553b5be7939; Fri, 15 Dec 2023 03:52:44 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id E120F82869E4; Thu, 14 Dec 2023 20:52:43 -0600 (CST) 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 gRVHeYDAcCqB; Thu, 14 Dec 2023 20:52:43 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id F32ED8285AE9; Thu, 14 Dec 2023 20:52:42 -0600 (CST) 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 VVV1gIaDpdrw; Thu, 14 Dec 2023 20:52:42 -0600 (CST) Received: from raptor-ewks-026.2lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id 9FEE482867CC; Thu, 14 Dec 2023 20:52:42 -0600 (CST) 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: 05535a5c-9af5-11ee-9b0f-b553b5be7939 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com F32ED8285AE9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1702608763; bh=PTGVv84Ek2dEZO/cpvmXSIJIyqcsMRVxyQ3qXqyT7ic=; h=From:To:Date:Message-Id:MIME-Version; b=V0JrNFGfk5JrqXkpR+jqEi4H74pr+w7xYdb92PDe3Urjo6d9f0+T35wmhoE7PEdoy QTo2NeHHFS2lnU6VSkyQraMkSmMuEzqeDzftVTA9CM1F/E2HYl+fW1xU4J1L+elrod hEIhmXDgVs5bGs1jltTtnGREmEl51LPpNZEbCuyM= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: Timothy Pearson , Jan Beulich , Shawn Anastasio Subject: [PATCH v2 6/7] xen/ppc: mm-radix: Replace debug printing code with printk Date: Thu, 14 Dec 2023 20:44:01 -0600 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: 1702608789967100003 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 --- 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..de181cf6f1 100644 --- a/xen/arch/ppc/mm-radix.c +++ b/xen/arch/ppc/mm-radix.c @@ -15,6 +15,12 @@ =20 void enable_mmu(void); =20 +#ifdef NDEBUG +#define radix_dprintk(...) +#else +#define radix_dprintk(msg, ...) printk(XENLOG_DEBUG msg, ## __VA_ARGS__) +#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++]; } =20 -#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; =20 - 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; } =20 *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 { --=20 2.30.2 From nobody Sat May 18 12:05:12 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=1702608788; cv=none; d=zohomail.com; s=zohoarc; b=DZzPGIXWege4DZuHPNfs/fUs8iYeYcJOGawhcshLtXpooOX58hetHMgDOD5IM+uSHaoAz3KKIXCXQosDCblOhwbx+W9MZFZXcSc47IgnuZRIPcpT/c7OeoMDMZ6mpbj4KdZgT+9GoN4AEXgKX1ILVDYYUP1icLUo1W/kQk6Zg7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702608788; 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=omGeWwxxs1EefNj9oLx+tt5P0J41D7DMHK4/6rhqXn8=; b=B2W0wLxzd2Z/iVHbeH9TQH/pRcer01JypQQis05iCeBLULz6XDvmngTuuJ8zeKB9XRPBOB4RmpnSTcV58yyle2fzt1zqLa3VENucUDexUx0hRr//Ul66f1uzVZcGGHtSRuyoPRQc7aPp7R1aY0ZFckNMDNBo0CKX2kKg3Nf4lj4= 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 1702608788808513.1660553649508; Thu, 14 Dec 2023 18:53:08 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.654840.1022297 (Exim 4.92) (envelope-from ) id 1rDyJk-0004CF-0D; Fri, 15 Dec 2023 02:52:48 +0000 Received: by outflank-mailman (output) from mailman id 654840.1022297; Fri, 15 Dec 2023 02:52:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rDyJj-00048m-NM; Fri, 15 Dec 2023 02:52:47 +0000 Received: by outflank-mailman (input) for mailman id 654840; Fri, 15 Dec 2023 02:52:46 +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 1rDyJi-0002yh-Et for xen-devel@lists.xenproject.org; Fri, 15 Dec 2023 02:52:46 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 05c8c75b-9af5-11ee-98ea-6d05b1d4d9a1; Fri, 15 Dec 2023 03:52:45 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id C21728285463; Thu, 14 Dec 2023 20:52:44 -0600 (CST) 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 0f5zos89AOXS; Thu, 14 Dec 2023 20:52:44 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id DDA77828698C; Thu, 14 Dec 2023 20:52:43 -0600 (CST) 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 rDbIojDsXB3J; Thu, 14 Dec 2023 20:52:43 -0600 (CST) Received: from raptor-ewks-026.2lan (5.edge.rptsys.com [23.155.224.38]) by mail.rptsys.com (Postfix) with ESMTPSA id E2FB182868E0; Thu, 14 Dec 2023 20:52:42 -0600 (CST) 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: 05c8c75b-9af5-11ee-98ea-6d05b1d4d9a1 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com DDA77828698C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1702608763; bh=omGeWwxxs1EefNj9oLx+tt5P0J41D7DMHK4/6rhqXn8=; h=From:To:Date:Message-Id:MIME-Version; b=JycP26csV4eCNTiWpwYj0UO1/1zMIq/ZdY4Vho8OAcEWRnTNRR0fasALiSnxiJFiE AY1j+f/dhj3GBPqFEIVY8OuFoU4UGnoErZPCda9BL732szXoFY5Qg0YZJnE34oucvV KVfpHH8JjwtSPDcggbVfGm/W5+l4w+QoEWSiBDAk= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: Timothy Pearson , Jan Beulich , Shawn Anastasio Subject: [PATCH v2 7/7] xen/ppc: mm-radix: Allocate Partition and Process Tables at runtime Date: Thu, 14 Dec 2023 20:44:02 -0600 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: 1702608789996100004 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 were allocated statically since the boot allocator was not yet available. Now that it is, allocate these tables at runtime and bump the size of the Process Table to its maximum supported value (on POWER9). Also bump the number of static LVL2/3 PD frames to tolerate cases where the boot allocator returns an address outside of the range of the LVL2 frame used for Xen. Signed-off-by: Shawn Anastasio --- Changes in v2: - Bump LVL2/3 PD count to 3 to avoid running out in case the boot allocator returns a suitably high address. xen/arch/ppc/mm-radix.c | 169 +++++++++++++++++++++++----------------- 1 file changed, 97 insertions(+), 72 deletions(-) diff --git a/xen/arch/ppc/mm-radix.c b/xen/arch/ppc/mm-radix.c index de181cf6f1..e5604d8fb3 100644 --- a/xen/arch/ppc/mm-radix.c +++ b/xen/arch/ppc/mm-radix.c @@ -22,7 +22,7 @@ void enable_mmu(void); #endif #define INITIAL_LVL1_PD_COUNT 1 -#define INITIAL_LVL2_LVL3_PD_COUNT 2 +#define INITIAL_LVL2_LVL3_PD_COUNT 3 #define INITIAL_LVL4_PT_COUNT 256 static size_t __initdata initial_lvl1_pd_pool_used; @@ -34,17 +34,13 @@ 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 prtb_entry - __aligned(PRTB_SIZE) initial_prtb[PRTB_SIZE / sizeof(struct prtb_entry= )]; +static struct patb_entry *initial_patb; +static struct prtb_entry *initial_prtb; static __init struct lvl1_pd *lvl1_pd_pool_alloc(void) { @@ -86,6 +82,62 @@ static __init struct lvl4_pt *lvl4_pt_pool_alloc(void) return &initial_lvl4_pt_pool[initial_lvl4_pt_pool_used++]; } +static void map_page_initial(struct lvl1_pd *lvl1, vaddr_t virt, paddr_t p= hys, + unsigned long flags) +{ + 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) ) + { + 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)); + + /* Allocate LVL 3 PD if necessary */ + pde =3D pt_entry(lvl2, virt); + if ( !pde_is_valid(*pde) ) + { + lvl3 =3D lvl3_pd_pool_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 lvl4_pt_pool_alloc(); + *pde =3D paddr_to_pde(__pa(lvl4), PDE_VALID, + XEN_PT_ENTRIES_LOG2_LVL_4); + } + else + lvl4 =3D __va(pde_to_paddr(*pde)); + + /* 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, vaddr_t map_start, vaddr_t map_end, @@ -105,80 +157,43 @@ 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) ) - { - lvl4 =3D lvl4_pt_pool_alloc(); - *pde =3D paddr_to_pde(__pa(lvl4), PDE_VALID, - XEN_PT_ENTRIES_LOG2_LVL_4); - } - 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) ) + else if ( is_kernel_rodata(page_addr) ) { - 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); + radix_dprintk("%016lx being marked as RODATA (RO)\n", page_add= r); + flags =3D PTE_XEN_RO; } 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); + } + + /* Map runtime-allocated PATB, PRTB */ + for ( page_addr =3D (uint64_t)initial_patb; + page_addr < (uint64_t)initial_patb + PATB_SIZE; + page_addr +=3D PAGE_SIZE ) + { + map_page_initial(lvl1, page_addr, __pa(page_addr), PTE_XEN_RW); + } + + for ( page_addr =3D (uint64_t)initial_prtb; + page_addr < (uint64_t)initial_prtb + PRTB_SIZE; + page_addr +=3D PAGE_SIZE ) + { + map_page_initial(lvl1, page_addr, __pa(page_addr), PTE_XEN_RW); } } @@ -210,6 +225,16 @@ void __init setup_initial_pagetables(void) { struct lvl1_pd *root =3D lvl1_pd_pool_alloc(); unsigned long lpcr; + mfn_t patb_mfn, prtb_mfn; + + /* Allocate mfns for in-memory tables using the boot allocator */ + prtb_mfn =3D alloc_boot_pages(PRTB_SIZE / PAGE_SIZE, + max(1, PRTB_SIZE_LOG2 - PAGE_SHIFT)); + patb_mfn =3D alloc_boot_pages(PATB_SIZE / PAGE_SIZE, + max(1, PATB_SIZE_LOG2 - PAGE_SHIFT)); + + initial_patb =3D __va(mfn_to_maddr(patb_mfn)); + initial_prtb =3D __va(mfn_to_maddr(prtb_mfn)); setup_initial_mapping(root, (vaddr_t)_start, (vaddr_t)_end, __pa(_star= t)); -- 2.30.2