Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1704423ybh; Tue, 14 Jul 2020 05:17:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyugfycWJQTkly3A9E/nNOeO3LI72DyVj3EQut2YcstmnyRrouJzWuZ9yvuOb3K1UcaXd6F X-Received: by 2002:a17:907:42cb:: with SMTP id nz19mr4086069ejb.447.1594729061866; Tue, 14 Jul 2020 05:17:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594729061; cv=none; d=google.com; s=arc-20160816; b=vHiOVbWRFLIc9BFH1k0a0ige8kwUiZN+vWxjAR6tWODuNIY45KZN50v9WqmMCfB7Ad Vuv4wfaBrYmFWFDZw9RDAMH5MWM7xfy6fih1I1MG1Vc4Qppc/UXElehLc/USdGLFvzkg vBV1seglbJYCl/eQCl1wYoOXhQ1M9lfc0+arMAXhYNqd5Zu3P7tT5S0ftvgCGKsqeC1O HO4Avory/e49gtka37JRbph5CJ3sQWGYZMJ3JPmtP/rgT9gv33w4wBLLdbZmQ7IG5QIW 6BVmaXE7c9hrakiKC98ktWvUYujNzCUt1CQSXMcFM+7XvxQGcJinDb9wdIWXMWeP2z+8 SLfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LP+/9SxXwmAD2pdJ3Mk0U2uOBSXxeIc+TIAC0Ht6658=; b=dMLkfeLEyo1gW4SosyrP6QBCqhwTH8GEv7nBinbDEWEFw8lzT5MweYI6JfftqTDO8/ a+ffMi7s0dFCZDzZoi6CPjqQvntPmoXPeSITDTwJLuMeVDbFL+88UvT3p2Er8zUEs3PD jLkELZhEravZ+ZYWfBLQBOEV0V1jDYAxcZa5MIGzu3Hvtd5GPJbYaWc52B3YYIaWFROu bT6EzPfeVneuB7tz0HCy8BekbepmBN6jePjwm2sRwTg+lwk87naho1wV3dO8OzXB8BpT K5SSmnn51vxeebkNSPQu3pcNfwc/+TJZYAnWrET/P6g+c6siFOuJvvho1B2gtEAwhzlq QM+w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v25si10095477eju.682.2020.07.14.05.17.17; Tue, 14 Jul 2020 05:17:41 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728324AbgGNMPx (ORCPT + 99 others); Tue, 14 Jul 2020 08:15:53 -0400 Received: from 8bytes.org ([81.169.241.247]:52886 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728009AbgGNMKv (ORCPT ); Tue, 14 Jul 2020 08:10:51 -0400 Received: from cap.home.8bytes.org (p5b006776.dip0.t-ipconnect.de [91.0.103.118]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by theia.8bytes.org (Postfix) with ESMTPSA id 9C076C07; Tue, 14 Jul 2020 14:10:48 +0200 (CEST) From: Joerg Roedel To: x86@kernel.org Cc: Joerg Roedel , Joerg Roedel , hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Sean Christopherson , Martin Radev , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH v4 29/75] x86/idt: Move two function from k/idt.c to i/a/desc.h Date: Tue, 14 Jul 2020 14:08:31 +0200 Message-Id: <20200714120917.11253-30-joro@8bytes.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200714120917.11253-1-joro@8bytes.org> References: <20200714120917.11253-1-joro@8bytes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Move these two functions from kernel/idt.c to include/asm/desc.h: * init_idt_data() * idt_init_desc() These functions are needed to setup IDT entries very early and need to be called from head64.c. To be usable this early these functions need to be compiled without instrumentation and the stack-protector feature. These features need to be kept enabled for kernel/idt.c, so head64.c must use its own versions. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/desc.h | 27 +++++++++++++++++++++++++ arch/x86/include/asm/desc_defs.h | 7 +++++++ arch/x86/kernel/idt.c | 34 -------------------------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h index 1ced11d31932..476082a83d1c 100644 --- a/arch/x86/include/asm/desc.h +++ b/arch/x86/include/asm/desc.h @@ -383,6 +383,33 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit) void alloc_intr_gate(unsigned int n, const void *addr); +static inline void init_idt_data(struct idt_data *data, unsigned int n, + const void *addr) +{ + BUG_ON(n > 0xFF); + + memset(data, 0, sizeof(*data)); + data->vector = n; + data->addr = addr; + data->segment = __KERNEL_CS; + data->bits.type = GATE_INTERRUPT; + data->bits.p = 1; +} + +static inline void idt_init_desc(gate_desc *gate, const struct idt_data *d) +{ + unsigned long addr = (unsigned long) d->addr; + + gate->offset_low = (u16) addr; + gate->segment = (u16) d->segment; + gate->bits = d->bits; + gate->offset_middle = (u16) (addr >> 16); +#ifdef CONFIG_X86_64 + gate->offset_high = (u32) (addr >> 32); + gate->reserved = 0; +#endif +} + extern unsigned long system_vectors[]; extern void load_current_idt(void); diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h index 5621fb3f2d1a..f7e7099af595 100644 --- a/arch/x86/include/asm/desc_defs.h +++ b/arch/x86/include/asm/desc_defs.h @@ -74,6 +74,13 @@ struct idt_bits { p : 1; } __attribute__((packed)); +struct idt_data { + unsigned int vector; + unsigned int segment; + struct idt_bits bits; + const void *addr; +}; + struct gate_struct { u16 offset_low; u16 segment; diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c index 367eb6a593dd..d3f0c8133300 100644 --- a/arch/x86/kernel/idt.c +++ b/arch/x86/kernel/idt.c @@ -11,13 +11,6 @@ #include #include -struct idt_data { - unsigned int vector; - unsigned int segment; - struct idt_bits bits; - const void *addr; -}; - #define DPL0 0x0 #define DPL3 0x3 @@ -178,20 +171,6 @@ bool idt_is_f00f_address(unsigned long address) } #endif -static inline void idt_init_desc(gate_desc *gate, const struct idt_data *d) -{ - unsigned long addr = (unsigned long) d->addr; - - gate->offset_low = (u16) addr; - gate->segment = (u16) d->segment; - gate->bits = d->bits; - gate->offset_middle = (u16) (addr >> 16); -#ifdef CONFIG_X86_64 - gate->offset_high = (u32) (addr >> 32); - gate->reserved = 0; -#endif -} - static __init void idt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size, bool sys) { @@ -205,19 +184,6 @@ idt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size, bool sy } } -static void init_idt_data(struct idt_data *data, unsigned int n, - const void *addr) -{ - BUG_ON(n > 0xFF); - - memset(data, 0, sizeof(*data)); - data->vector = n; - data->addr = addr; - data->segment = __KERNEL_CS; - data->bits.type = GATE_INTERRUPT; - data->bits.p = 1; -} - static __init void set_intr_gate(unsigned int n, const void *addr) { struct idt_data data; -- 2.27.0