Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp977512pxb; Wed, 6 Apr 2022 05:52:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNNWRRXplBUyzeATDYNAaoyPZS0yIXRi+LLGkoYDm0QwaTEYp3wx2whvPmUg8ESJXQ+zJS X-Received: by 2002:a17:903:2288:b0:153:bfbe:7354 with SMTP id b8-20020a170903228800b00153bfbe7354mr8572361plh.112.1649249541289; Wed, 06 Apr 2022 05:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649249541; cv=none; d=google.com; s=arc-20160816; b=zrCr9kr49fg7WNEBQ+mKm8KDVOM9b+7l9AtfIW4Oy+Ni7TzN86GsBdtkvzNnzgU9kc YrCVJkr68lUSjm7D0+aD6UGnh7D17nbEjF1+z9sb/fkAE/XCwoic1dxVCj6PkjZe76ZN BIcJrt+dUE5wtiO/bVxr0jYajLEPW3WnaV6HGBNalI0ZDAd5qc7bpqaIb9q/eb23csIp fRkR9/lBa5rNB3QbLn3TGaNJxippz2CP21YMBcPSV0LWp3E89TonWfkF+PaCgIxjs09G PbKEs60rsxQav/o+Uuv3C9+637krsEIznalJlZgrXprWzpD03hGxti0+2921fmbeADXw KKTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=juDmRm7zJOFlw90DcOSf1yX4bMFhv58WyLq8A0PPfCA=; b=N2UIaRrs1YeTvJL9T/axhbjhW5kxjHQPtih9HxPmdChwBzQV/SZU6KIWzMaxjPLvQY /tdUmALiw4RkzHamq4XwOgWgJYRZiTM6d8OKmO8o22IaEsaCwUtBy9K/VI0c9IwKLJ6e X/ZTQwdVBuhVOWQUmrdWCFSCTlht0r4TdeycGMh71pBLsB/qWSgUjIGWGerQ12Wf6IrA o4xxYg+XKq/VF+l7FjinJBnglTcUaEWjjBH8N3l50qg3f6oPKRVhNBbuKC0wUe4DX2z9 WDHqJXFUe0aCPuwtNzGM2Ls7aOZFqexsLjhmf8dHI8Y+vE8LmpQim1KH67mS93Cg3zJ+ 1ung== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fNOnRcUo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q1-20020a63e941000000b003816043efd4si3063825pgj.457.2022.04.06.05.52.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:52:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fNOnRcUo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8252C33D81B; Wed, 6 Apr 2022 02:48:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1841617AbiDFBYs (ORCPT + 99 others); Tue, 5 Apr 2022 21:24:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241763AbiDEOW7 (ORCPT ); Tue, 5 Apr 2022 10:22:59 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BF69E6C907 for ; Tue, 5 Apr 2022 06:09:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649164184; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=juDmRm7zJOFlw90DcOSf1yX4bMFhv58WyLq8A0PPfCA=; b=fNOnRcUoLWNHdXq6Qj3UG9bqKF7beffPpv70VbaxRGd5sqJPiFUcuH3BAubzRSMgxEB5L9 6uzpKtFFwev1ON9RM5JAYKi2Md80RTvYPzAU4SeWolZOkbxrU5+tzrcW5KzyPmbvcBQvbz 1d4gcUNCJafMPbqV86X4tcpNGl5T860= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-647-QaUaqGS_P46CJ7yCvh3Rhw-1; Tue, 05 Apr 2022 09:09:39 -0400 X-MC-Unique: QaUaqGS_P46CJ7yCvh3Rhw-1 Received: by mail-wm1-f71.google.com with SMTP id l7-20020a05600c1d0700b0038c9c48f1e7so1331360wms.2 for ; Tue, 05 Apr 2022 06:09:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=juDmRm7zJOFlw90DcOSf1yX4bMFhv58WyLq8A0PPfCA=; b=1n5+2uvN1xWXjYNJvHhxsGKxVqmB9407B/8wkdOB1G2J4MCWcJTjjmndRR2y2YtLti npWoB//Vn+duXvGeJF9a0KzjAdgB/rUyOf4WEFWd6smrDqtgZPeEKTtCvgcbJvcYB1OQ 3YT/i8VuoquYeB+uoqbocWNdQoRRoUQQmfC+jSkSdcawiIHz1emXrFr+zUCgQHf+0Bb1 t3fGCBiN1B+qclxAE1fvqlgTO1WcD5qoPygz1HCKF5uPmGut2TnXg8ZFuLOsnBXHjZgZ bYcdwMlTXz2AFHLkvTuQ0tmNUUXSO4dKlDh+7fHYL8fs5tY67kT3j4PGZ8t/7HtLMRig zElQ== X-Gm-Message-State: AOAM530FfjWjWapXi8XSyxYRMHn66fZosphLCbxVmvbXUvCbQfA2W04I BOdiNGD0aRaBg7YPnm660K7dWHzS4SGmCvbgvEPctAHcjSIQmShgYB8hOLVBGPTHiilfq375rWN 62tTMjcw/7XyzpllaJmpj/TXt X-Received: by 2002:a05:600c:1c8d:b0:38c:db69:5759 with SMTP id k13-20020a05600c1c8d00b0038cdb695759mr3169254wms.204.1649164173336; Tue, 05 Apr 2022 06:09:33 -0700 (PDT) X-Received: by 2002:a05:600c:1c8d:b0:38c:db69:5759 with SMTP id k13-20020a05600c1c8d00b0038cdb695759mr3169222wms.204.1649164173010; Tue, 05 Apr 2022 06:09:33 -0700 (PDT) Received: from [10.32.181.87] (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.googlemail.com with ESMTPSA id 3-20020a5d47a3000000b0020412ba45f6sm14282576wrb.8.2022.04.05.06.09.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Apr 2022 06:09:32 -0700 (PDT) Message-ID: <8ad49e0e-91ea-8dd9-0725-e263fae45a91@redhat.com> Date: Tue, 5 Apr 2022 15:09:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [RFC PATCH v5 035/104] KVM: x86/mmu: Disallow dirty logging for x86 TDX Content-Language: en-US To: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@gmail.com, Jim Mattson , erdemaktas@google.com, Connor Kuehl , Sean Christopherson References: <7fe3a6d75d0ad6469c97e2edf34a1886ff7be7be.1646422845.git.isaku.yamahata@intel.com> From: Paolo Bonzini In-Reply-To: <7fe3a6d75d0ad6469c97e2edf34a1886ff7be7be.1646422845.git.isaku.yamahata@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 3/4/22 20:48, isaku.yamahata@intel.com wrote: > From: Sean Christopherson > > TDX doesn't support dirty logging. Report dirty logging isn't supported so > that device model, for example qemu, can properly handle it. > > Signed-off-by: Sean Christopherson > Signed-off-by: Xiaoyao Li > Signed-off-by: Isaku Yamahata > --- > 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(-) > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index c52a052e208c..da411bcd8cbc 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -12876,6 +12876,11 @@ int kvm_sev_es_string_io(struct kvm_vcpu *vcpu, unsigned int size, > } > EXPORT_SYMBOL_GPL(kvm_sev_es_string_io); > > +bool kvm_arch_dirty_log_supported(struct kvm *kvm) > +{ > + return kvm->arch.vm_type != 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 a56044a31bc6..86f984e0c93f 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -1423,6 +1423,7 @@ bool kvm_arch_dy_has_pending_interrupt(struct kvm_vcpu *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); > > #ifndef __KVM_HAVE_ARCH_VM_ALLOC > /* > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 3adee9c6b370..ae3bf553f215 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -1423,9 +1423,18 @@ static void kvm_replace_memslot(struct kvm *kvm, > } > } > > -static int check_memory_region_flags(const struct kvm_userspace_memory_region *mem) > +bool __weak kvm_arch_dirty_log_supported(struct kvm *kvm) > { > - u32 valid_flags = 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 = 0; > + > + if (kvm_arch_dirty_log_supported(kvm)) > + valid_flags |= KVM_MEM_LOG_DIRTY_PAGES; > > #ifdef __KVM_HAVE_READONLY_MEM > valid_flags |= KVM_MEM_READONLY; > @@ -1826,7 +1835,7 @@ int __kvm_set_memory_region(struct kvm *kvm, > int as_id, id; > int r; > > - r = check_memory_region_flags(mem); > + r = check_memory_region_flags(kvm, mem); > if (r) > return r; > Reviewed-by: Paolo Bonzini