Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5724437ybp; Tue, 15 Oct 2019 04:12:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/m6cuMIVvAaMYrTuXdBw1QEO9S5LXeSrFWiMqYbrLnhJ9N1WEhH/7nZtrDhclW6WJ1ZHN X-Received: by 2002:aa7:cb5a:: with SMTP id w26mr33538157edt.188.1571137948941; Tue, 15 Oct 2019 04:12:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571137948; cv=none; d=google.com; s=arc-20160816; b=isSIvdC4uxItNPNLQ4QMgaFQyIpKsu5s+UKqNu4m84upO1xoyK9f2TtSJCVK5dG9KP 2EVSW6/NFuov49oqlJ+rcuVvf+nD00dFU+mfYhk5IDu9clG8mRPsB6MGuU06EKlZYmjK lqk1lT0gGBuhOrOcZktUzTwWr+2/nIai7NIgA7TgOBS6xYZPpLyc4xHhPiW+1JBRpMdB YETFmo6u1/n3BCBoxhGED2ZnNsarPKO69KXPRJZ2HA/W/jUkxAS2POAaHvt5/ezfJmSg 0QymZ12CvRnV5EAD+1hK+6cpFtfpAhnxJc83iixGCeY7ef8Zaa6zTS1mzCoIzzg1N/So 1G3w== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:openpgp:from:references:cc:to:subject; bh=Pb5c9lwLTcI2EdDTvk1a+i+Hv8sTLnOmEVzrLcGSMOs=; b=cytrxvaPMx3zyKi0Bp7WRYnB8tPkO+jroEhFmaBJDy/XPJ0xahRG03Sk7mJuDdq9jB B2WFsjlNynGWk03luixQV0BKy+/LcSvGToCDftkq9W8WAh2a+HtAajt0xCmGyvEiQxPd 17nsom7EH2xtFpT1LVSfzLbcTZY8fpDFDJPLWOg350yNGm0jI1gLVtLuj5mheNjimbw0 5sJHkhJJQCnDiZDojmcyrnaR6b+X+bAu709ke6Jpz6uMKE2J8q7IBPgYg6tOeeid5WtB tdgQ3yXKf8PQ7H8oYwvhgVz6E+hqif2ZIFIN1j2y0H1xLVkgeRbFOZEvo0VoTwiKMqc8 pFCw== 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 p15si12618289ejx.56.2019.10.15.04.12.05; Tue, 15 Oct 2019 04:12:28 -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 S1728863AbfJOI2m (ORCPT + 99 others); Tue, 15 Oct 2019 04:28:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52068 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728847AbfJOI2l (ORCPT ); Tue, 15 Oct 2019 04:28:41 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3328E4E4E6 for ; Tue, 15 Oct 2019 08:28:41 +0000 (UTC) Received: by mail-wm1-f70.google.com with SMTP id s19so5162587wmj.0 for ; Tue, 15 Oct 2019 01:28:41 -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:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Pb5c9lwLTcI2EdDTvk1a+i+Hv8sTLnOmEVzrLcGSMOs=; b=NdAmS8Vb6C9+I7NBqfEB/twXDTN0Ye/voTRRFXMyBOkeBHLB20WvyLHn00L7dyMqF0 /ZqjMhfWL5fM1djqffyCfa9akWn8KhYSj54rsPLkNAHlKwcY6L7mE1poOalLxx+y1QV8 HCD2EBf699k8RhH65bx+R+388jgqWFBIORluD6lnwRBQIRAnYLKktUzgKkEZ2hoIRbMr GdtP0udoe0y+5AeaOiB/ijNO5a4KSL3rzDdQKrOsOpx8CbzSJguJSfHf6KhhmvPdwr3m VQ6+ob37TA/mHttejvFeKKbA6qGS7HBjscauupaYo43yiiZC9zBibianO8DK4LhySzMG KXMQ== X-Gm-Message-State: APjAAAW6LyOS9HR8Tnedvh/Ch0XdB6w09+8NJpjoMokUN0vbf2LzGyd+ pt2Xzn5mxDI/AyV8XkQ1WzoMfjI+dSRyvnf+KCqZxQim8VcJxrPtKd9k/SUrOoIeOIcT40I6sCy NaK+qHHrHIUucjU37PVwZVxGc X-Received: by 2002:adf:f64f:: with SMTP id x15mr8751668wrp.381.1571128119764; Tue, 15 Oct 2019 01:28:39 -0700 (PDT) X-Received: by 2002:adf:f64f:: with SMTP id x15mr8751651wrp.381.1571128119461; Tue, 15 Oct 2019 01:28:39 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:d001:591b:c73b:6c41? ([2001:b07:6468:f312:d001:591b:c73b:6c41]) by smtp.gmail.com with ESMTPSA id o22sm49779359wra.96.2019.10.15.01.28.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Oct 2019 01:28:38 -0700 (PDT) Subject: Re: [PATCH 12/14] KVM: retpolines: x86: eliminate retpoline from vmx.c exit handlers To: Andrea Arcangeli , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vitaly Kuznetsov , Sean Christopherson References: <20190928172323.14663-1-aarcange@redhat.com> <20190928172323.14663-13-aarcange@redhat.com> From: Paolo Bonzini Openpgp: preference=signencrypt Message-ID: <933ca564-973d-645e-fe9c-9afb64edba5b@redhat.com> Date: Tue, 15 Oct 2019 10:28:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190928172323.14663-13-aarcange@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 28/09/19 19:23, Andrea Arcangeli wrote: > Reducing this list to only EXIT_REASON_MSR_WRITE, > EXIT_REASON_PREEMPTION_TIMER, EXIT_REASON_EPT_MISCONFIG, > EXIT_REASON_IO_INSTRUCTION increases the computation time of the > hrtimer guest testcase on Haswell i5-4670T CPU @ 2.30GHz by 7% with > the default spectre v2 mitigation enabled in the host and guest. On > skylake as opposed there's no measurable difference with the short > list. To put things in prospective on Haswell the same hrtimer > workload (note: it never calls cpuid and it never attempts to trigger > more vmexit on purpose) in guest takes 16.3% longer to compute on > upstream KVM running in the host than with the KVM mono v1 patchset > applied to the host kernel, while on skylake the same takes only 5.4% > more time (both with the default mitigations enabled in guest and > host). > > It's also unclear why EXIT_REASON_IO_INSTRUCTION should be included. If you're including EXIT_REASON_EPT_MISCONFIG (MMIO access) then you should include EXIT_REASON_IO_INSTRUCTION too. Depending on the devices that are in the guest, the doorbell register might be MMIO or PIO. > + if (exit_reason == EXIT_REASON_MSR_WRITE) > + return kvm_emulate_wrmsr(vcpu); > + else if (exit_reason == EXIT_REASON_PREEMPTION_TIMER) > + return handle_preemption_timer(vcpu); > + else if (exit_reason == EXIT_REASON_PENDING_INTERRUPT) > + return handle_interrupt_window(vcpu); > + else if (exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT) > + return handle_external_interrupt(vcpu); > + else if (exit_reason == EXIT_REASON_HLT) > + return kvm_emulate_halt(vcpu); > + else if (exit_reason == EXIT_REASON_PAUSE_INSTRUCTION) > + return handle_pause(vcpu); > + else if (exit_reason == EXIT_REASON_MSR_READ) > + return kvm_emulate_rdmsr(vcpu); > + else if (exit_reason == EXIT_REASON_CPUID) > + return kvm_emulate_cpuid(vcpu); > + else if (exit_reason == EXIT_REASON_EPT_MISCONFIG) > + return handle_ept_misconfig(vcpu); So, the difference between my suggested list (which I admit is just based on conjecture, not benchmarking) is that you add EXIT_REASON_PAUSE_INSTRUCTION, EXIT_REASON_PENDING_INTERRUPT, EXIT_REASON_EXTERNAL_INTERRUPT, EXIT_REASON_HLT, EXIT_REASON_MSR_READ, EXIT_REASON_CPUID. Which of these make a difference for the hrtimer testcase? It's of course totally fine to use benchmarks to prove that my intuition was bad---but you must also use them to show why your intuition is right. :) Paolo