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 3BCC6C54EAA for ; Fri, 27 Jan 2023 21:13:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7EAF76B0075; Fri, 27 Jan 2023 16:13:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 773F56B007B; Fri, 27 Jan 2023 16:13:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5EDB66B007D; Fri, 27 Jan 2023 16:13:23 -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 4997E6B0075 for ; Fri, 27 Jan 2023 16:13:23 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0F9921408B2 for ; Fri, 27 Jan 2023 21:13:23 +0000 (UTC) X-FDA: 80401829886.20.D6AFBEB Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by imf27.hostedemail.com (Postfix) with ESMTP id 5092A40017 for ; Fri, 27 Jan 2023 21:13:13 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=nfv2PKwv; spf=pass (imf27.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.208.44 as permitted sender) smtp.mailfrom=jeffxu@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674853993; 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=imBDhfMcLcKXaDGLuASwmEAm4ntQf7PMTsfwn14XH1M=; b=B/yINbOy/pPp0E8x3TBTcAegWQWsmktj7+lKxzXVwPJEMHiXOnjnMgClXxiBGDWfvbckoW bQsrRMO1TVs10XOhkJGIseFB5bj9RHS5qg4Tsqu/i6MLsxkzjhKG9tKd4lq6ek/NTgYM6s Rx0OsccUeYVLfcr7+/wWr113eLorS9c= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=nfv2PKwv; spf=pass (imf27.hostedemail.com: domain of jeffxu@chromium.org designates 209.85.208.44 as permitted sender) smtp.mailfrom=jeffxu@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674853993; a=rsa-sha256; cv=none; b=Lhi+OaA061FcQy5v7JNh6mmNZAVH7IVzJdxfIDACxvAdqP8FTOc6wwdRg2aONHFgCjX9eT IcLbLejcDHbe8dZENb5nzKLk/XinWWMXYgsd8LfEybzrGT1Cc82+GQ0fd8FiLvsyjg4fCU taRrSCuuzO5XHVC5LV7DUlszTaUCdzk= Received: by mail-ed1-f44.google.com with SMTP id g11so5826814eda.12 for ; Fri, 27 Jan 2023 13:13:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; 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=imBDhfMcLcKXaDGLuASwmEAm4ntQf7PMTsfwn14XH1M=; b=nfv2PKwv8nmNIsrxtNlcJZ04YCWzlt1NrwWGytEsxS+rkgRTd6TTSy64uEGdYMDC5X J4VtPAvL525VCNjI1Nj1/O1wIui46S5YSGq5cORZCyWFPTz9/zJJG87LuMZXgIJd2YPQ PNunMsmvgP+MPqPMMMheHBB05NXcqnnE3W08s= 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=imBDhfMcLcKXaDGLuASwmEAm4ntQf7PMTsfwn14XH1M=; b=yWOQRwbopasgOFfuyHc+kyk+rshxjHeyujRinpYCmNDUynohhA9R0YzQ83nimn7flF tTLbBF90lufeMf/pS52qEeyL2Y4MUfw94qBgHH/LFiEtD9QFfL8nDy/wCpqHGRhGNqFb S3bGNBLPPW1LnpaJUwWdcplA3WVW9R6AEZURMyblC1cB5mg7sc4GnQzeyD1d1KrU0mOz AIuTWRZGrt/BAb3S1+ZujnDCRA3R5uPSA1AQGLd5paXI3sN0jbaKtb3SHBp5/7DL788n Ph2Ye6PhFFAHURwX8ncY5FI4ofHhyCjBRmg75El2WRbaVaxZZjc72fz/eDEL6zSzjtO+ WnKQ== X-Gm-Message-State: AFqh2koIi+2aUwIWgQTZOzYLskN2Uulk6M2j7taURYkUZDKWywn3rhgm oD7MkF76R4k4ns3bamBQVh3GTVOF740B6I7UwRoU6w== X-Google-Smtp-Source: AMrXdXtJhjioAZgG0qasAtBFA5fERAcB5zMk6Ee785iatvsZkArD6ysilZbHBHJnithQrclt9ysUwZJXgMX3SG/eybc= X-Received: by 2002:aa7:dd53:0:b0:484:fcc3:424d with SMTP id o19-20020aa7dd53000000b00484fcc3424dmr6922593edw.40.1674853979903; Fri, 27 Jan 2023 13:12:59 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jeff Xu Date: Fri, 27 Jan 2023 13:12:48 -0800 Message-ID: Subject: Re: x86/pkeys in early kernel version To: Kyle Huey 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-Rspamd-Queue-Id: 5092A40017 X-Stat-Signature: zaq5751p1tn4zghmy7jmkyrbz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ity: 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: On Fri, Jan 27, 2023 at 11:30 AM Kyle Huey wrote: > > 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. > Thank you for the details! -Jeff > - 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