From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72E493469FA for ; Wed, 1 Apr 2026 07:00:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.208.177 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775026804; cv=pass; b=h4tbOIGenZdKWNYuNJgXsoa4JEd6AFGvG6rVa0odPpEAJfTQW+6jSxdlbOd3MQMy8P0RQunVj06+PGjGe1rqj51EIwsF4IJkuE9qzmt6eSPWQ4fvR9sHCZx0XJ3YfufUPMunjswAuCWFcr5Grj7hH6b8VYkrk4bWq42oG8Dn/7c= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775026804; c=relaxed/simple; bh=EZw0xTrrHS8NCGwOYVxrEJTQU8Emip4UNVDoMSCdCGU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ECXiR8cA5p4N6LaKru9JUeifgHGKN1gOpyFbDuB8GmJQhNAGTpjZ3igKV6t+q5dVbU9UfI2h1YcLiopUg/CWYGp+VEgf86lgll0Pla7VieVqTcpW5zEodRGdbKp2L2nIaqjad6lyUvpVHL6XH8Hl53HBQJnPtS31OXHbc5nZNuE= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TskO6cCF; arc=pass smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TskO6cCF" Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-38cbe79dddcso8960171fa.2 for ; Wed, 01 Apr 2026 00:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775026800; cv=none; d=google.com; s=arc-20240605; b=HheCnubf3KYbS5q3zRsbcQuNm2PJy69KNtBCV8xxDLVbyXBpgywgNAz3uMWxDC3KH9 NHUYXu4gBCyZTsvUVkzVl88TskmuqhIzjISSNf+904SKYkxuzR5XcI1enhn8zmVKsTJS hm+mv4P6vvBEkqXL739jn4HlKYRiciawSTB+xxtctJ+mank+tg4ON+EHKmNkIf1+5AWc 3Dpd8ofvFP5QdkY1Jg9/G5YQxOjkBl5+/hYGUkbEirn8vobqHQPJZYPiko7UnmP+Rqru +JFZLQNIx5nHSz3FgoICacxbmpgJL58QDo03L6QANoymEHDG8epfl9BKpV1n3J8sF2eP sxbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=X2fSX6/oSY51UXXqv+E0FoxinKuqIlzgMM14pWhQn9E=; fh=4t0oViTzLm9NBlxHjjKNG0mkjCbuC+w6xw20MDesuos=; b=lb9XM8hpoSEzqpHBdrfwOkYJwkMSPkjSnV7ZqNKawv3gVWb/SUC8IeHe9aDSIxJFAQ kzKAY5JZX57uidLyfVXC+gxt15ut8k8a6AQXSp3abnVuz1BK9oHL2l3r3nTyqmdUtOq+ P+AKg+/mxxRLrhGlRQLcBuQL08Zn00mOg8iz8KGKWGeRT4SAcn1TraqcHk1nlXpTVKBF lImw3DnzWtNxeHHx9ri4z0mmnORG4vQs/L8JkfHkR3kSYXBJEGU5sAIFn47eTfLtD14X jHlwkfv4Pv30i8kEJ0cgjkvEUMiOV30q/d/Zp8Qr+KMcCioBi/gPqcxpzkd6NY6ZHI+P FPqw==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775026800; x=1775631600; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=X2fSX6/oSY51UXXqv+E0FoxinKuqIlzgMM14pWhQn9E=; b=TskO6cCF+67VzWRYjuNhqWb02kM5Uzy61e/zej31ncCX4ahW48W5l6YIf9oFSTI/qq AhD2FSCv3L02/MfCpMgm2OvbtnPke9Tz08bKrv91LTp3FHrRFtyoOSvMRSsqKyFKh7I9 FSyGFFXVRX5OcRjKRBhzYj5qtqYHilwg9tmtdLqp4yq3rXEG4gb7IxFRWPJRSPi4Ac1c v5F6vm0IZ41s0nLAOOMV6Q+5mo1ft5j7+lsiW4/sb+Al21gmFzQZon9cplBJCHemBXXo Ra/bKtUIwGL19pzvJbnPaKGZsUPhNUHi2I9xvd7rI/ubSkADd1kiNxsAFAJ+h7AKpbXz 3ujg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775026800; x=1775631600; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=X2fSX6/oSY51UXXqv+E0FoxinKuqIlzgMM14pWhQn9E=; b=VpiU1lbKaAyoMW32xJq//w+ynhM08bO827fYz+Qf94QXCL6cXCTlwj5zNoohzcm38C /N3shniLgUFloQ3J/hT6NCiHR1OoJa99nD8DRz9Qd1AUUPqHJYppqFKARVRGyErNzr+q G4SQgVliBgs43o1nd3oKljhCPokTQniWlmybrpVhElPvbM2YdmrGngbsW/k50Qjziqf7 YziKVwr+oj016zCLTDKzQNPVT4vceXz2O2SSh30NtT74bkvSN/1yH6VeC7hcs/CBA0mZ vdkOjNWbD/jqlwih4IGnh5yQ9a4QEf2Ie6MYApID7A9JZR8ipoxnNR6ARwDbsVrQiza/ Clsg== X-Forwarded-Encrypted: i=1; AJvYcCUexWA7M/t2HieaNmLOR0WThdswVqYwZcT5R2Vcxm4mHpw7QvUkafJTTu9BjxEZ1boH8qxRkK9RNaVk48Y=@vger.kernel.org X-Gm-Message-State: AOJu0YxQdw2RKVgxHtHsgwLaODfkC4fm9bHyUahxGpuxxpy41gvVpPWF swTaMUqOiJ8vgbHnOlSsxG7ykPH4kSSovoufPC11BkFcj0p/z2+kYYWxeUNrCYUXHRwc0IM13WE gIOstktG7NbBiOh0rXeKSrgbDzoumxG8= X-Gm-Gg: ATEYQzxFMZct14sES7461dDOMpF0JXxJ7L7ei3lA2AYtUJpur329Pvwt3/rszlKOkD2 8gjr4e6YYJOMO7/zTgeOsl7zcR577/mP9KYEOEltcYwOUt5ct2DH2Hb4IJvk+N3gXxWqSfJCXir 7/+LV+KROhhkVILsa8JZmLdkwV77rLfPeamoZlnEwQtQYGQBfaoSSGjTr/M5iSvLFxfILMaix93 lK4LDiivTh/g/jOsx0HXppFHggIT/46CG6HGrHNOXtVTtS6QxbLp0OiPPVuTKr7qdqaBAKeDY0B BCv4yNvb7zkD13lXsANrnFbTGJT4/G9FRXyPeuOuvhOgN/iav7WCrMYbOCqve6QUE0PRPTL3/AY iKllrAIK41eYGmGhrs7wCaVrOc3a0/v91fHK4c9hF6ujwnw== X-Received: by 2002:a2e:bc88:0:b0:38a:4197:862c with SMTP id 38308e7fff4ca-38cc2f38bfcmr9452001fa.9.1775026800231; Wed, 01 Apr 2026 00:00:00 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260331063838.108857-1-ubizjak@gmail.com> In-Reply-To: From: Uros Bizjak Date: Wed, 1 Apr 2026 08:59:47 +0200 X-Gm-Features: AQROBzDqPaN-KSlHPDL-X_ePLtURkG4OW_dxi05J-49ZQGtri4bKnAbEWg7KYmg Message-ID: Subject: Re: [PATCH 1/2] x86/segment: Introduce storesegment() helper to write segment selectors to memory To: Ingo Molnar Cc: x86@kernel.org, linux-kernel@vger.kernel.org, "H. Peter Anvin" , Thomas Gleixner , Borislav Petkov , Dave Hansen Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Apr 1, 2026 at 8:40=E2=80=AFAM Ingo Molnar wrote= : > > > Why does the API have to be split into =3Dr and =3Dm variants? > > > > > > Coulnd't we use a more generic constraint and let the compiler > > > decide what the target is? Would that negatively impact > > > other aspects of code generation? > > > > The "=3Dr" variant actually outputs zero-extended value to the whole > > register width. So, the "=3Dr" variant is used to eliminate > > zero-extensions when the value is used in the follow-up calculations, > > comparisons, or when the value is stored to a location that is more > > than 16-bits wide. Additionally, "r" variant always uses MOVL, where > > operand size prefix byte (0x66) is not needed. > > > > The "=3Dm" variant only outputs to a 16-bit location. Having "=3Drm" he= re > > would always emit a 0x66 operand size prefix when register is used as > > an output, and there would be many zero-extensions emitted, because > > the compiler needs to zero-extend the value from 'unsigned short' to > > anything wider. > > > > Other than that, GCC (and Clang, too) has serious problems with "=3Drm" > > output constraints. Forward propagation (AKA combine pass) does not > > work reliably with assembly outputs (due to always present clobbers > > for assembly clauses), so there will be many cases of moves to a > > temporary register and even to a temporary stack location with this > > constraint. Having two separate functions (with clear and > > informational function comment) leaves the decision to the programmer, > > which function is the most optimal. > > Yeah, so I still have a problem with the split API, 'savesegment()' > is very similar to 'storesegment()' and there's no real way to tell > them apart in practice. > > Since the main difference is that the =3Dm variant outputs to an u16, I'd > suggest naming the two APIs according to the type they handle, not some > random word that nobody remembers: > > savesegment() > savesegment_u16() > > ... or so? Yes, the above is a good proposal. I was undecided how to name the new function, but the above is definitely more informative. Maybe also emphasize that the new function operates on memory, so: savesegment_mem16() (the location does not need to be unsigned)? Thanks, Uros.