From patchwork Wed Jan 3 16:00:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13510226 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53405C3DA6E for ; Wed, 3 Jan 2024 16:01:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE4816B00EE; Wed, 3 Jan 2024 11:01:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C944E6B00F4; Wed, 3 Jan 2024 11:01:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE70C6B00F0; Wed, 3 Jan 2024 11:01:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 99EAA6B00EB for ; Wed, 3 Jan 2024 11:01:29 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 54075A0929 for ; Wed, 3 Jan 2024 16:01:29 +0000 (UTC) X-FDA: 81638464698.12.6878E86 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 8F5E114004B for ; Wed, 3 Jan 2024 16:01:25 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UyJMV37c; spf=pass (imf26.hostedemail.com: domain of leobras@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=leobras@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704297685; a=rsa-sha256; cv=none; b=Y1tnNS1WWR34euJrtak8I9Dcdye2mhIlFto9e3AybsgptRogP4keAgfybeHWabDd1OOmyl 9GRV2AjxQJeT2krSgp/KfaxChFTy0pnsLHsZ6mCCeA/Pad2Q6PPllt610gvLsG3OBObyMX FCgzNoHyyNH/ZKU87o4bQhj7KnxJqJg= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=UyJMV37c; spf=pass (imf26.hostedemail.com: domain of leobras@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=leobras@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704297685; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UcuCCcEH82BE3ayeUzaJsR8GgVjZd2XA38iISRs+5EQ=; b=eE3Dc1H7PZ8bc+bQq5RF36aDCNMzuWq+YBCQBi8OBv89gpNmp3AQb7yOcpOYeXCXukUFGj gRw+vVc9qg1ZZJG/DdvsucvEt/AZsxcruEuMTEQ2o1UZ7qRyEunlKZKnq+EWzEeiu3XVib 6lQr9ABmQunKXKatNIFlR1MIO2qvIlQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704297684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UcuCCcEH82BE3ayeUzaJsR8GgVjZd2XA38iISRs+5EQ=; b=UyJMV37cnWYmSR25b1octj9uIXoKxDz3uLD5YZcROsuRtOXvpXw58McMHJTccvU8P++E8u /Ec47ISTNhmf7bYsGQ3frgPCYohFh7BIJfGo3fhHWF1jjuIvybisnvqICuBOKzmKS31jKa IHtF4LK7xq6bq2Nc+wRapk0Zt6k0DEg= Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-127-TvsXK2CnO-6JNA4vtlNiig-1; Wed, 03 Jan 2024 11:01:23 -0500 X-MC-Unique: TvsXK2CnO-6JNA4vtlNiig-1 Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-28b88d79b87so6302946a91.1 for ; Wed, 03 Jan 2024 08:01:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704297682; x=1704902482; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UcuCCcEH82BE3ayeUzaJsR8GgVjZd2XA38iISRs+5EQ=; b=xI+HSLWap/NPcJP+wjqafU4zJJQYfBu/oXL14bFoXj2l+4q7ijP1N/qCRXoTiUtmjb +6bD27Usj7pf6vjefn2p5AhF31fvvja9i2RUq7ZNp/54mLkvFl2ATxuF+wwQcVPQ0zpV UPTpPvPtD3rCeTEPFvoJXCEOhIgRTTnUdqshTp2S5XLuBs6TBJFVgL/ZqKrH8Cb68M9Z UkVPPAjkqQVDNXYaa7/FTcMaLbzzK/n2ALBtBH/EwXmjHcsNL8Z61Pfw53wqRp0ymm48 6xrAD/g/E+ho0t6YyZOf7n1s813dEL58IlOtY1zRkJhRFtgzW/2Zjcs4Vl9vV4nOG12O zqvA== X-Gm-Message-State: AOJu0YzI9dlDv/6vo3T53JBw3NCIAlzOl+bwhoQJnr+GLN+K7x2ijJDn A05enON67QTiCiWlpPARcYO1efE0cfBVzGcFrIbZ8xpFw3NaRIheKJheb9Gz7Q1zSYP6elCVtqj fwjKH87/DZ9ADlZT0oTM= X-Received: by 2002:a17:90a:ac0f:b0:28b:2e19:70ad with SMTP id o15-20020a17090aac0f00b0028b2e1970admr6096708pjq.25.1704297682418; Wed, 03 Jan 2024 08:01:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWGQZgfdECo7Rqv5SvlFkPiOgIc2kjMq7oXKIwuu4xXAPoN6bd8DlcIBQPspVWHa4cRptl2w== X-Received: by 2002:a17:90a:ac0f:b0:28b:2e19:70ad with SMTP id o15-20020a17090aac0f00b0028b2e1970admr6096675pjq.25.1704297681382; Wed, 03 Jan 2024 08:01:21 -0800 (PST) Received: from localhost.localdomain ([2804:431:c7ec:911:6911:ca60:846:eb46]) by smtp.gmail.com with ESMTPSA id qc8-20020a17090b288800b0028b1fce7c01sm1922253pjb.37.2024.01.03.08.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 08:01:20 -0800 (PST) From: Leonardo Bras To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Eric Biederman , Kees Cook , Oleg Nesterov , Leonardo Bras , Guo Ren , Andy Chiu , Conor Dooley , Xiao Wang , Vincent Chen , Charlie Jenkins , Greg Ungerer , Andrew Morton , Kemeng Shi , Alexandre Ghiti , David Hildenbrand , "Matthew Wilcox (Oracle)" , Qinglin Pan , Greentime Hu , Baoquan He , =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v1 4/5] riscv: Introduce is_compat_thread() into compat.h Date: Wed, 3 Jan 2024 13:00:22 -0300 Message-ID: <20240103160024.70305-6-leobras@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103160024.70305-2-leobras@redhat.com> References: <20240103160024.70305-2-leobras@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 8F5E114004B X-Stat-Signature: ujqxx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5OCGOt1JNnrM+7tvpDFHyrdRAoNIeyRuCVeVGtVHPVdxO9Q91zGFde/RIASscNJcWs6w6NaF9BSmjoIn70ovQTAG+v4l53aBKsoUspu3eJr/vKxFbyHjEuz6cqysHTDtz4UQ0WS6F6r0IITuRRKPNmqfTQPEk6jPnaqYyudJT3OgU/vxV2s5ufrTzBFBzLCBLRgrJftTXi4+XpfBnOorn4Wz45SYfgHk6I7+Y6DLIh2Ug8SXnx98KlgJBSAo0mIvX1I0Lp/MoR367KHu8rYHp5Tq5wFCDbsA2tAgYz5HXkdtt55c8AVVYOsOqdgCXsTh5zCi64fDJODP0EIsAcjyAhDvqymh/IwUlgTMHfUSUNxCHuwDBLF2NknXwCyq8CIm90VQcQjwOJF+Nw63rqDF3hwTjv+s887SAywBobpCuX4SBjssNLShs+gvLbGfzlXGGJWc+kN3cALsgYdwD929oeloAl8GESyi9uyB0bqwwFoYdVoKbCDTgnaDwgVpLryHOnUx2VOe4JYXHWDCJfDKj6w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: task_user_regset_view() makes use of a function very similar to is_compat_task(), but pointing to a any thread. In arm64 asm/compat.h there is a function very similar to that: is_compat_thread(struct thread_info *thread) Copy this function to riscv asm/compat.h and make use of it into task_user_regset_view(). Also, introduce a compile-time test for CONFIG_COMPAT and simplify the function code by removing the #ifdef. Signed-off-by: Leonardo Bras Reviewed-by: Guo Ren Reviewed-by: Andy Chiu --- arch/riscv/include/asm/compat.h | 8 ++++++++ arch/riscv/kernel/ptrace.c | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/riscv/include/asm/compat.h b/arch/riscv/include/asm/compat.h index 91517b51b8e27..da4b28cd01a95 100644 --- a/arch/riscv/include/asm/compat.h +++ b/arch/riscv/include/asm/compat.h @@ -20,6 +20,14 @@ static inline int is_compat_task(void) return test_thread_flag(TIF_32BIT); } +static inline int is_compat_thread(struct thread_info *thread) +{ + if (!IS_ENABLED(CONFIG_COMPAT)) + return 0; + + return test_ti_thread_flag(thread, TIF_32BIT); +} + struct compat_user_regs_struct { compat_ulong_t pc; compat_ulong_t ra; diff --git a/arch/riscv/kernel/ptrace.c b/arch/riscv/kernel/ptrace.c index 2afe460de16a6..f362832123616 100644 --- a/arch/riscv/kernel/ptrace.c +++ b/arch/riscv/kernel/ptrace.c @@ -374,14 +374,14 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, return ret; } +#else +static const struct user_regset_view compat_riscv_user_native_view = {}; #endif /* CONFIG_COMPAT */ const struct user_regset_view *task_user_regset_view(struct task_struct *task) { -#ifdef CONFIG_COMPAT - if (test_tsk_thread_flag(task, TIF_32BIT)) + if (is_compat_thread(&task->thread_info)) return &compat_riscv_user_native_view; else -#endif return &riscv_user_native_view; }