Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1mmtnC-0003gP-1J for mharc-grub-devel@gnu.org; Tue, 16 Nov 2021 03:26:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmtnA-0003cl-1c for grub-devel@gnu.org; Tue, 16 Nov 2021 03:26:12 -0500 Received: from de-smtp-delivery-102.mimecast.com ([194.104.111.102]:52913) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mmtn5-0005dd-Gm for grub-devel@gnu.org; Tue, 16 Nov 2021 03:26:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=mimecast20200619; t=1637051164; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=uXAyd2fO4v0I/CgVxuqnbUyMEVhb5EkxqL6KyM3dZOU=; b=MFyGR9y+LiCRNDg7i+f2TsBVtT6KYraNnlzg6f7aXbrvRDxCLwBxXG2ibyerf28Og33fOs UPpfZVmomxFbsRS66x+S4/gL4Vh2P88meRv/mqJXYS8w48mzHH+FZ/yRZXW3apiLQha31j 0008YCv84lCFcZLSAM77PRIqo190mCc= Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05lp2112.outbound.protection.outlook.com [104.47.18.112]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-36-vL4fd6ShOyiK6SCx03swnQ-1; Tue, 16 Nov 2021 09:26:03 +0100 X-MC-Unique: vL4fd6ShOyiK6SCx03swnQ-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SD8wn/wCg6lIneh/CUjot0U8kr1VifEG5+esbpIEHNy7flbmD8KP1WYQBv1II5le98ba/vv98xqb6zH+glrYHdotkQSstfHVwadkIWGl/WNmS0c8xwqzTSapv24qm1HySQHrOaFsvUToVcv6rtbfitoG3nu5cUzNG6cInOxotBvTogJKkeaKSugrIGjfSgFQO7UywcRWY0XfhuDIGIaPcabnO/pM0PxlCgU/vaYXznYim9FDo7N/hGjXoeloRTXtmmsstRPvzmKVE8MIjwBsMMyEDo2kPpREOJPxoV/R8xIR269GfJfqpn9zVkmp/Fr5jcEDZAokI66G72Byf631Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uXAyd2fO4v0I/CgVxuqnbUyMEVhb5EkxqL6KyM3dZOU=; b=NIj5vaOnET9zs1CbdF4KUTRoCrlMnR331yLix6ze60YxqM8amRKY1VKtUc8pDhzytuX0R8+qvzknUSO5vuHIQz++y7r1ufWbm5iwWBPQ2W5kVQOiddkB8hKFuT3JDbuxONIIfBD7C0fy1M2sxyMPMRRTG4EN31Qjqy4zSUnuYa3r3JB+poLxoRJo1UYtEPAfKCYTQwJaOpJEPPMgBcDxzR2Kmnwc8xBpA2Uv4BNsppB3K+onjZCsuKepsDiJD6bDDalD3e2Q2b5foGDGqLCaSH4DYWUvjjtjnEYduSWNivNr81nbHrjykg3D90jP13ghO3N71upGALARQMiEABq6Rg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from DU2PR04MB9081.eurprd04.prod.outlook.com (2603:10a6:10:2f0::13) by DB9PR04MB9281.eurprd04.prod.outlook.com (2603:10a6:10:36f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Tue, 16 Nov 2021 08:26:02 +0000 Received: from DU2PR04MB9081.eurprd04.prod.outlook.com ([fe80::a0d2:ba21:3a3f:6478]) by DU2PR04MB9081.eurprd04.prod.outlook.com ([fe80::a0d2:ba21:3a3f:6478%3]) with mapi id 15.20.4713.019; Tue, 16 Nov 2021 08:26:02 +0000 Date: Tue, 16 Nov 2021 16:25:56 +0800 From: Michael Chang To: The development of GNU GRUB Cc: Daniel Axtens Subject: Re: [PATCH 2/2] ieee1275: set real-base in the PowerPC IEEE1275 Note to 32MB Message-ID: <20211116082556.GB17545@mazu> References: <20211116034205.463101-1-dja@axtens.net> <20211116034205.463101-3-dja@axtens.net> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211116034205.463101-3-dja@axtens.net> User-Agent: Mutt/1.10.1 (2018-07-13) X-ClientProxiedBy: HK0PR01CA0072.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::36) To DU2PR04MB9081.eurprd04.prod.outlook.com (2603:10a6:10:2f0::13) MIME-Version: 1.0 Received: from localhost (2001:b011:30d0:3d0b:6600:6aff:fe77:a7be) by HK0PR01CA0072.apcprd01.prod.exchangelabs.com (2603:1096:203:a6::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27 via Frontend Transport; Tue, 16 Nov 2021 08:26:01 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc9cfe56-9c1f-4285-916a-08d9a8dab9a4 X-MS-TrafficTypeDiagnostic: DB9PR04MB9281: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k/6wNKtpyHxf8TIP5ioGQVrYFvcsDcTCJyq3DInM14XpbtfXMezKLbTv03ngf31gfj3+n4uR7lvARxS74e2JERbbJQQdZwuCnebZYRNIMPydhXlYph3FpkIpmYF7vBjJeSi/TmloZTMDpZ6dDp1NjVNu6xTX/TI5VffSpqhKDxYzSYAgVE1AWIMFicD9WnyOlo+6w3NWn8qZubGvLocFOmaYcXTj6VtSCJLJUNPpJZqdwy3BFecrK0P+JQ7XAxmTe5z9l25jx0K/AA8qiltk8Hn0agquMdSPF2ZNLvS+Vw38rlJdQV6Eo+FxM4H+Gko24KNGnTdCc63bG4rFhiCogH/dFZVdtWsB2sC2cpH3epMoa8UaePiv9mCM0//kWfRVh9fOjO0XLuSQM2HeTbNJ793OkiziOFjUdae6jLgf1oR3ZO0i/2HJoey3zeDr2YHKRJRvOezzU7YnrgzQfSRbjFscKMGyKj1/vN9KsonqQJYwvPGVh5bbZd0XQW/CIx1zOmb8HEJLn9ioh0FfzdWQOW9CVlUDn07zBT3X92lId5VTX77pAz9iqgCOtHNQigBh10YHPlx01mKUGOQanWZUI4YRDQ2GkUw0kkyqoyNylNjWpnCLYfzpTBjdddJcNP/CTAUVvnOEgpPE9FtJlzhuAXluJeFomTPpLY2hPvTlOeFrHlh9FZC9b82a46palbyeSWWeQhcBlUnBMq+SlD8OQdw9Wv7hgYlYfBHzGLDID58= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU2PR04MB9081.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(7916004)(366004)(6916009)(8936002)(4326008)(5660300002)(86362001)(6496006)(6666004)(1076003)(186003)(8676002)(9686003)(83380400001)(6486002)(66556008)(66946007)(966005)(316002)(38100700002)(508600001)(66476007)(33716001)(2906002)(33656002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?w0u83HFNKC8pzbi52GKz0MEo4323ZKVe1yjvmJlSfMB2RYU+8kNhNIo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a17mylUUy7FW+eQJWnKt4AxJU5CGrHSY9?= =?us-ascii?Q?O/IAltqeBFOyvqB0gexOqsmF3Rz/9y8Q1MukY+p5zBieCX6H4F3bETQsZdsD?= =?us-ascii?Q?K667MyYUzoFbxrIUC0z0ioB7vSjD9/X4sECqg1JPGf04NUa5nAzGT+Xt9nQn?= =?us-ascii?Q?J9Fnd66OO5Xd5v88/SofxB5nxoHmocOZB9jOZxReECbxRIdK2H58imhYg5Tm?= =?us-ascii?Q?zkKBcXn+L2GuZ3wq9QkdUK6ib6mDFT8CrS7TAdiVT6cytUbQdxUpLNHLAI7Y?= =?us-ascii?Q?yrKXJzlzY1Z9VNECSdDXTuBB3klAonlPK2111sxuqjAHR85jPgihFObTh9f4?= =?us-ascii?Q?jmqfiKz04SMmzsUe5Is7+b3G0MUC/TZTRGyXDySKmH588EaUPeE8T2KKRNN+?= =?us-ascii?Q?nnSJ99BCsx38arP44R9AfVMqWzpVYuj0zOzXzUwrCHSISIXtVDbMLXFZaNIY?= =?us-ascii?Q?ZqPC7caJo7S819Qs0ePYgnpmo8wklyVKQJZ22pGf0zM/+QuaSVcBaLEMyWGR?= =?us-ascii?Q?iX6wwPu0QI1eKIG9qvPYuf8ib0jJxRLOXpgFHRcIAWBVwuOlEbS5wlozGkRE?= =?us-ascii?Q?UFx1PmUeTEfVyUqKEoYx/87Zuk3IfNHkB3REUJrTd2MjqTSoNeaZ3MRtSt4D?= =?us-ascii?Q?xO4aC+PmBY8EvR8eis3DRSjDoGoXquht5F2LZvdrzgJe+ElOZ2Bb7DCujgow?= =?us-ascii?Q?HIUz+rEmQRVIPPCVoBqFT/U=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc9cfe56-9c1f-4285-916a-08d9a8dab9a4 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB9081.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2021 08:26:02.1379 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pGeo/pv9flKQrb6+U2pEvLR1G5WZh2zjAzL27t5+NwUWMP5WjEJWeTtjn6fYoSWd X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9281 Received-SPF: pass client-ip=194.104.111.102; envelope-from=mchang@suse.com; helo=de-smtp-delivery-102.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Nov 2021 08:26:12 -0000 On Tue, Nov 16, 2021 at 02:42:05PM +1100, Daniel Axtens wrote: > Background > ---------- > > Figuring out how to lay out memory in powerpc OpenFirmware is a bit > of a complicate dance. > > Firstly, firmware needs to reserve a little bit of space for things > like interrupt vectors that live at a fixed address. This is usually > 0x4000 bytes. PFW calls this "stage 1" (of the firmware, not the > bootloader!) > > As discussed in the previous patch, the ELF image is loaded at > 'load-base' before it's unpacked. load-base is, by default, set at the > end of stage 1. From there, the ELF loader unpacks the binary to > wherever the program headers say and the program is executed. > > Next in memory, we need space for the rest of firmware. (PFW calls > this "stage 2" of firmware.) The starting address begins at > 'real-base'.* We need to not run past real-base when loading our ELF > binary. > > load-base and real-base have defaults from firmware, and may be > configurable in various ways. > > On PFW: > > - real-base defaults to 12MB (0xc00000) > > - real-base is configurable with the IEEE1275 ELF note. > > - a proprietary OS bootloader configures real-base to > 0x2000000 (32MB). > > On SLOF: > > - real-base is set dynamically towards the end of accessible memory. > > - real-base is not configurable. > > On 32-bit, I'm not sure quite what the story is. I don't have any > 32-bit Apple hardware to test with. However, with this change, grub > still loads and runs, including when I hack up the tests to install > the note by default. > > * I'm assuming here that the firmware doesn't do virtual mode. This is > true on Power for both PFW and SLOF; Apple OF implementations may do > things differently. > > Moving real-base > ---------------- > > To account for growing grub binary sizes, we want to try to expand the > amount of memory that we have to work with. We have the following > constraints and inputs: > > - A good practical limit for the size of the grub binary is 8MB, as > that's about the size of the PReP partition on a number of distro > setups. (See previous patch.) > > - We also want things to work if people forget to include the > note. Even if distros build it in to signed images, people > running grub-install will probably forget to set it and we don't > want to break their systems. (Helpfully, if you're running > grub-install manually there's a decent chance you're not building > in a bunch of modules so things are likely to be smaller anyway.) > > - We want to avoid doing anything too novel with enterprise software. > > So when the note is included, set real-base to 32MB. > > Results > ------- > > This means that: > > - The ELF file will be loaded at 0x4000 and have just short of 8MB to > fit into. (This is entirely the work of the previous patch - the > 8MB limitation is because we now load at 8MB instead of 2MB.) > > - Nothing changes on SLOF, because SLOF ignores the note. We have > oodles of space in SLOF. > > - On PFW when the note is not installed, we have about 4MB of space > for ELF loader to put the program into (the gap between 8MB and the > default real-base of 12MB). This is well more than any current grub > image uses. > > - On PFW when the note _is_ installed, we will have about 24MB of > space to put the program bits into. This is well more than we're > likely to use unless people start putting very large arrays in BSS, > but it means we're aligned with a proprietary bootloader and > therefore we can be assured that some testing has been done. May I ask why 'proprietary' is used here to describe the usecase ? Does it possess any meaningful words like supportability to the firmware vendor that OS vendor have to think over before enabling the note for a 'general' feature like powerpc secure boot ? Thanks, Michael > > Signed-off-by: Daniel Axtens > --- > util/grub-mkimagexx.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c > index d78fa3e53308..2ac40b82a22d 100644 > --- a/util/grub-mkimagexx.c > +++ b/util/grub-mkimagexx.c > @@ -467,7 +467,7 @@ SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc > note_ptr->header.n_type = grub_host_to_target32 (GRUB_IEEE1275_NOTE_TYPE); > strcpy (note_ptr->name, GRUB_IEEE1275_NOTE_NAME); > note_ptr->descriptor.real_mode = grub_host_to_target32 (0xffffffff); > - note_ptr->descriptor.real_base = grub_host_to_target32 (0x00c00000); > + note_ptr->descriptor.real_base = grub_host_to_target32 (0x02000000); > note_ptr->descriptor.real_size = grub_host_to_target32 (0xffffffff); > note_ptr->descriptor.virt_base = grub_host_to_target32 (0xffffffff); > note_ptr->descriptor.virt_size = grub_host_to_target32 (0xffffffff); > -- > 2.32.0 > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel