Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3078096ybi; Mon, 10 Jun 2019 04:04:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxy0MMOfBF5AkdA3zLSwiDLBDyh9rOevKRaFTCsQxHhQ4k9IVRMw5FU3FgqXaZrUVTq+kf8 X-Received: by 2002:a63:6ec6:: with SMTP id j189mr9893263pgc.168.1560164684070; Mon, 10 Jun 2019 04:04:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560164684; cv=none; d=google.com; s=arc-20160816; b=G0JpBs1iDR9EoTpJnL2UQXAb2JAq7C7c4fpnAEgA6Mk3C5xD4wNin2zGl+/gup5MEU +KiUmTjCdJS5kKRuePO+N0XlOw6XwDwXWd03beHhMyjvGyV93q5R2dwzlxFHTBSgEIQ2 y2jMRJ5p6P8ON20skSLCqCsxd02w11iD5fbRXxnweYv8CIEL6t59unGzmVgbLVUHXy1p tFpFw9jupUwIoo8rbeeCs6dmF7DDxH8ESRujla+oYNGIQ64ATOI8AkCnU0jNvr0EaOLD 0iASwiq+lBxomAu+0ybQq1G6TfXd5InkxwuyoHKreWRJJcVKY4Ju9au86fguMPH8QiGY CE0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=IrBElB7Dvt+ekOLqOELcuBpGs5ztYGEVdrqPLh5WW7s=; b=EmNWrhCl66Rm8VwXsj8sDmTbH2Ot9FxYSmfOEbfRrPojGZ0dFTPSiC3tRwCgLSz1eL knefG0gR0t52IQD0yE9JTDKDOZRWwEkx2NBOqJBppXA9VTS7WJfkvVRxgslmaC7WCYWT sLQiETC4sfdmShTtOsrZcFM5KeRqdx1lZnl3+E6x6aLe2BXfKCL4WtrlndVfupallw59 w8961osw5QnsDzXf4p7h7nKj02CaXrm/70950GKZvjdlxcHWrxQxBJbz+6FaCWS2P8SW OED1Ogn4dyZcLiNFf/FiP6TrM+6SNg8eQS08DRtanNrjYeZZb9imDaQjNMYsze27oY3G g7mg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si2781932pgc.299.2019.06.10.04.04.27; Mon, 10 Jun 2019 04:04:44 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388748AbfFJKxE (ORCPT + 99 others); Mon, 10 Jun 2019 06:53:04 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:40579 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388373AbfFJKxD (ORCPT ); Mon, 10 Jun 2019 06:53:03 -0400 Received: by mail-pg1-f194.google.com with SMTP id d30so4842922pgm.7 for ; Mon, 10 Jun 2019 03:53:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=IrBElB7Dvt+ekOLqOELcuBpGs5ztYGEVdrqPLh5WW7s=; b=QT4rHmFbwB1C1/6hJxmu0iaRi5v7maTfPw6ylsIocA7Mxjai1gIRLioOsbOvMVw1Da OiLY0ZOtQgcFmsC/nLo9tDthW/hN3IGAH49PTq4zmXJZ0mnxfQH8NVa4HGSoZoan77Gd pAkY96SAzcM9Sf1rW0VP4yMhrcwTYYYs0GfPxEH+qQol94NXy37A5/nsdePU2Nn5hck8 9LFXXb8cRMW/YOwL0tXE+z+59Qr3dmbWIo3PgD0PAebU6YlvTkDKcr/KaHi2C3FWH9/s RmKCdcbqNNYJlBgltvsrg+o4B9+HhhTX36Xs8LMNnmibDlGSydQ4H+ed+vd8yTckUERU o6Uw== X-Gm-Message-State: APjAAAWzNlv2d6K0DYtN0r9KZut5XRpz/Yz/mqtBFBEAx4h7Lw5osnlv BoJXFJxtWfcp2w1jiY8VIbi1nB6sxg0= X-Received: by 2002:aa7:808d:: with SMTP id v13mr73501435pff.198.1560163982899; Mon, 10 Jun 2019 03:53:02 -0700 (PDT) Received: from localhost.localdomain ([122.177.221.32]) by smtp.gmail.com with ESMTPSA id p43sm10611287pjp.4.2019.06.10.03.52.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jun 2019 03:53:01 -0700 (PDT) Subject: Re: [PATCH v3 1/3] arm64, vmcoreinfo : Append 'PTRS_PER_PGD' to vmcoreinfo To: James Morse Cc: Mark Rutland , Kazuhito Hagio , Steve Capper , kexec@lists.infradead.org, Will Deacon , linux-kernel@vger.kernel.org, Dave Anderson , bhupesh.linux@gmail.com, linux-arm-kernel@lists.infradead.org References: <1553058574-18606-1-git-send-email-bhsharma@redhat.com> <1553058574-18606-2-git-send-email-bhsharma@redhat.com> <2757805b-61cb-8f4a-1917-0c57012f09df@arm.com> <58c6cda9-9fd4-3b3e-740a-7b9b80b1f634@redhat.com> <66da4098-b221-408b-50ca-f3790b943965@redhat.com> <380b137b-a611-5c8d-3890-8021084f87fe@redhat.com> <2a4af3a0-1342-fdd2-1cfd-e37abb99d8bd@arm.com> From: Bhupesh Sharma Message-ID: <3ab2ca1a-95de-cecf-f590-1e2d00bb644b@redhat.com> Date: Mon, 10 Jun 2019 16:22:55 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <2a4af3a0-1342-fdd2-1cfd-e37abb99d8bd@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi James, On 06/07/2019 08:41 PM, James Morse wrote: > Hi Bhupesh, > > (sorry for the delay on this) No problem. > On 04/05/2019 13:53, Bhupesh Sharma wrote: >> On 04/03/2019 11:24 PM, Bhupesh Sharma wrote: >>> On 04/02/2019 10:56 PM, James Morse wrote: >>>> Yes the kernel code is going to move around, this is why the information we expose via >>>> vmcoreinfo needs to be thought through: something we would always need, regardless of how >>>> the kernel implements it. >>>> > >>>> Pointer-auth changes all this again, as we may prefer to use the bits for pointer-auth in >>>> one TTB or the other. PTRS_PER_PGD may show the 52bit value in this case, but neither TTBR >>>> is mapping 52bits of VA. >>>> >>>> >>>>> So far, I have generally come across discussions where the following variations of the >>>>> address spaces have been proposed/requested: >>>>> - 48bit kernel VA + 48-bit User VA, >>>>> - 48-bit kernel VA + 52-bit User VA, >>>> >>>> + 52bit kernel, because there is excessive quantities of memory, and the kernel maps it >>>> all, but 48-bit user, because it never maps all the memory, and we prefer the bits for >>>> pointer-auth. >>>> >>>>> - 52-bit kernel VA + 52-bit User VA. >>>> >>>> And... all four may happen with the same built image. I don't see how you can tell these >>>> cases apart with the one (build-time-constant!) PTRS_PER_PGD value. >>>> >>>> I'm sure some of these cases are hypothetical, but by considering it all now, we can avoid >>>> three more kernel:vmcoreinfo updates, and three more fix-user-space-to-use-the-new-value. >>> >>> Agree. >>> >>>> I think you probably do need PTRS_PER_PGD, as this is the one value the mm is using to >>>> generate page tables. I'm pretty sure you also need T0SZ and T1SZ to know if that's >>>> actually in use, or the kernel is bodging round it with an offset. >>> >>> Sure, I am open to suggestions (as I realize that we need an additional VA_BITS_ACTUAL >>> variable export'ed for 52-bit kernel VA changes). > > (stepping back a bit:) > > I'm against exposing arch-specific #ifdefs that correspond to how we've configured the > arch code's interactions with mm. These are all moving targets, we can't have any of it > become ABI. Sure, I understand your concerns. > I have a straw-man for this: What is the value of PTE_FILE_MAX_BITS on your system? > I have no idea what this value is or means, an afternoon's archaeology would be needed(!). > This is something that made sense for one kernel version, a better idea came along, and it > was replaced. If we'd exposed this to user-space, we'd have to generate a value, even if > it doesn't mean anything. Exposing VA_BITS_ACTUAL is the same. > > (Keep an eye out for when we change the kernel memory map, and any second-guessing based > on VA_BITS turns out to be wrong) > > > What we do have are the hardware properties. The kernel can't change these. > > >>> Also how do we standardize reading T0SZ and T1SZ in user-space. Do you propose I make an >>> enhancement in the cpu-feature-registers interface (see [1]) or the HWCAPS interface >>> (see [2]) for the same? > > cpufeature won't help you if you've already panic()d and only have the vmcore file. This > stuff needs to go in vmcoreinfo. > > As long as there is a description of how userspace uses these values, I think adding > key/values for TCR_EL1.TxSZ to the vmcoreinfo is a sensible way out of this. You probably > need TTBR1_EL1.BADDR too. (it should be specific fields, to prevent 'new uses' becoming ABI) > > This tells you how the hardware was configured, and covers any combination of TxSZ tricks > we play, and whether those address bits are used for VA, or ptrauth for TTBR0 or TTRB1. Fair enough. Let me try and experiment with this suggestion a bit and I will come back with a RFC patch/patchset by this weekend. Hopefully, it will cover all the weird PA/VA bit combinations we are handling in arm64 distros these days :) Thanks, Bhupesh >> Any comments on the above points? At the moment we have to carry these fixes in the >> distribution kernels and I would like to have these fixed in upstream kernel itself. > > > Thanks, > > James > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel >