Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp43256lqe; Tue, 26 Mar 2024 19:55:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVW71xQH43CfSvjUeWTariW6FHsgEU55KIcQesKuR/b8LHzm1NDDSnf86kNJk1Zck2l56oZcAgLS0vJeg6B4+ldosNhaDTZy+EBVfpyig== X-Google-Smtp-Source: AGHT+IH2DouslnwNt9QScY6LFE5kvFGIbnpP0G/QD39oum5r7ednkpGFaNIVK6cgslbCFEDDZdO0 X-Received: by 2002:a05:6122:a14:b0:4c0:24e6:f49d with SMTP id 20-20020a0561220a1400b004c024e6f49dmr10174381vkn.1.1711508099727; Tue, 26 Mar 2024 19:54:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711508099; cv=pass; d=google.com; s=arc-20160816; b=QIxIAebRf05jF6Kfrkas1qFNHqG5+8S8+pzc2ASY6eTIHuxXSkjID1jNtRGSas4vDk wGWvFZembS32jTyGUwjFk+xLvcXzvvwmQmNcVs1vEFEPJU7M+Efnf46TFMue24/IdVaN M33lkeUQMeSANPBT3P1TGGFnbJM1DB5HcthR6GrB5UX/HIro5XrWfFKCUyGXyIXLImyv 7q/QTlecqU6mxnMMmC0QJNGG73dTwzaYF3Gfgix/DjEDj9D7o2oSvnfg2H50puC2Cxm3 MMZRLVGq1JXOk1AlVwM8sqj3VfL5M7mpp+k/cnH33zgT2b/EjJjQvCJLnMqNjPggtoB/ PMiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=VV6oEArn+7kyJpAGACseE2nCEoNM1g1+7pxpvaRSlGg=; fh=HNdIjAkpa9spnB7sg7HJG28o8XgNTA/tfENe6IoPQSE=; b=O72BhP5asfq0gO/YuW138npiLD7/NMlnKvTUWMrHO3gQxE9vZPMn81pe20QGe+c+S8 9psYDCbzQseC4M7vkHUoaMjGqjjHXkR0yHsgTapvpdJ8C8azC/fQ0+B5jW10F2626NT1 YQa1Uzjgf6OtwKQL1ssyw3ImeT1rtylUPLrykIx2IXX6Rg43Yej4nmblhEdefcW1Qrla HkhUnusUoZ2OO9p2C6EUka+MyaL8aCR5X+W80ZimPlxA9Av4gNWwFXJ7SE3zEoIac11x 1XD0J/exzlGuCqTAu5mTPOmt+Pi3dq6uh9d3+XS7DlZzaDAV+hG7HZujPmD7oDG6ccf2 ZoSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RgfTmEBs; 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-120247-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120247-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u9-20020ac858c9000000b004313a89730esi8836608qta.296.2024.03.26.19.54.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 19:54:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120247-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RgfTmEBs; 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-120247-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120247-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6CAF61C24504 for ; Wed, 27 Mar 2024 02:54:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDAFD225CE; Wed, 27 Mar 2024 02:54:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RgfTmEBs" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 5A05F219FD; Wed, 27 Mar 2024 02:54:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711508091; cv=none; b=g3TFt/FFKJO0TXjDhg6IH367IM4dj04Yl9AHJDlSe7SGsLvYzp1gioGl0jD4ehMnbNvRNP49hOiRCLz68k//NaKMFQ5vr1kyE4zVn8EEDvPEDx7oTA7rrRIrC33Z/WRyNFN8gcC9pu3zh4APw+x1+vqYBSZ1BPDfPlHWvBkY38w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711508091; c=relaxed/simple; bh=xIKUdUOxhPeSjvi7wBh6frImJmN0BKUrySEAkp7ZeUE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=EznVreyQJArwa73mnVZYlJWLkyZj/aYwnvhMpX0Kuydfn35uUdJUqAAOqCuujll8ViLi2i9OX4tU+RWacgwKmpR4r3qkH3303MQjYgIHCfToHT4KVggDpMuiJIPtMi/0i4Xw/PpOm8/BVp3+cf0O5Hq5yAKHKRqIECYluJh+ZW4= 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=RgfTmEBs; arc=none smtp.client-ip=192.198.163.8 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=1711508089; x=1743044089; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=xIKUdUOxhPeSjvi7wBh6frImJmN0BKUrySEAkp7ZeUE=; b=RgfTmEBs57K3XriTkyYyagGNahZoB8OZN29i72CS5/eaLgKXvIiFqPxw SoYU+Tq4TpADP8V4ObbvxuJ7hzQWloJXMDq2OYHHBTjhsd08mP+ig7WgI BiRPi5a+F9Fw9+WaY4i5hLC4PsS4CnQluEtR6NKCryJXLxKuJU15uytcM sPEdroqIrPhWxmX/Z012jgA/2vEqN6tLqtPtqrvN01KddrEFvXa/8U3mV ns41ufiuF6I9ABfQTKsXGk2bM/8yE0v7e/Qpbu40ZmRiyJnWsJboiUvVN K/JV5t/VB+WJLhTN4y5QcPOZNpzWeHE4DphlVBLM+mCAMUday7SvSN3tZ w==; X-CSE-ConnectionGUID: nEQsr2EdTt2t5F9Ahvm1wA== X-CSE-MsgGUID: C+R5JO4wQ9qIYOBfjRIHJQ== X-IronPort-AV: E=McAfee;i="6600,9927,11025"; a="24080066" X-IronPort-AV: E=Sophos;i="6.07,157,1708416000"; d="scan'208";a="24080066" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2024 19:54:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,157,1708416000"; d="scan'208";a="16806291" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.124.224.7]) ([10.124.224.7]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2024 19:54:45 -0700 Message-ID: <481141ba-4bdf-40f3-9c32-585281c7aa6f@intel.com> Date: Wed, 27 Mar 2024 10:54:41 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v19 059/130] KVM: x86/tdp_mmu: Don't zap private pages for unsupported cases To: Isaku Yamahata , Chao Gao Cc: "Edgecombe, Rick P" , "Zhang, Tina" , "isaku.yamahata@linux.intel.com" , "seanjc@google.com" , "Huang, Kai" , "Chen, Bo2" , "sagis@google.com" , "isaku.yamahata@gmail.com" , "linux-kernel@vger.kernel.org" , "Aktas, Erdem" , "kvm@vger.kernel.org" , "pbonzini@redhat.com" , "Yuan, Hang" , "sean.j.christopherson@intel.com" References: <96fcb59cd53ece2c0d269f39c424d087876b3c73.camel@intel.com> <20240325190525.GG2357401@ls.amr.corp.intel.com> <5917c0ee26cf2bb82a4ff14d35e46c219b40a13f.camel@intel.com> <20240325221836.GO2357401@ls.amr.corp.intel.com> <20240325231058.GP2357401@ls.amr.corp.intel.com> <20240325233528.GQ2357401@ls.amr.corp.intel.com> <20db87741e356e22a72fadeda8ab982260f26705.camel@intel.com> <20240326174859.GB2444378@ls.amr.corp.intel.com> Content-Language: en-US From: Xiaoyao Li In-Reply-To: <20240326174859.GB2444378@ls.amr.corp.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 3/27/2024 1:48 AM, Isaku Yamahata wrote: > On Tue, Mar 26, 2024 at 07:13:46PM +0800, > Chao Gao wrote: > >> On Tue, Mar 26, 2024 at 10:42:36AM +0800, Edgecombe, Rick P wrote: >>> On Tue, 2024-03-26 at 10:32 +0800, Chao Gao wrote: >>>>>>> Something like this for "112/130 KVM: TDX: Handle TDX PV rdmsr/wrmsr hypercall" >>>>>>> Compile only tested at this point. >>>>>> >>>>>> Seems reasonable to me. Does QEMU configure a special set of MSRs to filter for TDX currently? >>>>> >>>>> No for TDX at the moment.  We need to add such logic. >>>> >>>> What if QEMU doesn't configure the set of MSRs to filter? In this case, KVM >>>> still needs to handle the MSR accesses. >>> >>> Do you see a problem for the kernel? I think if any issues are limited to only the guest, then we >>> should count on userspace to configure the msr list. >> >> How can QEMU handle MTRR MSR accesses if KVM exits to QEMU? I am not sure if >> QEMU needs to do a lot of work to virtualize MTRR. > > The default kernel logic will to return error for > TDG.VP.VMCALL. > Qemu can have mostly same in the current kernel logic. > > rdmsr: > MTRRCAP: 0 > MTRRDEFTYPE: MTRR_TYPE_WRBACK > > wrmsr: > MTRRDEFTYPE: If write back, nop. Otherwise error. > > >> If QEMU doesn't configure the msr filter list correctly, KVM has to handle >> guest's MTRR MSR accesses. In my understanding, the suggestion is KVM zap >> private memory mappings. But guests won't accept memory again because no one >> currently requests guests to do this after writes to MTRR MSRs. In this case, >> guests may access unaccepted memory, causing infinite EPT violation loop >> (assume SEPT_VE_DISABLE is set). This won't impact other guests/workloads on >> the host. But I think it would be better if we can avoid wasting CPU resource >> on the useless EPT violation loop. > > Qemu is expected to do it correctly. There are manyways for userspace to go > wrong. This isn't specific to MTRR MSR. This seems incorrect. KVM shouldn't force userspace to filter some specific MSRs. The semantic of MSR filter is userspace configures it on its own will, not KVM requires to do so.