Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1589672ybn; Wed, 25 Sep 2019 22:02:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxA+pI5akPoMlOoG3zQ9SNJ8ZRd99WggzErr6D4cz4nuvRC/U6BafvIqmWRj30Qa3WUObD/ X-Received: by 2002:a17:906:f19a:: with SMTP id gs26mr1480685ejb.298.1569474151448; Wed, 25 Sep 2019 22:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569474151; cv=none; d=google.com; s=arc-20160816; b=bGE1OijW/omSYNpVhN+0cWq4LAgijztF59SBpBlC34OtLArxuVJdmP2fQb0CzfUul5 p22CkhNjO4dow2yF/wn35tBwthUiGbmdGFOt5nat5bR6ADnbWM4ye0/JVR5CHTrhJR5j HaGAXa8pHQCshNX2Ol9D2sPFtw0H2oqRXC2suu+sMaeLFDPQQXSd0aIjZCaxgvtoPO0D jK18qp4n//QQHr1EDWS/LEAnS88gpAhUdw/L7z4vNgVcRaOLJN/v0A/sCrPazE0AUMGn 2myaAx0cl928y87dkn+lq099dSii00dAR3hl/0i03Rm7pRwvahi2wNbnDjvbp+Z8mOwV 8CSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=9vL37zIFmffgVeH7v1mcWfprqBw3NJL51ULUW2psWJk=; b=PRBqYnw1YzFi8hW3ojgWs+EghoVOxKds9pc8ZkpTVgXo4WgWnS5SdgwXvSwFpTaR4z BFi9q2DlzuMhc11ThqNaoMUwVxHpGfw/oC+dFbl4QCGtdsOR/dsgVF2Efa0Xvjry76sP 1SBjKPaDuL/wFRnLYEOswKNfEGlJT0V74j5PV64KwuzIP0B49QUv5XoPOdeI3X3m96R/ BHQ+9ooCwcRF0ry/MwcvjsIwXZETY/EDnEU9w6RqFUEhtyY0BIA+HyEuU6F71XTKP6sl u+ft05ZI10oJRXyrXKo95NhprTfrlP/QVK8F1mjciYcnOP+7Ce78+IpucejszbMuN0Jk fb7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5si450474eje.339.2019.09.25.22.02.07; Wed, 25 Sep 2019 22:02:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388650AbfIWVIm (ORCPT + 99 others); Mon, 23 Sep 2019 17:08:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40104 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388040AbfIWVIl (ORCPT ); Mon, 23 Sep 2019 17:08:41 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 67CF530833A8; Mon, 23 Sep 2019 21:08:41 +0000 (UTC) Received: from mail (ovpn-120-159.rdu2.redhat.com [10.10.120.159]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A1FA65D71C; Mon, 23 Sep 2019 21:08:38 +0000 (UTC) Date: Mon, 23 Sep 2019 17:08:38 -0400 From: Andrea Arcangeli To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , "Dr. David Alan Gilbert" , Marcelo Tosatti , Peter Xu , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 15/17] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers Message-ID: <20190923210838.GA23063@redhat.com> References: <20190920212509.2578-1-aarcange@redhat.com> <20190920212509.2578-16-aarcange@redhat.com> <87o8zb8ik1.fsf@vitty.brq.redhat.com> <7329012d-0b3b-ce86-f58d-3d2d5dc5a790@redhat.com> <20190923190514.GB19996@redhat.com> <20190923202349.GL18195@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190923202349.GL18195@linux.intel.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 23 Sep 2019 21:08:41 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Mon, Sep 23, 2019 at 01:23:49PM -0700, Sean Christopherson wrote: > The attached patch should do the trick. The two most attractive options to me remains what I already have implemented under #ifdef CONFIG_RETPOLINE with direct calls (optionally replacing the "if" with a small "switch" still under CONFIG_RETPOLINE if we give up the prioritization of the checks), or the replacement of kvm_vmx_exit_handlers with a switch() as suggested by Vitaly which would cleanup some code. The intermediate solution that makes "const" work, has the cons of forcing to parse EXIT_REASON_VMCLEAR and the other vmx exit reasons twice, first through a pointer to function (or another if or switch statement) then with a second switch() statement. If we'd use a single switch statement per Vitaly's suggestion, the "if nested" would better be more simply implemented as: switch (exit_reason) { case EXIT_REASON_VMCLEAR: if (nested) return handle_vmclear(vcpu); else return handle_vmx_instruction(vcpu); case EXIT_REASON_VMCLEAR: if (nested) [..] This also removes the compiler dependency to auto inline handle_vmclear in the added nested_vmx_handle_vmx_instruction extern call. VMREAD/WRITE/RESUME are the most frequent vmexit in l0 while nested runs in l2. Thanks, Andrea