diff mbox

x86: use kvm_read/write_guest_virt for reading and writing segment descriptors

Message ID 6f9242d20908101011t2df862e7l8f35615c7dbb90ea@mail.gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mikhail Ershov Aug. 10, 2009, 5:11 p.m. UTC
Descriptor table can be placed on two non-contiguous pages.
It is better to read descriptor by linear address.

Signed-off-by: Mikhail Ershov <Mike.Ershov@gmail.com>
---
 arch/x86/kvm/x86.c |   10 ++--------
 1 files changed, 2 insertions(+), 8 deletions(-)


@@ -4027,16 +4026,13 @@ static int
load_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,
        kvm_queue_exception_e(vcpu, GP_VECTOR, selector & 0xfffc);
        return 1;
    }
-   gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, dtable.base);
-   gpa += index * 8;
-   return kvm_read_guest(vcpu->kvm, gpa, seg_desc, 8);
+   return kvm_read_guest_virt(dtable.base + index*8, seg_desc,
sizeof(*seg_desc), vcpu);
 }

 /* allowed just for 8 bytes segments */
 static int save_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,
                     struct desc_struct *seg_desc)
 {
-   gpa_t gpa;
    struct descriptor_table dtable;
    u16 index = selector >> 3;

@@ -4044,9 +4040,7 @@ static int save_guest_segment_descriptor(struct
kvm_vcpu *vcpu, u16 selector,

    if (dtable.limit < index * 8 + 7)
        return 1;
-   gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, dtable.base);
-   gpa += index * 8;
-   return kvm_write_guest(vcpu->kvm, gpa, seg_desc, 8);
+   return kvm_write_guest_virt(dtable.base + index*8, seg_desc,
sizeof(*seg_desc), vcpu);
 }

 static u32 get_tss_base_addr(struct kvm_vcpu *vcpu,

Comments

Avi Kivity Aug. 16, 2009, 12:04 p.m. UTC | #1
On 08/10/2009 08:11 PM, Mikhail Ershov wrote:
> Descriptor table can be placed on two non-contiguous pages.
> It is better to read descriptor by linear address.
>    

Patch is good, but is whitespace-corrupted.  Please send as an 
attachment (or using git-send-email).

Make sure the attachment is plain/text so mail clients can display it 
inline.
diff mbox

Patch

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 850cf56..13f39bb 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4017,7 +4017,6 @@  static void get_segment_descriptor_dtable(struct
kvm_vcpu *vcpu,
 static int load_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,
                     struct desc_struct *seg_desc)
 {
-   gpa_t gpa;
    struct descriptor_table dtable;
    u16 index = selector >> 3;