virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Andrew Morton <akpm@osdl.org>
Cc: lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>,
	virtualization <virtualization@lists.osdl.org>
Subject: [PATCH 3/4] Prep for paravirt: desc.h clearer parameter names, some code motion
Date: Fri, 27 Oct 2006 13:45:27 +1000	[thread overview]
Message-ID: <1161920728.17807.39.camel@localhost.localdomain> (raw)
In-Reply-To: <1161920622.17807.36.camel@localhost.localdomain>

Jeremy Fitzhardinge's patch to clarify arg names in asm/desc.h

"a" and "b" are better named "low" and "high"; Rusty mixed them up
once with amusing results.  Also change __u32 to u32 while there (this
must be kernel-only code, given the DECLARE_PER_CPU in the file
above).

Also moves set_ldt up higher in header, in preparation for paravirt.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

===================================================================
--- a/include/asm-i386/desc.h
+++ b/include/asm-i386/desc.h
@@ -32,19 +32,19 @@ extern struct desc_struct idt_table[];
 extern struct desc_struct idt_table[];
 extern void set_intr_gate(unsigned int irq, void * addr);
 
-static inline void pack_descriptor(__u32 *a, __u32 *b,
+static inline void pack_descriptor(u32 *low, u32 *high,
 	unsigned long base, unsigned long limit, unsigned char type, unsigned char flags)
 {
-	*a = ((base & 0xffff) << 16) | (limit & 0xffff);
-	*b = (base & 0xff000000) | ((base & 0xff0000) >> 16) |
+	*low = ((base & 0xffff) << 16) | (limit & 0xffff);
+	*high = (base & 0xff000000) | ((base & 0xff0000) >> 16) |
 		(limit & 0x000f0000) | ((type & 0xff) << 8) | ((flags & 0xf) << 20);
 }
 
-static inline void pack_gate(__u32 *a, __u32 *b,
+static inline void pack_gate(u32 *low, u32 *high,
 	unsigned long base, unsigned short seg, unsigned char type, unsigned char flags)
 {
-	*a = (seg << 16) | (base & 0xffff);
-	*b = (base & 0xffff0000) | ((type & 0xff) << 8) | (flags & 0xff);
+	*low = (seg << 16) | (base & 0xffff);
+	*high = (base & 0xffff0000) | ((type & 0xff) << 8) | (flags & 0xff);
 }
 
 #define DESCTYPE_LDT 	0x82	/* present, system, DPL-0, LDT */
@@ -78,47 +78,47 @@ static inline void load_TLS(struct threa
 #undef C
 }
 
-static inline void write_dt_entry(void *dt, int entry, __u32 entry_a, __u32 entry_b)
-{
-	__u32 *lp = (__u32 *)((char *)dt + entry*8);
-	*lp = entry_a;
-	*(lp+1) = entry_b;
-}
-
-#define write_ldt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
-#define write_gdt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
-#define write_idt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
-
-static inline void _set_gate(int gate, unsigned int type, void *addr, unsigned short seg)
-{
-	__u32 a, b;
-	pack_gate(&a, &b, (unsigned long)addr, seg, type, 0);
-	write_idt_entry(idt_table, gate, a, b);
-}
-
-static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const void *addr)
-{
-	__u32 a, b;
-	pack_descriptor(&a, &b, (unsigned long)addr,
-			offsetof(struct tss_struct, __cacheline_filler) - 1,
-			DESCTYPE_TSS, 0);
-	write_gdt_entry(get_cpu_gdt_table(cpu), entry, a, b);
-}
-
 static inline void set_ldt(void *addr, unsigned int entries)
 {
 	if (likely(entries == 0))
 		__asm__ __volatile__("lldt %w0"::"q" (0));
 	else {
 		unsigned cpu = smp_processor_id();
-		__u32 a, b;
-
-		pack_descriptor(&a, &b, (unsigned long)addr,
+		u32 low, high;
+
+		pack_descriptor(&low, &high, (unsigned long)addr,
 				entries * sizeof(struct desc_struct) - 1,
 				DESCTYPE_LDT, 0);
-		write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, a, b);
+		write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, low, high);
 		__asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8));
 	}
+}
+
+#define write_ldt_entry(dt, entry, low, high) write_dt_entry(dt,entry,low,high)
+#define write_gdt_entry(dt, entry, low, high) write_dt_entry(dt,entry,low,high)
+#define write_idt_entry(dt, entry, low, high) write_dt_entry(dt,entry,low,high)
+
+static inline void write_dt_entry(void *dt, int entry, u32 entry_low, u32 entry_high)
+{
+	u32 *lp = (u32 *)((char *)dt + entry*8);
+	lp[0] = entry_low;
+	lp[1] = entry_high;
+}
+
+static inline void _set_gate(int gate, unsigned int type, void *addr, unsigned short seg)
+{
+	u32 low, high;
+	pack_gate(&low, &high, (unsigned long)addr, seg, type, 0);
+	write_idt_entry(idt_table, gate, low, high);
+}
+
+static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const void *addr)
+{
+	u32 low, high;
+	pack_descriptor(&low, &high, (unsigned long)addr,
+			offsetof(struct tss_struct, __cacheline_filler) - 1,
+			DESCTYPE_TSS, 0);
+	write_gdt_entry(get_cpu_gdt_table(cpu), entry, low, high);
 }
 
 #define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)

  reply	other threads:[~2006-10-27  3:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-27  3:38 [PATCH 1/4] Prep for paravirt: move pagetable includes Rusty Russell
2006-10-27  3:42 ` [PATCH 1/4] Prep for paravirt: Be careful about touching BIOS address space Rusty Russell
2006-10-27  3:43   ` [PATCH 2/4] Prep for paravirt: cpu_detect extraction Rusty Russell
2006-10-27  3:45     ` Rusty Russell [this message]
2006-10-27  3:46       ` [PATCH 4/4] Prep for paravirt: rearrange processor.h Rusty Russell
2006-10-29 20:01       ` [PATCH] Re: [PATCH 3/4] Prep for paravirt: desc.h clearer parameter names, some code motion Don Mullis
2006-10-29 21:06         ` Andi Kleen
2006-10-29 21:44           ` Don Mullis
2006-10-30  0:05             ` Rusty Russell
2006-10-27 11:30   ` [PATCH 1/4] Prep for paravirt: Be careful about touching BIOS address space Pavel Machek
2006-10-27 21:31     ` Jeremy Fitzhardinge
2006-10-27 21:41       ` Andrew Morton
2006-10-28  4:33         ` Jeremy Fitzhardinge
2006-10-28  4:50           ` Andrew Morton
2006-10-30  2:35             ` Rusty Russell
2006-10-29 20:01   ` Don Mullis
2006-10-27 10:30 ` [PATCH 1/4] Prep for paravirt: move pagetable includes Zachary Amsden

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=1161920728.17807.39.camel@localhost.localdomain \
    --to=rusty@rustcorp.com.au \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=virtualization@lists.osdl.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;
as well as URLs for NNTP newsgroup(s).