Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1566432lqz; Mon, 1 Apr 2024 09:57:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW6QBIjzBVCHgQ3oBI7QmRnAAe8oAShBX8XLbVuALOG7HNKIC7SOLelVfH8cOg0T1fBNJwd7pYz2J0KIHRjTAZ+OIakwm7INaVnM/uYng== X-Google-Smtp-Source: AGHT+IE0jo2d7RGQSixenv4KEUx5CWal+q765Zd7BEw0eBsPSBXqWBdyENhes+rh1bzaoaAW47pB X-Received: by 2002:a17:903:234f:b0:1e2:61ca:9449 with SMTP id c15-20020a170903234f00b001e261ca9449mr493599plh.40.1711990659850; Mon, 01 Apr 2024 09:57:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711990659; cv=pass; d=google.com; s=arc-20160816; b=hp1jiGkSS8c+mjnmRPpp2an5DIr0mfm1AZNMSgre6xwbC2B7WfKHtaxYD3Q5VHPqTG rJ6OeykH0ZwZN2+DBM2wH/CnLm3g8Ym1pNDQ4pCUB7Hd4VhTL13HYWy+M9E6irb8cmO1 einP20PDIDQXXazKR4oBe89dNJc8wcPXCSa1NOxmgPZjwrLTJaJFFUIpbEsWI7/CEDkp eTW6pAbKEeoUB99zialnCmxdCMsL+xZ87MVP4srgBuSE+ZzeOos4Mwc02PFpb0MNGbVd xJpeyPJ3zxTTyZG/CRcnZyMDAmEm61YF03GcNl4SZtLCpmYRSFWwgQ5lWgx9uyx8bKYS 8n4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=SXWXDxA4hAxCjyuMS6SXVKSd48hGUzqLhteYMJWfkuM=; fh=V5WZw7RwUYwgMlQkvJaxchCffd9HziVpjV4DK7k5DFQ=; b=h94cseM3j+2VFhddOvn4IyvRkEQ62zptrXrLCNLgtxPa1+FGbkRphYZ7XLoFlemfTH vYRpHdfmqw4wTRFK2q9OsKtDpSxfqUJGGTmHTqgkxRM4Q+jd4bVnWlc8xerV9MR3thto 7yKvGeu4zkJdDrIxguGxUPBg6+nmk7pLjpG8noATTD/M2EudvMPRMthX0jTVVWh/GP8Z WG+IHm5ezF/XcQHzRt46R85Kk2/qOHTE1GUQIcuCNm4U2FG/y6DnwObcminDCr/4BUuy gzmD4LObMIW5nmaImpMxBN9xeee8Matm85BftGkRbjwar/Sbext1+GAFxA49RLad/aQV 3guA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@otheo.eu header.s=gm1 header.b=G2F5sCk2; arc=pass (i=1 spf=pass spfdomain=otheo.eu dkim=pass dkdomain=otheo.eu); spf=pass (google.com: domain of linux-kernel+bounces-126882-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126882-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s9-20020a170902ea0900b001debbc0f034si9998871plg.98.2024.04.01.09.57.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 09:57:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-126882-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@otheo.eu header.s=gm1 header.b=G2F5sCk2; arc=pass (i=1 spf=pass spfdomain=otheo.eu dkim=pass dkdomain=otheo.eu); spf=pass (google.com: domain of linux-kernel+bounces-126882-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-126882-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 891F928373B for ; Mon, 1 Apr 2024 16:57:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2C96BA3F; Mon, 1 Apr 2024 16:57:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=otheo.eu header.i=@otheo.eu header.b="G2F5sCk2" Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A4471DFF4 for ; Mon, 1 Apr 2024 16:57:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711990647; cv=none; b=nbKTPVhIw6ihlPQ1yeO2qV+hJFj53fa0iJXRGiGI4lRJvYlvBCCl5qEMu1FOtB28MUeZjcBpwrS3bH4fuxtJUQpw6PxHyUb7xnr2wT+wZCjSwEf5je5MSW110e6qknlNCSjVaIUrZOcVvrSdJ88eBNOED/F5IvfaOrOGkxQ/kMY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711990647; c=relaxed/simple; bh=vy2rwbkfeJlFAVqAh6iqsYi/WykwrRM/d7Y4v1HZ5aE=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=hjmfu8EjL7QnAO8L7f2BvwfTl61x7H/CCDm9i9RVDL121T3yQ1cZNpOeWv1X8irlxWvGzLrqXJxWNsV153H3pxsH77cx5BiuUKPw93dP8/H7zKzOAq9UondIgHyljJkk+fzvFTgDzHue5oX3P/v5KrfvEvgW51mr6e6adK1lxsY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=otheo.eu; spf=pass smtp.mailfrom=otheo.eu; dkim=pass (2048-bit key) header.d=otheo.eu header.i=@otheo.eu header.b=G2F5sCk2; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=otheo.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=otheo.eu Received: by mail.gandi.net (Postfix) with ESMTPSA id D137A240007; Mon, 1 Apr 2024 16:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=otheo.eu; s=gm1; t=1711990643; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SXWXDxA4hAxCjyuMS6SXVKSd48hGUzqLhteYMJWfkuM=; b=G2F5sCk2pJpMZJzoom4M7p7nAYCh0irmbxh+VYFfPzmowDvubASFpre48OhBTZhkQSftzk wIbB4ZYHi6orp5K3nzLU3/e5n0W+CiY+122zpCK9Lt7JsjQ7VF81d1wtaFgjxhdc3RmSyr WXUpNErmpa0fOicXmLEBokZVDeu6DyYTLCWBerQ13LipRvNDtRay3Py9qxh5MmuRDp5Ecq s5oHG5XiW+kBiNkpn5XkNeQ1nvU97V9Ifnc7DQ8Tdga7x3z3tBb6Bn7Ju0eu/sFLnPKf+l 5sqjONgZJ41Vm9kIqtCtqiS4pH23GH1qrKyCf1YQgP505LHaWzqk07rnpn6zDA== Date: Mon, 1 Apr 2024 18:57:12 +0200 From: Javier Pello To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Subject: [PATCH 1/1] x86/mm/pae: Align up pteval_t, pmdval_t and pudval_t to avoid split locks Message-Id: <20240401185712.a80deeb2fddeded0ad42cc04@otheo.eu> In-Reply-To: <20240401185451.6897208962d3fc47a12ffb5a@otheo.eu> References: <20240401185451.6897208962d3fc47a12ffb5a@otheo.eu> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; i686-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-GND-Sasl: #01#@otheo.eu From: Javier Pello 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 Cc: x86@kernel.org Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: "H. Peter Anvin" 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 -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