From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98EB6C43463 for ; Sun, 20 Sep 2020 16:16:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6389C20EDD for ; Sun, 20 Sep 2020 16:16:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726390AbgITQQE (ORCPT ); Sun, 20 Sep 2020 12:16:04 -0400 Received: from mga02.intel.com ([134.134.136.20]:34883 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726311AbgITQQD (ORCPT ); Sun, 20 Sep 2020 12:16:03 -0400 IronPort-SDR: Z/btV2oIZEGEE4OQBmo0xIMclj5hatdZqETj6rkChzv1weMYldD50leviV/xs7ANQWDPZohkAK vcowZdJMwHcQ== X-IronPort-AV: E=McAfee;i="6000,8403,9750"; a="147907847" X-IronPort-AV: E=Sophos;i="5.77,283,1596524400"; d="scan'208";a="147907847" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2020 09:16:03 -0700 IronPort-SDR: 2OiPkCNNx5PxzODqcuEyjmlGwl+i9mA/YoOKObe+NWpf6W3Imv6Rv9aqis8zuAINJgB2P3Fa99 forf2oD8sLNA== X-IronPort-AV: E=Sophos;i="5.77,283,1596524400"; d="scan'208";a="453615387" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.160]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Sep 2020 09:16:03 -0700 Date: Sun, 20 Sep 2020 09:16:02 -0700 From: Sean Christopherson To: Paolo Bonzini Cc: Maxim Levitsky , kvm@vger.kernel.org, Vitaly Kuznetsov , Ingo Molnar , Wanpeng Li , "H. Peter Anvin" , Borislav Petkov , Jim Mattson , Joerg Roedel , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , linux-kernel@vger.kernel.org, Thomas Gleixner Subject: Re: [PATCH v4 2/2] KVM: nSVM: implement ondemand allocation of the nested state Message-ID: <20200920161602.GA17325@linux.intel.com> References: <20200917101048.739691-1-mlevitsk@redhat.com> <20200917101048.739691-3-mlevitsk@redhat.com> <20200917162942.GE13522@sjchrist-ice> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Sep 19, 2020 at 05:09:09PM +0200, Paolo Bonzini wrote: > On 17/09/20 18:29, Sean Christopherson wrote: > >> + vcpu->arch.efer = old_efer; > >> + kvm_make_request(KVM_REQ_OUT_OF_MEMORY, vcpu); > > I really dislike KVM_REQ_OUT_OF_MEMORY. It's redundant with -ENOMEM and > > creates a huge discrepancy with respect to existing code, e.g. nVMX returns > > -ENOMEM in a similar situation. > > Maxim, your previous version was adding some error handling to > kvm_x86_ops.set_efer. I don't remember what was the issue; did you have > any problems propagating all the errors up to KVM_SET_SREGS (easy), > kvm_set_msr (harder) etc.? I objected to letting .set_efer() return a fault. A relatively minor issue is the code in vmx_set_efer() that handles lack of EFER because technically KVM can emulate EFER.SCE+SYSCALL without supporting EFER in hardware. Returning success/'0' would avoid that particular issue. My primary concern is that I'd prefer not to add another case where KVM can potentially ignore a fault indicated by a helper, a la vmx_set_cr4(). To that end, I'd be ok with adding error handling to .set_efer() if KVM enforces, via WARN in one of the .set_efer() call sites, that SVM/VMX can only return negative error codes, i.e. let SVM handle the -ENOMEM case but disallow fault injection. It doesn't actually change anything, but it'd give me a warm fuzzy feeling.