[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/shadow: call sh_detach_old_tables() directly
commit 661489874e87c0f6e21ac298b039aab9379f6ee0 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Thu Jan 12 11:14:50 2023 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Thu Jan 12 11:14:50 2023 +0100 x86/shadow: call sh_detach_old_tables() directly There's nothing really mode specific in this function anymore (the varying number of valid entries in v->arch.paging.shadow.shadow_table[] is dealt with fine by the zero check, and we have other similar cases of iterating through the full array in common.c), and hence there's neither a need to have multiple instances of it, nor does it need calling through a function pointer. While moving the function drop a non-conforming and not very useful (anymore) comment. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- xen/arch/x86/include/asm/paging.h | 1 - xen/arch/x86/mm/shadow/common.c | 25 ++++++++++++++++++++++--- xen/arch/x86/mm/shadow/multi.c | 25 ------------------------- xen/arch/x86/mm/shadow/types.h | 1 - 4 files changed, 22 insertions(+), 30 deletions(-) diff --git a/xen/arch/x86/include/asm/paging.h b/xen/arch/x86/include/asm/paging.h index b2b243a4ff..8c0b0ef29a 100644 --- a/xen/arch/x86/include/asm/paging.h +++ b/xen/arch/x86/include/asm/paging.h @@ -98,7 +98,6 @@ struct shadow_paging_mode { #ifdef CONFIG_SHADOW_PAGING - void (*detach_old_tables )(struct vcpu *v); #ifdef CONFIG_PV void (*write_guest_entry )(struct vcpu *v, intpte_t *p, intpte_t new, mfn_t gmfn); diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index 0c405ea5f3..8b4bea5f92 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -2302,6 +2302,25 @@ void shadow_prepare_page_type_change(struct domain *d, shadow_remove_all_shadows(d, page_to_mfn(page)); } +/* + * Removes v->arch.paging.shadow.shadow_table[]. + * Does all appropriate management/bookkeeping/refcounting/etc... + */ +static void sh_detach_old_tables(struct vcpu *v) +{ + struct domain *d = v->domain; + unsigned int i; + + for ( i = 0; i < ARRAY_SIZE(v->arch.paging.shadow.shadow_table); ++i ) + { + mfn_t smfn = pagetable_get_mfn(v->arch.paging.shadow.shadow_table[i]); + + if ( mfn_x(smfn) ) + sh_put_ref(d, smfn, 0); + v->arch.paging.shadow.shadow_table[i] = pagetable_null(); + } +} + /**************************************************************************/ /* Reset the up-pointers of every L3 shadow to 0. @@ -2373,7 +2392,7 @@ static void sh_update_paging_modes(struct vcpu *v) // First, tear down any old shadow tables held by this vcpu. // if ( v->arch.paging.mode ) - v->arch.paging.mode->shadow.detach_old_tables(v); + sh_detach_old_tables(v); #ifdef CONFIG_HVM if ( is_hvm_domain(d) ) @@ -2761,7 +2780,7 @@ void shadow_vcpu_teardown(struct vcpu *v) if ( !paging_mode_shadow(d) || !v->arch.paging.mode ) goto out; - v->arch.paging.mode->shadow.detach_old_tables(v); + sh_detach_old_tables(v); #ifdef CONFIG_HVM if ( shadow_mode_external(d) ) { @@ -2996,7 +3015,7 @@ static int shadow_one_bit_disable(struct domain *d, u32 mode) for_each_vcpu(d, v) { if ( v->arch.paging.mode ) - v->arch.paging.mode->shadow.detach_old_tables(v); + sh_detach_old_tables(v); if ( !(v->arch.flags & TF_kernel_mode) ) make_cr3(v, pagetable_get_mfn(v->arch.guest_table_user)); else diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c index e76c1cdb93..cd5a778d52 100644 --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -3200,30 +3200,6 @@ sh_update_linear_entries(struct vcpu *v) sh_flush_local(d); } - -/* - * Removes v->arch.paging.shadow.shadow_table[]. - * Does all appropriate management/bookkeeping/refcounting/etc... - */ -static void cf_check sh_detach_old_tables(struct vcpu *v) -{ - struct domain *d = v->domain; - mfn_t smfn; - unsigned int i; - - //// - //// vcpu->arch.paging.shadow.shadow_table[] - //// - - for_each_shadow_table(v, i) - { - smfn = pagetable_get_mfn(v->arch.paging.shadow.shadow_table[i]); - if ( mfn_x(smfn) ) - sh_put_ref(d, smfn, 0); - v->arch.paging.shadow.shadow_table[i] = pagetable_null(); - } -} - static void cf_check sh_update_cr3(struct vcpu *v, int do_locking, bool noflush) /* Updates vcpu->arch.cr3 after the guest has changed CR3. * Paravirtual guests should set v->arch.guest_table (and guest_table_user, @@ -4206,7 +4182,6 @@ const struct paging_mode sh_paging_mode = { .update_paging_modes = shadow_update_paging_modes, .flush_tlb = shadow_flush_tlb, .guest_levels = GUEST_PAGING_LEVELS, - .shadow.detach_old_tables = sh_detach_old_tables, #ifdef CONFIG_PV .shadow.write_guest_entry = sh_write_guest_entry, .shadow.cmpxchg_guest_entry = sh_cmpxchg_guest_entry, diff --git a/xen/arch/x86/mm/shadow/types.h b/xen/arch/x86/mm/shadow/types.h index 814a401853..fac59522b0 100644 --- a/xen/arch/x86/mm/shadow/types.h +++ b/xen/arch/x86/mm/shadow/types.h @@ -236,7 +236,6 @@ static inline shadow_l4e_t shadow_l4e_from_mfn(mfn_t mfn, u32 flags) #define sh_unhook_pae_mappings INTERNAL_NAME(sh_unhook_pae_mappings) #define sh_unhook_64b_mappings INTERNAL_NAME(sh_unhook_64b_mappings) #define sh_paging_mode INTERNAL_NAME(sh_paging_mode) -#define sh_detach_old_tables INTERNAL_NAME(sh_detach_old_tables) #define sh_audit_l1_table INTERNAL_NAME(sh_audit_l1_table) #define sh_audit_fl1_table INTERNAL_NAME(sh_audit_fl1_table) #define sh_audit_l2_table INTERNAL_NAME(sh_audit_l2_table) -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |