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

[PATCH 2/3] acpi/processor: sanitize _PDC buffer bits when running as Xen dom0


  • To: linux-kernel@xxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Mon, 21 Nov 2022 11:21:11 +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=Vg+rjiccX1faa/xjxY+0Qw0fO6LNKDvwiUc3ugbC6P0=; b=Py3N2rqEMs/y1gkTEcMh/PjCOddExM1RzWa67Z7mN80rLzUhIFE5qExWUwMD+yXd7IZ8I/OI53QFkQw6SL7Lr3gP8fwz2ooHKf9lhLSy3gg3r2DDeRJfZLJAU1gnywePhVHGg+91ru65G4RGSFAvPeBEivCtztzQNg2+HZaBvqNGbMBWNvLjeFDeFqI85SUkm8QR7xQy4zNSYcAkBG6DMeSPx7Va0NEVFi9l8tH+6fIaf/qlK502RIIRe3Dj9aWJ9PyyevadtNt3dDjxPoMphuzbopdQPlCqQOVIiJClWNJEvAPinqPDcNExFNYFEC7e4fWuHJPFYAHhpkeoCWgyFg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AvScgZsGqDa0NR2KIR7n5fVNr0diVh/savKaYpSfFFxvqyuJM6azyU+/FRCEzzJO8a+hm8DmeGQusqvj++TYP3vwpreShwlPGrYiJpsh2HN2EQNrNSdrNbW/oQKttzeusjbD7slYu+dRlU4bZoDuxZ/V09uRdE27d35zjgeWl9hwY8mCqRgylctDeCSbm/AgViwmq1M091Vx4blPlG3dQB5JvC0YELHPdLqDp3ekEftmEtJwGcbyse42d5dVRTGxtIfkKl+BSEeXbPKJTyCSgAAr01cgTwOKKKZ96CzUsVgP3vZpMjjQT0TiXDarx9phC6WOEFEH12vkuUZGquXMSg==
  • 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>, stable@xxxxxxxxxxxxxxx, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, x86@xxxxxxxxxx, "H. Peter Anvin" <hpa@xxxxxxxxx>, "Rafael J. Wysocki" <rafael@xxxxxxxxxx>, Len Brown <lenb@xxxxxxxxxx>, linux-acpi@xxxxxxxxxxxxxxx
  • Delivery-date: Mon, 21 Nov 2022 10:33:35 +0000
  • Ironport-data: A9a23:yb8t2KsqbvNlQZnNRYyVSp0py+fnVEZeMUV32f8akzHdYApBsoF/q tZmKWzXbPzbYDb8ftknaozkoxwGupeEn9IwSwFp+CExF3hA+JbJXdiXEBz9bniYRiHhoOCLz O1FM4Wdc5pkJpP4jk3wWlQ0hSAkjclkfpKlVKiffHg0HVU/IMsYoUoLs/YjhYJ1isSODQqIu Nfjy+XSI1bg0DNvWo4uw/vrRChH4bKj5lv0gnRkPaoR5QaEziFMZH4iDfrZw0XQE9E88tGSH 44v/JnhlkvF8hEkDM+Sk7qTWiXmlZaLYGBiIlIPM0STqkAqSh4ai87XB9JFAatjsB2bnsgZ9 Tl4ncfYpTHFnEH7sL91vxFwS0mSNEDdkVPNCSDXXce7lyUqf5ZwqhnH4Y5f0YAwo45K7W9yG fMwLxJQVkG5wNON76unaft2i9sgMtnQFdZK0p1g5Wmx4fcOZ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Vv4DoE/5TyWQm1/AygPg2DEh5zvLzkKZu2LqpYjcSCghA8RMqIpFel+BgnBQ9O1U4e Zu5Sa0ppBXBRTPkGDU4MXJbQhjkg6RrWA5meAeonRDWc81aaNXr6YY4ERJea1wVR7S2cQCKq 1DHcvc7PFZfRezaG3YhHBmxJiWUnE6Dn69Mz0/k/3Q9wITsGFyzkMeysBatGwH7ogBR55N4P mBGrh0lZlVJ/VmI55VNaMke4+aG2bNSRXDPCa5OlL8DpwKPHrLttre/Kg13ue3Y5YFpaFC16 gpaGko9VLaRnieSvFnhPZwg1LwqSSGLHjQI/hlltlEUuaWfsuvDcWBIGpe4fdI7c9vRvEzYM zDSK6+M8WTU1cGJrw5rjEWI6MiT0X2cPdlzurTCGj+1f7jG8nNitHxVsr1Cf7ELQsEM1mPcU frGgKDafl90g==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The Processor _PDC buffer bits notify ACPI of the OS capabilities, and
so ACPI can adjust the return of other Processor methods taking the OS
capabilities into account.

When Linux is running as a Xen dom0, it's the hypervisor the entity
in charge of processor power management, and hence Xen needs to make
sure the capabilities reported in the _PDC buffer match the
capabilities of the driver in Xen.

Introduce a small helper to sanitize the buffer when running as Xen
dom0.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
---
 arch/x86/include/asm/xen/hypervisor.h |  2 ++
 arch/x86/xen/enlighten.c              | 17 +++++++++++++++++
 drivers/acpi/processor_pdc.c          |  8 ++++++++
 3 files changed, 27 insertions(+)

diff --git a/arch/x86/include/asm/xen/hypervisor.h 
b/arch/x86/include/asm/xen/hypervisor.h
index b9f512138043..b4ed90ef5e68 100644
--- a/arch/x86/include/asm/xen/hypervisor.h
+++ b/arch/x86/include/asm/xen/hypervisor.h
@@ -63,12 +63,14 @@ void __init mem_map_via_hcall(struct boot_params 
*boot_params_p);
 
 #ifdef CONFIG_XEN_DOM0
 bool __init xen_processor_present(uint32_t acpi_id);
+void xen_sanitize_pdc(uint32_t *buf);
 #else
 static inline bool xen_processor_present(uint32_t acpi_id)
 {
        BUG();
        return false;
 }
+static inline void xen_sanitize_pdc(uint32_t *buf) { BUG(); }
 #endif
 
 #endif /* _ASM_X86_XEN_HYPERVISOR_H */
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index d4c44361a26c..394dd6675113 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -372,4 +372,21 @@ bool __init xen_processor_present(uint32_t acpi_id)
 
        return false;
 }
+
+void xen_sanitize_pdc(uint32_t *buf)
+{
+       struct xen_platform_op op = {
+               .cmd                    = XENPF_set_processor_pminfo,
+               .interface_version      = XENPF_INTERFACE_VERSION,
+               .u.set_pminfo.id        = -1,
+               .u.set_pminfo.type      = XEN_PM_PDC,
+       };
+       int ret;
+
+       set_xen_guest_handle(op.u.set_pminfo.pdc, buf);
+       ret = HYPERVISOR_platform_op(&op);
+       if (ret)
+               pr_info("sanitize of _PDC buffer bits from Xen failed: %d\n",
+                       ret);
+}
 #endif
diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c
index 18fb04523f93..58f4c208517a 100644
--- a/drivers/acpi/processor_pdc.c
+++ b/drivers/acpi/processor_pdc.c
@@ -137,6 +137,14 @@ acpi_processor_eval_pdc(acpi_handle handle, struct 
acpi_object_list *pdc_in)
                buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
 
        }
+       if (xen_initial_domain())
+               /*
+                * When Linux is running as Xen dom0 it's the hypervisor the
+                * entity in charge of the processor power management, and so
+                * Xen needs to check the OS capabilities reported in the _PDC
+                * buffer matches what the hypervisor driver supports.
+                */
+               xen_sanitize_pdc((uint32_t *)pdc_in->pointer->buffer.pointer);
        status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL);
 
        if (ACPI_FAILURE(status))
-- 
2.37.3




 


Rackspace

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