From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBF16C43460 for ; Tue, 4 May 2021 21:53:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B939E613D8 for ; Tue, 4 May 2021 21:53:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232938AbhEDVyq (ORCPT ); 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-Google-Smtp-Source: ABdhPJyIfszxo0bx3Jkguq3ZGyfAq1tH8gsNHrt6Rmn0FlLPMa9UdSaaKIKxu3FAamS9VYMkfrvs8g== 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?