Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp4045744pxy; Tue, 4 May 2021 16:38:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrXKU1BXX5BFfUFqGe0aoKHGrHXMeoixHN/TDs+R1/htGJBvRxM95RQC0+m0xEJ/QmDykU X-Received: by 2002:a05:6402:447:: with SMTP id p7mr28837560edw.89.1620171526429; Tue, 04 May 2021 16:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620171526; cv=none; d=google.com; s=arc-20160816; b=mvvBuj0O6r2eum49GcwqdlxzbKevR27aw3vKuIs1YI1kex5TZJPpBcIF3ctUGUiYb4 efnhNOn9saT2MCevK6iwWFzEgZoEt6Q2xBkbVlaOVvDbkP52z2EA8yM8PkYoWxYGxCMF /YhFs8jZHa5Nm8BmImXKvllSEy0k0bYDLSbnuLvbBa7f3lx0g7dHBN/hGnM3bFdd8IxN qozezoVCYDwD6om6jePpuhAolL2krt4d/inn5TdMSmOFbmXHot4ox8UxDdrVSWYKjLAo 6GudM4Q1s9UN7i21ifh3gVj4V3uRMZC2TB/VkbXxOiUZQrKBBLuj595yT7LxQlEGiQfQ 4ajg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FsMJe2qKChbQLfpmmI2er2bhYru7z7dSUmbB+MQYcyA=; b=j8qjDHZ9eVV2jwwTov0XYq3+yltm2qG5bon9sVSKQvFBeMBeJ6GSdpChw7sLksXCXO wY3RHIUI6c6ToUjLu5FxSRWffL5+deZNKAQAVukHgxZ3xoItNOl7wHGubfElL7AtbADF HwJ+x/ytofv7hvxCoMFLSoa22Dej/gFVYFT20mJDHPQLvV4MdQIKDLN/X1br4PEHX2bC FRiRyJYBTVIHJXfXyDeDEG5BW6obHJW4hsFoz+h4vCIPCTY9SkIClPy1wPDVOc4Kb0we vOrokyFOl/Ni+9XybXqzChNh6QrTUJiSZ926gnTJK0d8DGttAqewFrEi6/hikxYYNF/z Q9SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=PGoh0Qzz; 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 r21si3568069ejc.339.2021.05.04.16.38.22; Tue, 04 May 2021 16:38:46 -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=PGoh0Qzz; 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 S232934AbhEDVyq (ORCPT + 99 others); Tue, 4 May 2021 17:54:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232923AbhEDVyq (ORCPT ); Tue, 4 May 2021 17:54:46 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE607C06174A for ; Tue, 4 May 2021 14:53:50 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id v13so6089136ple.9 for ; Tue, 04 May 2021 14:53:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=FsMJe2qKChbQLfpmmI2er2bhYru7z7dSUmbB+MQYcyA=; b=PGoh0QzzOP4PWKgVUJgFGMnPDB9z/qJcSqqffhmjm4s/x5sxxsSaZAmxrbq5mKPW4L JmwSJzcfYvkb2ch2/dsk3/8nY2UDwC9PdQ26CCxFkFv57DMlvSQrrD/UvcxslTN2srD0 qGLVKOzczAmBiJcYf0KMNxFZQJwILjDiYjEpZ2zk/PkkZD7nFWsJ5xBz46AbGBP/css+ T0mGQvtT0ZTewdlOK9YMnvEXz6arFOAiJR8e9xEgf6yaiDWKXp0YwZCwt/JTFGZvXzma nuYBxQeGtkjs8jusd/8gTRL5dyKI+gSypuoeSuS/sqVNEY0XqPxrlJLSsq6Fp48gEn9r eg0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FsMJe2qKChbQLfpmmI2er2bhYru7z7dSUmbB+MQYcyA=; b=awtZ+utEFYu9n0Ik+RVMh3HyBGexiT5QvYu2FOFqj37j2WlFoyYFODffzcbz84IeoU zLvQWzr9z6Cc9vPLM5OkJIcj/YVzopyWy9jlZC1dr5Ke26YRgGkqA3q9NA0AF9v2OuYf tQ0O6aJHCo/g7SEabMtdZBEIUyF615M3VB1XYOCyUmcOlwWA6nu6ZdSEkXqqAHDKJwUR FFGy/wjm4JXdsTzMvcMPQfKpZMZm8U4kvSXHLgiSphVk5ppf/4os0TOvErRAramhvvr6 wEKf2JxMdDdeKF+xF5ath8SRA3R3+FqOxYB/LsiMyWO7QIErlWKLe2rwO6Cw1Jc+gzNy HtiQ== X-Gm-Message-State: AOAM530XWACSMrAc+KsLcBy7eyl1jW+/jVv8XH3oiCt8bc3x6I7YD/JR GsvLkILsdMP10WSCXjt+kq6NCg== X-Received: by 2002:a17:902:9a84:b029:ec:7fd5:193e with SMTP id w4-20020a1709029a84b02900ec7fd5193emr28456943plp.62.1620165230295; Tue, 04 May 2021 14:53:50 -0700 (PDT) Received: from google.com (240.111.247.35.bc.googleusercontent.com. [35.247.111.240]) by smtp.gmail.com with ESMTPSA id i126sm12898036pfc.20.2021.05.04.14.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 May 2021 14:53:49 -0700 (PDT) Date: Tue, 4 May 2021 21:53:45 +0000 From: Sean Christopherson To: Jim Mattson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm list , LKML , Xiaoyao Li , Reiji Watanabe Subject: Re: [PATCH 03/15] KVM: SVM: Inject #UD on RDTSCP when it should be disabled in the guest Message-ID: References: <20210504171734.1434054-1-seanjc@google.com> <20210504171734.1434054-4-seanjc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 04, 2021, Jim Mattson wrote: > On Tue, May 4, 2021 at 10:17 AM Sean Christopherson wrote: > > > > Intercept RDTSCP to inject #UD if RDTSC is disabled in the guest. > > > > Note, SVM does not support intercepting RDPID. Unlike VMX's > > ENABLE_RDTSCP control, RDTSCP interception does not apply to RDPID. This > > is a benign virtualization hole as the host kernel (incorrectly) sets > > MSR_TSC_AUX if RDTSCP is supported, and KVM loads the guest's MSR_TSC_AUX > > into hardware if RDTSCP is supported in the host, i.e. KVM will not leak > > the host's MSR_TSC_AUX to the guest. > > > > But, when the kernel bug is fixed, KVM will start leaking the host's > > MSR_TSC_AUX if RDPID is supported in hardware, but RDTSCP isn't available > > for whatever reason. This leak will be remedied in a future commit. > > > > Fixes: 46896c73c1a4 ("KVM: svm: add support for RDTSCP") > > Cc: stable@vger.kernel.org > > Signed-off-by: Sean Christopherson > > --- > ... > > @@ -4007,8 +4017,7 @@ static void svm_vcpu_after_set_cpuid(struct kvm_vcpu *vcpu) > > svm->nrips_enabled = kvm_cpu_cap_has(X86_FEATURE_NRIPS) && > > guest_cpuid_has(vcpu, X86_FEATURE_NRIPS); > > > > - /* Check again if INVPCID interception if required */ > > - svm_check_invpcid(svm); > > + svm_recalc_instruction_intercepts(vcpu, svm); > > Does the right thing happen here if the vCPU is in guest mode when > userspace decides to toggle the CPUID.80000001H:EDX.RDTSCP bit on or > off? I hate our terminology. By "guest mode", do you mean running the vCPU, or do you specifically mean running in L2?