Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp28375imw; Thu, 14 Jul 2022 19:41:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sPau9Sox9XD5AeVNsbNdPFmWWzJTzS67R71/utH7orYPCQg0fObg4YY27Jf43PP/Anc0Fz X-Received: by 2002:a17:907:7639:b0:72b:60b5:7458 with SMTP id jy25-20020a170907763900b0072b60b57458mr11629574ejc.664.1657852894220; Thu, 14 Jul 2022 19:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657852894; cv=none; d=google.com; s=arc-20160816; b=XkureuUl53Z0pC7XJN427tvOZDAdfoHT3+ZjlK5W56K6ipMuOQaQLgdpHRTgq2lCl5 MsdM5JNRnvnAZbKl4diEJLJDCIGeLQwbe6/oH10+tuDVZH2hFt4f437ISqeZDVMuGjm0 8e550r8Ej9b8doXBQsmj6GEFLbNyAgt+60Z0nAVceMSZ7O3PqvgGPH77pBu1LcPYeEls P6UU/8w+WuDWPC8QbQ29nFPpwoDVmuRCAUeMrjNvGRJRXCcQo5f2+UH6EXRri2Br0+AI st1zVgYk7IU+Hm6MSiA68qaqwwZlS744wq4RzmzaMY/HiG36YTo3n4o4uctfWewWAz5m dscQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Mqg6n5x0Y84PQx9gIusGWuD9BhHpucT1aFR6LeDoe2A=; b=gh36U2bj3znTqZvBFbbmbrdtBD6z/cqqIacUWwAFkEQKsBF7dWLBczYtLfxk+gtV6D HG3dqMpStv+YAaumsTIben0K9FhuMYoRKIM8Z66qtEI0lf+Le1rtZhdCs1G8b4BIBKZP gXWq0l+wJsu7M7HrzVPtozqmktIy2x70TU+OfDrC8w6xRAn3SetHNuCMS6gviSvsDDWZ l3JOX+j9hQ7nQz7FHg2rYEj+6HsdhqZexjiT7+1QsVcw/Rl7uHf+JjdPKwHlyRe3WY3g 1ImEogMFJO/vjWMO6M+s+EJcVdzGb8tN4PJ/NCEHC2GK6QHXEcH021MV8w/EnPWXgpO7 aPHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n22-20020aa7db56000000b0043ac3e75000si3741439edt.412.2022.07.14.19.40.52; Thu, 14 Jul 2022 19:41:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240831AbiGOCiG (ORCPT + 99 others); Thu, 14 Jul 2022 22:38:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbiGOCiF (ORCPT ); Thu, 14 Jul 2022 22:38:05 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8D705481E6 for ; Thu, 14 Jul 2022 19:38:03 -0700 (PDT) Received: from lingfengzhe-ms7c94.loongson.cn (unknown [10.90.50.23]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxf+ME09BiLbsfAA--.64763S2; Fri, 15 Jul 2022 10:37:56 +0800 (CST) From: Qi Hu To: Huacai Chen , WANG Xuerui , Oleg Nesterov Cc: Xu Li , loongarch@lists.linux.dev, LKML , Qi Hu Subject: [PATCH v2] LoongArch: Fix missing fcsr in ptrace's fpr_set Date: Fri, 15 Jul 2022 10:37:53 +0800 Message-Id: <20220715023753.436226-1-huqi@loongson.cn> X-Mailer: git-send-email 2.37.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf9Dxf+ME09BiLbsfAA--.64763S2 X-Coremail-Antispam: 1UD129KBjvJXoW7uryrtF1UJw4rWF1rXw1xuFg_yoW8XFWrpr ZxAas3Wr4rGFWSvr4Dt3yv9ryDX3s2gFyS9393J3WfAwnrXrs8XryjyFZ2vFW2y348Wayx XF9Y9r4YyFsFqaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkv14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AKxV WxJr0_GcWle2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2Wl Yx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbV WUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc2xSY4AK6svP MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr 0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0E wIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJV W8JwCI42IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI 42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x0JUdHUDUUUUU= X-CM-SenderInfo: pkxtxqxorr0wxvrqhubq/1tbiAQAICV3QvP1zwwACs+ X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In file ptrace.c, function fpr_set does not copy fcsr data from ubuf to kbuf. That's the reason why fcsr cannot be modified by ptrace. This patch fixs this problem and allows users using ptrace to modify the fcsr. Co-developed-by: Xu Li Signed-off-by: Qi Hu --- V1 -> V2: Change Signed-off-by to Co-developed-by in the commit message. --- arch/loongarch/kernel/ptrace.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/loongarch/kernel/ptrace.c b/arch/loongarch/kernel/ptrace.c index e6ab87948e1d..dc2b82ea894c 100644 --- a/arch/loongarch/kernel/ptrace.c +++ b/arch/loongarch/kernel/ptrace.c @@ -193,7 +193,7 @@ static int fpr_set(struct task_struct *target, const void *kbuf, const void __user *ubuf) { const int fcc_start = NUM_FPU_REGS * sizeof(elf_fpreg_t); - const int fcc_end = fcc_start + sizeof(u64); + const int fcsr_start = fcc_start + sizeof(u64); int err; BUG_ON(count % sizeof(elf_fpreg_t)); @@ -209,10 +209,12 @@ static int fpr_set(struct task_struct *target, if (err) return err; - if (count > 0) - err |= user_regset_copyin(&pos, &count, &kbuf, &ubuf, - &target->thread.fpu.fcc, - fcc_start, fcc_end); + err |= user_regset_copyin(&pos, &count, &kbuf, &ubuf, + &target->thread.fpu.fcc, fcc_start, + fcc_start + sizeof(u64)); + err |= user_regset_copyin(&pos, &count, &kbuf, &ubuf, + &target->thread.fpu.fcsr, fcsr_start, + fcsr_start + sizeof(u32)); return err; } -- 2.37.0