Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1515504imm; Sun, 27 May 2018 08:49:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKxKu3QLVkNxIMI1dfGh9LU7an6XXftPc4jNeYRUiL73WdQ/DzysydbyRTnrSjm8hvofx8C X-Received: by 2002:aa7:8051:: with SMTP id y17-v6mr1391985pfm.148.1527436182404; Sun, 27 May 2018 08:49:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527436182; cv=none; d=google.com; s=arc-20160816; b=IxuSfG4c/dQ7XMXP1UYrnzXN/2CDpX7uvR7vCS3sl5vr9JE2ttL05dWyFVUYpGqI37 Nvw/pNw/LZFfhr52t2IB2dBp3rG8K9ddqHISOCddXe4pGTwlRewZhl+Z6cUJbRCseJ9r 952v//DWmcKDtYUstB83Xd832cB+dbF2Z7oeSLkMWMOPHh/rRj2eYKOLeOVCszbOEWL7 TOpTavrDuqzX9dCc4ld2G/6QD3+HCKonVFf80NMSZkR1i8myKJlAFDK2klFCMTxZv9xV qTXg+OgV/vZnA/T/BAwJk9/tMpxpQSVx/Z0xGzRCUsOyWApMIv2Wo12uKX+x1/YmGW9s kesw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ARcfnzf/LFoA+v7KAMmI4BWGtcdYGJ3nTSjnEc/Pmaw=; b=hyhx+nN0kpTksXZ0Ti+OdIvCDplnv2iOSTOLU+2ZJ0Uwt3V+8KTfrXHpZ9CeF4I0Ep S629gMGPdlrv2eaIWP57RPiK/yI8FfXIZqfMxSzZHkMp1cEvVKDEHaFv7tVvZNzCFBsa CpeMF6bVToP1ApzpC1a9G0PbEFQFMTnx2+oTzMw6fH3LEIOpYh91JfhnkJYr5u4BXNWs cW6cc+usbp2NutglI4VJY3P7kzZNHRnyre2IRmyNtHVx86dhiBHzHofwbE32LOvJqQXS ntdokkw4ra6OWMFx6nnx7yJVDuws3GTRkdQg+110AW3ygpyg99zd9Hgltibn9KWR/Ccb bAaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7-v6si17236744pgq.121.2018.05.27.08.49.27; Sun, 27 May 2018 08:49:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033058AbeE0PsQ (ORCPT + 99 others); Sun, 27 May 2018 11:48:16 -0400 Received: from mga02.intel.com ([134.134.136.20]:28379 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032820AbeE0PqW (ORCPT ); Sun, 27 May 2018 11:46:22 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 May 2018 08:46:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,448,1520924400"; d="scan'208";a="227741108" Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by orsmga005.jf.intel.com with ESMTP; 27 May 2018 08:46:17 -0700 From: Fenghua Yu To: "Thomas Gleixner" , "Ingo Molnar" , "H. Peter Anvin" Cc: "Ashok Raj" , "Dave Hansen" , "Rafael Wysocki" , "Tony Luck" , "Alan Cox" , "Ravi V Shankar" , "Arjan van de Ven" , "linux-kernel" , "x86" , Fenghua Yu Subject: [RFC PATCH 14/16] x86/split_lock: Add debugfs interface to show and control firmware setting for split lock Date: Sun, 27 May 2018 08:46:03 -0700 Message-Id: <1527435965-202085-15-git-send-email-fenghua.yu@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1527435965-202085-1-git-send-email-fenghua.yu@intel.com> References: <1527435965-202085-1-git-send-email-fenghua.yu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By default, the firmware setting for split lock inherits from firmware setting before kernel boots. In cases like hard real time, user wants to identify split lock issues in firmware even when #AC for split lock is not enabled in firmware before kernel boots. The user may explicitly enable #AC for split lock for firmware. Getting bang whenever there is a split lock in firmware helps identify and fix the firmware split lock issue. The debugfs interface /sys/kernel/debug/x86/split_lock/firmware shows the firmware split lock setting: 0 for disabled and 1 for enabled. User can override the firmware setting by writing 1 to enable #AC for split lock in firmware and write 0 to disable #AC for split lock in firmware. When control flow comes to firmware (e.g. in S3, S4, S5, and EFI runtime), kernel sets the firmware setting for split lock. Kernel restores to kernel setting for split lock after coming back to kernel. Please note: System Management Mode (SMM) is out of control of kernel. So this interface cannot control split lock in SMM. Signed-off-by: Fenghua Yu --- arch/x86/kernel/cpu/test_ctl.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/x86/kernel/cpu/test_ctl.c b/arch/x86/kernel/cpu/test_ctl.c index d774485a5ca4..8bdc01067be9 100644 --- a/arch/x86/kernel/cpu/test_ctl.c +++ b/arch/x86/kernel/cpu/test_ctl.c @@ -516,12 +516,38 @@ static const struct file_operations user_mode_ops = { .llseek = default_llseek, }; +static int firmware_show(void *data, u64 *val) +{ + *val = split_lock_ac_firmware; + + return 0; +} + +static int firmware_store(void *data, u64 val) +{ + if (val != DISABLE_SPLIT_LOCK_AC && val != ENABLE_SPLIT_LOCK_AC) + return -EINVAL; + + /* No need to update setting if new setting is the same as old one. */ + if (val == split_lock_ac_firmware) + return 0; + + mutex_lock(&split_lock_mutex); + split_lock_ac_firmware = val; + mutex_unlock(&split_lock_mutex); + + return 0; +} + +DEFINE_DEBUGFS_ATTRIBUTE(firmware_ops, firmware_show, firmware_store, "%llx\n"); + static int __init debugfs_setup_split_lock(void) { struct debugfs_file debugfs_files[] = { {"enable", 0600, &enable_ops}, {"kernel_mode", 0600, &kernel_mode_ops }, {"user_mode", 0600, &user_mode_ops }, + {"firmware", 0600, &firmware_ops }, }; struct dentry *split_lock_dir, *fd; int i; -- 2.5.0