linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [tglx-devel:x86/l1dflush 7/9] arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces)
       [not found] <202104271144.G4fgnYlt-lkp@intel.com>
@ 2021-04-27  6:37 ` Thomas Gleixner
  2021-04-27 17:00   ` Linus Torvalds
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2021-04-27  6:37 UTC (permalink / raw)
  To: kernel test robot, Balbir Singh
  Cc: kbuild-all, linux-sparse, luc.vanoostenryck

On Tue, Apr 27 2021 at 11:00, kernel test robot wrote:

Cc+ sparse folks

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git x86/l1dflush
> head:   6955fbfdad4241331d1e33362306aec3a410803a
> commit: 193cb89595f7f3f4549b03ab9392fb9838d123e3 [7/9] x86/mm: Prepare for opt-in based L1D flush in switch_mm()
> config: i386-randconfig-s032-20210426 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
> reproduce:
>         # apt-get install sparse
>         # sparse version: v0.6.3-341-g8af24329-dirty
>         # https://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git/commit/?id=193cb89595f7f3f4549b03ab9392fb9838d123e3
>         git remote add tglx-devel https://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git
>         git fetch --no-tags tglx-devel x86/l1dflush
>         git checkout 193cb89595f7f3f4549b03ab9392fb9838d123e3
>         # save the attached .config to linux build tree
>         make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=i386 
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
>
> sparse warnings: (new ones prefixed by >>)
>>> arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got bool * @@
>    arch/x86/mm/tlb.c:354:13: sparse:     expected void const [noderef] __percpu *__vpp_verify
>    arch/x86/mm/tlb.c:354:13: sparse:     got bool *
>>> arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got bool * @@
>    arch/x86/mm/tlb.c:354:13: sparse:     expected void const [noderef] __percpu *__vpp_verify
>    arch/x86/mm/tlb.c:354:13: sparse:     got bool *
>>> arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got bool * @@
>    arch/x86/mm/tlb.c:354:13: sparse:     expected void const [noderef] __percpu *__vpp_verify
>    arch/x86/mm/tlb.c:354:13: sparse:     got bool *
>>> arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got bool * @@
>    arch/x86/mm/tlb.c:354:13: sparse:     expected void const [noderef] __percpu *__vpp_verify
>    arch/x86/mm/tlb.c:354:13: sparse:     got bool *
>>> arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got bool * @@
>    arch/x86/mm/tlb.c:354:13: sparse:     expected void const [noderef] __percpu *__vpp_verify
>    arch/x86/mm/tlb.c:354:13: sparse:     got bool *
>>> arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got bool * @@
>    arch/x86/mm/tlb.c:354:13: sparse:     expected void const [noderef] __percpu *__vpp_verify
>    arch/x86/mm/tlb.c:354:13: sparse:     got bool *
>>> arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got bool * @@
>    arch/x86/mm/tlb.c:354:13: sparse:     expected void const [noderef] __percpu *__vpp_verify
>    arch/x86/mm/tlb.c:354:13: sparse:     got bool *
>>> arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got bool * @@
>    arch/x86/mm/tlb.c:354:13: sparse:     expected void const [noderef] __percpu *__vpp_verify
>    arch/x86/mm/tlb.c:354:13: sparse:     got bool *
>>> arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got bool * @@
>    arch/x86/mm/tlb.c:354:13: sparse:     expected void const [noderef] __percpu *__vpp_verify
>    arch/x86/mm/tlb.c:354:13: sparse:     got bool *
>>> arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got bool * @@
>    arch/x86/mm/tlb.c:354:13: sparse:     expected void const [noderef] __percpu *__vpp_verify
>    arch/x86/mm/tlb.c:354:13: sparse:     got bool *
>
> vim +354 arch/x86/mm/tlb.c
>
>    336	
>    337	static void l1d_flush_evaluate(unsigned long prev_mm, unsigned long next_mm,
>    338					struct task_struct *next)
>    339	{
>    340		/* Flush L1D if the outgoing task requests it */
>    341		if (prev_mm & LAST_USER_MM_L1D_FLUSH)
>    342			wrmsrl(MSR_IA32_FLUSH_CMD, L1D_FLUSH);
>    343	
>    344		/* Check whether the incoming task opted in for L1D flush */
>    345		if (likely(!(next_mm & LAST_USER_MM_L1D_FLUSH)))
>    346			return;
>    347	
>    348		/*
>    349		 * Validate that it is not running on an SMT sibling as this would
>    350		 * make the excercise pointless because the siblings share L1D. If
>    351		 * it runs on a SMT sibling, notify it with SIGBUS on return to
>    352		 * user/guest
>    353		 */
>  > 354		if (this_cpu_read(cpu_info.smt_active)) {

That's a valid construct and the kernel of full of percpuvar.member reads/writes.

>    355			clear_ti_thread_flag(&next->thread_info, TIF_SPEC_L1D_FLUSH);
>    356			next->l1d_flush_kill.func = l1d_flush_force_sigbus;
>    357			task_work_add(next, &next->l1d_flush_kill, TWA_RESUME);
>    358		}
>    359	}
>    360	

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [tglx-devel:x86/l1dflush 7/9] arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces)
  2021-04-27  6:37 ` [tglx-devel:x86/l1dflush 7/9] arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces) Thomas Gleixner
@ 2021-04-27 17:00   ` Linus Torvalds
  2021-04-27 19:23     ` Luc Van Oostenryck
  2021-04-27 19:54     ` Thomas Gleixner
  0 siblings, 2 replies; 4+ messages in thread
From: Linus Torvalds @ 2021-04-27 17:00 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: kernel test robot, Balbir Singh, kbuild-all, Sparse Mailing-list,
	Luc Van Oostenryck

On Mon, Apr 26, 2021 at 11:37 PM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> >  > 354                if (this_cpu_read(cpu_info.smt_active)) {
>
> That's a valid construct and the kernel of full of percpuvar.member reads/writes.

Hmm. "cpu_info" doesn't seem to be marked as a percpu data structure.

Is this perhaps a UP config? Because we have:

  extern struct cpuinfo_x86       boot_cpu_data;
    ...
  #ifdef CONFIG_SMP
  DECLARE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info);
  #define cpu_data(cpu)           per_cpu(cpu_info, cpu)
  #else
  #define cpu_info                boot_cpu_data
  #define cpu_data(cpu)           boot_cpu_data
  #endif

and notice how if CONFIG_SMP isn't set, 'cpu_info' just turns into a
regular non-percpu thing.

But the sparse checking doesn't go away just because it's compiled for UP.

              Linus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [tglx-devel:x86/l1dflush 7/9] arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces)
  2021-04-27 17:00   ` Linus Torvalds
@ 2021-04-27 19:23     ` Luc Van Oostenryck
  2021-04-27 19:54     ` Thomas Gleixner
  1 sibling, 0 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2021-04-27 19:23 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Thomas Gleixner, kernel test robot, Balbir Singh, kbuild-all,
	Sparse Mailing-list

On Tue, Apr 27, 2021 at 10:00:48AM -0700, Linus Torvalds wrote:
> On Mon, Apr 26, 2021 at 11:37 PM Thomas Gleixner <tglx@linutronix.de> wrote:
> >
> > >  > 354                if (this_cpu_read(cpu_info.smt_active)) {
> >
> > That's a valid construct and the kernel of full of percpuvar.member reads/writes.
> 
> Hmm. "cpu_info" doesn't seem to be marked as a percpu data structure.
> 
> Is this perhaps a UP config? Because we have:

Yes, most probably.
Just to be sure, I checked with i386_defconfig (which is SMP) and
sparse doesn't complain (but then does if CONFIG_SMP is set to 'n').

-- Luc

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [tglx-devel:x86/l1dflush 7/9] arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces)
  2021-04-27 17:00   ` Linus Torvalds
  2021-04-27 19:23     ` Luc Van Oostenryck
@ 2021-04-27 19:54     ` Thomas Gleixner
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Gleixner @ 2021-04-27 19:54 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: kernel test robot, Balbir Singh, kbuild-all, Sparse Mailing-list,
	Luc Van Oostenryck

On Tue, Apr 27 2021 at 10:00, Linus Torvalds wrote:
> On Mon, Apr 26, 2021 at 11:37 PM Thomas Gleixner <tglx@linutronix.de> wrote:
>>
>> >  > 354                if (this_cpu_read(cpu_info.smt_active)) {
>>
>> That's a valid construct and the kernel of full of percpuvar.member reads/writes.
>
> Hmm. "cpu_info" doesn't seem to be marked as a percpu data structure.
>
> Is this perhaps a UP config? Because we have:
>
>   extern struct cpuinfo_x86       boot_cpu_data;
>     ...
>   #ifdef CONFIG_SMP
>   DECLARE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info);
>   #define cpu_data(cpu)           per_cpu(cpu_info, cpu)
>   #else
>   #define cpu_info                boot_cpu_data
>   #define cpu_data(cpu)           boot_cpu_data
>   #endif
>
> and notice how if CONFIG_SMP isn't set, 'cpu_info' just turns into a
> regular non-percpu thing.
>
> But the sparse checking doesn't go away just because it's compiled for UP.

Duh yes. I'm a moron.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-27 19:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <202104271144.G4fgnYlt-lkp@intel.com>
2021-04-27  6:37 ` [tglx-devel:x86/l1dflush 7/9] arch/x86/mm/tlb.c:354:13: sparse: sparse: incorrect type in initializer (different address spaces) Thomas Gleixner
2021-04-27 17:00   ` Linus Torvalds
2021-04-27 19:23     ` Luc Van Oostenryck
2021-04-27 19:54     ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).