Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3590092ybi; Mon, 10 Jun 2019 12:57:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzSMnOUVBkgLot13Zaq+UMHQRVkL8Lq8EoB3ncmizfjk9720SyL7aokYlrVOtu13+zqowOB X-Received: by 2002:a17:90a:654b:: with SMTP id f11mr23298657pjs.34.1560196622028; Mon, 10 Jun 2019 12:57:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560196622; cv=none; d=google.com; s=arc-20160816; b=Jl51maZFT9UEOm5AlVU/7bVqKhpa0MuFpOHD3q85P9JrtajOZelg06pSEq81TbyXuF tLQKw7HLcUIQk8YjdN5cS+WvIePbDNC017fvEGcdsBO6b1AQZx4gekJug2COPeu32YoG tHaQxbgTFhKrovaMeZCZRuGxERjjuQSHCJn6avrQM4VjhKfP7mGjz1wuGUj+jLpHPNcq z4r5WSJHYrqScp424p5qVYosJuoO6nSpaKy81zejN9TDfmIieHNjLqv6exXg4i52PE37 cj92ALmx7DYq6l8qg9yN8b/7+45kFyCr982zcKnWhlFXrfFH6nxkTTCL4ToKCBqIv/ab R2TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=811lIuMO3QaODXd3K9NvSgTVL+VZs2KoWd/ysaH2IQc=; b=OB2f70Dh+m/xLNrqv/9XRiQgY1DSiMeOS6ij9/8XHUbdnJnBDSn6pCB9AVPw6IPjY1 wqZLwlI/zMqtz90gOupQ4iyDSs//WzyaSwq5W+3sKrO0S6/gf9McLgP2strk2h0TuYTa 2Nzl6Swu8UHx0z6vowabnkHHtyIA7c3ilRQU7SI1D19kq4QN+iCh9g1kaWysBFYqaufU j9YWD5T+r/oiH8AEWNarVOHKV+stA9kIDcePNxlG9CsbQhDj5zTZnvBQGGyV4aoFUeYc bJv9HiGnCMXPNqI79ulUY5HYmqftJeORk9BxqltMZKdAaX67nn2hSsIaLcxhWnrrfrIv cEfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uLzHkUDA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id n7si9889954plk.435.2019.06.10.12.56.46; Mon, 10 Jun 2019 12:57:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uLzHkUDA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S2389385AbfFJT4D (ORCPT + 99 others); Mon, 10 Jun 2019 15:56:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:34002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389255AbfFJT4D (ORCPT ); Mon, 10 Jun 2019 15:56:03 -0400 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 0A653212F5 for ; Mon, 10 Jun 2019 19:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560196562; bh=BSrEs7k4Eaj+qfKqbXB7x6RBjqYairyQB7xlNqEmonI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=uLzHkUDAQ8jOsA8YXnkz0O3Qklab8tzkEtYYWwVgKRQkiQKzSqsdLapdzrorKdIKK n6Eo4HwM27qI73UXdMC+Vo7aJo27Dlu5OTlBwsHayFksgsHw2rZwNM92HHc08myrfM frywWd5NERvhfQ373QnY3PfJ7m2L8vxY6KRo3fOE= Received: by mail-wm1-f42.google.com with SMTP id g135so538845wme.4 for ; Mon, 10 Jun 2019 12:56:01 -0700 (PDT) X-Gm-Message-State: APjAAAUsE7VesxAJWHwnBuF2IQ7lhvoRnnHC71d6eOmAlukOWmqR2YFF ahr3nfFP95880ltaZys0VZN/XKob5czAh8OdR5kCBQ== X-Received: by 2002:a7b:cd84:: with SMTP id y4mr14984047wmj.79.1560196560570; Mon, 10 Jun 2019 12:56:00 -0700 (PDT) MIME-Version: 1.0 References: <20190606200926.4029-1-yu-cheng.yu@intel.com> <20190606200926.4029-4-yu-cheng.yu@intel.com> <20190607080832.GT3419@hirez.programming.kicks-ass.net> <20190607174336.GM3436@hirez.programming.kicks-ass.net> <34E0D316-552A-401C-ABAA-5584B5BC98C5@amacapital.net> <7e0b97bf1fbe6ff20653a8e4e147c6285cc5552d.camel@intel.com> <25281DB3-FCE4-40C2-BADB-B3B05C5F8DD3@amacapital.net> <3f19582d-78b1-5849-ffd0-53e8ca747c0d@intel.com> <5aa98999b1343f34828414b74261201886ec4591.camel@intel.com> <0665416d-9999-b394-df17-f2a5e1408130@intel.com> In-Reply-To: <0665416d-9999-b394-df17-f2a5e1408130@intel.com> From: Andy Lutomirski Date: Mon, 10 Jun 2019 12:55:48 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v7 03/14] x86/cet/ibt: Add IBT legacy code bitmap setup function To: Dave Hansen Cc: Yu-cheng Yu , Peter Zijlstra , X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , LKML , "open list:DOCUMENTATION" , Linux-MM , linux-arch , Linux API , Arnd Bergmann , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 10, 2019 at 12:52 PM Dave Hansen wrote: > > On 6/10/19 12:38 PM, Yu-cheng Yu wrote: > >>> When an application starts, its highest stack address is determined. > >>> It uses that as the maximum the bitmap needs to cover. > >> Huh, I didn't think we ran code from the stack. ;) > >> > >> Especially given the way that we implemented the new 5-level-paging > >> address space, I don't think that expecting code to be below the stack > >> is a good universal expectation. > > Yes, you make a good point. However, allowing the application manage the bitmap > > is the most efficient and flexible. If the loader finds a legacy lib is beyond > > the bitmap can cover, it can deal with the problem by moving the lib to a lower > > address; or re-allocate the bitmap. > > How could the loader reallocate the bitmap and coordinate with other > users of the bitmap? > > > If the loader cannot allocate a big bitmap to cover all 5-level > > address space (the bitmap will be large), it can put all legacy lib's > > at lower address. We cannot do these easily in the kernel. > > This is actually an argument to do it in the kernel. The kernel can > always allocate the virtual space however it wants, no matter how large. > If we hide the bitmap behind a kernel API then we can put it at high > 5-level user addresses because we also don't have to worry about the > high bits confusing userspace. > That's a fairly compelling argument. The bitmap is one bit per page, right? So it's smaller than the address space by a factor of 8*2^12 == 2^15. This means that, if we ever get full 64-bit linear addresses reserved entirely for userspace (which could happen if my perennial request to Intel to split user and kernel addresses completely happens), then we'll need 2^48 bytes for the bitmap, which simply does not fit in the address space of a legacy application.