[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86: Always have CR4.PKE set in HVM context


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 30 Apr 2021 11:21:00 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pJrh4Nr3g9Zk3M1SqFliLdzySo69DpNFN9meVThbPwI=; b=QstqMShRN/pIDYHIJiVI8NbpUYdf7YNsLyg6wtnbUksA7l0NiSIanS7994vYrdAkubqilgeNpEalSqebdB1+oqK5b/rG619x2DOJN9QPu1J9345yRKW9bWF/4CKeJ4agv2tw4uDW2U4PJ2pcjvM62sexo6gmK3W49jTXqOQ4bELix0niTpUBfXQwW4AranPtfpAgihH/ha0CoVntkA4Pn8Q4nWM3vB/WW9qycC3xY/zDVcRSaXdfm1qI4AdNsHXx+vBuuZY2vCX2EgvILtxyA1PtHhw+k5bZNxi9JPqGaBiTnLLDxtSDgSbPwpw4xvxnhmgzCADiZQwwA8JqmQ42vg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=krvqKJRvTnY5WOGPr5lMXkEVNhPanEdRgrUQdcv0qcHw5bI+aDRDvNWiwQN0BbHX7iU+OQdZ2wusDDti21Q1JUkGRSenerFBeC72Sa+3MoJi6Rug2fy3cgtP2Ivpt4DjXmX/jjIhRh+PZBh7ydUiAh5MB8B7WrxwqhyirObsKo+jmS5X3DsHGVRZA5OJnEBh/pX+XgDbx6abs4TW4UETSZRBKL6efD83jTDJ367GTdqgpO0i/QgugBnAgD7QVHC0LSe7py+AdkKwLKf12Pnvw1AAPtgQ0rb4zA2UnvZK34dW+NQ3rExS8iqDegSgSBiqqRcvGrHOuNyekGk9177Sdw==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 30 Apr 2021 10:21:30 +0000
  • Ironport-hdrordr: A9a23:46mWsqpwup6/zDXE9C36FqIaV5szL9V00zAX/kB9WHVpW+SFis brpugR0R/olTodMUtQ4eyoEq+GXH/a6NpJ+oEXJ7ivR03Lv2GvIYFk4+LZslndMgf58fNQ0r olTrhmBLTLfD1HpOvZwC39PNYk3dWdmZrDuc7y7VdICTtrZaZp8htjBm+gf3FeaQFaCfMCeK a0ydFAo1ObFkg/SuSeKj07U/PYp9vN/aiWAyIuIxI88gGBgXeJxdfBcySw5wwTWT9DzbAp/Q H+4nXEz56uuf261RPQvlW7h/9rseDs095SQPGL4/J6FhzXlg2qaI59Mofy3wwdnefH0jcXue iJmRs6IMR451TWYCWarRzgwAH83DtG0Q6Y9XaoxUHuutP4Tj4cDdQEv4REaRHUgnBQ2+1U4e Zw03mHt5BaKhXf2B7s/fTNXxFu0nW5umAjl+l7tQ04bbcj
  • Ironport-sdr: OAJuauWU7ilbsg2V85uK26ZONHtUW8gi5z7i+Zo4OeLNhfqofNffN1gOTdKaab5bUy7YTvXy/V rM1lhnE+KLQTGA2JBbdWixSmQ5kWbqHWL02JRgO7V/OU/HDb9/5A/ru6EbgDz4VMoLj5ODd/Uc iibLmLj5aiwMbMaf9ccMiXXn9t+PY43NLwGCYQLe4oQe+ODpnKI5YYDYQU8sJeFYYwBI9TAZXS ZQBCuct7A17FSxGhJLX/7fqdE3DO+MTwX8rSzF24uJZDqPPTNDhC2OQtPI9qpeQyc0cjLGTp43 i/Y=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 30/04/2021 10:08, Jan Beulich wrote:
> On 30.04.2021 00:12, Andrew Cooper wrote:
>> The sole user of read_pkru() is the emulated pagewalk, and guarded behind
>> guest_pku_enabled() which restricts the path to HVM (hap, even) context only.
>>
>> The commentary in read_pkru() concerning _PAGE_GNTTAB overlapping with
>> _PAGE_PKEY_BITS is only applicable to PV guests.
>>
>> The context switch path, via write_ptbase() unconditionally writes CR4 on any
>> context switch.
>>
>> Therefore, we can guarantee to separate CR4.PKE between PV and HVM context at
>> no extra cost.  Set PKE in mmu_cr4_features on boot, so it becomes set in HVM
>> context, and clear it in pv_make_cr4().
>>
>> Rename read_pkru() to rdpkru() now that it is a simple wrapper around the
>> instruction.  This saves two CR4 writes on every pagewalk, which typically
>> occur more than one per emulation.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> The changes looks perfectly fine to me, but I still feel urged to make
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
> conditional upon my "x86emul: support RDPKRU/WRPKRU" (submitted exactly
> half a year ago) going in first, unless there were to be review comments
> making extensive rework necessary. In the absence of such review
> feedback, I consider it pretty inappropriate for me to do rebasing work
> (no matter that this would be largely mechanical afaics) here for a
> patch which has been pending and effectively ignored for so long. (The
> main thing that immediately struck me as odd was "The sole user of
> read_pkru() is ...".)

So the observation about "sole user" occurred to me too, right after I
sent this.  Then I thought "surely Jan has spotted this and done a patch
for it".

Presumably you're talking about "x86emul: support RDPKRU/WRPKRU" from
Oct 30th ?  I found that via the archives, but I literally don't have a
copy in my inbox.


If I do the rebase, are you happy for this patch to stay as it is (so
the complicated change concerning context switching doesn't get more
complicated), and so we're not knowingly adding new constructs which
need immediate changes?

~Andrew




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.