Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1256649iob; Thu, 12 May 2022 15:04:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytnvEji5c4MiCj2sokOJK7dh8qL1Hl7XMlnoBvuH/ZKNrrRCswoWFAyt99uWDEx9Xl2id8 X-Received: by 2002:a63:894a:0:b0:3ab:23c7:33ff with SMTP id v71-20020a63894a000000b003ab23c733ffmr1310466pgd.245.1652393048160; Thu, 12 May 2022 15:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652393048; cv=none; d=google.com; s=arc-20160816; b=RiYA30aya6tg/VRA1TFUL/pXwXCRp4v3k/AbHVnSLscVb15GN+S5BQ7Lrw4pVBDWBe WhJofyP13gXuH1+5MjGYtKkCNs8Vno1QtnLrSeddqQQhOltPhYD8eQ0Jr+AqjckNFpYd G+YdAUXOxUL0/Tow1nTSddb/z5piat9FkTI37gommilVUls7raJvpkduCs04DnAzuRRg Bv6PkoGkMYMv96gEmHyzpd7tSNr/ux720am/XUKqaWAg8h/gJwqLZrU/0a+5LIPaz8IT 77sGKmTq+iERujZpmf8wFZGSRbc+qOLWj9kUhHblV4AEZpI3iPCX/qEKUt4r27NrAbPm 8z/g== 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=zQaYoCe85C4OWs0lOZEThzi3C5V4+Gn0nWrkUoVxviA=; b=K+vDNCfnxyIFjs6mBEbqN1g/o0I4mbdyLQmlo0ny3ODsxh1gJLxyaCNwbyL8PZV1wo N29Mwr+5rS+bHnYt2HJuGSh8hNK8MLJKI7BcPVRAo45xhT6o/QDcjngia3Zx/e2A6s6c g+tWkRJM0AF2OBNxP/ceolaNMEvN6acRLpxJdnYEKbyMM/CxJ0zBt2MCjGbg5ZjBn5rg bcqBJlXadXUNb7OnaHXanA5/kyVGzfQL/eV9sQOu9hkFFSJ56j7IPCDHEEZc78xj8GcC STcj8qlemikrsUYu/O1DMAf9XkIl1k01GQ+HqrZbtt0neANA4r9r7RAagsjyly2size8 +yWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="SZogx2/s"; 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 z8-20020a63c048000000b003c21952c7c7si656986pgi.37.2022.05.12.15.03.22; Thu, 12 May 2022 15:04:08 -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="SZogx2/s"; 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 S1358289AbiELUG4 (ORCPT + 99 others); Thu, 12 May 2022 16:06:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358274AbiELUGx (ORCPT ); Thu, 12 May 2022 16:06:53 -0400 Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E114265D17 for ; Thu, 12 May 2022 13:06:50 -0700 (PDT) Received: by mail-ot1-x32e.google.com with SMTP id s12-20020a0568301e0c00b00605f30530c2so3485106otr.9 for ; Thu, 12 May 2022 13:06:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=zQaYoCe85C4OWs0lOZEThzi3C5V4+Gn0nWrkUoVxviA=; b=SZogx2/smQbOu1ljZOuPd1be4aSXBhM2T0qGSEzJH+p3lVSle6GL68sLBALkTUnEQg T9fliaMhIdImcbaGR8BkughVY0chn+k+f3YuQSvMMo88ni23k2AloWvCLQBEEb8hs5H+ /HyRBvVbLWZLWHyM679x0swWskgKVxOAaFeCwnG+khnruWbeQiASf5mkATYeZ+bnoXTd Oepk+aWBC+K/KYrcT54hgqPcgP8Jqp6A+a21SEmOw+rKBTIS8NaFWgqQ5pHe5EI17JmD 1xqLNu/iuY4rCLHouiBMtcF7EQqO2Qtf0apq7w1j9ZJZqZMcF3HFWbzXSSD4j8mIJ/Kw j9PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=zQaYoCe85C4OWs0lOZEThzi3C5V4+Gn0nWrkUoVxviA=; b=nHfrdzWy9Pc/JQv5ltqAKO0ITKSSJNyunai4vchzzEvdtGh+KKVvQ926+djjDB4xlK NtGaAwmeORrP3Qi6y/4h2YvWz8DN2yZhQchgQ+N5XtYYWPu/JWlOK2DcAJJ+/frGOx8Z TNvMDX2o7SqDnAznbdmNDw0fBWGXTGo9zTiIXiNuPeeZ/y7x20VzmwK5KRZiWq7QIk2c Bl5VwvhMNUqerNmAL/sPIuiWGEaJOcs3kxz5Zj/mDaJ0FSgPr2EYkADmqWqDFmxuqy2V bKcN2cWAAujpuzj/YRU7t5W3QZroTF4VeyuDyBmUWpWVKlSxWKz7lgzrgOGYXp7+EPeg gqsA== X-Gm-Message-State: AOAM533RxQM1gwEfWmWZgs65lipXRcdsaxV5FokIgIXGz4a43cAYBnf+ WQ8OXPMuVdHbYWX3X/kqtKE5/FFvUmzLzRBXiu8QEg== X-Received: by 2002:a05:6830:280e:b0:606:ae45:6110 with SMTP id w14-20020a056830280e00b00606ae456110mr664767otu.14.1652386009945; Thu, 12 May 2022 13:06:49 -0700 (PDT) MIME-Version: 1.0 References: <20220512184514.15742-1-jon@nutanix.com> <07BEC8B1-469C-4E36-AE92-90BFDF93B2C4@nutanix.com> In-Reply-To: <07BEC8B1-469C-4E36-AE92-90BFDF93B2C4@nutanix.com> From: Jim Mattson Date: Thu, 12 May 2022 13:06:39 -0700 Message-ID: Subject: Re: [PATCH v4] x86/speculation, KVM: remove IBPB on vCPU load To: Jon Kohler Cc: Sean Christopherson , Jonathan Corbet , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , X86 ML , "H. Peter Anvin" , Kees Cook , Andrea Arcangeli , Josh Poimboeuf , Kim Phillips , Lukas Bulwahn , Peter Zijlstra , Ashok Raj , KarimAllah Ahmed , David Woodhouse , "linux-doc@vger.kernel.org" , LKML , "kvm @ vger . kernel . org" , Waiman Long Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,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, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 Thu, May 12, 2022 at 12:51 PM Jon Kohler wrote: > > > > > On May 12, 2022, at 3:35 PM, Sean Christopherson wr= ote: > > > > On Thu, May 12, 2022, Sean Christopherson wrote: > >> On Thu, May 12, 2022, Jon Kohler wrote: > >>> Remove IBPB that is done on KVM vCPU load, as the guest-to-guest > >>> attack surface is already covered by switch_mm_irqs_off() -> > >>> cond_mitigation(). > >>> > >>> The original commit 15d45071523d ("KVM/x86: Add IBPB support") was si= mply > >>> wrong in its guest-to-guest design intention. There are three scenari= os > >>> at play here: > >> > >> Jim pointed offline that there's a case we didn't consider. When swit= ching between > >> vCPUs in the same VM, an IBPB may be warranted as the tasks in the VM = may be in > >> different security domains. E.g. the guest will not get a notificatio= n that vCPU0 is > >> being swapped out for vCPU1 on a single pCPU. > >> > >> So, sadly, after all that, I think the IBPB needs to stay. But the do= cumentation > >> most definitely needs to be updated. > >> > >> A per-VM capability to skip the IBPB may be warranted, e.g. for contai= ner-like > >> use cases where a single VM is running a single workload. > > > > Ah, actually, the IBPB can be skipped if the vCPUs have different mm_st= ructs, > > because then the IBPB is fully redundant with respect to any IBPB perfo= rmed by > > switch_mm_irqs_off(). Hrm, though it might need a KVM or per-VM knob, = e.g. just > > because the VMM doesn't want IBPB doesn't mean the guest doesn't want I= BPB. > > > > That would also sidestep the largely theoretical question of whether vC= PUs from > > different VMs but the same address space are in the same security domai= n. It doesn't > > matter, because even if they are in the same domain, KVM still needs to= do IBPB. > > So should we go back to the earlier approach where we have it be only > IBPB on always_ibpb? Or what? > > At minimum, we need to fix the unilateral-ness of all of this :) since we= =E2=80=99re > IBPB=E2=80=99ing even when the user did not explicitly tell us to. > > That said, since I just re-read the documentation today, it does specific= ally > suggest that if the guest wants to protect *itself* it should turn on IBP= B or > STIBP (or other mitigations galore), so I think we end up having to think > about what our =E2=80=9Ccontract=E2=80=9D is with users who host their wo= rkloads on > KVM - are they expecting us to protect them in any/all cases? > > Said another way, the internal guest areas of concern aren=E2=80=99t some= thing > the kernel would always be able to A) identify far in advance and B) > always solve on the users behalf. There is an argument to be made > that the guest needs to deal with its own house, yea? To the extent that the guest has control over its own house, yes. Say the guest obviates the need for internal IBPB by statically partitioning virtual cores into different security domains. If the hypervisor breaks core isolation on the physical platform, it is responsible for providing the necessary mitigations.