Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp2788824ybg; Mon, 28 Oct 2019 02:23:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfRq6+cmMIGbmEFm2hdKxK0jVL9HwP97oA/jRv3TGHzv2/86CUM9Q3CXPMhEQEy4MFoqKv X-Received: by 2002:a50:eacc:: with SMTP id u12mr18486653edp.290.1572254599649; Mon, 28 Oct 2019 02:23:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572254599; cv=none; d=google.com; s=arc-20160816; b=ivYiTfYWCmqNHdMXaAR5NmyP8zf+91GvLZrXNeFNxf45cHaapGrH1avE/1MW7kQs95 S0BYPRNwB3cQ6qFoFduyd25D5SVjhGSFFvzduOrQ4XaJzz+WmFBHLJCsNpmH1zCKiJMP m+uodL/p3gFCt1RexVSgNAMLg5kIob7nfiyS9/bFfrCHCEVCDSSq4D+esgwEgWgNu5bV liQO84Nn1vak9t8uNu9dsFwyqCHfSdURXrPBvFn+NmQm8pB3IzvJygbCmIlPDcnk8caN kea1bbwMaFaRb/S6b2PDcic09WtKVT1Xw58sUyEFF2AWi4MlP0OJ0Emv5PM5eiWOHTvE l1aQ== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TCuNs7tzdxQ+QZITLHxkUCZPAEUXUv3k85ZV8o686ZQ=; b=Tb/HzH/sNVNHjciVd1hYSQ3/zen4AnH+qZh6XmQuzOpQIEUnoLxBy86rf19gjU4UqH L6ATeLImQ9ZMHCuQL8o4Ri8WbqHNdw+kvUsilJbXl7bSUcOD2jRGyH30n2ILOCi9GERO IcA4fQpQWVBrdHIT9oXzfp5o0GQm29WA5ZhlsaXiLcfILMxowxHNsr9IGOhnfgHDmd2S Z/KsRYG7XPTguQvHTi28E+6vFyQbcXCaDOtLR2XR3wybyJ4v5lZ1U/sXFnLvb/BEFy++ 6O+H8WkKzr1EODAbroFMG+R76NU7Pu7amSrxmIRJZkUtNQEQunm1w9dCe5QMMdyVC0jE vrfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=x1l7DicE; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si7475943edc.1.2019.10.28.02.22.56; Mon, 28 Oct 2019 02:23:19 -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; dkim=pass header.i=@kernel.org header.s=default header.b=x1l7DicE; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732712AbfJ0VZU (ORCPT + 99 others); Sun, 27 Oct 2019 17:25:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:47112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732099AbfJ0VZR (ORCPT ); Sun, 27 Oct 2019 17:25:17 -0400 Received: from localhost (100.50.158.77.rev.sfr.net [77.158.50.100]) (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 9D9AE222BD; Sun, 27 Oct 2019 21:25:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572211517; bh=sBK3e/HJ72aJFPRCV7NuKK2fRBkXmMl86jjjjgNUYbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x1l7DicE5Xt5jH5lncunI3pi2KhV55GeXOA7WSWnggczXocKGl/eD+A1mkTvvruVK iBIiE/5B2YMlxmFxsGjlfEif+23o+iJ5xRBYYC0hAYWe/y3sGq2BKD2+5cpwhvHgJq fluc4j11RYLZCrr6xpOZvpB1tzsKgE5YuBTPts0w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Kelley , Roman Kagan , Thomas Gleixner , Vitaly Kuznetsov Subject: [PATCH 5.3 177/197] x86/hyperv: Make vapic support x2apic mode Date: Sun, 27 Oct 2019 22:01:35 +0100 Message-Id: <20191027203405.081835714@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191027203351.684916567@linuxfoundation.org> References: <20191027203351.684916567@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: Roman Kagan commit e211288b72f15259da86eed6eca680758dbe9e74 upstream. Now that there's Hyper-V IOMMU driver, Linux can switch to x2apic mode when supported by the vcpus. However, the apic access functions for Hyper-V enlightened apic assume xapic mode only. As a result, Linux fails to bring up secondary cpus when run as a guest in QEMU/KVM with both hv_apic and x2apic enabled. According to Michael Kelley, when in x2apic mode, the Hyper-V synthetic apic MSRs behave exactly the same as the corresponding architectural x2apic MSRs, so there's no need to override the apic accessors. The only exception is hv_apic_eoi_write, which benefits from lazy EOI when available; however, its implementation works for both xapic and x2apic modes. Fixes: 29217a474683 ("iommu/hyper-v: Add Hyper-V stub IOMMU driver") Fixes: 6b48cb5f8347 ("X86/Hyper-V: Enlighten APIC access") Suggested-by: Michael Kelley Signed-off-by: Roman Kagan Signed-off-by: Thomas Gleixner Reviewed-by: Vitaly Kuznetsov Reviewed-by: Michael Kelley Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20191010123258.16919-1-rkagan@virtuozzo.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/hyperv/hv_apic.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) --- a/arch/x86/hyperv/hv_apic.c +++ b/arch/x86/hyperv/hv_apic.c @@ -260,11 +260,21 @@ void __init hv_apic_init(void) } if (ms_hyperv.hints & HV_X64_APIC_ACCESS_RECOMMENDED) { - pr_info("Hyper-V: Using MSR based APIC access\n"); + pr_info("Hyper-V: Using enlightened APIC (%s mode)", + x2apic_enabled() ? "x2apic" : "xapic"); + /* + * With x2apic, architectural x2apic MSRs are equivalent to the + * respective synthetic MSRs, so there's no need to override + * the apic accessors. The only exception is + * hv_apic_eoi_write, because it benefits from lazy EOI when + * available, but it works for both xapic and x2apic modes. + */ apic_set_eoi_write(hv_apic_eoi_write); - apic->read = hv_apic_read; - apic->write = hv_apic_write; - apic->icr_write = hv_apic_icr_write; - apic->icr_read = hv_apic_icr_read; + if (!x2apic_enabled()) { + apic->read = hv_apic_read; + apic->write = hv_apic_write; + apic->icr_write = hv_apic_icr_write; + apic->icr_read = hv_apic_icr_read; + } } }