[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86/mtrr: move is_var_mtrr_overlapped
commit d6876bf23ddd85e160d87da74fb01001ff0b6509 Author: Wei Liu <wei.liu2@xxxxxxxxxx> AuthorDate: Fri Aug 17 16:12:38 2018 +0100 Commit: Wei Liu <wei.liu2@xxxxxxxxxx> CommitDate: Tue Aug 21 15:13:34 2018 +0100 x86/mtrr: move is_var_mtrr_overlapped Move it to x86 generic code. While at it, use proper boolean type and fix some cosmetic issues. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> Acked-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/cpu/mtrr/generic.c | 32 ++++++++++++++++++++++++++++++++ xen/arch/x86/hvm/mtrr.c | 31 ------------------------------- xen/include/asm-x86/mtrr.h | 2 +- 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/xen/arch/x86/cpu/mtrr/generic.c b/xen/arch/x86/cpu/mtrr/generic.c index 09763654be..8f9cf1b1d7 100644 --- a/xen/arch/x86/cpu/mtrr/generic.c +++ b/xen/arch/x86/cpu/mtrr/generic.c @@ -51,6 +51,38 @@ get_fixed_ranges(mtrr_type * frs) } } +bool is_var_mtrr_overlapped(const struct mtrr_state *m) +{ + unsigned int seg, i; + unsigned int num_var_ranges = MASK_EXTR(m->mtrr_cap, MTRRcap_VCNT); + + for ( i = 0; i < num_var_ranges; i++ ) + { + uint64_t base1 = m->var_ranges[i].base >> PAGE_SHIFT; + uint64_t mask1 = m->var_ranges[i].mask >> PAGE_SHIFT; + + if ( !(m->var_ranges[i].mask & MTRR_PHYSMASK_VALID) ) + continue; + + for ( seg = i + 1; seg < num_var_ranges; seg++ ) + { + uint64_t base2 = m->var_ranges[seg].base >> PAGE_SHIFT; + uint64_t mask2 = m->var_ranges[seg].mask >> PAGE_SHIFT; + + if ( !(m->var_ranges[seg].mask & MTRR_PHYSMASK_VALID) ) + continue; + + if ( (base1 & mask1 & mask2) == (base2 & mask2 & mask1) ) + { + /* MTRRs overlap. */ + return true; + } + } + } + + return false; +} + void mtrr_save_fixed_ranges(void *info) { get_fixed_ranges(mtrr_state.fixed_ranges); diff --git a/xen/arch/x86/hvm/mtrr.c b/xen/arch/x86/hvm/mtrr.c index c502dda693..edfe5cd2b2 100644 --- a/xen/arch/x86/hvm/mtrr.c +++ b/xen/arch/x86/hvm/mtrr.c @@ -75,37 +75,6 @@ static uint8_t __read_mostly mtrr_epat_tbl[MTRR_NUM_TYPES][MEMORY_NUM_TYPES] = static uint8_t __read_mostly pat_entry_tbl[PAT_TYPE_NUMS] = { [0 ... PAT_TYPE_NUMS-1] = INVALID_MEM_TYPE }; -bool_t is_var_mtrr_overlapped(const struct mtrr_state *m) -{ - unsigned int seg, i; - unsigned int num_var_ranges = MASK_EXTR(m->mtrr_cap, MTRRcap_VCNT); - - for ( i = 0; i < num_var_ranges; i++ ) - { - uint64_t base1 = m->var_ranges[i].base >> PAGE_SHIFT; - uint64_t mask1 = m->var_ranges[i].mask >> PAGE_SHIFT; - - if ( !(m->var_ranges[i].mask & MTRR_PHYSMASK_VALID) ) - continue; - - for ( seg = i + 1; seg < num_var_ranges; seg ++ ) - { - uint64_t base2 = m->var_ranges[seg].base >> PAGE_SHIFT; - uint64_t mask2 = m->var_ranges[seg].mask >> PAGE_SHIFT; - - if ( !(m->var_ranges[seg].mask & MTRR_PHYSMASK_VALID) ) - continue; - - if ( (base1 & mask1 & mask2) == (base2 & mask2 & mask1) ) - { - /* MTRR is overlapped. */ - return 1; - } - } - } - return 0; -} - static int __init hvm_mtrr_pat_init(void) { unsigned int i, j; diff --git a/xen/include/asm-x86/mtrr.h b/xen/include/asm-x86/mtrr.h index 72d0690e28..7edcb94479 100644 --- a/xen/include/asm-x86/mtrr.h +++ b/xen/include/asm-x86/mtrr.h @@ -95,7 +95,7 @@ extern bool_t mtrr_def_type_msr_set(struct domain *, struct mtrr_state *, extern void memory_type_changed(struct domain *); extern bool_t pat_msr_set(uint64_t *pat, uint64_t msr); -bool_t is_var_mtrr_overlapped(const struct mtrr_state *m); +bool is_var_mtrr_overlapped(const struct mtrr_state *m); bool mtrr_pat_not_equal(const struct vcpu *vd, const struct vcpu *vs); #endif /* __ASM_X86_MTRR_H__ */ -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |