Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp176408pxj; Tue, 18 May 2021 00:21:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyP2CJ0BqxT1gXHyLsht77ik+eeG5Ov23FSG23+taSe5/9XUnrLPKOxsYcnjz62PoLt8jxi X-Received: by 2002:a17:907:76b8:: with SMTP id jw24mr4585193ejc.359.1621322509218; Tue, 18 May 2021 00:21:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621322509; cv=none; d=google.com; s=arc-20160816; b=cfnE0Bc9xu0z+v27OM5nsadHrxGQsHRiZPeYvBlosbrT3AOUHeQHhnwV31KMmHrz0Y ShBqxkDBVGxmr5h7i2Zc+D1P2AFXitm0LwF9GWHforNUthG/x4gpc7pcSEd2C5tc22q9 Ab52KzyaODxJ+W1a7gsRFkZYIl+RAKhFc2+WD3WUafruwWV+Ps4I2eNPuBg90u94Zx26 Tg0hVv6PsLVUcLAmkSTYgB1BpmiuLrhXMV7hLFb4VMCM8MPxno7PycvR9QMoEhSVd8nb y5NrNiARWXOFIu2X+5W2uI8DkYP5QlvJzteemGSj3Y+IJb+NItwRJTfCIOrH8XFO47X2 fcFw== 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=vwemvF7M/X0dTF7TL7kra2iykWmkUp6jwU/eGPsRoKo=; b=QKsqXT06leQoYPtr0oo3zmhMBxez2M0OrCzEDEqM4cN7Dx+cAtjllZ/kQOtg3mpR4h 5zLOsv/9cdLmISrC8VsdXivwLgP5cT3c9+9wuZyRfge74KCGvJP7a3PU1CMNgbDcAtp8 CQMmt/5qcBlFI6JRc9nn3YN/sp6Mdk5wJONZAZyc9637CGtR1iQP7L76xCY+3a8WMUrf k8apMEy+T6i4jLhDJzQVuKcDZq4N60KZrdefXWQj4tmXLI3auW4xZsE9JVFcQgXUcbXa J+iAdxn9OrFTMudyF3nDDVM7glpSv+gMM57fwhLWNGFeNLMlbYU3Lat1qAKKKOiTAKV6 ACzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=c1kiQv3q; 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 j16si17394407ejm.402.2021.05.18.00.21.25; Tue, 18 May 2021 00:21:49 -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=c1kiQv3q; 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 S241889AbhEQOyO (ORCPT + 99 others); Mon, 17 May 2021 10:54:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:37900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241773AbhEQOqB (ORCPT ); Mon, 17 May 2021 10:46:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EADF36143D; Mon, 17 May 2021 14:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261282; bh=9ri9GZbb/HmrQRcrfRDVGQdoa71PJHj6zHlJxZO/QfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c1kiQv3qJrnkQz3rCiyM+qsA1I7AlU+JWEbhYI6/gw3+Xp8yzf8VozUjjtcVmGY2n JwaNfurXdEafmDEha6NPs9yubDSlXTM4onMU8fTbupDM0bDZGMhgdtTEgoLIwv8RqK H/nc0sXjNMaLx+xmH60QGj5mkcrn7sKWwC+aWL08= 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.12 329/363] KVM: x86: Emulate RDPID only if RDTSCP is supported Date: Mon, 17 May 2021 16:03:15 +0200 Message-Id: <20210517140313.732360020@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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 @@ -589,7 +589,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;