Commit a87732f3 authored by Prasanna S. Panchamukhi's avatar Prasanna S. Panchamukhi Committed by Linus Torvalds

[PATCH] x68: consolidate code segment base calculation

Calculating the base address of the segment is tricky and is used in
several places as well.  This patch moves this tricky part in a common
place as suggested by Andi Kleen.
Signed-of-by: default avatarPrasanna S Panchamukhi <prasanna@in.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e0eabf37
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/preempt.h> #include <linux/preempt.h>
#include <asm/kdebug.h> #include <asm/kdebug.h>
#include <asm/desc.h>
/* kprobe_status settings */ /* kprobe_status settings */
#define KPROBE_HIT_ACTIVE 0x00000001 #define KPROBE_HIT_ACTIVE 0x00000001
...@@ -101,10 +102,8 @@ static int kprobe_handler(struct pt_regs *regs) ...@@ -101,10 +102,8 @@ static int kprobe_handler(struct pt_regs *regs)
if ((regs->xcs & 4) && (current->mm)) { if ((regs->xcs & 4) && (current->mm)) {
lp = (unsigned long *) ((unsigned long)((regs->xcs >> 3) * 8) lp = (unsigned long *) ((unsigned long)((regs->xcs >> 3) * 8)
+ (char *) current->mm->context.ldt); + (char *) current->mm->context.ldt);
addr = (kprobe_opcode_t *) ((((*lp) >> 16 & 0x0000ffff) addr = (kprobe_opcode_t *) (get_desc_base(lp) + regs->eip -
| (*(lp +1) & 0xff000000) sizeof(kprobe_opcode_t));
| ((*(lp +1) << 16) & 0x00ff0000))
+ regs->eip - sizeof(kprobe_opcode_t));
} else { } else {
addr = (kprobe_opcode_t *)(regs->eip - sizeof(kprobe_opcode_t)); addr = (kprobe_opcode_t *)(regs->eip - sizeof(kprobe_opcode_t));
} }
......
...@@ -112,9 +112,7 @@ static inline unsigned long get_segment_eip(struct pt_regs *regs, ...@@ -112,9 +112,7 @@ static inline unsigned long get_segment_eip(struct pt_regs *regs,
} }
/* Decode the code segment base from the descriptor */ /* Decode the code segment base from the descriptor */
base = (desc[0] >> 16) | base = get_desc_base((unsigned long *)desc);
((desc[1] & 0xff) << 16) |
(desc[1] & 0xff000000);
if (seg & (1<<2)) { if (seg & (1<<2)) {
up(&current->mm->context.sem); up(&current->mm->context.sem);
......
...@@ -126,6 +126,15 @@ static inline void load_LDT(mm_context_t *pc) ...@@ -126,6 +126,15 @@ static inline void load_LDT(mm_context_t *pc)
put_cpu(); 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 /* !__ASSEMBLY__ */
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment