From patchwork Mon Apr 15 13:00:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 2445071 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 5BAF13FD1A for ; Mon, 15 Apr 2013 13:00:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751743Ab3DONAg (ORCPT ); Mon, 15 Apr 2013 09:00:36 -0400 Received: from mail-bk0-f50.google.com ([209.85.214.50]:54895 "EHLO mail-bk0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751054Ab3DONAe (ORCPT ); Mon, 15 Apr 2013 09:00:34 -0400 Received: by mail-bk0-f50.google.com with SMTP id jg1so2362086bkc.37 for ; Mon, 15 Apr 2013 06:00:33 -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=KmBZxCASw5hMW7Ju55+qfDw47NjV0rjMfi1ECxjN55c=; b=r04Pehk59iBNaqQakd3fRysvGF4rmID9P8u1bOWbgTWPJxqLVg5j1GWrfUKFZuUjKJ ZsIGXbuG0rfSyCMguX7C8eSjmJwOBoyz0S0XEHqWX/8IWeWmuFQjv8JCHbUqSFmTwVld eNsTgV6nAlrF0kIGLa/MErn83PWXiv70I+da25rXzl3t+kVtzQUUHt1PfX52lvv9vaco WtJ6VnZpbJDXqPgYau8/1c9Eg2CMP02SNQ0J5EywWuCfetvmo+cRn/+SVprDmwX24IBJ t5cBGxnazhNiGd3h2zSdsHixVlstNr1dm6oDEG8aDhT+tnCFf8btOeG+CoSq/QFkgnO0 DbEA== X-Received: by 10.204.172.80 with SMTP id k16mr8408939bkz.123.1366030833213; Mon, 15 Apr 2013 06:00:33 -0700 (PDT) Received: from playground.lan (93-34-176-20.ip50.fastwebnet.it. [93.34.176.20]) by mx.google.com with ESMTPS id w6sm8466353bkz.17.2013.04.15.06.00.31 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 15 Apr 2013 06:00:31 -0700 (PDT) From: Paolo Bonzini To: linux-kernel@vger.kernel.org Cc: gnatapov@redhat.com, jan.kiszka@siemens.com, kvm@vger.kernel.org Subject: [PATCH v2] kvm: nVMX: check vmcs12 for valid activity state Date: Mon, 15 Apr 2013 15:00:27 +0200 Message-Id: <1366030827-5662-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 KVM does not use the activity state VMCS field, and does not support it in nested VMX either (the corresponding bits in the misc VMX feature MSR are zero). Fail entry if the activity state is set to anything but "active". Since the value will always be the same for L1 and L2, we do not need to read and write the corresponding VMCS field on L1/L2 transitions, either. Signed-off-by: Paolo Bonzini Reviewed-by: Jan Kiszka Reviewed-by: Gleb Natapov --- v1->v2: remove read/write of vmcs12->guest_activity_state, use GUEST_ACTIVITY_ACTIVE. arch/x86/kvm/vmx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index c75c25d..c252adf 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -7004,7 +7004,6 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) vmcs12->vm_entry_instruction_len); vmcs_write32(GUEST_INTERRUPTIBILITY_INFO, vmcs12->guest_interruptibility_info); - vmcs_write32(GUEST_ACTIVITY_STATE, vmcs12->guest_activity_state); vmcs_write32(GUEST_SYSENTER_CS, vmcs12->guest_sysenter_cs); kvm_set_dr(vcpu, 7, vmcs12->guest_dr7); vmcs_writel(GUEST_RFLAGS, vmcs12->guest_rflags); @@ -7223,6 +7222,11 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) return 1; } + if (vmcs12->guest_activity_state != GUEST_ACTIVITY_ACTIVE) { + nested_vmx_failValid(vcpu, VMXERR_ENTRY_INVALID_CONTROL_FIELD); + return 1; + } + if ((vmcs12->cpu_based_vm_exec_control & CPU_BASED_USE_MSR_BITMAPS) && !IS_ALIGNED(vmcs12->msr_bitmap, PAGE_SIZE)) { /*TODO: Also verify bits beyond physical address width are 0*/ @@ -7411,7 +7415,6 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) vmcs12->guest_gdtr_base = vmcs_readl(GUEST_GDTR_BASE); vmcs12->guest_idtr_base = vmcs_readl(GUEST_IDTR_BASE); - vmcs12->guest_activity_state = vmcs_read32(GUEST_ACTIVITY_STATE); vmcs12->guest_interruptibility_info = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO); vmcs12->guest_pending_dbg_exceptions =