Skip to contentSkip to conversation

x86/head: Fix incorrect size value of startup_gdt_descr

PATCH Applied Yuntao Wang 3 participants 3 messages Aug 7, 2023 – Oct 3, 2023 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/head: Fix incorrect size value of startup_gdt_descr

Since the size value is added to the base address to yield the last valid byte address of the GDT, the current size value of startup_gdt_descr is incorrect, fix it.

Fixes 866b556efa12 ("x86/head/64: Install startup GDT")
---
 arch/x86/kernel/head64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/head64.c +1 -1
index 49f7629b17f7..cfd70939a099 100644
@@ -80,7 +80,7 @@ static struct desc_struct startup_gdt[GDT_ENTRIES] = {
  * while the kernel still uses a direct mapping.
  */
 static struct desc_ptr startup_gdt_descr = {
-	.size = sizeof(startup_gdt),
+	.size = sizeof(startup_gdt) - 1,
 	.address = 0,
 };
 
Signature · 1 line
2.41.0
merge bot Applied
#1 lore raw

[tip: x86/boot] x86/boot: Fix incorrect startup_gdt_descr.size

The following commit has been merged into the x86/boot branch of tip:

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     001470fed5959d01faecbd57fcf2f60294da0de1
Gitweb:        https://git.kernel.org/tip/001470fed5959d01faecbd57fcf2f60294da0de1
Author:        Yuntao Wang <[email protected]>
AuthorDate:    Mon, 07 Aug 2023 16:45:47 +08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 03 Oct 2023 10:28:29 +02:00

x86/boot: Fix incorrect startup_gdt_descr.size

Since the size value is added to the base address to yield the last valid byte address of the GDT, the current size value of startup_gdt_descr is incorrect (too large by one), fix it.

[ mingo: This probably never mattered, because startup_gdt[] is only used
in a very controlled fashion - but make it consistent nevertheless. ]

Fixes 866b556efa12 ("x86/head/64: Install startup GDT")
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/kernel/head64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/head64.c +1 -1
index 49f7629..bbc2179 100644
@@ -80,7 +80,7 @@ static struct desc_struct startup_gdt[GDT_ENTRIES] = {
  * while the kernel still uses a direct mapping.
  */
 static struct desc_ptr startup_gdt_descr = {
-	.size = sizeof(startup_gdt),
+	.size = sizeof(startup_gdt)-1,
 	.address = 0,
 };
 
#2 lore raw

Re: [tip: x86/boot] x86/boot: Fix incorrect startup_gdt_descr.size

Quoted 32 lines · On October 3, 2023 1:39:57 AM PDT, tip-bot2 for Yuntao Wang…

The following commit has been merged into the x86/boot branch of tip:

Commit-ID:     001470fed5959d01faecbd57fcf2f60294da0de1
Gitweb:        https://git.kernel.org/tip/001470fed5959d01faecbd57fcf2f60294da0de1
Author:        Yuntao Wang <[email protected]>
AuthorDate:    Mon, 07 Aug 2023 16:45:47 +08:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 03 Oct 2023 10:28:29 +02:00

x86/boot: Fix incorrect startup_gdt_descr.size

Since the size value is added to the base address to yield the last valid byte address of the GDT, the current size value of startup_gdt_descr is incorrect (too large by one), fix it.

[ mingo: This probably never mattered, because startup_gdt[] is only used
in a very controlled fashion - but make it consistent nevertheless. ]

Fixes 866b556efa12 ("x86/head/64: Install startup GDT")
Cc "H. Peter Anvin" <[email protected]>

---
arch/x86/kernel/head64.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/head64.c +0 -0
index 49f7629..bbc2179 100644

arch/x86/kernel/head64.c static struct desc_struct startup_gdt[GDT_ENTRIES] = { · line 86

Quoted 8 lines
arch/x86/kernel/head64.c +1 -1
@@ -80,7 +80,7 @@ static struct desc_struct startup_gdt[GDT_ENTRIES] = {
 * while the kernel still uses a direct mapping.
 */
 static struct desc_ptr startup_gdt_descr = {
-	.size = sizeof(startup_gdt),
+	.size = sizeof(startup_gdt)-1,
 	.address = 0,
 };
 

Well, it never mattered because there wasn't enough space at the end for an extra entry, but it is still Technically Correct™.