Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp11026imw; Thu, 7 Jul 2022 19:58:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1viFVcywdjYwomtvYBVvQelnYMTDsdwH/vp7CQUvAH5kXDZAgqRxbsaVJGcscQ5pHReJKgE X-Received: by 2002:a17:902:d512:b0:16b:ff69:39 with SMTP id b18-20020a170902d51200b0016bff690039mr1251127plg.137.1657249100167; Thu, 07 Jul 2022 19:58:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657249100; cv=none; d=google.com; s=arc-20160816; b=ShH7ySPlnTbysjxt95nE17fLSilAt0GtqGMCmNFUAFlORZjjHTo34H74Qv4EheOoyr GvaSDAs9n3YR6AUSQmdI4ymbLaqB+ptT6Vmei1jgWZb1hHAB6um6c8nynpDvbFKwznR5 LsI4vMO37LFX2/PLogNob32ySMYT6ckJIMfMplWwaVfX/4WfWGHtMBaO7ccFqY2CKj/J lHmdgjOmxIokww4m4XcAF9F6USw3L4TboNtOC4WhPinvvOb22/n/kfwOJCpP+EnYvzRs YMY4TVhFrrQLF0DTn6fTvfibZ+jalVUrQmJ8KWxdRXau6Pj80tTCvIqZAzxE7oK3ntpC z+Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=srfbCunYzPcjnEC6s9HxBsEqiGMZ3y+MeUrlTiDHMMg=; b=WJxAZNNRCvaTtcaiNOcAzjFhuSAVgSHrwlPNNzFyr5jzjtX/kgkYiJlvdCEI3rlYzr uFnTOgYVlGx3LFBwn4RGeaNDRLUvWvLfL3NDByldCeeLTUTJ7FXl0jP9UM7crgT84sNV A2egQS9TkySdwXeLl74I33jJl6dHwv8nfJYSpAJkHmdGmrNIk4CtO6bDZ/Tj569c1DRD 12HjP5AaddKQ4hlCXnZ/2DAAopcyjuZpowPx5btMXPLpYxJs/RXBm4dfiJGwM2FbRn64 ip5lPrI1aZ0ZLntKUZzQSLOhEz74GdYB/hdc0WuBOdpzILu7JTgR5tOvjAc8HRw+8ZJ+ vuoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DeMPWcRE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c189-20020a6335c6000000b00415366cf295si3701457pga.19.2022.07.07.19.58.03; Thu, 07 Jul 2022 19:58:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DeMPWcRE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236738AbiGHCag (ORCPT + 99 others); Thu, 7 Jul 2022 22:30:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbiGHCaf (ORCPT ); Thu, 7 Jul 2022 22:30:35 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 962DA7435B; Thu, 7 Jul 2022 19:30:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657247434; x=1688783434; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=Qfe0hwBtuYqnedT3Jb3c7TgFpVkkn5l3WYf0C+Aib0Q=; b=DeMPWcREkEL5cMy6V0QknTMDku48mvVA6dbCE4quxcOrNUayV9YsMrID pk2I2FEWs4jdWbyBOjmQP3c4T2z2BnGKsEUXMNEy00JMu/LrEWfkQy+ph KrpLAZYm96sUrA4kcefxYiTItJ3ddL1Np+LdtsQz3kklOo68N7mwa8ESO 7KDXsFfw6FweiOWTRinYuLRdfjb+Ym782OvhM7p6DTXTpKFqM4hS21MH0 rTjBD+16+wAxAA2kcWNRxV1HFTdr04SeQ6iNsvtMNw46+bus4Wcf4H5+X Grpz9TqBmn1y+4MoOCojuWRs3v3nwun/e1k5oM43u/PKUqujRsuThtkr2 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10401"; a="267201899" X-IronPort-AV: E=Sophos;i="5.92,254,1650956400"; d="scan'208";a="267201899" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2022 19:30:32 -0700 X-IronPort-AV: E=Sophos;i="5.92,254,1650956400"; d="scan'208";a="683514184" Received: from pantones-mobl1.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.212.54.208]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jul 2022 19:30:30 -0700 Message-ID: Subject: Re: [PATCH v7 048/102] KVM: x86/mmu: Disallow dirty logging for x86 TDX From: Kai Huang To: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@gmail.com, Paolo Bonzini , Sean Christopherson , Xiaoyao Li Date: Fri, 08 Jul 2022 14:30:28 +1200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.2 (3.44.2-1.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2022-06-27 at 14:53 -0700, isaku.yamahata@intel.com wrote: > From: Sean Christopherson >=20 > TDX doesn't support dirty logging. Report dirty logging isn't supported = so > that device model, for example qemu, can properly handle it. >=20 > Signed-off-by: Sean Christopherson > Signed-off-by: Xiaoyao Li Xiaoyao's SoB looks weird. > Signed-off-by: Isaku Yamahata > Reviewed-by: Paolo Bonzini > --- > arch/x86/kvm/x86.c | 5 +++++ > include/linux/kvm_host.h | 1 + > virt/kvm/kvm_main.c | 15 ++++++++++++--- > 3 files changed, 18 insertions(+), 3 deletions(-) >=20 > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 4309ef0ade21..dcd1f5e2ba05 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -13164,6 +13164,11 @@ int kvm_sev_es_string_io(struct kvm_vcpu *vcpu, = unsigned int size, > } > EXPORT_SYMBOL_GPL(kvm_sev_es_string_io); > =20 > +bool kvm_arch_dirty_log_supported(struct kvm *kvm) > +{ > + return kvm->arch.vm_type !=3D KVM_X86_TDX_VM; > +} > + > EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_entry); > EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_exit); > EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_fast_mmio); > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index 79a4988fd51f..6fd8ec297236 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -1452,6 +1452,7 @@ bool kvm_arch_dy_has_pending_interrupt(struct kvm_v= cpu *vcpu); > int kvm_arch_post_init_vm(struct kvm *kvm); > void kvm_arch_pre_destroy_vm(struct kvm *kvm); > int kvm_arch_create_vm_debugfs(struct kvm *kvm); > +bool kvm_arch_dirty_log_supported(struct kvm *kvm); > =20 > #ifndef __KVM_HAVE_ARCH_VM_ALLOC > /* > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 7a5261eb7eb8..703c1d0c98da 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -1467,9 +1467,18 @@ static void kvm_replace_memslot(struct kvm *kvm, > } > } > =20 > -static int check_memory_region_flags(const struct kvm_userspace_memory_r= egion *mem) > +bool __weak kvm_arch_dirty_log_supported(struct kvm *kvm) > { > - u32 valid_flags =3D KVM_MEM_LOG_DIRTY_PAGES; > + return true; > +} > + > +static int check_memory_region_flags(struct kvm *kvm, > + const struct kvm_userspace_memory_region *mem) > +{ > + u32 valid_flags =3D 0; > + > + if (kvm_arch_dirty_log_supported(kvm)) > + valid_flags |=3D KVM_MEM_LOG_DIRTY_PAGES; > =20 > #ifdef __KVM_HAVE_READONLY_MEM > valid_flags |=3D KVM_MEM_READONLY; > @@ -1871,7 +1880,7 @@ int __kvm_set_memory_region(struct kvm *kvm, > int as_id, id; > int r; > =20 > - r =3D check_memory_region_flags(mem); > + r =3D check_memory_region_flags(kvm, mem); > if (r) > return r; > =20