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 A90F62FD1CA for ; Tue, 11 Aug 2026 05:37:39 +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=1786426661; cv=none; b=tPMblbaO9lncgy3nD9Ga2TqrOOrNf/iUqdeOQ4KbQpwMJpwr+VpmA0QeU2kK0tNSaRCL0n9sjze4W2wc39lHG6lvNePKq2DsvOj/DDNLSnzoF4TGCY4W0cLAYgf3hBHiDv5QGxunGLYFV+sp+ysKyevDB5FiNN730qglvDWLRb8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786426661; c=relaxed/simple; bh=rqAjFjpTf4Sz+gmkQd7d0Bzeo+GEe0LwT1CworaJ5sM=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=JeiZe50yzCuLHIExfHCZUdzEFKWRLGVsQFsvYNcryeoQ65TAJEdPUBV2T2G2dU34RXJP3988NL4j6sghM+Mj5uXhDHaedD/TdpA9uBXJTRAhdhilTgJfjMRZlsWOu02GhhXH9/lc02AqnZghfDpHobQlBEfMHtv+JLMV1Y12YSE= 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=fy7mI05x; 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="fy7mI05x" Received: from smtpclient.apple (c-24-130-165-117.hsd1.ca.comcast.net [24.130.165.117]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 67B5bP6G2957403 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 10 Aug 2026 22:37:26 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 67B5bP6G2957403 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2026072801; t=1786426646; bh=P3zepqkhCljvKOZ1+DWD9So5419AYYXbDOFTOZhTgIA=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=fy7mI05xZon4/HrfiB8zlL6e9EkmVIG5EQWwIiDvh9fkEE9RYTgmbY1caVTMgDd7a IrcZE2Qca6YT2zsCwKrHB83Xi/tcz7168bHUufad0iyCxpRe2io2Foexx41bDYfSPu XoEhjH1YUsfOntEqAuTBUL7w80hwIV/uXcCcehVBus55Ul1d4rxRydkX6mJL5E3P3B sO/BOr0gVrhAvwyId+RDpPRokopmlkEvarex7v+ONm45/28BjP6DKwDsWv7M/IdqWL olzSv5YP9+sCqkSEZ2vXW2tV+nurVmXUnVAj2Qik/u5zF2fKbpujKTStUn7r7RrHFl IkMCKBy0O1weQ== Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.700.51.1.1\)) Subject: Re: x86: missing FRED #PF event data? From: Xin Li In-Reply-To: <507D6E38-4328-4DFB-BB9B-1CE220A22075@zytor.com> Date: Mon, 10 Aug 2026 22:37:15 -0700 Cc: Sergey Senozhatsky , Thomas Gleixner , Peter Zijlstra , x86@kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <74290FF8-ED7D-473D-9A0B-4288B7EB7F4A@zytor.com> References: <29FD2DAB-C771-4E91-95C4-435B5DF90802@zytor.com> <507D6E38-4328-4DFB-BB9B-1CE220A22075@zytor.com> To: "H. Peter Anvin" X-Mailer: Apple Mail (2.3864.700.51.1.1) > On Aug 10, 2026, at 8:11=E2=80=AFPM, H. Peter Anvin = wrote: >=20 > On August 10, 2026 6:47:13 PM PDT, Sergey Senozhatsky = wrote: >> On (26/08/10 08:40), H. Peter Anvin wrote: >>> On August 10, 2026 1:58:18 AM PDT, Sergey Senozhatsky = wrote: >>>> On (26/08/10 16:38), Sergey Senozhatsky wrote: >>>>> [..] >>>>>> All the crashes are reported as NULL ptr derefs, however, I = believe this >>>>>> is not exactly the case. In all crashes CR2 is 0x1000 aligned = (we always >>>>>> crash accessing first byte of a page). It seems that = csum_partial() calls >>>>>> load_unaligned_zeropad() and we hit what load_unaligned_zeropad() = comment >>>>>> describes as very unlikely) case: "word being a page-crosser and = the >>>>>> next page not being mapped"). So instead of reading 4 remaining = bytes >>>>>> of the page and zeroes for trailing 4 bytes, we panic(). It = appears that >>>>>> FRED #PF is set to 0 while CR2 points to a correct page address. = I added >>>>>> a simple printk to exc_page_fault: >>>>>>=20 >>>>>> address =3D cpu_feature_enabled(X86_FEATURE_FRED) ? = fred_event_data(regs) : read_cr2(); >>>>>> /* Fall back to CR2 if FRED event data was empty */ >>>>>> if (unlikely(!address)) { >>>>>> address =3D read_cr2(); >>>>>> pr_err(":: fixed up address to %lx [[fred: %lx = cr2: %lx]]\n", address, fred_event_data(regs), read_cr2()); >>>>>> } >>>>>>=20 >>>>>> and got the following while running my tests (and well, we don't = crash >>>>>> anymore): >>>>>>=20 >>>>>> [ 254.040223] :: fixed up address to ffff9c4d64af4000 [[fred: 0 = cr2: ffff9c4d64af4000]] >>>>>> ... >>>>>> [ 1821.904563] :: fixed up address to ffff9c4e9dd0a000 [[fred: 0 = cr2: ffff9c4e9dd0a000]] >>>>>>=20 >>>>>> Does any of this make sense to you? >>>>>=20 >>>>> I think the explanation is some pKVM shenanigans. Sorry for the = noise. >>>>=20 >>>> No, I think we are back at square one. I thought that maybe pKVM >>>> was disabling FRED and that was causing issues. But I actually see >>>> that both cpu_feature_enabled(X86_FEATURE_FRED) and (cr4 & = X86_CR4_FRED) >>>> claim FRED is enabled, yet fred #PF data is 0 while CR2 holds the = correct >>>> address. >>>=20 >>> What is pKVM? Paravirtualized KVM? >>=20 >> Protected KVM. >>=20 >>> In that case, it is most likely pKVM not filling in the relevant = fields >>> in the FRED stack frame, which would be a very serious bug. >>>=20 >>> I cannot think of any other way that that could possibly happen = otherwise; >>> on bare metal those fields are set by hardware and Linux only = consumes them. >>=20 >> I agree. I'll look at it from the pKVM side. I was not aware of = pKVM >> when I started this discussion, I found out about it later. >=20 > If that code calls the FRED entry from KVM routine, that routine = doesn't have support for setting event_data in upstream. This would be = fixed if necessary. Per Sean, it=E2=80=99s =E2=80=9Chost=E2=80=9D running in a VM, so it=E2=80= =99s kind of like a filter hypervisor you ever mentioned; part of the = =E2=80=9Chost" running in non-root mode. So where is this page fault from? If it=E2=80=99s from non-root mode, = does this page fault cause a VM exit? If yes and pKVM forwards it to = FRED entry, I would guess it is exactly the case.=