Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1801359pxj; Wed, 19 May 2021 14:23:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXXdrLuuXUjYKcnnYwKSf8X/v2dI90DO6/RjeeKlsj0b4wCsExnf/x6GxlGeib2Sxotme/ X-Received: by 2002:a05:6e02:6cc:: with SMTP id p12mr1266140ils.244.1621459394663; Wed, 19 May 2021 14:23:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621459394; cv=none; d=google.com; s=arc-20160816; b=IowrOn7uiDFj+tY+YE05qL9bK2tqYCY14mrDRrpDMFgmsicMuKUocozTt/JV0k6DOK 1PEWQF7pVBM+KlWDXykV6FhXLL4jjFsbsyFcVP6yaNfhaQzU7GKfilqSMnXcoy2yx0ke KnHOvGcSj/hhsDRemuOWJYn+/FPvOKnjXpEW35dSAP7cxhMw2iuhAFn1vViZOEMBu2kr Ifz+z4ARtvlH+314R4RB2MzCphNVWgS800ZNa3+HHsd3v/xgqi1LZ+/Vq4ax3OHhFqKg SOqMvXM6FOQGbZyiL+obPY+26VJkCx0Mmge8Vfy073+KLqamk1QhmEXBkvOJmJy3wqBG 9WhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=owjrk77YDvMSdwtSYw/kbhFLq6C9oQtawBgMefYnrSE=; b=FawT/g3y6P3U8gZcqvik3Eu4yQ2M7rYzyuCKhJkiUZdCNUgEbDpdrCbFXRB2u8SlFt MleZTSv1QG8ikhESYamJw926XrY0QejnWCxb1IxKGmD+zxIoGUmNXE5gFb/50s0Ylt8j Q9iZaZRWeMq8uJ9fLD8zJk7EGTnSl1yClF9dC7cEiZsxlHJ+VOUbcg9QKfGswcT2F7rZ rq+RNGYPZOVbRC1mAZ5JwlszDopS3MAJlYZaRz4Wzlz2hzrAkrZiRERRIBasC2EO/VAT oNe1GatScwc8Uh1qL9Er2HEO96lre67dZ9KOkvUOl/Lw3NO1FRksYcRD+J70dluPHM+Y Agag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2021042801 header.b="r0BETT/o"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r188si511832jac.90.2021.05.19.14.23.02; Wed, 19 May 2021 14:23:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@zytor.com header.s=2021042801 header.b="r0BETT/o"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229755AbhESVXq (ORCPT + 99 others); Wed, 19 May 2021 17:23:46 -0400 Received: from terminus.zytor.com ([198.137.202.136]:51785 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229465AbhESVXm (ORCPT ); Wed, 19 May 2021 17:23:42 -0400 Received: from tazenda.hos.anvin.org ([IPv6:2601:646:8602:8be0:7285:c2ff:fefb:fd4]) (authenticated bits=0) by mail.zytor.com (8.16.1/8.15.2) with ESMTPSA id 14JLM1Ee4187848 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 19 May 2021 14:22:12 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 14JLM1Ee4187848 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2021042801; t=1621459333; bh=owjrk77YDvMSdwtSYw/kbhFLq6C9oQtawBgMefYnrSE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r0BETT/oQ0xeMKRCxSBi4uit0kJ4RzfEgE3GeNIxS+IgA28dldWe+MhqXVE32NgAT +Wftvj64qwN2BNwFTFG7Un46PEIBpOzJJ8NT90r4xmMYtzScYwjVd6Vu0BGx1Eze/L TE2+nVZ79zDEusNIwAZhmH4CS3FOh6EN0PZ0KNaMa/3RRRppQsENL+Ep1lvZofOiiQ ZDQXQSNvX1PlYa7DR37qucf3aG6CyZArnqB5DzPZOyUSfOsHfdkykG1UJ/GRYYPK2y gWMVHAscMit6BQzsIvLWUJb3zMYAweO2gaJmakK3HPzuY9EwHAuMQCN/lDzhk+DysO 24b2Zx8yzsc5g== From: "H. Peter Anvin" To: Thomas Gleixner , Ingo Molnar , Andy Lutomirski , Borislav Petkov , "H. Peter Anvin" Cc: Linux Kernel Mailing List Subject: [PATCH v3 6/8] x86/kexec: set_[gi]dt() -> native_[gi]dt_invalidate() in machine_kexec_*.c Date: Wed, 19 May 2021 14:21:52 -0700 Message-Id: <20210519212154.511983-7-hpa@zytor.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210519212154.511983-1-hpa@zytor.com> References: <20210519212154.511983-1-hpa@zytor.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "H. Peter Anvin (Intel)" 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) --- arch/x86/kernel/machine_kexec_32.c | 15 ++------------ arch/x86/kernel/machine_kexec_64.c | 33 ++---------------------------- 2 files changed, 4 insertions(+), 44 deletions(-) diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c index 1e34feebcd5d..1b373d79cedc 100644 --- a/arch/x86/kernel/machine_kexec_32.c +++ b/arch/x86/kernel/machine_kexec_32.c @@ -23,17 +23,6 @@ #include #include -static void set_gdt(void *newgdt, __u16 limit) -{ - struct desc_ptr curgdt; - - /* ia32 supports unaligned loads & stores */ - curgdt.size = limit; - curgdt.address = (unsigned long)newgdt; - - load_gdt(&curgdt); -} - static void load_segments(void) { #define __STR(X) #X @@ -232,8 +221,8 @@ void machine_kexec(struct kimage *image) * The gdt & idt are now invalid. * If you want to load them you must set up your own idt & gdt. */ - idt_invalidate(); - set_gdt(phys_to_virt(0), 0); + native_idt_invalidate(); + native_gdt_invalidate(); /* now call it */ image->start = relocate_kernel_ptr((unsigned long)image->head, diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c index c078b0d3ab0e..131f30fdcfbd 100644 --- a/arch/x86/kernel/machine_kexec_64.c +++ b/arch/x86/kernel/machine_kexec_64.c @@ -256,35 +256,6 @@ static int init_pgtable(struct kimage *image, unsigned long start_pgtable) return init_transition_pgtable(image, level4p); } -static void set_idt(void *newidt, u16 limit) -{ - struct desc_ptr curidt; - - /* x86-64 supports unaligned loads & stores */ - curidt.size = limit; - curidt.address = (unsigned long)newidt; - - __asm__ __volatile__ ( - "lidtq %0\n" - : : "m" (curidt) - ); -}; - - -static void set_gdt(void *newgdt, u16 limit) -{ - struct desc_ptr curgdt; - - /* x86-64 supports unaligned loads & stores */ - curgdt.size = limit; - curgdt.address = (unsigned long)newgdt; - - __asm__ __volatile__ ( - "lgdtq %0\n" - : : "m" (curgdt) - ); -}; - static void load_segments(void) { __asm__ __volatile__ ( @@ -379,8 +350,8 @@ void machine_kexec(struct kimage *image) * The gdt & idt are now invalid. * If you want to load them you must set up your own idt & gdt. */ - set_gdt(phys_to_virt(0), 0); - set_idt(phys_to_virt(0), 0); + native_idt_invalidate(); + native_gdt_invalidate(); /* now call it */ image->start = relocate_kernel((unsigned long)image->head, -- 2.31.1