mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/head: Fix incorrect size value of startup_gdt_descr
@ 2023-08-07  8:45 Yuntao Wang
  2023-10-03  8:39 ` [tip: x86/boot] x86/boot: Fix incorrect startup_gdt_descr.size tip-bot2 for Yuntao Wang
  0 siblings, 1 reply; 3+ messages in thread
From: Yuntao Wang @ 2023-08-07  8:45 UTC (permalink / raw)
  To: x86, linux-kernel
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin, Peter Zijlstra (Intel),
	Anshuman Khandual, Josh Poimboeuf, Pasha Tatashin, Joerg Roedel,
	Yuntao Wang

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")
Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
---
 arch/x86/kernel/head64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 49f7629b17f7..cfd70939a099 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -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.41.0


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

* [tip: x86/boot] x86/boot: Fix incorrect startup_gdt_descr.size
  2023-08-07  8:45 [PATCH] x86/head: Fix incorrect size value of startup_gdt_descr Yuntao Wang
@ 2023-10-03  8:39 ` tip-bot2 for Yuntao Wang
  2023-10-03 21:56   ` H. Peter Anvin
  0 siblings, 1 reply; 3+ messages in thread
From: tip-bot2 for Yuntao Wang @ 2023-10-03  8:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Yuntao Wang, Ingo Molnar, H. Peter Anvin, x86, linux-kernel

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 <ytcoode@gmail.com>
AuthorDate:    Mon, 07 Aug 2023 16:45:47 +08:00
Committer:     Ingo Molnar <mingo@kernel.org>
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")
Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lore.kernel.org/r/20230807084547.217390-1-ytcoode@gmail.com
---
 arch/x86/kernel/head64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 49f7629..bbc2179 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -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,
 };
 

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

* Re: [tip: x86/boot] x86/boot: Fix incorrect startup_gdt_descr.size
  2023-10-03  8:39 ` [tip: x86/boot] x86/boot: Fix incorrect startup_gdt_descr.size tip-bot2 for Yuntao Wang
@ 2023-10-03 21:56   ` H. Peter Anvin
  0 siblings, 0 replies; 3+ messages in thread
From: H. Peter Anvin @ 2023-10-03 21:56 UTC (permalink / raw)
  To: linux-kernel, tip-bot2 for Yuntao Wang, linux-tip-commits
  Cc: Yuntao Wang, Ingo Molnar, x86

On October 3, 2023 1:39:57 AM PDT, tip-bot2 for Yuntao Wang <tip-bot2@linutronix.de> wrote:
>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 <ytcoode@gmail.com>
>AuthorDate:    Mon, 07 Aug 2023 16:45:47 +08:00
>Committer:     Ingo Molnar <mingo@kernel.org>
>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")
>Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
>Signed-off-by: Ingo Molnar <mingo@kernel.org>
>Cc: "H. Peter Anvin" <hpa@zytor.com>
>Link: https://lore.kernel.org/r/20230807084547.217390-1-ytcoode@gmail.com
>---
> arch/x86/kernel/head64.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
>index 49f7629..bbc2179 100644
>--- a/arch/x86/kernel/head64.c
>+++ b/arch/x86/kernel/head64.c
>@@ -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™.

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

end of thread, other threads:[~2023-10-03 21:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07  8:45 [PATCH] x86/head: Fix incorrect size value of startup_gdt_descr Yuntao Wang
2023-10-03  8:39 ` [tip: x86/boot] x86/boot: Fix incorrect startup_gdt_descr.size tip-bot2 for Yuntao Wang
2023-10-03 21:56   ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®