On Thu, Oct 20, 2016 at 04:24:08PM +0800, Peter Xu wrote: > On Thu, Oct 20, 2016 at 10:17:07AM +0200, Andrew Jones wrote: > > On Fri, Oct 14, 2016 at 08:40:39PM +0800, Peter Xu wrote: > > > Signed-off-by: Peter Xu <peterx@xxxxxxxxxx> > > > --- > > > lib/x86/vm.c | 7 +++++++ > > > 1 file changed, 7 insertions(+) > > > > > > diff --git a/lib/x86/vm.c b/lib/x86/vm.c > > > index 906fbf2..9771bd7 100644 > > > --- a/lib/x86/vm.c > > > +++ b/lib/x86/vm.c > > > @@ -151,9 +151,16 @@ static void setup_mmu(unsigned long len) > > > > > > void setup_vm() > > > { > > > + static bool vm_inited = false; > > > + > > > + if (vm_inited) { > > > + return; > > > + } > > > + > > > end_of_memory = fwcfg_get_u64(FW_CFG_RAM_SIZE); > > > free_memory(&edata, end_of_memory - (unsigned long)&edata); > > > setup_mmu(end_of_memory); > > > + vm_inited = true; > > > } > > > > > > void *vmalloc(unsigned long size) > > > -- > > > 2.7.4 > > > > > > > My preference for kvm-unit-tests is that we avoid tolerating > > unit tests that do things "wrong". This patch allows setup_vm > > to be called multiple times, but why do that? Why not just > > ensure it's only called once? If it looks like a mistake that's > > easy to make and hard to debug, then maybe we need an assert > > > > assert(!end_of_memory); /* ensure we haven't already called setup_vm */ > > > > or something. > > Yeah, sure. The first two patches are just something good to have IMO, > I did it since I see we have similar thing in setup_idt(), and I feel > it good. I can replace it with an assertion. Let's do these patches separate from the series and maybe change setup_idt too? It'd be interesting to see if the assert in setup_idt would fire, i.e. if any users are relying on it being tolerant to multiple calls, and then find out why. drew -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html