From patchwork Tue Mar 7 14:04:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 65578 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2461292wrd; Tue, 7 Mar 2023 06:29:42 -0800 (PST) X-Google-Smtp-Source: AK7set9qsnaRo7BhvttNGFrf4rUgqjzj6YOVjnIWBDr7BjaAxCC2W9HMP8i55odGFLpk+2L77Z1t X-Received: by 2002:a17:903:230e:b0:19c:c961:ac15 with SMTP id d14-20020a170903230e00b0019cc961ac15mr17155235plh.0.1678199382451; Tue, 07 Mar 2023 06:29:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678199382; cv=none; d=google.com; s=arc-20160816; b=Yxmi4oIobNAbHQWIe5yfkaIJVAGkg2pM35+v+qUYNs/gIOOPESBGczKUDr7tx/xm62 ag5ozv4OpvQ0JohVtQMVUgM+LJ+98ER17wlIsqSdNNcZBxK/TTJG9XZFKhi2xSffpnMi n4iqppho22UjP9hu7jsj7VDE5hLfN+0gCI0Vegxe1gXRUBpPa+YG1AJ9hWau99nFRs8Y T/IFTNvo7WwCdfzpz3P8by4RcU6mXvPVEloUrVJKT6K/h7W5pv3mrRfD3Cp2NnJop+HP cxh32hm7Jjw4E7a7urRCPdzfaY4ZAkD65+mL7+FHeQI+UKrAW6XEjx2DmOUxYVmr+JMP YVww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vGuFfeboqV9gj5Z1bfITHF5MrgPujOnMZEeisr9DpLE=; b=TPbA+q5YwuSOH6VTOvZmjhp52UjqpLR7o/+mGt4a4+0XbrF5+w5/voOiQH89KVy0J5 ydb00eUBS9IpQR2ebe7oiZHBABwHG5TvyuYwsIXl6abUFEtdTgCwdGd+olfpblD4x87W 994L+Ttyp46LaHVGuRTvp5Z/5+QNL9Ditv8qWkomiJ57ESFmLI6de5E1ONo/5ib8hUNT Y1tIDhVZMUCsweYrXYSHweCNZPXVrPU6OPz+5jKTuaqDyyX3I2YUas8ByvnzptBem6W4 QPCcDsySRizDJgzPHPcuhBCMSighiWlGblB24qge5XVSJlCvU7241F+ttXkIlk3UKBTN WY3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f3P88CgX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a17090341cb00b0019a7ef5e99fsi14682042ple.86.2023.03.07.06.29.29; Tue, 07 Mar 2023 06:29:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f3P88CgX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231259AbjCGOJS (ORCPT + 99 others); Tue, 7 Mar 2023 09:09:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230380AbjCGOIj (ORCPT ); Tue, 7 Mar 2023 09:08:39 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC1BD85B10 for ; Tue, 7 Mar 2023 06:07:46 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F06626145A for ; Tue, 7 Mar 2023 14:07:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BF1BC4339E; Tue, 7 Mar 2023 14:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678198046; bh=QDcwBf9EH2tJ8eEyC1Nj4A3MrnVEC+rPwfe1iysJZno=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f3P88CgXVT+Ugyk0GX6xkiiygfzJAeGNw293YRfGLC057gYzoTHRmK6hjtQSwj4YC Yh37QCaD5DvY0bZCIqX+wZOYIIu0iJnSRermRuZvfn0qgFzZ9jr6MPERqUO4eUpg1k Rpzewkl2SxFKHHrgwew2jxR3UKrbcfI3A4T6iyR2skp+LtvQ2ZtVdPllTpylOgGb9z tROQ+mp1S3i8iC5N0aVSCOT1E74eHKITY7L2K5cQ6/QaHaxPDBqDGK463ghHVtRIaf RQ/e+ZBzvvLANTf2L7eE1CnPvrvp0BXV/SgxE2rsN520wJ0Xk8G7zNYCGIap2cIF2X SWYiIda8F6NuQ== From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Catalin Marinas , Will Deacon , Marc Zyngier , Mark Rutland , Ryan Roberts , Anshuman Khandual , Kees Cook Subject: [PATCH v3 20/60] arm64: idreg-override: avoid strlen() to check for empty strings Date: Tue, 7 Mar 2023 15:04:42 +0100 Message-Id: <20230307140522.2311461-21-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307140522.2311461-1-ardb@kernel.org> References: <20230307140522.2311461-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=911; i=ardb@kernel.org; h=from:subject; bh=QDcwBf9EH2tJ8eEyC1Nj4A3MrnVEC+rPwfe1iysJZno=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIYXdxWAN6+mCPXEZupER8qbJd7ZNU/Be93y60EaL59uSn 53iNTHoKGVhEONgkBVTZBGY/ffdztMTpWqdZ8nCzGFlAhnCwMUpABMpO8zI8HPWzi0xmf8dy3b6 +ztr3XNmn57R2daXdcHiysRopbDPRgz/ywJybG0DPkQGeW8xOqQwaePOdVVetV9qQ1KYOL7bG4o xAQA= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759719595205938244?= X-GMAIL-MSGID: =?utf-8?q?1759719595205938244?= strlen() is a costly way to decide whether a string is empty, as in that case, the first character will be NUL so we can check for that directly. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/idreg-override.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/idreg-override.c b/arch/arm64/kernel/idreg-override.c index 23bbbc37ac24ba09..476dc3f0e9d90e22 100644 --- a/arch/arm64/kernel/idreg-override.c +++ b/arch/arm64/kernel/idreg-override.c @@ -221,7 +221,7 @@ static void __init match_options(const char *cmdline) override = prel64_to_pointer(®->override_prel); - for (f = 0; strlen(reg->fields[f].name); f++) { + for (f = 0; reg->fields[f].name[0] != '\0'; f++) { u64 shift = reg->fields[f].shift; u64 width = reg->fields[f].width ?: 4; u64 mask = GENMASK_ULL(shift + width - 1, shift);