From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f174.google.com (mail-qt1-f174.google.com [209.85.160.174]) (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 CE6F4320CA8 for ; Thu, 18 Dec 2025 10:58:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766055521; cv=none; b=WF5imMG/qCGT3SnomKpcKyUIepMXFcuLUspow8PJja3jfgGR7A1tSPaVADguhi1OTUAlQ59Tzo9ne595uumfpioMUl6XpCeUHdDDJm179hGvyzJsaVeaQ+OFHUm5Z+d+xMVhJZoFNPKytWD2E2WZwz/UGOV7N5PhcGX1UFWkS2A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766055521; c=relaxed/simple; bh=SNwamGmVHjruQ7JTYEhBCTDEVv4fhkDNhhfBBZcOAGw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=rArK5oPrBd6tT5AH6jkAqeedcCKqj5e1hXRi/2PyQyjBqNrRcWk7IxoqR/joPFyFRJ1Oi3j7brtPX6smOSJWgM2fe8eW9ltLBYJprP4F5G7sHtktjuYw1tx4U93hC1CIPLkqPSkcv0P7OyYtwLC7ETyqud1MNDO7KlpSrpaGWVY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4Q1Y14xs; arc=none smtp.client-ip=209.85.160.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4Q1Y14xs" Received: by mail-qt1-f174.google.com with SMTP id d75a77b69052e-4ee1fca7a16so3963761cf.3 for ; Thu, 18 Dec 2025 02:58:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1766055517; x=1766660317; 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=VjD9k4GxT/dJM/CYl/w8rnkSJnKsP93xg3WFghQ+pno=; b=4Q1Y14xsK4DZShWnfSRycza6vASxJAuR88NuWC7EkvzGDkkGyYjzhJHVHVoOVvOblx /6WZe2sgn60Vb6bch0CYIGchTaTumcQ0fti04/3W0PFQjDkqpix+66YRNd9+/jSJv01e X+jajr4B/tksvP8R00KCK9sn0VZ0qQj1PjL7oo1Vtt8BpH0n3XUwAQUyVQ1RZvEsEqnI dsO+FF+hYsSsXdxnIIKioUZ4ZSFsgOJyQM85zb6O65LB6Iuau34BjOeYWCfQG7Cw7eff y3SeKLZHEM2rKZfUkB/Rx6QV2WkCkBcE2BReug1VayxPK4oKdUatke9vpyuegJiqaiMF t59Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766055517; x=1766660317; 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=VjD9k4GxT/dJM/CYl/w8rnkSJnKsP93xg3WFghQ+pno=; b=iS6GIPlGXvX/ylILaJpLiLTu7N5mVgGCfvSp/9ocJLiytfJW8tiPyu3EF2vEUjh3gM o29YKa7N58VYLCJKvdQaA7ypIqJs2v6WeD0dqn9lNvjwHgBZqMGApfkfyZ8W6VzhGZHN hMjwfeNfXwuxebW7bxTCOjCGgJUY74MNoTY2o1C9gCbLtURTNxVoeR9GJToOHxpodGXm opT2MRSg529u1bH46z3AKyDVPNg+kMjx9y/TVwhPxbDyipaBDpROLec4K9Gyz4uVHis9 yydneYe2YjEy70J+7HT/K5KPiSrQsPnutJeZpLJlyPxnQuvMWfn5ssplwvI+pMaS7B5N OZzA== X-Forwarded-Encrypted: i=1; AJvYcCV3KWCz9fOwwIPhZay2e34LxkYUEbg76lrPU2S3w+ab+UD6v0xGg5TAdYzPVxw8yjzXE6HvDoihhsV+CUM=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+G/8bwl4yNQs7gVKdNFeCcqo8v8x4TBFD2BlcWY/Y/CX8oax7 6o3zn0aDZaIiruJa1CXXlRP9VjxDsRc6qaOfbIPbGWfSEfVsMfSgn5EXpNiESHcMDvhMqbgQc9r IGBQIvL0d83GJxva2JMggkfbjCf8i663jDj+aySN9 X-Gm-Gg: AY/fxX5nLbAhgAW+QjMIrhOVaj4nsYwfN31361cCfrfXUDf5KCAOZStGOdNkOUduznW jNcn/9wtgD3DcHPLEPkCGX/rGyCFNIhQv5w/rldiiZ7hFM8D0VBZdElAmjI1uBcGBZ7pkmy4P+A H5TmW2etRi9Rr8u4vIgpA1hcyHZOCwzVedUY91LqmTqPio+jwOsrwzcMOsKGWbrfdeUhJb0gXw9 4z82BuGLJOL7PcL4T95lsPagK/xMDInKGLUC7GjY5JGj7n1uquBpTI0zytt1M8Zl8APTNld X-Google-Smtp-Source: AGHT+IEHX4/JJ+PByZwnUMcTRJTD9RisbLPpB580fbhU8O1kbfkrLFRGl3WXjeveVj+cgo8+Aj318T8zOfa2wbVgFos= X-Received: by 2002:a05:622a:1451:b0:4ed:a744:adc with SMTP id d75a77b69052e-4f1d04741b6mr252034061cf.10.1766055516390; Thu, 18 Dec 2025 02:58:36 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20251218095434.1052422-1-edumazet@google.com> <0214B313-79AF-411F-AE04-8FF2705C5A92@zytor.com> <20251218102256.GP3707891@noisy.programming.kicks-ass.net> In-Reply-To: <20251218102256.GP3707891@noisy.programming.kicks-ass.net> From: Eric Dumazet Date: Thu, 18 Dec 2025 11:58:25 +0100 X-Gm-Features: AQt7F2rxqnK9PvBIpkZewaz0OBH82PH7zzpTbdzkPxgMlPIK-WznD1Dmw78AeIA Message-ID: Subject: Re: [PATCH] x86/irqflags: Force a register output in native_save_fl() To: Peter Zijlstra Cc: "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, linux-kernel , Eric Dumazet Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Dec 18, 2025 at 11:22=E2=80=AFAM Peter Zijlstra wrote: > > On Thu, Dec 18, 2025 at 11:15:37AM +0100, Eric Dumazet wrote: > > > > >--- a/arch/x86/include/asm/irqflags.h > > > >+++ b/arch/x86/include/asm/irqflags.h > > > >@@ -18,14 +18,9 @@ extern __always_inline unsigned long native_save_= fl(void) > > > > { > > > > unsigned long flags; > > > > > > > >- /* > > > >- * "=3Drm" is safe here, because "pop" adjusts the stack befo= re > > > >- * it evaluates its effective address -- this is part of the > > > >- * documented behavior of the "pop" instruction. > > > >- */ > > > > asm volatile("# __raw_save_flags\n\t" > > > > "pushf ; pop %0" > > > >- : "=3Drm" (flags) > > > >+ : "=3Dr" (flags) > > > > : /* no input */ > > > > : "memory"); > > > > > > > > > > Maybe report a bug to the clang team? > > > > This has been done 8 years ago. No progress so far... > > > > They claim we should use __builtin_ia32_readeflags_u64 / > > __builtin_ia32_writeeflags_u64, which seems unlikely to please x86 > > maintainers ? > > Yeah, because the "rm" thing not being supported properly goes way > further than just this one case. And it really is abysmal that clang > hasn't managed to implement it in all that time :/ Let me know if you prefer a V2 with this instead. It saves ~190 bytes more with clang ;) Thanks ! diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflag= s.h index b30e5474c18e1be63b7c69354c26ae6a6cb02731..0209ae149f2b5f9ddacc6c8066a= 6d3191696ec42 100644 --- a/arch/x86/include/asm/irqflags.h +++ b/arch/x86/include/asm/irqflags.h @@ -16,20 +16,11 @@ extern inline unsigned long native_save_fl(void); extern __always_inline unsigned long native_save_fl(void) { - unsigned long flags; - - /* - * "=3Drm" is safe here, because "pop" adjusts the stack before - * it evaluates its effective address -- this is part of the - * documented behavior of the "pop" instruction. - */ - asm volatile("# __raw_save_flags\n\t" - "pushf ; pop %0" - : "=3Drm" (flags) - : /* no input */ - : "memory"); - - return flags; +#ifdef CONFIG_X86_64 + return __builtin_ia32_readeflags_u64(); +#else + return __builtin_ia32_readeflags_u32(); +#endif } static __always_inline void native_irq_disable(void)