Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp649158rdb; Fri, 22 Dec 2023 00:11:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFKAmIcJF0lri5Tm+3NcRhfr9r38cQhXypjKbKBjDFzgMFFTf273VAdTkLElWK3r9rvXJXL X-Received: by 2002:ac8:5ac3:0:b0:427:81de:9883 with SMTP id d3-20020ac85ac3000000b0042781de9883mr1251284qtd.92.1703232700917; Fri, 22 Dec 2023 00:11:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703232700; cv=none; d=google.com; s=arc-20160816; b=MNQxE7uPMcYZ/Spx0tW42pm9dgSm0T7iur2NSYtPgFYJ1vGrryLRbnm5D9iHmBmJsD EZYT3Zy0tfqoqidWo9JMYq8AZmSBZZehNOuH+lRs7QebKYwmuiWdXqDkwEPmGxguxXPV k9BDkPw6+ZmdVcuvMu+HG87l1dh76O8Mg/ii7t5xox+vGQ9Z/zbaCXF9HdYAL0a4PYUM EoYVw4pZycKU3kiSzDDYc4AHf+wwRsefg2medegSFxUjhW82I66mgomGznyDhCHscDRe gXolHsZZ2WLza885lRpWwsEdKy9Ds/rWEdG6qNHxT91epoiJBuK7ovRnT7aQPbmysivp ZfjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Exojwv7ObzcZGSnEBXNzoU0+GLRSyFVbo0h6MIrG11w=; fh=MSDPJIgNA+oz9s0OIIy1OGBF8jcy0QBjD/wwDTyyqyQ=; b=TNCpprKa6Iz2waYtGYU5bPiEhexbgjGixXRD9v9O2wK6voRbzhUJmvA5Hh0Do+vRwB q8CaWfvcV7RHIvebSsyBFsULEt6T4OF1tlqY6+GGlmEtvbSdNr5y8MMLWbnla3bfLxE8 98lBQG5RKKP/vPX9evmkZ1YDiL+cgrbHdrZXmB8P4qcqaLctEENs8o9T0qDupX0M7ufR OaW53neZD25iOlRfLDFlhY8KVZAg+U3yMc+spWvu8ZyptYd3PuTPl3wQGpCiKxOvuSvd kNy4owj0/K9KP/83SJQ6p6BCLP8nNESCRkdNY2bQRK4mHandUvP4g0OrHznGkr0NQUlq 5dsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ThJHIAWS; spf=pass (google.com: domain of linux-kernel+bounces-9481-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9481-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r20-20020a05622a035400b004069f6c1ec7si3749033qtw.668.2023.12.22.00.11.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 00:11:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9481-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ThJHIAWS; spf=pass (google.com: domain of linux-kernel+bounces-9481-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9481-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 977571C2506D for ; Fri, 22 Dec 2023 08:11:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F35B8D50B; Fri, 22 Dec 2023 08:11:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ThJHIAWS" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 37748C8D4 for ; Fri, 22 Dec 2023 08:11:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6CF4C433CA for ; Fri, 22 Dec 2023 08:11:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1703232683; bh=xlvrw1s0T46Tz1knGooTW4HgxuEaVE6Yt4gVH7KsSNs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ThJHIAWScS67tO4MPkBAG639WxhdKDyUoCbBibMIwOUCJSm4eLx5TYNjMlPfj2Euu EZZnLtFeL/Vz0lhk12fZaMNiHJLD5uIN47v8qoOS9iemaIwTaQkpzKExUBNRIHy4nv s4Jgd6KWl6FeJMwvuW/P+N4QQxpZnfiojXLU9BrQRcrO27M7kXtfGAenghgNeH6NRi c0NuJM835BWWVGTGNChon2OX+8Ifb7UfIIzWBKh/tzF2905e2gt4q1MfBTAFZY1u3w OV6Arg0gB3HvO3ovldS4JPJxJQV0jOhxwtJzGJ/DgFROvm0vwEXlkfUpxV76Qt2/uW AROH4os7cmJAg== Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-552d39ac3ccso4901890a12.0 for ; Fri, 22 Dec 2023 00:11:23 -0800 (PST) X-Gm-Message-State: AOJu0YydP80pbZl0P2A4EubRg5YjNCn37S2z2x0C5Lx7UDxCax6ZCVPb 1jg6FQegNC7NlZldHaJI/PBnVtXzcAmuKDE5Xc8= X-Received: by 2002:a17:907:9392:b0:a25:a0c6:ebf5 with SMTP id cm18-20020a170907939200b00a25a0c6ebf5mr762193ejc.21.1703232682173; Fri, 22 Dec 2023 00:11:22 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231222074605.452452-1-leobras@redhat.com> <20231222074605.452452-5-leobras@redhat.com> In-Reply-To: <20231222074605.452452-5-leobras@redhat.com> From: Guo Ren Date: Fri, 22 Dec 2023 16:11:10 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 4/4] riscv: Introduce set_compat_task() in asm/compat.h To: Leonardo Bras Cc: 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 , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Dec 22, 2023 at 3:47=E2=80=AFPM Leonardo Bras = wrote: > > In order to have all task compat bit access directly in compat.h, introdu= ce > set_compat_task() to set/reset those when needed. > > Also, since it's only used on an if/else scenario, simplify the macro usi= ng > it. > > Signed-off-by: Leonardo Bras > --- > arch/riscv/include/asm/compat.h | 8 ++++++++ > arch/riscv/include/asm/elf.h | 5 +---- > 2 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/arch/riscv/include/asm/compat.h b/arch/riscv/include/asm/com= pat.h > index da4b28cd01a95..aa103530a5c83 100644 > --- a/arch/riscv/include/asm/compat.h > +++ b/arch/riscv/include/asm/compat.h > @@ -28,6 +28,14 @@ static inline int is_compat_thread(struct thread_info = *thread) > return test_ti_thread_flag(thread, TIF_32BIT); > } > > +static inline void set_compat_task(bool is_compat) > +{ > + if (is_compat) > + set_thread_flag(TIF_32BIT); > + else > + clear_thread_flag(TIF_32BIT); > +} > + > struct compat_user_regs_struct { > compat_ulong_t pc; > compat_ulong_t ra; > diff --git a/arch/riscv/include/asm/elf.h b/arch/riscv/include/asm/elf.h > index 2e88257cafaea..c7aea7886d22a 100644 > --- a/arch/riscv/include/asm/elf.h > +++ b/arch/riscv/include/asm/elf.h > @@ -135,10 +135,7 @@ do { = \ > #ifdef CONFIG_COMPAT > > #define SET_PERSONALITY(ex) \ > -do { if ((ex).e_ident[EI_CLASS] =3D=3D ELFCLASS32) \ > - set_thread_flag(TIF_32BIT); \ > - else \ > - clear_thread_flag(TIF_32BIT); \ > +do { set_compat_task((ex).e_ident[EI_CLASS] =3D=3D ELFCLASS32); \ > if (personality(current->personality) !=3D PER_LINUX32) \ > set_personality(PER_LINUX | \ > (current->personality & (~PER_MASK))); \ > -- > 2.43.0 > LGTM Reviewed-by: Guo Ren --=20 Best Regards Guo Ren