From patchwork Mon Feb 26 08:27:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 206452 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1951687dyb; Mon, 26 Feb 2024 01:08:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXXTNrcj9gmVZoaW4uKhS3F3kR+nnrh7dv17TWuDoBgSC9QlqTQqHlbGEFsvela3+Yjt/pMZoyLdg0tPR4Z+PLQEsjAIg== X-Google-Smtp-Source: AGHT+IHi3/3Gi/OIV3jlkvqxNc/jQw8MxLazsu3qyVD1qXQrfI0BkK5MnfKM9Yn1Am08OJ9aRH5O X-Received: by 2002:a5b:b0f:0:b0:dc7:5018:4022 with SMTP id z15-20020a5b0b0f000000b00dc750184022mr4847209ybp.44.1708938532090; Mon, 26 Feb 2024 01:08:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708938532; cv=pass; d=google.com; s=arc-20160816; b=kTiYveK4nbq+nJvSfMdPlghK8YBKOZhYuo2M7NS0CFuFVdi7TgnGj0cissAmPWlA7e mpeuGgGS33OPu8HzPJoEpkbAOrQz2igJKujZ6tio4wyEtLkZ3uiKPnx4px7VofIM+trm ny3QfQqrQXR9NU0jX6rzldyloZYcdgZf8mOYqO6EJWwXMI0PM2/bza5ANEZlNPJXQdpK RHvkRFiErJvzRKHI3F+v5crnsEPxNHXCyyXSS3Wq9EjFZoQEfNR3I62pccJsFxG+JdbS 2Chdb8pabZiuoLu7y6hKXPiWkJqwYRPzDGV4pwyQCKKbCntVFnhFdQtJnZdpaPWQZpTD jGWQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=eVVWxdeAoBT/mYbPU7fUY/7nYVKN5Fu9rIrME/BfJJ4=; fh=Itbyk7CEvizIrzGEESCqq3I2tZgG1kc/GkVOa3S7Hsg=; b=DCI/vMz2MoHMEXz66l2L7t3k2F3OBy1CV9jAMZ4F0BHOyQeoN7eVdik6hEEMDjhdJC a2Fi6W/i7A6ueS+Y+1Kl3BHDQAZPi25LIKYEf8o6LbRdOlfxqwQprbiT1bzI/oq1OoAb o9ABQDuKlxLkXPDLSLXfbr06P4gTYvFQpYZN6rCYciapjKsrqjNYr4wzEmKGTm1vZQhL 1J44m7QSGH8Rix3AAKGN11+55qsXvfcJmOGPAtqzXsIudrLe5MJeJ5awuUuil5dmWNuh Dpuddfwaqyf+49EwuaQIlj3tGhKlgE61JBFDEWc9lYPmf0JhqDVknfOrrYqxJfXqaxfK r8gQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YXl9J4E0; 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-80883-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80883-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e22-20020ac86716000000b0042c3b7b7908si4552072qtp.350.2024.02.26.01.08.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:08:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80883-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YXl9J4E0; 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-80883-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80883-ouuuleilei=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 DBBAF1C234B6 for ; Mon, 26 Feb 2024 09:08:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F35E12FB06; Mon, 26 Feb 2024 08:29:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YXl9J4E0" Received: from mgamail.intel.com (unknown [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 C152B12CDB6; Mon, 26 Feb 2024 08:29:14 +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=1708936156; cv=none; b=tGxRkKGUZSucO1Ky80xu3qxjmjgL53ZIx+RrDd2Igafzu4BiBnksw6pbDJFHrfilzjNMMed0OB5GFLarPcvJmOHv/f+q2r0N9tVuG7nLmvtborJPhyZa2Na8MV6kl+Da2ALpfDtUIzx6/S5kVmhCwE0EgX/AOXzaiaXfIInIwD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936156; c=relaxed/simple; bh=TGyv4NcpisLqfQGp5DS6OP4mOwYZXVYUosr40c4DaB8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pGL7mOF3taQEW5odsgYbkwrvc4toHZezfVEbmlL12UJhHXUjPOIoAbFU2x3xKG3qVvZxdVgdyQ6rN9vs3K6o5kO4XHEGZW2bfIvvqA30t8N+QrhsX6dPboBea+L8vTEQbWCy4ubr2zLwtS73yX46YbRY0OXz6XgsrBl/0gflBaA= 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=YXl9J4E0; 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=1708936155; x=1740472155; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TGyv4NcpisLqfQGp5DS6OP4mOwYZXVYUosr40c4DaB8=; b=YXl9J4E0ymHwNWqQG5EXaIl5CRCVWLYXWp6/32LgwB2ktOnl8RJt1lEv xxwNs/y2GqMj2NAd/cnU760vDji553ees3Z3aJKFlAoctBg6vYQNiN9ED +hNUCjuByAz5sHT2OmHsaZGY4CO3E+do/oqjJHW3tNh3MiktuU14s9r9L C/D0vZ5cnIuvaNNg/EvbP/B7uklsYDMIX63WYJrHLgVHsrBMDmt6Yh05p +Lcq8ts1TIJrqJVEoF/dnuLudAV0BGcCHTMw7EWeoa2qvFN4mJ9CBp/v+ 3LF3j6HqZhQGPvkXE+0qX6CVytOojSL0WjCj8/XvwUSSjvgeQE54qJxUL A==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="20751387" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="20751387" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:29:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="6735120" 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; 26 Feb 2024 00:29:09 -0800 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com Subject: [PATCH v19 120/130] KVM: TDX: Add a method to ignore dirty logging Date: Mon, 26 Feb 2024 00:27:02 -0800 Message-Id: <1491dd247829bf1a29df1904aeed5ed6b464d29c.1708933498.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791951930036270195 X-GMAIL-MSGID: 1791951930036270195 From: Isaku Yamahata Currently TDX KVM doesn't support tracking dirty pages (yet). Implement a method to ignore it. Because the flag for kvm memory slot to enable dirty logging isn't accepted for TDX, warn on the method is called for TDX. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/vmx/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index 9aaa9bd7abf3..991bfdecaed2 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -834,6 +834,14 @@ static u8 vt_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio) return vmx_get_mt_mask(vcpu, gfn, is_mmio); } +static void vt_update_cpu_dirty_logging(struct kvm_vcpu *vcpu) +{ + if (KVM_BUG_ON(is_td_vcpu(vcpu), vcpu->kvm)) + return; + + vmx_update_cpu_dirty_logging(vcpu); +} + static int vt_mem_enc_ioctl(struct kvm *kvm, void __user *argp) { if (!is_td(kvm)) @@ -1008,7 +1016,7 @@ struct kvm_x86_ops vt_x86_ops __initdata = { .sched_in = vt_sched_in, .cpu_dirty_log_size = PML_ENTITY_NUM, - .update_cpu_dirty_logging = vmx_update_cpu_dirty_logging, + .update_cpu_dirty_logging = vt_update_cpu_dirty_logging, .nested_ops = &vmx_nested_ops,