Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp151172lqb; Thu, 14 Mar 2024 07:48:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVfXdO3gsq+nSUaBGQ+WzwhD/gxzXP9mLpVl8ITEAeemD6I80IEJUq9ytmTcTnAOlwFs3TM7wB+kUIer2u/fRITVEDjUh4C/65gDkCIfg== X-Google-Smtp-Source: AGHT+IFj60mwter4aw6vSWkq8zzJZpdyMj5SYIq+lTzFLiqayIkoRXsOMaE5czZKXR8GmxsGcN2G X-Received: by 2002:a05:6a00:4fcd:b0:6e6:9ff1:3055 with SMTP id le13-20020a056a004fcd00b006e69ff13055mr2379008pfb.15.1710427694888; Thu, 14 Mar 2024 07:48:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710427694; cv=pass; d=google.com; s=arc-20160816; b=Om6MisoLQIXBOq6LVnVQ/PiRAazHrMYIhMjW5fP/Q+mUfchkuQ6oe2R9YzNVTdK19U hvVHZG6bwXGlLGkuIQr32LXMjrcJQ7MC1XfH8e5yz0A+wa7VjhFMOzXGMiFd0OwF32Le 4QC4jxsVtU87rcZvNmP2pZv263i9l7NeV5WMtBeWnHa/igO2vmMjEHrtwec6dW0zUO/k 4ZZ1QQk+lDNo1ImGOXHhJf2CVTzoWhjpAfZ9xppIS/58whOnN2iPCJLSrsvd9YAsEOBg +V/reP8keNBzcywquw1/Z043HIt4F6985qAXifW+dkfYXD/tZi/MVIUo46flQf/005yK LuMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=UCLtGcT112yIVdDhvDfaxSfuuQ/aEnwbhFAj1Y1MJlw=; fh=zcYk0hhie9EvI3JTXZUbxAQg4K/eiRBhqYHAbScacp0=; b=ZTxaZI4228AmKZi991Y+tw4CvbDW7J4DF1/DIiVkH5O7A9Frb7kYfBvYy+7IS+EEvC Ws6fjN9lQhwGDl8LJOJAO/oNQrOuj0+QAK9W4x0MDFNK7fBz/3AryxJ3teRCbnC68dRY CIb6NdP9SNmvLExaifBtTqqRumVUG/FvXCmmFf6huvkaw0jHAmaRHASmOalxDzlsv8KV oQKlwN/xKEXGZ2ZIH7qRhKjDHZJ3dMZiUZEU+9/i9hwJ1h76suN5AX5JH1lCenXZt2eJ FX2Afz4njhu96KrjrZsE4Ha2g45x6K6UysSYhofeSfYC9LtY0Ft9X6TRN2GHOdJ31+E6 gSAQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=L4BnZfR4; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-103433-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103433-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t23-20020a632257000000b005dcbb6a2cccsi709070pgm.44.2024.03.14.07.48.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 07:48:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103433-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=L4BnZfR4; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-103433-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103433-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 005502843CB for ; Thu, 14 Mar 2024 14:48:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87C7F7173A; Thu, 14 Mar 2024 14:48:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="L4BnZfR4" Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6219B70CDF for ; Thu, 14 Mar 2024 14:47:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710427680; cv=none; b=t+0iycpT/+MTab6foamCIfd67d7Fga6YtZW2YEgtNQ3z/UaWfDiD/GUHtOh9L/hC255Hc+sFLct5xjaMuSDbTTjlVLGSDRYEr4fHa4Dr1gTPR94/2xEiWwv+6EPOOnlFq0Xka6rCx8Qs3/5J+mTEb+ozf/lEDYNNIg3XhpxxULs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710427680; c=relaxed/simple; bh=o8GtUI7JCR1UlHN2Jj7OLRVxrCmqhcWR9eQX21BsIY0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=BcrAUHqljNZv6TrJWKkLY5jWljHELqPJe7g1MH10Z0XxRgQn1ORn1jo/okaois9dMno+tAgbdG0PJWFgSsn3IcMJ9fP5FFmEodSiKxb+ekfubIkLBsULuxMwwHTOzNqPgtmMrThbRJNsZF1+V8QCr7nDgRQEcA3Fc0B6yiCT9yY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=L4BnZfR4; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-6e6b3bff094so1297913b3a.3 for ; Thu, 14 Mar 2024 07:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710427679; x=1711032479; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=UCLtGcT112yIVdDhvDfaxSfuuQ/aEnwbhFAj1Y1MJlw=; b=L4BnZfR47Qlt94yHryz6Xj3xsgDwbIB64vQogZFwiE4/ZqXqRPJHHRFv6E2+Qp7k8E UqUzs2dLr6WLQPtoXKash8SGD+b/9pZn4WSwTDhe2ssYaUPCR60Hx8plCcHE+Ub9/tU2 qPiB5uVXuC/szoR/i4p1XXDs6IMw/BkxcYHA8B3imypY2pJu2t0qAogrK8Z/IN5C+u9q SVu1/UVcYFXxWzLuPEESMo98Vtt9tJuOyRUHtGxOQdk0LrtGpUUq4CkEdWD+nrkD5W37 WpBqoi0Jxl5F3XF97c9jwlCR1fA2+mH7glIekoCkZejbFJ2amsa28ozuY3LaQhsIKGNF EVJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710427679; x=1711032479; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UCLtGcT112yIVdDhvDfaxSfuuQ/aEnwbhFAj1Y1MJlw=; b=ol3+NwSyMSkBU4UeylPNtraTXgp2x+CUAACO1bsjuIx6saBHgEF47eSwctgnT1jc24 nCKKciEucDJMSr1Sr2YdM/lXj84EaE7+r75+V1QTpqryORyEHFTSRvY7Xugd/QyuG5L7 gSq4rPC1r0mGjSiK5FTp4hQuUrOiNVstPTHzJ4XAHnjRZ6A9FqbaJkvd0wzFHwx3AESs x9Des8NtOMOUeYe29vjnGWT5oP9/xxWvufgWw5AP7ak3bxLUvXWMpbIpjVlXHZNlOOXg 5zqE4OqRu73tftkK1DrZvzlGnABmHjBjRy/xutK0FGbdHtR9+TdLEOHyvHwomKVsd/X8 eIyQ== X-Forwarded-Encrypted: i=1; AJvYcCVU9fX/BopodCH3E4W1ZSaA7RoQ5O+X0ZrzxFCtwSjigaLhq6VfYnZdJ7R+aQwNXuTr0KIZKCf8TvfWJsebhsgrVZBZU+2lC6RI9T/V X-Gm-Message-State: AOJu0YzDZHjLILkwKmzMtdOy0vuwbqCuRBTCG6vGo7iN84H2j12DPUqf J3uZnPMKJj4UHxGPRuXA8ZDeFI5bx322eodRUEi0eH/aDWxW8JD4kPd3/GbxM6vGK9nMTUOXUm8 /jg== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:3d15:b0:6e6:b638:3f78 with SMTP id lo21-20020a056a003d1500b006e6b6383f78mr86525pfb.5.1710427678684; Thu, 14 Mar 2024 07:47:58 -0700 (PDT) Date: Thu, 14 Mar 2024 07:47:57 -0700 In-Reply-To: <73c670d1-0301-49bf-472c-97ae8d1b6c7c@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240309010929.1403984-1-seanjc@google.com> <20240309010929.1403984-2-seanjc@google.com> <5ee34382-b45b-2069-ea33-ef58acacaa79@oracle.com> <73c670d1-0301-49bf-472c-97ae8d1b6c7c@oracle.com> Message-ID: Subject: Re: [PATCH 1/5] KVM: x86: Remove VMX support for virtualizing guest MTRR memtypes From: Sean Christopherson To: Dongli Zhang Cc: Paolo Bonzini , Lai Jiangshan , "Paul E. McKenney" , Josh Triplett , kvm@vger.kernel.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org, Kevin Tian , Yan Zhao , Yiwei Zhang Content-Type: text/plain; charset="us-ascii" On Thu, Mar 14, 2024, Dongli Zhang wrote: > On 3/12/24 10:08, Sean Christopherson wrote: > > On Mon, Mar 11, 2024, Dongli Zhang wrote: > >> Since it is also controlled by other cases, e.g., kvm_arch_has_noncoherent_dma() > >> at vmx_get_mt_mask(), it can be 'may_honor_guest_pat' too? > >> > >> Therefore, why not directly use 'shadow_memtype_mask' (without the API), or some > >> naming like "ept_enabled_for_hardware". > > > > Again, after this series, KVM will *always* honor guest PAT for CPUs with self-snoop, > > i.e. KVM will *never* ignore guest PAT. But for CPUs without self-snoop (or with > > errata), KVM conditionally honors/ignores guest PAT. > > > >> Even with the code from PATCH 5/5, we still have high chance that VM has > >> non-coherent DMA? > > > > I don't follow. On CPUs with self-snoop, whether or not the VM has non-coherent > > DMA (from VFIO!) is irrelevant. If the CPU has self-snoop, then KVM can safely > > honor guest PAT at all times. > > > Thank you very much for the explanation. > > According to my understanding of the explanation (after this series): > > 1. When static_cpu_has(X86_FEATURE_SELFSNOOP) == true, it is 100% to "honor > guest PAT". Yes. > 2. When static_cpu_has(X86_FEATURE_SELFSNOOP) == false (and > shadow_memtype_mask), although only 50% chance (depending on where there is > non-coherent DMA), at least now it is NOT 100% (to honor guest PAT) any longer. Yes, though I wouldn't assign a percent probability to the non-coherent DMA case. > Due to the fact it is not 100% (to honor guest PAT) any longer, there starts the > trend (from 100% to 50%) to "ignore guest PAT", that is: > kvm_mmu_may_ignore_guest_pat(). Yep.