qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PULL 38/47] memfd: add hugetlbsize argument


From: Peter Maydell
Subject: Re: [Qemu-devel] [PULL 38/47] memfd: add hugetlbsize argument
Date: Fri, 27 Apr 2018 13:42:35 +0100

On 5 February 2018 at 19:28, Paolo Bonzini <address@hidden> wrote:
> From: Marc-André Lureau <address@hidden>
>
> Learn to specificy hugetlb size as qemu_memfd_create() argument.

>  int qemu_memfd_create(const char *name, size_t size, bool hugetlb,
> -                      unsigned int seals, Error **errp)
> +                      uint64_t hugetlbsize, unsigned int seals, Error **errp)
>  {
> +    int htsize = hugetlbsize ? ctz64(hugetlbsize) : 0;
> +
> +    if (htsize && 1 << htsize != hugetlbsize) {
> +        error_setg(errp, "Hugepage size must be a power of 2");
> +        return -1;
> +    }
> +
> +    htsize = htsize << MFD_HUGE_SHIFT;

Hi; Coverity complains about this function (CID 1385858) because
we calculate a bit poisition htsize which could be up to 63, but
then use it in "1 << htsize" which is a 32-bit integer calculation
and could push the 1 off the top of the value.

This should be "1ULL", though of course a hugetlbsize of 4GB
is not very plausible.

PS: the variable name is "hugetlbsize" but the error message
says "hugepage size" -- is it a TLB size or a page size ?

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]