From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [PATCH 06/10] x86/hvm: pkeys, add functions to get pkeys value from PTE Date: Mon, 16 Nov 2015 07:42:06 -0700 Message-ID: <5649F94E02000078000B54AD@prv-mh.provo.novell.com> References: <1447669917-17939-1-git-send-email-huaitong.han@intel.com> <1447669917-17939-7-git-send-email-huaitong.han@intel.com> <5649E54E.1070302@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5649E54E.1070302@citrix.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper , ian.campbell@citrix.com, wei.liu2@citrix.com, george.dunlap@eu.citrix.com, ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com, eddie.dong@intel.com, Huaitong Han , jun.nakajima@intel.com, kevin.tian@intel.com, keir@xen.org Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 16.11.15 at 15:16, wrote: > On 16/11/15 10:31, Huaitong Han wrote: >> +#define _PAGE_PKEY_BIT0 19 /* Protection Keys, bit 1/4 */ >> +#define _PAGE_PKEY_BIT1 20 /* Protection Keys, bit 2/4 */ >> +#define _PAGE_PKEY_BIT2 21 /* Protection Keys, bit 3/4 */ >> +#define _PAGE_PKEY_BIT3 22 /* Protection Keys, bit 4/4 */ >> + >> +#define get_pte_pkeys(x) ((int)(get_pte_flags(x) >> _PAGE_PKEY_BIT0) & 0xF) > > Please implemented these as masks, for consistency with the other > _PAGE_* entries. I would recommend also having a _SHIFT and _MASK define. Since _SHIFT can always be calculated from _MASK, and since we have MASK_{INSR,EXTR}(), I'd prefer just _MASK ones to be added, unless this results in significantly less readable code. >> + >> /* Bit 23 of a 24-bit flag mask. This corresponds to bit 63 of a pte.*/ >> #define _PAGE_NX_BIT (1U<<23) >> > > There is however another issue. Xen currently uses bit 62 for software > purposes, which is incompatible with enabling PKE. _PAGE_GNTTAB needs > moving to a different, software-available bit. I would recommend bit 13 > of flags, adjacent to _PAGE_GUEST_KERNEL which is our other > software-used flag. Can we in fact do that? _PAGE_GNTTAB is visible to PV guests, and those guests need to avoid using that flag for their own purposes. Jan