Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2832955pxv; Mon, 12 Jul 2021 03:04:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXeJ4j8H+7QJTejVAI0zMtGXXZi/gq+LrifwVej5DgNYDZc0c/KJHRrPVV3Mq30P5hyeNO X-Received: by 2002:a05:6602:2bdc:: with SMTP id s28mr24227134iov.70.1626084272430; Mon, 12 Jul 2021 03:04:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084272; cv=none; d=google.com; s=arc-20160816; b=wUYuYrLdJ+x4y2XX+UgKpS4Mg2qQ1tGHyTgZQg8sz4fyZrgufjTYFcjJVN2cb5UqQP 3plbZSUxTV4e4mv+KPQdfn1QyFmzPlv3EAwaSXrn2vxDqPgwCL9ACegtRR0SeSiBEThA OH2AqR5edmYY/xOgwbCE9YUWwbqbHXAF4Neu4zL5BwMVKcQElku8tHWByhlpIzhp6AIG cVBpZGzvxzJOoqGmVKHgijCGbC+clpQ6tvkKlOkjASnLPTaelVs+0NRbAJUvtRHamfHR H7z2BNeTnfVhpbmkvhBzNLvuNVmjhmpibMgcLLtmxNZf1gccmzAPp+ay6IoEPPYfb5hL uZpg== 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=PiOiKJuilMclV29OosajvtNQPIc4shNuj25KM5HHpW8=; b=nHDiUjXaIsDP7bbBfFHg2uf8zJQibMoa3NKtfB9xq60xpiKLMV2QzzxtvMtxkhjiPY pyjSWRBfIVmdUldb4JzwTBR08+jAkeAruCOt5AIc7LmNarM7H28NUh5cAPJxqGc1tLhd B0zAnGcXWTKEQnxzqbGdeGWQzGogNLeY1RoYKftpc5+KsVFlTH1t/3pQcbByJObLzPcB ZAxUKOv+KN9demyAzubMcVVNzK8rfCz2YUBVdEVeMoNlBMsOS48/qotKi30RRhwtw4S6 jczNgTpqHVa0DdPDSLXGhTdWMcZ4rL0ihTvB9qDwPNcd+vGQgNhfYQucGLKomWthNsn+ vvOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H7JQQylJ; 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 f16si16272636iol.39.2021.07.12.03.04.20; Mon, 12 Jul 2021 03:04:32 -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=H7JQQylJ; 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 S1345252AbhGLHZM (ORCPT + 99 others); Mon, 12 Jul 2021 03:25:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:33000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239767AbhGLG63 (ORCPT ); Mon, 12 Jul 2021 02:58:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 85A6E61132; Mon, 12 Jul 2021 06:55:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626072939; bh=y7DZnX6J1qczp9U51K6H7G4dTyrIFHBrcBZ229g6Ct0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H7JQQylJhLDRUP3WYKlqWqI8Bh/FI5+9NxUfg/p1VPmJR9DQoSGEfrRbng6/217gF w+iHOcR7AtsDYSdxB1q8v84ktGHrZvLeKXNKLreNyRLaHUltoM/NVu3G4l+PtIDU2g Md8nPJ1y/3tvi9B5cHrqQpKa8jLy6v8vLvzdRyH4= 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.12 070/700] KVM: nVMX: Handle split-lock #AC exceptions that happen in L2 Date: Mon, 12 Jul 2021 08:02:33 +0200 Message-Id: <20210712060934.617562085@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@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 @@ -5775,6 +5775,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 @@ -4796,7 +4796,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; @@ -4905,7 +4905,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 @@ -379,6 +379,7 @@ void vmx_set_segment(struct kvm_vcpu *vc u64 construct_eptp(struct kvm_vcpu *vcpu, unsigned long 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);