Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp968720iob; Fri, 13 May 2022 18:03:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+bSKci8IEE8w0k86siQ8WmXB76p8LivwePp0XeeqTHHm0Lt82t2FEusjg2v7oWC+Y8ztG X-Received: by 2002:a05:600c:1989:b0:394:8dc0:b57f with SMTP id t9-20020a05600c198900b003948dc0b57fmr17257027wmq.110.1652490225892; Fri, 13 May 2022 18:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652490225; cv=none; d=google.com; s=arc-20160816; b=rg5KBgwPng1fetAANQ8tkSI/yiD/SuOY9e8OkPY8Xw1+fPFd0ku63DTvWE0EirG4MY h1ZktmeR9SYItL0Iejus4Hmp6GUK3BWRHZgpFBk/QMHmQ2EXU/8dZhuoWv4Ft2zq4gTx shpdZ/TkCUcpnJlX5urUGbBMVwc5TCvB960WMBSeN7lVbaQVLCcxycyCcBcJUs2JAzuU s55bcllr3xAM7IpPFsJaRNh5kcJPQ5eemQqDE23VlHjTHOlGcB1bEMP2PySgbSgm0uml BzVD5NeFGzvXs34JXpWY+OEBv/+a9V96B9/S9usahef+kNVEbFRH7nv/tvZvEApsBSBA HopQ== 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=sGoOKvntmctjnTFpu4Xea6mgPsfoHZFHEqN6iO1ZtLc=; b=TbYiQk5B7TXvJlgQxMau9cj4QhcnaSZPsDHxffWcaVa2J3SXXZdO378pHzMxR/v/E9 pI0hiCXbkaX8XI9lcxRX2Fe+v8XV87HjHLPyE04OE7q9we9SqEx21FStoVc/RTAUxg7N p27WigFS9BvCMZK/sk8TTqf0S9jY5HTSkzS3hK7d+tmNncb3gHAyUlfOt0lnN7eg2uSQ F30/lQAlxJgf9mrxnBIh7Bct/pQwCJGs1mdwB7nxIr0O6KKdKOLjMZDjyAIuXn2mwFxW XMmZCIN1mig29E/X+5K++6sxBB+nAEDRG98Z5EWqzArE2WldOBgreyvS3mpVsdXd5P4t AhaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=JMDSojiE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f3-20020a5d58e3000000b0020c5a159443si3524548wrd.280.2022.05.13.18.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 18:03:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=JMDSojiE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 7BBA5373C60; Fri, 13 May 2022 16:37:04 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358365AbiELU1j (ORCPT + 99 others); Thu, 12 May 2022 16:27:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234715AbiELU1h (ORCPT ); Thu, 12 May 2022 16:27:37 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C998351327 for ; Thu, 12 May 2022 13:27:35 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id w130so7879857oig.0 for ; Thu, 12 May 2022 13:27:35 -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=sGoOKvntmctjnTFpu4Xea6mgPsfoHZFHEqN6iO1ZtLc=; b=JMDSojiExZcn87ffWKkeqGVQmX/krfAFVjMPpYkk7+FfjLTnA88RVyvcURfoPkpBRe A6RclZi5OpkvLf8wo5kX68mOlDJYyTgsxNTGb4bPJpUy1kvmmuvdJxXr2ktjN5vBIlUP uZ0IWS/Z3K7N4HafatfJ9/2In2VUmbgt5j6THdq/VvUfUiaHq+OC6rsufuhjRhuu1yDQ UTj9uhobz63kSEvJEfF4yt/1wNDHO5bsknkSBs+QnRy9HGH2VaP9wUT7G6/6dzrqgvs2 DVuEKtSm0b+AuwVnHfmb8RXk1KEUBVkUIgF/LzZ4oTIB+QMbDU++6dylbTPaG/2Qg5y5 KARw== 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=sGoOKvntmctjnTFpu4Xea6mgPsfoHZFHEqN6iO1ZtLc=; b=8O9ChwHxMkRCR4EUnznxd0FcqEw/c8tsJRTHGJn0SOHjxMA1suK1mnHtz+ZXuSIvuL IbBInNZ3vbRCJnfzgG0kAVj08xe7YTQ9BGmqNT/yp81Dj3O3MOQFh1J/Ri5aCSLBwD3A hUSmPHYA7i1oH5qx6xfcyCqzTU3tC8VFHrJ5QHfMnQoKeaFFGvnTZkVgQCle+XCZ5fCb kaJ8xvrerZFYvCG3ullBg8fJwTWz5dnRPRK4gTrDRK3wFnR6bjnH7z60xWhx62+ad9kN t748sJPQ9x8v0hJW2i7+t6v/avDCsWJltts0XSlE7rVx3R7xrOuPa1nTRqP7c/xQz7M1 UgIA== X-Gm-Message-State: AOAM532fI752UiUm7TDBGj+3leENYG+4OXPiePCneyInhg0q/ZUHFslV qhof/kUhvpQlSCngtbbDyPMwkwmbX1xTsq/CbbyHEw== X-Received: by 2002:a05:6808:c2:b0:325:eb71:7266 with SMTP id t2-20020a05680800c200b00325eb717266mr6342516oic.269.1652387254885; Thu, 12 May 2022 13:27:34 -0700 (PDT) MIME-Version: 1.0 References: <20220512184514.15742-1-jon@nutanix.com> <07BEC8B1-469C-4E36-AE92-90BFDF93B2C4@nutanix.com> In-Reply-To: From: Jim Mattson Date: Thu, 12 May 2022 13:27:23 -0700 Message-ID: Subject: Re: [PATCH v4] x86/speculation, KVM: remove IBPB on vCPU load To: Sean Christopherson Cc: Jon Kohler , 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=-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 at 1:07 PM Sean Christopherson wro= te: > > 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 scena= rios > > >>> at play here: > > >> > > >> Jim pointed offline that there's a case we didn't consider. When sw= itching between > > >> vCPUs in the same VM, an IBPB may be warranted as the tasks in the V= M may be in > > >> different security domains. E.g. the guest will not get a notificat= ion 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 cont= ainer-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 per= formed 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 dom= ain. 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. > > I think we need separate controls for the guest. E.g. if the userspace V= MM is > sufficiently hardened then it can run without "do IBPB" flag, but that do= esn't > mean that the entire guest it's running is sufficiently hardened. > > > That said, since I just re-read the documentation today, it does specif= ically > > suggest that if the guest wants to protect *itself* it should turn on I= BPB or > > STIBP (or other mitigations galore), so I think we end up having to thi= nk > > about what our =E2=80=9Ccontract=E2=80=9D 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=E2=80=99t so= mething > > 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, u= nless the > owner of the host is also the owner of the guest workload, the safe appro= ach is to > assume the guest is vulnerable. Exactly. And if the guest has used taskset as its mitigation strategy, how is the host to know?