Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751462AbdINOKB (ORCPT ); Thu, 14 Sep 2017 10:10:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:39239 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751255AbdINOJ7 (ORCPT ); Thu, 14 Sep 2017 10:09:59 -0400 Date: Thu, 14 Sep 2017 16:09:50 +0200 From: Borislav Petkov To: Brijesh Singh Cc: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, Thomas Gleixner , Joerg Roedel , "Michael S . Tsirkin" , Paolo Bonzini , =?utf-8?B?XCJSYWRpbSBLcsSNbcOhxZlcIg==?= , Tom Lendacky Subject: Re: [RFC Part2 PATCH v3 23/26] KVM: X86: Add memory encryption enabled ops Message-ID: <20170914140950.r6aodxkypgpwbxzt@pd.tnic> References: <20170724200303.12197-1-brijesh.singh@amd.com> <20170724200303.12197-24-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170724200303.12197-24-brijesh.singh@amd.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1985 Lines: 62 On Mon, Jul 24, 2017 at 03:03:00PM -0500, Brijesh Singh wrote: > Extend kvm_x86_ops to add memory_encyption_enabled() ops. > It returns a > boolean indicating whether memory encryption is enabled on the VCPU. You don't need that sentence. > > Signed-off-by: Brijesh Singh > --- > arch/x86/include/asm/kvm_host.h | 1 + > arch/x86/kvm/svm.c | 8 ++++++++ > 2 files changed, 9 insertions(+) > > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index a91aadf..a14d4dd 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -1073,6 +1073,7 @@ struct kvm_x86_ops { > struct kvm_memory_encrypt_ram *ram); > int (*memory_encryption_unregister_ram)(struct kvm *kvm, > struct kvm_memory_encrypt_ram *ram); > + bool (*memory_encryption_enabled)(struct kvm_vcpu *vcpu); > }; > > struct kvm_arch_async_pf { > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index cdb1cf3..0bbd050 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -6548,6 +6548,12 @@ static int mem_encrypt_unregister_ram(struct kvm *kvm, > return 0; > } > > +static bool mem_encrypt_enabled(struct kvm_vcpu *vcpu) > +{ > + return !!(to_svm(vcpu)->vmcb->control.nested_ctl & > + SVM_NESTED_CTL_SEV_ENABLE); You don't need the !! > +} > + > static struct kvm_x86_ops svm_x86_ops __ro_after_init = { > .cpu_has_kvm_support = has_svm, > .disabled_by_bios = is_disabled, > @@ -6664,6 +6670,8 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = { > .memory_encryption_op = svm_memory_encryption_op, > .memory_encryption_register_ram = mem_encrypt_register_ram, > .memory_encryption_unregister_ram = mem_encrypt_unregister_ram, > + .memory_encryption_enabled = mem_encrypt_enabled, > + mem_enc_enabled looks better to me. -- Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) --