* [PATCH] Eliminate the difference of ioapic and iosapic
@ 2007-11-29 10:25 Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA3951B-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 11+ messages in thread
From: Zhang, Xiantao @ 2007-11-29 10:25 UTC (permalink / raw)
To: avi-atKUWr5tajBWk0Htik3J/w; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
[-- Attachment #1: Type: text/plain, Size: 6623 bytes --]
From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Date: Thu, 29 Nov 2007 18:17:13 +0800
Subject: [PATCH] Clearing up the difference of ioapic and iosapic
Since IA64 uses iosapic, we want to merget it with current ioapic code.
This patch should make x86 and IA64 happy.
Signed-off-by: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
drivers/kvm/ioapic.c | 26 +++++++++++++-------------
drivers/kvm/irq.h | 5 +++--
drivers/kvm/lapic.c | 23 ++++++++++++++++++-----
3 files changed, 34 insertions(+), 20 deletions(-)
diff --git a/drivers/kvm/ioapic.c b/drivers/kvm/ioapic.c
index cf1d50b..79c48ec 100644
--- a/drivers/kvm/ioapic.c
+++ b/drivers/kvm/ioapic.c
@@ -36,11 +36,8 @@
#include <linux/hrtimer.h>
#include <linux/io.h>
#include <asm/processor.h>
-#include <asm/msr.h>
#include <asm/page.h>
#include <asm/current.h>
-#include <asm/apicdef.h>
-#include <asm/io_apic.h>
#include "irq.h"
#if 0
#define ioapic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg)
@@ -136,7 +133,7 @@ static void ioapic_write_indirect(struct kvm_ioapic
*ioapic, u32 val)
}
static void ioapic_inj_irq(struct kvm_ioapic *ioapic,
- struct kvm_lapic *target,
+ struct kvm_vcpu *vcpu,
u8 vector, u8 trig_mode, u8 delivery_mode)
{
ioapic_debug("irq %d trig %d deliv %d\n", vector, trig_mode,
@@ -145,7 +142,7 @@ static void ioapic_inj_irq(struct kvm_ioapic
*ioapic,
ASSERT((delivery_mode == dest_Fixed) ||
(delivery_mode == dest_LowestPrio));
- kvm_apic_set_irq(target, vector, trig_mode);
+ kvm_apic_set_irq(vcpu, vector, trig_mode);
}
static u32 ioapic_get_delivery_bitmask(struct kvm_ioapic *ioapic, u8
dest,
@@ -196,7 +193,6 @@ static void ioapic_deliver(struct kvm_ioapic
*ioapic, int irq)
u8 vector = ioapic->redirtbl[irq].fields.vector;
u8 trig_mode = ioapic->redirtbl[irq].fields.trig_mode;
u32 deliver_bitmask;
- struct kvm_lapic *target;
struct kvm_vcpu *vcpu;
int vcpu_id;
@@ -212,13 +208,13 @@ static void ioapic_deliver(struct kvm_ioapic
*ioapic, int irq)
switch (delivery_mode) {
case dest_LowestPrio:
- target =
- kvm_apic_round_robin(ioapic->kvm, vector,
deliver_bitmask);
- if (target != NULL)
- ioapic_inj_irq(ioapic, target, vector,
+ vcpu = kvm_get_lowest_prio_vcpu(ioapic->kvm, vector,
+ deliver_bitmask);
+ if (vcpu != NULL)
+ ioapic_inj_irq(ioapic, vcpu, vector,
trig_mode, delivery_mode);
else
- ioapic_debug("null round robin: "
+ ioapic_debug("null lowest prio vcpu: "
"mask=%x vector=%x
delivery_mode=%x\n",
deliver_bitmask, vector,
dest_LowestPrio);
break;
@@ -229,8 +225,7 @@ static void ioapic_deliver(struct kvm_ioapic
*ioapic, int irq)
deliver_bitmask &= ~(1 << vcpu_id);
vcpu = ioapic->kvm->vcpus[vcpu_id];
if (vcpu) {
- target = vcpu->apic;
- ioapic_inj_irq(ioapic, target, vector,
+ ioapic_inj_irq(ioapic, vcpu, vector,
trig_mode,
delivery_mode);
}
}
@@ -365,6 +360,11 @@ static void ioapic_mmio_write(struct kvm_io_device
*this, gpa_t addr, int len,
case IOAPIC_REG_WINDOW:
ioapic_write_indirect(ioapic, data);
break;
+#ifdef CONFIG_IA64
+ case IOAPIC_REG_EOI:
+ kvm_ioapic_update_eoi(ioapic, data);
+ break;
+#endif
default:
break;
diff --git a/drivers/kvm/irq.h b/drivers/kvm/irq.h
index 5ad3cfd..78a34dd 100644
--- a/drivers/kvm/irq.h
+++ b/drivers/kvm/irq.h
@@ -145,14 +145,15 @@ void kvm_free_lapic(struct kvm_vcpu *vcpu);
u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu);
void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8);
void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value);
-struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
+
+struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector,
unsigned long bitmap);
u64 kvm_get_apic_base(struct kvm_vcpu *vcpu);
void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data);
int kvm_apic_match_physical_addr(struct kvm_lapic *apic, u16 dest);
void kvm_ioapic_update_eoi(struct kvm *kvm, int vector);
int kvm_apic_match_logical_addr(struct kvm_lapic *apic, u8 mda);
-int kvm_apic_set_irq(struct kvm_lapic *apic, u8 vec, u8 trig);
+int kvm_apic_set_irq(struct kvm_vcpu *vcpu, u8 vec, u8 trig);
void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu);
int kvm_ioapic_init(struct kvm *kvm);
void kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level);
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index 64f74bd..5efa6c0 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -185,8 +185,10 @@ int kvm_lapic_find_highest_irr(struct kvm_vcpu
*vcpu)
}
EXPORT_SYMBOL_GPL(kvm_lapic_find_highest_irr);
-int kvm_apic_set_irq(struct kvm_lapic *apic, u8 vec, u8 trig)
+int kvm_apic_set_irq(struct kvm_vcpu *vcpu, u8 vec, u8 trig)
{
+ struct kvm_lapic *apic = vcpu->apic;
+
if (!apic_test_and_set_irr(vec, apic)) {
/* a new pending irq is set in IRR */
if (trig)
@@ -394,7 +396,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic,
int delivery_mode,
return result;
}
-struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
+static struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8
vector,
unsigned long bitmap)
{
int last;
@@ -422,6 +424,17 @@ struct kvm_lapic *kvm_apic_round_robin(struct kvm
*kvm, u8 vector,
return apic;
}
+struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector,
+ unsigned long bitmap)
+{
+ struct kvm_lapic *apic;
+
+ apic = kvm_apic_round_robin(kvm, vector, bitmap);
+ if (apic)
+ return apic->vcpu;
+ return NULL;
+}
+
static void apic_set_eoi(struct kvm_lapic *apic)
{
int vector = apic_find_highest_isr(apic);
@@ -453,7 +466,7 @@ static void apic_send_ipi(struct kvm_lapic *apic)
unsigned int delivery_mode = icr_low & APIC_MODE_MASK;
unsigned int vector = icr_low & APIC_VECTOR_MASK;
- struct kvm_lapic *target;
+ struct kvm_vcpu *target;
struct kvm_vcpu *vcpu;
unsigned long lpr_map = 0;
int i;
@@ -480,9 +493,9 @@ static void apic_send_ipi(struct kvm_lapic *apic)
}
if (delivery_mode == APIC_DM_LOWEST) {
- target = kvm_apic_round_robin(vcpu->kvm, vector,
lpr_map);
+ target = kvm_get_lowest_prio_vcpu(vcpu->kvm, vector,
lpr_map);
if (target != NULL)
- __apic_accept_irq(target, delivery_mode,
+ __apic_accept_irq(target->apic, delivery_mode,
vector, level, trig_mode);
}
}
--
1.5.1.2
[-- Attachment #2: 0003-Clearing-up-the-difference-of-ioapic-and-iosapic.patch --]
[-- Type: application/octet-stream, Size: 6620 bytes --]
From 84ac1af4bad62ba311a1a1cd895a6cb7bc6b1a57 Mon Sep 17 00:00:00 2001
From: Zhang Xiantao <xiantao.zhang@intel.com>
Date: Thu, 29 Nov 2007 18:17:13 +0800
Subject: [PATCH] Clearing up the difference of ioapic and iosapic
Since IA64 uses iosapic, we want to merget it with current ioapic code.
This patch should make x86 and IA64 happy.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
---
drivers/kvm/ioapic.c | 26 +++++++++++++-------------
drivers/kvm/irq.h | 5 +++--
drivers/kvm/lapic.c | 23 ++++++++++++++++++-----
3 files changed, 34 insertions(+), 20 deletions(-)
diff --git a/drivers/kvm/ioapic.c b/drivers/kvm/ioapic.c
index cf1d50b..79c48ec 100644
--- a/drivers/kvm/ioapic.c
+++ b/drivers/kvm/ioapic.c
@@ -36,11 +36,8 @@
#include <linux/hrtimer.h>
#include <linux/io.h>
#include <asm/processor.h>
-#include <asm/msr.h>
#include <asm/page.h>
#include <asm/current.h>
-#include <asm/apicdef.h>
-#include <asm/io_apic.h>
#include "irq.h"
#if 0
#define ioapic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg)
@@ -136,7 +133,7 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)
}
static void ioapic_inj_irq(struct kvm_ioapic *ioapic,
- struct kvm_lapic *target,
+ struct kvm_vcpu *vcpu,
u8 vector, u8 trig_mode, u8 delivery_mode)
{
ioapic_debug("irq %d trig %d deliv %d\n", vector, trig_mode,
@@ -145,7 +142,7 @@ static void ioapic_inj_irq(struct kvm_ioapic *ioapic,
ASSERT((delivery_mode == dest_Fixed) ||
(delivery_mode == dest_LowestPrio));
- kvm_apic_set_irq(target, vector, trig_mode);
+ kvm_apic_set_irq(vcpu, vector, trig_mode);
}
static u32 ioapic_get_delivery_bitmask(struct kvm_ioapic *ioapic, u8 dest,
@@ -196,7 +193,6 @@ static void ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
u8 vector = ioapic->redirtbl[irq].fields.vector;
u8 trig_mode = ioapic->redirtbl[irq].fields.trig_mode;
u32 deliver_bitmask;
- struct kvm_lapic *target;
struct kvm_vcpu *vcpu;
int vcpu_id;
@@ -212,13 +208,13 @@ static void ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
switch (delivery_mode) {
case dest_LowestPrio:
- target =
- kvm_apic_round_robin(ioapic->kvm, vector, deliver_bitmask);
- if (target != NULL)
- ioapic_inj_irq(ioapic, target, vector,
+ vcpu = kvm_get_lowest_prio_vcpu(ioapic->kvm, vector,
+ deliver_bitmask);
+ if (vcpu != NULL)
+ ioapic_inj_irq(ioapic, vcpu, vector,
trig_mode, delivery_mode);
else
- ioapic_debug("null round robin: "
+ ioapic_debug("null lowest prio vcpu: "
"mask=%x vector=%x delivery_mode=%x\n",
deliver_bitmask, vector, dest_LowestPrio);
break;
@@ -229,8 +225,7 @@ static void ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
deliver_bitmask &= ~(1 << vcpu_id);
vcpu = ioapic->kvm->vcpus[vcpu_id];
if (vcpu) {
- target = vcpu->apic;
- ioapic_inj_irq(ioapic, target, vector,
+ ioapic_inj_irq(ioapic, vcpu, vector,
trig_mode, delivery_mode);
}
}
@@ -365,6 +360,11 @@ static void ioapic_mmio_write(struct kvm_io_device *this, gpa_t addr, int len,
case IOAPIC_REG_WINDOW:
ioapic_write_indirect(ioapic, data);
break;
+#ifdef CONFIG_IA64
+ case IOAPIC_REG_EOI:
+ kvm_ioapic_update_eoi(ioapic, data);
+ break;
+#endif
default:
break;
diff --git a/drivers/kvm/irq.h b/drivers/kvm/irq.h
index 5ad3cfd..78a34dd 100644
--- a/drivers/kvm/irq.h
+++ b/drivers/kvm/irq.h
@@ -145,14 +145,15 @@ void kvm_free_lapic(struct kvm_vcpu *vcpu);
u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu);
void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8);
void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value);
-struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
+
+struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector,
unsigned long bitmap);
u64 kvm_get_apic_base(struct kvm_vcpu *vcpu);
void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data);
int kvm_apic_match_physical_addr(struct kvm_lapic *apic, u16 dest);
void kvm_ioapic_update_eoi(struct kvm *kvm, int vector);
int kvm_apic_match_logical_addr(struct kvm_lapic *apic, u8 mda);
-int kvm_apic_set_irq(struct kvm_lapic *apic, u8 vec, u8 trig);
+int kvm_apic_set_irq(struct kvm_vcpu *vcpu, u8 vec, u8 trig);
void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu);
int kvm_ioapic_init(struct kvm *kvm);
void kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level);
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index 64f74bd..5efa6c0 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -185,8 +185,10 @@ int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu)
}
EXPORT_SYMBOL_GPL(kvm_lapic_find_highest_irr);
-int kvm_apic_set_irq(struct kvm_lapic *apic, u8 vec, u8 trig)
+int kvm_apic_set_irq(struct kvm_vcpu *vcpu, u8 vec, u8 trig)
{
+ struct kvm_lapic *apic = vcpu->apic;
+
if (!apic_test_and_set_irr(vec, apic)) {
/* a new pending irq is set in IRR */
if (trig)
@@ -394,7 +396,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
return result;
}
-struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
+static struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
unsigned long bitmap)
{
int last;
@@ -422,6 +424,17 @@ struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
return apic;
}
+struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector,
+ unsigned long bitmap)
+{
+ struct kvm_lapic *apic;
+
+ apic = kvm_apic_round_robin(kvm, vector, bitmap);
+ if (apic)
+ return apic->vcpu;
+ return NULL;
+}
+
static void apic_set_eoi(struct kvm_lapic *apic)
{
int vector = apic_find_highest_isr(apic);
@@ -453,7 +466,7 @@ static void apic_send_ipi(struct kvm_lapic *apic)
unsigned int delivery_mode = icr_low & APIC_MODE_MASK;
unsigned int vector = icr_low & APIC_VECTOR_MASK;
- struct kvm_lapic *target;
+ struct kvm_vcpu *target;
struct kvm_vcpu *vcpu;
unsigned long lpr_map = 0;
int i;
@@ -480,9 +493,9 @@ static void apic_send_ipi(struct kvm_lapic *apic)
}
if (delivery_mode == APIC_DM_LOWEST) {
- target = kvm_apic_round_robin(vcpu->kvm, vector, lpr_map);
+ target = kvm_get_lowest_prio_vcpu(vcpu->kvm, vector, lpr_map);
if (target != NULL)
- __apic_accept_irq(target, delivery_mode,
+ __apic_accept_irq(target->apic, delivery_mode,
vector, level, trig_mode);
}
}
--
1.5.1.2
[-- Attachment #3: Type: text/plain, Size: 309 bytes --]
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] Eliminate the difference of ioapic and iosapic
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA3951B-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-11-30 7:45 ` Avi Kivity
[not found] ` <474FBFAB.7020407-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 11+ messages in thread
From: Avi Kivity @ 2007-11-30 7:45 UTC (permalink / raw)
To: Zhang, Xiantao; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Zhang, Xiantao wrote:
> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Date: Thu, 29 Nov 2007 18:17:13 +0800
> Subject: [PATCH] Clearing up the difference of ioapic and iosapic
> Since IA64 uses iosapic, we want to merget it with current ioapic code.
> This patch should make x86 and IA64 happy.
> Signed-off-by: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
> drivers/kvm/ioapic.c | 26 +++++++++++++-------------
> drivers/kvm/irq.h | 5 +++--
> drivers/kvm/lapic.c | 23 ++++++++++++++++++-----
> 3 files changed, 34 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/kvm/ioapic.c b/drivers/kvm/ioapic.c
> index cf1d50b..79c48ec 100644
> --- a/drivers/kvm/ioapic.c
> +++ b/drivers/kvm/ioapic.c
> @@ -36,11 +36,8 @@
> #include <asm/page.h>
> #include <asm/current.h>
> -#include <asm/apicdef.h>
> -#include <asm/io_apic.h>
>
This will break compilation under certain .configs.
Other than that, the patch is good.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Eliminate the difference of ioapic andiosapic
[not found] ` <474FBFAB.7020407-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-11-30 8:23 ` Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA397B3-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 11+ messages in thread
From: Zhang, Xiantao @ 2007-11-30 8:23 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Avi Kivity wrote:
> Zhang, Xiantao wrote:
>> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>> Date: Thu, 29 Nov 2007 18:17:13 +0800
>> Subject: [PATCH] Clearing up the difference of ioapic and iosapic
>> Since IA64 uses iosapic, we want to merget it with current ioapic
>> code. This patch should make x86 and IA64 happy.
>> Signed-off-by: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> ---
>> drivers/kvm/ioapic.c | 26 +++++++++++++-------------
>> drivers/kvm/irq.h | 5 +++--
>> drivers/kvm/lapic.c | 23 ++++++++++++++++++-----
>> 3 files changed, 34 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/kvm/ioapic.c b/drivers/kvm/ioapic.c
>> index cf1d50b..79c48ec 100644
>> --- a/drivers/kvm/ioapic.c
>> +++ b/drivers/kvm/ioapic.c
>> @@ -36,11 +36,8 @@
>> #include <asm/page.h>
>> #include <asm/current.h>
>> -#include <asm/apicdef.h>
>> -#include <asm/io_apic.h>
>>
>
> This will break compilation under certain .configs.
>
> Other than that, the patch is good.
Can we use the compile option CONFIG_X86 to handle it ?
Xiantao
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Eliminate the difference of ioapic andiosapic
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA397B3-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-11-30 8:32 ` Avi Kivity
[not found] ` <474FCA8C.2090809-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 11+ messages in thread
From: Avi Kivity @ 2007-11-30 8:32 UTC (permalink / raw)
To: Zhang, Xiantao; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Zhang, Xiantao wrote:
> Avi Kivity wrote:
>
>> Zhang, Xiantao wrote:
>>
>>> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>>> Date: Thu, 29 Nov 2007 18:17:13 +0800
>>> Subject: [PATCH] Clearing up the difference of ioapic and iosapic
>>> Since IA64 uses iosapic, we want to merget it with current ioapic
>>> code. This patch should make x86 and IA64 happy.
>>> Signed-off-by: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> ---
>>> drivers/kvm/ioapic.c | 26 +++++++++++++-------------
>>> drivers/kvm/irq.h | 5 +++--
>>> drivers/kvm/lapic.c | 23 ++++++++++++++++++-----
>>> 3 files changed, 34 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/drivers/kvm/ioapic.c b/drivers/kvm/ioapic.c
>>> index cf1d50b..79c48ec 100644
>>> --- a/drivers/kvm/ioapic.c
>>> +++ b/drivers/kvm/ioapic.c
>>> @@ -36,11 +36,8 @@
>>> #include <asm/page.h>
>>> #include <asm/current.h>
>>> -#include <asm/apicdef.h>
>>> -#include <asm/io_apic.h>
>>>
>>>
>> This will break compilation under certain .configs.
>>
>> Other than that, the patch is good.
>>
>
> Can we use the compile option CONFIG_X86 to handle it ?
> Xiantao
>
Sure.
But where does ia64 get its ioapic defines then? Things like
dest_Fixed, I grepped for them in include/asm-ia64 but didn't find them.
Maybe an include/asm-ia64/io_apic.h can provide them?
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Eliminate the difference of ioapic andiosapic
[not found] ` <474FCA8C.2090809-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-11-30 10:22 ` Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA3981F-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 11+ messages in thread
From: Zhang, Xiantao @ 2007-11-30 10:22 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Avi Kivity wrote:
> Zhang, Xiantao wrote:
>> Avi Kivity wrote:
>>
>>> Zhang, Xiantao wrote:
>>>
>>>> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>>>> Date: Thu, 29 Nov 2007 18:17:13 +0800
>>>> Subject: [PATCH] Clearing up the difference of ioapic and iosapic
>>>> Since IA64 uses iosapic, we want to merget it with current ioapic
>>>> code. This patch should make x86 and IA64 happy.
>>>> Signed-off-by: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> ---
>>>> drivers/kvm/ioapic.c | 26 +++++++++++++-------------
>>>> drivers/kvm/irq.h | 5 +++--
>>>> drivers/kvm/lapic.c | 23 ++++++++++++++++++-----
>>>> 3 files changed, 34 insertions(+), 20 deletions(-)
>>>>
>>>> diff --git a/drivers/kvm/ioapic.c b/drivers/kvm/ioapic.c
>>>> index cf1d50b..79c48ec 100644
>>>> --- a/drivers/kvm/ioapic.c
>>>> +++ b/drivers/kvm/ioapic.c
>>>> @@ -36,11 +36,8 @@
>>>> #include <asm/page.h>
>>>> #include <asm/current.h>
>>>> -#include <asm/apicdef.h>
>>>> -#include <asm/io_apic.h>
>>>>
>>>>
>>> This will break compilation under certain .configs.
>>>
>>> Other than that, the patch is good.
>>>
>>
>> Can we use the compile option CONFIG_X86 to handle it ? Xiantao
>>
>
> Sure.
>
> But where does ia64 get its ioapic defines then? Things like
> dest_Fixed, I grepped for them in include/asm-ia64 but didn't find
> them.
>
> Maybe an include/asm-ia64/io_apic.h can provide them?
In IA64, it uses macros to define them for iosapic side. Seems only
io_apic.h should be included for dest_Fixed reference, and apicdef is
not necessary here.
Now, I defined it in IA64-specific head file, (e.g.) ia64.h.
Here, I don't think we can define io_apic.h under asm-ia64, since the
similar definition exists in iosapic.h. Maybe we can removed the
include here, and just define an common macro such kvm_dest_Fixed and
kvm_dest_Low_Prio in irq.h to solve it, and make kvm not dependent of
kernel's head files here. What's your opinion?
Xiantao
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Eliminate the difference of ioapic andiosapic
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA3981F-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-11-30 11:57 ` Avi Kivity
[not found] ` <474FFA8F.7040403-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 11+ messages in thread
From: Avi Kivity @ 2007-11-30 11:57 UTC (permalink / raw)
To: Zhang, Xiantao; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Zhang, Xiantao wrote:
> Avi Kivity wrote:
>
>> Zhang, Xiantao wrote:
>>
>>> Avi Kivity wrote:
>>>
>>>
>>>> Zhang, Xiantao wrote:
>>>>
>>>>
>>>>> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>>>>> Date: Thu, 29 Nov 2007 18:17:13 +0800
>>>>> Subject: [PATCH] Clearing up the difference of ioapic and iosapic
>>>>> Since IA64 uses iosapic, we want to merget it with current ioapic
>>>>> code. This patch should make x86 and IA64 happy.
>>>>> Signed-off-by: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> ---
>>>>> drivers/kvm/ioapic.c | 26 +++++++++++++-------------
>>>>> drivers/kvm/irq.h | 5 +++--
>>>>> drivers/kvm/lapic.c | 23 ++++++++++++++++++-----
>>>>> 3 files changed, 34 insertions(+), 20 deletions(-)
>>>>>
>>>>> diff --git a/drivers/kvm/ioapic.c b/drivers/kvm/ioapic.c
>>>>> index cf1d50b..79c48ec 100644
>>>>> --- a/drivers/kvm/ioapic.c
>>>>> +++ b/drivers/kvm/ioapic.c
>>>>> @@ -36,11 +36,8 @@
>>>>> #include <asm/page.h>
>>>>> #include <asm/current.h>
>>>>> -#include <asm/apicdef.h>
>>>>> -#include <asm/io_apic.h>
>>>>>
>>>>>
>>>>>
>>>> This will break compilation under certain .configs.
>>>>
>>>> Other than that, the patch is good.
>>>>
>>>>
>>> Can we use the compile option CONFIG_X86 to handle it ? Xiantao
>>>
>>>
>> Sure.
>>
>> But where does ia64 get its ioapic defines then? Things like
>> dest_Fixed, I grepped for them in include/asm-ia64 but didn't find
>> them.
>>
>> Maybe an include/asm-ia64/io_apic.h can provide them?
>>
>
> In IA64, it uses macros to define them for iosapic side. Seems only
> io_apic.h should be included for dest_Fixed reference, and apicdef is
> not necessary here.
> Now, I defined it in IA64-specific head file, (e.g.) ia64.h.
> Here, I don't think we can define io_apic.h under asm-ia64, since the
> similar definition exists in iosapic.h. Maybe we can removed the
> include here, and just define an common macro such kvm_dest_Fixed and
> kvm_dest_Low_Prio in irq.h to solve it, and make kvm not dependent of
> kernel's head files here. What's your opinion?
>
Hm... I guess we can have a drivers/kvm/ioapic.h which will contain the
definitions for io[s]apic, and drop the dependency on asm-x86/io_apic.h.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Eliminate the difference of ioapic andiosapic
[not found] ` <474FFA8F.7040403-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-11-30 11:59 ` Zhang, Xiantao
2007-12-02 12:29 ` Zhang, Xiantao
1 sibling, 0 replies; 11+ messages in thread
From: Zhang, Xiantao @ 2007-11-30 11:59 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Avi Kivity wrote:
> Zhang, Xiantao wrote:
>> Avi Kivity wrote:
>>
>>> Zhang, Xiantao wrote:
>>>
>>>> Avi Kivity wrote:
>>>>
>>>>
>>>>> Zhang, Xiantao wrote:
>>>>>
>>>>>
>>>>>> From: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>>>>>> Date: Thu, 29 Nov 2007 18:17:13 +0800
>>>>>> Subject: [PATCH] Clearing up the difference of ioapic and iosapic
>>>>>> Since IA64 uses iosapic, we want to merget it with current ioapic
>>>>>> code. This patch should make x86 and IA64 happy.
>>>>>> Signed-off-by: Zhang Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> ---
>>>>>> drivers/kvm/ioapic.c | 26 +++++++++++++-------------
>>>>>> drivers/kvm/irq.h | 5 +++--
>>>>>> drivers/kvm/lapic.c | 23 ++++++++++++++++++-----
>>>>>> 3 files changed, 34 insertions(+), 20 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/kvm/ioapic.c b/drivers/kvm/ioapic.c
>>>>>> index cf1d50b..79c48ec 100644
>>>>>> --- a/drivers/kvm/ioapic.c
>>>>>> +++ b/drivers/kvm/ioapic.c
>>>>>> @@ -36,11 +36,8 @@
>>>>>> #include <asm/page.h>
>>>>>> #include <asm/current.h>
>>>>>> -#include <asm/apicdef.h>
>>>>>> -#include <asm/io_apic.h>
>>>>>>
>>>>>>
>>>>>>
>>>>> This will break compilation under certain .configs.
>>>>>
>>>>> Other than that, the patch is good.
>>>>>
>>>>>
>>>> Can we use the compile option CONFIG_X86 to handle it ? Xiantao
>>>>
>>>>
>>> Sure.
>>>
>>> But where does ia64 get its ioapic defines then? Things like
>>> dest_Fixed, I grepped for them in include/asm-ia64 but didn't find
>>> them.
>>>
>>> Maybe an include/asm-ia64/io_apic.h can provide them?
>>>
>>
>> In IA64, it uses macros to define them for iosapic side. Seems only
>> io_apic.h should be included for dest_Fixed reference, and apicdef
>> is not necessary here. Now, I defined it in IA64-specific head file,
>> (e.g.) ia64.h.
>> Here, I don't think we can define io_apic.h under asm-ia64, since the
>> similar definition exists in iosapic.h. Maybe we can removed the
>> include here, and just define an common macro such kvm_dest_Fixed and
>> kvm_dest_Low_Prio in irq.h to solve it, and make kvm not dependent of
>> kernel's head files here. What's your opinion?
>>
>
> Hm... I guess we can have a drivers/kvm/ioapic.h which will contain
> the definitions for io[s]apic, and drop the dependency on
> asm-x86/io_apic.h.
Fine. OK, I will update the patch :)
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Eliminate the difference of ioapic andiosapic
[not found] ` <474FFA8F.7040403-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-30 11:59 ` Zhang, Xiantao
@ 2007-12-02 12:29 ` Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA398ED-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
1 sibling, 1 reply; 11+ messages in thread
From: Zhang, Xiantao @ 2007-12-02 12:29 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
[-- Attachment #1: Type: text/plain, Size: 979 bytes --]
Avi Kivity wrote:
> Zhang, Xiantao wrote:
>> Avi Kivity wrote:
>>
>
>> Here, I don't think we can define io_apic.h under asm-ia64, since the
>> similar definition exists in iosapic.h. Maybe we can removed the
>> include here, and just define an common macro such kvm_dest_Fixed and
>> kvm_dest_Low_Prio in irq.h to solve it, and make kvm not dependent of
>> kernel's head files here. What's your opinion?
>>
>
> Hm... I guess we can have a drivers/kvm/ioapic.h which will contain
> the definitions for io[s]apic, and drop the dependency on
> asm-x86/io_apic.h.
Hi Avi,
I didin't create the ioapic.h, since current irq.h has included
most the definitions of ioapic. Maybe we can create it later for irq.h
split. Now, I just put the definition in irq.h for delivery mode. Since
the delivery mode definitions doesn't depend on kernel header files, so
it will avoid possible failures with some special .configs.
Attached the patch.
Thanks
Xiantao
[-- Attachment #2: 0003-Clearing-up-the-difference-of-ioapic-and-iosapic.patch --]
[-- Type: application/octet-stream, Size: 7300 bytes --]
From 583121c5b6c1c1fe229da223ddd22c4969a2d746 Mon Sep 17 00:00:00 2001
From: Zhang Xiantao <xiantao.zhang@intel.com>
Date: Sun, 2 Dec 2007 20:23:02 +0800
Subject: [PATCH] Clearing up the difference of ioapic and iosapic
Since IA64 use iosapic, we want to merget it with current ioapic. This patch should
make x86 and IA64 happy. Use self-defined deliver mode to remove the dependency for kernel's header file.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
---
drivers/kvm/ioapic.c | 34 +++++++++++++++++-----------------
drivers/kvm/irq.h | 13 +++++++++++--
drivers/kvm/lapic.c | 23 ++++++++++++++++++-----
3 files changed, 46 insertions(+), 24 deletions(-)
diff --git a/drivers/kvm/ioapic.c b/drivers/kvm/ioapic.c
index cf1d50b..5618faa 100644
--- a/drivers/kvm/ioapic.c
+++ b/drivers/kvm/ioapic.c
@@ -36,11 +36,8 @@
#include <linux/hrtimer.h>
#include <linux/io.h>
#include <asm/processor.h>
-#include <asm/msr.h>
#include <asm/page.h>
#include <asm/current.h>
-#include <asm/apicdef.h>
-#include <asm/io_apic.h>
#include "irq.h"
#if 0
#define ioapic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg)
@@ -136,16 +133,16 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)
}
static void ioapic_inj_irq(struct kvm_ioapic *ioapic,
- struct kvm_lapic *target,
+ struct kvm_vcpu *vcpu,
u8 vector, u8 trig_mode, u8 delivery_mode)
{
ioapic_debug("irq %d trig %d deliv %d\n", vector, trig_mode,
delivery_mode);
- ASSERT((delivery_mode == dest_Fixed) ||
- (delivery_mode == dest_LowestPrio));
+ ASSERT((delivery_mode == IOAPIC_FIXED) ||
+ (delivery_mode == IOAPIC_LOWEST_PRIORITY));
- kvm_apic_set_irq(target, vector, trig_mode);
+ kvm_apic_set_irq(vcpu, vector, trig_mode);
}
static u32 ioapic_get_delivery_bitmask(struct kvm_ioapic *ioapic, u8 dest,
@@ -196,7 +193,6 @@ static void ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
u8 vector = ioapic->redirtbl[irq].fields.vector;
u8 trig_mode = ioapic->redirtbl[irq].fields.trig_mode;
u32 deliver_bitmask;
- struct kvm_lapic *target;
struct kvm_vcpu *vcpu;
int vcpu_id;
@@ -211,26 +207,25 @@ static void ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
}
switch (delivery_mode) {
- case dest_LowestPrio:
- target =
- kvm_apic_round_robin(ioapic->kvm, vector, deliver_bitmask);
- if (target != NULL)
- ioapic_inj_irq(ioapic, target, vector,
+ case IOAPIC_LOWEST_PRIORITY:
+ vcpu = kvm_get_lowest_prio_vcpu(ioapic->kvm, vector,
+ deliver_bitmask);
+ if (vcpu != NULL)
+ ioapic_inj_irq(ioapic, vcpu, vector,
trig_mode, delivery_mode);
else
- ioapic_debug("null round robin: "
+ ioapic_debug("null lowest prio vcpu: "
"mask=%x vector=%x delivery_mode=%x\n",
deliver_bitmask, vector, dest_LowestPrio);
break;
- case dest_Fixed:
+ case IOAPIC_FIXED:
for (vcpu_id = 0; deliver_bitmask != 0; vcpu_id++) {
if (!(deliver_bitmask & (1 << vcpu_id)))
continue;
deliver_bitmask &= ~(1 << vcpu_id);
vcpu = ioapic->kvm->vcpus[vcpu_id];
if (vcpu) {
- target = vcpu->apic;
- ioapic_inj_irq(ioapic, target, vector,
+ ioapic_inj_irq(ioapic, vcpu, vector,
trig_mode, delivery_mode);
}
}
@@ -365,6 +360,11 @@ static void ioapic_mmio_write(struct kvm_io_device *this, gpa_t addr, int len,
case IOAPIC_REG_WINDOW:
ioapic_write_indirect(ioapic, data);
break;
+#ifdef CONFIG_IA64
+ case IOAPIC_REG_EOI:
+ kvm_ioapic_update_eoi(ioapic, data);
+ break;
+#endif
default:
break;
diff --git a/drivers/kvm/irq.h b/drivers/kvm/irq.h
index 5ad3cfd..032b538 100644
--- a/drivers/kvm/irq.h
+++ b/drivers/kvm/irq.h
@@ -79,6 +79,14 @@ void kvm_pic_update_irq(struct kvm_pic *s);
#define IOAPIC_REG_VERSION 0x01
#define IOAPIC_REG_ARB_ID 0x02 /* x86 IOAPIC only */
+/*ioapic delivery mode*/
+#define IOAPIC_FIXED 0x0
+#define IOAPIC_LOWEST_PRIORITY 0x1
+#define IOAPIC_PMI 0x2
+#define IOAPIC_NMI 0x4
+#define IOAPIC_INIT 0x5
+#define IOAPIC_EXTINT 0x7
+
struct kvm_ioapic {
u64 base_address;
u32 ioregsel;
@@ -145,14 +153,15 @@ void kvm_free_lapic(struct kvm_vcpu *vcpu);
u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu);
void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8);
void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value);
-struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
+
+struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector,
unsigned long bitmap);
u64 kvm_get_apic_base(struct kvm_vcpu *vcpu);
void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data);
int kvm_apic_match_physical_addr(struct kvm_lapic *apic, u16 dest);
void kvm_ioapic_update_eoi(struct kvm *kvm, int vector);
int kvm_apic_match_logical_addr(struct kvm_lapic *apic, u8 mda);
-int kvm_apic_set_irq(struct kvm_lapic *apic, u8 vec, u8 trig);
+int kvm_apic_set_irq(struct kvm_vcpu *vcpu, u8 vec, u8 trig);
void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu);
int kvm_ioapic_init(struct kvm *kvm);
void kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level);
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index 64f74bd..5efa6c0 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -185,8 +185,10 @@ int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu)
}
EXPORT_SYMBOL_GPL(kvm_lapic_find_highest_irr);
-int kvm_apic_set_irq(struct kvm_lapic *apic, u8 vec, u8 trig)
+int kvm_apic_set_irq(struct kvm_vcpu *vcpu, u8 vec, u8 trig)
{
+ struct kvm_lapic *apic = vcpu->apic;
+
if (!apic_test_and_set_irr(vec, apic)) {
/* a new pending irq is set in IRR */
if (trig)
@@ -394,7 +396,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
return result;
}
-struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
+static struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
unsigned long bitmap)
{
int last;
@@ -422,6 +424,17 @@ struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
return apic;
}
+struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector,
+ unsigned long bitmap)
+{
+ struct kvm_lapic *apic;
+
+ apic = kvm_apic_round_robin(kvm, vector, bitmap);
+ if (apic)
+ return apic->vcpu;
+ return NULL;
+}
+
static void apic_set_eoi(struct kvm_lapic *apic)
{
int vector = apic_find_highest_isr(apic);
@@ -453,7 +466,7 @@ static void apic_send_ipi(struct kvm_lapic *apic)
unsigned int delivery_mode = icr_low & APIC_MODE_MASK;
unsigned int vector = icr_low & APIC_VECTOR_MASK;
- struct kvm_lapic *target;
+ struct kvm_vcpu *target;
struct kvm_vcpu *vcpu;
unsigned long lpr_map = 0;
int i;
@@ -480,9 +493,9 @@ static void apic_send_ipi(struct kvm_lapic *apic)
}
if (delivery_mode == APIC_DM_LOWEST) {
- target = kvm_apic_round_robin(vcpu->kvm, vector, lpr_map);
+ target = kvm_get_lowest_prio_vcpu(vcpu->kvm, vector, lpr_map);
if (target != NULL)
- __apic_accept_irq(target, delivery_mode,
+ __apic_accept_irq(target->apic, delivery_mode,
vector, level, trig_mode);
}
}
--
1.5.1.2
[-- Attachment #3: Type: text/plain, Size: 309 bytes --]
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] Eliminate the difference of ioapic andiosapic
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA398ED-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-12-02 12:43 ` Avi Kivity
[not found] ` <4752A859.2040909-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
0 siblings, 1 reply; 11+ messages in thread
From: Avi Kivity @ 2007-12-02 12:43 UTC (permalink / raw)
To: Zhang, Xiantao; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Zhang, Xiantao wrote:
> I didin't create the ioapic.h, since current irq.h has included
> most the definitions of ioapic. Maybe we can create it later for irq.h
> split. Now, I just put the definition in irq.h for delivery mode. Since
> the delivery mode definitions doesn't depend on kernel header files, so
> it will avoid possible failures with some special .configs.
>
Patch looks good, but please split into the dest_* -> IOAPIC_* change,
and the lapic -> vcpu change, since the combined patch is a little big.
--
error compiling committee.c: too many arguments to function
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] Eliminate the difference of ioapic andiosapic
[not found] ` <4752A859.2040909-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2007-12-02 14:57 ` Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA3991B-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 11+ messages in thread
From: Zhang, Xiantao @ 2007-12-02 14:57 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
[-- Attachment #1: Type: text/plain, Size: 625 bytes --]
Avi Kivity wrote:
> Zhang, Xiantao wrote:
>> I didin't create the ioapic.h, since current irq.h has included
>> most the definitions of ioapic. Maybe we can create it later for
>> irq.h split. Now, I just put the definition in irq.h for delivery
>> mode. Since the delivery mode definitions doesn't depend on kernel
>> header files, so it will avoid possible failures with some special
>> .configs.
>>
>
> Patch looks good, but please split into the dest_* -> IOAPIC_* change,
> and the lapic -> vcpu change, since the combined patch is a little
> big.
Done! Attached the patches. :)
Thanks -- Xiantao
[-- Attachment #2: 0005-In-iosapic-it-will-write-EOI-in-software-with-mmio.patch --]
[-- Type: application/octet-stream, Size: 933 bytes --]
From 9ddc666c43c32e09b2ab0d61113bc231c0965fa9 Mon Sep 17 00:00:00 2001
From: Zhang Xiantao <xiantao.zhang@intel.com>
Date: Sun, 2 Dec 2007 22:53:07 +0800
Subject: [PATCH] In iosapic, it will write EOI in software with mmio writing.
In iosapic, it will write EOI in software with mmio writing.
This is the minor different with ioapic.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
---
drivers/kvm/ioapic.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/drivers/kvm/ioapic.c b/drivers/kvm/ioapic.c
index 0feae6f..e7debfa 100644
--- a/drivers/kvm/ioapic.c
+++ b/drivers/kvm/ioapic.c
@@ -360,6 +360,11 @@ static void ioapic_mmio_write(struct kvm_io_device *this, gpa_t addr, int len,
case IOAPIC_REG_WINDOW:
ioapic_write_indirect(ioapic, data);
break;
+#ifdef CONFIG_IA64
+ case IOAPIC_REG_EOI:
+ kvm_ioapic_update_eoi(ioapic, data);
+ break;
+#endif
default:
break;
--
1.5.1.2
[-- Attachment #3: 0003-Using-kvm_vcpu-to-replace-lapic-in-ioapi.c.patch --]
[-- Type: application/octet-stream, Size: 5946 bytes --]
From 9cbf3606fbc19ae4ca0e19196dc5cb7aa4a48c8f Mon Sep 17 00:00:00 2001
From: Zhang Xiantao <xiantao.zhang@intel.com>
Date: Sun, 2 Dec 2007 22:35:57 +0800
Subject: [PATCH] Using kvm_vcpu to replace lapic in ioapi.c
This patch replace lapic structure with kvm_vcpu in ioapic.c, and make ioapic more flexible.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
---
drivers/kvm/ioapic.c | 18 ++++++++----------
drivers/kvm/irq.h | 5 +++--
drivers/kvm/lapic.c | 23 ++++++++++++++++++-----
3 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/drivers/kvm/ioapic.c b/drivers/kvm/ioapic.c
index cf1d50b..3629867 100644
--- a/drivers/kvm/ioapic.c
+++ b/drivers/kvm/ioapic.c
@@ -136,7 +136,7 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)
}
static void ioapic_inj_irq(struct kvm_ioapic *ioapic,
- struct kvm_lapic *target,
+ struct kvm_vcpu *vcpu,
u8 vector, u8 trig_mode, u8 delivery_mode)
{
ioapic_debug("irq %d trig %d deliv %d\n", vector, trig_mode,
@@ -145,7 +145,7 @@ static void ioapic_inj_irq(struct kvm_ioapic *ioapic,
ASSERT((delivery_mode == dest_Fixed) ||
(delivery_mode == dest_LowestPrio));
- kvm_apic_set_irq(target, vector, trig_mode);
+ kvm_apic_set_irq(vcpu, vector, trig_mode);
}
static u32 ioapic_get_delivery_bitmask(struct kvm_ioapic *ioapic, u8 dest,
@@ -196,7 +196,6 @@ static void ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
u8 vector = ioapic->redirtbl[irq].fields.vector;
u8 trig_mode = ioapic->redirtbl[irq].fields.trig_mode;
u32 deliver_bitmask;
- struct kvm_lapic *target;
struct kvm_vcpu *vcpu;
int vcpu_id;
@@ -212,13 +211,13 @@ static void ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
switch (delivery_mode) {
case dest_LowestPrio:
- target =
- kvm_apic_round_robin(ioapic->kvm, vector, deliver_bitmask);
- if (target != NULL)
- ioapic_inj_irq(ioapic, target, vector,
+ vcpu = kvm_get_lowest_prio_vcpu(ioapic->kvm, vector,
+ deliver_bitmask);
+ if (vcpu != NULL)
+ ioapic_inj_irq(ioapic, vcpu, vector,
trig_mode, delivery_mode);
else
- ioapic_debug("null round robin: "
+ ioapic_debug("null lowest prio vcpu: "
"mask=%x vector=%x delivery_mode=%x\n",
deliver_bitmask, vector, dest_LowestPrio);
break;
@@ -229,8 +228,7 @@ static void ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
deliver_bitmask &= ~(1 << vcpu_id);
vcpu = ioapic->kvm->vcpus[vcpu_id];
if (vcpu) {
- target = vcpu->apic;
- ioapic_inj_irq(ioapic, target, vector,
+ ioapic_inj_irq(ioapic, vcpu, vector,
trig_mode, delivery_mode);
}
}
diff --git a/drivers/kvm/irq.h b/drivers/kvm/irq.h
index 5ad3cfd..78a34dd 100644
--- a/drivers/kvm/irq.h
+++ b/drivers/kvm/irq.h
@@ -145,14 +145,15 @@ void kvm_free_lapic(struct kvm_vcpu *vcpu);
u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu);
void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8);
void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value);
-struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
+
+struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector,
unsigned long bitmap);
u64 kvm_get_apic_base(struct kvm_vcpu *vcpu);
void kvm_set_apic_base(struct kvm_vcpu *vcpu, u64 data);
int kvm_apic_match_physical_addr(struct kvm_lapic *apic, u16 dest);
void kvm_ioapic_update_eoi(struct kvm *kvm, int vector);
int kvm_apic_match_logical_addr(struct kvm_lapic *apic, u8 mda);
-int kvm_apic_set_irq(struct kvm_lapic *apic, u8 vec, u8 trig);
+int kvm_apic_set_irq(struct kvm_vcpu *vcpu, u8 vec, u8 trig);
void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu);
int kvm_ioapic_init(struct kvm *kvm);
void kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level);
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index 64f74bd..5efa6c0 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -185,8 +185,10 @@ int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu)
}
EXPORT_SYMBOL_GPL(kvm_lapic_find_highest_irr);
-int kvm_apic_set_irq(struct kvm_lapic *apic, u8 vec, u8 trig)
+int kvm_apic_set_irq(struct kvm_vcpu *vcpu, u8 vec, u8 trig)
{
+ struct kvm_lapic *apic = vcpu->apic;
+
if (!apic_test_and_set_irr(vec, apic)) {
/* a new pending irq is set in IRR */
if (trig)
@@ -394,7 +396,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
return result;
}
-struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
+static struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
unsigned long bitmap)
{
int last;
@@ -422,6 +424,17 @@ struct kvm_lapic *kvm_apic_round_robin(struct kvm *kvm, u8 vector,
return apic;
}
+struct kvm_vcpu *kvm_get_lowest_prio_vcpu(struct kvm *kvm, u8 vector,
+ unsigned long bitmap)
+{
+ struct kvm_lapic *apic;
+
+ apic = kvm_apic_round_robin(kvm, vector, bitmap);
+ if (apic)
+ return apic->vcpu;
+ return NULL;
+}
+
static void apic_set_eoi(struct kvm_lapic *apic)
{
int vector = apic_find_highest_isr(apic);
@@ -453,7 +466,7 @@ static void apic_send_ipi(struct kvm_lapic *apic)
unsigned int delivery_mode = icr_low & APIC_MODE_MASK;
unsigned int vector = icr_low & APIC_VECTOR_MASK;
- struct kvm_lapic *target;
+ struct kvm_vcpu *target;
struct kvm_vcpu *vcpu;
unsigned long lpr_map = 0;
int i;
@@ -480,9 +493,9 @@ static void apic_send_ipi(struct kvm_lapic *apic)
}
if (delivery_mode == APIC_DM_LOWEST) {
- target = kvm_apic_round_robin(vcpu->kvm, vector, lpr_map);
+ target = kvm_get_lowest_prio_vcpu(vcpu->kvm, vector, lpr_map);
if (target != NULL)
- __apic_accept_irq(target, delivery_mode,
+ __apic_accept_irq(target->apic, delivery_mode,
vector, level, trig_mode);
}
}
--
1.5.1.2
[-- Attachment #4: 0004-Replace-dest_Lowest_Prio-and-dest_Fixed-with-self-de.patch --]
[-- Type: application/octet-stream, Size: 2710 bytes --]
From 2c5db5064a39f783c712b0018e0b68ecc482ae41 Mon Sep 17 00:00:00 2001
From: Zhang Xiantao <xiantao.zhang@intel.com>
Date: Sun, 2 Dec 2007 22:49:09 +0800
Subject: [PATCH] Replace dest_Lowest_Prio and dest_Fixed with self-defined macros.
Using self-defined macros to remove the dependecies to kernel header files.
dest_Loest_Prio-> IOAPIC_LOWEST_PRIORITY
dest_Fixed-> IOAPIC_FIXED.
Signed-off-by: Zhang Xiantao <xiantao.zhang@intel.com>
---
drivers/kvm/ioapic.c | 13 +++++--------
drivers/kvm/irq.h | 8 ++++++++
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/kvm/ioapic.c b/drivers/kvm/ioapic.c
index 3629867..0feae6f 100644
--- a/drivers/kvm/ioapic.c
+++ b/drivers/kvm/ioapic.c
@@ -36,11 +36,8 @@
#include <linux/hrtimer.h>
#include <linux/io.h>
#include <asm/processor.h>
-#include <asm/msr.h>
#include <asm/page.h>
#include <asm/current.h>
-#include <asm/apicdef.h>
-#include <asm/io_apic.h>
#include "irq.h"
#if 0
#define ioapic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg)
@@ -142,8 +139,8 @@ static void ioapic_inj_irq(struct kvm_ioapic *ioapic,
ioapic_debug("irq %d trig %d deliv %d\n", vector, trig_mode,
delivery_mode);
- ASSERT((delivery_mode == dest_Fixed) ||
- (delivery_mode == dest_LowestPrio));
+ ASSERT((delivery_mode == IOAPIC_FIXED) ||
+ (delivery_mode == IOAPIC_LOWEST_PRIORITY));
kvm_apic_set_irq(vcpu, vector, trig_mode);
}
@@ -210,7 +207,7 @@ static void ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
}
switch (delivery_mode) {
- case dest_LowestPrio:
+ case IOAPIC_LOWEST_PRIORITY:
vcpu = kvm_get_lowest_prio_vcpu(ioapic->kvm, vector,
deliver_bitmask);
if (vcpu != NULL)
@@ -219,9 +216,9 @@ static void ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
else
ioapic_debug("null lowest prio vcpu: "
"mask=%x vector=%x delivery_mode=%x\n",
- deliver_bitmask, vector, dest_LowestPrio);
+ deliver_bitmask, vector, IOAPIC_LOWEST_PRIORITY);
break;
- case dest_Fixed:
+ case IOAPIC_FIXED:
for (vcpu_id = 0; deliver_bitmask != 0; vcpu_id++) {
if (!(deliver_bitmask & (1 << vcpu_id)))
continue;
diff --git a/drivers/kvm/irq.h b/drivers/kvm/irq.h
index 78a34dd..75f5f18 100644
--- a/drivers/kvm/irq.h
+++ b/drivers/kvm/irq.h
@@ -79,6 +79,14 @@ void kvm_pic_update_irq(struct kvm_pic *s);
#define IOAPIC_REG_VERSION 0x01
#define IOAPIC_REG_ARB_ID 0x02 /* x86 IOAPIC only */
+/*ioapic delivery mode*/
+#define IOAPIC_FIXED 0x0
+#define IOAPIC_LOWEST_PRIORITY 0x1
+#define IOAPIC_PMI 0x2
+#define IOAPIC_NMI 0x4
+#define IOAPIC_INIT 0x5
+#define IOAPIC_EXTINT 0x7
+
struct kvm_ioapic {
u64 base_address;
u32 ioregsel;
--
1.5.1.2
[-- Attachment #5: Type: text/plain, Size: 309 bytes --]
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
[-- Attachment #6: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] Eliminate the difference of ioapic andiosapic
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA3991B-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2007-12-02 20:35 ` Avi Kivity
0 siblings, 0 replies; 11+ messages in thread
From: Avi Kivity @ 2007-12-02 20:35 UTC (permalink / raw)
To: Zhang, Xiantao; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
Zhang, Xiantao wrote:
> Avi Kivity wrote:
>
>> Zhang, Xiantao wrote:
>>
>>> I didin't create the ioapic.h, since current irq.h has included
>>> most the definitions of ioapic. Maybe we can create it later for
>>> irq.h split. Now, I just put the definition in irq.h for delivery
>>> mode. Since the delivery mode definitions doesn't depend on kernel
>>> header files, so it will avoid possible failures with some special
>>> .configs.
>>>
>>>
>> Patch looks good, but please split into the dest_* -> IOAPIC_* change,
>> and the lapic -> vcpu change, since the combined patch is a little
>> big.
>>
> Done! Attached the patches. :)
>
Applied all; thanks. But please use git-send-email to send patches,
they're easier to review that way.
--
Any sufficiently difficult bug is indistinguishable from a feature.
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2007-12-02 20:35 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-29 10:25 [PATCH] Eliminate the difference of ioapic and iosapic Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA3951B-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-30 7:45 ` Avi Kivity
[not found] ` <474FBFAB.7020407-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-30 8:23 ` [PATCH] Eliminate the difference of ioapic andiosapic Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA397B3-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-30 8:32 ` Avi Kivity
[not found] ` <474FCA8C.2090809-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-30 10:22 ` Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA3981F-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-30 11:57 ` Avi Kivity
[not found] ` <474FFA8F.7040403-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-30 11:59 ` Zhang, Xiantao
2007-12-02 12:29 ` Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA398ED-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-12-02 12:43 ` Avi Kivity
[not found] ` <4752A859.2040909-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-12-02 14:57 ` Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA3991B-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-12-02 20:35 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox