Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp788385pxp; Fri, 11 Mar 2022 15:09:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxMLp0Ww7/PSK/eVk53UuVx/G8aGwajg4aorFu4+HkqMRN4G+Qkk5vVX5jpzXMPlnLNoslP X-Received: by 2002:a63:384e:0:b0:374:ae28:71fc with SMTP id h14-20020a63384e000000b00374ae2871fcmr10456763pgn.159.1647040153533; Fri, 11 Mar 2022 15:09:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647040153; cv=none; d=google.com; s=arc-20160816; b=a/4O3rtGzG/UxOZ/dwhVxf0v1SWfV+1bwNWh0Taigd7Djid4+6XzEikh9KZbrOE7D7 nWNIwnxb6o+eaJPj4CzCAVF84asUv2bfrfLoW62gqes8vTwy2znC1aSAxLm/qqv7/BEC HZtTTABm0cf4+NTmJlaeV5M6fvzYNyPaCMsFqcLFqqytuj6GVDXr9ZKFWoDGsp1fwd9d 52WfriK+ttVYvDLfgS0V2vAVp4WHnffh++kLBs/haGlvKq9scEFMrdDj7cR6f3hNVaET nXH7pl5JiVBoV90widHYnlUpdDpJsT9utu8u0GJikWKhWMLz9nO9+kEx8PIIZgPL8+r2 pm+Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=DC5Lyo0u7Webj/mowBh6O4eTeZkl9naLEHKUm4TCwDA=; b=N8/LJrBCBbaG9F9s2nnPeyuOvY2zEe81ZY+961i1/Z4Ctj5YIqByv2xwaDJw2+8Sm+ 7POTsJa8Gxd2h+cq3U42WhZKG4ue0OWSYFHu6xDXfs2Plnjol9KQsaKiZrneoggI0Cea 3D1fKVOcuR+BTSHTIFB3Sskvukyw9TCRNQY8HZAoVZ6q0shb5L9ymgwFStZQGnw3JCzy 7MMebEv976u9W3uC6HNGpOkOb+X2+VCW8kITN/ix7Iiby0JB56xCtBs5VhE8yGpu1f2T Rop+r8sCt7vltA5LAcDtE7PY08R8QINIFzjGPPblgWkybvdRi6UVUyX9B+6KuRHdxMdM 2kyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fIIGKec5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 133-20020a63028b000000b00364cff355f7si9335994pgc.257.2022.03.11.15.09.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 15:09:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fIIGKec5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B95322D1905; Fri, 11 Mar 2022 14:07:02 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350366AbiCKOon (ORCPT + 99 others); Fri, 11 Mar 2022 09:44:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350322AbiCKOod (ORCPT ); Fri, 11 Mar 2022 09:44:33 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BB6A141471 for ; Fri, 11 Mar 2022 06:43:27 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id l10so5272132wmb.0 for ; Fri, 11 Mar 2022 06:43:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DC5Lyo0u7Webj/mowBh6O4eTeZkl9naLEHKUm4TCwDA=; b=fIIGKec5DhH7F0ghCXPyZCkwex77X91zaslVC3Sc1TEvoJ4Bes/UzjErOJWjNuTDff 9qj08Pls0ObfslAUvMrOqrEuVqtN4idDs6iIh09TJjeV2iGXnEWNM6Q9ILUmZoj9530R 4vz81HPYCgDscgepPU9V1JpwS9PYhPIi6RsMwgoChYJaJXRSqiChSmATYJTYGHAqyj7u 7mViLQKVnWrzAga3B7jQkXShvFMjYcbRTpSL9WWrH6DNepV3YJNLkd69KrXXkZGuHqH9 tIjuPr2u7K56MtLiy6q6xGyttG3KdslZwUuS5NcBpfXxzBHMmEJKWpD1eqBN8JcqDHTx yBIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DC5Lyo0u7Webj/mowBh6O4eTeZkl9naLEHKUm4TCwDA=; b=5dcLR3lIkT4lgV96YLqFtbEVgr7XQGdj6kFpkjsqXa5w+AhuIbj5Wjlr0rP0M1eQC4 1W8XG9MfAk0m9LspFPfuJNOcB5Xale7U8cxnuRT4ktHPp3GpwA7/8coAl6oliUj9ODkE oD/LbcyuqRkCRAYXmOhbbmVQHg90u7cD/tQUWBoBo2jWLKHZr/zwdJshBQUOfBEj2GE2 Dcgc1aj7JggMaeFh7tB/TJWRM7Oyr3D2Q8XkeC4KDmSLSfmzblqroM9wxCz2/Hzuz/Q5 VQA80A+U1MY73BOqK1rqKwf1TtxWxiRW71wUVDMzIWkZDnZbjdJTbRPQkvFzleqJSJ2D gUbw== X-Gm-Message-State: AOAM53043/QHUcNVE9XYExDEQsg6gd59fMvgSSkboKUtH46xYKdebPL1 lhVTDtvqGM5eGj0DhiYIVESqUEFsrA== X-Received: by 2002:a05:600c:4c11:b0:383:fae4:41c2 with SMTP id d17-20020a05600c4c1100b00383fae441c2mr15947724wmp.104.1647009805909; Fri, 11 Mar 2022 06:43:25 -0800 (PST) Received: from localhost.localdomain ([46.53.250.95]) by smtp.gmail.com with ESMTPSA id e20-20020adfa454000000b001f01a14dce8sm6877637wra.97.2022.03.11.06.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 06:43:25 -0800 (PST) From: Alexey Dobriyan To: x86@kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org, adobriyan@gmail.com Subject: [PATCH 1/5] x86/alternative: simplify DUMP_BYTES macro Date: Fri, 11 Mar 2022 17:43:08 +0300 Message-Id: <20220311144312.88466-1-adobriyan@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Avoid zero length check with clever whitespace placement in the format string. Signed-off-by: Alexey Dobriyan (CloudLinux) --- arch/x86/kernel/alternative.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c index 5007c3ffe96f..6c9758ee6810 100644 --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -66,13 +66,10 @@ do { \ if (unlikely(debug_alternative)) { \ int j; \ \ - if (!(len)) \ - break; \ - \ printk(KERN_DEBUG pr_fmt(fmt), ##args); \ - for (j = 0; j < (len) - 1; j++) \ - printk(KERN_CONT "%02hhx ", buf[j]); \ - printk(KERN_CONT "%02hhx\n", buf[j]); \ + for (j = 0; j < (len); j++) \ + printk(KERN_CONT " %02hhx", buf[j]); \ + printk(KERN_CONT "\n"); \ } \ } while (0) @@ -214,7 +211,7 @@ static __always_inline int optimize_nops_range(u8 *instr, u8 instrlen, int off) add_nops(instr + off, nnops); local_irq_restore(flags); - DUMP_BYTES(instr, instrlen, "%px: [%d:%d) optimized NOPs: ", instr, off, i); + DUMP_BYTES(instr, instrlen, "%px: [%d:%d) optimized NOPs:", instr, off, i); return nnops; } @@ -303,8 +300,8 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start, instr, instr, a->instrlen, replacement, a->replacementlen); - DUMP_BYTES(instr, a->instrlen, "%px: old_insn: ", instr); - DUMP_BYTES(replacement, a->replacementlen, "%px: rpl_insn: ", replacement); + DUMP_BYTES(instr, a->instrlen, "%px: old_insn:", instr); + DUMP_BYTES(replacement, a->replacementlen, "%px: rpl_insn:", replacement); memcpy(insn_buff, replacement, a->replacementlen); insn_buff_sz = a->replacementlen; @@ -328,7 +325,7 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start, for (; insn_buff_sz < a->instrlen; insn_buff_sz++) insn_buff[insn_buff_sz] = 0x90; - DUMP_BYTES(insn_buff, insn_buff_sz, "%px: final_insn: ", instr); + DUMP_BYTES(insn_buff, insn_buff_sz, "%px: final_insn:", instr); text_poke_early(instr, insn_buff, insn_buff_sz); @@ -499,8 +496,8 @@ void __init_or_module noinline apply_retpolines(s32 *start, s32 *end) len = patch_retpoline(addr, &insn, bytes); if (len == insn.length) { optimize_nops(bytes, len); - DUMP_BYTES(((u8*)addr), len, "%px: orig: ", addr); - DUMP_BYTES(((u8*)bytes), len, "%px: repl: ", addr); + DUMP_BYTES(((u8*)addr), len, "%px: orig:", addr); + DUMP_BYTES(((u8*)bytes), len, "%px: repl:", addr); text_poke_early(addr, bytes, len); } } -- 2.34.1