aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2007-09-05 11:21:32 -0400
committerAvi Kivity <avi@qumranet.com>2007-10-13 04:18:27 -0400
commit1747fb71fd7c9389696e91f354d2f841b5c85790 (patch)
tree8c0658884e62693a94c2ebd35f83331ffa083a7d /drivers/kvm
parent81f50e3bfdf864103ef890ca156e7a9c922c7089 (diff)
KVM: Hoist SVM's get_cs_db_l_bits into core code.
SVM gets the DB and L bits for the cs by decoding the segment. This is in fact the completely generic code, so hoist it for kvm-lite to use. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm')
-rw-r--r--drivers/kvm/kvm.h1
-rw-r--r--drivers/kvm/kvm_main.c10
-rw-r--r--drivers/kvm/svm.c10
3 files changed, 12 insertions, 9 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 9bf9ac6389b1..ee9f8bdee755 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -586,6 +586,7 @@ void set_cr4(struct kvm_vcpu *vcpu, unsigned long cr0);
586void set_cr8(struct kvm_vcpu *vcpu, unsigned long cr0); 586void set_cr8(struct kvm_vcpu *vcpu, unsigned long cr0);
587unsigned long get_cr8(struct kvm_vcpu *vcpu); 587unsigned long get_cr8(struct kvm_vcpu *vcpu);
588void lmsw(struct kvm_vcpu *vcpu, unsigned long msw); 588void lmsw(struct kvm_vcpu *vcpu, unsigned long msw);
589void kvm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l);
589 590
590int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata); 591int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata);
591int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data); 592int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data);
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 7341c0949340..9dffbbea46a7 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -2270,6 +2270,16 @@ static int kvm_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
2270 return 0; 2270 return 0;
2271} 2271}
2272 2272
2273void kvm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l)
2274{
2275 struct kvm_segment cs;
2276
2277 get_segment(vcpu, &cs, VCPU_SREG_CS);
2278 *db = cs.db;
2279 *l = cs.l;
2280}
2281EXPORT_SYMBOL_GPL(kvm_get_cs_db_l_bits);
2282
2273/* 2283/*
2274 * List of msr numbers which we expose to userspace through KVM_GET_MSRS 2284 * List of msr numbers which we expose to userspace through KVM_GET_MSRS
2275 * and KVM_SET_MSRS, and KVM_GET_MSR_INDEX_LIST. 2285 * and KVM_SET_MSRS, and KVM_GET_MSR_INDEX_LIST.
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index e51f6b7f8ff3..35f3f83b5c6c 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -724,14 +724,6 @@ static void svm_get_segment(struct kvm_vcpu *vcpu,
724 var->unusable = !var->present; 724 var->unusable = !var->present;
725} 725}
726 726
727static void svm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l)
728{
729 struct vmcb_seg *s = svm_seg(vcpu, VCPU_SREG_CS);
730
731 *db = (s->attrib >> SVM_SELECTOR_DB_SHIFT) & 1;
732 *l = (s->attrib >> SVM_SELECTOR_L_SHIFT) & 1;
733}
734
735static void svm_get_idt(struct kvm_vcpu *vcpu, struct descriptor_table *dt) 727static void svm_get_idt(struct kvm_vcpu *vcpu, struct descriptor_table *dt)
736{ 728{
737 struct vcpu_svm *svm = to_svm(vcpu); 729 struct vcpu_svm *svm = to_svm(vcpu);
@@ -1771,7 +1763,7 @@ static struct kvm_arch_ops svm_arch_ops = {
1771 .get_segment_base = svm_get_segment_base, 1763 .get_segment_base = svm_get_segment_base,
1772 .get_segment = svm_get_segment, 1764 .get_segment = svm_get_segment,
1773 .set_segment = svm_set_segment, 1765 .set_segment = svm_set_segment,
1774 .get_cs_db_l_bits = svm_get_cs_db_l_bits, 1766 .get_cs_db_l_bits = kvm_get_cs_db_l_bits,
1775 .decache_cr4_guest_bits = svm_decache_cr4_guest_bits, 1767 .decache_cr4_guest_bits = svm_decache_cr4_guest_bits,
1776 .set_cr0 = svm_set_cr0, 1768 .set_cr0 = svm_set_cr0,
1777 .set_cr3 = svm_set_cr3, 1769 .set_cr3 = svm_set_cr3,