Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp798377pxk; Sat, 12 Sep 2020 00:08:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRbZMxcTMgZ4qX1Ys6ZAlSnhvj7hwfoY/OjvmTYyPyfL2VpU8Ho4ZMMwTZOU2IN1vGLgqP X-Received: by 2002:a17:906:934f:: with SMTP id p15mr5227923ejw.497.1599894501069; Sat, 12 Sep 2020 00:08:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599894501; cv=none; d=google.com; s=arc-20160816; b=qBpu4f02whSSfmLVmNYRkTPHakuwqzNe3goHUK+ggrty1/3u9Bj1iBRcXGvSF1JWK+ AKJGZi4IYrgDNwnuk5SgjpMCQtzrmvpzlEOPdRoT+RcUWxLnkLIZzgBqmmmDYIZR4XLq nhXHkGRHmtsdhM35BVxJbi1TNKLPwL9vxj3Pzd8MD0JdLGgAnYYwXJO9W5hdo3Si9xSH lWX3SNxMSQI6WgDYFUqDC5hX5/ABPHb+drPqHbIR1Q8osaX58/bLrukHSV6nbbKyfxHP +NKFgkxoV3MdjklQLfScdjYsbwWijBLd/UztEbecejry826ttXR7Gs8dGN24eQqVfjyK XWMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HSMMVRMvPv/BEsks+3u1863u6vUUQPSdZUatQkTPWwg=; b=npZ91xkKytgn1DUhK3Rfd4rgdlsO7GsOrXqYzc8VS46fLW2XkyQVSq2PDUYppoaOD2 6dMLCXlOmhdmaODEJl6PYeVIlg4OYREYqVVtEjcIgvDdhVtublY36QmlDkPUHXnPHM+z ctvNl3JnNlm72EBDgqhdaXKY+g1HNyZ7URZqk0OgADLXO3F2XYfwh12Mvp023X6j1996 lP7Gby6LyxCxkntDITnJmrG8PoEm7wq2u9fILGk/YSH7IkoT7UOeWOcQCTC/8j5n1rMQ hs5WSrmKS6SEJncB4IuowVHd2Gb1cZz/yWnEGCSxBQ8jrtgTx9qHh2cXleG0HSFFmFqU Tf1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c7si3504260edl.290.2020.09.12.00.07.59; Sat, 12 Sep 2020 00:08:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725931AbgILHGd (ORCPT + 99 others); Sat, 12 Sep 2020 03:06:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725923AbgILHGX (ORCPT ); Sat, 12 Sep 2020 03:06:23 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4944C061573 for ; Sat, 12 Sep 2020 00:06:22 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 5F83C29C425 From: Gabriel Krisman Bertazi To: luto@kernel.org, tglx@linutronix.de Cc: hpa@zytor.com, bp@alien8.de, rric@kernel.org, peterz@infradead.org, mingo@redhat.com, x86@kernel.org, linux-kernel@vger.kernel.org, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH 6/6] x86: elf: Use e_machine to select setup_additional_pages for x32 Date: Sat, 12 Sep 2020 03:05:53 -0400 Message-Id: <20200912070553.330622-7-krisman@collabora.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200912070553.330622-1-krisman@collabora.com> References: <20200912070553.330622-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since TIF_X32 is going away, avoid using it to find the ELF type when choosing which additional pages to set up. According to SysV AMD64 ABI Draft, an AMD64 ELF object using ILP32 must have ELFCLASS32 with (E_MACHINE == EM_X86_64), so use that ELF field to differentiate a x32 object from a IA32 object when executing start_thread in compat mode. Signed-off-by: Gabriel Krisman Bertazi --- arch/x86/entry/vdso/vma.c | 21 ++++++++++++--------- arch/x86/include/asm/elf.h | 11 ++++++++--- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 9185cb1d13b9..7a3cda8294a3 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -412,22 +412,25 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) } #ifdef CONFIG_COMPAT -int compat_arch_setup_additional_pages(struct linux_binprm *bprm, - int uses_interp) +int compat_arch_setup_additional_pages_ia32(struct linux_binprm *bprm, + int uses_interp) { -#ifdef CONFIG_X86_X32_ABI - if (test_thread_flag(TIF_X32)) { - if (!vdso64_enabled) - return 0; - return map_vdso_randomized(&vdso_image_x32); - } -#endif #ifdef CONFIG_IA32_EMULATION return load_vdso32(); #else return 0; #endif } + +int compat_arch_setup_additional_pages_x32(struct linux_binprm *bprm, + int uses_interp) +{ +#ifdef CONFIG_X86_X32_ABI + if (vdso64_enabled) + return map_vdso_randomized(&vdso_image_x32); +#endif + return 0; +} #endif #else int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp) diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h index 33c1c9be2e07..4d91f5b1079f 100644 --- a/arch/x86/include/asm/elf.h +++ b/arch/x86/include/asm/elf.h @@ -388,9 +388,14 @@ struct linux_binprm; #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 extern int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp); -extern int compat_arch_setup_additional_pages(struct linux_binprm *bprm, - int uses_interp); -#define compat_arch_setup_additional_pages compat_arch_setup_additional_pages +extern int compat_arch_setup_additional_pages_ia32(struct linux_binprm *bprm, + int uses_interp); +extern int compat_arch_setup_additional_pages_x32(struct linux_binprm *bprm, + int uses_interp); + +#define compat_arch_setup_additional_pages \ + ((elf_ex->e_machine == EM_X86_64) ? \ + compat_arch_setup_additional_pages_x32 : compat_arch_setup_additional_pages_ia32) /* Do not change the values. See get_align_mask() */ enum align_flags { -- 2.28.0