From patchwork Tue Mar 19 15:30:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 2301751 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 61E55DFB79 for ; Tue, 19 Mar 2013 15:30:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932261Ab3CSPal (ORCPT ); Tue, 19 Mar 2013 11:30:41 -0400 Received: from mail-wg0-f54.google.com ([74.125.82.54]:47142 "EHLO mail-wg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756327Ab3CSPak (ORCPT ); Tue, 19 Mar 2013 11:30:40 -0400 Received: by mail-wg0-f54.google.com with SMTP id fm10so467411wgb.21 for ; Tue, 19 Mar 2013 08:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer; bh=U9d8su3tnSlVVoXD3ydO4KQfxn57F5N3xUShbkBaoKE=; b=l4MzKttstcsICnNUnrutdwGeIEA6YBDXK+01PUNuCG2cAoyeBvNYex6a8uGT85Bc8i YPC6sKhbPWXnFtgeJrOK1AKv57grspomIoUfPuSBavwFLSFXATgwyofdWNnlufWKXuMA 5eflUAhJUgC+FclSp0ZBo4FFmwPxWZ0/m+dyZux1gvCvNtygYkt9iMA79m8cDVGacjv+ E9Iohuy51aWh/JQMqyMZqRxe6fPBa3RSus6j9DAt7oDsZDJGq7qdOn4jEss218Y79OIv /UeCGj1FKwNeZ5MkbwC/Ni2ifMRyLseT18n+RdCQP6YxSk5S/y835wT192xIpuVkzsDC E8lw== X-Received: by 10.194.59.100 with SMTP id y4mr4084942wjq.51.1363707038631; Tue, 19 Mar 2013 08:30:38 -0700 (PDT) Received: from playground.lan (93-34-176-20.ip50.fastwebnet.it. [93.34.176.20]) by mx.google.com with ESMTPS id du2sm1391029wib.0.2013.03.19.08.30.36 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 19 Mar 2013 08:30:37 -0700 (PDT) From: Paolo Bonzini To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org Subject: [PATCH] x86: correctly initialize the CS base on reset Date: Tue, 19 Mar 2013 16:30:26 +0100 Message-Id: <1363707026-19351-1-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The CS base was initialized to 0 on VMX (wrong, but usually overridden by userspace before starting) or 0xf0000 on SVM. The correct value is 0xffff0000, and VMX is able to emulate it now, so use it. Signed-off-by: Paolo Bonzini Reviewed-by: Gleb Natapov --- arch/x86/kvm/svm.c | 8 +------- arch/x86/kvm/vmx.c | 1 + 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 7219a40..7a46c1f 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1131,17 +1131,11 @@ static void init_vmcb(struct vcpu_svm *svm) init_seg(&save->gs); save->cs.selector = 0xf000; + save->cs.base = 0xffff0000; /* Executable/Readable Code Segment */ save->cs.attrib = SVM_SELECTOR_READ_MASK | SVM_SELECTOR_P_MASK | SVM_SELECTOR_S_MASK | SVM_SELECTOR_CODE_MASK; save->cs.limit = 0xffff; - /* - * cs.base should really be 0xffff0000, but vmx can't handle that, so - * be consistent with it. - * - * Replace when we have real mode working for vmx. - */ - save->cs.base = 0xf0000; save->gdtr.limit = 0xffff; save->idtr.limit = 0xffff; diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 4a0bafe..c75c25d 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4133,6 +4133,7 @@ static void vmx_vcpu_reset(struct kvm_vcpu *vcpu) seg_setup(VCPU_SREG_CS); vmcs_write16(GUEST_CS_SELECTOR, 0xf000); + vmcs_write32(GUEST_CS_BASE, 0xffff0000); seg_setup(VCPU_SREG_DS); seg_setup(VCPU_SREG_ES);