From: "Jan Beulich" Subject: [PATCH 1/3] x86: tolerate running on EFI runtime services page tables in map_domain_page() Date: Thu, 23 Oct 2014 14:44:46 +0100 Message-ID: <5449226E020000780004176D@mail.emea.novell.com> References: <54492111020000780004175B@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part2D183D5E.0__=" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XhIh5-0007nU-0k for xen-devel@lists.xenproject.org; Thu, 23 Oct 2014 13:44:47 +0000 In-Reply-To: <54492111020000780004175B@mail.emea.novell.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: xen-devel Cc: Keir Fraser 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. --=__Part2D183D5E.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline In the event of a #PF while inan EFI runtime service function we otherwise can't dump the page tables, making the analysis of the problem more cumbersome. Signed-off-by: Jan Beulich --- a/xen/arch/x86/domain_page.c +++ b/xen/arch/x86/domain_page.c @@ -7,6 +7,7 @@ */ =20 #include +#include #include #include #include @@ -37,11 +38,14 @@ static inline struct vcpu *mapcache_curr */ if ( unlikely(pagetable_is_null(v->arch.guest_table)) && is_pv_vcpu(v)= ) { + unsigned long cr3; + /* If we really are idling, perform lazy context switch now. */ if ( (v =3D idle_vcpu[smp_processor_id()]) =3D=3D current ) sync_local_execstate(); /* We must now be running on the idle page table. */ - ASSERT(read_cr3() =3D=3D __pa(idle_pg_table)); + ASSERT((cr3 =3D read_cr3()) =3D=3D __pa(idle_pg_table) || + (efi_enabled && cr3 =3D=3D efi_rs_page_table())); } =20 return v; --- a/xen/arch/x86/efi/stub.c +++ b/xen/arch/x86/efi/stub.c @@ -9,6 +9,12 @@ const bool_t efi_enabled =3D 0; =20 void __init efi_init_memory(void) { } =20 +paddr_t efi_rs_page_table(void) +{ + BUG(); + return 0; +} + unsigned long efi_get_time(void) { BUG(); --- a/xen/common/efi/runtime.c +++ b/xen/common/efi/runtime.c @@ -98,6 +98,11 @@ void efi_rs_leave(unsigned long cr3) stts(); } =20 +paddr_t efi_rs_page_table(void) +{ + return virt_to_maddr(efi_l4_pgtable); +} + unsigned long efi_get_time(void) { EFI_TIME time; --- a/xen/include/xen/efi.h +++ b/xen/include/xen/efi.h @@ -28,6 +28,7 @@ struct xenpf_efi_runtime_call; struct compat_pf_efi_runtime_call; =20 void efi_init_memory(void); +paddr_t efi_rs_page_table(void); unsigned long efi_get_time(void); void efi_halt_system(void); void efi_reset_system(bool_t warm); --=__Part2D183D5E.0__= Content-Type: text/plain; name="x86-mdp-tolerate-EFI.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-mdp-tolerate-EFI.patch" x86: tolerate running on EFI runtime services page tables in map_domain_pag= e()=0A=0AIn the event of a #PF while inan EFI runtime service function = we=0Aotherwise can't dump the page tables, making the analysis of = the=0Aproblem more cumbersome.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/arch/x86/domain_page.c=0A+++ b/xen/arch/x86/domain_p= age.c=0A@@ -7,6 +7,7 @@=0A */=0A =0A #include =0A+#incl= ude =0A #include =0A #include =0A = #include =0A@@ -37,11 +38,14 @@ static inline struct vcpu = *mapcache_curr=0A */=0A if ( unlikely(pagetable_is_null(v->arch.gu= est_table)) && is_pv_vcpu(v) )=0A {=0A+ unsigned long = cr3;=0A+=0A /* If we really are idling, perform lazy context = switch now. */=0A if ( (v =3D idle_vcpu[smp_processor_id()]) = =3D=3D current )=0A sync_local_execstate();=0A /* We = must now be running on the idle page table. */=0A- ASSERT(read_cr3()= =3D=3D __pa(idle_pg_table));=0A+ ASSERT((cr3 =3D read_cr3()) = =3D=3D __pa(idle_pg_table) ||=0A+ (efi_enabled && cr3 =3D=3D = efi_rs_page_table()));=0A }=0A =0A return v;=0A--- a/xen/arch/x86/e= fi/stub.c=0A+++ b/xen/arch/x86/efi/stub.c=0A@@ -9,6 +9,12 @@ const bool_t = efi_enabled =3D 0;=0A =0A void __init efi_init_memory(void) { }=0A = =0A+paddr_t efi_rs_page_table(void)=0A+{=0A+ BUG();=0A+ return = 0;=0A+}=0A+=0A unsigned long efi_get_time(void)=0A {=0A BUG();=0A--- = a/xen/common/efi/runtime.c=0A+++ b/xen/common/efi/runtime.c=0A@@ -98,6 = +98,11 @@ void efi_rs_leave(unsigned long cr3)=0A stts();=0A }=0A = =0A+paddr_t efi_rs_page_table(void)=0A+{=0A+ return virt_to_maddr(efi_l4= _pgtable);=0A+}=0A+=0A unsigned long efi_get_time(void)=0A {=0A = EFI_TIME time;=0A--- a/xen/include/xen/efi.h=0A+++ b/xen/include/xen/efi.h= =0A@@ -28,6 +28,7 @@ struct xenpf_efi_runtime_call;=0A struct compat_pf_efi= _runtime_call;=0A =0A void efi_init_memory(void);=0A+paddr_t efi_rs_page_ta= ble(void);=0A unsigned long efi_get_time(void);=0A void efi_halt_system(voi= d);=0A void efi_reset_system(bool_t warm);=0A --=__Part2D183D5E.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.xen.org http://lists.xen.org/xen-devel --=__Part2D183D5E.0__=--