Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp792221pxk; Thu, 1 Oct 2020 14:03:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybxyMFAnUBSiX7oIs8d4xvn6bp87HLm6XW4RkXP4TAFXk3vjW8V3O8H5z7Ys9aFmNQ8Q+W X-Received: by 2002:aa7:c3d4:: with SMTP id l20mr10398013edr.263.1601586224352; Thu, 01 Oct 2020 14:03:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601586224; cv=none; d=google.com; s=arc-20160816; b=BBwoc46sM2RvMDAwSwL34QRbSAeCv3y+2k8j8EDbEzrr/fQmUHZ5fgM1uDiOfdorQl mX2I6WJFliftFcyIoaY82dfJVs9zmZ3GD/vXwrFyWuqHV4vGFAGQqEJGuI1aDIsvBXNc hZVn3zV7BPqWF1eS58komlZEmFcSkPHwSLlKkWn39uV9DqWg4YLMTfn2Fgj12w2eBrsv E7RqbyNH6z2xMPburjpj0x/FKhHBrGEwr1HmHjdFWONIzfXETQ0FzH2gCRHjjdSJtmWe KtAUvHyopN8Er3vl5sC4RvbfGBkpYc/UgR3VEUcGgbbhoqmSmIraz/IzAjXvrwkaerfp ntnA== 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=HSMMVRMvPv/BEsks+3u1863u6vUUQPSdZUatQkTPWwg=; b=s0VIAn1R7K1l/9b41tDCdbN5zf9j1iPqBaoO4y930Z73mF7l6RB0e1z2xq+dDeFZ9B tqgCLhQifMrCxf6SnjBo1XU3UDmMNeFvYfr8nRPVYDvckjsjO3P2Pzmbmw97+LOo+6GC oqWoXvuY3pM29aVN9RU2p50Og7S2bxaU7xTUfSF949vqCruii5sa4RvImoxW8NSWNzFX qiQDwwD8d7hkaPivgFQlZZqofxFa7B6OhCpxZfDCnJe536lPR4A9qLVLECY4D9dYjkVs yuGQTWYr1VIeqygUTD/WHmFc4khy9muwx9vUhnLf0DME8WFQdMG94Wlj+J5iy16Llpr8 VIMg== 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 r11si4463379eja.148.2020.10.01.14.03.22; Thu, 01 Oct 2020 14:03:44 -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 S1733098AbgJAU7s (ORCPT + 99 others); Thu, 1 Oct 2020 16:59:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbgJAU7s (ORCPT ); Thu, 1 Oct 2020 16:59:48 -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 05714C0613D0 for ; Thu, 1 Oct 2020 13:59:48 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 76F8229D106 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, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v2 6/9] x86: elf: Use e_machine to select setup_additional_pages for x32 Date: Thu, 1 Oct 2020 16:58:16 -0400 Message-Id: <20201001205819.27879-7-krisman@collabora.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201001205819.27879-1-krisman@collabora.com> References: <20201001205819.27879-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 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