Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp297568ybi; Fri, 7 Jun 2019 08:13:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqiV0ub3467A0F/dLEp66N2IDJLIxMBuJFrkM4W+aEbffgYZlflX8e4B6cdZ0/bKgN5iYL X-Received: by 2002:a63:d416:: with SMTP id a22mr3221321pgh.218.1559920407203; Fri, 07 Jun 2019 08:13:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559920407; cv=none; d=google.com; s=arc-20160816; b=0lFIFpfW9BgO0/RF8cXzJ8qRPtxXwA00Fof9lWhTZoZyejhrJMONQVmVUBeIwBmpZW rRsi5YGjlPx5kauz4ANjLlGKudOtZeiZGz9VGREGsrGxba2m9Qrk/jdLUCHA4apeZ5rN jFyql6Jcqe3ygoQDSkEWy/csOV/4iKKyIoRzatjyb9T5/IpBB2YChmybfZ1rQYIobg1N oiHnlNOy4IAKT0xO8sRF4RozgMbyvvSwNWgainh8FhPWDa4YaTDeF4/aQtPLmRNjoyk6 51iyUMQkl81lpO0HK5nk5hmksrD9UtCS92VdZcujxFJQhyVyMFJ9OeQZsnbe2vPMMpYQ m1dQ== 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=B1yQtGyxil+z7BoceFbzNLxQmt6kFt0kbTOK/B0IqW0=; b=QnbkekQne7/pEMb82xpb2GEdy8BNJTnxC1zaZmIR00PDAM9esRIM+VyJur42ekvRsq nDUId8G5pANu7HBJEYh1kCx9HwgrQi5EAswS3239ClakjUIVtS1bgmaDS9CoB8PHGTJE CtsLno2PvzewjRajSiXCBy/ZEhZFwXcW8IV2mczDmh2C5zCbvl9Mk3SAGNxI1frpKhXJ Pve/gfEXKcKrY2Sy5mWV7NdEswdqi2DZrG0V8dffMLSXDzMSBuDzCNJ80YtNhdvNwtrw 8qIfvoslyv1wTqLkHfTcL+Vk/lJmYuJ/EqUYOR+stMf5ySTPQghPzFdyld1Ph2Z+F4uY GdMA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s7si1973479pfm.254.2019.06.07.08.13.09; Fri, 07 Jun 2019 08:13:27 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729408AbfFGPLq (ORCPT + 99 others); Fri, 7 Jun 2019 11:11:46 -0400 Received: from foss.arm.com ([217.140.110.172]:42284 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728446AbfFGPLq (ORCPT ); Fri, 7 Jun 2019 11:11:46 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DE300B16; Fri, 7 Jun 2019 08:11:45 -0700 (PDT) Received: from [10.1.196.105] (eglon.cambridge.arm.com [10.1.196.105]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8A97A3F802; Fri, 7 Jun 2019 08:11:44 -0700 (PDT) Subject: Re: [PATCH v3 1/3] arm64, vmcoreinfo : Append 'PTRS_PER_PGD' to vmcoreinfo To: Bhupesh Sharma Cc: linux-kernel@vger.kernel.org, bhupesh.linux@gmail.com, Mark Rutland , Will Deacon , Dave Anderson , Kazuhito Hagio , kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Steve Capper 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> From: James Morse Message-ID: <2a4af3a0-1342-fdd2-1cfd-e37abb99d8bd@arm.com> Date: Fri, 7 Jun 2019 16:11:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <380b137b-a611-5c8d-3890-8021084f87fe@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bhupesh, (sorry for the delay on this) 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. 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. > 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