Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1381821yba; Thu, 4 Apr 2019 09:36:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5P1ZlEOUHOu7NpxD3ISwDYncKVLU9RxBBRjtB5pwWqxE+I9/aupOCPtFRL73k4aN683AD X-Received: by 2002:a17:902:9a4c:: with SMTP id x12mr7496806plv.157.1554395811862; Thu, 04 Apr 2019 09:36:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554395811; cv=none; d=google.com; s=arc-20160816; b=YKFJfDwrP/mR4x8P+L4ZOvYNHrQUFNcoX5PhmtPnVOhy3H8xGGXezlegTUmkwAcz+7 eLm/tTS71SPFY3zfGrmhb5ZoHFZYNHoWNc64WI0HM5P4lh7TodKddwtLE5PZRTnuw+yA t7Ye+ahoCHWMAEIcUZGPNgiGVPCEQqHue3Y+SAIF93IK06OvAEwpnRrIdvbh4rYrrbPv nAYLVNCKmB2mwVR0+sFhV6Dowbd/vdXvhDi8fuWtwmRUH61uvPzVWeOdQCWLGerlSod9 5Dv/ptyRoMnl/qNe893ITjz1an2yg+PDcLtlMtXnJgslGO76JShgZN7eDCKuGjS8gQUf yqCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=s16NsjFSj7x7Zcsb2bmeulM5FN6ZJOJ0v1JbL/PiYlQ=; b=hVevQGVbjmHpUpNJul8lzp+PaSkJSDQyyE8To94mI2YFAckPOT/jvwfqOU/GRt24jD d4F1WQl77ONIC2yS0sEaf/OcfZ/3RFLlLpXHsXcNdiphFhVov8oRKYe5niYMmBz56/Ab cYiYztDNBCQ4JWIHXnQcjA69KI++fGxEzcYT8Yzb37NAOwuWsW/ntn7acYryCUz/xf1l tEa+HH1uhIl8HdGfhE5p5HsmYNUv10oX4g4zCQd27KTV6j5vpJZ/hB2g2osDwXnAow8W F9w1ctpKEt/fw8RFUG2LtzWjUyVjC+5T9+PfQQvWjsNEoKhgg++LmnRTs6pTcRJQgKJR oGiA== 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 a5si16471422pff.39.2019.04.04.09.36.36; Thu, 04 Apr 2019 09:36:51 -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 S1729401AbfDDQfr (ORCPT + 99 others); Thu, 4 Apr 2019 12:35:47 -0400 Received: from mga11.intel.com ([192.55.52.93]:16322 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727039AbfDDQfq (ORCPT ); Thu, 4 Apr 2019 12:35:46 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Apr 2019 09:35:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,308,1549958400"; d="scan'208";a="128641824" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.181]) by orsmga007.jf.intel.com with ESMTP; 04 Apr 2019 09:35:45 -0700 Date: Thu, 4 Apr 2019 09:35:45 -0700 From: Sean Christopherson To: David Laight Cc: 'Fenghua Yu' , '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' , 'linux-kernel' , 'x86' , "'linux-wireless@vger.kernel.org'" , "'netdev@vger.kernel.org'" , "'kvm@vger.kernel.org'" Subject: Re: [PATCH v6 04/20] x86/split_lock: Align x86_capability to unsigned long to avoid split locked access Message-ID: <20190404163545.GE9911@linux.intel.com> References: <1554326526-172295-1-git-send-email-fenghua.yu@intel.com> <1554326526-172295-5-git-send-email-fenghua.yu@intel.com> <73ecc9de54c3424da3cddd1a34cb8701@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 04, 2019 at 04:24:15PM +0000, David Laight wrote: > From: David Laight > > Sent: 04 April 2019 15:45 > > > > From: Fenghua Yu > > > Sent: 03 April 2019 22:22 > > > 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. > > > > That is not true. > > The BTS/BTR instructions access the memory word that contains the > > expected bit. > > The 'operand size' only affects the size of the register use for the > > bit offset. > > If the 'operand size' is 16 bits wide (+/- 32k bit offset) the cpu might > > do an aligned 16bit memory access, otherwise (32 or 64bit bit offset) it > > might do an aligned 32 bit access. > > It should never do an 64bit access and never a misaligned one (even if > > the base address is misaligned). > > Hmmm... I may have misread things slightly. > The accessed address is 'Effective Address + (4 ∗ (BitOffset DIV 32))'. > However nothing suggests that it ever does 64bit accesses. > > If it does do 64bit accesses when the operand size is 64 bits then the > asm stubs ought to be changed to only specify 32bit operand size. Heh, we had this discussion before[1], the op size dictates the size of the memory access and can generate unaligned accesses. [1] https://lkml.kernel.org/r/20181127195153.GE27075@linux.intel.com