* [PATCH][Rebased LAPIC5] Reading PPR directly from function rather than apic page
@ 2007-08-21 6:23 Yang, Sheng
[not found] ` <DB3BD37E3533EE46BED2FBA80995557F7056AC-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Yang, Sheng @ 2007-08-21 6:23 UTC (permalink / raw)
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
[-- Attachment #1: Type: text/plain, Size: 3302 bytes --]
After introducing TPR shadow, many TPR change won't cause vmexit, so the
present method of updating PPR can't catch it. Though we can also update
PPR
everytime when we want to read PPR, it's somehow ugly.
Because there are only two places need reading PPR, and PPR is
read-only, we
do it in more clear way. Now the apic_update_PPR() have been replaced by
apic_get_PPR() which returned current PPR, and we read the PPR directly
from
the function when we need it, rather than reading from apic page.
Signed-off-by: Sheng Yang <sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Notice: This patch based on the rebased lapic5, for the current lapic5
is broken...
---
drivers/kvm/lapic.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index 98a3719..ee3a552 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -192,7 +192,7 @@ static inline int apic_find_highest_isr(struct
kvm_lapic *apic)
return result;
}
-static void apic_update_ppr(struct kvm_lapic *apic)
+static u32 apic_get_ppr(struct kvm_lapic *apic)
{
u32 tpr, isrv, ppr;
int isr;
@@ -209,13 +209,12 @@ static void apic_update_ppr(struct kvm_lapic
*apic)
apic_debug("vlapic %p, ppr 0x%x, isr 0x%x, isrv 0x%x",
apic, ppr, isr, isrv);
- apic_set_reg(apic, APIC_PROCPRI, ppr);
+ return ppr;
}
static void apic_set_tpr(struct kvm_lapic *apic, u32 tpr)
{
apic_set_reg(apic, APIC_TASKPRI, tpr);
- apic_update_ppr(apic);
}
int kvm_apic_match_physical_addr(struct kvm_lapic *apic, u16 dest)
@@ -386,7 +385,6 @@ static void apic_set_eoi(struct kvm_lapic *apic)
return;
apic_clear_vector(vector, apic->regs + APIC_ISR);
- apic_update_ppr(apic);
if (apic_test_and_clear_vector(vector, apic->regs + APIC_TMR))
kvm_ioapic_update_eoi(apic->vcpu->kvm, vector);
@@ -486,6 +484,10 @@ static u32 __apic_read(struct kvm_lapic *apic,
unsigned int offset)
return 0;
switch (offset) {
+ case APIC_PROCPRI:
+ val = apic_get_ppr(apic);
+ break;
+
case APIC_ARBPRI:
printk(KERN_WARNING "Access APIC ARBPRI register "
"which is for P6\n");
@@ -823,7 +825,6 @@ static void lapic_reset(struct kvm_vcpu *vcpu)
apic->timer.pending = 0;
if (vcpu->vcpu_id == 0)
vcpu->apic_base |= MSR_IA32_APICBASE_BSP;
- apic_update_ppr(apic);
spin_unlock_bh(&apic->lock);
@@ -965,7 +966,7 @@ int kvm_apic_has_interrupt(struct kvm_vcpu *vcpu)
highest_irr = apic_find_highest_irr(apic);
if ((highest_irr == -1) ||
- ((highest_irr & 0xF0) <= apic_get_reg(apic, APIC_PROCPRI)))
+ ((highest_irr & 0xF0) <= apic_get_ppr(apic)))
return -1;
return highest_irr;
}
@@ -979,7 +980,6 @@ int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu)
return -1;
apic_set_vector(vector, apic->regs + APIC_ISR);
- apic_update_ppr(apic);
apic_clear_irr(vector, apic);
return vector;
}
@@ -995,7 +995,6 @@ void kvm_apic_post_state_restore(struct kvm_vcpu
*vcpu)
apic_set_reg(apic, APIC_LVR, APIC_VERSION);
val = apic_get_reg(apic, APIC_TMICT);
apic_set_reg(apic, APIC_TMCCT, val);
- apic_update_ppr(apic);
/* TODO: following code can be in a common API */
spin_lock_bh(&apic->lock);
--
1.5.2
[-- Attachment #2: Reading-PPR-directly-from-function-rather-than-apic.patch --]
[-- Type: application/octet-stream, Size: 3306 bytes --]
From 4bd3dfecdbcc76c25249b5767308165e492bfa93 Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Tue, 21 Aug 2007 14:02:01 +0800
Subject: [PATCH] Reading PPR directly from function rather than apic page
After introducing TPR shadow, many TPR change won't cause vmexit, so the
present method of updating PPR can't catch it. Though we can also update PPR
everytime when we want to read PPR, it's somehow ugly.
Because there are only two places need reading PPR, and PPR is read-only, we
do it in more clear way. Now the apic_update_PPR() have been replaced by
apic_get_PPR() which returned current PPR, and we read the PPR directly from
the function when we need it, rather than reading from apic page.
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
drivers/kvm/lapic.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index 98a3719..ee3a552 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -192,7 +192,7 @@ static inline int apic_find_highest_isr(struct kvm_lapic *apic)
return result;
}
-static void apic_update_ppr(struct kvm_lapic *apic)
+static u32 apic_get_ppr(struct kvm_lapic *apic)
{
u32 tpr, isrv, ppr;
int isr;
@@ -209,13 +209,12 @@ static void apic_update_ppr(struct kvm_lapic *apic)
apic_debug("vlapic %p, ppr 0x%x, isr 0x%x, isrv 0x%x",
apic, ppr, isr, isrv);
- apic_set_reg(apic, APIC_PROCPRI, ppr);
+ return ppr;
}
static void apic_set_tpr(struct kvm_lapic *apic, u32 tpr)
{
apic_set_reg(apic, APIC_TASKPRI, tpr);
- apic_update_ppr(apic);
}
int kvm_apic_match_physical_addr(struct kvm_lapic *apic, u16 dest)
@@ -386,7 +385,6 @@ static void apic_set_eoi(struct kvm_lapic *apic)
return;
apic_clear_vector(vector, apic->regs + APIC_ISR);
- apic_update_ppr(apic);
if (apic_test_and_clear_vector(vector, apic->regs + APIC_TMR))
kvm_ioapic_update_eoi(apic->vcpu->kvm, vector);
@@ -486,6 +484,10 @@ static u32 __apic_read(struct kvm_lapic *apic, unsigned int offset)
return 0;
switch (offset) {
+ case APIC_PROCPRI:
+ val = apic_get_ppr(apic);
+ break;
+
case APIC_ARBPRI:
printk(KERN_WARNING "Access APIC ARBPRI register "
"which is for P6\n");
@@ -823,7 +825,6 @@ static void lapic_reset(struct kvm_vcpu *vcpu)
apic->timer.pending = 0;
if (vcpu->vcpu_id == 0)
vcpu->apic_base |= MSR_IA32_APICBASE_BSP;
- apic_update_ppr(apic);
spin_unlock_bh(&apic->lock);
@@ -965,7 +966,7 @@ int kvm_apic_has_interrupt(struct kvm_vcpu *vcpu)
highest_irr = apic_find_highest_irr(apic);
if ((highest_irr == -1) ||
- ((highest_irr & 0xF0) <= apic_get_reg(apic, APIC_PROCPRI)))
+ ((highest_irr & 0xF0) <= apic_get_ppr(apic)))
return -1;
return highest_irr;
}
@@ -979,7 +980,6 @@ int kvm_get_apic_interrupt(struct kvm_vcpu *vcpu)
return -1;
apic_set_vector(vector, apic->regs + APIC_ISR);
- apic_update_ppr(apic);
apic_clear_irr(vector, apic);
return vector;
}
@@ -995,7 +995,6 @@ void kvm_apic_post_state_restore(struct kvm_vcpu *vcpu)
apic_set_reg(apic, APIC_LVR, APIC_VERSION);
val = apic_get_reg(apic, APIC_TMICT);
apic_set_reg(apic, APIC_TMCCT, val);
- apic_update_ppr(apic);
/* TODO: following code can be in a common API */
spin_lock_bh(&apic->lock);
--
1.5.2
[-- Attachment #3: Type: text/plain, Size: 315 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
[-- 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] 3+ messages in thread
end of thread, other threads:[~2007-08-22 7:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-21 6:23 [PATCH][Rebased LAPIC5] Reading PPR directly from function rather than apic page Yang, Sheng
[not found] ` <DB3BD37E3533EE46BED2FBA80995557F7056AC-wq7ZOvIWXbM/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-08-21 12:37 ` Avi Kivity
[not found] ` <46CADC6F.8060708-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-08-22 7:56 ` Yang, Sheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox