Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1513982imm; Sun, 27 May 2018 08:47:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJyTKtIvkSNDeJ9y/DaCmgTGvEbTMu1uvubGgpRF/E2MkbZ/sYrkyjSSUUrKsqzs0HqvA8A X-Received: by 2002:a65:5bce:: with SMTP id o14-v6mr1317843pgr.449.1527436028315; Sun, 27 May 2018 08:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527436028; cv=none; d=google.com; s=arc-20160816; b=dCAs9FX6quoEG15tZd7rRrZsqSdRXUJT5MtdgU9Kph1/psvC5UGHavo/IqvlSghHrY zYPL5jn5MGIPXS2uLzzYYVNlQZGnZ7hO7HdyD1WFy7iszBmYfZSeb/IQwgIfNkRp5c8Y xQFkO14Jj1l8TmZK1WIl11hVe55zdyG+6i91B7uhyAST3CTm+usjjMxMdHbPuSjFauR/ HYHY8Tu4g2KjZ2WerHTXPGkgZzbNwl3Yyl333UONZiWMXtBXJelukPgXsY7cg6iTFYMa RSUKQLUyOa3x1QBFSdSmqcsabQvHHi3NGr2bsIgLzZcaR7uIvyvHr0zi7fO5WP+zYKLO J+uQ== 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=hnPNQYBwP+agsOSfwHgIxiftF7UClMbFsMAcewPaF4I=; b=CNFyVmfYASPjFbbRm6+ODhOOSfk4Puhll2IKTAdWzds2nP8cSSBbVdm5TFTMzDUvRV GGk6qI9FTRPCdM4sBTi/A/a4TOI7iDSnWCzxUZRpuJG3dKHajLnRSmXIH/veaMRHgSz5 wMs/IXuCqHGkP8Uo0puQmeFB8XbsZV+kilesUW0TihZjXbqOkv2+inPLEmAzW2sPsMCV gZvQowTUZMqSMLVPGXckOetIEd0GAl37r0gEhIQbF9Oc86zUhUwApgv6X3/C4dGiKfPr XVzTI5+8DlulGBehUA4UiVM8mqdEhkG6ae9cHFTB0er5R/SpCTeycskgGIQoOs2cq0Lh sgFg== 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 d8-v6si22788740pgt.630.2018.05.27.08.46.37; Sun, 27 May 2018 08:47:08 -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 S1032856AbeE0PqY (ORCPT + 99 others); Sun, 27 May 2018 11:46:24 -0400 Received: from mga02.intel.com ([134.134.136.20]:28383 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032721AbeE0PqS (ORCPT ); Sun, 27 May 2018 11:46:18 -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:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,448,1520924400"; d="scan'208";a="227741069" Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by orsmga005.jf.intel.com with ESMTP; 27 May 2018 08:46:11 -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 03/16] x86/split_lock: Set up #AC exception for split locked accesses on all CPUs Date: Sun, 27 May 2018 08:45:52 -0700 Message-Id: <1527435965-202085-4-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 #AC for split lock is set up when each CPU is brought up. By default, kernel disables the feature bit 29 in TEST_CTL MSR on each CPU. Signed-off-by: Fenghua Yu --- arch/x86/include/asm/cpu.h | 3 +++ arch/x86/kernel/cpu/common.c | 2 ++ arch/x86/kernel/cpu/test_ctl.c | 14 ++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h index 083ef6d05c45..00f453fd44ac 100644 --- a/arch/x86/include/asm/cpu.h +++ b/arch/x86/include/asm/cpu.h @@ -43,6 +43,7 @@ unsigned int x86_stepping(unsigned int sig); #ifdef CONFIG_SPLIT_LOCK_AC void detect_split_lock_ac(void); bool do_split_lock_exception(struct pt_regs *regs, unsigned long error_code); +void setup_split_lock(void); #else /* CONFIG_SPLIT_LOCK_AC */ static inline void detect_split_lock_ac(void) {} static inline bool @@ -50,5 +51,7 @@ do_split_lock_exception(struct pt_regs *regs, unsigned long error_code) { return false; } + +static inline void setup_split_lock(void) {} #endif /* CONFIG_SPLIT_LOCK_AC */ #endif /* _ASM_X86_CPU_H */ diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index b02d90320ec6..af3f23170503 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -1382,6 +1382,8 @@ static void identify_cpu(struct cpuinfo_x86 *c) /* Init Machine Check Exception if available. */ mcheck_cpu_init(c); + setup_split_lock(); + select_idle_routine(c); #ifdef CONFIG_NUMA diff --git a/arch/x86/kernel/cpu/test_ctl.c b/arch/x86/kernel/cpu/test_ctl.c index 82f110759662..c72c0517c6ab 100644 --- a/arch/x86/kernel/cpu/test_ctl.c +++ b/arch/x86/kernel/cpu/test_ctl.c @@ -28,6 +28,8 @@ static DEFINE_PER_CPU(struct delayed_work, reenable_delayed_work); static unsigned long disable_split_lock_jiffies; static DEFINE_MUTEX(reexecute_split_lock_mutex); +static int split_lock_ac_kernel = DISABLE_SPLIT_LOCK_AC; + /* Detete feature of #AC for split lock by probing bit 29 in MSR_TEST_CTL. */ void detect_split_lock_ac(void) { @@ -84,6 +86,18 @@ static void _setup_split_lock(int split_lock_ac_val) wrmsrl(MSR_TEST_CTL, val); } +void setup_split_lock(void) +{ + if (!boot_cpu_has(X86_FEATURE_SPLIT_LOCK_AC)) + return; + + _setup_split_lock(split_lock_ac_kernel); + + pr_info_once("#AC execption for split lock is %sd\n", + split_lock_ac_kernel == ENABLE_SPLIT_LOCK_AC ? "enable" + : "disable"); +} + static void wait_for_reexecution(void) { while (time_before(jiffies, disable_split_lock_jiffies + -- 2.5.0