Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1044773lqp; Fri, 22 Mar 2024 04:08:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU7o+RI/wCsimueZB1X9aexsk8shQACn3/FRlytEJaQzJd5jgS5ZrZaqXVukq7lx57HK+s5FrnPPJovHXYsSdiSozR/VnSVsP82mEki5Q== X-Google-Smtp-Source: AGHT+IFs9tNXoclt1zATPdTGS8uauqRVrq7VNCLHt+7+yf7QR/ORUXbB35gB+efgs383fme61WRG X-Received: by 2002:a17:902:ea0c:b0:1e0:7b90:5c31 with SMTP id s12-20020a170902ea0c00b001e07b905c31mr2399065plg.59.1711105686964; Fri, 22 Mar 2024 04:08:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711105686; cv=pass; d=google.com; s=arc-20160816; b=lmluUceDJzhQ3Zp6EKQUsffj8lmpUDWnMEecmWXLYoNLfhgke+r0p8d1lLnXGOAN4B PHmRyPzQHdGpK/KCC/g6ukVgXnPYUQ1naeW9gj3CQupW5YcbLdyZq5aiR4Kk13BEd/Hk LeseXXskFNVQorCFwDCTYuw3yiI9llzom32vfIQMkTN8+hk56sCbOqFMwbEdt4aRBdUO 8gf4uTuT1bgrV6e7Mj4zKSW5w8O0XAOFVy8gnscjN94w6Se0i6zz4MJfLLyLbi7/UoQH sVSuXryUH1FrInkV31o/zSg1cu9TACXHFSSqi9WeXc3D12dTUkaTcoY3Yyd+rqhgYfPD Lq/A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=3vEhqtTPlY1TvYFcXQO0SZFnOE9PzEWsix7+imOWO1w=; fh=khv3Xpmj1MbMOOZoYxTd0pWc5THYDw8KK6oAD4Y2rec=; b=LkPEhm3wzxaOh5rvDNY2rI35mrLj59ohSjtcy8t/eITYSASG0wfgJqqzZfmA+SYJ+6 zjVlYOE8PbplJvPaJoK5gr7FOr3+Cbc6+w9w5C/pWVLnhxzqburixJCQDk3rZD2hMRVP rAUuIsMSWrHwGmMSXYqV78eP+d81QiaQzEyXWuIT5LDyBNsTLykwzbqwWBMJUw50XD9d 6fJaIS/tbjCinSwjaWYSgTzw8wEh/PJa0v8gcHMdLp/hV2++/xyJmDETMGxHFBckFse+ 5iVQR3pSnUMnMg0et3AsG/yC4M0nqrcnZJWo1PoikDKg8I3lxH0OXbkrkB7SsgqoE0hg 54UA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vGe67JcL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=kGrOyUqt; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-111338-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111338-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ay3-20020a1709028b8300b001dcafce30f5si1619324plb.424.2024.03.22.04.08.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 04:08:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111338-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vGe67JcL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=kGrOyUqt; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-111338-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111338-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 31B45288DAF for ; Fri, 22 Mar 2024 11:00:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 963F73FE5F; Fri, 22 Mar 2024 10:59:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="vGe67JcL"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kGrOyUqt" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4AD13F9E7; Fri, 22 Mar 2024 10:59:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711105165; cv=none; b=lOEiZSSBJm+fVZiBwpRw/fTIj5p+sHNwErVWmYoeqYE3r4DDVTHPmo/+MDmsVB6JNiZSAVFAesZqrKN0QqIpoEIFOiDyIWbF5sAZDKwdhoyEYigK175FpRhjNe9H6YCwAVWdIaf1MQK3i7z3QloGPdOr4nHitCCCSkNlzGwu+XM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711105165; c=relaxed/simple; bh=6y0SKQP3yg6vtCvcWYd+vp+JKLb8VWhaYpIGqyabjVU=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=m6NxfVR1aIQZaKIy/F73cYQg4THyWr8mB1F/FhRC1UCtDqcrA5Gw6wmjCi9maWWpgGjie9yj8DYgKiqHAgu8eAspjd2wL4uUQCFODNwaHtOf6AfeHbVbNfZ4I7CPmCFhm3NDXquM3pDaH7WVI11KleH7DcAX15NQKdV2t08LyZY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=vGe67JcL; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=kGrOyUqt; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Fri, 22 Mar 2024 10:59:21 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1711105162; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3vEhqtTPlY1TvYFcXQO0SZFnOE9PzEWsix7+imOWO1w=; b=vGe67JcLFJCYQqmooohRfmyHainVE5yfJ5xnTU36TY4u+33OzzVs9ZksFT2lTwdClQr6/j qCOjbwmHtbjvZ9Z8+9Az9YC11olegr6rO1jmkvi3Eyl3DOLroAhrQs6pMWKF0cT3kywYC0 R0Rsit1KdnrYFPVjznZlupfi4vBZ8g6TGYmCoG+7DBIgvfWH1NAfStKclpmZifIdmstsCj M1qSVRBA1k0CaIqGswPn36ks+FMADE2wPwGOdgZwAgIJ4wxEvy2xPDD/cK+jStd0xcfb25 gOrtVahBZH48mzj76l5qPB/Vhbr7tHHoekoDupkMiKWMei3vJ1kuh5E4tvyxpQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1711105162; h=from:from:sender:sender:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3vEhqtTPlY1TvYFcXQO0SZFnOE9PzEWsix7+imOWO1w=; b=kGrOyUqti5y5HY78ZYmB4cI3qKJXRR4hzafY8qBVkqRJKIiPAaydopSiiNb7ajx95xZKss 05/huNv6NCuFA0Bg== From: "tip-bot2 for Alexey Dobriyan" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/asm] x86/asm/64: Clean up memset16(), memset32(), memset64() assembly constraints in Cc: Alexey Dobriyan , Ingo Molnar , Uros Bizjak , Linus Torvalds , Andy Lutomirski , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240314165715.31831-1-adobriyan@gmail.com> References: <20240314165715.31831-1-adobriyan@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171110516145.10875.12682506155345317874.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the x86/asm branch of tip: Commit-ID: 4c9a93800121e90484cd07c8e5bde70e31cdb996 Gitweb: https://git.kernel.org/tip/4c9a93800121e90484cd07c8e5bde70e31cdb996 Author: Alexey Dobriyan AuthorDate: Thu, 14 Mar 2024 19:57:15 +03:00 Committer: Ingo Molnar CommitterDate: Fri, 22 Mar 2024 11:47:34 +01:00 x86/asm/64: Clean up memset16(), memset32(), memset64() assembly constraints in - Use "+" constraint modifier, simplify inputs and output lists, delete dummy variables with meaningless names, "&" only makes sense in complex assembly creating constraints on intermediate registers. But 1 instruction assemblies don't have inner body so to speak. - Write "rep stos*" on one line: Rep prefix is integral part of x86 instruction. I'm not sure why people separate "rep" with newline. Uros Bizjak adds context: "some archaic assemblers rejected 'rep insn' on one line. I have checked that the minimum required binutils-2.25 assembles this without problems." - Use __auto_type for maximum copy pasta experience, - Reformat a bit to make everything looks nicer. Note that "memory" clobber is too much if "n" is known at compile time. However, "=m" (*(T(*)[n])s) doesn't work because -Wvla even if "n" is compile time constant: if (BCP(n)) { rep stos : "=m" (*(T(*)[n])s) } else { rep stosw : "memory" } The above doesn't work. Signed-off-by: Alexey Dobriyan Signed-off-by: Ingo Molnar Reviewed-by: Uros Bizjak Cc: Linus Torvalds Cc: Andy Lutomirski Cc: "H. Peter Anvin" Link: https://lore.kernel.org/r/20240314165715.31831-1-adobriyan@gmail.com --- arch/x86/include/asm/string_64.h | 45 ++++++++++++++++--------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/arch/x86/include/asm/string_64.h b/arch/x86/include/asm/string_64.h index 857d364..9d0b324 100644 --- a/arch/x86/include/asm/string_64.h +++ b/arch/x86/include/asm/string_64.h @@ -30,37 +30,40 @@ void *__memset(void *s, int c, size_t n); #define __HAVE_ARCH_MEMSET16 static inline void *memset16(uint16_t *s, uint16_t v, size_t n) { - long d0, d1; - asm volatile("rep\n\t" - "stosw" - : "=&c" (d0), "=&D" (d1) - : "a" (v), "1" (s), "0" (n) - : "memory"); - return s; + const __auto_type s0 = s; + asm volatile ( + "rep stosw" + : "+D" (s), "+c" (n) + : "a" (v) + : "memory" + ); + return s0; } #define __HAVE_ARCH_MEMSET32 static inline void *memset32(uint32_t *s, uint32_t v, size_t n) { - long d0, d1; - asm volatile("rep\n\t" - "stosl" - : "=&c" (d0), "=&D" (d1) - : "a" (v), "1" (s), "0" (n) - : "memory"); - return s; + const __auto_type s0 = s; + asm volatile ( + "rep stosl" + : "+D" (s), "+c" (n) + : "a" (v) + : "memory" + ); + return s0; } #define __HAVE_ARCH_MEMSET64 static inline void *memset64(uint64_t *s, uint64_t v, size_t n) { - long d0, d1; - asm volatile("rep\n\t" - "stosq" - : "=&c" (d0), "=&D" (d1) - : "a" (v), "1" (s), "0" (n) - : "memory"); - return s; + const __auto_type s0 = s; + asm volatile ( + "rep stosq" + : "+D" (s), "+c" (n) + : "a" (v) + : "memory" + ); + return s0; } #endif