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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 B2865C433DF for ; Mon, 1 Jun 2020 18:54:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8760520679 for ; Mon, 1 Jun 2020 18:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591037652; bh=xDqOcDPxgEtN8yP3ZDnF8X43wyViTPb3+SglNOHmTUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=AxxXSlPTgo/1CMVclcZyTJKiHFj3SIElshZ4g29wqcL5//AXRbUOxewKO4wMeXfaC GrQNLApVKjjM2QZ42l2fNWmZ664f/hTB1Uh0D8EV3wC2h9q/jKTLV/wb7a6otQTBDt l2hEaSjz54SQPKgiWQLYFhySfvFkH5jLa6eViizk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730248AbgFASyM (ORCPT ); Mon, 1 Jun 2020 14:54:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:45366 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729907AbgFASCP (ORCPT ); Mon, 1 Jun 2020 14:02:15 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 647D9207D0; Mon, 1 Jun 2020 18:02:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591034534; bh=xDqOcDPxgEtN8yP3ZDnF8X43wyViTPb3+SglNOHmTUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RYg0eVU8MPi04EsobwPQyhTQduT5K4TXAYvoq+xroqWsOBiWgLT58Ego5H0u1S+7U trm7jmk7XaYoXKW/3H01cYpeJS7z28vh6uFkYiE6x1aoVBIqMePV9x6Vi7k3anTHnH 9mWyNLjk055oAqqSrNVUU3YBfKz7IFnjlcLXLgP4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gerhard Wiesinger , Jim Mattson , Sean Christopherson , Paolo Bonzini , Guenter Roeck Subject: [PATCH 4.14 75/77] KVM: VMX: check for existence of secondary exec controls before accessing Date: Mon, 1 Jun 2020 19:54:20 +0200 Message-Id: <20200601174029.419790717@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601174016.396817032@linuxfoundation.org> References: <20200601174016.396817032@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson commit fd6b6d9b82f97a851fb0078201ddc38fe9728cda upstream. Return early from vmx_set_virtual_apic_mode() if the processor doesn't support VIRTUALIZE_APIC_ACCESSES or VIRTUALIZE_X2APIC_MODE, both of which reside in SECONDARY_VM_EXEC_CONTROL. This eliminates warnings due to VMWRITEs to SECONDARY_VM_EXEC_CONTROL (VMCS field 401e) failing on processors without secondary exec controls. Remove the similar check for TPR shadowing as it is incorporated in the flexpriority_enabled check and the APIC-related code in vmx_update_msr_bitmap() is further gated by VIRTUALIZE_X2APIC_MODE. Reported-by: Gerhard Wiesinger Fixes: 8d860bbeedef ("kvm: vmx: Basic APIC virtualization controls have three settings") Cc: Jim Mattson Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Signed-off-by: Paolo Bonzini Cc: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -9280,15 +9280,16 @@ static void vmx_set_virtual_apic_mode(st if (!lapic_in_kernel(vcpu)) return; + if (!flexpriority_enabled && + !cpu_has_vmx_virtualize_x2apic_mode()) + return; + /* Postpone execution until vmcs01 is the current VMCS. */ if (is_guest_mode(vcpu)) { to_vmx(vcpu)->nested.change_vmcs01_virtual_apic_mode = true; return; } - if (!cpu_need_tpr_shadow(vcpu)) - return; - sec_exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL); sec_exec_control &= ~(SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES | SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE);