search for: user_mod

Displaying 20 results from an estimated 92 matches for "user_mod".

Did you mean: user_mode
2006 Jul 05
4
xenoprof passive profiling and "mode" setting
Xiaowei, I''m puzzled by the following bit of code in p4_check_ctrs():        if (guest_kernel_mode(current, regs))                 mode = 1;         else if (ring_0(regs))                 mode = 2; If I look at the definition for guest_kernel_mode() it is: include/asm-x86/x86_64/regs.h: #define guest_kernel_mode(v, r)   \     (ring_3(r) && ((v)->arch.flags &
2006 Jul 06
0
Fwd: RE: xenoprof passive profiling and "mode" setting
...nt" <raybry@mpdtxmail.amd.com> Cc: xen-devel@lists.xensource.com >guest_kernel_mode() does not work for HVM guests. It may need to be >fixed -- it had previously only been used in paravirtual-only contexts. > >It might make sense to invert[*] the predicate and rename to >user_mode(). Then definition is simply ring_3(regs) for x86/32 and >(ring_3(regs) && !((v)->arch.flags & TF_kernel_mode)) for x86/64. > >So maybe: > int mode = 2; > if (guest_mode(regs)) > mode = user_mode(current, regs) ? 0 : 1; Yes, this is a better solution for...
2007 Apr 18
2
[patch 3/8] Allow a kernel to not be in ring 0.
...@xensource.com> We allow for the fact that the guest kernel may not run in ring 0. This requires some abstraction in a few places when setting %cs or checking privilege level (user vs kernel). This is Chris' [RFC PATCH 15/33] move segment checks to subarch, except rather than using #define USER_MODE_MASK which depends on a config option, we use Zach's more flexible approach of assuming ring 3 == userspace. I also used "get_kernel_rpl()" over "get_kernel_cs()" because I think it reads better in the code... 1) Remove the hardcoded 3 and introduce #define SEGMENT_RPL_MA...
2007 Apr 18
2
[patch 3/8] Allow a kernel to not be in ring 0.
...@xensource.com> We allow for the fact that the guest kernel may not run in ring 0. This requires some abstraction in a few places when setting %cs or checking privilege level (user vs kernel). This is Chris' [RFC PATCH 15/33] move segment checks to subarch, except rather than using #define USER_MODE_MASK which depends on a config option, we use Zach's more flexible approach of assuming ring 3 == userspace. I also used "get_kernel_rpl()" over "get_kernel_cs()" because I think it reads better in the code... 1) Remove the hardcoded 3 and introduce #define SEGMENT_RPL_MA...
2020 Apr 28
0
[PATCH v3 40/75] x86/sev-es: Compile early handler code into kernel image
...f, 4); + if (put_user(d4, target)) + goto fault; + break; + case 8: + memcpy(&d8, buf, 8); + if (put_user(d8, target)) + goto fault; + break; + default: + WARN_ONCE(1, "%s: Invalid size: %zu\n", __func__, size); + return ES_UNSUPPORTED; + } + + return ES_OK; + +fault: + if (user_mode(ctxt->regs)) + error_code |= X86_PF_USER; + + ctxt->fi.vector = X86_TRAP_PF; + ctxt->fi.error_code = error_code; + ctxt->fi.cr2 = (unsigned long)dst; + + return ES_EXCEPTION; +} + +static enum es_result vc_read_mem(struct es_em_ctxt *ctxt, + char *src, char *buf, size_t size) +{...
2020 Feb 11
0
[PATCH 39/62] x86/sev-es: Harden runtime #VC handler for exceptions from user-space
...instruction (exit-code 0x%02lx IP: 0x%lx)\n", + exit_code, regs->ip); goto fail; case ES_EXCEPTION: forward_exception(&ctxt); @@ -278,10 +278,24 @@ dotraplinkage void do_vmm_communication(struct pt_regs *regs, unsigned long exit return; fail: - show_regs(regs); + if (user_mode(regs)) { + /* + * Do not kill the machine if user-space triggered the + * exception. Send SIGBUS instead and let user-space deal with + * it. + */ + force_sig_fault(SIGBUS, BUS_OBJERR, (void __user *)0); + } else { + /* Show some debug info */ + show_regs(regs); - while (true) - hal...
2020 Feb 11
0
[PATCH 50/62] x86/sev-es: Handle VMMCALL Events
...dle_mwait(struct ghcb *ghcb, struct es_em_ctxt *ctxt) return ghcb_hv_call(ghcb, ctxt, SVM_EXIT_MWAIT, 0, 0); } +static enum es_result handle_vmmcall(struct ghcb *ghcb, + struct es_em_ctxt *ctxt) +{ + enum es_result ret; + + ghcb_set_rax(ghcb, ctxt->regs->ax); + ghcb_set_cpl(ghcb, user_mode(ctxt->regs) ? 3 : 0); + + ret = ghcb_hv_call(ghcb, ctxt, SVM_EXIT_VMMCALL, 0, 0); + if (ret != ES_OK) + return ret; + + if (!ghcb_is_valid_rax(ghcb)) + return ES_VMM_ERROR; + + ctxt->regs->ax = ghcb->save.rax; + + return ES_OK; +} + static enum es_result handle_vc_exception(struct e...
2020 Feb 11
0
[PATCH 38/62] x86/sev-es: Handle instruction fetches from user-space
..._fetch_insn_byte(struct es_em_ctxt *ctxt, unsigned int offset, char *buffer) { - char *rip = (char *)ctxt->regs->ip; - - /* More checks are needed when we boot to user-space */ - if (!check_kernel(ctxt->regs)) - return ES_UNSUPPORTED; - - buffer[offset] = rip[offset]; + if (user_mode(ctxt->regs)) { + unsigned long addr = ctxt->regs->ip + offset; + char __user *rip = (char __user *)addr; + + if (unlikely(addr >= TASK_SIZE_MAX)) + return ES_UNSUPPORTED; + + if (copy_from_user(buffer + offset, rip, 1)) { + ctxt->fi.vector = X86_TRAP_PF; + ctxt->fi....
2020 Apr 28
0
[PATCH v3 49/75] x86/sev-es: Handle instruction fetches from user-space
...ode_insn(struct es_em_ctxt *ctxt) enum es_result ret; int res; - res = vc_fetch_insn_kernel(ctxt, buffer); - if (unlikely(res == -EFAULT)) { - ctxt->fi.vector = X86_TRAP_PF; - ctxt->fi.error_code = 0; - ctxt->fi.cr2 = ctxt->regs->ip; - return ES_EXCEPTION; + if (!user_mode(ctxt->regs)) { + res = vc_fetch_insn_kernel(ctxt, buffer); + if (unlikely(res == -EFAULT)) { + ctxt->fi.vector = X86_TRAP_PF; + ctxt->fi.error_code = 0; + ctxt->fi.cr2 = ctxt->regs->ip; + return ES_EXCEPTION; + } + + insn_init(&ctxt->insn, buffer, MA...
2020 Jul 14
0
[PATCH v4 63/75] x86/sev-es: Handle #DB Events
...el/sev-es.c index 8f275e5d1ce7..b0f08d9669f1 100644 --- a/arch/x86/kernel/sev-es.c +++ b/arch/x86/kernel/sev-es.c @@ -928,6 +928,14 @@ static enum es_result vc_handle_trap_ac(struct ghcb *ghcb, return ES_EXCEPTION; } +static __always_inline void vc_handle_trap_db(struct pt_regs *regs) +{ + if (user_mode(regs)) + noist_exc_debug(regs); + else + exc_debug(regs); +} + static enum es_result vc_handle_exitcode(struct es_em_ctxt *ctxt, struct ghcb *ghcb, unsigned long exit_code) @@ -1028,6 +1036,16 @@ DEFINE_IDTENTRY_VC_SAFE_STACK(exc_vmm_communication) struct ghcb *ghcb; lockdep...
2020 Aug 24
0
[PATCH v6 64/76] x86/sev-es: Handle #DB Events
...el/sev-es.c index ee0950f01590..e1f3ebbcc122 100644 --- a/arch/x86/kernel/sev-es.c +++ b/arch/x86/kernel/sev-es.c @@ -922,6 +922,14 @@ static enum es_result vc_handle_trap_ac(struct ghcb *ghcb, return ES_EXCEPTION; } +static __always_inline void vc_handle_trap_db(struct pt_regs *regs) +{ + if (user_mode(regs)) + noist_exc_debug(regs); + else + exc_debug(regs); +} + static enum es_result vc_handle_exitcode(struct es_em_ctxt *ctxt, struct ghcb *ghcb, unsigned long exit_code) @@ -1033,6 +1041,15 @@ DEFINE_IDTENTRY_VC_SAFE_STACK(exc_vmm_communication) struct ghcb *ghcb; lockdep...
2007 Jan 05
0
[IA64]: noreturn cannot be used if function may return
...3:31 2007 +1100 @@ -77,7 +77,7 @@ void console_print(char *msg) // called from unaligned.c //////////////////////////////////// -void die_if_kernel(char *str, struct pt_regs *regs, long err) /* __attribute__ ((noreturn)) */ +void die_if_kernel(char *str, struct pt_regs *regs, long err) { if (user_mode(regs)) return; @@ -88,7 +88,7 @@ void die_if_kernel(char *str, struct pt_ domain_crash_synchronous(); } -void vmx_die_if_kernel(char *str, struct pt_regs *regs, long err) /* __attribute__ ((noreturn)) */ +void vmx_die_if_kernel(char *str, struct pt_regs *regs, long err) { if (vmx_user_m...
2020 May 20
1
[PATCH v3 51/75] x86/sev-es: Handle MMIO events
On Tue, Apr 28, 2020 at 05:17:01PM +0200, Joerg Roedel wrote: > From: Tom Lendacky <thomas.lendacky at amd.com> > > Add handler for VC exceptions caused by MMIO intercepts. These > intercepts come along as nested page faults on pages with reserved > bits set. > > Signed-off-by: Tom Lendacky <thomas.lendacky at amd.com> > [ jroedel at suse.de: Adapt to VC
2007 Apr 18
1
[PATCH] Slight cleanups for x86 ring macros (against rc3-mm2)
...user-space with LDT SS restore_nocheck: diff -r d8064f9b5964 include/asm-i386/ptrace.h --- a/include/asm-i386/ptrace.h Mon Aug 07 13:30:17 2006 +1000 +++ b/include/asm-i386/ptrace.h Mon Aug 07 14:32:11 2006 +1000 @@ -74,11 +74,11 @@ extern void send_sigtrap(struct task_str */ static inline int user_mode(struct pt_regs *regs) { - return (regs->xcs & SEGMENT_RPL_MASK) == 3; + return (regs->xcs & SEGMENT_RPL_MASK) == USER_RPL; } static inline int user_mode_vm(struct pt_regs *regs) { - return (((regs->xcs & SEGMENT_RPL_MASK) | (regs->eflags & VM_MASK)) >= 3); + retu...
2007 Apr 18
1
[PATCH] Slight cleanups for x86 ring macros (against rc3-mm2)
...user-space with LDT SS restore_nocheck: diff -r d8064f9b5964 include/asm-i386/ptrace.h --- a/include/asm-i386/ptrace.h Mon Aug 07 13:30:17 2006 +1000 +++ b/include/asm-i386/ptrace.h Mon Aug 07 14:32:11 2006 +1000 @@ -74,11 +74,11 @@ extern void send_sigtrap(struct task_str */ static inline int user_mode(struct pt_regs *regs) { - return (regs->xcs & SEGMENT_RPL_MASK) == 3; + return (regs->xcs & SEGMENT_RPL_MASK) == USER_RPL; } static inline int user_mode_vm(struct pt_regs *regs) { - return (((regs->xcs & SEGMENT_RPL_MASK) | (regs->eflags & VM_MASK)) >= 3); + retu...
2007 Apr 18
2
[PATCH 19/21] i386 Kprobes semaphore fix
...u lock_kprobes(); p = get_kprobe(addr); if (!p) { + unsigned char instr; unlock_kprobes(); if (regs->eflags & VM_MASK) { /* We are in virtual-8086 mode. Return 0 */ goto no_kprobe; } - if (*addr != BREAKPOINT_INSTRUCTION) { + instr = BREAKPOINT_INSTRUCTION; + if (user_mode(regs)) + __get_user(instr, (unsigned char __user *) addr); + else + instr = *addr; + + if (instr != BREAKPOINT_INSTRUCTION) { /* * The breakpoint instruction was removed right * after we hit it. Another cpu has removed Index: linux-2.6.14-zach-work/arch/i386/kernel/ptrace.c...
2007 Apr 18
2
[PATCH 19/21] i386 Kprobes semaphore fix
...u lock_kprobes(); p = get_kprobe(addr); if (!p) { + unsigned char instr; unlock_kprobes(); if (regs->eflags & VM_MASK) { /* We are in virtual-8086 mode. Return 0 */ goto no_kprobe; } - if (*addr != BREAKPOINT_INSTRUCTION) { + instr = BREAKPOINT_INSTRUCTION; + if (user_mode(regs)) + __get_user(instr, (unsigned char __user *) addr); + else + instr = *addr; + + if (instr != BREAKPOINT_INSTRUCTION) { /* * The breakpoint instruction was removed right * after we hit it. Another cpu has removed Index: linux-2.6.14-zach-work/arch/i386/kernel/ptrace.c...
2011 Jul 27
9
[PATCH 0/5] Collected vdso/vsyscall fixes for 3.1
This fixes various problems that cropped up with the vdso patches. - Patch 1 fixes an information leak to userspace. - Patches 2 and 3 fix the kernel build on gold. - Patches 4 and 5 fix Xen (I hope). Konrad, could you could test these on Xen and run 'test_vsyscall test' [1]? I don't have a usable Xen setup. Also, I'd appreciate a review of patches 4 and 5 from some
2011 Jul 27
9
[PATCH 0/5] Collected vdso/vsyscall fixes for 3.1
This fixes various problems that cropped up with the vdso patches. - Patch 1 fixes an information leak to userspace. - Patches 2 and 3 fix the kernel build on gold. - Patches 4 and 5 fix Xen (I hope). Konrad, could you could test these on Xen and run 'test_vsyscall test' [1]? I don't have a usable Xen setup. Also, I'd appreciate a review of patches 4 and 5 from some
2011 Jul 27
9
[PATCH 0/5] Collected vdso/vsyscall fixes for 3.1
This fixes various problems that cropped up with the vdso patches. - Patch 1 fixes an information leak to userspace. - Patches 2 and 3 fix the kernel build on gold. - Patches 4 and 5 fix Xen (I hope). Konrad, could you could test these on Xen and run 'test_vsyscall test' [1]? I don't have a usable Xen setup. Also, I'd appreciate a review of patches 4 and 5 from some