From patchwork Mon Nov 23 12:39:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 11925133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76B65C64E7B for ; Mon, 23 Nov 2020 12:40:08 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EDAA220732 for ; Mon, 23 Nov 2020 12:40:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="k3Np63Do" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDAA220732 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.34173.65012 (Exim 4.92) (envelope-from ) id 1khB8P-0001Xr-Ml; Mon, 23 Nov 2020 12:39:57 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 34173.65012; Mon, 23 Nov 2020 12:39:57 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khB8P-0001Xj-JI; Mon, 23 Nov 2020 12:39:57 +0000 Received: by outflank-mailman (input) for mailman id 34173; Mon, 23 Nov 2020 12:39:57 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khB8P-0001Xd-5F for xen-devel@lists.xenproject.org; Mon, 23 Nov 2020 12:39:57 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 417f9d19-27c2-48c4-9f41-f122c49c5d15; Mon, 23 Nov 2020 12:39:56 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A64AFAC75; Mon, 23 Nov 2020 12:39:55 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khB8P-0001Xd-5F for xen-devel@lists.xenproject.org; Mon, 23 Nov 2020 12:39:57 +0000 X-Inumbo-ID: 417f9d19-27c2-48c4-9f41-f122c49c5d15 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 417f9d19-27c2-48c4-9f41-f122c49c5d15; Mon, 23 Nov 2020 12:39:56 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1606135195; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cPfib+BwguvslmqXZRj+FnJjCsQqD71Psr1mDnpBDDc=; b=k3Np63Do2MCnyD8xk+WTEnRBJA35RjVU22z3Mh+L4BM0BLKavbR+FNg5DSJBzMClD6SFph 51LFSTNJh9zxGHvQWgbbiW3hcjdeoWX1tRQ1vz0ZLR/IN9dEG5MO9vaCuuZZPT+Gx7czEo GqBFhi55fU8QwLR82/GYWPcya0ROkpo= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A64AFAC75; Mon, 23 Nov 2020 12:39:55 +0000 (UTC) Subject: [PATCH 1/4] x86/ACPI: fix mapping of FACS From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Julien Grall References: <7f895b0e-f46f-8fe2-b0ac-e0503ef06a1f@suse.com> Message-ID: <81a8c2f0-ae9b-98e0-f5c5-d32b423db491@suse.com> Date: Mon, 23 Nov 2020 13:39:55 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <7f895b0e-f46f-8fe2-b0ac-e0503ef06a1f@suse.com> Content-Language: en-US acpi_fadt_parse_sleep_info() runs when the system is already in SYS_STATE_boot. Hence its direct call to __acpi_map_table() won't work anymore. This call should probably have been replaced long ago already, as the layering violation hasn't been necessary for quite some time. Fixes: 1c4aa69ca1e1 ("xen/acpi: Rework acpi_os_map_memory() and acpi_os_unmap_memory()") Signed-off-by: Jan Beulich Acked-by: Roger Pau Monné --- a/xen/arch/x86/acpi/boot.c +++ b/xen/arch/x86/acpi/boot.c @@ -422,8 +422,7 @@ acpi_fadt_parse_sleep_info(struct acpi_t if (!facs_pa) goto bad; - facs = (struct acpi_table_facs *) - __acpi_map_table(facs_pa, sizeof(struct acpi_table_facs)); + facs = acpi_os_map_memory(facs_pa, sizeof(*facs)); if (!facs) goto bad; @@ -448,11 +447,16 @@ acpi_fadt_parse_sleep_info(struct acpi_t offsetof(struct acpi_table_facs, firmware_waking_vector); acpi_sinfo.vector_width = 32; + acpi_os_unmap_memory(facs, sizeof(*facs)); + printk(KERN_INFO PREFIX " wakeup_vec[%"PRIx64"], vec_size[%x]\n", acpi_sinfo.wakeup_vector, acpi_sinfo.vector_width); return; -bad: + + bad: + if (facs) + acpi_os_unmap_memory(facs, sizeof(*facs)); memset(&acpi_sinfo, 0, offsetof(struct acpi_sleep_info, sleep_control)); memset(&acpi_sinfo.sleep_status + 1, 0, From patchwork Mon Nov 23 12:40:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 11925135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C955BC2D0E4 for ; Mon, 23 Nov 2020 12:40:24 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BAAD20732 for ; Mon, 23 Nov 2020 12:40:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="JXRx3OrL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BAAD20732 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.34174.65025 (Exim 4.92) (envelope-from ) id 1khB8h-0002Ic-VZ; Mon, 23 Nov 2020 12:40:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 34174.65025; Mon, 23 Nov 2020 12:40:15 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khB8h-0002IV-Sa; Mon, 23 Nov 2020 12:40:15 +0000 Received: by outflank-mailman (input) for mailman id 34174; Mon, 23 Nov 2020 12:40:14 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khB8g-0002I5-Cl for xen-devel@lists.xenproject.org; Mon, 23 Nov 2020 12:40:14 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c7678cbe-34fb-4a3d-979a-983d358e2936; Mon, 23 Nov 2020 12:40:13 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B2FA5AC66; Mon, 23 Nov 2020 12:40:12 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khB8g-0002I5-Cl for xen-devel@lists.xenproject.org; Mon, 23 Nov 2020 12:40:14 +0000 X-Inumbo-ID: c7678cbe-34fb-4a3d-979a-983d358e2936 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c7678cbe-34fb-4a3d-979a-983d358e2936; Mon, 23 Nov 2020 12:40:13 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1606135212; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wbsqmr/l1bE1HyCRA6+0mV3xj2TzTTHW3TbItze53ho=; b=JXRx3OrLUhCfeSMYr2aweRmyPeOtOJ5Zq5ly7vvMFSqVX6P6kWXMt2DFt+9XbMOd8pALe5 57XePsQeZmtNUgSp6DfXGzWp94f5krxxZz+agu3WtN4H4aDixFNYsA7f/FjmsNOO5R4paW 0H642uy5fugBuMKVTGpimHnsUCrsfnU= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B2FA5AC66; Mon, 23 Nov 2020 12:40:12 +0000 (UTC) Subject: [PATCH 2/4] x86/ACPI: fix S3 wakeup vector mapping From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Julien Grall References: <7f895b0e-f46f-8fe2-b0ac-e0503ef06a1f@suse.com> Message-ID: Date: Mon, 23 Nov 2020 13:40:12 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <7f895b0e-f46f-8fe2-b0ac-e0503ef06a1f@suse.com> Content-Language: en-US Use of __acpi_map_table() here was at least close to an abuse already before, but it will now consistently return NULL here. Drop the layering violation and use set_fixmap() directly. Re-use of the ACPI fixmap area is hopefully going to remain "fine" for the time being. Add checks to acpi_enter_sleep(): The vector now needs to be contained within a single page, but the ACPI spec requires 64-byte alignment of FACS anyway. Also bail if no wakeup vector was determined in the first place, in part as preparation for a subsequent relaxation change. Fixes: 1c4aa69ca1e1 ("xen/acpi: Rework acpi_os_map_memory() and acpi_os_unmap_memory()") Signed-off-by: Jan Beulich Acked-by: Roger Pau Monné --- a/xen/arch/x86/acpi/boot.c +++ b/xen/arch/x86/acpi/boot.c @@ -443,6 +443,11 @@ acpi_fadt_parse_sleep_info(struct acpi_t "FACS is shorter than ACPI spec allow: %#x", facs->length); + if (facs_pa % 64) + printk(KERN_WARNING PREFIX + "FACS is not 64-byte aligned: %#lx", + facs_pa); + acpi_sinfo.wakeup_vector = facs_pa + offsetof(struct acpi_table_facs, firmware_waking_vector); acpi_sinfo.vector_width = 32; --- a/xen/arch/x86/acpi/power.c +++ b/xen/arch/x86/acpi/power.c @@ -174,17 +174,20 @@ static void acpi_sleep_prepare(u32 state if ( state != ACPI_STATE_S3 ) return; - wakeup_vector_va = __acpi_map_table( - acpi_sinfo.wakeup_vector, sizeof(uint64_t)); - /* TBoot will set resume vector itself (when it is safe to do so). */ if ( tboot_in_measured_env() ) return; + set_fixmap(FIX_ACPI_END, acpi_sinfo.wakeup_vector); + wakeup_vector_va = fix_to_virt(FIX_ACPI_END) + + PAGE_OFFSET(acpi_sinfo.wakeup_vector); + if ( acpi_sinfo.vector_width == 32 ) *(uint32_t *)wakeup_vector_va = bootsym_phys(wakeup_start); else *(uint64_t *)wakeup_vector_va = bootsym_phys(wakeup_start); + + clear_fixmap(FIX_ACPI_END); } static void acpi_sleep_post(u32 state) {} @@ -331,6 +334,12 @@ static long enter_state_helper(void *dat */ int acpi_enter_sleep(struct xenpf_enter_acpi_sleep *sleep) { + if ( sleep->sleep_state == ACPI_STATE_S3 && + (!acpi_sinfo.wakeup_vector || !acpi_sinfo.vector_width || + (PAGE_OFFSET(acpi_sinfo.wakeup_vector) > + PAGE_SIZE - acpi_sinfo.vector_width / 8)) ) + return -EOPNOTSUPP; + if ( sleep->flags & XENPF_ACPI_SLEEP_EXTENDED ) { if ( !acpi_sinfo.sleep_control.address || From patchwork Mon Nov 23 12:40:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 11925137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBF59C2D0E4 for ; Mon, 23 Nov 2020 12:40:49 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5AAFC2076E for ; Mon, 23 Nov 2020 12:40:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="gbIT+V0A" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5AAFC2076E Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.34182.65037 (Exim 4.92) (envelope-from ) id 1khB93-0002QS-Di; Mon, 23 Nov 2020 12:40:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 34182.65037; Mon, 23 Nov 2020 12:40:37 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khB93-0002QK-A8; Mon, 23 Nov 2020 12:40:37 +0000 Received: by outflank-mailman (input) for mailman id 34182; Mon, 23 Nov 2020 12:40:36 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khB92-0002OQ-Cj for xen-devel@lists.xenproject.org; Mon, 23 Nov 2020 12:40:36 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a14cf33e-5462-4b5e-b240-2c95284fbd29; Mon, 23 Nov 2020 12:40:31 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 943D8ABCE; Mon, 23 Nov 2020 12:40:30 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khB92-0002OQ-Cj for xen-devel@lists.xenproject.org; Mon, 23 Nov 2020 12:40:36 +0000 X-Inumbo-ID: a14cf33e-5462-4b5e-b240-2c95284fbd29 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a14cf33e-5462-4b5e-b240-2c95284fbd29; Mon, 23 Nov 2020 12:40:31 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1606135230; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SVkCF63cSzSDN2HfqCHv8cKlqji3PTKbOSNyrWOJa6o=; b=gbIT+V0AFH7qMN6Ub5jgkUvEvx8DXDNRxGyOWXzKF/Bx2OUqxpU2HIwp7y3Vv4nbkBz+zL LRqV+jYO/NhD1Y8zDaW0nizoEzr4nnkme5v7mqHFqEUy9RdBG98ngzFM3wgVZ3Fddmkhae HroC8qSqZTCOrVfpbv103VIajGMpLkk= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 943D8ABCE; Mon, 23 Nov 2020 12:40:30 +0000 (UTC) Subject: [PATCH 3/4] x86/DMI: fix table mapping when one lives above 1Mb From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Julien Grall References: <7f895b0e-f46f-8fe2-b0ac-e0503ef06a1f@suse.com> Message-ID: <53cd4ae3-d806-c3ad-02fd-317a09f15a24@suse.com> Date: Mon, 23 Nov 2020 13:40:30 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <7f895b0e-f46f-8fe2-b0ac-e0503ef06a1f@suse.com> Content-Language: en-US Use of __acpi_map_table() is kind of an abuse here, and doesn't work anymore for the majority of cases if any of the tables lives outside the low first Mb. Keep this (ab)use only prior to reaching SYS_STATE_boot, primarily to avoid needing to audit whether any of the calls here can happen this early in the first place; quite likely this isn't necessary at all - at least dmi_scan_machine() gets called late enough. For the "normal" case, call __vmap() directly, despite effectively duplicating acpi_os_map_memory(). There's one difference though: We shouldn't need to establish UC- mappings, WP or r/o WB mappings ought to be fine, as the tables are going to live in either RAM or ROM. Short of having PAGE_HYPERVISOR_WP and wanting to map the tables r/o anyway, use the latter of the two options. The r/o mapping implies some constification of code elsewhere in the file. For code touched anyway also switch to void (where possible) or uint8_t. Fixes: 1c4aa69ca1e1 ("xen/acpi: Rework acpi_os_map_memory() and acpi_os_unmap_memory()") Signed-off-by: Jan Beulich Acked-by: Roger Pau Monné --- a/xen/arch/x86/dmi_scan.c +++ b/xen/arch/x86/dmi_scan.c @@ -12,8 +12,6 @@ #include #include -#define bt_ioremap(b,l) ((void *)__acpi_map_table(b,l)) -#define bt_iounmap(b,l) ((void)0) #define memcpy_fromio memcpy #define alloc_bootmem(l) xmalloc_bytes(l) @@ -111,9 +109,32 @@ enum dmi_entry_type { #define dmi_printk(x) #endif -static char * __init dmi_string(struct dmi_header *dm, u8 s) +static const void *__init bt_ioremap(paddr_t addr, unsigned int len) { - char *bp=(char *)dm; + mfn_t mfn = _mfn(PFN_DOWN(addr)); + unsigned int offs = PAGE_OFFSET(addr); + + if ( addr + len <= MB(1) ) + return __va(addr); + + if ( system_state < SYS_STATE_boot ) + return __acpi_map_table(addr, len); + + return __vmap(&mfn, PFN_UP(offs + len), 1, 1, PAGE_HYPERVISOR_RO, + VMAP_DEFAULT) + offs; +} + +static void __init bt_iounmap(const void *ptr, unsigned int len) +{ + if ( (unsigned long)ptr < DIRECTMAP_VIRT_START && + system_state >= SYS_STATE_boot ) + vunmap(ptr); +} + +static const char *__init dmi_string(const struct dmi_header *dm, uint8_t s) +{ + const char *bp = (const void *)dm; + bp+=dm->length; if(!s) return ""; @@ -133,11 +154,10 @@ static char * __init dmi_string(struct d */ static int __init dmi_table(paddr_t base, u32 len, int num, - void (*decode)(struct dmi_header *)) + void (*decode)(const struct dmi_header *)) { - u8 *buf; - struct dmi_header *dm; - u8 *data; + const uint8_t *buf, *data; + const struct dmi_header *dm; int i=0; buf = bt_ioremap(base, len); @@ -301,7 +321,7 @@ typedef union { static int __init _dmi_iterate(const struct dmi_eps *dmi, const smbios_eps_u smbios, - void (*decode)(struct dmi_header *)) + void (*decode)(const struct dmi_header *)) { int num; u32 len; @@ -335,7 +355,7 @@ static int __init _dmi_iterate(const str return dmi_table(base, len, num, decode); } -static int __init dmi_iterate(void (*decode)(struct dmi_header *)) +static int __init dmi_iterate(void (*decode)(const struct dmi_header *)) { struct dmi_eps dmi; struct smbios3_eps smbios3; @@ -370,7 +390,7 @@ static int __init dmi_iterate(void (*dec return -1; } -static int __init dmi_efi_iterate(void (*decode)(struct dmi_header *)) +static int __init dmi_efi_iterate(void (*decode)(const struct dmi_header *)) { int ret = -1; @@ -433,10 +453,11 @@ static char *__initdata dmi_ident[DMI_ST * Save a DMI string */ -static void __init dmi_save_ident(struct dmi_header *dm, int slot, int string) +static void __init dmi_save_ident(const struct dmi_header *dm, int slot, int string) { - char *d = (char*)dm; - char *p = dmi_string(dm, d[string]); + const char *d = (const void *)dm; + const char *p = dmi_string(dm, d[string]); + if(p==NULL || *p == 0) return; if (dmi_ident[slot]) @@ -629,10 +650,10 @@ static const struct dmi_blacklist __init * out of here. */ -static void __init dmi_decode(struct dmi_header *dm) +static void __init dmi_decode(const struct dmi_header *dm) { #ifdef DMI_DEBUG - u8 *data = (u8 *)dm; + const uint8_t *data = (const void *)dm; #endif switch(dm->type) From patchwork Mon Nov 23 12:41:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 11925141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96383C2D0E4 for ; Mon, 23 Nov 2020 12:41:21 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2C04120732 for ; Mon, 23 Nov 2020 12:41:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="ZJ4yp331" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C04120732 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.34190.65048 (Exim 4.92) (envelope-from ) id 1khB9a-0002YF-ME; Mon, 23 Nov 2020 12:41:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 34190.65048; Mon, 23 Nov 2020 12:41:10 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khB9a-0002Y8-J0; Mon, 23 Nov 2020 12:41:10 +0000 Received: by outflank-mailman (input) for mailman id 34190; Mon, 23 Nov 2020 12:41:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khB9Y-0002Xw-KH for xen-devel@lists.xenproject.org; Mon, 23 Nov 2020 12:41:08 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 05c52c33-af8b-431e-a2d7-2b1f5c93c1a3; Mon, 23 Nov 2020 12:41:07 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 203E0AC60; Mon, 23 Nov 2020 12:41:07 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1khB9Y-0002Xw-KH for xen-devel@lists.xenproject.org; Mon, 23 Nov 2020 12:41:08 +0000 X-Inumbo-ID: 05c52c33-af8b-431e-a2d7-2b1f5c93c1a3 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 05c52c33-af8b-431e-a2d7-2b1f5c93c1a3; Mon, 23 Nov 2020 12:41:07 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1606135267; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YhDy7Mg6pP0gtjGsaM0dFyUyU3hPq8Z+OxGSvcjCo4c=; b=ZJ4yp331J2ZsZW67BKFgAMSZCYQmldzGDUPUwJNFQiG9m9CTVIopKsCXxW+gvRPuggRnqS gxZzLKL4OEDmEmRW/v0FJcsV1M5Jo/raux4VaJUCI12TKjuRX0ZlrKCp/ZPvyTn53DUryk iM8pnPZEtfWu5FVvoq77kiOzvKyilpE= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 203E0AC60; Mon, 23 Nov 2020 12:41:07 +0000 (UTC) Subject: [PATCH 4/4] x86/ACPI: don't invalidate S5 data when S3 wakeup vector cannot be determined From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Julien Grall References: <7f895b0e-f46f-8fe2-b0ac-e0503ef06a1f@suse.com> Message-ID: Date: Mon, 23 Nov 2020 13:41:06 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <7f895b0e-f46f-8fe2-b0ac-e0503ef06a1f@suse.com> Content-Language: en-US We can be more tolerant as long as the data collected from FACS is only needed to enter S3. A prior change already added suitable checking to acpi_enter_sleep(). Signed-off-by: Jan Beulich Acked-by: Roger Pau Monné --- a/xen/arch/x86/acpi/boot.c +++ b/xen/arch/x86/acpi/boot.c @@ -420,22 +420,22 @@ acpi_fadt_parse_sleep_info(struct acpi_t facs_pa = (uint64_t)fadt->facs; } if (!facs_pa) - goto bad; + return; facs = acpi_os_map_memory(facs_pa, sizeof(*facs)); if (!facs) - goto bad; + return; if (strncmp(facs->signature, "FACS", 4)) { printk(KERN_ERR PREFIX "Invalid FACS signature %.4s\n", facs->signature); - goto bad; + goto done; } if (facs->length < 24) { printk(KERN_ERR PREFIX "Invalid FACS table length: %#x", facs->length); - goto bad; + goto done; } if (facs->length < 64) @@ -452,6 +452,7 @@ acpi_fadt_parse_sleep_info(struct acpi_t offsetof(struct acpi_table_facs, firmware_waking_vector); acpi_sinfo.vector_width = 32; + done: acpi_os_unmap_memory(facs, sizeof(*facs)); printk(KERN_INFO PREFIX