From patchwork Tue Apr 18 09:13:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qing Zhang X-Patchwork-Id: 84713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2709817vqo; Tue, 18 Apr 2023 02:34:52 -0700 (PDT) X-Google-Smtp-Source: AKy350YwrQcL+XF+hB3MpxntbK7LdLgMLBPoeLXVmsYNY3Xfnf78eBmiovW8bcXv2uSbmJOHrmOx X-Received: by 2002:a17:90b:4f47:b0:246:a5d8:cb73 with SMTP id pj7-20020a17090b4f4700b00246a5d8cb73mr1738357pjb.14.1681810492003; Tue, 18 Apr 2023 02:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681810491; cv=none; d=google.com; s=arc-20160816; b=ipI7IMAwh3IRwrFBpsPqwzPtC8s3hxXKqFYa9grsYeUGA/LKkKwoNWEALsFSPB9hyM 47sD0U5Ub6RgM/M/IPWONJdocgC0KWDS6e3MMHjsPVBW5MkWZpWxSPTeZTAf6KWmz1vi 7NDIq0agNALDnhs3PjS6RBiocRqNPxi9WkVZcrOBcSJQHUNVDSBJvRYftf32n1ETHhnN nfZCYEmuOQ7HSszyuFUNXwjuVi7YOzukqnO0mHvJnvHHEUcz3P5evepD+ODOEisVM4NN tYf1aCj9l1pmubGqvmwZ3Z1sK8GxmN5R2x9RknM5GEiX7+TICnjtS5rYFTeF1kcEKrgO hy/w== 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=jrCtVb/dSGvIedafYE0Q5HS205WAaQCtMJgIYTRQf2c=; b=YboieL4Yb74rMrhy+pCLF57UkjLEQ6wqP/GNhDunGZ8Gej8mndIv/NhwQCyu95QIOB a/B8cN010VSFW3cBSywRurDSq0JZjxCNhuAxlJKGsF1rAphmYlW5iX10JmPG51otE+Zd vvFxw3PP8Byj7BmqzQTGeZwZKbFAdXZBYJH/wLtSb7nebHv2wAnHLApXNf6UZsQUXKFM BeUfZOjEW5++Q7EJbthTne6sX9Iq/Qjeb3bPdGBfKaNWUr4m1yQTYV7+kMiPV+wFeZdl 3nlleRwFlNyfhqC7y0Qvmz4o/L1x0kOHo2pxHCJb/IsjWm24O9MleCnk2lWNkYt+rOXm vumA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a17090aba8700b002409afb27ccsi16450827pjr.21.2023.04.18.02.34.36; Tue, 18 Apr 2023 02:34:51 -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 S231147AbjDRJOB (ORCPT + 99 others); Tue, 18 Apr 2023 05:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230189AbjDRJN7 (ORCPT ); Tue, 18 Apr 2023 05:13:59 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 23E4A59FE for ; Tue, 18 Apr 2023 02:13:53 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxedlQXz5kxWAeAA--.47516S3; Tue, 18 Apr 2023 17:13:52 +0800 (CST) Received: from localhost.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxGL1QXz5k5qosAA--.51153S2; Tue, 18 Apr 2023 17:13:52 +0800 (CST) From: Qing Zhang To: Huacai Chen , WANG Xuerui Cc: Jiaxun Yang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] LoongArch: Add pad structure members for explicit alignment Date: Tue, 18 Apr 2023 17:13:48 +0800 Message-Id: <20230418091348.9239-1-zhangqing@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8AxGL1QXz5k5qosAA--.51153S2 X-CM-SenderInfo: x2kd0wptlqwqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvJXoW7CrW7AF4fCF13Gry8Kr15Jwb_yoW8KFyfpr ZrAwnrKF4UKFyfGFs5tr4DZrn8J3s2kryI9as3Ca4SyF9IqryUXry8GryqyF43K3y0qFyS qFyakrWYva1DXwUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b7AYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_JrI_Jryl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWUCVW8JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l e2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27wAqx4xG64xvF2 IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JrI_JrylYx0Ex4A2jsIE14v26r1j6r4U McvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2 IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v2 6r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67 AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IY s7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr 0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU1EksDUUUUU== 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763506118848905978?= X-GMAIL-MSGID: =?utf-8?q?1763506118848905978?= This is done in order to easily calculate the number of breakpoints in hw_break_get. Signed-off-by: Qing Zhang --- arch/loongarch/include/uapi/asm/ptrace.h | 3 ++- arch/loongarch/kernel/ptrace.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/loongarch/include/uapi/asm/ptrace.h b/arch/loongarch/include/uapi/asm/ptrace.h index 2282ae1fd3b6..06e3be52cb04 100644 --- a/arch/loongarch/include/uapi/asm/ptrace.h +++ b/arch/loongarch/include/uapi/asm/ptrace.h @@ -57,11 +57,12 @@ struct user_lasx_state { }; struct user_watch_state { - uint16_t dbg_info; + uint64_t dbg_info; struct { uint64_t addr; uint64_t mask; uint32_t ctrl; + uint32_t pad; } dbg_regs[8]; }; diff --git a/arch/loongarch/kernel/ptrace.c b/arch/loongarch/kernel/ptrace.c index 0c7c41e41cad..9c3bc1bbf2ff 100644 --- a/arch/loongarch/kernel/ptrace.c +++ b/arch/loongarch/kernel/ptrace.c @@ -475,10 +475,10 @@ static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type, return 0; } -static int ptrace_hbp_get_resource_info(unsigned int note_type, u16 *info) +static int ptrace_hbp_get_resource_info(unsigned int note_type, u64 *info) { u8 num; - u16 reg = 0; + u64 reg = 0; switch (note_type) { case NT_LOONGARCH_HW_BREAK: @@ -616,7 +616,7 @@ static int hw_break_get(struct task_struct *target, const struct user_regset *regset, struct membuf to) { - u16 info; + u64 info; u32 ctrl; u64 addr, mask; int ret, idx = 0; @@ -646,6 +646,7 @@ static int hw_break_get(struct task_struct *target, membuf_store(&to, addr); membuf_store(&to, mask); membuf_store(&to, ctrl); + membuf_zero(&to, sizeof(u32)); idx++; } @@ -662,7 +663,7 @@ static int hw_break_set(struct task_struct *target, int ret, idx = 0, offset, limit; unsigned int note_type = regset->core_note_type; - /* Resource info */ + /* Resource info and pad */ offset = offsetof(struct user_watch_state, dbg_regs); user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, 0, offset); @@ -704,6 +705,10 @@ static int hw_break_set(struct task_struct *target, if (ret) return ret; offset += PTRACE_HBP_CTRL_SZ; + + user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, + offset, offset + PTRACE_HBP_PAD_SZ); + offset += PTRACE_HBP_PAD_SZ; idx++; } From patchwork Tue Apr 18 09:14:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qing Zhang X-Patchwork-Id: 84712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2709815vqo; Tue, 18 Apr 2023 02:34:52 -0700 (PDT) X-Google-Smtp-Source: AKy350b1V+x03aLEqV4e4wu+KmQ72dXCzIj9K9veUoAeYvksfVhmZSp0F5jn+Ma/v6NuQ1uXIpXX X-Received: by 2002:a05:6a20:244c:b0:ef:bd:3b with SMTP id t12-20020a056a20244c00b000ef00bd003bmr10965732pzc.55.1681810492004; Tue, 18 Apr 2023 02:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681810491; cv=none; d=google.com; s=arc-20160816; b=QgJjCSt4L9ws0IEjtFU1q8GFq96Pa64bKm8h9/JwfdEnxgu4vOB3W95ibVaa5g1FqF xwIWk0OIafo808gwZFzT/PHe7Y70lu/tMnDzfxgrZdibFIVUJSTFlpi8W44lm+vmkTRZ FvosxpmmL4zAksCwJEEsUr0ykpOHbnSNBnoCA+qVptzK/ozDcaPb7WU2Mh46E31STBe7 JHCm3vcP688bVQOpLaN8iHp0LfcRNMPAd4s+nJ9qP6mtxUESQEgdCif5KFGBchXfI2HN IbqL3eh/91Qg2wkWB6U7U2i0PXjSPLYVYvHHm+eYc1XZbjcEG1M9uf1X/kIRNY8t/ooG fihQ== 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=59sm/yEZUVcQzn2E0YlASs9rU9ZIYf4HLRgbyEG3Z64=; b=ZSgYlz1+L7kbmoqpEZoXZEdQb9S8ypzhAvTzbvDKk4EuO7iK7CDZLKTn6fQVSS7AAQ mFqQcr7aes7+i/vVjm80ZbmJq7eSmxGUAm1OBG0oCLztSPwU1V3mtGLXLhN7I/ucHwp0 GfMMVr6St/NakU4VWZb2Ti3xJaIC5/EUlaarFiP8QpCFPS7Zw9TXe6ukgThVBJa2z1gI QrQZLR6eJhRgstWKofTa3bbRrBdjvjLE359rm8ilwBoJhQxlTc/xRptlj8m4JWy0KzdI dESswIxbChcnuGB7DTBBE3IwxkH1s9pkbRUxLR0r20cgqk6OJWjD56hSDzrvFzqOrzHL e03w== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x23-20020aa79577000000b0063b356e36fesi484443pfq.372.2023.04.18.02.34.36; Tue, 18 Apr 2023 02:34:51 -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 S230519AbjDRJON (ORCPT + 99 others); Tue, 18 Apr 2023 05:14:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230189AbjDRJOL (ORCPT ); Tue, 18 Apr 2023 05:14:11 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AC13244BE for ; Tue, 18 Apr 2023 02:14:09 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxPNpgXz5k3WAeAA--.36030S3; Tue, 18 Apr 2023 17:14:08 +0800 (CST) Received: from localhost.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxGL1fXz5k_aosAA--.51154S2; Tue, 18 Apr 2023 17:14:07 +0800 (CST) From: Qing Zhang To: Huacai Chen , WANG Xuerui Cc: Jiaxun Yang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] LoongArch: Adjust the user_regset_copyin parameter to the correct offset Date: Tue, 18 Apr 2023 17:14:06 +0800 Message-Id: <20230418091406.9286-1-zhangqing@loongson.cn> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8AxGL1fXz5k_aosAA--.51154S2 X-CM-SenderInfo: x2kd0wptlqwqxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvdXoWrKw4xGw4fAF4DXr1kXF43KFg_yoWDurX_W3 WSvw1DKr98Wa15uwnxGw15Jr12qa1SqFWSva9FyFW2qryDGw15tr4xG3WDCrZ09F4fuF45 Aa9YgFZxAr4ayjkaLaAFLSUrUUUU1b8apTn2vfkv8UJUUUU8wcxFpf9Il3svdxBIdaVrn0 xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3UjIYCTnIWjp_UUUY g7kC6x804xWl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0rVWrJVCq3w AFIxvE14AKwVWUXVWUAwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK 6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j6F4UM28EF7 xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJwAa w2AFwI0_Jrv_JF1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44 I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jw0_WrylYx0Ex4A2 jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20x vY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km07C267AKxVWUXVWUAwC20s02 6c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF 0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvE c7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14 v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7I U89qXPUUUUU== 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763506118759559116?= X-GMAIL-MSGID: =?utf-8?q?1763506118759559116?= Ensure that user_watch_state can be set correctly by the user. Signed-off-by: Qing Zhang --- arch/loongarch/kernel/ptrace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/loongarch/kernel/ptrace.c b/arch/loongarch/kernel/ptrace.c index 9c3bc1bbf2ff..f5bd7b1430ae 100644 --- a/arch/loongarch/kernel/ptrace.c +++ b/arch/loongarch/kernel/ptrace.c @@ -687,7 +687,7 @@ static int hw_break_set(struct task_struct *target, break; ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &mask, - offset, offset + PTRACE_HBP_ADDR_SZ); + offset, offset + PTRACE_HBP_MASK_SZ); if (ret) return ret; @@ -696,8 +696,8 @@ static int hw_break_set(struct task_struct *target, return ret; offset += PTRACE_HBP_MASK_SZ; - ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &mask, - offset, offset + PTRACE_HBP_MASK_SZ); + ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ctrl, + offset, offset + PTRACE_HBP_CTRL_SZ); if (ret) return ret;