Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1020822iob; Fri, 13 May 2022 19:56:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2e8XO6cAaSmkkwEjqwM+/rBKi2aaS/4e0c7TeWtItOXPLeBiwRSd/2v/zOhn3ELyVaMaY X-Received: by 2002:adf:d1e9:0:b0:20c:6c76:14d5 with SMTP id g9-20020adfd1e9000000b0020c6c7614d5mr6295843wrd.375.1652496967490; Fri, 13 May 2022 19:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652496967; cv=none; d=google.com; s=arc-20160816; b=FSHwCApNwCkzeh7czoOo0cRIPmPMltrXrkGDBSSxKr8F4HE/EfVc78e9+g4LKUi2yg nD7nb1OqfdlYGF7cp8T9Fn4lRiK7ZkZtN6DzcV2EiObUpt2nOxsHk94oacmfSRuByku3 1FpVostU3k83luG83T7pQRCgc+iH0pD1T17XV84u1QU+8Lqq2odztRE4hWceji4OzW/U KK1WA8GdVKySXiLdTiM1jGq4L/G7RQhq4f48Q8limVym5YzAKuHnbwiu+oJLsOp8GNj/ gZYrKIfmaJ7d89A/ihz87NX1PWNuqZ/IvItTYUfT9E1+ewtNr4LJG/II0GiK0xrppAsN bZ1g== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=iOAKB7vKEZEg22vxCywimbh0xLHgxT/3D2j+uYXG4Rw=; b=vUCjJsr2dvXfsOyudsMW9IAJh23/4RcAU2K0i0KCIg0DbaggQSi2v0e4oILlg3XDYm VN25wzaIPBbUifvkjrHMOc6ILqIXmYPwgDPDhJGL5s7015P9rbDKz30DIwRpOShrcuXq J3GH2Uij8Ae7Vk1W+meAV0bIAKaBc1/476Npz46ajOeedUa0SgzQK/AoxMv3QUuABGIl T/Ymw2WCTIFQqr+l4v41JOhx9ugMtPMQH1nXceDU/TPy4Ez3LKDXsoqUDaiD0VLNSOHB 6MMqq641ZLeuu4uay7QCfGm4m3wEEwyoppo+3X0rjDNN5EVlqRqRdmBFiGzhvdrZnz0B 262g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=CxfhAMbb; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s9-20020adfa289000000b0020cdf9d108bsi3447957wra.317.2022.05.13.19.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 19:56:07 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=CxfhAMbb; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CED5E38F2EC; Fri, 13 May 2022 16:41:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358292AbiELUH2 (ORCPT + 99 others); Thu, 12 May 2022 16:07:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358288AbiELUHW (ORCPT ); Thu, 12 May 2022 16:07:22 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEBDD69736 for ; Thu, 12 May 2022 13:07:21 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id s14so5960375plk.8 for ; Thu, 12 May 2022 13:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=iOAKB7vKEZEg22vxCywimbh0xLHgxT/3D2j+uYXG4Rw=; b=CxfhAMbbtns0lTpJyPbLHoLtAWBjF+jQgBLSV3SbRZEEkp7AM6u3irkMLYD7+aJc/z YQhlkbqq6wKSwFd7w80FpEAONky2GqoH8nE2S3+bcyCMIoH/p7pn0NpxfrUvqTPe+WbH rvFIUheu+Lc4+9Qkbs+wm+v0Tp+6pvFz5apm7CRjYolOOW0olf5gDDh6jQPMbZ11KJAn bYfg1Su6uVO9Syc3E4/QPVVxpPdusdNaw3PsaEHhAnaAkzZdVHaA5g5l0ajZSW1ht2m0 d/ixsrgV4wsESqC5ala+wpcPi4pC9M+IlXiSgAAyaBpnavYCDSVgUULfV9TSr/VFUoMh Qzjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=iOAKB7vKEZEg22vxCywimbh0xLHgxT/3D2j+uYXG4Rw=; b=bTMzOksdgDAaHsPr5tdMAp7lhmi3gH6h044aEyqaIErnIkIf2YscO9iPPiRbTiKSi8 EIqnmgRIqDsUNFl4qoCd0waOBT+sNIaldyN80wzEuXyUSuojG1C2TrVO2CpFbuDCT0H+ HwGHHPvdI5WJz9IM6AC4fe0o8v4CuGR7FYq4bFvxUmybtJguBy9taLwJFhojy91hdZdM ReNcxqRhFOlo5KkPwJzVQjLHLoFqe+VI06chUelPU/0f6iTRelMDyBN9bQEoPDSB9RKE kuZ15Nojd0igP8ct4qPZ+hYYU4jDgQKSFrQu+GBvvqgn95a9yWNbzcjEdTfdP4cAoH69 r86A== X-Gm-Message-State: AOAM531Xwfx5+wcG08MGbMRt8XNQu5dySyd41EtjGqu2T3hS4yM7zyWb MFvkNs/w2CL0nnCWRMyWM5g/Bw== X-Received: by 2002:a17:902:ec04:b0:160:8bce:b073 with SMTP id l4-20020a170902ec0400b001608bceb073mr1119286pld.127.1652386041149; Thu, 12 May 2022 13:07:21 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id b11-20020a170902650b00b0015e8d4eb1c4sm341131plk.14.2022.05.12.13.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 13:07:20 -0700 (PDT) Date: Thu, 12 May 2022 20:07:17 +0000 From: Sean Christopherson To: Jon Kohler Cc: Jonathan Corbet , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , 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 Subject: Re: [PATCH v4] x86/speculation, KVM: remove IBPB on vCPU load Message-ID: References: <20220512184514.15742-1-jon@nutanix.com> <07BEC8B1-469C-4E36-AE92-90BFDF93B2C4@nutanix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <07BEC8B1-469C-4E36-AE92-90BFDF93B2C4@nutanix.com> X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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, Jon Kohler wrote: > > > > On May 12, 2022, at 3:35 PM, Sean Christopherson wrote: > > > > 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 simply > >>> wrong in its guest-to-guest design intention. There are three scenarios > >>> at play here: > >> > >> Jim pointed offline that there's a case we didn't consider. When switching 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 notification 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 documentation > >> most definitely needs to be updated. > >> > >> A per-VM capability to skip the IBPB may be warranted, e.g. for container-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_structs, > > because then the IBPB is fully redundant with respect to any IBPB performed 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 IBPB. > > > > That would also sidestep the largely theoretical question of whether vCPUs from > > different VMs but the same address space are in the same security domain. 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’re > IBPB’ing even when the user did not explicitly tell us to. I think we need separate controls for the guest. E.g. if the userspace VMM is sufficiently hardened then it can run without "do IBPB" flag, but that doesn't mean that the entire guest it's running is sufficiently hardened. > That said, since I just re-read the documentation today, it does specifically > suggest that if the guest wants to protect *itself* it should turn on IBPB or > STIBP (or other mitigations galore), so I think we end up having to think > about what our “contract” is with users who host their workloads on > KVM - are they expecting us to protect them in any/all cases? > > Said another way, the internal guest areas of concern aren’t something > 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? The issue is that the guest won't get a notification if vCPU0 is replaced with vCPU1 on the same physical CPU, thus the guest doesn't get an opportunity to emit IBPB. Since the host doesn't know whether or not the guest wants IBPB, unless the owner of the host is also the owner of the guest workload, the safe approach is to assume the guest is vulnerable.