From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 0A6192931FE for ; Tue, 11 Aug 2026 07:05:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786431942; cv=none; b=h6qRykWNuXbXKzU+FQ/F+vIE+iMdTZR/tMjyiNHEt1EO6dhvmGklCnzV52KoI/YzDgNfnr5T3NU2f4tYVWP8LHGUfzEf/YG4vte6bqqaGp/5cS+ixUgNHMbFxsO15rvK29KsLVt9GjudXPyHHj5yxFpRip0sMKY/ajjbbsRkrc0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786431942; c=relaxed/simple; bh=bdObl6Xtab/v3o0x0qq7l82250vTLr016pDydBk5pqg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aqQqnv+g+TPxpfTBUinV6wwV/sXHBcpon85WQfHOvgnU8nGR0DYIIQGhxjhlrnZaU4XmgDJFlzPzYMrxW/DsJ4ziDsxhQKDIlnfEqJii0gvdQ4PdDfduAgWQp455ZgC0mHbq3JM/Bw2zIIf38x31PLhQ8h0QF/18NJb3Uc0CtEg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=nSSBz9H0; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="nSSBz9H0" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2cacf197759so47127075ad.2 for ; Tue, 11 Aug 2026 00:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1786431940; x=1787036740; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=/uYUbP8qsi7RaMJfYYf8S2edvslSkkooEV/p2VWCFcg=; b=nSSBz9H05kfUef9J7+7OUGdcjO7kXTFrpFSS5eB5oAGw8ubKOf+aO0bwblHa8PTxoH ti0Yyvb6S8LtIQGEYs5ZZDxyDAxrI6e10FA8uKVGGb0MxxxTQ3LSttOy99QZs/gUOT3P PTmaSuQJ5njSFa7eeuETFntf9e1NoWvly+sxE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786431940; x=1787036740; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=/uYUbP8qsi7RaMJfYYf8S2edvslSkkooEV/p2VWCFcg=; b=bLE/KwfM81dCymtDYRENh1chmXimM2Ig91FGF5lssrerxzbx52F5DJ3PlcsANpUS49 BiKenhqt/wz6d8iN2FRFMXnioWJZ5qRph3W2J/FqNfQiviwn5os5VVksp4yNm3NGxy9V 2xK8MB5QRw1rNU7Na4phDXkVXPWUVOzcv/uaBW16EZ0VeAER+uaiWSZCQJSdnHP3m7Eh LbE94H0QKuKVIVV7IpnXzJIcoIzO0/6o3x+L6rTbwY5l32dQing16p2snqCWqUtC+8zC wuBCrEyclVvJJF8uIVXmbl2tLK9yDhktsgcVG8hau2bauZCcMJKSb7UR+KGHiRH8robA J4Lw== X-Forwarded-Encrypted: i=1; AHgh+RpGiTcJAfTSnGZDSjseh7z7zzcqKp+YT9M6Yv9OG2U1/6eT2//AsbqjH3H6bvM/3CZbOGtIl+tcH6pEtkI=@vger.kernel.org X-Gm-Message-State: AOJu0YwdzMu0H/SFrtWJODsKbTalR3xAqzhdJMNceU7dkX1oGmiYJHmC ZtlVYc4BjRc9+HgAauxc747tOGzu+6tqPzL0ypeihRgg4AclWhzrTzKf9bCxlEL/Aw== X-Gm-Gg: AR+sD12Ltine6rh9NIiZ/7mdTBisbHDvnHj28snPgHmwK0qLLp/DcgbvgihEThV7cYD 5xiRkuui1K00nfGyTrBMqaVqauzFRLOLfBteyTLU4tOtvT/p5kYDPHQ947omLOWT8FuxHNrs1EY tz/eO8CQ5sdXN1faGGyQZpu70GHERzwvsPGBYKHWNWEXOaFyVZeCdT5Rj5hNVMBefd5uLRQr2Nk 5jPNz01S1rtB6p/WErdgzopufjigIBXFTTJgKYYW/Qqks/O5ASrzKK8GtG4j/NloOsg+0QOQbj2 g+pT9bpF1+VQfYSdw6gJvcLCTHAHz8+teTPv/uZxh/8iUcPXz8tbL3SDDvfUc/af9YHFN64ZknE RozDJX3z8gMdyOZEDCQurzKZ35I8nyLhWLREUnqcoApuodZz6Ll/BkkpFO4f3zz1Jb80rcxZlHs XFvKGYMtF3WpRs/pw9NRHVld+RTEZFguRwmP+EUAiENH9UlQkDJn+JCzi6kq+P2fvQkDiDQLaoJ Az78o+1u2DpBLrZKcPPi3A0x09C X-Received: by 2002:a17:90b:4c8d:b0:381:792d:f993 with SMTP id 98e67ed59e1d1-392ec621702mr1166627a91.17.1786431940297; Tue, 11 Aug 2026 00:05:40 -0700 (PDT) Received: from google.com ([2a00:79e0:2031:6:cb77:e248:b4f8:7a92]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-392edc7b005sm676330a91.0.2026.08.11.00.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2026 00:05:39 -0700 (PDT) Date: Tue, 11 Aug 2026 16:05:36 +0900 From: Sergey Senozhatsky To: Xin Li , Chuanxiao Dong , Dmytro Maluka Cc: "H. Peter Anvin" , Sergey Senozhatsky , Thomas Gleixner , Peter Zijlstra , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: x86: missing FRED #PF event data? Message-ID: References: <29FD2DAB-C771-4E91-95C4-435B5DF90802@zytor.com> <507D6E38-4328-4DFB-BB9B-1CE220A22075@zytor.com> <74290FF8-ED7D-473D-9A0B-4288B7EB7F4A@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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <74290FF8-ED7D-473D-9A0B-4288B7EB7F4A@zytor.com> On (26/08/10 22:37), Xin Li wrote: > > 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: > >>>>>> > >>>>>> address = 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 = read_cr2(); > >>>>>> pr_err(":: fixed up address to %lx [[fred: %lx cr2: %lx]]\n", address, fred_event_data(regs), read_cr2()); > >>>>>> } > >>>>>> > >>>>>> and got the following while running my tests (and well, we don't crash > >>>>>> anymore): > >>>>>> > >>>>>> [ 254.040223] :: fixed up address to ffff9c4d64af4000 [[fred: 0 cr2: ffff9c4d64af4000]] > >>>>>> ... > >>>>>> [ 1821.904563] :: fixed up address to ffff9c4e9dd0a000 [[fred: 0 cr2: ffff9c4e9dd0a000]] > >>>>>> > >>>>>> Does any of this make sense to you? > >>>>> > >>>>> I think the explanation is some pKVM shenanigans. Sorry for the noise. > >>>> > >>>> 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. > >>> > >>> What is pKVM? Paravirtualized KVM? > >> > >> Protected KVM. > >> > >>> 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. > >>> > >>> 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. > >> > >> 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. > > > > 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’s “host” running in a VM, so it’s kind of like a filter > hypervisor you ever mentioned; part of the “host" running in non-root mode. > > So where is this page fault from? If it’s 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. Added Chuanxiao and Dmytro, folks please correct me. What I see: the page fault is happening in the non-root mode (native MMU?). I don't see a VM exit - I tried injecting FRED #PF data but exc_page_fault() still reads 0x00 FRED #PF data. What I also see is that... it seems to be a hybrid configurations. From what I can tell, guests have FRED enabled in CR4, while hypervisor has FRED disabled in CR4. So maybe this mix of FRED modes is what pushes empty FRED #PF frame? Sorry if I babbled complete nonsense. I'll happily hand it over to Chuanxiao and Dmytro at this point.