From patchwork Wed Jan 3 16:00:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13510223 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 BC9C7C3DA6E for ; Wed, 3 Jan 2024 16:01:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3940D6B02CE; Wed, 3 Jan 2024 11:01:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 344A36B02CF; Wed, 3 Jan 2024 11:01:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20D8F6B02D0; Wed, 3 Jan 2024 11:01:04 -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 10D956B02CE for ; Wed, 3 Jan 2024 11:01:04 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id D10E4A0917 for ; Wed, 3 Jan 2024 16:01:03 +0000 (UTC) X-FDA: 81638463606.04.F0A2960 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 65C6CC001A for ; Wed, 3 Jan 2024 16:01:00 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="OAve/LgS"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of leobras@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=leobras@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704297660; 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=eW7Hp92xFvn0uEDHFJ5uhGV0bhy55HqDGviT7ReovF8=; b=RRDDLF11yHJp0dMjVEHRsG9G+TwlwtcuM+QdmfBEOEPOdLuXSrlNiV2aZgB9zAo5jJsG3f Mn3+jhzYjLxpxCSm0TTQuuFbDg4MoCLacWpGuDaS2o2CrQxGm16kGj+1fKVeiKw8E9EbVh rC2FGTL6fgZ7S48WLHgWGg2iRspvzCE= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="OAve/LgS"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf28.hostedemail.com: domain of leobras@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=leobras@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704297660; a=rsa-sha256; cv=none; b=qk3nkjkNvNgMq5hsavRvC1Hy1lyiIsvRl6gmQROK5Tvy4d3UkUUcEW19Ii9elc8F0NXq1+ 9unrxvu46drbdx78IbIX7flvIXHRHP8oOobzcQLyM9Uao1ARGQNBrV+YtkfG5N3ungXIKf AHKNv3kh0+orI0XCa85MbQYXSS4Ptcc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704297659; 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=eW7Hp92xFvn0uEDHFJ5uhGV0bhy55HqDGviT7ReovF8=; b=OAve/LgSkYP+KgY5bCM2w1jaHbzsxPaIh/eyH0MkiNjvNec07RtVpLItmLODy5bOUOA3m6 ZOsAH6hrdL0JZWn6N2DAMEG57NQqPUwWGIASfSGzqymNBJEnrEvWtRSEMk6yPLqnEd840h tJfZ3JWaJvhJ0IGzd3gdvXRbbeaKRpQ= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-9by2_ElXOkGNysRYoqE_pw-1; Wed, 03 Jan 2024 11:00:58 -0500 X-MC-Unique: 9by2_ElXOkGNysRYoqE_pw-1 Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-28ccb055d6eso477405a91.1 for ; Wed, 03 Jan 2024 08:00:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704297656; x=1704902456; 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=eW7Hp92xFvn0uEDHFJ5uhGV0bhy55HqDGviT7ReovF8=; b=UFFOHrsnJePR2nNqrEH44kGIebNDJqBmxpO/aVIFS9NKuXeNlR7RQBJOc5fOKqcWHF Hjv1qOY40CWiq4Y/Vp1d3kim8sAbf8D6yt73q/EG2pb4vIuCRy3DPmwejKBr9pxlC93D QviLH2ArvnOvxMUJLCfi2sbfcv3VEak4grPR+EGXEHhEL9tQ97wadWhabiEj+otoQKfy wrvjktM34VzP2NLPxy0eqdI5mJIUXWrMnKhho6n7PfvYlRBXzhJnzU62eK+Vyx1gChsS 3iAdfTKYGrJvzH8qODYE5BnxMnzIJC6GbGDEVhdE2kGOGHdgfcIi6dukSlPoVSHsJlg3 Wd5g== X-Gm-Message-State: AOJu0Yyy9TD/0eW5zXPzOh6V/PQwmic8XzHNl7u0Nu0xk5e1E3g8yxLy Wi4C9FZ7+thNQZDthLIhIGTzwStXvxlCj9Tw/QLd1l7TO02DXWjjo1ow6HanNMcyOAuj9Ehb/BL 7fmWcFn6L/viv3fUhgnc= X-Received: by 2002:a17:90a:c245:b0:28c:eeef:aaca with SMTP id d5-20020a17090ac24500b0028ceeefaacamr705438pjx.4.1704297656082; Wed, 03 Jan 2024 08:00:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IH1Qw9aIClua9ds5Nw8/POsd9KwpDhXoK1ctp78/8BijwUvH1rwsQL+Vt2C/sTQWWAMNvcTuQ== X-Received: by 2002:a17:90a:c245:b0:28c:eeef:aaca with SMTP id d5-20020a17090ac24500b0028ceeefaacamr705420pjx.4.1704297655711; Wed, 03 Jan 2024 08:00:55 -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.00.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 08:00:55 -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 1/5] riscv: Improve arch_get_mmap_end() macro Date: Wed, 3 Jan 2024 13:00:19 -0300 Message-ID: <20240103160024.70305-3-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: rspam09 X-Rspamd-Queue-Id: 65C6CC001A X-Stat-Signature: 8kai6a8cw8r9o91gpkg9ewc69g5k9zfh X-Rspam-User: X-HE-Tag: 1704297660-589296 X-HE-Meta: U2FsdGVkX197ENCLtAk/MbwrHPuR2JP+AGffbFR3fSUjI6G/GB6+gyZJwWqsphnu1rI7l1NOx16QuMoW2s/6Twk8vIOH18rBllt0N/P9QwbWA32Z/YyYClUo8r3ffcDNeoiBYa0zUcFYvljlmMzfV5dFL/4PrYGkYJCpgL1MsMRazRcvasKgtPagg1pQSVQm66uO0G6MoXCaYvKHbHHx8+qBPYh6P1UY7sRpasf5TPSty/mvIiAkSzuiLgb3e66yI4L16+hrZHLHlOkZ0grF/SxlFtUwQky583UY+HafJxh6v7TELlG4ctNVq9ZE9H7xF6KpwFSDBxWbq4qloJXI2oYFztjB6l+XIPjH/RKIy3MhDLykECPt5PrOrQa8S5DpCQdtwtjIiqgLh9iRsg2KjOZdJ8GfhzwsmqPoYurOd1/3v3s+brfT+Atd8CHAd0c/zvg8fza5vezgaGgBIP7kgL18AuTyLcJxsaCUT5RhztTe+4MGJfskwDqH4z88wKAYkfLMkbbepWZtpu30oO5X7S1GlGr9CChLhy9aZNzXdPONfku8J1exDalEmfFlyvU5w5itCWn3jl/B+R+Zre7Q3VQH/1bujb8cZoiW+A/mR13yH9t6LTP/VUvcFqV/n0HHDps1XJ8jUBtYmcqywJea4la4vNrzTtJxxS95LzmBRRYvVM6CNpdzyz5WXCm9pemMxX3jYHQEf4DOk0blaGukOirtbyMDEoNlCnCV/yESenzyRyzaWfdlDohY7dQYPZbyTV7nHfn/qMkXeqKCFHMNnvESoCiXwywG86Zj5LmWKOjvT3Cmsfs4/D8si5UbwKkDOh4M39FwZqvflLBKKyPLAU+cT9K65/mJttL2ABdSOGGUdcqOxMyffETk7u623C8cCPy7FC7QN8GaCq5QcuGVIplI/zNZXIZeC0RaqEUz0K6ig+yQwePZuSB5/Gf+iXpKf+kXIM35eCaGPqmocdH g0R4/uYJ 1xOUWXPLKfUUBTyJHZfa1U5cweLGcaGyA0g64Xhofr7p3LVDcGdeG2pqEiDJrPms2UuXDcb4b8lgUI08rkHwQyPzWmP2d5Ndrr2Dqjps2JglbJqTVNNEuncxdLsidbS6KCjED4HaMdVlsI4Rmm2ALUDRnYM2h89j+oet9+8L5k2UOffAvBNLtEPFVWIvToyNeU5z912DPK/gjHDCDGa1Wp2HHucpHaLdNmQsdyuNUtg0fBFkT4CLEofUhJ0vf9zzMs/J792DG3Ytwp8qcEnfHr6/h8iOTFsGC5z7BfwSdGGmFMkI5cTMbOKqiDZcKVqWe5ESTi8fqrO8xvFliD7q3Ne7vsoVJQtHfPFyezA/1CDmMAJzj7eIRH/6jR1d6qpfLY7lZMc4C+FNLAbw+28L0hCHdIKQvFKSc36h06G0NALtVxqXYprq+7ozXUiwQpylO84vPYk3ETg6UEuvc9d3FMcDPalDh/BYMFOfWUTa7Vk5AUBV2aDqamPswHQ== 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: This macro caused me some confusion, which took some reviewer's time to make it clear, so I propose adding a short comment in code to avoid confusion in the future. Also, added some improvements to the macro, such as removing the assumption of VA_USER_SV57 being the largest address space. Signed-off-by: Leonardo Bras Reviewed-by: Guo Ren --- arch/riscv/include/asm/processor.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index f19f861cda549..2278e2a8362af 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -18,15 +18,21 @@ #define DEFAULT_MAP_WINDOW (UL(1) << (MMAP_VA_BITS - 1)) #define STACK_TOP_MAX TASK_SIZE_64 +/* + * addr is a hint to the maximum userspace address that mmap should provide, so + * this macro needs to return the largest address space available so that + * mmap_end < addr, being mmap_end the top of that address space. + * See Documentation/arch/riscv/vm-layout.rst for more details. + */ #define arch_get_mmap_end(addr, len, flags) \ ({ \ unsigned long mmap_end; \ typeof(addr) _addr = (addr); \ if ((_addr) == 0 || (IS_ENABLED(CONFIG_COMPAT) && is_compat_task())) \ mmap_end = STACK_TOP_MAX; \ - else if ((_addr) >= VA_USER_SV57) \ - mmap_end = STACK_TOP_MAX; \ - else if ((((_addr) >= VA_USER_SV48)) && (VA_BITS >= VA_BITS_SV48)) \ + else if (((_addr) >= VA_USER_SV57) && (VA_BITS >= VA_BITS_SV57)) \ + mmap_end = VA_USER_SV57; \ + else if (((_addr) >= VA_USER_SV48) && (VA_BITS >= VA_BITS_SV48)) \ mmap_end = VA_USER_SV48; \ else \ mmap_end = VA_USER_SV39; \ From patchwork Wed Jan 3 16:00:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13510224 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 0D11CC3DA6E for ; Wed, 3 Jan 2024 16:01:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 805596B02E0; Wed, 3 Jan 2024 11:01:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 78C2C6B02E2; Wed, 3 Jan 2024 11:01:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 606046B02E1; Wed, 3 Jan 2024 11:01:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 46B076B02D6 for ; Wed, 3 Jan 2024 11:01:10 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 121E8A033B for ; Wed, 3 Jan 2024 16:01:10 +0000 (UTC) X-FDA: 81638463900.11.A2375D5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 7123B180019 for ; Wed, 3 Jan 2024 16:01:07 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Dd8pxjqm; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of leobras@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=leobras@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704297667; 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=9dWOLJ/7H2GD4Bb9fMRINczeyfjJ7YRASwlhClz2V/8=; b=a1tO3VKlh63tD7ID86fd99xk6rk4DfKYonilKupH72cGCd6SaTJ1+9oyemHR9qDzKyzum/ 9kTWP6pd8owOlA+yZLEwxNaxSwP/Ubn4mZpK7Pqcxy3LmxY8qebiTqsCzvJB/xY5XkHQDu QYaK12/Cdv5GQsR50Uneiq055FKfdJE= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Dd8pxjqm; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of leobras@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=leobras@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704297667; a=rsa-sha256; cv=none; b=SOpLeq7FBLGUx/lMaLzI0grHNT/qvzzkTVTdLjnZH3hI7wlajM0bDFjX2HkYDxGO9zvvCW 6j9HWzVcyeGJpGdbd1air2+Z+cpQVJl069tqjb4gD0FJ5FijnTGyepcOYSeBx22GIft/kl JrzreNGfq3Q72dz8fGlkRyoKbFCEkoY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704297666; 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=9dWOLJ/7H2GD4Bb9fMRINczeyfjJ7YRASwlhClz2V/8=; b=Dd8pxjqmajlmxQvI0nN1Du/DQzf5sOpVWL9BMXPoYf/2ABBFzOVTx+uKh230YDh0Rc0CGB rbtkSchaGuuxkjtGerXuCcOsfggndl3rBhPTI1MC0omfcuOQBiRRa3qjleVjqnFMIvdu8G buWCgO79jsgwM4HJwZRE7hzFKBURLK4= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-100-hEjo9cCYNlWhhVLBC0PZ5g-1; Wed, 03 Jan 2024 11:01:05 -0500 X-MC-Unique: hEjo9cCYNlWhhVLBC0PZ5g-1 Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-28b88d79b87so6302511a91.1 for ; Wed, 03 Jan 2024 08:01:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704297664; x=1704902464; 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=9dWOLJ/7H2GD4Bb9fMRINczeyfjJ7YRASwlhClz2V/8=; b=tP0Ur+ZgjTmaetvmnoxENoqQ8HCahhD7B8qQ6IbfbWQ8WxrZIONBx38zzyECgGrjTE 4lPYlV0eZFUhmctOQVnSD/yY57kuH7r+yrKVGtlFsfWQ5WY+kRQjAEIWrveUN+gqGKzh aNKGSH+JPjVWNhNmrjojGiWH0KA6gYmCP/6ahhOPi2oaFDGarntPDSY4u8c+wQBqnh3n SnXCZSS90QZn4FZNdNTY0wNQZYYy4WjuDuxPSJXkbXklhibaWU/l/9BooXqgzTM+2Hh0 zXAjmgBz9Aj1bP/Qk06g+NlZB/wxFktw2BKpD2p6Vu4TjJfQgbBrBkG0V+gHTfw5vWMJ ANYA== X-Gm-Message-State: AOJu0YwZPBXQpIzq0ONi/Bn9EGkerVqXjV75Uitgf9kc+Yhv75sfzdVZ TfRevdNORESI3qqT6bYC5yvDp/mQtYuEHSKushUMgdUe/H1KwhlQwetXTK1+jDHaGUSubF7/6p9 +IDVUequTkgnE056kV/o= X-Received: by 2002:a17:90a:cc18:b0:28b:157c:e48d with SMTP id b24-20020a17090acc1800b0028b157ce48dmr6484879pju.78.1704297664219; Wed, 03 Jan 2024 08:01:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuVYYxexaKDE814y1fhNTdPHZYP8ZdcRM5q6bVvyRs+hK/lDTBPjjZPxt/iJQ3BUyAPZfgHQ== X-Received: by 2002:a17:90a:cc18:b0:28b:157c:e48d with SMTP id b24-20020a17090acc1800b0028b157ce48dmr6484861pju.78.1704297663874; Wed, 03 Jan 2024 08:01:03 -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.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 08:01:03 -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 2/5] riscv: Replace direct thread flag check with is_compat_task() Date: Wed, 3 Jan 2024 13:00:20 -0300 Message-ID: <20240103160024.70305-4-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: 7123B180019 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: bd1wrbwn95w8nqrktbi88jb7bcqsahj1 X-HE-Tag: 1704297667-598126 X-HE-Meta: U2FsdGVkX1+RNwEXQklHhoccQkynGD7ZPpXJBQfVdeBnK12riP/AHMC5ttO5AgTLw+C89CXiJzbunFqPJj+3kRcJ7v42aOoC29rbwAxVIPN0I1RV9Gf50u9vcdUm/a4kHq5l+Ch8swMKT3Ua0aO8ZgItMsUtv7AeeuBFi2qkrasKrfbXm9vxFxhif+sYamAFZN6ky2Ofyr7XbJHX7gQpi/xRXX8fsMI95hZwlYzDD5Rpb44H3wZ00GoXG6rID/m2JY4AwSVEU39fM8+cNT2R1iU1pvfRoZ5s3w4YjYy1H1LSgPGalYLD1EEjTeLAdVaG3hzGC6rwS9lAM6VXai9Gig2KqHylcBjSnunVZxl42CU5gsmqqf2fbBlK8EPwLD9AYgLmyPmRAUg9Y7jp+kA6XTDAFZ1biJjAZtTRwwj1E5TZl5Ppn9QY8PSJ0u33JERpWl70a8sX156WvSZVxvObJnDVah4cEdxufhtZF1X5tnN15jhtSeoPF0+Ohz7XTc11hz//VXNV2Hqk5K0+foL2gE4GmYE0KL6sF8MWf6ROyjdpy7cLAXUffYw0vJ+GQWvNKTjENA+BJiPVknUK0hqkH1vmSvJEyw9BnJokwdyrPfWYW1cjS+nIs3zvWb6Sh09kieftMsci8Vkn1bbS/si0yH8G6xgQOCHlxz+NzZMo8USFPqclSj8GGeobJutCL/GwSLq/uZuppritZCfdqKndQomFCfOJRiC+WHOB+uG2m5jpBIyRXoW2/+YTMia2+ySETTjLviLQrDa3sJeE9CnhqcwiJDbf9R1GtfnDCBmQ777QANtjtlBY+QuuOFbll8kBj3PxVNB8vBYHZSvyvUDUcHByHD5O/1l9ysNxqpoxdX56D5WD2g2TLeBtNygHw0i3Q8pqdPQzTKwP6pRboR//nVqKF0bRRxkG3LZc3+sz+NMCgqgz0j1wKlIpodg6Jdd69OtUsWMI6AfbqgrhAyo D8sTr7Ls fJtwxP8gMOJc9qYJ/sjwSqidolmZmJ0IILIT2YKBobqNz0PUfHQtSXTPCHEIE+b+1aSWm7+VuXeA61b/ZaZuGULzKg8fLfGfkYctajPb1UYudotc2/aObzZykFAtkmWyqT0Gt5QTqhvamvY79ytjX4XzaEgwTQQr3kT3PHIGSSYw9wKmenfAnDGmO9jJ+gplLjZco5teHBFmyzG4autKoGOgjkC6X6ws2syOOYCdbGbjCELMbAvSGI5rBE+WOZ76ILL3CWk9p1s4k06qDW1czve1G3Xmwj+SkCvIOUFa+OdMFZCTxleq/zDzmWNreBd2acvRn/1QjJjOwV5trBQTqiexX7GW9zHPsgRIP4KEVOI9oSYo+ofaDxiAYQU/rQtMc0Ynh3ilISQWVho8Woa44u6qDiTl97dVuU5ddue7MKIxu8IooiZkIT5X1mC3nbGNXQ110 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: There is some code that detects compat mode into a task by checking the flag directly, and other code that check using the helper is_compat_task(). Since the helper already exists, use it instead of checking the flags directly. Signed-off-by: Leonardo Bras --- arch/riscv/include/asm/elf.h | 2 +- arch/riscv/include/asm/pgtable.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/elf.h b/arch/riscv/include/asm/elf.h index 06c236bfab53b..59a08367fddd7 100644 --- a/arch/riscv/include/asm/elf.h +++ b/arch/riscv/include/asm/elf.h @@ -54,7 +54,7 @@ extern bool compat_elf_check_arch(Elf32_Ehdr *hdr); #ifdef CONFIG_64BIT #ifdef CONFIG_COMPAT -#define STACK_RND_MASK (test_thread_flag(TIF_32BIT) ? \ +#define STACK_RND_MASK (is_compat_task() ? \ 0x7ff >> (PAGE_SHIFT - 12) : \ 0x3ffff >> (PAGE_SHIFT - 12)) #else diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index ab00235b018f8..1d472b31e0cfe 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -882,7 +882,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte) #ifdef CONFIG_COMPAT #define TASK_SIZE_32 (_AC(0x80000000, UL) - PAGE_SIZE) -#define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ +#define TASK_SIZE (is_compat_task() ? \ TASK_SIZE_32 : TASK_SIZE_64) #else #define TASK_SIZE TASK_SIZE_64 From patchwork Wed Jan 3 16:00:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13510225 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 99CD1C3DA6E for ; Wed, 3 Jan 2024 16:01:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2AB096B0330; Wed, 3 Jan 2024 11:01:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 25AC66B0336; Wed, 3 Jan 2024 11:01:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D4F26B0337; Wed, 3 Jan 2024 11:01:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E7E2B6B0330 for ; Wed, 3 Jan 2024 11:01:23 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7445F40943 for ; Wed, 3 Jan 2024 16:01:23 +0000 (UTC) X-FDA: 81638464446.30.7C70AC6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 3255012002D for ; Wed, 3 Jan 2024 16:01:18 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YB0a5Bgb; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of leobras@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=leobras@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704297679; 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=pGw3FQc0MsxvF9cxW/ZiV7CdITqr1kZ41Lg1YYp8Ods=; b=5pNss1+BhjKqcwu+t7jM+P7GGl4OW/MChH4lmrphNF2GCSN9ZcZPrQseBL7dv6vx64nNOF XAdIX+7B6kEPyBrgxxklP4EfxJ6jASgrAyZ9NVdq7zyX4SnByvGZSmdeA3ijYpBK4KhHGS 442H6G39qcrLfhc1BuzFPwnpf2H5abE= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YB0a5Bgb; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of leobras@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=leobras@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704297679; a=rsa-sha256; cv=none; b=uh8qExRdmk2nDx1/yCO63ZbgAoyppKybKLnFbzW7Sblyi+1Vq2FgPhmBGLMcR+L4XdffW8 aJpECvEjtvVnFrRetIYmC//S9WcXLlrCnNxb7BR5ljUJpfun2eG9CJ2L/tF640m/Fanaef qX+2oTYkalOAWgUDqq3cJsPAEcJVRE4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704297678; 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=pGw3FQc0MsxvF9cxW/ZiV7CdITqr1kZ41Lg1YYp8Ods=; b=YB0a5BgbYGzWkaJctlUt/qkqpTsLztxXCb79hR5TFAknYDEBgr2cLvsFeEPhQ/B8pyIu0K 6bw5wWRYM05KB8Ob6GVYbdFWg6qr23ElYGhH70V2fD3HHOsdipkFBoaeH+lNvoEh5ZV+Ww 6I2eCiJqIoD6Iz/jReoMX+BPCeY/g4o= Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-7Iuy6uoTMcGnzqXaIjyAaw-1; Wed, 03 Jan 2024 11:01:16 -0500 X-MC-Unique: 7Iuy6uoTMcGnzqXaIjyAaw-1 Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-28bbe965866so6292805a91.3 for ; Wed, 03 Jan 2024 08:01:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704297673; x=1704902473; 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=pGw3FQc0MsxvF9cxW/ZiV7CdITqr1kZ41Lg1YYp8Ods=; b=pHRaBU3zauVZMyG4BdkIRTzZi02ieWRRFihwdt6HwgkozwUBVwgEVqm5tlrszbomkW hfryahNimM27LzAUpe6hjJL2yAh8CEUdzIA8GAqj4ys/c7zB4rSHsWkLmxoxkD7rYH9b ikcAyVdgkB6cSwWGgLncyOocii+IaFiHEShJYxp5GGoMcanqhjbhF6FU9OwtNLbGJSae vAAWjKsxu4194pkZAGix6G//hEejpz15cWXGvRh3L6Odd7OU7VdM6ApmE8wzn8vxg+OA QOoidNWYleG+wjn+2lCWdWinr0Kdddv9grMpNPLDN04deO4NhDsgFwBkR1zI3hyGZkEF H/jQ== X-Gm-Message-State: AOJu0YzwXrq24rsaxOfOHqnuQIpwFkto+mxdC1EDP1NSRXaKwsak6I2S uWaV7KzXTi65UJIAOmCnRDk9PrM0zhoDt8SOmay7xQk25wktanIgc+S9frdwqp6/Yu0JmxR0gyV e+vfjZjUSOwBlk+4ehsk= X-Received: by 2002:a17:90b:4f82:b0:28b:cf7f:3f17 with SMTP id qe2-20020a17090b4f8200b0028bcf7f3f17mr6279170pjb.77.1704297673437; Wed, 03 Jan 2024 08:01:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IE2RComsIUtAWCzXZpT7ImLMVrEUH4zz96VXv/Gywk03MIGNb3i0+fYpKYCJQlz+rbFDL1dHg== X-Received: by 2002:a17:90b:4f82:b0:28b:cf7f:3f17 with SMTP id qe2-20020a17090b4f8200b0028bcf7f3f17mr6279141pjb.77.1704297672832; Wed, 03 Jan 2024 08:01:12 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 08:01:12 -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 3/5] riscv: add compile-time test into is_compat_task() Date: Wed, 3 Jan 2024 13:00:21 -0300 Message-ID: <20240103160024.70305-5-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: 3255012002D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: a3n3yfosz7z9ntyb4xe3oyugygofw3ac X-HE-Tag: 1704297678-461722 X-HE-Meta: U2FsdGVkX1+0Frhzi9luQIBI2/stEs4NTtQlZJ0KeWc7MHF8EIxm6tfQyba0eZhgpNOYstUKq33fDgaCX0bSvFesQPDo70jRFfU2OTxiRd03uB6lFEiL2WCBBa909qMHqg8DXNGZMp9Dm6RTk7Xub/m4U8lQbttYTbI6RVUOBCYCqNR9vklyU4B6hizOtqRNv40qdBbULMkyEKX1+7WoHRdex9GhAV6wZEsUKFNd6gqu1ALf2a4eSYoiYPb4wzvqrWFigBPTCjhWXXIaidDrAJOXKFzoinIBwvURAtODbbqknlCaIkxLiZztJUDC0QxgB+K6yfRWGirnijgpmAvNboLPEIHA5PvEK2Ujgn13bJ32f7HNrXjvgorPwFev9D1M0iA1wZ6xG+UkNEbSS73PBlvru1sFcciyIRnUy2Gv/wwfm+TEDc4UVzWf7EluJ0gPfXivJG9XX45ZBiRzNWVPkaN4cFJItGBibgkOMF7GKNYPrMiInZzaSDMhxHzrlxkNjUB5Q+NaeBTSDu5/t8s1Hm2mcuJeXQO0TdoT9EYEDxf/80COrUTIIH+xjql1Vonfo0R/OOJP5YckRO6RGWfUTuYM9ZXVjer1uCSyxCLlwtQUa617lrBMalP2JUXMCjqAlPCxMknv4gr2tdi/ouDMH0lHYDB2VzeGw1hnbMAe/KRS0PiV9A8JYV0eAonbYIb9JfsHsSV8JePfLwFKvsYYFMzFUUOXak6gWJVBi8FAgHTBGTCD7HcQ1U156j0HQx96hQm4BzoGcJ0+15uKPa6kWfwzLxYJBPIHXj2BJubxWsMm0qWyXJ28Ozcl7le3eMnNG1EuMJXmQKvzsQni2dZzmljKvXcciRPB4PZbMRoyub67h0qEF0MYEDWG6rM+fkqXZlJdV0MFUXnrjEEP+PsJoZ3AvZb7L05pgZbTBxQC+0YSm1K4gNK+Bvnp1Gc6XgdkJhz5mvUmnaOHTI6oemU 11gUZGyC vw37ihsTdcqu6juOF01b/APAuVUJN7BxSiV0zNqyyzeUGL1hSCmOwZ9srIrnZ18jT/6WZOUUjq+Wol4DG8cLQ809+rvzocNHu5o9fVwGDzv1RX4AkcbQck+/trorCXr06dKvafqNDMu5Ty2g= 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: Currently several places will test for CONFIG_COMPAT before testing is_compat_task(), probably in order to avoid a run-time test into the task structure. Since is_compat_task() is an inlined function, it would be helpful to add a compile-time test of CONFIG_COMPAT, making sure it always returns zero when the option is not enabled during the kernel build. With this, the compiler is able to understand in build-time that is_compat_task() will always return 0, and optimize-out some of the extra code introduced by the option. This will also allow removing a lot #ifdefs that were introduced, and make the code more clean. Signed-off-by: Leonardo Bras Reviewed-by: Guo Ren Reviewed-by: Andy Chiu --- arch/riscv/include/asm/compat.h | 3 +++ arch/riscv/include/asm/elf.h | 4 ---- arch/riscv/include/asm/pgtable.h | 6 ------ arch/riscv/include/asm/processor.h | 4 ++-- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/arch/riscv/include/asm/compat.h b/arch/riscv/include/asm/compat.h index 2ac955b51148f..91517b51b8e27 100644 --- a/arch/riscv/include/asm/compat.h +++ b/arch/riscv/include/asm/compat.h @@ -14,6 +14,9 @@ static inline int is_compat_task(void) { + if (!IS_ENABLED(CONFIG_COMPAT)) + return 0; + return test_thread_flag(TIF_32BIT); } diff --git a/arch/riscv/include/asm/elf.h b/arch/riscv/include/asm/elf.h index 59a08367fddd7..2e88257cafaea 100644 --- a/arch/riscv/include/asm/elf.h +++ b/arch/riscv/include/asm/elf.h @@ -53,13 +53,9 @@ extern bool compat_elf_check_arch(Elf32_Ehdr *hdr); #define ELF_ET_DYN_BASE ((DEFAULT_MAP_WINDOW / 3) * 2) #ifdef CONFIG_64BIT -#ifdef CONFIG_COMPAT #define STACK_RND_MASK (is_compat_task() ? \ 0x7ff >> (PAGE_SHIFT - 12) : \ 0x3ffff >> (PAGE_SHIFT - 12)) -#else -#define STACK_RND_MASK (0x3ffff >> (PAGE_SHIFT - 12)) -#endif #endif /* diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 1d472b31e0cfe..ea5b269be223a 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -127,16 +127,10 @@ #define VA_USER_SV48 (UL(1) << (VA_BITS_SV48 - 1)) #define VA_USER_SV57 (UL(1) << (VA_BITS_SV57 - 1)) -#ifdef CONFIG_COMPAT #define MMAP_VA_BITS_64 ((VA_BITS >= VA_BITS_SV48) ? VA_BITS_SV48 : VA_BITS) #define MMAP_MIN_VA_BITS_64 (VA_BITS_SV39) #define MMAP_VA_BITS (is_compat_task() ? VA_BITS_SV32 : MMAP_VA_BITS_64) #define MMAP_MIN_VA_BITS (is_compat_task() ? VA_BITS_SV32 : MMAP_MIN_VA_BITS_64) -#else -#define MMAP_VA_BITS ((VA_BITS >= VA_BITS_SV48) ? VA_BITS_SV48 : VA_BITS) -#define MMAP_MIN_VA_BITS (VA_BITS_SV39) -#endif /* CONFIG_COMPAT */ - #else #include #endif /* CONFIG_64BIT */ diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index 2278e2a8362af..d2d7ce30baf3e 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -28,7 +28,7 @@ ({ \ unsigned long mmap_end; \ typeof(addr) _addr = (addr); \ - if ((_addr) == 0 || (IS_ENABLED(CONFIG_COMPAT) && is_compat_task())) \ + if ((_addr) == 0 || is_compat_task()) \ mmap_end = STACK_TOP_MAX; \ else if (((_addr) >= VA_USER_SV57) && (VA_BITS >= VA_BITS_SV57)) \ mmap_end = VA_USER_SV57; \ @@ -45,7 +45,7 @@ typeof(addr) _addr = (addr); \ typeof(base) _base = (base); \ unsigned long rnd_gap = DEFAULT_MAP_WINDOW - (_base); \ - if ((_addr) == 0 || (IS_ENABLED(CONFIG_COMPAT) && is_compat_task())) \ + if ((_addr) == 0 || is_compat_task()) \ mmap_base = (_base); \ else if (((_addr) >= VA_USER_SV57) && (VA_BITS >= VA_BITS_SV57)) \ mmap_base = VA_USER_SV57 - rnd_gap; \ 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: ujqxxz3tjuh4fjsy5f3ua8mcjnzykxxe X-Rspam-User: X-HE-Tag: 1704297685-449024 X-HE-Meta: U2FsdGVkX1++3hd50FVuoHrOtueQ4lpHguD0f+0M763pgg9nDTQidwjSXruMspCwl+ZbU1c/TMdmovTOKDy11L8iwqz9esY0xloMBtHxTZdsW4twnCRKA+JwW3/+raRwlhgkk7vCcEB/slrX1KN5kVjqBGD0hKHYdAoaIzzP97giAfD/w7P0H9st1bGFkF9OBdLeqKN6kViVnnd0hYq6F4Zf2qyYqYjLyWYavsDDC8cVz0XHa3WsYoXpr8K0a3ywzy5pWzfxsta8HthdHIU89Wspmt89FPzmg6uXuyrJQEb0cwORKCBdttDYB7ViLy0QpTrK9NrXqV679/HZUqPWkQO3bofa85qFydLOOueeSIIga8oyI+NBXeZo6o2kBkxJ5nXVLwOcyIoN70i4c1Rlf1/GFHQFbXF2KIqdvLnOYQgV4VhklaPduNz/EundazD5K/fHhMY6fwjNJKoYIUq05KAof5l+KcpIf2GYZE6MjyF8YC0PsEdoqCbliOYgCqv1MR6bqibSLfOr7lZ1qqdNRDCQXVk4XvyRL0eZGCygSkKOy+WpPhSOtEcTUvoAGqDmp/Ob7RevbIz5j0XyzKaaMV4t9U+zTyFPkhjQRLpCKNbpHLz5qqVRhoyQblktTt00n+e8ScgUf5rtYZzGaW5MyegmgGdKhvEFFoDBW48S4DBu+7XbUHYrfBfWKdZlpAy/BnYjfIH9Nc1d0hM28xfzFvg5JFoz3gwfcb9YpTSWj6HrxWujOTcuZDqQJXhKO4VclCr/pDCT/m3E4rASzgsPca+45adryRQN4CTn9WRH/6DCiLBjJmIX0T28ujQ25lncMLst8/FXIVJLl2N987Zr83thF9nevFacrxC+dRPC4vvjPHI8G0Sg4TmBZhlyGyrp5jy213DL42PdAZ6rUPhwB7N6W0K3Z18dNGZRBVPGNUaslTVYe8UAO9oAxr1yV7tbsnmjFdCmG6kvSx9c8p6 mKlJGlx6 ax0wRDi9XoHssvtv++gLD7EgP9zy1bsLtIOY5OCGOt1JNnrM+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; } 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-Rspamd-Server: rspam01 X-HE-Tag: 1704297693-847255 X-HE-Meta: U2FsdGVkX1+eiBEsinTrCVztNHiZXEL++BljpJxRYhhiK66aXCAO8RP66NRnHSw83CdSEyE8YBf2bpiz17YzwrtxmTxApgg1cCiVpzLX8LWdwLidwRJtZPdL9l+WpVCULew8DTL4rCMU/bZEg4RdeAXfsQVpSKu49CCcgn07w8wbkpMd0bk6oL2ki/EzKHeMGIoxsH5M2uQIeExNysdgvd2cmeCTM5BI9/UswASFPBcEpqxsT66iaUp8XkZOcB4fe9UiAp9VALmyvqPWrMshCwy9Aj4iB2Rbbn84ZQCkb+JCRSh+28YptrLx0L1iqJZFto450v/S3nM5U1e7i+tIDEgcPD22lt3Kyiz5Yj/0C2Uk7P3AC7wso+zGFasaRMSyO7l/MZu8fBwKtzoe9onHBufXRmRsr4UCaVVSVWKxefAYKM0djcRQ9I3aoJNhzTZOPGZyi9oqMA12+kLYvvoD+dnvmNrpPOVqP3vImimww5Ck6SXTaEs/j4bZanLNfMMPNuD7Pb2OexeDPjup4YT1xFNKW8bGVz2At7iRsuAg0e10KdwIqwUVBixO1vkz22QTfWTQN+Nh4/E/gtf2PGi6ARMjrg20x1tcjYVeiu/GEYjv7LnDbjmfBRYsnfmNUyXKTJgIkw6sgkEZnjI6K+5Q7i+RJBUv6yog7xtbxcGLrlwBcYP4sEQCxfRK9LpKvaRjBbtD6AEXQKGxPVwqiluU/mSyFOlwy9OpLWIS85hXHhT6f5bHze9FDPyyI9rNaom32oFT/u4TRYgGiQhLvnTDfNuk3uXumQ/iiVfOekwl0xpze00ZgLDHzInGkyDJjTGTq/UQf2hzX87QG/+JCPHRALLyMQ22KdJm1ImRlsBeZqezb5jatjQEIbZM5AhGO3C53TXRV9aXqrFTZsTZI3d7bm9l2uq/v/NNcRS1ynhLetzGnXUUOmkuF7gRXgjhtBwqQ5YzyOro79LtSIMxUlP 4JvGFW+o Kt8xcUeuC+iDw4FTFJxnRqM4gxNeh6vTEkD1HOGBaECJUA19WI6fn1dQsCD0vcB+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))); \