Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5106244pxj; Tue, 22 Jun 2021 15:26:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5qefYJw6Xn58qOwUzh7+LrSC/8sijO4ZbidsJ8ZE+Z+69bgidXqlChUJ+3YMnK1sIjU/x X-Received: by 2002:a6b:8ec2:: with SMTP id q185mr4611435iod.22.1624400801592; Tue, 22 Jun 2021 15:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624400801; cv=none; d=google.com; s=arc-20160816; b=s0FSM0ZuFZpW818u3ctey701/vWin+ZNncxGwadXkdW7g5NPor8DdpkkC8SEs1Bha7 YqWqHGgS3Yfy1Ep1JVpf28D0fbLrbi6lRkvKzaajqIvwtJw6zXG+M+GZKomOejsecpJi pcJcnbHtLLJdEOoArlbSR/PkX0UE6OKN914QOJUNGSs4+MRPIPfMpJICRp9Pbd5bZvrI hgExdwXtXMiawUiPN7RZioT5NxKSL9qOxwAHUsvdCa4H7bk5vjDIfn8GaC7J29mW6sg4 h2sJQOumPvzqUYKNatUJjwzoPB2zdK07Il9xkGTWQ1dQbnrCYutQzjwe/JfK0E5n1V3K WJEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:in-reply-to:references:date:from:cc :to:subject:ironport-sdr:ironport-sdr; bh=iKfX49Bwvg4890N+SKC+VnwGDCZwSNNT9Ipu68pi2+I=; b=pcs+uy1VAnTLCDM4/lNF5V0VpaEWI8de3eP3NSY2UNZdO7ysxo65K3AskpS3URYINF 3ll3T9cUnd80qdBwtN+poY5KlEdRHBJ+/MzGi6py5vNOC0O5jV8xCqte+Jq+rbI/6DVb SH4HwsqXJVw8s7c+9YE7WUx6Ek+6TDwLpqtDtSv9l0MbVYUTu9CKyAx/van33czwRKAO AnE/GPNZ26tAy+CmdNkPOR3H8Fdz6iCKRISo6ngLVsbthuCOiPhuzM3lcVDD1Ux5Qv8W 2iMS+60YdILRTI1xvmMQbHIeQN4858WjRUIZpd977DAPIMP+uqyLVrc6uiz9xjlU8ibi 9jSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si746357jap.0.2021.06.22.15.26.30; Tue, 22 Jun 2021 15:26:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230379AbhFVW2E (ORCPT + 99 others); Tue, 22 Jun 2021 18:28:04 -0400 Received: from mga04.intel.com ([192.55.52.120]:42834 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbhFVW2A (ORCPT ); Tue, 22 Jun 2021 18:28:00 -0400 IronPort-SDR: Mjd6RI1Z939a88c7zpL0wVqiTZT2Ltkbn1DpDpE51qhC22sUMR1awEHYdw1NZMM6Ykh+b4AmAl 0GrjmKUesj7Q== X-IronPort-AV: E=McAfee;i="6200,9189,10023"; a="205326073" X-IronPort-AV: E=Sophos;i="5.83,292,1616482800"; d="scan'208";a="205326073" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2021 15:25:44 -0700 IronPort-SDR: l/2YXcZIURD4o4Mz8p7B9GgFYO6mzupeXtmpv8/Lii3Yi7ndbLUqPRyV4pM9pjUFP/Z5jhG50m 6atJVNRTCPfQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,292,1616482800"; d="scan'208";a="444756931" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by orsmga007.jf.intel.com with ESMTP; 22 Jun 2021 15:25:43 -0700 Subject: [RFC][PATCH 2/8] x86/fpu: hook up PKRU into signal user ABIs To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Dave Hansen , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, luto@kernel.org From: Dave Hansen Date: Tue, 22 Jun 2021 15:24:59 -0700 References: <20210622222455.E901B5AC@viggo.jf.intel.com> In-Reply-To: <20210622222455.E901B5AC@viggo.jf.intel.com> Message-Id: <20210622222459.9C76B034@viggo.jf.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen One nice thing about having PKRU be XSAVE-managed is that it gets naturally exposed into the XSAVE-using ABIs. Now that XSAVE will not be used to manage PKRU, these ABIs need to be manually enabled to deal with PKRU. For signals (the restore_hwregs_from_user() path), it's quite straightforward. restore_hwregs_from_user() will update PKRU in from the user signal buffer. Ensure that PKRU is shuffled into the thread storage. Signed-off-by: Dave Hansen Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: x86@kernel.org Cc: Andy Lutomirski --- b/arch/x86/kernel/fpu/signal.c | 7 +++++++ 1 file changed, 7 insertions(+) diff -puN arch/x86/kernel/fpu/signal.c~fpu-sig-stash-pkru arch/x86/kernel/fpu/signal.c --- a/arch/x86/kernel/fpu/signal.c~fpu-sig-stash-pkru 2021-06-22 14:49:07.899051760 -0700 +++ b/arch/x86/kernel/fpu/signal.c 2021-06-22 14:49:07.903051760 -0700 @@ -233,6 +233,13 @@ static int restore_hwregs_from_user(void if (!ret && unlikely(init_bv)) os_xrstor(&init_fpstate.xsave, init_bv); + + /* + * PKRU may have been modified by XRSTOR, + * save the possibly updated value: + */ + current->thread.pkru = read_pkru(); + return ret; } else if (use_fxsr()) { return fxrstor_from_user_sigframe(buf); _