[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3] platform/x86: don't unconditionally attach Intel PMC when virtualized


  • To: linux-kernel@xxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Thu, 10 Nov 2022 17:31:44 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=anhVgeEpURpP2uRlzZ2W5M+ywycrkzKb3c1lNsONauU=; b=ODH52CuwS8nvfMmbbLeYwQb2zkEJ0MWvEo5MjZyx+dWrg4PBRQZYzWrM/ifHPGjVyR0z49C+DJt460xwaBKIzT10Sy9brexzLWbbnGxPbErEnD0EXKOAFVREz/ZLA1EPMYvCVgR+k4ZcCmStGDmNx32x1l5i2oYegs/5VwpKS6/8Xn/m0l0XM3cTqX+b4dUeCF5TwCGKI8K7J/aSxWnbFoL5lP+j/eeubQ0n6xo55JzdTF0KjcG7Mlb5XnhnQJNZAWvOq95I99Yadnkq4G9vs9+WRDxx5QQfwN5TJel1Qswmx6P38yRJLBXnutsqpKIQL8BDT1tFIX0h4XlFXAf/qg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M3oXtMg77lXL9aexkF0fEWovV60EY6CZfI++HBlXsWzr/Z/DSi+/Bs7dcr6vMW+LGj5DgKOPRl7ufyLPxJlR4lFo8/53E5SkoH3DW+c/t5RkqClUx+jHa12FeqnhgRRqmrhWeWayq3hZiBvi6Vssa6gxTZu/ee8iANttu9Cc8bsP3gPypzC1kiLOkV2klxacLjYsuwY7AnXgnCvAcjhh9xSpnnhoMBpa1fUHP3B7VR0fKagVZOzZbfuVcwv8oZvFYXsiJQ4UXUE+xvCKB1t9/ipdV5bLKp/eTko58lKf4dC/OC6XAqlZ2WeHaeH0Dc+aG9YpPQO9HzfVB9kUMQI7+w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, jgross@xxxxxxxx, Roger Pau Monne <roger.pau@xxxxxxxxxx>, "David E . Box" <david.e.box@xxxxxxxxxxxxxxx>, Rajneesh Bhardwaj <irenic.rajneesh@xxxxxxxxx>, David E Box <david.e.box@xxxxxxxxx>, Hans de Goede <hdegoede@xxxxxxxxxx>, Mark Gross <markgross@xxxxxxxxxx>, Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>, Srinivas Pandruvada <srinivas.pandruvada@xxxxxxxxxxxxxxx>, platform-driver-x86@xxxxxxxxxxxxxxx
  • Delivery-date: Thu, 10 Nov 2022 16:32:26 +0000
  • Ironport-data: A9a23:xxNJlq1BWPIEkHSv9/bD5c9xkn2cJEfYwER7XKvMYLTBsI5bpzwGz jQaWjyDOfeCM2Twed8lOoW/9kkGvcKBzdAyHVA+pC1hF35El5HIVI+TRqvS04F+DeWYFR46s J9OAjXkBJppJpMJjk71atANlVEliefTAOK5ULSfUsxIbVcMYD87jh5+kPIOjIdtgNyoayuAo tq3qMDEULOf82cc3lk8tuTS9nuDgNyo4GlC5wVnPagQ1LPjvyJ94Kw3dPnZw0TQGuG4LsbiL 87fwbew+H/u/htFIrtJRZ6iLyXm6paLVeS/oiI+t5qK23CulQRrukoPD9IOaF8/ttm8t4sZJ OOhF3CHYVxB0qXkwIzxWvTDes10FfUuFLTveRBTvSEPpqFvnrSFL/hGVSkL0YMkFulfCkpxx NckDjs3c0rbiaWRnaK6dPMyr5F2RCXrFNt3VnBI6xj8VKxja7aTBqLA6JlfwSs6gd1IEbDGf c0FZDFzbRPG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qptG8bC4mCuJa7LgpOCfx2g4FhpVRwa hL12WWu958FhXbhhnw4NDOSlVDile0m3w/iuQe5kYvGrf2UIUh4bD3wXklX6vpREnBmc4a+a hVfYnhDc9tAB6nhyuzhBgv/DSuNk5DbituDHJy+vB96AIm4kyR/3FouPD3oU1wi67VM6M0gd gsEp4Y5o2mHfVmGJ5VNaMmffadLFDrbFblDF+ySG6XZZ3vfUi94qLK3A==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The current logic in the Intel PMC driver will forcefully attach it
when detecting any CPU on the intel_pmc_core_platform_ids array,
even if the matching ACPI device is not present.

There's no checking in pmc_core_probe() to assert that the PMC device
is present, and hence on virtualized environments the PMC device
probes successfully, even if the underlying registers are not present.
Previous to 21ae43570940 the driver would check for the presence of a
specific PCI device, and that prevented the driver from attaching when
running virtualized.

Fix by only forcefully attaching the PMC device when not running
virtualized.  Note that virtualized platforms can still get the device
to load if the appropriate ACPI device is present on the tables
provided to the VM.

Make an exception for the Xen initial domain, which does have full
hardware access, and hence can attach to the PMC if present.

Fixes: 21ae43570940 ('platform/x86: intel_pmc_core: Substitute PCI with CPUID 
enumeration')
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Acked-by: David E. Box <david.e.box@xxxxxxxxxxxxxxx>
---
Changes since v2:
 - Don't split condition line.

Changes since v1:
 - Use cpu_feature_enabled() instead of boot_cpu_has().
---
 drivers/platform/x86/intel/pmc/pltdrv.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/platform/x86/intel/pmc/pltdrv.c 
b/drivers/platform/x86/intel/pmc/pltdrv.c
index 15ca8afdd973..ddfba38c2104 100644
--- a/drivers/platform/x86/intel/pmc/pltdrv.c
+++ b/drivers/platform/x86/intel/pmc/pltdrv.c
@@ -18,6 +18,8 @@
 #include <asm/cpu_device_id.h>
 #include <asm/intel-family.h>
 
+#include <xen/xen.h>
+
 static void intel_pmc_core_release(struct device *dev)
 {
        kfree(dev);
@@ -53,6 +55,13 @@ static int __init pmc_core_platform_init(void)
        if (acpi_dev_present("INT33A1", NULL, -1))
                return -ENODEV;
 
+       /*
+        * Skip forcefully attaching the device for VMs. Make an exception for
+        * Xen dom0, which does have full hardware access.
+        */
+       if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR) && 
!xen_initial_domain())
+               return -ENODEV;
+
        if (!x86_match_cpu(intel_pmc_core_platform_ids))
                return -ENODEV;
 
-- 
2.37.3




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.