From nobody Fri Dec 19 18:44:26 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2163D168BE for ; Fri, 22 Dec 2023 07:47:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DjqhbIJk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703231219; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nJKdTz0fBLuk4zNW5VLOm1jY/M0/StXJiYDFTohFsJw=; b=DjqhbIJkAZIEPaWhWuFyQGNUdeYwTj0hTQnUIVtDgcPkeXJ7bfsoTz8icwKLhT6ie39ZuG wvx1GILBYCAOYG23jDPEj450wV1cmzb+Nl1p7Nwz9rG/XHL+ZqIUyYrGr7PEbNaaagr9sP r8+rAeNnjZ3zom/0YACulcoYrF04SNs= Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-290-XAa0y1LIPzytKDxcP7-IuA-1; Fri, 22 Dec 2023 02:46:55 -0500 X-MC-Unique: XAa0y1LIPzytKDxcP7-IuA-1 Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-6d7e5d286a1so1180982b3a.1 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=i1Bl+5T455m0DeJuHcgKsa7lMxa6Vqd53sLJFu9bp1RuA6JaeW5ptp28tfy+Y/7kfi qeH85Qu8cRmqlPeJRjLieyOUK05um8OtmzT+T5dE9u/Ab4zWT3PE9sRoC/d3FeUI9Ufb aHbDlVf8wGkajcrx8ATRm47fEHNahDh1GXpeMkWvdjkgdDjJOHmWOzFWmOW6eWvzCfHK Sfbjr3BW2LnLUFN4nuSfLczlXGF9JWRZMhKs/xIKY9io5qwqNb4gltIGgrEpKF3yJ+BW iaG8rNcq0pe0L185/25cOGoXCF05luZ7KJtUwAIycT1FnLCgOofoHUMjErXDgwGO3A+e y1dw== X-Gm-Message-State: AOJu0YxD2XX4AjnK9cOtPlAEMlDweM5KewcL1k9mc9j3Y7rDleGIpB3z qq04yLOmNLr4EKWx8JWh0CnGi3qvnEr4boqVOwdf6BdncB1QFv0qoKIM585Tts5ko6p+32W4aHu Lno9sw9ikzjG9f0DM+FG5EwIHOwQv5Z9P X-Received: by 2002:aa7:9104:0:b0:6d9:3659:5419 with SMTP id 4-20020aa79104000000b006d936595419mr998852pfh.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?q?Bj=C3=B6rn=20T=C3=B6pel?= , =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/compa= t.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 *t= hread) return test_ti_thread_flag(thread, TIF_32BIT); } =20 +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 =20 #define SET_PERSONALITY(ex) \ -do { if ((ex).e_ident[EI_CLASS] =3D=3D ELFCLASS32) \ - set_thread_flag(TIF_32BIT); \ - else \ - clear_thread_flag(TIF_32BIT); \ +do { set_compat_task((ex).e_ident[EI_CLASS] =3D=3D ELFCLASS32); \ if (personality(current->personality) !=3D PER_LINUX32) \ set_personality(PER_LINUX | \ (current->personality & (~PER_MASK))); \ --=20 2.43.0