Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5728225ybp; Tue, 15 Oct 2019 04:15:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKxNb+S64mMM9wKJr+HFnTZ9+9FH0Ze0vhHwQuARHdnmIB1ajB9c3vhi3piAgqxnboquv2 X-Received: by 2002:a17:906:4a8d:: with SMTP id x13mr32609351eju.317.1571138146416; Tue, 15 Oct 2019 04:15:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571138146; cv=none; d=google.com; s=arc-20160816; b=RkhG+CsuBwp1Cze2xQrZP7Dp2iFOtyfiNjfh0t3FV6BzBc8s8AhMzPjDO2sOPC8PDv 2p4Uf1CAt8X3DDQVaRi85jNx7bOhq84Wn/lOCdsuxSNTZ9Iqkux5a0jiN5qPDnntxbNe RiF/AixZYZyKge3SNiAIM0NXqe9nsPv/9WOAJ5BbdajB9lroxP4+HW6KpLdfVGYGxjrt AG4QLpT5Jy/97A8V7+NChq/eKQWRMaZPZm9KxuEkfj8XGaVh2zCksF+cpCOx2R/d55U/ 2RJjiw+E6eItejInj/HTbSzXFxmfc+hR9bvdIGPFQQQnGxNu0QZd5z8t3KAu/MzxHSml Yesw== 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 :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=f0/S0Im4vU5RHJUWtwizt8sntHrKoPLlfpv5dDdtv+Q=; b=MOOvP7ZYY1zxW3V3yw7KBTN/f0P+u+bQankp0hE0aVq5AlzF80AHPtIkdEZnBGVQZS qgy5Mdbunaedm97uh8DM4uHyKjeet2DFAJMOLWnmI5ZWXATD89xFLfAggCcx5IRZw3eC 713hzDNFS9yjp2OG0unuZEBbCUvT933wA/g9KKDzaQMBDXvuhhOJ92wHqrQ5058Zh6yD KywC24XP50WRUvsZ9KPWU/ypjerhhdvtRWTAcV6rz7jfCfL4lRXO5nReQYvbac0E4wnT AxVFNftrAxK8UCqIP35/dNAI/tfqOlHaezlLke3LbhB61AfIuolZRv8Avnk5uXlsK2M/ MFCw== ARC-Authentication-Results: i=1; mx.google.com; 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 z16si8645303edb.420.2019.10.15.04.15.23; Tue, 15 Oct 2019 04:15:46 -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; 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 S1729607AbfJOJC1 (ORCPT + 99 others); Tue, 15 Oct 2019 05:02:27 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:43057 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729455AbfJOJCT (ORCPT ); Tue, 15 Oct 2019 05:02:19 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1iKIib-0004U2-Rz; Tue, 15 Oct 2019 11:02:14 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 85A7F1C03AB; Tue, 15 Oct 2019 11:02:13 +0200 (CEST) Date: Tue, 15 Oct 2019 09:02:13 -0000 From: "tip-bot2 for Roman Kagan" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/hyperv: Make vapic support x2apic mode Cc: Michael Kelley , Roman Kagan , Thomas Gleixner , Vitaly Kuznetsov , stable@vger.kernel.org, Ingo Molnar , Borislav Petkov , linux-kernel@vger.kernel.org In-Reply-To: <20191010123258.16919-1-rkagan@virtuozzo.com> References: <20191010123258.16919-1-rkagan@virtuozzo.com> MIME-Version: 1.0 Message-ID: <157113013342.12254.11286176752899066675.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/urgent branch of tip: Commit-ID: e211288b72f15259da86eed6eca680758dbe9e74 Gitweb: https://git.kernel.org/tip/e211288b72f15259da86eed6eca680758dbe9e74 Author: Roman Kagan AuthorDate: Thu, 10 Oct 2019 12:33:05 Committer: Thomas Gleixner CommitterDate: Tue, 15 Oct 2019 10:57:09 +02:00 x86/hyperv: Make vapic support x2apic mode 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 --- arch/x86/hyperv/hv_apic.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c index 5c056b8..e01078e 100644 --- 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; + } } }