Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1427453

Re: [PATCH v6 1/3] x86/mm: PUD VA support for physical mapping (x86_64)

From Ingo Molnar <mingo@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v6 1/3] x86/mm: PUD VA support for physical mapping (x86_64)
Date 2016-06-21 10:40 +0200
Message-ID <rMpnX-3mT-19@gated-at.bofh.it> (permalink)
References <rCQ65-6Yp-7@gated-at.bofh.it> <rCQ65-6Yp-13@gated-at.bofh.it> <rKXWN-4zo-13@gated-at.bofh.it> <rMa5z-24j-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


* Thomas Garnier <thgarnie@google.com> wrote:

> > Secondly, and that's a new problem introduced by this patch:
> >
> >> +     int i = pud_index((unsigned long)__va(addr));
> >> +             pud_t *pud = pud_page + pud_index((unsigned long)__va(addr));
> >
> > ... beyond the repetition, using type casts is fragile. Type casts should be a red
> > flag to anyone involved in low level, security relevant code! So I'm pretty
> > unhappy about seeing such a problem in such a patch.
> >
> > This code should be doing something like:
> >
> >         unsigned long vaddr_start = __va(paddr_start);
> >
> > ... which gets rid of the type cast, the repetition and documents the code much
> > better as well.
> 
> Unfortunately, we can't do that because __va return a void*. We will
> get this warning on compile:
> 
> arch/x86/mm/init_64.c:537:8: warning: assignment makes integer from
> pointer without a cast [enabled by default]
>   vaddr = __va(paddr_start);
> 
> If we used void*, we would need to type cast even more places. What do
> you think?

Hm, indeed, you are right - so I guess the type cast is OK.

Thanks,

	Ingo

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: [PATCH v6 1/3] x86/mm: PUD VA support for physical mapping  (x86_64) Ingo Molnar <mingo@kernel.org> - 2016-06-17 11:10 +0200
  Re: [PATCH v6 1/3] x86/mm: PUD VA support for physical mapping (x86_64) Thomas Garnier <thgarnie@google.com> - 2016-06-20 18:20 +0200
    Re: [PATCH v6 1/3] x86/mm: PUD VA support for physical mapping  (x86_64) Ingo Molnar <mingo@kernel.org> - 2016-06-21 10:40 +0200

csiph-web