From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 7717D386569 for ; Mon, 30 Mar 2026 05:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774850331; cv=none; b=LgKlZv09FUgbqXVzrZw7xN6PEhPT4KS9gqaQIwgwPg1zRKq9C2HRY8KRRfvzbIxAne5Co3y7jWXzi1atvy1yy3akZ+NwRBrIT0vtim4Fy7muWzmdLnH7p1myCyTCepZPrXF8bvY1FVSv/g4Ko2D+/XTG1H1u1ZPL8VIXly4QYhA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774850331; c=relaxed/simple; bh=JxlY+Q6YlArxRPFjIBcDy7cUCg1qCv5lcXgIRei49Ic=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EMTO18iGGQdJqeGGrsZrSd3ijSJ72ckypRwUgb2piB+89TeKAmZr9NHmbDFIsIYYv7sDj7S4xZMn8Jl8ipgtdinf9z9wo9iSjZ6OWFCmuuiZLTCTbCkCCyJGDHV4dJS98udNc1zJk0jy7gmVEdmNPJpD6TuPTNXh/UOFiO3mA2k= ARC-Authentication-Results:i=1; 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=DVbGw4CQ; arc=none smtp.client-ip=209.85.221.45 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="DVbGw4CQ" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-43d01d6b50cso204058f8f.1 for ; Sun, 29 Mar 2026 22:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774850328; x=1775455128; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CAyX6GXYtg7Rn3FHKIXBbFd5m2ihGyjftaZK5jVFt/A=; b=DVbGw4CQwgDn+9T8CmwjqsX7/S0z875AF54jkzXNwdS+DW9dfeZlaFio5YkCRtrOj8 nlCwV7UebdsssVD+Mfs1BkjJGWoLnR+9UPho2ztwnPnexxq5czfWrvxS2viczq3xoa7n LSdJ3KpnMm5VvaVSjbKycc6rpX8F9cmD+6zfPiMtG3xjWzdXlA1SS26uZSzJh0/FPtxP bKWt4C3wFHyOHgeJPSMwHY9Kv6bYJqXioJXwHKZr5M5VADlwysjFHeR1osS6/Tf5W7qJ Qr9aELQcLTMDwPv/+JsLyhmj+SgS4R0Et8hqsibjl6NwIy3RaiWkJ3b4Wk4vXeHRzv8I ftmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774850328; x=1775455128; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=CAyX6GXYtg7Rn3FHKIXBbFd5m2ihGyjftaZK5jVFt/A=; b=hqieEIUTQpCaDFh812VEzwVTh6Lzgp4YJpL5XhMGZm+qWUg5zTfjs6/80+OATRkTAq 1zrzKSTyvJdv1DyFFHWcfs2dBKNW0OO7IXmGHbLtvVo1bcQdYcu3B4Gg8bqGmcdK/L0G Fp93LWJEkgpwH2FRnc8Vl3m7VZONFSS7aVdcpm4ophW2gM3dfuBRMiBiM0PaNcfck2L1 yPVg3WYRrklVY2Qon10sZoWK68/Rz7oOnd25Do8tfhr1U2d4c4E+eueM82zfpS9FYR8k GYHG0BDw6dhpFiOFs/jR/ra9iWRqMBpGaFtmbVz+ygbfT6wYa+eEpJEm+uqVqpUrS38C SdZQ== X-Forwarded-Encrypted: i=1; AJvYcCWxzLyD7bNS7Gs852qwDBAhU58pmCMoATECa4rLvKTN2Gk00wiq8610zx0hWtc9TckQsKsLZV5yIBb70FQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9qXYokuRlfENuJrj+TvHpZfhyZPQ7zkzqIGQRNHe4vDy1llMX CJrQu+JqasVJkZzrRRbr+29+6oYyRfs00EZUr8rBQzaSiN7hZt9razBX7xRkvGDr X-Gm-Gg: ATEYQzy+l9wGkA2AHqCLNk2EkXBfIh/fkb/wgRGDz9YmlrTfxhVyikdhWb+YC40D+pY 3biERs28+qqqx0t6UOAfJtOMJ/0V5BKkH4wedyEOdeJs4GXQQMm8JlUgkvsSd18c4XLmYafRIHE dzCwHJ+uJhaWG1+cAw55rB/IrHhq8GPV3Qt4Iyymk4RSuR199NWn2eYl9pUpBlliXRiYwUWHNaz 9O8g1tHsTWfk0JfYzUZgNd5liuv6ap7oVhoXNcyjJ9zErksBa4NQWl87oCV5ycpeRnux3irguXs svqwWD8cOjQ6aqNY1xv2gnerevz86Y1moyWdyUTqWmL4w2wA0E4P7/0ZGE5KPNT4wKqHI0nw3Yi 2HC57OcXYj2oF1diaroal1MdXtHaEW0Aw8ZAX8Np+mrloOU5msTMELZsFmfCiUfFBHYy9YZJ2BO nuHBXudALfY/CJImn1RCMEg4S/lkl5zgzIy5hO2UK+efvKzdkHygiQN2Ucz6KBAkerg2pDyAB5d rbZUuXDSbcSZ9dJjUYXcgjMBtlGe5qFMrz41PU2WR7Y X-Received: by 2002:a05:6000:2681:b0:439:c78b:cbef with SMTP id ffacd0b85a97d-43b9ea4a534mr18221034f8f.25.1774850327772; Sun, 29 Mar 2026 22:58:47 -0700 (PDT) Received: from fedora ([193.77.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43cf247079esm16324269f8f.25.2026.03.29.22.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Mar 2026 22:58:46 -0700 (PDT) From: Uros Bizjak To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak , "Peter Zijlstra (Intel)" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH RESEND v4 2/4] x86/segment: Remove unnecessary memory clobber from savesegment() Date: Mon, 30 Mar 2026 07:57:43 +0200 Message-ID: <20260330055823.5793-2-ubizjak@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260330055823.5793-1-ubizjak@gmail.com> References: <20260330055823.5793-1-ubizjak@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The savesegment() macro uses inline assembly to copy a segment register into a general-purpose register: movl %seg, reg This instruction does not access memory, yet the inline asm currently declares a "memory" clobber, which unnecessarily acts as a compiler barrier and may inhibit optimization. Remove the "memory" clobber and mark the asm as `asm volatile` instead. Segment register loads in the kernel are implemented using `asm volatile`, so the compiler will not schedule segment register reads before those loads. Using `asm volatile` preserves the intended ordering with other segment register operations without imposing an unnecessary global memory barrier. No functional change intended. Signed-off-by: Uros Bizjak Acked-by: "Peter Zijlstra (Intel)" Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" --- arch/x86/include/asm/segment.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h index 9f5be2bbd291..3fe3a310844c 100644 --- a/arch/x86/include/asm/segment.h +++ b/arch/x86/include/asm/segment.h @@ -348,7 +348,7 @@ static inline void __loadsegment_fs(unsigned short value) * Save a segment register away: */ #define savesegment(seg, value) \ - asm("movl %%" #seg ",%k0" : "=r" (value) : : "memory") + asm volatile("movl %%" #seg ",%k0" : "=r" (value)) #endif /* !__ASSEMBLER__ */ #endif /* __KERNEL__ */ -- 2.53.0