From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.zytor.com (terminus.zytor.com [198.137.202.136]) (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 0C8DD391E7F for ; Thu, 12 Mar 2026 18:57:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.136 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773341859; cv=none; b=rsv0Yhz63Wxs+wlj5gUG7jQxvaZFcXYW5nOqysKhQGHesRE2KXMgiiKOGRhZOOQWdr+6Ls8Kgp9QwmNuy2dK5pF0R8PwN/fMSUjuAxvHehtLWNrwVZd0GZphF9C9r3fiAe9pnsEL3FsSUokFSB+Z74JTxzIy1Mil/2AmBph2r9E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773341859; c=relaxed/simple; bh=j33o/Qeuc0okdniIUYHmQSzF2Ot/oGfCeshayam2g00=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=XOlkKjWwUvCpYNL/8UKQ0uc5dPg9H5Y5u/N8KPwRHVxBm5X6CxRMZm5N4g5FhIXjW9csOR0LFzVyM6O/aDRVh/91BZd1X8Nnw6L+sI3yWB8ECHdOZsFnKDp/g9J12neEiNTDAXwmpYKioS7pXcN8uzeWxV+HjoLIWJ157VIic14= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com; spf=pass smtp.mailfrom=zytor.com; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b=B3CIUrlY; arc=none smtp.client-ip=198.137.202.136 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=zytor.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=zytor.com header.i=@zytor.com header.b="B3CIUrlY" Received: from [172.27.2.41] (c-76-133-66-138.hsd1.ca.comcast.net [76.133.66.138]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 62CIv3Jg2923990 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Thu, 12 Mar 2026 11:57:03 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 62CIv3Jg2923990 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2026022301; t=1773341825; bh=fhNmo//t2wNJNmlpVNgfqn5DltY4+lIWcgYO+TakIpo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=B3CIUrlYo0n1y646oYuSCEL0tFpm92Tgc8i4BvCRi7p+5sv2B0logMbQxU3cJh0Md I9pF0O/2HbqMZ6B6JUE+/04HpFS8QmORNXBkhIx6Ouu61yRcLuYiVcPU+h1iq5NXGp ZpxOxYGy8hPmZz2GO7IipaKVruFVUAD5omaIit+4Jge4ZW57iR5FEpYOOLvizoSePP dxDwjsO+8DxM0WRE4k7pIFWMqtaTSauStDhy/00iJOG1mfzJUjJcOwhYLpIOu3hNhQ VCd8Qr3QkI/2OLY7BHeINS0mh49Tpf9akS6iNnZxdEIPM4YpEDxNZvXhsXHu3uPVUP DCbVCC0861S5g== Message-ID: <0fd93689-3038-467e-ac96-ff5ad6533147@zytor.com> Date: Thu, 12 Mar 2026 11:56:58 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [tip: x86/cleanups] x86/segment: Use MOVL when reading segment registers To: Uros Bizjak Cc: linux-kernel@vger.kernel.org, "Borislav Petkov (AMD)" , x86@kernel.org, Dave Hansen , Ingo Molnar , Thomas Gleixner , Peter Zijlstra , David Laight References: <20260105090422.6243-1-ubizjak@gmail.com> <176891088183.510.8607818928752445249.tip-bot2@tip-bot2> <3A54B6DC-2462-41DA-8C34-D38CCD2A9A2B@zytor.com> Content-Language: en-US, sv-SE From: "H. Peter Anvin" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2026-03-12 02:30, Uros Bizjak wrote: > > so one can use this variant when the segment register is really saved > to a memory. The above code improves to: > > 32333: 8c a2 0c 0c 00 00 mov %fs,0xc0c(%rdx) > 32339: 8c aa 0e 0c 00 00 mov %gs,0xc0e(%rdx) > > Unfortunately, inline asm does not support alternative instructions > that would depend on output argument type (reg vs mem), so the > selection can not be automatic. But by having specialized macro, a > developer can use the variant that results in the most optimal code. > > A prototype patch is attached to the message. > On a more general note, there is a *really* ugly way to distinguish operand type on the gas side: .section ".rodata","a" .macro classify typevar:req argument:req \typevar = 0 .irpc char,\argument .ifeq .L_type .ifc \char,% \typevar = 1 /* Register */ .endif .ifc \char,( \typevar = 2 /* Memory */ .endif .ifc \char,$ \typevar = 3 /* Immediate */ .endif .endif .endr .ifne .L_type \typevar = 2 .endif .endm classify .L_type,%rax .ascii "Type = " .byte .L_type + 0x30 .asciz "\n" -hpa