Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3808446pxy; Tue, 4 May 2021 10:20:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLLz3Rc7Fcn7qOQFV8Ruv3+6boNVz6GjSbw+TZe6mX5LGcmXmrXr0QHSKL2zO5+BW6XT/d X-Received: by 2002:a63:e911:: with SMTP id i17mr14665067pgh.148.1620148835556; Tue, 04 May 2021 10:20:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620148835; cv=none; d=google.com; s=arc-20160816; b=thFR771jfpNovR3U378SFt4EknhnRMfxQAG+gZV+czaENqTxa96xzmkdzxwUhc4xlg VK8uIBh4Tz+axGHj4huTW3QmqsqDSYlb0RJI8L+zC9KM5wNplYajdjiuWdi1wa8an7Kj tnY/39qLhqXrMlC34t89beG/9KHZnsoabBWI9pHgFXYS50pgvKg2vHKJkBQf4NEfr5Mt CGeslLNJwRwu8WhksfKetbtYJQlCn7gL8eFwlho0ieUkfw7l+iNo+oB0cMhUu2euGUdQ +OM9Xh9tsU6O6yqg7U7X9E3Tf+vKMqb3J4Cupb6EihXt8AZtcc69f0ateV4Z0wAAwlyL +CTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:dkim-signature; bh=zyk/CnPUPX4IZt1E/UCYCEZ+CYodKlkrWWKieBP0u40=; b=uXlcKpACIvHwd6d1ranWtaZcmRRxdMoT5lw35uk0VhzM9bRqqHTKpQnMe6CFciA5i+ WaMuFW5u1SCHnrKuW4Xg0Cu66KoDoL5kp9l/kY3y4Jif6GpotjNpfeP7N0vXYLX8ty7O Wnfbs1ypv4zhYFGAmT0a4YbHthgcto6UaKFVCfMWFfDXYEzZ3IF3WQY+l8dtJQYUo7GQ ubRBxUt5m7mawa6mnRXyuKR1fBaayEO+5lWlJMGEqTIrb8cNl+o7BRtrRaRewn2CM8Ia m45iqQk6tE17JQsJcESRzwIeohpdTyKwXEASZNqnML4MqcQyYKOdymfZ0Ur29c1SgmCV WV7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=sXmep3CN; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u128si17945550pfc.317.2021.05.04.10.20.22; Tue, 04 May 2021 10:20:35 -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=@google.com header.s=20161025 header.b=sXmep3CN; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232138AbhEDRSu (ORCPT + 99 others); Tue, 4 May 2021 13:18:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232052AbhEDRSo (ORCPT ); Tue, 4 May 2021 13:18:44 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9101C06138A for ; Tue, 4 May 2021 10:17:47 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id a15-20020a05622a02cfb02901b5e54ac2e5so4024839qtx.4 for ; Tue, 04 May 2021 10:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=zyk/CnPUPX4IZt1E/UCYCEZ+CYodKlkrWWKieBP0u40=; b=sXmep3CNmV6ncUmh4Bwt9ZAeJiSDP0JoBEhefkkGoDExZ3KWPbvsIU53JnIsEc8zfT 2CLrK3Ev6uYm//ZTV8x3LBbl0pu76DCNtR4bhbBmeIoP1Yxz394XylT340mUTD2ikJIm +1cv0jsiXrLQd9DYbrRc3EM3FU169gR0ontu9WZBcWU/oftdv3RNOpv39sWk79rVQmhu B/zjoWAHBa3MpJXy4gwirrxumf1PQnWBGtr/HgGs/qyv9/i2JD56atdndo7MZm/gbzY5 MFZ6Abd/WzdR+F5CHGnUmZQzWy1xnjK6u/Qywe7tLexPOd7WjMK9OLibvAMFXhgOgPAB HnXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=zyk/CnPUPX4IZt1E/UCYCEZ+CYodKlkrWWKieBP0u40=; b=SIigVCfE3WSyfFf9xF0U+PKFvaCi0X2486xQ6vKDhj0YCbaXRhg4U35q12RpP1ye3+ paxxACUcJ+/i87AcdV3TRQ728JBooSzZo3coUVVhf06pRqVVrMAre2mIVbfCaTlNWwA5 LPoETPcyGnumkQ4pPXSqhqb1TGDPBN3yr8gL8jWpqnplqvP1GFX7aEKj6a5Rdml7xxTR 3Mqrsn3qnsr7pzy0BbzZR8JwiaE45O1NTqlo+91678GCUJq2Sas7JsvVktDteopIey+O pCuhXVR5hMwxXph5QxXoLCrhYd/zM6/+UcwGIBU1k64ETiNhCm0UNaC52hNX4vcz4b2V olmQ== X-Gm-Message-State: AOAM533Tdw7+CFiMqyFHEu2Q3VZrfkojWyHFnLyZ8fow34jPBCnjtwL/ oXQA2N8ISg5/QMjvUo6+bj+OdqDbOVU= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:df57:48cb:ea33:a156]) (user=seanjc job=sendgmr) by 2002:a05:6214:c2d:: with SMTP id a13mr18106571qvd.37.1620148666938; Tue, 04 May 2021 10:17:46 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 4 May 2021 10:17:21 -0700 In-Reply-To: <20210504171734.1434054-1-seanjc@google.com> Message-Id: <20210504171734.1434054-3-seanjc@google.com> Mime-Version: 1.0 References: <20210504171734.1434054-1-seanjc@google.com> X-Mailer: git-send-email 2.31.1.527.g47e6f16901-goog Subject: [PATCH 02/15] KVM: x86: Emulate RDPID only if RDTSCP is supported From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoyao Li , Reiji Watanabe Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/x86/kvm/cpuid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index f765bf7a529c..c96f79c9fff2 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -637,7 +637,8 @@ static int __do_cpuid_func_emulated(struct kvm_cpuid_array *array, u32 func) 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; -- 2.31.1.527.g47e6f16901-goog