All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wrong CHS limit check
@ 2008-03-21 15:14 Robert Millan
  2008-04-13 18:29 ` Robert Millan
  2008-04-13 18:40 ` Robert Millan
  0 siblings, 2 replies; 3+ messages in thread
From: Robert Millan @ 2008-03-21 15:14 UTC (permalink / raw
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 352 bytes --]


This patch fixes (I think) the grub_biosdisk_rw() CHS limit check, which as
described in http://www.allensmith.net/Storage/HDDlimit/Int13h.htm is slightly
below LBA-24, not LBA-32 as current code assumes.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)

[-- Attachment #2: chs_limit.diff --]
[-- Type: text/x-diff, Size: 1180 bytes --]

2008-03-21  Robert Millan  <rmh@aybabtu.com>

	* disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Fix CHS limit check,
	as per http://www.allensmith.net/Storage/HDDlimit/Int13h.htm

diff -urp grub2/disk/i386/pc/biosdisk.c tmp/disk/i386/pc/biosdisk.c
--- grub2/disk/i386/pc/biosdisk.c	2008-02-03 09:27:15.000000000 +0100
+++ tmp/disk/i386/pc/biosdisk.c	2008-03-21 16:11:20.000000000 +0100
@@ -237,15 +237,17 @@ grub_biosdisk_rw (int cmd, grub_disk_t d
     {
       unsigned coff, hoff, soff;
       unsigned head;
-      unsigned real_sector = (unsigned) sector;
       
-      /* It is impossible to reach over 2TB with the traditional
-	 CHS access.  */
-      if (sector > ~0UL)
+      /* It is impossible to reach over 8064 MiB (a bit less than LBA24) with
+	 the traditional CHS access.  */
+      if (sector >
+	  1024 /* cylinders */ *
+	  256 /* heads */ *
+	  63 /* spt */)
 	return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of disk");
 
-      soff = real_sector % data->sectors + 1;
-      head = real_sector / data->sectors;
+      soff = sector % data->sectors + 1;
+      head = sector / data->sectors;
       hoff = head % data->heads;
       coff = head / data->heads;
 

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

* Re: [PATCH] wrong CHS limit check
  2008-03-21 15:14 [PATCH] wrong CHS limit check Robert Millan
@ 2008-04-13 18:29 ` Robert Millan
  2008-04-13 18:40 ` Robert Millan
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Millan @ 2008-04-13 18:29 UTC (permalink / raw
  To: grub-devel

On Fri, Mar 21, 2008 at 04:14:46PM +0100, Robert Millan wrote:
> +      soff = sector % data->sectors + 1;
> +      head = sector / data->sectors;

Or rather, as pointed out by Bean on IRC:

  soff = ((grub_uint32_t) sector) % data->sectors + 1;
  head = ((grub_uint32_t) sector) / data->sectors;

to avoid gratuitous 64-bit division where 32-bit is enough.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

* Re: [PATCH] wrong CHS limit check
  2008-03-21 15:14 [PATCH] wrong CHS limit check Robert Millan
  2008-04-13 18:29 ` Robert Millan
@ 2008-04-13 18:40 ` Robert Millan
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Millan @ 2008-04-13 18:40 UTC (permalink / raw
  To: grub-devel


Committed.

On Fri, Mar 21, 2008 at 04:14:46PM +0100, Robert Millan wrote:
> 
> This patch fixes (I think) the grub_biosdisk_rw() CHS limit check, which as
> described in http://www.allensmith.net/Storage/HDDlimit/Int13h.htm is slightly
> below LBA-24, not LBA-32 as current code assumes.
> 
> -- 
> Robert Millan
> 
> <GPLv2> I know my rights; I want my phone call!
> <DRM> What use is a phone call… if you are unable to speak?
> (as seen on /.)

> 2008-03-21  Robert Millan  <rmh@aybabtu.com>
> 
> 	* disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Fix CHS limit check,
> 	as per http://www.allensmith.net/Storage/HDDlimit/Int13h.htm
> 
> diff -urp grub2/disk/i386/pc/biosdisk.c tmp/disk/i386/pc/biosdisk.c
> --- grub2/disk/i386/pc/biosdisk.c	2008-02-03 09:27:15.000000000 +0100
> +++ tmp/disk/i386/pc/biosdisk.c	2008-03-21 16:11:20.000000000 +0100
> @@ -237,15 +237,17 @@ grub_biosdisk_rw (int cmd, grub_disk_t d
>      {
>        unsigned coff, hoff, soff;
>        unsigned head;
> -      unsigned real_sector = (unsigned) sector;
>        
> -      /* It is impossible to reach over 2TB with the traditional
> -	 CHS access.  */
> -      if (sector > ~0UL)
> +      /* It is impossible to reach over 8064 MiB (a bit less than LBA24) with
> +	 the traditional CHS access.  */
> +      if (sector >
> +	  1024 /* cylinders */ *
> +	  256 /* heads */ *
> +	  63 /* spt */)
>  	return grub_error (GRUB_ERR_OUT_OF_RANGE, "out of disk");
>  
> -      soff = real_sector % data->sectors + 1;
> -      head = real_sector / data->sectors;
> +      soff = sector % data->sectors + 1;
> +      head = sector / data->sectors;
>        hoff = head % data->heads;
>        coff = head / data->heads;
>  

> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel


-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)



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

end of thread, other threads:[~2008-04-13 18:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-21 15:14 [PATCH] wrong CHS limit check Robert Millan
2008-04-13 18:29 ` Robert Millan
2008-04-13 18:40 ` Robert Millan

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.