mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Damato <ice799@gmail.com>
To: linux-x86_64@vger.kernel.org, linux-newbie@vger.kernel.org,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Joe Damato <ice799@gmail.com>
Subject: [PATCH 11/12] x86: Use macros for getting/setting descriptors
Date: Fri, 24 Oct 2008 20:15:31 -0700	[thread overview]
Message-ID: <0df5b7f8e2bee4a3599d6b80ea344b69d4bb4dc6.1224903713.git.ice799@gmail.com> (raw)
In-Reply-To: <63f6f0d8b3da967e88094b6cd4b23f2ba78abbdc.1224903712.git.ice799@gmail.com>
In-Reply-To: <52f8491fb5d55c0171840b01638ea6db0a98f3be.1224903712.git.ice799@gmail.com>

Use macros for getting/setting the hi and lo 32bits of descriptors since 'a' and 'b' were removed.

Signed-off-by: Joe Damato <ice799@gmail.com>
---
 arch/x86/kernel/tls.c                 |    2 +-
 arch/x86/kernel/vmi_32.c              |    3 ++-
 arch/x86/lguest/boot.c                |    2 +-
 arch/x86/math-emu/fpu_system.h        |   19 +++++++++----------
 drivers/lguest/interrupts_and_traps.c |   18 +++++++++---------
 drivers/lguest/segments.c             |   14 +++++++-------
 drivers/pnp/pnpbios/bioscalls.c       |    4 ++--
 include/asm-x86/xen/hypercall.h       |    4 ++--
 8 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
index 6bb7b85..653c995 100644
--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -42,7 +42,7 @@ static void set_tls_desc(struct task_struct *p, int idx,
 
 	while (n-- > 0) {
 		if (LDT_empty(info))
-			desc->a = desc->b = 0;
+			desc_hi(desc) = desc_lo(desc) = 0;
 		else
 			fill_ldt(desc, info);
 		++info;
diff --git a/arch/x86/kernel/vmi_32.c b/arch/x86/kernel/vmi_32.c
index 8c87b9b..939363b 100644
--- a/arch/x86/kernel/vmi_32.c
+++ b/arch/x86/kernel/vmi_32.c
@@ -189,7 +189,8 @@ static void vmi_cpuid(unsigned int *ax, unsigned int *bx,
 
 static inline void vmi_maybe_load_tls(struct desc_struct *gdt, int nr, struct desc_struct *new)
 {
-	if (gdt[nr].a != new->a || gdt[nr].b != new->b)
+	if (desc_hi(gdt[nr]) != desc_hi(*new) ||
+	    desc_lo(gdt[nr]) != desc_lo(*new))
 		write_gdt_entry(gdt, nr, new, 0);
 }
 
diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
index 48ee4f9..a2391d8 100644
--- a/arch/x86/lguest/boot.c
+++ b/arch/x86/lguest/boot.c
@@ -236,7 +236,7 @@ static void lguest_load_idt(const struct desc_ptr *desc)
 	struct desc_struct *idt = (void *)desc->address;
 
 	for (i = 0; i < (desc->size+1)/8; i++)
-		hcall(LHCALL_LOAD_IDT_ENTRY, i, idt[i].a, idt[i].b);
+		hcall(LHCALL_LOAD_IDT_ENTRY, i, desc_lo(idt[i]), desc_hi(idt[i]));
 }
 
 /*
diff --git a/arch/x86/math-emu/fpu_system.h b/arch/x86/math-emu/fpu_system.h
index 13488fa..3fb2237 100644
--- a/arch/x86/math-emu/fpu_system.h
+++ b/arch/x86/math-emu/fpu_system.h
@@ -23,16 +23,15 @@
 /* s is always from a cpu register, and the cpu does bounds checking
  * during register load --> no further bounds checks needed */
 #define LDT_DESCRIPTOR(s)	(((struct desc_struct *)current->mm->context.ldt)[(s) >> 3])
-#define SEG_D_SIZE(x)		((x).b & (3 << 21))
-#define SEG_G_BIT(x)		((x).b & (1 << 23))
-#define SEG_GRANULARITY(x)	(((x).b & (1 << 23)) ? 4096 : 1)
-#define SEG_286_MODE(x)		((x).b & ( 0xff000000 | 0xf0000 | (1 << 23)))
-#define SEG_BASE_ADDR(s)	(((s).b & 0xff000000) \
-				 | (((s).b & 0xff) << 16) | ((s).a >> 16))
-#define SEG_LIMIT(s)		(((s).b & 0xff0000) | ((s).a & 0xffff))
-#define SEG_EXECUTE_ONLY(s)	(((s).b & ((1 << 11) | (1 << 9))) == (1 << 11))
-#define SEG_WRITE_PERM(s)	(((s).b & ((1 << 11) | (1 << 9))) == (1 << 9))
-#define SEG_EXPAND_DOWN(s)	(((s).b & ((1 << 11) | (1 << 10))) \
+#define SEG_D_SIZE(x)		(desc_hi(x) & (3 << 21))
+#define SEG_G_BIT(x)		(desc_hi(x) & (1 << 23))
+#define SEG_GRANULARITY(x)	((desc_hi(x) & (1 << 23)) ? 4096 : 1)
+#define SEG_286_MODE(x)		(desc_hi(x) & ( 0xff000000 | 0xf0000 | (1 << 23)))
+#define SEG_BASE_ADDR(s)	(ldttss_offset(s))
+#define SEG_LIMIT(s)		(ldttss_limit(s))
+#define SEG_EXECUTE_ONLY(s)	((desc_hi(s) & ((1 << 11) | (1 << 9))) == (1 << 11))
+#define SEG_WRITE_PERM(s)	((desc_hi(s) & ((1 << 11) | (1 << 9))) == (1 << 9))
+#define SEG_EXPAND_DOWN(s)	((desc_hi(s) & ((1 << 11) | (1 << 10))) \
 				 == (1 << 10))
 
 #define I387			(current->thread.xstate)
diff --git a/drivers/lguest/interrupts_and_traps.c b/drivers/lguest/interrupts_and_traps.c
index 48aa15b..bfb24d9 100644
--- a/drivers/lguest/interrupts_and_traps.c
+++ b/drivers/lguest/interrupts_and_traps.c
@@ -184,7 +184,7 @@ void maybe_do_interrupt(struct lg_cpu *cpu)
 		/* set_guest_interrupt() takes the interrupt descriptor and a
 		 * flag to say whether this interrupt pushes an error code onto
 		 * the stack as well: virtual interrupts never do. */
-		set_guest_interrupt(cpu, idt->a, idt->b, 0);
+		set_guest_interrupt(cpu, desc_lo(idt), desc_hi(idt), 0);
 	}
 
 	/* Every time we deliver an interrupt, we update the timestamp in the
@@ -256,8 +256,8 @@ int deliver_trap(struct lg_cpu *cpu, unsigned int num)
 	 * bogus one in): if we fail here, the Guest will be killed. */
 	if (!idt_present(cpu->arch.idt[num].a, cpu->arch.idt[num].b))
 		return 0;
-	set_guest_interrupt(cpu, cpu->arch.idt[num].a,
-			    cpu->arch.idt[num].b, has_err(num));
+	set_guest_interrupt(cpu, desc_lo(cpu->arch.idt[num]),
+			    desc_hi(cpu->arch.idt[num]), has_err(num));
 	return 1;
 }
 
@@ -360,7 +360,7 @@ static void set_trap(struct lg_cpu *cpu, gate_desc *trap,
 
 	/* We zero-out a not-present entry */
 	if (!idt_present(lo, hi)) {
-		trap->a = trap->b = 0;
+		desc_hi(trap) = desc_lo(trap) = 0;
 		return;
 	}
 
@@ -372,8 +372,8 @@ static void set_trap(struct lg_cpu *cpu, gate_desc *trap,
 	 * type.  The privilege level controls where the trap can be triggered
 	 * manually with an "int" instruction.  This is usually GUEST_PL,
 	 * except for system calls which userspace can use. */
-	trap->a = ((__KERNEL_CS|GUEST_PL)<<16) | (lo&0x0000FFFF);
-	trap->b = (hi&0xFFFFEF00);
+	desc_lo(trap) = ((__KERNEL_CS|GUEST_PL)<<16) | (lo&0x0000FFFF);
+	desc_hi(trap) = (hi&0xFFFFEF00);
 }
 
 /*H:230 While we're here, dealing with delivering traps and interrupts to the
@@ -419,11 +419,11 @@ static void default_idt_entry(gate_desc *idt,
 	else if (base)
 		/* Copy priv. level from what Guest asked for.  This allows
 		 * debug (int 3) traps from Guest userspace, for example. */
-		flags |= (base->b & 0x6000);
+		flags |= (desc_hi(base) & 0x6000);
 
 	/* Now pack it into the IDT entry in its weird format. */
-	idt->a = (LGUEST_CS<<16) | (handler&0x0000FFFF);
-	idt->b = (handler&0xFFFF0000) | flags;
+	desc_lo(idt) = (LGUEST_CS<<16) | (handler&0x0000FFFF);
+	desc_hi(idt) = (handler&0xFFFF0000) | flags;
 }
 
 /* When the Guest first starts, we put default entries into the IDT. */
diff --git a/drivers/lguest/segments.c b/drivers/lguest/segments.c
index ec6aa3f..8506880 100644
--- a/drivers/lguest/segments.c
+++ b/drivers/lguest/segments.c
@@ -71,14 +71,14 @@ static void fixup_gdt_table(struct lg_cpu *cpu, unsigned start, unsigned end)
 		/* Segment descriptors contain a privilege level: the Guest is
 		 * sometimes careless and leaves this as 0, even though it's
 		 * running at privilege level 1.  If so, we fix it here. */
-		if ((cpu->arch.gdt[i].b & 0x00006000) == 0)
-			cpu->arch.gdt[i].b |= (GUEST_PL << 13);
+		if ((desc_hi(cpu->arch.gdt[i]) & 0x00006000) == 0)
+			desc_hi(cpu->arch.gdt[i]) |= (GUEST_PL << 13);
 
 		/* Each descriptor has an "accessed" bit.  If we don't set it
 		 * now, the CPU will try to set it when the Guest first loads
 		 * that entry into a segment register.  But the GDT isn't
 		 * writable by the Guest, so bad things can happen. */
-		cpu->arch.gdt[i].b |= 0x00000100;
+		desc_hi(cpu->arch.gdt[i]) |= 0x00000100;
 	}
 }
 
@@ -102,8 +102,8 @@ void setup_default_gdt_entries(struct lguest_ro_state *state)
 	 * Forgive the magic flags: the 0x8900 means the entry is Present, it's
 	 * privilege level 0 Available 386 TSS system segment, and the 0x67
 	 * means Saturn is eclipsed by Mercury in the twelfth house. */
-	gdt[GDT_ENTRY_TSS].a = 0x00000067 | (tss << 16);
-	gdt[GDT_ENTRY_TSS].b = 0x00008900 | (tss & 0xFF000000)
+	desc_lo(gdt[GDT_ENTRY_TSS]) = 0x00000067 | (tss << 16);
+	desc_hi(gdt[GDT_ENTRY_TSS]) = 0x00008900 | (tss & 0xFF000000)
 		| ((tss >> 16) & 0x000000FF);
 }
 
@@ -116,8 +116,8 @@ void setup_guest_gdt(struct lg_cpu *cpu)
 	cpu->arch.gdt[GDT_ENTRY_KERNEL_DS] = FULL_SEGMENT;
 	/* ...except the Guest is allowed to use them, so set the privilege
 	 * level appropriately in the flags. */
-	cpu->arch.gdt[GDT_ENTRY_KERNEL_CS].b |= (GUEST_PL << 13);
-	cpu->arch.gdt[GDT_ENTRY_KERNEL_DS].b |= (GUEST_PL << 13);
+	desc_hi(cpu->arch.gdt[GDT_ENTRY_KERNEL_CS]) |= (GUEST_PL << 13);
+	desc_hi(cpu->arch.gdt[GDT_ENTRY_KERNEL_DS]) |= (GUEST_PL << 13);
 }
 
 /*H:650 An optimization of copy_gdt(), for just the three "thead-local storage"
diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
index 7ff8244..2b9bb7c 100644
--- a/drivers/pnp/pnpbios/bioscalls.c
+++ b/drivers/pnp/pnpbios/bioscalls.c
@@ -476,8 +476,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
 	pnp_bios_callpoint.offset = header->fields.pm16offset;
 	pnp_bios_callpoint.segment = PNP_CS16;
 
-	bad_bios_desc.a = 0;
-	bad_bios_desc.b = 0x00409200;
+	desc_lo(bad_bios_desc) = 0;
+	desc_hi(bad_bios_desc) = 0x00409200;
 
 	set_base(bad_bios_desc, __va((unsigned long)0x40 << 4));
 	_set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4));
diff --git a/include/asm-x86/xen/hypercall.h b/include/asm-x86/xen/hypercall.h
index 44f4259..6e36e20 100644
--- a/include/asm-x86/xen/hypercall.h
+++ b/include/asm-x86/xen/hypercall.h
@@ -472,8 +472,8 @@ MULTI_update_descriptor(struct multicall_entry *mcl, u64 maddr,
 	} else {
 		mcl->args[0] = maddr;
 		mcl->args[1] = maddr >> 32;
-		mcl->args[2] = desc.a;
-		mcl->args[3] = desc.b;
+		mcl->args[2] = desc_lo(desc);
+		mcl->args[3] = desc_hi(desc);
 	}
 }
 
-- 
1.5.4.3


  reply	other threads:[~2008-10-25  3:33 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-25  3:15 [PATCH 00/12] x86: Cleanup idt, gdt/ldt/tss structs Joe Damato
2008-10-25  3:15 ` [PATCH 01/12] x86: Cleanup x86 descriptors, remove a/b fields from structs Joe Damato
2008-10-25  3:15   ` [PATCH 02/12] x86: Use new gate_struct for gate_desc Joe Damato
2008-10-25  3:15     ` [PATCH 03/12] x86: Cleanup usage of struct desc_struct Joe Damato
2008-10-25  3:15       ` [PATCH 04/12] x86: Add macros for gate_desc Joe Damato
2008-10-25  3:15         ` [PATCH 05/12] x86: Refactor pack_gate " Joe Damato
2008-10-25  3:15           ` [PATCH 06/12] x86: Refactor pack_descriptor Joe Damato
2008-10-25  3:15             ` [PATCH 07/12] x86: Add a static initializer for IDTs Joe Damato
2008-10-25  3:15               ` [PATCH 08/12] x86: Use static intializer for IDT entries Joe Damato
2008-10-25  3:15                 ` [PATCH 09/12] x86: Add static initiazlier for descriptors Joe Damato
2008-10-25  3:15                   ` [PATCH 10/12] x86: Use static initializers " Joe Damato
2008-10-25  3:15                     ` Joe Damato [this message]
2008-10-25  3:15                       ` [PATCH 12/12] x86: Use struct fields instead of bitmasks Joe Damato
2008-10-29 12:56                         ` Jeremy Fitzhardinge
2008-10-29 12:58                   ` [PATCH 09/12] x86: Add static initiazlier for descriptors Jeremy Fitzhardinge
2008-10-29 12:54         ` [PATCH 04/12] x86: Add macros for gate_desc Jeremy Fitzhardinge
2008-10-29 12:52       ` [PATCH 03/12] x86: Cleanup usage of struct desc_struct Jeremy Fitzhardinge
2008-10-29 12:53     ` [PATCH 02/12] x86: Use new gate_struct for gate_desc Jeremy Fitzhardinge
2008-10-25  5:40 ` [PATCH 00/12] x86: Cleanup idt, gdt/ldt/tss structs Willy Tarreau
2008-10-27 10:57   ` Ingo Molnar
2008-10-25  9:39 ` walter harms
2008-10-27 10:55 ` Ingo Molnar
2008-10-27 14:34   ` H. Peter Anvin
2008-10-27 21:15   ` Joe Damato
2008-10-27 23:02     ` Jeremy Fitzhardinge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0df5b7f8e2bee4a3599d6b80ea344b69d4bb4dc6.1224903713.git.ice799@gmail.com \
    --to=ice799@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-newbie@vger.kernel.org \
    --cc=linux-x86_64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®