Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4721919pxv; Tue, 6 Jul 2021 07:40:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+u6v/YQfnyF9/L6194pZp/3IIMSQfKS0+xKIlaq1VnxqXeweJogTI5U/DCNyE1UDloGsp X-Received: by 2002:a05:6402:d0a:: with SMTP id eb10mr24003565edb.139.1625582432990; Tue, 06 Jul 2021 07:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625582432; cv=none; d=google.com; s=arc-20160816; b=0zg0FoVgZLyuJRmj9smhKIU6Plee6B/aJvm0K9tuLDQ5fDTtcGAGsT8p01teX5I3Cb BIJt5YoR03epYMmerb2/ezyro5MzGw9OYNUpkti6TJUhgiKrCuiyfR2s6NJmdQ3RnUYS sLXYmfLQKk6sin6KzOIokLtW0ETGd6t/Ui0Rae+O+KenGs4KvKLQz3F7DvHMnVq93o+f cgmsX6BsYHJgoe2YAOhP+oN49wEYU73wB5bmORB10ZANiPDatTa8WSQejHnK/8DwsWLg nOFcej5+kA75aOjsn3q7wXDM7NvgrQIBjalp1msL+vePz06l1BFhVuiVaP3paBNxInza ITJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=kAXRQIQOyrP0g5o0EvkttGD6vMDJoyXaK3EIFo8Ix/U=; b=k3NePHOfcW6K7cM+sGfHim00bfiPCl1+otE0PURmlScw6sgAS4hvPg8RyierJJutqY vc9zKAQUjI19GNe+KLePyV/l1wPWtVTK7+MFzSBSDH+W+vCegsR613+usWZ2NNd6pCSg erJRV07Q7+o+nDe+xk6H1ufGjsIF4IM6x4fQmjj2TU7YGaVescqrRHPQGiOWpUg8F8fX obcKiuvdoYYo6JXLoT7NyJnLZbxc5z9MZb4Z9tqUy6tuXWAR2kfPxWgp+ILan/drvo8B 5CAiAqoiDMJ3DKQ78/DwkSJMC8wGCfGkVvKcuaEwkvmjwWon+d97dVXqulaNc3gWSTwi 9jKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fCbswAoM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 10si13773121eji.574.2021.07.06.07.40.08; Tue, 06 Jul 2021 07:40:32 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fCbswAoM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231967AbhGFOfs (ORCPT + 99 others); Tue, 6 Jul 2021 10:35:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28997 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232328AbhGFOfq (ORCPT ); Tue, 6 Jul 2021 10:35:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625581702; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kAXRQIQOyrP0g5o0EvkttGD6vMDJoyXaK3EIFo8Ix/U=; b=fCbswAoMfb4Kq3dS4ADqYmwXF+YVxFa940/d+Q6EBttufzAW2xPgi5F+2EqVyljiT6O2/8 u2MPZMSi9Lkvu+S7tuECvXBpFBN1ZyoJQsbp7c921qGMEL1rIYQqOs9+tdVEIwbVqJ20zt pHJ5PVBHNPfBT7XfFu6XTjXGpLIDmi8= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-268-BMJLQjgHMza41XAdu_dHKw-1; Tue, 06 Jul 2021 10:12:13 -0400 X-MC-Unique: BMJLQjgHMza41XAdu_dHKw-1 Received: by mail-ej1-f71.google.com with SMTP id h14-20020a1709070b0eb02904d7c421e00bso2723008ejl.2 for ; Tue, 06 Jul 2021 07:12:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kAXRQIQOyrP0g5o0EvkttGD6vMDJoyXaK3EIFo8Ix/U=; b=E0kNKddKM+pby6IQqB2qDQnCCNW1KBai3lahrAie0C4a95T9F+2OS3aepmMjuok4fN 90zxjMxCjPEwXGTIWTZ27sacw3raO4Pd/MvYwxy6jix0hjTBno3SuX0h9tb/B5tC1opI 6rn7RUW5k0naxq41fWyP4LtUMVrhYAmtgu2N6TisVDWBEaNnQnSZL/aARrW+ilcgPOqY mhR46tGqx94TwX8h3JiIyaUZzi5liW3me++pP1zssO3LF8ex0PRdeLZ04JCfgzu6V0pi Tx9hnXAWLkv3ztZtsnylUuoqnVOLnciht/xd2gWLO+lcu0vq9Ra93Et8ZVkPmulLP19B ry0g== X-Gm-Message-State: AOAM530iRaCnLbr/Cc1auQeTtirq+lLx2DDSbHHo4kTvO4QdurUoupLa WqxMElaE5T45y53MB3nHc4BAHzOnVfhcoi7Fev4Wj3qUi0QQfHqnkCuTlqoF257hbAAt4knHoPn Uvgz+p9aUQYKN9PJMAILVa14p X-Received: by 2002:a17:907:1691:: with SMTP id hc17mr18418949ejc.382.1625580732544; Tue, 06 Jul 2021 07:12:12 -0700 (PDT) X-Received: by 2002:a17:907:1691:: with SMTP id hc17mr18418922ejc.382.1625580732303; Tue, 06 Jul 2021 07:12:12 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id f9sm5585747edw.88.2021.07.06.07.12.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Jul 2021 07:12:10 -0700 (PDT) Subject: Re: [RFC PATCH v2 34/69] KVM: x86: Add support for vCPU and device-scoped KVM_MEMORY_ENCRYPT_OP To: isaku.yamahata@intel.com, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , 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@gmail.com, Sean Christopherson References: <68b1d5fb6afc30e41e46be63ef67412ec3b08fab.1625186503.git.isaku.yamahata@intel.com> From: Paolo Bonzini Message-ID: Date: Tue, 6 Jul 2021 16:12:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <68b1d5fb6afc30e41e46be63ef67412ec3b08fab.1625186503.git.isaku.yamahata@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/07/21 00:04, isaku.yamahata@intel.com wrote: > 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; > } > Reviewed-by: Paolo Bonzini