Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp910000imb; Fri, 1 Mar 2019 18:54:57 -0800 (PST) X-Google-Smtp-Source: APXvYqzwdikDCP8q0PkL802Q5Snd10EvsImQGRaqqnltVA0y1DO0myJAFCxaKpJuuaEtQ0APt7wG X-Received: by 2002:a63:535d:: with SMTP id t29mr8175212pgl.251.1551495297151; Fri, 01 Mar 2019 18:54:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551495297; cv=none; d=google.com; s=arc-20160816; b=0Tfey1FkbJL1Xp6T6n5TKy3uHfVhj5a4htF6FNgTvhHpjBtX7K+yauY+xQj9vlA0eY iBO3tkk1VheSvpH+zKiR0pmTB/S92SlMbY7C1k8a/eFaUNAHPLqljl3br4gomnFPu4ze RdJPAwwy6SsUpXr25x26xMB4bNRjQt/2AiGGlGuo6OJ5v6lcQJyXzzLbOA58KkVBhQUW 3VM01dLfRDV8QdTaS1a7veiWOXlwIdXoXHPReWzBwe0UAoyTFZeCSsoHL+vJaR+RhFgZ yNyqoI6UF1hEbLJ39fd5Yifarp5gGAIB7Z0fmoCOd95EMBm6mrSVEVtANpqDsAtG73vP 1BUg== 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=LPY8v6NlSPVG6Tg/OvNf+0Lk0ZurBehcHLiq7ZwZlXg=; b=HGby4JQik34C/0yhlrxAbJwh16bjhK2Xf/dlMsxFMXpeHn5Iv6ScAF6DV+vTaT9qP/ bPQp5OHsELp4bUXvtqG+isXmPZSNm65J2Ka7fiNQmV4WbKVjYkrynFOibPpaSGFVDSOs ZiOH91bUrXBl07KEL/qT+uswYO4O7d6qhloUk/G2KngWH3DJMd7cokT1HWpPEJBgEkjB dPTlSr+1qhaLfg780OGQAbcprhcZ4bQn3SSBf0fL3i9mHRTbchYAaKO7UIFi11mUSruH 9HUBH+L24Nf7LlQbTRfodGjEp74kdCnIVSdA4JPZn+/ckhb5mk/IzD7C4EEGyQoApJno zppw== 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 r203si9822545pgr.517.2019.03.01.18.54.42; Fri, 01 Mar 2019 18:54:57 -0800 (PST) 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 S1728250AbfCBCxn (ORCPT + 99 others); Fri, 1 Mar 2019 21:53:43 -0500 Received: from mga09.intel.com ([134.134.136.24]:61568 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727806AbfCBCwa (ORCPT ); Fri, 1 Mar 2019 21:52:30 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Mar 2019 18:52:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,430,1544515200"; d="scan'208";a="148572598" Received: from romley-ivt3.sc.intel.com ([172.25.110.60]) by fmsmga004.fm.intel.com with ESMTP; 01 Mar 2019 18:52:28 -0800 From: Fenghua Yu To: "Thomas Gleixner" , "Ingo Molnar" , "Borislav Petkov" , "H Peter Anvin" , "Paolo Bonzini" , "Dave Hansen" , "Ashok Raj" , "Peter Zijlstra" , "Ravi V Shankar" , "Xiaoyao Li " Cc: "linux-kernel" , "x86" , kvm@vger.kernel.org, Fenghua Yu Subject: [PATCH v4 04/17] x86/split_lock: Align x86_capability to unsigned long to avoid split locked access Date: Fri, 1 Mar 2019 18:44:58 -0800 Message-Id: <1551494711-213533-5-git-send-email-fenghua.yu@intel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1551494711-213533-1-git-send-email-fenghua.yu@intel.com> References: <1551494711-213533-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 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 we choose the simpler solution by enforcing alignment using __aligned(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 33051436c864..eb8ae701ef65 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]; + /* Unsigned long alignment to avoid split lock in atomic bitmap 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.7.4