From: Javier Pello <devel@otheo.eu>
To: linux-kernel@vger.kernel.org
Cc: x86@kernel.org, Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: [PATCH 1/1] x86/mm/pae: Align up pteval_t, pmdval_t and pudval_t to avoid split locks
Date: Mon, 1 Apr 2024 18:57:12 +0200 [thread overview]
Message-ID: <20240401185712.a80deeb2fddeded0ad42cc04@otheo.eu> (raw)
In-Reply-To: <20240401185451.6897208962d3fc47a12ffb5a@otheo.eu>
From: Javier Pello <devel@otheo.eu>
When PAE is enabled on x86-32, the types pte_t, pmd_t and pud_t are
defined in terms of pteval_t, pmdval_t and pudval_t, respectively,
all of which are typedefs for u64, which is an 8-byte type with
4-byte alignment. However, variables of these types are subject to
compare-and-exchange operations in their respective native_set_*
functions, which can trigger split locks if a variable spans two
cache lines, for instance on the stack. Annotate these types with
__aligned(8) to avoid this.
Signed-off-by: Javier Pello <devel@otheo.eu>
Cc: x86@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: stable@vger.kernel.org
---
arch/x86/include/asm/pgtable-3level_types.h | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/arch/x86/include/asm/pgtable-3level_types.h b/arch/x86/include/asm/pgtable-3level_types.h
index 80911349..61f62ab4 100644
--- a/arch/x86/include/asm/pgtable-3level_types.h
+++ b/arch/x86/include/asm/pgtable-3level_types.h
@@ -5,12 +5,16 @@
#ifndef __ASSEMBLY__
#include <linux/types.h>
-typedef u64 pteval_t;
-typedef u64 pmdval_t;
-typedef u64 pudval_t;
-typedef u64 p4dval_t;
-typedef u64 pgdval_t;
-typedef u64 pgprotval_t;
+/*
+ * Variables of these types are subject to atomic compare-and-exchange
+ * operations, so they have to be properly aligned to avoid split locks.
+ */
+typedef u64 pteval_t __aligned(8);
+typedef u64 pmdval_t __aligned(8);
+typedef u64 pudval_t __aligned(8);
+typedef u64 p4dval_t __aligned(8);
+typedef u64 pgdval_t __aligned(8);
+typedef u64 pgprotval_t __aligned(8);
typedef union {
struct {
--
2.43.3
next prev parent reply other threads:[~2024-04-01 16:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-01 16:54 [PATCH 0/1] Split lock detected in kernel mode on x86-32 with PAE Javier Pello
2024-04-01 16:57 ` Javier Pello [this message]
2024-04-01 17:56 ` [PATCH 1/1] x86/mm/pae: Align up pteval_t, pmdval_t and pudval_t to avoid split locks Dave Hansen
2024-04-02 17:23 ` Javier Pello
2024-04-02 17:43 ` Dave Hansen
2024-04-03 7:57 ` Ingo Molnar
2024-04-03 11:08 ` Brian Gerst
2024-04-04 7:56 ` Ingo Molnar
2024-04-04 15:36 ` Brian Gerst
2024-04-04 16:29 ` Dave Hansen
2024-04-03 15:54 ` Javier Pello
2024-04-03 15:58 ` Dave Hansen
2024-04-04 15:26 ` Sean Christopherson
2024-04-04 18:31 ` Dave Hansen
2024-04-04 21:55 ` Sean Christopherson
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=20240401185712.a80deeb2fddeded0ad42cc04@otheo.eu \
--to=devel@otheo.eu \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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
all inboxes | Powered by JetHome®