Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2396602pxk; Sat, 3 Oct 2020 20:30:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyack3nSEktqcUB862awnHNSFclkTT7wwUol4mqNJrfqH6DXlITNS4MzKFYK2JVhIGYHlXU X-Received: by 2002:a17:906:fb8f:: with SMTP id lr15mr8798839ejb.25.1601782234527; Sat, 03 Oct 2020 20:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601782234; cv=none; d=google.com; s=arc-20160816; b=JoMsntES3D80ldM3odbpQXJPBXmbmJYEReo6N61gyZxarTn6/DjWaRxQR5+jbVSdET T4Ii0ighDyUq5ZPvDM13JbYFQ4LDNfxfJ7f2wdmoITC/0G57yIdcLIYvQWYJwO3vPONH YDsYNzYp3GOu5QfPAc90BnZYCTyfYMopga09vIAJiNShAVCbAbmznmY9GPNoqjSGBJs7 6L2HOdVdUqsjHQnyXnH7E2xr2D36Mw5Ivo+D9cU75IRc0VRe8b3aNZbnMrJrparMspJ5 C1Lyw6EwgxMJ4epcbwHGG0Zs66AqjAcdQToyeCb8DrwQSUZxIRjnfnC/xMLevPCDTrDy NKZQ== 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=/zo+pywB/qolEWc0XKsOPiQt2tVtyyRPB6E+ilmzEjw=; b=Uofn18uaJ7pjQA5YcX8h9URC5usqmZsCcdunEoWvc8gGDnX0eMEXHlNEQanYBfh9G0 E3afCZEac2YbBsLwS7L/+yfxfw+XAh+2+DVEWT8dCTUj0j55wAW2E49g2opV5PrTTaqu i6jUoan2qJUB8DEIU4AJbYccmTfAGM+3ZxlUVK5iRHdRB10RxCgv5pnzaiyfQVPTslFx /I4Ci2h7y1SABnBIgIStiehuJab6DZfjuP3msSjI+r/c4UPcYAKqTdRPNq8dlTRAzJrO hcrKEFSIFy9YbSV3R3yOLo4GKHpVWswCEeJwzfqDAOptL3ONIKnRdZ9Ao+mwJfG3KHvA Jo7w== 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 gg18si1508254ejb.184.2020.10.03.20.30.12; Sat, 03 Oct 2020 20:30:34 -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 S1726672AbgJDD0R (ORCPT + 99 others); Sat, 3 Oct 2020 23:26:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726641AbgJDD0P (ORCPT ); Sat, 3 Oct 2020 23:26:15 -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 4E01FC0613E7 for ; Sat, 3 Oct 2020 20:26:15 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 10DA229B00E 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 08/10] x86: elf: Use e_machine to select additional_pages between x32 Date: Sat, 3 Oct 2020 23:25:34 -0400 Message-Id: <20201004032536.1229030-9-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 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 setup_additional_pages in compat mode. Signed-off-by: Gabriel Krisman Bertazi --- Changes since v2: - Avoid a function-like macro in compat_setup_additional_pages (Andy) --- arch/x86/entry/vdso/vma.c | 4 ++-- arch/x86/include/asm/elf.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 9185cb1d13b9..50e5d3a2e70a 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -413,10 +413,10 @@ 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 uses_interp, bool x32) { #ifdef CONFIG_X86_X32_ABI - if (test_thread_flag(TIF_X32)) { + if (x32) { if (!vdso64_enabled) return 0; return map_vdso_randomized(&vdso_image_x32); diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h index 109697a19eb1..44a9b9940535 100644 --- a/arch/x86/include/asm/elf.h +++ b/arch/x86/include/asm/elf.h @@ -383,8 +383,10 @@ struct linux_binprm; 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 + int uses_interp, bool x32); +#define COMPAT_ARCH_SETUP_ADDITIONAL_PAGES(bprm, ex, interpreter) \ + compat_arch_setup_additional_pages(bprm, interpreter, \ + (ex->e_machine == EM_X86_64)) /* Do not change the values. See get_align_mask() */ enum align_flags { -- 2.28.0