From patchwork Mon Apr 15 13:43:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13630083 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 B96C0C4345F for ; Mon, 15 Apr 2024 13:44:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wtbxcCOjNqKikZ4+vs0wLkSrZ5iSy3Vgjj4tfm2zv+o=; b=U2AuogL5lKn4v1 Ii1uJrLQy+1llppkYWxc9tT4DHQXYLsNj2k/i2g/g0BbObatNJlFt6iraYOh/b0ZPa282UhiH7ruL YNmPtmD23eqbQRcozvA7OPYOTUR9vdyM0bPcuJ/YD6aTi3o04eMq0HZfJ5SSl8lBv7UOC+Oxhd/v0 bWJ08diwepl2G3DHcyaa+goawnbR8mp8PUrDDfzua/EhugMxlebDtnxFqS9ILZumMjOSYSeLckUrB UDT7kejZo/Ogo9+YHhAnvxqo40Jid3/U23PS73Ufn7KNhGl+46VKGeDMMDaChtAYz4AAGjO6RIBUO +nC4N0RJNhas8l7p79Hg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwMd0-00000008Xgz-1pgC; Mon, 15 Apr 2024 13:44:10 +0000 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwMcb-00000008XRh-1c1I for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2024 13:43:47 +0000 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2da0b3f7ad2so39159331fa.2 for ; Mon, 15 Apr 2024 06:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713188623; x=1713793423; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=NrM2dGN+EheWjKnt5zlJvOk5v0Ei3knf8+WuyH2chzo=; b=fhW3v2BAmLAU8GbPB5lJj58cwrF/P1wxHWtJ3YfbN9wIoEDwLqvqzrMYtuRA2G537/ JaKLDR5Nv9segBy+Zd33Y1k0jgcxlwtjB+Ph/7T0Ovhof8nxC9EHAcPe0q2GEHbGAizh i2wrx2KizrfchKJsT1zaS9mXZDyceFVvdxEje28i+Or16+9cu+7Vysp4KSrX5gUdtU6J ZpH528gBrwY+69CM98huBVYdKhDHeuO048Ogqbaiw/kN3PuN+Q0COcm2+3EtcZa6ghkf 0WFHNVq5SgYOCQG2NCHRBsiMszTgwWYNg3ADGJsrpCp9aWv6YjU3rHucpvnNHB8r3hk9 aNFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713188623; x=1713793423; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NrM2dGN+EheWjKnt5zlJvOk5v0Ei3knf8+WuyH2chzo=; b=el1lN3+AxQ1UVDkD5mIu/epcx6ln9J2/0QMp+sQE4F/gUwdSyQ523p03oLLLCbFHIv 7BeB9FSJQMbANRTcr2xmAlXHZSThp1vluQif6EDNjVolY6djPpEqRLU/u6grKBqTVD6U 3m56Sgh0Ri+Ft0wzHR6/EEQsYKphNPfode0MfCXrvAFvGr7Tmg4vD3zIdzUkA2V+208m uhg/5J21xLNLIbt7EC1fjbA4j+VgypD/+VxiUqMH72KXfjaVN7OZ4WJ/nCxahu2ZQNEe FHE1OQfydNjj1X6Tlr1CFkUabxgBrpCCU6p2iNySqksONTMo8IEV8kk48QwYPMtI/nuB 42JA== X-Gm-Message-State: AOJu0Yz2TnGPwKL3KRACnYYV+W4N29uUTS0T8bBj9EEr01xS7VFwVQU4 TkPdOaS6A8xLxWpelYeEVp8VWqWxEJgHgoYQTwdjloWbQGbhDyIscxpUgYolEVJaOVkO+82aT55 N X-Google-Smtp-Source: AGHT+IG94lB9rql4I3J1YIwyMpGhO47ECSfiEOBK36ZwoxzhQGBWhB1wnYr49xE+cUmyLtMHraD2IQ== X-Received: by 2002:a05:651c:1546:b0:2da:91f5:a624 with SMTP id y6-20020a05651c154600b002da91f5a624mr1263154ljp.17.1713188623672; Mon, 15 Apr 2024 06:43:43 -0700 (PDT) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id p11-20020a2eb98b000000b002d43737e2d7sm1297988ljp.30.2024.04.15.06.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 06:43:42 -0700 (PDT) From: Linus Walleij Date: Mon, 15 Apr 2024 15:43:27 +0200 Subject: [PATCH v5 08/10] ARM: lib: Annotate loop delay instructions for CFI MIME-Version: 1.0 Message-Id: <20240415-arm32-cfi-v5-8-ff11093eeccc@linaro.org> References: <20240415-arm32-cfi-v5-0-ff11093eeccc@linaro.org> In-Reply-To: <20240415-arm32-cfi-v5-0-ff11093eeccc@linaro.org> To: Russell King , Sami Tolvanen , Kees Cook , Nathan Chancellor , Nick Desaulniers , Ard Biesheuvel , Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, Linus Walleij X-Mailer: b4 0.13.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_064345_588586_FE04C531 X-CRM114-Status: GOOD ( 14.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When we annotate the loop delay code with SYM_TYPED_FUNC_START() a function prototype signature will be emitted into the object file above each site called from C, and the delay loop code is using "fallthroughs" from the different assembly callbacks. This will not work as the execution flow will run into the prototype signatures. Rewrite the code to use explicit branches to the other code segments and annotate the code using SYM_TYPED_FUNC_START(). Tested on the ARM Versatile which uses the calibrated loop delay. Tested-by: Kees Cook Signed-off-by: Linus Walleij --- arch/arm/lib/delay-loop.S | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/arm/lib/delay-loop.S b/arch/arm/lib/delay-loop.S index 3ac05177d097..33b08ca1c242 100644 --- a/arch/arm/lib/delay-loop.S +++ b/arch/arm/lib/delay-loop.S @@ -5,6 +5,7 @@ * Copyright (C) 1995, 1996 Russell King */ #include +#include #include #include @@ -24,21 +25,26 @@ * HZ <= 1000 */ -ENTRY(__loop_udelay) +SYM_TYPED_FUNC_START(__loop_udelay) ldr r2, .LC1 mul r0, r2, r0 @ r0 = delay_us * UDELAY_MULT -ENTRY(__loop_const_udelay) @ 0 <= r0 <= 0xfffffaf0 + b __loop_const_udelay +SYM_FUNC_END(__loop_udelay) + +SYM_TYPED_FUNC_START(__loop_const_udelay) @ 0 <= r0 <= 0xfffffaf0 ldr r2, .LC0 ldr r2, [r2] umull r1, r0, r2, r0 @ r0-r1 = r0 * loops_per_jiffy adds r1, r1, #0xffffffff @ rounding up ... adcs r0, r0, r0 @ and right shift by 31 reteq lr + b __loop_delay +SYM_FUNC_END(__loop_const_udelay) .align 3 @ Delay routine -ENTRY(__loop_delay) +SYM_TYPED_FUNC_START(__loop_delay) subs r0, r0, #1 #if 0 retls lr @@ -58,6 +64,4 @@ ENTRY(__loop_delay) #endif bhi __loop_delay ret lr -ENDPROC(__loop_udelay) -ENDPROC(__loop_const_udelay) -ENDPROC(__loop_delay) +SYM_FUNC_END(__loop_delay)