KVM: remove status in kvm_lapic structure
status is a redundancy to apic spurious vector, it's not needed.
Removing it
also reduces the states that should be saved.
Signed-off-by: Yaozu (Eddie) Dong <[EMAIL PROTECTED]>
Signed-off-by: Qing He <[EMAIL PROTECTED]>
---
drivers/kvm/irq.h | 1 -
drivers/kvm/lapic.c | 29 ++++++++++++-----------------
2 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/drivers/kvm/irq.h b/drivers/kvm/irq.h
index 700db5e..9e184d7 100644
--- a/drivers/kvm/irq.h
+++ b/drivers/kvm/irq.h
@@ -106,7 +106,6 @@ struct kvm_ioapic {
struct kvm_lapic {
spinlock_t lock; /* TODO for revise */
- u32 status;
unsigned long base_address;
struct kvm_io_device dev;
struct {
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index ca592b7..b198434 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -50,12 +50,20 @@
#define APIC_SHORT_MASK 0xc0000
#define APIC_DEST_NOSHORT 0x0
#define APIC_DEST_MASK 0x800
-#define _APIC_SW_DISABLE 0
-#define APIC_SW_DISABLE (1 << _APIC_SW_DISABLE)
#define MAX_APIC_VECTOR 256
#define VEC_POS(v) ((v) & (32 - 1))
#define REG_POS(v) (((v) >> 5) << 4)
+static inline u32 apic_get_reg(struct kvm_lapic *apic, int reg_off)
+{
+ return *((u32 *) (apic->regs + reg_off));
+}
+
+static inline void apic_set_reg(struct kvm_lapic *apic, int reg_off,
u32 val)
+{
+ *((u32 *) (apic->regs + reg_off)) = val;
+}
+
static inline int apic_test_and_set_vector(int vec, void *bitmap)
{
return test_and_set_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));
@@ -83,7 +91,7 @@ static inline int apic_hw_enabled(struct kvm_lapic
*apic)
static inline int apic_sw_enabled(struct kvm_lapic *apic)
{
- return !((apic)->status & APIC_SW_DISABLE);
+ return apic_get_reg(apic, APIC_SPIV) & APIC_SPIV_APIC_ENABLED;
}
static inline int apic_enabled(struct kvm_lapic *apic)
@@ -98,16 +106,6 @@ static inline int apic_enabled(struct kvm_lapic
*apic)
(LVT_MASK | APIC_MODE_MASK | APIC_INPUT_POLARITY | \
APIC_LVT_REMOTE_IRR | APIC_LVT_LEVEL_TRIGGER)
-static inline u32 apic_get_reg(struct kvm_lapic *apic, int reg_off)
-{
- return *((u32 *) (apic->regs + reg_off));
-}
-
-static inline void apic_set_reg(struct kvm_lapic *apic, int reg_off,
u32 val)
-{
- *((u32 *) (apic->regs + reg_off)) = val;
-}
-
static inline int kvm_apic_id(struct kvm_lapic *apic)
{
return GET_APIC_ID(apic_get_reg(apic, APIC_ID));
@@ -592,7 +590,6 @@ static void apic_mmio_write(struct kvm_io_device
*this,
int i;
u32 lvt_val;
- apic->status |= APIC_SW_DISABLE;
for (i = 0; i < APIC_LVT_NUM; i++) {
lvt_val = apic_get_reg(apic,
APIC_LVTT + 0x10
* i);
@@ -600,8 +597,7 @@ static void apic_mmio_write(struct kvm_io_device
*this,
lvt_val | APIC_LVT_MASKED);
}
- } else
- apic->status &= ~APIC_SW_DISABLE;
+ }
break;
case APIC_ICR:
@@ -825,7 +821,6 @@ static void lapic_reset(struct kvm_vcpu *vcpu)
}
apic->timer.divide_count = 0;
apic->timer.pending = 0;
- apic->status = APIC_SW_DISABLE;
if (vcpu->vcpu_id == 0)
vcpu->apic_base |= MSR_IA32_APICBASE_BSP;
apic_update_ppr(apic);
kvm-kern-lapic-remove-status.patch
Description: kvm-kern-lapic-remove-status.patch
------------------------------------------------------------------------- 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/
_______________________________________________ kvm-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/kvm-devel
