[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2] 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 14:33:35 +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=Dzqqmd9ZAYBFPAQ7LVpanx8nD/Gwxq7UiI84XX0ieBo=; b=OVv27C0AMKFuKRleORmG59j5CefvLFRtCInZBxe5GWuextJR7Ayu8w076yhF8gLtGTFouiKOKsiwKIdB8cPe4uIPIWCG7AfPkrGHlYiWBmx/Ddyz0KTrAzcPBUQSaTnO5V0jsNld/vO1ILjjSuuzxTKGUaLXLjLG7Tn44Gip8BrXn85Za775TayW42+PkoC2I7zupNSXDoou+w4i2bGbjQg4HZFZaVhoUTlv5LZXDkeK7UMfsYFM+9OP6cr7hwDJ+r0oH2jfHANVLGpvsb1dZPtjNJ0vHpaErhIbUeW3ZsEje1WXsfbYdWMsdQKq5ltzBuxMF1KNyTacCgA3NEK+qA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JF1EcmabSMYcK2N3bfpBwoN1XHD2XSeb6kId634wkNO4EHC0xs4Rj3G6DULN3l5Ne+vDKRWEIsqDwQ3vONa0KVdvRyL2XFYI8izkygefXHhl0pbedDz9vQIfbyVoLW+2pW1GcXYAIiFCuSzUCwuYLLrm2hhSdP+GXIODtNXLJE9nTbN/8G1QixTECXyTxDcvTT01qDuUHRFNiz/dz93cmYtS/9r15WvPcd0ga0u9lbeosKV3BAXQgGfWi98+7tQdkFPzetI7F2o5sa2ACbgZJ9o3kFHigLTTs3Rc+krcA4EInBJ+m1IcM/M89qrfA3Te02rVX/PBPaeFpiVhaPGi4A==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: 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>, Juergen Gross <jgross@xxxxxxxx>, platform-driver-x86@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Thu, 10 Nov 2022 13:34:04 +0000
- Ironport-data: A9a23:I7B7uaLoiU6egehcFE+RzpUlxSXFcZb7ZxGr2PjKsXjdYENS1zwEn DFOXGyDPvvcZGT2L9wnb4nn8xtT6JGHzYVnTwVlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHv+kUrWs1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPdwP9TlK6q4mlB5wVmPakjUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5qCGxQ0 McmcgoONDSbmN2Lz4C7aMBF05FLwMnDZOvzu1lG5BSAVbMMZ8+GRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKG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ptG8bC4mCuJa7LgpOCfx2g4FhpVRwa 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>
Cc: Rajneesh Bhardwaj <irenic.rajneesh@xxxxxxxxx>
Cc: David E Box <david.e.box@xxxxxxxxx>
Cc: Hans de Goede <hdegoede@xxxxxxxxxx>
Cc: Mark Gross <markgross@xxxxxxxxxx>
Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Cc: Srinivas Pandruvada <srinivas.pandruvada@xxxxxxxxxxxxxxx>
Cc: Juergen Gross <jgross@xxxxxxxx>
Cc: platform-driver-x86@xxxxxxxxxxxxxxx
Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
---
Changes since v1:
- Use cpu_feature_enabled() instead of boot_cpu_has().
---
drivers/platform/x86/intel/pmc/pltdrv.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/platform/x86/intel/pmc/pltdrv.c
b/drivers/platform/x86/intel/pmc/pltdrv.c
index 15ca8afdd973..4f9fe8a21d8f 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,14 @@ 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
|