[PATCH] i386/relocator_common.S: drop empty #ifdef

2020-08-12 Thread Cao jin
Signed-off-by: Cao jin 
---
 grub-core/lib/i386/relocator_common.S | 2 --
 1 file changed, 2 deletions(-)

diff --git a/grub-core/lib/i386/relocator_common.S 
b/grub-core/lib/i386/relocator_common.S
index 03f427a03..1b5210dd3 100644
--- a/grub-core/lib/i386/relocator_common.S
+++ b/grub-core/lib/i386/relocator_common.S
@@ -29,8 +29,6 @@
 #endif
 
.macro DISABLE_PAGING
-#ifdef GRUB_MACHINE_IEEE1275
-#endif
 
movl%cr0, %eax
andl$(~GRUB_MEMORY_CPU_CR0_PAGING_ON), %eax
-- 
2.21.1




___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] realmode.S: update comments

2020-07-27 Thread Cao jin
Commit b81d609e4c forget to update it.

Signed-off-by: Cao jin 
---
 grub-core/kern/i386/realmode.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grub-core/kern/i386/realmode.S b/grub-core/kern/i386/realmode.S
index 998fdc756..265cdcb9d 100644
--- a/grub-core/kern/i386/realmode.S
+++ b/grub-core/kern/i386/realmode.S
@@ -77,7 +77,7 @@ protstack:
  *  description.
  */
 
-   .p2align5   /* force 4-byte alignment */
+   .p2align5   /* force 32-byte alignment */
 gdt:
.word   0, 0
.byte   0, 0, 0, 0
-- 
2.21.1




___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: questions about relocator16.S

2018-08-15 Thread Cao jin
Sorry I don't see reply in time because I am not on the TO or CC list.

On 08/14/2018 04:36 PM, Vladimir 'phcoder' Serbinenko wrote:
> 
> 
> вт, 14 авг. 2018 г., 9:11 Cao jin  <mailto:caoj.f...@cn.fujitsu.com>>:
> 
> Hi,
> 
>   I am learning these code, and now have 2 questions:
> 
> 1. at the bottom of relocator_common.S, there is:
> 
> LOCAL(jump_vector):
>         /* Jump location. Is filled by the code */
>         .long   0
>         .long   CODE_SEGMENT
> 
> Since it is offset & segment selector value, why is not ".word
> CODE_SEGMENT", is there any subtle difference?
> 
> i386 is little endian, so effectively it just reserves 2 bytes more and
> fills them with zeros.
> 

Yes, I think so.

> 
> 2. in relocator16.S, after "RELOAD_GDT", the other segment registers are
> updated two times with DATA_SEGMENT & PSEUDO_REAL_DSEG, they are pretty
> close, there is no memory read/write between them, so why we need the
> updates with DATA_SEGMENT?
> 
> It's derived from older code that may have had accesses there. But it
> was tested on many CPUs and changing it risks triggering obscure bug in
> an obscure CPU
> 

I see.

Thanks very much for your explanation, Vladimir:)

-- 
Sincerely,
Cao jin



___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


questions about relocator16.S

2018-08-14 Thread Cao jin
Hi,

  I am learning these code, and now have 2 questions:

1. at the bottom of relocator_common.S, there is:

LOCAL(jump_vector):
/* Jump location. Is filled by the code */
.long   0
.long   CODE_SEGMENT

Since it is offset & segment selector value, why is not ".word
CODE_SEGMENT", is there any subtle difference?

2. in relocator16.S, after "RELOAD_GDT", the other segment registers are
updated two times with DATA_SEGMENT & PSEUDO_REAL_DSEG, they are pretty
close, there is no memory read/write between them, so why we need the
updates with DATA_SEGMENT?

-- 
Sincerely,
Cao jin



___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] relocator16.S: comments update

2018-08-14 Thread Cao jin
Signed-off-by: Cao jin 
---
 grub-core/lib/i386/relocator16.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/grub-core/lib/i386/relocator16.S b/grub-core/lib/i386/relocator16.S
index c8d6f86d8..a8b48d2c4 100644
--- a/grub-core/lib/i386/relocator16.S
+++ b/grub-core/lib/i386/relocator16.S
@@ -204,8 +204,8 @@ LOCAL(gate_a20_check_state):
ret
 
 LOCAL(gate_a20_done):
-   /* we are in real mode now
-* set up the real mode segment registers : DS, SS, ES
+   /* we are in real mode now. Set up the real mode segment registers and
+* all the other general purpose registers. cs is updated with ljmp.
 */
/* movw imm16, %ax.  */
.byte   0xb8
@@ -298,7 +298,7 @@ LOCAL(gdt):
.byte   0, 0x92, 0xCF, 0
 
/* -- 16 bit real mode CS --
-* base = 0x, limit 0x0 (1 B Granularity), present
+* base = filled by code, limit 0x0 (1 B Granularity), present
 * type = 16 bit code execute/read only/conforming, DPL = 0
 */
.word   0x
-- 
2.17.0




___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] linux16 module: code cleanup

2018-08-07 Thread Cao jin
1. move relocator related code more close to each other
2. use variable "len" since it has correct assignment, and keep coding
style with upper code

Signed-off-by: Cao jin 
---
 grub-core/loader/i386/pc/linux.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c
index b69cb7a3a..531b58d37 100644
--- a/grub-core/loader/i386/pc/linux.c
+++ b/grub-core/loader/i386/pc/linux.c
@@ -236,10 +236,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ 
((unused)),
(unsigned) real_size,
(unsigned) grub_linux16_prot_size);
 
-  relocator = grub_relocator_new ();
-  if (!relocator)
-goto fail;
-
   for (i = 1; i < argc; i++)
 if (grub_memcmp (argv[i], "vga=", 4) == 0)
   {
@@ -299,6 +295,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ 
((unused)),
  }
   }
 
+  relocator = grub_relocator_new ();
+  if (!relocator)
+goto fail;
+
   {
 grub_relocator_chunk_t ch;
 err = grub_relocator_alloc_chunk_addr (relocator, &ch,
@@ -355,8 +355,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
   }
 
   len = grub_linux16_prot_size;
-  if (grub_file_read (file, grub_linux_prot_chunk, grub_linux16_prot_size)
-  != (grub_ssize_t) grub_linux16_prot_size && !grub_errno)
+  if (grub_file_read (file, grub_linux_prot_chunk, len) != len && !grub_errno)
 grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
argv[0]);
 
-- 
2.17.0




___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] grub-setup: debug message cleanup

2018-07-03 Thread Cao jin
variable "root" is initialized after root device probing, and is null in
current place, so, drop it.

Signed-off-by: Cao jin 
---
 util/setup.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

BTW, I am still not very sure about "root device" in grub, is it the
partition where boot directory resides?

diff --git a/util/setup.c b/util/setup.c
index 8aa5a39a7..7d3bf2c27 100644
--- a/util/setup.c
+++ b/util/setup.c
@@ -298,9 +298,8 @@ SETUP (const char *dir,
   bl.first_block = (struct grub_boot_blocklist *) (core_img
   + GRUB_DISK_SECTOR_SIZE
   - sizeof (*bl.block));
-  grub_util_info ("root is `%s', dest is `%s'", root, dest);
 
-  grub_util_info ("Opening dest");
+  grub_util_info ("Opening dest `%s'", dest);
   dest_dev = grub_device_open (dest);
   if (! dest_dev)
 grub_util_error ("%s", grub_errmsg);
-- 
2.14.3




___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] diskboot: trivial correction on stale comments

2018-04-10 Thread Cao jin
diskboot.img now is loaded at 0x8000 and is jumped to with 0:0x8000.

Signed-off-by: Cao jin 
---
 grub-core/boot/i386/pc/diskboot.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/grub-core/boot/i386/pc/diskboot.S 
b/grub-core/boot/i386/pc/diskboot.S
index 1ee4cf5b2..c1addc0df 100644
--- a/grub-core/boot/i386/pc/diskboot.S
+++ b/grub-core/boot/i386/pc/diskboot.S
@@ -37,8 +37,8 @@
 start:
 _start:
/*
-* _start is loaded at 0x2000 and is jumped to with
-* CS:IP 0:0x2000 in kernel.
+* _start is loaded at 0x8000 and is jumped to with
+* CS:IP 0:0x8000 in kernel.
 */
 
/*
-- 
2.14.3




___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: stale comment in diskboot.S ?

2018-04-10 Thread Cao jin
Hi Daniel,

On 04/11/2018 04:25 AM, Daniel Kiper wrote:
> On Wed, Mar 28, 2018 at 04:09:00PM +0800, Cao jin wrote:
>> Hi,
>>
>> I was reading the code, and I want to confirm is following comment is stale?
>>
>>  /*
>>   * _start is loaded at 0x2000 and is jumped to with
>>   * CS:IP 0:0x2000 in kernel.
>>   */
>>
>> As I understand, it is loaded at 0x8000 and is jumped to with 0:0x8000.
> 
> It looks that you are right. Could you fix that comment?
> I am happy to take a patch for it.
> 

Sure, patch is on the way.

-- 
Sincerely,
Cao jin



___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


stale comment in diskboot.S ?

2018-03-28 Thread Cao jin
Hi,

I was reading the code, and I want to confirm is following comment is stale?

/*
 * _start is loaded at 0x2000 and is jumped to with
 * CS:IP 0:0x2000 in kernel.
 */

As I understand, it is loaded at 0x8000 and is jumped to with 0:0x8000.
-- 
Sincerely,
Cao jin



___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel