From: Gleb Natapov <gleb@redhat.com>
To: avi@redhat.com, mtosatti@redhat.com
Cc: kvm@vger.kernel.org
Subject: [PATCH unit-tests 03/16] Remove duplicated idt code from apic test.
Date: Wed, 22 Dec 2010 17:06:16 +0200 [thread overview]
Message-ID: <1293030389-1143-4-git-send-email-gleb@redhat.com> (raw)
In-Reply-To: <1293030389-1143-1-git-send-email-gleb@redhat.com>
Use library idt code instead.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
x86/apic.c | 49 +++++++++++--------------------------------------
1 files changed, 11 insertions(+), 38 deletions(-)
diff --git a/x86/apic.c b/x86/apic.c
index 2207040..6d06f9f 100644
--- a/x86/apic.c
+++ b/x86/apic.c
@@ -2,22 +2,7 @@
#include "apic.h"
#include "vm.h"
#include "smp.h"
-
-typedef struct {
- unsigned short offset0;
- unsigned short selector;
- unsigned short ist : 3;
- unsigned short : 5;
- unsigned short type : 4;
- unsigned short : 1;
- unsigned short dpl : 2;
- unsigned short p : 1;
- unsigned short offset1;
-#ifdef __x86_64__
- unsigned offset2;
- unsigned reserved;
-#endif
-} idt_entry_t;
+#include "idt.h"
typedef struct {
ulong regs[sizeof(ulong)*2];
@@ -90,8 +75,6 @@ asm (
#endif
);
-static idt_entry_t *idt = 0;
-
static int g_fail;
static int g_tests;
@@ -128,22 +111,12 @@ void test_enable_x2apic(void)
}
}
-static void set_idt_entry(unsigned vec, void (*func)(isr_regs_t *regs))
+static void handle_irq(unsigned vec, void (*func)(isr_regs_t *regs))
{
u8 *thunk = vmalloc(50);
- ulong ptr = (ulong)thunk;
- idt_entry_t ent = {
- .offset0 = ptr,
- .selector = read_cs(),
- .ist = 0,
- .type = 14,
- .dpl = 0,
- .p = 1,
- .offset1 = ptr >> 16,
-#ifdef __x86_64__
- .offset2 = ptr >> 32,
-#endif
- };
+
+ set_idt_entry(vec, thunk, 0);
+
#ifdef __x86_64__
/* sub $8, %rsp */
*thunk++ = 0x48; *thunk++ = 0x83; *thunk++ = 0xec; *thunk++ = 0x08;
@@ -164,7 +137,6 @@ static void set_idt_entry(unsigned vec, void (*func)(isr_regs_t *regs))
*thunk ++ = 0xe9;
*(u32 *)thunk = (ulong)isr_entry_point - (ulong)(thunk + 4);
#endif
- idt[vec] = ent;
}
static void irq_disable(void)
@@ -194,7 +166,7 @@ static void test_self_ipi(void)
{
int vec = 0xf1;
- set_idt_entry(vec, self_ipi_isr);
+ handle_irq(vec, self_ipi_isr);
irq_enable();
apic_icr_write(APIC_DEST_SELF | APIC_DEST_PHYSICAL | APIC_DM_FIXED | vec,
0);
@@ -234,7 +206,7 @@ static void ioapic_isr_77(isr_regs_t *regs)
static void test_ioapic_intr(void)
{
- set_idt_entry(0x77, ioapic_isr_77);
+ handle_irq(0x77, ioapic_isr_77);
set_ioapic_redir(0x10, 0x77);
toggle_irq_line(0x10);
asm volatile ("nop");
@@ -262,8 +234,8 @@ static void ioapic_isr_66(isr_regs_t *regs)
static void test_ioapic_simultaneous(void)
{
- set_idt_entry(0x78, ioapic_isr_78);
- set_idt_entry(0x66, ioapic_isr_66);
+ handle_irq(0x78, ioapic_isr_78);
+ handle_irq(0x66, ioapic_isr_66);
set_ioapic_redir(0x10, 0x78);
set_ioapic_redir(0x11, 0x66);
irq_disable();
@@ -323,7 +295,7 @@ static void test_sti_nmi(void)
return;
}
- set_idt_entry(2, nmi_handler);
+ handle_irq(2, nmi_handler);
on_cpu(1, update_cr3, (void *)read_cr3());
sti_loop_active = 1;
@@ -343,6 +315,7 @@ int main()
{
setup_vm();
smp_init();
+ setup_idt();
test_lapic_existence();
--
1.7.2.3
next prev parent reply other threads:[~2010-12-22 15:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-22 15:06 [PATCH unit-tests 00/16] task switch and event injection tests Gleb Natapov
2010-12-22 15:06 ` [PATCH unit-tests 01/16] Move idt.c into lib code Gleb Natapov
2010-12-22 15:06 ` [PATCH unit-tests 02/16] Make access.c use library functions Gleb Natapov
2010-12-22 15:06 ` Gleb Natapov [this message]
2010-12-22 15:06 ` [PATCH unit-tests 04/16] Remove unused function from apic test Gleb Natapov
2010-12-22 15:06 ` [PATCH unit-tests 05/16] Rename idt.[ch] into desc.[ch] Gleb Natapov
2010-12-29 9:38 ` Avi Kivity
2010-12-22 15:06 ` [PATCH unit-tests 06/16] Specify correct operand length for ltr and str Gleb Natapov
2010-12-29 9:37 ` Avi Kivity
2010-12-29 9:40 ` Gleb Natapov
2010-12-29 9:43 ` Gleb Natapov
2010-12-29 9:47 ` Avi Kivity
2010-12-22 15:06 ` [PATCH unit-tests 07/16] Move irq_(enable|disable) into library code Gleb Natapov
2010-12-22 15:06 ` [PATCH unit-tests 08/16] Add another task switch test Gleb Natapov
2010-12-22 15:06 ` [PATCH unit-tests 09/16] Move vm.[ch] info library code Gleb Natapov
2010-12-22 15:06 ` [PATCH unit-tests 10/16] Fix mmu on 32 bit Gleb Natapov
2010-12-22 15:06 ` [PATCH unit-tests 11/16] Set WP bit in CR0 to make write protection work Gleb Natapov
2010-12-22 15:06 ` [PATCH unit-tests 12/16] Fix exception handling on i386 arch Gleb Natapov
2010-12-22 15:06 ` [PATCH unit-tests 13/16] Move handle_irq() from apic test into library code Gleb Natapov
2010-12-22 15:06 ` [PATCH unit-tests 14/16] Add handle_exception() interface Gleb Natapov
2010-12-22 15:06 ` [PATCH unit-tests 15/16] Move invlpg() into library code Gleb Natapov
2010-12-22 15:06 ` [PATCH unit-tests 16/16] Add even injection test Gleb Natapov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1293030389-1143-4-git-send-email-gleb@redhat.com \
--to=gleb@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox