From patchwork Sun Apr 21 18:28:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13637483 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 B0270C4345F for ; Sun, 21 Apr 2024 18:29:11 +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=WJNzfCX3mYTdbA TWH4+lWHrYkvF+4MgGWJ7wS/B3uDXzR6COsdMPG1VldxMpoArqZXvIhf0I23yq9R5IbYrCxVHjRby w7XGKkukJ2Ek1kz1FoqWKeG4WEOT+YsJpC9OJfze45hLxdwEYMFkjKBYcFeJ3JFslcv8fXMbVGNQ1 PzrBSd+yUSO2YM8im8wmxrVSdtzEG+ohduCgY7jLpcPwPx9GpwG7jlqSg25jQdu6qcXs54QwnuPck /7RAefk0Zl4i0usSsRuj/d3YrvFzhGhk1AloSbeIj8QwfBYUHoREg7TwsxHLoSQCexNzhhxzvk3of MTIHaYj84dB64RBoA1sw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rybvt-0000000B49l-0Od7; Sun, 21 Apr 2024 18:28:57 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rybvc-0000000B42u-36og for linux-arm-kernel@lists.infradead.org; Sun, 21 Apr 2024 18:28:42 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-518a56cdbcfso5715489e87.2 for ; Sun, 21 Apr 2024 11:28:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713724118; x=1714328918; 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=QLoyY4XR3nhhwra1CCHOBjIymplWqPaq2zzpbOH3WKDe37gyLMTVmvu3rshOu/lfcW vMngEOzfC0q9fac9l06RT4b9hFZwuZ3FmaF12PCo5ye7PXwrY1KYG7csakjzOL5SXTmT EsW9XW10iZJ0Hc7V+X6f5QJNu4MJGORKerOK0bmr0ptbUErEHiJYm3BD7/9SX2/42rTE RoIXyP1zxLlqmQaw9zzNvkTcqadnvK3uidnZrLCPBveafDykY3lIEg25tLDSuBP1wxki tI6n5UUpJp9qpXBJZPrN/5t7KqJFNWh1f/9ckDqvvArNymik8KC6YWSbfF0j4FEg0tRp WCnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713724118; x=1714328918; 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=EHhVklqCoBUBNogUYwmvH32kCGcbQfTk+3Dse8Lx76jggMjb6J6cWX2A119vv63o/+ Vv91Ya6Og9q/KGVeNGP9yzVkiTbm8ctkbCige5FeoUdxHILj0hZ7QoWiW4Zt9fpPm/IE wG2z7ndKgyCy2Ez1HJz62gebgorkH5ZTzu//T5kAf+KAKJDuDP651MrFOZCI6tGRqiUN 05Qsv2HJ1mGzTHMWf/Cz9J9CbIZGWg1iHcOD0u5Nsjm/eb2v7UpBGs2XbBAn7DOxdppN GWajNMhHDrQGZkZp/Re7U78CWk+bI9VNusiWYBmubm0jAb0YRlIoSc1TMdPia2QJ53a8 5pAQ== X-Gm-Message-State: AOJu0YyXy3GrTWgZKPBmXiWscBQmaD9dmQs4fVLIgX1o1tMedO1i8sb+ 97VEqTQTGZTXth6jynPK5Ohjn3Mqqzv6cUuz1uo98dT/hq9jTb9Y1fPnEXSY2ao= X-Google-Smtp-Source: AGHT+IEh4egod2woZlvsaC0LomDmn5pY2lASSJpITdB0Oc8MC5cFfYxA/L8olJpiH4vs6LxsOlev1w== X-Received: by 2002:a05:6512:1319:b0:516:d0c2:3ff9 with SMTP id x25-20020a056512131900b00516d0c23ff9mr6886919lfu.67.1713724117939; Sun, 21 Apr 2024 11:28:37 -0700 (PDT) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id s14-20020a19770e000000b005188ea5d2b5sm1549641lfc.303.2024.04.21.11.28.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Apr 2024 11:28:37 -0700 (PDT) From: Linus Walleij Date: Sun, 21 Apr 2024 20:28:35 +0200 Subject: [PATCH v7 09/11] ARM: lib: Annotate loop delay instructions for CFI MIME-Version: 1.0 Message-Id: <20240421-arm32-cfi-v7-9-6e132a948cc8@linaro.org> References: <20240421-arm32-cfi-v7-0-6e132a948cc8@linaro.org> In-Reply-To: <20240421-arm32-cfi-v7-0-6e132a948cc8@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-20240421_112840_978659_3AF8F6BB X-CRM114-Status: GOOD ( 14.25 ) 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)