From patchwork Tue Nov 17 06:50:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Hung X-Patchwork-Id: 1401397 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) 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-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CZxRH0kr0z9sPB for ; Tue, 17 Nov 2020 17:50:49 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1keup7-0000cR-Ho; Tue, 17 Nov 2020 06:50:41 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1keup6-0000bv-8K for fwts-devel@lists.ubuntu.com; Tue, 17 Nov 2020 06:50:40 +0000 Received: from 2.general.alexhung.us.vpn ([10.172.65.255] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1keup5-0006qR-Ns; Tue, 17 Nov 2020 06:50:40 +0000 From: Alex Hung To: fwts-devel@lists.ubuntu.com Subject: [PATCH] mtrr: add tests for enable bits in MTRR_DEF_TYPE MSR Date: Mon, 16 Nov 2020 23:50:36 -0700 Message-Id: <20201117065036.519662-1-alex.hung@canonical.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" Signed-off-by: Alex Hung --- src/bios/mtrr/mtrr.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/bios/mtrr/mtrr.c b/src/bios/mtrr/mtrr.c index c9b77941..ca1dbc2c 100644 --- a/src/bios/mtrr/mtrr.c +++ b/src/bios/mtrr/mtrr.c @@ -594,6 +594,35 @@ static int mtrr_deinit(fwts_framework *fw) return FWTS_OK; } +static int mtrr_test0(fwts_framework *fw) +{ + uint64_t mtrr_def_msr; + if (fwts_cpu_readmsr(fw, 0, MTRR_DEF_TYPE_MSR, &mtrr_def_msr) != FWTS_OK) { + fwts_failed(fw, LOG_LEVEL_CRITICAL, + "MTRRMSRDefaultNotAvailable", + "MTRR_DEF_TYPE_MSR cannot be read from CPU."); + return FWTS_OK; + } + + if (mtrr_def_msr & 0x800) + fwts_passed(fw, "MTRRs enabled flag is set in MTRR_DEF_TYPE MSR correctly."); + else + fwts_failed(fw, LOG_LEVEL_CRITICAL, + "MTRRDisabled", + "MTRRs enabled flag is clear in MTRR_DEF_TYPE MSR and " + "all MTRRs are disabled "); + + if (mtrr_def_msr & 0x400) + fwts_passed(fw, "fixed MTRRs enabled flag is set in MTRR_DEF_TYPE MSR correctly."); + else + fwts_failed(fw, LOG_LEVEL_CRITICAL, + "MTRRFixedRangeDisabled", + "Fixed MTRRs enabled flag is clear in MTRR_DEF_TYPE MSR and " + "all Fixed-range MTRRs are disabled "); + + return FWTS_OK; +} + static int mtrr_test1(fwts_framework *fw) { return validate_iomem(fw); @@ -658,6 +687,7 @@ static int mtrr_test3(fwts_framework *fw) } static fwts_framework_minor_test mtrr_tests[] = { + { mtrr_test0, "Validate MTRR default enabled." }, { mtrr_test1, "Validate the kernel MTRR IOMEM setup." }, { mtrr_test2, "Validate the MTRR setup across all processors." }, { mtrr_test3, "Test for AMD MtrrFixDramModEn being cleared by the BIOS." },