Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp210337rdb; Tue, 5 Dec 2023 03:23:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IF7dnvno3ND2uLL37O609RtgoRY4XvAsiHsncxajGl+pLzn6fkNwjGXkvd3D+NXSSjW+WWa X-Received: by 2002:a17:902:aa92:b0:1d0:6ffe:1e93 with SMTP id d18-20020a170902aa9200b001d06ffe1e93mr3201580plr.118.1701775433460; Tue, 05 Dec 2023 03:23:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701775433; cv=none; d=google.com; s=arc-20160816; b=kq5LYb2ej+uabX4pg/2Ts5eHXSUpbVNd4FEcAAogEetKPVCDi0369nboUyrMayuh4y pC3DEIIgsY6WF7sOk8c57fukXVObCm2QmlF+Q+y9yTTZNy/phUKJzeOdGx4ZAJ/DcFsd CamPOcS1l22ZIVU9cOaZnqc897cARNZn7zEgIzdxUDFJUNs/v0y2EUD9vrFWZ/vrYdyh cgRp8H/CsV6Y+NlEcvMGkPhF9GDWKcFbArTBC48p329GF3vKHghmWwi1uHw4j2Mn0W8e RiDIw2CG/wRiDR0c8fgfnyzYTNGX4LdrecE+rGCDcl0C8/dNaDyT8ExoCg1Pj1/y+P/Q 3qfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rRSLmRR0nuRB2OQ+ZAJAP9IUoh7kx5+1x++a0urBmsg=; fh=uCCWEUVpLc/xDP/D3WvGY/BxHU9d0NQYu/T71GEsNmA=; b=gsN1UIF1HNhQFHSGShwWjJ4Cp5NN0Uj5k+f3h9FO5pvZQ5Tb1fWJCi7Lqksk3+xX8/ qxgSypZPRBIT1hrAnTLEuwGIqzujlj9Nl4Cm4emenxngR9HGNMX4hChCm99QxSFLzWrf JCFNYMbyQn2mniuwvfklHIsIn0HXRTVGTfJcYdHF1NkZfh5MOrOuNlMafpMNOq7XwOjz WblpDpsl9bNgOf3gxNGTLoBDK0LUQ0lUfHRwqH1u5+khGEM67fjY0rh4EA7v33AH++62 Q1s9biMc7DqBQeG1OIdrAb8h2DYoFf3hgAsjqbeLjDwRJbK3HlTOae0GpbSv4ejWVSvT 6RJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=k8vPfu5C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id jb12-20020a170903258c00b001d07b6a0ae9si4840862plb.203.2023.12.05.03.23.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 03:23:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=k8vPfu5C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id DF90080B1337; Tue, 5 Dec 2023 03:23:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377006AbjLELWY (ORCPT + 99 others); Tue, 5 Dec 2023 06:22:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442137AbjLELVa (ORCPT ); Tue, 5 Dec 2023 06:21:30 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E080B197; Tue, 5 Dec 2023 03:21:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701775291; x=1733311291; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0MXczFK3xOQViMofjzuL8bjmZe4faEq58HCGtZP2g9c=; b=k8vPfu5C+ebCBXTQxHaQ5fm2tXhaANd4s5q49TtYRYJArFdmec8KC9G8 b1rskdHKFrJRL6m0F59FeVRz2u2u0HhdKctLP5hgNCEH/JVgRASrzcWz+ jj0g+bt8Q4A4Qi+FEPt4wf+GHjTEBWoycF7FKGPAX7qGBHh/f0TWxLiNi CBs6gDCDrSBdCo/I7YE8L7iWXIkvatkiz8D/ilDe8dBYEt/aXmQbwxJ6f 7w0xYz0T6ilOmGxixO4YYZAjw5jgquWWXnoA7qzgNikSx759gLw1gxmqw RYD/HMAtg/Y8vlCPTkXomNIErwOw7fi+QNVAf0B8Vb++UmoA7I4TV69TR A==; X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="942555" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="942555" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Dec 2023 03:21:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10914"; a="1018192972" X-IronPort-AV: E=Sophos;i="6.04,252,1695711600"; d="scan'208";a="1018192972" Received: from unknown (HELO fred..) ([172.25.112.68]) by fmsmga006.fm.intel.com with ESMTP; 05 Dec 2023 03:21:22 -0800 From: Xin Li To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-edac@vger.kernel.org, linux-hyperv@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, luto@kernel.org, pbonzini@redhat.com, seanjc@google.com, peterz@infradead.org, jgross@suse.com, ravi.v.shankar@intel.com, mhiramat@kernel.org, andrew.cooper3@citrix.com, jiangshanlai@gmail.com, nik.borisov@suse.com, shan.kang@intel.com Subject: [PATCH v13 21/35] x86/fred: Make exc_page_fault() work for FRED Date: Tue, 5 Dec 2023 02:50:10 -0800 Message-ID: <20231205105030.8698-22-xin3.li@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231205105030.8698-1-xin3.li@intel.com> References: <20231205105030.8698-1-xin3.li@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 05 Dec 2023 03:23:43 -0800 (PST) From: "H. Peter Anvin (Intel)" On a FRED system, the faulting address (CR2) is passed on the stack, to avoid the problem of transient state. Thus the page fault address is read from the FRED stack frame instead of CR2 when FRED is enabled. Signed-off-by: H. Peter Anvin (Intel) Tested-by: Shan Kang Signed-off-by: Xin Li --- Change since v12: * No "we" in a commit message, use passive voice (Borislav Petkov). --- arch/x86/mm/fault.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index ab778eac1952..7675bc067153 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -34,6 +34,7 @@ #include /* kvm_handle_async_pf */ #include /* fixup_vdso_exception() */ #include +#include #define CREATE_TRACE_POINTS #include @@ -1516,8 +1517,10 @@ handle_page_fault(struct pt_regs *regs, unsigned long error_code, DEFINE_IDTENTRY_RAW_ERRORCODE(exc_page_fault) { - unsigned long address = read_cr2(); irqentry_state_t state; + unsigned long address; + + address = cpu_feature_enabled(X86_FEATURE_FRED) ? fred_event_data(regs) : read_cr2(); prefetchw(¤t->mm->mmap_lock); -- 2.43.0