> > > +/* > > > + * Get the number of page-tables needed to replace a block with a > > > + * fully populated tree, up to the PTE level, at particular level. > > > + */ > > > +static inline int stage2_block_get_nr_page_tables(u32 level) > > > +{ > > > + if (WARN_ON_ONCE(level < KVM_PGTABLE_MIN_BLOCK_LEVEL || > > > + level >= KVM_PGTABLE_MAX_LEVELS)) > > > + return -EINVAL; > > > + > > > + switch (level) { > > > + case 1: > > > + return PTRS_PER_PTE + 1; > > > + case 2: > > > + return 1; > > > + case 3: > > > + return 0; > > > + default: > > > + return -EINVAL; > > > + }; > > > +} > > > > Shaoqin, > > > > "Is the level 3 check really needed?" > > > > Regarding your question about the need for "case 3". You are right, > > it's not actually needed in this particular case (when called from > > stage2_split_walker()). However, it would be nice to reuse this > > function and so it should cover all functions. > > > > Thanks, > > Ricardo > > > > Hi Ricardo, > > Thanks for your explanation. And I'm wondering since > stage2_block_get_nr_page_tables() is aimed to get how many pages needed to > populate a new pgtable and replace the block mapping, and level 3 is the > PTE, it can't be split. So is it still ok to put level 3 in this function, > although put it here has no effect. > > Shaoqin Hi, The "level 3" check is not used by kvm_pgtable_stage2_split(), but stage2_block_get_nr_page_tables(level=3) is not an invalid (EINVAL) call either. Sorry for the late reply. Thanks, Ricardo