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 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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