From patchwork Wed Apr 17 08:30:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13632991 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 37D66C05052 for ; Wed, 17 Apr 2024 08:32:04 +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=xeCs1YtbH7hoEC LfzX3poU8GCc19YttFK3MaglcBvo287CLwSbCU3lA7MIucBdZJ4FaUE7Qli+vC7tqxIzNt246vv/N m3UPjWI99f5lAdbwcTBXwAQ0F0a5iJLwJMvPIAAqD9jJdvhVfkZXqrkPwu20tFZOhmyUBkzVfyC6I D1CwXW+Cu2+I7IOEylqLBOMAR3glwIJ9h7dMQ45fxLWRrQrElb9QMzcZwsWcXrP6VH71FzKynCuaN X/Fhyaf+aG63q3IZ1rHoH44TD6GwYelyj0f2OptCGUfni/DDpAJpyfLZOZm+k0jOUzqP1D+WjuuW9 AYwG/1BN7tBzcuPWZpGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rx0hk-0000000FDey-1ltx; Wed, 17 Apr 2024 08:31:44 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rx0hF-0000000FDNS-1ttz for linux-arm-kernel@lists.infradead.org; Wed, 17 Apr 2024 08:31:21 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-5176f217b7bso9411263e87.0 for ; Wed, 17 Apr 2024 01:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713342670; x=1713947470; 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=W777DePpHRyEnsRrJ7+bMQCGxoO72LjRk/CwjfPOaIpmlOORDMyZZfhPa3PAiTjX3r cS6O2lmAfngGvXywYv6zg2nynucTQHWmqzUgVyeF/ttTHXo3V7if4YFhMPWDGnTOQ8nu jUtVRJ55Lkw5cv8dKAesBp5GVquL2j5rhR5xNHWICHCkB/CI/KWAHRlePq04Bopeg6Ay wvpEEkhzbN/9etO1WKTy8XGTWXe9HJGBKJ92HNYU7/bIorntiiNQCOyxPnD1TCOLYaS7 mn5/8ZDDmmVfgdrFBQXGgCJNMjDs2gQGl/s4j9iNTe6thFimdm+oY5gD0vqDJwEt81C4 wKHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713342670; x=1713947470; 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=sZIKw/qK+D+BWtpgSqEzZDvZzU+sCW3LCc/+xmQ/FpniXc+cqLKSQnx5Y21s/hk1Fo kPYszR8GN+HF+JlPBx+dEQe+PBAPp/pEwBOVWY04hwRNkEdNsc4kYIgSz5hrAIZkhnPw 54qNBMOebLNgZiIiJd0YBswWPjazGk+OPsIT1WEb4vRab+6ps98wRWRIFOsR0LaZYIBZ zYlNRvTO0lRAKrALWz6Dokj0AmBNPgMxTeugqnbRkAzOEZf2abouPZVTinrXUN2bLotm iUoVy3XccuuIEcT0CVkiIZAr8yvTc8z91RbqVLxuQYJFbe9HtsB58slmV4xbYd4H5N6b y6Bw== X-Gm-Message-State: AOJu0Yz1iJyVNwXe6cja26F9ry5rq9xPQz5kzVe1l2bd4wfi5yc1bxgV ZnICEwlLp3/XYkd+Up72Bb3EV6tWSgdGMc3JhOH76fobKTeZOrNtUskhPqgjZ38= X-Google-Smtp-Source: AGHT+IHfxdzveXLE3ehxMNcuRZ7EtQNOh9qmXu6zJBln4qQr28zP5D1P0a3kERNqOCToEAMzdHtEyQ== X-Received: by 2002:a05:6512:29c:b0:515:d196:6d4d with SMTP id j28-20020a056512029c00b00515d1966d4dmr12105878lfp.24.1713342670389; Wed, 17 Apr 2024 01:31:10 -0700 (PDT) Received: from [192.168.1.140] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id d10-20020ac24c8a000000b00516d2489f16sm1873151lfl.260.2024.04.17.01.31.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 01:31:09 -0700 (PDT) From: Linus Walleij Date: Wed, 17 Apr 2024 10:30:58 +0200 Subject: [PATCH v6 09/11] ARM: lib: Annotate loop delay instructions for CFI MIME-Version: 1.0 Message-Id: <20240417-arm32-cfi-v6-9-6486385eb136@linaro.org> References: <20240417-arm32-cfi-v6-0-6486385eb136@linaro.org> In-Reply-To: <20240417-arm32-cfi-v6-0-6486385eb136@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-20240417_013113_758306_586431E4 X-CRM114-Status: GOOD ( 14.03 ) 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)