From patchwork Fri Feb 5 00:57:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 12069077 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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham 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 ABF52C433DB for ; Fri, 5 Feb 2021 01:02:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8382364FAF for ; Fri, 5 Feb 2021 01:02:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232432AbhBEBCa (ORCPT ); Thu, 4 Feb 2021 20:02:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232363AbhBEA7h (ORCPT ); Thu, 4 Feb 2021 19:59:37 -0500 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46CB5C061225 for ; Thu, 4 Feb 2021 16:58:16 -0800 (PST) Received: by mail-yb1-xb4a.google.com with SMTP id b125so5139352ybg.10 for ; Thu, 04 Feb 2021 16:58:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=q+0liJU8GabPl3PYejQh9F1gWHvngMzF13S5XCf8sWU=; b=ak9k2tm3NeARyReFBJfp7ptQLkAVEnEQOS8Y1mhvL1hqpa5bbLgrUULs5DGex4m4dD ktNSQGASgy4DqP6+Lu5EUhUn8fYtzoNyqXs/N6Uubsl/2m3J7wVAemQU8KOp3XJHiwUm XKnh0H9dXpAu65qrGcEAOswbGoDTq0lHyoOr+Qp+/Lm2nt6ndTei4NDuooEsR32MIbUf YI3hScxOnslWCuUP3X4I/9dHfKIAOg2n+NLUIJdTlxbT537jmZMJjKaRbgho+CiY6i2s tB6tDIKiYnj2xSfGcUdEkEXk2MItY96AXgDCRnYEaBU68p/0a6Xgop2+//kpaTrF/mLu BRzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=q+0liJU8GabPl3PYejQh9F1gWHvngMzF13S5XCf8sWU=; b=OHVAjZl+wKmWHaRwZ/sWl+HeLeYMOnR4emmN/j6zgx6Pli8Il+fZOGZaH6xRXY8QZu Nas5TkmXc6iSRfo+YIJAGM75EV9eJnZJK3mK3a2HKsNkgH6gFy/BY0arXG/1bdSqqomf yNjK6JEYavvSOjlb68D+49o30a7pKT8Id9sz79O4bQ9IyOhPmBdDv18nQ6US9xfUY9J5 l472SqLY3ENj6Ujca/nnHL6XSFBvCPqA7BH6c221Un6P1S9Zf7nQOQgBYHgYq05L0JCy YxnnxmYJuW3ZGnS70/14TWYJpADML3RXXwUekQRoCZQAZD7hFltD9FiIt1om8cWo9MHc U6vg== X-Gm-Message-State: AOAM533ggmF9jk984fhdh+6ZJqZa2OopHyL1ZxcUg/zVNtCL+/PaRIx8 nhwFy6kYirwyHUf+tlAkEFEm704gt/Y= X-Google-Smtp-Source: ABdhPJwlqJaLwYUDq5qtdREqGOMWIu5lte952elgDFrAu7wbn41ukhS6gKTkxcmv/c4m8Hr0NC+w1vwSXFY= Sender: "seanjc via sendgmr" X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:f16f:a28e:552e:abea]) (user=seanjc job=sendgmr) by 2002:a25:da41:: with SMTP id n62mr2578073ybf.155.1612486695505; Thu, 04 Feb 2021 16:58:15 -0800 (PST) Reply-To: Sean Christopherson Date: Thu, 4 Feb 2021 16:57:49 -0800 In-Reply-To: <20210205005750.3841462-1-seanjc@google.com> Message-Id: <20210205005750.3841462-9-seanjc@google.com> Mime-Version: 1.0 References: <20210205005750.3841462-1-seanjc@google.com> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH 8/9] KVM: SVM: Don't manually emulate RDPMC if nrips=0 From: Sean Christopherson To: Paolo Bonzini , Jiri Kosina Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Remove bizarre code that causes KVM to run RDPMC through the emulator when nrips is disabled. Accelerated emulation of RDPMC doesn't rely on any additional data from the VMCB, and SVM has generic handling for updating RIP to skip instructions when nrips is disabled. Signed-off-by: Sean Christopherson --- arch/x86/kvm/svm/svm.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 74f37f282050..b6acc73d356a 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -2434,14 +2434,6 @@ static int rsm_interception(struct kvm_vcpu *vcpu) return kvm_emulate_instruction_from_buffer(vcpu, rsm_ins_bytes, 2); } -static int rdpmc_interception(struct kvm_vcpu *vcpu) -{ - if (!nrips) - return emulate_on_interception(vcpu); - - return kvm_emulate_rdpmc(vcpu); -} - static bool check_selective_cr0_intercepted(struct kvm_vcpu *vcpu, unsigned long val) { @@ -3068,7 +3060,7 @@ static int (*const svm_exit_handlers[])(struct kvm_vcpu *vcpu) = { [SVM_EXIT_SMI] = kvm_emulate_as_nop, [SVM_EXIT_INIT] = kvm_emulate_as_nop, [SVM_EXIT_VINTR] = interrupt_window_interception, - [SVM_EXIT_RDPMC] = rdpmc_interception, + [SVM_EXIT_RDPMC] = kvm_emulate_rdpmc, [SVM_EXIT_CPUID] = kvm_emulate_cpuid, [SVM_EXIT_IRET] = iret_interception, [SVM_EXIT_INVD] = kvm_emulate_invd,