xen/x86: add some cr3 helpers

Add some helper macros to access the address and pcid parts of cr3.

Use those helpers where appropriate.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Juergen Gross authored and Wei Liu committed 2018-05-04 15:55:07 +01:00
1 parent a5407c1d8c
commit 1a32c98687
4 files changed
+15 -3

No files matched your search

+1 -1
View File
@@ -98,7 +98,7 @@ dbg_pv_va2mfn(dbgva_t vaddr, struct domain *dp, uint64_t pgd3val)
l2_pgentry_t l2e, *l2t;
l1_pgentry_t l1e, *l1t;
unsigned long cr3 = (pgd3val ? pgd3val : dp->vcpu[0]->arch.cr3);
mfn_t mfn = maddr_to_mfn(cr3);
mfn_t mfn = maddr_to_mfn(cr3_pa(cr3));
DBGP2("vaddr:%lx domid:%d cr3:%lx pgd3:%lx\n", vaddr, dp->domain_id,
cr3, pgd3val);
+1 -1
View File
@@ -51,7 +51,7 @@ static inline struct vcpu *mapcache_current_vcpu(void)
if ( (v = idle_vcpu[smp_processor_id()]) == current )
sync_local_execstate();
/* We must now be running on the idle page table. */
ASSERT(read_cr3() == __pa(idle_pg_table));
ASSERT(cr3_pa(read_cr3()) == __pa(idle_pg_table));
}
return v;
+10
View File
@@ -288,6 +288,16 @@ static inline void write_cr3(unsigned long val)
asm volatile ( "mov %0, %%cr3" : : "r" (val) : "memory" );
}
static inline unsigned long cr3_pa(unsigned long cr3)
{
return cr3 & X86_CR3_ADDR_MASK;
}
static inline unsigned long cr3_pcid(unsigned long cr3)
{
return cr3 & X86_CR3_PCID_MASK;
}
static inline unsigned long read_cr4(void)
{
return get_cpu_info()->cr4;
+3 -1
View File
@@ -45,7 +45,9 @@
/*
* Intel CPU flags in CR3
*/
#define X86_CR3_NOFLUSH (_AC(1, ULL) << 63)
#define X86_CR3_NOFLUSH (_AC(1, ULL) << 63)
#define X86_CR3_ADDR_MASK (PAGE_MASK & PADDR_MASK)
#define X86_CR3_PCID_MASK _AC(0x0fff, ULL) /* Mask for PCID */
/*
* Intel CPU features in CR4
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.