Re: [PATCH v3 28/34] s390/mm: Define KMSAN metadata for vmalloc and modules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 04, 2024 at 11:03:42AM +0100, Alexander Gordeev wrote:
> On Tue, Jan 02, 2024 at 04:05:31PM +0100, Heiko Carstens wrote:
> Hi Heiko,
> ...
> > > @@ -253,9 +253,17 @@ static unsigned long setup_kernel_memory_layout(void)
> > >  	MODULES_END = round_down(__abs_lowcore, _SEGMENT_SIZE);
> > >  	MODULES_VADDR = MODULES_END - MODULES_LEN;
> > >  	VMALLOC_END = MODULES_VADDR;
> > > +#ifdef CONFIG_KMSAN
> > > +	VMALLOC_END -= MODULES_LEN * 2;
> > > +#endif
> > >  
> > >  	/* allow vmalloc area to occupy up to about 1/2 of the rest virtual space left */
> > >  	vmalloc_size = min(vmalloc_size, round_down(VMALLOC_END / 2, _REGION3_SIZE));
> > > +#ifdef CONFIG_KMSAN
> > > +	/* take 2/3 of vmalloc area for KMSAN shadow and origins */
> > > +	vmalloc_size = round_down(vmalloc_size / 3, _REGION3_SIZE);
> > > +	VMALLOC_END -= vmalloc_size * 2;
> > > +#endif
> > 
> > Please use
> > 
> > 	if (IS_ENABLED(CONFIG_KMSAN))
> > 
> > above, since this way we get more compile time checks.
> 
> This way we will get a mixture of CONFIG_KASAN and CONFIG_KMSAN
> #ifdef vs IS_ENABLED() checks within one function. I guess, we
> would rather address it with a separate cleanup?

I don't think so, since you can't convert the CONFIG_KASAN ifdef to
IS_ENABLED() here: it won't compile.

But IS_ENABLED(CONFIG_KMSAN) should work. I highly prefer IS_ENABLED() over
ifdef since it allows for better compile time checks, and you won't be
surprised by code that doesn't compile if you just change a config option.
We've seen that way too often.




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux