Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2034003rdg; Sun, 15 Oct 2023 08:11:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNZQGgmjOY6usr0G4de6fWXnY8MkM6SgpyDg0ICbuT0tpLhJrXgDwR79YHYPpujWdSb7GK X-Received: by 2002:a05:6808:610:b0:3a7:aa1:f883 with SMTP id y16-20020a056808061000b003a70aa1f883mr31478085oih.29.1697382673943; Sun, 15 Oct 2023 08:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697382673; cv=none; d=google.com; s=arc-20160816; b=zak7nQZPkpyeDaDmTCFUGJ2jul1NbCzHr1lqpT4fyciu3WJh/7rO0969S3oX8wfBLj Gk21bbSFsO75mKZmBTGT739FnoivW1nvJEpXSsaFepKWFCuZory3OiYsx0SL0McOsuX8 +P8N/Aw+afDwOBO1XgjJ4NY6jlkLm3meztXRkddtEg9X8+EBYo+FkMa5TkfzAV54ifZE +ZbG/nzUZt2tfqpYD8031R2W3ZAYtq4SWeL2aBbJeXosw+0O16Vtu9gtOsF3rw/F/5gF ow3pFn/Wof6zfQFQhXa8PhcwcGHyJ9MKhin2V+SiED+qx8NPeyqcQXYOLRbeA+8oM0Lo Lh9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/SIkw9UIdG+8DLvulMMvS1f58yonmIZNsKYzNT69uM0=; fh=CPj+yuBbFXQjOZVaSVb9CsCk+t/T5PZwGR+i/Nj1yYo=; b=HoQ0p7/0DY9DmS9eAfATzWwfSjof9liBvpLOggLzvMWOMpgRHnwA9DvW9PRcW4ki4B LWLQ+DgATnsYzO3U2W+jMRmHi79WgKnuyRAZJmESttTKKgMV1hOUeAf2H+XeM5bfpDwa zED5PCTt0cgS0NZ4h7YxfhuWaNAK17MNxvxAV8lcYN3GnDaNBbsJjn5U77pOpaXVlJiX HVbXCglmfmyzmJ2jKXPAsxaPDoTI7jjBvZHV+QKsTpBGzEKMhEAPj1Es/HguGYVWy3rp najogXQiYfg7/ChGqQJrH+CjmSijR1wrMUlqnYULpXDgKsDimFVmMfgtOUQT0fPwaOG0 QeKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O9a7bfLl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id ca32-20020a056a0206a000b005aa0e024d60si7295825pgb.25.2023.10.15.08.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 08:11:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=O9a7bfLl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 922218095DF6; Sun, 15 Oct 2023 08:10:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbjJOPKG (ORCPT + 99 others); Sun, 15 Oct 2023 11:10:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbjJOPKF (ORCPT ); Sun, 15 Oct 2023 11:10:05 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F03DDC1; Sun, 15 Oct 2023 08:10:02 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5F21C433C8; Sun, 15 Oct 2023 15:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697382602; bh=1kAFRzKp03CHX8VTzkP3LzHdDTSohAeq3KRbJ19F8XI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=O9a7bfLlqAOzv4bPpkFMX95llHrA/Wqp7jdP+kRKGX3ZnvTN1wcgUf5ZFtZhCimR+ 9s9ll+q5mcyGa4If3hUatTD/HJCeUdqPnzybQ+v0WPtj/YNadQ8NrlKC9Mkt7GG1U0 SJ4P58fqzXaz9edHqiozVL/xLAxqm5c1aXFRq/Nhl4bGQqQddAQzwmC/hQiLuyRf6C DTGLfge2UopEHyhD9ryondt/Kyp17RdHcT3Rr8/K3fsT05H/vUltCHkSvOxvZS7rzn 61VgbhJxT8uVomRVXwdHVf0fb2ON1SoI3HZo4FeNGYW81ykrJAmnUrfja+AKoXg3Vz kTHjl1UolNDoQ== Date: Sun, 15 Oct 2023 11:09:55 -0400 From: Guo Ren To: Alejandro Colomar Cc: linux-man , linux-kernel , linux-csky@vger.kernel.org, Arnd Bergmann Subject: Re: set_thread_area.2: csky architecture undocumented Message-ID: References: <014e670b-2a11-3deb-4e7e-bfe9defd8597@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sun, 15 Oct 2023 08:10:28 -0700 (PDT) On Sun, Oct 15, 2023 at 01:20:42AM +0200, Alejandro Colomar wrote: > Hi Guo, > > On Tue, Nov 24, 2020 at 08:07:07PM +0800, Guo Ren wrote: > > Huh, 3 years already! I've had this in my head for all this time; just > didn't find the energy to act on it. > > > Thx Michael & Alejandro, > > > > Yes, the man page has no csky's. > > I've applied a patch to add initial documentation for it: > > > > > > C-SKY have abiv1 and abiv2 > > For abiv1: There is no register for tls saving, We use trap 3 to got > > tls and use set_thread_area to init ti->tp_value. > > For abiv2: The r31 is the tls register. We could directly read r31 to > > got r31 and use set_thread_area to init reg->tls value. > > > > In glibc: > > # ifdef __CSKYABIV2__ > > /* Define r31 as thread pointer register. */ > > # define READ_THREAD_POINTER() \ > > mov r0, r31; > > # else > > # define READ_THREAD_POINTER() \ > > trap 3; > > # endif > > > > /* Code to initially initialize the thread pointer. This might need > > special attention since 'errno' is not yet available and if the > > operation can cause a failure 'errno' must not be touched. */ > > # define TLS_INIT_TP(tcbp) \ > > ({ INTERNAL_SYSCALL_DECL (err); \ > > long result_var; \ > > result_var = INTERNAL_SYSCALL (set_thread_area, err, 1, \ > > (char *) (tcbp) + TLS_TCB_OFFSET); \ > > INTERNAL_SYSCALL_ERROR_P (result_var, err) \ > > ? "unknown error" : NULL; }) > > > > In kernel: > > SYSCALL_DEFINE1(set_thread_area, unsigned long, addr) > > { > > struct thread_info *ti = task_thread_info(current); > > struct pt_regs *reg = current_pt_regs(); > > > > reg->tls = addr; > > ti->tp_value = addr; > > > > return 0; > > } > > > > Any comments are welcome :) > > I'm sorry, but I have little understanding of this syscall, and that > shounds like gibberish to me :) > > Feel free to send a patch to improve the documentation for csky. Yeah, I've sent a patch for it; please review: https://lore.kernel.org/linux-csky/20231015150732.1991997-1-guoren@kernel.org/ > > Cheers, > Alex > > > > > > > On Tue, Nov 24, 2020 at 5:51 PM Michael Kerrisk (man-pages) > > wrote: > > > > > > Hi Alex, > > > > > > On 11/23/20 10:31 PM, Alejandro Colomar (man-pages) wrote: > > > > Hi Michael, > > > > > > > > SYNOPSIS > > > > #include > > > > > > > > #if defined __i386__ || defined __x86_64__ > > > > # include > > > > > > > > int get_thread_area(struct user_desc *u_info); > > > > int set_thread_area(struct user_desc *u_info); > > > > > > > > #elif defined __m68k__ > > > > > > > > int get_thread_area(void); > > > > int set_thread_area(unsigned long tp); > > > > > > > > #elif defined __mips__ > > > > > > > > int set_thread_area(unsigned long addr); > > > > > > > > #endif > > > > > > > > Note: There are no glibc wrappers for these system calls; see > > > > NOTES. > > > > > > > > > > > > $ grep -rn 'SYSCALL_DEFINE.*et_thread_area' > > > > arch/csky/kernel/syscall.c:6: > > > > SYSCALL_DEFINE1(set_thread_area, unsigned long, addr) > > > > arch/mips/kernel/syscall.c:86: > > > > SYSCALL_DEFINE1(set_thread_area, unsigned long, addr) > > > > arch/x86/kernel/tls.c:191: > > > > SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, u_info) > > > > arch/x86/kernel/tls.c:243: > > > > SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, u_info) > > > > arch/x86/um/tls_32.c:277: > > > > SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, user_desc) > > > > arch/x86/um/tls_32.c:325: > > > > SYSCALL_DEFINE1(get_thread_area, struct user_desc __user *, user_desc) > > > > > > > > > > > > See kernel commit 4859bfca11c7d63d55175bcd85a75d6cee4b7184 > > > > > > > > > > > > I'd change > > > > - #elif defined __mips__ > > > > + #elif defined(__mips__ || __csky__) > > > > > > > > and then change the rest of the text to add csky when appropriate. > > > > Am I correct? > > > > > > AFAICT, you are correct. I think the reason that csky is missing is > > > that the architecture was added after this manual pages was added. > > > > > > Thanks, > > > > > > Michael > > > > > > > > > -- > > > Michael Kerrisk > > > Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ > > > Linux/UNIX System Programming Training: http://man7.org/training/ > > > > > > > > -- > > Best Regards > > Guo Ren > > > > ML: https://lore.kernel.org/linux-csky/ > > -- >