Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9980575ybi; Wed, 24 Jul 2019 13:28:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxh/R/tD2JJ6p8DJdjpRCEKk4s6bGv75oCebjAHcHIIwjkxBr64BpKVMOdRf5k97mgZwst/ X-Received: by 2002:aa7:81ca:: with SMTP id c10mr13206768pfn.185.1564000096671; Wed, 24 Jul 2019 13:28:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000096; cv=none; d=google.com; s=arc-20160816; b=CsqFkYR4GaPsN10rxZW9d4dxGGsU90pyuy3+FCij64mjhTdk7Gi2aO34pVwmQYGdNG gjZknia3bFMLKqFfbN43FnK+6njG2IW84vidq0oRMNKfS0YKg81Sm6mjQr7NWRqBOSDq H3dscNSi+vXjwZdE/poYJsAjjwav5RKcvgPL+eL/TjJz2P/DVVNCmgPoMbwOkqo3Up6L KjTRGvxRUuemovDYgBpmsC59HKJ98KFzWBWneFdPGEUa++cZGpLvNvP3pyCKpHgUZQLE y3GXkHXLU4xYn/v6fAnsDA7yhR8xEvwSlLDfimFGiPiv+RoN7CjQou6Eouk41I7SvpTh D7hQ== 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=BtN8LqYCcBUOkibaVIDFyLH++GgePTkTNoMU6LZ68Ac=; b=SPATXkcQF/h9WG5BRqtJTtZ3vVpt0/ftyL4mD6zBCWd9hZFRh521y1NDmrqSHavL0d 5Vq7D0HRwVxg0Ui3ldu2GWARaGXDdYq+kWmJWB9xoRs1wSyD8DWspgC6tIQxLFJP9RZh TLc6cD+cYpGry7R/QbOPCmNjOsiot4LMabqp0VzrxZ5Tbk3pDkzlcfdEE3cBeLgeXsJd ih/VmQR9UaPoPIeOBFuMDyFrCKR0FuMfEJAry8qhpRKd27ZTtUenQMcECtoL293XMif4 jSVUQr6HN+003YjRMnTf0hKTr53GFhJyAgWJxe7v2x6kzLCyR2CDtmHckKvIiMAvPmqd tNuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bz5GxgP3; 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 v8si13905753plg.122.2019.07.24.13.28.01; Wed, 24 Jul 2019 13:28:16 -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=bz5GxgP3; 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 S2389805AbfGXTiz (ORCPT + 99 others); Wed, 24 Jul 2019 15:38:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:39690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388130AbfGXTiw (ORCPT ); Wed, 24 Jul 2019 15:38:52 -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 0F8F8214AF; Wed, 24 Jul 2019 19:38:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997131; bh=1ISgymW0dhzU5kusBtoD+doCSuaV84R8I3wlBCcZM9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bz5GxgP3W+varUlBf4X4yQAh+jkS+N2itZRhqFk6Z5Rk7b4W7H/cBTeuqkEchNCOF VeVvpSvDXnqSGamPrI1yzCQs4u6mWaK0qdI26Q4BLq6vWGIEfkYtfLG1JixumTWvc4 wA/MNbBsKkxkcNdJFR38Yc4KklwKJ/YGOwsme2dw= 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.2 330/413] KVM: VMX: check CPUID before allowing read/write of IA32_XSS Date: Wed, 24 Jul 2019 21:20:21 +0200 Message-Id: <20190724191759.454363598@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@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; @@ -1933,7 +1936,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