Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp579000pxj; Fri, 28 May 2021 10:20:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgDAGoSYlDtRr648QIoq/A652D+xFL5zMAadu3he/RzKE/mcj/vImmBOiRnCj9wV/48C+h X-Received: by 2002:a05:6e02:882:: with SMTP id z2mr8205547ils.91.1622222442838; Fri, 28 May 2021 10:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622222442; cv=none; d=google.com; s=arc-20160816; b=gvQV+mR5LsH4MxG7J982T2HyUVm0Y9CwFh4eS0oydc3AW//BPnMH3quW/tesO3JRRy jqX9HY4HPrTBCvyr4fG3pXc1ULLGyhjPvK9zk167a1SDUt96pXGwQjHdcKrUFbIKsim4 DrEAKqAXwrrOUq6aTL5dITGH52CDZ8WsM+ks8lY0jxh5ttgza/E0Dq92dNRNwRNnItiN HC+owBjasMdbUN6k+MlkSm4LKdvQP6ZKTQrrTpZpUfLHy3afESPzSDs7cuhUXiDGRd98 Mn2mdyIbmwJHA3Q5Ydf6QgTameZFYpNruZMoFvthhBYLBpFKbh85KJdWREqB8a6lDNHl iPVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:dkim-signature; bh=yn9C2UzCiHbFRwGxQpkM9gMoYuukHkOj0HNSuagaxxw=; b=n6aPZ8A9TPyvsvoGgdV02Xq7z9JXMQOJclOuBK7Ym93/Qmz3zrxhDYnw+UYZeVenlg 1Y5Y7t63YtYhQx/w9AqHoZTgyQ3AiUkWTteJqntyo+vAY0JzYwgfS1ESP8fxXAteK8Xf 6MtltEuBATbyJZ3Mg8fPSshqXzWJxXfD8Lvmpdc26h9V1iQLATP8kNJmjslFJaqx6Bms QTV7Fd5q+1ek3xuDa8JWlLeuhyZdG8FMqLonjUrGkTve8Ys5QMy44qSoRI7pPnGQjvZQ WX71GG8uArcsHEU47JMLGh1/LwIXzh3pwtY17K/Zb+iR4DEHoW2QUZvyeGv+woQaKatq D0YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o0O+4tmo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si6154737jaj.15.2021.05.28.10.20.29; Fri, 28 May 2021 10:20:42 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o0O+4tmo; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236386AbhE1RPe (ORCPT + 99 others); Fri, 28 May 2021 13:15:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:35954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229641AbhE1RPc (ORCPT ); Fri, 28 May 2021 13:15:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 95338613B6; Fri, 28 May 2021 17:13:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622222037; bh=btu1XKYl/SxptLijDHm9O5VtHEC06LI6a/VkclgT8tE=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=o0O+4tmo1e3pS1ydtGlw+kn/keT9AcWAQQMJE+kzkkp6aXqL6LN9KCGW3u0msJJsr UdXTfQSR737WilcuaFQ5JkMeVw2w8zyGDzFxM6z9SNZiulb2+YlJ0vAs84eoNzmlsI TBHNe574uCR3h7DvAAGTjFlXpioNQ7Xvy+4DO0SiPvNonDoxS/o4NJU5CvBr2IJAWx Tvr2kVWadNIEFHCdA5msCESZ6VishJPDfFMMFWuhbGqiEz7lviMgRO0DSFgQsG4Vd+ RSHGjm7+6zjTyo3VjIkYOLOscQ7Gu0cIYBlo1+Tf8CS7J7ogEX2nhJDxFVowDJTcjr /w/fBViEKDw7A== Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailauth.nyi.internal (Postfix) with ESMTP id 97B1327C0054; Fri, 28 May 2021 13:13:55 -0400 (EDT) Received: from imap21 ([10.202.2.71]) by compute2.internal (MEProxy); Fri, 28 May 2021 13:13:55 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdekjedguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedftehn ugihucfnuhhtohhmihhrshhkihdfuceolhhuthhosehkvghrnhgvlhdrohhrgheqnecugg ftrfgrthhtvghrnheptdfhheettddvtedvtedugfeuuefhtddugedvleevleefvdetleff gfefvdekgeefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homheprghnugihodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudeiudek heeifedvqddvieefudeiiedtkedqlhhuthhopeepkhgvrhhnvghlrdhorhhgsehlihhnuh igrdhluhhtohdruhhs X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 014BB51C0060; Fri, 28 May 2021 13:13:52 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-468-gdb53729b73-fm-20210517.001-gdb53729b Mime-Version: 1.0 Message-Id: <3781d3ec-6d1b-4d04-8bed-19985115153d@www.fastmail.com> In-Reply-To: <4c3bfc27-a542-8e91-7ccf-4be8b1e6c844@intel.com> References: <20210527235109.B2A9F45F@viggo.jf.intel.com> <87eedq7u2b.ffs@nanos.tec.linutronix.de> <4c3bfc27-a542-8e91-7ccf-4be8b1e6c844@intel.com> Date: Fri, 28 May 2021 10:13:32 -0700 From: "Andy Lutomirski" To: "Dave Hansen" , "Thomas Gleixner" , "Dave Hansen" , linux-mm@kvack.org Cc: "Linux Kernel Mailing List" , "Ingo Molnar" , "Borislav Petkov" , "the arch/x86 maintainers" , shuah@kernel.org, "Babu Moger" , dave.kleikamp@oracle.com, linuxram@us.ibm.com, bauerman@linux.ibm.com Subject: Re: [PATCH 0/5] x86/pkeys: PKRU manipulation bug fixes and cleanups Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 28, 2021, at 9:11 AM, Dave Hansen wrote: > On 5/28/21 8:32 AM, Thomas Gleixner wrote: > >> > >> This series: > >> * Moves the PKRU manipulation to a more appropriate location, > >> away from the page table code > >> * Wraps get_xsave_addr() with more structured, less error-prone > >> interfaces. > >> * Conditionally hides a pkey debugfs file, eliminating the need > >> for new runtime checks to work with the new interface. > >> * Add a selftest to make it more likely to catch bugs like this > >> in the future. This improved selftest catches this issue on > >> Intel CPUs. Without the improvement, it only triggers on AMD. > > I think all of this is fundamentaly wrong. > > > > Contrary to FPU state, PKRU has to be updated at context switch > > time. There is absolutely no point in having PKRU XSAVES managed. > > > > It's broken in several ways. Anything which clears and loads the FPU > > will load the wrong PKRU value. Go figure... > > > > So the right thing is to disable PKRU in XCR0 and on sched out simply do > > > > task->thread.pkru = read_pkru(); > > > > and on sched in > > > > write_pkru(task->thread.pkru); > > > > Simple, trivial and not going to be wreckaged by anything which fiddles > > with xstates. We all know by now that xstates is a trainwreck and not > > having stuff like that in there is making the fixes I'm doing way > > simpler. > > As for the general sentiment that PKRU is not suitable for management > with XSAVE, I'm with you. > > I have a few concerns about moving away from XSAVE management, though. > I'm not nixing the whole idea, but there are some things we need to resolve. > > First is that there _may_ be ABI concerns. I tend to think that, for -stable, we should fix the bug without an ABI change.