From patchwork Tue Sep 6 14:11:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 1126452 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p86EBlV3007108 for ; Tue, 6 Sep 2011 14:11:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754661Ab1IFOLl (ORCPT ); Tue, 6 Sep 2011 10:11:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17760 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753209Ab1IFOLj (ORCPT ); Tue, 6 Sep 2011 10:11:39 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p86EBdk9028515 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 6 Sep 2011 10:11:39 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p86EBcQs007155 for ; Tue, 6 Sep 2011 10:11:39 -0400 Received: from s01.tlv.redhat.com (s01.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 77A9B250B58; Tue, 6 Sep 2011 17:11:38 +0300 (IDT) From: Avi Kivity To: Marcelo Tosatti , Lucas Meneghel Rodrigues Cc: kvm@vger.kernel.org Subject: [PATCH kvm-unit-tests 1/3] x86/desc: switch to using boot_idt Date: Tue, 6 Sep 2011 17:11:34 +0300 Message-Id: <1315318296-22815-2-git-send-email-avi@redhat.com> In-Reply-To: <1315318296-22815-1-git-send-email-avi@redhat.com> References: <1315318296-22815-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 06 Sep 2011 14:11:47 +0000 (UTC) boot_idt is set up an all cpus by the startup code, unlike the idt local to desc.c. Signed-off-by: Avi Kivity --- lib/x86/desc.c | 17 +++-------------- 1 files changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/x86/desc.c b/lib/x86/desc.c index 11bd2a2..0ed8c22 100644 --- a/lib/x86/desc.c +++ b/lib/x86/desc.c @@ -62,21 +62,11 @@ typedef struct { u16 iomap_base; } tss32_t; -static idt_entry_t idt[256] __attribute__((aligned(4096))); - -void load_lidt(idt_entry_t *idt, int nentries) -{ - struct descriptor_table_ptr dt; - - dt.limit = nentries * sizeof(*idt) - 1; - dt.base = (unsigned long)idt; - lidt(&dt); - asm volatile ("lidt %0" : : "m"(dt)); -} +extern idt_entry_t boot_idt[256]; void set_idt_entry(int vec, void *addr, int dpl) { - idt_entry_t *e = &idt[vec]; + idt_entry_t *e = &boot_idt[vec]; memset(e, 0, sizeof *e); e->offset0 = (unsigned long)addr; e->selector = read_cs(); @@ -92,7 +82,7 @@ void set_idt_entry(int vec, void *addr, int dpl) void set_idt_sel(int vec, u16 sel) { - idt_entry_t *e = &idt[vec]; + idt_entry_t *e = &boot_idt[vec]; e->selector = sel; } @@ -239,7 +229,6 @@ static void *idt_handlers[32] = { void setup_idt(void) { int i; - load_lidt(idt, 256); for (i = 0; i < 32; i++) if (idt_handlers[i]) set_idt_entry(i, idt_handlers[i], 0);