From patchwork Mon Feb 26 08:26:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 206427 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1947292dyb; Mon, 26 Feb 2024 00:59:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUjS8jlmIExQ1ssBl7xVZEH+AYBAL+LoG1DF64I8LhuVr2rKlITlvul1mKTHJ+8l01BsVSp2MX9o8MNMry8nhrVMFXqEQ== X-Google-Smtp-Source: AGHT+IHludtLDHpRiAbHiIMKty8jQTB84ub7zUfcXGMzh4A1o/pdDYwchTzfE15KDGXzc0NsT1c5 X-Received: by 2002:a17:906:e0d3:b0:a43:7edb:87 with SMTP id gl19-20020a170906e0d300b00a437edb0087mr310238ejb.4.1708937978036; Mon, 26 Feb 2024 00:59:38 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708937978; cv=pass; d=google.com; s=arc-20160816; b=QBG1G4gDjt+hI9uwtbfekj5V7sUXdGqg9BrJYYyRzW+hW620UaEo9/atigNu/YQJoM t3CdHuFn/PFXVFyktbhEvZOlA/gy2cqDvZ1sU2dZROjPrs4aalhIXPVYADsVwW59TMLq r4kkVdi0zGMNJ0Sa92yZTqcC+vjL1zhca0WQGN/XWf+k9ldpCCNrojjIsBQZgGAZ3oRk pDM2AxbiVKOSNGuFLzTOgBgJ2qXUfVt0r1OhYqfJRpJone4Wlc6wdVpxRUZhq3c4PAhG w0G76PTR8uyrjsdMkFwMDXwQDaLduQGVdG7nKTv+Ro3YFexCS7l0vKweI6osDjKaVXnB A4zA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Vhjx3RQK46dkz072G7trcvecyucPXT8J1/DUFmtAdnY=; fh=Itbyk7CEvizIrzGEESCqq3I2tZgG1kc/GkVOa3S7Hsg=; b=z+y8ra8c9LOh2qDd630XrCqIgIq98prEM4RSLtItS3sEuV6WMulEC2/00yZa6cSmmD VrNqOsYoDicM8rDcKL4Xkath3By6hfpGSkt0mW6V1d2jaj5v/CtlY4h+53HAYU362AG+ l+jkRMYApF/C5QxY8mEEj48KxsvSm8gWF6Y69P5np+iL9BipKUH/rTUdT1gAPhlyu0ks AdY86hpnEIcAIrASgfid4xs3PWPcTM9AiCBKKdKARk1/jfjnkVJCNdYx7z6L3oYHF3ur vWHm7M8VxX35LJa/PyFhQnIPhZwhjWce3NJE8Pyj1Sa70TzDzdPboDdaeKuK62c5cyZv qMag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=U3pgJNqI; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-80855-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80855-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d10-20020a1709067f0a00b00a4356d767ddsi571403ejr.793.2024.02.26.00.59.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 00:59:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80855-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=U3pgJNqI; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-80855-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80855-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 970CC1F23026 for ; Mon, 26 Feb 2024 08:59:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97E4C7E0E4; Mon, 26 Feb 2024 08:28:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="U3pgJNqI" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A287E7AE52; Mon, 26 Feb 2024 08:28:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936133; cv=none; b=goPw+waxVSiY2AgP5WvkL/t1rFcXTUjbSMKIxK2On6Tujx4XGbjNjz0aOgwaDC8+Cn1cjtHWH8lwCq8SnFZL9hGVLq2xPQpGgxR8fAxEXqyR7tTAhAOOiKGUw0hgbYw55gJV9yDHTpGp9M6QdDW3XdRLUtHyr8cY2UZAc767z0Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936133; c=relaxed/simple; bh=8srNeTZplG2ftxUe7RfzcGruSkR0LpbTdRnxJyIOPTQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n+5VFxFW+REiQ/tN9nESidefxIfI9rs6WSIv+tfQ4Mx/gnnIUk71qt5jJqDzOlUGTY3F5YVrBmD8NBpKaoqgRW4vUzXTFyCwz2DNwINa3BNrZcrAY7c40YL/LhJ35qQAAg3MUhEwqRD9gRqnfcu1kirLZtR4shbuXBYOkHG09x4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=U3pgJNqI; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708936132; x=1740472132; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8srNeTZplG2ftxUe7RfzcGruSkR0LpbTdRnxJyIOPTQ=; b=U3pgJNqI7q9mouSD+psZBjkzyPrmAktiNCS83+XBGchTJbZ3rlO4qfi0 wYcA32wNj2O5nyDBUPk6JmjxbhYqM6thgzKdHN3xWsxgj8hBk/ek077sA PR7GYXZMhHAFMNjiQtd2DEH0sgeRAfBcWPs9dy+IwTGXvw4maG8wHOFe0 HKoFHStkRL9pmNQeOLG/kktUbdhZj9cZK0fa46u5Sz2c8VTTNaSzMbg5z Ge7Q5hZ2fYKWCsSDHbkBbpsTQJTBQ1WWt1V4kThtwc8ao57daK+glbhwB UvRJy1gEf+4jYCQqLv75dRr80C5XYJQh0W0lx+ToFki6JLOkTr2plbx99 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="3069567" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="3069567" Received: from orviesa004.jf.intel.com ([10.64.159.144]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:28:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="11272653" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:28:51 -0800 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 , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com Subject: [PATCH v19 093/130] KVM: TDX: Implements vcpu request_immediate_exit Date: Mon, 26 Feb 2024 00:26:35 -0800 Message-Id: <3fd2824a8f77412476b58155776e88dfe84a8c73.1708933498.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791951349257510830 X-GMAIL-MSGID: 1791951349257510830 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index f2c9d6358f9e..ee6c04959d4c 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -372,6 +372,16 @@ 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)) { + __kvm_request_immediate_exit(vcpu); + return; + } + + vmx_request_immediate_exit(vcpu); +} + static u8 vt_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio) { if (is_td_vcpu(vcpu)) @@ -549,7 +559,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,