Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp184418lqh; Wed, 27 Mar 2024 20:40:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVVvD0v3hr1rn60ApuN4/+h3Q+ZiO54Aflr0NeQA0itCTrdvva7QotyMj5RnArrr358/rixIZq9p5NotPTzZaRqdS5i8PO2XDjF3Jk+8A== X-Google-Smtp-Source: AGHT+IFB/kej6YWDgTGpvHES5YjYU57d6KXxGbUnE85X8dB8Qx2uxQHJKIb8vmTGF6HOAIQaTuGF X-Received: by 2002:a05:6a21:616:b0:1a3:72d6:641e with SMTP id ll22-20020a056a21061600b001a372d6641emr1793487pzb.20.1711597248707; Wed, 27 Mar 2024 20:40:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711597248; cv=pass; d=google.com; s=arc-20160816; b=i+oUdpje0DNEyheR0Z3uuabCY7Dw42oIo7gcxx1x4V5idK2EvYv7jGYkrHMTr0lmc3 obtIzbQ/sBEKlHs67R/lt7OPnYdgWBojyduoCg/NLYM5KwTUtw1Nkqlb4cCtfHa+MWLv 2kNHwCJB5MjHlg0/jMK4crsGnVyNk8x3PXajdaJjCH2a2X2WXW+JF+ANmmvXLGsrnNYq n48aHcd3tTLY2csIKPcMiWXbCm86ZS4imp7YYa4An2k/h8unhIbsATLAmPSkEYn5T0Ss UTX6hVUoAfwQ3DNk0nkoJKnRc/ExvOOJ1f8RRigxPVCY2fSxB7uO3rdOv1imNkiRA3f/ Y8IA== 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=XuY6GUkOgvMtfxqJqC6Xlw1zeE8KNLsF2WTCNUyHKH8=; fh=6pGK6zO7G4RbGimrT0Hr+oyIx69u8UoK0yzGlj7WlaM=; b=QU4IkS6lc+39YANH9Zqr7FCU/tpb88GSpjxgRPiTXCtHmoWoTD+6dR9hZ+uMd77xcA OI2XbjMGDUDxVRfdjj/ih4LPUZaGhgBN0PcM0Qver5COS98HKKwXMahqJq11jRy9xVBB mRxlzQd2ORDEaklXeF7KIwDsi9LaULD5zaF4wai5Rl9X7VrN8XF81tvQ6Fpk2wyN3Vpb 1ISa571zeR+r+Fh1V4vvhfoVINHXfqLfC9bzCUqg0qYrQmIvettHGI3MxRX+uIYrN/Y0 GGikkNYxiQI/nH+RSlbQDzXnQhbMy1Rj+mEy7KFqkSRaep8XRjmYkRR7K47NqjvOe7zn fLWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="R/fQxXWZ"; 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-122384-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122384-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 q18-20020a170902eb9200b001e0cdc0784asi542817plg.321.2024.03.27.20.40.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 20:40:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122384-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="R/fQxXWZ"; 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-122384-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122384-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 5D6FE295F8E for ; Thu, 28 Mar 2024 03:40:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28B4A376E4; Thu, 28 Mar 2024 03:40:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="R/fQxXWZ" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 BE7591DA5B; Thu, 28 Mar 2024 03:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711597237; cv=none; b=QyaIZN1jepJkbE7QZ/2d6+8NixAEXEOMdY1UIKrlCe/O1XtFABH08EYNXSGGwfMoCp3H/03z610vcZ1JqEYvFP+U9yLgcvc78YOYZnDM4bCyPxLeacM7FnI8pvdjHhTSnUqDkKpc17GuO5BeGly/EAltDiMjN6bnOpgwH0llYbY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711597237; c=relaxed/simple; bh=Ym+ihHFVt13GNw2mWqOvJzw+VVmFqNGAwtRWX7YdW7U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=L0XFNz55LnvQW3gsd61T8ehYevfq+5A55IxXoRi+O31U+sbyZqICE8eGg6ekeE6AetjcEfxJid7/BlBuE8LXbZnd2XeucPebZ8ypdP8wF3LdyUqNIRZsrpzjMz19fRMeREEZNtoFWrAZ36d8cDS28bOZe7rVbLKFJkn7/gjHzbA= 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=R/fQxXWZ; arc=none smtp.client-ip=192.198.163.7 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=1711597235; x=1743133235; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=Ym+ihHFVt13GNw2mWqOvJzw+VVmFqNGAwtRWX7YdW7U=; b=R/fQxXWZHiSq1AT6FqujqhKYnKCXpLAzevhFoR5GaOdf7Vi+EyDQ6g1f OL/+oFi4rU0gxfx01JeMgEpcEZdaMeKAcy04olPXPYYc/XXgNex4O8Gtz 6hZWEswlnIQA8A9xAGoUHvdJu66j9XHa/XRrGhKhv86DOBNZYpuHbxHMV IiuE3NcTvu702sJ59YsSdwYlFUHhhuGC5emEaHwe9NDYJoumHKFQVE0PS i4fLrjLMaSNZXAy06IxBKKxwP4vrlU74wk6VoLx4Gt/tF959aaBoUqdMX W6OjoiETIPwB1Tcp7i2MBHFWXuVdXQe2SYwg4XT/b0iHJdHbyeeHULUaA Q==; X-CSE-ConnectionGUID: lJbeGd3yQuiH8qwSP4jG/g== X-CSE-MsgGUID: r0M5cMuCSrWCDw17VfQnTg== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="32131414" X-IronPort-AV: E=Sophos;i="6.07,160,1708416000"; d="scan'208";a="32131414" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 20:40:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,160,1708416000"; d="scan'208";a="21191081" Received: from xiaoyaol-hp-g830.ccr.corp.intel.com (HELO [10.124.224.7]) ([10.124.224.7]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 20:40:30 -0700 Message-ID: Date: Thu, 28 Mar 2024 11:40:27 +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: "Edgecombe, Rick P" , "Gao, Chao" , "Yamahata, Isaku" Cc: "Zhang, Tina" , "seanjc@google.com" , "Huang, Kai" , "Chen, Bo2" , "sagis@google.com" , "isaku.yamahata@gmail.com" , "linux-kernel@vger.kernel.org" , "Aktas, Erdem" , "isaku.yamahata@linux.intel.com" , "pbonzini@redhat.com" , "Yuan, Hang" , "kvm@vger.kernel.org" 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> <481141ba-4bdf-40f3-9c32-585281c7aa6f@intel.com> <34ca8222fcfebf1d9b2ceb20e44582176d2cef24.camel@intel.com> <873263e8-371a-47a0-bba3-ed28fcc1fac0@intel.com> <5f07dd6c-b06a-49ed-ab16-24797c9f1bf7@intel.com> <20ef977a-75e5-4bbc-9acf-fa1250132138@intel.com> <783d85acd13fedafc6032a82f202eb74dc2bd214.camel@intel.com> Content-Language: en-US From: Xiaoyao Li In-Reply-To: <783d85acd13fedafc6032a82f202eb74dc2bd214.camel@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/28/2024 11:04 AM, Edgecombe, Rick P wrote: > On Thu, 2024-03-28 at 09:30 +0800, Xiaoyao Li wrote: >>> The current ABI of KVM_EXIT_X86_RDMSR when TDs are created is nothing. So I don't see how this >>> is >>> any kind of ABI break. If you agree we shouldn't try to support MTRRs, do you have a different >>> exit >>> reason or behavior in mind? >> >> Just return error on TDVMCALL of RDMSR/WRMSR on TD's access of MTRR MSRs. > > MTRR appears to be configured to be type "Fixed" in the TDX module. So the guest could expect to be > able to use it and be surprised by a #GP. > > { > "MSB": "12", > "LSB": "12", > "Field Size": "1", > "Field Name": "MTRR", > "Configuration Details": null, > "Bit or Field Virtualization Type": "Fixed", > "Virtualization Details": "0x1" > }, > > If KVM does not support MTRRs in TDX, then it has to return the error somewhere or pretend to > support it (do nothing but not return an error). Returning an error to the guest would be making up > arch behavior, and to a lesser degree so would ignoring the WRMSR. The root cause is that it's a bad design of TDX to make MTRR fixed1. When guest reads MTRR CPUID as 1 while getting #VE on MTRR MSRs, it already breaks the architectural behavior. (MAC faces the similar issue , MCA is fixed1 as well while accessing MCA related MSRs gets #VE. This is why TDX is going to fix them by introducing new feature and make them configurable) > So that is why I lean towards > returning to userspace and giving the VMM the option to ignore it, return an error to the guest or > show an error to the user. "show an error to the user" doesn't help at all. Because user cannot fix it, nor does QEMU. > If KVM can't support the behavior, better to get an actual error in > userspace than a mysterious guest hang, right? What behavior do you mean? > Outside of what kind of exit it is, do you object to the general plan to punt to userspace? > > Since this is a TDX specific limitation, I guess there is KVM_EXIT_TDX_VMCALL as a general category > of TDVMCALLs that cannot be handled by KVM. I just don't see any difference between handling it in KVM and handling it in userspace: either a) return error to guest or b) ignore the WRMSR.