diff options
author | Mikhail Ershov <Mike.Ershov@gmail.com> | 2009-08-19 06:08:07 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-09-10 03:46:52 -0400 |
commit | d9048d3278ed4d395e63899257c3fa377693968b (patch) | |
tree | 8a1b95d5bb939690ab03513efcc6cd4bff9ab923 /arch/x86/kvm | |
parent | 7bdb588827265bf42dd420e95d34275c83603568 (diff) |
KVM: Use kvm_{read,write}_guest_virt() to read and write segment descriptors
Segment descriptors tables can be placed on two non-contiguous pages.
This patch makes reading segment descriptors by linear address.
Signed-off-by: Mikhail Ershov <Mike.Ershov@gmail.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/x86.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c0e942747b0f..59a8ba4d56bd 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -4021,7 +4021,6 @@ static void get_segment_descriptor_dtable(struct kvm_vcpu *vcpu, | |||
4021 | static int load_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, | 4021 | static int load_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, |
4022 | struct desc_struct *seg_desc) | 4022 | struct desc_struct *seg_desc) |
4023 | { | 4023 | { |
4024 | gpa_t gpa; | ||
4025 | struct descriptor_table dtable; | 4024 | struct descriptor_table dtable; |
4026 | u16 index = selector >> 3; | 4025 | u16 index = selector >> 3; |
4027 | 4026 | ||
@@ -4031,16 +4030,13 @@ static int load_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, | |||
4031 | kvm_queue_exception_e(vcpu, GP_VECTOR, selector & 0xfffc); | 4030 | kvm_queue_exception_e(vcpu, GP_VECTOR, selector & 0xfffc); |
4032 | return 1; | 4031 | return 1; |
4033 | } | 4032 | } |
4034 | gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, dtable.base); | 4033 | return kvm_read_guest_virt(dtable.base + index*8, seg_desc, sizeof(*seg_desc), vcpu); |
4035 | gpa += index * 8; | ||
4036 | return kvm_read_guest(vcpu->kvm, gpa, seg_desc, 8); | ||
4037 | } | 4034 | } |
4038 | 4035 | ||
4039 | /* allowed just for 8 bytes segments */ | 4036 | /* allowed just for 8 bytes segments */ |
4040 | static int save_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, | 4037 | static int save_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, |
4041 | struct desc_struct *seg_desc) | 4038 | struct desc_struct *seg_desc) |
4042 | { | 4039 | { |
4043 | gpa_t gpa; | ||
4044 | struct descriptor_table dtable; | 4040 | struct descriptor_table dtable; |
4045 | u16 index = selector >> 3; | 4041 | u16 index = selector >> 3; |
4046 | 4042 | ||
@@ -4048,9 +4044,7 @@ static int save_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, | |||
4048 | 4044 | ||
4049 | if (dtable.limit < index * 8 + 7) | 4045 | if (dtable.limit < index * 8 + 7) |
4050 | return 1; | 4046 | return 1; |
4051 | gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, dtable.base); | 4047 | return kvm_write_guest_virt(dtable.base + index*8, seg_desc, sizeof(*seg_desc), vcpu); |
4052 | gpa += index * 8; | ||
4053 | return kvm_write_guest(vcpu->kvm, gpa, seg_desc, 8); | ||
4054 | } | 4048 | } |
4055 | 4049 | ||
4056 | static u32 get_tss_base_addr(struct kvm_vcpu *vcpu, | 4050 | static u32 get_tss_base_addr(struct kvm_vcpu *vcpu, |