lkml.org 
[lkml]   [2020]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.14 012/237] arm64: ptrace: nofpsimd: Fail FP/SIMD regset operations
    Date
    From: Suzuki K Poulose <suzuki.poulose@arm.com>

    commit c9d66999f064947e6b577ceacc1eb2fbca6a8d3c upstream

    When fp/simd is not supported on the system, fail the operations
    of FP/SIMD regsets.

    Cc: stable@vger.kernel.org # v4.14
    Cc: Will Deacon <will@kernel.org>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
    Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
    Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    arch/arm64/kernel/ptrace.c | 21 +++++++++++++++++++++
    1 file changed, 21 insertions(+)

    diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
    index 242527f29c410..e230b4dff9602 100644
    --- a/arch/arm64/kernel/ptrace.c
    +++ b/arch/arm64/kernel/ptrace.c
    @@ -624,6 +624,13 @@ static int gpr_set(struct task_struct *target, const struct user_regset *regset,
    return 0;
    }

    +static int fpr_active(struct task_struct *target, const struct user_regset *regset)
    +{
    + if (!system_supports_fpsimd())
    + return -ENODEV;
    + return regset->n;
    +}
    +
    /*
    * TODO: update fp accessors for lazy context switching (sync/flush hwstate)
    */
    @@ -634,6 +641,9 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset,
    struct user_fpsimd_state *uregs;
    uregs = &target->thread.fpsimd_state.user_fpsimd;

    + if (!system_supports_fpsimd())
    + return -EINVAL;
    +
    if (target == current)
    fpsimd_preserve_current_state();

    @@ -648,6 +658,9 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset,
    struct user_fpsimd_state newstate =
    target->thread.fpsimd_state.user_fpsimd;

    + if (!system_supports_fpsimd())
    + return -EINVAL;
    +
    ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &newstate, 0, -1);
    if (ret)
    return ret;
    @@ -740,6 +753,7 @@ static const struct user_regset aarch64_regsets[] = {
    */
    .size = sizeof(u32),
    .align = sizeof(u32),
    + .active = fpr_active,
    .get = fpr_get,
    .set = fpr_set
    },
    @@ -914,6 +928,9 @@ static int compat_vfp_get(struct task_struct *target,
    compat_ulong_t fpscr;
    int ret, vregs_end_pos;

    + if (!system_supports_fpsimd())
    + return -EINVAL;
    +
    uregs = &target->thread.fpsimd_state.user_fpsimd;

    if (target == current)
    @@ -947,6 +964,9 @@ static int compat_vfp_set(struct task_struct *target,
    compat_ulong_t fpscr;
    int ret, vregs_end_pos;

    + if (!system_supports_fpsimd())
    + return -EINVAL;
    +
    uregs = &target->thread.fpsimd_state.user_fpsimd;

    vregs_end_pos = VFP_STATE_SIZE - sizeof(compat_ulong_t);
    @@ -1004,6 +1024,7 @@ static const struct user_regset aarch32_regsets[] = {
    .n = VFP_STATE_SIZE / sizeof(compat_ulong_t),
    .size = sizeof(compat_ulong_t),
    .align = sizeof(compat_ulong_t),
    + .active = fpr_active,
    .get = compat_vfp_get,
    .set = compat_vfp_set
    },
    --
    2.20.1


    \
     
     \ /
      Last update: 2020-02-27 15:41    [W:4.154 / U:0.112 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site