2017-08-25 11:01:24

by Thomas Gleixner

[permalink] [raw]
Subject: [patch 20/41] x86: Replace access to desc_struct:a/b fields

The union inside of desc_struct which allows access to the raw u32 parts of
the descriptors. This raw access part is about to go away.

Replace the few code parts which access those fields.

Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Boris Ostrovsky <[email protected]>
Cc: Juergen Gross <[email protected]>
---
arch/x86/include/asm/xen/hypercall.h | 6 ++++--
arch/x86/kernel/tls.c | 2 +-
arch/x86/xen/enlighten_pv.c | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)

Index: b/arch/x86/include/asm/xen/hypercall.h
===================================================================
--- a/arch/x86/include/asm/xen/hypercall.h
+++ b/arch/x86/include/asm/xen/hypercall.h
@@ -552,6 +552,8 @@ static inline void
MULTI_update_descriptor(struct multicall_entry *mcl, u64 maddr,
struct desc_struct desc)
{
+ u32 *p = (u32 *) &desc;
+
mcl->op = __HYPERVISOR_update_descriptor;
if (sizeof(maddr) == sizeof(long)) {
mcl->args[0] = maddr;
@@ -559,8 +561,8 @@ MULTI_update_descriptor(struct multicall
} else {
mcl->args[0] = maddr;
mcl->args[1] = maddr >> 32;
- mcl->args[2] = desc.a;
- mcl->args[3] = desc.b;
+ mcl->args[2] = *p++;
+ mcl->args[3] = *p;
}

trace_xen_mc_entry(mcl, sizeof(maddr) == sizeof(long) ? 2 : 4);
Index: b/arch/x86/kernel/tls.c
===================================================================
--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -93,7 +93,7 @@ static void set_tls_desc(struct task_str

while (n-- > 0) {
if (LDT_empty(info) || LDT_zero(info)) {
- desc->a = desc->b = 0;
+ memset(desc, 0, sizeof(*desc));
} else {
fill_ldt(desc, info);

Index: b/arch/x86/xen/enlighten_pv.c
===================================================================
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -494,7 +494,7 @@ static void __init xen_load_gdt_boot(con
static inline bool desc_equal(const struct desc_struct *d1,
const struct desc_struct *d2)
{
- return d1->a == d2->a && d1->b == d2->b;
+ return memcmp(d1, d2, sizeof(*d1));
}

static void load_TLS_descriptor(struct thread_struct *t,



2017-08-25 11:14:16

by Jürgen Groß

[permalink] [raw]
Subject: Re: [patch 20/41] x86: Replace access to desc_struct:a/b fields

On 25/08/17 12:31, Thomas Gleixner wrote:
> The union inside of desc_struct which allows access to the raw u32 parts of
> the descriptors. This raw access part is about to go away.
>
> Replace the few code parts which access those fields.
>
> Signed-off-by: Thomas Gleixner <[email protected]>
> Cc: Boris Ostrovsky <[email protected]>
> Cc: Juergen Gross <[email protected]>

Reviewed-by: Juergen Gross <[email protected]>


Juergen

2017-08-25 13:57:23

by Boris Ostrovsky

[permalink] [raw]
Subject: Re: [patch 20/41] x86: Replace access to desc_struct:a/b fields


>
> Index: b/arch/x86/xen/enlighten_pv.c
> ===================================================================
> --- a/arch/x86/xen/enlighten_pv.c
> +++ b/arch/x86/xen/enlighten_pv.c
> @@ -494,7 +494,7 @@ static void __init xen_load_gdt_boot(con
> static inline bool desc_equal(const struct desc_struct *d1,
> const struct desc_struct *d2)
> {
> - return d1->a == d2->a && d1->b == d2->b;
> + return memcmp(d1, d2, sizeof(*d1));
> }

Shouldn't this be !memcmp() ?

-boris

2017-08-25 14:02:11

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [patch 20/41] x86: Replace access to desc_struct:a/b fields

On Fri, 25 Aug 2017, Boris Ostrovsky wrote:

>
> >
> > Index: b/arch/x86/xen/enlighten_pv.c
> > ===================================================================
> > --- a/arch/x86/xen/enlighten_pv.c
> > +++ b/arch/x86/xen/enlighten_pv.c
> > @@ -494,7 +494,7 @@ static void __init xen_load_gdt_boot(con
> > static inline bool desc_equal(const struct desc_struct *d1,
> > const struct desc_struct *d2)
> > {
> > - return d1->a == d2->a && d1->b == d2->b;
> > + return memcmp(d1, d2, sizeof(*d1));
> > }
>
> Shouldn't this be !memcmp() ?

Bah yes.

2017-08-25 14:16:21

by Steven Rostedt

[permalink] [raw]
Subject: Re: [patch 20/41] x86: Replace access to desc_struct:a/b fields

On Fri, 25 Aug 2017 16:02:02 +0200 (CEST)
Thomas Gleixner <[email protected]> wrote:

> On Fri, 25 Aug 2017, Boris Ostrovsky wrote:
>
> >
> > >
> > > Index: b/arch/x86/xen/enlighten_pv.c
> > > ===================================================================
> > > --- a/arch/x86/xen/enlighten_pv.c
> > > +++ b/arch/x86/xen/enlighten_pv.c
> > > @@ -494,7 +494,7 @@ static void __init xen_load_gdt_boot(con
> > > static inline bool desc_equal(const struct desc_struct *d1,
> > > const struct desc_struct *d2)
> > > {
> > > - return d1->a == d2->a && d1->b == d2->b;
> > > + return memcmp(d1, d2, sizeof(*d1));
> > > }
> >
> > Shouldn't this be !memcmp() ?
>
> Bah yes.

This is why I'm one of those that like to add the "== 0" to it. Because
I always get this wrong :-p

-- Steve