From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gerd Knorr Subject: [patch] shadow mode cleanup Date: Fri, 21 Oct 2005 16:10:47 +0200 Message-ID: <4358F6E7.5070302@suse.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090004070204070303080006" 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 List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------090004070204070303080006 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, Just a minor cleanup in the shadow mode setup code. PAE shadow mode now actually dies in a "not-implemented-yet" BUG() instead of trapping into a null pointer dereference before that ;) please apply, Gerd --------------090004070204070303080006 Content-Type: text/plain; name="fix" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fix" diff -r 7c951e3eb5ab xen/arch/x86/shadow.c --- a/xen/arch/x86/shadow.c Wed Oct 19 10:53:00 2005 +++ b/xen/arch/x86/shadow.c Fri Oct 21 16:06:59 2005 @@ -3259,7 +3259,7 @@ #elif CONFIG_PAGING_LEVELS == 3 struct shadow_ops MODE_B_HANDLER = { - .guest_paging_levels = 3, + .guest_paging_levels = 3, .invlpg = shadow_invlpg_32, .fault = shadow_fault_32, .update_pagetables = shadow_update_pagetables, @@ -3270,7 +3270,6 @@ .is_out_of_sync = is_out_of_sync, .gva_to_gpa = gva_to_gpa_pae, }; - #endif diff -r 7c951e3eb5ab xen/arch/x86/shadow_public.c --- a/xen/arch/x86/shadow_public.c Wed Oct 19 10:53:00 2005 +++ b/xen/arch/x86/shadow_public.c Fri Oct 21 16:06:59 2005 @@ -32,14 +32,19 @@ #if CONFIG_PAGING_LEVELS >= 3 #include - +#endif + +#if CONFIG_PAGING_LEVELS == 2 +extern struct shadow_ops MODE_A_HANDLER; +#endif +#if CONFIG_PAGING_LEVELS == 3 +extern struct shadow_ops MODE_B_HANDLER; #endif #if CONFIG_PAGING_LEVELS == 4 extern struct shadow_ops MODE_F_HANDLER; extern struct shadow_ops MODE_D_HANDLER; #endif -extern struct shadow_ops MODE_A_HANDLER; #define SHADOW_MAX_GUEST32(_encoded) ((L1_PAGETABLE_ENTRIES_32 - 1) - ((_encoded) >> 16)) /****************************************************************************/ @@ -49,31 +54,42 @@ int shadow_set_guest_paging_levels(struct domain *d, int levels) { + int result = 0; shadow_lock(d); switch(levels) { + case 4: #if CONFIG_PAGING_LEVELS >= 4 - case 4: - if ( d->arch.ops != &MODE_F_HANDLER ) + if ( d->arch.ops != &MODE_F_HANDLER ) { d->arch.ops = &MODE_F_HANDLER; - shadow_unlock(d); - return 1; -#endif + result = 1; + } +#endif + break; case 3: +#if CONFIG_PAGING_LEVELS == 3 + if ( d->arch.ops != &MODE_B_HANDLER ) { + d->arch.ops = &MODE_B_HANDLER; + result = 1; + } +#endif + break; case 2: #if CONFIG_PAGING_LEVELS == 2 - if ( d->arch.ops != &MODE_A_HANDLER ) + if ( d->arch.ops != &MODE_A_HANDLER ) { d->arch.ops = &MODE_A_HANDLER; + result = 1; + } #elif CONFIG_PAGING_LEVELS == 4 - if ( d->arch.ops != &MODE_D_HANDLER ) + if ( d->arch.ops != &MODE_D_HANDLER ) { d->arch.ops = &MODE_D_HANDLER; -#endif - shadow_unlock(d); - return 1; - default: - shadow_unlock(d); - return 0; - } + result = 1; + } +#endif + break; + } + shadow_unlock(d); + return result; } void shadow_invlpg(struct vcpu *v, unsigned long va) --------------090004070204070303080006 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 --------------090004070204070303080006--