Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1281085yba; Thu, 4 Apr 2019 07:46:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwg5XuIZir/A7Facc92ibEdjALpddWPEs+XCkk8dp1PP0wh6j8TUr/e3WpxK8Ys3BEjHPnn X-Received: by 2002:a17:902:f089:: with SMTP id go9mr6550480plb.309.1554389160746; Thu, 04 Apr 2019 07:46:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554389160; cv=none; d=google.com; s=arc-20160816; b=HM/nw/blGFJ/sPW5qY40iiYPaEma04mCqhhytLS+AtfBjgtE+ZKASGRqqWtOgNDK5V IhV7tyfWcxw16pXwo2Q7gbfvkmNJerZ9NDibGZEoMiRoyXKJklOf1Q+Sq9ydS9vTn5Jq rQOw67N1GHR6LFbqcTnsB9DVTaf4598vLEngzIsE3OD2Wu7+db5vyBhotb3v6Dip/nim xXpXdeJqvTWi6ixjxdmHMqTc1GUfBEDHO8ZFbBvcXiSVPewNGv1XB8BQvW08OYy0h6SI FuVrSKUIwwuTXCso5CQTurBwrQ40JfSLFVFncQnES47md0oznm3BVHIL0eAaWlwi12me oLFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=kX88ghS5oXI/Oizo/0KGW3Slp4wevJ42As3CUbyD7sg=; b=mDT8+buzyxTyz6ByenT6qmH0La/EmHlWR6K+Hfa510tg2I7pfnCQPHzh8nAY38n9uU p0sNMKXqAZH1FO0U4wVg5Pkqb2r2QqMt0cJD8KlFAT7xmiI6gsVQnwUFTzRGtb40iMhn 03GwqEFyZhr4bzdf1Jbc/EwWr8KvvMukBB2r7kRNJJpyHHe7iPbgT048Rvnh6UuXj6LV 4fDHFMdyY4pXXO5sUr+AghZktvdqMg+MecqJathKetbg+yPpiiTQj2dYopImQnH6W6z6 RHoRh9XZGFpoWFElYV3Ze3truxp4z9sqsqYTVNOrjZ6uBrJRDzMAXXzkp37QzOy12IRL 8NeA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l186si75213pge.128.2019.04.04.07.45.45; Thu, 04 Apr 2019 07:46:00 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729156AbfDDOnl convert rfc822-to-8bit (ORCPT + 99 others); Thu, 4 Apr 2019 10:43:41 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([146.101.78.151]:32763 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729095AbfDDOnk (ORCPT ); Thu, 4 Apr 2019 10:43:40 -0400 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-45-Ax38F7LhM8a1MVH26902Kg-1; Thu, 04 Apr 2019 15:43:37 +0100 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 4 Apr 2019 15:44:44 +0100 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Thu, 4 Apr 2019 15:44:44 +0100 From: David Laight To: '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" CC: 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 Thread-Topic: [PATCH v6 04/20] x86/split_lock: Align x86_capability to unsigned long to avoid split locked access Thread-Index: AQHU6mTrt6127B4KeUCFmArv0ksdfKYsEdZA Date: Thu, 4 Apr 2019 14:44:44 +0000 Message-ID: <73ecc9de54c3424da3cddd1a34cb8701@AcuMS.aculab.com> References: <1554326526-172295-1-git-send-email-fenghua.yu@intel.com> <1554326526-172295-5-git-send-email-fenghua.yu@intel.com> In-Reply-To: <1554326526-172295-5-git-send-email-fenghua.yu@intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-MC-Unique: Ax38F7LhM8a1MVH26902Kg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)