All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [hyperv-linux:hyperv-next 22/32] arch/x86/hyperv/hv_init.c:366:21: sparse: sparse: incorrect type in assignment (different address spaces)
       [not found] <MWHPR21MB1593756095FD9752BA19DCDED78D9@MWHPR21MB1593.namprd21.prod.outlook.com>
@ 2021-02-11 15:58 ` Wei Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2021-02-11 15:58 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 3136 bytes --]

On Wed, Feb 10, 2021 at 06:13:22PM +0000, Michael Kelley wrote:
> From: Wei Liu <wei.liu@kernel.org>
> > > >
> > > > "sparse warnings: (new ones prefixed by >>)"
> > > >    arch/x86/hyperv/hv_init.c:90:30: sparse: sparse: incorrect type in initializer (different
> > address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got
> > void [noderef] __percpu ** @@
> > > >    arch/x86/hyperv/hv_init.c:90:30: sparse:     expected void const [noderef] __percpu
> > *__vpp_verify
> > > >    arch/x86/hyperv/hv_init.c:90:30: sparse:     got void [noderef] __percpu **
> > > >    arch/x86/hyperv/hv_init.c:95:39: sparse: sparse: incorrect type in initializer (different
> > address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got
> > void [noderef] __percpu ** @@
> > > >    arch/x86/hyperv/hv_init.c:95:39: sparse:     expected void const [noderef] __percpu
> > *__vpp_verify
> > > >    arch/x86/hyperv/hv_init.c:95:39: sparse:     got void [noderef] __percpu **
> > >
> > > I don't think this class of issue is newly introduced specifically by
> > > the Linux root partition changes.
> > >
> > > Sparse is complaining the pointer types don't match. GCC doesn't
> > > actually care.
> > >
> > > Off the top of my head, this should be fixable by using the __force
> > > annotation. But that means littering that everywhere. That does not look
> > > nice.
> > >
> > > Thoughts?
> > 
> > One way of doing it would be to provide helpers like
> > hv_get_hypercall_input_arg and hv_get_hypercall_output_arg. The __force
> > annotation is going to be enclosed with these two functions. We still
> > need to replace all the this_cpu_ptr(XXX) with the helpers, so code
> > churn is inevitable.
> > 
> > If people deem these issues important enough to fix and we agree on an
> > approach I don't mind writing a patch myself.
> > 
> 
> Without your helpers proposal, where would you put the __force
> annotation?

Basically in every location we switch to
    X = (__force *)this_cpu_ptr(Y);

With helpers it will look like
    X = hv_get_hypercall_input_arg();

__force is then encapsulated in the helpers. That would be much easier
to reason about.

I haven't written any code yet because I want to reproduce these issues
first.  I tried doing that a few days ago. Unfortunately the stock
Sparse that comes with Debian segfaulted long before it got to Hyper-V
code.

> It's not clear to me that the assignment to the local variable
> "input_arg" is the problem.  To me, the error looks more like it is coming from
> the __verify_pcpu_ptr() macro, which is where __vpp_verify is defined and
> initialized.
> 

I can't find my reference anymore, but to me this class of issues look to stem
from the type mismatch derived from the annotation of __percpu in
include/linux/compiler_types.h.

 # define __percpu       __attribute__((noderef, address_space(__percpu)))

Notice the "different address space" in the logs.  The pointers in code are
not annotated, so they are in a different address space to Sparse.

Wei.

> Michael

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

* Re: [hyperv-linux:hyperv-next 22/32] arch/x86/hyperv/hv_init.c:366:21: sparse: sparse: incorrect type in assignment (different address spaces)
  2021-02-10 15:10   ` Wei Liu
@ 2021-02-10 18:13     ` Michael Kelley
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Kelley @ 2021-02-10 18:13 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2093 bytes --]

From: Wei Liu <wei.liu@kernel.org>
> > >
> > > "sparse warnings: (new ones prefixed by >>)"
> > >    arch/x86/hyperv/hv_init.c:90:30: sparse: sparse: incorrect type in initializer (different
> address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got
> void [noderef] __percpu ** @@
> > >    arch/x86/hyperv/hv_init.c:90:30: sparse:     expected void const [noderef] __percpu
> *__vpp_verify
> > >    arch/x86/hyperv/hv_init.c:90:30: sparse:     got void [noderef] __percpu **
> > >    arch/x86/hyperv/hv_init.c:95:39: sparse: sparse: incorrect type in initializer (different
> address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got
> void [noderef] __percpu ** @@
> > >    arch/x86/hyperv/hv_init.c:95:39: sparse:     expected void const [noderef] __percpu
> *__vpp_verify
> > >    arch/x86/hyperv/hv_init.c:95:39: sparse:     got void [noderef] __percpu **
> >
> > I don't think this class of issue is newly introduced specifically by
> > the Linux root partition changes.
> >
> > Sparse is complaining the pointer types don't match. GCC doesn't
> > actually care.
> >
> > Off the top of my head, this should be fixable by using the __force
> > annotation. But that means littering that everywhere. That does not look
> > nice.
> >
> > Thoughts?
> 
> One way of doing it would be to provide helpers like
> hv_get_hypercall_input_arg and hv_get_hypercall_output_arg. The __force
> annotation is going to be enclosed with these two functions. We still
> need to replace all the this_cpu_ptr(XXX) with the helpers, so code
> churn is inevitable.
> 
> If people deem these issues important enough to fix and we agree on an
> approach I don't mind writing a patch myself.
> 

Without your helpers proposal, where would you put the __force
annotation?   It's not clear to me that the assignment to the local variable
"input_arg" is the problem.  To me, the error looks more like it is coming from
the __verify_pcpu_ptr() macro, which is where __vpp_verify is defined and
initialized.

Michael

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

* Re: [hyperv-linux:hyperv-next 22/32] arch/x86/hyperv/hv_init.c:366:21: sparse: sparse: incorrect type in assignment (different address spaces)
  2021-02-09 19:52 ` Wei Liu
@ 2021-02-10 15:10   ` Wei Liu
  2021-02-10 18:13     ` Michael Kelley
  0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2021-02-10 15:10 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2947 bytes --]

On Tue, Feb 09, 2021 at 07:52:17PM +0000, Wei Liu wrote:
> On Wed, Feb 10, 2021 at 01:40:32AM +0800, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git hyperv-next
> > head:   9c9e1c68259d6cf8a348289fd13ed8f320c0d662
> > commit: df3ae25f31b1f0ed6560c207a975abb2d4f87722 [22/32] x86/hyperv: extract partition ID from Microsoft Hypervisor if necessary
> > config: x86_64-randconfig-s022-20210209 (attached as .config)
> > compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
> > reproduce:
> >         # apt-get install sparse
> >         # sparse version: v0.6.3-215-g0fb77bb6-dirty
> >         # https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/commit/?id=df3ae25f31b1f0ed6560c207a975abb2d4f87722
> >         git remote add hyperv-linux https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
> >         git fetch --no-tags hyperv-linux hyperv-next
> >         git checkout df3ae25f31b1f0ed6560c207a975abb2d4f87722
> >         # save the attached .config to linux build tree
> >         make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 
> > 
> > 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/hyperv/hv_init.c:90:30: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got void [noderef] __percpu ** @@
> >    arch/x86/hyperv/hv_init.c:90:30: sparse:     expected void const [noderef] __percpu *__vpp_verify
> >    arch/x86/hyperv/hv_init.c:90:30: sparse:     got void [noderef] __percpu **
> >    arch/x86/hyperv/hv_init.c:95:39: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got void [noderef] __percpu ** @@
> >    arch/x86/hyperv/hv_init.c:95:39: sparse:     expected void const [noderef] __percpu *__vpp_verify
> >    arch/x86/hyperv/hv_init.c:95:39: sparse:     got void [noderef] __percpu **
> 
> I don't think this class of issue is newly introduced specifically by
> the Linux root partition changes.
> 
> Sparse is complaining the pointer types don't match. GCC doesn't
> actually care.
> 
> Off the top of my head, this should be fixable by using the __force
> annotation. But that means littering that everywhere. That does not look
> nice.
> 
> Thoughts?

One way of doing it would be to provide helpers like
hv_get_hypercall_input_arg and hv_get_hypercall_output_arg. The __force
annotation is going to be enclosed with these two functions. We still
need to replace all the this_cpu_ptr(XXX) with the helpers, so code
churn is inevitable.

If people deem these issues important enough to fix and we agree on an
approach I don't mind writing a patch myself.

Wei.

> 
> Wei.

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

* Re: [hyperv-linux:hyperv-next 22/32] arch/x86/hyperv/hv_init.c:366:21: sparse: sparse: incorrect type in assignment (different address spaces)
  2021-02-09 17:40 kernel test robot
@ 2021-02-09 19:52 ` Wei Liu
  2021-02-10 15:10   ` Wei Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2021-02-09 19:52 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 2385 bytes --]

On Wed, Feb 10, 2021 at 01:40:32AM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git hyperv-next
> head:   9c9e1c68259d6cf8a348289fd13ed8f320c0d662
> commit: df3ae25f31b1f0ed6560c207a975abb2d4f87722 [22/32] x86/hyperv: extract partition ID from Microsoft Hypervisor if necessary
> config: x86_64-randconfig-s022-20210209 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
> reproduce:
>         # apt-get install sparse
>         # sparse version: v0.6.3-215-g0fb77bb6-dirty
>         # https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/commit/?id=df3ae25f31b1f0ed6560c207a975abb2d4f87722
>         git remote add hyperv-linux https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
>         git fetch --no-tags hyperv-linux hyperv-next
>         git checkout df3ae25f31b1f0ed6560c207a975abb2d4f87722
>         # save the attached .config to linux build tree
>         make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 
> 
> 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/hyperv/hv_init.c:90:30: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got void [noderef] __percpu ** @@
>    arch/x86/hyperv/hv_init.c:90:30: sparse:     expected void const [noderef] __percpu *__vpp_verify
>    arch/x86/hyperv/hv_init.c:90:30: sparse:     got void [noderef] __percpu **
>    arch/x86/hyperv/hv_init.c:95:39: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got void [noderef] __percpu ** @@
>    arch/x86/hyperv/hv_init.c:95:39: sparse:     expected void const [noderef] __percpu *__vpp_verify
>    arch/x86/hyperv/hv_init.c:95:39: sparse:     got void [noderef] __percpu **

I don't think this class of issue is newly introduced specifically by
the Linux root partition changes.

Sparse is complaining the pointer types don't match. GCC doesn't
actually care.

Off the top of my head, this should be fixable by using the __force
annotation. But that means littering that everywhere. That does not look
nice.

Thoughts?

Wei.

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

* [hyperv-linux:hyperv-next 22/32] arch/x86/hyperv/hv_init.c:366:21: sparse: sparse: incorrect type in assignment (different address spaces)
@ 2021-02-09 17:40 kernel test robot
  2021-02-09 19:52 ` Wei Liu
  0 siblings, 1 reply; 5+ messages in thread
From: kernel test robot @ 2021-02-09 17:40 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 5261 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git hyperv-next
head:   9c9e1c68259d6cf8a348289fd13ed8f320c0d662
commit: df3ae25f31b1f0ed6560c207a975abb2d4f87722 [22/32] x86/hyperv: extract partition ID from Microsoft Hypervisor if necessary
config: x86_64-randconfig-s022-20210209 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-215-g0fb77bb6-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/commit/?id=df3ae25f31b1f0ed6560c207a975abb2d4f87722
        git remote add hyperv-linux https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git
        git fetch --no-tags hyperv-linux hyperv-next
        git checkout df3ae25f31b1f0ed6560c207a975abb2d4f87722
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

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/hyperv/hv_init.c:90:30: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got void [noderef] __percpu ** @@
   arch/x86/hyperv/hv_init.c:90:30: sparse:     expected void const [noderef] __percpu *__vpp_verify
   arch/x86/hyperv/hv_init.c:90:30: sparse:     got void [noderef] __percpu **
   arch/x86/hyperv/hv_init.c:95:39: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got void [noderef] __percpu ** @@
   arch/x86/hyperv/hv_init.c:95:39: sparse:     expected void const [noderef] __percpu *__vpp_verify
   arch/x86/hyperv/hv_init.c:95:39: sparse:     got void [noderef] __percpu **
   arch/x86/hyperv/hv_init.c:227:30: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got void [noderef] __percpu ** @@
   arch/x86/hyperv/hv_init.c:227:30: sparse:     expected void const [noderef] __percpu *__vpp_verify
   arch/x86/hyperv/hv_init.c:227:30: sparse:     got void [noderef] __percpu **
   arch/x86/hyperv/hv_init.c:234:39: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got void [noderef] __percpu ** @@
   arch/x86/hyperv/hv_init.c:234:39: sparse:     expected void const [noderef] __percpu *__vpp_verify
   arch/x86/hyperv/hv_init.c:234:39: sparse:     got void [noderef] __percpu **
   arch/x86/hyperv/hv_init.c:366:24: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected void const [noderef] __percpu *__vpp_verify @@     got void [noderef] __percpu ** @@
   arch/x86/hyperv/hv_init.c:366:24: sparse:     expected void const [noderef] __percpu *__vpp_verify
   arch/x86/hyperv/hv_init.c:366:24: sparse:     got void [noderef] __percpu **
>> arch/x86/hyperv/hv_init.c:366:21: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct hv_get_partition_id *output_page @@     got void [noderef] __percpu * @@
   arch/x86/hyperv/hv_init.c:366:21: sparse:     expected struct hv_get_partition_id *output_page
   arch/x86/hyperv/hv_init.c:366:21: sparse:     got void [noderef] __percpu *
   arch/x86/hyperv/hv_init.c:407:31: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected void [noderef] __percpu **extern [addressable] [toplevel] hyperv_pcpu_input_arg @@     got void *[noderef] __percpu * @@
   arch/x86/hyperv/hv_init.c:407:31: sparse:     expected void [noderef] __percpu **extern [addressable] [toplevel] hyperv_pcpu_input_arg
   arch/x86/hyperv/hv_init.c:407:31: sparse:     got void *[noderef] __percpu *
   arch/x86/hyperv/hv_init.c:413:40: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected void [noderef] __percpu **extern [addressable] [toplevel] hyperv_pcpu_output_arg @@     got void *[noderef] __percpu * @@
   arch/x86/hyperv/hv_init.c:413:40: sparse:     expected void [noderef] __percpu **extern [addressable] [toplevel] hyperv_pcpu_output_arg
   arch/x86/hyperv/hv_init.c:413:40: sparse:     got void *[noderef] __percpu *

vim +366 arch/x86/hyperv/hv_init.c

   358	
   359	static void __init hv_get_partition_id(void)
   360	{
   361		struct hv_get_partition_id *output_page;
   362		u64 status;
   363		unsigned long flags;
   364	
   365		local_irq_save(flags);
 > 366		output_page = *this_cpu_ptr(hyperv_pcpu_output_arg);
   367		status = hv_do_hypercall(HVCALL_GET_PARTITION_ID, NULL, output_page);
   368		if ((status & HV_HYPERCALL_RESULT_MASK) != HV_STATUS_SUCCESS) {
   369			/* No point in proceeding if this failed */
   370			pr_err("Failed to get partition ID: %lld\n", status);
   371			BUG();
   372		}
   373		hv_current_partition_id = output_page->partition_id;
   374		local_irq_restore(flags);
   375	}
   376	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34458 bytes --]

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

end of thread, other threads:[~2021-02-11 15:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <MWHPR21MB1593756095FD9752BA19DCDED78D9@MWHPR21MB1593.namprd21.prod.outlook.com>
2021-02-11 15:58 ` [hyperv-linux:hyperv-next 22/32] arch/x86/hyperv/hv_init.c:366:21: sparse: sparse: incorrect type in assignment (different address spaces) Wei Liu
2021-02-09 17:40 kernel test robot
2021-02-09 19:52 ` Wei Liu
2021-02-10 15:10   ` Wei Liu
2021-02-10 18:13     ` Michael Kelley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.