All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev,
	Andrew Cooper <Andrew.Cooper3@citrix.com>,
	Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
	Borislav Petkov <bp@suse.de>,
	stable@kernel.org, Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 4.9 29/76] x86/cpu: Restore AMDs DE_CFG MSR after resume
Date: Wed, 23 Nov 2022 09:50:28 +0100	[thread overview]
Message-ID: <20221123084547.687446661@linuxfoundation.org> (raw)
In-Reply-To: <20221123084546.742331901@linuxfoundation.org>

From: Borislav Petkov <bp@suse.de>

commit 2632daebafd04746b4b96c2f26a6021bc38f6209 upstream.

DE_CFG contains the LFENCE serializing bit, restore it on resume too.
This is relevant to older families due to the way how they do S3.

Unify and correct naming while at it.

Fixes: e4d0e84e4907 ("x86/cpu/AMD: Make LFENCE a serializing instruction")
Reported-by: Andrew Cooper <Andrew.Cooper3@citrix.com>
Reported-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: <stable@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/x86/include/asm/msr-index.h |    8 +++++---
 arch/x86/kernel/cpu/amd.c        |   10 ++++------
 arch/x86/kvm/svm.c               |   10 +++++-----
 arch/x86/kvm/x86.c               |    2 +-
 arch/x86/power/cpu.c             |    1 +
 5 files changed, 16 insertions(+), 15 deletions(-)

--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -364,6 +364,11 @@
 #define MSR_AMD64_OSVW_STATUS		0xc0010141
 #define MSR_AMD64_LS_CFG		0xc0011020
 #define MSR_AMD64_DC_CFG		0xc0011022
+
+#define MSR_AMD64_DE_CFG		0xc0011029
+#define MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT	 1
+#define MSR_AMD64_DE_CFG_LFENCE_SERIALIZE	BIT_ULL(MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT)
+
 #define MSR_AMD64_BU_CFG2		0xc001102a
 #define MSR_AMD64_IBSFETCHCTL		0xc0011030
 #define MSR_AMD64_IBSFETCHLINAD		0xc0011031
@@ -414,9 +419,6 @@
 #define FAM10H_MMIO_CONF_BASE_MASK	0xfffffffULL
 #define FAM10H_MMIO_CONF_BASE_SHIFT	20
 #define MSR_FAM10H_NODE_ID		0xc001100c
-#define MSR_F10H_DECFG			0xc0011029
-#define MSR_F10H_DECFG_LFENCE_SERIALIZE_BIT	1
-#define MSR_F10H_DECFG_LFENCE_SERIALIZE		BIT_ULL(MSR_F10H_DECFG_LFENCE_SERIALIZE_BIT)
 
 /* K8 MSRs */
 #define MSR_K8_TOP_MEM1			0xc001001a
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -735,8 +735,6 @@ static void init_amd_gh(struct cpuinfo_x
 		set_cpu_bug(c, X86_BUG_AMD_TLB_MMATCH);
 }
 
-#define MSR_AMD64_DE_CFG	0xC0011029
-
 static void init_amd_ln(struct cpuinfo_x86 *c)
 {
 	/*
@@ -898,16 +896,16 @@ static void init_amd(struct cpuinfo_x86
 		 * msr_set_bit() uses the safe accessors, too, even if the MSR
 		 * is not present.
 		 */
-		msr_set_bit(MSR_F10H_DECFG,
-			    MSR_F10H_DECFG_LFENCE_SERIALIZE_BIT);
+		msr_set_bit(MSR_AMD64_DE_CFG,
+			    MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT);
 
 		/*
 		 * Verify that the MSR write was successful (could be running
 		 * under a hypervisor) and only then assume that LFENCE is
 		 * serializing.
 		 */
-		ret = rdmsrl_safe(MSR_F10H_DECFG, &val);
-		if (!ret && (val & MSR_F10H_DECFG_LFENCE_SERIALIZE)) {
+		ret = rdmsrl_safe(MSR_AMD64_DE_CFG, &val);
+		if (!ret && (val & MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT)) {
 			/* A serializing LFENCE stops RDTSC speculation */
 			set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
 		} else {
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -3528,9 +3528,9 @@ static int svm_get_msr_feature(struct kv
 	msr->data = 0;
 
 	switch (msr->index) {
-	case MSR_F10H_DECFG:
-		if (boot_cpu_has(X86_FEATURE_LFENCE_RDTSC))
-			msr->data |= MSR_F10H_DECFG_LFENCE_SERIALIZE;
+	case MSR_AMD64_DE_CFG:
+		if (cpu_feature_enabled(X86_FEATURE_LFENCE_RDTSC))
+			msr->data |= MSR_AMD64_DE_CFG_LFENCE_SERIALIZE;
 		break;
 	default:
 		return 1;
@@ -3638,7 +3638,7 @@ static int svm_get_msr(struct kvm_vcpu *
 			msr_info->data = 0x1E;
 		}
 		break;
-	case MSR_F10H_DECFG:
+	case MSR_AMD64_DE_CFG:
 		msr_info->data = svm->msr_decfg;
 		break;
 	default:
@@ -3829,7 +3829,7 @@ static int svm_set_msr(struct kvm_vcpu *
 	case MSR_VM_IGNNE:
 		vcpu_unimpl(vcpu, "unimplemented wrmsr: 0x%x data 0x%llx\n", ecx, data);
 		break;
-	case MSR_F10H_DECFG: {
+	case MSR_AMD64_DE_CFG: {
 		struct kvm_msr_entry msr_entry;
 
 		msr_entry.index = msr->index;
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1026,7 +1026,7 @@ static unsigned num_emulated_msrs;
  * can be used by a hypervisor to validate requested CPU features.
  */
 static u32 msr_based_features[] = {
-	MSR_F10H_DECFG,
+	MSR_AMD64_DE_CFG,
 	MSR_IA32_UCODE_REV,
 	MSR_IA32_ARCH_CAPABILITIES,
 };
--- a/arch/x86/power/cpu.c
+++ b/arch/x86/power/cpu.c
@@ -526,6 +526,7 @@ static void pm_save_spec_msr(void)
 		MSR_TSX_FORCE_ABORT,
 		MSR_IA32_MCU_OPT_CTRL,
 		MSR_AMD64_LS_CFG,
+		MSR_AMD64_DE_CFG,
 	};
 
 	msr_build_context(spec_msr_id, ARRAY_SIZE(spec_msr_id));



  parent reply	other threads:[~2022-11-23  8:56 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  8:49 [PATCH 4.9 00/76] 4.9.334-rc1 review Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 01/76] HID: hyperv: fix possible memory leak in mousevsc_probe() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 02/76] net: gso: fix panic on frag_list with mixed head alloc types Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 03/76] bnxt_en: fix potentially incorrect return value for ndo_rx_flow_steer Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 04/76] net: fman: Unregister ethernet device on removal Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 05/76] capabilities: fix undefined behavior in bit shift for CAP_TO_MASK Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 06/76] net: lapbether: fix issue of dev reference count leakage in lapbeth_device_event() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 07/76] hamradio: fix issue of dev reference count leakage in bpq_device_event() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 08/76] ipv6: addrlabel: fix infoleak when sending struct ifaddrlblmsg to network Greg Kroah-Hartman
2022-11-23  8:54   ` syzbot
2022-11-23  8:50 ` [PATCH 4.9 09/76] tipc: fix the msg->req tlv len check in tipc_nl_compat_name_table_dump_header Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 10/76] dmaengine: mv_xor_v2: Fix a resource leak in mv_xor_v2_remove() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 11/76] drivers: net: xgene: disable napi when register irq failed in xgene_enet_open() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 12/76] net: cxgb3_main: disable napi when bind qsets failed in cxgb_up() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 13/76] ethernet: s2io: disable napi when start nic failed in s2io_card_up() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 14/76] net: mv643xx_eth: disable napi when init rxq or txq failed in mv643xx_eth_open() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 15/76] net: macvlan: fix memory leaks of macvlan_common_newlink Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 16/76] ALSA: hda: fix potential memleak in add_widget_node Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 17/76] ALSA: usb-audio: Add quirk entry for M-Audio Micro Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 18/76] nilfs2: fix deadlock in nilfs_count_free_blocks() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 19/76] platform/x86: hp_wmi: Fix rfkill causing soft blocked wifi Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 20/76] btrfs: selftests: fix wrong error check in btrfs_free_dummy_root() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 21/76] udf: Fix a slab-out-of-bounds write bug in udf_find_entry() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 22/76] cert host tools: Stop complaining about deprecated OpenSSL functions Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 23/76] dmaengine: at_hdmac: Fix at_lli struct definition Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 24/76] dmaengine: at_hdmac: Dont start transactions at tx_submit level Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 25/76] dmaengine: at_hdmac: Fix completion of unissued descriptor in case of errors Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 26/76] dmaengine: at_hdmac: Dont allow CPU to reorder channel enable Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 27/76] dmaengine: at_hdmac: Fix impossible condition Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 28/76] dmaengine: at_hdmac: Check return code of dma_async_device_register Greg Kroah-Hartman
2022-11-23  8:50 ` Greg Kroah-Hartman [this message]
2022-11-23  8:50 ` [PATCH 4.9 30/76] rtc: cmos: fix build on non-ACPI platforms Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 31/76] drm/imx: imx-tve: Fix return type of imx_tve_connector_mode_valid Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 32/76] Bluetooth: L2CAP: Fix l2cap_global_chan_by_psm Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 33/76] ASoC: core: Fix use-after-free in snd_soc_exit() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 34/76] serial: 8250_omap: remove wait loop from Errata i202 workaround Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 35/76] serial: 8250: omap: Flush PM QOS work on remove Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 36/76] tty: n_gsm: fix sleep-in-atomic-context bug in gsm_control_send Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 37/76] ASoC: soc-utils: Remove __exit for snd_soc_util_exit() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 38/76] parport_pc: Avoid FIFO port location truncation Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 39/76] pinctrl: devicetree: fix null pointer dereferencing in pinctrl_dt_to_map Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 40/76] mISDN: fix possible memory leak in mISDN_dsp_element_register() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 41/76] mISDN: fix misuse of put_device() in mISDN_register_device() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 42/76] net: caif: fix double disconnect client in chnl_net_open() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 43/76] xen/pcpu: fix possible memory leak in register_pcpu() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 44/76] net/x25: Fix skb leak in x25_lapb_receive_frame() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 45/76] cifs: Fix wrong return value checking when GETFLAGS Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 46/76] ftrace: Fix the possible incorrect kernel message Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 47/76] ftrace: Optimize the allocation for mcount entries Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 48/76] ring_buffer: Do not deactivate non-existant pages Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 49/76] ALSA: usb-audio: Drop snd_BUG_ON() from snd_usbmidi_output_open() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 50/76] USB: serial: option: add Sierra Wireless EM9191 Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 51/76] USB: serial: option: remove old LARA-R6 PID Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 52/76] USB: serial: option: add u-blox LARA-R6 00B modem Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 53/76] USB: serial: option: add u-blox LARA-L6 modem Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 54/76] USB: serial: option: add Fibocom FM160 0x0111 composition Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 55/76] usb: add NO_LPM quirk for Realforce 87U Keyboard Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 56/76] usb: chipidea: fix deadlock in ci_otg_del_timer Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 57/76] iio: adc: at91_adc: fix possible memory leak in at91_adc_allocate_trigger() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 58/76] iio: trigger: sysfs: fix possible memory leak in iio_sysfs_trig_init() Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 59/76] iio: pressure: ms5611: changed hardcoded SPI speed to value limited Greg Kroah-Hartman
2022-11-23  8:50 ` [PATCH 4.9 60/76] dm ioctl: fix misbehavior if list_versions races with module loading Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 61/76] serial: 8250: Fall back to non-DMA Rx if IIR_RDI occurs Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 62/76] serial: 8250_lpss: Configure DMA also w/o DMA filter Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 63/76] mmc: core: properly select voltage range without power cycle Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 64/76] misc/vmw_vmci: fix an infoleak in vmci_host_do_receive_datagram() Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 65/76] nilfs2: fix use-after-free bug of ns_writer on remount Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 66/76] serial: 8250: Flush DMA Rx on RLSI Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 67/76] tcp: cdg: allow tcp_cdg_release() to be called multiple times Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 68/76] kcm: avoid potential race in kcm_tx_work Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 69/76] 9p: trans_fd/p9_conn_cancel: drop client lock earlier Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 70/76] gfs2: Check sb_bsize_shift after reading superblock Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 71/76] gfs2: Switch from strlcpy to strscpy Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 72/76] 9p/trans_fd: always use O_NONBLOCK read/write Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 73/76] mm: fs: initialize fsdata passed to write_begin/write_end interface Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 74/76] ntfs: fix use-after-free in ntfs_attr_find() Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 75/76] ntfs: fix out-of-bounds read " Greg Kroah-Hartman
2022-11-23  8:51 ` [PATCH 4.9 76/76] ntfs: check overflow when iterating ATTR_RECORDs Greg Kroah-Hartman
2022-11-23 11:14 ` [PATCH 4.9 00/76] 4.9.334-rc1 review Pavel Machek
2022-11-23 11:47 ` Pavel Machek
2022-11-23 15:25 ` Jon Hunter
2022-11-24  2:35 ` Guenter Roeck
2022-11-24 13:01 ` Naresh Kamboju
2022-11-28 21:55 ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221123084547.687446661@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=bp@suse.de \
    --cc=patches@lists.linux.dev \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=stable@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.