Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2369310rdb; Tue, 10 Oct 2023 01:37:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGw4z3uRe+aqLgdguBj5f0S+0PAG6bUuyVuk+h1+PiID3JqNqLB7HIj7ffiAmwHqb3VCQkC X-Received: by 2002:a17:902:ef87:b0:1c3:a91a:627f with SMTP id iz7-20020a170902ef8700b001c3a91a627fmr14207487plb.47.1696927047643; Tue, 10 Oct 2023 01:37:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696927047; cv=none; d=google.com; s=arc-20160816; b=kDXl8yhdAqvEBLrFcfKanJ1O8Z0w/FdW4UnrLoHD0F0pKvOfogZpCKF86zRmbgGfuS Ty/lkXCzIpciZxsShiBKgmnOYM1dwOVN6vPALqZKHneaJ7xYo29WQPeUZj5B79KYE1Gw Q2L9ULLo6OXdiK+GuwJHVcl8Q9Ep3Lk7CQODZqmNgA91VuIBKGm+E+yYEdRaYakqPYsu iUGudUCglcaKN0wFTkiVRfKD/iCYG4Aezb0XboGUbZBf83Z2DBTfUsIenYfDrkg5mrNu q8xnx6lXxvQ4miHdHVQuREyCpt/DQgptvzkvTteG51CUu8Szv0fqzWKxQuHNKcSMPIQ6 fK2Q== 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=KnMqxK9awJe/mQEKThSvG9YggkO6XpnHT0Y2ocPHqVI=; fh=qpQuS5DB8/tFQfmdgX1i3QvppRzkrzhfKx2/rzpwOaE=; b=EcxLiwrtK6mkEA6JadtUdcvcZ7TTYxYWHZEMSC/ZKHGtYtjhz74duGvocb53KFFI4U mialuMaYxLOs6Bh/1CvYr6TckZwnxppfDbutjP2S9/YwIC/kvDe+8RwBcr9d8bRmOMDk 3ok86N8lqE4Tq+5aEvyIJ4WXtMTHVuo9+r5km1b9DFt60dvg8UIiFVA5S0RhV+J5a/Fv b8zdUVhzKzwxenw1D/I9/YZRpRCZ3/eCYqps4nreEC0AcHmTPxk3yFOc2KVYQcyfKUPx iAzhtGnVsFwkRXLp8Hb8C4DsizGz16J6sVDr2OSB/5buffQMgFrmGNzMxl43Hs8bUVpd AgDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZpEJeiiZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id w5-20020a170902ca0500b001c342073f76si10565911pld.323.2023.10.10.01.37.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 01:37:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZpEJeiiZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 81AE182DDAEC; Tue, 10 Oct 2023 01:37:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443037AbjJJIgV (ORCPT + 99 others); Tue, 10 Oct 2023 04:36:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442921AbjJJIfk (ORCPT ); Tue, 10 Oct 2023 04:35:40 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51691B6; Tue, 10 Oct 2023 01:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696926936; x=1728462936; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ltSCu5LbcZQkZ8VDt/3RcMj+M7LqTSv2OY7y3BW7maY=; b=ZpEJeiiZhtjBxR1u8J/utaagfBKDuvkDbH/JKu3uwKNDCmRFTSia2G86 OUEOCnUU5DZbD+/l7R/5rOJJL+PaUX8xk4MNK1trPsv9oL8XsBbqqIHlW hI1HcbSYAdgfk8hfUhsgKsPOKOponaOX+zaVPKJxLED6WT+V0+frtD5Oa JDp1bajZrg4ffHJxVlY+TC0YbKHr9TDlg4TZszvFcHFgDzau+iBns2JOO U7bNiJDi9JahWusrxBHhKlXbEEopQBw2g/hjSY1F5aJ2Kth4k2iMtUcL0 UUVPooM+4x78FA5Ibj+04dw8xLg6sMMhnwFfGyyfKZPkn+BjFColkCytO w==; X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="363689820" X-IronPort-AV: E=Sophos;i="6.03,212,1694761200"; d="scan'208";a="363689820" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2023 01:35:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10858"; a="1084687197" X-IronPort-AV: E=Sophos;i="6.03,212,1694761200"; d="scan'208";a="1084687197" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2023 01:35:34 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Michael Roth , Paolo Bonzini , Sean Christopherson , linux-coco@lists.linux.dev, Chao Peng Subject: [PATCH 07/12] x86/mce/inject: Wire up the x86 MCE injector to FADV_MCE_INJECT Date: Tue, 10 Oct 2023 01:35:15 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Tue, 10 Oct 2023 01:37:23 -0700 (PDT) X-Spam-Level: ** From: Isaku Yamahata To inject machine check based on FADV_MCE_INJECT, wire up the x86 MCE injector to register its handler to get notified physical address on FADV_MCE_INJECT. Signed-off-by: Isaku Yamahata --- arch/x86/kernel/cpu/mce/inject.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/x86/kernel/cpu/mce/inject.c b/arch/x86/kernel/cpu/mce/inject.c index ae3efbeb78bd..43d896a89648 100644 --- a/arch/x86/kernel/cpu/mce/inject.c +++ b/arch/x86/kernel/cpu/mce/inject.c @@ -294,6 +294,17 @@ static struct notifier_block inject_nb = { .notifier_call = mce_inject_raise, }; +static int fadvise_inject_addr(struct notifier_block *nb, unsigned long val, + void *data) +{ + inj_addr_set(&i_mce, val); + return NOTIFY_DONE; +} + +static struct notifier_block fadvise_nb = { + .notifier_call = fadvise_inject_addr, +} + /* * Caller needs to be make sure this cpu doesn't disappear * from under us, i.e.: get_cpu/put_cpu. @@ -784,6 +795,7 @@ static int __init inject_init(void) register_nmi_handler(NMI_LOCAL, mce_raise_notify, 0, "mce_notify"); mce_register_injector_chain(&inject_nb); + fadvise_register_mce_injector_chain(&fadvise_nb); setup_inj_struct(&i_mce); @@ -795,6 +807,7 @@ static int __init inject_init(void) static void __exit inject_exit(void) { + fadvise_unregister_mce_injector_chain(&fadvise_nb); mce_unregister_injector_chain(&inject_nb); unregister_nmi_handler(NMI_LOCAL, "mce_notify"); -- 2.25.1