Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2862808pxv; Mon, 12 Jul 2021 03:52:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4QUjI6PEMvjkB5py0N/HjGIUElRdp8dlLFL7Rc2ibFz3VMeYuzk4rYNvKaAyjZrkSyozo X-Received: by 2002:a05:6e02:218c:: with SMTP id j12mr5928887ila.32.1626087160261; Mon, 12 Jul 2021 03:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626087160; cv=none; d=google.com; s=arc-20160816; b=XXS00ZnQP1LQ0pK2oaXlZO7AyrHokzBwwrdfCUIvPzhsejRwgyEhHVCEz1AOkiNfKM M2+NgOx2elVNT2hcqVa6aIe4fKR7xMDmU1NOmPNPNYxnJGAIjpcU5KeL/Dyolwgu1Wlx Ck3bvY6PLp2aN6AF994nDqn4Nd4SVlkaChZf1DhZDtx4UJOQkjhMloOFuqpg5QhCF0JO ACiXQsQq+30NxyT1R//BFtPLSxDoWmeVEmtQ2cA6mmo7jc3XZpd1cydzG7qACD8VrVXN cApZvdlv9EvTuAtPPWneps6Hl7afxxxplOB86H2kZ6UExGg1Z+6pWQuR/y9yai1vY4s+ GRNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0A/ksWzUXxG4qJ8AifmEWiH6m++cNhztrSrdGrrSVsA=; b=VKxgMWXaIOWZSnPN0b7nbJWep7vuxcvM3zBLagjxwBdTzkAaGZRvyykQ4U2UFIP9VH W1RRWjIuL8As1iAIdi9buJxmlTLcy70nVuzF7SO1kQWgKrZgBguoDsoq1jQCess9C2y4 ZQiJcvuxpKWlXtP1lThtdzuNrK3zK9fkvePsnj6qDUcDT5VjWFdYg6gBzlijLs6c8V8f znrPCbHOFOcYb0dRIm7m3tf5tcNTUkkNhDnBkUONtf0mIsh1rY0u0BgCRYmVbfeptX0z XXOSBwImrTwVXZ46NHnZizMNQRGIAu4S3aSTq+r+LMwuVsiEl/3Vpx5Hh2txYqFe7gdl DZEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BzxrUO5G; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si18425511jad.12.2021.07.12.03.52.25; Mon, 12 Jul 2021 03:52:40 -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=@linuxfoundation.org header.s=korg header.b=BzxrUO5G; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357203AbhGLIRG (ORCPT + 99 others); Mon, 12 Jul 2021 04:17:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:55094 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243294AbhGLHdI (ORCPT ); Mon, 12 Jul 2021 03:33:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E165E6128E; Mon, 12 Jul 2021 07:30:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626075019; bh=AxcmgYa9PuUqlaY7RkQckBsHZSN9iuSIopyYGxQKJgw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BzxrUO5GZRfI6AaXjRITzVM3W+uGe3DQo7bVaM3kG7CfjYxZ7v8Y7xxV0QPayWsoY H/lWF4d+M2eS2qJarJn7At2OyFvmXrb5h3h0XJk4SYAf+o/MFNw286d60hZOFGGy4Z 0MSym9CtIheOvD3JRLneNQXnGqEz5WRxMkUB00iA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaoyao Li , Sean Christopherson , Paolo Bonzini Subject: [PATCH 5.13 074/800] KVM: nVMX: Handle split-lock #AC exceptions that happen in L2 Date: Mon, 12 Jul 2021 08:01:37 +0200 Message-Id: <20210712060923.573448085@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060912.995381202@linuxfoundation.org> References: <20210712060912.995381202@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson commit b33bb78a1fada6445c265c585ee0dd0fc6279102 upstream. Mark #ACs that won't be reinjected to the guest as wanted by L0 so that KVM handles split-lock #AC from L2 instead of forwarding the exception to L1. Split-lock #AC isn't yet virtualized, i.e. L1 will treat it like a regular #AC and do the wrong thing, e.g. reinject it into L2. Fixes: e6f8b6c12f03 ("KVM: VMX: Extend VMXs #AC interceptor to handle split lock #AC in guest") Cc: Xiaoyao Li Signed-off-by: Sean Christopherson Message-Id: <20210622172244.3561540-1-seanjc@google.com> Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/vmx/nested.c | 3 +++ arch/x86/kvm/vmx/vmcs.h | 5 +++++ arch/x86/kvm/vmx/vmx.c | 4 ++-- arch/x86/kvm/vmx/vmx.h | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -5806,6 +5806,9 @@ static bool nested_vmx_l0_wants_exit(str else if (is_breakpoint(intr_info) && vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) return true; + else if (is_alignment_check(intr_info) && + !vmx_guest_inject_ac(vcpu)) + return true; return false; case EXIT_REASON_EXTERNAL_INTERRUPT: return true; --- a/arch/x86/kvm/vmx/vmcs.h +++ b/arch/x86/kvm/vmx/vmcs.h @@ -117,6 +117,11 @@ static inline bool is_gp_fault(u32 intr_ return is_exception_n(intr_info, GP_VECTOR); } +static inline bool is_alignment_check(u32 intr_info) +{ + return is_exception_n(intr_info, AC_VECTOR); +} + static inline bool is_machine_check(u32 intr_info) { return is_exception_n(intr_info, MC_VECTOR); --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -4829,7 +4829,7 @@ static int handle_machine_check(struct k * - Guest has #AC detection enabled in CR0 * - Guest EFLAGS has AC bit set */ -static inline bool guest_inject_ac(struct kvm_vcpu *vcpu) +bool vmx_guest_inject_ac(struct kvm_vcpu *vcpu) { if (!boot_cpu_has(X86_FEATURE_SPLIT_LOCK_DETECT)) return true; @@ -4937,7 +4937,7 @@ static int handle_exception_nmi(struct k kvm_run->debug.arch.exception = ex_no; break; case AC_VECTOR: - if (guest_inject_ac(vcpu)) { + if (vmx_guest_inject_ac(vcpu)) { kvm_queue_exception_e(vcpu, AC_VECTOR, error_code); return 1; } --- a/arch/x86/kvm/vmx/vmx.h +++ b/arch/x86/kvm/vmx/vmx.h @@ -387,6 +387,7 @@ void vmx_get_segment(struct kvm_vcpu *vc void vmx_set_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg); u64 construct_eptp(struct kvm_vcpu *vcpu, hpa_t root_hpa, int root_level); +bool vmx_guest_inject_ac(struct kvm_vcpu *vcpu); void vmx_update_exception_bitmap(struct kvm_vcpu *vcpu); void vmx_update_msr_bitmap(struct kvm_vcpu *vcpu); bool vmx_nmi_blocked(struct kvm_vcpu *vcpu);