Skip to contentSkip to conversation

confusion about monitor table in shadow mode

DISCUSSION Li Yaqiong 2 participants 2 messages Jan 15, 2009 1 message not in the archive

lore
Share & tools
lore

Li Yaqiong

author
#1 lore raw
In reply to a message not in the archive

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
	#endif

If 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

#2 lore raw
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_LEVELS should be 2. In this case, SHADOW_PAGING_LEVELS will be 3 and sh_make_monitor_table will 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.]