1. 12 7月, 2018 5 次提交
    • M
      arm64: implement syscall wrappers · 4378a7d4
      Mark Rutland 提交于
      To minimize the risk of userspace-controlled values being used under
      speculation, this patch adds pt_regs based syscall wrappers for arm64,
      which pass the minimum set of required userspace values to syscall
      implementations. For each syscall, a wrapper which takes a pt_regs
      argument is automatically generated, and this extracts the arguments
      before calling the "real" syscall implementation.
      
      Each syscall has three functions generated:
      
      * __do_<compat_>sys_<name> is the "real" syscall implementation, with
        the expected prototype.
      
      * __se_<compat_>sys_<name> is the sign-extension/narrowing wrapper,
        inherited from common code. This takes a series of long parameters,
        casting each to the requisite types required by the "real" syscall
        implementation in __do_<compat_>sys_<name>.
      
        This wrapper *may* not be necessary on arm64 given the AAPCS rules on
        unused register bits, but it seemed safer to keep the wrapper for now.
      
      * __arm64_<compat_>_sys_<name> takes a struct pt_regs pointer, and
        extracts *only* the relevant register values, passing these on to the
        __se_<compat_>sys_<name> wrapper.
      
      The syscall invocation code is updated to handle the calling convention
      required by __arm64_<compat_>_sys_<name>, and passes a single struct
      pt_regs pointer.
      
      The compiler can fold the syscall implementation and its wrappers, such
      that the overhead of this approach is minimized.
      
      Note that we play games with sys_ni_syscall(). It can't be defined with
      SYSCALL_DEFINE0() because we must avoid the possibility of error
      injection. Additionally, there are a couple of locations where we need
      to call it from C code, and we don't (currently) have a
      ksys_ni_syscall().  While it has no wrapper, passing in a redundant
      pt_regs pointer is benign per the AAPCS.
      
      When ARCH_HAS_SYSCALL_WRAPPER is selected, no prototype is defines for
      sys_ni_syscall(). Since we need to treat it differently for in-kernel
      calls and the syscall tables, the prototype is defined as-required.
      
      The wrappers are largely the same as their x86 counterparts, but
      simplified as we don't have a variety of compat calling conventions that
      require separate stubs. Unlike x86, we have some zero-argument compat
      syscalls, and must define COMPAT_SYSCALL_DEFINE0() to ensure that these
      are also given an __arm64_compat_sys_ prefix.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Reviewed-by: NDominik Brodowski <linux@dominikbrodowski.net>
      Reviewed-by: NCatalin Marinas <catalin.marinas@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      4378a7d4
    • M
      arm64: convert compat wrappers to C · 55f84926
      Mark Rutland 提交于
      In preparation for converting to pt_regs syscall wrappers, convert our
      existing compat wrappers to C. This will allow the pt_regs wrappers to
      be automatically generated, and will allow for the compat register
      manipulation to be folded in with the pt_regs accesses.
      
      To avoid confusion with the upcoming pt_regs wrappers and existing
      compat wrappers provided by core code, the C wrappers are renamed to
      compat_sys_aarch32_<syscall>.
      
      With the assembly wrappers gone, we can get rid of entry32.S and the
      associated boilerplate.
      
      Note that these must call the ksys_* syscall entry points, as the usual
      sys_* entry points will be modified to take a single pt_regs pointer
      argument.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Acked-by: NCatalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      55f84926
    • M
      arm64: drop alignment from syscall tables · 80d63bc3
      Mark Rutland 提交于
      Our syscall tables are aligned to 4096 bytes, which allowed their
      addresses to be generated with a single adrp in entry.S. This has the
      unfortunate property of wasting space in .rodata for the necessary
      padding.
      
      Now that the address is generated by C code, we can rely on the compiler
      to do the right thing, and drop the alignemnt.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      80d63bc3
    • M
      arm64: introduce syscall_fn_t · 27d83e68
      Mark Rutland 提交于
      In preparation for invoking arbitrary syscalls from C code, let's define
      a type for an arbitrary syscall, matching the parameter passing rules of
      the AAPCS.
      
      There should be no functional change as a result of this patch.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      27d83e68
    • M
      arm64: remove sigreturn wrappers · 3085e164
      Mark Rutland 提交于
      The arm64 sigreturn* syscall handlers are non-standard. Rather than
      taking a number of user parameters in registers as per the AAPCS,
      they expect the pt_regs as their sole argument.
      
      To make this work, we override the syscall definitions to invoke
      wrappers written in assembly, which mov the SP into x0, and branch to
      their respective C functions.
      
      On other architectures (such as x86), the sigreturn* functions take no
      argument and instead use current_pt_regs() to acquire the user
      registers. This requires less boilerplate code, and allows for other
      features such as interposing C code in this path.
      
      This patch takes the same approach for arm64.
      Signed-off-by: NMark Rutland <mark.rutland@arm.com>
      Tentatively-reviewed-by: NDave Martin <dave.martin@arm.com>
      Reviewed-by: NCatalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Signed-off-by: NWill Deacon <will.deacon@arm.com>
      3085e164
  2. 19 3月, 2015 1 次提交
  3. 27 1月, 2015 1 次提交