From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A14CBC433F5 for ; Tue, 10 May 2022 14:56:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345343AbiEJPAv (ORCPT ); Tue, 10 May 2022 11:00:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345197AbiEJPAf (ORCPT ); Tue, 10 May 2022 11:00:35 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEEF61271B7 for ; Tue, 10 May 2022 07:22:15 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id x88so4464588pjj.1 for ; Tue, 10 May 2022 07:22:15 -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=96fSaQwSEKdzhJug6s/ISEl8NYk3c2RDSas8DqlcA5w=; b=g574joSyahf6XWUX/Lnob9ZLo6UrKXwHHmmJyn3M7gflnngYL0fXMZ1GNnLQlZNRnO lk1H5/5/wVOIblC31ckvcokOutL/YExJkjcuVR3T2aK7vXTFv5WsT2sm9GnRnSlUwAJL GIXZOHO5Rk8fbMXWLU/J8pwIFvck+ueAanIhtgjqHd90RDfeuHLW5zqqUefkfxGxXWdQ Yr2E5nzKPeusenjIgtCSSq6YxaNo97VjySQmB21ZsX7DbJSOQynOuVzf49YfJJhkCQVS 7sh9FDYfv60HN0muf43DXOEQ7EI1i4Qkdr0Dq7qcDTmuP6SDwupLx+btugKqr0WD9g9p 1iwQ== 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=96fSaQwSEKdzhJug6s/ISEl8NYk3c2RDSas8DqlcA5w=; b=77aJjPkR5yTsazI8pd3zSgQlsnsaIcLE2yD32fhDLX+tB9GF0nXqLt6kZL+FbLi6l5 XbyFBbKvRu9GPyLqIOszXBPFdXF+hqN50spO13ycoM957BsNIciHAVGd/P6fsCsYXDxG SwXs6uoKMEolCBsswmrnRXglJjOMkfVIwlBnfnDThZtGgKkIFOOrBDFvmGLbpdtj+Eux ATVkE9ObqNrt5DUi3q2zgyupMLaaqIMxhjPEaPNLl8V/LAqc3KxBkM3X2E4usqrqGmP1 uCCHI5TMBzEdDSp1lfaJSUVi6gJCymgUax5rh3sz3zVcmv3H+UJsc0CAE+kFWvtbUGF4 MxYQ== X-Gm-Message-State: AOAM532KlKVZwNDjAb73fwigc15D5AW3dQYzOxCcl/UH5TwOSd3GYrDK E38kW25PiImdxw5prcxe7grAxw== X-Google-Smtp-Source: ABdhPJx7PsVQomRvckqYDAybqAGOiMLH95hlWgarTNYXO+eMC+95JlU0QlBLIWIa984tkMCt6p0LIg== X-Received: by 2002:a17:90b:3e84:b0:1dc:5942:af0e with SMTP id rj4-20020a17090b3e8400b001dc5942af0emr235327pjb.61.1652192535114; Tue, 10 May 2022 07:22:15 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id p6-20020a170902bd0600b0015e8d4eb265sm2088260pls.175.2022.05.10.07.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 07:22:14 -0700 (PDT) Date: Tue, 10 May 2022 14:22:11 +0000 From: Sean Christopherson To: Jon Kohler Cc: Borislav Petkov , Thomas Gleixner , Ingo Molnar , Dave Hansen , "x86@kernel.org" , "H. Peter Anvin" , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Josh Poimboeuf , Peter Zijlstra , Balbir Singh , Kim Phillips , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , Andrea Arcangeli , Kees Cook , Waiman Long Subject: Re: [PATCH v3] x86/speculation, KVM: only IBPB for switch_mm_always_ibpb on vCPU load Message-ID: References: <645E4ED5-F6EE-4F8F-A990-81F19ED82BFA@nutanix.com> <4E46337F-79CB-4ADA-B8C0-009E7500EDF8@nutanix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4E46337F-79CB-4ADA-B8C0-009E7500EDF8@nutanix.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 30, 2022, Jon Kohler wrote: > > > On Apr 30, 2022, at 5:50 AM, Borislav Petkov wrote: > > So let me try to understand this use case: you have a guest and a bunch > > of vCPUs which belong to it. And that guest gets switched between those > > vCPUs and KVM does IBPB flushes between those vCPUs. > > > > So either I'm missing something - which is possible - but if not, that > > "protection" doesn't make any sense - it is all within the same guest! > > So that existing behavior was silly to begin with so we might just as > > well kill it. > > Close, its not 1 guest with a bunch of vCPU, its a bunch of guests with > a small amount of vCPUs, thats the small nuance here, which is one of > the reasons why this was hard to see from the beginning. > > AFAIK, the KVM IBPB is avoided when switching in between vCPUs > belonging to the same vmcs/vmcb (i.e. the same guest), e.g. you could > have one VM highly oversubscribed to the host and you wouldn’t see > either the KVM IBPB or the switch_mm IBPB. All good. No, KVM does not avoid IBPB when switching between vCPUs in a single VM. Every vCPU has a separate VMCS/VMCB, and so the scenario described above where a single VM has a bunch of vCPUs running on a limited set of logical CPUs will emit IBPB on every single switch.