From patchwork Sat Jan 4 12:39:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amanieu d'Antras X-Patchwork-Id: 234447 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5ACFC2D0C2 for ; Sat, 4 Jan 2020 13:03:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 69C4C22B48 for ; Sat, 4 Jan 2020 13:03:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZqwHItTa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725827AbgADNDR (ORCPT ); Sat, 4 Jan 2020 08:03:17 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39564 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgADNDR (ORCPT ); Sat, 4 Jan 2020 08:03:17 -0500 Received: by mail-wr1-f66.google.com with SMTP id y11so44817680wrt.6; Sat, 04 Jan 2020 05:03:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jx4SLI4Z9KLYRUbb1SFG68L+fEF+yXR27NZhSzKFTk8=; b=ZqwHItTaGb0+q64wIW1e3ynchu1RaPOBaFfyODjRFgo212r8rS7eNTGLlQZQK7/q/w iIitPsM1OvU1G92EM+fd/ZSnHDBKZbjnF4raLjZZKrOlHULUgoPeA3Ak+10c8oAqrLyC nYzAIZpz7nyADyNpkJIv/X4dFccPwc8vKURED2IQdW0MOy9QMGTYfjzj15pEg8EcmGMU I+icVnKNsLMlAnFJa1LHU871ZtH5l0R/ZeFTsWKApE5CJnPAfmcgQBqnzmQZDjX9bQuh GZIr3COROkNjPyjaeaY9BK+bzPcG5qNUYK68sZ8Da75at8bRvleqbvQdFbDLyitAAbZU dbwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jx4SLI4Z9KLYRUbb1SFG68L+fEF+yXR27NZhSzKFTk8=; b=JJJnTydomsJFKZlARco1HDMd7dqMpG6wNQC29SHK2HOheaDbN0nUESRNi6CUzB5PYS KlhYNSkO2BNqnK1+TyB4z+WYIOUQDIOwhUf68ZqMAJ9pJn/6D/8FRvPgvCw+AneWza60 ZqcMXXtClW1Qup1/P6crqyG9bTPuBqIjPMP1+v4LulE66785DvkT3Mb9D1VnhlcBhyVQ 07Fa3ItLeobBQnCDrpRWLMDG/gw3wsgUb1a5W++daReMTl3dNQ0ZkHp3f7kATNgqSk1G fGcdCCb+EXCtfhnUVccyYJM7aNNBzksRlB0w1ZJp1U4Hghl9mYrbbH8LB0zR6i7VUVO3 l2eA== X-Gm-Message-State: APjAAAWUQsdaD8LDgdqljPO5CCrXSA5iKQY+NhtefCk0mRtMZIeIF71x ue8xJecsMf9UzgNefWrXVOtJna3KuhuE3g== X-Google-Smtp-Source: APXvYqzW5AW8mbrFYj0jm5McWGPTxMYPtwOzhTfncOAiDksqp2LtR6eyWR6PaW6sANsNC/oG0vkaQg== X-Received: by 2002:a5d:6350:: with SMTP id b16mr94761787wrw.132.1578142995287; Sat, 04 Jan 2020 05:03:15 -0800 (PST) Received: from amanieu-laptop.home ([2a01:cb19:8051:6200:3fe7:84:7f3:e713]) by smtp.gmail.com with ESMTPSA id z83sm15911096wmg.2.2020.01.04.05.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jan 2020 05:03:14 -0800 (PST) From: Amanieu d'Antras To: linux-kernel@vger.kernel.org Cc: Christian Brauner , Amanieu d'Antras , linux-um@lists.infradead.org, stable@vger.kernel.org Subject: [PATCH] um: Implement copy_thread_tls Date: Sat, 4 Jan 2020 13:39:30 +0100 Message-Id: <20200104123928.1048822-1-amanieu@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102172413.654385-1-amanieu@gmail.com> References: <20200102172413.654385-1-amanieu@gmail.com> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This is required for clone3 which passes the TLS value through a struct rather than a register. Signed-off-by: Amanieu d'Antras Cc: linux-um@lists.infradead.org Cc: # 5.3.x --- arch/um/Kconfig | 1 + arch/um/include/asm/ptrace-generic.h | 2 +- arch/um/kernel/process.c | 6 +++--- arch/x86/um/tls_32.c | 6 ++---- arch/x86/um/tls_64.c | 7 +++---- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/arch/um/Kconfig b/arch/um/Kconfig index 2a6d04fcb3e9..6f0edd0c0220 100644 --- a/arch/um/Kconfig +++ b/arch/um/Kconfig @@ -14,6 +14,7 @@ config UML select HAVE_FUTEX_CMPXCHG if FUTEX select HAVE_DEBUG_KMEMLEAK select HAVE_DEBUG_BUGVERBOSE + select HAVE_COPY_THREAD_TLS select GENERIC_IRQ_SHOW select GENERIC_CPU_DEVICES select GENERIC_CLOCKEVENTS diff --git a/arch/um/include/asm/ptrace-generic.h b/arch/um/include/asm/ptrace-generic.h index 81c647ef9c6c..adf91ef553ae 100644 --- a/arch/um/include/asm/ptrace-generic.h +++ b/arch/um/include/asm/ptrace-generic.h @@ -36,7 +36,7 @@ extern long subarch_ptrace(struct task_struct *child, long request, extern unsigned long getreg(struct task_struct *child, int regno); extern int putreg(struct task_struct *child, int regno, unsigned long value); -extern int arch_copy_tls(struct task_struct *new); +extern int arch_set_tls(struct task_struct *new, unsigned long tls); extern void clear_flushed_tls(struct task_struct *task); extern int syscall_trace_enter(struct pt_regs *regs); extern void syscall_trace_leave(struct pt_regs *regs); diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index 263a8f069133..17045e7211bf 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c @@ -153,8 +153,8 @@ void fork_handler(void) userspace(¤t->thread.regs.regs, current_thread_info()->aux_fp_regs); } -int copy_thread(unsigned long clone_flags, unsigned long sp, - unsigned long arg, struct task_struct * p) +int copy_thread_tls(unsigned long clone_flags, unsigned long sp, + unsigned long arg, struct task_struct * p, unsigned long tls) { void (*handler)(void); int kthread = current->flags & PF_KTHREAD; @@ -188,7 +188,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp, * Set a new TLS for the child thread? */ if (clone_flags & CLONE_SETTLS) - ret = arch_copy_tls(p); + ret = arch_set_tls(p, tls); } return ret; diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c index 5bd949da7a4a..ac8eee093f9c 100644 --- a/arch/x86/um/tls_32.c +++ b/arch/x86/um/tls_32.c @@ -215,14 +215,12 @@ static int set_tls_entry(struct task_struct* task, struct user_desc *info, return 0; } -int arch_copy_tls(struct task_struct *new) +int arch_set_tls(struct task_struct *new, unsigned long tls) { struct user_desc info; int idx, ret = -EFAULT; - if (copy_from_user(&info, - (void __user *) UPT_SI(&new->thread.regs.regs), - sizeof(info))) + if (copy_from_user(&info, (void __user *) tls, sizeof(info))) goto out; ret = -EINVAL; diff --git a/arch/x86/um/tls_64.c b/arch/x86/um/tls_64.c index 3a621e0d3925..ebd3855d9b13 100644 --- a/arch/x86/um/tls_64.c +++ b/arch/x86/um/tls_64.c @@ -6,14 +6,13 @@ void clear_flushed_tls(struct task_struct *task) { } -int arch_copy_tls(struct task_struct *t) +int arch_set_tls(struct task_struct *t, unsigned long tls) { /* * If CLONE_SETTLS is set, we need to save the thread id - * (which is argument 5, child_tid, of clone) so it can be set - * during context switches. + * so it can be set during context switches. */ - t->thread.arch.fs = t->thread.regs.regs.gp[R8 / sizeof(long)]; + t->thread.arch.fs = tls; return 0; } From patchwork Thu Jan 2 17:24:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amanieu d'Antras X-Patchwork-Id: 234816 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DD9EC3276D for ; Thu, 2 Jan 2020 17:24:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5015D227BF for ; Thu, 2 Jan 2020 17:24:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="t7xqOm6O" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727877AbgABRYX (ORCPT ); Thu, 2 Jan 2020 12:24:23 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:42307 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727692AbgABRYU (ORCPT ); Thu, 2 Jan 2020 12:24:20 -0500 Received: by mail-wr1-f65.google.com with SMTP id q6so39885991wro.9; Thu, 02 Jan 2020 09:24:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iynuWkDBVTaiEzHNP7sxuTkwJnSTns6zopxJWRhFfwM=; b=t7xqOm6OFo39bFTfx2QgOe5P+nWEAEOUff1YJ0pwLEf6Fv1AZqBvjPowdPWbEO6KoE Z/9uqLpZ0LzZIHVqJdI3giZkl0gpTCdkocT04PmvIu3PBgyLagUCnjv8kczWyoppCDIb c+NcxYZMBC+gUNbOk83IsiTHaC/tQCl5z1POP8n+zKVYYQhHZMeRKB9wA0qZH/BOmGuO 6f/ycMdHuWvmwKljtf3dL3ThfirhWgPclMEjQIVSrR/x+EB+tMFBtxl8HMCyBqFzMh3m qIMRPCxHGm/bcYwCdocfZnXu1WaNpkCBc0ZTiDueiQ4IL3xgm0F28WsImiKxy6Bappvr O7gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iynuWkDBVTaiEzHNP7sxuTkwJnSTns6zopxJWRhFfwM=; b=idwZSWrxhbUNDzNF+WsR46ElZHzBSrFJ+E27qM29DPnWqjOyGG7kWWK8r5c76XF4i1 FBhdJvL94cIkzTejVqau0xmSh7TgughoPXfbzj2AqFPjpGnNnVVgvndKKV4fzPX/Tl/E IEbK3SMxnS9JUJnmfoH/WUFVVEY/fqIKd5XbQkCC+0UoS6hIUYJ51xJQG7ebxb/NzehJ hewBxYr9FsLT1qEdfuEnmmEFWl1B/0D4AL8EZ8s9vUCl0x4DsEr5dH/42IRFdhajiXQK BE6U93c5ezaZ+umed7V+LhhvTmPL4DoBoDn9WNUTrzf/9NxCqb/RybXX6FrOGJmiILLy gghw== X-Gm-Message-State: APjAAAUBFKfgjAB3eFl7JaeRzEBVJGLj5BUvXVz62q2gaO1fZDWgUW8Y VGQhTVspjSDqojGk7+1MVDrRf2c8uTE3xp6W X-Google-Smtp-Source: APXvYqyGvFmZbRqFUgjsGsKZXKYs8CPJrTsut+rS8ZrZ5qhYlWYH9pC/PaHj2Q9P1tF2BhjHeQQ/qg== X-Received: by 2002:adf:f484:: with SMTP id l4mr83117692wro.207.1577985858109; Thu, 02 Jan 2020 09:24:18 -0800 (PST) Received: from amanieu-laptop.home ([2a01:cb19:8051:6200:3fe7:84:7f3:e713]) by smtp.gmail.com with ESMTPSA id z21sm9480328wml.5.2020.01.02.09.24.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2020 09:24:17 -0800 (PST) From: Amanieu d'Antras To: linux-kernel@vger.kernel.org Cc: Christian Brauner , stable@vger.kernel.org, Amanieu d'Antras , linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/7] arm64: Implement copy_thread_tls Date: Thu, 2 Jan 2020 18:24:08 +0100 Message-Id: <20200102172413.654385-3-amanieu@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102172413.654385-1-amanieu@gmail.com> References: <20200102172413.654385-1-amanieu@gmail.com> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This is required for clone3 which passes the TLS value through a struct rather than a register. Signed-off-by: Amanieu d'Antras Cc: linux-arm-kernel@lists.infradead.org Cc: # 5.3.x --- arch/arm64/Kconfig | 1 + arch/arm64/kernel/process.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b1b4476ddb83..e688dfad0b72 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -138,6 +138,7 @@ config ARM64 select HAVE_CMPXCHG_DOUBLE select HAVE_CMPXCHG_LOCAL select HAVE_CONTEXT_TRACKING + select HAVE_COPY_THREAD_TLS select HAVE_DEBUG_BUGVERBOSE select HAVE_DEBUG_KMEMLEAK select HAVE_DMA_CONTIGUOUS diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 71f788cd2b18..d54586d5b031 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -360,8 +360,8 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) asmlinkage void ret_from_fork(void) asm("ret_from_fork"); -int copy_thread(unsigned long clone_flags, unsigned long stack_start, - unsigned long stk_sz, struct task_struct *p) +int copy_thread_tls(unsigned long clone_flags, unsigned long stack_start, + unsigned long stk_sz, struct task_struct *p, unsigned long tls) { struct pt_regs *childregs = task_pt_regs(p); @@ -394,11 +394,11 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start, } /* - * If a TLS pointer was passed to clone (4th argument), use it - * for the new thread. + * If a TLS pointer was passed to clone, use it for the new + * thread. */ if (clone_flags & CLONE_SETTLS) - p->thread.uw.tp_value = childregs->regs[3]; + p->thread.uw.tp_value = tls; } else { memset(childregs, 0, sizeof(struct pt_regs)); childregs->pstate = PSR_MODE_EL1h; From patchwork Thu Jan 2 17:24:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amanieu d'Antras X-Patchwork-Id: 234814 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74A2BC3276C for ; Thu, 2 Jan 2020 17:24:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4727B21734 for ; Thu, 2 Jan 2020 17:24:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SwCZtPUy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727873AbgABRYW (ORCPT ); Thu, 2 Jan 2020 12:24:22 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43456 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726125AbgABRYU (ORCPT ); Thu, 2 Jan 2020 12:24:20 -0500 Received: by mail-wr1-f67.google.com with SMTP id d16so39945812wre.10; Thu, 02 Jan 2020 09:24:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wNOM5YVf4Ad6YkKqspKwGYhIR/Pz9al6tY5IJ5pfrD0=; b=SwCZtPUy7OtzJgJcz1GAVpSUiK2Wku5rYGazNe18hkD4mO3uO37I3VyKCT3uxlHNGQ qdExGA/rdyWzZuoQP3xspFWs9ZU2TgiZWUHHojawnIyZPLN7pBWOc+UauRYSVJ7d080c ZB+lQ/cSGWPV9wTJDCCg31/w6f02/DWXGF6NlKCGyyLILak+d+AWig7jZvvxj6QFQwkI g5gJe/SlzOoKR7nVtsuLhpbeWfFd5+bL/16aiF2HkPcAhvVGyPkW5e8Z94ZbTuJgogIW /8770zeWkHXy9I9tENFedyoDEyP6G9mGJgGonax3W7gJ+I1nK8u4GygsoM0A55D8mHKk C1eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wNOM5YVf4Ad6YkKqspKwGYhIR/Pz9al6tY5IJ5pfrD0=; b=EMrVwIt2GxRn74ILAYDbuyX3EMZxOI4FbhlkWUeurpyWITrRN63FgJBJSQ++aqYiYp psvsarkabCTHqb+XdfyPukzViMZwy409drbarKBLgAjy/VaxVl5G0WzrmWSvSwGt1vd4 ibmPbu6jgMu4xltf85PShufhVwQ3XWMAZXLYC8NqNtNapRdUmtNAlbXRe8+RQML7mnA7 +KWLc7KVCgIMzV3aevQc8qhyUijCzyvGBGMTbFZ6GtGHvgQS0wQDabkZzO+Putnpmtut tmob7BaHrRBCqVUv50wPCA5YDMk+YdH4/Qk1dmlH0ODRbOV0Iw3nfKoY0kgW9yW7Ur/G q70A== X-Gm-Message-State: APjAAAWYI6OSUBwOXK6V1izrlPm9PowxXTonO6zVJFx5wZTgWKBtvNOf 8dz7lSDuj/bUrmShZ5d22AZ3IP5vCb8Zh64n X-Google-Smtp-Source: APXvYqzgd13vw55RXc1eoKXj4u9D5u6lDd1qVd/FLD5j6iUamc1uycDFuWu9VEWu7ed++1noj0mNVQ== X-Received: by 2002:adf:f091:: with SMTP id n17mr85594064wro.387.1577985858946; Thu, 02 Jan 2020 09:24:18 -0800 (PST) Received: from amanieu-laptop.home ([2a01:cb19:8051:6200:3fe7:84:7f3:e713]) by smtp.gmail.com with ESMTPSA id z21sm9480328wml.5.2020.01.02.09.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2020 09:24:18 -0800 (PST) From: Amanieu d'Antras To: linux-kernel@vger.kernel.org Cc: Christian Brauner , stable@vger.kernel.org, Amanieu d'Antras , linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/7] arm: Implement copy_thread_tls Date: Thu, 2 Jan 2020 18:24:09 +0100 Message-Id: <20200102172413.654385-4-amanieu@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102172413.654385-1-amanieu@gmail.com> References: <20200102172413.654385-1-amanieu@gmail.com> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This is required for clone3 which passes the TLS value through a struct rather than a register. Signed-off-by: Amanieu d'Antras Cc: linux-arm-kernel@lists.infradead.org Cc: # 5.3.x --- arch/arm/Kconfig | 1 + arch/arm/kernel/process.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index ba75e3661a41..96dab76da3b3 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -72,6 +72,7 @@ config ARM select HAVE_ARM_SMCCC if CPU_V7 select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32 select HAVE_CONTEXT_TRACKING + select HAVE_COPY_THREAD_TLS select HAVE_C_RECORDMCOUNT select HAVE_DEBUG_KMEMLEAK select HAVE_DMA_CONTIGUOUS if MMU diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index cea1c27c29cb..46e478fb5ea2 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -226,8 +226,8 @@ void release_thread(struct task_struct *dead_task) asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); int -copy_thread(unsigned long clone_flags, unsigned long stack_start, - unsigned long stk_sz, struct task_struct *p) +copy_thread_tls(unsigned long clone_flags, unsigned long stack_start, + unsigned long stk_sz, struct task_struct *p, unsigned long tls) { struct thread_info *thread = task_thread_info(p); struct pt_regs *childregs = task_pt_regs(p); @@ -261,7 +261,7 @@ copy_thread(unsigned long clone_flags, unsigned long stack_start, clear_ptrace_hw_breakpoint(p); if (clone_flags & CLONE_SETTLS) - thread->tp_value[0] = childregs->ARM_r3; + thread->tp_value[0] = tls; thread->tp_value[1] = get_tpuser(); thread_notify(THREAD_NOTIFY_COPY, thread); From patchwork Thu Jan 2 17:24:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amanieu d'Antras X-Patchwork-Id: 234815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40C56C2D0DC for ; Thu, 2 Jan 2020 17:24:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0EFC921734 for ; Thu, 2 Jan 2020 17:24:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eknhSys+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727962AbgABRYe (ORCPT ); Thu, 2 Jan 2020 12:24:34 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:53364 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727859AbgABRYX (ORCPT ); Thu, 2 Jan 2020 12:24:23 -0500 Received: by mail-wm1-f65.google.com with SMTP id m24so6194626wmc.3; Thu, 02 Jan 2020 09:24:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nhEROhYvxQBpHG5tza2RMbb/t8HVyPfGN5knOZoumCE=; b=eknhSys+rc63QT2i9bwpakpxMChXuthSC86wntebhDjo69A4H0UfbC0yOzBpSL0mHx MzuY7eWJeovQ65PLjYUk+CDjXzlJ3ImpOBULYzHOhZsYriuhakcrf8SyuJBUFh6y/3Hq VWVwO/ATOi94iP5KoHKW2faAlxyArNiGP50VuGYBBtZTsmHx1sortGoCpsvBl6NZjYkf XX+z0vs0XF+9u/WL9yhTf6DG1T/MwTpu1jnkz2AQQofREbruYuzfaII/ZWrhJXPTWHgN 2usCqVM/+wSjv6gB/LlC4HWHlX9zV9RjLTjeCzEoceTtOZRNmcBvIEKmrmXp1slsftIR 3hZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nhEROhYvxQBpHG5tza2RMbb/t8HVyPfGN5knOZoumCE=; b=VxD4PKco2qQHwUhnfwZ83+lU0uKmsu0l4Xio3ZiDzoanvW2VM97hkp4b4tgUgJnmEz L5iUrlaJFRNX8faH5AAwDjafzIjuoREKfupLU/N+k1Xb2H4NSARVxnQ7HFlyLbzK76ls LJdw4X7Jki2Jv+daRtVy9J+fQMmNzW2qSprE98Pq8O5K+NiJHUWLSHLPP4bh88LGxD2o FJUk2hLnSe2UofOkTZSXq40R0J3K+9pmSLr6UgEk7+qjTZwHdNhR+wJlZPFuR9GALCZj iPDSB8quzn/UNJinkvKnC8vBAFAgT1/ikIR+XMR10NAdF6VLV7Uy1Yts91QwdJveNcuu MxAg== X-Gm-Message-State: APjAAAWboMsWgBKK9Qh+6TfI/qDvmavqP6L23O0F0ip0om3hFl5L2+7m 7zfl12Gr4BEoyw0C3caAFW/FbjPaZzjwuYPr X-Google-Smtp-Source: APXvYqxLvMSwkkjy+lC/cVYbgrgkLkZ9PFS2hChYg9j0ye+fawiAzQzUVh+XFvNyZWFc136aIXGdLg== X-Received: by 2002:a1c:ded6:: with SMTP id v205mr15076301wmg.86.1577985861294; Thu, 02 Jan 2020 09:24:21 -0800 (PST) Received: from amanieu-laptop.home ([2a01:cb19:8051:6200:3fe7:84:7f3:e713]) by smtp.gmail.com with ESMTPSA id z21sm9480328wml.5.2020.01.02.09.24.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2020 09:24:20 -0800 (PST) From: Amanieu d'Antras To: linux-kernel@vger.kernel.org Cc: Christian Brauner , stable@vger.kernel.org, Amanieu d'Antras , linux-xtensa@linux-xtensa.org Subject: [PATCH 6/7] xtensa: Implement copy_thread_tls Date: Thu, 2 Jan 2020 18:24:12 +0100 Message-Id: <20200102172413.654385-7-amanieu@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102172413.654385-1-amanieu@gmail.com> References: <20200102172413.654385-1-amanieu@gmail.com> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This is required for clone3 which passes the TLS value through a struct rather than a register. Signed-off-by: Amanieu d'Antras Cc: linux-xtensa@linux-xtensa.org Cc: # 5.3.x --- arch/xtensa/Kconfig | 1 + arch/xtensa/kernel/process.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 4a3fa295d8fe..296c5324dace 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -24,6 +24,7 @@ config XTENSA select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL select HAVE_ARCH_KASAN if MMU && !XIP_KERNEL select HAVE_ARCH_TRACEHOOK + select HAVE_COPY_THREAD_TLS select HAVE_DEBUG_KMEMLEAK select HAVE_DMA_CONTIGUOUS select HAVE_EXIT_THREAD diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c index 9e1c49134c07..3edecc41ef8c 100644 --- a/arch/xtensa/kernel/process.c +++ b/arch/xtensa/kernel/process.c @@ -202,8 +202,9 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) * involved. Much simpler to just not copy those live frames across. */ -int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn, - unsigned long thread_fn_arg, struct task_struct *p) +int copy_thread_tls(unsigned long clone_flags, unsigned long usp_thread_fn, + unsigned long thread_fn_arg, struct task_struct *p, + unsigned long tls) { struct pt_regs *childregs = task_pt_regs(p); @@ -266,9 +267,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn, childregs->syscall = regs->syscall; - /* The thread pointer is passed in the '4th argument' (= a5) */ if (clone_flags & CLONE_SETTLS) - childregs->threadptr = childregs->areg[5]; + childregs->threadptr = tls; } else { p->thread.ra = MAKE_RA_FOR_CALL( (unsigned long)ret_from_kernel_thread, 1);