Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10489245ybi; Thu, 25 Jul 2019 00:12:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqxl2A7gjBqM2bkeX+itbC2Vk07M0E86E1jDpie/9VgGMW+j4BizFE8zf3BXoxzsVwPmWtad X-Received: by 2002:a17:90a:d996:: with SMTP id d22mr91442630pjv.86.1564038767419; Thu, 25 Jul 2019 00:12:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564038767; cv=none; d=google.com; s=arc-20160816; b=Rme6M+1vlAlcFAE73erFpSLGKt+mZ1WfG6vit3OsYdQgLI6r++X2y/1R1AUiir7/R/ h59QXcb2Ul9MNsye5ouxKEcI94Xc2xHey2U31GuzF+ATJFnWgSlRKLvuJ7OjAlRUzCzq QtCd45vL3sz+WkDE/idCPmkmmkLMH+5bP7Mm8n4dYBN0+6oE+IhOxBa+zLz6EPvVy//I naodlOydMctoNENPS8TxYE/ooTXafXtZMXPTL1RH2+JvWVJDIdaF6x5Eg7KLE7kU9dBd maKhHDYTXZeCIVfTMUjCJCgXQEfST7dhyrgshcst66GoQZQhYVRAuqMvxYbD9TUNVOmt 1Cog== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GnyxHpz1dwZ9vE8ZNZ8l7XYJA15jkbt8gy9lE4T4aAg=; b=UbKGy5QOPTzd3gJhke22hJoOXCYToyRPmdMGlyLf2CKGeJ9jPfdT4V3E+CR75/Xq1H jrkdkiCpnr5FgZhrzgwS/a903SFCzGWR2CUVzwy4/nsVDqtDJdsUgIf0snDTUQsV5kjQ s06FjMfIvKIusZGiqOsZr5xa0KNFRfjwWD9taKnUEQT7qaYkcUx4SmXY7ZcR9PPWvuru HT2JS8ZUtlXX6uG+vOT/U8zCL5JJ6ckrj7DlQsmK6+FplR9FUAvK757MjNlBsMMlYkKb kx5xE01ZqpVHY5PbBcAqXm78zGWeEQ0IuDXCTdWqRrqI6wzOffmRoAWmi8Nu5gWewfLZ 8+6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hJ7FH4f4; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a191si16905716pge.93.2019.07.25.00.12.33; Thu, 25 Jul 2019 00:12:47 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=hJ7FH4f4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404962AbfGXT7e (ORCPT + 99 others); Wed, 24 Jul 2019 15:59:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:46826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392023AbfGXT7d (ORCPT ); Wed, 24 Jul 2019 15:59:33 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A555221873; Wed, 24 Jul 2019 19:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563998372; bh=LrB+hJ1+bC40bO/7nVV2tlcLtiMmj9KGumerYeppRj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hJ7FH4f4TZ3oLz6qwI5SVI0PrsgYseX0o7yo9pPEqNCtUTFE51jUwoqbA4Fo+lhGk HcN430HbKlDlMKCVzps4DO+dCbO4AkSdq0xx24n4X5wnidHRJe4Wtyope1QhN/eGzt TTpcL958vhJ5ov0bgsXPulLeVrZp+oupreG6zOs8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaoyao Li , Tao Xu , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Wanpeng Li Subject: [PATCH 5.1 301/371] KVM: VMX: check CPUID before allowing read/write of IA32_XSS Date: Wed, 24 Jul 2019 21:20:53 +0200 Message-Id: <20190724191746.921260968@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191724.382593077@linuxfoundation.org> References: <20190724191724.382593077@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wanpeng Li commit 4d763b168e9c5c366b05812c7bba7662e5ea3669 upstream. Raise #GP when guest read/write IA32_XSS, but the CPUID bits say that it shouldn't exist. Fixes: 203000993de5 (kvm: vmx: add MSR logic for XSAVES) Reported-by: Xiaoyao Li Reported-by: Tao Xu Cc: Paolo Bonzini Cc: Radim Krčmář Cc: stable@vger.kernel.org Signed-off-by: Wanpeng Li Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx/vmx.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1718,7 +1718,10 @@ static int vmx_get_msr(struct kvm_vcpu * return vmx_get_vmx_msr(&vmx->nested.msrs, msr_info->index, &msr_info->data); case MSR_IA32_XSS: - if (!vmx_xsaves_supported()) + if (!vmx_xsaves_supported() || + (!msr_info->host_initiated && + !(guest_cpuid_has(vcpu, X86_FEATURE_XSAVE) && + guest_cpuid_has(vcpu, X86_FEATURE_XSAVES)))) return 1; msr_info->data = vcpu->arch.ia32_xss; break; @@ -1929,7 +1932,10 @@ static int vmx_set_msr(struct kvm_vcpu * return 1; return vmx_set_vmx_msr(vcpu, msr_index, data); case MSR_IA32_XSS: - if (!vmx_xsaves_supported()) + if (!vmx_xsaves_supported() || + (!msr_info->host_initiated && + !(guest_cpuid_has(vcpu, X86_FEATURE_XSAVE) && + guest_cpuid_has(vcpu, X86_FEATURE_XSAVES)))) return 1; /* * The only supported bit as of Skylake is bit 8, but