Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3060281rwl; Mon, 27 Mar 2023 08:43:54 -0700 (PDT) X-Google-Smtp-Source: AKy350b0ww5TniVI5p4bz3OM972+5tFghfrw3ai5x36B2RwU/Fva9gRvSk15vofQrd3pValngiBJ X-Received: by 2002:a17:906:4787:b0:933:89a1:57e6 with SMTP id cw7-20020a170906478700b0093389a157e6mr17395145ejc.26.1679931834148; Mon, 27 Mar 2023 08:43:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679931834; cv=none; d=google.com; s=arc-20160816; b=LBqiVOpRyKq8/3CEBz3AbuWLQdVV5qyHKSKv0kh87LW1X3fJQxv17euYK58yJfOT0A ul46+Z8qYyzE0e0pcqqaBxaMsZLxFIhAq7daFKAYeaUEOrL4zyk5w1ZUZdvglJbPH1SY JwlVB8cXUBb4vPnIcninTWvTGjyAq/V9QKjO+VTzUrhhN+fs5uqVay61gHIJ7iIyi25E el2AGjn5nhjHK7dyyhj6QRq4HI1G8GA+d5t/Ez3Tl25y4OKfokVm+PtkhKAzDntf8DvF nyj4Ff+DqYzkoJX6rcPBj19OCKIVHPorK/5S/Is6UhQM9Ue3o3gXSR3ZrR2zMOCU2TqJ fglw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=2scqCpn+SlvwNwMyXAR1S8e8r39frvTEmZWmCdUynfo=; b=BxInOXUE36suienUsMsGaqbal3Rq19nh3CX2NvXTiKlk2VPjbw7FnRH/CPZU3M8QH8 nMj3mK5pjv6THJtUBHJ32w6u806EueWAT7GO8wNd87w2jjsOUCWzsEUjhDrCExnrQY9S F0FDtlDVOq7/YlZETZaNrMnSyQetQ/jwiI0S1Okl9IUreazQFRC/Pu7zKxjigx2MAfrq T80ke91HJwaK/EUmMBlXXg5mQCmyuULTacuigytVRFhWZN40tOP+OVLT//iuWzLF/Blw w6GxIloEaCtFTZLvoYzI3sLBpz5TPtUtMt0RHIstsgMqmA9s8OfqZjQeviuIYM4vd+XS l9dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rFuTXmnS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n14-20020aa7db4e000000b004af6c524991si28132371edt.109.2023.03.27.08.43.29; Mon, 27 Mar 2023 08:43:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rFuTXmnS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232723AbjC0Phn (ORCPT + 99 others); Mon, 27 Mar 2023 11:37:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231834AbjC0Phl (ORCPT ); Mon, 27 Mar 2023 11:37:41 -0400 Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3F3C2738 for ; Mon, 27 Mar 2023 08:37:40 -0700 (PDT) Received: by mail-oi1-x22b.google.com with SMTP id y184so6651774oiy.8 for ; Mon, 27 Mar 2023 08:37:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679931460; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2scqCpn+SlvwNwMyXAR1S8e8r39frvTEmZWmCdUynfo=; b=rFuTXmnSGmSvQSqlTCwOwfje4dNunkyQvBQO1B0OEvIHKkhsQfByRaQcSeSdkocF5F yX5bCRDLIxqpm38oYlhRVTBZnKZZyCzAT3tmFdduJnJIWAB4dNqYrmwMuqy5p0BI3sSD mhkrQ8TcipD6vcrzyVkebrs0a3r308DuqctCTsGHROhou/kEUIj8jvRKfVIzu6Q9HPLw dFjRG+qM+HSJhcNuO1bncPlwqbiI0YzErn7+H1mTYkhwIol9FFPfJ8h3ieDG/VxCH+LK hhNfznLzq/+I9QjUSBuPCbtWWn5xvv1gxYSFnb+/aIijxkOshfIyTFx4YYYC/r4rYjmu VRCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679931460; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2scqCpn+SlvwNwMyXAR1S8e8r39frvTEmZWmCdUynfo=; b=sToLXqI1D/T+K5PCF5z7+Yp327PAMOaVV5WSivGtQadGx/EclYa7x7yKAwa6ohbw2P OzisbpVQetItIDiZukgmF5zzkKRbdo5HWz3fIeexK0KbTmZjFtZ9JGvuMSKPy/lb+U+I 9IojbI9sMFP8bOVLJkDGE/prZLHKjpvGNUTgnGZG2oqU7LYAwCKGUAhIZCRtkD0UGayX rFRiN9k1ZAqhYT5esq6r84fKjZntOHqMTV809cgkoGKC7G0ltD5g8ikdv8QuAJ2hoRup ZAqP/qHuEatwqPUHWSYkzqiDwXpJfYKYSxFySafm7818KQYf4wbesHCdufm3UtTIAR6Z pKDQ== X-Gm-Message-State: AO0yUKVV6qJ0SoO//wveD7daPc0pb+S0I0l+Dwdg08xLVwDYMx7GQZXR 0PWgqBSn0emrR2UiUGUjJCmDrNZY1v0OHiIadHeSvg== X-Received: by 2002:a54:4710:0:b0:384:4e2d:81ea with SMTP id k16-20020a544710000000b003844e2d81eamr3381518oik.9.1679931459915; Mon, 27 Mar 2023 08:37:39 -0700 (PDT) MIME-Version: 1.0 References: <20230322011440.2195485-1-seanjc@google.com> <20230322011440.2195485-6-seanjc@google.com> <373823f7-00ba-070c-53c7-384d29889e40@intel.com> In-Reply-To: <373823f7-00ba-070c-53c7-384d29889e40@intel.com> From: Jim Mattson Date: Mon, 27 Mar 2023 08:37:28 -0700 Message-ID: Subject: Re: [PATCH 5/6] KVM: x86: Virtualize FLUSH_L1D and passthrough MSR_IA32_FLUSH_CMD To: Xiaoyao Li Cc: Sean Christopherson , Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Nathan Chancellor , Emanuele Giuseppe Esposito , Pawan Gupta Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-15.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 26, 2023 at 8:33=E2=80=AFPM Xiaoyao Li w= rote: > > On 3/22/2023 9:14 AM, Sean Christopherson wrote: > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > index c83ec88da043..3c58dbae7b4c 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -3628,6 +3628,18 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, st= ruct msr_data *msr_info) > > > > wrmsrl(MSR_IA32_PRED_CMD, PRED_CMD_IBPB); > > break; > > + case MSR_IA32_FLUSH_CMD: > > + if (!msr_info->host_initiated && > > + !guest_cpuid_has(vcpu, X86_FEATURE_FLUSH_L1D)) > > + return 1; > > + > > + if (!boot_cpu_has(X86_FEATURE_FLUSH_L1D) || (data & ~L1D_= FLUSH)) > > + return 1; > > + if (!data) > > + break; > > + > > + wrmsrl(MSR_IA32_FLUSH_CMD, L1D_FLUSH); > > + break; > > Then KVM provides the ability to flush the L1 data cache of host to > userspace. Can it be exploited to degrade the host performance if > userspace VMM keeps flushing the L1 data cache? The L1D$ isn't very big. A guest could always flush out any previously cached data simply by referencing its own data. Is the ability to flush the L1D$ by WRMSR that egregious?