Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp322267pxa; Thu, 27 Aug 2020 03:24:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvZVsqHfdbuPF6sAetsSNv9QqRRiURrxCpH2NXYbIo2/VQHNildXrdjORv5UxPQIqvrJbu X-Received: by 2002:a17:906:a293:: with SMTP id i19mr6562183ejz.523.1598523859281; Thu, 27 Aug 2020 03:24:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598523859; cv=none; d=google.com; s=arc-20160816; b=MZMarPOKVJzEMpQme6vcJA1CXDtQTyuJy468f9NIRWMP30fBncSUWc2XoMquYw1RDS nSAcf7ocfXDBmhxWinJrQTCSsaQJ7x6DqLi+z5fle5sWS8+RF7vagl2ScBUdSNPicNgk SrMm5uLp/PpaLz6BwKSWIdlkWMDOlyNGVOCfevEyPIr7r0ABaRIDp+an6d2yzY+bVYAG bF7Ols+7B/UhTfDTFRCRhW9asol6eLCocxkRzlA1HYqsmlSEcFBNrPkrX7mGB/WTHxK4 6Ikj18ANNyZ/t0XIMEJ3OlErmb1dytCZ7aLgYRb1B+RI36jTxVRnO8D0PFqazlr6a4/i R7VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=+kLy6tLm5kHK6ubmxV4JMC+Ts5+1/ugqr6zlczEOapo=; b=EeKA0HaHmcqWlLmACj9WZTjYYStReCVNeJm5Cq9rx6yMEfU7mjS8V/0XlrhNlWTvkl tlv3c2hkmwO++aTulNEG5sZzv3oePILYCkw96I85E3kNwJ01+n1nK0MpWd9M8mg25RXj OMT2u6KCAUHQA78rcfNbjrOxr6a/+tuHj2wGhq5xnHpn/GV0iKsgUDrMfIqMMwcomdzY fyf2vEaIqEsqoTsfDHbGNoU6GL+7pImTlSI6NxdC5yI7DE+iz6FVjzfUmbMprLC45R/3 pLDUQsYv6B+EgXicwLG9ANJvBZ1sILiwG7lGIf8yDsy2A/a1S5Y4AKilkVcH2uDFtXQG gCrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ddkHhs8U; 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 o93si683406eda.375.2020.08.27.03.23.56; Thu, 27 Aug 2020 03:24:19 -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=ddkHhs8U; 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 S1728623AbgH0KX0 (ORCPT + 99 others); Thu, 27 Aug 2020 06:23:26 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:43825 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726938AbgH0KXZ (ORCPT ); Thu, 27 Aug 2020 06:23:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598523803; 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=+kLy6tLm5kHK6ubmxV4JMC+Ts5+1/ugqr6zlczEOapo=; b=ddkHhs8USk7aO6x5hxM8tUkQiDO64nIFQZd9dcE9BsGs9rLnSJbCfrfaF1a0mBURxZScY0 6m2G0X5vxJuN1nx7W5afqS0v54Cf9ZGFrkbOQNUedGhsYVaRGKLoGxnOKwESoO/bXiraXS +pQZeDUv0ZS5/JY/SxqNLhgVA2VsCNc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-478-aVScZKfANIKVFLxVfpsGkQ-1; Thu, 27 Aug 2020 06:23:20 -0400 X-MC-Unique: aVScZKfANIKVFLxVfpsGkQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2D6AD800683; Thu, 27 Aug 2020 10:23:18 +0000 (UTC) Received: from starship (unknown [10.35.206.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92A581944D; Thu, 27 Aug 2020 10:23:13 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2 4/7] KVM: x86: allow kvm_x86_ops.set_efer to return a value From: Maxim Levitsky To: Sean Christopherson , Jim Mattson Cc: kvm list , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Ingo Molnar , Thomas Gleixner , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , Joerg Roedel , Wanpeng Li , Borislav Petkov , Vitaly Kuznetsov , Paolo Bonzini Date: Thu, 27 Aug 2020 13:23:12 +0300 In-Reply-To: <20200821004350.GB13886@sjchrist-ice> References: <20200820133339.372823-1-mlevitsk@redhat.com> <20200820133339.372823-5-mlevitsk@redhat.com> <20200821004350.GB13886@sjchrist-ice> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.3 (3.36.3-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-08-20 at 17:43 -0700, Sean Christopherson wrote: > On Thu, Aug 20, 2020 at 02:43:56PM -0700, Jim Mattson wrote: > > On Thu, Aug 20, 2020 at 6:34 AM Maxim Levitsky wrote: > > > This will be used later to return an error when setting this msr fails. > > > > > > For VMX, it already has an error condition when EFER is > > > not in the shared MSR list, so return an error in this case. > > > > > > Signed-off-by: Maxim Levitsky > > > --- > > > --- a/arch/x86/kvm/x86.c > > > +++ b/arch/x86/kvm/x86.c > > > @@ -1471,7 +1471,8 @@ static int set_efer(struct kvm_vcpu *vcpu, struct msr_data *msr_info) > > > efer &= ~EFER_LMA; > > > efer |= vcpu->arch.efer & EFER_LMA; > > > > > > - kvm_x86_ops.set_efer(vcpu, efer); > > > + if (kvm_x86_ops.set_efer(vcpu, efer)) > > > + return 1; > > > > This seems like a userspace ABI change to me. Previously, it looks > > like userspace could always use KVM_SET_MSRS to set MSR_EFER to 0 or > > EFER_SCE, and it would always succeed. Now, it looks like it will fail > > on CPUs that don't support EFER in hardware. (Perhaps it should fail, > > but it didn't before, AFAICT.) > > KVM emulates SYSCALL, presumably that also works when EFER doesn't exist in > hardware. This is a fair point. How about checking the return value only when '!msr_info->host_initiated' in set_efer? This way userspace initiated EFER write will work as it did before, but guest initiated write will fail (and set_efer already checks and fails for many cases) I also digged a bit around the failure check in VMX, the 'find_msr_entry(vmx, MSR_EFER);' This one if I am not mistaken will only fail when host doesn't support EFER. I don't mind ignoring this error as well as it was before. > > The above also adds weirdness to nested VMX as vmx_set_efer() simply can't > fail. It will now fail on non 64 bit Intel CPUs that support VMX. I do think that we had these for a while. As I said I'll return 0 when find_msr_entry fails, thus return this behavior as it was on Intel. Best regards, Maxim Levitsky