Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp798962pxk; Sat, 12 Sep 2020 00:09:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0SNhENbbcD7DslWFRF7lhvef62U3uHkFnJE6yAgYVlOZgA/JgT5t2n3y3J/sPPovVMIh3 X-Received: by 2002:a17:906:cb92:: with SMTP id mf18mr5364920ejb.485.1599894597515; Sat, 12 Sep 2020 00:09:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599894597; cv=none; d=google.com; s=arc-20160816; b=J1iBDgL26Poe1MhnsjW+K73yJcoeWSsX1jbYp1J/kcHgYazhynUXWtfHtJdSJxEF56 Fm70CtWJkGhNs0SQrReUQy4Ul1o/JnCAaTgp0sGQOKShpt4HJI+fHwwbnDpVE7oY9i8w N0xyEA2pTJwVs5rsgdpxiMRq7hNRhHrkFCVyV7u04U1c+aDUju9S7cCQ2RCkRsWiue8f +rrn2SQwOsm4k6cpoI89JdJ06/5IHnMxZn8kjx6fEHHj5b5de9c2wFhr0D0Y7/5jHrVD hGhEyqHU6nbmV/rj0rKIkdNLcUMpbBhLUNAGlhN5TaIvWk07WOZWrPEYPVfpDTp2aKSO J6lg== 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=lMb5WtYmd63Lq/A4CLiTSB00gw1boT6OgEZADfayR10=; b=ZNS+gDZg5bo87rBRShATvJln5nyIb38O8s2yUKk+RN15z1h4km5rXhD+ajFBGlslew lRYYTP//XAf8leNU7iMHWYouVCHrXk8NxgiLv53Qvv8n3YNIWrCmGr2jmypNez3cMW7E MOppSqbbenb71Xm+xoJRlZWs+1NKJ2nnZJVnzDsRogazieyBSfXYKmBpYzB2C22oDFXi oq2YdB/jHJlTvJVoguTkk/TxcWK1aIq5N0ay+gT0Zr+iJhqjjD+ozmwJ2y5tzLq6t0uS gokhQxeCIdgAKQGPEuXrfAOpLoGWmcVcFPBtjfEJWi9N75Hs7rfKSBXgDAd4V4I4JVah KDfw== 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 t22si3388631edi.341.2020.09.12.00.09.34; Sat, 12 Sep 2020 00:09:57 -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 S1725925AbgILHGY (ORCPT + 99 others); Sat, 12 Sep 2020 03:06:24 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:45340 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725921AbgILHGT (ORCPT ); Sat, 12 Sep 2020 03:06:19 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id DE30229C432 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 5/6] x86: elf: Use e_machine to select start_thread for x32 Date: Sat, 12 Sep 2020 03:05:52 -0400 Message-Id: <20200912070553.330622-6-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 on compat_start_thread 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/include/asm/elf.h | 11 +++++++++-- arch/x86/kernel/process_64.c | 11 +++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h index 9220efc65d78..33c1c9be2e07 100644 --- a/arch/x86/include/asm/elf.h +++ b/arch/x86/include/asm/elf.h @@ -186,8 +186,15 @@ static inline void elf_common_init(struct thread_struct *t, #define COMPAT_ELF_PLAT_INIT(regs, load_addr) \ elf_common_init(¤t->thread, regs, __USER_DS) -void compat_start_thread(struct pt_regs *regs, u32 new_ip, u32 new_sp); -#define compat_start_thread compat_start_thread +void compat_start_thread_ia32(struct pt_regs *regs, u32 new_ip, u32 new_sp); +void compat_start_thread_x32(struct pt_regs *regs, u32 new_ip, u32 new_sp); +#define compat_start_thread(regs, new_ip, new_sp) \ +do { \ + if (elf_ex->e_machine == EM_X86_64) \ + compat_start_thread_x32(regs, new_ip, new_sp); \ + else \ + compat_start_thread_ia32(regs, new_ip, new_sp); \ +} while (0) void set_personality_ia32(bool); #define COMPAT_SET_PERSONALITY(ex) \ diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c index 9afefe325acb..56e882c339e6 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -511,12 +511,15 @@ start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp) EXPORT_SYMBOL_GPL(start_thread); #ifdef CONFIG_COMPAT -void compat_start_thread(struct pt_regs *regs, u32 new_ip, u32 new_sp) +void compat_start_thread_ia32(struct pt_regs *regs, u32 new_ip, u32 new_sp) { start_thread_common(regs, new_ip, new_sp, - test_thread_flag(TIF_X32) - ? __USER_CS : __USER32_CS, - __USER_DS, __USER_DS); + __USER32_CS, __USER_DS, __USER_DS); +} +void compat_start_thread_x32(struct pt_regs *regs, u32 new_ip, u32 new_sp) +{ + start_thread_common(regs, new_ip, new_sp, + __USER_CS, __USER_DS, __USER_DS); } #endif -- 2.28.0