lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdXJ+waZJ95bRLPYYsneXf98c=9d9n1jdkWMKhUpAAB_RA@mail.gmail.com>
Date:	Mon, 18 Feb 2013 11:29:18 +0100
From:	Geert Uytterhoeven <geert@...ux-m68k.org>
To:	Haiyang Zhang <haiyangz@...rosoft.com>
Cc:	FlorianSchandinat@....de, linux-fbdev@...r.kernel.org,
	kys@...rosoft.com, olaf@...fle.de, jasowang@...hat.com,
	linux-kernel@...r.kernel.org, devel@...uxdriverproject.org
Subject: Re: [PATCH RFC] video: Add Hyper-V Synthetic Video Frame Buffer Driver

On Fri, Feb 15, 2013 at 8:09 PM, Haiyang Zhang <haiyangz@...rosoft.com> wrote:
> +/* Allocate framebuffer memory */
> +#define FOUR_MEGA (4*1024*1024)
> +#define NALLOC 10
> +static void *hvfb_getmem(void)
> +{
> +       ulong *p;
> +       int i, j;
> +       ulong ret = 0;
> +
> +       if (screen_fb_size == FOUR_MEGA) {
> +               ret = __get_free_pages(GFP_KERNEL|__GFP_ZERO,
> +                                      get_order(FOUR_MEGA));
> +               goto out1;
> +       }
> +
> +       if (screen_fb_size != FOUR_MEGA * 2)
> +               return NULL;
> +
> +       /*
> +        * Windows 2012 requires frame buffer size to be 8MB, which exceeds
> +        * the limit of __get_free_pages(). So, we allocate multiple 4MB
> +        * chunks, and find out two adjacent ones.
> +        */
> +       p = kmalloc(NALLOC * sizeof(ulong), GFP_KERNEL);
> +       if (!p)
> +               return NULL;
> +
> +       for (i = 0; i < NALLOC; i++)
> +               p[i] = __get_free_pages(GFP_KERNEL|__GFP_ZERO,
> +                                       get_order(FOUR_MEGA));
> +
> +       for (i = 0; i < NALLOC; i++)
> +               for (j = 0; j < NALLOC; j++) {
> +                       if (p[j] && p[i] && virt_to_phys((void *)p[j]) -
> +                           virt_to_phys((void *)p[i]) == FOUR_MEGA &&
> +                           p[j] - p[i] == FOUR_MEGA) {
> +                               ret = p[i];
> +                               goto out;
> +                       }
> +               }
> +
> +out:
> +       for (i = 0; i < NALLOC; i++)
> +               if (p[i] && !(ret && (p[i] == ret || p[i] == ret + FOUR_MEGA)))
> +                       free_pages(p[i], get_order(FOUR_MEGA));
> +
> +       kfree(p);
> +
> +out1:
> +       if (!ret)
> +               return NULL;
> +
> +       /* Get an extra ref-count to prevent page error when x-window exits */
> +       for (i = 0; i < screen_fb_size; i += PAGE_SIZE)
> +               atomic_inc(&virt_to_page((void *)ret + i)->_count);
> +
> +       return (void *)ret;
> +}

Please instead reserve some memory at boot time, or allocate it very early
(cfr. ps3fb).

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ