Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3813572pxj; Mon, 24 May 2021 15:49:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPf7SelFC629oyh2dUmbUA/b5NbpELFxNFdE1zkH7KDQCpv4sYvqdg1WEQSDqbUhTE3yuL X-Received: by 2002:a50:a446:: with SMTP id v6mr28656988edb.254.1621896579783; Mon, 24 May 2021 15:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621896579; cv=none; d=google.com; s=arc-20160816; b=zExn6ghqJOpghFIMtOGRpfnCWFcZu/35aT91LGs+ypM7+2ja4rLZIPCL7ak/5uAUJT eD0XGSjana77jvWnkjidv5K3helxgo7RrRXHK842NrvQWmDVvwt9eY5K+9P46JgFJAMr qF5CnWePLWJqr5ScN1gmtPpu803CcDMJfGt3BiqMPPR97W+3rWaMx/Ny50d10b54RTw9 BVxe9iO0VGUTaLH3iodp2GC8uudQwoT1uSKCUE82Y0RbTw7EzdZ2+jz0RhEWj//mtTu8 UCzLFvV37TAQU+po6jcy8ZyB5RMEWYTXBTwy91z3+mwsvgDJLKMr3XXHeBN8cBeMwNNP MYNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=hoy3e/I5xnBrFyarcOwWtri9p33MhFrhxPmYcCRuOP8=; b=P66txeXmQZKAcZNWlkhZICU6JIY7bje5Qf3ZRvM8OAiblt9iddD3Ryg3Yrdkx98bNP 3jKzYx2fgIF477ttNNZTx3jcw1fM+Dxk9mipTs5/WmpKorMKyi3d4Ty6//kY71Ge5Vb2 SsiPkdU1jGULT7RtvolgRQ+yqAsZW/vdJRC6YQCwzSe1+S5dcDIRWRgSWYitVEqbxI/l 2HbTo0nAFXhMvo2ECBnEHrn1+SZxqQCTaIsLHDvcbitkVMqwpFLA2yxUfvDbomENK4Aj pMkZkKtJKAE4B6pTXa6RC+OQJdmwgeKQjFNtRBlpbrcPAVITcw8lZKG0Zmda6fYfm8Sj srIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=l7eXdUCU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g19si15146878edu.311.2021.05.24.15.49.16; Mon, 24 May 2021 15:49:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=l7eXdUCU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229554AbhEXWtp (ORCPT + 99 others); Mon, 24 May 2021 18:49:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbhEXWtp (ORCPT ); Mon, 24 May 2021 18:49:45 -0400 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 499D6C061574 for ; Mon, 24 May 2021 15:48:16 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id i12-20020a05683033ecb02903346fa0f74dso16120889otu.10 for ; Mon, 24 May 2021 15:48:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hoy3e/I5xnBrFyarcOwWtri9p33MhFrhxPmYcCRuOP8=; b=l7eXdUCUS2uQYjPY2ylTXmFp1AtY/hF+NCpE9LRTeTvR4y49DU7F8tuIyWp5Il0aOk KCTpGZ3ObZsoVRQfHnOBDllSo7GM5BuGNuwc4q2BnEt4biUSqmZSXz7XIbZqR2uHe1qg kO8LiGVD500dgFPKd5hpVos1GRytTZbVrtbggOiXpPrdC2mMCgzPpiQKoRoiWprEX0Ar V70e+hFHS6Kso0b7roWinUO3YK0ZoHk2jgG0LVqgY4cy24Me6XzBF+Ev1pxpzC967A6S KPdTMhhbiSxXrxH2lv1kwH2tvmXwhlN1d0LMx0kH/LPVt+5/S8DXrcEQXWP3b6QIOyMO FuBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hoy3e/I5xnBrFyarcOwWtri9p33MhFrhxPmYcCRuOP8=; b=E/QkVJ5uTURTFZRr0a/E4mvT884sYu0X0XsmTgg8X/qwHs4kLn/m8XSlvqfYSpI/7I f1PEonFOmmNONPYB76Dl36F4P5c79nCgsPnj95+UCwpBovKwSpiI8+yf9dThIwxQ7pH2 RH49v1B1r9+Ka1Xsi3SbbW/mp8BHQzIOonv3f0HWzjuU1rXWS2evwd3F/atAIlliBTbe QR9ydRq+gMYtdUdgZUgFvERbz7iXgBqgrSI+PAVbDdc3INYzir00xSzi+eOXzl4JX/x5 bXGwBzwagw3jKfVpAhhQhDaQy/aZhSVu7St9Z6bRh72fIVl+dtTNIOliNk+B+c0JH/kS u5nw== X-Gm-Message-State: AOAM533AL4rTc/iZkOBRqMxibEbNw2DRhNJsH8RbX9tnELp7aDkvlbhD TjuEMuPyC2fz/7lepsgdD0hlvZMTj74lrDx305aUVA== X-Received: by 2002:a9d:131:: with SMTP id 46mr20854696otu.241.1621896495340; Mon, 24 May 2021 15:48:15 -0700 (PDT) MIME-Version: 1.0 References: <20210424004645.3950558-1-seanjc@google.com> <20210424004645.3950558-43-seanjc@google.com> In-Reply-To: From: Jim Mattson Date: Mon, 24 May 2021 15:48:04 -0700 Message-ID: Subject: Re: [PATCH 42/43] KVM: VMX: Drop VMWRITEs to zero fields at vCPU RESET To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm list , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 24, 2021 at 3:28 PM Sean Christopherson wrote: > > On Mon, May 24, 2021, Paolo Bonzini wrote: > > On 24/04/21 02:46, Sean Christopherson wrote: > > > Don't waste time writing zeros via VMWRITE during vCPU RESET, the VMCS > > > is zero allocated. > > > > Is this guaranteed to be valid, or could the VMCS in principle use some > > weird encoding? (Like it does for the access rights, even though this does > > not matter for this patch). > > Phooey. In principle, the CPU can do whatever it wants, e.g. the SDM states that > software should never write to the data portion of the VMCS under any circumstance. > > In practice, I would be flabbergasted if Intel ever ships a CPU that doesn't play > nice with zero initiazing the VMCS via software writes. I'd bet dollars to > donuts that KVM isn't the only software that relies on that behavior. It's not just Intel. It's any manufacturer of physical or virtual CPUs that implement VT-x. Non-architected behavior isn't guaranteed. > That said, I'm not against switching to VMWRITE for everything, but regardless > of which route we choose, we should commit to one or the other. I.e. double down > on memset() and bet that Intel won't break KVM, or replace the memset() in > alloc_vmcs_cpu() with a sequence that writes all known (possible?) fields. The > current approach of zeroing the memory in software but initializing _some_ fields > is the worst option, e.g. I highly doubt vmcs01 and vmcs02 do VMWRITE(..., 0) on > the same fields. The memset should probably be dropped, unless it is there to prevent information leakage. However, it is not necessary to VMWRITE all known (or possible) fields--just those that aren't guarded by an enable bit.