/* Follow this shadow's up-pointer, if it has one, and remove the reference
* found there. Returns 1 if that was the only reference to this shadow */
{
+ struct domain *d = v->domain;
struct page_info *sp = mfn_to_page(smfn);
mfn_t pmfn;
void *vaddr;
ASSERT(sp->u.sh.type > 0);
ASSERT(sp->u.sh.type < SH_type_max_shadow);
- ASSERT(sh_type_has_up_pointer(v, sp->u.sh.type));
+ ASSERT(sh_type_has_up_pointer(d, sp->u.sh.type));
if (sp->up == 0) return 0;
pmfn = _mfn(sp->up >> PAGE_SHIFT);
mfn_x(gmfn), (uint32_t)pg->shadow_flags, t); \
break; \
} \
- if ( sh_type_is_pinnable(v, t) ) \
+ if ( sh_type_is_pinnable(d, t) ) \
sh_unpin(v, smfn); \
- else if ( sh_type_has_up_pointer(v, t) ) \
+ else if ( sh_type_has_up_pointer(d, t) ) \
sh_remove_shadow_via_pointer(v, smfn); \
if( !fast \
&& (pg->count_info & PGC_page_table) \
mfn_t sl3mfn = shadow_l4e_get_mfn(new_sl4e);
ok = sh_get_ref(v, sl3mfn, paddr);
/* Are we pinning l3 shadows to handle wierd linux behaviour? */
- if ( sh_type_is_pinnable(v, SH_type_l3_64_shadow) )
+ if ( sh_type_is_pinnable(d, SH_type_l3_64_shadow) )
ok |= sh_pin(v, sl3mfn);
if ( !ok )
{
SHADOW_DEBUG(MAKE_SHADOW, "(%05lx, %u)=>%05lx\n",
mfn_x(gmfn), shadow_type, mfn_x(smfn));
- if ( sh_type_has_up_pointer(v, shadow_type) )
+ if ( sh_type_has_up_pointer(d, shadow_type) )
/* Lower-level shadow, not yet linked form a higher level */
mfn_to_page(smfn)->up = 0;
struct page_info *sp;
mfn_t smfn;
- if ( !sh_type_has_up_pointer(v, SH_type_l1_shadow) )
+ if ( !sh_type_has_up_pointer(d, SH_type_l1_shadow) )
return 0;
smfn = get_shadow_status(d, gl1mfn, SH_type_l1_shadow);
#if (SHADOW_PAGING_LEVELS == 4)
/* up to l3 */
sp = mfn_to_page(smfn);
- ASSERT(sh_type_has_up_pointer(v, SH_type_l2_shadow));
+ ASSERT(sh_type_has_up_pointer(d, SH_type_l2_shadow));
if ( sp->u.sh.count != 1 || !sp->up )
return 0;
smfn = _mfn(sp->up >> PAGE_SHIFT);
/* up to l4 */
sp = mfn_to_page(smfn);
if ( sp->u.sh.count != 1
- || !sh_type_has_up_pointer(v, SH_type_l3_64_shadow) || !sp->up )
+ || !sh_type_has_up_pointer(d, SH_type_l3_64_shadow) || !sp->up )
return 0;
smfn = _mfn(sp->up >> PAGE_SHIFT);
ASSERT(mfn_valid(smfn));
* What counts as a pinnable shadow?
*/
-static inline int sh_type_is_pinnable(struct vcpu *v, unsigned int t)
+static inline int sh_type_is_pinnable(struct domain *d, unsigned int t)
{
/* Top-level shadow types in each mode can be pinned, so that they
* persist even when not currently in use in a guest CR3 */
* page. When we're shadowing those kernels, we have to pin l3
* shadows so they don't just evaporate on every context switch.
* For all other guests, we'd rather use the up-pointer field in l3s. */
- if ( unlikely((v->domain->arch.paging.shadow.opt_flags & SHOPT_LINUX_L3_TOPLEVEL)
+ if ( unlikely((d->arch.paging.shadow.opt_flags & SHOPT_LINUX_L3_TOPLEVEL)
&& t == SH_type_l3_64_shadow) )
return 1;
#endif
return 0;
}
-static inline int sh_type_has_up_pointer(struct vcpu *v, unsigned int t)
+static inline int sh_type_has_up_pointer(struct domain *d, unsigned int t)
{
/* Multi-page shadows don't have up-pointers */
if ( t == SH_type_l1_32_shadow
|| t == SH_type_l2_32_shadow )
return 0;
/* Pinnable shadows don't have up-pointers either */
- return !sh_type_is_pinnable(v, t);
+ return !sh_type_is_pinnable(d, t);
}
static inline void sh_terminate_list(struct page_list_head *tmp_list)
* Returns 0 for failure, 1 for success. */
static inline int sh_get_ref(struct vcpu *v, mfn_t smfn, paddr_t entry_pa)
{
+ struct domain *d = v->domain;
u32 x, nx;
struct page_info *sp = mfn_to_page(smfn);
/* We remember the first shadow entry that points to each shadow. */
if ( entry_pa != 0
- && sh_type_has_up_pointer(v, sp->u.sh.type)
+ && sh_type_has_up_pointer(d, sp->u.sh.type)
&& sp->up == 0 )
sp->up = entry_pa;
* physical address of the shadow entry that held this reference. */
static inline void sh_put_ref(struct vcpu *v, mfn_t smfn, paddr_t entry_pa)
{
+ struct domain *d = v->domain;
u32 x, nx;
struct page_info *sp = mfn_to_page(smfn);
/* If this is the entry in the up-pointer, remove it */
if ( entry_pa != 0
- && sh_type_has_up_pointer(v, sp->u.sh.type)
+ && sh_type_has_up_pointer(d, sp->u.sh.type)
&& sp->up == entry_pa )
sp->up = 0;
sp[0] = mfn_to_page(smfn);
pages = shadow_size(sp[0]->u.sh.type);
already_pinned = sp[0]->u.sh.pinned;
- ASSERT(sh_type_is_pinnable(v, sp[0]->u.sh.type));
+ ASSERT(sh_type_is_pinnable(d, sp[0]->u.sh.type));
ASSERT(sp[0]->u.sh.head);
pin_list = &d->arch.paging.shadow.pinned_shadows;
ASSERT(mfn_valid(smfn));
sp = mfn_to_page(smfn);
head_type = sp->u.sh.type;
- ASSERT(sh_type_is_pinnable(v, sp->u.sh.type));
+ ASSERT(sh_type_is_pinnable(d, sp->u.sh.type));
ASSERT(sp->u.sh.head);
if ( !sp->u.sh.pinned )