Received: by 2002:a05:6358:795:b0:dc:4c66:fc3e with SMTP id n21csp1447109rwj; Sun, 30 Oct 2022 00:30:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4eDr5SMcIJCKI5vPGSNkJDjx+KvoBMeogkFy7u8kxd1UgGFTqBQYgjpEYjHDdlKTfQTl9n X-Received: by 2002:a17:902:8bc9:b0:186:e151:6b29 with SMTP id r9-20020a1709028bc900b00186e1516b29mr8271053plo.8.1667115053340; Sun, 30 Oct 2022 00:30:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667115053; cv=none; d=google.com; s=arc-20160816; b=bNR7lng7s4n3o3o7MO6vL2896krXE3qBd3Hz7Z3QxwsQgn2jE5uHuzqTypTQQagnBg ssz1HNxy6pBavtFvz+39ykezBA4vSnV+RdcFpwmuRUMmQM7tz7DDzxYmrrj8MbfQ/DSa WaO1WZ0OwUfF5OShD3OG4trL+BL4qwYHk2z1HLbpGgdYdeGa8ENyidjOPkBVDBZ2Eq04 HAiO5IU7q6CpYS7JCX9Q2EXuZbY5Np8pXHdOVbh85SjOz6QFD3JKdL9wm92IgQxBRIS9 lOjo/xIaIrKNBkyTqwshs6PUSpWLL/jdLCWn78OHXcx5jzM9ykFUzTMAyKE7EPWsiIct 1PpA== 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=xAOn1yxmr6Mrub1+62oU563RkVMRUrUsy2JXqFXS+GQ=; b=jCVdiOriu16mA4VZtdpCh/wHaijpOaxtLptIAf07UlHonEP47eaAaX/khwPfd+ODRz RXOCpOFxa+I4rb242ECBed3isrzIx0SF4mz/Dz0dsllf0O+6dBmV73NXGYjNNsA53Msh 06ZWBgFz/hwkgBqyHeFn8OiDK7k6GoLk1nwx+KryFcqoDsIyUaItzBflp67NAaCqWkfT JiakD27rj9Wmr3Y7O8T0Q80G1IV4/u5QK1VauNlf3l9SAyLPo3mLsaO9DMO2ISou2Wx4 To+YasRGThIi2s4QFtxX2x1DOFFCNEt8FLwcS2BBn+lYnIcp7JrctKA+GKPVb0Hf/j6y V8vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OWchnVj3; 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 i6-20020a170902c94600b001780ba6c694si5661343pla.35.2022.10.30.00.30.42; Sun, 30 Oct 2022 00:30:53 -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=OWchnVj3; 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 S230055AbiJ3G3l (ORCPT + 99 others); Sun, 30 Oct 2022 02:29:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230420AbiJ3G1P (ORCPT ); Sun, 30 Oct 2022 02:27:15 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 383F6286; Sat, 29 Oct 2022 23:24:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667111062; x=1698647062; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tg3ti5XASbFLYxgQdIxcPquIONUemSJw0hYO8oY7anU=; b=OWchnVj3PFC9l32zzftfaHkD4zUXNQN1c1YIN6DfAjWIt0qB26fhLWUF h2Jnm5PJGHJQ6Qchv7zuOeopteY3vjLnUIeIqZtftVlSFkc0xPbh2/n9B 2QZNJj8Y+EcD9phlFvhs5YAhtXLbBy8ycz03j6TLLn2AX6dGeTxHgXuYL SeW2hLHLQQuOHP6D6n+g6D38NsKLQ5W8aGeYxBfSNEZ9O6Z+I7LTVBC7U gSxs9f9/isjhVpikA3BFr2RVPLpmu2tJ9AFs+PVFdj2v4labePzW9RLcQ oz00GT+xOqd7e6p5LUGI13IOY9EaeWGsbFwotddqHiRZu+dcYsjGGx/lk A==; X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="288435997" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="288435997" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:24:14 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="878393168" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="878393168" 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:14 -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 102/108] KVM: TDX: Handle TDG.VP.VMCALL hypercall Date: Sat, 29 Oct 2022 23:23:43 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_PASS,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 From: Isaku Yamahata Implement TDG.VP.VMCALL hypercall. If the input value is zero, return success code and zero in output registers. TDG.VP.VMCALL hypercall is a subleaf of TDG.VP.VMCALL to enumerate which TDG.VP.VMCALL sub leaves are supported. This hypercall is for future enhancement of the Guest-Host-Communication Interface (GHCI) specification. The GHCI version of 344426-001US defines it to require input R12 to be zero and to return zero in output registers, R11, R12, R13, and R14 so that guest TD enumerates no enhancement. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/vmx/tdx.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index 4db552b60271..8e8ac1081ce4 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -1068,6 +1068,20 @@ static int tdx_emulate_wrmsr(struct kvm_vcpu *vcpu) return 1; } +static int tdx_get_td_vm_call_info(struct kvm_vcpu *vcpu) +{ + if (tdvmcall_a0_read(vcpu)) + tdvmcall_set_return_code(vcpu, TDG_VP_VMCALL_INVALID_OPERAND); + else { + tdvmcall_set_return_code(vcpu, TDG_VP_VMCALL_SUCCESS); + kvm_r11_write(vcpu, 0); + tdvmcall_a0_write(vcpu, 0); + tdvmcall_a1_write(vcpu, 0); + tdvmcall_a2_write(vcpu, 0); + } + return 1; +} + static int tdx_report_fatal_error(struct kvm_vcpu *vcpu) { /* @@ -1135,6 +1149,8 @@ static int handle_tdvmcall(struct kvm_vcpu *vcpu) return tdx_emulate_rdmsr(vcpu); case EXIT_REASON_MSR_WRITE: return tdx_emulate_wrmsr(vcpu); + case TDG_VP_VMCALL_GET_TD_VM_CALL_INFO: + return tdx_get_td_vm_call_info(vcpu); case TDG_VP_VMCALL_REPORT_FATAL_ERROR: return tdx_report_fatal_error(vcpu); case TDG_VP_VMCALL_MAP_GPA: -- 2.25.1