From patchwork Fri Mar 24 13:29:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 9642827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2FA09601E9 for ; Fri, 24 Mar 2017 13:31:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B8701FFAD for ; Fri, 24 Mar 2017 13:31:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E1811FFB2; Fri, 24 Mar 2017 13:31:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9C7F927D29 for ; Fri, 24 Mar 2017 13:31:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1crPHV-0002bY-7W; Fri, 24 Mar 2017 13:29:29 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1crPHT-0002bP-Gq for xen-devel@lists.xenproject.org; Fri, 24 Mar 2017 13:29:27 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id F9/98-14551-63F15D85; Fri, 24 Mar 2017 13:29:26 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOLMWRWlGSWpSXmKPExsXitHSDva6Z/NU Ig9n9rBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bSKUuYCvYGVLzf85WlgfGKfRcjJ4eEgL/E 8g2XmUBsNgEdialPL7F2MXJwiAioSNzea9DFyMXBLPCUUWLFkY1gcWGBCInDvypBylkEVCWOX NvKBBLmFXCX2PwhDWKinMT54z+ZQWwhoCnrp85iA7F5BQQlTs58wgJiMwtISBx88YJ5AiP3LC SpWUhSCxiZVjFqFKcWlaUW6RqZ6SUVZaZnlOQmZuboGhoY6+WmFhcnpqfmJCYV6yXn525iBAZ CPQMD4w7Ghr1+hxglOZiURHndtl2JEOJLyk+pzEgszogvKs1JLT7EKMPBoSTByyNzNUJIsCg1 PbUiLTMHGJIwaQkOHiUR3qcgad7igsTc4sx0iNQpRl2OObN3v2ESYsnLz0uVEuf9Kg1UJABSl FGaBzcCFh+XGGWlhHkZGRgYhHgKUotyM0tQ5V8xinMwKgnznpMCmsKTmVcCt+kV0BFMQEfM3n AF5IiSRISUVAOj1YmzUldtIrMLZ6j7TjqVEb1nykGZ8nyudadL1s7/9lAuROSH/CeR9YELtLg 8z3du6pB4c0H+wr8/4hcY+EQD8m98n//dZ6XzBP27Zq+8PhfseH5K/nnqiiVcf/6z5ywWLeZf 7n1/a33d6bssX+ewFG0J6GTUqKu9afaH7fG6jNP3kg9rP561R4mlOCPRUIu5qDgRAJhhCn2KA gAA X-Env-Sender: prvs=249263d75=Paul.Durrant@citrix.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1490362163!84320447!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4455 invoked from network); 24 Mar 2017 13:29:25 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-16.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 24 Mar 2017 13:29:25 -0000 X-IronPort-AV: E=Sophos;i="5.36,215,1486425600"; d="scan'208";a="424547725" From: Paul Durrant To: Date: Fri, 24 Mar 2017 13:29:10 +0000 Message-ID: <1490362150-24679-1-git-send-email-paul.durrant@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Cc: Wei Liu , Owen Smith , Andrew Cooper , Ian Jackson , Paul Durrant , Jan Beulich Subject: [Xen-devel] [PATCH v3] tools/firmware: add ACPI device for Windows laptop/slate mode switch X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Microsoft have defined an ACPI device to support switching Windows 10 between laptop/desktop mode and slate/tablet mode [1]. This patch adds an SSDT containing such a device. The presence of the device is controlled by a new 'acpi_conv' boolean in xl.cfg. The new device will not be present by default. [1] https://msdn.microsoft.com/en-us/windows/hardware/commercialize/design/device-experiences/continuum Signed-off-by: Owen Smith Signed-off-by: Paul Durrant --- Cc: Ian Jackson Cc: Wei Liu Cc: Jan Beulich Cc: Andrew Cooper NOTE: Odd looking braces style in tools/libacpi/build.c is for consistency with existing code. v3: - s/acpi_conv/acpi_laptop_slate/g v2: - Fix default if xenstore key is missing --- docs/man/xl.cfg.pod.5.in | 5 +++++ tools/firmware/hvmloader/util.c | 2 ++ tools/libacpi/Makefile | 4 ++-- tools/libacpi/build.c | 11 +++++++++++ tools/libacpi/libacpi.h | 31 +++++++++++++++--------------- tools/libacpi/ssdt_laptop_slate.asl | 38 +++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_create.c | 3 +++ tools/libxl/libxl_types.idl | 1 + tools/xl/xl_parse.c | 1 + 9 files changed, 79 insertions(+), 17 deletions(-) create mode 100644 tools/libacpi/ssdt_laptop_slate.asl diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in index 52802d5..39c2cb9 100644 --- a/docs/man/xl.cfg.pod.5.in +++ b/docs/man/xl.cfg.pod.5.in @@ -1256,6 +1256,11 @@ ACPI table. True (1) by default. Include S4 (suspend-to-disk) power state in the virtual firmware ACPI table. True (1) by default. +=item B + +Include the Windows laptop/slate mode switch device in the virtual +firmware ACPI table. False (0) by default. + =item B Include information regarding APIC (Advanced Programmable Interrupt diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c index 03cfb79..db5f240 100644 --- a/tools/firmware/hvmloader/util.c +++ b/tools/firmware/hvmloader/util.c @@ -947,6 +947,8 @@ void hvmloader_acpi_build_tables(struct acpi_config *config, config->table_flags |= ACPI_HAS_SSDT_S3; if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1) ) config->table_flags |= ACPI_HAS_SSDT_S4; + if ( !strncmp(xenstore_read("platform/acpi_laptop_slate", "0"), "1", 1) ) + config->table_flags |= ACPI_HAS_SSDT_LAPTOP_SLATE; config->table_flags |= (ACPI_HAS_TCPA | ACPI_HAS_IOAPIC | ACPI_HAS_WAET | ACPI_HAS_PMTIMER | diff --git a/tools/libacpi/Makefile b/tools/libacpi/Makefile index 6d8445d..fd7af1b 100644 --- a/tools/libacpi/Makefile +++ b/tools/libacpi/Makefile @@ -25,7 +25,7 @@ C_SRC-$(CONFIG_X86) = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c dsdt_pvh C_SRC-$(CONFIG_ARM_64) = dsdt_anycpu_arm.c DSDT_FILES ?= $(C_SRC-y) C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, $(DSDT_FILES)) -H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h) +H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h ssdt_laptop_slate.h) MKDSDT_CFLAGS-$(CONFIG_ARM_64) = -DCONFIG_ARM_64 MKDSDT_CFLAGS-$(CONFIG_X86) = -DCONFIG_X86 @@ -89,7 +89,7 @@ iasl: @echo @exit 1 -build.o: ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h +build.o: ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h ssdt_laptop_slate.h acpi.a: $(OBJS) $(AR) rc $@ $(OBJS) diff --git a/tools/libacpi/build.c b/tools/libacpi/build.c index a02ffbf..f9881c9 100644 --- a/tools/libacpi/build.c +++ b/tools/libacpi/build.c @@ -20,6 +20,7 @@ #include "ssdt_s4.h" #include "ssdt_tpm.h" #include "ssdt_pm.h" +#include "ssdt_laptop_slate.h" #include #include #include @@ -406,6 +407,16 @@ static int construct_secondary_tables(struct acpi_ctxt *ctxt, printf("S4 disabled\n"); } + if ( config->table_flags & ACPI_HAS_SSDT_LAPTOP_SLATE ) + { + ssdt = ctxt->mem_ops.alloc(ctxt, sizeof(ssdt_laptop_slate), 16); + if (!ssdt) return -1; + memcpy(ssdt, ssdt_laptop_slate, sizeof(ssdt_laptop_slate)); + table_ptrs[nr_tables++] = ctxt->mem_ops.v2p(ctxt, ssdt); + } else { + printf("CONV disabled\n"); + } + /* TPM TCPA and SSDT. */ if ( (config->table_flags & ACPI_HAS_TCPA) && (config->tis_hdr[0] == tis_signature[0]) && diff --git a/tools/libacpi/libacpi.h b/tools/libacpi/libacpi.h index 67bd67f..2ed1ecf 100644 --- a/tools/libacpi/libacpi.h +++ b/tools/libacpi/libacpi.h @@ -20,21 +20,22 @@ #ifndef __LIBACPI_H__ #define __LIBACPI_H__ -#define ACPI_HAS_COM1 (1<<0) -#define ACPI_HAS_COM2 (1<<1) -#define ACPI_HAS_LPT1 (1<<2) -#define ACPI_HAS_HPET (1<<3) -#define ACPI_HAS_SSDT_PM (1<<4) -#define ACPI_HAS_SSDT_S3 (1<<5) -#define ACPI_HAS_SSDT_S4 (1<<6) -#define ACPI_HAS_TCPA (1<<7) -#define ACPI_HAS_IOAPIC (1<<8) -#define ACPI_HAS_WAET (1<<9) -#define ACPI_HAS_PMTIMER (1<<10) -#define ACPI_HAS_BUTTONS (1<<11) -#define ACPI_HAS_VGA (1<<12) -#define ACPI_HAS_8042 (1<<13) -#define ACPI_HAS_CMOS_RTC (1<<14) +#define ACPI_HAS_COM1 (1<<0) +#define ACPI_HAS_COM2 (1<<1) +#define ACPI_HAS_LPT1 (1<<2) +#define ACPI_HAS_HPET (1<<3) +#define ACPI_HAS_SSDT_PM (1<<4) +#define ACPI_HAS_SSDT_S3 (1<<5) +#define ACPI_HAS_SSDT_S4 (1<<6) +#define ACPI_HAS_TCPA (1<<7) +#define ACPI_HAS_IOAPIC (1<<8) +#define ACPI_HAS_WAET (1<<9) +#define ACPI_HAS_PMTIMER (1<<10) +#define ACPI_HAS_BUTTONS (1<<11) +#define ACPI_HAS_VGA (1<<12) +#define ACPI_HAS_8042 (1<<13) +#define ACPI_HAS_CMOS_RTC (1<<14) +#define ACPI_HAS_SSDT_LAPTOP_SLATE (1<<15) struct xen_vmemrange; struct acpi_numa { diff --git a/tools/libacpi/ssdt_laptop_slate.asl b/tools/libacpi/ssdt_laptop_slate.asl new file mode 100644 index 0000000..3e5fbd5 --- /dev/null +++ b/tools/libacpi/ssdt_laptop_slate.asl @@ -0,0 +1,38 @@ +/* + * ssdt_conv.asl + * + * Copyright (c) 2017 Citrix Systems, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +/* + * Windows laptop/slate mode device + * + * See https://msdn.microsoft.com/en-us/windows/hardware/commercialize/design/device-experiences/continuum#method-2----use-the-injection-interface + */ + +DefinitionBlock ("SSDT_LAPTOP_SLATE.aml", "SSDT", 2, "Xen", "HVM", 0) +{ + Device (CONV) { + Method (_HID, 0x0, NotSerialized) { + Return("ID9001") + } + Name (_CID, "PNP0C60") + } +} + +/* + * Local variables: + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 25389e1..90f9342 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -313,6 +313,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, libxl_defbool_setdefault(&b_info->u.hvm.acpi, true); libxl_defbool_setdefault(&b_info->u.hvm.acpi_s3, true); libxl_defbool_setdefault(&b_info->u.hvm.acpi_s4, true); + libxl_defbool_setdefault(&b_info->u.hvm.acpi_laptop_slate, false); libxl_defbool_setdefault(&b_info->u.hvm.nx, true); libxl_defbool_setdefault(&b_info->u.hvm.viridian, false); libxl_defbool_setdefault(&b_info->u.hvm.hpet, true); @@ -458,6 +459,8 @@ int libxl__domain_build(libxl__gc *gc, localents[i++] = libxl_defbool_val(info->u.hvm.acpi_s3) ? "1" : "0"; localents[i++] = "platform/acpi_s4"; localents[i++] = libxl_defbool_val(info->u.hvm.acpi_s4) ? "1" : "0"; + localents[i++] = "platform/acpi_laptop_slate"; + localents[i++] = libxl_defbool_val(info->u.hvm.acpi_laptop_slate) ? "1" : "0"; if (info->u.hvm.mmio_hole_memkb) { uint64_t max_ram_below_4g = (1ULL << 32) - (info->u.hvm.mmio_hole_memkb << 10); diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl index 2475a4d..3f91d68 100644 --- a/tools/libxl/libxl_types.idl +++ b/tools/libxl/libxl_types.idl @@ -507,6 +507,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("acpi", libxl_defbool), ("acpi_s3", libxl_defbool), ("acpi_s4", libxl_defbool), + ("acpi_laptop_slate",libxl_defbool), ("nx", libxl_defbool), ("viridian", libxl_defbool), ("viridian_enable", libxl_bitmap), diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index b72f990..c23c951 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1065,6 +1065,7 @@ void parse_config_data(const char *config_source, xlu_cfg_get_defbool(config, "apic", &b_info->u.hvm.apic, 0); xlu_cfg_get_defbool(config, "acpi_s3", &b_info->u.hvm.acpi_s3, 0); xlu_cfg_get_defbool(config, "acpi_s4", &b_info->u.hvm.acpi_s4, 0); + xlu_cfg_get_defbool(config, "acpi_laptop_slate", &b_info->u.hvm.acpi_laptop_slate, 0); xlu_cfg_get_defbool(config, "nx", &b_info->u.hvm.nx, 0); xlu_cfg_get_defbool(config, "hpet", &b_info->u.hvm.hpet, 0); xlu_cfg_get_defbool(config, "vpt_align", &b_info->u.hvm.vpt_align, 0);