Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2395769pxk; Sat, 3 Oct 2020 20:28:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWmPGqoH5W+Y93FtlcEphqdtUbaGOvZbk3JioZkLzD27QnYbxJk/luYMB/jgA3gvNH2srq X-Received: by 2002:a17:906:1d11:: with SMTP id n17mr8889309ejh.280.1601782101834; Sat, 03 Oct 2020 20:28:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601782101; cv=none; d=google.com; s=arc-20160816; b=EPO9V91gxYpzhduPcMxTRs2rOGP7KZFD9MksLKX/MH9AZMLLowxRk5pif/fXKnhwbF 91A5MMcMeKUYimPHWgSHLk8yJc55cB+8qrUb4g/hoeN7io1yvM8g/DGj2L5q8Y7BrtQx xg5xhYCOpNvMAcZx1ZvfmG0XCP0iomRc9kO8y0Lsye/b+rOxxaq4FXt4JPP/ShQbYpd0 aKQtSXFgULs7khJ2UfjjOc/UMWFC9OdR+hmHyTxwThuR74EiDt4RbUZB82dc7l9mJgWS WYy6ByGehoTnzvDiGvVD34ELjv3pPtjWDRBH9S561VYmc66sAkr37Ru/oLhuwcsSB0us 14gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=P7+j+hsnN2IjQqs0blwpxG07onwgF4l4I36DGpJSAAs=; b=W673P3SCLdq4heHUuJRGlwwA0MD5/TOrr74X237JMews3iJ2t2OJWoCrs/xNalZ8qf hEpPuEcB+TkYS4jQuKfr15adBeeDk85D0uRO04AZ75vgy4bWMLZ5le5JjqTjZO12NBzh k5muvKeyMNNaIRhe6OAJnrHa+TXNwFUenFnWQLbxKWwi/y718I7u1uLcUI9Ih72+L2B/ mIfu32SqvMx6lvtgkV8DPKlM8piZAAG+MKULzrOLIO4IgmBp7rNbpmGuvBowBlBtw7kH ODH9aA3iVaQ8aAWYXQslTkBrj9aDhlX3cUtgHCiQtCxgDDh1ujBuxVY7ENuG61L8H5mQ IDiw== 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 s5si4406101edj.285.2020.10.03.20.27.59; Sat, 03 Oct 2020 20:28: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 S1726630AbgJDD0K (ORCPT + 99 others); Sat, 3 Oct 2020 23:26:10 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:35104 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726614AbgJDD0H (ORCPT ); Sat, 3 Oct 2020 23:26:07 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 128E129B008 From: Gabriel Krisman Bertazi To: luto@kernel.org, tglx@linutronix.de Cc: hch@lst.de, hpa@zytor.com, bp@alien8.de, rric@kernel.org, peterz@infradead.org, mingo@redhat.com, x86@kernel.org, linux-kernel@vger.kernel.org, dave.hansen@linux.intel.com, sean.j.christopherson@intel.com, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v3 06/10] x86: elf: Use e_machine to select start_thread for x32 Date: Sat, 3 Oct 2020 23:25:32 -0400 Message-Id: <20201004032536.1229030-7-krisman@collabora.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201004032536.1229030-1-krisman@collabora.com> References: <20201004032536.1229030-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 in 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 --- Changes since v2: - Avoid a function-like macro in compat_start_thread (Andy) --- arch/x86/include/asm/elf.h | 5 +++-- arch/x86/kernel/process_64.c | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h index 9220efc65d78..109697a19eb1 100644 --- a/arch/x86/include/asm/elf.h +++ b/arch/x86/include/asm/elf.h @@ -186,8 +186,9 @@ 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(struct pt_regs *regs, u32 new_ip, u32 new_sp, bool x32); +#define COMPAT_START_THREAD(ex, regs, new_ip, new_sp) \ + compat_start_thread(regs, new_ip, new_sp, ex->e_machine == EM_X86_64) 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..a4935d134e9d 100644 --- a/arch/x86/kernel/process_64.c +++ b/arch/x86/kernel/process_64.c @@ -511,11 +511,10 @@ 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(struct pt_regs *regs, u32 new_ip, u32 new_sp, bool x32) { start_thread_common(regs, new_ip, new_sp, - test_thread_flag(TIF_X32) - ? __USER_CS : __USER32_CS, + x32 ? __USER_CS : __USER32_CS, __USER_DS, __USER_DS); } #endif -- 2.28.0