stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Andy Lutomirski <luto@kernel.org>,
	Nadav Amit <nadav.amit@gmail.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Arjan van de Ven <arjan@linux.intel.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@intel.com>,
	Juergen Gross <jgross@suse.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Mel Gorman <mgorman@suse.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Rik van Riel <riel@redhat.com>,
	linux-mm@kvack.org, Ingo Molnar <mingo@kernel.org>,
	Hugh Dickins <hughd@google.com>
Subject: [PATCH 4.9 21/75] x86/mm: Enable CR4.PCIDE on supported systems
Date: Mon,  1 Jan 2018 15:31:58 +0100	[thread overview]
Message-ID: <20180101140059.950536297@linuxfoundation.org> (raw)
In-Reply-To: <20180101140056.475827799@linuxfoundation.org>

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Andy Lutomirski <luto@kernel.org>

commit 660da7c9228f685b2ebe664f9fd69aaddcc420b5 upstream.

We can use PCID if the CPU has PCID and PGE and we're not on Xen.

By itself, this has no effect. A followup patch will start using PCID.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Nadav Amit <nadav.amit@gmail.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/6327ecd907b32f79d5aa0d466f04503bbec5df88.1498751203.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/include/asm/tlbflush.h |    8 ++++++++
 arch/x86/kernel/cpu/common.c    |   22 ++++++++++++++++++++++
 arch/x86/xen/enlighten.c        |    6 ++++++
 3 files changed, 36 insertions(+)

--- a/arch/x86/include/asm/tlbflush.h
+++ b/arch/x86/include/asm/tlbflush.h
@@ -191,6 +191,14 @@ static inline void __flush_tlb_all(void)
 		__flush_tlb_global();
 	else
 		__flush_tlb();
+
+	/*
+	 * Note: if we somehow had PCID but not PGE, then this wouldn't work --
+	 * we'd end up flushing kernel translations for the current ASID but
+	 * we might fail to flush kernel translations for other cached ASIDs.
+	 *
+	 * To avoid this issue, we force PCID off if PGE is off.
+	 */
 }
 
 static inline void __flush_tlb_one(unsigned long addr)
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -324,6 +324,25 @@ static __always_inline void setup_smap(s
 	}
 }
 
+static void setup_pcid(struct cpuinfo_x86 *c)
+{
+	if (cpu_has(c, X86_FEATURE_PCID)) {
+		if (cpu_has(c, X86_FEATURE_PGE)) {
+			cr4_set_bits(X86_CR4_PCIDE);
+		} else {
+			/*
+			 * flush_tlb_all(), as currently implemented, won't
+			 * work if PCID is on but PGE is not.  Since that
+			 * combination doesn't exist on real hardware, there's
+			 * no reason to try to fully support it, but it's
+			 * polite to avoid corrupting data if we're on
+			 * an improperly configured VM.
+			 */
+			clear_cpu_cap(c, X86_FEATURE_PCID);
+		}
+	}
+}
+
 /*
  * Protection Keys are not available in 32-bit mode.
  */
@@ -1082,6 +1101,9 @@ static void identify_cpu(struct cpuinfo_
 	setup_smep(c);
 	setup_smap(c);
 
+	/* Set up PCID */
+	setup_pcid(c);
+
 	/*
 	 * The vendor-specific functions might have changed features.
 	 * Now we do "generic changes."
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -444,6 +444,12 @@ static void __init xen_init_cpuid_mask(v
 		~((1 << X86_FEATURE_MTRR) |  /* disable MTRR */
 		  (1 << X86_FEATURE_ACC));   /* thermal monitoring */
 
+	/*
+	 * Xen PV would need some work to support PCID: CR3 handling as well
+	 * as xen_flush_tlb_others() would need updating.
+	 */
+	cpuid_leaf1_ecx_mask &= ~(1 << (X86_FEATURE_PCID % 32));  /* disable PCID */
+
 	if (!xen_initial_domain())
 		cpuid_leaf1_edx_mask &=
 			~((1 << X86_FEATURE_ACPI));  /* disable ACPI */


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2018-01-01 14:31 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-01 14:31 [PATCH 4.9 00/75] 4.9.74-stable review Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 01/75] sync objtools copy of x86-opcode-map.txt Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 02/75] tracing: Remove extra zeroing out of the ring buffer page Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 03/75] tracing: Fix possible double free on failure of allocating trace buffer Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 04/75] tracing: Fix crash when it fails to alloc ring buffer Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 05/75] ring-buffer: Mask out the info bits when returning buffer page length Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 06/75] iw_cxgb4: Only validate the MSN for successful completions Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 07/75] ASoC: wm_adsp: Fix validation of firmware and coeff lengths Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 08/75] ASoC: da7218: fix fix child-node lookup Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 09/75] ASoC: fsl_ssi: AC97 ops need regmap, clock and cleaning up on failure Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 10/75] ASoC: twl4030: fix child-node lookup Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 11/75] ASoC: tlv320aic31xx: Fix GPIO1 register definition Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 12/75] ALSA: hda: Drop useless WARN_ON() Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 13/75] ALSA: hda - fix headset mic detection issue on a Dell machine Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 14/75] x86/vm86/32: Switch to flush_tlb_mm_range() in mark_screen_rdonly() Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 15/75] x86/mm: Remove flush_tlb() and flush_tlb_current_task() Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 16/75] x86/mm: Make flush_tlb_mm_range() more predictable Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 17/75] x86/mm: Reimplement flush_tlb_page() using flush_tlb_mm_range() Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 18/75] x86/mm: Remove the UP asm/tlbflush.h code, always use the (formerly) SMP code Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 19/75] x86/mm: Disable PCID on 32-bit kernels Greg Kroah-Hartman
2018-01-01 14:31 ` [PATCH 4.9 20/75] x86/mm: Add the nopcid boot option to turn off PCID Greg Kroah-Hartman
2018-01-01 14:31 ` Greg Kroah-Hartman [this message]
2018-01-01 14:31 ` [PATCH 4.9 22/75] x86/mm/64: Fix reboot interaction with CR4.PCIDE Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 25/75] ipv6: mcast: better catch silly mtu values Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 26/75] net: fec: unmap the xmit buffer that are not transferred by DMA Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 27/75] net: igmp: Use correct source address on IGMPv3 reports Greg Kroah-Hartman
2018-01-16  3:50   ` Sebastian Gottschall
2018-01-16  3:58     ` Kevin Cernekee
2018-01-16  4:26       ` Sebastian Gottschall
2018-01-16  4:32         ` Kevin Cernekee
2018-01-16  4:44           ` Sebastian Gottschall
2018-01-16  5:16             ` Kevin Cernekee
2018-01-16  9:18               ` Sebastian Gottschall
2018-01-16 15:31                 ` Kevin Cernekee
2018-01-16 15:40                   ` Sebastian Gottschall
2018-01-16  9:21               ` Sebastian Gottschall
2018-01-16  4:55     ` Sebastian Gottschall
2018-01-16  5:55     ` Greg Kroah-Hartman
2018-01-16  7:34       ` Sebastian Gottschall
2018-01-16  8:15         ` Greg Kroah-Hartman
2018-01-16 15:25     ` David Miller
2018-01-16 15:34       ` Sebastian Gottschall
2018-01-01 14:32 ` [PATCH 4.9 28/75] netlink: Add netns check on taps Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 30/75] net: reevalulate autoflowlabel setting after sysctl setting Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 31/75] ptr_ring: add barriers Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 32/75] RDS: Check cmsg_len before dereferencing CMSG_DATA Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 33/75] tcp_bbr: record "full bw reached" decision in new full_bw_reached bit Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 34/75] tcp md5sig: Use skbs saddr when replying to an incoming segment Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 35/75] tg3: Fix rx hang on MTU change with 5717/5719 Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 36/75] net: ipv4: fix for a race condition in raw_sendmsg Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 37/75] net: mvmdio: disable/unprepare clocks in EPROBE_DEFER case Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 38/75] sctp: Replace use of sockets_allocated with specified macro Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 39/75] adding missing rcu_read_unlock in ipxip6_rcv Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 40/75] ipv4: Fix use-after-free when flushing FIB tables Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 41/75] net: bridge: fix early call to br_stp_change_bridge_id and plug newlink leaks Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 42/75] net: fec: Allow reception of frames bigger than 1522 bytes Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 43/75] net: Fix double free and memory corruption in get_net_ns_by_id() Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 44/75] net: phy: micrel: ksz9031: reconfigure autoneg after phy autoneg workaround Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 45/75] sock: free skb in skb_complete_tx_timestamp on error Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 46/75] tcp: invalidate rate samples during SACK reneging Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 47/75] net/mlx5: Fix rate limit packet pacing naming and struct Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 48/75] net/mlx5e: Fix features check of IPv6 traffic Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 49/75] net/mlx5e: Fix possible deadlock of VXLAN lock Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 50/75] net/mlx5e: Add refcount to VXLAN structure Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 51/75] net/mlx5e: Prevent possible races in VXLAN control flow Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 52/75] net/mlx5: Fix error flow in CREATE_QP command Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 53/75] s390/qeth: apply takeover changes when mode is toggled Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 54/75] s390/qeth: dont apply takeover changes to RXIP Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 55/75] s390/qeth: lock IP table while applying takeover changes Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 56/75] s390/qeth: update takeover IPs after configuration change Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 57/75] usbip: fix usbip bind writing random string after command in match_busid Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 58/75] usbip: prevent leaking socket pointer address in messages Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 59/75] usbip: stub: stop printing kernel pointer addresses " Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 60/75] usbip: vhci: " Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 61/75] USB: serial: ftdi_sio: add id for Airbus DS P8GR Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 63/75] USB: serial: option: add support for Telit ME910 PID 0x1101 Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 65/75] usb: Add device quirk for Logitech HD Pro Webcam C925e Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 66/75] usb: add RESET_RESUME for ELSA MicroLink 56K Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 67/75] USB: Fix off by one in type-specific length check of BOS SSP capability Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 68/75] usb: xhci: Add XHCI_TRUST_TX_LENGTH for Renesas uPD720201 Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 69/75] timers: Use deferrable base independent of base::nohz_active Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 70/75] timers: Invoke timer_start_debug() where it makes sense Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 71/75] timers: Reinitialize per cpu bases on hotplug Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 72/75] nohz: Prevent a timer interrupt storm in tick_nohz_stop_sched_tick() Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 73/75] x86/smpboot: Remove stale TLB flush invocations Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 74/75] n_tty: fix EXTPROC vs ICANON interaction with TIOCINQ (aka FIONREAD) Greg Kroah-Hartman
2018-01-01 14:32 ` [PATCH 4.9 75/75] tty: fix tty_ldisc_receive_buf() documentation Greg Kroah-Hartman
2018-01-01 20:38 ` [PATCH 4.9 00/75] 4.9.74-stable review Naresh Kamboju
2018-01-02 16:49 ` Guenter Roeck
2018-01-02 18:22   ` Greg Kroah-Hartman
2018-01-02 16:57 ` Neal Cardwell
2018-01-02 18:21   ` Greg Kroah-Hartman
2018-01-02 18:32   ` David Miller
2018-01-02 19:11     ` Neal Cardwell
2018-01-02 19:12       ` David Miller
2018-01-02 20:08       ` Greg KH
2018-01-02 22:31         ` Neal Cardwell
2018-01-02 22:23 ` Shuah Khan

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=20180101140059.950536297@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@linux.intel.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=hughd@google.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@kernel.org \
    --cc=nadav.amit@gmail.com \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).