From patchwork Fri Dec 22 07:46:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13503070 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 0E46CC41535 for ; Fri, 22 Dec 2023 07:47:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 819CA6B0081; Fri, 22 Dec 2023 02:47:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C9006B0082; Fri, 22 Dec 2023 02:47:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 643066B0085; Fri, 22 Dec 2023 02:47:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4C60D6B0081 for ; Fri, 22 Dec 2023 02:47:00 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1745B1604EC for ; Fri, 22 Dec 2023 07:47:00 +0000 (UTC) X-FDA: 81593673000.17.8C9D013 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 02F454000F for ; Fri, 22 Dec 2023 07:46:57 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MFWZXPsj; spf=pass (imf27.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=1703231218; 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=nJKdTz0fBLuk4zNW5VLOm1jY/M0/StXJiYDFTohFsJw=; b=CXYgqarABG90+2bpa5gEI2BY167iSElvXUc17c80ZsCctvKnEBD0XnHS0qw3J4D2vIZdcn roCgrHpns4kBpuG0bFYOmFfbQcDXqUMiefki9cUnM+QBWOxINqKew4gZDaFSOd0Zosk5uR Ou0nkgNG1pjwl2j5Ska8bW7YIdRDGNw= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MFWZXPsj; spf=pass (imf27.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=1703231218; a=rsa-sha256; cv=none; b=72uW70Ivb0VVGippuJm7sNXUEkhZ0VWC1/sHInrqiTs3aJzhOMvaTK+ArMT+9yswFRErQE Ay948ZPkq3fsClFZZ69/sPRx2+jwZDspr5ZyMFw/7RUlIGnv6IEfEhapJvonlC9C4yLzTO ySTQkAILj0FdOmg2ZDFTYE4X9VO7F1g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703231217; 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=nJKdTz0fBLuk4zNW5VLOm1jY/M0/StXJiYDFTohFsJw=; b=MFWZXPsjOS/Rh6ih9aTXX0z+cuxeWNIoccfz80WNLUm/ff0UOTHbzxrHNwpMCuqWsqC1ct tUWXKqJhSpwugvH7xKEriNT0SkFQzkVX6mz7bWaqCqwqy8cTOJRZNTgRsl/UTjE8NZUhid QlAZu4QioR6eNF1F4tkMmY1LyE1BVNo= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-223-oh5qS7r7Mj2BpI3M6ZYhzQ-1; Fri, 22 Dec 2023 02:46:55 -0500 X-MC-Unique: oh5qS7r7Mj2BpI3M6ZYhzQ-1 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-6d5a08e6a80so1192401b3a.0 for ; Thu, 21 Dec 2023 23:46:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703231214; x=1703836014; 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=nJKdTz0fBLuk4zNW5VLOm1jY/M0/StXJiYDFTohFsJw=; b=uMKKPW61dtly23cX3RtrX2FUhtEfgu+xnNAmvICluXI/voggBa6dGae4nx38K6+uZX iXRdFgmJNLEnRVZD4CNQW3DN1YIAlsSgfnr5lzZ02NYN8T0iQrHnHC6CVyaOjNrxxi6z N/G7OVpSblg7c9S6uJuMchf1V9MY3hFZyJrmcLwu4z0N0QVq1DPD4zuqocsNtpSEzks5 A4EHqtvz48iQhfTiAY4hqjVINaSJ/kJLhKrLgN7l5DM9IVT/IrQgP1GaNZMU6a73V7t+ xGENLlpDb3lGqyvz1bRG77a+SVHiXR7DToqRjTxWXI6/BKFKCInw9Nah0XtOvgowxGdC 7+dw== X-Gm-Message-State: AOJu0Yz10SNlbi4UkozZFU0/y+L3/qUiCvZR+LLqt1PiReQG9+kx3H0W rpM/DcYoNpksXR75JyD15v00wojrTzO0QJ9KCtkwPTSpbqJ/6jfER4efXL0EXblqRL+Gmif1GPu 5mGx1ks2DH1WAAtWzw84= X-Received: by 2002:aa7:9104:0:b0:6d9:3659:5419 with SMTP id 4-20020aa79104000000b006d936595419mr998847pfh.21.1703231214628; Thu, 21 Dec 2023 23:46:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGMFmEyFRjwKSQRTyr1Tjdg/8FK7+G5rpG28wVcUI80rZUZeycJ9jxcUGtZ0nSOM5ugBFakSg== X-Received: by 2002:aa7:9104:0:b0:6d9:3659:5419 with SMTP id 4-20020aa79104000000b006d936595419mr998837pfh.21.1703231214349; Thu, 21 Dec 2023 23:46:54 -0800 (PST) Received: from localhost.localdomain ([2804:1b3:a802:7496:88a7:1b1a:a837:bebf]) by smtp.gmail.com with ESMTPSA id m2-20020a62f202000000b006d97eaba6cesm1527015pfh.21.2023.12.21.23.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 23:46:53 -0800 (PST) From: Leonardo Bras To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Eric Biederman , Kees Cook , Oleg Nesterov , Leonardo Bras , 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?Q2zDqW1l?= =?utf-8?b?bnQgTMOpZ2Vy?= , Guo Ren Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH 4/4] riscv: Introduce set_compat_task() in asm/compat.h Date: Fri, 22 Dec 2023 04:46:04 -0300 Message-ID: <20231222074605.452452-5-leobras@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231222074605.452452-1-leobras@redhat.com> References: <20231222074605.452452-1-leobras@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: 02F454000F X-Rspam-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N guc/fGIqSkaAIs3XboK4MCMN8knVerZQMzp+ePSk869W43zMMm2vI9+KH5kppcHcz88WcCk7iNrTUjji3ewGBg8BrrApAFMJyPxwAuvGcG7Y1EjxW/ToYe6YLdA4zZul5AO7fimljrFo7b1QGMJ7f/HNvCeHgk3HHuqWwFS4zQwAfUbywVpAwxOFbtQ55azSgV9tyPztE56w+E6aAYfuAc/AhtPmMXmD9PWk3FfOBGN5dKNbTEy5hyrxnryocxJC9NUGg3KkP5UPPGLWRinIqJadQlvBmeAaleu0Xn4abCmew1dAr6EijfUJYOd7hAxdz/Dk7mdLkO1Xi9smiaZtrQmhiplvn8mxNfn6gkiADlO1D6XSG8poqvvz5XT+4N46wl2puACu9wKGNv12GhKNQLkAxx1SY7C/A2CqQ4I8V1CtZWxjHADZSI0O9a7OYY0TLFAGP 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: In order to have all task compat bit access directly in compat.h, introduce set_compat_task() to set/reset those when needed. Also, since it's only used on an if/else scenario, simplify the macro using it. Signed-off-by: Leonardo Bras Reviewed-by: Guo Ren --- 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/compat.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] == ELFCLASS32) \ - set_thread_flag(TIF_32BIT); \ - else \ - clear_thread_flag(TIF_32BIT); \ +do { set_compat_task((ex).e_ident[EI_CLASS] == ELFCLASS32); \ if (personality(current->personality) != PER_LINUX32) \ set_personality(PER_LINUX | \ (current->personality & (~PER_MASK))); \