Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3523181pxb; Mon, 4 Apr 2022 19:50:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBQCOHWCi9ky61jvjIh14qGLwKvbkAWbTT/VZ638WuM6kruf/yRr1DsEyj4xK6M24oiZ21 X-Received: by 2002:a17:90b:3d0b:b0:1c9:b387:4372 with SMTP id pt11-20020a17090b3d0b00b001c9b3874372mr1607290pjb.74.1649127004705; Mon, 04 Apr 2022 19:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649127004; cv=none; d=google.com; s=arc-20160816; b=AhddEnBO/E9oHOQm5ZswM8+rd9a7UWp5bDhdf7Q7g/5mdbc4WkTDt4RulU4FAf/ewO AzxromB8E8wXqhr14wh25Qq/r6wVY2RxOP4tyga69dNuZLV9e9FHgYq5yCmHAsiDA/XS z8cdzOgQ44sHweRWSIvvIf8wAD1WSndBqGaJXLj0y+7iUDegHTChr0nHvW9n0FvKEpwX 6Cry3op/tvzaW0rDBV7hmpYOuCTTI66Z0MUjeA9nScn2mDKUYp/mNYipOBghbzkWM9A1 xQci4MrK8qvoWV5Oc5QpkiPpZPlIakjVtppiAQ8aWGfUO/zU8KIThJZgcxR8cUl6vklZ u4iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Hp4L2cVTqta3/N48brNHzNHGdOlT5FDTQPDHhtqZR6U=; b=cS7/4J6hELT4lRi3zVVD+M6SEF/OnSmANKJIAGFoHaXBqNR/KecVAN5hfkAvtHcu6A i4qaR6Wrh6tqhk/g8z+hPVhyenDy4ZJ43uqkvi42uWDSrgncnvHcnpsdRkC3GbCgjNkR gT+/iiXSKeapRFabXk7InEH4bcL9d3zUQEr4rDw8EaVyT02ozeNjz2+0EdS4eGeRLFY0 3VeygFSiBhS5xa18gzZgSmNGCtkm7uwA0lT5BegIEB+Pgd3kIRuevWrFQwxHcWRrkdnw MFCi6/B3XG5XpT46zPkuKK5B+LGbe9ib1/UtcNteZkwvhYyAyhflpHWpx1B4YP3klZoC /AJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=RCrYpMKB; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i18-20020a170902c95200b00155c6577751si12951838pla.33.2022.04.04.19.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 19:50:04 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=RCrYpMKB; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 18919435BDB; Mon, 4 Apr 2022 18:13:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344303AbiDCW15 (ORCPT + 99 others); Sun, 3 Apr 2022 18:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376563AbiDCW1y (ORCPT ); Sun, 3 Apr 2022 18:27:54 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC0043982F for ; Sun, 3 Apr 2022 15:25:58 -0700 (PDT) Received: from zn.tnic (p2e55dff8.dip0.t-ipconnect.de [46.85.223.248]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 798AC1EC0391; Mon, 4 Apr 2022 00:25:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1649024753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=Hp4L2cVTqta3/N48brNHzNHGdOlT5FDTQPDHhtqZR6U=; b=RCrYpMKBIoF34czM4Y1d0g2hGszHWl+bZuGTBkhiYlQ9cEHHSM95JeUMDlG3Kob7dGxyfZ jDcoj9xVjPLAwwHHkYsbBGaBfMY80u59ea9UlZ49SIeLy+qLqAQsepWJgRePAjFgwzxLHH /lX8cg1Gi2aOZmW3m/KsvPbDc8uQl8U= Date: Mon, 4 Apr 2022 00:25:51 +0200 From: Borislav Petkov To: Alexey Dobriyan Cc: x86@kernel.org, tglx@linutronix.de, mingo@redhat.com, dave.hansen@linux.intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/5] x86/alternative: simplify DUMP_BYTES macro Message-ID: References: <20220311144312.88466-1-adobriyan@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220311144312.88466-1-adobriyan@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 On Fri, Mar 11, 2022 at 05:43:08PM +0300, Alexey Dobriyan wrote: > 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) That doesn't work always. Before: SMP alternatives: feat: 9*32+0, old: (current_save_fsgs+0x32/0xa0 (ffffffff81017762) len: 5), repl: (ffffffff89997c78, len: 0) SMP alternatives: ffffffff81017762: old_insn: eb 32 0f 1f 00 SMP alternatives: ffffffff81017762: final_insn: 90 90 90 90 90 SMP alternatives: ffffffff81017762: [0:5) optimized NOPs: 0f 1f 44 00 00 After: SMP alternatives: feat: 9*32+0, old: (current_save_fsgs+0x32/0xa0 (ffffffff81017762) len: 5), repl: (ffffffff89997c78, len: 0) SMP alternatives: ffffffff81017762: old_insn: eb 32 0f 1f 00 SMP alternatives: ffffffff89997c78: rpl_insn: <----- * SMP alternatives: ffffffff81017762: final_insn: 90 90 90 90 90 SMP alternatives: ffffffff81017762: [0:5) optimized NOPs: 0f 1f 44 00 00 there is no replacement insn in this case: static __always_inline bool _static_cpu_has(u16 bit) { asm_volatile_goto( ALTERNATIVE_TERNARY("jmp 6f", %P[feature], "", "jmp %l[t_no]") ^^ -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette