Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4581899pxj; Wed, 12 May 2021 08:38:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy02WRk4v+ahSSHVzIrfACaxLk7VGhL368eIvgcmOlP0hOgWhDl5K1AEEFT/WMLHjyBCpJS X-Received: by 2002:a05:6830:200e:: with SMTP id e14mr31563343otp.111.1620833887012; Wed, 12 May 2021 08:38:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620833887; cv=none; d=google.com; s=arc-20160816; b=gNAJ08XH43JxLWag9/YljEzWW8AKBrYzDAqhnpEKVQNwzcQthlZun5KUQ2RTiwtNo0 ecGGGEDyftXI+s0966C03I7xbQY+OMj11ryHwXYMN+8DIQLt1PSc7H0E0CoYSeuPpCkp cXsy0XwnSh5oerxvBiD0i+sIkPuaxXXsg9lGh1kNzDutY3ALx/4VlDLpFt8ryh2kJRty 8qNRm7b0rjWwP5bdChec6pxJgNFEE8V0IzUbIKjQ0I6fc6W0PjdhKAXRh1jjO5Ts/+Ky nlkZpgDZhl7d1GuUZupOYcIoIoQhs6yJ8/y50pl7/mDUAdY3lzGVGZlgx4BQaiZxAhJ4 7ekA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J3E/29ftuClNFISyUcNQF3bLbgY3CZAcr7mEakl1H/0=; b=bRgDaxUf9qFWKN4DOj9C+i1/BOmhr92tdPp5NixlbjABpxgrGJYhB+ZZYRPL6mc3ye SJb2x0pIbYB9UrFAJhHPCs1ycbbE2IV7S627/sOoVvyC1c8hoJhUykDz6YE/pcDKh18F heQ6BQ7uT8P/vY1DKBrJODpj/GG6UU1hE7IahMmlOBrNOHIIs0dgBwx/K+NiLA9hELLm dgUjTuQ3sdczDe39DFCW+aMjYMFnlemKw4C4CUJS4UyPGaRr/ScFbwcfpHjCfiYzR1QD j9I/gOMKVCuTiAVJvjl4LfI+lMNvH1o/IE8Csf3JGJJtewdI5SRgicD8qtu2Q4btoThK krLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JVxLtmn6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f6si246008otq.184.2021.05.12.08.37.52; Wed, 12 May 2021 08:38:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JVxLtmn6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236258AbhELPhZ (ORCPT + 99 others); Wed, 12 May 2021 11:37:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:50230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234369AbhELPQi (ORCPT ); Wed, 12 May 2021 11:16:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 362766197F; Wed, 12 May 2021 15:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620831989; bh=aKbZE3fedz4sA3b54nyP8h+UcrUdBSKv9ojwgJ99yCk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JVxLtmn6yNTgKHrjrkqonPgEaMZlg3wZUMParaSo4EU+Z3fCzvA8V06hbjr2Wmc6M 166jhRBrXX96PepfPFIkLHd7Jqr/u/pEwnfRr8UQRJUSq7nd8KJMsS9e7JfbZKFcKY gn7STXm/2Z6aJf5hFgH1kAabKdWpWvx90lSsoiK4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Vitaly Kuznetsov , Paolo Bonzini Subject: [PATCH 5.10 096/530] KVM: SVM: Inject #GP on guest MSR_TSC_AUX accesses if RDTSCP unsupported Date: Wed, 12 May 2021 16:43:26 +0200 Message-Id: <20210512144822.960368766@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson commit 6f2b296aa6432d8274e258cc3220047ca04f5de0 upstream. Inject #GP on guest accesses to MSR_TSC_AUX if RDTSCP is unsupported in the guest's CPUID model. Fixes: 46896c73c1a4 ("KVM: svm: add support for RDTSCP") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20210423223404.3860547-2-seanjc@google.com> Reviewed-by: Vitaly Kuznetsov Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/svm/svm.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -2519,6 +2519,9 @@ static int svm_get_msr(struct kvm_vcpu * case MSR_TSC_AUX: if (!boot_cpu_has(X86_FEATURE_RDTSCP)) return 1; + if (!msr_info->host_initiated && + !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP)) + return 1; msr_info->data = svm->tsc_aux; break; /* @@ -2713,6 +2716,10 @@ static int svm_set_msr(struct kvm_vcpu * if (!boot_cpu_has(X86_FEATURE_RDTSCP)) return 1; + if (!msr->host_initiated && + !guest_cpuid_has(vcpu, X86_FEATURE_RDTSCP)) + return 1; + /* * This is rare, so we update the MSR here instead of using * direct_access_msrs. Doing that would require a rdmsr in