Skip to content

Commit 056c52f

Browse files
H. Peter Anvin (Intel)KAGA-KOKO
authored andcommitted
x86/kexec: Set_[gi]dt() -> native_[gi]dt_invalidate() in machine_kexec_*.c
These files contain private set_gdt() functions which are only used to invalid the gdt; machine_kexec_64.c also contains a set_idt() function to invalidate the idt. phys_to_virt(0) *really* doesn't make any sense for creating an invalid GDT. A NULL pointer (virtual 0) makes a lot more sense; although neither will allow any actual memory reference, a NULL pointer stands out more. Replace these calls with native_[gi]dt_invalidate(). Signed-off-by: H. Peter Anvin (Intel) <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 283fa3b commit 056c52f

File tree

2 files changed

+4
-44
lines changed

2 files changed

+4
-44
lines changed

arch/x86/kernel/machine_kexec_32.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,6 @@
2323
#include <asm/set_memory.h>
2424
#include <asm/debugreg.h>
2525

26-
static void set_gdt(void *newgdt, __u16 limit)
27-
{
28-
struct desc_ptr curgdt;
29-
30-
/* ia32 supports unaligned loads & stores */
31-
curgdt.size = limit;
32-
curgdt.address = (unsigned long)newgdt;
33-
34-
load_gdt(&curgdt);
35-
}
36-
3726
static void load_segments(void)
3827
{
3928
#define __STR(X) #X
@@ -232,8 +221,8 @@ void machine_kexec(struct kimage *image)
232221
* The gdt & idt are now invalid.
233222
* If you want to load them you must set up your own idt & gdt.
234223
*/
235-
idt_invalidate();
236-
set_gdt(phys_to_virt(0), 0);
224+
native_idt_invalidate();
225+
native_gdt_invalidate();
237226

238227
/* now call it */
239228
image->start = relocate_kernel_ptr((unsigned long)image->head,

arch/x86/kernel/machine_kexec_64.c

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -256,35 +256,6 @@ static int init_pgtable(struct kimage *image, unsigned long start_pgtable)
256256
return init_transition_pgtable(image, level4p);
257257
}
258258

259-
static void set_idt(void *newidt, u16 limit)
260-
{
261-
struct desc_ptr curidt;
262-
263-
/* x86-64 supports unaligned loads & stores */
264-
curidt.size = limit;
265-
curidt.address = (unsigned long)newidt;
266-
267-
__asm__ __volatile__ (
268-
"lidtq %0\n"
269-
: : "m" (curidt)
270-
);
271-
};
272-
273-
274-
static void set_gdt(void *newgdt, u16 limit)
275-
{
276-
struct desc_ptr curgdt;
277-
278-
/* x86-64 supports unaligned loads & stores */
279-
curgdt.size = limit;
280-
curgdt.address = (unsigned long)newgdt;
281-
282-
__asm__ __volatile__ (
283-
"lgdtq %0\n"
284-
: : "m" (curgdt)
285-
);
286-
};
287-
288259
static void load_segments(void)
289260
{
290261
__asm__ __volatile__ (
@@ -379,8 +350,8 @@ void machine_kexec(struct kimage *image)
379350
* The gdt & idt are now invalid.
380351
* If you want to load them you must set up your own idt & gdt.
381352
*/
382-
set_gdt(phys_to_virt(0), 0);
383-
set_idt(phys_to_virt(0), 0);
353+
native_idt_invalidate();
354+
native_gdt_invalidate();
384355

385356
/* now call it */
386357
image->start = relocate_kernel((unsigned long)image->head,

0 commit comments

Comments
 (0)