From: Tim Deegan Subject: Re: [PATCH V9 4/5] xen/mm: Clean up pfec handling in gva_to_gfn Date: Wed, 3 Feb 2016 15:57:10 +0000 Message-ID: <20160203155710.GA1682@deinos.phlegethon.org> References: <1454508725-22786-1-git-send-email-huaitong.han@intel.com> <1454508725-22786-5-git-send-email-huaitong.han@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1454508725-22786-5-git-send-email-huaitong.han@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Huaitong Han Cc: keir@xen.org, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, George Dunlap , xen-devel@lists.xen.org, jbeulich@suse.com List-Id: xen-devel@lists.xenproject.org At 22:12 +0800 on 03 Feb (1454537524), Huaitong Han wrote: > From: George Dunlap > > At the moment, the pfec argument to gva_to_gfn has two functions: > > * To inform guest_walk what kind of access is happenind > > * As a value to pass back into the guest in the event of a fault. > > Unfortunately this is not quite treated consistently: the hvm_fetch_* > function will "pre-clear" the PFEC_insn_fetch flag before calling > gva_to_gfn; meaning guest_walk doesn't actually know whether a given > access is an instruction fetch or not. This works now, but will cause > issues when pkeys are introduced, since guest_walk will need to know > whether an access is an instruction fetch even if it doesn't return > PFEC_insn_fetch. > > Fix this by making a clean separation for in and out functionalities > of the pfec argument: > > 1. Always pass in the access type to gva_to_gfn > > 2. Filter out inappropriate access flags before returning from gva_to_gfn. > > (The PFEC_insn_fetch flag should only be passed to the guest if either NX or > SMEP is enabled. See Intel 64 Developer's Manual, Volume 3, Chapter Paging, > PAGE-FAULT EXCEPTIONS) > > Signed-off-by: George Dunlap > Signed-off-by: Huaitong Han > Acked-by: Jan Beulich Acked-by: Tim Deegan