From patchwork Sun Oct 30 06:23:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 12910 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1666906wru; Sat, 29 Oct 2022 23:31:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5TmFI/maPUULazJYE6URpuFoTr/CseWxX6+nKJ27naOUFwbm3+RHeoeV6y4y4lR0yC+Oqg X-Received: by 2002:a05:6a00:2350:b0:541:b5bf:2774 with SMTP id j16-20020a056a00235000b00541b5bf2774mr7578439pfj.28.1667111514556; Sat, 29 Oct 2022 23:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667111514; cv=none; d=google.com; s=arc-20160816; b=n8zD8wXbtwC38y7pnYlcFh3t/gnDlzeeOZWsQGbGMS/uiMn433xncmXdoawneUM0tx j+SGLj+mHb40nzjQwIbtnCEBUmEuqPnyXyzBhitrFwte1AALi4ls0XwUJw4Od4Z9ERxt Q7kAdDYQ4Q1kCr3yDcznDr1Tvhic/PWHfueleT/VdpSDhwtVd4HzjuaJyqCQx2AUsMuL iy6MGi/o+x7aIw1cafnX8vj577I3yZRFJ9xwNbnDDYug8ebc4S+v9vz6Y2DyBd8KxzJy hjlbCzEtIPJqE91KalpzJ7eSdQfZ+i08JjUSdy9uZ9o1+Vbsg2zB3As9ac7zRp+NSA1K UIrg== 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=inxVGe4vF4QKhLwMNf44Py0JWUdBuj5CIFdGMj7BVmc=; b=C+JaYnhWjTsH4pcJT9nvsWcSXSH0MJYsh57pCNyrqOoNHM1SaIVPdu65y5ZUxbFGsm OE64226pE0ImJU06X8mJ+psfldDXz491r/y9Q8guuYRkzpJPp+M492qIg0pGKnnEA3T6 HZLxHWbn1KDCffRczECZyJJe0dQDnecq6nSpL4vhdQIXH/bB15Gs0T//Q/qoXvPAzri6 DUhimJFiQEhsrUDqenRZW4oOuhdBke3BJuxqSEuPjOhSRYOCNfPbYHyZk6jzmdQrU/y6 obSiCtLBS9gre/JEmJVFqQGddR4XUsP+pRhQ19xowdF/ZY+TPHfIvBSjDZDk65cpovWs M9ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ChN4CBjE; 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 11-20020a63194b000000b0043966935b33si4101782pgz.166.2022.10.29.23.31.42; Sat, 29 Oct 2022 23:31:54 -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=ChN4CBjE; 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 S231372AbiJ3GbJ (ORCPT + 99 others); Sun, 30 Oct 2022 02:31:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230464AbiJ3G3k (ORCPT ); Sun, 30 Oct 2022 02:29:40 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B168D33F; Sat, 29 Oct 2022 23:24:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667111087; x=1698647087; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WudwhLKpm6+sj0md1RnElvGL9BNFi0c26OmHP/0eVm4=; b=ChN4CBjE9xf493v4op0BGibWSdPyTEVD97lGfzKssanIDo/vsccIvkvc JVQYwm46VQWWqWxQKsVYAMAXIXR3NqSmVsBtIL53Tpa5s5W9OtsQUFeee OwXEDRolbzf45HvDiZyECQXOmE0EcuIOUsg2C/A5iVEluNxhmZvRQ5F8p aN8b6YoT0StxgiQE5K9EO2xDvDxHZJ5qv9g6eoF4LslfZ+j7KMOx7nlz8 y5JJfHBfiz4J95Hl1OQOZrxdMKIj7yqHrx4GCW23coDJbrjPo47jJr9YF f+Sb2nV9yHYPVKMmopNvmfXiT3rQsjxOBZ+9lsBJknjHeqsaJZTl3eptV Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="395037195" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="395037195" 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:11 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="878393107" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="878393107" 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:11 -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 082/108] KVM: TDX: Implements vcpu request_immediate_exit Date: Sat, 29 Oct 2022 23:23:23 -0700 Message-Id: <6901f181c0bfb99a8f675fdffc6429559edb5732.1667110240.git.isaku.yamahata@intel.com> 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?1748093123327203514?= X-GMAIL-MSGID: =?utf-8?q?1748093123327203514?= From: Isaku Yamahata Now we are able to inject interrupts into TDX vcpu, it's ready to block TDX vcpu. Wire up kvm x86 methods for blocking/unblocking vcpu for TDX. To unblock on pending events, request immediate exit methods is also needed. Signed-off-by: Isaku Yamahata Reviewed-by: Paolo Bonzini --- 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 13ad1278bef2..3e9007a7edfb 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -319,6 +319,14 @@ static void vt_enable_irq_window(struct kvm_vcpu *vcpu) vmx_enable_irq_window(vcpu); } +static void vt_request_immediate_exit(struct kvm_vcpu *vcpu) +{ + if (is_td_vcpu(vcpu)) + return __kvm_request_immediate_exit(vcpu); + + vmx_request_immediate_exit(vcpu); +} + static int vt_mem_enc_ioctl(struct kvm *kvm, void __user *argp) { if (!is_td(kvm)) @@ -446,7 +454,7 @@ struct kvm_x86_ops vt_x86_ops __initdata = { .check_intercept = vmx_check_intercept, .handle_exit_irqoff = vmx_handle_exit_irqoff, - .request_immediate_exit = vmx_request_immediate_exit, + .request_immediate_exit = vt_request_immediate_exit, .sched_in = vt_sched_in,