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 A365FEE49BD for ; Wed, 11 Sep 2024 15:02:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C87594005B; Wed, 11 Sep 2024 11:02:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 151F294004F; Wed, 11 Sep 2024 11:02:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F343994005B; Wed, 11 Sep 2024 11:02:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CF5AE94004F for ; Wed, 11 Sep 2024 11:02:04 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6E0D51A1720 for ; Wed, 11 Sep 2024 15:02:04 +0000 (UTC) X-FDA: 82552772568.08.D9643E5 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf26.hostedemail.com (Postfix) with ESMTP id 5938E14000B for ; Wed, 11 Sep 2024 15:02:02 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@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=1726066870; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EYbGKm1870+1flzJfJIV1AUuqRBsBPnqdKUWToQbszU=; b=LCOblRUcQ5YWr96Wj0FDftX6XDB30jfTVJArUP+6gUbcb2fEyxCwyT6T4KOZbyT223jfhd DW5DasXiGlBl0cjslAdJ0wD0Air/9Sucbkx+VH60rUOu5XGiiSd7SV7tTdf2bFGGOxuTUG HUEfDvhzGhxU7lPZFrbYBgQQdm6bKPU= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of kevin.brodsky@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=kevin.brodsky@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726066870; a=rsa-sha256; cv=none; b=KwSS06uL/mkbvZsyqW6uqV5qZc5NDEf3QVW75QFm7O816GF3x5Kw6l/T4Y4rIS5UKrOhjU 8LWtzAz+Mm1Hoymoo+6Zj30Xg6vYYgsENZqNYWWc/CTJB8hXsAkY6avrmne9+ksmHptFOv yCd0MH31gv5DwVFxDXNIMn6my+TkPHQ= 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 DBAFD1007; Wed, 11 Sep 2024 08:02:30 -0700 (PDT) Received: from [10.57.74.200] (unknown [10.57.74.200]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BE3AF3F73B; Wed, 11 Sep 2024 08:01:55 -0700 (PDT) Message-ID: <425b8f8c-b6b5-422a-b5f4-41dd2d1ae3bb@arm.com> Date: Wed, 11 Sep 2024 17:01:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 06/30] arm64: context switch POR_EL0 register To: Joey Gouly , linux-arm-kernel@lists.infradead.org Cc: nd@arm.com, akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, anshuman.khandual@arm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, 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, skhan@linuxfoundation.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev, linux-kselftest@vger.kernel.org References: <20240822151113.1479789-1-joey.gouly@arm.com> <20240822151113.1479789-7-joey.gouly@arm.com> Content-Language: en-GB From: Kevin Brodsky In-Reply-To: <20240822151113.1479789-7-joey.gouly@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 5938E14000B X-Stat-Signature: aj6qowdr5xy44dtckcsmczq3wgrmf789 X-HE-Tag: 1726066922-254928 X-HE-Meta: U2FsdGVkX1/sHhvtseGGAIT/4q0UE/tkcKpyL6A/XPz26Ql7S1+dGrX9ChJTe/ETw5GyvVHFCKsc2m5qzIivbbcoer/fVcbXxchXoDjEEVzjXYub6wb0A5Td68x14keRA+hBsghFEWyIRKQwOfcwCkbocdRWQTagKp76aXiVmCNSr8Kun5R8k4W0bOLDyWZWhb0YhZOm7XdyHr9L4HAptslEx2JGtdMRb/+RqeWAYJuh/z7h6i6ZMqoEej6L7Bhrl3fw4vGi0gDp9oD1UnGVoHl4tzF8EJxOht1XCKL11xH3gGL+MTO8gGZkkU1cY0dqjEjyf4uXpOroms+8ibfOgTPD8zOrGCCnSpryH+/eK1tlE9oaMUr42vhSvvqLEpczofkfzGgGvag9aCcfePPICD4E7FcgNgZII2V2iqfpCvQ5v9axoqhHWMMxeUIgPox5eo2ZTVOoimVsVIVTjoP84N/aymaiIx3lkc17h0RST44PCIQENYcJFL40X8tOUhN9oXy0TJ69NvfcLtGm3KJ4oY54bFTrS6aYHc8ieqAyb3llpW/KjXQqPAJVfxcUAG8QDR8+6FWI/UpJRkLVCvI3Y8NRWgmDc0pkb3qoR+rozNMDb75z20O279dWY3X8QQAakC1/y+LVbKraDK0h5m3mZhgbgkdAFub14LK2V6DZD4Myti/ACEyXecHI4sz3uv+PjckYNlTtqRzPZCCw9raEfXjg3LL1YzTu4uEUvVyBL56C56uDIjwhIhi60ZdsT9zbqc0MCyvUxCR1MgGW6eSqCPvgbBWje3LviLWI0asNHT3GdCGhmjpWp6CiseHR3Zhp0b3cU+ZmE/cBgBZAHegFdkUurfaT98ZKQQUOGGi6jOVm3/5wGGlZYOorI2RKlr/usVlVsvpq9VUY9KlouR8DJVsm/91dHFuKY+9RTjH15ueoQ+/98wBuJAjjgnDLT9AS1XKOnpmZ7wsFsV76b8S TFkKEKqi 9yv/ozxOxTHho15eMguNj5/XIy05Nqe3Zd0Jw9dZKN9lI/iNekQ2zpFoXmmUki1KKJ9fNtEcyOfl6fLoqXqan4nrJoIXnWW64IiqNU4tSvS/6jEFMqggeqKDfMj7eq5/woptL40Oecp7RB6C4+KNxdzzx9S5n8LyuUaPUWi4lurzhRspeYwx1irdlP2ouKPGQeiRXsSczrdizSWUraCXFc/4OuN/FMxpJDOx98h4US/ycHmex92jxnP0LrDsyvAlpPfGXl39hcwYDsDbXLbt8h1vetg== 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 22/08/2024 17:10, Joey Gouly wrote: > @@ -371,6 +382,9 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) > if (system_supports_tpidr2()) > p->thread.tpidr2_el0 = read_sysreg_s(SYS_TPIDR2_EL0); > > + if (system_supports_poe()) > + p->thread.por_el0 = read_sysreg_s(SYS_POR_EL0); Here we are only reloading POR_EL0's value if the target is a user thread. However, as this series stands, POR_EL0 is also relevant to kthreads, because any uaccess or GUP done from a kthread will also be checked against POR_EL0. This is especially important in cases like the io_uring kthread, which accesses the memory of the user process that spawned it. To prevent such a kthread from inheriting a stale value of POR_EL0, it seems that we should reload POR_EL0's value in all cases (user and kernel thread). Other approaches could also be considered (e.g. resetting POR_EL0 to unrestricted when creating a kthread), see my reply on v4 [1]. Kevin [1] https://lore.kernel.org/linux-arm-kernel/b4f8b351-4c83-43b4-bfbe-8f67f3f56fb9@arm.com/