From patchwork Sun Oct 30 06:22:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 12883 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1666361wru; Sat, 29 Oct 2022 23:29:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4AMst/nIpgoVx/vg5VCIIOgjr7Ydsuw/KNS5wuFQykQBDCdQbeNKWKGaML3bL+0iN16fPp X-Received: by 2002:a17:902:e743:b0:187:1d0:6b with SMTP id p3-20020a170902e74300b0018701d0006bmr7978826plf.119.1667111395960; Sat, 29 Oct 2022 23:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667111395; cv=none; d=google.com; s=arc-20160816; b=lxGDdi+8/FSPA1xGUtTzRictyyTM+JC3FCqDH3K531zXRpm5IxjQm7QC5PXsWDODZJ tGbvf6gWsdCkjafXNRVGBj/+Eb4IqVviaJuY/J8XG6B/MDgJiFSfd1NlbjrRZGg5iNT5 071c/KUqXoFTSmdX71adFdQZOsb9TZsyzggl3akkrWg3d3t2Yy2fzn0sdEinaMsHME3A WYPu/recahOKwuH8ouZddBHKBja30XRcn8TywqA4whRuoGtej6Jh+EApNspe1uNsWbYp JKbdtMu9jiuR4nV9Qos2eVKxPI9BtLLWXJwxC8DCgXdRHwHWVVOBMDC4GIb+npjGO5uG 54LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=me9bWRiTZ5mTreuBxbpHPwy2YoWGfS4FgLnMaxiHSls=; b=BSgmkXgsm6E5fbP06CpShb6UpTUXpDyasTt1+rVfo0KpEggxbMZt74pWp6fBX6wwBX ZonAsGmQiBdxdYbqXnmUkIIwHeMQD+eklWnOJTD/nMKagWbhYWADmt+skRhey1m8HioM AzQqRTSMc1Oy7zYic1zjt/SFMjBbuWYdRENPxJ6mYhu+S+4bS2vktuMRHYTAn+CnlT4N D5KXLJcQ+Z+0CWQqm/W7GK7LhWWgFq2g0kY9HX5oBE5FwsMa4p55dIUCltLPe1Ca2eRZ gzsldyCP8/Cgj1xRTMui9GbwNJ2r7EjtHvSY2akokl/lnqmTmEzhY8Hyg4R2672waMMG rj7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PTtuyg9C; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16-20020a632a10000000b0046f56372127si4199986pgq.468.2022.10.29.23.29.43; Sat, 29 Oct 2022 23:29:55 -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=PTtuyg9C; 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 S230127AbiJ3G2l (ORCPT + 99 others); Sun, 30 Oct 2022 02:28:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbiJ3GZF (ORCPT ); Sun, 30 Oct 2022 02:25:05 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91F7B1DD; Sat, 29 Oct 2022 23:24:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667111053; x=1698647053; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=elmKS02WiygU5IrlA++TZV5oI8cDn28t+pY/4QpTrh0=; b=PTtuyg9CnidcTcQ70FemTdfk9KIJyp1nl+N8JoRCWwgWMjH6Aif+pY8x axuIwHsPh0q1UaFnkpwqVGl/wbaMVvzEUoAD6bgdQM4yE8gIc0YyiVXPD HCS6SUnkF/bC4p0xscUYSPCX7h7IBrPshxJ+uEQ7TLAInksCkJaRKDHgN WBWdlIdhAZ4SZMMwndjGdEigum6Xlyv9xIHVFAPmrW7keZcgRaCgg4Iiy JN077KBuuXFqxm7rfqubZIUtWo6QhPiTTV4t/6bnsz+jiBhRljdii/RM9 YufRrkZLGwmk6ok7Zuuu9owDXU5jnLHnq2A7w7IHMab5vuGjkVm55hL63 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="395037169" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="395037169" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:24:06 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="878393027" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="878393027" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:24:06 -0700 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 , David Matlack Subject: [PATCH v10 056/108] KVM: TDX: don't request KVM_REQ_APIC_PAGE_RELOAD Date: Sat, 29 Oct 2022 23:22:57 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.9 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748092999117285416?= X-GMAIL-MSGID: =?utf-8?q?1748092999117285416?= 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. WARNING: arch/x86/kvm/vmx/main.c:696 vt_set_apic_access_page_addr+0x3c/0x50 [kvm_intel] RIP: 0010:vt_set_apic_access_page_addr+0x3c/0x50 [kvm_intel] Call Trace: vcpu_enter_guest+0x145d/0x24d0 [kvm] kvm_arch_vcpu_ioctl_run+0x25d/0xcc0 [kvm] kvm_vcpu_ioctl+0x414/0xa30 [kvm] __x64_sys_ioctl+0xc0/0x100 do_syscall_64+0x39/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae Signed-off-by: Isaku Yamahata --- arch/x86/kvm/x86.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 3868605462ed..5dadd0f9a10e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -10487,7 +10487,9 @@ 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) + /* TDX doesn't need APIC page. */ + if (kvm->arch.vm_type != KVM_X86_TDX_VM && + start <= apic_address && apic_address < end) kvm_make_all_cpus_request(kvm, KVM_REQ_APIC_PAGE_RELOAD); }