From mboxrd@z Thu Jan 1 00:00:00 1970 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 29F7FC02198 for ; Mon, 10 Feb 2025 21:29:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.884983.1294736 (Exim 4.92) (envelope-from ) id 1thbLL-0002gh-HE; Mon, 10 Feb 2025 21:29:27 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 884983.1294736; Mon, 10 Feb 2025 21:29:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1thbLL-0002ga-E6; Mon, 10 Feb 2025 21:29:27 +0000 Received: by outflank-mailman (input) for mailman id 884983; Mon, 10 Feb 2025 21:29:26 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1thbLK-0002gU-Gb for xen-devel@lists.xenproject.org; Mon, 10 Feb 2025 21:29:26 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1thbLJ-00BLjw-2x; Mon, 10 Feb 2025 21:29:25 +0000 Received: from [2a02:8012:3a1:0:c076:8426:eb1f:4b85] by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1thbLJ-003VGK-1X; Mon, 10 Feb 2025 21:29:25 +0000 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" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID; bh=npBN2BLbyZA1r634Oi0gIPhDvPdyEoVTA/qMLJ8vMuM=; b=Xm/X8nucekTcMFXUwpaRA+yUnW Xd3ROWOW31fGPFD1vfu3S33d0/qHmxTOvXS4TjhH2MdQe2Fkj4xhnZkP/dbW9OpsQ5fSeSlvA9AG7 Asu14G704g41QbnyZstcD+YCEY0Bli35zEqPx++JNlu0t3Ek6Q2Grq7Z5VU4omvGOnJA=; Message-ID: Date: Mon, 10 Feb 2025 21:29:23 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/4] ARM: Fix register constraints in run_in_exception_handler() Content-Language: en-GB To: Andrew Cooper , Xen-devel Cc: Stefano Stabellini , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel , Oleksii Kurochko References: <20250208000256.431883-1-andrew.cooper3@citrix.com> <20250208000256.431883-3-andrew.cooper3@citrix.com> From: Julien Grall In-Reply-To: <20250208000256.431883-3-andrew.cooper3@citrix.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, On 08/02/2025 00:02, Andrew Cooper wrote: > 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. Just to confirm, you mean, the compiler is not clever enough to notice that the value should be in the register BUG_FN_REG and therefore, two registers will be clobbered. Is that correct? > > 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 > --- > 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, "") -- Julien Grall