From: Xi Ruoyao <xry111@xry111.site>
To: Tiezhu Yang <yangtiezhu@loongson.cn>,
Huacai Chen <chenhuacai@kernel.org>
Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] LoongArch: Extend the maximum number of watchpoints
Date: Thu, 23 Jan 2025 22:04:28 +0800 [thread overview]
Message-ID: <ade86769d44670a1cb91842bb6d5d60f4a25f5d2.camel@xry111.site> (raw)
In-Reply-To: <20250122032310.26729-3-yangtiezhu@loongson.cn>
On Wed, 2025-01-22 at 11:23 +0800, Tiezhu Yang wrote:
> The maximum number of load/store watchpoints and fetch instruction
> watchpoints is 14 each according to LoongArch Reference Manual, so
> extend the maximum number of watchpoints from 8 to 14 for ptrace.
>
> By the way, just simply change 8 to 14 for the definition in struct
> user_watch_state at the beginning, but it may corrupt uapi, then add
> a new struct user_watch_state_v2 directly.
>
> As far as I can tell, the only users for this struct in the userspace
> are GDB and LLDB, there are no any problems of software compatibility
> between the application and kernel according to the analysis.
>
> The compatibility problem has been considered when developing and testing
> the patches, when the applications in the userspace get watchpoint state,
> the length will be specified which will not bigger than the sizeof struct
> user_watch_state or user_watch_state_v2, the actual length is assigned as
> the minimal value of the application and kernel in the generic ptrace:
>
> kernel/ptrace.c: ptrace_regset():
>
> kiov->iov_len = min(kiov->iov_len,
> (__kernel_size_t) (regset->n * regset->size));
>
> if (req == PTRACE_GETREGSET)
> return copy_regset_to_user(task, view, regset_no, 0,
> kiov->iov_len, kiov->iov_base);
> else
> return copy_regset_from_user(task, view, regset_no, 0,
> kiov->iov_len, kiov->iov_base);
>
> For example, there are four kind of combinations, all of them work well.
>
> (1) "older kernel + older gdb", the actual length is 8+(8+8+4+4)*8=200;
> (2) "newer kernel + newer gdb", the actual length is 8+(8+8+4+4)*14=344;
> (3) "older kernel + newer gdb", the actual length is 8+(8+8+4+4)*8=200;
> (4) "newer kernel + older gdb", the actual length is 8+(8+8+4+4)*8=200.
OK, I think it has cleared my doubts.
Reviewed-by: Xi Ruoyao <xry111@xry111.site>
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
next prev parent reply other threads:[~2025-01-23 14:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-22 3:23 [PATCH v2 0/2] LoongArch: Change " Tiezhu Yang
2025-01-22 3:23 ` [PATCH v2 1/2] LoongArch: Change 8 to 14 for LOONGARCH_MAX_{BRP,WRP} Tiezhu Yang
2025-01-24 16:11 ` WANG Xuerui
2025-01-22 3:23 ` [PATCH v2 2/2] LoongArch: Extend the maximum number of watchpoints Tiezhu Yang
2025-01-23 14:04 ` Xi Ruoyao [this message]
2025-01-24 16:10 ` WANG Xuerui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ade86769d44670a1cb91842bb6d5d60f4a25f5d2.camel@xry111.site \
--to=xry111@xry111.site \
--cc=chenhuacai@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=yangtiezhu@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®