Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1515096imm; Sun, 27 May 2018 08:49:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrfc6aDdFvpqtD2/21dCUd6qcYwfM6eW0OPrxWyxjtbijC4MOTcNwvFoQ/VLP1gidKYj41d X-Received: by 2002:a17:902:1029:: with SMTP id b38-v6mr10224388pla.277.1527436142499; Sun, 27 May 2018 08:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527436142; cv=none; d=google.com; s=arc-20160816; b=fHTndcgf4ZuYSZNCt2qV8v75Xi7SFPvSSHjHU5JzXVxuIKGMWLYh1haKbr0Nketec2 Z1ccezWcezfTRsxBNiOo9Ev1GogHQ8gQk7GsnwEsBmkGANo4QutDppgwpu1+BAY+dZxG bxHTz/FrqOOFSB77L9ZQn9U/febYTE1tucSgMY6m2o/QNoAtIAe9WivAk/p4FPtq9rsM Z6e1I1zf08C1NPC7kMyBoQ2O5dlemICX52lFAegV2q/Y7Uuvu+5mCnt8PsXu8objgx1w b9HHg/HEhAyYdR6No+xc/ntoGB/ttJ1Mj9mANIvTOSOEzSpw8un9IhZKlP09TG7casCP xiTw== 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=7ms+amTnsFX3P+WmAUaWhPKn+oT0UsDYTzNdiTcNWrQ=; b=NYDLef1pgX9LRyHSmJlv/wET/pBy6lkUcl5xl2hfqukZDt4bMCRBf/T1NJ9qG/6xLn SltQJYD0QCV21k9pHtWOPA6NXLAD3JZ9uFsH1fA8iKqZ2uwnSqGaJZuzTD9ysdnMfKx9 Q73TLCI0mFVak0CLjiEyjzcgQ2LrArVimNBm8KLJHq9oM8oo+IruVZ7T8PPidDdFgQBd k8Tl2YOmo3bUhX4jkUuusY4m+aq6G9oo3u5mbI0b5hth7ZRHv3ZGdcwVMIt1ZnlurDqc 055DdCSRgRbnFK0QU9v2dwyZv4jpYCbXGUPfU2Twq04jP+omTIUPcYHS+I8xloEFC6QT AI7w== 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 e1-v6si28687060ple.195.2018.05.27.08.48.47; Sun, 27 May 2018 08:49:02 -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 S1032893AbeE0Pqc (ORCPT + 99 others); Sun, 27 May 2018 11:46:32 -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 S1032786AbeE0PqT (ORCPT ); Sun, 27 May 2018 11:46:19 -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:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,448,1520924400"; d="scan'208";a="227741082" Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by orsmga005.jf.intel.com with ESMTP; 27 May 2018 08:46:13 -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 07/16] x86/split_lock: Handle suspend/hibernate and resume Date: Sun, 27 May 2018 08:45:56 -0700 Message-Id: <1527435965-202085-8-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 During suspend or hibernation, system enters firmware. To avoid potential firmware issue that may generate #AC exception for split locked accesses, handle the #AC as fatal exception, and block suspend or hibernation, the setting of #AC for split lock is restored to firmware setting during suspend or hibernation. When resuming from suspend or hibernation, the split lock setting is restored to kernel setting. Signed-off-by: Fenghua Yu Acked-by: Rafael J. Wysocki --- arch/x86/include/asm/cpu.h | 2 ++ arch/x86/kernel/cpu/test_ctl.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h index 45fec729c470..f2ca84deccc6 100644 --- a/arch/x86/include/asm/cpu.h +++ b/arch/x86/include/asm/cpu.h @@ -45,6 +45,7 @@ void detect_split_lock_ac(void); bool do_split_lock_exception(struct pt_regs *regs, unsigned long error_code); void setup_split_lock(void); void restore_split_lock_ac_firmware(void); +void restore_split_lock_ac_kernel(void); #else /* CONFIG_SPLIT_LOCK_AC */ static inline void detect_split_lock_ac(void) {} static inline bool @@ -55,5 +56,6 @@ do_split_lock_exception(struct pt_regs *regs, unsigned long error_code) static inline void setup_split_lock(void) {} static inline void restore_split_lock_ac_firmware(void) {} +static inline void restore_split_lock_ac_kernel(void) {} #endif /* CONFIG_SPLIT_LOCK_AC */ #endif /* _ASM_X86_CPU_H */ diff --git a/arch/x86/kernel/cpu/test_ctl.c b/arch/x86/kernel/cpu/test_ctl.c index 9e47f8174a47..82440740b2b9 100644 --- a/arch/x86/kernel/cpu/test_ctl.c +++ b/arch/x86/kernel/cpu/test_ctl.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #define DISABLE_SPLIT_LOCK_AC 0 @@ -112,6 +113,15 @@ void restore_split_lock_ac_firmware(void) restore_split_lock_ac(split_lock_ac_firmware); } +/* Restore kernel setting for #AC enable bit for split lock. */ +void restore_split_lock_ac_kernel(void) +{ + if (!boot_cpu_has(X86_FEATURE_SPLIT_LOCK_AC)) + return; + + restore_split_lock_ac(split_lock_ac_kernel); +} + static void split_lock_cpu_reboot(void *unused) { restore_split_lock_ac_firmware(); @@ -247,11 +257,29 @@ static int split_lock_online(unsigned int cpu) static int split_lock_offline(unsigned int cpu) { + restore_split_lock_ac_firmware(); cancel_delayed_work(&per_cpu(reenable_delayed_work, cpu)); return 0; } +static int split_lock_bsp_suspend(void) +{ + restore_split_lock_ac_firmware(); + + return 0; +} + +static void split_lock_bsp_resume(void) +{ + restore_split_lock_ac_kernel(); +} + +static struct syscore_ops split_lock_syscore_ops = { + .suspend = split_lock_bsp_suspend, + .resume = split_lock_bsp_resume, +}; + static int __init split_lock_init(void) { int ret; @@ -264,6 +292,8 @@ static int __init split_lock_init(void) if (ret < 0) return ret; + register_syscore_ops(&split_lock_syscore_ops); + register_reboot_notifier(&split_lock_reboot_nb); return 0; -- 2.5.0