From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v1 3/6] x86: Enable Supervisor Mode Execution Prevention (SMAP) for Xen Date: Tue, 15 Apr 2014 15:09:42 +0100 Message-ID: <534D3DA6.3070908@citrix.com> References: <1397566907-19710-1-git-send-email-feng.wu@intel.com> <534D3B87.7030109@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <534D3B87.7030109@citrix.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: Feng Wu Cc: JBeulich@suse.com, eddie.dong@intel.com, Ian.Campbell@citrix.com, jun.nakajima@intel.com, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On 15/04/14 15:00, Andrew Cooper wrote: > On 15/04/14 14:01, Feng Wu wrote: >> @@ -1379,8 +1396,8 @@ void do_page_fault(struct cpu_user_regs *regs) >> >> if ( unlikely(!guest_mode(regs)) ) >> { >> - pf_type = spurious_page_fault(addr, error_code); >> - BUG_ON(pf_type == smep_fault); >> + pf_type = spurious_page_fault(addr, regs); >> + BUG_ON((pf_type == smep_fault) || (pf_type == smap_fault)); > On further consideration, given the nature of faults like these, this > code would be better as: > > if ( (pf_type == smep_fault) || (pf_type == smap_fault) ) > { > console_start_sync(); > printk("Xen SM%cP violation", pf_type == smep_fault ? 'E' : 'A'); > fatal_trap(TRAP_page_fault, regs); > } > > This would make the resulting crash crystal clear as to what went wrong, > and forgo the first step of having to look up which BUG() tripped. > > ~Andrew And having just sent this email, I further realise that functions like show_page_walk() need protection against SMAP otherwise we will take a recursive fault when trying to dump the error information from the first fault. I don't recall any of your other patches dealing with this. All this error printing can probably better be colated together after the exception table search. ~Andrew