From: "Jan Beulich" Subject: Re: [PATCH] x86: adjust reserved bit page fault handling Date: Fri, 01 Feb 2008 10:38:29 +0000 Message-ID: <47A304B5.76E4.0078.0@novell.com> References: <47A2EA32.76E4.0078.0@novell.com> <20080201092815.GA19416@york.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20080201092815.GA19416@york.uk.xensource.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Tim Deegan Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org >>> Tim Deegan 01.02.08 10:28 >>> >At 08:45 +0000 on 01 Feb (1201855522), Jan Beulich wrote: >> @@ -1034,8 +1047,10 @@ static int fixup_page_fault(unsigned lon >> struct vcpu *v =3D current; >> struct domain *d =3D v->domain; >> =20 >> - /* No fixups in interrupt context or when interrupts are disabled. = */ >> - if ( in_irq() || !(regs->eflags & X86_EFLAGS_IF) ) >> + /* No fixups in interrupt context, when interrupts are disabled, = or >> + * when a reserved bit was found to be set. */ >> + if ( in_irq() || !(regs->eflags & X86_EFLAGS_IF) || >> + (regs->error_code & PFEC_reserved_bit) ) >> return 0; >> =20 >> if ( unlikely(IN_HYPERVISOR_RANGE(addr)) ) > >The shadow pagetable code deliberately introduces invalid pagetable >entries as part of its fast-path treatment of MMIO and not-present >entries in the guest tables, so paging_fault needs to be called for >PFEC_reserved_bit faults. Here's a replacement patch then, it would still be questionable whether reserved bit faults should ever be propagated to a guest... Signed-off-by: Jan Beulich Index: 2008-01-28/xen/arch/x86/traps.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-01-28.orig/xen/arch/x86/traps.c 2008-01-28 11:31:44.0000000= 00 +0100 +++ 2008-01-28/xen/arch/x86/traps.c 2008-02-01 11:25:49.000000000 = +0100 @@ -823,6 +823,18 @@ asmlinkage void do_machine_check(struct=20 machine_check_vector(regs, regs->error_code); } =20 +static inline void reserved_bit_page_fault(int guest, unsigned long addr, + struct cpu_user_regs *regs) +{ + if ( guest ) + gdprintk(XENLOG_ERR, ""); + else + dprintk(XENLOG_ERR, ""); + printk("reserved bit in page table (ec=3D%04X): ", regs->error_code); + show_page_walk(addr); + show_execution_state(regs); +} + void propagate_page_fault(unsigned long addr, u16 error_code) { struct trap_info *ti; @@ -852,6 +864,8 @@ void propagate_page_fault(unsigned long=20 v->domain->domain_id, v->vcpu_id, error_code); show_page_walk(addr); } + else if ( unlikely(error_code & PFEC_reserved_bit) ) + reserved_bit_page_fault(1, addr, guest_cpu_user_regs()); } =20 static int handle_gdt_ldt_mapping_fault( @@ -1047,7 +1061,8 @@ static int fixup_page_fault(unsigned lon trace_trap_two_addr(TRC_PV_PAGING_FIXUP, regs->eip, = addr); return ret; } - if ( (addr >=3D GDT_LDT_VIRT_START) && (addr < GDT_LDT_VIRT_END) = ) + if ( !(regs->error_code & PFEC_reserved_bit) && + (addr >=3D GDT_LDT_VIRT_START) && (addr < GDT_LDT_VIRT_END) = ) return handle_gdt_ldt_mapping_fault( addr - GDT_LDT_VIRT_START, regs); return 0; @@ -1057,7 +1072,8 @@ static int fixup_page_fault(unsigned lon 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) =3D=3D PFEC_write_access)= && + ((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; =20 @@ -1101,6 +1117,8 @@ asmlinkage void do_page_fault(struct cpu if ( likely((fixup =3D search_exception_table(regs->eip)) !=3D 0) = ) { perfc_incr(copy_user_faults); + if ( unlikely(regs->error_code & PFEC_reserved_bit) ) + reserved_bit_page_fault(0, addr, regs); regs->eip =3D fixup; return; }