Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp648433pxj; Tue, 18 May 2021 11:00:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxM31N55XyA9KI3gh3oIcfNpKmSJ3sVaWkQsIvDHp4cY7y63V9UILXjHKjaV13rtV2cNO9t X-Received: by 2002:a05:6638:32a8:: with SMTP id f40mr7061629jav.84.1621360823308; Tue, 18 May 2021 11:00:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621360823; cv=none; d=google.com; s=arc-20160816; b=gZ+Cn3UIXJVA19BwFlWyaIcgNq4pC9eX+xEgX4fLfT5V4Qvl0YoeqswDBBk/FvZWp+ 2lu1gpym0TZ/NhVMR8P+k4ydcM3z632F7PMdVi/Bo7I5lVgAfA/6K0tC8CL8ss8Tb21c 8IEUlbmow3weJFzsDhRJV5TpQv8crVbUtnN0PKcNFxcCTOdTjhjPtMSL41u/dt6MCNbc tqUiCyRhk8Bz5FwS5eC2OdfZtHOlkKi2MfVeYEbrgtKX0BFNPiBAilOU05/Hq7v+lvp6 Lh6RQeo7kfQLFteF1yhkuAnlsyVbRvt2INlj7MVa0cP+C5IorC5M2kO/JBpG6w9/qD0Y f4PQ== 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=x64CTi9Cjb+QWXWyaPban50jguLskWy6BUWwHS6Z6S0=; b=Ol9oXM1tVfVHLTU/YRBQfDCRJGIUCuauANKp/AN9+GfpERRMVaRgXQPwkC0ldXKi1Z PLWY8GF9l+Gha1ShmyWPLNJrScKHxTlZhRy8mr7QbvF2kYUQgVfoSS3Pg/t4/W/WWqSf l79Mh3XaDrZlPxDWC5m/byLdxIh8mt0ZEqIatzFqv0Q/FlXBglRXTjxToFU5BZTdPp7M EAs7qg8bTnyvZioj4Dg2I/Ka5InQBexq4pysW5htjiO/kj/xLyfvQrKXD7JMBUQ3miGJ 1BIIz1wb6M0M2za/UCc8cHhGFGTNwuPRPHWrT7fVSJdCM3NK6mX9ZSuDYhRRn26pnDT9 IMww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=F58xz+1j; 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 t10si15543433ilf.139.2021.05.18.10.59.44; Tue, 18 May 2021 11:00:23 -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=F58xz+1j; 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 S1346916AbhEQQKa (ORCPT + 99 others); Mon, 17 May 2021 12:10:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:36524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244617AbhEQPqu (ORCPT ); Mon, 17 May 2021 11:46:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3735B61D3A; Mon, 17 May 2021 14:44:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262674; bh=rvO3SlW0XpyOs4ayDRzP2T/+tAG9p/YataboeAOhmwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F58xz+1j/nQCcGG5mLVSVRlp9ZjsAJm2q95deMF3MKvC9CzlJ+4xJcfmPtaNLAhzM 7q3B9PGcuzNtoWolz98GsIautwoTvkf8GSIILGe/AUJyr7cU/trHc8MoVcI9WBF5iJ k72TLby6rg7Y78911aF+iQ0CGbS5W9V4oOq5zEfY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Jim Mattson , Reiji Watanabe , Paolo Bonzini Subject: [PATCH 5.10 256/289] KVM: x86: Emulate RDPID only if RDTSCP is supported Date: Mon, 17 May 2021 16:03:01 +0200 Message-Id: <20210517140313.762996034@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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 85d0011264da24be08ae907d7f29983a597ca9b1 upstream. Do not advertise emulation support for RDPID if RDTSCP is unsupported. RDPID emulation subtly relies on MSR_TSC_AUX to exist in hardware, as both vmx_get_msr() and svm_get_msr() will return an error if the MSR is unsupported, i.e. ctxt->ops->get_msr() will fail and the emulator will inject a #UD. Note, RDPID emulation also relies on RDTSCP being enabled in the guest, but this is a KVM bug and will eventually be fixed. Fixes: fb6d4d340e05 ("KVM: x86: emulate RDPID") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20210504171734.1434054-3-seanjc@google.com> Reviewed-by: Jim Mattson Reviewed-by: Reiji Watanabe Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/cpuid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -572,7 +572,8 @@ static int __do_cpuid_func_emulated(stru case 7: entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX; entry->eax = 0; - entry->ecx = F(RDPID); + if (kvm_cpu_cap_has(X86_FEATURE_RDTSCP)) + entry->ecx = F(RDPID); ++array->nent; default: break;