> From: Gavin Shan <gs...@redhat.com>
> Sent: Thursday, October 12, 2023 1:18 AM
> To: Salil Mehta <salil.me...@opnsrc.net>; Salil Mehta
> <salil.me...@huawei.com>; qemu-devel@nongnu.org; qemu-...@nongnu.org
> Cc: m...@kernel.org; jean-phili...@linaro.org; Jonathan Cameron
> <jonathan.came...@huawei.com>; lpieral...@kernel.org;
> peter.mayd...@linaro.org; richard.hender...@linaro.org;
> imamm...@redhat.com; andrew.jo...@linux.dev; da...@redhat.com;
> phi...@linaro.org; eric.au...@redhat.com; oliver.up...@linux.dev;
> pbonz...@redhat.com; m...@redhat.com; w...@kernel.org; raf...@kernel.org;
> alex.ben...@linaro.org; li...@armlinux.org.uk;
> dar...@os.amperecomputing.com; il...@os.amperecomputing.com;
> vis...@os.amperecomputing.com; karl.heub...@oracle.com;
> miguel.l...@oracle.com; zhukeqian <zhukeqi...@huawei.com>; wangxiongfeng
> (C) <wangxiongfe...@huawei.com>; wangyanan (Y) <wangyana...@huawei.com>;
> jiakern...@gmail.com; maob...@loongson.cn; lixiang...@loongson.cn; Linuxarm
> <linux...@huawei.com>
> Subject: Re: [PATCH V5 8/9] physmem: Add helper function to destroy CPU
> AddressSpace
> 
> Hi Salil,
> 
> On 10/12/23 10:04, Salil Mehta wrote:
> > On 12/10/2023 00:31, Gavin Shan wrote:
> >> On 10/12/23 05:43, Salil Mehta wrote:
> 
> [...]
> 
> >>> +void cpu_address_space_destroy(CPUState *cpu, int asidx)
> >>> +{
> >>> +    CPUAddressSpace *cpuas;
> >>> +
> >>> +    assert(asidx < cpu->num_ases);
> >>> +    assert(asidx == 0 || !kvm_enabled());
> >>> +    assert(cpu->cpu_ases);
> >>> +
> >>
> >> The two asserts on @asidx and @cpu->cpu_ases can be combined
> >> to one so that these 3 asserts can be combined to two.
> >>
> >>         /* Only one address space is supported by KVM */
> >>         assert(asidx == 0 || !kvm_enabled());
> >>         assert(asidx >= 0 && asidx < cpu->cpu_ases_count)
> >
> > We can do that.
> >
> > I am not in favor to remove  'assert(cpu->cpu_ases);' as this can save
> lot of debugging.
> >
> 
> Ok, It's fine to keep 'assert(cpu->cpu_ases)', but 'assert(asidx >= 0)' is
> still needed? For example, the wrong chunk of memory will be release when
> @asidx is smaller than zero, which is out-of-bound to @cpu->cpu_ases[]

Yes, of course, we can keep that.

Thanks
Salil.

Reply via email to