All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/dom0: change align type to int
@ 2019-01-04 15:14 Roger Pau Monne
  2019-01-04 15:35 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Roger Pau Monne @ 2019-01-04 15:14 UTC (permalink / raw)
  To: xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich, Roger Pau Monne

There's no reason to use long to store the alignment, since the bigger
page size is 1GB, and the alignment is stored as a frame number.

Reported-by: Jan Beulich <JBeulich@suse.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 xen/arch/x86/hvm/dom0_build.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
index 5ae3a32060..b696100043 100644
--- a/xen/arch/x86/hvm/dom0_build.c
+++ b/xen/arch/x86/hvm/dom0_build.c
@@ -92,8 +92,7 @@ static int __init pvh_populate_memory_range(struct domain *d,
                                             unsigned long nr_pages)
 {
     struct {
-        unsigned long align;
-        unsigned int order;
+        unsigned int align, order;
     } static const __initconst orders[] = {
         /* NB: must be sorted by decreasing size. */
         { .align = PFN_DOWN(GB(1)), .order = PAGE_ORDER_1G },
-- 
2.17.2 (Apple Git-113)


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH] x86/dom0: change align type to int
  2019-01-04 15:14 [PATCH] x86/dom0: change align type to int Roger Pau Monne
@ 2019-01-04 15:35 ` Jan Beulich
  2019-01-07 16:33   ` Roger Pau Monné
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2019-01-04 15:35 UTC (permalink / raw)
  To: Roger Pau Monne; +Cc: Andrew Cooper, Wei Liu, xen-devel

>>> On 04.01.19 at 16:14, <roger.pau@citrix.com> wrote:
> There's no reason to use long to store the alignment, since the bigger

biggest?

> page size is 1GB, and the alignment is stored as a frame number.
> 
> Reported-by: Jan Beulich <JBeulich@suse.com>
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> ---
> Cc: Jan Beulich <jbeulich@suse.com>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
> ---
>  xen/arch/x86/hvm/dom0_build.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
> index 5ae3a32060..b696100043 100644
> --- a/xen/arch/x86/hvm/dom0_build.c
> +++ b/xen/arch/x86/hvm/dom0_build.c
> @@ -92,8 +92,7 @@ static int __init pvh_populate_memory_range(struct domain *d,
>                                              unsigned long nr_pages)
>  {
>      struct {
> -        unsigned long align;
> -        unsigned int order;
> +        unsigned int align, order;
>      } static const __initconst orders[] = {
>          /* NB: must be sorted by decreasing size. */
>          { .align = PFN_DOWN(GB(1)), .order = PAGE_ORDER_1G },

That's not enough afaict, you also need to use 1UL in

            end = (start + nr_pages) & ~(orders[0].align - 1);

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [PATCH] x86/dom0: change align type to int
  2019-01-04 15:35 ` Jan Beulich
@ 2019-01-07 16:33   ` Roger Pau Monné
  0 siblings, 0 replies; 3+ messages in thread
From: Roger Pau Monné @ 2019-01-07 16:33 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Andrew Cooper, Wei Liu, xen-devel

On Fri, Jan 04, 2019 at 08:35:38AM -0700, Jan Beulich wrote:
> >>> On 04.01.19 at 16:14, <roger.pau@citrix.com> wrote:
> > There's no reason to use long to store the alignment, since the bigger
> 
> biggest?
> 
> > page size is 1GB, and the alignment is stored as a frame number.
> > 
> > Reported-by: Jan Beulich <JBeulich@suse.com>
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> > ---
> > Cc: Jan Beulich <jbeulich@suse.com>
> > Cc: Andrew Cooper <andrew.cooper3@citrix.com>
> > Cc: Wei Liu <wei.liu2@citrix.com>
> > ---
> >  xen/arch/x86/hvm/dom0_build.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
> > index 5ae3a32060..b696100043 100644
> > --- a/xen/arch/x86/hvm/dom0_build.c
> > +++ b/xen/arch/x86/hvm/dom0_build.c
> > @@ -92,8 +92,7 @@ static int __init pvh_populate_memory_range(struct domain *d,
> >                                              unsigned long nr_pages)
> >  {
> >      struct {
> > -        unsigned long align;
> > -        unsigned int order;
> > +        unsigned int align, order;
> >      } static const __initconst orders[] = {
> >          /* NB: must be sorted by decreasing size. */
> >          { .align = PFN_DOWN(GB(1)), .order = PAGE_ORDER_1G },
> 
> That's not enough afaict, you also need to use 1UL in
> 
>             end = (start + nr_pages) & ~(orders[0].align - 1);

Right, I'm afraid I prefer to keep align as unsigned long in order to
avoid such mistakes.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2019-01-07 16:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-04 15:14 [PATCH] x86/dom0: change align type to int Roger Pau Monne
2019-01-04 15:35 ` Jan Beulich
2019-01-07 16:33   ` Roger Pau Monné

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.