Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1147065imm; Wed, 19 Sep 2018 12:57:32 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaslXX29oPTnT2MNUJQdip8CTR7jZpdznhCCzahwmbJ2BRoZtvfXHkhIXxbQaV6lScbRDLG X-Received: by 2002:a62:2e02:: with SMTP id u2-v6mr37992426pfu.134.1537387052781; Wed, 19 Sep 2018 12:57:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537387052; cv=none; d=google.com; s=arc-20160816; b=o/7w+3kRFZXVV4YiaWmYg5MU0t9JYPvv6aupx5ytYumzlmbwxgaibUVSK2A3SnBRG0 tOzxfl13q1+V723Cutg03MorOMd8yxhg023euCm5rgyyU721g6QJyMqE3GMcPiRJlQyk OUKqKl238oc1caslLP4OcIXKOT5dZHAYHne3PNkit1HsL9Dica82p6wZwDVvPKsUhQR+ DovswXO/0ntUQaqlDfk5RoEIHmYJ26YJbO2IBYTYOtlLgTan7x7y/koakcq5bTO6p9zi SksmKPm69pGiE8QbcUwOw5rb34RH3oq1gI89b2L5oy8N7ob11CdIDlwuDWnsrEjhGMRp gkjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=bzyfvbrR/LHN7Wn4QNbtu6FWbxbPrPUtwbxxperCojo=; b=PpocxDJmzsS7rUVyybfxja4kopZfDZRbXv20U5WeIPvD6jvDhY+h2c1VL+5WfqjtKQ QLGwyf3G/K6lu1Et1rVHkMiMhspF9ZyaXEIewKhmYbNyf7jB497P6F8gxtIjqPmMwYp6 bbdetp9CleKaHbBFJ+S+HtflMANnLOF6Xnw6Ea2bd2cENZARLK+P0rdzycGaxz3y9m97 YPr3GNHMCYAXESvGmDEfnP0xK3L8WJR0ACjRZdFDMaa+uy0SBi8FourLZnLZu6T67QOf e4hasSkfG+lQrnO3W3o/oiafa7LVwjAQvZDMgiYydIboDIvol9kwzGAI9hupgAGMjwVy waFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=gDSygDlY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t31-v6si17626282pga.167.2018.09.19.12.57.16; Wed, 19 Sep 2018 12:57:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=gDSygDlY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732919AbeITB3E (ORCPT + 99 others); Wed, 19 Sep 2018 21:29:04 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:47055 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728096AbeITB3D (ORCPT ); Wed, 19 Sep 2018 21:29:03 -0400 Received: by mail-pg1-f195.google.com with SMTP id b129-v6so3220118pga.13 for ; Wed, 19 Sep 2018 12:49:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=bzyfvbrR/LHN7Wn4QNbtu6FWbxbPrPUtwbxxperCojo=; b=gDSygDlYuxjvk29iodPYikGSp1PxDeOW9ymjfkV2ZDdIraBQbV2uL32jXuWE51DiX+ 4NW/kLK0EuW7NVpU53VEAnx78WbqnP7AZkPa7woZ0RMwv20OCzIQGemYaTfrwKihHom+ J3rLq06r0wl+9khpynmAjh0bX124nXddmsBHf4SJMVOX9ow7Jjsrd7G4PsDcRwbjuDSU +0ZMOB9KrUOoFJYrCHoEJS3nvTIaL9O1NArlUiQblS0LAY/7X1KSGuOrh/JTXfLr6MsW wOxD7MOm5O3DcXAEuLnChzY1lLF8sXgj6cdFUPu7Yy/lh1jeiVIx76eDr1Ufw6niIPMM 50Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=bzyfvbrR/LHN7Wn4QNbtu6FWbxbPrPUtwbxxperCojo=; b=C7i1McmVfUDLRgOQnY0uOieQ2F3WRtHwCYx4xg4E9QCdgWV3gVLVAC79PeaMxGAJXH POzdLytN8kcel6WT1Bcs3GkkxZ6jI8aq2ZoIFQYbecwWA9dgseU0HCd9+k1qQB7kZFT/ jsjwwAIhWriU6F76hljx5YZS7O/6tohPWoT8k8/7R00cbpaBxbgI8pK3BJj6KG5vImo7 z+ZEjtHHZN8vUVO2WYZCFZuYKt3YYSJbM8ffmnwubCC1cEIuZxukhsYpXHYq3bceoXYt NSEF6zbyBO8OdBfgHSUU2ASOULcqCmr+ooFTfnxQNTL2vHLNhQ18+LLE/jd0liqIAPbP Sk8A== X-Gm-Message-State: APzg51AkStrBJiEdA69ad9DBwiAh0DPubAUgK/q0ogq+CvDVewzNDDb1 gbNahNuCZUdKz7hTfyqPEGbTfg== X-Received: by 2002:a63:165f:: with SMTP id 31-v6mr12757840pgw.103.1537386577095; Wed, 19 Sep 2018 12:49:37 -0700 (PDT) Received: from ?IPv6:2601:646:c200:7429:ad:6d57:4d4:12f6? ([2601:646:c200:7429:ad:6d57:4d4:12f6]) by smtp.gmail.com with ESMTPSA id h190-v6sm36847591pge.18.2018.09.19.12.49.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Sep 2018 12:49:36 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: [RFC PATCH 04/10 v2 ] x86/fpu: eager switch PKRU state From: Andy Lutomirski X-Mailer: iPhone Mail (15G77) In-Reply-To: <099b9f82-e162-c91a-bc51-aa1ac0cd50aa@redhat.com> Date: Wed, 19 Sep 2018 12:49:35 -0700 Cc: Sebastian Andrzej Siewior , Rik van Riel , linux-kernel@vger.kernel.org, x86@kernel.org, Andy Lutomirski , =?utf-8?Q?Radim_Kr=C4=8Dm=C3=A1=C5=99?= , kvm@vger.kernel.org, "Jason A. Donenfeld" Content-Transfer-Encoding: quoted-printable Message-Id: <27496B23-92A0-462C-A198-6A4413634488@amacapital.net> References: <8e5b64e4-b3e6-f884-beb6-b7b69ab2d8c1@redhat.com> <20180914203501.qibhpmueosvkr74w@linutronix.de> <20180918142701.atfb4ul45k7tl6ew@linutronix.de> <7e9a13f3-93f5-fe4a-20d2-f4f9407bd43b@redhat.com> <83e271e1298d603c1105dd0dbea32d67da9cf1fa.camel@surriel.com> <36e8493f-f994-e885-8fe6-2f0d4a9904a1@redhat.com> <20180918160419.2zeru6xnufxixcax@linutronix.de> <11aa7d0f4ba36eff8b61a5dc1bd35ee5195fd576.camel@surriel.com> <20180919165719.iepvc7tg6aabp5mm@linutronix.de> <099b9f82-e162-c91a-bc51-aa1ac0cd50aa@redhat.com> To: Paolo Bonzini Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Sep 19, 2018, at 10:00 AM, Paolo Bonzini wrote: >=20 >> On 19/09/2018 18:57, Sebastian Andrzej Siewior wrote: >>> On 2018-09-19 07:55:51 [+0200], Paolo Bonzini wrote: >>> A kthread can do use_mm/unuse_mm. >>=20 >> indeed. The FPU struct for the kernel thread isn't valid / does not >> contain the expected PKRU value. So loading the pkru value from the >> struct FPU does not work as expected. We could set it to 0 for a kernel >> thread so we don't end up with a random value. >> If we want to get this usecase working then we would have to move pkru >> value from FPU to mm_struct and consider it in use_mm(). Do we want >> this? >=20 > As a start, I think keeping it in the FPU struct but loading it > unconditionally will work. kthreads will not obey PKU but it will be > better already. >=20 > I honestly don't know if PKRU should be per-mm, I don't know mm very > well despite my brilliant observation above. :) >=20 >=20 It must be per thread. I don=E2=80=99t think it=E2=80=99s possible to have s= ane semantics per mm. I also think that use_mm should set PKRU to the same value that signal handl= ers use. If we use 0, it=E2=80=99s a recipe for accidental PK bypass.=