linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [v2] x86 mpx: give bndX registers actual names
@ 2014-10-31 21:58 Dave Hansen
  2014-10-31 22:10 ` Thomas Gleixner
  2014-11-18  0:04 ` [tip:x86/mpx] x86: mpx: Give " tip-bot for Dave Hansen
  0 siblings, 2 replies; 3+ messages in thread
From: Dave Hansen @ 2014-10-31 21:58 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dave Hansen, dave.hansen, x86, hpa, qiaowei.ren, fenghua.yu


Changes from V1:
 * name it 'bndreg' instead plain 'bnd'

--

From: Dave Hansen <dave.hansen@linux.intel.com>

Consider the bndX MPX registers.  There 4 registers each
containing a 64-bit lower and a 64-bit upper bound.  That's 8*64
bits and we declare it thusly:

	struct bndregs_struct {
		u64 bndregs[8];
	}

Let's say you want to read the upper bound from the MPX register
bnd2 out of the xsave buf.  You do:

	bndregno = 2;
	upper_bound = xsave_buf->bndregs.bndregs[2*bndregno+1];

That kinda sucks.  Every time you access it, you need to know:
1. Each bndX register is two entries wide in "bndregs"
2. The lower comes first followed by upper.  We do the +1 to get
   upper vs. lower.

This replaces the old definition.  You can now access them
indexed by the register number directly, and with a meaningful
name for the lower and upper bound:

	bndregno = 2;
	xsave_buf->bndreg[bndregno].ub;

It's now *VERY* clear that there are 4 registers.  The programmer
now doesn't have to care what order the lower and upper bounds
are in, and it's harder to get it wrong.

The naming "lb" and "ub" reflects the names found in the Intel
SDM Extensions documentation of these registers.  I'm not married
to it.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@linux.intel.com>
Cc: Qiaowei Ren <qiaowei.ren@intel.com>
Cc: "Yu, Fenghua" <fenghua.yu@intel.com>

---

 b/arch/x86/include/asm/processor.h |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff -puN arch/x86/include/asm/processor.h~mpx-give-regsters-real-names arch/x86/include/asm/processor.h
--- a/arch/x86/include/asm/processor.h~mpx-give-regsters-real-names	2014-10-31 14:53:40.237438291 -0700
+++ b/arch/x86/include/asm/processor.h	2014-10-31 14:53:40.243438554 -0700
@@ -374,8 +374,9 @@ struct lwp_struct {
 	u8 reserved[128];
 };
 
-struct bndregs_struct {
-	u64 bndregs[8];
+struct bndreg_struct {
+	u64 lb; /* lower bound */
+	u64 ub; /* upper bound */
 } __packed;
 
 struct bndcsr_struct {
@@ -394,7 +395,7 @@ struct xsave_struct {
 	struct xsave_hdr_struct xsave_hdr;
 	struct ymmh_struct ymmh;
 	struct lwp_struct lwp;
-	struct bndregs_struct bndregs;
+	struct bndreg_struct bndreg[4];
 	struct bndcsr_struct bndcsr;
 	/* new processor state extensions will go here */
 } __attribute__ ((packed, aligned (64)));
_

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [v2] x86 mpx: give bndX registers actual names
  2014-10-31 21:58 [PATCH] [v2] x86 mpx: give bndX registers actual names Dave Hansen
@ 2014-10-31 22:10 ` Thomas Gleixner
  2014-11-18  0:04 ` [tip:x86/mpx] x86: mpx: Give " tip-bot for Dave Hansen
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Gleixner @ 2014-10-31 22:10 UTC (permalink / raw)
  To: Dave Hansen; +Cc: linux-kernel, dave.hansen, x86, hpa, qiaowei.ren, fenghua.yu

On Fri, 31 Oct 2014, Dave Hansen wrote:

> 
> Changes from V1:
>  * name it 'bndreg' instead plain 'bnd'

Peter wanted you to do s/struct bndreg_struct/struct bndreg/

Which makes a lot of sense as there is no point of having the extra
_struct. Except you are part of the 

   bndreg_struct_t *ptrStructBndregStruct_p;

universe :)

Thanks,

	tglx



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:x86/mpx] x86: mpx: Give bndX registers actual names
  2014-10-31 21:58 [PATCH] [v2] x86 mpx: give bndX registers actual names Dave Hansen
  2014-10-31 22:10 ` Thomas Gleixner
@ 2014-11-18  0:04 ` tip-bot for Dave Hansen
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Dave Hansen @ 2014-11-18  0:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, linux-kernel, dave, qiaowei.ren, fenghua.yu, dave.hansen,
	mingo, hpa, tglx

Commit-ID:  c04e051cccd2446d9ca373628d14b7e732462f5d
Gitweb:     http://git.kernel.org/tip/c04e051cccd2446d9ca373628d14b7e732462f5d
Author:     Dave Hansen <dave.hansen@linux.intel.com>
AuthorDate: Fri, 31 Oct 2014 14:58:20 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 18 Nov 2014 00:58:52 +0100

x86: mpx: Give bndX registers actual names

Consider the bndX MPX registers.  There 4 registers each
containing a 64-bit lower and a 64-bit upper bound.  That's 8*64
bits and we declare it thusly:

	struct bndregs_struct {
		u64 bndregs[8];
	}
    
Let's say you want to read the upper bound from the MPX register
bnd2 out of the xsave buf.  You do:

	bndregno = 2;
	upper_bound = xsave_buf->bndregs.bndregs[2*bndregno+1];

That kinda sucks.  Every time you access it, you need to know:
1. Each bndX register is two entries wide in "bndregs"
2. The lower comes first followed by upper.  We do the +1 to get
   upper vs. lower.

This replaces the old definition.  You can now access them
indexed by the register number directly, and with a meaningful
name for the lower and upper bound:

	bndregno = 2;
	xsave_buf->bndreg[bndregno].upper_bound;

It's now *VERY* clear that there are 4 registers.  The programmer
now doesn't have to care what order the lower and upper bounds
are in, and it's harder to get it wrong.

[ tglx: Changed ub/lb to upper_bound/lower_bound and renamed struct
bndreg_struct to struct bndreg ]

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: "H. Peter Anvin" <hpa@linux.intel.com>
Cc: Qiaowei Ren <qiaowei.ren@intel.com>
Cc: "Yu, Fenghua" <fenghua.yu@intel.com>
Cc: Dave Hansen <dave@sr71.net>
Link: http://lkml.kernel.org/r/20141031215820.5EA5E0EC@viggo.jf.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/include/asm/processor.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index eb71ec7..0f2263a 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -374,8 +374,9 @@ struct lwp_struct {
 	u8 reserved[128];
 };
 
-struct bndregs_struct {
-	u64 bndregs[8];
+struct bndreg {
+	u64 lower_bound;
+	u64 upper_bound;
 } __packed;
 
 struct bndcsr_struct {
@@ -394,7 +395,7 @@ struct xsave_struct {
 	struct xsave_hdr_struct xsave_hdr;
 	struct ymmh_struct ymmh;
 	struct lwp_struct lwp;
-	struct bndregs_struct bndregs;
+	struct bndreg bndreg[4];
 	struct bndcsr_struct bndcsr;
 	/* new processor state extensions will go here */
 } __attribute__ ((packed, aligned (64)));

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-18  0:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-31 21:58 [PATCH] [v2] x86 mpx: give bndX registers actual names Dave Hansen
2014-10-31 22:10 ` Thomas Gleixner
2014-11-18  0:04 ` [tip:x86/mpx] x86: mpx: Give " tip-bot for Dave Hansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).