1. 14 6月, 2018 1 次提交
    • L
      Kbuild: rename CC_STACKPROTECTOR[_STRONG] config variables · 050e9baa
      Linus Torvalds 提交于
      The changes to automatically test for working stack protector compiler
      support in the Kconfig files removed the special STACKPROTECTOR_AUTO
      option that picked the strongest stack protector that the compiler
      supported.
      
      That was all a nice cleanup - it makes no sense to have the AUTO case
      now that the Kconfig phase can just determine the compiler support
      directly.
      
      HOWEVER.
      
      It also meant that doing "make oldconfig" would now _disable_ the strong
      stackprotector if you had AUTO enabled, because in a legacy config file,
      the sane stack protector configuration would look like
      
        CONFIG_HAVE_CC_STACKPROTECTOR=y
        # CONFIG_CC_STACKPROTECTOR_NONE is not set
        # CONFIG_CC_STACKPROTECTOR_REGULAR is not set
        # CONFIG_CC_STACKPROTECTOR_STRONG is not set
        CONFIG_CC_STACKPROTECTOR_AUTO=y
      
      and when you ran this through "make oldconfig" with the Kbuild changes,
      it would ask you about the regular CONFIG_CC_STACKPROTECTOR (that had
      been renamed from CONFIG_CC_STACKPROTECTOR_REGULAR to just
      CONFIG_CC_STACKPROTECTOR), but it would think that the STRONG version
      used to be disabled (because it was really enabled by AUTO), and would
      disable it in the new config, resulting in:
      
        CONFIG_HAVE_CC_STACKPROTECTOR=y
        CONFIG_CC_HAS_STACKPROTECTOR_NONE=y
        CONFIG_CC_STACKPROTECTOR=y
        # CONFIG_CC_STACKPROTECTOR_STRONG is not set
        CONFIG_CC_HAS_SANE_STACKPROTECTOR=y
      
      That's dangerously subtle - people could suddenly find themselves with
      the weaker stack protector setup without even realizing.
      
      The solution here is to just rename not just the old RECULAR stack
      protector option, but also the strong one.  This does that by just
      removing the CC_ prefix entirely for the user choices, because it really
      is not about the compiler support (the compiler support now instead
      automatially impacts _visibility_ of the options to users).
      
      This results in "make oldconfig" actually asking the user for their
      choice, so that we don't have any silent subtle security model changes.
      The end result would generally look like this:
      
        CONFIG_HAVE_CC_STACKPROTECTOR=y
        CONFIG_CC_HAS_STACKPROTECTOR_NONE=y
        CONFIG_STACKPROTECTOR=y
        CONFIG_STACKPROTECTOR_STRONG=y
        CONFIG_CC_HAS_SANE_STACKPROTECTOR=y
      
      where the "CC_" versions really are about internal compiler
      infrastructure, not the user selections.
      Acked-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      050e9baa
  2. 13 6月, 2018 2 次提交
    • K
      treewide: kzalloc() -> kcalloc() · 6396bb22
      Kees Cook 提交于
      The kzalloc() function has a 2-factor argument form, kcalloc(). This
      patch replaces cases of:
      
              kzalloc(a * b, gfp)
      
      with:
              kcalloc(a * b, gfp)
      
      as well as handling cases of:
      
              kzalloc(a * b * c, gfp)
      
      with:
      
              kzalloc(array3_size(a, b, c), gfp)
      
      as it's slightly less ugly than:
      
              kzalloc_array(array_size(a, b), c, gfp)
      
      This does, however, attempt to ignore constant size factors like:
      
              kzalloc(4 * 1024, gfp)
      
      though any constants defined via macros get caught up in the conversion.
      
      Any factors with a sizeof() of "unsigned char", "char", and "u8" were
      dropped, since they're redundant.
      
      The Coccinelle script used for this was:
      
      // Fix redundant parens around sizeof().
      @@
      type TYPE;
      expression THING, E;
      @@
      
      (
        kzalloc(
      -	(sizeof(TYPE)) * E
      +	sizeof(TYPE) * E
        , ...)
      |
        kzalloc(
      -	(sizeof(THING)) * E
      +	sizeof(THING) * E
        , ...)
      )
      
      // Drop single-byte sizes and redundant parens.
      @@
      expression COUNT;
      typedef u8;
      typedef __u8;
      @@
      
      (
        kzalloc(
      -	sizeof(u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(__u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(char) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(unsigned char) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(u8) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(__u8) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(char) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(unsigned char) * COUNT
      +	COUNT
        , ...)
      )
      
      // 2-factor product with sizeof(type/expression) and identifier or constant.
      @@
      type TYPE;
      expression THING;
      identifier COUNT_ID;
      constant COUNT_CONST;
      @@
      
      (
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (COUNT_ID)
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * COUNT_ID
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * COUNT_CONST
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (COUNT_ID)
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * COUNT_ID
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * COUNT_CONST
      +	COUNT_CONST, sizeof(THING)
        , ...)
      )
      
      // 2-factor product, only identifiers.
      @@
      identifier SIZE, COUNT;
      @@
      
      - kzalloc
      + kcalloc
        (
      -	SIZE * COUNT
      +	COUNT, SIZE
        , ...)
      
      // 3-factor product with 1 sizeof(type) or sizeof(expression), with
      // redundant parens removed.
      @@
      expression THING;
      identifier STRIDE, COUNT;
      type TYPE;
      @@
      
      (
        kzalloc(
      -	sizeof(TYPE) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      )
      
      // 3-factor product with 2 sizeof(variable), with redundant parens removed.
      @@
      expression THING1, THING2;
      identifier COUNT;
      type TYPE1, TYPE2;
      @@
      
      (
        kzalloc(
      -	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kzalloc(
      -	sizeof(THING1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(THING1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      )
      
      // 3-factor product, only identifiers, with redundant parens removed.
      @@
      identifier STRIDE, SIZE, COUNT;
      @@
      
      (
        kzalloc(
      -	(COUNT) * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      )
      
      // Any remaining multi-factor products, first at least 3-factor products,
      // when they're not all constants...
      @@
      expression E1, E2, E3;
      constant C1, C2, C3;
      @@
      
      (
        kzalloc(C1 * C2 * C3, ...)
      |
        kzalloc(
      -	(E1) * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	(E1) * (E2) * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	(E1) * (E2) * (E3)
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	E1 * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      )
      
      // And then all remaining 2 factors products when they're not all constants,
      // keeping sizeof() as the second factor argument.
      @@
      expression THING, E1, E2;
      type TYPE;
      constant C1, C2, C3;
      @@
      
      (
        kzalloc(sizeof(THING) * C2, ...)
      |
        kzalloc(sizeof(TYPE) * C2, ...)
      |
        kzalloc(C1 * C2 * C3, ...)
      |
        kzalloc(C1 * C2, ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (E2)
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * E2
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (E2)
      +	E2, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * E2
      +	E2, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	(E1) * E2
      +	E1, E2
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	(E1) * (E2)
      +	E1, E2
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	E1 * E2
      +	E1, E2
        , ...)
      )
      Signed-off-by: NKees Cook <keescook@chromium.org>
      6396bb22
    • K
      treewide: kmalloc() -> kmalloc_array() · 6da2ec56
      Kees Cook 提交于
      The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
      patch replaces cases of:
      
              kmalloc(a * b, gfp)
      
      with:
              kmalloc_array(a * b, gfp)
      
      as well as handling cases of:
      
              kmalloc(a * b * c, gfp)
      
      with:
      
              kmalloc(array3_size(a, b, c), gfp)
      
      as it's slightly less ugly than:
      
              kmalloc_array(array_size(a, b), c, gfp)
      
      This does, however, attempt to ignore constant size factors like:
      
              kmalloc(4 * 1024, gfp)
      
      though any constants defined via macros get caught up in the conversion.
      
      Any factors with a sizeof() of "unsigned char", "char", and "u8" were
      dropped, since they're redundant.
      
      The tools/ directory was manually excluded, since it has its own
      implementation of kmalloc().
      
      The Coccinelle script used for this was:
      
      // Fix redundant parens around sizeof().
      @@
      type TYPE;
      expression THING, E;
      @@
      
      (
        kmalloc(
      -	(sizeof(TYPE)) * E
      +	sizeof(TYPE) * E
        , ...)
      |
        kmalloc(
      -	(sizeof(THING)) * E
      +	sizeof(THING) * E
        , ...)
      )
      
      // Drop single-byte sizes and redundant parens.
      @@
      expression COUNT;
      typedef u8;
      typedef __u8;
      @@
      
      (
        kmalloc(
      -	sizeof(u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kmalloc(
      -	sizeof(__u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kmalloc(
      -	sizeof(char) * (COUNT)
      +	COUNT
        , ...)
      |
        kmalloc(
      -	sizeof(unsigned char) * (COUNT)
      +	COUNT
        , ...)
      |
        kmalloc(
      -	sizeof(u8) * COUNT
      +	COUNT
        , ...)
      |
        kmalloc(
      -	sizeof(__u8) * COUNT
      +	COUNT
        , ...)
      |
        kmalloc(
      -	sizeof(char) * COUNT
      +	COUNT
        , ...)
      |
        kmalloc(
      -	sizeof(unsigned char) * COUNT
      +	COUNT
        , ...)
      )
      
      // 2-factor product with sizeof(type/expression) and identifier or constant.
      @@
      type TYPE;
      expression THING;
      identifier COUNT_ID;
      constant COUNT_CONST;
      @@
      
      (
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(TYPE) * (COUNT_ID)
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(TYPE) * COUNT_ID
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(TYPE) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(TYPE) * COUNT_CONST
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(THING) * (COUNT_ID)
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(THING) * COUNT_ID
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(THING) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(THING)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(THING) * COUNT_CONST
      +	COUNT_CONST, sizeof(THING)
        , ...)
      )
      
      // 2-factor product, only identifiers.
      @@
      identifier SIZE, COUNT;
      @@
      
      - kmalloc
      + kmalloc_array
        (
      -	SIZE * COUNT
      +	COUNT, SIZE
        , ...)
      
      // 3-factor product with 1 sizeof(type) or sizeof(expression), with
      // redundant parens removed.
      @@
      expression THING;
      identifier STRIDE, COUNT;
      type TYPE;
      @@
      
      (
        kmalloc(
      -	sizeof(TYPE) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kmalloc(
      -	sizeof(TYPE) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kmalloc(
      -	sizeof(TYPE) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kmalloc(
      -	sizeof(TYPE) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kmalloc(
      -	sizeof(THING) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kmalloc(
      -	sizeof(THING) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kmalloc(
      -	sizeof(THING) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kmalloc(
      -	sizeof(THING) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      )
      
      // 3-factor product with 2 sizeof(variable), with redundant parens removed.
      @@
      expression THING1, THING2;
      identifier COUNT;
      type TYPE1, TYPE2;
      @@
      
      (
        kmalloc(
      -	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kmalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kmalloc(
      -	sizeof(THING1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kmalloc(
      -	sizeof(THING1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kmalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      |
        kmalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      )
      
      // 3-factor product, only identifiers, with redundant parens removed.
      @@
      identifier STRIDE, SIZE, COUNT;
      @@
      
      (
        kmalloc(
      -	(COUNT) * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kmalloc(
      -	COUNT * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kmalloc(
      -	COUNT * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kmalloc(
      -	(COUNT) * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kmalloc(
      -	COUNT * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kmalloc(
      -	(COUNT) * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kmalloc(
      -	(COUNT) * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kmalloc(
      -	COUNT * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      )
      
      // Any remaining multi-factor products, first at least 3-factor products,
      // when they're not all constants...
      @@
      expression E1, E2, E3;
      constant C1, C2, C3;
      @@
      
      (
        kmalloc(C1 * C2 * C3, ...)
      |
        kmalloc(
      -	(E1) * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kmalloc(
      -	(E1) * (E2) * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kmalloc(
      -	(E1) * (E2) * (E3)
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kmalloc(
      -	E1 * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      )
      
      // And then all remaining 2 factors products when they're not all constants,
      // keeping sizeof() as the second factor argument.
      @@
      expression THING, E1, E2;
      type TYPE;
      constant C1, C2, C3;
      @@
      
      (
        kmalloc(sizeof(THING) * C2, ...)
      |
        kmalloc(sizeof(TYPE) * C2, ...)
      |
        kmalloc(C1 * C2 * C3, ...)
      |
        kmalloc(C1 * C2, ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(TYPE) * (E2)
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(TYPE) * E2
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(THING) * (E2)
      +	E2, sizeof(THING)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	sizeof(THING) * E2
      +	E2, sizeof(THING)
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	(E1) * E2
      +	E1, E2
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	(E1) * (E2)
      +	E1, E2
        , ...)
      |
      - kmalloc
      + kmalloc_array
        (
      -	E1 * E2
      +	E1, E2
        , ...)
      )
      Signed-off-by: NKees Cook <keescook@chromium.org>
      6da2ec56
  3. 02 6月, 2018 1 次提交
  4. 01 6月, 2018 1 次提交
  5. 24 5月, 2018 3 次提交
    • M
      MIPS: ptrace: Fix PTRACE_PEEKUSR requests for 64-bit FGRs · c7e81462
      Maciej W. Rozycki 提交于
      Use 64-bit accesses for 64-bit floating-point general registers with
      PTRACE_PEEKUSR, removing the truncation of their upper halves in the
      FR=1 mode, caused by commit bbd426f5 ("MIPS: Simplify FP context
      access"), which inadvertently switched them to using 32-bit accesses.
      
      The PTRACE_POKEUSR side is fine as it's never been broken and continues
      using 64-bit accesses.
      
      Fixes: bbd426f5 ("MIPS: Simplify FP context access")
      Signed-off-by: NMaciej W. Rozycki <macro@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 3.15+
      Patchwork: https://patchwork.linux-mips.org/patch/19334/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      c7e81462
    • M
      MIPS: prctl: Disallow FRE without FR with PR_SET_FP_MODE requests · 28e4213d
      Maciej W. Rozycki 提交于
      Having PR_FP_MODE_FRE (i.e. Config5.FRE) set without PR_FP_MODE_FR (i.e.
      Status.FR) is not supported as the lone purpose of Config5.FRE is to
      emulate Status.FR=0 handling on FPU hardware that has Status.FR=1
      hardwired[1][2].  Also we do not handle this case elsewhere, and assume
      throughout our code that TIF_HYBRID_FPREGS and TIF_32BIT_FPREGS cannot
      be set both at once for a task, leading to inconsistent behaviour if
      this does happen.
      
      Return unsuccessfully then from prctl(2) PR_SET_FP_MODE calls requesting
      PR_FP_MODE_FRE to be set with PR_FP_MODE_FR clear.  This corresponds to
      modes allowed by `mips_set_personality_fp'.
      
      References:
      
      [1] "MIPS Architecture For Programmers, Vol. III: MIPS32 / microMIPS32
          Privileged Resource Architecture", Imagination Technologies,
          Document Number: MD00090, Revision 6.02, July 10, 2015, Table 9.69
          "Config5 Register Field Descriptions", p. 262
      
      [2] "MIPS Architecture For Programmers, Volume III: MIPS64 / microMIPS64
          Privileged Resource Architecture", Imagination Technologies,
          Document Number: MD00091, Revision 6.03, December 22, 2015, Table
          9.72 "Config5 Register Field Descriptions", p. 288
      
      Fixes: 9791554b ("MIPS,prctl: add PR_[GS]ET_FP_MODE prctl options for MIPS")
      Signed-off-by: NMaciej W. Rozycki <macro@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 4.0+
      Patchwork: https://patchwork.linux-mips.org/patch/19327/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      28e4213d
    • M
      MIPS: ptrace: Make FPU context layout comments match reality · d1157b10
      Maciej W. Rozycki 提交于
      Correct comments across ptrace(2) handlers about an FPU register context
      layout discrepancy between MIPS I and later ISAs, which was fixed with
      `linux-mips.org' (LMO) commit 42533948caac ("Major pile of FP emulator
      changes."), the fix corrected with LMO commit 849fa7a50dff ("R3k FPU
      ptrace() handling fixes."), and then broken and fixed over and over
      again, until last time fixed with commit 80cbfad7 ("MIPS: Correct
      MIPS I FP context layout").
      
      NB running the GDB test suite for the relevant ABI/ISA and watching out
      for regressions is advisable when poking around ptrace(2).
      Signed-off-by: NMaciej W. Rozycki <macro@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/19326/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      d1157b10
  6. 22 5月, 2018 1 次提交
  7. 21 5月, 2018 1 次提交
  8. 17 5月, 2018 1 次提交
  9. 16 5月, 2018 1 次提交
  10. 15 5月, 2018 23 次提交
    • M
      MIPS: perf: Fix perf with MT counting other threads · 84002c88
      Matt Redfearn 提交于
      When perf is used in non-system mode, i.e. without specifying CPUs to
      count on, check_and_calc_range falls into the case when it sets
      M_TC_EN_ALL in the counter config_base. This has the impact of always
      counting for all of the threads in a core, even when the user has not
      requested it. For example this can be seen with a test program which
      executes 30002 instructions and 10000 branches running on one VPE and a
      busy load on the other VPE in the core. Without this commit, the
      expected count is not returned:
      
      taskset 4 dd if=/dev/zero of=/dev/null count=100000 & taskset 8 perf
      stat -e instructions:u,branches:u ./test_prog
      
       Performance counter stats for './test_prog':
      
                  103235      instructions:u
                   17015      branches:u
      
      In order to fix this, remove check_and_calc_range entirely and perform
      all of the logic in mipsxx_pmu_enable_event. Since
      mipsxx_pmu_enable_event now requires the range of the event, ensure that
      it is set by mipspmu_perf_event_encode in the same circumstances as
      before (i.e. #ifdef CONFIG_MIPS_MT_SMP && num_possible_cpus() > 1).
      
      The logic of mipsxx_pmu_enable_event now becomes:
      If the CPU is a BMIPS5000, then use the special vpe_id() implementation
      to select which VPE to count.
      If the counter has a range greater than a single VPE, i.e. it is a
      core-wide counter, then ensure that the counter is set up to count
      events from all TCs (though, since this is true by definition, is this
      necessary? Just enabling a core-wide counter in the per-VPE case appears
      experimentally to return the same counts. This is left in for now as the
      logic was present before).
      If the event is set up to count a particular CPU (i.e. system mode),
      then the VPE ID of that CPU is used for the counter.
      Otherwise, the event should be counted on the CPU scheduling this thread
      (this was the critical bit missing from the previous implementation) so
      the VPE ID of this CPU is used for the counter.
      
      With this commit, the same test as before returns the counts expected:
      
      taskset 4 dd if=/dev/zero of=/dev/null count=100000 & taskset 8 perf
      stat -e instructions:u,branches:u ./test_prog
      
       Performance counter stats for './test_prog':
      
                   30002      instructions:u
                   10000      branches:u
      Signed-off-by: NMatt Redfearn <matt.redfearn@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/19138/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      84002c88
    • M
      MIPS: perf: Use correct VPE ID when setting up VPE tracing · 840a8b55
      Matt Redfearn 提交于
      There are a couple of FIXME's in the perf code which state that
      cpu_data[event->cpu].vpe_id reports 0 for both CPUs. This is no longer
      the case, since the vpe_id is used extensively by SMP CPS.
      
      VPE local counting gets around this by using smp_processor_id() instead.
      As it happens this does work correctly to count events on the right VPE,
      but relies on 2 assumptions:
      a) Always having 2 VPEs / core.
      b) The hardware only paying attention to the least significant bit of
      the PERFCTL.VPEID field.
      If either of these assumptions change then the incorrect VPEs events
      will be counted.
      
      Fix this by replacing smp_processor_id() with
      cpu_vpe_id(&current_cpu_data), in the vpe_id() macro, and pass vpe_id()
      to M_PERFCTL_VPEID() when setting up PERFCTL.VPEID. The FIXME's can also
      be removed since they no longer apply.
      Signed-off-by: NMatt Redfearn <matt.redfearn@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/19137/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      840a8b55
    • M
      MIPS: perf: More robustly probe for the presence of per-tc counters · 800fb712
      Matt Redfearn 提交于
      The presence of per TC performance counters is now detected by
      cpu-probe.c and indicated by MIPS_CPU_MT_PER_TC_PERF_COUNTERS in
      cpu_data. Switch detection of the feature to use this new flag rather
      than blindly testing the implementation specific config7 register with a
      magic number.
      Signed-off-by: NMatt Redfearn <matt.redfearn@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Maciej W. Rozycki <macro@mips.com>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Robert Richter <rric@kernel.org>
      Cc: linux-mips@linux-mips.org
      Cc: oprofile-list@lists.sf.net
      Patchwork: https://patchwork.linux-mips.org/patch/19142/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      800fb712
    • M
      MIPS: Probe for MIPS MT perf counters per TC · 8270ab48
      Matt Redfearn 提交于
      Processors implementing the MIPS MT ASE may have performance counters
      implemented per core or per TC. Processors implemented by MIPS
      Technologies signify presence per TC through a bit in the implementation
      specific Config7 register. Currently the code which probes for their
      presence blindly reads a magic number corresponding to this bit, despite
      it potentially having a different meaning in the CPU implementation.
      
      Since CPU features are generally detected by cpu-probe.c, perform the
      detection here instead. Introduce cpu_set_mt_per_tc_perf which checks
      the bit in config7 and call it from MIPS CPUs known to implement this
      bit and the MT ASE, specifically, the 34K, 1004K and interAptiv.
      
      Once the presence of the per-tc counter is indicated in cpu_data, tests
      for it can be updated to use this flag.
      Suggested-by: NJames Hogan <jhogan@kernel.org>
      Signed-off-by: NMatt Redfearn <matt.redfearn@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Matt Redfearn <matt.redfearn@mips.com>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: Maciej W. Rozycki <macro@mips.com>
      Cc: linux-mips@linux-mips.org>
      Patchwork: https://patchwork.linux-mips.org/patch/19136/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      8270ab48
    • D
      bpf, mips: remove unused function · 0631b658
      Daniel Borkmann 提交于
      The ool_skb_header_pointer() and size_to_len() is unused same as
      tmp_offset, therefore remove all of them.
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      0631b658
    • A
      MIPS: mscc: Connect phys to ports on ocelot_pcb123 · 8798e392
      Alexandre Belloni 提交于
      Add phy to switch port connections for PCB123 for internal PHYs.
      Signed-off-by: NAlexandre Belloni <alexandre.belloni@bootlin.com>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: linux-mips@linux-mips.org
      Cc: netdev@vger.kernel.org
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      8798e392
    • A
      MIPS: mscc: Add switch to ocelot · 49b03169
      Alexandre Belloni 提交于
      Ocelot has an integrated switch, add support for it.
      Signed-off-by: NAlexandre Belloni <alexandre.belloni@bootlin.com>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: linux-mips@linux-mips.org
      Cc: netdev@vger.kernel.org
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      49b03169
    • P
      MIPS: JZ4740: Drop old platform reset code · 1761ad8c
      Paul Cercueil 提交于
      This work is now performed by the watchdog driver directly.
      Signed-off-by: NPaul Cercueil <paul@crapouillou.net>
      Acked-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Mathieu Malaterre <malat@debian.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-watchdog@vger.kernel.org
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      1761ad8c
    • P
      MIPS: qi_lb60: Enable the jz4740-wdt driver · c49173ff
      Paul Cercueil 提交于
      The watchdog is an useful piece of hardware, so there's no reason not to
      enable it.
      
      Besides, this is important for restart to work after the change in the
      next commit.
      
      This commit enables the Kconfig option in the qi_lb60 defconfig.
      Signed-off-by: NPaul Cercueil <paul@crapouillou.net>
      Acked-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Mathieu Malaterre <malat@debian.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-watchdog@vger.kernel.org
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      c49173ff
    • P
      MIPS: JZ4780: dts: Fix watchdog node · 9a0225d9
      Paul Cercueil 提交于
      - The previous node requested a memory area of 0x100 bytes, while the
        driver only manipulates four registers present in the first 0x10 bytes.
      
      - The driver requests for the "rtc" clock, but the previous node did not
        provide any.
      Signed-off-by: NPaul Cercueil <paul@crapouillou.net>
      Reviewed-by: NMathieu Malaterre <malat@debian.org>
      Acked-by: NJames Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Mathieu Malaterre <malat@debian.org>
      Cc: linux-mips@linux-mips.org
      Cc: devicetree@vger.kernel.org
      Cc: linux-watchdog@vger.kernel.org
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      9a0225d9
    • P
      MIPS: JZ4740: dts: Add bindings for the jz4740-wdt driver · fbc23c71
      Paul Cercueil 提交于
      Also remove the watchdog platform_device from platform.c, since it
      wasn't used anywhere anyway.
      Signed-off-by: NPaul Cercueil <paul@crapouillou.net>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Wim Van Sebroeck <wim@linux-watchdog.org>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Mathieu Malaterre <malat@debian.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-watchdog@vger.kernel.org
      Cc: devicetree@vger.kernel.org
      [jhogan@kernel.org: Drop jz4740_wdt_device declaration from header]
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      fbc23c71
    • C
      MIPS: VPE: Fix spelling mistake: "uneeded" -> "unneeded" · aae22f16
      Colin Ian King 提交于
      Trivial fix to spelling mistake in pr_warn message text.
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: kernel-janitors@vger.kernel.org
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      aae22f16
    • A
      MIPS: Re-use kstrtobool_from_user() · f83e4e1e
      Andy Shevchenko 提交于
      Re-use kstrtobool_from_user() instead of open coded variant.
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      f83e4e1e
    • B
      MIPS: Convert update_persistent_clock() to update_persistent_clock64() · f06e7aa4
      Baolin Wang 提交于
      Since struct timespec is not y2038 safe on 32bit machines, this patch
      converts update_persistent_clock() to update_persistent_clock64() using
      struct timespec64.
      
      The rtc_mips_set_time() and rtc_mips_set_mmss() interfaces were using
      'unsigned long' type that is not y2038 safe on 32bit machines, moreover
      there is only one platform implementing rtc_mips_set_time() and two
      platforms implementing rtc_mips_set_mmss(), so we can just make them each
      implement update_persistent_clock64() directly, to get that helper out
      of the common mips code by removing rtc_mips_set_time() and
      rtc_mips_set_mmss() interfaces.
      Signed-off-by: NBaolin Wang <baolin.wang@linaro.org>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: linux-mips@linux-mips.org
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      f06e7aa4
    • B
      MIPS: Convert read_persistent_clock() to read_persistent_clock64() · 09adad17
      Baolin Wang 提交于
      Since struct timespec is not y2038 safe on 32bit machines, this patch
      converts read_persistent_clock() to read_persistent_clock64() using
      struct timespec64, as well as converting mktime() to mktime64().
      Signed-off-by: NBaolin Wang <baolin.wang@linaro.org>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Huacai Chen <chenhc@lemote.com>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: linux-mips@linux-mips.org
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      09adad17
    • B
      MIPS: sni: Remove the read_persistent_clock() · d7c72c57
      Baolin Wang 提交于
      The dummy read_persistent_clock() uses a timespec, which is not year
      2038 safe on 32bit systems. Thus remove this obsolete interface.
      Signed-off-by: NBaolin Wang <baolin.wang@linaro.org>
      Acked-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Patchwork: https://patchwork.linux-mips.org/patch/19114/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      d7c72c57
    • M
      MIPS: Fix ptrace(2) PTRACE_PEEKUSR and PTRACE_POKEUSR accesses to o32 FGRs · 9a3a92cc
      Maciej W. Rozycki 提交于
      Check the TIF_32BIT_FPREGS task setting of the tracee rather than the
      tracer in determining the layout of floating-point general registers in
      the floating-point context, correcting access to odd-numbered registers
      for o32 tracees where the setting disagrees between the two processes.
      
      Fixes: 597ce172 ("MIPS: Support for 64-bit FP with O32 binaries")
      Signed-off-by: NMaciej W. Rozycki <macro@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 3.14+
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      9a3a92cc
    • A
      MIPS: xilfpga: Actually include FDT in fitImage · 947bc875
      Alexandre Belloni 提交于
      Commit b35565bb ("MIPS: generic: Add support for MIPSfpga") added
      and its.S file for xilfpga but forgot to add it to
      arch/mips/generic/Platform so it is never used.
      
      Fixes: b35565bb ("MIPS: generic: Add support for MIPSfpga")
      Signed-off-by: NAlexandre Belloni <alexandre.belloni@bootlin.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 4.15+
      Patchwork: https://patchwork.linux-mips.org/patch/19245/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      947bc875
    • A
      MIPS: xilfpga: Stop generating useless dtb.o · a5a92abb
      Alexandre Belloni 提交于
      A dtb.o is generated from nexys4ddr.dts but this is never used since it
      has been moved to mips/generic with commit b35565bb ("MIPS: generic:
      Add support for MIPSfpga").
      
      Fixes: b35565bb ("MIPS: generic: Add support for MIPSfpga")
      Signed-off-by: NAlexandre Belloni <alexandre.belloni@bootlin.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 4.15+
      Patchwork: https://patchwork.linux-mips.org/patch/19244/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      a5a92abb
    • C
      KVM: Fix spelling mistake: "cop_unsuable" -> "cop_unusable" · ba3696e9
      Colin Ian King 提交于
      Trivial fix to spelling mistake in debugfs_entries text.
      
      Fixes: 669e846e ("KVM/MIPS32: MIPS arch specific APIs for KVM")
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: kernel-janitors@vger.kernel.org
      Cc: <stable@vger.kernel.org> # 3.10+
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      ba3696e9
    • M
      MIPS: ptrace: Expose FIR register through FP regset · 71e909c0
      Maciej W. Rozycki 提交于
      Correct commit 7aeb753b ("MIPS: Implement task_user_regset_view.")
      and expose the FIR register using the unused 4 bytes at the end of the
      NT_PRFPREG regset.  Without that register included clients cannot use
      the PTRACE_GETREGSET request to retrieve the complete FPU register set
      and have to resort to one of the older interfaces, either PTRACE_PEEKUSR
      or PTRACE_GETFPREGS, to retrieve the missing piece of data.  Also the
      register is irreversibly missing from core dumps.
      
      This register is architecturally hardwired and read-only so the write
      path does not matter.  Ignore data supplied on writes then.
      
      Fixes: 7aeb753b ("MIPS: Implement task_user_regset_view.")
      Signed-off-by: NJames Hogan <jhogan@kernel.org>
      Signed-off-by: NMaciej W. Rozycki <macro@mips.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 3.13+
      Patchwork: https://patchwork.linux-mips.org/patch/19273/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      71e909c0
    • P
      MIPS: Fix build with DEBUG_ZBOOT and MACH_JZ4770 · c60128ce
      Paul Cercueil 提交于
      The debug definitions were missing for MACH_JZ4770, resulting in a build
      failure when DEBUG_ZBOOT was set.
      
      Since the UART addresses are the same across all Ingenic SoCs, we just
      use a #ifdef CONFIG_MACH_INGENIC instead of checking for individual
      Ingenic SoCs.
      
      Additionally, I added a #define for the UART0 address in-code and
      dropped the <asm/mach-jz4740/base.h> include, for the reason that this
      include file is slowly being phased out as the whole platform is being
      moved to devicetree.
      
      Fixes: 9be5f3e9 ("MIPS: ingenic: Initial JZ4770 support")
      Signed-off-by: NPaul Cercueil <paul@crapouillou.net>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 4.16
      Patchwork: https://patchwork.linux-mips.org/patch/18957/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      c60128ce
    • N
      MIPS: c-r4k: Fix data corruption related to cache coherence · 55a2aa08
      NeilBrown 提交于
      When DMA will be performed to a MIPS32 1004K CPS, the L1-cache for the
      range needs to be flushed and invalidated first.
      The code currently takes one of two approaches.
      1/ If the range is less than the size of the dcache, then HIT type
         requests flush/invalidate cache lines for the particular addresses.
         HIT-type requests a globalised by the CPS so this is safe on SMP.
      
      2/ If the range is larger than the size of dcache, then INDEX type
         requests flush/invalidate the whole cache. INDEX type requests affect
         the local cache only. CPS does not propagate them in any way. So this
         invalidation is not safe on SMP CPS systems.
      
      Data corruption due to '2' can quite easily be demonstrated by
      repeatedly "echo 3 > /proc/sys/vm/drop_caches" and then sha1sum a file
      that is several times the size of available memory. Dropping caches
      means that large contiguous extents (large than dcache) are more likely.
      
      This was not a problem before Linux-4.8 because option 2 was never used
      if CONFIG_MIPS_CPS was defined. The commit which removed that apparently
      didn't appreciate the full consequence of the change.
      
      We could, in theory, globalize the INDEX based flush by sending an IPI
      to other cores. These cache invalidation routines can be called with
      interrupts disabled and synchronous IPI require interrupts to be
      enabled. Asynchronous IPI may not trigger writeback soon enough. So we
      cannot use IPI in practice.
      
      We can already test if IPI would be needed for an INDEX operation with
      r4k_op_needs_ipi(R4K_INDEX). If this is true then we mustn't try the
      INDEX approach as we cannot use IPI. If this is false (e.g. when there
      is only one core and hence one L1 cache) then it is safe to use the
      INDEX approach without IPI.
      
      This patch avoids options 2 if r4k_op_needs_ipi(R4K_INDEX), and so
      eliminates the corruption.
      
      Fixes: c00ab489 ("MIPS: Remove cpu_has_safe_index_cacheops")
      Signed-off-by: NNeilBrown <neil@brown.name>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Paul Burton <paul.burton@mips.com>
      Cc: linux-mips@linux-mips.org
      Cc: <stable@vger.kernel.org> # 4.8+
      Patchwork: https://patchwork.linux-mips.org/patch/19259/Signed-off-by: NJames Hogan <jhogan@kernel.org>
      55a2aa08
  11. 09 5月, 2018 5 次提交