Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp820569pxk; Thu, 1 Oct 2020 14:54:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaacWzy+OFkmv3xpvRvO0ztvvne1oVmnQWhIMRdDLZtcwFszRFvhMNBjV5mIh34+zVa/10 X-Received: by 2002:a17:906:a886:: with SMTP id ha6mr5722775ejb.135.1601589254130; Thu, 01 Oct 2020 14:54:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601589254; cv=none; d=google.com; s=arc-20160816; b=NUQOLt596hJpDtND7SCqEL27cjR/DcftBxAyfIexwx4rhpMXCbgDV+ZctmVzsjfPKf /UpSUiRzrEM0AVFptEBLPih21h0vTJsjm1VPy5ve3kgErp5cqKa6d8SF0Zs/4JArKEbQ gkkxBhj3ouovRsA+ML8cTMB/Kn1wMLePDf67TZf1zT7C6xbLGpQ6RXtAcOAvsXalLE5v 1V6lrLiHapV+54INTSiSTekFgA0lTnmnpZMuXYRVA6kSyk7Nd5bt0efSXrgHNwb3JFRc mnHfdwTyMTlmrOJk3osjV3WebQQjrJUQVDJHwc48WvqQ2UloHU5f134Foi0nkRyXnGM0 uF2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=CgYBM/op3f64l61J2/6sJV6kyhAdRA1OvDmKQ9PLEqA=; b=HHx/qwjSlAtqQBCHpGUEd4V6vCaF6DKbEUXiSSzThRL8SPbiOvdLOO9SRfuV3iFYSq mQ34OMHBGdfI6cwLYrToCPvFvfvlkMNPxUCvgug9KU+50A1AvN/0Jkn6hlZDYXYVe3th +IzzMDMzNE3as4VsoUSBNQNt1JD0QwnLEwIDvwzanUX/boc63RpxxKa5XUQ8WZqYcqBo JM4mYD6Dgs+nEDp3uQUP9yLzLD5jVbXwSt+3rA2CHzhpy9bdpP9VPyr1f8soqRTFIZy/ /FWizr4UanmzDUejogAsCu2tRJoSRs11cbx3347EfVvTUe++AARoPkNubrJ2H7wXnAK8 06AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="F/AbhBkl"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r6si4115695edm.211.2020.10.01.14.53.51; Thu, 01 Oct 2020 14:54:14 -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; dkim=pass header.i=@kernel.org header.s=default header.b="F/AbhBkl"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727017AbgJAVuo (ORCPT + 99 others); Thu, 1 Oct 2020 17:50:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:42288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733191AbgJAVun (ORCPT ); Thu, 1 Oct 2020 17:50:43 -0400 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 02B1C21D92 for ; Thu, 1 Oct 2020 21:50:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601589042; bh=76o5IWY0IjEXulXQPFJbRhNDDvLFQbEd3W7KfG4VVzQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=F/AbhBklTEaoJTrxlE28WYn134NeK+ItLT5KGSjSOWgumyyPk90OtPCXVNwOxDOPF IGwJhLToUWHhbPKercPHmh+7VdP/vhFxOP5dN2HxhmjNZhR3pJuHtliCkGZ4jNPjqk uiXt0Izcohrli6QHsKe8LEE9m5T+IP5R+3sIf+jE= Received: by mail-wr1-f43.google.com with SMTP id z1so366522wrt.3 for ; Thu, 01 Oct 2020 14:50:41 -0700 (PDT) X-Gm-Message-State: AOAM531qGGR87BV8cZ9E4DOmbcYCa7AJLFMgB8Ay1tZWO1aVjrV89a/R ER9TRddxP48/tQFY10TRCZNkSp/KZKbzc00STMqTpg== X-Received: by 2002:adf:a3c3:: with SMTP id m3mr11023133wrb.70.1601589040533; Thu, 01 Oct 2020 14:50:40 -0700 (PDT) MIME-Version: 1.0 References: <20201001205819.27879-1-krisman@collabora.com> <20201001205819.27879-7-krisman@collabora.com> In-Reply-To: <20201001205819.27879-7-krisman@collabora.com> From: Andy Lutomirski Date: Thu, 1 Oct 2020 14:50:29 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 6/9] x86: elf: Use e_machine to select setup_additional_pages for x32 To: Gabriel Krisman Bertazi Cc: Andrew Lutomirski , Thomas Gleixner , Christoph Hellwig , "H. Peter Anvin" , Borislav Petkov , Robert Richter , Peter Zijlstra , Ingo Molnar , X86 ML , LKML , Dave Hansen , kernel@collabora.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 1, 2020 at 1:59 PM Gabriel Krisman Bertazi wrote: > > 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) > As in the previous patch, can you wire up the new argument for real, please?