Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1885775pxv; Fri, 2 Jul 2021 15:09:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVuvNpcF5xE4ebc8SZz8H8tmiMk0WVcU6hxOsnsgx4Mc+/5i6rR3GFpHEa6iDNzCs1Zwt7 X-Received: by 2002:a17:906:2583:: with SMTP id m3mr1852433ejb.506.1625263764917; Fri, 02 Jul 2021 15:09:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625263764; cv=none; d=google.com; s=arc-20160816; b=HR+K3etyYdVbNBnBN15670PV5+zcoK7thC+nNHwOdY82lIE03aGdwbZNoF//MlPqk+ IPkpeBFJpp8rJpvamL9Jt4phxhLkeO0lmf8JjOZ25AxXWZYAnOMvjRyU9BMYAgvidl3Z BAyJpa874aEALHI4unnZczVri/tb/FinjvD7mucT1st173xHsDyq05DZdpranByzPdeT KCjN1RBtLgPZY5InwUq0kcGS6g8hzZ9xffCxuLyk/scbxPx524qRKKVfpxWG29KGjHJv GmOtQk8wTmiJOQIXpZDDnO1oo0sRrSrqmDUyIYx2Wqwo/bTlkjZPXkZSKpF0rm3ZQTT3 HRuQ== 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; bh=5cnJKIzPF6TDRe5GjZ9l/TelJ+AH6oHDVfHRuqrkXB4=; b=VQfSmDI8/Z4hkmEmqUBYZMh96zsDpCgD3jBiVQpRs2o4SkylFmlUTpAEbTQexGw45p FxFTHoIOHFzIGhqzDy1s6zd0pTEDoYiEZXb0uaZ9FdC7Ocyb+kPO3VsJd0Syb2+PMouG EfsGakc4H9cX9S1T+PHGpMJLYtHSfHqkbmwBk451g6nshOJX0EQ5b1YICrKr4/aeVcO1 2lvnfhiwn/cUbjj6fp/lRDVMwtvsAUC/GR8RLlT8E/UlA8WZ5zGQ1DggN+nStqqzZfSI TAa70a0RjPxXkEKXF9DPIFtcjsH8n02SuXuQqgwYL0jblrZ7Q8RKkg6oQIGw0LDBXZ8l J6qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k5si1109356edv.339.2021.07.02.15.09.02; Fri, 02 Jul 2021 15:09:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234434AbhGBWKB (ORCPT + 99 others); Fri, 2 Jul 2021 18:10:01 -0400 Received: from mga12.intel.com ([192.55.52.136]:50200 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233151AbhGBWH6 (ORCPT ); Fri, 2 Jul 2021 18:07:58 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10033"; a="188472741" X-IronPort-AV: E=Sophos;i="5.83,320,1616482800"; d="scan'208";a="188472741" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jul 2021 15:05:25 -0700 X-IronPort-AV: E=Sophos;i="5.83,320,1616482800"; d="scan'208";a="642814785" 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; 02 Jul 2021 15:05:25 -0700 From: isaku.yamahata@intel.com To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , erdemaktas@google.com, Connor Kuehl , Sean Christopherson , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Sean Christopherson Subject: [RFC PATCH v2 34/69] KVM: x86: Add support for vCPU and device-scoped KVM_MEMORY_ENCRYPT_OP Date: Fri, 2 Jul 2021 15:04:40 -0700 Message-Id: <68b1d5fb6afc30e41e46be63ef67412ec3b08fab.1625186503.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson Signed-off-by: Sean Christopherson Signed-off-by: Isaku Yamahata --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/x86.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 9791c4bb5198..e3abf077f328 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1377,7 +1377,9 @@ struct kvm_x86_ops { int (*pre_leave_smm)(struct kvm_vcpu *vcpu, const char *smstate); void (*enable_smi_window)(struct kvm_vcpu *vcpu); + int (*mem_enc_op_dev)(void __user *argp); int (*mem_enc_op)(struct kvm *kvm, void __user *argp); + int (*mem_enc_op_vcpu)(struct kvm_vcpu *vcpu, void __user *argp); int (*mem_enc_reg_region)(struct kvm *kvm, struct kvm_enc_region *argp); int (*mem_enc_unreg_region)(struct kvm *kvm, struct kvm_enc_region *argp); int (*vm_copy_enc_context_from)(struct kvm *kvm, unsigned int source_fd); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index f7ae0a47e555..da9f1081cb03 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4109,6 +4109,12 @@ long kvm_arch_dev_ioctl(struct file *filp, case KVM_GET_SUPPORTED_HV_CPUID: r = kvm_ioctl_get_supported_hv_cpuid(NULL, argp); break; + case KVM_MEMORY_ENCRYPT_OP: + r = -EINVAL; + if (!kvm_x86_ops.mem_enc_op_dev) + goto out; + r = kvm_x86_ops.mem_enc_op_dev(argp); + break; default: r = -EINVAL; break; @@ -5263,6 +5269,12 @@ long kvm_arch_vcpu_ioctl(struct file *filp, break; } #endif + case KVM_MEMORY_ENCRYPT_OP: + r = -EINVAL; + if (!kvm_x86_ops.mem_enc_op_vcpu) + goto out; + r = kvm_x86_ops.mem_enc_op_vcpu(vcpu, argp); + break; default: r = -EINVAL; } -- 2.25.1