[PATCH 11/12] x86: Use macros for getting/setting descriptors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Joe Damato <ice799@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

[Index of Archives]     [Audio]     [Hams]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Fedora Users]

  Powered by Linux