Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp602991rwr; Wed, 19 Apr 2023 10:26:22 -0700 (PDT) X-Google-Smtp-Source: AKy350b3dhtHKx41rrdaFpqbYKSUNlwJGZj18vG/fDrYKoRqWkgr5vsyBxUKogjxJa1Yb0c4YqQA X-Received: by 2002:a17:902:9b81:b0:1a5:1f13:67fc with SMTP id y1-20020a1709029b8100b001a51f1367fcmr5433163plp.31.1681925181974; Wed, 19 Apr 2023 10:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681925181; cv=none; d=google.com; s=arc-20160816; b=tgouPh+pqKW8tZE8LlmUFdF8OrLgXf09Up+YMAJPdydirHkbPqdpX9jOI9Ze527yZD ZAt6cG+VBmTcXN+NBLPo0kzQZzOF8kuoKJPkBQ9DtQBH2Uc7RAwKGbHnShH/osoSouOB PdquR2A7bt6Lh7A5S0Emx4A6zwe87YDOx4knv4osUW/ccKWtc9b9KhLw4BH+9tpvQ5U2 vH+OYpwNEGEpPTEBvmJSFNkHEPcUXFXUT4AfPT8n3W+v+Ajeqrb9O/nuovQhuKyN03vO m2vxA0x56xfaPw6CDAzaIDEj1G82bHXk5P/Y78NcB8KbqxLYoXXp1bIJ5QQzL9zo6vEj C+YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=wW0prydE6Ccz4rPMQ7mGrs9zyjmeeLoPFYmyULwIemc=; b=wIXMEtTuFhJpARGsiLJm8Kf2O5VBugKebwXZoxrnlEDAwBtUBnFyQ6cEdGK/4EeEP7 sv81lgHP6TyfdOHyZMWAIEx+8z9hzs2Ecwy23ecE41mY6u/+M4C9DUxIGgfBaZk9FoEN oXvTbYVDrSAuSUW/wOux0CMnJPZ86Vv0EXBVksgcYhHnhDPRDhzeJ6YtBrDibvlOJOyb dY191GnljXaNAvAvalIge80jHvTU1lfH9CbPaaqG8Qw2MSvx3D1F/MVeQxFgCYqrDxQo CkCQ9LnwxVuFTCHX/vFGJTDkVHeIJMil5koHOskeKtiy0EjQRmYzuSkt1oX1qLYCmwW1 QqoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=x4QuBhvr; 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 jo13-20020a170903054d00b001a05a78f952si16165336plb.272.2023.04.19.10.26.10; Wed, 19 Apr 2023 10:26:21 -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; dkim=pass header.i=@xen0n.name header.s=mail header.b=x4QuBhvr; 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 S232692AbjDSRYc (ORCPT + 99 others); Wed, 19 Apr 2023 13:24:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232321AbjDSRYa (ORCPT ); Wed, 19 Apr 2023 13:24:30 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F192365B5 for ; Wed, 19 Apr 2023 10:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1681925065; bh=UyddDLaSnHim8LvLfZeMZsuxwKd9NlUs6I+vTPaquA8=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=x4QuBhvrOVumU6lfmBATy7YcNq7Tt4ewJHbz9/HPgMIR6VUWSNmzp8NjZKD+QTkD/ +6G3U0woQCjF0LaMUeejFEfk+8s4aLN18oAOl5tUla9wfOJYvZ2R3pTzjzJArE6rui njab+fTPihLz2H19NWoSu5CX4yep5VFHIzeHSeGI= Received: from [192.168.9.172] (unknown [101.228.138.124]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 3460D6011C; Thu, 20 Apr 2023 01:24:25 +0800 (CST) Message-ID: <48bc7236-638d-9086-daaf-62eacea80dd2@xen0n.name> Date: Thu, 20 Apr 2023 01:24:24 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH 1/2] LoongArch: Add pad structure members for explicit alignment Content-Language: en-US From: WANG Xuerui To: Xi Ruoyao , Qing Zhang , Huacai Chen Cc: Jiaxun Yang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org References: <20230418091348.9239-1-zhangqing@loongson.cn> <899085c1-7a74-8bab-1429-1b6e9e4c2c30@xen0n.name> In-Reply-To: <899085c1-7a74-8bab-1429-1b6e9e4c2c30@xen0n.name> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On 4/19/23 19:00, WANG Xuerui wrote: > On 2023/4/19 18:42, Xi Ruoyao wrote: >> On Tue, 2023-04-18 at 17:13 +0800, Qing Zhang wrote: >>> 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 { > > Drive-by comment to the patch author: there is no "user_lasx_state" > yet. Please always state your base commit if not obvious, or you > should start from some well-known upstream HEAD (e.g. Linus' rc tags, > loongarch-fixes, or loongarch-next). > >>>   }; >>>     struct user_watch_state { >>> -       uint16_t dbg_info; >>> +       uint64_t dbg_info; >> >> Ouch.  This is a breaking change when we consider user code like >> `printf(PRIu16 "\n", ptr->dbg_info);`.  Is it really necessary? > > Ah right. This is UAPI so without *very* concrete and convicing reason > why the change is not going to impact any potential users, it's gonna > be a presumed NAK. In other words you must demonstrate (1) why it's > absolutely necessary to make the change and (2) that it's impossible > to impact anyone, before any such changes can even be considered. Please ignore all of this. The memory layout is actually the same after the change due to the padding, I was somehow thinking in big-endian a few hours ago. (The commit message didn't help either, I think both Ruoyao and me got into the habitual thinking that changes like this are most likely just churn without real benefits, after *not* seeing the rationale in the commit message which was kinda expected.) > >> >>>          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++; >>>          } >> > -- WANG "xen0n" Xuerui Linux/LoongArch mailing list: https://lore.kernel.org/loongarch/