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 1ED07C38142 for ; Fri, 27 Jan 2023 19:35:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 798FC6B0074; Fri, 27 Jan 2023 14:35:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 748D46B0075; Fri, 27 Jan 2023 14:35:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 610A16B0078; Fri, 27 Jan 2023 14:35:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 517B96B0074 for ; Fri, 27 Jan 2023 14:35:49 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 17862C0FE8 for ; Fri, 27 Jan 2023 19:35:49 +0000 (UTC) X-FDA: 80401584018.25.43B4979 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by imf07.hostedemail.com (Postfix) with ESMTP id 4073E40035 for ; Fri, 27 Jan 2023 19:35:39 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kylehuey.com header.s=google header.b=L3EAK2nH; spf=pass (imf07.hostedemail.com: domain of me@kylehuey.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=me@kylehuey.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674848139; a=rsa-sha256; cv=none; b=jHrevurVq9OjS9iErraMPIGTZWwoKlqq+AbcKDRfy+f5/H/AA123f7hA2mr5s6UVcsPGuQ 60V0Mr4d7fKf+NfdXt3VSv0T5H5Q7XcNuVZnjapg9vvEqWWyU5sn2kPQl1hXKpdqSv3CNc S0IrEVdEWS9pvcBo8+coZ5RtRSbZLfk= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kylehuey.com header.s=google header.b=L3EAK2nH; spf=pass (imf07.hostedemail.com: domain of me@kylehuey.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=me@kylehuey.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674848139; 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:dkim-signature; bh=mEQ+4NkCHJ9DfIeYIKEY/BhHghk9cfrKkpDVreNwpGY=; b=549RgeIKliBkbj+4w2Fxf2r26l/uD5Grq3GdAsmclVQbA5enT0cJoac4nZUv2MNK5qfiKv 484PQO7/L6b1Lf5HAOzCG5LzTzQ5fyjTMoAZqcV6drrsKO6qEKdnYJ0x7ma3W8pbD4T3pw GvHCYBrGe3K3zimi+Ab2MujamZBathE= Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-4ff1fa82bbbso80559027b3.10 for ; Fri, 27 Jan 2023 11:35:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kylehuey.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=mEQ+4NkCHJ9DfIeYIKEY/BhHghk9cfrKkpDVreNwpGY=; b=L3EAK2nHNnvk2Gym/ciywi1Yy9cb1LkWnoo8WNc4Ejr4zX3Bxw07VKmeOaSY3kJx99 /7wbT/UUd9e9Ze3hoCRUjL4BvdqUopRG4Q5OYGtAbqW1AIw+zCkSV1FvAInI/NkWsTXK kw9nYgzhp7Xv2HZkkfHsWtVgFMcy0+7b5bT8qlaDCAJK7V0CESJXgtAh8Apn8pNqwvNa bn3UK8gFfAqoHTzyiXOAkqVjWAI51GkFvKDeBF1cYJxw26B1/5s3mzp5st6B4oIqj1di A2bQrgeyKveE1knuJENoGQSiW9DcFpq+865VmqCAM3HKkrAmhg4nDPhP8eGd52z5F08C 0dbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mEQ+4NkCHJ9DfIeYIKEY/BhHghk9cfrKkpDVreNwpGY=; b=EJjpJik6gzaqB3q3f4xGd3NyaZgcA/GZGx+swKr8WoMtc+MEGB3cgh9x1XPtooFtCF UNWFt8c1kHvvyBZLZDYp4rTLKLqrEpRkjOOd8E5bJVJ36U7ukBG1XFeEhIFL1A7nDRzf pSQFvc4BJTmlmJfYktRwyeCkC5Yu3QaKshYzTXLRQvdZAjS1urSkcT3A3TP3NhkOUWma ytuDwezMSBnfvOz3OE1fl5oGlMrXNu7j2jVRcRvG1u1lA6de+cqCVNIupBvJOb2zvx7H 8yr4sEwSYQk454CLYvz6Fjh7dJC7OYLU1IfoyFEx27FUa0JCDWITpL8LlJWxsG9j5eIL tfnA== X-Gm-Message-State: AFqh2kqXwExeTCltwRgQpZmctKuGlMCpIScSmzO9wC2M4Vh1XFRSX+3F IbHCXoqhZuZddnQ5IuVDvh0O9lGQNA8py9SpXhHCqYzkCGTOjw== X-Google-Smtp-Source: AMrXdXsss6bkiqvXYc4VzexYMOWUm72xVVVudLxwIr0XelgeoA7qz/UAcoGjivLhWY/uyNVjEuU8j+mhizOSGEyQVHo= X-Received: by 2002:a81:1e8b:0:b0:4cd:f438:1d8c with SMTP id e133-20020a811e8b000000b004cdf4381d8cmr4970164ywe.314.1674847830665; Fri, 27 Jan 2023 11:30:30 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Kyle Huey Date: Fri, 27 Jan 2023 11:30:15 -0800 Message-ID: Subject: Re: x86/pkeys in early kernel version To: Jeff Xu Cc: Dave Hansen , linux-mm@kvack.org, =?UTF-8?Q?Stephen_R=C3=B6ttger?= , "tglx@linutronix.de" , Jorge Lucangeli Obes , Kees Cook , Guenter Roeck Content-Type: text/plain; charset="UTF-8" X-Rspam-User: X-Rspamd-Queue-Id: 4073E40035 X-Rspamd-Server: rspam01 X-Stat-Signature: xe7y3p8iursk8emsanzj6tpi5na75fsc X-HE-Tag: 1674848139-559495 X-HE-Meta: U2FsdGVkX1+JzuX62UC5Jb35VkMbUe+MCt9MF0GFADSklSfRt4BcZQVilhRQwLK2uvaVfsp8Fc4zVbguWPq2NDdLWAqvRLBvNEH1Bntmuendo30eBZ2hKU4vm0lQcYqP9FQkraCjlcrk1zxuoia9s3tQpBCsUJ5pITgkEGGJjMyKi57lQVa4gwX891Das8Z8MYUXjJ4Zn72QEZCadHjINKBDWiL0DH5K5/V6Kip2KdKAS0zAc1b5pwZ13eLMHKj75UUyrESAPI+TzjBAQ2aQZ4ztMd6Yb0Bz9HI0vAcBuB+QhDba8PQS48Yascz/S3AQ2ItKrmPInHaaWYA3j9mV3i9/m7IcT+0r6LYftyyZ3M2WF0cd1ByTX+g+s75DPZVt/Pvwq8/EKw6A+dVA2/hV9dVWQopZ15tR2O+BuWcMmRf3DlV5iEPgtHF00aMb8zdx6gIxz5b8chY9l/LypdRGO4wiYO6uXd1sWwap5UHqNOBh5CHBC0Mj5yXWnvfynZg5j5DhgdnZBuoTt8sSzkdbTYdXcyBjIWpNbNiypqKQJ3ZwPcEYXP+YH5NqwYH9uWLp7ULtxEQGUW7G8zCt3CwaPiAYze2qSeje1v9V/KWglI+q1/Xx2yHDDNW7EZ3ObCendK7RZoj1cx7XPYm40VkUzmf5663hyI87sc8DziR/FQfjEy3+hvFYwsKb1xouMpoJYm44qObGvEj1WBrhPhavbzEnK17jYv/VKIxPqRsNSdVtidj08nBARQsBpIz+oin+BwDKXfApkwYvuBtoqo8lxQapEuRB4EXg4jUVPBZAl8Jdb9VWMPzVlQLr61JSw7hOq6OCpSNSMZnexBzSXi3R2q155+Gi2wePL2p0Wew6RZxvHQkImx+6bPpVdPt2BcXT6JuKEnp70gBr31i1u2cZ28z9WJpc5np/CGG/M9T8tojWVlcV5Ws2bwXhZ2sRuSb+7SRVi1tIS/PZuMNhLwa bL86gYBm gfnqDOOo296wISF9MgSngyafgEWSiLcV4xSf3QOKGb543JSJcOuSs927gLenW2VY6FAqL1XIb6vfJ+3vW0W9pxbKt5KHipzbyVMW7S+QYn1Yyvwf7A1tFL0hNo6hwY49Eb40waOLB7a0O2HB0vUx2RcAcKGnuSW2SzkoIae3rBtlZABcV5yv5QrpzjtyEQ7pzDXcga+ssu0PyL8J2Z7/mNV5uaI2HuooIN9ola7Y2Nd6VX3AfNCyAdIQ8nc0mAhCTEi520rhED6Glyl44z9Tfouo2clrLxVXiaERt0kVoxbuFrcQpEkXGz9HQLBWscMwpnsiW61UkjHlW0BMdT+Z3AeWr5KyalIQHTGUAYOlO/8kiSD52WP1iV5Fx3hR6p8eNoQ0/1aX26ae3epf1KN5AWd904nL5/qMt4k9MDQezT3OIFCZIYuQVgEQFj6hwpiaSHSPllgxp8ljn1cV/aA6VW1Cle/4Z91y+mDcswxSdGDkBX7ke99wEOEdSwN4dkHI6jPOY2Zui6oXFeCyAXY0irUkMrWB5hRP2HzdVRy1FZGWGzl10toLdVDHG4wTQ0CiAWzp+ou6FilITgQ7tDVV2M/cjB0VzLpNS/XDzAHgU+tnszyHDLCPITQMpFRypl9ufMcudyR232BbGamwLCaGgoooP4VxaRSlXpY3e49GzuKczC0KtUOEdgLPWBQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000114, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Jan 27, 2023 at 11:22 AM Kyle Huey wrote: > > On Fri, Jan 27, 2023 at 11:08 AM Jeff Xu wrote: > > > > On Thu, Jan 26, 2023 at 9:55 PM Kyle Huey wrote: > > > > > > On Thu, Jan 26, 2023 at 9:36 PM Jeff Xu wrote: > > > > > > > > On Wed, Jan 25, 2023 at 5:43 PM Jeff Xu wrote: > > > > > > > > > > On Wed, Jan 25, 2023 at 11:13 AM Dave Hansen wrote: > > > > > > > > > > > > On 1/25/23 11:02, Jeff Xu wrote: > > > > > > > I'm investigating if there is a need to backport x86/pkeys > > > > > > > fix/feature into earlier kernel versions, Chrome is starting to use > > > > > > > PKEY in x86, and I hope experts here can give advice on this. > > > > > > > > > > > > > > For background, ChromeOS regularly syncs with upstream kernel > > > > > > > versions, and has production that uses 4.4/4.14/4.19/5.4/5.10/5.15. > > > > > > To be honest, I haven't got the foggiest idea what you need to backport. > > > > > > I can barely keep track of mainline. > > > > > > > > > > > > Are there really production 4.4 kernels that you need to run on > > > > > > pkey-capable hardware? That would mean running a 2015-era kernel on a > > > > > > CPU released in late 2020. I think Q3'2020 is when the 11th gen CPUs > > > > > > came out which were the first non-server CPUs that had pkeys. > > > > > > > > > > > Thanks! > > > > > For 11th gen CPUs, chromebook uses 5.4 and above, so that eliminate > > > > > half of the versions. > > > > > > > > > > > On a positive note, the pkeys selftest has been pretty consistently > > > > > > updated as we find bugs. I'd be curious how well a mainline version of > > > > > > that selftests runs on old kernels. But, I'm too scared to find out > > > > > > what's down that particular rabbit hole myself. > > > > > > > > > I took the latest selftest from main and run on 5.15 kernel, > > > > all passed except test_ptrace_modifies_pkru > > > > assert() at protection_keys.c::1623 test_nr: 20 iteration: 1 > > > > > > > > Is there a bugfix for the ptrace area ? > > > > Thanks > > > > > > > > > What 5.15 series kernel did you run it on? The patches for that didn't > > > get backported until 5.15.88 > > > > > Thanks! I'm using 5.15.87. > > Will this patch set be backported to 5.4 and 5.10 ? > > The selftest (from main) also failed on 5.4, in the same test, > > but at different line: > > assert() at protection_keys.c::1651 test_nr: 20 iteration: 1 > > The regression that patch set was intended to fix was introduced in > 5.14. I don't know why the test is failing on 5.4 but I have no plans > to investigate it. Just looking at the line the test is failing on though I would suspect that when PKRU was being managed by XSAVE (pre-5.14) that the PKRU register didn't get updated for clearing XSTATE_BV until the XRSTOR was actually executed (upon return to userspace). So multiple ptrace calls in succession without userspace code execution would see a stale PKRU value if the PKRU register was "changed" by clearing the relevant XSTATE_BV flag. This is an extreme edge case, so I doubt you actually care about the behavior. - Kyle > - Kyle > > > - Jeff > > > > > - Kyle > > > > > > > > > > > > > > > > I can start with 5.10 or 5.15, it seems there are quite some changes though, > > > > > for example, this one by Thomas > > > > > https://lore.kernel.org/lkml/20210623120127.327154589@linutronix.de/ > > > > > > > > > > My question is, if I have to pick a version that doesn't require a lot > > > > > of backporting, > > > > > and functionality is stable enough, what version would this be ? 5.4/5.10/5.15 ? > > > > > > > > > > -Jeff