Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1090011rwi; Thu, 27 Oct 2022 11:01:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5yt30n30ImISPHbG+Qi7wwLwEWw803KW4hQ+Iq4eFL5i/CTUGi3206FobBjEzwEhbd1+W3 X-Received: by 2002:a17:906:8a6c:b0:7a8:2f09:d88d with SMTP id hy12-20020a1709068a6c00b007a82f09d88dmr19809150ejc.49.1666893715813; Thu, 27 Oct 2022 11:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666893715; cv=none; d=google.com; s=arc-20160816; b=oogdIVzbA46i9mWjUQ1C5YdJAHtjYvCkFwzOwLKDX2oedRYRMFp+gDh7RNK264GKQw WmKbNpEngqm60MXPdCaFhoub8ASCWyCmYHc5LxuU+dCf8NKRpcgf/tIQQhqmObwDEjXL F6ucv+ruFdto28xAS8rlztfahoieFk//4zjIKhn+7dk0YAJXFRE/4jcQb9WOjaZ9MJXE nNNrtHpiE66xz6LN6LsYd0TkEkMrQSPp0FPAP0eiIZNQqP/Tdxl97n0O8aMNLs1GbGtI 9CeFPUyraPct8FPq5aOqJkefnKmdPhnMFksHHw8XHEyiIZr5jJs3pIdmetU/v0yluSei Uptg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yaOhC/XkGsSCC4NKTcHE5SV3sjYTBD/FamF80tCvBnY=; b=n8yU+OIpFmH5mr5DL5486i4bzfquTcqnrhpTyT2Lozte+E/qyuxhiRA6zb9KNYeb2O 2HpVvjvMfPiPxvOZoW/298uTCThNZ1xbmgtT0ltXqXOls26gB8BTlGhEpElb3wWJMZJv rOF2dEjOcNljslbu+rOJ9Ay3h+/oIUtcGw0DpA6LJtHGnZ1p/fDTMqxu/XMj5aHWJ5p6 Azl+LxzbUl4+iCcg+m40dLeUgQIIxYTGpIWcHnpkqm1EDSL/Vn3622Ef1Htzk31cH+GF +MjuCm1HZX3KvqSB9jZEyJwyjybCQt3nhMRQyaoHcQtriAqTA5tt60zUmONiGxCi54li 5mYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v9-20020a1709062f0900b0073ce34d1a13si570219eji.499.2022.10.27.11.01.22; Thu, 27 Oct 2022 11:01:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236021AbiJ0SAA (ORCPT + 99 others); Thu, 27 Oct 2022 14:00:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236019AbiJ0R7Z (ORCPT ); Thu, 27 Oct 2022 13:59:25 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7568B17F9BB; Thu, 27 Oct 2022 10:59:16 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.0.0) id fe07034ed0e76a0e; Thu, 27 Oct 2022 19:59:14 +0200 Received: from kreacher.localnet (unknown [213.134.169.45]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 70A4766D83E; Thu, 27 Oct 2022 19:59:13 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Bob Moore Subject: [PATCH 04/11] ACPICA: Do not touch VGA memory when EBDA < 1ki_b Date: Thu, 27 Oct 2022 19:50:59 +0200 Message-ID: <1914944.PYKUYFuaPT@kreacher> In-Reply-To: <4756726.GXAFRqVoOG@kreacher> References: <4756726.GXAFRqVoOG@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.169.45 X-CLIENT-HOSTNAME: 213.134.169.45 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvgedrtdeggdduudejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepledtieekkeekveeikeetgffgteeuteefjeevjeegudelvdduheeiuedvieehieevnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucfkphepvddufedrudefgedrudeiledrgeehnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepvddufedrudefgedrudeiledrgeehpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeefpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhosggvrhhtrdhmohhorhgvsehinhhtvghlrdgtohhm X-DCC--Metrics: v370.home.net.pl 1024; Body=3 Fuz1=3 Fuz2=3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vit Kabele ACPICA commit a36eda9631e84f271319c41288889dd5b1329369 The ACPICA code assumes that EBDA region must be at least 1ki_b in size. Because this is not guaranteed, it might happen that while scanning the memory for RSDP pointer, the kernel touches memory above 640ki_b. This is unwanted as the VGA memory range may not be decoded or even present when running under virtualization. Link: https://github.com/acpica/acpica/commit/a36eda96 Signed-off-by: Vit Kabele Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpica/tbxfroot.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) Index: linux-pm/drivers/acpi/acpica/tbxfroot.c =================================================================== --- linux-pm.orig/drivers/acpi/acpica/tbxfroot.c +++ linux-pm/drivers/acpi/acpica/tbxfroot.c @@ -114,6 +114,7 @@ acpi_find_root_pointer(acpi_physical_add u8 *table_ptr; u8 *mem_rover; u32 physical_address; + u32 ebda_window_size; ACPI_FUNCTION_TRACE(acpi_find_root_pointer); @@ -145,24 +146,31 @@ acpi_find_root_pointer(acpi_physical_add */ if (physical_address > 0x400 && physical_address < 0xA0000) { /* - * 1b) Search EBDA paragraphs (EBDA is required to be a - * minimum of 1K length) + * Calculate the scan window size + * The EBDA is not guaranteed to be larger than a ki_b and in case + * that it is smaller, the scanning function would leave the low + * memory and continue to the VGA range. + */ + ebda_window_size = ACPI_MIN(ACPI_EBDA_WINDOW_SIZE, + 0xA0000 - physical_address); + + /* + * 1b) Search EBDA paragraphs */ table_ptr = acpi_os_map_memory((acpi_physical_address) physical_address, - ACPI_EBDA_WINDOW_SIZE); + ebda_window_size); if (!table_ptr) { ACPI_ERROR((AE_INFO, "Could not map memory at 0x%8.8X for length %u", - physical_address, ACPI_EBDA_WINDOW_SIZE)); + physical_address, ebda_window_size)); return_ACPI_STATUS(AE_NO_MEMORY); } mem_rover = - acpi_tb_scan_memory_for_rsdp(table_ptr, - ACPI_EBDA_WINDOW_SIZE); - acpi_os_unmap_memory(table_ptr, ACPI_EBDA_WINDOW_SIZE); + acpi_tb_scan_memory_for_rsdp(table_ptr, ebda_window_size); + acpi_os_unmap_memory(table_ptr, ebda_window_size); if (mem_rover) {