Should be:

if (newhmr->sz || !(newhmr->sz & (TARGET_PAGE_SIZE-1))) {

which is the same as the existing for TARGET_PAGE_SIZE a power of 2,

Aidan



On Tue, Aug 27, 2013 at 7:23 PM, Roei Tell <notifications@github.com> wrote:

> In heca-all.c:
>
> >      }
> > -}
> > -
> > -static uint32_t get_param_int(const char *name, const char *optarg)
> > -{
> > -    char target[128];
> > -    uint32_t result = 0;
> > -
> > -    get_param(target, name, 128, optarg);
> > -    result = strtoull(target, NULL, 10);
> > -    if (result <= 0 || (result & 0xFFFF) != result) {
> > -        printf("error?\n");
> > -        fprintf(stderr, "Could not get parameter value");
> > -        exit(1);
> > +    if (newhmr->sz == 0 || newhmr->sz % TARGET_PAGE_SIZE != 0) {
>
> This is not necessarily true, as we discussed. Take for example
> sz=2^10+2^9 and P_SZ=2^8, so doing
> (2^10 + 2^9) AND (2^8-1) results in 0.
>
> If we could assume both sizes are powers of 2, we would just directly
> compare sz >= SZ to know if SZ is a divisor.
>
> In any case the suggested change is a bug.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/hecatonchire/qemu-heca/pull/6/files#r6009774>
> .
>