From patchwork Wed Jun 13 18:55:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 929042 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 415bYh3PKNz9s19; Thu, 14 Jun 2018 04:55:52 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fTAvt-0007RX-Lb; Wed, 13 Jun 2018 18:55:49 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1fTAvs-0007RR-Iw for fwts-devel@lists.ubuntu.com; Wed, 13 Jun 2018 18:55:48 +0000 Received: from 1.general.alexhung.us.vpn ([10.172.65.254] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fTAvr-0005UH-Q4; Wed, 13 Jun 2018 18:55:48 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH] mtrr: fix incorrect type detection Date: Wed, 13 Jun 2018 11:55:23 -0700 Message-Id: <1528916123-30139-1-git-send-email-alex.hung@canonical.com> X-Mailer: git-send-email 2.7.4 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" From: Stan Hung cache_types() in mtrr.c trying to parse the memory range covered by MTRR. If match, the "end" of the range will move to the the start of MTRR. mtrr.c #234 end = entry->start; Ex: Memory 0x0000 ~ 0xFFFF MTRR 0x1000 ~ 0xFFFF WB MTRR 0x0000 ~ 0x0FFF WB In original flow, if we put this memory range into cache_types function. The first round check will update the range to 0x0000 ~ 0x1000 Then it won't hit the 0x0000 ~ 0x0FFF MTRR and set the DEFAULT flag to identify the usage of default MTRR. Signed-off-by: Stan Hung Acked-by: Colin Ian King Acked-by: Alex Hung --- src/bios/mtrr/mtrr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c index 50c8df9d..ecd6204e 100644 --- a/src/bios/mtrr/mtrr.c +++ b/src/bios/mtrr/mtrr.c @@ -231,7 +231,7 @@ restart: entry = fwts_list_data(struct mtrr_entry*, item); if (entry->end >= end && entry->start < end) { - end = entry->start; + end = (entry->start == 0) ? 0 : (entry->start - 1); if (end < start) end = start; else