From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF042C531DC for ; Tue, 20 Aug 2024 14:06:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E9D06B008A; Tue, 20 Aug 2024 10:06:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64BE26B008C; Tue, 20 Aug 2024 10:06:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C6646B0092; Tue, 20 Aug 2024 10:06:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 302046B008A for ; Tue, 20 Aug 2024 10:06:34 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9D692A020E for ; Tue, 20 Aug 2024 14:06:33 +0000 (UTC) X-FDA: 82472799066.20.6FDF793 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf17.hostedemail.com (Postfix) with ESMTP id AFA5940022 for ; Tue, 20 Aug 2024 14:06:31 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724162753; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=52uiSFP6brUOYOkgfLYxt+wwY4WQHNHuEsK1LqriNR4=; b=oIXFeyv0ReNHWtGGd8KbMtcoXYpjZF2MnNrTjVougXMl07pyOnafsn4YcgoPLPvOy2nvil +BniuR6kmn+hbPkXqeXiB599lv2DnBaz7DXICNxNjE4TeQ6gAJzF5nC/j7od0twNI/jetk D8l82kCJfXrSm2bz3yOzqIsoOiFZAc0= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724162753; a=rsa-sha256; cv=none; b=f2LhoBxYBlenwyvOMu1J4mXaZcweiMDHYfn6esE+PFZ9mlF9OjnnrbrDBf/Eh/L8CNHcEF oaTVu680mMluLW2Q8zgX3yYtCqlMwvWbeXzGMd6vCK547mdJonx46t1ShEIcKFWHFgfg2V GejaYKS+yUyKwP0Xst/zQaQn6hKrP94= 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 DB55ADA7; Tue, 20 Aug 2024 07:06:56 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DE2083F66E; Tue, 20 Aug 2024 07:06:27 -0700 (PDT) Date: Tue, 20 Aug 2024 15:06:06 +0100 From: Joey Gouly To: Dave Martin Cc: Catalin Marinas , linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, bp@alien8.de, broonie@kernel.org, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: Re: [PATCH v4 18/29] arm64: add POE signal support Message-ID: <20240820140606.GA1011855@e124191.cambridge.arm.com> References: <20240801155441.GB841837@e124191.cambridge.arm.com> <20240806103532.GA1986436@e124191.cambridge.arm.com> <20240806143103.GB2017741@e124191.cambridge.arm.com> <20240815131815.GA3657684@e124191.cambridge.arm.com> <20240820095441.GA688664@e124191.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: AFA5940022 X-Stat-Signature: ki8mhs5kwn1yoci3ke4mp4pj6ufj49yt X-HE-Tag: 1724162791-311422 X-HE-Meta: U2FsdGVkX1+n4FXD38F6SwA/sWxlopig0HIzM+8FYlt9vVzIdgnMAECZx9MsPj5QfMbAMBQf8ZOIZ2nnDcabXH4tPe/J996hbKjtcMM94S+h++HH6AyinJgPO34EYheqih7oibY1FEitj98mvZNhxCXiMXqH/rec6zLwCmNBMo/HwocyMyxVbmSi6D1C8jv5yWVOCWFwqNIsHAUrmzP7TsHk8Z1LeXR4DizguktmKnNYR/4OFVI8QqKr7hD+ybtXpUnds36Z9E7TZfPw59Va9ATAg4/o4fV/VeaZXKka3Swm2/NvnmUvLLOXBFIgHO1hLtw3HrSYuU2vZhR29aYOoUCUjkWgvUo6IKGihdYehJzY9k2f7VIHSXBS+Ep7PibOHylse25kEzyiZG9z5aiAblDrenwH2/a6Fv680W62Ucob6F3zWE2VTsC018TpUwgFGbQbMrnxQakZGA8x+CnYmrseNTv2NTHCj/YpPlO9wxkUEHO9r5m+6s1kj0D5njORnMgl+KN+INFjo77bvEvM35IZtJCCr3j5v8GI+fVbPGflUh2sOkATi4S0HT3tAOndiESEJWFNTkcHD6+iaNXkzCQSBZxiac398N51YOqlMJ3wJg68+1+bm9e+93nAGx+uiTMJs5+CUjJLmbCqaq5SJ/fFaL33JIyJc3O8SmvP3kcJRRe1qdc/wkrXzmxS1JlxU4UHeFwP141k+L0s63uGQnOgQ3pJa8UHGcTRUakFJ1pS4eXBPnV7V2nN64QWG+aNa3jXFEZbUASUN/XsQw8KdQTUUGtm8EluSVfK1uL6MYsBD4a78c67JQ38WD+Zj4VOZXKXqSd+spoVFczf7NN9aAl5HmdrkGayAKvgh/fHhApc+rHX1wOURfdQ/MED6CuUCPJ1HGqj15PF44QXcNfqYfK+xnVTzQwYFUzRf2V6GqdrXh3ubDK6LeiI4W2eha9pqzZbFpuwUT+7X7k1XOj e3SKMHNr pZ+k8DkPyOA63YuI7Am+TQs5YZ1JFXm+4+cjWwUcgUTeeRjbsOqNwWDFEQfrNoWQ+fWDOZZTRQtAosrAa0kYvZGTVpCyQUpvLidCoP/YgsYHE72O8gQUjOGPAte0/zSoToBQaLElogaXFW55bLLzr3zWJ0s+Nxfny1nAPMHHgKXFQqKk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Aug 20, 2024 at 02:54:50PM +0100, Dave Martin wrote: > On Tue, Aug 20, 2024 at 10:54:41AM +0100, Joey Gouly wrote: > > On Mon, Aug 19, 2024 at 06:09:06PM +0100, Catalin Marinas wrote: > > > On Thu, Aug 15, 2024 at 04:09:26PM +0100, Dave P Martin wrote: > > > > On Thu, Aug 15, 2024 at 02:18:15PM +0100, Joey Gouly wrote: > > > > > That's a lot of words to say, or ask, do you agree with the approach of only > > > > > saving POR_EL0 in the signal frame if num_allocated_pkeys() > 1? > > > > > > > > > > Thanks, > > > > > Joey > > > > > > > > ...So..., given all the above, it is perhaps best to go back to > > > > dumping POR_EL0 unconditionally after all, unless we have a mechanism > > > > to determine whether pkeys are in use at all. > > > > > > Ah, I can see why checking for POR_EL0_INIT is useful. Only checking for > > > the allocated keys gets confusing with pkey 0. > > > > > > Not sure what the deal is with pkey 0. Is it considered allocated by > > > default or unallocatable? If the former, it implies that pkeys are > > > already in use (hence the additional check for POR_EL0_INIT). In > > > principle the hardware allows us to use permissions where the pkeys do > > > not apply but we'd run out of indices and PTE bits to encode them, so I > > > think by default we should assume that pkey 0 is pre-allocated. > > > > > > > > > > You can consider pkey 0 allocated by default. You can actually pkey_free(0), there's nothing stopping that. > > Is that intentional? I don't really know? It's intentional from my side in that it, I allow it, because it doesn't look like x86 or PPC block pkey_free(0). I found this code that does pkey_free(0), but obviously it's a bit of a weird test case: https://github.com/ColinIanKing/stress-ng/blob/master/test/test-pkey-free.c#L29 > > You're not supposed to free pkeys that are in use, and it's quasi- > impossible to know whether pkey 0 is in use: all binaries in the > process assume that pkey is available and use it by default for their > pages, plus the stack will be painted with pkey 0, and the vDSO has to > be painted with some pkey. > > Actually, that's a good point, because of the vDSO I think that only > special bits of code with a private ABI (e.g., JITted code etc.) that > definitely don't call into the vDSO can block permissions on pkey 0... > otherwise, stuff will break. > > > > > > So I agree that it's probably best to save it unconditionally. > > > > Alright, will leave it as is! > > Ack, I think the whole discussion around this has shown that there > isn't a _simple_ argument for conditionally dumping POR_EL0... so I'm > prepared to admit defeat here. > > We might still try to slow down the consumption of the remaining space > with a "misc registers" record, instead of dedicating a record to > POR_EL0. I have some thoughts on that, but if nobody cares that much > then this probably isn't worth pursuing. > > Cheers > ---Dave >