From patchwork Sat Feb 8 00:02:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13966112 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 607A2C021A2 for ; Sat, 8 Feb 2025 00:05:19 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.884153.1293957 (Exim 4.92) (envelope-from ) id 1tgYLL-0001oL-0M; Sat, 08 Feb 2025 00:05:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 884153.1293957; Sat, 08 Feb 2025 00:05:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tgYLK-0001oE-Tv; Sat, 08 Feb 2025 00:05:06 +0000 Received: by outflank-mailman (input) for mailman id 884153; Sat, 08 Feb 2025 00:05:05 +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 1tgYLJ-0001YL-Nm for xen-devel@lists.xenproject.org; Sat, 08 Feb 2025 00:05:05 +0000 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [2a00:1450:4864:20::343]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 58dcfaea-e5b0-11ef-b3ef-695165c68f79; Sat, 08 Feb 2025 01:05:04 +0100 (CET) Received: by mail-wm1-x343.google.com with SMTP id 5b1f17b1804b1-4361e89b6daso17507345e9.3 for ; Fri, 07 Feb 2025 16:05:04 -0800 (PST) Received: from andrewcoop.eng.citrite.net (host-92-26-98-202.as13285.net. [92.26.98.202]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391da9656fsm72336295e9.3.2025.02.07.16.05.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 16:05:02 -0800 (PST) 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: 58dcfaea-e5b0-11ef-b3ef-695165c68f79 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1738973103; x=1739577903; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l/JTU8E7ncqUSv3tjrzaMPmZsR3+I1KsMdSHHDijONc=; b=Xkikaa9yYEnU/n6l3n1SxpntCOvvsBOkOtsFwUHn1wDn6KBtGbJxVw9k2P+HwU+ARy uFAqVe168IBR0UWgybK/x9qZ2mF5fqu1a1rvpkGD/pz3qOqSCg/D1mUQqesOIc5oMveA uqKfL8/tFB+rojacaGZJrcaFptDEuvkKPWu08= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738973103; x=1739577903; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l/JTU8E7ncqUSv3tjrzaMPmZsR3+I1KsMdSHHDijONc=; b=dY7y43qrAcYNp1EIO26kkSlcGpwb7zXK+vRxsbdOd7B8FFKLiMSGZhO3eyu1mXvLYs szBdT9XUEO6gAEUSNFSZ1vjixSirCwJojuT2ohGyQmOGS2Gy3pMCuHkKfiZ2unJH15ia rGZdj3w8u9L7LHSOullIqoJNgKOWkAkYOEFzA27UxLlLyNgjFOXfGQMWN3YVMy5YtHMR kyGuuGZQYqJRL0BNkVvGP6S0yeJutGq2xDnxN4RpAaD8K1ItxQuL2RZssj2llKFh4+yr XNIksVFmz7DWxmS+1wYFf0AK/B8HKmosOxN78TWxpOdJvj74Eb9yOs67G/retnlipeTF f90g== X-Gm-Message-State: AOJu0YxpX+hk5H72erN8MlgwbQOx63a9wdZDOYZ30F2E6rluDLnYe67q BB0ge+99tbUUllgp/7y5pq69p7l5AtvMANXeoRZGDiokuyRkENPX/ldI2vA5MOm28od7/HANCEf 0S8w9ng== X-Gm-Gg: ASbGnctyn9r8ni21hC5XJDhdrS0t5ciSst24hhjcXv9lRoRvl1DCSUMbjZHTR9plYFU dxR11wBZlgOtIyQB4P+KeU7Ownz1mulfLAEjOEZMquKrfjjtyaFvBVKI44O/nuAo9fYFR1vyMM5 XPVDBxRpBKmOTQ7urjywM+d/zcb9U7L//lVVCcjBIBkprvl5kfWTUjeyAWPyxfNxXQ2bgnb0/Cq lakOsaOStZFZNuQZsvV3O+Dauc/vf3glIvE8D2XbhOV1pFMN/xGpEizhP4QBMWLzvCzgLVALYbx Q/HdqUAFjyCGEe7al9QtfGRcI7WTPl6euynyf70SbCnx2Ju8gImXWx2EgHoXj5Nnvfu1uVM= X-Google-Smtp-Source: AGHT+IHYvycWEUIGEKe3t6G6gShQYPPQiohc3YZiKSG34e+e0c3zYqEPjfHn8RpER53bOkVXxkEPTA== X-Received: by 2002:a05:600c:c19:b0:434:a386:6ae with SMTP id 5b1f17b1804b1-439249842bamr44251245e9.7.1738973103303; Fri, 07 Feb 2025 16:05:03 -0800 (PST) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko Subject: [PATCH for-4.20? 1/4] ARM32/traps: Fix do_trap_undefined_instruction()'s detection of kernel text Date: Sat, 8 Feb 2025 00:02:53 +0000 Message-Id: <20250208000256.431883-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250208000256.431883-1-andrew.cooper3@citrix.com> References: <20250208000256.431883-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 While fixing some common/arch boundaries for UBSAN support on other architectures, the following debugging patch: diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index c1f2d1b89d43..58d1d048d339 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -504,6 +504,8 @@ void asmlinkage __init start_xen(unsigned long fdt_paddr) system_state = SYS_STATE_active; + dump_execution_state(); + for_each_domain( d ) domain_unpause_by_systemcontroller(d); fails with: (XEN) *** Serial input to DOM0 (type 'CTRL-a' three times to switch input) (XEN) CPU0: Unexpected Trap: Undefined Instruction (XEN) ----[ Xen-4.20-rc arm32 debug=n Not tainted ]---- (XEN) CPU: 0 (XEN) (XEN) **************************************** (XEN) Panic on CPU 0: (XEN) CPU0: Unexpected Trap: Undefined Instruction (XEN) **************************************** This is because the condition for init text is wrong. While there's nothing interesting from that point onwards in start_xen(), it's also wrong for any livepatch which brings in an adjusted BUG_FRAME(). Use is_active_kernel_text() which is the correct test for this purpose, and is aware of init and livepatch regions too. Commit c8d4b6304a5e ("xen/arm: add support for run_in_exception_handler()"), made run_in_exception_handler() work, but didn't complete the TODO left in commit 3e802c6ca1fb ("xen/arm: Correctly support WARN_ON"). Do so, to make ARM consistent with other architectures. Fixes: 3e802c6ca1fb ("xen/arm: Correctly support WARN_ON") Signed-off-by: Andrew Cooper Reviewed-by: Michal Orzel --- CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel CC: Oleksii Kurochko Sample run going wrong: https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/9078570105 Sample run with dump_execution_state() working: https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/9079185111 --- xen/arch/arm/arm32/traps.c | 3 +-- xen/arch/arm/include/asm/processor.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/arm32/traps.c b/xen/arch/arm/arm32/traps.c index a2fc1c22cbc9..b88d41811b49 100644 --- a/xen/arch/arm/arm32/traps.c +++ b/xen/arch/arm/arm32/traps.c @@ -36,8 +36,7 @@ void do_trap_undefined_instruction(struct cpu_user_regs *regs) uint32_t pc = regs->pc; uint32_t instr; - if ( !is_kernel_text(pc) && - (system_state >= SYS_STATE_active || !is_kernel_inittext(pc)) ) + if ( !is_active_kernel_text(pc) ) goto die; /* PC should be always a multiple of 4, as Xen is using ARM instruction set */ diff --git a/xen/arch/arm/include/asm/processor.h b/xen/arch/arm/include/asm/processor.h index 60b587db697f..d80d44aeaa8f 100644 --- a/xen/arch/arm/include/asm/processor.h +++ b/xen/arch/arm/include/asm/processor.h @@ -577,8 +577,7 @@ void panic_PAR(uint64_t par); void show_registers(const struct cpu_user_regs *regs); void show_stack(const struct cpu_user_regs *regs); -//#define dump_execution_state() run_in_exception_handler(show_execution_state) -#define dump_execution_state() WARN() +#define dump_execution_state() run_in_exception_handler(show_execution_state) #define cpu_relax() barrier() /* Could yield? */ From patchwork Sat Feb 8 00:02:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13966108 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 DAB0EC02199 for ; Sat, 8 Feb 2025 00:05:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.884154.1293968 (Exim 4.92) (envelope-from ) id 1tgYLM-00022o-73; Sat, 08 Feb 2025 00:05:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 884154.1293968; Sat, 08 Feb 2025 00:05:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tgYLM-00022f-3p; Sat, 08 Feb 2025 00:05:08 +0000 Received: by outflank-mailman (input) for mailman id 884154; Sat, 08 Feb 2025 00:05:06 +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 1tgYLK-0001YL-Nu for xen-devel@lists.xenproject.org; Sat, 08 Feb 2025 00:05:06 +0000 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [2a00:1450:4864:20::32f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 59589284-e5b0-11ef-b3ef-695165c68f79; Sat, 08 Feb 2025 01:05:04 +0100 (CET) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-436341f575fso31348785e9.1 for ; Fri, 07 Feb 2025 16:05:04 -0800 (PST) Received: from andrewcoop.eng.citrite.net (host-92-26-98-202.as13285.net. [92.26.98.202]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391da9656fsm72336295e9.3.2025.02.07.16.05.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 16:05:03 -0800 (PST) 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: 59589284-e5b0-11ef-b3ef-695165c68f79 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1738973104; x=1739577904; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rTqKadIyN6sdNG1mQTo/PfPx9tGHKvwwDx2zM0f3o6c=; b=s8TX7GSIJOm+EZj9W2M1lMDA5zChEcW7ojw/daUjyVRQsyJ/SjT9L7fMYRjFS6HfC5 hCbAPU009+ZiBtJXKl3t169I3ADzxxU6u+nSO+aDMymDBrT6j1EBCYx0a09r+OYr9+hF tZqyUBfTIWxOHRoaj0vSJIna4TbjtKKyc1Vas= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738973104; x=1739577904; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rTqKadIyN6sdNG1mQTo/PfPx9tGHKvwwDx2zM0f3o6c=; b=rd2WbxVR0FgR0b9YdolQW2cFZII8WUFNgAfajL+Xb3UFnieSOJ1xl1JODhbIeaBj1/ elOeLOYQntO4fWfOo5kfb8qxTds8wlKFHpz5YASONXxJ8baZ9CA9stip3UMa+Zcvf/hj nMdJdrUv4IFMABoI4R4ZLHjZtUMUGfWauSkb6zohJeNhttpDgEXXMlKU7fe1jrwk6JeD fP0B2BHzGz6bP9s0IOu3EG/aPYbtMot1tnPbsSassseHziPyFTGrm1s9zKmzs6WDnTHp JIs+wBz1Q28vfzGEAQz6+74YaIWyEtP+PbXH1Xx5lquBqqJmbSdeF+yUAFqzVqKTNviJ MzuQ== X-Gm-Message-State: AOJu0YzTp/e+MIF4McQB8njo/D+bE9bjQdnc24JuDcEeJGxnJtlkXpzF otELJRZGR0P+nmagJnIBcYY+KhBWKD/olvSxvInIA1ByvpUceSecpouZEyC76yHZUi5GzJYClX6 bCI0= X-Gm-Gg: ASbGncvX3DLZg/ZhQnzSmZVBj7DOxqX3SSjBWbsje3++Ol2QbpMCg/dZu9/Jc69mpHB BPFj1BgMh3mtAXu+nE4u5L8v9ILudwOalBcVPB0JrPetQ6gdCKgdqM8JcBbWb2aJu+Rf+4HbDvW XADXgwMME0IMIfRW3HpS/wxvwVowYNnX6EWWqvm6uEPPh+5bnjVIBKHP7S83+1KrvQjded1YFHd 2v7p/b48zj5yZdJqYc8pHlKbt6tFCeSpmKApTh8vN1oHwo0KjrHwJc6q4LoKcpF7y5Mr9ObyU8S 53j9HmanSl4QEeJ/u8Qua3Gu9VaPSb8Mck96giEmZ8qvpiouzmzpPxV2UFWUWZ9Aan6B2hU= X-Google-Smtp-Source: AGHT+IEI9ETemwVvAetCXftnYLIP2CDAIhNoUpO/d3c9x8BeNctPIDNzf5wh7Jsw4xt2iot2pqKZjw== X-Received: by 2002:a5d:6c66:0:b0:38c:5cd0:ecf3 with SMTP id ffacd0b85a97d-38dc8da6393mr4491670f8f.11.1738973104053; Fri, 07 Feb 2025 16:05:04 -0800 (PST) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko Subject: [PATCH 2/4] ARM: Fix register constraints in run_in_exception_handler() Date: Sat, 8 Feb 2025 00:02:54 +0000 Message-Id: <20250208000256.431883-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250208000256.431883-1-andrew.cooper3@citrix.com> References: <20250208000256.431883-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Right now, run_in_exception_handler() takes an input in an arbitrary register, and clobbers BUG_FN_REG. This causes the compiler to calculate fn in the wrong regsiter. Instead, use `register asm()` which is the normal way of tying register constraints to exact registers. Bloat-o-meter reports: ARM64: Function old new delta dump_registers 356 348 -8 ARM32: ns16550_poll 52 48 -4 dump_registers 432 428 -4 The other instruction dropped in ARM64's dump_registers() is an alignment nop. No functional change. Signed-off-by: Andrew Cooper ---- CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel CC: Oleksii Kurochko Reviewed-by: Michal Orzel --- xen/arch/arm/include/asm/bug.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/include/asm/bug.h b/xen/arch/arm/include/asm/bug.h index cacaf014ab09..8bf71587bea1 100644 --- a/xen/arch/arm/include/asm/bug.h +++ b/xen/arch/arm/include/asm/bug.h @@ -59,15 +59,15 @@ struct bug_frame { * be called function in a fixed register. */ #define run_in_exception_handler(fn) do { \ - asm ("mov " __stringify(BUG_FN_REG) ", %0\n" \ - "1:"BUG_INSTR"\n" \ + register unsigned long _fn asm (STR(BUG_FN_REG)) = (unsigned long)(fn); \ + asm ("1:"BUG_INSTR"\n" \ ".pushsection .bug_frames." __stringify(BUGFRAME_run_fn) "," \ " \"a\", %%progbits\n" \ "2:\n" \ ".p2align 2\n" \ ".long (1b - 2b)\n" \ ".long 0, 0, 0\n" \ - ".popsection" :: "r" (fn) : __stringify(BUG_FN_REG) ); \ + ".popsection" :: "r" (_fn) ); \ } while (0) #define WARN() BUG_FRAME(BUGFRAME_warn, __LINE__, __FILE__, 0, "") From patchwork Sat Feb 8 00:02:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13966111 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 4B48EC021A1 for ; Sat, 8 Feb 2025 00:05:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.884155.1293978 (Exim 4.92) (envelope-from ) id 1tgYLN-0002Hu-Du; Sat, 08 Feb 2025 00:05:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 884155.1293978; Sat, 08 Feb 2025 00:05:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tgYLN-0002Hl-AV; Sat, 08 Feb 2025 00:05:09 +0000 Received: by outflank-mailman (input) for mailman id 884155; Sat, 08 Feb 2025 00:05:08 +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 1tgYLM-00022W-8i for xen-devel@lists.xenproject.org; Sat, 08 Feb 2025 00:05:08 +0000 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [2a00:1450:4864:20::42a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5a9b9d0e-e5b0-11ef-a073-877d107080fb; Sat, 08 Feb 2025 01:05:07 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-38dd0dc21b2so313496f8f.2 for ; Fri, 07 Feb 2025 16:05:07 -0800 (PST) Received: from andrewcoop.eng.citrite.net (host-92-26-98-202.as13285.net. [92.26.98.202]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391da9656fsm72336295e9.3.2025.02.07.16.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 16:05:05 -0800 (PST) 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: 5a9b9d0e-e5b0-11ef-a073-877d107080fb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1738973106; x=1739577906; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k79odjZVJL9qLhOKUcXOXOULzXIyeOuWCwsvg6fXSdI=; b=Ng4y2rot+MBJhxcOO5Y//IPsjLxm8Z2PY80dnPGWb+Z3Fa2CsOdABtld/2lflzb9RD BPhsbu+nSLQQuePBq9Mmne1G2EArK6bHvqKFbrWRHkT+RjlcY080u4I2KJjPREP85jQo 3BV5XgpY4yTblw7RBXqLgo6WDVRKLxQSQH4kE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738973106; x=1739577906; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k79odjZVJL9qLhOKUcXOXOULzXIyeOuWCwsvg6fXSdI=; b=CUFiHtXkiNz7/IFleUGvRYttSJVwL7daNJk2WSVeD2oAfIbS8fz9pSQ/76kBnsWxb1 5hDdUUXfuNhnoprsmycN+UotBmXDQbUkrqg7IhHs+oe+VbBLr9w26aQg6B+BE4+Tezvi uB4cg5WSABJYw9kZyoFS1Mm4y+cBl5R4hdjKwXPj4mfZ4mPI/NzsXCpkJRiAUH4RIfSe gVSK1aMceO4jQlj34YTbfgeHBEPne+9LC8B6gB0nzKsMH8bVAzE22lDQVNvg8E/H15Uh QT89TBcbUUmkYDdotEib3icz8pKVINlAkRqY1AnvpHt14kOASLvBuwrnjllghN10CanG 33HA== X-Gm-Message-State: AOJu0YxZudUlNilE3etXdlV5hPT4NwT0VNTFEBbtLqqOX7KN0cHCjHwK LY+23coKDIAOIo+6QRByXInCTaXiRP/vuFBLMPAc18zPHNTrlgnisdQlv+6EqgwEg86smx6pV+G NZkE= X-Gm-Gg: ASbGncud6WD42LTF+OyfBqNT2+OmgFX1KdqlvuMlJQF36roQenq7QEQK+bv+7aNb5yF 3z46s4F1KvLvM2dCLulQjZoWwWn+OY3oTxOoh3I4V8twe4oO2lgNXbV7OrFcf72PztkKdBwvZjk 45mmTMnlc3VrIoaLsuFXJzicl+hj4G/Fx7AzoSnmpGRCgWaJKNODDKDbMrr/A+L1J7ep+Hb6TM1 WMalURzv/6MFIn3dOfzBuiVOxGx7vD2yQMVQJpPmSjzvkNpF72ynJ85LzrfYdE3j/s/xKg/kPUd wAYt1yH8yKm6h/4zApc0vBzFUcTbs2qZjEcRe6no/2EHF3zuvW+SyjMCMWIIymI0xtBuNO8= X-Google-Smtp-Source: AGHT+IGJkEWOFX5Gjq2VAs2p6GZzpMkyV0TM9zLwmOR59crbwu92jAZYa+h37SfthZDUenAOfcn4Dg== X-Received: by 2002:a05:6000:1884:b0:385:e0d6:fb73 with SMTP id ffacd0b85a97d-38dc8dc1f92mr3586402f8f.15.1738973106144; Fri, 07 Feb 2025 16:05:06 -0800 (PST) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko , Shawn Anastasio Subject: [PATCH 3/4] xen: Centralise the declaration of dump_execution_state() Date: Sat, 8 Feb 2025 00:02:55 +0000 Message-Id: <20250208000256.431883-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250208000256.431883-1-andrew.cooper3@citrix.com> References: <20250208000256.431883-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Three architectures have an identical dump_execution_state(), and PPC has a stub for show_execution_state() that just isn't wired up yet. show_execution_state() is declared in a common header, meaning that dump_execution_state() really ought to be too. Move them both into xen/bug.h as they're tightly tied to run_in_exception_handler(). Drop the include of xen/kernel.h from ubsan.c which was required reviously for RISC-V to compile. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Oleksii Kurochko. Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monné CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel CC: Oleksii Kurochko CC: Shawn Anastasio --- xen/arch/arm/include/asm/processor.h | 2 -- xen/arch/riscv/include/asm/processor.h | 2 -- xen/arch/x86/include/asm/processor.h | 1 - xen/common/ubsan/ubsan.c | 1 - xen/include/xen/bug.h | 3 +++ xen/include/xen/kernel.h | 2 -- 6 files changed, 3 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/include/asm/processor.h b/xen/arch/arm/include/asm/processor.h index d80d44aeaa8f..f2c4d990c71c 100644 --- a/xen/arch/arm/include/asm/processor.h +++ b/xen/arch/arm/include/asm/processor.h @@ -577,8 +577,6 @@ void panic_PAR(uint64_t par); void show_registers(const struct cpu_user_regs *regs); void show_stack(const struct cpu_user_regs *regs); -#define dump_execution_state() run_in_exception_handler(show_execution_state) - #define cpu_relax() barrier() /* Could yield? */ /* All a bit UP for the moment */ diff --git a/xen/arch/riscv/include/asm/processor.h b/xen/arch/riscv/include/asm/processor.h index 39696fb58dc6..90b800956303 100644 --- a/xen/arch/riscv/include/asm/processor.h +++ b/xen/arch/riscv/include/asm/processor.h @@ -91,8 +91,6 @@ static inline void sfence_vma(void) asm volatile ( "sfence.vma" ::: "memory" ); } -#define dump_execution_state() run_in_exception_handler(show_execution_state) - #endif /* __ASSEMBLY__ */ #endif /* ASM__RISCV__PROCESSOR_H */ diff --git a/xen/arch/x86/include/asm/processor.h b/xen/arch/x86/include/asm/processor.h index d247ef8dd226..c2eafaecfd40 100644 --- a/xen/arch/x86/include/asm/processor.h +++ b/xen/arch/x86/include/asm/processor.h @@ -405,7 +405,6 @@ static always_inline void rep_nop(void) void show_code(const struct cpu_user_regs *regs); void show_stack_overflow(unsigned int cpu, const struct cpu_user_regs *regs); void show_registers(const struct cpu_user_regs *regs); -#define dump_execution_state() run_in_exception_handler(show_execution_state) void show_page_walk(unsigned long addr); void noreturn fatal_trap(const struct cpu_user_regs *regs, bool show_remote); diff --git a/xen/common/ubsan/ubsan.c b/xen/common/ubsan/ubsan.c index e99370322b44..a96153c08078 100644 --- a/xen/common/ubsan/ubsan.c +++ b/xen/common/ubsan/ubsan.c @@ -11,7 +11,6 @@ */ #include -#include #include #include #include diff --git a/xen/include/xen/bug.h b/xen/include/xen/bug.h index 99814c4bef36..2325a46e7f61 100644 --- a/xen/include/xen/bug.h +++ b/xen/include/xen/bug.h @@ -155,6 +155,9 @@ int do_bug_frame(const struct cpu_user_regs *regs, unsigned long pc); #endif /* CONFIG_GENERIC_BUG_FRAME */ +void cf_check show_execution_state(const struct cpu_user_regs *regs); +#define dump_execution_state() run_in_exception_handler(show_execution_state) + #endif /* !__ASSEMBLY__ */ #endif /* __XEN_BUG_H__ */ diff --git a/xen/include/xen/kernel.h b/xen/include/xen/kernel.h index c5b6cc977772..57a1ef4e17b7 100644 --- a/xen/include/xen/kernel.h +++ b/xen/include/xen/kernel.h @@ -94,10 +94,8 @@ bool is_active_kernel_text(unsigned long addr); extern const char xen_config_data[]; extern const unsigned int xen_config_data_size; -struct cpu_user_regs; struct vcpu; -void cf_check show_execution_state(const struct cpu_user_regs *regs); void vcpu_show_execution_state(struct vcpu *v); #endif /* _LINUX_KERNEL_H */ From patchwork Sat Feb 8 00:02:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 13966110 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 27535C0219D for ; Sat, 8 Feb 2025 00:05:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.884156.1293987 (Exim 4.92) (envelope-from ) id 1tgYLO-0002YM-OP; Sat, 08 Feb 2025 00:05:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 884156.1293987; Sat, 08 Feb 2025 00:05:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tgYLO-0002YB-L6; Sat, 08 Feb 2025 00:05:10 +0000 Received: by outflank-mailman (input) for mailman id 884156; Sat, 08 Feb 2025 00:05:09 +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 1tgYLM-00022W-TY for xen-devel@lists.xenproject.org; Sat, 08 Feb 2025 00:05:08 +0000 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [2a00:1450:4864:20::342]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5ae5cbea-e5b0-11ef-a073-877d107080fb; Sat, 08 Feb 2025 01:05:07 +0100 (CET) Received: by mail-wm1-x342.google.com with SMTP id 5b1f17b1804b1-4361f796586so31213115e9.3 for ; Fri, 07 Feb 2025 16:05:07 -0800 (PST) Received: from andrewcoop.eng.citrite.net (host-92-26-98-202.as13285.net. [92.26.98.202]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391da9656fsm72336295e9.3.2025.02.07.16.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 16:05:06 -0800 (PST) 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: 5ae5cbea-e5b0-11ef-a073-877d107080fb DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1738973107; x=1739577907; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4XBm5j6ovtjFP/ueMrH+LLKAL+E/KD6k9CCT9TTP67k=; b=CCRPzPRI6Lzw84Widh77uvGcxqBe0DUcNe6aXJVhRJMfXfZ4VS32OLeNUYpdhQk55d 6E7oAlXTwIjBqTEnEZ3Kb7DpszwiPsfqnt5sTCnAp0Hqopj3S8qKp8sk9zM9oPTOs+eM pFevEYYwNJ5vjv9fmQ0pwbirJ+ID/53czUpvI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738973107; x=1739577907; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4XBm5j6ovtjFP/ueMrH+LLKAL+E/KD6k9CCT9TTP67k=; b=Hxq+F3ON8jDdk0w00MOLm76cg0dLS0zdQ1C9h+7qRzBCC0RcTHRXjrv1PrLpvxinH4 KP5yKRIPbqMbajnEVEp+t3ti/72gMYdTmrEZhIMx0IRmFDh4wwazsmnGba3xxmH134lC HZcmoAJkmZlcY7NMTZvTCjbByiiYkmi3/xpg37uqe2an+11JuMd4q4+k8Fdz9xB4LB0E EjpRRY/JcLi55JDqBfMAfJmLvojiIpM1VVQSWWTfoJyb5mHYNm7P+jmCK4ei3OkMfr9T WZcAq2n1+MyH9Vptmbla/Rz6bXbGsGnxJ3IymW2DBPqbvggw73Q/KvDs9KaYMQmaLT1K xfPg== X-Gm-Message-State: AOJu0YydAKTVKFaBymLoCg+XLhUAj7jdo3sE9D8xaaDYlCo1ea4L38Cz kTOz2CARjasuqsp/zKK0MKJ6LBYuM0wyySist7P8VlZEgFnierlaov9pg0oM2BlI4spfZ9Omxqu P8PkgNA== X-Gm-Gg: ASbGncvHmddAlNWK6Y9wD9sMYe+A0E83wyUASp4YBsXWsDm/qdhKwkBTJUh6Rnw8qKg edViiAlOV7KNh6BMtd1TrXW3DAUsu/ZRaNuDrAEUnMQAUWqKLrcDGQMOUoKGMO5z0oYN7GFSuou LWo9Wb3rrWqUG04RkXJt0g0RgiVtMG38kygut1A4gJgGTbtAGCFl2UjNMQILCmRFNa25TfHV/rY 27DRsoI/t/2Ul6vmuhigPbx6UDCQWIkcwV7NP0dA8LZk8VJKIo/1jN5dAznGV3Z2Q+AqH9bjt49 vTSA3Dm4akPKul/mptC7DE3Pk5qkDX1rIxZ3d7HBes+euO4az9XP/v/SbL2CaRK+6Qt+LEo= X-Google-Smtp-Source: AGHT+IHczOdSHsviYLLMgvYKf+bJrqZzTPJyL1pvJ7dr78Qm9NyAC/l4tWgOjjl78mGXmCjL/6jqLw== X-Received: by 2002:a05:600c:b86:b0:434:a26c:8291 with SMTP id 5b1f17b1804b1-439249a7aaamr50794555e9.24.1738973106728; Fri, 07 Feb 2025 16:05:06 -0800 (PST) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Shawn Anastasio Subject: [PATCH 4/4] [BROKEN] PPC: Activate UBSAN in testing Date: Sat, 8 Feb 2025 00:02:56 +0000 Message-Id: <20250208000256.431883-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250208000256.431883-1-andrew.cooper3@citrix.com> References: <20250208000256.431883-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Signed-off-by: Andrew Cooper --- CC: Shawn Anastasio This compiles, but something is up with the console and nothing useful comes out. Sample: https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/9079440897 --- automation/gitlab-ci/build.yaml | 3 +++ xen/arch/ppc/Kconfig | 1 + xen/arch/ppc/stubs.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/automation/gitlab-ci/build.yaml b/automation/gitlab-ci/build.yaml index 35e224366f62..6a2e491534d3 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 6db575a48d34..917f5d53a6c3 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/stubs.c b/xen/arch/ppc/stubs.c index fff82f5cf3cc..671e71aa0a60 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)