Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp939218rdb; Fri, 22 Dec 2023 09:14:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFo7tnNZ213bVrEm7HXWwzMSu/6H/t/H1euexPn6e4n6uL0CUc+2D7Oa0Hop+5A8D0sHaAP X-Received: by 2002:ac2:4882:0:b0:50e:4e6c:ea8f with SMTP id x2-20020ac24882000000b0050e4e6cea8fmr870376lfc.41.1703265295959; Fri, 22 Dec 2023 09:14:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703265295; cv=none; d=google.com; s=arc-20160816; b=oDME6wGGESwZPNrBEk/v2LFw1p1HJ53KLMCgNrF0JrnP4wlxIXkc2YmGB68eCudKeP BOEx4ubytC19Is5LMpdsVDpjQAu/HWihHWEQxcsk6zjtJRrqrJuvpw3Clxk1vk2IZrp5 4osi8l7kIJ75iTtc4Xl6atuh6Ca+7AtWsEShWDsyaiNfuh+xRKBKNlKNaFe81MBPAp9p oO/eJDrhgfWyqrr3KUBMC9YAG4aVBR03ylklvBmUIwMKGpCvFMDZwBLwq02rTwW1ZaUm PIIpJkL4EQZBET86VZIo/5Ux9KoFkJ7mu02Lxa4WP6b4ilRAmXjdQ3qSUDD9OmQwRSwQ EsGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=9cqFAbdxj/IpuKwhr/dOiRTwiBgTE3bII6IeIMBlh9I=; fh=tVzQPCFOxj16z/xMT5OMPC7EkSlM1Yzys29u0FUZ8yk=; b=tzC1KlE6+dNyA57DnjFlZxnayL0sgMG2C/oV4S+6BohfhIIimq5+Fhi3YNRieb4Bxv Tjtia7f3o85TT2wlTfP+3yTWKtliS7kWVmppbfvX/gGxYtynA8Jv6t8wqzF6JeJjFlGm bzx/bBIdwpGnrjUYbUf9Z3+OJ0oXSnOB9/29G81o47brmOYaGhxrtFQulILmL/wWBG7j tQb+2iCavwfv7mgdpY95U4BIPGTPUpy/cmMhGQaNUSmfWbIxfUiEZTJYiWc7QKzVenEp BalQX+xTny4bBvu6bZF/NUFkda+5jHDL3JbBnQo59h0krSm7JeHKI1UyVBa+//bcunGm JK/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A0oLBRWT; spf=pass (google.com: domain of linux-kernel+bounces-9938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9938-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f29-20020a170906739d00b00a269787cea4si1990496ejl.952.2023.12.22.09.14.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 09:14:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=A0oLBRWT; spf=pass (google.com: domain of linux-kernel+bounces-9938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9938-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 850641F22F0B for ; Fri, 22 Dec 2023 17:14:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E092A28DC6; Fri, 22 Dec 2023 17:14:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="A0oLBRWT" X-Original-To: linux-kernel@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96C0728DB9 for ; Fri, 22 Dec 2023 17:14:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703265284; 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=9cqFAbdxj/IpuKwhr/dOiRTwiBgTE3bII6IeIMBlh9I=; b=A0oLBRWTSeKbrRXFGRqocks8WbwSOiFJW3IBFFwkz1k/R8QKVwT/Qlq508BLUhc5GQ3Xq2 B/+yRDJlZM27UJCTxXp1jR0Bchaebw2jUE2AiZSje1/wZ99ZO0C4eIk4PuZcnNG4gFbEc7 4lh2WustgbaENTNkYPUAKK+k71efjeQ= Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-35-EAg--q8OMIe4nQlFM2B3oA-1; Fri, 22 Dec 2023 12:14:41 -0500 X-MC-Unique: EAg--q8OMIe4nQlFM2B3oA-1 Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-6d8d059a790so2252270b3a.0 for ; Fri, 22 Dec 2023 09:14:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703265280; x=1703870080; h=content-transfer-encoding:content-disposition: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=9cqFAbdxj/IpuKwhr/dOiRTwiBgTE3bII6IeIMBlh9I=; b=bRASjgt1EQDt9UWfXdzZFcCmDZ9i3GJqatqW2des+7q+oDz6NWVie+KUWa9d/7kvxT boldNf3E+jsHbxv+5Vpsdl+med3j32KDziv0RGrIQs74UpoC1EYxy2p2M64FWrugTW26 kD/XXBqC/ByPl10L3sEZ747RbWYarDTHc+hXrrya5EvE+7brRSpqW0RQWD74D8SXvyU/ 4D+napeQaRPmksFRUtm8gD0Ahfev8oE9013bAYcvqQPk65fHvav/ltj6YnCoj4fEmdVJ boTqFQFwB4tpGhpSyF6fO+xUYWsPZGKB93DL9OVj02SAK+I8GC1gjB8NyZ0CnMTWSNXF w0/g== X-Gm-Message-State: AOJu0Yy0yA+JDysN186QYbSbJ1dA+pRKKrsqQ2DDUEzr6zs5hZey/aXS PfIGvNTdNGZTSNuVIiiIEvSeLtJPUGoksQ99nvxBwWFpDpGddYB3HPaRN1Zitm5JDzDMiIyMpzs 3A+RVWlUocImojreg3KACu3vQ/Xei6L/+ X-Received: by 2002:aa7:8611:0:b0:6d9:83a8:658a with SMTP id p17-20020aa78611000000b006d983a8658amr1601753pfn.43.1703265280012; Fri, 22 Dec 2023 09:14:40 -0800 (PST) X-Received: by 2002:aa7:8611:0:b0:6d9:83a8:658a with SMTP id p17-20020aa78611000000b006d983a8658amr1601741pfn.43.1703265279717; Fri, 22 Dec 2023 09:14:39 -0800 (PST) Received: from localhost.localdomain ([2804:1b3:a802:7496:88a7:1b1a:a837:bebf]) by smtp.gmail.com with ESMTPSA id k28-20020aa7999c000000b006d98f584ad5sm1180812pfh.199.2023.12.22.09.14.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 09:14:39 -0800 (PST) From: Leonardo Bras To: Guo Ren Cc: Leonardo Bras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Eric Biederman , Kees Cook , Oleg Nesterov , Conor Dooley , Andy Chiu , Greg Ungerer , Vincent Chen , Xiao Wang , Charlie Jenkins , Andrew Morton , Alexandre Ghiti , Kemeng Shi , David Hildenbrand , "Matthew Wilcox (Oracle)" , Qinglin Pan , Greentime Hu , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , =?iso-8859-1?Q?Cl=E9ment_L=E9ger?= , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH 3/4] riscv: Introduce is_compat_thread() into compat.h Date: Fri, 22 Dec 2023 14:14:21 -0300 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: <20231222074605.452452-1-leobras@redhat.com> <20231222074605.452452-4-leobras@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Fri, Dec 22, 2023 at 07:20:36PM +0800, Guo Ren wrote: > On Fri, Dec 22, 2023 at 3:47 PM Leonardo Bras wrote: > > > > 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 > > --- > > 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; > We also could put this into is_compat_task(). > Yeah! it's done in a previous patch. :) > > + > > + 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; > > } > > -- > > 2.43.0 > > > LGTM > > Reviewed-by: Guo Ren Thanks! Leo > > -- > Best Regards > Guo Ren >