Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4042543imw; Mon, 11 Jul 2022 23:52:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vkWoBywGzYYY+sQu4ZX4SGDOeJfmLngPLNOJJ1EGJzE01C0wVjrSrj8uwdcjM3696H8LV9 X-Received: by 2002:a17:90a:4294:b0:1ee:f3f2:9cd0 with SMTP id p20-20020a17090a429400b001eef3f29cd0mr2569102pjg.79.1657608748558; Mon, 11 Jul 2022 23:52:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657608748; cv=none; d=google.com; s=arc-20160816; b=j1feUPaqX7nD36yL2GCR35JfilVjhu0ojR9eMP+6xQn63/4pAoFxHHB6sag2W6kruw suc41UfSXN1OISKRUb/evvrp0b1jkfJ5BzQrXjhQ6kmNg7BteQIOteS0X6JCPA1wSvfh Ldnet1gN3spvo6QpbzNBwHsxvsHvURxpmfpf+Fng7PfRUwFadJ5o6BArZi5f7hyWlwfS UA2T7QJh5h5I7uaQegKsNo0306KSEIg/jUVTRssi8OFiRcfUM2ZF6LXvkm3+K1pSQPNW aFmypSn7QVPI91G3tzzx+BZ65XXA1oHM59TN6nfcmACG/xfQBa8qiuex08TZy7IxqO7V X4qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Vd6Tj0PNjc+0kcAEnkaL7HkD5/8BKDlxUYRVzLvphfI=; b=tXRnPqDclPgckmOYag4sR76/39Gai9iPrvv/Hn2TSvSIDb3Mm4cNp7IbqErWOgXn4R zRoaC09ZF7l3F1gOIeJ4mwCcDknxy3kFiFMTBCOrbYfRJ0kqY8P+STYEyOWvaoZbihCp vofmqNQxb4hn5M5Zgw+ESmO9usrnJcRGNk4VuCJ8lgpo8SyohoVc0+DPats7Y0QIxsoz W0V0bq40vJ6YncsOUHlI5MZyA6tXCG+0lGmfD9GZ+nPLuqe2YqrM/efPUoyNYUFQK77z ki4RWN64K1H9oZr6JfX0fc0iKZXJNoGjII8pkMQmVJoSXytoEJbHYwUpPMvE4OP+H6F5 suOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Bj4lOYyS; 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 u21-20020a056a00125500b0051f2b9f9b3bsi13740380pfi.243.2022.07.11.23.52.15; Mon, 11 Jul 2022 23:52:28 -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=Bj4lOYyS; 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 S231676AbiGLGPM (ORCPT + 99 others); Tue, 12 Jul 2022 02:15:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiGLGPH (ORCPT ); Tue, 12 Jul 2022 02:15:07 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5356381482; Mon, 11 Jul 2022 23:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1657606506; x=1689142506; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=e8t4m3KSkmOMZJqJPmnwIUB4x8PWpY13C+jIK4OpPdk=; b=Bj4lOYyS8/pHcS3o6u0RNabm8fWNib0glCPlLCyC/20bkyxhzQk9q7pj C3ipmiJZqC7Y74N2j7sG2lUV0v7pvfCH0bVhy6/wDE/5UiNaQC0FPfn/U JofedWty7gdu59OR+Yu5NPe1rY/wbaummpn09NHJ92ySX0vFUzo2eocIN 0Sm2ZppPFGV0hR4a+Ob4+2fLfVnFGxqR6OyB0+uv9V+hNLwjvjPm+saFT ZKmi7k0xezKJDQV17FJ2C8jcNfCEdW+FkjgLTwBzXQuR1UfvQE5owqcVY FRc+rG3g4hWLQqgWwfCEpApnZBIlxpcxcvJhMjS5jPjMxI/EjGmYKk6wc A==; X-IronPort-AV: E=McAfee;i="6400,9594,10405"; a="371157329" X-IronPort-AV: E=Sophos;i="5.92,264,1650956400"; d="scan'208";a="371157329" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 23:15:05 -0700 X-IronPort-AV: E=Sophos;i="5.92,264,1650956400"; d="scan'208";a="622378386" Received: from gao-cwp.sh.intel.com (HELO gao-cwp) ([10.239.159.23]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jul 2022 23:15:03 -0700 Date: Tue, 12 Jul 2022 14:14:45 +0800 From: Chao Gao To: Yuan Yao Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini Subject: Re: [PATCH v7 053/102] KVM: TDX: don't request KVM_REQ_APIC_PAGE_RELOAD Message-ID: <20220712061439.GA28707@gao-cwp> References: <20220712034743.glrfvpx54ja6jrzg@yy-desk-7060> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220712034743.glrfvpx54ja6jrzg@yy-desk-7060> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 Tue, Jul 12, 2022 at 11:47:43AM +0800, Yuan Yao wrote: >On Mon, Jun 27, 2022 at 02:53:45PM -0700, isaku.yamahata@intel.com wrote: >> From: Isaku Yamahata >> >> TDX doesn't need APIC page depending on vapic and its callback is >> WARN_ON_ONCE(is_tdx). To avoid unnecessary overhead and WARN_ON_ONCE(), >> skip requesting KVM_REQ_APIC_PAGE_RELOAD when TD. !kvm_gfn_shared_mask() doesn't ensure the VM is a TD. Right? >> >> >> Signed-off-by: Isaku Yamahata >> --- >> arch/x86/kvm/x86.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c >> index 8f57dfb2a8c9..c90ec611de2f 100644 >> --- a/arch/x86/kvm/x86.c >> +++ b/arch/x86/kvm/x86.c >> @@ -10042,7 +10042,8 @@ void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm, >> * Update it when it becomes invalid. >> */ >> apic_address = gfn_to_hva(kvm, APIC_DEFAULT_PHYS_BASE >> PAGE_SHIFT); >> - if (start <= apic_address && apic_address < end) >> + if (start <= apic_address && apic_address < end && >> + !kvm_gfn_shared_mask(kvm)) > >Minor: please condier to check kvm_gfn_shared_mask(kvm) before range, >means firstly check is or not, then suitable or not. > >> kvm_make_all_cpus_request(kvm, KVM_REQ_APIC_PAGE_RELOAD); >> } >> >> -- >> 2.25.1 >>