From nobody Wed Apr 1 12:37:23 2026 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 E855B3D8901; Tue, 31 Mar 2026 08:02:10 +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=1774944132; cv=none; b=HWGUIHFF8oAN+Ky2YfUIu7funG71uha9JW6+Wu8N+Jpkfdybec224mapirP3n9V/Yfbxii0nzFmgf6JzOqPJJowukyP2LxczhH+EIKgfUTDP1q9BmvJpEuI+FQjU8nREmpCXcrUIDCWOmqN96tFHqPKRDhzsZzU5BQ4oXAUTF6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774944132; c=relaxed/simple; bh=1jbIuze1pWTbvjPBN7eDJj1H6QTGe/ZaYgoa/egkRmg=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=GS4nNdVU0xLJjbm4CaRkyXATB2Y5+IZp2i/zYJ28RHZl5/ENQIwJe0TlHGRSyGBYIWY+8Af7X3xy0u/SnJnUUEPkiXbRwMQdMXURGQLUVMrtkcVp1TdmF4yPFw1EfaBXiPfCt+5PVRTYhU5xB435+3XVOzk50Sjq7tQhnCZkSvU= 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=Zzsewuku; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=rQ5qhvgJ; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Zzsewuku"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rQ5qhvgJ" Date: Tue, 31 Mar 2026 08:02:07 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774944129; 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=tL9D6xx3YlMkPAHmefHpFxtFQJV9MKL8PqzojVoGVqM=; b=ZzsewukuTtGS0sjxbvayR2RpB2JDwMkJaQE7gmMhLvHx3B7VCNIuKTvJWyS3iKwHq255ga di/Y3a24MylZHNQmnMbNnTz6qtswsgs50rdhsZdm+FXUe/b3pMW4nMG++2bsg0l5eubP5i ba32Fjjpyi/vzaD9qE8EaxaYT4OL2ud5ELIoleTJpFbTbY3i04e0yG2IGjSqQq57BitucQ 9XFYG9w/1irV5raI4D6S/2jl4vTpjJ90u4+R+Jym4LFr07eRLkexqiWzdadDcFWYHQ+ZgW dAwQ5bO0Lyp18yUCLJup3LI2DedkyWRu45+UK1qQOWhxfsE3vwtbgCN6XdEavA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774944129; 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=tL9D6xx3YlMkPAHmefHpFxtFQJV9MKL8PqzojVoGVqM=; b=rQ5qhvgJwg6CNfEDJKjsqmleX5PpsiTQiSsZ8rZvaOpbqVk6GRf2z3tnpJT/yP4txQdCk4 7SL9zczdzbTSOzCg== From: "tip-bot2 for Uros Bizjak" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/asm] x86/elf: Use savesegment() for segment register reads in ELF core dump Cc: Uros Bizjak , Ingo Molnar , "H. Peter Anvin" , Linus Torvalds , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260330085938.67985-1-ubizjak@gmail.com> References: <20260330085938.67985-1-ubizjak@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177494412789.1647592.4759277386663312528.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: quoted-printable The following commit has been merged into the x86/asm branch of tip: Commit-ID: 47d2f007615ace34c5ec9026cd5f286833c62c1b Gitweb: https://git.kernel.org/tip/47d2f007615ace34c5ec9026cd5f28683= 3c62c1b Author: Uros Bizjak AuthorDate: Mon, 30 Mar 2026 10:59:20 +02:00 Committer: Ingo Molnar CommitterDate: Tue, 31 Mar 2026 09:50:10 +02:00 x86/elf: Use savesegment() for segment register reads in ELF core dump ELF_CORE_COPY_REGS() currently reads %ds, %es, %fs, and %gs using inline assembly and manual zero-extension. This results in redundant instructions like `mov %eax,%eax`. Replace the inline assembly with the `savesegment()` helper, which automatically zero-extends the value to the full register width, eliminating unnecessary instructions. For example, the %ds load sequence changes from: d03: 8c d8 mov %ds,%eax d05: 89 c0 mov %eax,%eax d07: 48 89 84 24 38 01 00 mov %rax,0x138(%rsp) d0e: 00 to: ce8: 8c d8 mov %ds,%eax cea: 48 89 84 24 38 01 00 mov %rax,0x138(%rsp) cf1: 00 thus eliminating the unnecessary zero-extending `mov %eax,%eax`. No functional change intended. Signed-off-by: Uros Bizjak Signed-off-by: Ingo Molnar Cc: H. Peter Anvin Cc: Linus Torvalds Link: https://patch.msgid.link/20260330085938.67985-1-ubizjak@gmail.com --- arch/x86/include/asm/elf.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h index 2ba5f16..c7f9897 100644 --- a/arch/x86/include/asm/elf.h +++ b/arch/x86/include/asm/elf.h @@ -187,7 +187,6 @@ void set_personality_ia32(bool); =20 #define ELF_CORE_COPY_REGS(pr_reg, regs) \ do { \ - unsigned v; \ (pr_reg)[0] =3D (regs)->r15; \ (pr_reg)[1] =3D (regs)->r14; \ (pr_reg)[2] =3D (regs)->r13; \ @@ -211,10 +210,10 @@ do { \ (pr_reg)[20] =3D (regs)->ss; \ (pr_reg)[21] =3D x86_fsbase_read_cpu(); \ (pr_reg)[22] =3D x86_gsbase_read_cpu_inactive(); \ - asm("movl %%ds,%0" : "=3Dr" (v)); (pr_reg)[23] =3D v; \ - asm("movl %%es,%0" : "=3Dr" (v)); (pr_reg)[24] =3D v; \ - asm("movl %%fs,%0" : "=3Dr" (v)); (pr_reg)[25] =3D v; \ - asm("movl %%gs,%0" : "=3Dr" (v)); (pr_reg)[26] =3D v; \ + savesegment(ds, (pr_reg)[23]); \ + savesegment(es, (pr_reg)[24]); \ + savesegment(fs, (pr_reg)[25]); \ + savesegment(gs, (pr_reg)[26]); \ } while (0); =20 /* I'm not sure if we can use '-' here */