Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp751013lql; Mon, 11 Mar 2024 17:08:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXmzQqk0ApCBQrP131hJh5eGE4EnOmKI5wDQKoKhHq6qSRVIk5buMKXn8SixPeteUTA7f+YmRC35TVTnymtOXxQmwXuCoxraN3qL8647w== X-Google-Smtp-Source: AGHT+IGWumdSUln++I1zB6Qwo5E604JMEYQgDMlmk+/8c09ctHZpgbRwvW/Vji7rdBr5AcZA540g X-Received: by 2002:a05:6512:1108:b0:513:b062:98bf with SMTP id l8-20020a056512110800b00513b06298bfmr1965155lfg.20.1710202135430; Mon, 11 Mar 2024 17:08:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710202135; cv=pass; d=google.com; s=arc-20160816; b=Vr1pzSEtC6r4gjbo4+hMBYgSNQJIqZdN6aF4mY1Hbo9UBzyZ1JzwVjKViJMXrDKuXB DWgxTiU9o2EnzmskQRlbnWIHtqLRPt6l3x1MQ6SDovxlJscIDhuyQiHzOXWuTFuaOTm/ ecko4GnfT6d+1zHNqzM36Y0Mg6s48f9moCIFK6XxIwdH72lJzTl44UBCBDHIp1wCe3rw AVAOYa4tuRuBjcsPmOCO7PsALsy4llD1YOfWmEA9stDx068ebKSySNl+gav7MPHUOuUR 5UjotPdN7iL6yRBxH2o03Ikwd/PHmVPp+37YmPpP6brk87Gqjb1bUFASyWEnOJ8CjB4W FTGQ== 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=+d74PXd4taKq/kej/o6mNWve0XFGzP2O6HVRwkMDONA=; fh=gJVbUQcpbXhQ70cssysx+/qtN9vg00nQKb/ltR3KaNc=; b=forMOK2KSyQ1+CWFNo71Q6onqv/uMvrvuSoP50FcJmUGiMlbZ7WPVxDpYX8quUc/8A Ukiraq6oBs4znvsuIvqSR62d5dcfcEq2nSMQ6QQ1HD0xY5sqrE60E36gibp+H2wIyiu4 NsSRizQTLf0WTANKDe+mXNM/nnHz50ycL1sUbTFaFRJt8ifZtQ6vvpRTXCa3H6Z6GD4F bGI8EL0uo68bkEBP1Xyh4m7Lk1rkbRUOVUGEFTDRDWG88aeajY4aP8uCPYTdXUF9v8TK +AcicG3LHaZN9Dz5OohSt4xYmCmNKjJhPecEFsh5NJcEe0EN70tqCXagz3XelCtECxbX I7Vg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=birIeGsB; 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-99688-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99688-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id di22-20020a170906731600b00a45ad08475asi3045458ejc.78.2024.03.11.17.08.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 17:08:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99688-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=birIeGsB; 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-99688-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99688-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1B4481F220B1 for ; Tue, 12 Mar 2024 00:08:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 678907E9; Tue, 12 Mar 2024 00:08:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="birIeGsB" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 2B2A719B for ; Tue, 12 Mar 2024 00:08:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710202126; cv=none; b=eiwLk9CGPh7FakcmLonfJDdl6oflgYKPB8hhPUZwgcBy11Prh89HGO+Pqzv4ArWWAn5YAogTyn+BSDAW/iiO9Sr913Xg/FeTO/Own8nnWsoS232uXBexGPLpAbJIO3XtYB43XJtFS7b49CfLxtL7YzWmUakarCpkRBhjn6VR1kA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710202126; c=relaxed/simple; bh=0Yb12pPEmKrsC1pLW8reJgDFPcWSOLnjlFPRgboKnzM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=GG4IS9FgKA/0JIbBTY1la2E5lFeXs1GflP/b40FeSWpG8REjOR7w84j3QYfmq7qRLBIg/TFHm3gH0JQeV59y60mGkQ1OULcF0DY1jcY/l+OSUPfjWsMxqSUdiqlcDQPkZVoivlTxDFhauDXmF+W9Pn/R3GXx2ewKqriL7uZNfDA= 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=birIeGsB; arc=none smtp.client-ip=209.85.219.201 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-yb1-f201.google.com with SMTP id 3f1490d57ef6-dd169dd4183so123557276.3 for ; Mon, 11 Mar 2024 17:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710202124; x=1710806924; 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=+d74PXd4taKq/kej/o6mNWve0XFGzP2O6HVRwkMDONA=; b=birIeGsBBaAQIffVUzrsSkdieJBLwk7eZdpIOPCXTqlADokw1+d/KcrsIhieBq67uH xDVqBjEMll/LUgDtNKkYOfO/gkSQyGbHUVMMrXcPbN9GUyIIVeS7QdRFAFb9B/6wHysY +ErhaYewCw0Q5kMAq7C4v33IM9CUgjBWLbizzanf8uRAFKzsRIqY8wPp7hXmF+H/4lWr ZR2cSLBWJOug8HxXdYbP/RFd65BsDybx1OOYkaGlNpGyyjE5H20uFXRFhkG5Rm0ruFw1 cLlyRsVqRn9Z3Ljfubmk5U6Y0qSHoR9WoTr0kGtJnARq+dlOwbH7s+QoFfPnZY9aV7sC mr7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710202124; x=1710806924; 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=+d74PXd4taKq/kej/o6mNWve0XFGzP2O6HVRwkMDONA=; b=Tr1VJxI/c24R24NiFqMKbbaZ0FvKZxbHyxaKkSqIYMSkaaxqT4xjmPpCNb39n0+Sz9 1aVWYHFIuqKtMpVDMkQCGjP1WsSjZbMdbPH1RVZ+jZaWix6otSTr1CYxIavz2Pq3a6rX ri/uXIy1gOpjQtgrZBWWv7EQWdbjl5Oi6zFX5KFVWHpRyhKVx0oRN4BxYpmfy1AkMiSL 5qHwoAuXUo85SLhNtcxCX3GydTas38pe+WZjUReEbkaN7SvZ1JeRWJ7rECm/UhQJB7gr 58+4c0SKfHPPGoRgG//3TTLRKjStlRAZvup56P5uBE6iBoBnjHtQ28By7XMkuhSJLYsJ DXUg== X-Forwarded-Encrypted: i=1; AJvYcCUdFuDCQY0cIlDGcspf+3d3zMlVtPiwTuFFdXJ7hLJcbKjLxkpoJizlm8x9xG48rlIgS+irSJ7FEM1/1hljMWbWRsDvOYpVuGtCLBrS X-Gm-Message-State: AOJu0YwS12ECGTon2XwbCW4ry11qALSSGDak1bkpfRiEVIG8e2+Eisn9 elyzeNGSNJIAY8isJ4VR8EaqnadxmwwwdbyUUShVZNqByc9o4pzGrO6rvse82Jnotxzg9JXJPi/ THQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:ab6f:0:b0:dcd:3a37:65 with SMTP id u102-20020a25ab6f000000b00dcd3a370065mr414308ybi.7.1710202124212; Mon, 11 Mar 2024 17:08:44 -0700 (PDT) Date: Mon, 11 Mar 2024 17:08:42 -0700 In-Reply-To: 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> Message-ID: Subject: Re: [PATCH 1/5] KVM: x86: Remove VMX support for virtualizing guest MTRR memtypes From: Sean Christopherson To: Yan Zhao 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 , Yiwei Zhang Content-Type: text/plain; charset="us-ascii" On Mon, Mar 11, 2024, Yan Zhao wrote: > On Fri, Mar 08, 2024 at 05:09:25PM -0800, Sean Christopherson wrote: > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c > > index 7a74388f9ecf..66bf79decdad 100644 > > --- a/arch/x86/kvm/vmx/vmx.c > > +++ b/arch/x86/kvm/vmx/vmx.c > > @@ -7596,39 +7596,27 @@ static int vmx_vm_init(struct kvm *kvm) > > > > static u8 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio) > > { > > - /* We wanted to honor guest CD/MTRR/PAT, but doing so could result in > > - * memory aliases with conflicting memory types and sometimes MCEs. > > - * We have to be careful as to what are honored and when. > > - * > > - * For MMIO, guest CD/MTRR are ignored. The EPT memory type is set to > > - * UC. The effective memory type is UC or WC depending on guest PAT. > > - * This was historically the source of MCEs and we want to be > > - * conservative. > > - * > > - * When there is no need to deal with noncoherent DMA (e.g., no VT-d > > - * or VT-d has snoop control), guest CD/MTRR/PAT are all ignored. The > > - * EPT memory type is set to WB. The effective memory type is forced > > - * WB. > > - * > > - * Otherwise, we trust guest. Guest CD/MTRR/PAT are all honored. The > > - * EPT memory type is used to emulate guest CD/MTRR. > > + /* > > + * Force UC for host MMIO regions, as allowing the guest to access MMIO > > + * with cacheable accesses will result in Machine Checks. > This does not always force UC. If guest PAT is WC, the effecitve one is WC. Doh, right, I keep forgetting that KVM doesn't ignore guest PAT for MMIO.