From patchwork Thu Jul 8 14:10:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammed Gamal X-Patchwork-Id: 110858 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o68EB7WZ018609 for ; Thu, 8 Jul 2010 14:11:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757507Ab0GHOLE (ORCPT ); Thu, 8 Jul 2010 10:11:04 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:54474 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755856Ab0GHOLC (ORCPT ); Thu, 8 Jul 2010 10:11:02 -0400 Received: by mail-bw0-f46.google.com with SMTP id 1so456893bwz.19 for ; Thu, 08 Jul 2010 07:11:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=IQR+blHVADt3h5SeZk4oAA+Ytv2R3TEK1KyMR0ctczI=; b=eYPVWQ8PndjH680x8/tji4+KWAXDWPD6He0f6YRxrG9WK2kATrjfSenziTLxig94Qr zLIH8rzSG2SEPkrfeLEa2xULHyvAUjFJr+h6WeKH6ZJ6OXv9RY+jd6N965i0h5nGuElQ bRuTR6ve6fY58D+se5LEQnV1Ma0SCgD3xcNFY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=OaP4jWTB833MBFiWscKLdLReVHgnxIf53Po42Lv9p5IIzYsuJ9GWfii9e9bvx96S/Y KqAleglwDY/sNRbMtjQHxgYYmeqvQBNgMZiEp8N2h8blr26n+AWpxZexKwoz1JUClUna LKpbLLtTv5ohTko6tvoTctxjv27wg0nVuNQT8= Received: by 10.204.46.73 with SMTP id i9mr1358540bkf.156.1278598258646; Thu, 08 Jul 2010 07:10:58 -0700 (PDT) Received: from localhost ([41.238.114.156]) by mx.google.com with ESMTPS id o20sm33218057bkw.3.2010.07.08.07.10.56 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 08 Jul 2010 07:10:57 -0700 (PDT) From: Mohammed Gamal To: avi@redhat.com Cc: mtosatti@redhat.com, kvm@vger.kernel.org, Mohammed Gamal Subject: [RFC PATCH v2 1/3] Add helper methods to get segment limits Date: Thu, 8 Jul 2010 17:10:34 +0300 Message-Id: <1278598236-12103-2-git-send-email-m.gamal005@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1278598236-12103-1-git-send-email-m.gamal005@gmail.com> References: <1278598236-12103-1-git-send-email-m.gamal005@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 08 Jul 2010 14:11:07 +0000 (UTC) diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h index 51cfd73..ce90048 100644 --- a/arch/x86/include/asm/kvm_emulate.h +++ b/arch/x86/include/asm/kvm_emulate.h @@ -138,6 +138,7 @@ struct x86_emulate_ops { u16 (*get_segment_selector)(int seg, struct kvm_vcpu *vcpu); void (*set_segment_selector)(u16 sel, int seg, struct kvm_vcpu *vcpu); unsigned long (*get_cached_segment_base)(int seg, struct kvm_vcpu *vcpu); + u32 (*get_cached_segment_limit)(int seg, struct kvm_vcpu *vcpu); void (*get_gdt)(struct desc_ptr *dt, struct kvm_vcpu *vcpu); ulong (*get_cr)(int cr, struct kvm_vcpu *vcpu); int (*set_cr)(int cr, ulong val, struct kvm_vcpu *vcpu); diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 502e53f..e32efc4 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -468,6 +468,7 @@ struct kvm_x86_ops { int (*get_msr)(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata); int (*set_msr)(struct kvm_vcpu *vcpu, u32 msr_index, u64 data); u64 (*get_segment_base)(struct kvm_vcpu *vcpu, int seg); + u32 (*get_segment_limit)(struct kvm_vcpu *vcpu, int seg); void (*get_segment)(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg); int (*get_cpl)(struct kvm_vcpu *vcpu); diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 56c9b6b..504761d 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1038,6 +1038,13 @@ static u64 svm_get_segment_base(struct kvm_vcpu *vcpu, int seg) return s->base; } +static u32 svm_get_segment_limit(struct kvm_vcpu *vcpu, int seg) +{ + struct vmcb_seg *s = svm_seg(vcpu, seg); + + return s->limit; +} + static void svm_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg) { @@ -3461,6 +3468,7 @@ static struct kvm_x86_ops svm_x86_ops = { .get_msr = svm_get_msr, .set_msr = svm_set_msr, .get_segment_base = svm_get_segment_base, + .get_segment_limit = svm_get_segment_limit, .get_segment = svm_get_segment, .set_segment = svm_set_segment, .get_cpl = svm_get_cpl, diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 2fdcc98..4e2626b 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -2001,6 +2001,13 @@ static u64 vmx_get_segment_base(struct kvm_vcpu *vcpu, int seg) return vmcs_readl(sf->base); } +static u32 vmx_get_segment_limit(struct kvm_vcpu *vcpu, int seg) +{ + struct kvm_vmx_segment_field *sf = &kvm_vmx_segment_fields[seg]; + + return vmcs_read32(sf->limit); +} + static void vmx_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg) { @@ -4304,6 +4311,7 @@ static struct kvm_x86_ops vmx_x86_ops = { .get_msr = vmx_get_msr, .set_msr = vmx_set_msr, .get_segment_base = vmx_get_segment_base, + .get_segment_limit = vmx_get_segment_limit, .get_segment = vmx_get_segment, .set_segment = vmx_set_segment, .get_cpl = vmx_get_cpl, diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6ed3176..d5a231b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3674,6 +3674,11 @@ static unsigned long get_segment_base(struct kvm_vcpu *vcpu, int seg) return kvm_x86_ops->get_segment_base(vcpu, seg); } +static u32 get_segment_limit (struct kvm_vcpu *vcpu, int seg) +{ + return kvm_x86_ops->get_segment_limit(vcpu, seg); +} + int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address) { kvm_mmu_invlpg(vcpu, address); @@ -3790,6 +3795,12 @@ static unsigned long emulator_get_cached_segment_base(int seg, return get_segment_base(vcpu, seg); } +static u32 emulate_get_cached_segment_limit(int seg, + struct kvm_vcpu *vcpu) +{ + return get_segment_limit(vcpu, seg); +} + static bool emulator_get_cached_descriptor(struct desc_struct *desc, int seg, struct kvm_vcpu *vcpu) { @@ -3876,6 +3887,7 @@ static struct x86_emulate_ops emulate_ops = { .get_segment_selector = emulator_get_segment_selector, .set_segment_selector = emulator_set_segment_selector, .get_cached_segment_base = emulator_get_cached_segment_base, + .get_cached_segment_limit = emulate_get_cached_segment_limit, .get_gdt = emulator_get_gdt, .get_cr = emulator_get_cr, .set_cr = emulator_set_cr,