LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] xen: fix sparse warning in p2m.c
@ 2014-12-05  6:16 Juergen Gross
  2014-12-05 10:43 ` [Xen-devel] " David Vrabel
  0 siblings, 1 reply; 2+ messages in thread
From: Juergen Gross @ 2014-12-05  6:16 UTC (permalink / raw)
  To: linux-kernel, xen-devel, konrad.wilk, david.vrabel, boris.ostrovsky
  Cc: Juergen Gross

The patch "Speed up set_phys_to_machine() by using read-only mappings"
introduced a sparse warning:

arch/x86/xen/p2m.c:628:13: sparse: incorrect type in argument 1
                           (different address spaces)

Avoid the warning.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/xen/p2m.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index 8b5db51..2defca9 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -615,6 +615,7 @@ bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
 {
 	pte_t *ptep;
 	unsigned int level;
+	unsigned long __user *addr;
 
 	/* don't track P2M changes in autotranslate guests */
 	if (unlikely(xen_feature(XENFEAT_auto_translated_physmap)))
@@ -625,7 +626,8 @@ bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
 		return true;
 	}
 
-	if (likely(!__put_user(mfn, xen_p2m_addr + pfn)))
+	addr = (unsigned long __user *)xen_p2m_addr + pfn;
+	if (likely(!__put_user(mfn, addr)))
 		return true;
 
 	ptep = lookup_address((unsigned long)(xen_p2m_addr + pfn), &level);
-- 
2.1.2


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

* Re: [Xen-devel] [PATCH] xen: fix sparse warning in p2m.c
  2014-12-05  6:16 [PATCH] xen: fix sparse warning in p2m.c Juergen Gross
@ 2014-12-05 10:43 ` David Vrabel
  0 siblings, 0 replies; 2+ messages in thread
From: David Vrabel @ 2014-12-05 10:43 UTC (permalink / raw)
  To: Juergen Gross, linux-kernel, xen-devel, konrad.wilk,
	david.vrabel, boris.ostrovsky

On 05/12/14 06:16, Juergen Gross wrote:
> The patch "Speed up set_phys_to_machine() by using read-only mappings"
> introduced a sparse warning:
> 
> arch/x86/xen/p2m.c:628:13: sparse: incorrect type in argument 1
>                            (different address spaces)
> 
> Avoid the warning.

Thanks.

But can you add some helper functions instead?  Perhaps:

static inline int xen_safe_write_ulong(unsigned long *addr,
    unsigned long val)
{
    //...
}

static inline int xen_safe_read_ulong(unsigned long *addr,
        unsigned long *val)
{
    //...
}

David

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

end of thread, other threads:[~2014-12-05 10:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-05  6:16 [PATCH] xen: fix sparse warning in p2m.c Juergen Gross
2014-12-05 10:43 ` [Xen-devel] " David Vrabel

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).