confusion about monitor table in shadow mode
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi,Tim
I have confusion when understanding monitor table in shadow
mode. In arch/x86/mm/shadow/mutli.c, the definition of sh_make_monitor_table is following:
#if SHADOW_PAGING_LEVELS == GUEST_PAGING_LEVELS
mfn_t
sh_make_monitor_table(struct vcpu *v)
{
.......
}
The macro SHADOW_PAGING_LEVELS is defined in arch/x86/mm/shadow/types.h:
#if GUEST_PAGING_LEVELS == 4
#define SHADOW_PAGING_LEVELS 4
#else
#define SHADOW_PAGING_LEVELS 3
#endifIf a 32-bit hvm is created, its GUEST_PAGING_LEVELS should be 2. In this case, SHADOW_PAGING_LEVELS will be 3 and sh_make_monitor_table will not be compiled. Is it correct? But, when a hvm domain is initialized, Xen will call sh_update_paging_modes to create a monitor table for it:
In sh_update_paging_modes:
#ifdef __x86_64__
if ( hvm_long_mode_enabled(v) )
{
// long mode guest...
v->arch.paging.mode =
&SHADOW_INTERNAL_NAME(sh_paging_mode, 4);
}
else
#endif
if ( hvm_pae_enabled(v) )
{
// 32-bit PAE mode guest...
v->arch.paging.mode =
&SHADOW_INTERNAL_NAME(sh_paging_mode, 3);
}
else
{
// 32-bit 2 level guest...
v->arch.paging.mode =
&SHADOW_INTERNAL_NAME(sh_paging_mode, 2);
}
}
if ( pagetable_is_null(v->arch.monitor_table) )
{
mfn_t mmfn =
v->arch.paging.mode->shadow.make_monitor_table(v);
v->arch.monitor_table = pagetable_from_mfn(mmfn);
make_cr3(v, mfn_x(mmfn));
hvm_update_host_cr3(v);
}This function will finally be called by hvm_domain_initialise. But sh_make_monitor_table is NULL-poinitor. What will happened in this case?
Need your help!
-Techie
Quoted 6 lines · Li Yaqiong
#if SHADOW_PAGING_LEVELS == GUEST_PAGING_LEVELS
mfn_t
sh_make_monitor_table(struct vcpu *v)
{
.......
}...
Quoted 3 lines
If a 32-bit hvm is created, its
GUEST_PAGING_LEVELSshould be 2. In this case,SHADOW_PAGING_LEVELSwill be 3 andsh_make_monitor_tablewill not be compiled.
Guests with GUEST_PAGING_LEVELS == 2 will us the three-level version, because their SHADOW_PAGING_LEVELS will be 3. See the comment in shadow/types.h where the renaming is defined:
/* sh_make_monitor_table depends only on the number of shadow levels */ #define sh_make_monitor_table \
SHADOW_INTERNAL_NAME(sh_make_monitor_table, SHADOW_PAGING_LEVELS)
#define sh_destroy_monitor_table \
SHADOW_INTERNAL_NAME(sh_destroy_monitor_table, SHADOW_PAGING_LEVELS)
Cheers,
Tim.
Signature · 3 lines
Tim Deegan <[email protected]> Principal Software Engineer, Citrix Systems (R&D) Ltd. [Company #02300071, SL9 0DZ, UK.]