From patchwork Sun Apr 28 17:27:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Nesterov X-Patchwork-Id: 240265 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1A2952C009D for ; Mon, 29 Apr 2013 03:31:13 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755889Ab3D1Rau (ORCPT ); Sun, 28 Apr 2013 13:30:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35806 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753977Ab3D1Rat (ORCPT ); Sun, 28 Apr 2013 13:30:49 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3SHUXtj031760 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 28 Apr 2013 13:30:33 -0400 Received: from tranklukator.brq.redhat.com (dhcp-1-102.brq.redhat.com [10.34.1.102]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id r3SHUTKV030270; Sun, 28 Apr 2013 13:30:29 -0400 Received: by tranklukator.brq.redhat.com (nbSMTP-1.00) for uid 500 oleg@redhat.com; Sun, 28 Apr 2013 19:27:36 +0200 (CEST) Date: Sun, 28 Apr 2013 19:27:31 +0200 From: Oleg Nesterov To: Frederic Weisbecker Cc: "H. Peter Anvin" , Ingo Molnar , Linus Torvalds , Cyrill Gorcunov , Peter Zijlstra , Thomas Gleixner , David Miller , "Theodore Ts'o" , Linux Kernel Mailing List , the arch/x86 maintainers , Network Development , "linux-ext4@vger.kernel.org" Subject: Re: [PATCH v2] x86: make DR*_RESERVED unsigned long Message-ID: <20130428172731.GA26169@redhat.com> References: <20130424072630.GB1780@gmail.com> <20130424170702.GA1867@redhat.com> <5178282D.9030902@zytor.com> <20130425144818.GA25921@redhat.com> <20130426163802.GA30351@redhat.com> <517AAED5.7040400@zytor.com> <20130426171526.GA30875@redhat.com> <20130427144537.GA24256@redhat.com> <20130428005814.GB10354@somewhere> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130428005814.GB10354@somewhere> User-Agent: Mutt/1.5.18 (2008-05-17) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 04/28, Frederic Weisbecker wrote: > > On Sat, Apr 27, 2013 at 04:45:37PM +0200, Oleg Nesterov wrote: > > > > -/* Define reserved bits in DR6 which are always set to 1 */ > > -#define DR6_RESERVED (0xFFFF0FF0) > > +#define DR6_MASK (0xF00FU) /* Everything else is reserved */ > > I'm personally fine either with that or with Peter's suggestion to do: > > -#define DR6_RESERVED (0xFFFF0FF0) > +#define DR6_RESERVED (~0xF00FUL) I missed this suggestion... Yes, and this allows to kill ifdef too. > If this should stay stable UAPI, I do not know, but I guess it would be safer to keep the old define's. > I really don't mind. Oh, I do not mind too ;) OK, please see v3. ------------------------------------------------------------------------------ Subject: [PATCH v3] x86: make DR*_RESERVED unsigned long DR6_RESERVED and DR_CONTROL_RESERVED are used to clear the unwanted bits in the "unsigned long" data, but "ulong &= ~int" also clears the upper bits that are not specified in mask. This is actually fine, dr6[32:63] are reserved, but this is not clear so it would be better to make them "unsigned long" to cleanup the code. However, depending on sizeof(long), DR6_RESERVED should be either 0xFFFF0FF0 or 0xFFFFFFFF_FFFF0FF0, so this patch redefines them as (~ 32_bit_mask UL) to avoid ifdef's. Reported-by: Linus Torvalds Suggested-by: H. Peter Anvin Signed-off-by: Oleg Nesterov --- arch/x86/include/uapi/asm/debugreg.h | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/uapi/asm/debugreg.h b/arch/x86/include/uapi/asm/debugreg.h index 3c0874d..4ff5d05 100644 --- a/arch/x86/include/uapi/asm/debugreg.h +++ b/arch/x86/include/uapi/asm/debugreg.h @@ -15,7 +15,7 @@ are either reserved or not of interest to us. */ /* Define reserved bits in DR6 which are always set to 1 */ -#define DR6_RESERVED (0xFFFF0FF0) +#define DR6_RESERVED (~0xF00FUL) #define DR_TRAP0 (0x1) /* db0 */ #define DR_TRAP1 (0x2) /* db1 */ @@ -64,11 +64,7 @@ We can slow the instruction pipeline for instructions coming via the gdt or the ldt if we want to. I am not sure why this is an advantage */ -#ifdef __i386__ -#define DR_CONTROL_RESERVED (0xFC00) /* Reserved by Intel */ -#else -#define DR_CONTROL_RESERVED (0xFFFFFFFF0000FC00UL) /* Reserved */ -#endif +#define DR_CONTROL_RESERVED (~0xFFFF03FFUL) /* Reserved by Intel */ #define DR_LOCAL_SLOWDOWN (0x100) /* Local slow the pipeline */ #define DR_GLOBAL_SLOWDOWN (0x200) /* Global slow the pipeline */