Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp805133iob; Fri, 13 May 2022 13:07:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKR+J56iGVOO7r2imOkMR9J/q1csyKanLQv15+emi5fAqH0kJGGFVpnLq5Jjwfi5D+XXi6 X-Received: by 2002:a17:907:160c:b0:6f4:4b2c:8e53 with SMTP id hb12-20020a170907160c00b006f44b2c8e53mr5765707ejc.10.1652472428861; Fri, 13 May 2022 13:07:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652472428; cv=none; d=google.com; s=arc-20160816; b=qkkCMso2OxCGYo0u1tYunULZcqc6GrItyPNPjyytk5ePdvmBs9fHbcq12P+VWMo0EW +KhYy5qQWTCdtAHR8erI9RSEIuH7QFPmi1t7A900+fL4THizUw8iugi+atlqirOr4eBZ ysHqNcnT6dizQRaxoocxd6j6ZVO6IDTQBbJeM/2Zu+OY8Lt2KTmOrgJYxBHo9OXa+pHc Yk5QC1w9lMevbbRKDZJGEBMSphTpYQUQnbPE0ph6XSlZmVoF9WyEb4mVb9go5P/1Uk1Z D0WvGvITM1RyNlS6awLKXxfjvkgqWSGPLMX0xdz7jOmsZiwv027CCHxwwNBE/EllMew5 ZMaw== 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=3RxQPTxtVrqqVoiaHfpMeR5z0m/4z2ervHUzJOsJZ9g=; b=H/sDFkT4i/kNNGArV1zsJll5bW3EzvzyX7EDrwxZjXybMMthpjqfEfZVP5+9gpNp9c YFeW5AmI69Rf+lHkK9aj2JuMH5mqBinjOmc1PUDsZzolJNumSIfxruMotk3OCY0kOkM1 Op+LuWIhbTTAGEkIRJ5v2zc940cej52GGKs1fvugXmS/1VN7gpLR5Q9P3IryjiToMD8W QGUfYtymxOKzEDRaMYt8cUXva6Ej+6+Y30EPuqPTY6eVPO0aEqWKlDCaByJLDL46rxUa S/kuKimc3XuLZuksFUoBUG+UWlpqNdRa2vzjnGBBrhKywtqdOpw/Cq0YSFc90SN/zSql VZjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=HVDFRvfc; 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 hr28-20020a1709073f9c00b006f3c442e22fsi3153547ejc.361.2022.05.13.13.06.42; Fri, 13 May 2022 13:07: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=HVDFRvfc; 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 S1383834AbiEMThJ (ORCPT + 99 others); Fri, 13 May 2022 15:37:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383686AbiEMThH (ORCPT ); Fri, 13 May 2022 15:37:07 -0400 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3F5954182 for ; Fri, 13 May 2022 12:37:05 -0700 (PDT) Received: by mail-oi1-x22c.google.com with SMTP id e189so11312586oia.8 for ; Fri, 13 May 2022 12:37:05 -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=3RxQPTxtVrqqVoiaHfpMeR5z0m/4z2ervHUzJOsJZ9g=; b=HVDFRvfchpN7PSr7N06wi5d+LNSlIIt5soxH3QJ0+gRBVr/dSg3cRv/Kfvc+wdo32N pibM/02iUEue6Qxq/rOTds4X5rjrw8cvNTSdnZnzhOEgDrBLoUvFjtWAdyj7d2Fx9lmY pLyD/RPmCSmos2YTVv3X/wr2j4M2h77vSHOD01u8pQyumY7R6aOwyYLtD1gUssCgTSP8 kU3Tupzqd99Tu0kb6YusiYStRndmJ1gpmeq27VqYWLNqjul+u3ecx0MnP2hZIVnL6x2B 28OLuzcm2pIx8EfHUdyyHbuZB0sHYpa7hbo4deW3vh6/bY1itk3QrppPHft2Y5zqdWrU JhBg== 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=3RxQPTxtVrqqVoiaHfpMeR5z0m/4z2ervHUzJOsJZ9g=; b=bOdN3V/1zvqaeiQrzCxx5n2T5snoK3TsYKREcmYH6Ej2OWPoBIfok2JsgBhoTy9B/Y sLJJQvZYZM62dXXYSFXkixnCF9tqgkJ5vqxPKAArZPlLbbLK7GZnJFaKh8PjmhnxI5jf fD4dy2MHpfMwbP1tzIiotzW6VDL0w+mrgDR1OorwFUPnpuSKNpXYmsd75eU/WCDVaD7n jKe1l5lljNTClAJwl2V+2pLk+8qUsLbC7yIYpYC86AFMaaShDhVCrNcHx/tWQ3WOBKw5 tlaKefdLXr7DJGTAOeShog4t58ty9QwnzN7Wc8FkhFsh6xCAuaKw/gSDqUvPJhGO9Wq5 zZnw== X-Gm-Message-State: AOAM533f38q2a94zxPn2wW3jEymeG4c41ub6l9zmQCgfENZY/SWGAeDq fMfKLqEZVhPNYGeoRJVmbBr5NbbeZpDcbxkjVqEvqg== X-Received: by 2002:a05:6808:2125:b0:326:b51f:bbc2 with SMTP id r37-20020a056808212500b00326b51fbbc2mr8695466oiw.13.1652470624894; Fri, 13 May 2022 12:37:04 -0700 (PDT) MIME-Version: 1.0 References: <20220512184514.15742-1-jon@nutanix.com> <07BEC8B1-469C-4E36-AE92-90BFDF93B2C4@nutanix.com> <73BC3891-34DC-4EB7-BD1C-5FD312A8F18A@nutanix.com> In-Reply-To: <73BC3891-34DC-4EB7-BD1C-5FD312A8F18A@nutanix.com> From: Jim Mattson Date: Fri, 13 May 2022 12:36:53 -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 Fri, May 13, 2022 at 8:21 AM Jon Kohler wrote: > > > > > On May 12, 2022, at 11:50 PM, Jim Mattson wrote: > > > > On Thu, May 12, 2022 at 8:19 PM Jon Kohler wrote: > >> > >> > >> > >>> On May 12, 2022, at 11:06 PM, Jim Mattson wrote= : > >>> > >>> On Thu, May 12, 2022 at 5:50 PM Jon Kohler wrote: > >>> > >>>> You mentioned if someone was concerned about performance, are you > >>>> saying they also critically care about performance, such that they a= re > >>>> willing to *not* use IBPB at all, and instead just use taskset and h= ope > >>>> nothing ever gets scheduled on there, and then hope that the hypervi= sor > >>>> does the job for them? > >>> > >>> I am saying that IBPB is not the only viable mitigation for > >>> cross-process indirect branch steering. Proper scheduling can also > >>> solve the problem, without the overhead of IBPB. Say that you have tw= o > >>> security domains: trusted and untrusted. If you have a two-socket > >>> system, and you always run trusted workloads on socket#0 and untruste= d > >>> workloads on socket#1, IBPB is completely superfluous. However, if th= e > >>> hypervisor chooses to schedule a vCPU thread from virtual socket#0 > >>> after a vCPU thread from virtual socket#1 on the same logical > >>> processor, then it *must* execute an IBPB between those two vCPU > >>> threads. Otherwise, it has introduced a non-architectural > >>> vulnerability that the guest can't possibly be aware of. > >>> > >>> If you can't trust your OS to schedule tasks where you tell it to > >>> schedule them, can you really trust it to provide you with any kind o= f > >>> inter-process security? > >> > >> Fair enough, so going forward: > >> Should this be mandatory in all cases? How this whole effort came > >> was that a user could configure their KVM host with conditional > >> IBPB, but this particular mitigation is now always on no matter what. > >> > >> In our previous patch review threads, Sean and I mostly settled on mak= ing > >> this particular avenue active only when a user configures always_ibpb,= such > >> that for cases like the one you describe (and others like it that come= up in > >> the future) can be covered easily, but for cond_ibpb, we can document > >> that it doesn=E2=80=99t cover this case. > >> > >> Would that be acceptable here? > > > > That would make me unhappy. We use cond_ibpb, and I don't want to > > switch to always_ibpb, yet I do want this barrier. > > Ok gotcha, which I think is a good point for cloud providers, since the > workload(s) are especially opaque. > > How about this: I could work up a v5 patch here where this was at minimum > a system level knob (similar to other mitigation knobs) and documented > In more detail. That way folks who might want more control here have the > basic ability to do that without recompiling the kernel. Such a =E2=80=9C= knob=E2=80=9D would > be on by default, such that there is no functional regression here. > > Would that be ok with you as a middle ground? That would be great. Module parameter or sysctl is fine with me. Thanks! > Thanks again, > Jon > > > > >>> > >>>> Would this be the expectation of just KVM? Or all hypervisors on the > >>>> market? > >>> > >>> Any hypervisor that doesn't do this is broken, but that won't keep it > >>> off the market. :-) > >> > >> Very true :) > >> >