From nobody Sun Nov 2 01:48:19 2025 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=1740168562; cv=none; d=zohomail.com; s=zohoarc; b=F5ds6/GlH8Tlq0dYBeVGKlO3ZQfq7MC3yP0wDPUi7aBTnkZBeZ3Rw/WPoGmzA7M+FWjj38lQHR4HHKXMjThY9LuONLYviraqRM0T4jfOfSungxSMtf/e8Gim+0nPN9F47Ndmoztmc/Y8qWQWjKYuumr4hXKzQxm93tPk+3AN9/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1740168562; 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=wn8lAIb9qnZLpvYqwlQ9gH9RYtSwITlSk1VLzVXXQWE=; b=IBj+OQyxjFFQpmMhJJnBBvu2c9CtU+rle0/0C7JEKOBdpOS0kAZ2x1M532q+BIIym1hIM0HZ7eSK1Ph3RyFjLsaV0tkKat7ayZI8rJ7dOZrdtEgTeuDmxJr6BFVwWw+PyJCmbuT454YP7Fnm7+eFJ4xJu5FalPyI4kOLaKfyJz0= 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 1740168562348398.19425672592854; Fri, 21 Feb 2025 12:09:22 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.894564.1303279 (Exim 4.92) (envelope-from ) id 1tlZKI-00049r-4U; Fri, 21 Feb 2025 20:08:46 +0000 Received: by outflank-mailman (output) from mailman id 894564.1303279; Fri, 21 Feb 2025 20:08: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 1tlZKI-00049k-15; Fri, 21 Feb 2025 20:08:46 +0000 Received: by outflank-mailman (input) for mailman id 894564; Fri, 21 Feb 2025 20:08: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 1tlZKG-00049Y-OU for xen-devel@lists.xenproject.org; Fri, 21 Feb 2025 20:08:44 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a5d78a40-f08f-11ef-9aa9-95dc52dad729; Fri, 21 Feb 2025 21:08:43 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id A4B258287311; Fri, 21 Feb 2025 14:08: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 IoAusBhSdU3V; Fri, 21 Feb 2025 14:08:42 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 06C2E8286E9D; Fri, 21 Feb 2025 14:08: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 1xvBLXcQI7-X; Fri, 21 Feb 2025 14:08: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 14A2D8287FBD; Fri, 21 Feb 2025 14:08: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: a5d78a40-f08f-11ef-9aa9-95dc52dad729 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com 06C2E8286E9D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1740168522; bh=wn8lAIb9qnZLpvYqwlQ9gH9RYtSwITlSk1VLzVXXQWE=; h=From:To:Date:Message-Id:MIME-Version; b=E4u8YjjEFSWsgg/qa7TT05uHV5Xtiyuq54A/qovGAWQfr/hDl4tlPKVyD8cwpFhRv aD8faB4NTfq9JOH5kNkjgy60FFiL3SRxM6wQR8gRvwnNNdGp9eW4rjCYBNC2E4d6UC JG6VdPkjKGjaVKTccD+A0MnaH/ti+vqrc4Hh8t5I= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: tpearson@raptorengineering.com, Andrew Cooper , Shawn Anastasio Subject: [PATCH 1/2] xen/ppc: Fix opal.c's misaligned DT reads to avoid tripping UBSAN Date: Fri, 21 Feb 2025 14:08:36 -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: 1740168563399019000 Content-Type: text/plain; charset="utf-8" Fix two misaligned reads from the FDT in the opal setup code to avoid tripping UBSAN failures. Without this change, UBSAN-enabled builds on PPC will fail on boot before the serial console is even initialized. Reported-by: Andrew Cooper Signed-off-by: Shawn Anastasio --- xen/arch/ppc/opal.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/xen/arch/ppc/opal.c b/xen/arch/ppc/opal.c index 1183b7d5ef..3d0e4daf27 100644 --- a/xen/arch/ppc/opal.c +++ b/xen/arch/ppc/opal.c @@ -34,8 +34,9 @@ static void opal_putchar(char c) void __init boot_opal_init(const void *fdt) { int opal_node; - const __be64 *opal_base; - const __be64 *opal_entry; + const __be64 *opal_base_p; + const __be64 *opal_entry_p; + __be64 opal_base, opal_entry; =20 if ( fdt_check_header(fdt) < 0 ) { @@ -54,17 +55,20 @@ void __init boot_opal_init(const void *fdt) die(); } =20 - opal_base =3D fdt_getprop(fdt, opal_node, "opal-base-address", NULL); - opal_entry =3D fdt_getprop(fdt, opal_node, "opal-entry-address", NULL); - if ( !opal_base || !opal_entry ) + opal_base_p =3D fdt_getprop(fdt, opal_node, "opal-base-address", NULL); + opal_entry_p =3D fdt_getprop(fdt, opal_node, "opal-entry-address", NUL= L); + if ( !opal_base_p || !opal_entry_p ) { early_printk("Failed to get opal-base-address/opal-entry-address " "property from DT!\n"); die(); } =20 - opal.base =3D be64_to_cpu(*opal_base); - opal.entry =3D be64_to_cpu(*opal_entry); + memcpy(&opal_base, opal_base_p, sizeof(opal_base)); + memcpy(&opal_entry, opal_entry_p, sizeof(opal_entry)); + + opal.base =3D be64_to_cpu(opal_base); + opal.entry =3D be64_to_cpu(opal_entry); =20 early_printk_init(opal_putchar); =20 --=20 2.30.2