From: zach@vmware.com
To: akpm@osdl.org, chrisl@vmware.com, chrisw@osdl.org, hpa@zytor.com,
Keir.Fraser@cl.cam.ac.uk, linux-kernel@vger.kernel.org,
m+Ian.Pratt@cl.cam.ac.uk, mbligh@mbligh.org, pratap@vmware.com,
virtualization@lists.osdl.org, zach@vmware.com,
zwane@arm.linux.org.uk
Subject: [PATCH 7/14] i386 / Add some descriptor convenience functions
Date: Wed, 10 Aug 2005 21:56:20 -0700 [thread overview]
Message-ID: <200508110456.j7B4uKNb019579@zach-dev.vmware.com> (raw)
Add some convenient descriptor access functions and move them all into desc.h
Patch-base: 2.6.13-rc5-mm1
Patch-keys: i386 desc cleanup
Signed-off-by: Zachary Amsden <zach@vmware.com>
Index: linux-2.6.13/include/asm-i386/desc.h
===================================================================
--- linux-2.6.13.orig/include/asm-i386/desc.h 2005-08-09 19:43:38.000000000 -0700
+++ linux-2.6.13/include/asm-i386/desc.h 2005-08-10 20:42:03.000000000 -0700
@@ -14,6 +14,28 @@
#include <asm/mmu.h>
+#define desc_empty(desc) \
+ (!((desc)->a + (desc)->b))
+
+#define desc_equal(desc1, desc2) \
+ (((desc1)->a == (desc2)->a) && ((desc1)->b == (desc2)->b))
+
+static inline unsigned long get_desc_base(struct desc_struct *desc)
+{
+ unsigned long base;
+ base = ((desc->a >> 16) & 0x0000ffff) |
+ ((desc->b << 16) & 0x00ff0000) |
+ (desc->b & 0xff000000);
+ return base;
+}
+
+static inline unsigned long get_desc_limit(struct desc_struct *desc)
+{
+ unsigned long limit;
+ limit = (desc->a & 0x0ffff) | (desc->b & 0xf0000);
+ return limit;
+}
+
extern struct desc_struct cpu_gdt_table[GDT_ENTRIES];
DECLARE_PER_CPU(struct desc_struct, cpu_gdt_table[GDT_ENTRIES]);
@@ -111,15 +133,5 @@
put_cpu();
}
-static inline unsigned long get_desc_base(unsigned long *desc)
-{
- unsigned long base;
- base = ((desc[0] >> 16) & 0x0000ffff) |
- ((desc[1] << 16) & 0x00ff0000) |
- (desc[1] & 0xff000000);
- return base;
-}
-
#endif /* !__ASSEMBLY__ */
-
#endif
Index: linux-2.6.13/include/asm-i386/processor.h
===================================================================
--- linux-2.6.13.orig/include/asm-i386/processor.h 2005-08-09 19:43:38.000000000 -0700
+++ linux-2.6.13/include/asm-i386/processor.h 2005-08-09 19:43:59.000000000 -0700
@@ -28,11 +28,6 @@
unsigned long a,b;
};
-#define desc_empty(desc) \
- (!((desc)->a + (desc)->b))
-
-#define desc_equal(desc1, desc2) \
- (((desc1)->a == (desc2)->a) && ((desc1)->b == (desc2)->b))
/*
* Default implementation of macro that returns current
* instruction pointer ("program counter").
Index: linux-2.6.13/arch/i386/mm/fault.c
===================================================================
--- linux-2.6.13.orig/arch/i386/mm/fault.c 2005-08-09 19:43:47.000000000 -0700
+++ linux-2.6.13/arch/i386/mm/fault.c 2005-08-10 20:42:04.000000000 -0700
@@ -75,7 +75,8 @@
{
unsigned long eip = regs->eip;
unsigned seg = regs->xcs & 0xffff;
- u32 seg_ar, seg_limit, base, *desc;
+ u32 seg_ar, seg_limit, base;
+ struct desc_struct *desc;
/* The standard kernel/user address space limit. */
*eip_limit = (seg & 3) ? USER_DS.seg : KERNEL_DS.seg;
@@ -108,12 +109,12 @@
desc = (void *)desc + (seg & ~7);
} else {
/* Must disable preemption while reading the GDT. */
- desc = (u32 *)&per_cpu(cpu_gdt_table, get_cpu());
+ desc = per_cpu(cpu_gdt_table, get_cpu());
desc = (void *)desc + (seg & ~7);
}
/* Decode the code segment base from the descriptor */
- base = get_desc_base((unsigned long *)desc);
+ base = get_desc_base(desc);
if (segment_from_ldt(seg)) {
up(¤t->mm->context.sem);
Index: linux-2.6.13/arch/i386/kernel/kprobes.c
===================================================================
--- linux-2.6.13.orig/arch/i386/kernel/kprobes.c 2005-08-09 19:43:47.000000000 -0700
+++ linux-2.6.13/arch/i386/kernel/kprobes.c 2005-08-09 19:54:16.000000000 -0700
@@ -156,7 +156,6 @@
struct kprobe *p;
int ret = 0;
kprobe_opcode_t *addr = NULL;
- unsigned long *lp;
/* We're in an interrupt, but this is clear and BUG()-safe. */
preempt_disable();
@@ -164,9 +163,10 @@
* calculate the address by reading the base address from the LDT entry.
*/
if (segment_from_ldt(regs->xcs) && (current->mm)) {
- lp = (unsigned long *) ((unsigned long)(segment_index(regs->xcs) * 8)
- + (char *) current->mm->context.ldt);
- addr = (kprobe_opcode_t *) (get_desc_base(lp) + regs->eip -
+ struct desc_struct *desc;
+ desc = (struct desc_struct *) ((char *) current->mm->context.ldt +
+ (segment_index(regs->xcs) * 8));
+ addr = (kprobe_opcode_t *) (get_desc_base(desc) + regs->eip -
sizeof(kprobe_opcode_t));
} else {
addr = (kprobe_opcode_t *)(regs->eip - sizeof(kprobe_opcode_t));
next reply other threads:[~2005-08-11 4:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-11 4:56 zach [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-08-16 17:03 [PATCH 7/14] i386 / Add some descriptor convenience functions Chuck Ebbert
2005-08-16 18:06 ` Zachary Amsden
2005-08-16 18:14 ` Andi Kleen
2005-08-16 18:56 ` Chris Wright
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=200508110456.j7B4uKNb019579@zach-dev.vmware.com \
--to=zach@vmware.com \
--cc=Keir.Fraser@cl.cam.ac.uk \
--cc=akpm@osdl.org \
--cc=chrisl@vmware.com \
--cc=chrisw@osdl.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=m+Ian.Pratt@cl.cam.ac.uk \
--cc=mbligh@mbligh.org \
--cc=pratap@vmware.com \
--cc=virtualization@lists.osdl.org \
--cc=zwane@arm.linux.org.uk \
/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