From patchwork Fri Dec 22 07:46:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13503067 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 05E81C46CD4 for ; Fri, 22 Dec 2023 07:46:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0ED506B0075; Fri, 22 Dec 2023 02:46:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 09DC66B0078; Fri, 22 Dec 2023 02:46:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E7FEB6B007B; Fri, 22 Dec 2023 02:46:41 -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 D4AD46B0075 for ; Fri, 22 Dec 2023 02:46:41 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A8131140338 for ; Fri, 22 Dec 2023 07:46:41 +0000 (UTC) X-FDA: 81593672202.14.88FB659 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id A1D2214001C for ; Fri, 22 Dec 2023 07:46:39 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gjULgw2E; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.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=1703231199; 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=5ZTb3X6S2yAiPER58jblqqGqjjnTAvykMLu7KfVmsot5MU1zTu8qSB6QDL1ontBYwTW5du AolHFbHx1iS3kkYAGffQvvEaiwuU6rfwl4YY0KpQs/FXkAggKBbgANzdbTtfOKcTZUtvip lW4f/x1dyBgCBE5ZT/jIrdr7qT8O1hA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=gjULgw2E; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.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=1703231199; a=rsa-sha256; cv=none; b=vCX5qlPAZJvexEQBZmjnqr31HLUPk+VvQQHzMOiwyoIkgLidxJ1PF+JjFbuH2kamXMh5+N MSwtyzNKePx1+2aVpmVPRLmFEK0agRJcUbpqgliJBg1P76mrId1aji8aiSs19a+0EavmfS MQbg8M9xpvimgtH9lXzkfHZQHDkGvaQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703231199; 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=gjULgw2ERygmkaSCWZ7fwpOSzXijqvBwPgrmxOT0ZhgsuhWah0uN1KWg7yLigInYPCern+ aC7fAbNmcDUlPl0xFez5KKBTeOifSLNDoyjHyCNFojrCz4INkM6NxDeC0aaPkZg9TdrpoP jvYI9npEoHtg3xmZDKAhem3mNyqHGj8= Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-556-7DrFq8AwPjGpwQwdmVyOYw-1; Fri, 22 Dec 2023 02:46:37 -0500 X-MC-Unique: 7DrFq8AwPjGpwQwdmVyOYw-1 Received: by mail-oi1-f199.google.com with SMTP id 5614622812f47-3bb761408f9so1723437b6e.2 for ; Thu, 21 Dec 2023 23:46:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703231196; x=1703835996; 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=cS2Vr8v35H+YTIxoAxmr7LlWjnrdHpHDhyW1W9H1Zqx2ouj7f2zs+ihVz9XNPiEg5F 31/QOY1f6rWxg45p1X3J3ltjfT2MhZm9b3rZKyRrnPSAD4XAuGXwE7qkY6S6C9PEqPXJ N+ncROi4ik0gwGeSNrvZlTh7K97Bc4gNbVM55nYQOQ6Sq3QEOtRgrkjvoz011dUG1OK0 sDHd5CFMyA6qlihuONK3T3mwD0TtCAu/1tRWF6BOgstibakXyQRkp3IvyOxckauP03D9 UO4jI/3E8XuhCeXHEHGTdaUQN/sIaT3Gu6w4IqNuR7WPMFuwzCbdOxU0Vr93OncXii64 9qsw== X-Gm-Message-State: AOJu0Yx26JOKBQlyoT1ZJJhzGwaIHBh3Yb3YkUo5KVvYDjiQIkfj8bDU e2GA3zU3BIDImlr8fRA04c/mb/ldxdMMuH8J4ave5gefD5vFLjTmiysJ9IlwFrt/JdfVv6lM/me RFcX/75cEcx0mvi3XEm0= X-Received: by 2002:a05:6808:218e:b0:3a8:7c67:7cd with SMTP id be14-20020a056808218e00b003a87c6707cdmr1261209oib.24.1703231196681; Thu, 21 Dec 2023 23:46:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6noE7Pu5xAXvjh6CjMsnvaqxm6CqicXC5ZlFE2NmSpCIPLtETaqNzkTmN5ZP4z5PF3/bRXQ== X-Received: by 2002:a05:6808:218e:b0:3a8:7c67:7cd with SMTP id be14-20020a056808218e00b003a87c6707cdmr1261182oib.24.1703231196440; Thu, 21 Dec 2023 23:46:36 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 23:46:35 -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 1/4] riscv: Replace direct thread flag check with is_compat_task() Date: Fri, 22 Dec 2023 04:46:01 -0300 Message-ID: <20231222074605.452452-2-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: A1D2214001C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: p9bue7fk1m8k5hyjawwxm38q6bfei7hb X-HE-Tag: 1703231199-621799 X-HE-Meta: U2FsdGVkX1+AeiHzAG7c9LNm+/Qvp+oeaMnKrRhysze3BBcz5pcXB+AoH58tmJGPyDG8VUpF8/fVaZfXgsR5Lm0Q44iCNoEJAsj4sbADwvxnNKRejBhwU7JpADhmmFXvVPBbIbPbluxyBsm1tJKfSdXGuDWLL94OoYoEdsER/tv1gwPBVV61pxJffvswnBdD264JGYLJVUL1qUlvxhtnjBApyREVYx1d8Pb4OXgjd0xHHoi7lgQtufjtDt+o8QHburB2571/PrK4yywd+XUpczwykNsR4PdfcmyHd6XZjaSTicKn8ez66ij/WZvbWkekvG7haMOKs/Iuzk9ZPr9ReNjfIdn9NqMQQtXt+PhZeceeast5kx9NmtFmbP/V1vLYBY2TAnIBDULs5tALYvAFjxYFSnCp1Z2TcnkLxhfgvVTWP0fqcTYSb7vXJUI7xrfLcUTA6a2+g6Z21eWtosfqKZggDOWo+gPASoC2TcAdzRPlNkxXGTQp7jA2rT+pClSs4I0GrlHo7nqyFD6/99aAVnnYqKcvP4fGxxPttanxMOhBv0Nb31FPKcUZ2jL9/BA1NmqpWIe16O08Pt6HrGFT2NFK560xYDCL79p/jweJ4fCyRMi9Nb/vBhwyZv9115JZp1WpPeTeDdE0iVVbAAHgC05iVec7/drFXaiw5f9dtmPhQfrdwtdSAab5s32qrablRX3rK0MGhQ0gquKpjs+BlONMszTzEbibUyAKHLvNabmHyT+Go55qWUGuxQ9Pk9Xk0yYmVi7wJblrTCS0+d3MFlMsEqU4EZ2SJwb9Zk1Ka397YPYFl6uGzypLeysXae0h9eWvrBlgoxNjLc03/hrS3tluy+ZQXBKdp1emb6nirhGWkxr1sha7M8oSfr0oNdX1nf1nuE/5pig7O219DGr13/PiXrGhwZCWxqmQS+PFtl/yOYlDRpYrjYZICRsSUtwT1nRF+9rHdE6wBMj7E6W PJWjUaa7 JpA8roWcZ4DR/q4U4p/eiK1LO6ILEnfx5vaBm2tFyRO1Hd1PYZXl9c1LcYykDFxx1p/BpuNb52zbHmGvPClschEJmzsu69SePYW0oH0gtAZ5OWE7jd9W2O6UNgs33RF/B6mTeDoeCswogzDPeBx9Cf/PoY2A6s4h7XTpwZ0JdhWtVhA9kQ9WD2eGjzuvR+1zR9BUGj925TAXGZeKdiCQU+ei/BzpPAyFuCfRAenWeqW/LLE0QMnMDL2NqasYoyg6JX9aVpTYx0FEvWW+mQ9GgdXZSHmPSLEe7L0rNz2riOYbxQGm33Zpkze7i8xPwkZ+4CZuvWSfgtXfzIBekAdTW2sWwdvXJN+DsVyUZphkEIFp4kn1zlc5BA7nRQqZGIp2svasm5Vw5Xl3SGuxfYhar6MLcvFG4YkcfaZDhZfqrCQImERjvUq3khm1sLwcOMVT7LK18 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 Fri Dec 22 07:46:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13503068 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 3244DC46CD8 for ; Fri, 22 Dec 2023 07:46:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B6486B007B; Fri, 22 Dec 2023 02:46:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 867506B007D; Fri, 22 Dec 2023 02:46:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 706756B007E; Fri, 22 Dec 2023 02:46:50 -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 5CD636B007B for ; Fri, 22 Dec 2023 02:46:50 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 307A840399 for ; Fri, 22 Dec 2023 07:46:50 +0000 (UTC) X-FDA: 81593672580.06.6B9A6B2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 3114C8000A for ; Fri, 22 Dec 2023 07:46:47 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AVXG507g; spf=pass (imf02.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=1703231208; 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=fChu8SySxAk9bR4FCWD8rViiukJB4FWPqrqCbBPM0wY=; b=h4Yx1C+zROjkGsHHAxNeJNB6uPoUwkwnZrjX26cF2aZAAkSRCNlDza5lbQgJUDc7pWo+JJ rlNhN3KVxQvGK/QykEKp9LhqBHbIi+rbb6XKfOuno4VmQxjwNtoxnN7qJGRPwicNlHmoN2 tx/1ACkwNuyKrkT3rCsfNhY6R/krtJ0= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AVXG507g; spf=pass (imf02.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=1703231208; a=rsa-sha256; cv=none; b=ufKR4kZWoRx2TT5QTc3/8lR+17z+rXF54ZGi+NNAnFwJjMTBXOgjQ9Xed93hZtnPia42bK 1n2z1YZvkNZXxlFspoejnV49iC0osKDQIg64vzvFOThLFi1ovA/lQf6o9smmaengl+xJJL fV+URXAo++Ca0yLisen7z5sxXxXlAN0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703231207; 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=fChu8SySxAk9bR4FCWD8rViiukJB4FWPqrqCbBPM0wY=; b=AVXG507gC4H453v00p+C3J6H37yhv2Y2m9Pkkcavp6V3a6s7YhfQkMyHlh/k4qHLTT3A+b vQ/ENfedxI30Q+5wJEOpa86yuv0Xn93vVJDFtVTSCuBcK4mb44Af05CbeOiXuzNgwSrhFR ta7NVER+Gwx9Llwrf1EV78j0qTVkt3E= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-523-Xn9PYzEkMtKQaEY6LUlvcQ-1; Fri, 22 Dec 2023 02:46:43 -0500 X-MC-Unique: Xn9PYzEkMtKQaEY6LUlvcQ-1 Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-3bb8a3e268cso444468b6e.1 for ; Thu, 21 Dec 2023 23:46:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703231202; x=1703836002; 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=fChu8SySxAk9bR4FCWD8rViiukJB4FWPqrqCbBPM0wY=; b=rmTJHKLx1iuRrZRQUlevbzXIpzdA0hOweTilGnLEtUyqu6/ENXjTcXggP519OUXSjO 7P0JksYRxG2dQGVgiW2knOaVHjLUUwBFqS7t0AKQGbhlVvCjsrhRTZjh8+CpcTRKdTld faWIi7ha496XmEQ793ooRL1Z6N7UATWuN0Cn9WFm/1dlIACnG+WJuJ0Cg+6PwXBiKSMg wrIKv93x4vhHDsBIPFVtwncMrLy2cRI/Kf6vcL6AJQZ1I7dEDhpGEGCr4KOX/RKa0wU5 kXgVmKxhFuH6jQpyNfSTQuQTJ/t+qo1PLaUxhEv5edYLnxbE8+J0wpGjGu1Z7TahOp56 W+gw== X-Gm-Message-State: AOJu0YxsdrgJB/AQLKaRXMAytXpxOLUFSgH9lyYLbvNAO/H9W6gorBh8 R34NmqdfLhZ92zx2knelghDhy+4ffr35JPsdmoY1GbmSCjvfKpb0u72ywM92+Ga61/yguN0Iopi CNGxQvATBY0Kmy9LcZ2E= X-Received: by 2002:a05:6808:199e:b0:3af:9838:8494 with SMTP id bj30-20020a056808199e00b003af98388494mr1174163oib.20.1703231202614; Thu, 21 Dec 2023 23:46:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfty2NP0/+vK/Z37DtQxU8NTNsz0hOUOMzPkaafOkXIkbGg41CPwcD8fDjKPqNGVFT8AzCRw== X-Received: by 2002:a05:6808:199e:b0:3af:9838:8494 with SMTP id bj30-20020a056808199e00b003af98388494mr1174135oib.20.1703231202376; Thu, 21 Dec 2023 23:46:42 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 23:46:41 -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 2/4] riscv: add compile-time test into is_compat_task() Date: Fri, 22 Dec 2023 04:46:02 -0300 Message-ID: <20231222074605.452452-3-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: 3114C8000A X-Rspam-User: X-Stat-Signature: cjmwx93zuzof87k4fc6ppma59nj31s7s X-Rspamd-Server: rspam01 X-HE-Tag: 1703231207-419980 X-HE-Meta: U2FsdGVkX1+UhGdBZaJCRBFTyg7x3t2rAd4uEKIlbnivK4jtrQptDF3+pUzpbBc2EjY+c1Cwk5j79LeEmWqzWr2SSkGgvyqNCS5yHdL+b7Do5Uu+I8S+AYvmZZWB65y8vMEYZAMpcChW12woxf7Tk/+nitY8RrSkkOFE+QkdJmJLu4lzRm81Ky7Bhxa+Zr/RMwbmTT/Pu2PfUgXCjhgiWsBChcAczo9trfSggwTQKz/s49zGMGO4EsfMjKhkqP4qcKF+C8UnxQM4iEeUUx3Rk2FJyS+N8ZWq0+AYb8/nMd46hiMgpmGHQQtnsr6p8g4JLDl9WB8hDsTPcTo8aeEaZuHbKZj06KrjvHyGcQ64ttgJFzGBKHA5vCprsAqqeKVJtBXKsvg8va4vnrpnKHKGKDAB1/gRzqfey0tTv9UFn6uLoz7jrebmwAApe4uxMunL5Yj0RHDediL1yVw8sxTbd+MoRaBQ4oY5fyiFSbL/jjoQzbnZos24e8ohWEF4AkHqOB+x/O6SE5pmm8fNhBltPWLWlI4xpEfKZYTanzw6TDf9fcVUUkIxN7u1hMzAF3asG8EQw/VHUAJRU900heKO9YhcqM5MjGJOeU+3tKJ2XCBBUtDQ8nAtdcM83vYPGbN/JVmtyCz16nv/UELCTysGQkemPLeAH0aiFwiuZTpxqYySD1bKs5PJbM6TLGcbQAXTv0gYMS2zD2lKDVkO/qej0Gc7AYsSx0HDFv41UUuGny7HEkwI9uW54t5h+Xi8FQ81gJJOJhwMgeyCX44GskRUou29aXuHLvX97s0PTMOfF/9Jl5/yGgTyqFknKaiQYI1ksWfApPRysR4x9F7dVPZPb5hxsqk3T3c8zxm6Xl3Vm5lwGV+YTpLsu9hfjQxm/LyBWYW9SdUTLhTJ5hxMV63zNTomuSQvhRgGYnBJ3nnJKbg0B+Cv3xazxm1Do9EVrnDoYFPKzBV1zcrA63vYqDv sjDca91n mSMAfa6RT8qFvqCE76/MUF8v12S5kjhALZOHQSmOzp0mblKfSp093f/rZlBigM6EtquC3GzqpBwyBB5lpVUXmvOXcTZHlynPkr88HjUJ4fMWkJbwbi8LEJT22gWYogV627bolTlsXdPM817I= 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 f19f861cda549..ed32e53e55999 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -22,7 +22,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) \ mmap_end = STACK_TOP_MAX; \ @@ -39,7 +39,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 Fri Dec 22 07:46:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13503069 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 0193FC41535 for ; Fri, 22 Dec 2023 07:46:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 58D226B007E; Fri, 22 Dec 2023 02:46:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 534026B0080; Fri, 22 Dec 2023 02:46:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B47B6B0081; Fri, 22 Dec 2023 02:46:54 -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 272886B007E for ; Fri, 22 Dec 2023 02:46:54 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F11CFA0738 for ; Fri, 22 Dec 2023 07:46:53 +0000 (UTC) X-FDA: 81593672706.17.7EEC2FE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id DB923C0002 for ; Fri, 22 Dec 2023 07:46:51 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eZODkezz; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.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=1703231211; 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=CivPyX79A0Z1hBiu+NIjR9u/sMwnUQBrdiWOV2RqYZw=; b=6RgV9japp7eyuaNGT55Q3UVsa6Y8skZceu3xlrdGwS+WA44VWL9fimTfWWPJ1ygyR5zpc9 oqmu9F6WoVYOMFpI0MqrfeW92Izh4nBpsXFJ6lmrpUBtt6SKsIjTZ5R5dLWwoQ8INePKsS C/sJUPuGQkVGgyQNPnXvdkwE3rpgxTM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eZODkezz; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.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=1703231211; a=rsa-sha256; cv=none; b=8bYIay8JAqToFpNxYSIPaTg7pmXOjEC/bHG/ZyMsTKEIaiHXpID78RZdZ2eC7Mm+RQYj/O xM5DvMxUzPcviHptQcKeGyPFHQAOoV6q7ZlSpTQBFbZSJpYV2gN4WxkGjG8YCafFhbX3kQ BtAgoMlljKvQyn/sxm/wQyhtfouZxiY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703231211; 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=CivPyX79A0Z1hBiu+NIjR9u/sMwnUQBrdiWOV2RqYZw=; b=eZODkezzb3ZKdOlfJTCPfoqEPQWfs5NbXT3WfZwSLeRmx8ds6PiSy0elxsDmmm/V646e+4 YWsvq+ntrYAI+YtYEIvUzaUU45Rt9HaudtCXUqq7Q7gkckigAMXuZL5VKWcm4PAXu4uTUa uab5dZaYUdnlW/sIH7AZFD4S/dZjvfo= 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-657-nYGUPjvLNaiudHzB1MTaPA-1; Fri, 22 Dec 2023 02:46:49 -0500 X-MC-Unique: nYGUPjvLNaiudHzB1MTaPA-1 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-6d26718254fso944359b3a.1 for ; Thu, 21 Dec 2023 23:46:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703231208; x=1703836008; 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=CivPyX79A0Z1hBiu+NIjR9u/sMwnUQBrdiWOV2RqYZw=; b=V5NQ0vl4ejYgOmR63aWFGcwQYyce7i92zrXalTX7ggc5Rw4iwWaEE6vOQX3AmnjXaX 7XgDW6dijF/XOUvjGxx/OMRyACgbCPs8+e79OyDUnymSv83jgI5LQiBd+Hvvm1R4MqWQ nNZZ9+MwRJAiWLCPAI2O5m6/4aUDTzdFXfcyviPPeXbAWU2lI+5327l8Iv5gnkQUfG+T Ce023Fu9ISvTIfy8ybAcIAs2ewXQUHZFv183IUTgjqk75gbvrQ0ICSOWUsfFZytIFyFL VbmDtJdnebHCzE3A/em1pH0LZZ5+9XAhFDDs6pC/GTbN6yhOuts4TOBBfEn27z6wt9mc jNnQ== X-Gm-Message-State: AOJu0YxHd88WYH7dDgRSFoVkEp2hUVnMAWSpZ2b63SLP2TzZjFMl8Usr tmAQp+Dl1yN3P/6TBoy3TGAgMiuQxUA/TkQXVJdIiiOofPSLM0oGl9+r5h9pvN0ojNs6Wp9o2Ng DDks1MFS2R27LBbNjKJ8= X-Received: by 2002:aa7:930c:0:b0:6d9:6261:919e with SMTP id cz12-20020aa7930c000000b006d96261919emr591314pfb.19.1703231208667; Thu, 21 Dec 2023 23:46:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3ju0vDAUEHX0GCDDvkiFL8Wq0IKN/wM1vpTmL1pxShU1txvq7JIxARGiDwyFtjeAX5+gIOw== X-Received: by 2002:aa7:930c:0:b0:6d9:6261:919e with SMTP id cz12-20020aa7930c000000b006d96261919emr591291pfb.19.1703231208347; Thu, 21 Dec 2023 23:46:48 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 23:46:47 -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 3/4] riscv: Introduce is_compat_thread() into compat.h Date: Fri, 22 Dec 2023 04:46:03 -0300 Message-ID: <20231222074605.452452-4-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: DB923C0002 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: hryid37q7es4836wn3uxjma4et5c18et X-HE-Tag: 1703231211-339817 X-HE-Meta: U2FsdGVkX1/iWdq7uFOB9fgYzoM7ZDxSd0reGQbj1fsYNuwLGJgrBlRw0MAp+OopF+gRNPmoHiiMlOAotJKW+wAI4be4MsaQGu1ZuYG/2yYAgtqmzIedzS29t4/KlMopejNck8KrNJAoTk+p1NGynfCFtEg6koJ0bWBSVMhtPddG9qyLFevHOtn4vX0smeGvd6y23qsTTVrbs5vv/aev23LKDb8WLkwTZeyMJaCEBvcIPXEYvevDmo1sPpeuITshkUlwozuYWRfBEwf3qgz3JNA9+EojFB9O948pCb3sI+gnizsFO7Xzwpaz5fPpTbse+OUfu4zwq+r5bUkt0gJ5UKm9TXkKRZrDI6nHhOoM6r1qskCP6qHo4EGE52VW3Z8aohmlDRx0jGexWLSMz2vRXqdGQDZ5n8VoGFllBsekRgAcJB58JgcvXMKngTgxbvrV+HiGI3lAbVWIMRmgtGYmTuShrTDKbEzcYJaEi0xO5Ao43JJ6YzqgTQOA1od4Zi1kBeZsAGDHrUu4G2ZVYXZLmTEc3j1MYC+zG5eAsTTLKUSyD3GmOx0bYcVtJQthWYStoHcUr8VgWwSE6ff/NO2xAf1H9eS+3OxskUgZ7qDAC+lqj1MSaTLDTDRHgpctn6djtQ7bflvXzt9dfxGrg7yM4G7rQLxcv/5gy+jvCmGW5TNEL5J94wy7+a8aF6da+j7vvDQe0J413S8xXvwEnQf+ii9tevp+E0EtLCZYBnpQaK4OnXgGMcNJ1uzat3BRlJ2nCfhwauZPweUz5T3xFhCZRkWgbDnkmcZasM9WUqosmw21l/SHG6si+l45vcEN9obF1O1BES6EjfWqZR0ugfrDRmrPirjHpjjFHR8ruvwyp663qV//hLPHc/8d2cXSxfuylKzn7SuOyHuK5oDuDFCi6Z/Fpg0UO/7iHwyFihCF+ZekILMKHsqQwqfAXoQF2GoK1TcWJjWOZBpB4uXBTmv Sisc2bId XukGZwJhtEhdTVML8bSyPoHMQfO1VAefxCOO2dkvwAHvQ62XsVClEfPbdZ8P4ncDeYVbvK08fJDE4HSdWCZGArfbRSMY2WQJ5X44Z9svIzaq0YnbPfIQJZOFuhBIAKGD9geS582oEjzfmjDAKNI0z2YCYWJjR182h23ZdfXDBv2044ROlv/TBbjMch+csZPZaVB5v+FtpXEwOcK+FlhJdIJb4Zjxx/47FCCghL79/oTYy7DhfHkv4dwwUuJSdfstMTXoIu8PhIc1nJiUvg7GEJ8XNTMKYYBhQH/j9EM+ox9xA1uUj3OzQ5yqSrI7jDJSF4WiouUi5dl6iU0RApPJix1vc1LhdDLHfxJzLsupOKa1lkQhGamcwy6IZ6zdz2Tpenht9KUbTEfGsbWa9h9TRUATaP3M/p+1U7xeRm24f69m2Iq4hA1vMa/UsQ9MZLdNdpKwa 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 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-User: X-Stat-Signature: fpzt8wzk16i63namkwyd5jfzc3p6tgn6 X-Rspamd-Server: rspam01 X-HE-Tag: 1703231217-174059 X-HE-Meta: U2FsdGVkX1+SkclBq8wFsmqfzxhwd+aVgN8FxwquJXQqOfb95YeAvEcrAkx1DwCUgHaN4dOu3N4KzlORTPoRaY7im61GjLzBPeNG2IwC6Fleeh8xxKEzKSnIYscbWNyYJSx6KZ46RsIERZEseZmZpAXmdUeqFXLbvJo4BER9HqXvyBFijc7bbawlpWaZaXco1LvawLnJwgjb8O8ttavs/rcph3QRqpGJJ2deUY5cEvEOW9Ye6ss+pwC7Y05sH94myhTqNd8ZaINFRhgtKw29u/GpVOAOvMc7ufwIXf5xTenZtOc93Lc6emOjj7Yjh233Jn254KAc8ByHx2UbzYnSFu4AnWzQ3ftR4xKW8REML8LkYr9yv42sEKXnzP8CkWy4W6yKeo7HS+WNfKTRUeoGwNCoi1OVxFnIjcIGCpLZUw1Rhqoh94eYnLN9FI1reabYHpSYYBS7HuyXohsJioHKQCVSV/IllbRmgL1yLA3vgCg+LhGVL5X3b77gmUCczMslM0BlqGRpyaWmPP5wKsUQB/RONt3YTy+z5JkYz6m4R3R53pWaE3SHu3N7WH0Mh5yEFhnaIJ8xdUjz95Xh/EweSNDDzPZiSIGQq+tUGuKtqZnlyPkkTSWhdRdZyUJoa41b02LVADkOpSJEqspBdUGmSHDvxFIqcmbvYnYB4anQxD/EEfKHrJQwSxCjVLldZGb17pKeuvOv40YHv4MnFoBSsRg5FiGfdrS6LdeMPflz6YTBa4RaDXMmg9X3xVZIvN2E1LG++wcUu3i3L69+jiLQv+aWVwxNfaJiFE0Y8YPqJ4Ro1S0N7H+U4EhLGJ0nS5l8iiArB2pEXWDRbZaOty4ZSB06tGkYv01g0Q4sZul89cmvxdDiJ3yxxpxl8gPiNnHg7xk736/9w4xhDSMPrzyoxc8h6fBlzIv8/v19DcxTPERhG9qJVRt4XQ1qQGrj8Sicaf6n8c+HBkKhrUcUxld sB2Ly0eN 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))); \