Received: by 10.223.176.5 with SMTP id f5csp1641977wra; Wed, 31 Jan 2018 09:19:39 -0800 (PST) X-Google-Smtp-Source: AH8x224XmUyR+W/UjQO+pIdvwHW3bVMQ4KTSIrHX59HnGrBZtyvydH6pKwK3lAADRie8FhZs+nrh X-Received: by 10.99.102.1 with SMTP id a1mr15527812pgc.452.1517419178966; Wed, 31 Jan 2018 09:19:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517419178; cv=none; d=google.com; s=arc-20160816; b=t9225SIHR9yQNRpjXrRgP9kkYLW6ofNpwQGr5zJ+bQ4atKgF/rOUMMyQxOMuq1K2ef VSuU1DF8K+rClutsOkaEqzaXo9UxIKj/t1YOyYpxdrLLtUFIgZ2xYoOy7cSYr4v8LCU0 2hSodNykloIPVUeNTx2Fvlkxm16319Ywwf8Sd/u3oSSHhsHSiBKxe9zXjXYzs52HpmFy oma8SJcF11/O9N9JedI10L8uiOrOdZAlju0wGqJ6bkAImExBwkCd0kCy8LgDYOY++hxw fgj639vvkVDpDnC2n1vLpbtNoBtkuQ7IyHmK5UIo4zvS9CcgWiC3fbgLNDm3/sIlVoeK PgFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:arc-authentication-results; bh=5oPHtjHnF/CirIJt25d+B6ubLza6rYuFtUDt68ptx94=; b=0bzldjpsAj67MaZ75seiR69Lopg21fje52dSKCTCYSt2lMU022/JU9orOadxzca/t5 9o1s/6NXIugPNcmKVPQgZr4IhCCnAWcTNoEezPbFAETl0RrkOSw9DVqGLjRFELxpPLcq WDohJhUkti9ck4K7gT6sxZhAomEjMgzYIDR0OMAo1Ovi9fkGT/HQCvQkS+w+/2984+aF 90HtLvbUEz8A6g4NZbTLYEr2roI3nvNR0i2JcOa0CjU+gGmoP6Nha9+ZJnwAlbAYpCls DMFlF0CGKD3HutZkuThU6fVxlTI8HP1BrnGKwLBMASe0wq1+xZzmT2CdvXQnzq0Njqqs DyVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x16si11398287pgc.817.2018.01.31.09.19.24; Wed, 31 Jan 2018 09:19:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753502AbeAaRNr (ORCPT + 99 others); Wed, 31 Jan 2018 12:13:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39774 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753460AbeAaRNq (ORCPT ); Wed, 31 Jan 2018 12:13:46 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 67C7E780E9; Wed, 31 Jan 2018 17:13:46 +0000 (UTC) Received: from flask (unknown [10.43.2.80]) by smtp.corp.redhat.com (Postfix) with SMTP id AE07560473; Wed, 31 Jan 2018 17:13:44 +0000 (UTC) Received: by flask (sSMTP sendmail emulation); Wed, 31 Jan 2018 18:13:33 +0100 From: =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini Subject: [PATCH] KVM: nVMX: preserve SECONDARY_EXEC_DESC without UMIP Date: Wed, 31 Jan 2018 18:12:50 +0100 Message-Id: <20180131171250.29568-1-rkrcmar@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 31 Jan 2018 17:13:46 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org L1 might want to use SECONDARY_EXEC_DESC, so we must not clear the VMCS bit if UMIP is not being emulated. We must still set the bit when emulating UMIP as the feature can be passed to L2 where L0 will do the emulation and because L2 can change CR4 without a VM exit, we should clear the bit if UMIP is disabled. Fixes: 0367f205a3b7 ("KVM: vmx: add support for emulating UMIP") Signed-off-by: Radim Krčmář --- I haven't tested emulated UMIP (yet) nor machines with UMIP, but at least kvm-unit-tests don't throw an error anymore. arch/x86/kvm/vmx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 438802d0b01d..b1e554a74b34 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -4379,7 +4379,8 @@ static int vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) vmcs_set_bits(SECONDARY_VM_EXEC_CONTROL, SECONDARY_EXEC_DESC); hw_cr4 &= ~X86_CR4_UMIP; - } else + } else if (!is_guest_mode(vcpu) || + !nested_cpu_has2(get_vmcs12(vcpu), SECONDARY_EXEC_DESC)) vmcs_clear_bits(SECONDARY_VM_EXEC_CONTROL, SECONDARY_EXEC_DESC); -- 2.15.0