Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2976912lqp; Mon, 25 Mar 2024 15:19:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWHyjdyPseflY7GC0ZGkCSEb/eWnSFgVQOAwnD0oypj5EPKOoEmKUPPlZKgl2gQSBWLbtWQMYHuY7l0VgPr2/MfHEZv+cdHPn7YeDnxqQ== X-Google-Smtp-Source: AGHT+IF1tshYK3yNO6hxT8PMrOh3ehob0t5BjMBi3srXd1h6UcApoAkr7ywF2kdlyMLriFdTW1yM X-Received: by 2002:a05:6a20:7a81:b0:1a3:6378:1e8d with SMTP id u1-20020a056a207a8100b001a363781e8dmr7649280pzh.26.1711405150929; Mon, 25 Mar 2024 15:19:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711405150; cv=pass; d=google.com; s=arc-20160816; b=0WU5FgD4Mww2TSp5CqEGQy0uvHRR10x64Si7FIBq813w/lkAgrVoUiaEf2kY7TX39X NubrQH6+qnA+U7UNyq+1TWYspZYIlAkQX+8+2dK6kLBpzigJSAkS2bSmmONyit70IgnT BmAJPivJ4EKEEAhDhIGhWJ3J4kRFXvc0FYWNeRqdo0Amt0OcuA8szpCcFOdAND98Qbae oyi2AHuG8aIcGcGjm6WQ8WHZo6Xmeo/OqsKt44rAEQPTKsnu3k9bQyHIwXzQ3jf0WaYF TCw20dZgBIhO1U7hULALy1DG7NW8fNBaFiYnOwONtiYXl4cMaEUFCXi2bvL+gXKbn9Eh EMjw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PDOafh2vBe0SZZaMcHz8V3Mc/fOWZtVHi4DBvDVgLi8=; fh=417BGlpmZrcMpB9+n2SRBcPtOdnJwl+9Gz18F6peV4E=; b=TkOn4o4cteJ1tgNjfKMtK30rfm610UJMCntrwjJed7eCJPmWLo0k9Dj3JE1JZnEb10 5WYCMA/MduYnT779YBkQSD/Tbd4DxcJuH9EmK5bYMMi7VrT/eeYs5nIAcYD6uAExDNpX 9JP6T/r70uMseda8gRQstNYLJv3y8up1b3mahvI9XH/UEwBzoVH5cIiC5k6CZbRjR7bR P8+Rlbe0jlL4cdWOOizYQsmE7+GESyYM7O+mqX/R4jTf7pdMDfmG+29eneQNoA0CqahQ 5XGWfCo0JIEUt/P/TWF9pa2AZdnDUAnIfFElo8q1MRL3XEvOnBbEkKHKSI7YeVtwZFFZ GgRg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=i2JBh3og; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-118091-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118091-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id gr20-20020a056a004d1400b006e629ca2803si5804891pfb.180.2024.03.25.15.19.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 15:19:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118091-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=i2JBh3og; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-118091-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118091-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 03F392E23C1 for ; Mon, 25 Mar 2024 22:18:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6FDD67580C; Mon, 25 Mar 2024 22:18:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="i2JBh3og" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF50370CC2; Mon, 25 Mar 2024 22:18:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711405119; cv=none; b=igWmmv9hZk0eJDMLoenBsWIXUdzNb9QHxs0X/yCW+taQNEdXbc2ctiznTSJCVFj+JagIuSddMVup1lKLrcvPjZtrHLHtVys1bPM/Tgm3WtXOKCQCuXWWVV8OKse+gnjjt/UigaBqtAkZG2HkHf0azBBXYZA3DV+1iPVmrBXimCM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711405119; c=relaxed/simple; bh=feUQgOvzcNlvP1Ks242aVU3gOvHsb8SG3N7apTriglg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OMWSEo1ZCirmWOStMRsS9dge+R1u7aQH5LePUeJ+Wc9xIwCH6zzQ/M2oClwzkNhtfCdtXG+eg4jhAkBHXSFXBphcAXPTsn0iZRPlmLbtGf7V8hbVMKqepImzW3Vay70KWNAlMR+sNgaUoNy6r1j4VmmWf35xL9aGj/7EFS09BI0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=i2JBh3og; arc=none smtp.client-ip=198.175.65.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711405118; x=1742941118; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=feUQgOvzcNlvP1Ks242aVU3gOvHsb8SG3N7apTriglg=; b=i2JBh3ogKEvpyxNaMbsRpnJwqTkKq6wXi62vTyfprG1jFMijpLHwRuLS BDFqSG8mmrcbb01s6Yg04ptYRXn5splQdSwAyyU7ph436SHgP1XefpIZl dOrh/e1263u31J6ynvtzlFp5u0sC6JVkCk5uGL58yin83CIj2h2M8cjrv AZe3IfkZzENqfkt2hYW9etDM/KA46X2xitUFT33aGYsYL3uUD2U9/kShw ovipwz+MupBMTUM5sQwLWrOhGh/DfcHsknvWkaTpdW1+lNeFlIKv/B1BE HvldIn8jL78bYKdQg9f0YQNqZWomo1Q5cEL2jqyHLdURYnzwxO4eUhksL g==; X-IronPort-AV: E=McAfee;i="6600,9927,11024"; a="6372056" X-IronPort-AV: E=Sophos;i="6.07,154,1708416000"; d="scan'208";a="6372056" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 15:18:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,154,1708416000"; d="scan'208";a="15845759" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2024 15:18:37 -0700 Date: Mon, 25 Mar 2024 15:18:36 -0700 From: Isaku Yamahata To: "Edgecombe, Rick P" Cc: "Yamahata, Isaku" , "Zhang, Tina" , "seanjc@google.com" , "Huang, Kai" , "pbonzini@redhat.com" , "Chen, Bo2" , "sagis@google.com" , "isaku.yamahata@gmail.com" , "linux-kernel@vger.kernel.org" , "Aktas, Erdem" , "isaku.yamahata@linux.intel.com" , "sean.j.christopherson@intel.com" , "Yuan, Hang" , "kvm@vger.kernel.org" Subject: Re: [PATCH v19 059/130] KVM: x86/tdp_mmu: Don't zap private pages for unsupported cases Message-ID: <20240325221836.GO2357401@ls.amr.corp.intel.com> References: <1ed955a44cd81738b498fe52823766622d8ad57f.1708933498.git.isaku.yamahata@intel.com> <618614fa6c62a232d95da55546137251e1847f48.camel@intel.com> <20240319235654.GC1994522@ls.amr.corp.intel.com> <1c2283aab681bd882111d14e8e71b4b35549e345.camel@intel.com> <20240321225910.GU1994522@ls.amr.corp.intel.com> <96fcb59cd53ece2c0d269f39c424d087876b3c73.camel@intel.com> <20240325190525.GG2357401@ls.amr.corp.intel.com> <5917c0ee26cf2bb82a4ff14d35e46c219b40a13f.camel@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5917c0ee26cf2bb82a4ff14d35e46c219b40a13f.camel@intel.com> On Mon, Mar 25, 2024 at 07:55:04PM +0000, "Edgecombe, Rick P" wrote: > On Mon, 2024-03-25 at 12:05 -0700, Isaku Yamahata wrote: > > Right, the guest has to accept it on VE.  If the unmap was intentional by guest, > > that's fine.  The unmap is unintentional (with vMTRR), the guest doesn't expect > > VE with the GPA. > > > > > > > But, I guess we should punt to userspace is the guest tries to use > > > MTRRs, not that userspace can handle it happening in a TD...  But it > > > seems cleaner and safer then skipping zapping some pages inside the > > > zapping code. > > > > > > I'm still not sure if I understand the intention and constraints fully. > > > So please correct. This (the skipping the zapping for some operations) > > > is a theoretical correctness issue right? It doesn't resolve a TD > > > crash? > > > > For lapic, it's safe guard. Because TDX KVM disables APICv with > > APICV_INHIBIT_REASON_TDX, apicv won't call kvm_zap_gfn_range(). > Ah, I see it: > https://lore.kernel.org/lkml/38e2f8a77e89301534d82325946eb74db3e47815.1708933498.git.isaku.yamahata@intel.com/ > > Then it seems a warning would be more appropriate if we are worried there might be a way to still > call it. If we are confident it can't, then we can just ignore this case. > > > > > For MTRR, the purpose is to make the guest boot (without the guest kernel > > command line like clearcpuid=mtrr) . > > If we can assume the guest won't touch MTRR registers somehow, KVM can return an > > error to TDG.VP.VMCALL(MTRR registers). So it doesn't call > > kvm_zap_gfn_range(). Or we can use KVM_EXIT_X86_{RDMSR, WRMSR} as you suggested. > > My understanding is that Sean prefers to exit to userspace when KVM can't handle something, versus > making up behavior that keeps known guests alive. So I would think we should change this patch to > only be about not using the zapping roots optimization. Then a separate patch should exit to > userspace on attempt to use MTRRs. And we ignore the APIC one. > > This is trying to guess what maintainers would want here. I'm less sure what Paolo prefers. When we hit KVM_MSR_FILTER, the current implementation ignores it and makes it error to guest. Surely we should make it KVM_EXIT_X86_{RDMSR, WRMSR}, instead. It's aligns with the existing implementation(default VM and SW-protected) and more flexible. -- Isaku Yamahata