Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5613419imm; Wed, 12 Sep 2018 08:31:01 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbTcJ8pKl/nTaRTCxrdw/rRoGzy9GVCoWstDRd/YrINYo8aOP+8Q7Ny1Vn91AeDHjSTHtUJ X-Received: by 2002:a63:1644:: with SMTP id 4-v6mr2945494pgw.103.1536766261897; Wed, 12 Sep 2018 08:31:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536766261; cv=none; d=google.com; s=arc-20160816; b=HzCf2y1dIbCHIWQzgsK7a3ZjV3J3jhFnqcKRW4QWKlpwarW/K71awQBBe0GtotB9cJ DMuKPMVeeUHnV8rvGKkgiNPuVsYSpMcUMmpeZ58i/dUksIQMyIen9xHrhH6PgZLFykFS 2s6C9BnRUTD4ClqJgQ17dQ/OtghdRzd9esYi2pSDnY+zoBNea+XZpvzgDSMDOLJFRLBb YxvJKe73dbIC0Rju4LYksXOMnz5OHKW+VGvoQP+Tltez61sb/rYkgFfCcRB6jMkttJXi 1/BOugNnEzLwAoJrel4jnXaIbvCvWcIwfCndSMV1V4kQpNF70M2wjMf2PYuJCEqMFvjt k2YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to:date :cc:to:from:subject:message-id; bh=xKs7TrSMjUr+1TsxmBtsahlpWhDI3xRCWMn/ZaHnWjU=; b=iticzKqs1l/r3/M/010hIfFUp8FzdkIMKDn0GIZvzxCToCbrshXewTNnFxdS3uMmt0 yS4vBcwzAbXDZuISmZr/oSl1pTyyY9vbkXHUK2lyyT5c8r5tFts/IoC+lBwBVHaOLo92 aa+IivTnOk5XvFUDbhX5sMRGrfl8aUFawtILYoW3crP4OxsGQipCMrfatMyFdOYYyTbS NOXicYEXDr3y3JdLUnWtwwn5kaqDnSJ8J8iPsKSl+WZFzTG/b5Exepy33TP+revm2MQR 74ETkIo9xBnTha2u58lag9IgMlb5UQ0rrMY/VerLJww3M7LrlW3xX9BEPRbSQBpHcrC0 gr8A== ARC-Authentication-Results: i=1; mx.google.com; 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 u22-v6si1345868plk.443.2018.09.12.08.30.33; Wed, 12 Sep 2018 08:31:01 -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; 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 S1727577AbeILUfS (ORCPT + 99 others); Wed, 12 Sep 2018 16:35:18 -0400 Received: from shelob.surriel.com ([96.67.55.147]:50048 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726677AbeILUfS (ORCPT ); Wed, 12 Sep 2018 16:35:18 -0400 Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1g075p-0001QO-Vi; Wed, 12 Sep 2018 11:30:14 -0400 Message-ID: Subject: Re: [RFC PATCH 04/10] x86/fpu: eager switch PKRU state From: Rik van Riel To: Andy Lutomirski , Sebastian Andrzej Siewior Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Andy Lutomirski , Paolo Bonzini , Radim =?UTF-8?Q?Kr=C4=8Dm=C3=A1=C5=99?= , kvm@vger.kernel.org, "Jason A. Donenfeld" Date: Wed, 12 Sep 2018 11:30:10 -0400 In-Reply-To: <181B4EB8-9FEB-415C-8069-192FB8A5B418@amacapital.net> References: <20180912133353.20595-1-bigeasy@linutronix.de> <20180912133353.20595-5-bigeasy@linutronix.de> <181B4EB8-9FEB-415C-8069-192FB8A5B418@amacapital.net> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-9uLlLkQIutZ/7ofX5Ed9" X-Mailer: Evolution 3.28.5 (3.28.5-1.fc28) Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-9uLlLkQIutZ/7ofX5Ed9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2018-09-12 at 08:20 -0700, Andy Lutomirski wrote: > >=20 > > --- a/arch/x86/mm/pkeys.c > > +++ b/arch/x86/mm/pkeys.c > > @@ -18,6 +18,20 @@ > >=20 > > #include /* boot_cpu_has, > > ... */ > > #include /* > > vma_pkey() */ > > +#include > > + > > +void write_pkru(u32 pkru) > > +{ > > + if (!boot_cpu_has(X86_FEATURE_OSPKE)) > > + return; > > + > > + current->thread.fpu.pkru =3D pkru; > > + >=20 > I thought that the offset of PKRU in the xstate was fixed after boot. You are right, it is. However, that offset would need to be stored somewhere, and the value read every time we wanted to read or store the PKRU value from/to the floating point state. I suspect that would not be any faster than keeping a copy of the PKRU value in a known location. > Anyway, as written, this needs a lockdep assertion that we=E2=80=99re not > preemptible, an explicit preempt_disable(), or a comment explaining > why it=E2=80=99s okay if we get preempted in this function. >=20 > > + __fpregs_changes_begin(); This handles the preemption disabling, see patch 3 of the series. > > + __fpregs_load_activate(¤t->thread.fpu, > > smp_processor_id()); > > + __write_pkru(pkru); > > + __fpregs_changes_end(); > > +} > >=20 > > int __execute_only_pkey(struct mm_struct *mm) > > { > > --=20 > > 2.19.0 > >=20 >=20 >=20 --=20 All Rights Reversed. --=-9uLlLkQIutZ/7ofX5Ed9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEKR73pCCtJ5Xj3yADznnekoTE3oMFAluZMQIACgkQznnekoTE 3oMCngf+MQ5EGK03pITbeTj/SLYeCBLG2MaNDq5exs5NICa6GLbattuWAGfUI7Ez SmUdvWTWGnWCS9OUxm7wo0P1VWOjuaxE21maRQXai9SaMUzAF7iR3QeYCcBJP5L9 6IutHmElE4LPLvY7YT3wvv6Dq8uLEZ/fOns567fQsMGqiA8MISUxsN/mo4tHimsS M/GgjD+g3wX+Rft74lVwRW/0hRTWR97dkrnX1YPz5Oxp2jIha2TcAK0visaSlujy 3WF0EUgDJBpgU6iVraX4mc3xHu0/aCfCJKMtIC4ghj4q6SM+eGMKpX/asGLOleAN K8GdwbUz1LR+ShLMzu0olhqSUB/ciA== =rdjP -----END PGP SIGNATURE----- --=-9uLlLkQIutZ/7ofX5Ed9--