Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 262870
b: refs/heads/master
c: 318f5a2
h: refs/heads/master
v: v3
  • Loading branch information
Andy Lutomirski authored and H. Peter Anvin committed Aug 4, 2011
1 parent 88e2c8f commit 68c801f
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5d5791af4c0d4fd32093882357506355c3357503
refs/heads/master: 318f5a2a672152328c9fb4dead504b89ec738a43
4 changes: 2 additions & 2 deletions trunk/arch/x86/include/asm/desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in

desc->base2 = (info->base_addr & 0xff000000) >> 24;
/*
* Don't allow setting of the lm bit. It is useless anyway
* because 64bit system calls require __USER_CS:
* Don't allow setting of the lm bit. It would confuse
* user_64bit_mode and would get overridden by sysret anyway.
*/
desc->l = 0;
}
Expand Down
6 changes: 6 additions & 0 deletions trunk/arch/x86/include/asm/paravirt_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#include <asm/desc_defs.h>
#include <asm/kmap_types.h>
#include <asm/pgtable_types.h>

struct page;
struct thread_struct;
Expand All @@ -63,6 +64,11 @@ struct paravirt_callee_save {
struct pv_info {
unsigned int kernel_rpl;
int shared_kernel_pmd;

#ifdef CONFIG_X86_64
u16 extra_user_64bit_cs; /* __USER_CS if none */
#endif

int paravirt_enabled;
const char *name;
};
Expand Down
19 changes: 19 additions & 0 deletions trunk/arch/x86/include/asm/ptrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ struct pt_regs {
#ifdef __KERNEL__

#include <linux/init.h>
#ifdef CONFIG_PARAVIRT
#include <asm/paravirt_types.h>
#endif

struct cpuinfo_x86;
struct task_struct;
Expand Down Expand Up @@ -187,6 +190,22 @@ static inline int v8086_mode(struct pt_regs *regs)
#endif
}

#ifdef CONFIG_X86_64
static inline bool user_64bit_mode(struct pt_regs *regs)
{
#ifndef CONFIG_PARAVIRT
/*
* On non-paravirt systems, this is the only long mode CPL 3
* selector. We do not allow long mode selectors in the LDT.
*/
return regs->cs == __USER_CS;
#else
/* Headers are too twisted for this to go in paravirt.h. */
return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
#endif
}
#endif

/*
* X86_32 CPUs don't save ss and esp if the CPU is already in kernel mode
* when it traps. The previous stack will be directly underneath the saved
Expand Down
4 changes: 4 additions & 0 deletions trunk/arch/x86/kernel/paravirt.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ struct pv_info pv_info = {
.paravirt_enabled = 0,
.kernel_rpl = 0,
.shared_kernel_pmd = 1, /* Only used when CONFIG_X86_PAE is set */

#ifdef CONFIG_X86_64
.extra_user_64bit_cs = __USER_CS,
#endif
};

struct pv_init_ops pv_init_ops = {
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/kernel/step.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)

#ifdef CONFIG_X86_64
case 0x40 ... 0x4f:
if (regs->cs != __USER_CS)
if (!user_64bit_mode(regs))
/* 32-bit mode: register increment */
return 0;
/* 64-bit mode: REX prefix */
Expand Down
6 changes: 1 addition & 5 deletions trunk/arch/x86/kernel/vsyscall_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,7 @@ void dotraplinkage do_emulate_vsyscall(struct pt_regs *regs, long error_code)

local_irq_enable();

/*
* Real 64-bit user mode code has cs == __USER_CS. Anything else
* is bogus.
*/
if (regs->cs != __USER_CS) {
if (!user_64bit_mode(regs)) {
/*
* If we trapped from kernel mode, we might as well OOPS now
* instead of returning to some random address and OOPSing
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
* but for now it's good enough to assume that long
* mode only uses well known segments or kernel.
*/
return (!user_mode(regs)) || (regs->cs == __USER_CS);
return (!user_mode(regs) || user_64bit_mode(regs));
#endif
case 0x60:
/* 0x64 thru 0x67 are valid prefixes in all modes. */
Expand Down
4 changes: 4 additions & 0 deletions trunk/arch/x86/xen/enlighten.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,10 @@ static const struct pv_info xen_info __initconst = {
.paravirt_enabled = 1,
.shared_kernel_pmd = 0,

#ifdef CONFIG_X86_64
.extra_user_64bit_cs = FLAT_USER_CS64,
#endif

.name = "Xen",
};

Expand Down

0 comments on commit 68c801f

Please sign in to comment.