Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1584644pxu; Tue, 24 Nov 2020 04:11:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvgCGzPLdDW6CFgYk1eV4zQ3UUG12YvtHi8GaCxZm7anQwrSBGIKETXQroRQTzFdA1hkCI X-Received: by 2002:a17:906:af8c:: with SMTP id mj12mr3757502ejb.85.1606219899332; Tue, 24 Nov 2020 04:11:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606219899; cv=none; d=google.com; s=arc-20160816; b=FaqwGFCrqfNxQj416jPEgxwZOvy1/zpO9mzDA2Cy0fBct6+9FtuFi33d9O3rpjHop5 sfXwaVcuui0WpWzTHek4Dt2dxwCY7xxx0W+BW5uWyjtpwOraRVPy9s4XWQYyeee1TTA1 iKCv9zFy+SkHi8yq+dnxF9/7qZr3NZeUFUK5gAFlLFyVItneDocbpMMc3aTXP5W7QBVa oSiZJbWhKLPjUx01fuf7SFdUft2WSEO02Hz9Qb8qHN3EXt3RxT3ClMHUESmDbJzmwSFl d5NiRMHRsKIFdjrpOnpZ8bXk5SXHcO8/atGnSyFggpzimx3V5v52O3waNNtGxQGQZdSQ 3xfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=gJLQkuOR7iaZZXCv8X/Ajy4jbykiUDaaoY0dwcl4tjQ=; b=GUMmHF/7mbC3Sf5ReIxaNmJvSPqdmwoCDnyq1KyP4K8SJjSZbeW6kJI4amuU+PRYCR sGHOP3jn2zl/HfyasjS0Hd5Kp4RbP7tBmGuaLOpMaETd/KT/uX/7CpP3ZvIH1ufKkqCw cgEbDWPz7SdPOfnCrdt5QMxpigiFOWTIA/CaeK6J4LaltC4n5eY3ici0//1p8eLx2+4W 64e0pCTx5upuZmZgk4ILvgMIjTgh+tTI2MFaPH/RwWGqi+bBl/53LF1LxhCjEz564Nla X/5q0NXChsXCT+4t+tkDvvc3UbN6TqRCQNPQVDMOxXMCjgy71BxHLeSuYSFZy0Oa8tvU 2zQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cRZrmG9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c21si3137870edw.37.2020.11.24.04.11.14; Tue, 24 Nov 2020 04:11:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cRZrmG9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733187AbgKXMHW (ORCPT + 99 others); Tue, 24 Nov 2020 07:07:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:47858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729172AbgKXMHW (ORCPT ); Tue, 24 Nov 2020 07:07:22 -0500 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E65882083E; Tue, 24 Nov 2020 12:07:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606219641; bh=rx8W+sC4G+tM3j+KvfVJeDHAi7n5iz4DUaSf+4YMG0E=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cRZrmG9JK1S4GuqvmQ1WSh/UGHPZMfb+MiTwGgeah95ugW08GPN7A8GFjSPe+ys4h PZEErrpd1b/F0kztnopn3hViNX9INXaABPOgzab3C1bXOIa6OeEXx0m3d8wXX10xRp em6SIOzF7bDSMrQKIxrT5dHuKO21TsXC8qo93hzM= Received: by mail-lf1-f54.google.com with SMTP id t6so12393046lfl.13; Tue, 24 Nov 2020 04:07:20 -0800 (PST) X-Gm-Message-State: AOAM531Dm10CyIR0fbufVUDdzv27E9Ld2El6l99cXq3gn9BjEmb0DL3H F8y2JJQnz9qRdU5JWpzqpknz784/r52KVOKrSow= X-Received: by 2002:a19:fc0f:: with SMTP id a15mr1551270lfi.248.1606219639088; Tue, 24 Nov 2020 04:07:19 -0800 (PST) MIME-Version: 1.0 References: <014e670b-2a11-3deb-4e7e-bfe9defd8597@gmail.com> In-Reply-To: From: Guo Ren Date: Tue, 24 Nov 2020 20:07:07 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: set_thread_area.2: csky architecture undocumented To: "Michael Kerrisk (man-pages)" Cc: "Alejandro Colomar (man-pages)" , linux-man , linux-kernel , linux-csky@vger.kernel.org, Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thx Michael & Alejandro, Yes, the man page has no csky's. 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 :) 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/