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 6BDD630EF75 for ; Tue, 6 Jan 2026 17:07:22 +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=1767719244; cv=none; b=Tv/7WHlwQIQEUqyLxan/K7ovshLH7K82jIhxtxGXfK8cZfkNXx/oaMcMcDWxuJsFvTbkcFMTr27JnBdcXfkTj2WfOGKnDhRoXZeGxCCJxY5VeMOy+YJKnStQfVTHVwSNPgPY/lJsmFQi82qXdA+wa80xR129wnULtlm+PbF0EBs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767719244; c=relaxed/simple; bh=vuytlwv+Zmhi8t5nq+JZSGhClDFagfkf+TRngStOsh8=; h=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type; b=pkIL6LPkv3GxbKYWc2LGyZUL+Yn5TMHU6pjoyyb1E3XuYNRxMoQRI1cO7bXbjvY5IxtZfv/iSuG5MeC9J1Rhbq07pgB/UsOJu4NrqmxvkEJxjyAcUhdAhKZd3DetbNh9cQZ/NYwPqxAzUQjOOAfsYYUqo9YqdQO3XTGNFQKbKY4= 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=XY3Uu/Qc; 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="XY3Uu/Qc" Received: from ehlo.thunderbird.net (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 606H6Qdt3934190 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Tue, 6 Jan 2026 09:06:26 -0800 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 606H6Qdt3934190 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025122301; t=1767719187; bh=nHIfnrbHZUWXCltnuSDZzQs/j56ee0MHWdGb2y/FaYk=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=XY3Uu/Qc1Xf+lwiNJNprjmmW/1BWaWdqwNmT4MTNEE+ZMqYh8IVfqr+62YSpOFnpy 7toO5QOFS4cWVTh/kdM294ttEf/J2dpvBjhTN8MpBVBJDLmqYJlpsGq4ce5DWduFYo aSLs/fx8un3SKa2rbP5h26Asl9y+qIwerB3TBQ0kwbc9vfLagR8AZ/OZTmD/ofSTs3 KVu4jfxlYMFgvC66fz98Uxnb5Equw7t13ETathzuqjQBOqTdETXAIudykB9oCKpQv8 Eb8FdUUpR1t50OkfXGbofjsLy8MokbbOhti0AYypZokEsYLJ17iqRRXxuoNLOZIIUU iscvkh/CdFKsg== Date: Tue, 06 Jan 2026 09:06:24 -0800 From: "H. Peter Anvin" To: Andrew Cooper , Peter Zijlstra CC: LKML , Xin Li , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Subject: Re: [PATCH] x86/fred: Correct speculative safety in fred_extint() User-Agent: K-9 Mail for Android In-Reply-To: <3f9765e1-8f02-409f-813c-24ff378f7a90@citrix.com> References: <20260106131504.679932-1-andrew.cooper3@citrix.com> <20260106152008.GZ3707891@noisy.programming.kicks-ass.net> <3f9765e1-8f02-409f-813c-24ff378f7a90@citrix.com> Message-ID: <64E26E02-B9E0-43F1-8FAB-6436BDCFDB50@zytor.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On January 6, 2026 8:46:41 AM PST, Andrew Cooper wrote: >On 06/01/2026 3:20 pm, Peter Zijlstra wrote: >> On Tue, Jan 06, 2026 at 01:15:04PM +0000, Andrew Cooper wrote: >>> This is why we have array_access_nospec() in Xen, so you can't separat= e the >>> safety calculation from the array access=2E >>> >>> The observant reader might notice that the result of reading sysvec_ta= ble[] is >>> also subject to memory predictions=2E Aren't CPUs wonderful=2E=2E=2E >>> >>> In practice, even having array_index_nospec() part of the array access >>> expression is no guarantee of avoiding spilling to the stack=2E KASAN= is liable >>> to hide a function call behind the scenes, while UBSAN is very good at >>> inserting it's own unsafe range checks around objects it knows the siz= e of=2E >>> Aren't compilers wonderful=2E=2E=2E >> Yeah, then again nobody should be running *SAN kernels in production, >> right ;-) > >Aren't distros wonderful=2E=2E=2E > >~Andrew This would probably be best addressed with an intrinsic=2E=20 That being said, there are a few reasons why this may not matter in the ca= se of FRED specifically=2E=20 Note that this value comes from memory in the first place, *but* it comes = from memory just written to the stack and thus is virtually guaranteed to b= e live in the L1 TLB and cache=2E Now with PTL about to be released, I'm al= so actively looking at ways to optimize FRED entry=2E One way is to precomp= ute certain useful values in the entry path, instead of simply zeroing the = GPRs one can extract data that will be needed further on in the data path i= nto the argument registers=2E=20 Note that FRED entry is an architectural speculation barrier=2E Furthermore, my measurements so far indicate that doing an early-out on th= e SYSCALL path is pretty essential=2E It might even be valuable enough to d= o in the assembly stub code=2E=20