From patchwork Wed Jan 3 16:00:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13510227 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 2C836C47077 for ; Wed, 3 Jan 2024 16:01:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE9676B011A; Wed, 3 Jan 2024 11:01:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A99826B0184; Wed, 3 Jan 2024 11:01:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 913396B0186; Wed, 3 Jan 2024 11:01:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7C3256B011A for ; Wed, 3 Jan 2024 11:01:36 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4655F16032C for ; Wed, 3 Jan 2024 16:01:36 +0000 (UTC) X-FDA: 81638464992.01.C560C0D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 414FE4001F for ; Wed, 3 Jan 2024 16:01:33 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fzH53KVa; spf=pass (imf04.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=1704297693; 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=tvTrIj9bDaC7vtXATJc2+i25LfcfP+uiCW+wrXL+g5Y=; b=qSxBVxuR2QiBiDJ9nINAp+EIXTL6qakRiQluQLJkhH0XIxR9/x6181CuHcQQHYkNOh8ous gFUgJlCSh16qruucZvVXF2Amhsp2peEcqC0UZQ7NvEUTIUmpnoiV0akV9IpQ4seGr6rThx XrHKSXTxDm/65RV4qAKo2vDODPpSB8Q= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fzH53KVa; spf=pass (imf04.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=1704297693; a=rsa-sha256; cv=none; b=UEKVF0Vmv9FIj3rKDNtZen045Vor8aDKFG845yMB3SI6oa5ytaf6nOHG5NwlfdrNRgzfmy XtXNU3im+Gt+7Z0ISNpRRL4+QM3Nh1xX67EiObA09fCBcRT9rTbjExd23ttjFWPyymw288 1XoaBX7Zr+UW0lONW1RYHEDN3ss2KWo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704297692; 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=tvTrIj9bDaC7vtXATJc2+i25LfcfP+uiCW+wrXL+g5Y=; b=fzH53KVa/Xm6vAnUBO59vKA7mgrMiN8X9LZIKToednw4/0sSe/aunZLmx3+3kSs/AMiadV t0D7NfYpeBlohzp0cA0RnYlr+YKvbiVq/SCDkkx4VIVHn1+SP1LM+Y8luiZG5EbpTe71Ib cgCMrPnKb3afhDJgJ8ViXOtKYvDrQP0= Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-225-HOASuBRGMu-huZ58ueIsSA-1; Wed, 03 Jan 2024 11:01:31 -0500 X-MC-Unique: HOASuBRGMu-huZ58ueIsSA-1 Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-5cdfa8dea37so430333a12.0 for ; Wed, 03 Jan 2024 08:01:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704297690; x=1704902490; 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=tvTrIj9bDaC7vtXATJc2+i25LfcfP+uiCW+wrXL+g5Y=; b=u5QTGRbficRpFJ8pAzt6zv0KCUZTKcSQjO2MQlQ2X0mazdaEDmXzlVwoSdESERph3B e+UkiF6DjYzaf9c8gVpRp2G2IAekA0BdYddwpi9VyAvgmw5XljKjJOWbxW0txFMLBnX7 36O+wz4xCZxikFKDXvc6jlhU12k6BevW8T6NJNNI1NWxG1IPreKjajIVGidBI/KaLkjW +CBnGVLpDUqy7+x3nfhIiNEJzmkLb+83HPDQb2FS+O1KTRqBsAvvY704jbtzh/oV3Xq8 9TgPikzizCzG/ffh9V8W0u6mnrCGe6Kqd1EZdIM7AgscUaikJLwKofFm5OFh1TuKlyk5 HzUw== X-Gm-Message-State: AOJu0Yx5sES7UC+IB95epuhqpWupB2EGI1Q3v5iE7FeqC1Alp5kkBi+6 pq5XI13gNydnSAR0UMaeX5E5bY30FYp4C6RpC5RMj2/ZeYlDeDAMa0MIpijLvxmlWE40/bB1xXQ p/Qjlnky5b9hbpcl9Gec= X-Received: by 2002:a17:90a:6c41:b0:28c:8db3:deee with SMTP id x59-20020a17090a6c4100b0028c8db3deeemr1641815pjj.7.1704297689921; Wed, 03 Jan 2024 08:01:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLk0qBowIms70OWWZMDrR0eSOerzAwBSl15cF1uRBrdZRmyJm9IRzrY9G6FK4FX/myhaWIiQ== X-Received: by 2002:a17:90a:6c41:b0:28c:8db3:deee with SMTP id x59-20020a17090a6c4100b0028c8db3deeemr1641790pjj.7.1704297689594; Wed, 03 Jan 2024 08:01:29 -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.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 08:01:29 -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 5/5] riscv: Introduce set_compat_task() in asm/compat.h Date: Wed, 3 Jan 2024 13:00:23 -0300 Message-ID: <20240103160024.70305-7-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-Queue-Id: 414FE4001F X-Rspam-User: X-Stat-Signature: iwspbk5dr7xggqz6zkbych4kgwdpkbud X-Rspam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fn1dQsCD0vcB+u3ZFCbpgBBk6Xs/1jAiuCvMFVkGqLUyIBxwhkbVjs2hbqKVXXYiizxRjWFub/Rt7f62YO48JNFYgpJOREN9o7zrahlmqZNQFbgGaZ/P4NN4dbBJUD/i0r9LF8HsQjCzioxOrDs+i3kye10QYdcNSMgMwLmhAcNXK/g7NaJEkC1UU544UDd6nrUK1YSJfdXiKo6PdOA5UUmRNLL3dEP/nIVsO3NRy1g59oy4MolLeiIn5EhWtk+k2WlZ+5U8l1Nb8rcSmY1HQNlzyWCmS8tUCHONY4UjG03qLpB3YuFNgv7HxyBqF41O1QN13upxKeZ9ZwVjVLP3WWcvpJ/xvjUGqwj2ISOz7CbNkOCHpVhcP+3qIHOeeOGh4E4AhSmF3m/eO1gbZrXPpkxHDYxxaQQx8R1/9SeCxBCqgIvfoDN9dryN3gmCEj/UiMp+vCXQ== 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))); \