Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp563414yba; Wed, 3 Apr 2019 14:31:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOvvkGra/fVcTVkFgi1enZun7lFUB0ca5OelKtHfmclBFW5v47hsK4V1JBkF8BrJWBjs7X X-Received: by 2002:aa7:9294:: with SMTP id j20mr1837904pfa.64.1554327077074; Wed, 03 Apr 2019 14:31:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554327077; cv=none; d=google.com; s=arc-20160816; b=pcoNERnduQ4iNY7k1dIR9jfI3GBY4ogYFtPw6znbq01cmkpqiwMcXrRLVNbvWO6MAW 5K05tAmGBmSkSB6gJkeblVARZ5hKOd9hlhYl8/gXblvix55zgTr4Iye33T9UMXlQKT4d M79HOlp78S77D1MdHNx2PiE8PZzOjflccM+r7vStabTvPZC8klJ8nKPu8kMjsyYl+qy6 rGlS6GyGCgp4DbLF3T7nk0Qu4elWeyWoJhAQiEXwN2wAoM7VA+PQCCzLWLkBrEiJ8hj/ 01tNx531LwH2zo3N+ILuWlNK0RZg+2Mf2vBAqMiWvYo9O+bcc3zbYAKYH2NnKv4mthiR M4QQ== 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; bh=ptpRwkLV+YqW8NBnFDCs0JoTewLIrQueLy2l75VSNhs=; b=JCw0EOL10PaJQ97PfzTD2zcU/aN4zX7ikiAMItI2ojdL8c3xS/Nmb9Sa4gmjYOCVlo xpUyggOQNS6Z5NGQo0ygPnX8Mw1KRHm9QdYRR9LkyOnmfhCI3C6zWZsbdxvJekVq7gKe 07ApKCqDcD2gVVHMAA/Wq+mgTF6IpIeUr2niIihonZjmKUnVTNwHH17hE5Rd7Pl+TXQF 1rBaX5UPgjFt41yOABOkr7aKKd8YDE5I9fILb6l+hHddOXy11pMUgy8P/nzjV4Ey1GFw A7VdgN0aIkm9/b82eE2vQ9DeHOVE9FwITqXLvNpui28Rtsr0jDE9CMNaWXyOranv9Rvd a0Jw== 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 w10si12066444plz.37.2019.04.03.14.31.01; Wed, 03 Apr 2019 14:31:17 -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 S1726783AbfDCVaV (ORCPT + 99 others); Wed, 3 Apr 2019 17:30:21 -0400 Received: from mga05.intel.com ([192.55.52.43]:37312 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726628AbfDCVaT (ORCPT ); Wed, 3 Apr 2019 17:30:19 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Apr 2019 14:30:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,306,1549958400"; d="scan'208";a="334754234" Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by fmsmga005.fm.intel.com with ESMTP; 03 Apr 2019 14:30:10 -0700 From: Fenghua Yu To: "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "H Peter Anvin" , "Dave Hansen" , "Paolo Bonzini" , "Ashok Raj" , "Peter Zijlstra" , "Kalle Valo" , "Xiaoyao Li " , "Michael Chan" , "Ravi V Shankar" Cc: "linux-kernel" , "x86" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, kvm@vger.kernel.org, Fenghua Yu Subject: [PATCH v6 04/20] x86/split_lock: Align x86_capability to unsigned long to avoid split locked access Date: Wed, 3 Apr 2019 14:21:50 -0700 Message-Id: <1554326526-172295-5-git-send-email-fenghua.yu@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1554326526-172295-1-git-send-email-fenghua.yu@intel.com> References: <1554326526-172295-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 set_cpu_cap() calls locked BTS and clear_cpu_cap() calls locked BTR to operate on bitmap defined in x86_capability. Locked BTS/BTR accesses a single unsigned long location. In 64-bit mode, the location is at: base address of x86_capability + (bit offset in x86_capability / 64) * 8 Since base address of x86_capability may not be aligned to unsigned long, the single unsigned long location may cross two cache lines and accessing the location by locked BTS/BTR introductions will trigger #AC. To fix the split lock issue, align x86_capability to unsigned long so that the location will be always within one cache line. Changing x86_capability[]'s type to unsigned long may also fix the issue because x86_capability[] will be naturally aligned to unsigned long. But this needs additional code changes. So choose the simpler solution by setting alignment to size of unsigned long. Signed-off-by: Fenghua Yu --- arch/x86/include/asm/processor.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 2bb3a648fc12..7c62b9ad6e5a 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -93,7 +93,9 @@ struct cpuinfo_x86 { __u32 extended_cpuid_level; /* Maximum supported CPUID level, -1=no CPUID: */ int cpuid_level; - __u32 x86_capability[NCAPINTS + NBUGINTS]; + /* Aligned to size of unsigned long to avoid split lock in atomic ops */ + __u32 x86_capability[NCAPINTS + NBUGINTS] + __aligned(sizeof(unsigned long)); char x86_vendor_id[16]; char x86_model_id[64]; /* in KB - valid for CPUS which support this call: */ -- 2.19.1