Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3083421rwl; Mon, 27 Mar 2023 09:02:13 -0700 (PDT) X-Google-Smtp-Source: AKy350Y9rwMFVJsD4DNG6hYjI8qnbmpm6Z5VPFfW6OL/6f6tMyCxzhgEc4EwRyEbJU4NWdqTllyZ X-Received: by 2002:a17:903:228f:b0:1a0:67ef:dc61 with SMTP id b15-20020a170903228f00b001a067efdc61mr14610050plh.17.1679932933518; Mon, 27 Mar 2023 09:02:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679932933; cv=none; d=google.com; s=arc-20160816; b=tJUCO1SscP23qMEiuHXT7nC7/5osqNhg4G2RNj1iB7mh3p/P41GNGvZuZf0PidroNu wLTq7gBjC7YeCKKCjSPVbcvTRsww3qphtCXaBnXWSpcYf18efiWEq4G28inSO3O3If4U poi5ZuHfU/u6dWVGKDN4cd4tjDgbjgaG8Kn/gu41mYlDLavoxLDjEQTrxnhexvNWsd4N RRTBVM7oYXtOAoJko6IenMOdWyowEaYY6WvYPELrFWFqxLRNKn78+FLyWMlex2yqhHjp 2YdETzVx0/tQnhZnLyUqzkdpAXg5oB4LiBwfEhGR8SY1GIo1z0xyrX+iROy8AhCA8OmE Lm4A== 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:from:subject :message-id:references:mime-version:in-reply-to:date:dkim-signature; bh=mAmapc1h2/zUGtfRb73ywDzpB2MYvKSxif+WSZz20gk=; b=J1RHJAQg4N2ebvs1o9SfuFqXpGyos0Vo8D70sVAQnHa/RyG9hHzmH+G2PTNP4VKEJz Vm1reO9RqEbEY0AZRkZi0Ga9YZcSXVtiFiUsVNhCll/dNKoKVKOS8Sjq31gfU4WQvHuv L6R1hTtyJufXcdzulopSVx/P5YMMOXu89LDrnVCaOBp/oNxToC9nP0/sPNLXvolvPfQH Dk+QnPRsQoTWUC72SPnUgM7kRvmiRaet+kJiReoVIo4Rup+e4vEYkrgw6cv5R8i04HNF TbPIX+sKlAK2SMVzdrPUZ2tObm5AFGjVSuMeFuuvvL9UuB4yNK4iWUcxPD1wQA/039OX Rp/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=jLWDoZbw; 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 ay9-20020a1709028b8900b0019ca7ed8931si26357985plb.279.2023.03.27.09.01.58; Mon, 27 Mar 2023 09:02:13 -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=jLWDoZbw; 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 S232544AbjC0QAJ (ORCPT + 99 others); Mon, 27 Mar 2023 12:00:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230014AbjC0QAI (ORCPT ); Mon, 27 Mar 2023 12:00:08 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56CFD2688 for ; Mon, 27 Mar 2023 09:00:07 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id b8-20020aa78708000000b005eaa50faa35so4605309pfo.20 for ; Mon, 27 Mar 2023 09:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1679932807; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=mAmapc1h2/zUGtfRb73ywDzpB2MYvKSxif+WSZz20gk=; b=jLWDoZbwHwB4mTozuWWzTVJsgQ++DRHbDKBRAmJ2Ye4/tqeZ8WRBqLPqDeOyJB/Vl9 KmABEnph4x/Xb5iRvoY7agFFgTAAH7xBmcuTD6w8hh3QHWB44qDuI4SdFCEDwJ89zxo5 jtb+rQGoFdQGL6dgQeWs4DZZPNBGMA2yLWwqw/4dyr08EmBt6XC5exK5kN4AT2DjWBVy FSYBfU/JarBoPXimnInHhSy6cdkX90HZXaAm89/TfbKHz8faGM8wveg71HI7B8MZci7c NvFu+DzBwbFRRA4griTQMpFO5av6mdAY77pZuJ7bYRWurmpvtc12i/EXtRo6CD02kvF/ mA+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679932807; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=mAmapc1h2/zUGtfRb73ywDzpB2MYvKSxif+WSZz20gk=; b=lnn2WGV0OhW4aZlrEex2Pit4pksiQtbA/Zjmp0Lj4UvPOdQSwd790S/d3kkobIAW1n mxLZ8F4+KtnKLt+d4HuvTg6USGYQegYmwjg8eOIZWIlKpnMB5hcdbXVSeR5qmhsh69HF V+5RSazPbJLPtr1nlRRucG6hup93SginrF25/m5hKFEmw5mPE/aymjUPTMjuvUA//Ks3 qBWZgap+ZX96mNV2yofaPf3zDP1bwh5YWxW6znSz/e8SjLhfa1/xoGXdTn94OwmDsuH9 oV9WSZe52OAl0xpDo+2PNwwkLZww7FAQKZbV8jdzlJILQgj94CIwc9J1ho6Db6y1v5dT SO8g== X-Gm-Message-State: AAQBX9dd0jUEm2yhDpLFe5Fw/Pe3RkpIEJCq3XK9EWvuKwoo7x/MBfJL a1gbo3s7ZB6M+0Y0C0wnuPEfdMUmvak= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:7892:b0:1a1:f9f7:b752 with SMTP id q18-20020a170902789200b001a1f9f7b752mr4074759pll.0.1679932806751; Mon, 27 Mar 2023 09:00:06 -0700 (PDT) Date: Mon, 27 Mar 2023 09:00:05 -0700 In-Reply-To: Mime-Version: 1.0 References: <20230322011440.2195485-1-seanjc@google.com> <20230322011440.2195485-6-seanjc@google.com> <373823f7-00ba-070c-53c7-384d29889e40@intel.com> Message-ID: Subject: Re: [PATCH 5/6] KVM: x86: Virtualize FLUSH_L1D and passthrough MSR_IA32_FLUSH_CMD From: Sean Christopherson To: Jim Mattson Cc: Xiaoyao Li , 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=-7.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_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 Mon, Mar 27, 2023, Jim Mattson wrote: > On Sun, Mar 26, 2023 at 8:33=E2=80=AFPM Xiaoyao Li = wrote: > > > > 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, = struct 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 & ~L1= D_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? >=20 > 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? Yeah, AFAIK RDT and the like only provide QoS controls for L3, so L1 is fai= r game.