Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp823316pxb; Thu, 17 Feb 2022 15:50:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJxRzx6kIERJ2g0PB5PxWX5EzHx0JGBKL6IQKtjeyjdtkPGYjaxNnRauLrcwhAQk4aO332ie X-Received: by 2002:a63:e747:0:b0:372:c757:c569 with SMTP id j7-20020a63e747000000b00372c757c569mr4234023pgk.516.1645141850622; Thu, 17 Feb 2022 15:50:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645141850; cv=none; d=google.com; s=arc-20160816; b=jxpcxks7ovmK8vc3h8y+fCGcVQwAO9fVNMGSWZOfP6IsLJ6gDPlV7SANHTAy/lebeM BOZHLzQmZnG+CwvnNtSog4DfFqUIWjfGdjMXFM/seEDeU8oIsSLfOeDPYcx2Whv27UXs RiWm/tXjPJXlNOraW+tR/p33yjFy/LoKoo5Ni2kxfMRT4O1veEf/9H5PGPM+g6eTM9+s ryk0OCk+kOVkEfT2HDNm6w734KIOV4F5V1Dz0fEqbitM6AezIx33BeIhJs04j/06iDjy U3+c7A0ivnkuwa9ID+SClJ/4ceeYG9O5HP5CcCvoPBDP/uL6OG2QxMTX/0uIuiknbJg+ SSZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=R4HSynY+GXD3vvbZ57eqLTHLNIFY/JTbAe+61rsZUWQ=; b=wMkPG7Luq2A68IK/99619RAHfyUc+L3/pXy8CZa9Iu47P/+063hn9tRVv6G12Xd73U FMnxqMdFJ5EYVI7yAcipe1YXLEsp6VM2Bm7LpANANPo1OmCxVs56DUGnZLrHnXxEnCVN gH8p4Z99SwgpnbUklncoW5S9qJQ9B3IVSCMtl0tSxN6Bm/ahXsl4LyBkTXMZKeySnIaH s03wASD9e9/B5sz/XG+JR4m/chN5pu989cUKxbZa7FDsmkeNZ6f4df9CcCSPz3kgx9Y/ tdzLUVELz7Qd+3e8vZT7R9NZc2SKucVY/JuHbTAuK3ZTbYryI4U2PdfLHByPRzEjW0Ru WyHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=mjICA68i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id dw18si1933150pjb.140.2022.02.17.15.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 15:50:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=mjICA68i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A88DC4D258; Thu, 17 Feb 2022 15:23:30 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235044AbiBQUnb (ORCPT + 99 others); Thu, 17 Feb 2022 15:43:31 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:58206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbiBQUna (ORCPT ); Thu, 17 Feb 2022 15:43:30 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D64415C9D3 for ; Thu, 17 Feb 2022 12:43:15 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id x5so11757384edd.11 for ; Thu, 17 Feb 2022 12:43:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=R4HSynY+GXD3vvbZ57eqLTHLNIFY/JTbAe+61rsZUWQ=; b=mjICA68i4LOmyP3tUQUOzGui3EbhuY2aprlcHIZSLWaJ8jt6kABk6AtxAMqpFqkL6J RCe98mtXnoqQAId+IK8SZl23y6FH7hnNd1Jt0qFqnhvTSiljon62CD+CwbMnEZZ1EDr7 ruYj8FBZJPGOuN3oJRjLgKEZl37/fJ4k8X6VJTi6RccFlrU2+LkCDfwT1/1JTAQUZhbJ 4Q7grk7QjB5dpjpNFD1XuIKDk22hQVGh4HpbqV6AeWkMNjC+Z5oBNXRyxIToFdsu2Uxw 9Da9QNEffTjNLeMS9ys69pi9L+Zlv64vlf36ZjyjLL0aXHAs7+c1I3Rtt8Y8nwoP7dA/ evng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=R4HSynY+GXD3vvbZ57eqLTHLNIFY/JTbAe+61rsZUWQ=; b=fswWoQ/UrooX8b+s3tEK2o6Lc8yP03s8Uu6lUgWj584ypFZt8NwxmmVq2IjsiAxnNP Bbo5K2a1jRlOESITmCQX1YCxhdc7Y+cdPG21SEwWOQGp33QEdARaQOLt1dLH3Ru+4nJL Ya0fFthZYstP7smuR5cguuMi4nxcaoQCjO8OmTbHYgI5UkwO8+KTslJpTPvEBteuKEsh WDj5XNJZBvQlkOwueRh49jAh6UI2vefJHzjsBknaoTu6ajI4RgTKyMGVIq/OSDqP4XTk mYs2CiylILwotwUKV5XbLPm3ldE5ZccciNX5iXe8341HZUIe+NzbZdNfxYfEEvOti9tH rvuQ== X-Gm-Message-State: AOAM530Cr8G/G4lacLdS2IMTGQkyMrgBuXMiu+o2gnmqM3czo9jru5iP iZYkrrtKjHpfDGDMrPkWZTr1iHgRJADNxaN0lDQcsQ== X-Received: by 2002:aa7:cd81:0:b0:410:d64e:aa31 with SMTP id x1-20020aa7cd81000000b00410d64eaa31mr4594705edv.167.1645130593426; Thu, 17 Feb 2022 12:43:13 -0800 (PST) MIME-Version: 1.0 References: <543efc25-9b99-53cd-e305-d8b4d917b64b@intel.com> <20220215192233.8717-1-bgeffon@google.com> In-Reply-To: From: Brian Geffon Date: Thu, 17 Feb 2022 15:42:37 -0500 Message-ID: Subject: Re: [PATCH stable 5.4,5.10] x86/fpu: Correct pkru/xstate inconsistency To: Dave Hansen Cc: Greg KH , Thomas Gleixner , Willis Kung , Guenter Roeck , Borislav Petkov , Andy Lutomirski , "# v4 . 10+" , "the arch/x86 maintainers" , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 17, 2022 at 11:44 AM Dave Hansen wrote: > > On 2/17/22 05:31, Brian Geffon wrote: > > How would you and Greg KH like to proceed with this? I'm happy to help > > however I can. > > If I could wave a magic wand, I'd just apply the whole FPU rewrite to > stable. > > My second choice would be to stop managing PKRU with XSAVE. > x86_pkru_load() uses WRPKRU instead of XSAVE and keeps the task's PKRU > in task->pkru instead of the XSAVE buffer. Doing that will take some > care, including pulling XFEATURE_PKRU out of the feature mask (RFBM) at > XRSTOR. I _think_ that can be done in a manageable set of patches which > will keep stable close to mainline. I recognize that more bugs might > get introduced in the process which are unique to stable. Hi Dave, I did take some time to look through that series and pick out what I think is the minimum set that would pull out PKRU from xstate, that list is: 9782a712eb x86/fpu: Add PKRU storage outside of task XSAVE buffer 784a46618f x86/pkeys: Move read_pkru() and write_pkru() ff7ebff47c59 x86/pkru: Provide pkru_write_default() 739e2eec0f x86/pkru: Provide pkru_get_init_value() fa8c84b77a x86/cpu: Write the default PKRU value when enabling PKE 72a6c08c44 x86/pkru: Remove xstate fiddling from write_pkru() 2ebe81c6d8 x86/fpu: Dont restore PKRU in fpregs_restore_userspace() 71ef453355 x86/kvm: Avoid looking up PKRU in XSAVE buffer 954436989c x86/fpu: Remove PKRU handling from switch_fpu_finish() e84ba47e31 x86/fpu: Hook up PKRU into ptrace() 30a304a138 x86/fpu: Mask PKRU from kernel XRSTOR[S] operations 0e8c54f6b2c x86/fpu: Don't store PKRU in xstate in fpu_reset_fpstate() The majority of these don't apply cleanly to 5.4, and there are some other patches we'd have to pull back too that moved code and some of the those won't be needed for 5.10 though. TBH, I'm not sure it makes sense to try to do this just given the fact that most do not cleanly apply. Brian > > If you give that a shot and realize that it's not feasible to do a > subset, then we can fall back to the minimal fix. I'm not asking for a > multi-month engineering effort here. Maybe an hour or two to see if > it's really as scary as it looks.