From: "Jan Beulich" Subject: [PATCH] x86: tighten filter on ptwr_do_page_fault() Date: Mon, 29 Nov 2010 11:22:32 +0000 Message-ID: <4CF39B080200007800024A34@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartB39E01E8.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartB39E01E8.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Even not-so-recent Linux may, due to post-2.6.18 changes to the process creation code, cause quite a number (depending on environment and argument size) of faulting accesses to user space originating from kernel mode. Generally those happen for non-present pages and would lead to a nested page fault from guest_get_eff_l1e(). They can be avoided by checking for PFEC_page_present as long as the guest isn't running on shadow page tables. Signed-off-by: Jan Beulich --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1244,13 +1244,19 @@ static int fixup_page_fault(unsigned lon } =20 if ( VM_ASSIST(d, VMASST_TYPE_writable_pagetables) && - guest_kernel_mode(v, regs) && - /* Do not check if access-protection fault since the page may=20 - legitimately be not present in shadow page tables */ - ((regs->error_code & (PFEC_write_access|PFEC_reserved_bit)) = =3D=3D - PFEC_write_access) && - ptwr_do_page_fault(v, addr, regs) ) - return EXCRET_fault_fixed; + guest_kernel_mode(v, regs) ) + { + unsigned int mbs =3D PFEC_write_access; + + /* Do not check if access-protection fault since the page may=20 + legitimately be not present in shadow page tables */ + if ( !paging_mode_enabled(d) ) + mbs |=3D PFEC_page_present; + if ( (regs->error_code & (mbs | PFEC_reserved_bit | + PFEC_insn_fetch)) =3D=3D mbs && + ptwr_do_page_fault(v, addr, regs) ) + return EXCRET_fault_fixed; + } =20 /* For non-external shadowed guests, we fix up both their own=20 * pagefaults and Xen's, since they share the pagetables. */ --=__PartB39E01E8.0__= Content-Type: text/plain; name="x86-ptwr-fault-filter.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-ptwr-fault-filter.patch" Even not-so-recent Linux may, due to post-2.6.18 changes to the=0Aprocess = creation code, cause quite a number (depending on environment=0Aand = argument size) of faulting accesses to user space originating from=0Akernel= mode. Generally those happen for non-present pages and would=0Alead to a = nested page fault from guest_get_eff_l1e(). They can be=0Aavoided by = checking for PFEC_page_present as long as the guest isn't=0Arunning on = shadow page tables.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/arch/x86/traps.c=0A+++ b/xen/arch/x86/traps.c=0A@@ = -1244,13 +1244,19 @@ static int fixup_page_fault(unsigned lon=0A }=0A = =0A if ( VM_ASSIST(d, VMASST_TYPE_writable_pagetables) &&=0A- = guest_kernel_mode(v, regs) &&=0A- /* Do not check if access-protect= ion fault since the page may =0A- legitimately be not present = in shadow page tables */=0A- ((regs->error_code & (PFEC_write_acces= s|PFEC_reserved_bit)) =3D=3D=0A- PFEC_write_access) &&=0A- = ptwr_do_page_fault(v, addr, regs) )=0A- return EXCRET_fault_fixed;= =0A+ guest_kernel_mode(v, regs) )=0A+ {=0A+ unsigned int = mbs =3D PFEC_write_access;=0A+=0A+ /* Do not check if access-protect= ion fault since the page may =0A+ legitimately be not present in = shadow page tables */=0A+ if ( !paging_mode_enabled(d) )=0A+ = mbs |=3D PFEC_page_present;=0A+ if ( (regs->error_code & (mbs | = PFEC_reserved_bit |=0A+ PFEC_insn_fetch)) = =3D=3D mbs &&=0A+ ptwr_do_page_fault(v, addr, regs) )=0A+ = return EXCRET_fault_fixed;=0A+ }=0A =0A /* For non-external = shadowed guests, we fix up both their own =0A * pagefaults and Xen's, = since they share the pagetables. */=0A --=__PartB39E01E8.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartB39E01E8.0__=--