xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Frediano Ziglio <frediano.ziglio@citrix.com>
To: Frediano Ziglio <frediano.ziglio@citrix.com>, xen-devel@lists.xen.org
Subject: [PATCH 3/7] vgabios: Fix size computation overflow
Date: Tue, 1 May 2012 14:52:42 +0100	[thread overview]
Message-ID: <1335880366-9873-4-git-send-email-frediano.ziglio@citrix.com> (raw)
In-Reply-To: <1335880366-9873-1-git-send-email-frediano.ziglio@citrix.com>


Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
---
 tools/firmware/vgabios/vbe.c |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/tools/firmware/vgabios/vbe.c b/tools/firmware/vgabios/vbe.c
index 3d42216..35d9866 100644
--- a/tools/firmware/vgabios/vbe.c
+++ b/tools/firmware/vgabios/vbe.c
@@ -742,6 +742,29 @@ no_vbe_flag:
   jmp  _display_string
 ASM_END  
 
+ASM_START
+_size64:
+  push bp
+  mov  bp, sp
+  push dx
+
+; multiply bbp by yres first as results fit in 16bits
+; then multiply by xres
+  mov  ax, 8[bp]
+  mul  word 6[bp]
+  mul  word 4[bp]
+; divide by 2^19 ceiling result
+  add  ax, #0xffff
+  adc  dx, #7
+  mov  ax, dx
+  shr  ax, #3
+
+  pop  dx
+  pop  bp
+  ret
+ASM_END
+
+
 /** Function 00h - Return VBE Controller Information
  * 
  * Input:
@@ -846,9 +869,12 @@ Bit16u *AX;Bit16u ES;Bit16u DI;
                 
         do
         {
+                Bit16u size_64k = size64(cur_info->info.XResolution, cur_info->info.YResolution, cur_info->info.BitsPerPixel);
+                Bit16u max_bpp = dispi_get_max_bpp();
+
                 if ((cur_info->info.XResolution <= dispi_get_max_xres()) &&
-                    (cur_info->info.BitsPerPixel <= dispi_get_max_bpp()) &&
-                    (cur_info->info.XResolution * cur_info->info.XResolution * cur_info->info.BitsPerPixel <= vbe_info_block.TotalMemory << 19 )) {
+                    (cur_info->info.BitsPerPixel <= max_bpp) &&
+                    (size_64k <= vbe_info_block.TotalMemory)) {
 #ifdef DEBUG
                   printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode);
                   cur_mode++;
-- 
1.7.5.4

  parent reply	other threads:[~2012-05-01 13:52 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-01 13:52 VGABIOS patches Frediano Ziglio
2012-05-01 13:52 ` [PATCH 1/7] vgabios: Output to Xen debug port instead of using Bochs one Frediano Ziglio
2012-05-01 14:03   ` Paul Durrant
2012-05-01 13:52 ` [PATCH 2/7] vgabios: Does not define cur_mode if not required Frediano Ziglio
2012-05-01 13:52 ` Frediano Ziglio [this message]
2012-05-01 13:52 ` [PATCH 4/7] vgabios: Report mode not supported getting mode informations Frediano Ziglio
2012-05-01 13:52 ` [PATCH 5/7] vgabios: Reduce stack usage " Frediano Ziglio
2012-05-01 13:52 ` [PATCH 6/7] vgabios: Check if mode is currently supported as vesa specifications Frediano Ziglio
2012-05-01 13:52 ` [PATCH 7/7] vgabios: Make Windows 8 support greater resolutions Frediano Ziglio
  -- strict thread matches above, loose matches on Subject: below --
2012-05-04 12:36 [PATCH 0/7] VGA BIOS patches Frediano Ziglio
2012-05-04 12:36 ` [PATCH 3/7] vgabios: Fix size computation overflow Frediano Ziglio
2012-05-04 14:12   ` Ian Campbell
2012-05-04 14:18     ` Frediano Ziglio
2012-05-04 14:26       ` Ian Campbell
2012-05-04 14:45         ` Frediano Ziglio
2012-05-04 14:47         ` Frediano Ziglio
2012-05-04 14:48         ` Frediano Ziglio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1335880366-9873-4-git-send-email-frediano.ziglio@citrix.com \
    --to=frediano.ziglio@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).