From patchwork Fri Feb 21 20:08:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Anastasio X-Patchwork-Id: 13986232 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2BA4AC021B3 for ; Fri, 21 Feb 2025 20:09:06 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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 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; if ( fdt_check_header(fdt) < 0 ) { @@ -54,17 +55,20 @@ void __init boot_opal_init(const void *fdt) die(); } - opal_base = fdt_getprop(fdt, opal_node, "opal-base-address", NULL); - opal_entry = fdt_getprop(fdt, opal_node, "opal-entry-address", NULL); - if ( !opal_base || !opal_entry ) + opal_base_p = fdt_getprop(fdt, opal_node, "opal-base-address", NULL); + opal_entry_p = fdt_getprop(fdt, opal_node, "opal-entry-address", NULL); + if ( !opal_base_p || !opal_entry_p ) { early_printk("Failed to get opal-base-address/opal-entry-address " "property from DT!\n"); die(); } - opal.base = be64_to_cpu(*opal_base); - opal.entry = 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 = be64_to_cpu(opal_base); + opal.entry = be64_to_cpu(opal_entry); early_printk_init(opal_putchar); From patchwork Fri Feb 21 20:08:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Anastasio X-Patchwork-Id: 13986233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8CF29C021B6 for ; Fri, 21 Feb 2025 20:09:07 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.894566.1303300 (Exim 4.92) (envelope-from ) id 1tlZKK-0004cB-LN; Fri, 21 Feb 2025 20:08:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 894566.1303300; Fri, 21 Feb 2025 20:08: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 1tlZKK-0004c4-Gc; Fri, 21 Feb 2025 20:08:48 +0000 Received: by outflank-mailman (input) for mailman id 894566; Fri, 21 Feb 2025 20:08:47 +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 1tlZKI-00049e-W4 for xen-devel@lists.xenproject.org; Fri, 21 Feb 2025 20:08:46 +0000 Received: from raptorengineering.com (mail.raptorengineering.com [23.155.224.40]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a71eedbd-f08f-11ef-9896-31a8f345e629; Fri, 21 Feb 2025 21:08:45 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id 75222828714E; Fri, 21 Feb 2025 14:08: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 usZ911c4BZFo; Fri, 21 Feb 2025 14:08:44 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by mail.rptsys.com (Postfix) with ESMTP id D75F18286E9D; Fri, 21 Feb 2025 14:08: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 vGHF0shFT-mT; Fri, 21 Feb 2025 14:08: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 78D4A828714E; Fri, 21 Feb 2025 14:08:42 -0600 (CST) 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: a71eedbd-f08f-11ef-9896-31a8f345e629 DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rptsys.com D75F18286E9D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raptorengineering.com; s=B8E824E6-0BE2-11E6-931D-288C65937AAD; t=1740168523; bh=VKiNhIhFzhXjck7mqEqrWgb9EZDd1QiPkU136TnDXEg=; h=From:To:Date:Message-Id:MIME-Version; b=Ic/DoOLWezLMIjPewnE5jrx4iBz7A1FLynpZFyVxSCZyzROgntOiay9e5/RxTQ4Pg afDJXtVlNFjL58m/YtpoC/uRr6H5GrfTlnqwYJYMTP8c2jN6+mylw9UcujL5fF7ay3 pjB7rvYL4ot1iA0f9q2C7q4s32u+yMbBGK4XGyWQ= X-Virus-Scanned: amavisd-new at rptsys.com From: Shawn Anastasio To: xen-devel@lists.xenproject.org Cc: tpearson@raptorengineering.com, Andrew Cooper , Doug Goldstein , Stefano Stabellini , Shawn Anastasio Subject: [PATCH 2/2] PPC: Activate UBSAN in testing Date: Fri, 21 Feb 2025 14:08:37 -0600 Message-Id: <6610afb521d2af1bfe4ad7710e469666d318a0c6.1740168326.git.sanastasio@raptorengineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 From: Andrew Cooper Signed-off-by: Andrew Cooper Signed-off-by: Shawn Anastasio --- Changes from Andrew's v1: - Define dump_execution_state in the same manner as risc-v automation/gitlab-ci/build.yaml | 3 +++ xen/arch/ppc/Kconfig | 1 + xen/arch/ppc/include/asm/processor.h | 2 ++ xen/arch/ppc/stubs.c | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) -- 2.30.2 diff --git a/automation/gitlab-ci/build.yaml b/automation/gitlab-ci/build.yaml index 35e224366f..6a2e491534 100644 --- a/automation/gitlab-ci/build.yaml +++ b/automation/gitlab-ci/build.yaml @@ -352,6 +352,9 @@ debian-12-ppc64le-gcc-debug: CONTAINER: debian:12-ppc64le KBUILD_DEFCONFIG: ppc64_defconfig HYPERVISOR_ONLY: y + EXTRA_XEN_CONFIG: | + CONFIG_UBSAN=y + CONFIG_UBSAN_FATAL=y debian-12-riscv64-gcc-debug: extends: .gcc-riscv64-cross-build-debug diff --git a/xen/arch/ppc/Kconfig b/xen/arch/ppc/Kconfig index 6db575a48d..917f5d53a6 100644 --- a/xen/arch/ppc/Kconfig +++ b/xen/arch/ppc/Kconfig @@ -2,6 +2,7 @@ config PPC def_bool y select FUNCTION_ALIGNMENT_4B select HAS_DEVICE_TREE + select HAS_UBSAN select HAS_VMAP config PPC64 diff --git a/xen/arch/ppc/include/asm/processor.h b/xen/arch/ppc/include/asm/processor.h index a01b62b8a4..50161cc32d 100644 --- a/xen/arch/ppc/include/asm/processor.h +++ b/xen/arch/ppc/include/asm/processor.h @@ -219,6 +219,8 @@ static inline void noreturn die(void) */ #define cpu_relax() asm volatile ( "or %r1, %r1, %r1; or %r2, %r2, %r2" ) +#define dump_execution_state() run_in_exception_handler(show_execution_state) + #endif /* __ASSEMBLY__ */ #endif /* _ASM_PPC_PROCESSOR_H */ diff --git a/xen/arch/ppc/stubs.c b/xen/arch/ppc/stubs.c index fff82f5cf3..671e71aa0a 100644 --- a/xen/arch/ppc/stubs.c +++ b/xen/arch/ppc/stubs.c @@ -47,7 +47,7 @@ void send_timer_event(struct vcpu *v) void show_execution_state(const struct cpu_user_regs *regs) { - BUG_ON("unimplemented"); + printk("TODO: Implement show_execution_state(regs)\n"); } void arch_hypercall_tasklet_result(struct vcpu *v, long res)