Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5730245ybp; Tue, 15 Oct 2019 04:17:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCZUVkMyVm517EJw8//j1FsQkQoPbWnzXKpY7z0A+zoWWO9yHFw/XWWUqH6Lp4FnFMuWwz X-Received: by 2002:a05:6402:13c9:: with SMTP id a9mr32256882edx.141.1571138251573; Tue, 15 Oct 2019 04:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571138251; cv=none; d=google.com; s=arc-20160816; b=OAICW9OMZHps7GqewTP1RTUXugNRv7tyWYngOSE8gXuHWMgxq4c/1IuNiaSW3ZZfMc d9/VqouW6/OkZ3Q4gyEcNyzQ1dmL6cszVIq5WrUOSM6UYN3BoLznz6E0IpJ29+wuBvVN LJ+2eOAMadqVyj9GfVGXeOMruLBBvh0CnfqxnKrcP8S4GePWo+VVDkOO3uajV9CWAUY8 MeBYd9tf7Y3dUxO4Y6E13PcWfMD6iDRW74CNRNqC6Gh7nX+dLmL2jakIbIIfgH8u/nEc pOiIOWIx4UJNyeDhImSFQcLS5rDf1+r6d/QQH2oJieGAmf/CZqLicD9xHY7qtphRoTKy S3dQ== 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=HODj2vOd8Kxg3t4s9yxXLFCsNq8T74gTGOJ3HfwiMi7a+ke7mqU+wTtwupBi18ixn6 cw7yy5xhFaS2ZlMkRr4gaaUWKgzeWRo7pamwTjZJyYB9DcBzDDbvqb2YTBFSyFOoNkw3 MLd/YA5VVVH2PwT1ic0NAId2tGr/x9VkbJLiFHVU1vW4iD0zdRDoF4+LOM+WgOlZsHel JMqdLibzWOS/HtytZbngz9mf94vAgB4x7o4rgi9qVbhM1BrFpi61wyRdODJyGew16ak8 bPKH3/PPhSa2ICU+MaGWW5eNieIl3da6v2LIuo29mRmysNm/DkSDAmfSlNjKdp9F/UjM lMPg== 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 a53si15930870edc.175.2019.10.15.04.17.08; Tue, 15 Oct 2019 04:17:31 -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 S1729207AbfJOJCN (ORCPT + 99 others); Tue, 15 Oct 2019 05:02:13 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:43043 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727838AbfJOJCM (ORCPT ); Tue, 15 Oct 2019 05:02:12 -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 1iKIiU-0004Se-Ql; Tue, 15 Oct 2019 11:02:06 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 65CFE1C03AB; Tue, 15 Oct 2019 11:02:06 +0200 (CEST) Date: Tue, 15 Oct 2019 09:02:06 -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: <157113012628.12254.17085476162161245613.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; + } } }